pcm-agents 0.6.11 → 0.6.13

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 (292) hide show
  1. package/dist/cjs/error-event-J_ZWIqWF.js +33 -0
  2. package/dist/cjs/error-event-J_ZWIqWF.js.map +1 -0
  3. package/dist/cjs/{index-CvEfNyEj.js → index-CRlt8Nv6.js} +53 -3
  4. package/dist/cjs/index-CRlt8Nv6.js.map +1 -0
  5. package/dist/cjs/index-WNdOTXnX.js +11068 -0
  6. package/dist/cjs/index-WNdOTXnX.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +2 -2
  8. package/dist/cjs/loader.cjs.js +3 -5
  9. package/dist/cjs/loader.cjs.js.map +1 -1
  10. package/dist/cjs/message.service-DGUsA-FY.js +135 -0
  11. package/dist/cjs/message.service-DGUsA-FY.js.map +1 -0
  12. package/dist/cjs/{pcm-1zhanshi-mnms-modal_17.cjs.entry.js → pcm-1zhanshi-mnms-modal_21.cjs.entry.js} +3276 -216
  13. package/dist/cjs/pcm-1zhanshi-mnms-modal_21.cjs.entry.js.map +1 -0
  14. package/dist/cjs/pcm-agents.cjs.js +4 -6
  15. package/dist/cjs/pcm-agents.cjs.js.map +1 -1
  16. package/dist/cjs/pcm-message.cjs.entry.js +3 -3
  17. package/dist/cjs/pcm-message.cjs.entry.js.map +1 -1
  18. package/dist/cjs/pcm-message.entry.cjs.js.map +1 -1
  19. package/dist/cjs/pcm-mnms-video-modal.cjs.entry.js +8 -8
  20. package/dist/cjs/pcm-mnms-video-modal.cjs.entry.js.map +1 -1
  21. package/dist/cjs/pcm-mnms-video-modal.entry.cjs.js.map +1 -1
  22. package/dist/cjs/pcm-mnms-zp-modal.cjs.entry.js +29 -86
  23. package/dist/cjs/pcm-mnms-zp-modal.cjs.entry.js.map +1 -1
  24. package/dist/cjs/pcm-mnms-zp-modal.entry.cjs.js.map +1 -1
  25. package/dist/cjs/{sentry-reporter-BWFtw_aT.js → sentry-reporter-tpI4WdkE.js} +12 -40
  26. package/dist/cjs/sentry-reporter-tpI4WdkE.js.map +1 -0
  27. package/dist/collection/collection-manifest.json +5 -1
  28. package/dist/collection/components/pcm-1zhanshi-mnms-modal/pcm-1zhanshi-mnms-modal.js.map +1 -1
  29. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.css +986 -986
  30. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js +7 -9
  31. package/dist/collection/components/pcm-app-chat-modal/pcm-app-chat-modal.js.map +1 -1
  32. package/dist/collection/components/pcm-button/pcm-button.css +199 -199
  33. package/dist/collection/components/pcm-button/pcm-button.js +6 -6
  34. package/dist/collection/components/pcm-button/pcm-button.js.map +1 -1
  35. package/dist/collection/components/pcm-card/pcm-card.css +259 -259
  36. package/dist/collection/components/pcm-card/pcm-card.js +1 -1
  37. package/dist/collection/components/pcm-card/pcm-card.js.map +1 -1
  38. package/dist/collection/components/pcm-chat-message/pcm-chat-message.css +554 -554
  39. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js +3 -3
  40. package/dist/collection/components/pcm-chat-message/pcm-chat-message.js.map +1 -1
  41. package/dist/collection/components/pcm-drawer/pcm-drawer.css +102 -102
  42. package/dist/collection/components/pcm-drawer/pcm-drawer.js +1 -1
  43. package/dist/collection/components/pcm-drawer/pcm-drawer.js.map +1 -1
  44. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.css +854 -854
  45. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js +5 -7
  46. package/dist/collection/components/pcm-hr-chat-modal/pcm-hr-chat-modal.js.map +1 -1
  47. package/dist/collection/components/pcm-htws-modal/pcm-htws-modal.css +95 -95
  48. package/dist/collection/components/pcm-htws-modal/pcm-htws-modal.js +1 -1
  49. package/dist/collection/components/pcm-htws-modal/pcm-htws-modal.js.map +1 -1
  50. package/dist/collection/components/pcm-hyzj-modal/pcm-hyzj-modal.js +2 -2
  51. package/dist/collection/components/pcm-hyzj-modal/pcm-hyzj-modal.js.map +1 -1
  52. package/dist/collection/components/pcm-jd-modal/pcm-jd-modal.css +312 -312
  53. package/dist/collection/components/pcm-jd-modal/pcm-jd-modal.js +1 -1
  54. package/dist/collection/components/pcm-jd-modal/pcm-jd-modal.js.map +1 -1
  55. package/dist/collection/components/pcm-jlpp-modal/pcm-jlpp-modal.js +2 -2
  56. package/dist/collection/components/pcm-jlpp-modal/pcm-jlpp-modal.js.map +1 -1
  57. package/dist/collection/components/pcm-message/pcm-message.css +64 -64
  58. package/dist/collection/components/pcm-message/pcm-message.js +2 -2
  59. package/dist/collection/components/pcm-message/pcm-message.js.map +1 -1
  60. package/dist/collection/components/pcm-mnct-modal/pcm-mnct-modal.css +1 -1
  61. package/dist/collection/components/pcm-mnct-modal/pcm-mnct-modal.js +2 -2
  62. package/dist/collection/components/pcm-mnct-modal/pcm-mnct-modal.js.map +1 -1
  63. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js +67 -84
  64. package/dist/collection/components/pcm-mnms-modal/pcm-mnms-modal.js.map +1 -1
  65. package/dist/collection/components/pcm-mnms-video-modal/pcm-mnms-video-modal.js +2 -2
  66. package/dist/collection/components/pcm-mnms-video-modal/pcm-mnms-video-modal.js.map +1 -1
  67. package/dist/collection/components/pcm-mnms-zp-modal/pcm-mnms-zp-modal.js +67 -84
  68. package/dist/collection/components/pcm-mnms-zp-modal/pcm-mnms-zp-modal.js.map +1 -1
  69. package/dist/collection/components/pcm-mobile-input-btn/pcm-mobile-input-btn.css +140 -0
  70. package/dist/collection/components/pcm-mobile-input-btn/pcm-mobile-input-btn.js +307 -0
  71. package/dist/collection/components/pcm-mobile-input-btn/pcm-mobile-input-btn.js.map +1 -0
  72. package/dist/collection/components/pcm-mobile-input-btn/uploadNumberSDK.js +25 -0
  73. package/dist/collection/components/pcm-mobile-input-btn/uploadNumberSDK.js.map +1 -0
  74. package/dist/collection/components/pcm-mobile-upload-btn/pcm-mobile-upload-btn.css +127 -0
  75. package/dist/collection/components/pcm-mobile-upload-btn/pcm-mobile-upload-btn.js +350 -0
  76. package/dist/collection/components/pcm-mobile-upload-btn/pcm-mobile-upload-btn.js.map +1 -0
  77. package/dist/collection/components/pcm-mobile-upload-btn/uploadNumberSDK.js +25 -0
  78. package/dist/collection/components/pcm-mobile-upload-btn/uploadNumberSDK.js.map +1 -0
  79. package/dist/collection/components/pcm-msbg-modal/pcm-msbg-modal.js +2 -2
  80. package/dist/collection/components/pcm-msbg-modal/pcm-msbg-modal.js.map +1 -1
  81. package/dist/collection/components/pcm-qgqjl-modal/pcm-qgqjl-modal.css +1 -1
  82. package/dist/collection/components/pcm-qgqjl-modal/pcm-qgqjl-modal.js +2 -2
  83. package/dist/collection/components/pcm-qgqjl-modal/pcm-qgqjl-modal.js.map +1 -1
  84. package/dist/collection/components/pcm-time-count-down/pcm-time-count-down.css +0 -0
  85. package/dist/collection/components/pcm-time-count-down/pcm-time-count-down.js +106 -0
  86. package/dist/collection/components/pcm-time-count-down/pcm-time-count-down.js.map +1 -0
  87. package/dist/collection/components/pcm-upload/pcm-upload.css +0 -0
  88. package/dist/collection/components/pcm-upload/pcm-upload.js +408 -0
  89. package/dist/collection/components/pcm-upload/pcm-upload.js.map +1 -0
  90. package/dist/collection/components/pcm-zsk-chat-modal/pcm-zsk-chat-modal.css +969 -969
  91. package/dist/collection/components/pcm-zsk-chat-modal/pcm-zsk-chat-modal.js +3 -5
  92. package/dist/collection/components/pcm-zsk-chat-modal/pcm-zsk-chat-modal.js.map +1 -1
  93. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.css +68 -68
  94. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js +4 -4
  95. package/dist/collection/components/pcm-zygh-modal/pcm-zygh-modal.js.map +1 -1
  96. package/dist/collection/global/global.css +401 -398
  97. package/dist/collection/global/markdown.css +1233 -1233
  98. package/dist/collection/global/message.js.map +1 -1
  99. package/dist/collection/index.js.map +1 -1
  100. package/dist/collection/interfaces/chat.js.map +1 -1
  101. package/dist/collection/interfaces/events.js.map +1 -1
  102. package/dist/collection/services/message.service.js.map +1 -1
  103. package/dist/collection/utils/env.js +3 -0
  104. package/dist/collection/utils/env.js.map +1 -1
  105. package/dist/collection/utils/error-event.js.map +1 -1
  106. package/dist/collection/utils/init.js.map +1 -1
  107. package/dist/collection/utils/sentry-reporter.js.map +1 -1
  108. package/dist/collection/utils/utils.js +48 -24
  109. package/dist/collection/utils/utils.js.map +1 -1
  110. package/dist/components/index.js +3 -5482
  111. package/dist/components/index.js.map +1 -1
  112. package/dist/components/{p-AYWZDCn8.js → p-B0WOTw9J.js} +51 -4
  113. package/dist/components/p-B0WOTw9J.js.map +1 -0
  114. package/dist/components/{p-DUQ46MUh.js → p-BGXbWUJg.js} +3 -3
  115. package/dist/components/{p-DUQ46MUh.js.map → p-BGXbWUJg.js.map} +1 -1
  116. package/dist/{esm/sentry-reporter-BFBS363a.js → components/p-BW3r6Lrf.js} +5 -32
  117. package/dist/components/p-BW3r6Lrf.js.map +1 -0
  118. package/dist/{esm/app-globals-Chti62re.js → components/p-BdiUKin5.js} +9619 -4296
  119. package/dist/components/p-BdiUKin5.js.map +1 -0
  120. package/dist/components/{p-FjtoYPVY.js → p-BywzltXy.js} +10 -9
  121. package/dist/components/p-BywzltXy.js.map +1 -0
  122. package/dist/components/p-C2OsjtRx.js +208 -0
  123. package/dist/components/p-C2OsjtRx.js.map +1 -0
  124. package/dist/components/{p-D2Z8casl.js → p-CuIvbaWY.js} +5 -5
  125. package/dist/components/p-CuIvbaWY.js.map +1 -0
  126. package/dist/components/p-D0ZMoyH8.js +251 -0
  127. package/dist/components/p-D0ZMoyH8.js.map +1 -0
  128. package/dist/components/{p-CjbFHLT7.js → p-De3VHEUn.js} +7 -71
  129. package/dist/components/p-De3VHEUn.js.map +1 -0
  130. package/dist/components/p-Dv8qvK0w.js +2646 -0
  131. package/dist/components/p-Dv8qvK0w.js.map +1 -0
  132. package/dist/components/p-RD3mwuBX.js +226 -0
  133. package/dist/components/p-RD3mwuBX.js.map +1 -0
  134. package/dist/components/p-njngFX_n.js +80 -0
  135. package/dist/components/p-njngFX_n.js.map +1 -0
  136. package/dist/components/pcm-1zhanshi-mnms-modal.js +7 -7
  137. package/dist/components/pcm-1zhanshi-mnms-modal.js.map +1 -1
  138. package/dist/components/pcm-app-chat-modal.js +1 -1
  139. package/dist/components/pcm-button.js +2 -2
  140. package/dist/components/pcm-button.js.map +1 -1
  141. package/dist/components/pcm-card.js +3 -3
  142. package/dist/components/pcm-card.js.map +1 -1
  143. package/dist/components/pcm-chat-message.js +1 -1
  144. package/dist/components/pcm-drawer.js +1 -1
  145. package/dist/components/pcm-hr-chat-modal.js +5 -4
  146. package/dist/components/pcm-hr-chat-modal.js.map +1 -1
  147. package/dist/components/pcm-htws-modal.js +8 -7
  148. package/dist/components/pcm-htws-modal.js.map +1 -1
  149. package/dist/components/pcm-hyzj-modal.js +8 -7
  150. package/dist/components/pcm-hyzj-modal.js.map +1 -1
  151. package/dist/components/pcm-jd-modal.js +8 -7
  152. package/dist/components/pcm-jd-modal.js.map +1 -1
  153. package/dist/components/pcm-jlpp-modal.js +8 -7
  154. package/dist/components/pcm-jlpp-modal.js.map +1 -1
  155. package/dist/components/pcm-message.js +3 -3
  156. package/dist/components/pcm-message.js.map +1 -1
  157. package/dist/components/pcm-mnct-modal.js +8 -7
  158. package/dist/components/pcm-mnct-modal.js.map +1 -1
  159. package/dist/components/pcm-mnms-modal.js +60 -90
  160. package/dist/components/pcm-mnms-modal.js.map +1 -1
  161. package/dist/components/pcm-mnms-video-modal.js +8 -7
  162. package/dist/components/pcm-mnms-video-modal.js.map +1 -1
  163. package/dist/components/pcm-mnms-zp-modal.js +60 -90
  164. package/dist/components/pcm-mnms-zp-modal.js.map +1 -1
  165. package/dist/components/pcm-mobile-input-btn.d.ts +11 -0
  166. package/dist/components/pcm-mobile-input-btn.js +9 -0
  167. package/dist/components/pcm-mobile-input-btn.js.map +1 -0
  168. package/dist/components/pcm-mobile-upload-btn.d.ts +11 -0
  169. package/dist/components/pcm-mobile-upload-btn.js +9 -0
  170. package/dist/components/pcm-mobile-upload-btn.js.map +1 -0
  171. package/dist/components/pcm-msbg-modal.js +8 -7
  172. package/dist/components/pcm-msbg-modal.js.map +1 -1
  173. package/dist/components/pcm-qgqjl-modal.js +8 -7
  174. package/dist/components/pcm-qgqjl-modal.js.map +1 -1
  175. package/dist/components/pcm-time-count-down.d.ts +11 -0
  176. package/dist/components/pcm-time-count-down.js +9 -0
  177. package/dist/components/pcm-time-count-down.js.map +1 -0
  178. package/dist/components/pcm-upload.d.ts +11 -0
  179. package/dist/components/pcm-upload.js +9 -0
  180. package/dist/components/pcm-upload.js.map +1 -0
  181. package/dist/components/pcm-zsk-chat-modal.js +4 -4
  182. package/dist/components/pcm-zsk-chat-modal.js.map +1 -1
  183. package/dist/components/pcm-zygh-modal.js +8 -7
  184. package/dist/components/pcm-zygh-modal.js.map +1 -1
  185. package/dist/esm/error-event-C0FYX2-Z.js +31 -0
  186. package/dist/esm/error-event-C0FYX2-Z.js.map +1 -0
  187. package/dist/esm/{index-GyOE8SlD.js → index-BnNqOUZf.js} +51 -4
  188. package/dist/esm/index-BnNqOUZf.js.map +1 -0
  189. package/dist/esm/index-BuVfV0zo.js +11035 -0
  190. package/dist/esm/index-BuVfV0zo.js.map +1 -0
  191. package/dist/esm/index.js +2 -2
  192. package/dist/esm/loader.js +3 -5
  193. package/dist/esm/loader.js.map +1 -1
  194. package/dist/esm/message.service-DXVhHj6-.js +133 -0
  195. package/dist/esm/message.service-DXVhHj6-.js.map +1 -0
  196. package/dist/esm/{pcm-1zhanshi-mnms-modal_17.entry.js → pcm-1zhanshi-mnms-modal_21.entry.js} +3225 -169
  197. package/dist/esm/pcm-1zhanshi-mnms-modal_21.entry.js.map +1 -0
  198. package/dist/esm/pcm-agents.js +4 -6
  199. package/dist/esm/pcm-agents.js.map +1 -1
  200. package/dist/esm/pcm-message.entry.js +3 -3
  201. package/dist/esm/pcm-message.entry.js.map +1 -1
  202. package/dist/esm/pcm-mnms-video-modal.entry.js +5 -5
  203. package/dist/esm/pcm-mnms-video-modal.entry.js.map +1 -1
  204. package/dist/esm/pcm-mnms-zp-modal.entry.js +28 -85
  205. package/dist/esm/pcm-mnms-zp-modal.entry.js.map +1 -1
  206. package/dist/esm/sentry-reporter-CYzy4_8O.js +70 -0
  207. package/dist/esm/sentry-reporter-CYzy4_8O.js.map +1 -0
  208. package/dist/pcm-agents/index.esm.js +1 -1
  209. package/dist/pcm-agents/loader.esm.js.map +1 -1
  210. package/dist/pcm-agents/p-18a06873.entry.js +2 -0
  211. package/dist/pcm-agents/p-18a06873.entry.js.map +1 -0
  212. package/dist/pcm-agents/p-47e2e1d0.entry.js +2 -0
  213. package/dist/pcm-agents/p-47e2e1d0.entry.js.map +1 -0
  214. package/dist/pcm-agents/{p-3608c0c6.entry.js → p-7a582f00.entry.js} +2 -2
  215. package/dist/pcm-agents/p-7a582f00.entry.js.map +1 -0
  216. package/dist/pcm-agents/p-BhFnI70g.js +2 -0
  217. package/dist/pcm-agents/p-BhFnI70g.js.map +1 -0
  218. package/dist/pcm-agents/p-BuVfV0zo.js +3 -0
  219. package/dist/pcm-agents/p-BuVfV0zo.js.map +1 -0
  220. package/dist/pcm-agents/p-C0FYX2-Z.js +2 -0
  221. package/dist/pcm-agents/p-C0FYX2-Z.js.map +1 -0
  222. package/dist/pcm-agents/p-DXVhHj6-.js +2 -0
  223. package/dist/pcm-agents/p-DXVhHj6-.js.map +1 -0
  224. package/dist/pcm-agents/p-DkeaAFic.js +2 -0
  225. package/dist/pcm-agents/p-DkeaAFic.js.map +1 -0
  226. package/dist/pcm-agents/p-f5f96853.entry.js +245 -0
  227. package/dist/pcm-agents/p-f5f96853.entry.js.map +1 -0
  228. package/dist/pcm-agents/pcm-agents.esm.js +1 -1
  229. package/dist/pcm-agents/pcm-agents.esm.js.map +1 -1
  230. package/dist/pcm-agents/pcm-message.entry.esm.js.map +1 -1
  231. package/dist/pcm-agents/pcm-mnms-video-modal.entry.esm.js.map +1 -1
  232. package/dist/pcm-agents/pcm-mnms-zp-modal.entry.esm.js.map +1 -1
  233. package/dist/store/auth.store.js.map +1 -1
  234. package/dist/store/config.store.js.map +1 -1
  235. package/dist/types/components/pcm-mnms-modal/pcm-mnms-modal.d.ts +9 -4
  236. package/dist/types/components/pcm-mnms-zp-modal/pcm-mnms-zp-modal.d.ts +9 -4
  237. package/dist/types/components/pcm-mobile-input-btn/pcm-mobile-input-btn.d.ts +36 -0
  238. package/dist/types/components/pcm-mobile-input-btn/uploadNumberSDK.d.ts +9 -0
  239. package/dist/types/components/pcm-mobile-upload-btn/pcm-mobile-upload-btn.d.ts +44 -0
  240. package/dist/types/components/pcm-mobile-upload-btn/uploadNumberSDK.d.ts +9 -0
  241. package/dist/types/components/pcm-time-count-down/pcm-time-count-down.d.ts +15 -0
  242. package/dist/types/components/pcm-upload/pcm-upload.d.ts +54 -0
  243. package/dist/types/components/pcm-upload/type.d.ts +4 -0
  244. package/dist/types/components.d.ts +798 -30
  245. package/dist/types/stencil-public-runtime.d.ts +1 -1
  246. package/dist/types/utils/env.d.ts +2 -0
  247. package/dist/types/utils/utils.d.ts +30 -12
  248. package/package.json +70 -69
  249. package/dist/cjs/app-globals-BIO4q6tX.js +0 -5487
  250. package/dist/cjs/app-globals-BIO4q6tX.js.map +0 -1
  251. package/dist/cjs/exports-Dc-pQh4A.js +0 -4087
  252. package/dist/cjs/exports-Dc-pQh4A.js.map +0 -1
  253. package/dist/cjs/index-C_qhED9Z.js +0 -1538
  254. package/dist/cjs/index-C_qhED9Z.js.map +0 -1
  255. package/dist/cjs/index-CvEfNyEj.js.map +0 -1
  256. package/dist/cjs/pcm-1zhanshi-mnms-modal_17.cjs.entry.js.map +0 -1
  257. package/dist/cjs/sentry-reporter-BWFtw_aT.js.map +0 -1
  258. package/dist/components/p-75J0r72D.js +0 -4017
  259. package/dist/components/p-75J0r72D.js.map +0 -1
  260. package/dist/components/p-AYWZDCn8.js.map +0 -1
  261. package/dist/components/p-CR7WLzmM.js +0 -1303
  262. package/dist/components/p-CR7WLzmM.js.map +0 -1
  263. package/dist/components/p-CjbFHLT7.js.map +0 -1
  264. package/dist/components/p-D2Z8casl.js.map +0 -1
  265. package/dist/components/p-FjtoYPVY.js.map +0 -1
  266. package/dist/esm/app-globals-Chti62re.js.map +0 -1
  267. package/dist/esm/exports-Bs-zO1WZ.js +0 -4017
  268. package/dist/esm/exports-Bs-zO1WZ.js.map +0 -1
  269. package/dist/esm/index-Bq0K-WqZ.js +0 -1528
  270. package/dist/esm/index-Bq0K-WqZ.js.map +0 -1
  271. package/dist/esm/index-GyOE8SlD.js.map +0 -1
  272. package/dist/esm/pcm-1zhanshi-mnms-modal_17.entry.js.map +0 -1
  273. package/dist/esm/sentry-reporter-BFBS363a.js.map +0 -1
  274. package/dist/pcm-agents/p-2Gpw8rvH.js +0 -2
  275. package/dist/pcm-agents/p-2Gpw8rvH.js.map +0 -1
  276. package/dist/pcm-agents/p-3608c0c6.entry.js.map +0 -1
  277. package/dist/pcm-agents/p-60d7a0b0.entry.js +0 -2
  278. package/dist/pcm-agents/p-60d7a0b0.entry.js.map +0 -1
  279. package/dist/pcm-agents/p-9e6efc2d.entry.js +0 -2
  280. package/dist/pcm-agents/p-9e6efc2d.entry.js.map +0 -1
  281. package/dist/pcm-agents/p-BUV0S8Cc.js +0 -2
  282. package/dist/pcm-agents/p-BUV0S8Cc.js.map +0 -1
  283. package/dist/pcm-agents/p-Bq0K-WqZ.js +0 -3
  284. package/dist/pcm-agents/p-Bq0K-WqZ.js.map +0 -1
  285. package/dist/pcm-agents/p-Bs-zO1WZ.js +0 -2
  286. package/dist/pcm-agents/p-Bs-zO1WZ.js.map +0 -1
  287. package/dist/pcm-agents/p-CeRTfvY9.js +0 -2
  288. package/dist/pcm-agents/p-CeRTfvY9.js.map +0 -1
  289. package/dist/pcm-agents/p-e6c87a78.entry.js +0 -2
  290. package/dist/pcm-agents/p-e6c87a78.entry.js.map +0 -1
  291. /package/dist/types/{code/agents-sdk → Users/debugksir/Documents/pcm/sdk}/packages/pcm-agents/.stencil/store/auth.store.d.ts +0 -0
  292. /package/dist/types/{code/agents-sdk → Users/debugksir/Documents/pcm/sdk}/packages/pcm-agents/.stencil/store/config.store.d.ts +0 -0
