@wirecat/amo-cli 0.6.0 → 0.7.0

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 (282) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -2
  3. package/contracts/wirecat.json +14 -0
  4. package/dist/amo/button.js +1 -1
  5. package/dist/amo/json.js +1 -1
  6. package/dist/amo/oauth.js +1 -2
  7. package/dist/amo/transport.js +1 -2
  8. package/dist/api-keys.js +1 -1
  9. package/dist/bin/amo.js +11 -11
  10. package/dist/bundle/amo.js +5 -183
  11. package/dist/bundle/{chunk-FYOPPKAN.js → chunk-3HWD4BKU.js} +4 -6
  12. package/dist/bundle/{chunk-GOCMJBEE.js → chunk-4EXURQQQ.js} +21 -19
  13. package/dist/bundle/chunk-AEWYRB6F.js +8 -0
  14. package/dist/bundle/{chunk-SWCJM3YD.js → chunk-GL7CRTHR.js} +3 -3
  15. package/dist/bundle/chunk-N2UB32VN.js +76 -0
  16. package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
  17. package/dist/bundle/program-SQH3SPOW.js +2352 -0
  18. package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
  19. package/dist/bundle/store-SJ2TOUGU.js +12 -0
  20. package/dist/bundle/writer-I7GBI3VE.js +12 -0
  21. package/dist/commands/account.js +1 -1
  22. package/dist/commands/api.js +1 -3
  23. package/dist/commands/crm-shared.js +2 -3
  24. package/dist/commands/schedule.js +1 -1
  25. package/dist/commands/session.js +1 -3
  26. package/dist/commands/write.js +1 -2
  27. package/dist/config.js +1 -2
  28. package/dist/context.js +1 -2
  29. package/dist/crm/activities.js +1 -1
  30. package/dist/crm/records.js +1 -1
  31. package/dist/crm/source.js +1 -1
  32. package/dist/crm/writer.js +1 -1
  33. package/dist/identity.js +4 -0
  34. package/dist/program.js +1 -2
  35. package/dist/setup/flow.js +1 -1
  36. package/dist/store.js +1 -1
  37. package/dist/version.js +1 -1
  38. package/dist/whoami.js +1 -1
  39. package/package.json +3 -3
  40. package/scenarios/first-sync.md +13 -11
  41. package/scenarios/keep-in-sync.md +7 -6
  42. package/scenarios/safe-agent-writes.md +10 -9
  43. package/dist/amo/account.d.ts +0 -18
  44. package/dist/amo/account.d.ts.map +0 -1
  45. package/dist/amo/account.js.map +0 -1
  46. package/dist/amo/allow-list.d.ts +0 -31
  47. package/dist/amo/allow-list.d.ts.map +0 -1
  48. package/dist/amo/allow-list.js.map +0 -1
  49. package/dist/amo/button.d.ts +0 -53
  50. package/dist/amo/button.d.ts.map +0 -1
  51. package/dist/amo/button.js.map +0 -1
  52. package/dist/amo/errors.d.ts +0 -12
  53. package/dist/amo/errors.d.ts.map +0 -1
  54. package/dist/amo/errors.js.map +0 -1
  55. package/dist/amo/json.d.ts +0 -3
  56. package/dist/amo/json.d.ts.map +0 -1
  57. package/dist/amo/json.js.map +0 -1
  58. package/dist/amo/oauth.d.ts +0 -64
  59. package/dist/amo/oauth.d.ts.map +0 -1
  60. package/dist/amo/oauth.js.map +0 -1
  61. package/dist/amo/operation.d.ts +0 -45
  62. package/dist/amo/operation.d.ts.map +0 -1
  63. package/dist/amo/operation.js.map +0 -1
  64. package/dist/amo/operations.d.ts +0 -3
  65. package/dist/amo/operations.d.ts.map +0 -1
  66. package/dist/amo/operations.js.map +0 -1
  67. package/dist/amo/routes.d.ts +0 -67
  68. package/dist/amo/routes.d.ts.map +0 -1
  69. package/dist/amo/routes.js.map +0 -1
  70. package/dist/amo/transport.d.ts +0 -62
  71. package/dist/amo/transport.d.ts.map +0 -1
  72. package/dist/amo/transport.js.map +0 -1
  73. package/dist/api-keys.d.ts +0 -47
  74. package/dist/api-keys.d.ts.map +0 -1
  75. package/dist/api-keys.js.map +0 -1
  76. package/dist/bin/amo.d.ts +0 -3
  77. package/dist/bin/amo.d.ts.map +0 -1
  78. package/dist/bin/amo.js.map +0 -1
  79. package/dist/bundle/agent-VVACEKSX.js +0 -42
  80. package/dist/bundle/all-profiles-QNUKL4NA.js +0 -320
  81. package/dist/bundle/anthropic-PQN6MNP7.js +0 -90
  82. package/dist/bundle/app-server-Q2QEA7GP.js +0 -258
  83. package/dist/bundle/areas-27FRPBF3.js +0 -71
  84. package/dist/bundle/bun-F4M4KCNA.js +0 -169
  85. package/dist/bundle/bun-sqlite-P5IDBDVR.js +0 -75
  86. package/dist/bundle/chunk-22KAQPX7.js +0 -58
  87. package/dist/bundle/chunk-2JGNMZ55.js +0 -338
  88. package/dist/bundle/chunk-2VDHC7QO.js +0 -288
  89. package/dist/bundle/chunk-34ZOMVUK.js +0 -185
  90. package/dist/bundle/chunk-3J3EDSXF.js +0 -1939
  91. package/dist/bundle/chunk-3TYER5IK.js +0 -80
  92. package/dist/bundle/chunk-5NGLCDYQ.js +0 -106
  93. package/dist/bundle/chunk-5SQTHOBI.js +0 -12313
  94. package/dist/bundle/chunk-6GE36KUE.js +0 -360
  95. package/dist/bundle/chunk-6GZKY3HV.js +0 -3752
  96. package/dist/bundle/chunk-6OV2TRGF.js +0 -362
  97. package/dist/bundle/chunk-7CPIZFOE.js +0 -460
  98. package/dist/bundle/chunk-A5K2NU3K.js +0 -37780
  99. package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
  100. package/dist/bundle/chunk-AEC4H5WZ.js +0 -259
  101. package/dist/bundle/chunk-APBEDWOE.js +0 -1718
  102. package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
  103. package/dist/bundle/chunk-B7L5MSRP.js +0 -136
  104. package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
  105. package/dist/bundle/chunk-D72URWJE.js +0 -532
  106. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  107. package/dist/bundle/chunk-DIZEHPS6.js +0 -1347
  108. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  109. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  110. package/dist/bundle/chunk-DUPCDJ3W.js +0 -357
  111. package/dist/bundle/chunk-DWT24UVR.js +0 -388
  112. package/dist/bundle/chunk-DXWJORSY.js +0 -1703
  113. package/dist/bundle/chunk-DY3PLWIH.js +0 -332
  114. package/dist/bundle/chunk-DYWHAJRK.js +0 -1259
  115. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  116. package/dist/bundle/chunk-EXRM3ML4.js +0 -76
  117. package/dist/bundle/chunk-FFER7KJI.js +0 -407
  118. package/dist/bundle/chunk-FIP2DG7W.js +0 -64
  119. package/dist/bundle/chunk-FTH6WGYO.js +0 -24
  120. package/dist/bundle/chunk-FWRLGIF6.js +0 -5304
  121. package/dist/bundle/chunk-G3N2RHGF.js +0 -738
  122. package/dist/bundle/chunk-G46PNDWL.js +0 -58
  123. package/dist/bundle/chunk-G6NY7LFB.js +0 -230
  124. package/dist/bundle/chunk-GRGCZSES.js +0 -1007
  125. package/dist/bundle/chunk-GVSKLZRD.js +0 -30
  126. package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
  127. package/dist/bundle/chunk-HN2LCLGT.js +0 -1068
  128. package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
  129. package/dist/bundle/chunk-HOF7GQWW.js +0 -142
  130. package/dist/bundle/chunk-HUAHLO6N.js +0 -29
  131. package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
  132. package/dist/bundle/chunk-IN3VL7UU.js +0 -560
  133. package/dist/bundle/chunk-ISQ23VKV.js +0 -123
  134. package/dist/bundle/chunk-JVBCQHCS.js +0 -80
  135. package/dist/bundle/chunk-K5W7YEHB.js +0 -9541
  136. package/dist/bundle/chunk-KAFSS35C.js +0 -193
  137. package/dist/bundle/chunk-KLRCTMES.js +0 -100
  138. package/dist/bundle/chunk-KYRYD4CR.js +0 -38
  139. package/dist/bundle/chunk-LBZSURLL.js +0 -798
  140. package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
  141. package/dist/bundle/chunk-LH6FJYMO.js +0 -334
  142. package/dist/bundle/chunk-LJKINNWC.js +0 -209
  143. package/dist/bundle/chunk-M36XP74N.js +0 -86
  144. package/dist/bundle/chunk-MNPGZCKE.js +0 -361
  145. package/dist/bundle/chunk-MRPMORLH.js +0 -353
  146. package/dist/bundle/chunk-NNREILWP.js +0 -189
  147. package/dist/bundle/chunk-NSOY4FMN.js +0 -159
  148. package/dist/bundle/chunk-OEEWVKJX.js +0 -53
  149. package/dist/bundle/chunk-OGJFDKDL.js +0 -161
  150. package/dist/bundle/chunk-PATZAYFZ.js +0 -453
  151. package/dist/bundle/chunk-PCR6GFNP.js +0 -1171
  152. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  153. package/dist/bundle/chunk-Q4MH2O5E.js +0 -108
  154. package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
  155. package/dist/bundle/chunk-QQRJEWKB.js +0 -1197
  156. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  157. package/dist/bundle/chunk-SDVUGWD7.js +0 -614
  158. package/dist/bundle/chunk-SEFE6PGL.js +0 -218
  159. package/dist/bundle/chunk-SYRDEMQE.js +0 -68141
  160. package/dist/bundle/chunk-SYYQZDHJ.js +0 -95
  161. package/dist/bundle/chunk-T3W4V4A6.js +0 -63
  162. package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
  163. package/dist/bundle/chunk-TES7MB6I.js +0 -82
  164. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  165. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  166. package/dist/bundle/chunk-U6XPWCWM.js +0 -133
  167. package/dist/bundle/chunk-UFKC7TIX.js +0 -28404
  168. package/dist/bundle/chunk-UNWF3TH5.js +0 -274
  169. package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
  170. package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
  171. package/dist/bundle/chunk-X76RS6JO.js +0 -1043
  172. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  173. package/dist/bundle/chunk-YF3S26TS.js +0 -4172
  174. package/dist/bundle/chunk-ZCQ4H7CA.js +0 -54
  175. package/dist/bundle/chunk-ZOZV32IR.js +0 -170
  176. package/dist/bundle/chunk-ZTKHXDEU.js +0 -52
  177. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  178. package/dist/bundle/cli-EAD3WZLR.js +0 -1254
  179. package/dist/bundle/command-contract-SMEJ2ICG.js +0 -40
  180. package/dist/bundle/command-server-entry-YTZP6I4T.js +0 -169
  181. package/dist/bundle/decode-57BE5OBT.js +0 -296
  182. package/dist/bundle/dispatch-56FECRCU.js +0 -411
  183. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  184. package/dist/bundle/dist-T54K3FJV.js +0 -7577
  185. package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
  186. package/dist/bundle/embed-NFGFYUO4.js +0 -37
  187. package/dist/bundle/embedder-SRBOJMXX.js +0 -110
  188. package/dist/bundle/failure-WDSX6H3B.js +0 -24
  189. package/dist/bundle/first-run-HWRUL2GR.js +0 -28
  190. package/dist/bundle/first-screen-ATN4D3FQ.js +0 -41
  191. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  192. package/dist/bundle/meeting-combined-BGDEHCWY.js +0 -26
  193. package/dist/bundle/meeting-model-WWGVRXPL.js +0 -24
  194. package/dist/bundle/meeting-semantic-ZQ47BL2Z.js +0 -21
  195. package/dist/bundle/node-P3PUHKYH.js +0 -176
  196. package/dist/bundle/node-P4E63KXA.js +0 -2340
  197. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  198. package/dist/bundle/node-sqlite-JOTSNH3P.js +0 -73
  199. package/dist/bundle/oauth-XPSAL6VO.js +0 -19
  200. package/dist/bundle/open-PO52FVA5.js +0 -22
  201. package/dist/bundle/openai-WITYLMY5.js +0 -237
  202. package/dist/bundle/process-AFIXYXWL.js +0 -91
  203. package/dist/bundle/program-JODTZNBZ.js +0 -4920
  204. package/dist/bundle/prompt-XORLAXHY.js +0 -16
  205. package/dist/bundle/recognize-JKMZHDYS.js +0 -25
  206. package/dist/bundle/remote-3IMEJTEH.js +0 -30
  207. package/dist/bundle/rerank-3F2E6NNN.js +0 -51
  208. package/dist/bundle/serve-6BWU3NMB.js +0 -198
  209. package/dist/bundle/server-GPSB5WFG.js +0 -220
  210. package/dist/bundle/server-HMCC64ZU.js +0 -88
  211. package/dist/bundle/source-E72OS27D.js +0 -47
  212. package/dist/bundle/sqlite-runtime-YHYQDUXE.js +0 -19
  213. package/dist/bundle/state-R7W4U6T4.js +0 -35
  214. package/dist/bundle/store-HTVRL7FB.js +0 -312
  215. package/dist/bundle/store-IWW6U6QN.js +0 -34
  216. package/dist/bundle/store-TBZ3ZS6H.js +0 -186
  217. package/dist/bundle/store-maintenance-command-CJM2VLMW.js +0 -75
  218. package/dist/bundle/surface-5GBWNYBE.js +0 -74
  219. package/dist/bundle/writer-TW2Q55VJ.js +0 -49
  220. package/dist/commands/account.d.ts +0 -4
  221. package/dist/commands/account.d.ts.map +0 -1
  222. package/dist/commands/account.js.map +0 -1
  223. package/dist/commands/api.d.ts +0 -3
  224. package/dist/commands/api.d.ts.map +0 -1
  225. package/dist/commands/api.js.map +0 -1
  226. package/dist/commands/crm-shared.d.ts +0 -8
  227. package/dist/commands/crm-shared.d.ts.map +0 -1
  228. package/dist/commands/crm-shared.js.map +0 -1
  229. package/dist/commands/schedule.d.ts +0 -3
  230. package/dist/commands/schedule.d.ts.map +0 -1
  231. package/dist/commands/schedule.js.map +0 -1
  232. package/dist/commands/session.d.ts +0 -35
  233. package/dist/commands/session.d.ts.map +0 -1
  234. package/dist/commands/session.js.map +0 -1
  235. package/dist/commands/write.d.ts +0 -14
  236. package/dist/commands/write.d.ts.map +0 -1
  237. package/dist/commands/write.js.map +0 -1
  238. package/dist/config.d.ts +0 -4
  239. package/dist/config.d.ts.map +0 -1
  240. package/dist/config.js.map +0 -1
  241. package/dist/context.d.ts +0 -62
  242. package/dist/context.d.ts.map +0 -1
  243. package/dist/context.js.map +0 -1
  244. package/dist/crm/activities.d.ts +0 -32
  245. package/dist/crm/activities.d.ts.map +0 -1
  246. package/dist/crm/activities.js.map +0 -1
  247. package/dist/crm/records.d.ts +0 -20
  248. package/dist/crm/records.d.ts.map +0 -1
  249. package/dist/crm/records.js.map +0 -1
  250. package/dist/crm/source.d.ts +0 -41
  251. package/dist/crm/source.d.ts.map +0 -1
  252. package/dist/crm/source.js.map +0 -1
  253. package/dist/crm/writer.d.ts +0 -14
  254. package/dist/crm/writer.d.ts.map +0 -1
  255. package/dist/crm/writer.js.map +0 -1
  256. package/dist/identity.d.ts +0 -7
  257. package/dist/identity.d.ts.map +0 -1
  258. package/dist/identity.js.map +0 -1
  259. package/dist/index.d.ts +0 -3
  260. package/dist/index.d.ts.map +0 -1
  261. package/dist/index.js.map +0 -1
  262. package/dist/program.d.ts +0 -6
  263. package/dist/program.d.ts.map +0 -1
  264. package/dist/program.js.map +0 -1
  265. package/dist/reasons.d.ts +0 -10
  266. package/dist/reasons.d.ts.map +0 -1
  267. package/dist/reasons.js.map +0 -1
  268. package/dist/setup/flow.d.ts +0 -2
  269. package/dist/setup/flow.d.ts.map +0 -1
  270. package/dist/setup/flow.js.map +0 -1
  271. package/dist/store.d.ts +0 -15
  272. package/dist/store.d.ts.map +0 -1
  273. package/dist/store.js.map +0 -1
  274. package/dist/version.d.ts +0 -2
  275. package/dist/version.d.ts.map +0 -1
  276. package/dist/version.js.map +0 -1
  277. package/dist/wcat.d.ts +0 -3
  278. package/dist/wcat.d.ts.map +0 -1
  279. package/dist/wcat.js.map +0 -1
  280. package/dist/whoami.d.ts +0 -24
  281. package/dist/whoami.d.ts.map +0 -1
  282. package/dist/whoami.js.map +0 -1
