@kaanbiryol/crate-server 0.0.0-stage → 0.17.9

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 (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -2
  3. package/THIRD_PARTY_NOTICES.md +3664 -0
  4. package/assets/coordinator.mjs +116 -0
  5. package/assets/credential-revocation.mjs +18 -0
  6. package/assets/database-upgrade-rules.mjs +42 -0
  7. package/assets/migrations/README.md +19 -0
  8. package/assets/qrcode.mjs +1638 -0
  9. package/assets/schema.sql +368 -0
  10. package/assets/server-release.json +6 -0
  11. package/assets/worker-runtime.json +12 -0
  12. package/assets/worker.mjs +1458 -0
  13. package/npm-shrinkwrap.json +939 -0
  14. package/package.json +38 -4
  15. package/scripts/assets.mjs +33 -0
  16. package/scripts/commands/data.mjs +80 -0
  17. package/scripts/commands/devices.mjs +100 -0
  18. package/scripts/commands/doctor.mjs +127 -0
  19. package/scripts/commands/service.mjs +19 -0
  20. package/scripts/commands/setup.mjs +194 -0
  21. package/scripts/commands/start.mjs +171 -0
  22. package/scripts/commands/status.mjs +49 -0
  23. package/scripts/commands/update.mjs +138 -0
  24. package/scripts/crate-server.mjs +11 -0
  25. package/scripts/deployment-fingerprint.mjs +13 -0
  26. package/scripts/local-server-alerts.mjs +53 -0
  27. package/scripts/local-server-backup-schedule.mjs +153 -0
  28. package/scripts/local-server-backup.mjs +275 -0
  29. package/scripts/local-server-cloudflared.mjs +93 -0
  30. package/scripts/local-server-control.mjs +150 -0
  31. package/scripts/local-server-devices.mjs +71 -0
  32. package/scripts/local-server-host-status.mjs +72 -0
  33. package/scripts/local-server-http.mjs +120 -0
  34. package/scripts/local-server-install.mjs +22 -0
  35. package/scripts/local-server-lifecycle.mjs +54 -0
  36. package/scripts/local-server-lock.mjs +217 -0
  37. package/scripts/local-server-migrations.mjs +43 -0
  38. package/scripts/local-server-options.mjs +134 -0
  39. package/scripts/local-server-pairing.mjs +47 -0
  40. package/scripts/local-server-process.mjs +77 -0
  41. package/scripts/local-server-qr.mjs +34 -0
  42. package/scripts/local-server-quick.mjs +116 -0
  43. package/scripts/local-server-readiness.mjs +48 -0
  44. package/scripts/local-server-runtime.mjs +460 -0
  45. package/scripts/local-server-service.mjs +209 -0
  46. package/scripts/local-server-style.mjs +12 -0
  47. package/scripts/local-server-tailscale.mjs +122 -0
  48. package/scripts/local-server-tunnel.mjs +212 -0
  49. package/scripts/local-server-watchdog.mjs +37 -0
  50. package/scripts/local-server-wizard.mjs +100 -0
  51. package/scripts/local-server.mjs +100 -0
  52. package/vendor/miniflare/LICENSE +25 -0
  53. package/vendor/miniflare/dist/local-explorer-ui/assets/ArrowClockwise.es-Cs0EHtoR.js +1 -0
  54. package/vendor/miniflare/dist/local-explorer-ui/assets/Breadcrumbs-BlzUUgNz.js +1 -0
  55. package/vendor/miniflare/dist/local-explorer-ui/assets/CaretDown.es-r8EMGhHM.js +1 -0
  56. package/vendor/miniflare/dist/local-explorer-ui/assets/CaretLeft.es-CCxvlwgr.js +1 -0
  57. package/vendor/miniflare/dist/local-explorer-ui/assets/CaretRight.es-CWeeOO8C.js +1 -0
  58. package/vendor/miniflare/dist/local-explorer-ui/assets/CaretUpDown.es-Bp73BWZN.js +1 -0
  59. package/vendor/miniflare/dist/local-explorer-ui/assets/Check.es-B3dV_aVM.js +1 -0
  60. package/vendor/miniflare/dist/local-explorer-ui/assets/Copy.es-DUyM7PbX.js +1 -0
  61. package/vendor/miniflare/dist/local-explorer-ui/assets/CopyButton-DdMFsAgv.js +1 -0
  62. package/vendor/miniflare/dist/local-explorer-ui/assets/CronTriggersContext-CtoQyHCH.js +1 -0
  63. package/vendor/miniflare/dist/local-explorer-ui/assets/CronTriggersPage-BC2FvZf5.js +1 -0
  64. package/vendor/miniflare/dist/local-explorer-ui/assets/DotsThree.es-B9u_qIrH.js +1 -0
  65. package/vendor/miniflare/dist/local-explorer-ui/assets/Download.es-v8YTKdZh.js +1 -0
  66. package/vendor/miniflare/dist/local-explorer-ui/assets/List.es-GlowdvL8.js +1 -0
  67. package/vendor/miniflare/dist/local-explorer-ui/assets/ListBullets.es-DrJsrtCL.js +1 -0
  68. package/vendor/miniflare/dist/local-explorer-ui/assets/MagnifyingGlass.es-BzOo3pru.js +1 -0
  69. package/vendor/miniflare/dist/local-explorer-ui/assets/PaperPlaneTilt.es-DTLdWOnM.js +1 -0
  70. package/vendor/miniflare/dist/local-explorer-ui/assets/Paperclip.es-6Ysj3lly.js +1 -0
  71. package/vendor/miniflare/dist/local-explorer-ui/assets/Pencil.es-CDpuGAys.js +1 -0
  72. package/vendor/miniflare/dist/local-explorer-ui/assets/Plus.es-xOjOjCs5.js +1 -0
  73. package/vendor/miniflare/dist/local-explorer-ui/assets/ResourceError-DNadec0F.js +1 -0
  74. package/vendor/miniflare/dist/local-explorer-ui/assets/Spinner.es-oqUPe-aY.js +1 -0
  75. package/vendor/miniflare/dist/local-explorer-ui/assets/TableSelect-DgjN53ZF.js +25 -0
  76. package/vendor/miniflare/dist/local-explorer-ui/assets/Trash.es-DTqwcb2_.js +1 -0
  77. package/vendor/miniflare/dist/local-explorer-ui/assets/Warning.es-CLa-n7LD.js +1 -0
  78. package/vendor/miniflare/dist/local-explorer-ui/assets/X.es-BiJFnG31.js +1 -0
  79. package/vendor/miniflare/dist/local-explorer-ui/assets/_appId-Cow8QNw6.js +1 -0
  80. package/vendor/miniflare/dist/local-explorer-ui/assets/_appId-TnuOHwOA.js +5 -0
  81. package/vendor/miniflare/dist/local-explorer-ui/assets/_bucketName-Cow8QNw6.js +1 -0
  82. package/vendor/miniflare/dist/local-explorer-ui/assets/_bucketName-DMGTgdaZ.js +1 -0
  83. package/vendor/miniflare/dist/local-explorer-ui/assets/_bucketName-Daanvg3W.js +1 -0
  84. package/vendor/miniflare/dist/local-explorer-ui/assets/_bucketName-DqCj-aYZ.js +1 -0
  85. package/vendor/miniflare/dist/local-explorer-ui/assets/_bucketName-uYCS7veQ.js +1 -0
  86. package/vendor/miniflare/dist/local-explorer-ui/assets/_captureId-Cb6ggQGG.js +1 -0
  87. package/vendor/miniflare/dist/local-explorer-ui/assets/_captureId-Cow8QNw6.js +1 -0
  88. package/vendor/miniflare/dist/local-explorer-ui/assets/_captureId-Daanvg3W.js +1 -0
  89. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-BW1__nAw.js +1 -0
  90. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-Cow8QNw6.js +1 -0
  91. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-DCj9M_Uf.js +1 -0
  92. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-DMGTgdaZ.js +1 -0
  93. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-Daanvg3W.js +1 -0
  94. package/vendor/miniflare/dist/local-explorer-ui/assets/_className-uYCS7veQ.js +1 -0
  95. package/vendor/miniflare/dist/local-explorer-ui/assets/_databaseId-BEh2sOY5.js +1 -0
  96. package/vendor/miniflare/dist/local-explorer-ui/assets/_databaseId-Cow8QNw6.js +1 -0
  97. package/vendor/miniflare/dist/local-explorer-ui/assets/_instanceId-Cow8QNw6.js +1 -0
  98. package/vendor/miniflare/dist/local-explorer-ui/assets/_instanceId-CxJm9jpK.js +1 -0
  99. package/vendor/miniflare/dist/local-explorer-ui/assets/_instanceId-Daanvg3W.js +1 -0
  100. package/vendor/miniflare/dist/local-explorer-ui/assets/_namespaceId-Cow8QNw6.js +1 -0
  101. package/vendor/miniflare/dist/local-explorer-ui/assets/_namespaceId-HT9g0tMq.js +1 -0
  102. package/vendor/miniflare/dist/local-explorer-ui/assets/_objectId-Cow8QNw6.js +1 -0
  103. package/vendor/miniflare/dist/local-explorer-ui/assets/_objectId-Daanvg3W.js +1 -0
  104. package/vendor/miniflare/dist/local-explorer-ui/assets/_objectId-DdmD-NV1.js +1 -0
  105. package/vendor/miniflare/dist/local-explorer-ui/assets/_workflowName-Cow8QNw6.js +1 -0
  106. package/vendor/miniflare/dist/local-explorer-ui/assets/_workflowName-DMGTgdaZ.js +1 -0
  107. package/vendor/miniflare/dist/local-explorer-ui/assets/_workflowName-Daanvg3W.js +1 -0
  108. package/vendor/miniflare/dist/local-explorer-ui/assets/_workflowName-WgIBBs_w.js +1 -0
  109. package/vendor/miniflare/dist/local-explorer-ui/assets/_workflowName-uYCS7veQ.js +1 -0
  110. package/vendor/miniflare/dist/local-explorer-ui/assets/ad-hoc-B9HL0oNk.js +1 -0
  111. package/vendor/miniflare/dist/local-explorer-ui/assets/async-t2_zA-v_.js +1 -0
  112. package/vendor/miniflare/dist/local-explorer-ui/assets/button-cdxnqcgzwko8ooha-CjoTKpgy.js +1 -0
  113. package/vendor/miniflare/dist/local-explorer-ui/assets/checkbox-kt1uojk2f9e0d0h1-D923QL-G.js +1 -0
  114. package/vendor/miniflare/dist/local-explorer-ui/assets/clipboard-text-vcbvmtne4zjk4b18-CEoJIuMe.js +1 -0
  115. package/vendor/miniflare/dist/local-explorer-ui/assets/configured-BGeRrlYf.js +1 -0
  116. package/vendor/miniflare/dist/local-explorer-ui/assets/cron-triggers-ZP5ClwAa.js +1 -0
  117. package/vendor/miniflare/dist/local-explorer-ui/assets/dialog-oqh8l3l3zutpibxx-nho54TMC.js +1 -0
  118. package/vendor/miniflare/dist/local-explorer-ui/assets/dropdown-ncwhcd912vmone8k-BAT0p_ep.js +1 -0
  119. package/vendor/miniflare/dist/local-explorer-ui/assets/email-B-IveBKB.js +1 -0
  120. package/vendor/miniflare/dist/local-explorer-ui/assets/events-ClnoiyGH.js +1 -0
  121. package/vendor/miniflare/dist/local-explorer-ui/assets/events-Cow8QNw6.js +1 -0
  122. package/vendor/miniflare/dist/local-explorer-ui/assets/field-krp6z6vfbkrvufz2-DsLUBjzS.js +1 -0
  123. package/vendor/miniflare/dist/local-explorer-ui/assets/format-CjQ0gyEW.js +1 -0
  124. package/vendor/miniflare/dist/local-explorer-ui/assets/helpers-Bz2sloWm.js +1 -0
  125. package/vendor/miniflare/dist/local-explorer-ui/assets/index-BHW_FKpE.js +30 -0
  126. package/vendor/miniflare/dist/local-explorer-ui/assets/index-CiXL10aq.css +2 -0
  127. package/vendor/miniflare/dist/local-explorer-ui/assets/input-area-no30c09udyjxshu5-T786oEMj.js +1 -0
  128. package/vendor/miniflare/dist/local-explorer-ui/assets/input-group-lxdd09p60cf27pe1-BqVz8A4J.js +1 -0
  129. package/vendor/miniflare/dist/local-explorer-ui/assets/input-h48k3uagzrgb98au-BF-hE08e.js +1 -0
  130. package/vendor/miniflare/dist/local-explorer-ui/assets/label-latndvb1ngem7we8-mWoel0Kk.js +1 -0
  131. package/vendor/miniflare/dist/local-explorer-ui/assets/link-DadJAPnd.js +1 -0
  132. package/vendor/miniflare/dist/local-explorer-ui/assets/link-provider-mn2voeohon7cj9o4-CNosc_Ni.js +13 -0
  133. package/vendor/miniflare/dist/local-explorer-ui/assets/matchContext-C1eKDtty.js +1 -0
  134. package/vendor/miniflare/dist/local-explorer-ui/assets/object._-Cow8QNw6.js +1 -0
  135. package/vendor/miniflare/dist/local-explorer-ui/assets/object._-DDwO6NT7.js +1 -0
  136. package/vendor/miniflare/dist/local-explorer-ui/assets/object._-Daanvg3W.js +1 -0
  137. package/vendor/miniflare/dist/local-explorer-ui/assets/observability-CC1mP6Xo.js +15 -0
  138. package/vendor/miniflare/dist/local-explorer-ui/assets/observability-CX-6-j6d.js +1 -0
  139. package/vendor/miniflare/dist/local-explorer-ui/assets/observability-Cow8QNw6.js +1 -0
  140. package/vendor/miniflare/dist/local-explorer-ui/assets/react-BZY8YNV6.js +1 -0
  141. package/vendor/miniflare/dist/local-explorer-ui/assets/redirect-CckYXsV1.js +1 -0
  142. package/vendor/miniflare/dist/local-explorer-ui/assets/routes-BlOyav-b.js +1 -0
  143. package/vendor/miniflare/dist/local-explorer-ui/assets/routing-CVthjHxr.js +2 -0
  144. package/vendor/miniflare/dist/local-explorer-ui/assets/routing-Cow8QNw6.js +1 -0
  145. package/vendor/miniflare/dist/local-explorer-ui/assets/routing-DMGTgdaZ.js +1 -0
  146. package/vendor/miniflare/dist/local-explorer-ui/assets/routing-uYCS7veQ.js +1 -0
  147. package/vendor/miniflare/dist/local-explorer-ui/assets/select-kva5ru5f673kah1m-DQuxH2_G.js +1 -0
  148. package/vendor/miniflare/dist/local-explorer-ui/assets/sending-BPjb3S3Y.js +1 -0
  149. package/vendor/miniflare/dist/local-explorer-ui/assets/sending-Cow8QNw6.js +1 -0
  150. package/vendor/miniflare/dist/local-explorer-ui/assets/switch-ihaydbzem62bey4p-C9M-MPNS.js +1 -0
  151. package/vendor/miniflare/dist/local-explorer-ui/assets/table-inweecadl3her7pd-UWLv9e8D.js +1 -0
  152. package/vendor/miniflare/dist/local-explorer-ui/assets/text-nmyi1rkwdj37f30f-BLzIhmEO.js +1 -0
  153. package/vendor/miniflare/dist/local-explorer-ui/assets/types-DTx0hLYz.js +1 -0
  154. package/vendor/miniflare/dist/local-explorer-ui/assets/useCursorPaginatedList-BGUINn38.js +1 -0
  155. package/vendor/miniflare/dist/local-explorer-ui/assets/useRouterState-BLq6Ai_6.js +1 -0
  156. package/vendor/miniflare/dist/local-explorer-ui/favicon.svg +3 -0
  157. package/vendor/miniflare/dist/local-explorer-ui/index.html +27 -0
  158. package/vendor/miniflare/dist/src/index.d.ts +14183 -0
  159. package/vendor/miniflare/dist/src/index.js +123738 -0
  160. package/vendor/miniflare/dist/src/mdream_edge_bg.wasm +0 -0
  161. package/vendor/miniflare/dist/src/plugins/artifacts/git-sidecar.js +21071 -0
  162. package/vendor/miniflare/dist/src/workers/access/access-identity.worker.js +10 -0
  163. package/vendor/miniflare/dist/src/workers/analytics-engine/analytics-engine.worker.js +21 -0
  164. package/vendor/miniflare/dist/src/workers/analytics-engine/remote.worker.js +2578 -0
  165. package/vendor/miniflare/dist/src/workers/artifacts/binding.worker.js +903 -0
  166. package/vendor/miniflare/dist/src/workers/artifacts/wrapped-binding.worker.js +52 -0
  167. package/vendor/miniflare/dist/src/workers/assets/assets-kv.worker.js +27 -0
  168. package/vendor/miniflare/dist/src/workers/assets/assets.worker.js +1525 -0
  169. package/vendor/miniflare/dist/src/workers/assets/router.worker.js +1883 -0
  170. package/vendor/miniflare/dist/src/workers/assets/rpc-proxy.worker.js +55 -0
  171. package/vendor/miniflare/dist/src/workers/browser-rendering/binding.worker.js +453 -0
  172. package/vendor/miniflare/dist/src/workers/cache/cache-entry-noop.worker.js +18 -0
  173. package/vendor/miniflare/dist/src/workers/cache/cache-entry.worker.js +24 -0
  174. package/vendor/miniflare/dist/src/workers/cache/cache.worker.js +652 -0
  175. package/vendor/miniflare/dist/src/workers/core/dev-control.worker.js +52 -0
  176. package/vendor/miniflare/dist/src/workers/core/dev-registry-proxy.worker.js +371 -0
  177. package/vendor/miniflare/dist/src/workers/core/do-wrapper.worker.js +67 -0
  178. package/vendor/miniflare/dist/src/workers/core/entry.worker.js +5516 -0
  179. package/vendor/miniflare/dist/src/workers/core/outbound.worker.js +147 -0
  180. package/vendor/miniflare/dist/src/workers/d1/database.worker.js +298 -0
  181. package/vendor/miniflare/dist/src/workers/d1/entry.worker.js +143 -0
  182. package/vendor/miniflare/dist/src/workers/dispatch-namespace/dispatch-namespace-proxy.worker.js +2574 -0
  183. package/vendor/miniflare/dist/src/workers/dispatch-namespace/dispatch-namespace.worker.js +11 -0
  184. package/vendor/miniflare/dist/src/workers/email/email-store.worker.js +606 -0
  185. package/vendor/miniflare/dist/src/workers/email/email.worker.js +26 -0
  186. package/vendor/miniflare/dist/src/workers/email/send_email.worker.js +3703 -0
  187. package/vendor/miniflare/dist/src/workers/flagship/binding.worker.js +394 -0
  188. package/vendor/miniflare/dist/src/workers/flagship/object.worker.js +349 -0
  189. package/vendor/miniflare/dist/src/workers/hello-world/binding.worker.js +18 -0
  190. package/vendor/miniflare/dist/src/workers/hello-world/object.worker.js +13 -0
  191. package/vendor/miniflare/dist/src/workers/images/images.worker.js +450 -0
  192. package/vendor/miniflare/dist/src/workers/k2/binding.worker.js +2583 -0
  193. package/vendor/miniflare/dist/src/workers/kv/namespace.worker.js +323 -0
  194. package/vendor/miniflare/dist/src/workers/kv/sites.worker.js +148 -0
  195. package/vendor/miniflare/dist/src/workers/local-explorer/explorer.worker.js +17275 -0
  196. package/vendor/miniflare/dist/src/workers/observability/collector.worker.js +725 -0
  197. package/vendor/miniflare/dist/src/workers/pipelines/pipeline.worker.js +9 -0
  198. package/vendor/miniflare/dist/src/workers/queues/broker.worker.js +391 -0
  199. package/vendor/miniflare/dist/src/workers/r2/bucket.worker.js +1171 -0
  200. package/vendor/miniflare/dist/src/workers/r2/public.worker.js +1319 -0
  201. package/vendor/miniflare/dist/src/workers/r2/s3/index.worker.js +11128 -0
  202. package/vendor/miniflare/dist/src/workers/ratelimit/ratelimit-object.worker.js +55 -0
  203. package/vendor/miniflare/dist/src/workers/ratelimit/ratelimit.worker.js +69 -0
  204. package/vendor/miniflare/dist/src/workers/secrets-store/secret.worker.js +64 -0
  205. package/vendor/miniflare/dist/src/workers/shared/index.worker.js +730 -0
  206. package/vendor/miniflare/dist/src/workers/shared/object-entry.worker.js +33 -0
  207. package/vendor/miniflare/dist/src/workers/shared/remote-proxy-client.worker.js +2698 -0
  208. package/vendor/miniflare/dist/src/workers/shared/zod.worker.js +15459 -0
  209. package/vendor/miniflare/dist/src/workers/stream/binding.worker.js +282 -0
  210. package/vendor/miniflare/dist/src/workers/stream/object.worker.js +479 -0
  211. package/vendor/miniflare/dist/src/workers/workflows/binding.worker.js +5137 -0
  212. package/vendor/miniflare/dist/src/workers/workflows/wrapped-binding.worker.js +111 -0
  213. package/vendor/miniflare/package.json +135 -0
@@ -0,0 +1,1638 @@
1
+ // node_modules/qrcode-generator/dist/qrcode.mjs
2
+ var qrcode = function(typeNumber, errorCorrectionLevel) {
3
+ const PAD0 = 236;
4
+ const PAD1 = 17;
5
+ let _typeNumber = typeNumber;
6
+ const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
7
+ let _modules = null;
8
+ let _moduleCount = 0;
9
+ let _dataCache = null;
10
+ const _dataList = [];
11
+ const _this = {};
12
+ const makeImpl = function(test, maskPattern) {
13
+ _moduleCount = _typeNumber * 4 + 17;
14
+ _modules = (function(moduleCount) {
15
+ const modules = new Array(moduleCount);
16
+ for (let row = 0; row < moduleCount; row += 1) {
17
+ modules[row] = new Array(moduleCount);
18
+ for (let col = 0; col < moduleCount; col += 1) {
19
+ modules[row][col] = null;
20
+ }
21
+ }
22
+ return modules;
23
+ })(_moduleCount);
24
+ setupPositionProbePattern(0, 0);
25
+ setupPositionProbePattern(_moduleCount - 7, 0);
26
+ setupPositionProbePattern(0, _moduleCount - 7);
27
+ setupPositionAdjustPattern();
28
+ setupTimingPattern();
29
+ setupTypeInfo(test, maskPattern);
30
+ if (_typeNumber >= 7) {
31
+ setupTypeNumber(test);
32
+ }
33
+ if (_dataCache == null) {
34
+ _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
35
+ }
36
+ mapData(_dataCache, maskPattern);
37
+ };
38
+ const setupPositionProbePattern = function(row, col) {
39
+ for (let r = -1; r <= 7; r += 1) {
40
+ if (row + r <= -1 || _moduleCount <= row + r) continue;
41
+ for (let c = -1; c <= 7; c += 1) {
42
+ if (col + c <= -1 || _moduleCount <= col + c) continue;
43
+ if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
44
+ _modules[row + r][col + c] = true;
45
+ } else {
46
+ _modules[row + r][col + c] = false;
47
+ }
48
+ }
49
+ }
50
+ };
51
+ const getBestMaskPattern = function() {
52
+ let minLostPoint = 0;
53
+ let pattern = 0;
54
+ for (let i = 0; i < 8; i += 1) {
55
+ makeImpl(true, i);
56
+ const lostPoint = QRUtil.getLostPoint(_this);
57
+ if (i == 0 || minLostPoint > lostPoint) {
58
+ minLostPoint = lostPoint;
59
+ pattern = i;
60
+ }
61
+ }
62
+ return pattern;
63
+ };
64
+ const setupTimingPattern = function() {
65
+ for (let r = 8; r < _moduleCount - 8; r += 1) {
66
+ if (_modules[r][6] != null) {
67
+ continue;
68
+ }
69
+ _modules[r][6] = r % 2 == 0;
70
+ }
71
+ for (let c = 8; c < _moduleCount - 8; c += 1) {
72
+ if (_modules[6][c] != null) {
73
+ continue;
74
+ }
75
+ _modules[6][c] = c % 2 == 0;
76
+ }
77
+ };
78
+ const setupPositionAdjustPattern = function() {
79
+ const pos = QRUtil.getPatternPosition(_typeNumber);
80
+ for (let i = 0; i < pos.length; i += 1) {
81
+ for (let j = 0; j < pos.length; j += 1) {
82
+ const row = pos[i];
83
+ const col = pos[j];
84
+ if (_modules[row][col] != null) {
85
+ continue;
86
+ }
87
+ for (let r = -2; r <= 2; r += 1) {
88
+ for (let c = -2; c <= 2; c += 1) {
89
+ if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
90
+ _modules[row + r][col + c] = true;
91
+ } else {
92
+ _modules[row + r][col + c] = false;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ };
99
+ const setupTypeNumber = function(test) {
100
+ const bits = QRUtil.getBCHTypeNumber(_typeNumber);
101
+ for (let i = 0; i < 18; i += 1) {
102
+ const mod = !test && (bits >> i & 1) == 1;
103
+ _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
104
+ }
105
+ for (let i = 0; i < 18; i += 1) {
106
+ const mod = !test && (bits >> i & 1) == 1;
107
+ _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
108
+ }
109
+ };
110
+ const setupTypeInfo = function(test, maskPattern) {
111
+ const data = _errorCorrectionLevel << 3 | maskPattern;
112
+ const bits = QRUtil.getBCHTypeInfo(data);
113
+ for (let i = 0; i < 15; i += 1) {
114
+ const mod = !test && (bits >> i & 1) == 1;
115
+ if (i < 6) {
116
+ _modules[i][8] = mod;
117
+ } else if (i < 8) {
118
+ _modules[i + 1][8] = mod;
119
+ } else {
120
+ _modules[_moduleCount - 15 + i][8] = mod;
121
+ }
122
+ }
123
+ for (let i = 0; i < 15; i += 1) {
124
+ const mod = !test && (bits >> i & 1) == 1;
125
+ if (i < 8) {
126
+ _modules[8][_moduleCount - i - 1] = mod;
127
+ } else if (i < 9) {
128
+ _modules[8][15 - i - 1 + 1] = mod;
129
+ } else {
130
+ _modules[8][15 - i - 1] = mod;
131
+ }
132
+ }
133
+ _modules[_moduleCount - 8][8] = !test;
134
+ };
135
+ const mapData = function(data, maskPattern) {
136
+ let inc = -1;
137
+ let row = _moduleCount - 1;
138
+ let bitIndex = 7;
139
+ let byteIndex = 0;
140
+ const maskFunc = QRUtil.getMaskFunction(maskPattern);
141
+ for (let col = _moduleCount - 1; col > 0; col -= 2) {
142
+ if (col == 6) col -= 1;
143
+ while (true) {
144
+ for (let c = 0; c < 2; c += 1) {
145
+ if (_modules[row][col - c] == null) {
146
+ let dark = false;
147
+ if (byteIndex < data.length) {
148
+ dark = (data[byteIndex] >>> bitIndex & 1) == 1;
149
+ }
150
+ const mask = maskFunc(row, col - c);
151
+ if (mask) {
152
+ dark = !dark;
153
+ }
154
+ _modules[row][col - c] = dark;
155
+ bitIndex -= 1;
156
+ if (bitIndex == -1) {
157
+ byteIndex += 1;
158
+ bitIndex = 7;
159
+ }
160
+ }
161
+ }
162
+ row += inc;
163
+ if (row < 0 || _moduleCount <= row) {
164
+ row -= inc;
165
+ inc = -inc;
166
+ break;
167
+ }
168
+ }
169
+ }
170
+ };
171
+ const createBytes = function(buffer, rsBlocks) {
172
+ let offset = 0;
173
+ let maxDcCount = 0;
174
+ let maxEcCount = 0;
175
+ const dcdata = new Array(rsBlocks.length);
176
+ const ecdata = new Array(rsBlocks.length);
177
+ for (let r = 0; r < rsBlocks.length; r += 1) {
178
+ const dcCount = rsBlocks[r].dataCount;
179
+ const ecCount = rsBlocks[r].totalCount - dcCount;
180
+ maxDcCount = Math.max(maxDcCount, dcCount);
181
+ maxEcCount = Math.max(maxEcCount, ecCount);
182
+ dcdata[r] = new Array(dcCount);
183
+ for (let i = 0; i < dcdata[r].length; i += 1) {
184
+ dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
185
+ }
186
+ offset += dcCount;
187
+ const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
188
+ const rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
189
+ const modPoly = rawPoly.mod(rsPoly);
190
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
191
+ for (let i = 0; i < ecdata[r].length; i += 1) {
192
+ const modIndex = i + modPoly.getLength() - ecdata[r].length;
193
+ ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
194
+ }
195
+ }
196
+ let totalCodeCount = 0;
197
+ for (let i = 0; i < rsBlocks.length; i += 1) {
198
+ totalCodeCount += rsBlocks[i].totalCount;
199
+ }
200
+ const data = new Array(totalCodeCount);
201
+ let index = 0;
202
+ for (let i = 0; i < maxDcCount; i += 1) {
203
+ for (let r = 0; r < rsBlocks.length; r += 1) {
204
+ if (i < dcdata[r].length) {
205
+ data[index] = dcdata[r][i];
206
+ index += 1;
207
+ }
208
+ }
209
+ }
210
+ for (let i = 0; i < maxEcCount; i += 1) {
211
+ for (let r = 0; r < rsBlocks.length; r += 1) {
212
+ if (i < ecdata[r].length) {
213
+ data[index] = ecdata[r][i];
214
+ index += 1;
215
+ }
216
+ }
217
+ }
218
+ return data;
219
+ };
220
+ const createData = function(typeNumber2, errorCorrectionLevel2, dataList) {
221
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
222
+ const buffer = qrBitBuffer();
223
+ for (let i = 0; i < dataList.length; i += 1) {
224
+ const data = dataList[i];
225
+ buffer.put(data.getMode(), 4);
226
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
227
+ data.write(buffer);
228
+ }
229
+ let totalDataCount = 0;
230
+ for (let i = 0; i < rsBlocks.length; i += 1) {
231
+ totalDataCount += rsBlocks[i].dataCount;
232
+ }
233
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
234
+ throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
235
+ }
236
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
237
+ buffer.put(0, 4);
238
+ }
239
+ while (buffer.getLengthInBits() % 8 != 0) {
240
+ buffer.putBit(false);
241
+ }
242
+ while (true) {
243
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
244
+ break;
245
+ }
246
+ buffer.put(PAD0, 8);
247
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
248
+ break;
249
+ }
250
+ buffer.put(PAD1, 8);
251
+ }
252
+ return createBytes(buffer, rsBlocks);
253
+ };
254
+ _this.addData = function(data, mode) {
255
+ mode = mode || "Byte";
256
+ let newData = null;
257
+ switch (mode) {
258
+ case "Numeric":
259
+ newData = qrNumber(data);
260
+ break;
261
+ case "Alphanumeric":
262
+ newData = qrAlphaNum(data);
263
+ break;
264
+ case "Byte":
265
+ newData = qr8BitByte(data);
266
+ break;
267
+ case "Kanji":
268
+ newData = qrKanji(data);
269
+ break;
270
+ default:
271
+ throw "mode:" + mode;
272
+ }
273
+ _dataList.push(newData);
274
+ _dataCache = null;
275
+ };
276
+ _this.isDark = function(row, col) {
277
+ if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
278
+ throw row + "," + col;
279
+ }
280
+ return _modules[row][col];
281
+ };
282
+ _this.getModuleCount = function() {
283
+ return _moduleCount;
284
+ };
285
+ _this.make = function() {
286
+ if (_typeNumber < 1) {
287
+ let typeNumber2 = 1;
288
+ for (; typeNumber2 < 40; typeNumber2++) {
289
+ const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
290
+ const buffer = qrBitBuffer();
291
+ for (let i = 0; i < _dataList.length; i++) {
292
+ const data = _dataList[i];
293
+ buffer.put(data.getMode(), 4);
294
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
295
+ data.write(buffer);
296
+ }
297
+ let totalDataCount = 0;
298
+ for (let i = 0; i < rsBlocks.length; i++) {
299
+ totalDataCount += rsBlocks[i].dataCount;
300
+ }
301
+ if (buffer.getLengthInBits() <= totalDataCount * 8) {
302
+ break;
303
+ }
304
+ }
305
+ _typeNumber = typeNumber2;
306
+ }
307
+ makeImpl(false, getBestMaskPattern());
308
+ };
309
+ _this.createTableTag = function(cellSize, margin) {
310
+ cellSize = cellSize || 2;
311
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
312
+ let qrHtml = "";
313
+ qrHtml += '<table style="';
314
+ qrHtml += " border-width: 0px; border-style: none;";
315
+ qrHtml += " border-collapse: collapse;";
316
+ qrHtml += " padding: 0px; margin: " + margin + "px;";
317
+ qrHtml += '">';
318
+ qrHtml += "<tbody>";
319
+ for (let r = 0; r < _this.getModuleCount(); r += 1) {
320
+ qrHtml += "<tr>";
321
+ for (let c = 0; c < _this.getModuleCount(); c += 1) {
322
+ qrHtml += '<td style="';
323
+ qrHtml += " border-width: 0px; border-style: none;";
324
+ qrHtml += " border-collapse: collapse;";
325
+ qrHtml += " padding: 0px; margin: 0px;";
326
+ qrHtml += " width: " + cellSize + "px;";
327
+ qrHtml += " height: " + cellSize + "px;";
328
+ qrHtml += " background-color: ";
329
+ qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
330
+ qrHtml += ";";
331
+ qrHtml += '"/>';
332
+ }
333
+ qrHtml += "</tr>";
334
+ }
335
+ qrHtml += "</tbody>";
336
+ qrHtml += "</table>";
337
+ return qrHtml;
338
+ };
339
+ _this.createSvgTag = function(cellSize, margin, alt, title) {
340
+ let opts = {};
341
+ if (typeof arguments[0] == "object") {
342
+ opts = arguments[0];
343
+ cellSize = opts.cellSize;
344
+ margin = opts.margin;
345
+ alt = opts.alt;
346
+ title = opts.title;
347
+ }
348
+ cellSize = cellSize || 2;
349
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
350
+ alt = typeof alt === "string" ? { text: alt } : alt || {};
351
+ alt.text = alt.text || null;
352
+ alt.id = alt.text ? alt.id || "qrcode-description" : null;
353
+ title = typeof title === "string" ? { text: title } : title || {};
354
+ title.text = title.text || null;
355
+ title.id = title.text ? title.id || "qrcode-title" : null;
356
+ const size = _this.getModuleCount() * cellSize + margin * 2;
357
+ let c, mc, r, mr, qrSvg = "", rect;
358
+ rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
359
+ qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
360
+ qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
361
+ qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
362
+ qrSvg += ' preserveAspectRatio="xMinYMin meet"';
363
+ qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
364
+ qrSvg += ">";
365
+ qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
366
+ qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
367
+ qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
368
+ qrSvg += '<path d="';
369
+ for (r = 0; r < _this.getModuleCount(); r += 1) {
370
+ mr = r * cellSize + margin;
371
+ for (c = 0; c < _this.getModuleCount(); c += 1) {
372
+ if (_this.isDark(r, c)) {
373
+ mc = c * cellSize + margin;
374
+ qrSvg += "M" + mc + "," + mr + rect;
375
+ }
376
+ }
377
+ }
378
+ qrSvg += '" stroke="transparent" fill="black"/>';
379
+ qrSvg += "</svg>";
380
+ return qrSvg;
381
+ };
382
+ _this.createDataURL = function(cellSize, margin) {
383
+ cellSize = cellSize || 2;
384
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
385
+ const size = _this.getModuleCount() * cellSize + margin * 2;
386
+ const min = margin;
387
+ const max = size - margin;
388
+ return createDataURL(size, size, function(x, y) {
389
+ if (min <= x && x < max && min <= y && y < max) {
390
+ const c = Math.floor((x - min) / cellSize);
391
+ const r = Math.floor((y - min) / cellSize);
392
+ return _this.isDark(r, c) ? 0 : 1;
393
+ } else {
394
+ return 1;
395
+ }
396
+ });
397
+ };
398
+ _this.createImgTag = function(cellSize, margin, alt) {
399
+ cellSize = cellSize || 2;
400
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
401
+ const size = _this.getModuleCount() * cellSize + margin * 2;
402
+ let img = "";
403
+ img += "<img";
404
+ img += ' src="';
405
+ img += _this.createDataURL(cellSize, margin);
406
+ img += '"';
407
+ img += ' width="';
408
+ img += size;
409
+ img += '"';
410
+ img += ' height="';
411
+ img += size;
412
+ img += '"';
413
+ if (alt) {
414
+ img += ' alt="';
415
+ img += escapeXml(alt);
416
+ img += '"';
417
+ }
418
+ img += "/>";
419
+ return img;
420
+ };
421
+ const escapeXml = function(s) {
422
+ let escaped = "";
423
+ for (let i = 0; i < s.length; i += 1) {
424
+ const c = s.charAt(i);
425
+ switch (c) {
426
+ case "<":
427
+ escaped += "&lt;";
428
+ break;
429
+ case ">":
430
+ escaped += "&gt;";
431
+ break;
432
+ case "&":
433
+ escaped += "&amp;";
434
+ break;
435
+ case '"':
436
+ escaped += "&quot;";
437
+ break;
438
+ default:
439
+ escaped += c;
440
+ break;
441
+ }
442
+ }
443
+ return escaped;
444
+ };
445
+ const _createHalfASCII = function(margin) {
446
+ const cellSize = 1;
447
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
448
+ const size = _this.getModuleCount() * cellSize + margin * 2;
449
+ const min = margin;
450
+ const max = size - margin;
451
+ let y, x, r1, r2, p;
452
+ const blocks = {
453
+ "\u2588\u2588": "\u2588",
454
+ "\u2588 ": "\u2580",
455
+ " \u2588": "\u2584",
456
+ " ": " "
457
+ };
458
+ const blocksLastLineNoMargin = {
459
+ "\u2588\u2588": "\u2580",
460
+ "\u2588 ": "\u2580",
461
+ " \u2588": " ",
462
+ " ": " "
463
+ };
464
+ let ascii = "";
465
+ for (y = 0; y < size; y += 2) {
466
+ r1 = Math.floor((y - min) / cellSize);
467
+ r2 = Math.floor((y + 1 - min) / cellSize);
468
+ for (x = 0; x < size; x += 1) {
469
+ p = "\u2588";
470
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
471
+ p = " ";
472
+ }
473
+ if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
474
+ p += " ";
475
+ } else {
476
+ p += "\u2588";
477
+ }
478
+ ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
479
+ }
480
+ ascii += "\n";
481
+ }
482
+ if (size % 2 && margin > 0) {
483
+ return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("\u2580");
484
+ }
485
+ return ascii.substring(0, ascii.length - 1);
486
+ };
487
+ _this.createASCII = function(cellSize, margin) {
488
+ cellSize = cellSize || 1;
489
+ if (cellSize < 2) {
490
+ return _createHalfASCII(margin);
491
+ }
492
+ cellSize -= 1;
493
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
494
+ const size = _this.getModuleCount() * cellSize + margin * 2;
495
+ const min = margin;
496
+ const max = size - margin;
497
+ let y, x, r, p;
498
+ const white = Array(cellSize + 1).join("\u2588\u2588");
499
+ const black = Array(cellSize + 1).join(" ");
500
+ let ascii = "";
501
+ let line = "";
502
+ for (y = 0; y < size; y += 1) {
503
+ r = Math.floor((y - min) / cellSize);
504
+ line = "";
505
+ for (x = 0; x < size; x += 1) {
506
+ p = 1;
507
+ if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
508
+ p = 0;
509
+ }
510
+ line += p ? white : black;
511
+ }
512
+ for (r = 0; r < cellSize; r += 1) {
513
+ ascii += line + "\n";
514
+ }
515
+ }
516
+ return ascii.substring(0, ascii.length - 1);
517
+ };
518
+ _this.renderTo2dContext = function(context, cellSize) {
519
+ cellSize = cellSize || 2;
520
+ const length = _this.getModuleCount();
521
+ for (let row = 0; row < length; row++) {
522
+ for (let col = 0; col < length; col++) {
523
+ context.fillStyle = _this.isDark(row, col) ? "black" : "white";
524
+ context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
525
+ }
526
+ }
527
+ };
528
+ return _this;
529
+ };
530
+ qrcode.stringToBytes = function(s) {
531
+ const bytes = [];
532
+ for (let i = 0; i < s.length; i += 1) {
533
+ const c = s.charCodeAt(i);
534
+ bytes.push(c & 255);
535
+ }
536
+ return bytes;
537
+ };
538
+ qrcode.createStringToBytes = function(unicodeData, numChars) {
539
+ const unicodeMap = (function() {
540
+ const bin = base64DecodeInputStream(unicodeData);
541
+ const read = function() {
542
+ const b = bin.read();
543
+ if (b == -1) throw "eof";
544
+ return b;
545
+ };
546
+ let count = 0;
547
+ const unicodeMap2 = {};
548
+ while (true) {
549
+ const b0 = bin.read();
550
+ if (b0 == -1) break;
551
+ const b1 = read();
552
+ const b2 = read();
553
+ const b3 = read();
554
+ const k = String.fromCharCode(b0 << 8 | b1);
555
+ const v = b2 << 8 | b3;
556
+ unicodeMap2[k] = v;
557
+ count += 1;
558
+ }
559
+ if (count != numChars) {
560
+ throw count + " != " + numChars;
561
+ }
562
+ return unicodeMap2;
563
+ })();
564
+ const unknownChar = "?".charCodeAt(0);
565
+ return function(s) {
566
+ const bytes = [];
567
+ for (let i = 0; i < s.length; i += 1) {
568
+ const c = s.charCodeAt(i);
569
+ if (c < 128) {
570
+ bytes.push(c);
571
+ } else {
572
+ const b = unicodeMap[s.charAt(i)];
573
+ if (typeof b == "number") {
574
+ if ((b & 255) == b) {
575
+ bytes.push(b);
576
+ } else {
577
+ bytes.push(b >>> 8);
578
+ bytes.push(b & 255);
579
+ }
580
+ } else {
581
+ bytes.push(unknownChar);
582
+ }
583
+ }
584
+ }
585
+ return bytes;
586
+ };
587
+ };
588
+ var QRMode = {
589
+ MODE_NUMBER: 1 << 0,
590
+ MODE_ALPHA_NUM: 1 << 1,
591
+ MODE_8BIT_BYTE: 1 << 2,
592
+ MODE_KANJI: 1 << 3
593
+ };
594
+ var QRErrorCorrectionLevel = {
595
+ L: 1,
596
+ M: 0,
597
+ Q: 3,
598
+ H: 2
599
+ };
600
+ var QRMaskPattern = {
601
+ PATTERN000: 0,
602
+ PATTERN001: 1,
603
+ PATTERN010: 2,
604
+ PATTERN011: 3,
605
+ PATTERN100: 4,
606
+ PATTERN101: 5,
607
+ PATTERN110: 6,
608
+ PATTERN111: 7
609
+ };
610
+ var QRUtil = (function() {
611
+ const PATTERN_POSITION_TABLE = [
612
+ [],
613
+ [6, 18],
614
+ [6, 22],
615
+ [6, 26],
616
+ [6, 30],
617
+ [6, 34],
618
+ [6, 22, 38],
619
+ [6, 24, 42],
620
+ [6, 26, 46],
621
+ [6, 28, 50],
622
+ [6, 30, 54],
623
+ [6, 32, 58],
624
+ [6, 34, 62],
625
+ [6, 26, 46, 66],
626
+ [6, 26, 48, 70],
627
+ [6, 26, 50, 74],
628
+ [6, 30, 54, 78],
629
+ [6, 30, 56, 82],
630
+ [6, 30, 58, 86],
631
+ [6, 34, 62, 90],
632
+ [6, 28, 50, 72, 94],
633
+ [6, 26, 50, 74, 98],
634
+ [6, 30, 54, 78, 102],
635
+ [6, 28, 54, 80, 106],
636
+ [6, 32, 58, 84, 110],
637
+ [6, 30, 58, 86, 114],
638
+ [6, 34, 62, 90, 118],
639
+ [6, 26, 50, 74, 98, 122],
640
+ [6, 30, 54, 78, 102, 126],
641
+ [6, 26, 52, 78, 104, 130],
642
+ [6, 30, 56, 82, 108, 134],
643
+ [6, 34, 60, 86, 112, 138],
644
+ [6, 30, 58, 86, 114, 142],
645
+ [6, 34, 62, 90, 118, 146],
646
+ [6, 30, 54, 78, 102, 126, 150],
647
+ [6, 24, 50, 76, 102, 128, 154],
648
+ [6, 28, 54, 80, 106, 132, 158],
649
+ [6, 32, 58, 84, 110, 136, 162],
650
+ [6, 26, 54, 82, 110, 138, 166],
651
+ [6, 30, 58, 86, 114, 142, 170]
652
+ ];
653
+ const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
654
+ const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
655
+ const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
656
+ const _this = {};
657
+ const getBCHDigit = function(data) {
658
+ let digit = 0;
659
+ while (data != 0) {
660
+ digit += 1;
661
+ data >>>= 1;
662
+ }
663
+ return digit;
664
+ };
665
+ _this.getBCHTypeInfo = function(data) {
666
+ let d = data << 10;
667
+ while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
668
+ d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
669
+ }
670
+ return (data << 10 | d) ^ G15_MASK;
671
+ };
672
+ _this.getBCHTypeNumber = function(data) {
673
+ let d = data << 12;
674
+ while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
675
+ d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
676
+ }
677
+ return data << 12 | d;
678
+ };
679
+ _this.getPatternPosition = function(typeNumber) {
680
+ return PATTERN_POSITION_TABLE[typeNumber - 1];
681
+ };
682
+ _this.getMaskFunction = function(maskPattern) {
683
+ switch (maskPattern) {
684
+ case QRMaskPattern.PATTERN000:
685
+ return function(i, j) {
686
+ return (i + j) % 2 == 0;
687
+ };
688
+ case QRMaskPattern.PATTERN001:
689
+ return function(i, j) {
690
+ return i % 2 == 0;
691
+ };
692
+ case QRMaskPattern.PATTERN010:
693
+ return function(i, j) {
694
+ return j % 3 == 0;
695
+ };
696
+ case QRMaskPattern.PATTERN011:
697
+ return function(i, j) {
698
+ return (i + j) % 3 == 0;
699
+ };
700
+ case QRMaskPattern.PATTERN100:
701
+ return function(i, j) {
702
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
703
+ };
704
+ case QRMaskPattern.PATTERN101:
705
+ return function(i, j) {
706
+ return i * j % 2 + i * j % 3 == 0;
707
+ };
708
+ case QRMaskPattern.PATTERN110:
709
+ return function(i, j) {
710
+ return (i * j % 2 + i * j % 3) % 2 == 0;
711
+ };
712
+ case QRMaskPattern.PATTERN111:
713
+ return function(i, j) {
714
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
715
+ };
716
+ default:
717
+ throw "bad maskPattern:" + maskPattern;
718
+ }
719
+ };
720
+ _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
721
+ let a = qrPolynomial([1], 0);
722
+ for (let i = 0; i < errorCorrectLength; i += 1) {
723
+ a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
724
+ }
725
+ return a;
726
+ };
727
+ _this.getLengthInBits = function(mode, type) {
728
+ if (1 <= type && type < 10) {
729
+ switch (mode) {
730
+ case QRMode.MODE_NUMBER:
731
+ return 10;
732
+ case QRMode.MODE_ALPHA_NUM:
733
+ return 9;
734
+ case QRMode.MODE_8BIT_BYTE:
735
+ return 8;
736
+ case QRMode.MODE_KANJI:
737
+ return 8;
738
+ default:
739
+ throw "mode:" + mode;
740
+ }
741
+ } else if (type < 27) {
742
+ switch (mode) {
743
+ case QRMode.MODE_NUMBER:
744
+ return 12;
745
+ case QRMode.MODE_ALPHA_NUM:
746
+ return 11;
747
+ case QRMode.MODE_8BIT_BYTE:
748
+ return 16;
749
+ case QRMode.MODE_KANJI:
750
+ return 10;
751
+ default:
752
+ throw "mode:" + mode;
753
+ }
754
+ } else if (type < 41) {
755
+ switch (mode) {
756
+ case QRMode.MODE_NUMBER:
757
+ return 14;
758
+ case QRMode.MODE_ALPHA_NUM:
759
+ return 13;
760
+ case QRMode.MODE_8BIT_BYTE:
761
+ return 16;
762
+ case QRMode.MODE_KANJI:
763
+ return 12;
764
+ default:
765
+ throw "mode:" + mode;
766
+ }
767
+ } else {
768
+ throw "type:" + type;
769
+ }
770
+ };
771
+ _this.getLostPoint = function(qrcode2) {
772
+ const moduleCount = qrcode2.getModuleCount();
773
+ let lostPoint = 0;
774
+ for (let row = 0; row < moduleCount; row += 1) {
775
+ for (let col = 0; col < moduleCount; col += 1) {
776
+ let sameCount = 0;
777
+ const dark = qrcode2.isDark(row, col);
778
+ for (let r = -1; r <= 1; r += 1) {
779
+ if (row + r < 0 || moduleCount <= row + r) {
780
+ continue;
781
+ }
782
+ for (let c = -1; c <= 1; c += 1) {
783
+ if (col + c < 0 || moduleCount <= col + c) {
784
+ continue;
785
+ }
786
+ if (r == 0 && c == 0) {
787
+ continue;
788
+ }
789
+ if (dark == qrcode2.isDark(row + r, col + c)) {
790
+ sameCount += 1;
791
+ }
792
+ }
793
+ }
794
+ if (sameCount > 5) {
795
+ lostPoint += 3 + sameCount - 5;
796
+ }
797
+ }
798
+ }
799
+ ;
800
+ for (let row = 0; row < moduleCount - 1; row += 1) {
801
+ for (let col = 0; col < moduleCount - 1; col += 1) {
802
+ let count = 0;
803
+ if (qrcode2.isDark(row, col)) count += 1;
804
+ if (qrcode2.isDark(row + 1, col)) count += 1;
805
+ if (qrcode2.isDark(row, col + 1)) count += 1;
806
+ if (qrcode2.isDark(row + 1, col + 1)) count += 1;
807
+ if (count == 0 || count == 4) {
808
+ lostPoint += 3;
809
+ }
810
+ }
811
+ }
812
+ for (let row = 0; row < moduleCount; row += 1) {
813
+ for (let col = 0; col < moduleCount - 6; col += 1) {
814
+ if (qrcode2.isDark(row, col) && !qrcode2.isDark(row, col + 1) && qrcode2.isDark(row, col + 2) && qrcode2.isDark(row, col + 3) && qrcode2.isDark(row, col + 4) && !qrcode2.isDark(row, col + 5) && qrcode2.isDark(row, col + 6)) {
815
+ lostPoint += 40;
816
+ }
817
+ }
818
+ }
819
+ for (let col = 0; col < moduleCount; col += 1) {
820
+ for (let row = 0; row < moduleCount - 6; row += 1) {
821
+ if (qrcode2.isDark(row, col) && !qrcode2.isDark(row + 1, col) && qrcode2.isDark(row + 2, col) && qrcode2.isDark(row + 3, col) && qrcode2.isDark(row + 4, col) && !qrcode2.isDark(row + 5, col) && qrcode2.isDark(row + 6, col)) {
822
+ lostPoint += 40;
823
+ }
824
+ }
825
+ }
826
+ let darkCount = 0;
827
+ for (let col = 0; col < moduleCount; col += 1) {
828
+ for (let row = 0; row < moduleCount; row += 1) {
829
+ if (qrcode2.isDark(row, col)) {
830
+ darkCount += 1;
831
+ }
832
+ }
833
+ }
834
+ const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
835
+ lostPoint += ratio * 10;
836
+ return lostPoint;
837
+ };
838
+ return _this;
839
+ })();
840
+ var QRMath = (function() {
841
+ const EXP_TABLE = new Array(256);
842
+ const LOG_TABLE = new Array(256);
843
+ for (let i = 0; i < 8; i += 1) {
844
+ EXP_TABLE[i] = 1 << i;
845
+ }
846
+ for (let i = 8; i < 256; i += 1) {
847
+ EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
848
+ }
849
+ for (let i = 0; i < 255; i += 1) {
850
+ LOG_TABLE[EXP_TABLE[i]] = i;
851
+ }
852
+ const _this = {};
853
+ _this.glog = function(n) {
854
+ if (n < 1) {
855
+ throw "glog(" + n + ")";
856
+ }
857
+ return LOG_TABLE[n];
858
+ };
859
+ _this.gexp = function(n) {
860
+ while (n < 0) {
861
+ n += 255;
862
+ }
863
+ while (n >= 256) {
864
+ n -= 255;
865
+ }
866
+ return EXP_TABLE[n];
867
+ };
868
+ return _this;
869
+ })();
870
+ var qrPolynomial = function(num, shift) {
871
+ if (typeof num.length == "undefined") {
872
+ throw num.length + "/" + shift;
873
+ }
874
+ const _num = (function() {
875
+ let offset = 0;
876
+ while (offset < num.length && num[offset] == 0) {
877
+ offset += 1;
878
+ }
879
+ const _num2 = new Array(num.length - offset + shift);
880
+ for (let i = 0; i < num.length - offset; i += 1) {
881
+ _num2[i] = num[i + offset];
882
+ }
883
+ return _num2;
884
+ })();
885
+ const _this = {};
886
+ _this.getAt = function(index) {
887
+ return _num[index];
888
+ };
889
+ _this.getLength = function() {
890
+ return _num.length;
891
+ };
892
+ _this.multiply = function(e) {
893
+ const num2 = new Array(_this.getLength() + e.getLength() - 1);
894
+ for (let i = 0; i < _this.getLength(); i += 1) {
895
+ for (let j = 0; j < e.getLength(); j += 1) {
896
+ num2[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
897
+ }
898
+ }
899
+ return qrPolynomial(num2, 0);
900
+ };
901
+ _this.mod = function(e) {
902
+ if (_this.getLength() - e.getLength() < 0) {
903
+ return _this;
904
+ }
905
+ const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
906
+ const num2 = new Array(_this.getLength());
907
+ for (let i = 0; i < _this.getLength(); i += 1) {
908
+ num2[i] = _this.getAt(i);
909
+ }
910
+ for (let i = 0; i < e.getLength(); i += 1) {
911
+ num2[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
912
+ }
913
+ return qrPolynomial(num2, 0).mod(e);
914
+ };
915
+ return _this;
916
+ };
917
+ var QRRSBlock = (function() {
918
+ const RS_BLOCK_TABLE = [
919
+ // L
920
+ // M
921
+ // Q
922
+ // H
923
+ // 1
924
+ [1, 26, 19],
925
+ [1, 26, 16],
926
+ [1, 26, 13],
927
+ [1, 26, 9],
928
+ // 2
929
+ [1, 44, 34],
930
+ [1, 44, 28],
931
+ [1, 44, 22],
932
+ [1, 44, 16],
933
+ // 3
934
+ [1, 70, 55],
935
+ [1, 70, 44],
936
+ [2, 35, 17],
937
+ [2, 35, 13],
938
+ // 4
939
+ [1, 100, 80],
940
+ [2, 50, 32],
941
+ [2, 50, 24],
942
+ [4, 25, 9],
943
+ // 5
944
+ [1, 134, 108],
945
+ [2, 67, 43],
946
+ [2, 33, 15, 2, 34, 16],
947
+ [2, 33, 11, 2, 34, 12],
948
+ // 6
949
+ [2, 86, 68],
950
+ [4, 43, 27],
951
+ [4, 43, 19],
952
+ [4, 43, 15],
953
+ // 7
954
+ [2, 98, 78],
955
+ [4, 49, 31],
956
+ [2, 32, 14, 4, 33, 15],
957
+ [4, 39, 13, 1, 40, 14],
958
+ // 8
959
+ [2, 121, 97],
960
+ [2, 60, 38, 2, 61, 39],
961
+ [4, 40, 18, 2, 41, 19],
962
+ [4, 40, 14, 2, 41, 15],
963
+ // 9
964
+ [2, 146, 116],
965
+ [3, 58, 36, 2, 59, 37],
966
+ [4, 36, 16, 4, 37, 17],
967
+ [4, 36, 12, 4, 37, 13],
968
+ // 10
969
+ [2, 86, 68, 2, 87, 69],
970
+ [4, 69, 43, 1, 70, 44],
971
+ [6, 43, 19, 2, 44, 20],
972
+ [6, 43, 15, 2, 44, 16],
973
+ // 11
974
+ [4, 101, 81],
975
+ [1, 80, 50, 4, 81, 51],
976
+ [4, 50, 22, 4, 51, 23],
977
+ [3, 36, 12, 8, 37, 13],
978
+ // 12
979
+ [2, 116, 92, 2, 117, 93],
980
+ [6, 58, 36, 2, 59, 37],
981
+ [4, 46, 20, 6, 47, 21],
982
+ [7, 42, 14, 4, 43, 15],
983
+ // 13
984
+ [4, 133, 107],
985
+ [8, 59, 37, 1, 60, 38],
986
+ [8, 44, 20, 4, 45, 21],
987
+ [12, 33, 11, 4, 34, 12],
988
+ // 14
989
+ [3, 145, 115, 1, 146, 116],
990
+ [4, 64, 40, 5, 65, 41],
991
+ [11, 36, 16, 5, 37, 17],
992
+ [11, 36, 12, 5, 37, 13],
993
+ // 15
994
+ [5, 109, 87, 1, 110, 88],
995
+ [5, 65, 41, 5, 66, 42],
996
+ [5, 54, 24, 7, 55, 25],
997
+ [11, 36, 12, 7, 37, 13],
998
+ // 16
999
+ [5, 122, 98, 1, 123, 99],
1000
+ [7, 73, 45, 3, 74, 46],
1001
+ [15, 43, 19, 2, 44, 20],
1002
+ [3, 45, 15, 13, 46, 16],
1003
+ // 17
1004
+ [1, 135, 107, 5, 136, 108],
1005
+ [10, 74, 46, 1, 75, 47],
1006
+ [1, 50, 22, 15, 51, 23],
1007
+ [2, 42, 14, 17, 43, 15],
1008
+ // 18
1009
+ [5, 150, 120, 1, 151, 121],
1010
+ [9, 69, 43, 4, 70, 44],
1011
+ [17, 50, 22, 1, 51, 23],
1012
+ [2, 42, 14, 19, 43, 15],
1013
+ // 19
1014
+ [3, 141, 113, 4, 142, 114],
1015
+ [3, 70, 44, 11, 71, 45],
1016
+ [17, 47, 21, 4, 48, 22],
1017
+ [9, 39, 13, 16, 40, 14],
1018
+ // 20
1019
+ [3, 135, 107, 5, 136, 108],
1020
+ [3, 67, 41, 13, 68, 42],
1021
+ [15, 54, 24, 5, 55, 25],
1022
+ [15, 43, 15, 10, 44, 16],
1023
+ // 21
1024
+ [4, 144, 116, 4, 145, 117],
1025
+ [17, 68, 42],
1026
+ [17, 50, 22, 6, 51, 23],
1027
+ [19, 46, 16, 6, 47, 17],
1028
+ // 22
1029
+ [2, 139, 111, 7, 140, 112],
1030
+ [17, 74, 46],
1031
+ [7, 54, 24, 16, 55, 25],
1032
+ [34, 37, 13],
1033
+ // 23
1034
+ [4, 151, 121, 5, 152, 122],
1035
+ [4, 75, 47, 14, 76, 48],
1036
+ [11, 54, 24, 14, 55, 25],
1037
+ [16, 45, 15, 14, 46, 16],
1038
+ // 24
1039
+ [6, 147, 117, 4, 148, 118],
1040
+ [6, 73, 45, 14, 74, 46],
1041
+ [11, 54, 24, 16, 55, 25],
1042
+ [30, 46, 16, 2, 47, 17],
1043
+ // 25
1044
+ [8, 132, 106, 4, 133, 107],
1045
+ [8, 75, 47, 13, 76, 48],
1046
+ [7, 54, 24, 22, 55, 25],
1047
+ [22, 45, 15, 13, 46, 16],
1048
+ // 26
1049
+ [10, 142, 114, 2, 143, 115],
1050
+ [19, 74, 46, 4, 75, 47],
1051
+ [28, 50, 22, 6, 51, 23],
1052
+ [33, 46, 16, 4, 47, 17],
1053
+ // 27
1054
+ [8, 152, 122, 4, 153, 123],
1055
+ [22, 73, 45, 3, 74, 46],
1056
+ [8, 53, 23, 26, 54, 24],
1057
+ [12, 45, 15, 28, 46, 16],
1058
+ // 28
1059
+ [3, 147, 117, 10, 148, 118],
1060
+ [3, 73, 45, 23, 74, 46],
1061
+ [4, 54, 24, 31, 55, 25],
1062
+ [11, 45, 15, 31, 46, 16],
1063
+ // 29
1064
+ [7, 146, 116, 7, 147, 117],
1065
+ [21, 73, 45, 7, 74, 46],
1066
+ [1, 53, 23, 37, 54, 24],
1067
+ [19, 45, 15, 26, 46, 16],
1068
+ // 30
1069
+ [5, 145, 115, 10, 146, 116],
1070
+ [19, 75, 47, 10, 76, 48],
1071
+ [15, 54, 24, 25, 55, 25],
1072
+ [23, 45, 15, 25, 46, 16],
1073
+ // 31
1074
+ [13, 145, 115, 3, 146, 116],
1075
+ [2, 74, 46, 29, 75, 47],
1076
+ [42, 54, 24, 1, 55, 25],
1077
+ [23, 45, 15, 28, 46, 16],
1078
+ // 32
1079
+ [17, 145, 115],
1080
+ [10, 74, 46, 23, 75, 47],
1081
+ [10, 54, 24, 35, 55, 25],
1082
+ [19, 45, 15, 35, 46, 16],
1083
+ // 33
1084
+ [17, 145, 115, 1, 146, 116],
1085
+ [14, 74, 46, 21, 75, 47],
1086
+ [29, 54, 24, 19, 55, 25],
1087
+ [11, 45, 15, 46, 46, 16],
1088
+ // 34
1089
+ [13, 145, 115, 6, 146, 116],
1090
+ [14, 74, 46, 23, 75, 47],
1091
+ [44, 54, 24, 7, 55, 25],
1092
+ [59, 46, 16, 1, 47, 17],
1093
+ // 35
1094
+ [12, 151, 121, 7, 152, 122],
1095
+ [12, 75, 47, 26, 76, 48],
1096
+ [39, 54, 24, 14, 55, 25],
1097
+ [22, 45, 15, 41, 46, 16],
1098
+ // 36
1099
+ [6, 151, 121, 14, 152, 122],
1100
+ [6, 75, 47, 34, 76, 48],
1101
+ [46, 54, 24, 10, 55, 25],
1102
+ [2, 45, 15, 64, 46, 16],
1103
+ // 37
1104
+ [17, 152, 122, 4, 153, 123],
1105
+ [29, 74, 46, 14, 75, 47],
1106
+ [49, 54, 24, 10, 55, 25],
1107
+ [24, 45, 15, 46, 46, 16],
1108
+ // 38
1109
+ [4, 152, 122, 18, 153, 123],
1110
+ [13, 74, 46, 32, 75, 47],
1111
+ [48, 54, 24, 14, 55, 25],
1112
+ [42, 45, 15, 32, 46, 16],
1113
+ // 39
1114
+ [20, 147, 117, 4, 148, 118],
1115
+ [40, 75, 47, 7, 76, 48],
1116
+ [43, 54, 24, 22, 55, 25],
1117
+ [10, 45, 15, 67, 46, 16],
1118
+ // 40
1119
+ [19, 148, 118, 6, 149, 119],
1120
+ [18, 75, 47, 31, 76, 48],
1121
+ [34, 54, 24, 34, 55, 25],
1122
+ [20, 45, 15, 61, 46, 16]
1123
+ ];
1124
+ const qrRSBlock = function(totalCount, dataCount) {
1125
+ const _this2 = {};
1126
+ _this2.totalCount = totalCount;
1127
+ _this2.dataCount = dataCount;
1128
+ return _this2;
1129
+ };
1130
+ const _this = {};
1131
+ const getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
1132
+ switch (errorCorrectionLevel) {
1133
+ case QRErrorCorrectionLevel.L:
1134
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1135
+ case QRErrorCorrectionLevel.M:
1136
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1137
+ case QRErrorCorrectionLevel.Q:
1138
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1139
+ case QRErrorCorrectionLevel.H:
1140
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1141
+ default:
1142
+ return void 0;
1143
+ }
1144
+ };
1145
+ _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
1146
+ const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
1147
+ if (typeof rsBlock == "undefined") {
1148
+ throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
1149
+ }
1150
+ const length = rsBlock.length / 3;
1151
+ const list = [];
1152
+ for (let i = 0; i < length; i += 1) {
1153
+ const count = rsBlock[i * 3 + 0];
1154
+ const totalCount = rsBlock[i * 3 + 1];
1155
+ const dataCount = rsBlock[i * 3 + 2];
1156
+ for (let j = 0; j < count; j += 1) {
1157
+ list.push(qrRSBlock(totalCount, dataCount));
1158
+ }
1159
+ }
1160
+ return list;
1161
+ };
1162
+ return _this;
1163
+ })();
1164
+ var qrBitBuffer = function() {
1165
+ const _buffer = [];
1166
+ let _length = 0;
1167
+ const _this = {};
1168
+ _this.getBuffer = function() {
1169
+ return _buffer;
1170
+ };
1171
+ _this.getAt = function(index) {
1172
+ const bufIndex = Math.floor(index / 8);
1173
+ return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
1174
+ };
1175
+ _this.put = function(num, length) {
1176
+ for (let i = 0; i < length; i += 1) {
1177
+ _this.putBit((num >>> length - i - 1 & 1) == 1);
1178
+ }
1179
+ };
1180
+ _this.getLengthInBits = function() {
1181
+ return _length;
1182
+ };
1183
+ _this.putBit = function(bit) {
1184
+ const bufIndex = Math.floor(_length / 8);
1185
+ if (_buffer.length <= bufIndex) {
1186
+ _buffer.push(0);
1187
+ }
1188
+ if (bit) {
1189
+ _buffer[bufIndex] |= 128 >>> _length % 8;
1190
+ }
1191
+ _length += 1;
1192
+ };
1193
+ return _this;
1194
+ };
1195
+ var qrNumber = function(data) {
1196
+ const _mode = QRMode.MODE_NUMBER;
1197
+ const _data = data;
1198
+ const _this = {};
1199
+ _this.getMode = function() {
1200
+ return _mode;
1201
+ };
1202
+ _this.getLength = function(buffer) {
1203
+ return _data.length;
1204
+ };
1205
+ _this.write = function(buffer) {
1206
+ const data2 = _data;
1207
+ let i = 0;
1208
+ while (i + 2 < data2.length) {
1209
+ buffer.put(strToNum(data2.substring(i, i + 3)), 10);
1210
+ i += 3;
1211
+ }
1212
+ if (i < data2.length) {
1213
+ if (data2.length - i == 1) {
1214
+ buffer.put(strToNum(data2.substring(i, i + 1)), 4);
1215
+ } else if (data2.length - i == 2) {
1216
+ buffer.put(strToNum(data2.substring(i, i + 2)), 7);
1217
+ }
1218
+ }
1219
+ };
1220
+ const strToNum = function(s) {
1221
+ let num = 0;
1222
+ for (let i = 0; i < s.length; i += 1) {
1223
+ num = num * 10 + chatToNum(s.charAt(i));
1224
+ }
1225
+ return num;
1226
+ };
1227
+ const chatToNum = function(c) {
1228
+ if ("0" <= c && c <= "9") {
1229
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1230
+ }
1231
+ throw "illegal char :" + c;
1232
+ };
1233
+ return _this;
1234
+ };
1235
+ var qrAlphaNum = function(data) {
1236
+ const _mode = QRMode.MODE_ALPHA_NUM;
1237
+ const _data = data;
1238
+ const _this = {};
1239
+ _this.getMode = function() {
1240
+ return _mode;
1241
+ };
1242
+ _this.getLength = function(buffer) {
1243
+ return _data.length;
1244
+ };
1245
+ _this.write = function(buffer) {
1246
+ const s = _data;
1247
+ let i = 0;
1248
+ while (i + 1 < s.length) {
1249
+ buffer.put(
1250
+ getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)),
1251
+ 11
1252
+ );
1253
+ i += 2;
1254
+ }
1255
+ if (i < s.length) {
1256
+ buffer.put(getCode(s.charAt(i)), 6);
1257
+ }
1258
+ };
1259
+ const getCode = function(c) {
1260
+ if ("0" <= c && c <= "9") {
1261
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1262
+ } else if ("A" <= c && c <= "Z") {
1263
+ return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
1264
+ } else {
1265
+ switch (c) {
1266
+ case " ":
1267
+ return 36;
1268
+ case "$":
1269
+ return 37;
1270
+ case "%":
1271
+ return 38;
1272
+ case "*":
1273
+ return 39;
1274
+ case "+":
1275
+ return 40;
1276
+ case "-":
1277
+ return 41;
1278
+ case ".":
1279
+ return 42;
1280
+ case "/":
1281
+ return 43;
1282
+ case ":":
1283
+ return 44;
1284
+ default:
1285
+ throw "illegal char :" + c;
1286
+ }
1287
+ }
1288
+ };
1289
+ return _this;
1290
+ };
1291
+ var qr8BitByte = function(data) {
1292
+ const _mode = QRMode.MODE_8BIT_BYTE;
1293
+ const _data = data;
1294
+ const _bytes = qrcode.stringToBytes(data);
1295
+ const _this = {};
1296
+ _this.getMode = function() {
1297
+ return _mode;
1298
+ };
1299
+ _this.getLength = function(buffer) {
1300
+ return _bytes.length;
1301
+ };
1302
+ _this.write = function(buffer) {
1303
+ for (let i = 0; i < _bytes.length; i += 1) {
1304
+ buffer.put(_bytes[i], 8);
1305
+ }
1306
+ };
1307
+ return _this;
1308
+ };
1309
+ var qrKanji = function(data) {
1310
+ const _mode = QRMode.MODE_KANJI;
1311
+ const _data = data;
1312
+ const stringToBytes2 = qrcode.stringToBytes;
1313
+ !(function(c, code) {
1314
+ const test = stringToBytes2(c);
1315
+ if (test.length != 2 || (test[0] << 8 | test[1]) != code) {
1316
+ throw "sjis not supported.";
1317
+ }
1318
+ })("\u53CB", 38726);
1319
+ const _bytes = stringToBytes2(data);
1320
+ const _this = {};
1321
+ _this.getMode = function() {
1322
+ return _mode;
1323
+ };
1324
+ _this.getLength = function(buffer) {
1325
+ return ~~(_bytes.length / 2);
1326
+ };
1327
+ _this.write = function(buffer) {
1328
+ const data2 = _bytes;
1329
+ let i = 0;
1330
+ while (i + 1 < data2.length) {
1331
+ let c = (255 & data2[i]) << 8 | 255 & data2[i + 1];
1332
+ if (33088 <= c && c <= 40956) {
1333
+ c -= 33088;
1334
+ } else if (57408 <= c && c <= 60351) {
1335
+ c -= 49472;
1336
+ } else {
1337
+ throw "illegal char at " + (i + 1) + "/" + c;
1338
+ }
1339
+ c = (c >>> 8 & 255) * 192 + (c & 255);
1340
+ buffer.put(c, 13);
1341
+ i += 2;
1342
+ }
1343
+ if (i < data2.length) {
1344
+ throw "illegal char at " + (i + 1);
1345
+ }
1346
+ };
1347
+ return _this;
1348
+ };
1349
+ var byteArrayOutputStream = function() {
1350
+ const _bytes = [];
1351
+ const _this = {};
1352
+ _this.writeByte = function(b) {
1353
+ _bytes.push(b & 255);
1354
+ };
1355
+ _this.writeShort = function(i) {
1356
+ _this.writeByte(i);
1357
+ _this.writeByte(i >>> 8);
1358
+ };
1359
+ _this.writeBytes = function(b, off, len) {
1360
+ off = off || 0;
1361
+ len = len || b.length;
1362
+ for (let i = 0; i < len; i += 1) {
1363
+ _this.writeByte(b[i + off]);
1364
+ }
1365
+ };
1366
+ _this.writeString = function(s) {
1367
+ for (let i = 0; i < s.length; i += 1) {
1368
+ _this.writeByte(s.charCodeAt(i));
1369
+ }
1370
+ };
1371
+ _this.toByteArray = function() {
1372
+ return _bytes;
1373
+ };
1374
+ _this.toString = function() {
1375
+ let s = "";
1376
+ s += "[";
1377
+ for (let i = 0; i < _bytes.length; i += 1) {
1378
+ if (i > 0) {
1379
+ s += ",";
1380
+ }
1381
+ s += _bytes[i];
1382
+ }
1383
+ s += "]";
1384
+ return s;
1385
+ };
1386
+ return _this;
1387
+ };
1388
+ var base64EncodeOutputStream = function() {
1389
+ let _buffer = 0;
1390
+ let _buflen = 0;
1391
+ let _length = 0;
1392
+ let _base64 = "";
1393
+ const _this = {};
1394
+ const writeEncoded = function(b) {
1395
+ _base64 += String.fromCharCode(encode(b & 63));
1396
+ };
1397
+ const encode = function(n) {
1398
+ if (n < 0) {
1399
+ throw "n:" + n;
1400
+ } else if (n < 26) {
1401
+ return 65 + n;
1402
+ } else if (n < 52) {
1403
+ return 97 + (n - 26);
1404
+ } else if (n < 62) {
1405
+ return 48 + (n - 52);
1406
+ } else if (n == 62) {
1407
+ return 43;
1408
+ } else if (n == 63) {
1409
+ return 47;
1410
+ } else {
1411
+ throw "n:" + n;
1412
+ }
1413
+ };
1414
+ _this.writeByte = function(n) {
1415
+ _buffer = _buffer << 8 | n & 255;
1416
+ _buflen += 8;
1417
+ _length += 1;
1418
+ while (_buflen >= 6) {
1419
+ writeEncoded(_buffer >>> _buflen - 6);
1420
+ _buflen -= 6;
1421
+ }
1422
+ };
1423
+ _this.flush = function() {
1424
+ if (_buflen > 0) {
1425
+ writeEncoded(_buffer << 6 - _buflen);
1426
+ _buffer = 0;
1427
+ _buflen = 0;
1428
+ }
1429
+ if (_length % 3 != 0) {
1430
+ const padlen = 3 - _length % 3;
1431
+ for (let i = 0; i < padlen; i += 1) {
1432
+ _base64 += "=";
1433
+ }
1434
+ }
1435
+ };
1436
+ _this.toString = function() {
1437
+ return _base64;
1438
+ };
1439
+ return _this;
1440
+ };
1441
+ var base64DecodeInputStream = function(str) {
1442
+ const _str = str;
1443
+ let _pos = 0;
1444
+ let _buffer = 0;
1445
+ let _buflen = 0;
1446
+ const _this = {};
1447
+ _this.read = function() {
1448
+ while (_buflen < 8) {
1449
+ if (_pos >= _str.length) {
1450
+ if (_buflen == 0) {
1451
+ return -1;
1452
+ }
1453
+ throw "unexpected end of file./" + _buflen;
1454
+ }
1455
+ const c = _str.charAt(_pos);
1456
+ _pos += 1;
1457
+ if (c == "=") {
1458
+ _buflen = 0;
1459
+ return -1;
1460
+ } else if (c.match(/^\s$/)) {
1461
+ continue;
1462
+ }
1463
+ _buffer = _buffer << 6 | decode(c.charCodeAt(0));
1464
+ _buflen += 6;
1465
+ }
1466
+ const n = _buffer >>> _buflen - 8 & 255;
1467
+ _buflen -= 8;
1468
+ return n;
1469
+ };
1470
+ const decode = function(c) {
1471
+ if (65 <= c && c <= 90) {
1472
+ return c - 65;
1473
+ } else if (97 <= c && c <= 122) {
1474
+ return c - 97 + 26;
1475
+ } else if (48 <= c && c <= 57) {
1476
+ return c - 48 + 52;
1477
+ } else if (c == 43) {
1478
+ return 62;
1479
+ } else if (c == 47) {
1480
+ return 63;
1481
+ } else {
1482
+ throw "c:" + c;
1483
+ }
1484
+ };
1485
+ return _this;
1486
+ };
1487
+ var gifImage = function(width, height) {
1488
+ const _width = width;
1489
+ const _height = height;
1490
+ const _data = new Array(width * height);
1491
+ const _this = {};
1492
+ _this.setPixel = function(x, y, pixel) {
1493
+ _data[y * _width + x] = pixel;
1494
+ };
1495
+ _this.write = function(out) {
1496
+ out.writeString("GIF87a");
1497
+ out.writeShort(_width);
1498
+ out.writeShort(_height);
1499
+ out.writeByte(128);
1500
+ out.writeByte(0);
1501
+ out.writeByte(0);
1502
+ out.writeByte(0);
1503
+ out.writeByte(0);
1504
+ out.writeByte(0);
1505
+ out.writeByte(255);
1506
+ out.writeByte(255);
1507
+ out.writeByte(255);
1508
+ out.writeString(",");
1509
+ out.writeShort(0);
1510
+ out.writeShort(0);
1511
+ out.writeShort(_width);
1512
+ out.writeShort(_height);
1513
+ out.writeByte(0);
1514
+ const lzwMinCodeSize = 2;
1515
+ const raster = getLZWRaster(lzwMinCodeSize);
1516
+ out.writeByte(lzwMinCodeSize);
1517
+ let offset = 0;
1518
+ while (raster.length - offset > 255) {
1519
+ out.writeByte(255);
1520
+ out.writeBytes(raster, offset, 255);
1521
+ offset += 255;
1522
+ }
1523
+ out.writeByte(raster.length - offset);
1524
+ out.writeBytes(raster, offset, raster.length - offset);
1525
+ out.writeByte(0);
1526
+ out.writeString(";");
1527
+ };
1528
+ const bitOutputStream = function(out) {
1529
+ const _out = out;
1530
+ let _bitLength = 0;
1531
+ let _bitBuffer = 0;
1532
+ const _this2 = {};
1533
+ _this2.write = function(data, length) {
1534
+ if (data >>> length != 0) {
1535
+ throw "length over";
1536
+ }
1537
+ while (_bitLength + length >= 8) {
1538
+ _out.writeByte(255 & (data << _bitLength | _bitBuffer));
1539
+ length -= 8 - _bitLength;
1540
+ data >>>= 8 - _bitLength;
1541
+ _bitBuffer = 0;
1542
+ _bitLength = 0;
1543
+ }
1544
+ _bitBuffer = data << _bitLength | _bitBuffer;
1545
+ _bitLength = _bitLength + length;
1546
+ };
1547
+ _this2.flush = function() {
1548
+ if (_bitLength > 0) {
1549
+ _out.writeByte(_bitBuffer);
1550
+ }
1551
+ };
1552
+ return _this2;
1553
+ };
1554
+ const getLZWRaster = function(lzwMinCodeSize) {
1555
+ const clearCode = 1 << lzwMinCodeSize;
1556
+ const endCode = (1 << lzwMinCodeSize) + 1;
1557
+ let bitLength = lzwMinCodeSize + 1;
1558
+ const table = lzwTable();
1559
+ for (let i = 0; i < clearCode; i += 1) {
1560
+ table.add(String.fromCharCode(i));
1561
+ }
1562
+ table.add(String.fromCharCode(clearCode));
1563
+ table.add(String.fromCharCode(endCode));
1564
+ const byteOut = byteArrayOutputStream();
1565
+ const bitOut = bitOutputStream(byteOut);
1566
+ bitOut.write(clearCode, bitLength);
1567
+ let dataIndex = 0;
1568
+ let s = String.fromCharCode(_data[dataIndex]);
1569
+ dataIndex += 1;
1570
+ while (dataIndex < _data.length) {
1571
+ const c = String.fromCharCode(_data[dataIndex]);
1572
+ dataIndex += 1;
1573
+ if (table.contains(s + c)) {
1574
+ s = s + c;
1575
+ } else {
1576
+ bitOut.write(table.indexOf(s), bitLength);
1577
+ if (table.size() < 4095) {
1578
+ if (table.size() == 1 << bitLength) {
1579
+ bitLength += 1;
1580
+ }
1581
+ table.add(s + c);
1582
+ }
1583
+ s = c;
1584
+ }
1585
+ }
1586
+ bitOut.write(table.indexOf(s), bitLength);
1587
+ bitOut.write(endCode, bitLength);
1588
+ bitOut.flush();
1589
+ return byteOut.toByteArray();
1590
+ };
1591
+ const lzwTable = function() {
1592
+ const _map = {};
1593
+ let _size = 0;
1594
+ const _this2 = {};
1595
+ _this2.add = function(key) {
1596
+ if (_this2.contains(key)) {
1597
+ throw "dup key:" + key;
1598
+ }
1599
+ _map[key] = _size;
1600
+ _size += 1;
1601
+ };
1602
+ _this2.size = function() {
1603
+ return _size;
1604
+ };
1605
+ _this2.indexOf = function(key) {
1606
+ return _map[key];
1607
+ };
1608
+ _this2.contains = function(key) {
1609
+ return typeof _map[key] != "undefined";
1610
+ };
1611
+ return _this2;
1612
+ };
1613
+ return _this;
1614
+ };
1615
+ var createDataURL = function(width, height, getPixel) {
1616
+ const gif = gifImage(width, height);
1617
+ for (let y = 0; y < height; y += 1) {
1618
+ for (let x = 0; x < width; x += 1) {
1619
+ gif.setPixel(x, y, getPixel(x, y));
1620
+ }
1621
+ }
1622
+ const b = byteArrayOutputStream();
1623
+ gif.write(b);
1624
+ const base64 = base64EncodeOutputStream();
1625
+ const bytes = b.toByteArray();
1626
+ for (let i = 0; i < bytes.length; i += 1) {
1627
+ base64.writeByte(bytes[i]);
1628
+ }
1629
+ base64.flush();
1630
+ return "data:image/gif;base64," + base64;
1631
+ };
1632
+ var qrcode_default = qrcode;
1633
+ var stringToBytes = qrcode.stringToBytes;
1634
+ export {
1635
+ qrcode_default as default,
1636
+ qrcode,
1637
+ stringToBytes
1638
+ };