@@ -0,0 +1,2646 @@
1
+ class MessageService {
2
+ _container = null;
3
+ _instances = new Map();
4
+ _maxCount = 2; // 最大同时显示数量
5
+ _idCounter = 0;
6
+ getContainer() {
7
+ if (!this._container) {
8
+ this._container = document.createElement('div');
9
+ this._container.className = 'pcm-message-container';
10
+ document.body.appendChild(this._container);
11
+ }
12
+ return this._container;
13
+ }
14
+ generateId() {
15
+ return `pcm-message-${++this._idCounter}`;
16
+ }
17
+ getMessageKey(options) {
18
+ // 如果提供了key,使用key;否则使用content+type作为key
19
+ return options.key || `${options.content}-${options.type}`;
20
+ }
21
+ removeOldestMessage() {
22
+ if (this._instances.size >= this._maxCount) {
23
+ const firstKey = this._instances.keys().next().value;
24
+ if (firstKey) {
25
+ this.removeMessage(firstKey);
26
+ }
27
+ }
28
+ }
29
+ removeMessage(key) {
30
+ const instance = this._instances.get(key);
31
+ if (instance) {
32
+ // 清除定时器
33
+ if (instance.timer) {
34
+ clearTimeout(instance.timer);
35
+ }
36
+ // 移除DOM元素
37
+ if (instance.element && instance.element.parentNode) {
38
+ instance.element.parentNode.removeChild(instance.element);
39
+ }
40
+ // 从实例映射中移除
41
+ this._instances.delete(key);
42
+ }
43
+ }
44
+ create(options) {
45
+ const messageKey = this.getMessageKey(options);
46
+ // 如果相同key的消息已存在,先移除
47
+ if (this._instances.has(messageKey)) {
48
+ this.removeMessage(messageKey);
49
+ }
50
+ // 检查数量限制
51
+ this.removeOldestMessage();
52
+ const messageElement = document.createElement('pcm-message');
53
+ messageElement.setAttribute('content', options.content);
54
+ if (options.type) {
55
+ messageElement.setAttribute('type', options.type);
56
+ }
57
+ if (options.duration !== undefined) {
58
+ messageElement.setAttribute('duration', options.duration.toString());
59
+ }
60
+ const container = this.getContainer();
61
+ container.appendChild(messageElement);
62
+ // 创建实例记录
63
+ const id = this.generateId();
64
+ const instance = {
65
+ id,
66
+ element: messageElement,
67
+ options: { ...options }
68
+ };
69
+ // 设置自动移除定时器
70
+ const duration = options.duration ?? 3000;
71
+ if (duration > 0) {
72
+ instance.timer = window.setTimeout(() => {
73
+ this.removeMessage(messageKey);
74
+ }, duration);
75
+ }
76
+ // 保存实例
77
+ this._instances.set(messageKey, instance);
78
+ return messageElement;
79
+ }
80
+ success(content, duration) {
81
+ const options = typeof content === 'string'
82
+ ? { content, type: 'success', duration }
83
+ : { ...content, type: 'success' };
84
+ this.create(options);
85
+ }
86
+ error(content, duration) {
87
+ const options = typeof content === 'string'
88
+ ? { content, type: 'error', duration }
89
+ : { ...content, type: 'error' };
90
+ this.create(options);
91
+ }
92
+ info(content, duration) {
93
+ const options = typeof content === 'string'
94
+ ? { content, type: 'info', duration }
95
+ : { ...content, type: 'info' };
96
+ this.create(options);
97
+ }
98
+ warning(content, duration) {
99
+ const options = typeof content === 'string'
100
+ ? { content, type: 'warning', duration }
101
+ : { ...content, type: 'warning' };
102
+ this.create(options);
103
+ }
104
+ // 清除所有消息
105
+ clear() {
106
+ this._instances.forEach((_, key) => {
107
+ this.removeMessage(key);
108
+ });
109
+ }
110
+ // 清除指定key的消息
111
+ remove(key) {
112
+ this.removeMessage(key);
113
+ }
114
+ // 设置最大显示数量
115
+ setMaxCount(count) {
116
+ this._maxCount = Math.max(1, count);
117
+ }
118
+ // 销毁服务(清理资源)
119
+ destroy() {
120
+ this.clear();
121
+ if (this._container && this._container.parentNode) {
122
+ this._container.parentNode.removeChild(this._container);
123
+ this._container = null;
124
+ }
125
+ }
126
+ }
127
+ // 创建单例实例
128
+ const Message = new MessageService();
129
+
130
+ /**
131
+ * @module QRCode
132
+ * @package @nuintun/qrcode
133
+ * @license MIT
134
+ * @version 5.0.2
135
+ * @author nuintun <nuintun@qq.com>
136
+ * @description A pure JavaScript QRCode encode and decode library.
137
+ * @see https://github.com/nuintun/qrcode#readme
138
+ */
139
+
140
+ /**
141
+ * @module Charset
142
+ */
143
+ const VALUES_TO_CHARSET = new Map();
144
+ class Charset {
145
+ #label;
146
+ #values;
147
+ // See: https://en.wikipedia.org/wiki/Extended_Channel_Interpretation
148
+ static CP437 = new Charset('cp437', 2, 0);
149
+ static ISO_8859_1 = new Charset('iso-8859-1', 3, 1);
150
+ static ISO_8859_2 = new Charset('iso-8859-2', 4);
151
+ static ISO_8859_3 = new Charset('iso-8859-3', 5);
152
+ static ISO_8859_4 = new Charset('iso-8859-4', 6);
153
+ static ISO_8859_5 = new Charset('iso-8859-5', 7);
154
+ static ISO_8859_6 = new Charset('iso-8859-6', 8);
155
+ static ISO_8859_7 = new Charset('iso-8859-7', 9);
156
+ static ISO_8859_8 = new Charset('iso-8859-8', 10);
157
+ static ISO_8859_9 = new Charset('iso-8859-9', 11);
158
+ static ISO_8859_10 = new Charset('iso-8859-10', 12);
159
+ static ISO_8859_11 = new Charset('iso-8859-11', 13);
160
+ static ISO_8859_13 = new Charset('iso-8859-13', 15);
161
+ static ISO_8859_14 = new Charset('iso-8859-14', 16);
162
+ static ISO_8859_15 = new Charset('iso-8859-15', 17);
163
+ static ISO_8859_16 = new Charset('iso-8859-16', 18);
164
+ static SHIFT_JIS = new Charset('shift-jis', 20);
165
+ static CP1250 = new Charset('cp1250', 21);
166
+ static CP1251 = new Charset('cp1251', 22);
167
+ static CP1252 = new Charset('cp1252', 23);
168
+ static CP1256 = new Charset('cp1256', 24);
169
+ static UTF_16BE = new Charset('utf-16be', 25);
170
+ static UTF_8 = new Charset('utf-8', 26);
171
+ static ASCII = new Charset('ascii', 27);
172
+ static BIG5 = new Charset('big5', 28);
173
+ static GB2312 = new Charset('gb2312', 29);
174
+ static EUC_KR = new Charset('euc-kr', 30);
175
+ static GBK = new Charset('gbk', 31);
176
+ static GB18030 = new Charset('gb18030', 32);
177
+ static UTF_16LE = new Charset('utf-16le', 33);
178
+ static UTF_32BE = new Charset('utf-32be', 34);
179
+ static UTF_32LE = new Charset('utf-32le', 35);
180
+ static ISO_646_INV = new Charset('iso-646-inv', 170);
181
+ static BINARY = new Charset('binary', 899);
182
+ /**
183
+ * @constructor
184
+ * @param label The label of charset.
185
+ * @param values The values of charset.
186
+ */
187
+ constructor(label, ...values) {
188
+ this.#label = label;
189
+ this.#values = Object.freeze(values);
190
+ for (const value of values) {
191
+ if (value >= 0 && value <= 999999 && Number.isInteger(value)) {
192
+ VALUES_TO_CHARSET.set(value, this);
193
+ } else {
194
+ throw new Error('illegal extended channel interpretation value');
195
+ }
196
+ }
197
+ }
198
+ /**
199
+ * @property label
200
+ * @description Get the label of charset.
201
+ */
202
+ get label() {
203
+ return this.#label;
204
+ }
205
+ /**
206
+ * @property values
207
+ * @description Get the values of charset.
208
+ */
209
+ get values() {
210
+ return this.#values;
211
+ }
212
+ }
213
+
214
+ /**
215
+ * @module QRCode
216
+ * @package @nuintun/qrcode
217
+ * @license MIT
218
+ * @version 5.0.2
219
+ * @author nuintun <nuintun@qq.com>
220
+ * @description A pure JavaScript QRCode encode and decode library.
221
+ * @see https://github.com/nuintun/qrcode#readme
222
+ */
223
+
224
+ /**
225
+ * @module utils
226
+ */
227
+ function toBit(value) {
228
+ return value & 0x01;
229
+ }
230
+ function toInt32(value) {
231
+ return value | 0;
232
+ }
233
+ function getBitMask(value) {
234
+ return 1 << getBitOffset(value);
235
+ }
236
+ function getBitOffset(value) {
237
+ return value & 0x1f;
238
+ }
239
+ // Return the position of the most significant bit set (to one) in the "value". The most
240
+ // significant bit is position 32. If there is no bit set, return 0. Examples:
241
+ // - findMSBSet(0) => 0
242
+ // - findMSBSet(1) => 1
243
+ // - findMSBSet(255) => 8
244
+ function findMSBSet(value) {
245
+ return 32 - Math.clz32(value);
246
+ }
247
+ // Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH
248
+ // code is used for encoding type information and version information.
249
+ // Example: Calculation of version information of 7.
250
+ // f(x) is created from 7.
251
+ // - 7 = 000111 in 6 bits
252
+ // - f(x) = x^2 + x^1 + x^0
253
+ // g(x) is given by the standard (p. 67)
254
+ // - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1
255
+ // Multiply f(x) by x^(18 - 6)
256
+ // - f'(x) = f(x) * x^(18 - 6)
257
+ // - f'(x) = x^14 + x^13 + x^12
258
+ // Calculate the remainder of f'(x) / g(x)
259
+ // x^2
260
+ // __________________________________________________
261
+ // g(x) )x^14 + x^13 + x^12
262
+ // x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2
263
+ // --------------------------------------------------
264
+ // x^11 + x^10 + x^7 + x^4 + x^2
265
+ //
266
+ // The remainder is x^11 + x^10 + x^7 + x^4 + x^2
267
+ // Encode it in binary: 110010010100
268
+ // The return value is 0xc94 (1100 1001 0100)
269
+ //
270
+ // Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit
271
+ // operations. We don't care if coefficients are positive or negative.
272
+ function calculateBCHCode(value, poly) {
273
+ // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1
274
+ // from 13 to make it 12.
275
+ const msbSetInPoly = findMSBSet(poly);
276
+ value <<= msbSetInPoly - 1;
277
+ // Do the division business using exclusive-or operations.
278
+ while (findMSBSet(value) >= msbSetInPoly) {
279
+ value ^= poly << (findMSBSet(value) - msbSetInPoly);
280
+ }
281
+ // Now the "value" is the remainder (i.e. the BCH code).
282
+ return value;
283
+ }
284
+
285
+ /**
286
+ * @module QRCode
287
+ * @package @nuintun/qrcode
288
+ * @license MIT
289
+ * @version 5.0.2
290
+ * @author nuintun <nuintun@qq.com>
291
+ * @description A pure JavaScript QRCode encode and decode library.
292
+ * @see https://github.com/nuintun/qrcode#readme
293
+ */
294
+
295
+ /**
296
+ * @module Mode
297
+ */
298
+ const VALUES_TO_MODE = new Map();
299
+ class Mode {
300
+ #bits;
301
+ #characterCountBitsSet;
302
+ static TERMINATOR = new Mode([0, 0, 0], 0x00);
303
+ static NUMERIC = new Mode([10, 12, 14], 0x01);
304
+ static ALPHANUMERIC = new Mode([9, 11, 13], 0x02);
305
+ static STRUCTURED_APPEND = new Mode([0, 0, 0], 0x03);
306
+ static BYTE = new Mode([8, 16, 16], 0x04);
307
+ static ECI = new Mode([0, 0, 0], 0x07);
308
+ static KANJI = new Mode([8, 10, 12], 0x08);
309
+ static FNC1_FIRST_POSITION = new Mode([0, 0, 0], 0x05);
310
+ static FNC1_SECOND_POSITION = new Mode([0, 0, 0], 0x09);
311
+ static HANZI = new Mode([8, 10, 12], 0x0d);
312
+ constructor(characterCountBitsSet, bits) {
313
+ this.#bits = bits;
314
+ this.#characterCountBitsSet = new Int32Array(characterCountBitsSet);
315
+ VALUES_TO_MODE.set(bits, this);
316
+ }
317
+ get bits() {
318
+ return this.#bits;
319
+ }
320
+ getCharacterCountBits({ version }) {
321
+ let offset;
322
+ if (version <= 9) {
323
+ offset = 0;
324
+ } else if (version <= 26) {
325
+ offset = 1;
326
+ } else {
327
+ offset = 2;
328
+ }
329
+ return this.#characterCountBitsSet[offset];
330
+ }
331
+ }
332
+
333
+ /**
334
+ * @module QRCode
335
+ * @package @nuintun/qrcode
336
+ * @license MIT
337
+ * @version 5.0.2
338
+ * @author nuintun <nuintun@qq.com>
339
+ * @description A pure JavaScript QRCode encode and decode library.
340
+ * @see https://github.com/nuintun/qrcode#readme
341
+ */
342
+
343
+
344
+ /**
345
+ * @module mask
346
+ */
347
+ // Penalty weights.
348
+ const N1 = 3;
349
+ const N2 = 3;
350
+ const N3 = 40;
351
+ const N4 = 10;
352
+ // Is dark point.
353
+ function isDark(matrix, x, y) {
354
+ return matrix.get(x, y) === 1;
355
+ }
356
+ // Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both
357
+ // horizontal and vertical orders respectively.
358
+ function applyMaskPenaltyRule1Internal(matrix, isVertical) {
359
+ let penalty = 0;
360
+ const { size } = matrix;
361
+ for (let y = 0; y < size; y++) {
362
+ let prevBit = -1;
363
+ let numSameBitCells = 0;
364
+ for (let x = 0; x < size; x++) {
365
+ const bit = isVertical ? matrix.get(y, x) : matrix.get(x, y);
366
+ if (bit === prevBit) {
367
+ numSameBitCells++;
368
+ } else {
369
+ if (numSameBitCells >= 5) {
370
+ penalty += N1 + (numSameBitCells - 5);
371
+ }
372
+ // set prev bit.
373
+ prevBit = bit;
374
+ // include the cell itself.
375
+ numSameBitCells = 1;
376
+ }
377
+ }
378
+ if (numSameBitCells >= 5) {
379
+ penalty += N1 + (numSameBitCells - 5);
380
+ }
381
+ }
382
+ return penalty;
383
+ }
384
+ // Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
385
+ // give penalty to them. Example: 00000 or 11111.
386
+ function applyMaskPenaltyRule1(matrix) {
387
+ return applyMaskPenaltyRule1Internal(matrix) + applyMaskPenaltyRule1Internal(matrix, true);
388
+ }
389
+ // Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
390
+ // penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a
391
+ // penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
392
+ function applyMaskPenaltyRule2(matrix) {
393
+ let penalty = 0;
394
+ const size = matrix.size - 1;
395
+ for (let y = 0; y < size; y++) {
396
+ for (let x = 0; x < size; x++) {
397
+ const bit = matrix.get(x, y);
398
+ if (
399
+ // Find 2x2 blocks with the same color.
400
+ bit === matrix.get(x + 1, y) &&
401
+ bit === matrix.get(x, y + 1) &&
402
+ bit === matrix.get(x + 1, y + 1)
403
+ ) {
404
+ penalty += N2;
405
+ }
406
+ }
407
+ }
408
+ return penalty;
409
+ }
410
+ // Is is four white, check on horizontal and vertical.
411
+ function isFourWhite(matrix, offset, from, to, isVertical) {
412
+ if (from < 0 || to > matrix.size) {
413
+ return false;
414
+ }
415
+ for (let i = from; i < to; i++) {
416
+ if (isVertical ? isDark(matrix, offset, i) : isDark(matrix, i, offset)) {
417
+ return false;
418
+ }
419
+ }
420
+ return true;
421
+ }
422
+ // Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
423
+ // starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
424
+ // find patterns like 000010111010000, we give penalty once.
425
+ function applyMaskPenaltyRule3(matrix) {
426
+ let numPenalties = 0;
427
+ const { size } = matrix;
428
+ for (let y = 0; y < size; y++) {
429
+ for (let x = 0; x < size; x++) {
430
+ if (
431
+ // Find consecutive runs of 1:1:3:1:1:4 or 4:1:1:3:1:1, patterns like 000010111010000.
432
+ x + 6 < size &&
433
+ isDark(matrix, x, y) &&
434
+ !isDark(matrix, x + 1, y) &&
435
+ isDark(matrix, x + 2, y) &&
436
+ isDark(matrix, x + 3, y) &&
437
+ isDark(matrix, x + 4, y) &&
438
+ !isDark(matrix, x + 5, y) &&
439
+ isDark(matrix, x + 6, y) &&
440
+ (isFourWhite(matrix, y, x - 4, x) || isFourWhite(matrix, y, x + 7, x + 11))
441
+ ) {
442
+ numPenalties++;
443
+ }
444
+ if (
445
+ // Find consecutive runs of 1:1:3:1:1:4 or 4:1:1:3:1:1, patterns like 000010111010000.
446
+ y + 6 < size &&
447
+ isDark(matrix, x, y) &&
448
+ !isDark(matrix, x, y + 1) &&
449
+ isDark(matrix, x, y + 2) &&
450
+ isDark(matrix, x, y + 3) &&
451
+ isDark(matrix, x, y + 4) &&
452
+ !isDark(matrix, x, y + 5) &&
453
+ isDark(matrix, x, y + 6) &&
454
+ (isFourWhite(matrix, x, y - 4, y, true) || isFourWhite(matrix, x, y + 7, y + 11, true))
455
+ ) {
456
+ numPenalties++;
457
+ }
458
+ }
459
+ }
460
+ return numPenalties * N3;
461
+ }
462
+ // Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
463
+ // penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
464
+ function applyMaskPenaltyRule4(matrix) {
465
+ let numDarkCells = 0;
466
+ const { size } = matrix;
467
+ for (let y = 0; y < size; y++) {
468
+ for (let x = 0; x < size; x++) {
469
+ if (isDark(matrix, x, y)) {
470
+ numDarkCells++;
471
+ }
472
+ }
473
+ }
474
+ const numTotalCells = size * size;
475
+ const fivePercentVariances = toInt32((Math.abs(numDarkCells * 2 - numTotalCells) * 10) / numTotalCells);
476
+ return fivePercentVariances * N4;
477
+ }
478
+ // The mask penalty calculation is complicated. See Table 11 of ISO/IEC 18004:2015(E)(p.54) for details.
479
+ // Basically it applies four rules and summate all penalties.
480
+ function calculateMaskPenalty(matrix) {
481
+ return (
482
+ applyMaskPenaltyRule1(matrix) +
483
+ applyMaskPenaltyRule2(matrix) +
484
+ applyMaskPenaltyRule3(matrix) +
485
+ applyMaskPenaltyRule4(matrix)
486
+ );
487
+ }
488
+ // Return is apply mask at "x" and "y". See 7.8 of ISO/IEC 18004:2015(E)(p.50) for mask pattern conditions.
489
+ function isApplyMask(mask, x, y) {
490
+ let temporary;
491
+ let intermediate;
492
+ switch (mask) {
493
+ case 0:
494
+ intermediate = (y + x) & 0x01;
495
+ break;
496
+ case 1:
497
+ intermediate = y & 0x01;
498
+ break;
499
+ case 2:
500
+ intermediate = x % 3;
501
+ break;
502
+ case 3:
503
+ intermediate = (y + x) % 3;
504
+ break;
505
+ case 4:
506
+ intermediate = (toInt32(y / 2) + toInt32(x / 3)) & 0x01;
507
+ break;
508
+ case 5:
509
+ temporary = y * x;
510
+ intermediate = (temporary & 0x01) + (temporary % 3);
511
+ break;
512
+ case 6:
513
+ temporary = y * x;
514
+ intermediate = ((temporary & 0x01) + (temporary % 3)) & 0x01;
515
+ break;
516
+ case 7:
517
+ intermediate = (((y * x) % 3) + ((y + x) & 0x01)) & 0x01;
518
+ break;
519
+ default:
520
+ throw new Error(`illegal mask: ${mask}`);
521
+ }
522
+ return intermediate === 0;
523
+ }
524
+
525
+ /**
526
+ * @module QRCode
527
+ * @package @nuintun/qrcode
528
+ * @license MIT
529
+ * @version 5.0.2
530
+ * @author nuintun <nuintun@qq.com>
531
+ * @description A pure JavaScript QRCode encode and decode library.
532
+ * @see https://github.com/nuintun/qrcode#readme
533
+ */
534
+
535
+ /**
536
+ * @module ECLevel
537
+ */
538
+ const VALUES_TO_ECLEVEL = new Map();
539
+ class ECLevel {
540
+ #name;
541
+ #bits;
542
+ #level;
543
+ // L = ~7% correction.
544
+ static L = new ECLevel('L', 0, 0x01);
545
+ // L = ~15% correction.
546
+ static M = new ECLevel('M', 1, 0x00);
547
+ // L = ~25% correction.
548
+ static Q = new ECLevel('Q', 2, 0x03);
549
+ // L = ~30% correction.
550
+ static H = new ECLevel('H', 3, 0x02);
551
+ constructor(name, level, bits) {
552
+ this.#bits = bits;
553
+ this.#name = name;
554
+ this.#level = level;
555
+ VALUES_TO_ECLEVEL.set(bits, this);
556
+ }
557
+ get bits() {
558
+ return this.#bits;
559
+ }
560
+ get name() {
561
+ return this.#name;
562
+ }
563
+ get level() {
564
+ return this.#level;
565
+ }
566
+ }
567
+
568
+ /**
569
+ * @module QRCode
570
+ * @package @nuintun/qrcode
571
+ * @license MIT
572
+ * @version 5.0.2
573
+ * @author nuintun <nuintun@qq.com>
574
+ * @description A pure JavaScript QRCode encode and decode library.
575
+ * @see https://github.com/nuintun/qrcode#readme
576
+ */
577
+
578
+ /**
579
+ * @module ECB
580
+ */
581
+ class ECB {
582
+ #count;
583
+ #numDataCodewords;
584
+ constructor(count, numDataCodewords) {
585
+ this.#count = count;
586
+ this.#numDataCodewords = numDataCodewords;
587
+ }
588
+ get count() {
589
+ return this.#count;
590
+ }
591
+ get numDataCodewords() {
592
+ return this.#numDataCodewords;
593
+ }
594
+ }
595
+
596
+ /**
597
+ * @module QRCode
598
+ * @package @nuintun/qrcode
599
+ * @license MIT
600
+ * @version 5.0.2
601
+ * @author nuintun <nuintun@qq.com>
602
+ * @description A pure JavaScript QRCode encode and decode library.
603
+ * @see https://github.com/nuintun/qrcode#readme
604
+ */
605
+
606
+ /**
607
+ * @module ECBlocks
608
+ */
609
+ class ECBlocks {
610
+ #ecBlocks;
611
+ #numTotalCodewords;
612
+ #numTotalECCodewords;
613
+ #numTotalDataCodewords;
614
+ #numECCodewordsPerBlock;
615
+ constructor(numECCodewordsPerBlock, ...ecBlocks) {
616
+ let numBlocks = 0;
617
+ let numTotalDataCodewords = 0;
618
+ for (const { count, numDataCodewords } of ecBlocks) {
619
+ numBlocks += count;
620
+ numTotalDataCodewords += numDataCodewords * count;
621
+ }
622
+ const numTotalECCodewords = numECCodewordsPerBlock * numBlocks;
623
+ this.#ecBlocks = ecBlocks;
624
+ this.#numTotalECCodewords = numTotalECCodewords;
625
+ this.#numTotalDataCodewords = numTotalDataCodewords;
626
+ this.#numECCodewordsPerBlock = numECCodewordsPerBlock;
627
+ this.#numTotalCodewords = numTotalDataCodewords + numTotalECCodewords;
628
+ }
629
+ get ecBlocks() {
630
+ return this.#ecBlocks;
631
+ }
632
+ get numTotalCodewords() {
633
+ return this.#numTotalCodewords;
634
+ }
635
+ get numTotalECCodewords() {
636
+ return this.#numTotalECCodewords;
637
+ }
638
+ get numTotalDataCodewords() {
639
+ return this.#numTotalDataCodewords;
640
+ }
641
+ get numECCodewordsPerBlock() {
642
+ return this.#numECCodewordsPerBlock;
643
+ }
644
+ }
645
+
646
+ /**
647
+ * @module QRCode
648
+ * @package @nuintun/qrcode
649
+ * @license MIT
650
+ * @version 5.0.2
651
+ * @author nuintun <nuintun@qq.com>
652
+ * @description A pure JavaScript QRCode encode and decode library.
653
+ * @see https://github.com/nuintun/qrcode#readme
654
+ */
655
+
656
+ class Version {
657
+ #size;
658
+ #version;
659
+ #ecBlocks;
660
+ #alignmentPatterns;
661
+ constructor(version, alignmentPatterns, ...ecBlocks) {
662
+ this.#version = version;
663
+ this.#ecBlocks = ecBlocks;
664
+ this.#size = 17 + 4 * version;
665
+ this.#alignmentPatterns = alignmentPatterns;
666
+ }
667
+ get size() {
668
+ return this.#size;
669
+ }
670
+ get version() {
671
+ return this.#version;
672
+ }
673
+ get alignmentPatterns() {
674
+ return this.#alignmentPatterns;
675
+ }
676
+ getECBlocks({ level }) {
677
+ return this.#ecBlocks[level];
678
+ }
679
+ }
680
+ const VERSIONS = [
681
+ new Version(
682
+ 1,
683
+ [],
684
+ new ECBlocks(7, new ECB(1, 19)),
685
+ new ECBlocks(10, new ECB(1, 16)),
686
+ new ECBlocks(13, new ECB(1, 13)),
687
+ new ECBlocks(17, new ECB(1, 9))
688
+ ),
689
+ new Version(
690
+ 2,
691
+ [6, 18],
692
+ new ECBlocks(10, new ECB(1, 34)),
693
+ new ECBlocks(16, new ECB(1, 28)),
694
+ new ECBlocks(22, new ECB(1, 22)),
695
+ new ECBlocks(28, new ECB(1, 16))
696
+ ),
697
+ new Version(
698
+ 3,
699
+ [6, 22],
700
+ new ECBlocks(15, new ECB(1, 55)),
701
+ new ECBlocks(26, new ECB(1, 44)),
702
+ new ECBlocks(18, new ECB(2, 17)),
703
+ new ECBlocks(22, new ECB(2, 13))
704
+ ),
705
+ new Version(
706
+ 4,
707
+ [6, 26],
708
+ new ECBlocks(20, new ECB(1, 80)),
709
+ new ECBlocks(18, new ECB(2, 32)),
710
+ new ECBlocks(26, new ECB(2, 24)),
711
+ new ECBlocks(16, new ECB(4, 9))
712
+ ),
713
+ new Version(
714
+ 5,
715
+ [6, 30],
716
+ new ECBlocks(26, new ECB(1, 108)),
717
+ new ECBlocks(24, new ECB(2, 43)),
718
+ new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)),
719
+ new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))
720
+ ),
721
+ new Version(
722
+ 6,
723
+ [6, 34],
724
+ new ECBlocks(18, new ECB(2, 68)),
725
+ new ECBlocks(16, new ECB(4, 27)),
726
+ new ECBlocks(24, new ECB(4, 19)),
727
+ new ECBlocks(28, new ECB(4, 15))
728
+ ),
729
+ new Version(
730
+ 7,
731
+ [6, 22, 38],
732
+ new ECBlocks(20, new ECB(2, 78)),
733
+ new ECBlocks(18, new ECB(4, 31)),
734
+ new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)),
735
+ new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))
736
+ ),
737
+ new Version(
738
+ 8,
739
+ [6, 24, 42],
740
+ new ECBlocks(24, new ECB(2, 97)),
741
+ new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)),
742
+ new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)),
743
+ new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))
744
+ ),
745
+ new Version(
746
+ 9,
747
+ [6, 26, 46],
748
+ new ECBlocks(30, new ECB(2, 116)),
749
+ new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)),
750
+ new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)),
751
+ new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))
752
+ ),
753
+ new Version(
754
+ 10,
755
+ [6, 28, 50],
756
+ new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)),
757
+ new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)),
758
+ new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)),
759
+ new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))
760
+ ),
761
+ new Version(
762
+ 11,
763
+ [6, 30, 54],
764
+ new ECBlocks(20, new ECB(4, 81)),
765
+ new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)),
766
+ new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)),
767
+ new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))
768
+ ),
769
+ new Version(
770
+ 12,
771
+ [6, 32, 58],
772
+ new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)),
773
+ new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)),
774
+ new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)),
775
+ new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))
776
+ ),
777
+ new Version(
778
+ 13,
779
+ [6, 34, 62],
780
+ new ECBlocks(26, new ECB(4, 107)),
781
+ new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)),
782
+ new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)),
783
+ new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))
784
+ ),
785
+ new Version(
786
+ 14,
787
+ [6, 26, 46, 66],
788
+ new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)),
789
+ new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)),
790
+ new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)),
791
+ new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))
792
+ ),
793
+ new Version(
794
+ 15,
795
+ [6, 26, 48, 70],
796
+ new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)),
797
+ new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)),
798
+ new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)),
799
+ new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))
800
+ ),
801
+ new Version(
802
+ 16,
803
+ [6, 26, 50, 74],
804
+ new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)),
805
+ new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)),
806
+ new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)),
807
+ new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))
808
+ ),
809
+ new Version(
810
+ 17,
811
+ [6, 30, 54, 78],
812
+ new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)),
813
+ new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)),
814
+ new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)),
815
+ new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))
816
+ ),
817
+ new Version(
818
+ 18,
819
+ [6, 30, 56, 82],
820
+ new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)),
821
+ new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)),
822
+ new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)),
823
+ new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))
824
+ ),
825
+ new Version(
826
+ 19,
827
+ [6, 30, 58, 86],
828
+ new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)),
829
+ new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)),
830
+ new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)),
831
+ new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))
832
+ ),
833
+ new Version(
834
+ 20,
835
+ [6, 34, 62, 90],
836
+ new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)),
837
+ new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)),
838
+ new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)),
839
+ new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))
840
+ ),
841
+ new Version(
842
+ 21,
843
+ [6, 28, 50, 72, 94],
844
+ new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)),
845
+ new ECBlocks(26, new ECB(17, 42)),
846
+ new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)),
847
+ new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))
848
+ ),
849
+ new Version(
850
+ 22,
851
+ [6, 26, 50, 74, 98],
852
+ new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)),
853
+ new ECBlocks(28, new ECB(17, 46)),
854
+ new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)),
855
+ new ECBlocks(24, new ECB(34, 13))
856
+ ),
857
+ new Version(
858
+ 23,
859
+ [6, 30, 54, 78, 102],
860
+ new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)),
861
+ new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)),
862
+ new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)),
863
+ new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))
864
+ ),
865
+ new Version(
866
+ 24,
867
+ [6, 28, 54, 80, 106],
868
+ new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)),
869
+ new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)),
870
+ new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)),
871
+ new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))
872
+ ),
873
+ new Version(
874
+ 25,
875
+ [6, 32, 58, 84, 110],
876
+ new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)),
877
+ new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)),
878
+ new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)),
879
+ new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))
880
+ ),
881
+ new Version(
882
+ 26,
883
+ [6, 30, 58, 86, 114],
884
+ new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)),
885
+ new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)),
886
+ new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)),
887
+ new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))
888
+ ),
889
+ new Version(
890
+ 27,
891
+ [6, 34, 62, 90, 118],
892
+ new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)),
893
+ new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)),
894
+ new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)),
895
+ new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))
896
+ ),
897
+ new Version(
898
+ 28,
899
+ [6, 26, 50, 74, 98, 122],
900
+ new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)),
901
+ new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)),
902
+ new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)),
903
+ new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))
904
+ ),
905
+ new Version(
906
+ 29,
907
+ [6, 30, 54, 78, 102, 126],
908
+ new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)),
909
+ new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)),
910
+ new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)),
911
+ new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))
912
+ ),
913
+ new Version(
914
+ 30,
915
+ [6, 26, 52, 78, 104, 130],
916
+ new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)),
917
+ new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)),
918
+ new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)),
919
+ new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))
920
+ ),
921
+ new Version(
922
+ 31,
923
+ [6, 30, 56, 82, 108, 134],
924
+ new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)),
925
+ new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)),
926
+ new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)),
927
+ new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))
928
+ ),
929
+ new Version(
930
+ 32,
931
+ [6, 34, 60, 86, 112, 138],
932
+ new ECBlocks(30, new ECB(17, 115)),
933
+ new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)),
934
+ new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)),
935
+ new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))
936
+ ),
937
+ new Version(
938
+ 33,
939
+ [6, 30, 58, 86, 114, 142],
940
+ new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)),
941
+ new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)),
942
+ new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)),
943
+ new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))
944
+ ),
945
+ new Version(
946
+ 34,
947
+ [6, 34, 62, 90, 118, 146],
948
+ new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)),
949
+ new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)),
950
+ new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)),
951
+ new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))
952
+ ),
953
+ new Version(
954
+ 35,
955
+ [6, 30, 54, 78, 102, 126, 150],
956
+ new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)),
957
+ new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)),
958
+ new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)),
959
+ new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))
960
+ ),
961
+ new Version(
962
+ 36,
963
+ [6, 24, 50, 76, 102, 128, 154],
964
+ new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)),
965
+ new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)),
966
+ new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)),
967
+ new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))
968
+ ),
969
+ new Version(
970
+ 37,
971
+ [6, 28, 54, 80, 106, 132, 158],
972
+ new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)),
973
+ new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)),
974
+ new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)),
975
+ new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))
976
+ ),
977
+ new Version(
978
+ 38,
979
+ [6, 32, 58, 84, 110, 136, 162],
980
+ new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)),
981
+ new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)),
982
+ new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)),
983
+ new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))
984
+ ),
985
+ new Version(
986
+ 39,
987
+ [6, 26, 54, 82, 110, 138, 166],
988
+ new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)),
989
+ new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)),
990
+ new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)),
991
+ new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))
992
+ ),
993
+ new Version(
994
+ 40,
995
+ [6, 30, 58, 86, 114, 142, 170],
996
+ new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)),
997
+ new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)),
998
+ new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)),
999
+ new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))
1000
+ )
1001
+ ];
1002
+
1003
+ /**
1004
+ * @module QRCode
1005
+ * @package @nuintun/qrcode
1006
+ * @license MIT
1007
+ * @version 5.0.2
1008
+ * @author nuintun <nuintun@qq.com>
1009
+ * @description A pure JavaScript QRCode encode and decode library.
1010
+ * @see https://github.com/nuintun/qrcode#readme
1011
+ */
1012
+
1013
+ /**
1014
+ * @module Polynomial
1015
+ */
1016
+ class Polynomial {
1017
+ #field;
1018
+ #coefficients;
1019
+ constructor(field, coefficients) {
1020
+ const { length } = coefficients;
1021
+ if (length <= 0) {
1022
+ throw new Error('polynomial coefficients cannot empty');
1023
+ }
1024
+ this.#field = field;
1025
+ if (length > 1 && coefficients[0] === 0) {
1026
+ // Leading term must be non-zero for anything except the constant polynomial "0".
1027
+ let firstNonZero = 1;
1028
+ while (firstNonZero < length && coefficients[firstNonZero] === 0) {
1029
+ firstNonZero++;
1030
+ }
1031
+ if (firstNonZero === length) {
1032
+ this.#coefficients = new Int32Array([0]);
1033
+ } else {
1034
+ const array = new Int32Array(length - firstNonZero);
1035
+ array.set(coefficients.subarray(firstNonZero));
1036
+ this.#coefficients = array;
1037
+ }
1038
+ } else {
1039
+ this.#coefficients = coefficients;
1040
+ }
1041
+ }
1042
+ get coefficients() {
1043
+ return this.#coefficients;
1044
+ }
1045
+ isZero() {
1046
+ return this.#coefficients[0] === 0;
1047
+ }
1048
+ getDegree() {
1049
+ return this.#coefficients.length - 1;
1050
+ }
1051
+ getCoefficient(degree) {
1052
+ const coefficients = this.#coefficients;
1053
+ return coefficients[coefficients.length - 1 - degree];
1054
+ }
1055
+ evaluate(a) {
1056
+ if (a === 0) {
1057
+ // Just return the x^0 coefficient.
1058
+ return this.getCoefficient(0);
1059
+ }
1060
+ let result;
1061
+ const coefficients = this.#coefficients;
1062
+ if (a === 1) {
1063
+ // Just the sum of the coefficients.
1064
+ result = 0;
1065
+ for (const coefficient of coefficients) {
1066
+ result ^= coefficient;
1067
+ }
1068
+ return result;
1069
+ }
1070
+ [result] = coefficients;
1071
+ const field = this.#field;
1072
+ const { length } = coefficients;
1073
+ for (let i = 1; i < length; i++) {
1074
+ result = field.multiply(a, result) ^ coefficients[i];
1075
+ }
1076
+ return result;
1077
+ }
1078
+ multiply(other) {
1079
+ const field = this.#field;
1080
+ const coefficients = this.#coefficients;
1081
+ const { length } = coefficients;
1082
+ if (other instanceof Polynomial) {
1083
+ if (this.isZero() || other.isZero()) {
1084
+ return field.zero;
1085
+ }
1086
+ const otherCoefficients = other.#coefficients;
1087
+ const otherLength = otherCoefficients.length;
1088
+ const product = new Int32Array(length + otherLength - 1);
1089
+ for (let i = 0; i < length; i++) {
1090
+ const coefficient = coefficients[i];
1091
+ for (let j = 0; j < otherLength; j++) {
1092
+ product[i + j] ^= field.multiply(coefficient, otherCoefficients[j]);
1093
+ }
1094
+ }
1095
+ return new Polynomial(field, product);
1096
+ }
1097
+ if (other === 0) {
1098
+ return field.zero;
1099
+ }
1100
+ if (other === 1) {
1101
+ return this;
1102
+ }
1103
+ const product = new Int32Array(length);
1104
+ for (let i = 0; i < length; i++) {
1105
+ product[i] = field.multiply(coefficients[i], other);
1106
+ }
1107
+ return new Polynomial(field, product);
1108
+ }
1109
+ multiplyByMonomial(degree, coefficient) {
1110
+ const field = this.#field;
1111
+ if (coefficient === 0) {
1112
+ return field.zero;
1113
+ }
1114
+ const coefficients = this.#coefficients;
1115
+ const { length } = coefficients;
1116
+ const product = new Int32Array(length + degree);
1117
+ for (let i = 0; i < length; i++) {
1118
+ product[i] = field.multiply(coefficients[i], coefficient);
1119
+ }
1120
+ return new Polynomial(field, product);
1121
+ }
1122
+ addOrSubtract(other) {
1123
+ if (this.isZero()) {
1124
+ return other;
1125
+ }
1126
+ if (other.isZero()) {
1127
+ return this;
1128
+ }
1129
+ let largerCoefficients = other.#coefficients;
1130
+ let largerLength = largerCoefficients.length;
1131
+ let smallerCoefficients = this.#coefficients;
1132
+ let smallerLength = smallerCoefficients.length;
1133
+ if (largerLength < smallerLength) {
1134
+ [largerLength, smallerLength] = [smallerLength, largerLength];
1135
+ [largerCoefficients, smallerCoefficients] = [smallerCoefficients, largerCoefficients];
1136
+ }
1137
+ // Diff index offset.
1138
+ const offset = largerLength - smallerLength;
1139
+ const coefficients = new Int32Array(largerLength);
1140
+ // Copy high-order terms only found in higher-degree polynomial's coefficients.
1141
+ coefficients.set(largerCoefficients.subarray(0, offset));
1142
+ for (let i = offset; i < largerLength; i++) {
1143
+ coefficients[i] = smallerCoefficients[i - offset] ^ largerCoefficients[i];
1144
+ }
1145
+ return new Polynomial(this.#field, coefficients);
1146
+ }
1147
+ divide(other) {
1148
+ const field = this.#field;
1149
+ let quotient = field.zero;
1150
+ let remainder = this;
1151
+ const denominatorLeadingTerm = other.getCoefficient(other.getDegree());
1152
+ const invertDenominatorLeadingTerm = field.invert(denominatorLeadingTerm);
1153
+ while (remainder.getDegree() >= other.getDegree() && !remainder.isZero()) {
1154
+ const remainderDegree = remainder.getDegree();
1155
+ const degreeDiff = remainderDegree - other.getDegree();
1156
+ const scale = field.multiply(remainder.getCoefficient(remainderDegree), invertDenominatorLeadingTerm);
1157
+ const term = other.multiplyByMonomial(degreeDiff, scale);
1158
+ const iterationQuotient = field.buildPolynomial(degreeDiff, scale);
1159
+ quotient = quotient.addOrSubtract(iterationQuotient);
1160
+ remainder = remainder.addOrSubtract(term);
1161
+ }
1162
+ return [quotient, remainder];
1163
+ }
1164
+ }
1165
+
1166
+ /**
1167
+ * @module QRCode
1168
+ * @package @nuintun/qrcode
1169
+ * @license MIT
1170
+ * @version 5.0.2
1171
+ * @author nuintun <nuintun@qq.com>
1172
+ * @description A pure JavaScript QRCode encode and decode library.
1173
+ * @see https://github.com/nuintun/qrcode#readme
1174
+ */
1175
+
1176
+
1177
+ /**
1178
+ * @module GaloisField
1179
+ */
1180
+ class GaloisField {
1181
+ #size;
1182
+ #one;
1183
+ #zero;
1184
+ #generator;
1185
+ #expTable;
1186
+ #logTable;
1187
+ constructor(primitive, size, generator) {
1188
+ let x = 1;
1189
+ const expTable = new Int32Array(size);
1190
+ for (let i = 0; i < size; i++) {
1191
+ expTable[i] = x;
1192
+ // We're assuming the generator alpha is 2.
1193
+ x *= 2;
1194
+ if (x >= size) {
1195
+ x ^= primitive;
1196
+ x &= size - 1;
1197
+ }
1198
+ }
1199
+ const logTable = new Int32Array(size);
1200
+ for (let i = 0, length = size - 1; i < length; i++) {
1201
+ logTable[expTable[i]] = i;
1202
+ }
1203
+ this.#size = size;
1204
+ this.#expTable = expTable;
1205
+ this.#logTable = logTable;
1206
+ this.#generator = generator;
1207
+ this.#one = new Polynomial(this, new Int32Array([1]));
1208
+ this.#zero = new Polynomial(this, new Int32Array([0]));
1209
+ }
1210
+ get size() {
1211
+ return this.#size;
1212
+ }
1213
+ get one() {
1214
+ return this.#one;
1215
+ }
1216
+ get zero() {
1217
+ return this.#zero;
1218
+ }
1219
+ get generator() {
1220
+ return this.#generator;
1221
+ }
1222
+ exp(a) {
1223
+ return this.#expTable[a];
1224
+ }
1225
+ log(a) {
1226
+ return this.#logTable[a];
1227
+ }
1228
+ invert(a) {
1229
+ return this.#expTable[this.#size - this.#logTable[a] - 1];
1230
+ }
1231
+ multiply(a, b) {
1232
+ if (a === 0 || b === 0) {
1233
+ return 0;
1234
+ }
1235
+ const logTable = this.#logTable;
1236
+ return this.#expTable[(logTable[a] + logTable[b]) % (this.#size - 1)];
1237
+ }
1238
+ buildPolynomial(degree, coefficient) {
1239
+ if (coefficient === 0) {
1240
+ return this.#zero;
1241
+ }
1242
+ const coefficients = new Int32Array(degree + 1);
1243
+ coefficients[0] = coefficient;
1244
+ return new Polynomial(this, coefficients);
1245
+ }
1246
+ }
1247
+ const QR_CODE_FIELD_256 = new GaloisField(0x011d, 256, 0);
1248
+
1249
+ /**
1250
+ * @module QRCode
1251
+ * @package @nuintun/qrcode
1252
+ * @license MIT
1253
+ * @version 5.0.2
1254
+ * @author nuintun <nuintun@qq.com>
1255
+ * @description A pure JavaScript QRCode encode and decode library.
1256
+ * @see https://github.com/nuintun/qrcode#readme
1257
+ */
1258
+
1259
+
1260
+ /**
1261
+ * @module index
1262
+ */
1263
+ function getUnicodeCodes(content, maxCode) {
1264
+ const bytes = [];
1265
+ for (const character of content) {
1266
+ const code = character.codePointAt(0);
1267
+ // If gt max code, push "?".
1268
+ bytes.push(code == null || code > maxCode ? 63 : code);
1269
+ }
1270
+ return new Uint8Array(bytes);
1271
+ }
1272
+ function encode$1(content, charset) {
1273
+ switch (charset) {
1274
+ case Charset.ASCII:
1275
+ return getUnicodeCodes(content, 0x7f);
1276
+ case Charset.ISO_8859_1:
1277
+ return getUnicodeCodes(content, 0xff);
1278
+ case Charset.UTF_8:
1279
+ return new TextEncoder().encode(content);
1280
+ default:
1281
+ throw Error(`built-in encode not support charset: ${charset.label}`);
1282
+ }
1283
+ }
1284
+
1285
+ /**
1286
+ * @module QRCode
1287
+ * @package @nuintun/qrcode
1288
+ * @license MIT
1289
+ * @version 5.0.2
1290
+ * @author nuintun <nuintun@qq.com>
1291
+ * @description A pure JavaScript QRCode encode and decode library.
1292
+ * @see https://github.com/nuintun/qrcode#readme
1293
+ */
1294
+
1295
+
1296
+ /**
1297
+ * @module BitArray
1298
+ */
1299
+ const LOAD_FACTOR = 0.75;
1300
+ function offset(index) {
1301
+ return toInt32(index / 32);
1302
+ }
1303
+ function makeArray(length) {
1304
+ return new Int32Array(Math.ceil(length / 32));
1305
+ }
1306
+ class BitArray {
1307
+ #length;
1308
+ #bits;
1309
+ constructor(length = 0) {
1310
+ this.#length = length;
1311
+ this.#bits = makeArray(length);
1312
+ }
1313
+ #alloc(length) {
1314
+ const bits = this.#bits;
1315
+ if (length > bits.length * 32) {
1316
+ const array = makeArray(Math.ceil(length / LOAD_FACTOR));
1317
+ array.set(bits);
1318
+ this.#bits = array;
1319
+ }
1320
+ this.#length = length;
1321
+ }
1322
+ get length() {
1323
+ return this.#length;
1324
+ }
1325
+ get byteLength() {
1326
+ return Math.ceil(this.#length / 8);
1327
+ }
1328
+ set(index) {
1329
+ this.#bits[offset(index)] |= getBitMask(index);
1330
+ }
1331
+ get(index) {
1332
+ return toBit(this.#bits[offset(index)] >>> getBitOffset(index));
1333
+ }
1334
+ xor(mask) {
1335
+ const bits = this.#bits;
1336
+ const maskBits = mask.#bits;
1337
+ const length = Math.min(this.#length, mask.#length);
1338
+ for (let i = 0; i < length; i++) {
1339
+ // The last int could be incomplete (i.e. not have 32 bits in
1340
+ // it) but there is no problem since 0 XOR 0 == 0.
1341
+ bits[i] ^= maskBits[i];
1342
+ }
1343
+ }
1344
+ append(value, length = 1) {
1345
+ let index = this.#length;
1346
+ if (value instanceof BitArray) {
1347
+ length = value.#length;
1348
+ this.#alloc(index + length);
1349
+ for (let i = 0; i < length; i++) {
1350
+ if (value.get(i) !== 0) {
1351
+ this.set(index);
1352
+ }
1353
+ index++;
1354
+ }
1355
+ } else {
1356
+ this.#alloc(index + length);
1357
+ for (let i = length - 1; i >= 0; i--) {
1358
+ if (toBit(value >>> i) !== 0) {
1359
+ this.set(index);
1360
+ }
1361
+ index++;
1362
+ }
1363
+ }
1364
+ }
1365
+ writeToUint8Array(bitOffset, target, byteOffset, byteLength) {
1366
+ for (let i = 0; i < byteLength; i++) {
1367
+ let byte = 0;
1368
+ for (let j = 0; j < 8; j++) {
1369
+ if (this.get(bitOffset++) !== 0) {
1370
+ byte |= 1 << (7 - j);
1371
+ }
1372
+ }
1373
+ target[byteOffset + i] = byte;
1374
+ }
1375
+ }
1376
+ clear() {
1377
+ this.#bits.fill(0);
1378
+ }
1379
+ }
1380
+
1381
+ /**
1382
+ * @module QRCode
1383
+ * @package @nuintun/qrcode
1384
+ * @license MIT
1385
+ * @version 5.0.2
1386
+ * @author nuintun <nuintun@qq.com>
1387
+ * @description A pure JavaScript QRCode encode and decode library.
1388
+ * @see https://github.com/nuintun/qrcode#readme
1389
+ */
1390
+
1391
+ /**
1392
+ * @module ByteMatrix
1393
+ */
1394
+ class ByteMatrix {
1395
+ #size;
1396
+ #bytes;
1397
+ constructor(size) {
1398
+ this.#size = size;
1399
+ this.#bytes = new Int8Array(size * size);
1400
+ }
1401
+ get size() {
1402
+ return this.#size;
1403
+ }
1404
+ set(x, y, value) {
1405
+ this.#bytes[y * this.#size + x] = value;
1406
+ }
1407
+ get(x, y) {
1408
+ return this.#bytes[y * this.#size + x];
1409
+ }
1410
+ clear(value) {
1411
+ this.#bytes.fill(value);
1412
+ }
1413
+ }
1414
+
1415
+ /**
1416
+ * @module QRCode
1417
+ * @package @nuintun/qrcode
1418
+ * @license MIT
1419
+ * @version 5.0.2
1420
+ * @author nuintun <nuintun@qq.com>
1421
+ * @description A pure JavaScript QRCode encode and decode library.
1422
+ * @see https://github.com/nuintun/qrcode#readme
1423
+ */
1424
+
1425
+
1426
+ /**
1427
+ * @module matrix
1428
+ */
1429
+ // Format information poly: 101 0011 0111.
1430
+ const FORMAT_INFO_POLY = 0x537;
1431
+ // Format information mask.
1432
+ const FORMAT_INFO_MASK = 0x5412;
1433
+ // Version information poly: 1 1111 0010 0101.
1434
+ const VERSION_INFO_POLY = 0x1f25;
1435
+ // Finder pattern shape.
1436
+ const FINDER_PATTERN_SHAPE = [
1437
+ [1, 1, 1, 1, 1, 1, 1],
1438
+ [1, 0, 0, 0, 0, 0, 1],
1439
+ [1, 0, 1, 1, 1, 0, 1],
1440
+ [1, 0, 1, 1, 1, 0, 1],
1441
+ [1, 0, 1, 1, 1, 0, 1],
1442
+ [1, 0, 0, 0, 0, 0, 1],
1443
+ [1, 1, 1, 1, 1, 1, 1]
1444
+ ];
1445
+ // Alignment pattern shape.
1446
+ const ALIGNMENT_PATTERN_SHAPE = [
1447
+ [1, 1, 1, 1, 1],
1448
+ [1, 0, 0, 0, 1],
1449
+ [1, 0, 1, 0, 1],
1450
+ [1, 0, 0, 0, 1],
1451
+ [1, 1, 1, 1, 1]
1452
+ ];
1453
+ // Format information coordinates.
1454
+ const FORMAT_INFO_COORDINATES = [
1455
+ [8, 0],
1456
+ [8, 1],
1457
+ [8, 2],
1458
+ [8, 3],
1459
+ [8, 4],
1460
+ [8, 5],
1461
+ [8, 7],
1462
+ [8, 8],
1463
+ [7, 8],
1464
+ [5, 8],
1465
+ [4, 8],
1466
+ [3, 8],
1467
+ [2, 8],
1468
+ [1, 8],
1469
+ [0, 8]
1470
+ ];
1471
+ // Is empty point.
1472
+ function isEmpty(matrix, x, y) {
1473
+ return matrix.get(x, y) === -1;
1474
+ }
1475
+ function embedFinderPattern(matrix, x, y) {
1476
+ for (let i = 0; i < 7; i++) {
1477
+ const pattern = FINDER_PATTERN_SHAPE[i];
1478
+ for (let j = 0; j < 7; j++) {
1479
+ matrix.set(x + j, y + i, pattern[j]);
1480
+ }
1481
+ }
1482
+ }
1483
+ function embedHorizontalSeparator(matrix, x, y) {
1484
+ for (let j = 0; j < 8; j++) {
1485
+ matrix.set(x + j, y, 0);
1486
+ }
1487
+ }
1488
+ function embedVerticalSeparator(matrix, x, y) {
1489
+ for (let i = 0; i < 7; i++) {
1490
+ matrix.set(x, y + i, 0);
1491
+ }
1492
+ }
1493
+ // Embed finder patterns and surrounding vertical/horizontal separators.
1494
+ function embedFinderPatternsAndSeparators(matrix) {
1495
+ // Embed three big squares at corners.
1496
+ const pdpWidth = 7;
1497
+ // Embed horizontal separation patterns around the squares.
1498
+ const hspWidth = 8;
1499
+ // Embed vertical separation patterns around the squares.
1500
+ const vspHeight = 7;
1501
+ // Matrix width
1502
+ const { size } = matrix;
1503
+ // Left top corner.
1504
+ embedFinderPattern(matrix, 0, 0);
1505
+ // Right top corner.
1506
+ embedFinderPattern(matrix, size - pdpWidth, 0);
1507
+ // Left bottom corner.
1508
+ embedFinderPattern(matrix, 0, size - pdpWidth);
1509
+ // Left top corner.
1510
+ embedHorizontalSeparator(matrix, 0, hspWidth - 1);
1511
+ // Right top corner.
1512
+ embedHorizontalSeparator(matrix, size - hspWidth, hspWidth - 1);
1513
+ // Left bottom corner.
1514
+ embedHorizontalSeparator(matrix, 0, size - hspWidth);
1515
+ // Left top corner.
1516
+ embedVerticalSeparator(matrix, vspHeight, 0);
1517
+ // Right top corner.
1518
+ embedVerticalSeparator(matrix, size - vspHeight - 1, 0);
1519
+ // Left bottom corner.
1520
+ embedVerticalSeparator(matrix, vspHeight, size - vspHeight);
1521
+ }
1522
+ function embedTimingPatterns(matrix) {
1523
+ const size = matrix.size - 8;
1524
+ // -8 is for skipping position detection patterns (7: size)
1525
+ // separation patterns (1: size). Thus, 8 = 7 + 1.
1526
+ for (let x = 8; x < size; x++) {
1527
+ const bit = (x + 1) & 0x01;
1528
+ // Horizontal line.
1529
+ if (isEmpty(matrix, x, 6)) {
1530
+ matrix.set(x, 6, bit);
1531
+ }
1532
+ }
1533
+ // -8 is for skipping position detection patterns (7: size)
1534
+ // separation patterns (1: size). Thus, 8 = 7 + 1.
1535
+ for (let y = 8; y < size; y++) {
1536
+ const bit = (y + 1) & 0x01;
1537
+ // Vertical line.
1538
+ if (isEmpty(matrix, 6, y)) {
1539
+ matrix.set(6, y, bit);
1540
+ }
1541
+ }
1542
+ }
1543
+ function embedAlignmentPattern(matrix, x, y) {
1544
+ for (let i = 0; i < 5; i++) {
1545
+ const pattern = ALIGNMENT_PATTERN_SHAPE[i];
1546
+ for (let j = 0; j < 5; j++) {
1547
+ matrix.set(x + j, y + i, pattern[j]);
1548
+ }
1549
+ }
1550
+ }
1551
+ // Embed position alignment patterns if need be.
1552
+ function embedAlignmentPatterns(matrix, { version }) {
1553
+ if (version >= 2) {
1554
+ const { alignmentPatterns } = VERSIONS[version - 1];
1555
+ const { length } = alignmentPatterns;
1556
+ for (let i = 0; i < length; i++) {
1557
+ const y = alignmentPatterns[i];
1558
+ for (let j = 0; j < length; j++) {
1559
+ const x = alignmentPatterns[j];
1560
+ if (isEmpty(matrix, x, y)) {
1561
+ // If the cell is unset, we embed the position alignment pattern here.
1562
+ // -2 is necessary since the x/y coordinates point to the center of the pattern, not the
1563
+ // left top corner.
1564
+ embedAlignmentPattern(matrix, x - 2, y - 2);
1565
+ }
1566
+ }
1567
+ }
1568
+ }
1569
+ }
1570
+ // Embed the lonely dark dot at left bottom corner. ISO/IEC 18004:2015(E)(p.56)
1571
+ function embedDarkModule(matrix) {
1572
+ matrix.set(8, matrix.size - 8, 1);
1573
+ }
1574
+ // Make bit vector of format information. On success, store the result in "bits".
1575
+ // Encode error correction level and mask pattern. See 8.9 of
1576
+ // ISO/IEC 18004:2015(E)(p.55) for details.
1577
+ function makeFormatInfoBits(bits, ecLevel, mask) {
1578
+ const formatInfo = (ecLevel.bits << 3) | mask;
1579
+ bits.append(formatInfo, 5);
1580
+ const bchCode = calculateBCHCode(formatInfo, FORMAT_INFO_POLY);
1581
+ bits.append(bchCode, 10);
1582
+ const maskBits = new BitArray();
1583
+ maskBits.append(FORMAT_INFO_MASK, 15);
1584
+ bits.xor(maskBits);
1585
+ }
1586
+ // Embed format information. On success, modify the matrix.
1587
+ function embedFormatInfo(matrix, ecLevel, mask) {
1588
+ const formatInfoBits = new BitArray();
1589
+ makeFormatInfoBits(formatInfoBits, ecLevel, mask);
1590
+ const { size } = matrix;
1591
+ const { length } = formatInfoBits;
1592
+ for (let i = 0; i < length; i++) {
1593
+ // Type info bits at the left top corner.
1594
+ const [x, y] = FORMAT_INFO_COORDINATES[i];
1595
+ // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in formatInfoBits.
1596
+ const bit = formatInfoBits.get(length - 1 - i);
1597
+ matrix.set(x, y, bit);
1598
+ if (i < 8) {
1599
+ // Right top corner.
1600
+ matrix.set(size - i - 1, 8, bit);
1601
+ } else {
1602
+ // Left bottom corner.
1603
+ matrix.set(8, size - 7 + (i - 8), bit);
1604
+ }
1605
+ }
1606
+ // Then, embed the dark dot at the left bottom corner.
1607
+ embedDarkModule(matrix);
1608
+ }
1609
+ // Make bit vector of version information. On success, store the result in "bits".
1610
+ // See 7.10 of ISO/IEC 18004:2015(E)(p.58) for details.
1611
+ function makeVersionInfoBits(bits, version) {
1612
+ bits.append(version, 6);
1613
+ const bchCode = calculateBCHCode(version, VERSION_INFO_POLY);
1614
+ bits.append(bchCode, 12);
1615
+ }
1616
+ // Embed version information if need be. On success, modify the matrix.
1617
+ // See 7.10 of ISO/IEC 18004:2015(E)(p.58) for how to embed version information.
1618
+ function embedVersionInfo(matrix, { version }) {
1619
+ if (version >= 7) {
1620
+ const versionInfoBits = new BitArray();
1621
+ makeVersionInfoBits(versionInfoBits, version);
1622
+ // It will decrease from 17 to 0.
1623
+ let bitIndex = 6 * 3 - 1;
1624
+ const { size } = matrix;
1625
+ for (let i = 0; i < 6; i++) {
1626
+ for (let j = 0; j < 3; j++) {
1627
+ // Place bits in LSB (least significant bit) to MSB order.
1628
+ const bit = versionInfoBits.get(bitIndex--);
1629
+ // Left bottom corner.
1630
+ matrix.set(i, size - 11 + j, bit);
1631
+ // Right bottom corner.
1632
+ matrix.set(size - 11 + j, i, bit);
1633
+ }
1634
+ }
1635
+ }
1636
+ }
1637
+ // Embed "codewords". On success, modify the matrix.
1638
+ // See 7.7.3 of ISO/IEC 18004:2015(E)(p.46) for how to embed codewords.
1639
+ function embedCodewords(matrix, codewords, mask) {
1640
+ let bitIndex = 0;
1641
+ const { size } = matrix;
1642
+ const { length } = codewords;
1643
+ // Start from the right bottom cell.
1644
+ for (let x = size - 1; x >= 1; x -= 2) {
1645
+ // Skip the vertical timing pattern.
1646
+ if (x === 6) {
1647
+ x = 5;
1648
+ }
1649
+ for (let y = 0; y < size; y++) {
1650
+ for (let i = 0; i < 2; i++) {
1651
+ const offsetX = x - i;
1652
+ const upward = ((x + 1) & 2) === 0;
1653
+ const offsetY = upward ? size - 1 - y : y;
1654
+ // Skip the cell if it's not empty.
1655
+ if (isEmpty(matrix, offsetX, offsetY)) {
1656
+ // Padding bit. If there is no bit left, we'll fill the left cells with 0.
1657
+ let bit = 0;
1658
+ if (bitIndex < length) {
1659
+ bit = codewords.get(bitIndex++);
1660
+ }
1661
+ // Is apply mask.
1662
+ if (isApplyMask(mask, offsetX, offsetY)) {
1663
+ bit ^= 1;
1664
+ }
1665
+ matrix.set(offsetX, offsetY, bit);
1666
+ }
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ // Embed function patterns. On success, modify the matrix.
1672
+ // The function patterns are:
1673
+ // - Finder patterns and separators
1674
+ // - Alignment patterns, if version >= 2
1675
+ // - Timing patterns
1676
+ function embedFunctionPatterns(matrix, version) {
1677
+ // Let's get started with embedding big squares at corners.
1678
+ embedFinderPatternsAndSeparators(matrix);
1679
+ // Alignment patterns appear if version >= 2.
1680
+ embedAlignmentPatterns(matrix, version);
1681
+ // Timing patterns should be embedded after position adj. patterns.
1682
+ embedTimingPatterns(matrix);
1683
+ }
1684
+ // Embed encoding region. On success, modify the matrix.
1685
+ // The encoding region are:
1686
+ // - Format Info
1687
+ // - Version Info, if version >= 7
1688
+ // - Data with correction
1689
+ function embedEncodingRegion(matrix, codewords, version, ecLevel, mask) {
1690
+ // Type information appear with any version.
1691
+ embedFormatInfo(matrix, ecLevel, mask);
1692
+ // Version info appear if version >= 7.
1693
+ embedVersionInfo(matrix, version);
1694
+ // Data should be embedded at end.
1695
+ embedCodewords(matrix, codewords, mask);
1696
+ }
1697
+ // Build 2D matrix of QR Code from "codewords" with "ecLevel", "version" and "getMaskPattern". On
1698
+ // success, store the result in "matrix".
1699
+ function buildMatrix(codewords, version, ecLevel, mask) {
1700
+ const matrix = new ByteMatrix(version.size);
1701
+ // Clear matrix.
1702
+ matrix.clear(-1);
1703
+ // Embed function patterns.
1704
+ embedFunctionPatterns(matrix, version);
1705
+ // Embed encoding region.
1706
+ embedEncodingRegion(matrix, codewords, version, ecLevel, mask);
1707
+ return matrix;
1708
+ }
1709
+
1710
+ /**
1711
+ * @module QRCode
1712
+ * @package @nuintun/qrcode
1713
+ * @license MIT
1714
+ * @version 5.0.2
1715
+ * @author nuintun <nuintun@qq.com>
1716
+ * @description A pure JavaScript QRCode encode and decode library.
1717
+ * @see https://github.com/nuintun/qrcode#readme
1718
+ */
1719
+
1720
+ /**
1721
+ * @module BlockPair
1722
+ */
1723
+ class BlockPair {
1724
+ #ecCodewords;
1725
+ #dataCodewords;
1726
+ constructor(dataCodewords, ecCodewords) {
1727
+ this.#ecCodewords = ecCodewords;
1728
+ this.#dataCodewords = dataCodewords;
1729
+ }
1730
+ get ecCodewords() {
1731
+ return this.#ecCodewords;
1732
+ }
1733
+ get dataCodewords() {
1734
+ return this.#dataCodewords;
1735
+ }
1736
+ }
1737
+
1738
+ /**
1739
+ * @module QRCode
1740
+ * @package @nuintun/qrcode
1741
+ * @license MIT
1742
+ * @version 5.0.2
1743
+ * @author nuintun <nuintun@qq.com>
1744
+ * @description A pure JavaScript QRCode encode and decode library.
1745
+ * @see https://github.com/nuintun/qrcode#readme
1746
+ */
1747
+
1748
+
1749
+ /**
1750
+ * @module Encoder
1751
+ */
1752
+ function buildGenerator(field, generators, degree) {
1753
+ const { length } = generators;
1754
+ if (degree >= length) {
1755
+ const { generator } = field;
1756
+ let lastGenerator = generators[length - 1];
1757
+ for (let i = length; i <= degree; i++) {
1758
+ const coefficients = new Int32Array([1, field.exp(i - 1 + generator)]);
1759
+ const nextGenerator = lastGenerator.multiply(new Polynomial(field, coefficients));
1760
+ generators.push(nextGenerator);
1761
+ lastGenerator = nextGenerator;
1762
+ }
1763
+ }
1764
+ return generators[degree];
1765
+ }
1766
+ let Encoder$1 = class Encoder {
1767
+ #field;
1768
+ #generators;
1769
+ constructor(field = QR_CODE_FIELD_256) {
1770
+ this.#field = field;
1771
+ this.#generators = [new Polynomial(field, new Int32Array([1]))];
1772
+ }
1773
+ encode(received, ecLength) {
1774
+ const dataBytes = received.length - ecLength;
1775
+ const infoCoefficients = new Int32Array(dataBytes);
1776
+ const generator = buildGenerator(this.#field, this.#generators, ecLength);
1777
+ infoCoefficients.set(received.subarray(0, dataBytes));
1778
+ const base = new Polynomial(this.#field, infoCoefficients);
1779
+ const info = base.multiplyByMonomial(ecLength, 1);
1780
+ const [, remainder] = info.divide(generator);
1781
+ const { coefficients } = remainder;
1782
+ const numZeroCoefficients = ecLength - coefficients.length;
1783
+ const zeroCoefficientsOffset = dataBytes + numZeroCoefficients;
1784
+ received.fill(0, dataBytes, zeroCoefficientsOffset);
1785
+ received.set(coefficients, zeroCoefficientsOffset);
1786
+ }
1787
+ };
1788
+
1789
+ /**
1790
+ * @module QRCode
1791
+ * @package @nuintun/qrcode
1792
+ * @license MIT
1793
+ * @version 5.0.2
1794
+ * @author nuintun <nuintun@qq.com>
1795
+ * @description A pure JavaScript QRCode encode and decode library.
1796
+ * @see https://github.com/nuintun/qrcode#readme
1797
+ */
1798
+
1799
+
1800
+ /**
1801
+ * @module encoder
1802
+ */
1803
+ function generateECCodewords(codewords, numECCodewords) {
1804
+ const numDataCodewords = codewords.length;
1805
+ const buffer = new Int32Array(numDataCodewords + numECCodewords);
1806
+ // Copy data codewords.
1807
+ buffer.set(codewords);
1808
+ // Reed solomon encode.
1809
+ new Encoder$1().encode(buffer, numECCodewords);
1810
+ // Get ec codewords.
1811
+ return new Uint8Array(buffer.subarray(numDataCodewords));
1812
+ }
1813
+ function injectECCodewords(bits, { ecBlocks, numECCodewordsPerBlock }) {
1814
+ // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll
1815
+ // store the divided data bytes blocks and error correction bytes blocks into "blocks".
1816
+ let maxNumECCodewords = 0;
1817
+ let maxNumDataCodewords = 0;
1818
+ let dataCodewordsOffset = 0;
1819
+ // Block pair.
1820
+ const blocks = [];
1821
+ for (const { count, numDataCodewords } of ecBlocks) {
1822
+ for (let i = 0; i < count; i++) {
1823
+ const dataCodewords = new Uint8Array(numDataCodewords);
1824
+ bits.writeToUint8Array(dataCodewordsOffset * 8, dataCodewords, 0, numDataCodewords);
1825
+ const ecCodewords = generateECCodewords(dataCodewords, numECCodewordsPerBlock);
1826
+ blocks.push(new BlockPair(dataCodewords, ecCodewords));
1827
+ dataCodewordsOffset += numDataCodewords;
1828
+ maxNumECCodewords = Math.max(maxNumECCodewords, ecCodewords.length);
1829
+ maxNumDataCodewords = Math.max(maxNumDataCodewords, numDataCodewords);
1830
+ }
1831
+ }
1832
+ const codewords = new BitArray();
1833
+ // First, place data blocks.
1834
+ for (let i = 0; i < maxNumDataCodewords; i++) {
1835
+ for (const { dataCodewords } of blocks) {
1836
+ if (i < dataCodewords.length) {
1837
+ codewords.append(dataCodewords[i], 8);
1838
+ }
1839
+ }
1840
+ }
1841
+ // Then, place error correction blocks.
1842
+ for (let i = 0; i < maxNumECCodewords; i++) {
1843
+ for (const { ecCodewords } of blocks) {
1844
+ if (i < ecCodewords.length) {
1845
+ codewords.append(ecCodewords[i], 8);
1846
+ }
1847
+ }
1848
+ }
1849
+ return codewords;
1850
+ }
1851
+ function appendTerminator(bits, numDataCodewords) {
1852
+ const capacity = numDataCodewords * 8;
1853
+ // Append terminator if there is enough space (value is 0000).
1854
+ for (let i = 0; i < 4 && bits.length < capacity; i++) {
1855
+ bits.append(0);
1856
+ }
1857
+ // Append terminator. See 7.4.9 of ISO/IEC 18004:2015(E)(p.32) for details.
1858
+ // If the last byte isn't 8-bit aligned, we'll add padding bits.
1859
+ const numBitsInLastByte = bits.length & 0x07;
1860
+ if (numBitsInLastByte > 0) {
1861
+ for (let i = numBitsInLastByte; i < 8; i++) {
1862
+ bits.append(0);
1863
+ }
1864
+ }
1865
+ // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
1866
+ const numPaddingCodewords = numDataCodewords - bits.byteLength;
1867
+ for (let i = 0; i < numPaddingCodewords; i++) {
1868
+ bits.append(i & 0x01 ? 0x11 : 0xec, 8);
1869
+ }
1870
+ }
1871
+ function isByteMode(segment) {
1872
+ return segment.mode === Mode.BYTE;
1873
+ }
1874
+ function isHanziMode(segment) {
1875
+ return segment.mode === Mode.HANZI;
1876
+ }
1877
+ function appendModeInfo(bits, mode) {
1878
+ bits.append(mode.bits, 4);
1879
+ }
1880
+ function appendECI(bits, segment, currentECIValue) {
1881
+ if (isByteMode(segment)) {
1882
+ const [value] = segment.charset.values;
1883
+ if (value !== currentECIValue) {
1884
+ bits.append(Mode.ECI.bits, 4);
1885
+ // See 7.4.2.2 of ISO/IEC 18004:2015(E)(p.24) for details.
1886
+ if (value <= 127) {
1887
+ bits.append(value, 8);
1888
+ } else if (value <= 16383) {
1889
+ bits.append(0x8000 | value, 16);
1890
+ } else {
1891
+ bits.append(0xc00000 | value, 24);
1892
+ }
1893
+ return value;
1894
+ }
1895
+ }
1896
+ return currentECIValue;
1897
+ }
1898
+ function appendFNC1Info(bits, fnc1) {
1899
+ const [mode, indicator] = fnc1;
1900
+ // Append FNC1 if applicable.
1901
+ switch (mode) {
1902
+ case 'GS1':
1903
+ // GS1 formatted codes are prefixed with a FNC1 in first position mode header.
1904
+ appendModeInfo(bits, Mode.FNC1_FIRST_POSITION);
1905
+ break;
1906
+ case 'AIM':
1907
+ // AIM formatted codes are prefixed with a FNC1 in first position mode header.
1908
+ appendModeInfo(bits, Mode.FNC1_SECOND_POSITION);
1909
+ // Append AIM application indicator.
1910
+ bits.append(indicator, 8);
1911
+ break;
1912
+ }
1913
+ }
1914
+ function getSegmentLength(segment, bits) {
1915
+ // Byte segment use byte Length.
1916
+ if (isByteMode(segment)) {
1917
+ return bits.byteLength;
1918
+ }
1919
+ // Other segments use the real length of characters.
1920
+ // All rest segments content codePointAt at 0x0000 to 0xffff, so use length directly.
1921
+ return segment.content.length;
1922
+ }
1923
+ function appendLengthInfo(bits, mode, version, numLetters) {
1924
+ bits.append(numLetters, mode.getCharacterCountBits(version));
1925
+ }
1926
+ function willFit(numInputBits, version, ecLevel) {
1927
+ // In the following comments, we use numbers of Version 7-H.
1928
+ const ecBlocks = version.getECBlocks(ecLevel);
1929
+ const numInputCodewords = Math.ceil(numInputBits / 8);
1930
+ return ecBlocks.numTotalDataCodewords >= numInputCodewords;
1931
+ }
1932
+ function chooseVersion(numInputBits, ecLevel) {
1933
+ for (const version of VERSIONS) {
1934
+ if (willFit(numInputBits, version, ecLevel)) {
1935
+ return version;
1936
+ }
1937
+ }
1938
+ throw new Error('data too big for all versions');
1939
+ }
1940
+ function calculateBitsNeeded(segmentBlocks, version) {
1941
+ let bitsNeeded = 0;
1942
+ for (const { mode, head, body } of segmentBlocks) {
1943
+ bitsNeeded += head.length + mode.getCharacterCountBits(version) + body.length;
1944
+ }
1945
+ return bitsNeeded;
1946
+ }
1947
+ function chooseRecommendVersion(segmentBlocks, ecLevel) {
1948
+ // Hard part: need to know version to know how many bits length takes. But need to know how many
1949
+ // bits it takes to know version. First we take a guess at version by assuming version will be
1950
+ // the minimum, 1:
1951
+ const provisionalBitsNeeded = calculateBitsNeeded(segmentBlocks, VERSIONS[0]);
1952
+ const provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel);
1953
+ // Use that guess to calculate the right version. I am still not sure this works in 100% of cases.
1954
+ const bitsNeeded = calculateBitsNeeded(segmentBlocks, provisionalVersion);
1955
+ return chooseVersion(bitsNeeded, ecLevel);
1956
+ }
1957
+ function chooseBestMaskAndMatrix(codewords, version, ecLevel) {
1958
+ let bestMask = 0;
1959
+ let bestMatrix = buildMatrix(codewords, version, ecLevel, bestMask);
1960
+ let minPenalty = calculateMaskPenalty(bestMatrix);
1961
+ // We try all rest mask patterns to choose the best one.
1962
+ for (let mask = 1; mask < 8; mask++) {
1963
+ const matrix = buildMatrix(codewords, version, ecLevel, mask);
1964
+ const penalty = calculateMaskPenalty(matrix);
1965
+ // Lower penalty is better.
1966
+ if (penalty < minPenalty) {
1967
+ bestMask = mask;
1968
+ bestMatrix = matrix;
1969
+ minPenalty = penalty;
1970
+ }
1971
+ }
1972
+ return [bestMask, bestMatrix];
1973
+ }
1974
+
1975
+ /**
1976
+ * @module QRCode
1977
+ * @package @nuintun/qrcode
1978
+ * @license MIT
1979
+ * @version 5.0.2
1980
+ * @author nuintun <nuintun@qq.com>
1981
+ * @description A pure JavaScript QRCode encode and decode library.
1982
+ * @see https://github.com/nuintun/qrcode#readme
1983
+ */
1984
+
1985
+ /**
1986
+ * @module Dict
1987
+ * @see https://github.com/google/dart-gif-encoder
1988
+ */
1989
+ // The highest code that can be defined in the CodeBook.
1990
+ const MAX_CODE = (1 << 12) - 1;
1991
+ /**
1992
+ * A dict contains codes defined during LZW compression. It's a mapping from a string
1993
+ * of pixels to the code that represents it. The codes are stored in a trie which is
1994
+ * represented as a map. Codes may be up to 12 bits. The size of the codebook is always
1995
+ * the minimum power of 2 needed to represent all the codes and automatically increases
1996
+ * as new codes are defined.
1997
+ */
1998
+ class Dict {
1999
+ #bof;
2000
+ #eof;
2001
+ #bits;
2002
+ #depth;
2003
+ #size;
2004
+ #unused;
2005
+ #codes;
2006
+ constructor(depth) {
2007
+ const bof = 1 << depth;
2008
+ const eof = bof + 1;
2009
+ this.#bof = bof;
2010
+ this.#eof = eof;
2011
+ this.#depth = depth;
2012
+ this.reset();
2013
+ }
2014
+ get bof() {
2015
+ return this.#bof;
2016
+ }
2017
+ get eof() {
2018
+ return this.#eof;
2019
+ }
2020
+ get bits() {
2021
+ return this.#bits;
2022
+ }
2023
+ get depth() {
2024
+ return this.#depth;
2025
+ }
2026
+ reset() {
2027
+ const bits = this.#depth + 1;
2028
+ this.#bits = bits;
2029
+ this.#size = 1 << bits;
2030
+ this.#codes = new Map();
2031
+ this.#unused = this.#eof + 1;
2032
+ }
2033
+ add(code, index) {
2034
+ let unused = this.#unused;
2035
+ if (unused > MAX_CODE) {
2036
+ return false;
2037
+ }
2038
+ this.#codes.set((code << 8) | index, unused++);
2039
+ let bits = this.#bits;
2040
+ let size = this.#size;
2041
+ if (unused > size) {
2042
+ size = 1 << ++bits;
2043
+ }
2044
+ this.#bits = bits;
2045
+ this.#size = size;
2046
+ this.#unused = unused;
2047
+ return true;
2048
+ }
2049
+ get(code, index) {
2050
+ return this.#codes.get((code << 8) | index);
2051
+ }
2052
+ }
2053
+
2054
+ /**
2055
+ * @module QRCode
2056
+ * @package @nuintun/qrcode
2057
+ * @license MIT
2058
+ * @version 5.0.2
2059
+ * @author nuintun <nuintun@qq.com>
2060
+ * @description A pure JavaScript QRCode encode and decode library.
2061
+ * @see https://github.com/nuintun/qrcode#readme
2062
+ */
2063
+
2064
+ /**
2065
+ * @module DictStream
2066
+ * @see https://github.com/google/dart-gif-encoder
2067
+ */
2068
+ class DictStream {
2069
+ #bits = 0;
2070
+ #dict;
2071
+ #buffer = 0;
2072
+ #bytes = [];
2073
+ constructor(dict) {
2074
+ this.#dict = dict;
2075
+ }
2076
+ write(code) {
2077
+ let bits = this.#bits;
2078
+ let buffer = this.#buffer | (code << bits);
2079
+ bits += this.#dict.bits;
2080
+ const bytes = this.#bytes;
2081
+ while (bits >= 8) {
2082
+ bytes.push(buffer & 0xff);
2083
+ buffer >>= 8;
2084
+ bits -= 8;
2085
+ }
2086
+ this.#bits = bits;
2087
+ this.#buffer = buffer;
2088
+ }
2089
+ pipe(stream) {
2090
+ const bytes = this.#bytes;
2091
+ // Add the remaining bits. (Unused bits are set to zero.)
2092
+ if (this.#bits > 0) {
2093
+ bytes.push(this.#buffer);
2094
+ }
2095
+ stream.writeByte(this.#dict.depth);
2096
+ // Divide it up into blocks with a size in front of each block.
2097
+ const { length } = bytes;
2098
+ for (let i = 0; i < length; ) {
2099
+ const remain = length - i;
2100
+ if (remain >= 255) {
2101
+ stream.writeByte(0xff);
2102
+ stream.writeBytes(bytes, i, 255);
2103
+ i += 255;
2104
+ } else {
2105
+ stream.writeByte(remain);
2106
+ stream.writeBytes(bytes, i, remain);
2107
+ i = length;
2108
+ }
2109
+ }
2110
+ stream.writeByte(0);
2111
+ }
2112
+ }
2113
+
2114
+ /**
2115
+ * @module QRCode
2116
+ * @package @nuintun/qrcode
2117
+ * @license MIT
2118
+ * @version 5.0.2
2119
+ * @author nuintun <nuintun@qq.com>
2120
+ * @description A pure JavaScript QRCode encode and decode library.
2121
+ * @see https://github.com/nuintun/qrcode#readme
2122
+ */
2123
+
2124
+
2125
+ /**
2126
+ * @module index
2127
+ * @see https://github.com/google/dart-gif-encoder
2128
+ */
2129
+ function compress(pixels, depth, stream) {
2130
+ const dict = new Dict(depth);
2131
+ const buffer = new DictStream(dict);
2132
+ buffer.write(dict.bof);
2133
+ if (pixels.length > 0) {
2134
+ let code = pixels[0];
2135
+ const { length } = pixels;
2136
+ for (let i = 1; i < length; i++) {
2137
+ const pixelIndex = pixels[i];
2138
+ const nextCode = dict.get(code, pixelIndex);
2139
+ if (nextCode != null) {
2140
+ code = nextCode;
2141
+ } else {
2142
+ buffer.write(code);
2143
+ // Reset dict when full.
2144
+ if (!dict.add(code, pixelIndex)) {
2145
+ buffer.write(dict.bof);
2146
+ dict.reset();
2147
+ }
2148
+ code = pixelIndex;
2149
+ }
2150
+ }
2151
+ buffer.write(code);
2152
+ }
2153
+ buffer.write(dict.eof);
2154
+ buffer.pipe(stream);
2155
+ }
2156
+
2157
+ /**
2158
+ * @module QRCode
2159
+ * @package @nuintun/qrcode
2160
+ * @license MIT
2161
+ * @version 5.0.2
2162
+ * @author nuintun <nuintun@qq.com>
2163
+ * @description A pure JavaScript QRCode encode and decode library.
2164
+ * @see https://github.com/nuintun/qrcode#readme
2165
+ */
2166
+
2167
+ /**
2168
+ * @module ByteStream
2169
+ */
2170
+ class ByteStream {
2171
+ #bytes = [];
2172
+ get bytes() {
2173
+ return this.#bytes;
2174
+ }
2175
+ writeByte(value) {
2176
+ this.#bytes.push(value & 0xff);
2177
+ }
2178
+ writeInt16(value) {
2179
+ this.#bytes.push(value & 0xff, (value >> 8) & 0xff);
2180
+ }
2181
+ writeBytes(bytes, offset = 0, length = bytes.length) {
2182
+ const buffer = this.#bytes;
2183
+ for (let i = 0; i < length; i++) {
2184
+ buffer.push(bytes[offset + i] & 0xff);
2185
+ }
2186
+ }
2187
+ }
2188
+
2189
+ /**
2190
+ * @module QRCode
2191
+ * @package @nuintun/qrcode
2192
+ * @license MIT
2193
+ * @version 5.0.2
2194
+ * @author nuintun <nuintun@qq.com>
2195
+ * @description A pure JavaScript QRCode encode and decode library.
2196
+ * @see https://github.com/nuintun/qrcode#readme
2197
+ */
2198
+
2199
+
2200
+ /**
2201
+ * @module Base64Stream
2202
+ */
2203
+ const { fromCharCode } = String;
2204
+ function encode(byte) {
2205
+ byte &= 0x3f;
2206
+ if (byte >= 0) {
2207
+ if (byte < 26) {
2208
+ // A.
2209
+ return 0x41 + byte;
2210
+ } else if (byte < 52) {
2211
+ // a.
2212
+ return 0x61 + (byte - 26);
2213
+ } else if (byte < 62) {
2214
+ // 0.
2215
+ return 0x30 + (byte - 52);
2216
+ } else if (byte === 62) {
2217
+ // +.
2218
+ return 0x2b;
2219
+ } else if (byte === 63) {
2220
+ // /.
2221
+ return 0x2f;
2222
+ }
2223
+ }
2224
+ throw new Error(`illegal char: ${fromCharCode(byte)}`);
2225
+ }
2226
+ class Base64Stream {
2227
+ #bits = 0;
2228
+ #buffer = 0;
2229
+ #length = 0;
2230
+ #stream = new ByteStream();
2231
+ get bytes() {
2232
+ return this.#stream.bytes;
2233
+ }
2234
+ write(byte) {
2235
+ let bits = this.#bits + 8;
2236
+ const stream = this.#stream;
2237
+ const buffer = (this.#buffer << 8) | (byte & 0xff);
2238
+ while (bits >= 6) {
2239
+ stream.writeByte(encode(buffer >>> (bits - 6)));
2240
+ bits -= 6;
2241
+ }
2242
+ this.#length++;
2243
+ this.#bits = bits;
2244
+ this.#buffer = buffer;
2245
+ }
2246
+ close() {
2247
+ const bits = this.#bits;
2248
+ const stream = this.#stream;
2249
+ if (bits > 0) {
2250
+ stream.writeByte(encode(this.#buffer << (6 - bits)));
2251
+ this.#bits = 0;
2252
+ this.#buffer = 0;
2253
+ }
2254
+ const length = this.#length;
2255
+ if (length % 3 != 0) {
2256
+ // Padding.
2257
+ const pad = 3 - (length % 3);
2258
+ for (let i = 0; i < pad; i++) {
2259
+ // =.
2260
+ stream.writeByte(0x3d);
2261
+ }
2262
+ }
2263
+ }
2264
+ }
2265
+
2266
+ /**
2267
+ * @module QRCode
2268
+ * @package @nuintun/qrcode
2269
+ * @license MIT
2270
+ * @version 5.0.2
2271
+ * @author nuintun <nuintun@qq.com>
2272
+ * @description A pure JavaScript QRCode encode and decode library.
2273
+ * @see https://github.com/nuintun/qrcode#readme
2274
+ */
2275
+
2276
+
2277
+ /**
2278
+ * @module GIFImage
2279
+ */
2280
+ class GIFImage {
2281
+ #width;
2282
+ #height;
2283
+ #foreground;
2284
+ #background;
2285
+ #pixels = [];
2286
+ constructor(width, height, { foreground = [0x00, 0x00, 0x00], background = [0xff, 0xff, 0xff] } = {}) {
2287
+ this.#width = width;
2288
+ this.#height = height;
2289
+ this.#foreground = foreground;
2290
+ this.#background = background;
2291
+ }
2292
+ #encode() {
2293
+ const width = this.#width;
2294
+ const height = this.#height;
2295
+ const stream = new ByteStream();
2296
+ const background = this.#background;
2297
+ const foreground = this.#foreground;
2298
+ // GIF signature: GIF89a.
2299
+ stream.writeBytes([0x47, 0x49, 0x46, 0x38, 0x39, 0x61]);
2300
+ // Logical screen descriptor.
2301
+ stream.writeInt16(width);
2302
+ stream.writeInt16(height);
2303
+ stream.writeBytes([0x80, 0, 0]);
2304
+ // Global background color palette.
2305
+ stream.writeBytes([background[0], background[1], background[2]]);
2306
+ // Global foreground color palette.
2307
+ stream.writeBytes([foreground[0], foreground[1], foreground[2]]);
2308
+ // Image descriptor.
2309
+ stream.writeByte(0x2c);
2310
+ stream.writeInt16(0);
2311
+ stream.writeInt16(0);
2312
+ stream.writeInt16(width);
2313
+ stream.writeInt16(height);
2314
+ stream.writeByte(0);
2315
+ // Compress pixels to stream.
2316
+ compress(this.#pixels, 2, stream);
2317
+ // GIF terminator.
2318
+ stream.writeByte(0x3b);
2319
+ return stream.bytes;
2320
+ }
2321
+ set(x, y, color) {
2322
+ this.#pixels[y * this.#width + x] = color;
2323
+ }
2324
+ toDataURL() {
2325
+ const bytes = this.#encode();
2326
+ const stream = new Base64Stream();
2327
+ for (const byte of bytes) {
2328
+ stream.write(byte);
2329
+ }
2330
+ stream.close();
2331
+ const base64 = stream.bytes;
2332
+ let url = 'data:image/gif;base64,';
2333
+ for (const byte of base64) {
2334
+ url += fromCharCode(byte);
2335
+ }
2336
+ return url;
2337
+ }
2338
+ }
2339
+
2340
+ /**
2341
+ * @module QRCode
2342
+ * @package @nuintun/qrcode
2343
+ * @license MIT
2344
+ * @version 5.0.2
2345
+ * @author nuintun <nuintun@qq.com>
2346
+ * @description A pure JavaScript QRCode encode and decode library.
2347
+ * @see https://github.com/nuintun/qrcode#readme
2348
+ */
2349
+
2350
+
2351
+ /**
2352
+ * @module Encoded
2353
+ */
2354
+ class Encoded {
2355
+ #mask;
2356
+ #level;
2357
+ #version;
2358
+ #matrix;
2359
+ constructor(matrix, version, level, mask) {
2360
+ this.#mask = mask;
2361
+ this.#level = level;
2362
+ this.#matrix = matrix;
2363
+ this.#version = version;
2364
+ }
2365
+ /**
2366
+ * @property matrix
2367
+ * @description Get the size of qrcode.
2368
+ */
2369
+ get size() {
2370
+ return this.#matrix.size;
2371
+ }
2372
+ /**
2373
+ * @property mask
2374
+ * @description Get the mask of qrcode.
2375
+ */
2376
+ get mask() {
2377
+ return this.#mask;
2378
+ }
2379
+ /**
2380
+ * @property level
2381
+ * @description Get the error correction level of qrcode.
2382
+ */
2383
+ get level() {
2384
+ return this.#level.name;
2385
+ }
2386
+ /**
2387
+ * @property version
2388
+ * @description Get the version of qrcode.
2389
+ */
2390
+ get version() {
2391
+ return this.#version.version;
2392
+ }
2393
+ /**
2394
+ * @method get
2395
+ * @description Get the bit value of the specified coordinate of qrcode.
2396
+ */
2397
+ get(x, y) {
2398
+ const { size } = this.#matrix;
2399
+ if (x < 0 || y < 0 || x >= size || y >= size) {
2400
+ throw new Error(`illegal coordinate: [${x}, ${y}]`);
2401
+ }
2402
+ return this.#matrix.get(x, y);
2403
+ }
2404
+ /**
2405
+ * @method toDataURL
2406
+ * @param moduleSize The size of one qrcode module
2407
+ * @param options Set rest options of gif, like margin, foreground and background.
2408
+ */
2409
+ toDataURL(moduleSize = 2, { margin = moduleSize * 4, ...colors } = {}) {
2410
+ moduleSize = Math.max(1, moduleSize >> 0);
2411
+ margin = Math.max(0, margin >> 0);
2412
+ const matrix = this.#matrix;
2413
+ const matrixSize = matrix.size;
2414
+ const size = moduleSize * matrixSize + margin * 2;
2415
+ const gif = new GIFImage(size, size, colors);
2416
+ const max = size - margin;
2417
+ for (let y = 0; y < size; y++) {
2418
+ for (let x = 0; x < size; x++) {
2419
+ if (x >= margin && x < max && y >= margin && y < max) {
2420
+ const offsetX = toInt32((x - margin) / moduleSize);
2421
+ const offsetY = toInt32((y - margin) / moduleSize);
2422
+ gif.set(x, y, matrix.get(offsetX, offsetY));
2423
+ } else {
2424
+ // Margin pixels.
2425
+ gif.set(x, y, 0);
2426
+ }
2427
+ }
2428
+ }
2429
+ return gif.toDataURL();
2430
+ }
2431
+ }
2432
+
2433
+ /**
2434
+ * @module QRCode
2435
+ * @package @nuintun/qrcode
2436
+ * @license MIT
2437
+ * @version 5.0.2
2438
+ * @author nuintun <nuintun@qq.com>
2439
+ * @description A pure JavaScript QRCode encode and decode library.
2440
+ * @see https://github.com/nuintun/qrcode#readme
2441
+ */
2442
+
2443
+
2444
+ /**
2445
+ * @module asserts
2446
+ */
2447
+ function assertContent(content) {
2448
+ if (content === '') {
2449
+ throw new Error('segment content should be at least 1 character');
2450
+ }
2451
+ }
2452
+ function assertCharset(charset) {
2453
+ if (!(charset instanceof Charset)) {
2454
+ throw new Error('illegal charset');
2455
+ }
2456
+ }
2457
+ function assertHints(hints) {
2458
+ const { fnc1 } = hints;
2459
+ // FNC1.
2460
+ if (fnc1 != null) {
2461
+ const [mode] = fnc1;
2462
+ if (mode !== 'GS1' && mode !== 'AIM') {
2463
+ throw new Error('illegal fn1 hint');
2464
+ }
2465
+ if (mode === 'AIM') {
2466
+ const [, indicator] = fnc1;
2467
+ if (indicator < 0 || indicator > 0xff || !Number.isInteger(indicator)) {
2468
+ throw new Error('illegal fn1 application indicator');
2469
+ }
2470
+ }
2471
+ }
2472
+ }
2473
+ function assertLevel(level) {
2474
+ if (['L', 'M', 'Q', 'H'].indexOf(level) < 0) {
2475
+ throw new Error('illegal error correction level');
2476
+ }
2477
+ }
2478
+ function assertVersion(version) {
2479
+ if (version !== 'Auto') {
2480
+ if (version < 1 || version > 40 || !Number.isInteger(version)) {
2481
+ throw new Error('illegal version');
2482
+ }
2483
+ }
2484
+ }
2485
+
2486
+ /**
2487
+ * @module QRCode
2488
+ * @package @nuintun/qrcode
2489
+ * @license MIT
2490
+ * @version 5.0.2
2491
+ * @author nuintun <nuintun@qq.com>
2492
+ * @description A pure JavaScript QRCode encode and decode library.
2493
+ * @see https://github.com/nuintun/qrcode#readme
2494
+ */
2495
+
2496
+
2497
+ /**
2498
+ * @module Encoder
2499
+ */
2500
+ class Encoder {
2501
+ #hints;
2502
+ #level;
2503
+ #encode;
2504
+ #version;
2505
+ /**
2506
+ * @constructor
2507
+ * @param options The options of encoder.
2508
+ */
2509
+ constructor({ hints = {}, level = 'L', version = 'Auto', encode: encode$1$1 = encode$1 } = {}) {
2510
+ assertHints(hints);
2511
+ assertLevel(level);
2512
+ assertVersion(version);
2513
+ this.#hints = hints;
2514
+ this.#encode = encode$1$1;
2515
+ this.#version = version;
2516
+ this.#level = ECLevel[level];
2517
+ }
2518
+ /**
2519
+ * @method encode
2520
+ * @description Encode the segments.
2521
+ * @param segments The segments.
2522
+ */
2523
+ encode(...segments) {
2524
+ const ecLevel = this.#level;
2525
+ const encode = this.#encode;
2526
+ const { fnc1 } = this.#hints;
2527
+ const versionNumber = this.#version;
2528
+ const segmentBlocks = [];
2529
+ // Only append FNC1 once.
2530
+ let isFNC1Appended = false;
2531
+ // Current ECI value.
2532
+ let [currentECIValue] = Charset.ISO_8859_1.values;
2533
+ // Init segments.
2534
+ for (const segment of segments) {
2535
+ const { mode } = segment;
2536
+ const head = new BitArray();
2537
+ const body = segment.encode(encode);
2538
+ const length = getSegmentLength(segment, body);
2539
+ // Append ECI segment if applicable.
2540
+ currentECIValue = appendECI(head, segment, currentECIValue);
2541
+ // Append FNC1 if applicable.
2542
+ if (fnc1 != null && !isFNC1Appended) {
2543
+ isFNC1Appended = true;
2544
+ appendFNC1Info(head, fnc1);
2545
+ }
2546
+ // With ECI in place, Write the mode marker.
2547
+ appendModeInfo(head, mode);
2548
+ // If is Hanzi mode append GB2312 subset.
2549
+ if (isHanziMode(segment)) {
2550
+ head.append(1, 4);
2551
+ }
2552
+ // Push segment block.
2553
+ segmentBlocks.push({ mode, head, body, length });
2554
+ }
2555
+ let version;
2556
+ if (versionNumber === 'Auto') {
2557
+ version = chooseRecommendVersion(segmentBlocks, ecLevel);
2558
+ } else {
2559
+ version = VERSIONS[versionNumber - 1];
2560
+ const bitsNeeded = calculateBitsNeeded(segmentBlocks, version);
2561
+ if (!willFit(bitsNeeded, version, ecLevel)) {
2562
+ throw new Error('data too big for requested version');
2563
+ }
2564
+ }
2565
+ const buffer = new BitArray();
2566
+ for (const { mode, head, body, length } of segmentBlocks) {
2567
+ buffer.append(head);
2568
+ appendLengthInfo(buffer, mode, version, length);
2569
+ buffer.append(body);
2570
+ }
2571
+ const ecBlocks = version.getECBlocks(ecLevel);
2572
+ appendTerminator(buffer, ecBlocks.numTotalDataCodewords);
2573
+ const codewords = injectECCodewords(buffer, ecBlocks);
2574
+ const [mask, matrix] = chooseBestMaskAndMatrix(codewords, version, ecLevel);
2575
+ return new Encoded(matrix, version, ecLevel, mask);
2576
+ }
2577
+ }
2578
+
2579
+ /**
2580
+ * @module QRCode
2581
+ * @package @nuintun/qrcode
2582
+ * @license MIT
2583
+ * @version 5.0.2
2584
+ * @author nuintun <nuintun@qq.com>
2585
+ * @description A pure JavaScript QRCode encode and decode library.
2586
+ * @see https://github.com/nuintun/qrcode#readme
2587
+ */
2588
+
2589
+
2590
+ /**
2591
+ * @module Byte
2592
+ */
2593
+ class Byte {
2594
+ #content;
2595
+ #charset;
2596
+ /**
2597
+ * @constructor
2598
+ * @param content The content to encode.
2599
+ * @param charset The charset of the content.
2600
+ */
2601
+ constructor(content, charset = Charset.ISO_8859_1) {
2602
+ assertContent(content);
2603
+ assertCharset(charset);
2604
+ this.#content = content;
2605
+ this.#charset = charset;
2606
+ }
2607
+ /**
2608
+ * @property mode
2609
+ * @description The mode of the segment.
2610
+ */
2611
+ get mode() {
2612
+ return Mode.BYTE;
2613
+ }
2614
+ /**
2615
+ * @property content
2616
+ * @description The content of the segment.
2617
+ */
2618
+ get content() {
2619
+ return this.#content;
2620
+ }
2621
+ /**
2622
+ * @property charset
2623
+ * @description The charset of the content.
2624
+ */
2625
+ get charset() {
2626
+ return this.#charset;
2627
+ }
2628
+ /**
2629
+ * @method encode
2630
+ * @description Encode the segment.
2631
+ * @param encode The text encode function.
2632
+ */
2633
+ encode(encode) {
2634
+ const bits = new BitArray();
2635
+ const bytes = encode(this.#content, this.#charset);
2636
+ for (const byte of bytes) {
2637
+ bits.append(byte, 8);
2638
+ }
2639
+ return bits;
2640
+ }
2641
+ }
2642
+
2643
+ export { Byte as B, Encoder as E, Message as M };
2644
+ //# sourceMappingURL=p-Dv8qvK0w.js.map
2645
+
2646
+ //# sourceMappingURL=p-Dv8qvK0w.js.map