@@ -1,1718 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- REASONS
5
- } from "./chunk-X76RS6JO.js";
6
- import {
7
- RECORD_TYPES
8
- } from "./chunk-3J3EDSXF.js";
9
- import {
10
- defineReasons
11
- } from "./chunk-QFOP3KUP.js";
12
- import {
13
- __name
14
- } from "./chunk-ZVVMGPBJ.js";
15
-
16
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/records-table.js
17
- var TABLE_RECORD_TYPES = Object.keys(RECORD_TYPES).filter((type) => RECORD_TYPES[type].sheet !== false);
18
-
19
- // node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs
20
- var qrcode = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
21
- const PAD0 = 236;
22
- const PAD1 = 17;
23
- let _typeNumber = typeNumber;
24
- const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
25
- let _modules = null;
26
- let _moduleCount = 0;
27
- let _dataCache = null;
28
- const _dataList = [];
29
- const _this = {};
30
- const makeImpl = /* @__PURE__ */ __name(function(test, maskPattern) {
31
- _moduleCount = _typeNumber * 4 + 17;
32
- _modules = (function(moduleCount) {
33
- const modules = new Array(moduleCount);
34
- for (let row = 0; row < moduleCount; row += 1) {
35
- modules[row] = new Array(moduleCount);
36
- for (let col = 0; col < moduleCount; col += 1) {
37
- modules[row][col] = null;
38
- }
39
- }
40
- return modules;
41
- })(_moduleCount);
42
- setupPositionProbePattern(0, 0);
43
- setupPositionProbePattern(_moduleCount - 7, 0);
44
- setupPositionProbePattern(0, _moduleCount - 7);
45
- setupPositionAdjustPattern();
46
- setupTimingPattern();
47
- setupTypeInfo(test, maskPattern);
48
- if (_typeNumber >= 7) {
49
- setupTypeNumber(test);
50
- }
51
- if (_dataCache == null) {
52
- _dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
53
- }
54
- mapData(_dataCache, maskPattern);
55
- }, "makeImpl");
56
- const setupPositionProbePattern = /* @__PURE__ */ __name(function(row, col) {
57
- for (let r = -1; r <= 7; r += 1) {
58
- if (row + r <= -1 || _moduleCount <= row + r) continue;
59
- for (let c = -1; c <= 7; c += 1) {
60
- if (col + c <= -1 || _moduleCount <= col + c) continue;
61
- 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) {
62
- _modules[row + r][col + c] = true;
63
- } else {
64
- _modules[row + r][col + c] = false;
65
- }
66
- }
67
- }
68
- }, "setupPositionProbePattern");
69
- const getBestMaskPattern = /* @__PURE__ */ __name(function() {
70
- let minLostPoint = 0;
71
- let pattern = 0;
72
- for (let i = 0; i < 8; i += 1) {
73
- makeImpl(true, i);
74
- const lostPoint = QRUtil.getLostPoint(_this);
75
- if (i == 0 || minLostPoint > lostPoint) {
76
- minLostPoint = lostPoint;
77
- pattern = i;
78
- }
79
- }
80
- return pattern;
81
- }, "getBestMaskPattern");
82
- const setupTimingPattern = /* @__PURE__ */ __name(function() {
83
- for (let r = 8; r < _moduleCount - 8; r += 1) {
84
- if (_modules[r][6] != null) {
85
- continue;
86
- }
87
- _modules[r][6] = r % 2 == 0;
88
- }
89
- for (let c = 8; c < _moduleCount - 8; c += 1) {
90
- if (_modules[6][c] != null) {
91
- continue;
92
- }
93
- _modules[6][c] = c % 2 == 0;
94
- }
95
- }, "setupTimingPattern");
96
- const setupPositionAdjustPattern = /* @__PURE__ */ __name(function() {
97
- const pos = QRUtil.getPatternPosition(_typeNumber);
98
- for (let i = 0; i < pos.length; i += 1) {
99
- for (let j = 0; j < pos.length; j += 1) {
100
- const row = pos[i];
101
- const col = pos[j];
102
- if (_modules[row][col] != null) {
103
- continue;
104
- }
105
- for (let r = -2; r <= 2; r += 1) {
106
- for (let c = -2; c <= 2; c += 1) {
107
- if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
108
- _modules[row + r][col + c] = true;
109
- } else {
110
- _modules[row + r][col + c] = false;
111
- }
112
- }
113
- }
114
- }
115
- }
116
- }, "setupPositionAdjustPattern");
117
- const setupTypeNumber = /* @__PURE__ */ __name(function(test) {
118
- const bits = QRUtil.getBCHTypeNumber(_typeNumber);
119
- for (let i = 0; i < 18; i += 1) {
120
- const mod = !test && (bits >> i & 1) == 1;
121
- _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
122
- }
123
- for (let i = 0; i < 18; i += 1) {
124
- const mod = !test && (bits >> i & 1) == 1;
125
- _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
126
- }
127
- }, "setupTypeNumber");
128
- const setupTypeInfo = /* @__PURE__ */ __name(function(test, maskPattern) {
129
- const data = _errorCorrectionLevel << 3 | maskPattern;
130
- const bits = QRUtil.getBCHTypeInfo(data);
131
- for (let i = 0; i < 15; i += 1) {
132
- const mod = !test && (bits >> i & 1) == 1;
133
- if (i < 6) {
134
- _modules[i][8] = mod;
135
- } else if (i < 8) {
136
- _modules[i + 1][8] = mod;
137
- } else {
138
- _modules[_moduleCount - 15 + i][8] = mod;
139
- }
140
- }
141
- for (let i = 0; i < 15; i += 1) {
142
- const mod = !test && (bits >> i & 1) == 1;
143
- if (i < 8) {
144
- _modules[8][_moduleCount - i - 1] = mod;
145
- } else if (i < 9) {
146
- _modules[8][15 - i - 1 + 1] = mod;
147
- } else {
148
- _modules[8][15 - i - 1] = mod;
149
- }
150
- }
151
- _modules[_moduleCount - 8][8] = !test;
152
- }, "setupTypeInfo");
153
- const mapData = /* @__PURE__ */ __name(function(data, maskPattern) {
154
- let inc = -1;
155
- let row = _moduleCount - 1;
156
- let bitIndex = 7;
157
- let byteIndex = 0;
158
- const maskFunc = QRUtil.getMaskFunction(maskPattern);
159
- for (let col = _moduleCount - 1; col > 0; col -= 2) {
160
- if (col == 6) col -= 1;
161
- while (true) {
162
- for (let c = 0; c < 2; c += 1) {
163
- if (_modules[row][col - c] == null) {
164
- let dark = false;
165
- if (byteIndex < data.length) {
166
- dark = (data[byteIndex] >>> bitIndex & 1) == 1;
167
- }
168
- const mask = maskFunc(row, col - c);
169
- if (mask) {
170
- dark = !dark;
171
- }
172
- _modules[row][col - c] = dark;
173
- bitIndex -= 1;
174
- if (bitIndex == -1) {
175
- byteIndex += 1;
176
- bitIndex = 7;
177
- }
178
- }
179
- }
180
- row += inc;
181
- if (row < 0 || _moduleCount <= row) {
182
- row -= inc;
183
- inc = -inc;
184
- break;
185
- }
186
- }
187
- }
188
- }, "mapData");
189
- const createBytes = /* @__PURE__ */ __name(function(buffer, rsBlocks) {
190
- let offset = 0;
191
- let maxDcCount = 0;
192
- let maxEcCount = 0;
193
- const dcdata = new Array(rsBlocks.length);
194
- const ecdata = new Array(rsBlocks.length);
195
- for (let r = 0; r < rsBlocks.length; r += 1) {
196
- const dcCount = rsBlocks[r].dataCount;
197
- const ecCount = rsBlocks[r].totalCount - dcCount;
198
- maxDcCount = Math.max(maxDcCount, dcCount);
199
- maxEcCount = Math.max(maxEcCount, ecCount);
200
- dcdata[r] = new Array(dcCount);
201
- for (let i = 0; i < dcdata[r].length; i += 1) {
202
- dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
203
- }
204
- offset += dcCount;
205
- const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
206
- const rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
207
- const modPoly = rawPoly.mod(rsPoly);
208
- ecdata[r] = new Array(rsPoly.getLength() - 1);
209
- for (let i = 0; i < ecdata[r].length; i += 1) {
210
- const modIndex = i + modPoly.getLength() - ecdata[r].length;
211
- ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
212
- }
213
- }
214
- let totalCodeCount = 0;
215
- for (let i = 0; i < rsBlocks.length; i += 1) {
216
- totalCodeCount += rsBlocks[i].totalCount;
217
- }
218
- const data = new Array(totalCodeCount);
219
- let index = 0;
220
- for (let i = 0; i < maxDcCount; i += 1) {
221
- for (let r = 0; r < rsBlocks.length; r += 1) {
222
- if (i < dcdata[r].length) {
223
- data[index] = dcdata[r][i];
224
- index += 1;
225
- }
226
- }
227
- }
228
- for (let i = 0; i < maxEcCount; i += 1) {
229
- for (let r = 0; r < rsBlocks.length; r += 1) {
230
- if (i < ecdata[r].length) {
231
- data[index] = ecdata[r][i];
232
- index += 1;
233
- }
234
- }
235
- }
236
- return data;
237
- }, "createBytes");
238
- const createData = /* @__PURE__ */ __name(function(typeNumber2, errorCorrectionLevel2, dataList) {
239
- const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
240
- const buffer = qrBitBuffer();
241
- for (let i = 0; i < dataList.length; i += 1) {
242
- const data = dataList[i];
243
- buffer.put(data.getMode(), 4);
244
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
245
- data.write(buffer);
246
- }
247
- let totalDataCount = 0;
248
- for (let i = 0; i < rsBlocks.length; i += 1) {
249
- totalDataCount += rsBlocks[i].dataCount;
250
- }
251
- if (buffer.getLengthInBits() > totalDataCount * 8) {
252
- throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
253
- }
254
- if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
255
- buffer.put(0, 4);
256
- }
257
- while (buffer.getLengthInBits() % 8 != 0) {
258
- buffer.putBit(false);
259
- }
260
- while (true) {
261
- if (buffer.getLengthInBits() >= totalDataCount * 8) {
262
- break;
263
- }
264
- buffer.put(PAD0, 8);
265
- if (buffer.getLengthInBits() >= totalDataCount * 8) {
266
- break;
267
- }
268
- buffer.put(PAD1, 8);
269
- }
270
- return createBytes(buffer, rsBlocks);
271
- }, "createData");
272
- _this.addData = function(data, mode) {
273
- mode = mode || "Byte";
274
- let newData = null;
275
- switch (mode) {
276
- case "Numeric":
277
- newData = qrNumber(data);
278
- break;
279
- case "Alphanumeric":
280
- newData = qrAlphaNum(data);
281
- break;
282
- case "Byte":
283
- newData = qr8BitByte(data);
284
- break;
285
- case "Kanji":
286
- newData = qrKanji(data);
287
- break;
288
- default:
289
- throw "mode:" + mode;
290
- }
291
- _dataList.push(newData);
292
- _dataCache = null;
293
- };
294
- _this.isDark = function(row, col) {
295
- if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
296
- throw row + "," + col;
297
- }
298
- return _modules[row][col];
299
- };
300
- _this.getModuleCount = function() {
301
- return _moduleCount;
302
- };
303
- _this.make = function() {
304
- if (_typeNumber < 1) {
305
- let typeNumber2 = 1;
306
- for (; typeNumber2 < 40; typeNumber2++) {
307
- const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
308
- const buffer = qrBitBuffer();
309
- for (let i = 0; i < _dataList.length; i++) {
310
- const data = _dataList[i];
311
- buffer.put(data.getMode(), 4);
312
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
313
- data.write(buffer);
314
- }
315
- let totalDataCount = 0;
316
- for (let i = 0; i < rsBlocks.length; i++) {
317
- totalDataCount += rsBlocks[i].dataCount;
318
- }
319
- if (buffer.getLengthInBits() <= totalDataCount * 8) {
320
- break;
321
- }
322
- }
323
- _typeNumber = typeNumber2;
324
- }
325
- makeImpl(false, getBestMaskPattern());
326
- };
327
- _this.createTableTag = function(cellSize, margin) {
328
- cellSize = cellSize || 2;
329
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
330
- let qrHtml = "";
331
- qrHtml += '<table style="';
332
- qrHtml += " border-width: 0px; border-style: none;";
333
- qrHtml += " border-collapse: collapse;";
334
- qrHtml += " padding: 0px; margin: " + margin + "px;";
335
- qrHtml += '">';
336
- qrHtml += "<tbody>";
337
- for (let r = 0; r < _this.getModuleCount(); r += 1) {
338
- qrHtml += "<tr>";
339
- for (let c = 0; c < _this.getModuleCount(); c += 1) {
340
- qrHtml += '<td style="';
341
- qrHtml += " border-width: 0px; border-style: none;";
342
- qrHtml += " border-collapse: collapse;";
343
- qrHtml += " padding: 0px; margin: 0px;";
344
- qrHtml += " width: " + cellSize + "px;";
345
- qrHtml += " height: " + cellSize + "px;";
346
- qrHtml += " background-color: ";
347
- qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
348
- qrHtml += ";";
349
- qrHtml += '"/>';
350
- }
351
- qrHtml += "</tr>";
352
- }
353
- qrHtml += "</tbody>";
354
- qrHtml += "</table>";
355
- return qrHtml;
356
- };
357
- _this.createSvgTag = function(cellSize, margin, alt, title) {
358
- let opts = {};
359
- if (typeof arguments[0] == "object") {
360
- opts = arguments[0];
361
- cellSize = opts.cellSize;
362
- margin = opts.margin;
363
- alt = opts.alt;
364
- title = opts.title;
365
- }
366
- cellSize = cellSize || 2;
367
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
368
- alt = typeof alt === "string" ? { text: alt } : alt || {};
369
- alt.text = alt.text || null;
370
- alt.id = alt.text ? alt.id || "qrcode-description" : null;
371
- title = typeof title === "string" ? { text: title } : title || {};
372
- title.text = title.text || null;
373
- title.id = title.text ? title.id || "qrcode-title" : null;
374
- const size = _this.getModuleCount() * cellSize + margin * 2;
375
- let c, mc, r, mr, qrSvg = "", rect;
376
- rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
377
- qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
378
- qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
379
- qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
380
- qrSvg += ' preserveAspectRatio="xMinYMin meet"';
381
- qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
382
- qrSvg += ">";
383
- qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
384
- qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
385
- qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
386
- qrSvg += '<path d="';
387
- for (r = 0; r < _this.getModuleCount(); r += 1) {
388
- mr = r * cellSize + margin;
389
- for (c = 0; c < _this.getModuleCount(); c += 1) {
390
- if (_this.isDark(r, c)) {
391
- mc = c * cellSize + margin;
392
- qrSvg += "M" + mc + "," + mr + rect;
393
- }
394
- }
395
- }
396
- qrSvg += '" stroke="transparent" fill="black"/>';
397
- qrSvg += "</svg>";
398
- return qrSvg;
399
- };
400
- _this.createDataURL = function(cellSize, margin) {
401
- cellSize = cellSize || 2;
402
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
403
- const size = _this.getModuleCount() * cellSize + margin * 2;
404
- const min = margin;
405
- const max = size - margin;
406
- return createDataURL(size, size, function(x, y) {
407
- if (min <= x && x < max && min <= y && y < max) {
408
- const c = Math.floor((x - min) / cellSize);
409
- const r = Math.floor((y - min) / cellSize);
410
- return _this.isDark(r, c) ? 0 : 1;
411
- } else {
412
- return 1;
413
- }
414
- });
415
- };
416
- _this.createImgTag = function(cellSize, margin, alt) {
417
- cellSize = cellSize || 2;
418
- margin = typeof margin == "undefined" ? cellSize * 4 : margin;
419
- const size = _this.getModuleCount() * cellSize + margin * 2;
420
- let img = "";
421
- img += "<img";
422
- img += ' src="';
423
- img += _this.createDataURL(cellSize, margin);
424
- img += '"';
425
- img += ' width="';
426
- img += size;
427
- img += '"';
428
- img += ' height="';
429
- img += size;
430
- img += '"';
431
- if (alt) {
432
- img += ' alt="';
433
- img += escapeXml(alt);
434
- img += '"';
435
- }
436
- img += "/>";
437
- return img;
438
- };
439
- const escapeXml = /* @__PURE__ */ __name(function(s) {
440
- let escaped = "";
441
- for (let i = 0; i < s.length; i += 1) {
442
- const c = s.charAt(i);
443
- switch (c) {
444
- case "<":
445
- escaped += "&lt;";
446
- break;
447
- case ">":
448
- escaped += "&gt;";
449
- break;
450
- case "&":
451
- escaped += "&amp;";
452
- break;
453
- case '"':
454
- escaped += "&quot;";
455
- break;
456
- default:
457
- escaped += c;
458
- break;
459
- }
460
- }
461
- return escaped;
462
- }, "escapeXml");
463
- const _createHalfASCII = /* @__PURE__ */ __name(function(margin) {
464
- const cellSize = 1;
465
- margin = typeof margin == "undefined" ? cellSize * 2 : margin;
466
- const size = _this.getModuleCount() * cellSize + margin * 2;
467
- const min = margin;
468
- const max = size - margin;
469
- let y, x, r1, r2, p;
470
- const blocks = {
471
- "\u2588\u2588": "\u2588",
472
- "\u2588 ": "\u2580",
473
- " \u2588": "\u2584",
474
- " ": " "
475
- };
476
- const blocksLastLineNoMargin = {
477
- "\u2588\u2588": "\u2580",
478
- "\u2588 ": "\u2580",
479
- " \u2588": " ",
480
- " ": " "
481
- };
482
- let ascii = "";
483
- for (y = 0; y < size; y += 2) {
484
- r1 = Math.floor((y - min) / cellSize);
485
- r2 = Math.floor((y + 1 - min) / cellSize);
486
- for (x = 0; x < size; x += 1) {
487
- p = "\u2588";
488
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
489
- p = " ";
490
- }
491
- if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
492
- p += " ";
493
- } else {
494
- p += "\u2588";
495
- }
496
- ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
497
- }
498
- ascii += "\n";
499
- }
500
- if (size % 2 && margin > 0) {
501
- return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("\u2580");
502
- }
503
- return ascii.substring(0, ascii.length - 1);
504
- }, "_createHalfASCII");
505
- _this.createASCII = function(cellSize, margin) {
506
- cellSize = cellSize || 1;
507
- if (cellSize < 2) {
508
- return _createHalfASCII(margin);
509
- }
510
- cellSize -= 1;
511
- margin = typeof margin == "undefined" ? cellSize * 2 : margin;
512
- const size = _this.getModuleCount() * cellSize + margin * 2;
513
- const min = margin;
514
- const max = size - margin;
515
- let y, x, r, p;
516
- const white = Array(cellSize + 1).join("\u2588\u2588");
517
- const black = Array(cellSize + 1).join(" ");
518
- let ascii = "";
519
- let line = "";
520
- for (y = 0; y < size; y += 1) {
521
- r = Math.floor((y - min) / cellSize);
522
- line = "";
523
- for (x = 0; x < size; x += 1) {
524
- p = 1;
525
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
526
- p = 0;
527
- }
528
- line += p ? white : black;
529
- }
530
- for (r = 0; r < cellSize; r += 1) {
531
- ascii += line + "\n";
532
- }
533
- }
534
- return ascii.substring(0, ascii.length - 1);
535
- };
536
- _this.renderTo2dContext = function(context, cellSize) {
537
- cellSize = cellSize || 2;
538
- const length = _this.getModuleCount();
539
- for (let row = 0; row < length; row++) {
540
- for (let col = 0; col < length; col++) {
541
- context.fillStyle = _this.isDark(row, col) ? "black" : "white";
542
- context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
543
- }
544
- }
545
- };
546
- return _this;
547
- }, "qrcode");
548
- qrcode.stringToBytes = function(s) {
549
- const bytes = [];
550
- for (let i = 0; i < s.length; i += 1) {
551
- const c = s.charCodeAt(i);
552
- bytes.push(c & 255);
553
- }
554
- return bytes;
555
- };
556
- qrcode.createStringToBytes = function(unicodeData, numChars) {
557
- const unicodeMap = (function() {
558
- const bin = base64DecodeInputStream(unicodeData);
559
- const read = /* @__PURE__ */ __name(function() {
560
- const b = bin.read();
561
- if (b == -1) throw "eof";
562
- return b;
563
- }, "read");
564
- let count = 0;
565
- const unicodeMap2 = {};
566
- while (true) {
567
- const b0 = bin.read();
568
- if (b0 == -1) break;
569
- const b1 = read();
570
- const b2 = read();
571
- const b3 = read();
572
- const k = String.fromCharCode(b0 << 8 | b1);
573
- const v = b2 << 8 | b3;
574
- unicodeMap2[k] = v;
575
- count += 1;
576
- }
577
- if (count != numChars) {
578
- throw count + " != " + numChars;
579
- }
580
- return unicodeMap2;
581
- })();
582
- const unknownChar = "?".charCodeAt(0);
583
- return function(s) {
584
- const bytes = [];
585
- for (let i = 0; i < s.length; i += 1) {
586
- const c = s.charCodeAt(i);
587
- if (c < 128) {
588
- bytes.push(c);
589
- } else {
590
- const b = unicodeMap[s.charAt(i)];
591
- if (typeof b == "number") {
592
- if ((b & 255) == b) {
593
- bytes.push(b);
594
- } else {
595
- bytes.push(b >>> 8);
596
- bytes.push(b & 255);
597
- }
598
- } else {
599
- bytes.push(unknownChar);
600
- }
601
- }
602
- }
603
- return bytes;
604
- };
605
- };
606
- var QRMode = {
607
- MODE_NUMBER: 1 << 0,
608
- MODE_ALPHA_NUM: 1 << 1,
609
- MODE_8BIT_BYTE: 1 << 2,
610
- MODE_KANJI: 1 << 3
611
- };
612
- var QRErrorCorrectionLevel = {
613
- L: 1,
614
- M: 0,
615
- Q: 3,
616
- H: 2
617
- };
618
- var QRMaskPattern = {
619
- PATTERN000: 0,
620
- PATTERN001: 1,
621
- PATTERN010: 2,
622
- PATTERN011: 3,
623
- PATTERN100: 4,
624
- PATTERN101: 5,
625
- PATTERN110: 6,
626
- PATTERN111: 7
627
- };
628
- var QRUtil = (function() {
629
- const PATTERN_POSITION_TABLE = [
630
- [],
631
- [6, 18],
632
- [6, 22],
633
- [6, 26],
634
- [6, 30],
635
- [6, 34],
636
- [6, 22, 38],
637
- [6, 24, 42],
638
- [6, 26, 46],
639
- [6, 28, 50],
640
- [6, 30, 54],
641
- [6, 32, 58],
642
- [6, 34, 62],
643
- [6, 26, 46, 66],
644
- [6, 26, 48, 70],
645
- [6, 26, 50, 74],
646
- [6, 30, 54, 78],
647
- [6, 30, 56, 82],
648
- [6, 30, 58, 86],
649
- [6, 34, 62, 90],
650
- [6, 28, 50, 72, 94],
651
- [6, 26, 50, 74, 98],
652
- [6, 30, 54, 78, 102],
653
- [6, 28, 54, 80, 106],
654
- [6, 32, 58, 84, 110],
655
- [6, 30, 58, 86, 114],
656
- [6, 34, 62, 90, 118],
657
- [6, 26, 50, 74, 98, 122],
658
- [6, 30, 54, 78, 102, 126],
659
- [6, 26, 52, 78, 104, 130],
660
- [6, 30, 56, 82, 108, 134],
661
- [6, 34, 60, 86, 112, 138],
662
- [6, 30, 58, 86, 114, 142],
663
- [6, 34, 62, 90, 118, 146],
664
- [6, 30, 54, 78, 102, 126, 150],
665
- [6, 24, 50, 76, 102, 128, 154],
666
- [6, 28, 54, 80, 106, 132, 158],
667
- [6, 32, 58, 84, 110, 136, 162],
668
- [6, 26, 54, 82, 110, 138, 166],
669
- [6, 30, 58, 86, 114, 142, 170]
670
- ];
671
- const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
672
- const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
673
- const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
674
- const _this = {};
675
- const getBCHDigit = /* @__PURE__ */ __name(function(data) {
676
- let digit = 0;
677
- while (data != 0) {
678
- digit += 1;
679
- data >>>= 1;
680
- }
681
- return digit;
682
- }, "getBCHDigit");
683
- _this.getBCHTypeInfo = function(data) {
684
- let d = data << 10;
685
- while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
686
- d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
687
- }
688
- return (data << 10 | d) ^ G15_MASK;
689
- };
690
- _this.getBCHTypeNumber = function(data) {
691
- let d = data << 12;
692
- while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
693
- d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
694
- }
695
- return data << 12 | d;
696
- };
697
- _this.getPatternPosition = function(typeNumber) {
698
- return PATTERN_POSITION_TABLE[typeNumber - 1];
699
- };
700
- _this.getMaskFunction = function(maskPattern) {
701
- switch (maskPattern) {
702
- case QRMaskPattern.PATTERN000:
703
- return function(i, j) {
704
- return (i + j) % 2 == 0;
705
- };
706
- case QRMaskPattern.PATTERN001:
707
- return function(i, j) {
708
- return i % 2 == 0;
709
- };
710
- case QRMaskPattern.PATTERN010:
711
- return function(i, j) {
712
- return j % 3 == 0;
713
- };
714
- case QRMaskPattern.PATTERN011:
715
- return function(i, j) {
716
- return (i + j) % 3 == 0;
717
- };
718
- case QRMaskPattern.PATTERN100:
719
- return function(i, j) {
720
- return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
721
- };
722
- case QRMaskPattern.PATTERN101:
723
- return function(i, j) {
724
- return i * j % 2 + i * j % 3 == 0;
725
- };
726
- case QRMaskPattern.PATTERN110:
727
- return function(i, j) {
728
- return (i * j % 2 + i * j % 3) % 2 == 0;
729
- };
730
- case QRMaskPattern.PATTERN111:
731
- return function(i, j) {
732
- return (i * j % 3 + (i + j) % 2) % 2 == 0;
733
- };
734
- default:
735
- throw "bad maskPattern:" + maskPattern;
736
- }
737
- };
738
- _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
739
- let a = qrPolynomial([1], 0);
740
- for (let i = 0; i < errorCorrectLength; i += 1) {
741
- a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
742
- }
743
- return a;
744
- };
745
- _this.getLengthInBits = function(mode, type) {
746
- if (1 <= type && type < 10) {
747
- switch (mode) {
748
- case QRMode.MODE_NUMBER:
749
- return 10;
750
- case QRMode.MODE_ALPHA_NUM:
751
- return 9;
752
- case QRMode.MODE_8BIT_BYTE:
753
- return 8;
754
- case QRMode.MODE_KANJI:
755
- return 8;
756
- default:
757
- throw "mode:" + mode;
758
- }
759
- } else if (type < 27) {
760
- switch (mode) {
761
- case QRMode.MODE_NUMBER:
762
- return 12;
763
- case QRMode.MODE_ALPHA_NUM:
764
- return 11;
765
- case QRMode.MODE_8BIT_BYTE:
766
- return 16;
767
- case QRMode.MODE_KANJI:
768
- return 10;
769
- default:
770
- throw "mode:" + mode;
771
- }
772
- } else if (type < 41) {
773
- switch (mode) {
774
- case QRMode.MODE_NUMBER:
775
- return 14;
776
- case QRMode.MODE_ALPHA_NUM:
777
- return 13;
778
- case QRMode.MODE_8BIT_BYTE:
779
- return 16;
780
- case QRMode.MODE_KANJI:
781
- return 12;
782
- default:
783
- throw "mode:" + mode;
784
- }
785
- } else {
786
- throw "type:" + type;
787
- }
788
- };
789
- _this.getLostPoint = function(qrcode2) {
790
- const moduleCount = qrcode2.getModuleCount();
791
- let lostPoint = 0;
792
- for (let row = 0; row < moduleCount; row += 1) {
793
- for (let col = 0; col < moduleCount; col += 1) {
794
- let sameCount = 0;
795
- const dark = qrcode2.isDark(row, col);
796
- for (let r = -1; r <= 1; r += 1) {
797
- if (row + r < 0 || moduleCount <= row + r) {
798
- continue;
799
- }
800
- for (let c = -1; c <= 1; c += 1) {
801
- if (col + c < 0 || moduleCount <= col + c) {
802
- continue;
803
- }
804
- if (r == 0 && c == 0) {
805
- continue;
806
- }
807
- if (dark == qrcode2.isDark(row + r, col + c)) {
808
- sameCount += 1;
809
- }
810
- }
811
- }
812
- if (sameCount > 5) {
813
- lostPoint += 3 + sameCount - 5;
814
- }
815
- }
816
- }
817
- ;
818
- for (let row = 0; row < moduleCount - 1; row += 1) {
819
- for (let col = 0; col < moduleCount - 1; col += 1) {
820
- let count = 0;
821
- if (qrcode2.isDark(row, col)) count += 1;
822
- if (qrcode2.isDark(row + 1, col)) count += 1;
823
- if (qrcode2.isDark(row, col + 1)) count += 1;
824
- if (qrcode2.isDark(row + 1, col + 1)) count += 1;
825
- if (count == 0 || count == 4) {
826
- lostPoint += 3;
827
- }
828
- }
829
- }
830
- for (let row = 0; row < moduleCount; row += 1) {
831
- for (let col = 0; col < moduleCount - 6; col += 1) {
832
- 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)) {
833
- lostPoint += 40;
834
- }
835
- }
836
- }
837
- for (let col = 0; col < moduleCount; col += 1) {
838
- for (let row = 0; row < moduleCount - 6; row += 1) {
839
- 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)) {
840
- lostPoint += 40;
841
- }
842
- }
843
- }
844
- let darkCount = 0;
845
- for (let col = 0; col < moduleCount; col += 1) {
846
- for (let row = 0; row < moduleCount; row += 1) {
847
- if (qrcode2.isDark(row, col)) {
848
- darkCount += 1;
849
- }
850
- }
851
- }
852
- const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
853
- lostPoint += ratio * 10;
854
- return lostPoint;
855
- };
856
- return _this;
857
- })();
858
- var QRMath = (function() {
859
- const EXP_TABLE = new Array(256);
860
- const LOG_TABLE = new Array(256);
861
- for (let i = 0; i < 8; i += 1) {
862
- EXP_TABLE[i] = 1 << i;
863
- }
864
- for (let i = 8; i < 256; i += 1) {
865
- EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
866
- }
867
- for (let i = 0; i < 255; i += 1) {
868
- LOG_TABLE[EXP_TABLE[i]] = i;
869
- }
870
- const _this = {};
871
- _this.glog = function(n) {
872
- if (n < 1) {
873
- throw "glog(" + n + ")";
874
- }
875
- return LOG_TABLE[n];
876
- };
877
- _this.gexp = function(n) {
878
- while (n < 0) {
879
- n += 255;
880
- }
881
- while (n >= 256) {
882
- n -= 255;
883
- }
884
- return EXP_TABLE[n];
885
- };
886
- return _this;
887
- })();
888
- var qrPolynomial = /* @__PURE__ */ __name(function(num, shift) {
889
- if (typeof num.length == "undefined") {
890
- throw num.length + "/" + shift;
891
- }
892
- const _num = (function() {
893
- let offset = 0;
894
- while (offset < num.length && num[offset] == 0) {
895
- offset += 1;
896
- }
897
- const _num2 = new Array(num.length - offset + shift);
898
- for (let i = 0; i < num.length - offset; i += 1) {
899
- _num2[i] = num[i + offset];
900
- }
901
- return _num2;
902
- })();
903
- const _this = {};
904
- _this.getAt = function(index) {
905
- return _num[index];
906
- };
907
- _this.getLength = function() {
908
- return _num.length;
909
- };
910
- _this.multiply = function(e) {
911
- const num2 = new Array(_this.getLength() + e.getLength() - 1);
912
- for (let i = 0; i < _this.getLength(); i += 1) {
913
- for (let j = 0; j < e.getLength(); j += 1) {
914
- num2[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
915
- }
916
- }
917
- return qrPolynomial(num2, 0);
918
- };
919
- _this.mod = function(e) {
920
- if (_this.getLength() - e.getLength() < 0) {
921
- return _this;
922
- }
923
- const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
924
- const num2 = new Array(_this.getLength());
925
- for (let i = 0; i < _this.getLength(); i += 1) {
926
- num2[i] = _this.getAt(i);
927
- }
928
- for (let i = 0; i < e.getLength(); i += 1) {
929
- num2[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
930
- }
931
- return qrPolynomial(num2, 0).mod(e);
932
- };
933
- return _this;
934
- }, "qrPolynomial");
935
- var QRRSBlock = (function() {
936
- const RS_BLOCK_TABLE = [
937
- // L
938
- // M
939
- // Q
940
- // H
941
- // 1
942
- [1, 26, 19],
943
- [1, 26, 16],
944
- [1, 26, 13],
945
- [1, 26, 9],
946
- // 2
947
- [1, 44, 34],
948
- [1, 44, 28],
949
- [1, 44, 22],
950
- [1, 44, 16],
951
- // 3
952
- [1, 70, 55],
953
- [1, 70, 44],
954
- [2, 35, 17],
955
- [2, 35, 13],
956
- // 4
957
- [1, 100, 80],
958
- [2, 50, 32],
959
- [2, 50, 24],
960
- [4, 25, 9],
961
- // 5
962
- [1, 134, 108],
963
- [2, 67, 43],
964
- [2, 33, 15, 2, 34, 16],
965
- [2, 33, 11, 2, 34, 12],
966
- // 6
967
- [2, 86, 68],
968
- [4, 43, 27],
969
- [4, 43, 19],
970
- [4, 43, 15],
971
- // 7
972
- [2, 98, 78],
973
- [4, 49, 31],
974
- [2, 32, 14, 4, 33, 15],
975
- [4, 39, 13, 1, 40, 14],
976
- // 8
977
- [2, 121, 97],
978
- [2, 60, 38, 2, 61, 39],
979
- [4, 40, 18, 2, 41, 19],
980
- [4, 40, 14, 2, 41, 15],
981
- // 9
982
- [2, 146, 116],
983
- [3, 58, 36, 2, 59, 37],
984
- [4, 36, 16, 4, 37, 17],
985
- [4, 36, 12, 4, 37, 13],
986
- // 10
987
- [2, 86, 68, 2, 87, 69],
988
- [4, 69, 43, 1, 70, 44],
989
- [6, 43, 19, 2, 44, 20],
990
- [6, 43, 15, 2, 44, 16],
991
- // 11
992
- [4, 101, 81],
993
- [1, 80, 50, 4, 81, 51],
994
- [4, 50, 22, 4, 51, 23],
995
- [3, 36, 12, 8, 37, 13],
996
- // 12
997
- [2, 116, 92, 2, 117, 93],
998
- [6, 58, 36, 2, 59, 37],
999
- [4, 46, 20, 6, 47, 21],
1000
- [7, 42, 14, 4, 43, 15],
1001
- // 13
1002
- [4, 133, 107],
1003
- [8, 59, 37, 1, 60, 38],
1004
- [8, 44, 20, 4, 45, 21],
1005
- [12, 33, 11, 4, 34, 12],
1006
- // 14
1007
- [3, 145, 115, 1, 146, 116],
1008
- [4, 64, 40, 5, 65, 41],
1009
- [11, 36, 16, 5, 37, 17],
1010
- [11, 36, 12, 5, 37, 13],
1011
- // 15
1012
- [5, 109, 87, 1, 110, 88],
1013
- [5, 65, 41, 5, 66, 42],
1014
- [5, 54, 24, 7, 55, 25],
1015
- [11, 36, 12, 7, 37, 13],
1016
- // 16
1017
- [5, 122, 98, 1, 123, 99],
1018
- [7, 73, 45, 3, 74, 46],
1019
- [15, 43, 19, 2, 44, 20],
1020
- [3, 45, 15, 13, 46, 16],
1021
- // 17
1022
- [1, 135, 107, 5, 136, 108],
1023
- [10, 74, 46, 1, 75, 47],
1024
- [1, 50, 22, 15, 51, 23],
1025
- [2, 42, 14, 17, 43, 15],
1026
- // 18
1027
- [5, 150, 120, 1, 151, 121],
1028
- [9, 69, 43, 4, 70, 44],
1029
- [17, 50, 22, 1, 51, 23],
1030
- [2, 42, 14, 19, 43, 15],
1031
- // 19
1032
- [3, 141, 113, 4, 142, 114],
1033
- [3, 70, 44, 11, 71, 45],
1034
- [17, 47, 21, 4, 48, 22],
1035
- [9, 39, 13, 16, 40, 14],
1036
- // 20
1037
- [3, 135, 107, 5, 136, 108],
1038
- [3, 67, 41, 13, 68, 42],
1039
- [15, 54, 24, 5, 55, 25],
1040
- [15, 43, 15, 10, 44, 16],
1041
- // 21
1042
- [4, 144, 116, 4, 145, 117],
1043
- [17, 68, 42],
1044
- [17, 50, 22, 6, 51, 23],
1045
- [19, 46, 16, 6, 47, 17],
1046
- // 22
1047
- [2, 139, 111, 7, 140, 112],
1048
- [17, 74, 46],
1049
- [7, 54, 24, 16, 55, 25],
1050
- [34, 37, 13],
1051
- // 23
1052
- [4, 151, 121, 5, 152, 122],
1053
- [4, 75, 47, 14, 76, 48],
1054
- [11, 54, 24, 14, 55, 25],
1055
- [16, 45, 15, 14, 46, 16],
1056
- // 24
1057
- [6, 147, 117, 4, 148, 118],
1058
- [6, 73, 45, 14, 74, 46],
1059
- [11, 54, 24, 16, 55, 25],
1060
- [30, 46, 16, 2, 47, 17],
1061
- // 25
1062
- [8, 132, 106, 4, 133, 107],
1063
- [8, 75, 47, 13, 76, 48],
1064
- [7, 54, 24, 22, 55, 25],
1065
- [22, 45, 15, 13, 46, 16],
1066
- // 26
1067
- [10, 142, 114, 2, 143, 115],
1068
- [19, 74, 46, 4, 75, 47],
1069
- [28, 50, 22, 6, 51, 23],
1070
- [33, 46, 16, 4, 47, 17],
1071
- // 27
1072
- [8, 152, 122, 4, 153, 123],
1073
- [22, 73, 45, 3, 74, 46],
1074
- [8, 53, 23, 26, 54, 24],
1075
- [12, 45, 15, 28, 46, 16],
1076
- // 28
1077
- [3, 147, 117, 10, 148, 118],
1078
- [3, 73, 45, 23, 74, 46],
1079
- [4, 54, 24, 31, 55, 25],
1080
- [11, 45, 15, 31, 46, 16],
1081
- // 29
1082
- [7, 146, 116, 7, 147, 117],
1083
- [21, 73, 45, 7, 74, 46],
1084
- [1, 53, 23, 37, 54, 24],
1085
- [19, 45, 15, 26, 46, 16],
1086
- // 30
1087
- [5, 145, 115, 10, 146, 116],
1088
- [19, 75, 47, 10, 76, 48],
1089
- [15, 54, 24, 25, 55, 25],
1090
- [23, 45, 15, 25, 46, 16],
1091
- // 31
1092
- [13, 145, 115, 3, 146, 116],
1093
- [2, 74, 46, 29, 75, 47],
1094
- [42, 54, 24, 1, 55, 25],
1095
- [23, 45, 15, 28, 46, 16],
1096
- // 32
1097
- [17, 145, 115],
1098
- [10, 74, 46, 23, 75, 47],
1099
- [10, 54, 24, 35, 55, 25],
1100
- [19, 45, 15, 35, 46, 16],
1101
- // 33
1102
- [17, 145, 115, 1, 146, 116],
1103
- [14, 74, 46, 21, 75, 47],
1104
- [29, 54, 24, 19, 55, 25],
1105
- [11, 45, 15, 46, 46, 16],
1106
- // 34
1107
- [13, 145, 115, 6, 146, 116],
1108
- [14, 74, 46, 23, 75, 47],
1109
- [44, 54, 24, 7, 55, 25],
1110
- [59, 46, 16, 1, 47, 17],
1111
- // 35
1112
- [12, 151, 121, 7, 152, 122],
1113
- [12, 75, 47, 26, 76, 48],
1114
- [39, 54, 24, 14, 55, 25],
1115
- [22, 45, 15, 41, 46, 16],
1116
- // 36
1117
- [6, 151, 121, 14, 152, 122],
1118
- [6, 75, 47, 34, 76, 48],
1119
- [46, 54, 24, 10, 55, 25],
1120
- [2, 45, 15, 64, 46, 16],
1121
- // 37
1122
- [17, 152, 122, 4, 153, 123],
1123
- [29, 74, 46, 14, 75, 47],
1124
- [49, 54, 24, 10, 55, 25],
1125
- [24, 45, 15, 46, 46, 16],
1126
- // 38
1127
- [4, 152, 122, 18, 153, 123],
1128
- [13, 74, 46, 32, 75, 47],
1129
- [48, 54, 24, 14, 55, 25],
1130
- [42, 45, 15, 32, 46, 16],
1131
- // 39
1132
- [20, 147, 117, 4, 148, 118],
1133
- [40, 75, 47, 7, 76, 48],
1134
- [43, 54, 24, 22, 55, 25],
1135
- [10, 45, 15, 67, 46, 16],
1136
- // 40
1137
- [19, 148, 118, 6, 149, 119],
1138
- [18, 75, 47, 31, 76, 48],
1139
- [34, 54, 24, 34, 55, 25],
1140
- [20, 45, 15, 61, 46, 16]
1141
- ];
1142
- const qrRSBlock = /* @__PURE__ */ __name(function(totalCount, dataCount) {
1143
- const _this2 = {};
1144
- _this2.totalCount = totalCount;
1145
- _this2.dataCount = dataCount;
1146
- return _this2;
1147
- }, "qrRSBlock");
1148
- const _this = {};
1149
- const getRsBlockTable = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
1150
- switch (errorCorrectionLevel) {
1151
- case QRErrorCorrectionLevel.L:
1152
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1153
- case QRErrorCorrectionLevel.M:
1154
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1155
- case QRErrorCorrectionLevel.Q:
1156
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1157
- case QRErrorCorrectionLevel.H:
1158
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1159
- default:
1160
- return void 0;
1161
- }
1162
- }, "getRsBlockTable");
1163
- _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
1164
- const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
1165
- if (typeof rsBlock == "undefined") {
1166
- throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
1167
- }
1168
- const length = rsBlock.length / 3;
1169
- const list = [];
1170
- for (let i = 0; i < length; i += 1) {
1171
- const count = rsBlock[i * 3 + 0];
1172
- const totalCount = rsBlock[i * 3 + 1];
1173
- const dataCount = rsBlock[i * 3 + 2];
1174
- for (let j = 0; j < count; j += 1) {
1175
- list.push(qrRSBlock(totalCount, dataCount));
1176
- }
1177
- }
1178
- return list;
1179
- };
1180
- return _this;
1181
- })();
1182
- var qrBitBuffer = /* @__PURE__ */ __name(function() {
1183
- const _buffer = [];
1184
- let _length = 0;
1185
- const _this = {};
1186
- _this.getBuffer = function() {
1187
- return _buffer;
1188
- };
1189
- _this.getAt = function(index) {
1190
- const bufIndex = Math.floor(index / 8);
1191
- return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
1192
- };
1193
- _this.put = function(num, length) {
1194
- for (let i = 0; i < length; i += 1) {
1195
- _this.putBit((num >>> length - i - 1 & 1) == 1);
1196
- }
1197
- };
1198
- _this.getLengthInBits = function() {
1199
- return _length;
1200
- };
1201
- _this.putBit = function(bit) {
1202
- const bufIndex = Math.floor(_length / 8);
1203
- if (_buffer.length <= bufIndex) {
1204
- _buffer.push(0);
1205
- }
1206
- if (bit) {
1207
- _buffer[bufIndex] |= 128 >>> _length % 8;
1208
- }
1209
- _length += 1;
1210
- };
1211
- return _this;
1212
- }, "qrBitBuffer");
1213
- var qrNumber = /* @__PURE__ */ __name(function(data) {
1214
- const _mode = QRMode.MODE_NUMBER;
1215
- const _data = data;
1216
- const _this = {};
1217
- _this.getMode = function() {
1218
- return _mode;
1219
- };
1220
- _this.getLength = function(buffer) {
1221
- return _data.length;
1222
- };
1223
- _this.write = function(buffer) {
1224
- const data2 = _data;
1225
- let i = 0;
1226
- while (i + 2 < data2.length) {
1227
- buffer.put(strToNum(data2.substring(i, i + 3)), 10);
1228
- i += 3;
1229
- }
1230
- if (i < data2.length) {
1231
- if (data2.length - i == 1) {
1232
- buffer.put(strToNum(data2.substring(i, i + 1)), 4);
1233
- } else if (data2.length - i == 2) {
1234
- buffer.put(strToNum(data2.substring(i, i + 2)), 7);
1235
- }
1236
- }
1237
- };
1238
- const strToNum = /* @__PURE__ */ __name(function(s) {
1239
- let num = 0;
1240
- for (let i = 0; i < s.length; i += 1) {
1241
- num = num * 10 + chatToNum(s.charAt(i));
1242
- }
1243
- return num;
1244
- }, "strToNum");
1245
- const chatToNum = /* @__PURE__ */ __name(function(c) {
1246
- if ("0" <= c && c <= "9") {
1247
- return c.charCodeAt(0) - "0".charCodeAt(0);
1248
- }
1249
- throw "illegal char :" + c;
1250
- }, "chatToNum");
1251
- return _this;
1252
- }, "qrNumber");
1253
- var qrAlphaNum = /* @__PURE__ */ __name(function(data) {
1254
- const _mode = QRMode.MODE_ALPHA_NUM;
1255
- const _data = data;
1256
- const _this = {};
1257
- _this.getMode = function() {
1258
- return _mode;
1259
- };
1260
- _this.getLength = function(buffer) {
1261
- return _data.length;
1262
- };
1263
- _this.write = function(buffer) {
1264
- const s = _data;
1265
- let i = 0;
1266
- while (i + 1 < s.length) {
1267
- buffer.put(
1268
- getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)),
1269
- 11
1270
- );
1271
- i += 2;
1272
- }
1273
- if (i < s.length) {
1274
- buffer.put(getCode(s.charAt(i)), 6);
1275
- }
1276
- };
1277
- const getCode = /* @__PURE__ */ __name(function(c) {
1278
- if ("0" <= c && c <= "9") {
1279
- return c.charCodeAt(0) - "0".charCodeAt(0);
1280
- } else if ("A" <= c && c <= "Z") {
1281
- return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
1282
- } else {
1283
- switch (c) {
1284
- case " ":
1285
- return 36;
1286
- case "$":
1287
- return 37;
1288
- case "%":
1289
- return 38;
1290
- case "*":
1291
- return 39;
1292
- case "+":
1293
- return 40;
1294
- case "-":
1295
- return 41;
1296
- case ".":
1297
- return 42;
1298
- case "/":
1299
- return 43;
1300
- case ":":
1301
- return 44;
1302
- default:
1303
- throw "illegal char :" + c;
1304
- }
1305
- }
1306
- }, "getCode");
1307
- return _this;
1308
- }, "qrAlphaNum");
1309
- var qr8BitByte = /* @__PURE__ */ __name(function(data) {
1310
- const _mode = QRMode.MODE_8BIT_BYTE;
1311
- const _data = data;
1312
- const _bytes = qrcode.stringToBytes(data);
1313
- const _this = {};
1314
- _this.getMode = function() {
1315
- return _mode;
1316
- };
1317
- _this.getLength = function(buffer) {
1318
- return _bytes.length;
1319
- };
1320
- _this.write = function(buffer) {
1321
- for (let i = 0; i < _bytes.length; i += 1) {
1322
- buffer.put(_bytes[i], 8);
1323
- }
1324
- };
1325
- return _this;
1326
- }, "qr8BitByte");
1327
- var qrKanji = /* @__PURE__ */ __name(function(data) {
1328
- const _mode = QRMode.MODE_KANJI;
1329
- const _data = data;
1330
- const stringToBytes2 = qrcode.stringToBytes;
1331
- !(function(c, code) {
1332
- const test = stringToBytes2(c);
1333
- if (test.length != 2 || (test[0] << 8 | test[1]) != code) {
1334
- throw "sjis not supported.";
1335
- }
1336
- })("\u53CB", 38726);
1337
- const _bytes = stringToBytes2(data);
1338
- const _this = {};
1339
- _this.getMode = function() {
1340
- return _mode;
1341
- };
1342
- _this.getLength = function(buffer) {
1343
- return ~~(_bytes.length / 2);
1344
- };
1345
- _this.write = function(buffer) {
1346
- const data2 = _bytes;
1347
- let i = 0;
1348
- while (i + 1 < data2.length) {
1349
- let c = (255 & data2[i]) << 8 | 255 & data2[i + 1];
1350
- if (33088 <= c && c <= 40956) {
1351
- c -= 33088;
1352
- } else if (57408 <= c && c <= 60351) {
1353
- c -= 49472;
1354
- } else {
1355
- throw "illegal char at " + (i + 1) + "/" + c;
1356
- }
1357
- c = (c >>> 8 & 255) * 192 + (c & 255);
1358
- buffer.put(c, 13);
1359
- i += 2;
1360
- }
1361
- if (i < data2.length) {
1362
- throw "illegal char at " + (i + 1);
1363
- }
1364
- };
1365
- return _this;
1366
- }, "qrKanji");
1367
- var byteArrayOutputStream = /* @__PURE__ */ __name(function() {
1368
- const _bytes = [];
1369
- const _this = {};
1370
- _this.writeByte = function(b) {
1371
- _bytes.push(b & 255);
1372
- };
1373
- _this.writeShort = function(i) {
1374
- _this.writeByte(i);
1375
- _this.writeByte(i >>> 8);
1376
- };
1377
- _this.writeBytes = function(b, off, len) {
1378
- off = off || 0;
1379
- len = len || b.length;
1380
- for (let i = 0; i < len; i += 1) {
1381
- _this.writeByte(b[i + off]);
1382
- }
1383
- };
1384
- _this.writeString = function(s) {
1385
- for (let i = 0; i < s.length; i += 1) {
1386
- _this.writeByte(s.charCodeAt(i));
1387
- }
1388
- };
1389
- _this.toByteArray = function() {
1390
- return _bytes;
1391
- };
1392
- _this.toString = function() {
1393
- let s = "";
1394
- s += "[";
1395
- for (let i = 0; i < _bytes.length; i += 1) {
1396
- if (i > 0) {
1397
- s += ",";
1398
- }
1399
- s += _bytes[i];
1400
- }
1401
- s += "]";
1402
- return s;
1403
- };
1404
- return _this;
1405
- }, "byteArrayOutputStream");
1406
- var base64EncodeOutputStream = /* @__PURE__ */ __name(function() {
1407
- let _buffer = 0;
1408
- let _buflen = 0;
1409
- let _length = 0;
1410
- let _base64 = "";
1411
- const _this = {};
1412
- const writeEncoded = /* @__PURE__ */ __name(function(b) {
1413
- _base64 += String.fromCharCode(encode(b & 63));
1414
- }, "writeEncoded");
1415
- const encode = /* @__PURE__ */ __name(function(n) {
1416
- if (n < 0) {
1417
- throw "n:" + n;
1418
- } else if (n < 26) {
1419
- return 65 + n;
1420
- } else if (n < 52) {
1421
- return 97 + (n - 26);
1422
- } else if (n < 62) {
1423
- return 48 + (n - 52);
1424
- } else if (n == 62) {
1425
- return 43;
1426
- } else if (n == 63) {
1427
- return 47;
1428
- } else {
1429
- throw "n:" + n;
1430
- }
1431
- }, "encode");
1432
- _this.writeByte = function(n) {
1433
- _buffer = _buffer << 8 | n & 255;
1434
- _buflen += 8;
1435
- _length += 1;
1436
- while (_buflen >= 6) {
1437
- writeEncoded(_buffer >>> _buflen - 6);
1438
- _buflen -= 6;
1439
- }
1440
- };
1441
- _this.flush = function() {
1442
- if (_buflen > 0) {
1443
- writeEncoded(_buffer << 6 - _buflen);
1444
- _buffer = 0;
1445
- _buflen = 0;
1446
- }
1447
- if (_length % 3 != 0) {
1448
- const padlen = 3 - _length % 3;
1449
- for (let i = 0; i < padlen; i += 1) {
1450
- _base64 += "=";
1451
- }
1452
- }
1453
- };
1454
- _this.toString = function() {
1455
- return _base64;
1456
- };
1457
- return _this;
1458
- }, "base64EncodeOutputStream");
1459
- var base64DecodeInputStream = /* @__PURE__ */ __name(function(str) {
1460
- const _str = str;
1461
- let _pos = 0;
1462
- let _buffer = 0;
1463
- let _buflen = 0;
1464
- const _this = {};
1465
- _this.read = function() {
1466
- while (_buflen < 8) {
1467
- if (_pos >= _str.length) {
1468
- if (_buflen == 0) {
1469
- return -1;
1470
- }
1471
- throw "unexpected end of file./" + _buflen;
1472
- }
1473
- const c = _str.charAt(_pos);
1474
- _pos += 1;
1475
- if (c == "=") {
1476
- _buflen = 0;
1477
- return -1;
1478
- } else if (c.match(/^\s$/)) {
1479
- continue;
1480
- }
1481
- _buffer = _buffer << 6 | decode(c.charCodeAt(0));
1482
- _buflen += 6;
1483
- }
1484
- const n = _buffer >>> _buflen - 8 & 255;
1485
- _buflen -= 8;
1486
- return n;
1487
- };
1488
- const decode = /* @__PURE__ */ __name(function(c) {
1489
- if (65 <= c && c <= 90) {
1490
- return c - 65;
1491
- } else if (97 <= c && c <= 122) {
1492
- return c - 97 + 26;
1493
- } else if (48 <= c && c <= 57) {
1494
- return c - 48 + 52;
1495
- } else if (c == 43) {
1496
- return 62;
1497
- } else if (c == 47) {
1498
- return 63;
1499
- } else {
1500
- throw "c:" + c;
1501
- }
1502
- }, "decode");
1503
- return _this;
1504
- }, "base64DecodeInputStream");
1505
- var gifImage = /* @__PURE__ */ __name(function(width, height) {
1506
- const _width = width;
1507
- const _height = height;
1508
- const _data = new Array(width * height);
1509
- const _this = {};
1510
- _this.setPixel = function(x, y, pixel) {
1511
- _data[y * _width + x] = pixel;
1512
- };
1513
- _this.write = function(out) {
1514
- out.writeString("GIF87a");
1515
- out.writeShort(_width);
1516
- out.writeShort(_height);
1517
- out.writeByte(128);
1518
- out.writeByte(0);
1519
- out.writeByte(0);
1520
- out.writeByte(0);
1521
- out.writeByte(0);
1522
- out.writeByte(0);
1523
- out.writeByte(255);
1524
- out.writeByte(255);
1525
- out.writeByte(255);
1526
- out.writeString(",");
1527
- out.writeShort(0);
1528
- out.writeShort(0);
1529
- out.writeShort(_width);
1530
- out.writeShort(_height);
1531
- out.writeByte(0);
1532
- const lzwMinCodeSize = 2;
1533
- const raster = getLZWRaster(lzwMinCodeSize);
1534
- out.writeByte(lzwMinCodeSize);
1535
- let offset = 0;
1536
- while (raster.length - offset > 255) {
1537
- out.writeByte(255);
1538
- out.writeBytes(raster, offset, 255);
1539
- offset += 255;
1540
- }
1541
- out.writeByte(raster.length - offset);
1542
- out.writeBytes(raster, offset, raster.length - offset);
1543
- out.writeByte(0);
1544
- out.writeString(";");
1545
- };
1546
- const bitOutputStream = /* @__PURE__ */ __name(function(out) {
1547
- const _out = out;
1548
- let _bitLength = 0;
1549
- let _bitBuffer = 0;
1550
- const _this2 = {};
1551
- _this2.write = function(data, length) {
1552
- if (data >>> length != 0) {
1553
- throw "length over";
1554
- }
1555
- while (_bitLength + length >= 8) {
1556
- _out.writeByte(255 & (data << _bitLength | _bitBuffer));
1557
- length -= 8 - _bitLength;
1558
- data >>>= 8 - _bitLength;
1559
- _bitBuffer = 0;
1560
- _bitLength = 0;
1561
- }
1562
- _bitBuffer = data << _bitLength | _bitBuffer;
1563
- _bitLength = _bitLength + length;
1564
- };
1565
- _this2.flush = function() {
1566
- if (_bitLength > 0) {
1567
- _out.writeByte(_bitBuffer);
1568
- }
1569
- };
1570
- return _this2;
1571
- }, "bitOutputStream");
1572
- const getLZWRaster = /* @__PURE__ */ __name(function(lzwMinCodeSize) {
1573
- const clearCode = 1 << lzwMinCodeSize;
1574
- const endCode = (1 << lzwMinCodeSize) + 1;
1575
- let bitLength = lzwMinCodeSize + 1;
1576
- const table = lzwTable();
1577
- for (let i = 0; i < clearCode; i += 1) {
1578
- table.add(String.fromCharCode(i));
1579
- }
1580
- table.add(String.fromCharCode(clearCode));
1581
- table.add(String.fromCharCode(endCode));
1582
- const byteOut = byteArrayOutputStream();
1583
- const bitOut = bitOutputStream(byteOut);
1584
- bitOut.write(clearCode, bitLength);
1585
- let dataIndex = 0;
1586
- let s = String.fromCharCode(_data[dataIndex]);
1587
- dataIndex += 1;
1588
- while (dataIndex < _data.length) {
1589
- const c = String.fromCharCode(_data[dataIndex]);
1590
- dataIndex += 1;
1591
- if (table.contains(s + c)) {
1592
- s = s + c;
1593
- } else {
1594
- bitOut.write(table.indexOf(s), bitLength);
1595
- if (table.size() < 4095) {
1596
- if (table.size() == 1 << bitLength) {
1597
- bitLength += 1;
1598
- }
1599
- table.add(s + c);
1600
- }
1601
- s = c;
1602
- }
1603
- }
1604
- bitOut.write(table.indexOf(s), bitLength);
1605
- bitOut.write(endCode, bitLength);
1606
- bitOut.flush();
1607
- return byteOut.toByteArray();
1608
- }, "getLZWRaster");
1609
- const lzwTable = /* @__PURE__ */ __name(function() {
1610
- const _map = {};
1611
- let _size = 0;
1612
- const _this2 = {};
1613
- _this2.add = function(key) {
1614
- if (_this2.contains(key)) {
1615
- throw "dup key:" + key;
1616
- }
1617
- _map[key] = _size;
1618
- _size += 1;
1619
- };
1620
- _this2.size = function() {
1621
- return _size;
1622
- };
1623
- _this2.indexOf = function(key) {
1624
- return _map[key];
1625
- };
1626
- _this2.contains = function(key) {
1627
- return typeof _map[key] != "undefined";
1628
- };
1629
- return _this2;
1630
- }, "lzwTable");
1631
- return _this;
1632
- }, "gifImage");
1633
- var createDataURL = /* @__PURE__ */ __name(function(width, height, getPixel) {
1634
- const gif = gifImage(width, height);
1635
- for (let y = 0; y < height; y += 1) {
1636
- for (let x = 0; x < width; x += 1) {
1637
- gif.setPixel(x, y, getPixel(x, y));
1638
- }
1639
- }
1640
- const b = byteArrayOutputStream();
1641
- gif.write(b);
1642
- const base64 = base64EncodeOutputStream();
1643
- const bytes = b.toByteArray();
1644
- for (let i = 0; i < bytes.length; i += 1) {
1645
- base64.writeByte(bytes[i]);
1646
- }
1647
- base64.flush();
1648
- return "data:image/gif;base64," + base64;
1649
- }, "createDataURL");
1650
- var stringToBytes = qrcode.stringToBytes;
1651
-
1652
- // dist/reasons.js
1653
- var CORE = new Set(REASONS.map((one) => one.reason));
1654
- var OWN = [
1655
- ["account.malformed", "validation_error", "that is not an amoCRM or Kommo account address"],
1656
- ["account.token-missing", "validation_error", "a profile moved to another account needs that account's token"],
1657
- ["account.host-missing", "configuration_error", "AMO_TOKEN needs AMO_HOST, the account's address"],
1658
- ["connect.url-invalid", "configuration_error", "AMO_CONNECT_URL is not an https address"],
1659
- ["oauth.browser-amocrm-only", "validation_error", "the browser sign-in works only for amoCRM accounts at amocrm.ru"],
1660
- ["session.expired", "authentication_error", "amoCRM refused the token: it expired or was revoked"],
1661
- ["amo.subscription-ended", "permission_error", "the amoCRM subscription has ended"],
1662
- ["amo.access-denied", "permission_error", "the token's user may not do this in amoCRM"],
1663
- ["amo.blocked", "permission_error", "amoCRM blocks every request from here"],
1664
- ["amo.filters-off", "validation_error", "the account has no API filter add-on, so amoCRM cannot narrow this list"],
1665
- ["amo.scope-all-refused", "configuration_error", "amo never copies the whole CRM: set the scope to mine"],
1666
- ["api.path-id-missing", "validation_error", "the path still has a placeholder where the record's id belongs"],
1667
- ["body.invalid", "validation_error", "--body or --params is not the JSON this call takes"],
1668
- ["employee.delete", "permission_error", "only an amoCRM administrator deletes through amo"],
1669
- ["employee.clear", "permission_error", "only an amoCRM administrator sets a field to nothing through amo"],
1670
- ["employee.unbind", "permission_error", "only an amoCRM administrator unlinks records through amo"]
1671
- ];
1672
- var REASONS2 = defineReasons(OWN.filter(([reason]) => !CORE.has(reason)).map(([reason, code, message]) => ({
1673
- reason,
1674
- code,
1675
- message,
1676
- details: []
1677
- })));
1678
- var DETAILS2 = ["fields", "account", "profiles"];
1679
-
1680
- // dist/version.js
1681
- var VERSION = "0.6.0";
1682
-
1683
- // dist/identity.js
1684
- var PACKAGE = "@wirecat/amo-cli";
1685
- var IDENTITY = {
1686
- command: "amo",
1687
- appName: "amo-cli",
1688
- envPrefix: "AMO",
1689
- description: "read and change an amoCRM or Kommo account's CRM",
1690
- version: VERSION,
1691
- issues: "https://github.com/WireCatLabs/amo-cli/issues/new",
1692
- messenger: false,
1693
- contentLanguages: ["ru", "en"],
1694
- // amo paces itself to 5 requests a second (src/context.ts); a run's budget counts on half that.
1695
- requestMs: 400,
1696
- errors: { reasons: REASONS2, details: DETAILS2 }
1697
- };
1698
- var DESKTOP = {
1699
- ...IDENTITY,
1700
- docs: "https://github.com/WireCatLabs/amo-cli#readme",
1701
- // Each account lives on its own host under one of these (src/amo/account.ts); amo reaches only the one signed in.
1702
- hosts: ["*.amocrm.ru", "*.amocrm.com", "*.kommo.com", "wirecat.dev", "connect.wirecat.dev"],
1703
- userHosts: "the amoCRM or Kommo account you sign in to, such as example.amocrm.ru",
1704
- tagline: "amoCRM and Kommo CRM: deals, contacts and companies",
1705
- syncs: "your deals, contacts and companies",
1706
- signIn: {
1707
- gives: "Lets your agent read and change the account's CRM with the rights of the administrator who made the token, or of the user who signed in through your own integration.",
1708
- asks: "The account's address and a long-lived token from a private integration's Keys and scopes tab, or that integration's ID and secret key."
1709
- }
1710
- };
1711
- var SKILL = new URL("../skills/amo-cli/SKILL.md", new URL("../identity.js", import.meta.url).href);
1712
-
1713
- export {
1714
- PACKAGE,
1715
- IDENTITY,
1716
- DESKTOP,
1717
- SKILL
1718
- };