去你大爷的闲鱼口令

它将 V2EX 帖子中的闲鱼口令/淘口令转换为可直接访问的链接,使您可一键直达闲鱼/淘宝。

  1. // ==UserScript==
  2. // @name 去你大爷的闲鱼口令
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.1
  5. // @description 它将 V2EX 帖子中的闲鱼口令/淘口令转换为可直接访问的链接,使您可一键直达闲鱼/淘宝。
  6. // @author Wood
  7. // @match https://*.v2ex.com/*
  8. // @grant none
  9. // ==/UserScript==
  10. (function webpackUniversalModuleDefinition(root, factory) {
  11. if(typeof exports === 'object' && typeof module === 'object')
  12. module.exports = factory();
  13. else if(typeof define === 'function' && define.amd)
  14. define([], factory);
  15. else if(typeof exports === 'object')
  16. exports["FuckXyCode"] = factory();
  17. else
  18. root["FuckXyCode"] = factory();
  19. })(window, function() {
  20. return /******/ (function(modules) { // webpackBootstrap
  21. /******/ // The module cache
  22. /******/ var installedModules = {};
  23. /******/
  24. /******/ // The require function
  25. /******/ function __webpack_require__(moduleId) {
  26. /******/
  27. /******/ // Check if module is in cache
  28. /******/ if(installedModules[moduleId]) {
  29. /******/ return installedModules[moduleId].exports;
  30. /******/ }
  31. /******/ // Create a new module (and put it into the cache)
  32. /******/ var module = installedModules[moduleId] = {
  33. /******/ i: moduleId,
  34. /******/ l: false,
  35. /******/ exports: {}
  36. /******/ };
  37. /******/
  38. /******/ // Execute the module function
  39. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  40. /******/
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/
  44. /******/ // Return the exports of the module
  45. /******/ return module.exports;
  46. /******/ }
  47. /******/
  48. /******/
  49. /******/ // expose the modules object (__webpack_modules__)
  50. /******/ __webpack_require__.m = modules;
  51. /******/
  52. /******/ // expose the module cache
  53. /******/ __webpack_require__.c = installedModules;
  54. /******/
  55. /******/ // define getter function for harmony exports
  56. /******/ __webpack_require__.d = function(exports, name, getter) {
  57. /******/ if(!__webpack_require__.o(exports, name)) {
  58. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  59. /******/ }
  60. /******/ };
  61. /******/
  62. /******/ // define __esModule on exports
  63. /******/ __webpack_require__.r = function(exports) {
  64. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  65. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  66. /******/ }
  67. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  68. /******/ };
  69. /******/
  70. /******/ // create a fake namespace object
  71. /******/ // mode & 1: value is a module id, require it
  72. /******/ // mode & 2: merge all properties of value into the ns
  73. /******/ // mode & 4: return value when already ns object
  74. /******/ // mode & 8|1: behave like require
  75. /******/ __webpack_require__.t = function(value, mode) {
  76. /******/ if(mode & 1) value = __webpack_require__(value);
  77. /******/ if(mode & 8) return value;
  78. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  79. /******/ var ns = Object.create(null);
  80. /******/ __webpack_require__.r(ns);
  81. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  82. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  83. /******/ return ns;
  84. /******/ };
  85. /******/
  86. /******/ // getDefaultExport function for compatibility with non-harmony modules
  87. /******/ __webpack_require__.n = function(module) {
  88. /******/ var getter = module && module.__esModule ?
  89. /******/ function getDefault() { return module['default']; } :
  90. /******/ function getModuleExports() { return module; };
  91. /******/ __webpack_require__.d(getter, 'a', getter);
  92. /******/ return getter;
  93. /******/ };
  94. /******/
  95. /******/ // Object.prototype.hasOwnProperty.call
  96. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  97. /******/
  98. /******/ // __webpack_public_path__
  99. /******/ __webpack_require__.p = "";
  100. /******/
  101. /******/
  102. /******/ // Load entry module and return exports
  103. /******/ return __webpack_require__(__webpack_require__.s = "./src/Index.ts");
  104. /******/ })
  105. /************************************************************************/
  106. /******/ ({
  107.  
  108. /***/ "./node_modules/base64-js/index.js":
  109. /*!*****************************************!*\
  110. !*** ./node_modules/base64-js/index.js ***!
  111. \*****************************************/
  112. /*! no static exports found */
  113. /***/ (function(module, exports, __webpack_require__) {
  114.  
  115. "use strict";
  116.  
  117.  
  118. exports.byteLength = byteLength
  119. exports.toByteArray = toByteArray
  120. exports.fromByteArray = fromByteArray
  121.  
  122. var lookup = []
  123. var revLookup = []
  124. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  125.  
  126. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  127. for (var i = 0, len = code.length; i < len; ++i) {
  128. lookup[i] = code[i]
  129. revLookup[code.charCodeAt(i)] = i
  130. }
  131.  
  132. // Support decoding URL-safe base64 strings, as Node.js does.
  133. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  134. revLookup['-'.charCodeAt(0)] = 62
  135. revLookup['_'.charCodeAt(0)] = 63
  136.  
  137. function getLens (b64) {
  138. var len = b64.length
  139.  
  140. if (len % 4 > 0) {
  141. throw new Error('Invalid string. Length must be a multiple of 4')
  142. }
  143.  
  144. // Trim off extra bytes after placeholder bytes are found
  145. // See: https://github.com/beatgammit/base64-js/issues/42
  146. var validLen = b64.indexOf('=')
  147. if (validLen === -1) validLen = len
  148.  
  149. var placeHoldersLen = validLen === len
  150. ? 0
  151. : 4 - (validLen % 4)
  152.  
  153. return [validLen, placeHoldersLen]
  154. }
  155.  
  156. // base64 is 4/3 + up to two characters of the original data
  157. function byteLength (b64) {
  158. var lens = getLens(b64)
  159. var validLen = lens[0]
  160. var placeHoldersLen = lens[1]
  161. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  162. }
  163.  
  164. function _byteLength (b64, validLen, placeHoldersLen) {
  165. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  166. }
  167.  
  168. function toByteArray (b64) {
  169. var tmp
  170. var lens = getLens(b64)
  171. var validLen = lens[0]
  172. var placeHoldersLen = lens[1]
  173.  
  174. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  175.  
  176. var curByte = 0
  177.  
  178. // if there are placeholders, only get up to the last complete 4 chars
  179. var len = placeHoldersLen > 0
  180. ? validLen - 4
  181. : validLen
  182.  
  183. var i
  184. for (i = 0; i < len; i += 4) {
  185. tmp =
  186. (revLookup[b64.charCodeAt(i)] << 18) |
  187. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  188. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  189. revLookup[b64.charCodeAt(i + 3)]
  190. arr[curByte++] = (tmp >> 16) & 0xFF
  191. arr[curByte++] = (tmp >> 8) & 0xFF
  192. arr[curByte++] = tmp & 0xFF
  193. }
  194.  
  195. if (placeHoldersLen === 2) {
  196. tmp =
  197. (revLookup[b64.charCodeAt(i)] << 2) |
  198. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  199. arr[curByte++] = tmp & 0xFF
  200. }
  201.  
  202. if (placeHoldersLen === 1) {
  203. tmp =
  204. (revLookup[b64.charCodeAt(i)] << 10) |
  205. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  206. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  207. arr[curByte++] = (tmp >> 8) & 0xFF
  208. arr[curByte++] = tmp & 0xFF
  209. }
  210.  
  211. return arr
  212. }
  213.  
  214. function tripletToBase64 (num) {
  215. return lookup[num >> 18 & 0x3F] +
  216. lookup[num >> 12 & 0x3F] +
  217. lookup[num >> 6 & 0x3F] +
  218. lookup[num & 0x3F]
  219. }
  220.  
  221. function encodeChunk (uint8, start, end) {
  222. var tmp
  223. var output = []
  224. for (var i = start; i < end; i += 3) {
  225. tmp =
  226. ((uint8[i] << 16) & 0xFF0000) +
  227. ((uint8[i + 1] << 8) & 0xFF00) +
  228. (uint8[i + 2] & 0xFF)
  229. output.push(tripletToBase64(tmp))
  230. }
  231. return output.join('')
  232. }
  233.  
  234. function fromByteArray (uint8) {
  235. var tmp
  236. var len = uint8.length
  237. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  238. var parts = []
  239. var maxChunkLength = 16383 // must be multiple of 3
  240.  
  241. // go through the array every three bytes, we'll deal with trailing stuff later
  242. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  243. parts.push(encodeChunk(
  244. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  245. ))
  246. }
  247.  
  248. // pad the end with zeros, but make sure to not forget the extra bytes
  249. if (extraBytes === 1) {
  250. tmp = uint8[len - 1]
  251. parts.push(
  252. lookup[tmp >> 2] +
  253. lookup[(tmp << 4) & 0x3F] +
  254. '=='
  255. )
  256. } else if (extraBytes === 2) {
  257. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  258. parts.push(
  259. lookup[tmp >> 10] +
  260. lookup[(tmp >> 4) & 0x3F] +
  261. lookup[(tmp << 2) & 0x3F] +
  262. '='
  263. )
  264. }
  265.  
  266. return parts.join('')
  267. }
  268.  
  269.  
  270. /***/ }),
  271.  
  272. /***/ "./node_modules/dijkstrajs/dijkstra.js":
  273. /*!*********************************************!*\
  274. !*** ./node_modules/dijkstrajs/dijkstra.js ***!
  275. \*********************************************/
  276. /*! no static exports found */
  277. /***/ (function(module, exports, __webpack_require__) {
  278.  
  279. "use strict";
  280.  
  281.  
  282. /******************************************************************************
  283. * Created 2008-08-19.
  284. *
  285. * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
  286. *
  287. * Copyright (C) 2008
  288. * Wyatt Baldwin <self@wyattbaldwin.com>
  289. * All rights reserved
  290. *
  291. * Licensed under the MIT license.
  292. *
  293. * http://www.opensource.org/licenses/mit-license.php
  294. *
  295. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  296. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  297. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  298. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  299. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  300. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  301. * THE SOFTWARE.
  302. *****************************************************************************/
  303. var dijkstra = {
  304. single_source_shortest_paths: function(graph, s, d) {
  305. // Predecessor map for each node that has been encountered.
  306. // node ID => predecessor node ID
  307. var predecessors = {};
  308.  
  309. // Costs of shortest paths from s to all nodes encountered.
  310. // node ID => cost
  311. var costs = {};
  312. costs[s] = 0;
  313.  
  314. // Costs of shortest paths from s to all nodes encountered; differs from
  315. // `costs` in that it provides easy access to the node that currently has
  316. // the known shortest path from s.
  317. // XXX: Do we actually need both `costs` and `open`?
  318. var open = dijkstra.PriorityQueue.make();
  319. open.push(s, 0);
  320.  
  321. var closest,
  322. u, v,
  323. cost_of_s_to_u,
  324. adjacent_nodes,
  325. cost_of_e,
  326. cost_of_s_to_u_plus_cost_of_e,
  327. cost_of_s_to_v,
  328. first_visit;
  329. while (!open.empty()) {
  330. // In the nodes remaining in graph that have a known cost from s,
  331. // find the node, u, that currently has the shortest path from s.
  332. closest = open.pop();
  333. u = closest.value;
  334. cost_of_s_to_u = closest.cost;
  335.  
  336. // Get nodes adjacent to u...
  337. adjacent_nodes = graph[u] || {};
  338.  
  339. // ...and explore the edges that connect u to those nodes, updating
  340. // the cost of the shortest paths to any or all of those nodes as
  341. // necessary. v is the node across the current edge from u.
  342. for (v in adjacent_nodes) {
  343. if (adjacent_nodes.hasOwnProperty(v)) {
  344. // Get the cost of the edge running from u to v.
  345. cost_of_e = adjacent_nodes[v];
  346.  
  347. // Cost of s to u plus the cost of u to v across e--this is *a*
  348. // cost from s to v that may or may not be less than the current
  349. // known cost to v.
  350. cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
  351.  
  352. // If we haven't visited v yet OR if the current known cost from s to
  353. // v is greater than the new cost we just found (cost of s to u plus
  354. // cost of u to v across e), update v's cost in the cost list and
  355. // update v's predecessor in the predecessor list (it's now u).
  356. cost_of_s_to_v = costs[v];
  357. first_visit = (typeof costs[v] === 'undefined');
  358. if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
  359. costs[v] = cost_of_s_to_u_plus_cost_of_e;
  360. open.push(v, cost_of_s_to_u_plus_cost_of_e);
  361. predecessors[v] = u;
  362. }
  363. }
  364. }
  365. }
  366.  
  367. if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
  368. var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
  369. throw new Error(msg);
  370. }
  371.  
  372. return predecessors;
  373. },
  374.  
  375. extract_shortest_path_from_predecessor_list: function(predecessors, d) {
  376. var nodes = [];
  377. var u = d;
  378. var predecessor;
  379. while (u) {
  380. nodes.push(u);
  381. predecessor = predecessors[u];
  382. u = predecessors[u];
  383. }
  384. nodes.reverse();
  385. return nodes;
  386. },
  387.  
  388. find_path: function(graph, s, d) {
  389. var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
  390. return dijkstra.extract_shortest_path_from_predecessor_list(
  391. predecessors, d);
  392. },
  393.  
  394. /**
  395. * A very naive priority queue implementation.
  396. */
  397. PriorityQueue: {
  398. make: function (opts) {
  399. var T = dijkstra.PriorityQueue,
  400. t = {},
  401. key;
  402. opts = opts || {};
  403. for (key in T) {
  404. if (T.hasOwnProperty(key)) {
  405. t[key] = T[key];
  406. }
  407. }
  408. t.queue = [];
  409. t.sorter = opts.sorter || T.default_sorter;
  410. return t;
  411. },
  412.  
  413. default_sorter: function (a, b) {
  414. return a.cost - b.cost;
  415. },
  416.  
  417. /**
  418. * Add a new item to the queue and ensure the highest priority element
  419. * is at the front of the queue.
  420. */
  421. push: function (value, cost) {
  422. var item = {value: value, cost: cost};
  423. this.queue.push(item);
  424. this.queue.sort(this.sorter);
  425. },
  426.  
  427. /**
  428. * Return the highest priority element in the queue.
  429. */
  430. pop: function () {
  431. return this.queue.shift();
  432. },
  433.  
  434. empty: function () {
  435. return this.queue.length === 0;
  436. }
  437. }
  438. };
  439.  
  440.  
  441. // node.js module exports
  442. if (true) {
  443. module.exports = dijkstra;
  444. }
  445.  
  446.  
  447. /***/ }),
  448.  
  449. /***/ "./node_modules/iclipboard/esm/copy.js":
  450. /*!*********************************************!*\
  451. !*** ./node_modules/iclipboard/esm/copy.js ***!
  452. \*********************************************/
  453. /*! exports provided: copy */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455.  
  456. "use strict";
  457. __webpack_require__.r(__webpack_exports__);
  458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return copy; });
  459. /*!
  460. * Copyright 2018 yangjunbao <yangjunbao@shimo.im>. All rights reserved.
  461. * @since 2018-11-02 19:47:25
  462. */
  463. var _action;
  464. /**
  465. * Check copy is supported or not
  466. * @returns {'copy' | 'cut' | false} - false if not supported, else the mode
  467. */
  468. function getAction() {
  469. if (_action === void 0) {
  470. _action = document.queryCommandSupported('copy')
  471. ? 'copy'
  472. : document.queryCommandSupported('cut')
  473. ? 'cut' : false;
  474. }
  475. return _action;
  476. }
  477. function createSelection(text) {
  478. var input = document.createElement('input');
  479. input.style.cssText = "position: absolute; top: -9999px; left: -9999px;";
  480. document.body.appendChild(input);
  481. input.value = text;
  482. input.readOnly = true;
  483. input.select();
  484. input.setSelectionRange(0, text.length);
  485. return input;
  486. }
  487. /**
  488. * Copy text to system clipboard
  489. * @param {string} text - the text to copy
  490. * @returns {boolean} - true if copy succeeded, else false
  491. */
  492. function copy(text) {
  493. var action = getAction();
  494. if (!action) {
  495. return false;
  496. }
  497. var input = createSelection(text);
  498. try {
  499. return document.execCommand(action);
  500. }
  501. catch (_a) {
  502. return false;
  503. }
  504. finally {
  505. document.body.removeChild(input);
  506. }
  507. }
  508. copy.isSupported = getAction;
  509.  
  510.  
  511. /***/ }),
  512.  
  513. /***/ "./node_modules/iclipboard/esm/index.js":
  514. /*!**********************************************!*\
  515. !*** ./node_modules/iclipboard/esm/index.js ***!
  516. \**********************************************/
  517. /*! exports provided: copy */
  518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  519.  
  520. "use strict";
  521. __webpack_require__.r(__webpack_exports__);
  522. /* harmony import */ var _copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./copy */ "./node_modules/iclipboard/esm/copy.js");
  523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "copy", function() { return _copy__WEBPACK_IMPORTED_MODULE_0__["copy"]; });
  524.  
  525. /*!
  526. * Copyright 2018 yangjunbao <yangjunbao@shimo.im>. All rights reserved.
  527. * @since 2018-11-02 19:47:25
  528. */
  529.  
  530.  
  531.  
  532. /***/ }),
  533.  
  534. /***/ "./node_modules/ieee754/index.js":
  535. /*!***************************************!*\
  536. !*** ./node_modules/ieee754/index.js ***!
  537. \***************************************/
  538. /*! no static exports found */
  539. /***/ (function(module, exports) {
  540.  
  541. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  542. var e, m
  543. var eLen = (nBytes * 8) - mLen - 1
  544. var eMax = (1 << eLen) - 1
  545. var eBias = eMax >> 1
  546. var nBits = -7
  547. var i = isLE ? (nBytes - 1) : 0
  548. var d = isLE ? -1 : 1
  549. var s = buffer[offset + i]
  550.  
  551. i += d
  552.  
  553. e = s & ((1 << (-nBits)) - 1)
  554. s >>= (-nBits)
  555. nBits += eLen
  556. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  557.  
  558. m = e & ((1 << (-nBits)) - 1)
  559. e >>= (-nBits)
  560. nBits += mLen
  561. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  562.  
  563. if (e === 0) {
  564. e = 1 - eBias
  565. } else if (e === eMax) {
  566. return m ? NaN : ((s ? -1 : 1) * Infinity)
  567. } else {
  568. m = m + Math.pow(2, mLen)
  569. e = e - eBias
  570. }
  571. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  572. }
  573.  
  574. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  575. var e, m, c
  576. var eLen = (nBytes * 8) - mLen - 1
  577. var eMax = (1 << eLen) - 1
  578. var eBias = eMax >> 1
  579. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  580. var i = isLE ? 0 : (nBytes - 1)
  581. var d = isLE ? 1 : -1
  582. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  583.  
  584. value = Math.abs(value)
  585.  
  586. if (isNaN(value) || value === Infinity) {
  587. m = isNaN(value) ? 1 : 0
  588. e = eMax
  589. } else {
  590. e = Math.floor(Math.log(value) / Math.LN2)
  591. if (value * (c = Math.pow(2, -e)) < 1) {
  592. e--
  593. c *= 2
  594. }
  595. if (e + eBias >= 1) {
  596. value += rt / c
  597. } else {
  598. value += rt * Math.pow(2, 1 - eBias)
  599. }
  600. if (value * c >= 2) {
  601. e++
  602. c /= 2
  603. }
  604.  
  605. if (e + eBias >= eMax) {
  606. m = 0
  607. e = eMax
  608. } else if (e + eBias >= 1) {
  609. m = ((value * c) - 1) * Math.pow(2, mLen)
  610. e = e + eBias
  611. } else {
  612. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  613. e = 0
  614. }
  615. }
  616.  
  617. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  618.  
  619. e = (e << mLen) | m
  620. eLen += mLen
  621. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  622.  
  623. buffer[offset + i - d] |= s * 128
  624. }
  625.  
  626.  
  627. /***/ }),
  628.  
  629. /***/ "./node_modules/isarray/index.js":
  630. /*!***************************************!*\
  631. !*** ./node_modules/isarray/index.js ***!
  632. \***************************************/
  633. /*! no static exports found */
  634. /***/ (function(module, exports) {
  635.  
  636. var toString = {}.toString;
  637.  
  638. module.exports = Array.isArray || function (arr) {
  639. return toString.call(arr) == '[object Array]';
  640. };
  641.  
  642.  
  643. /***/ }),
  644.  
  645. /***/ "./node_modules/node-libs-browser/node_modules/buffer/index.js":
  646. /*!*********************************************************************!*\
  647. !*** ./node_modules/node-libs-browser/node_modules/buffer/index.js ***!
  648. \*********************************************************************/
  649. /*! no static exports found */
  650. /***/ (function(module, exports, __webpack_require__) {
  651.  
  652. "use strict";
  653. /* WEBPACK VAR INJECTION */(function(global) {/*!
  654. * The buffer module from node.js, for the browser.
  655. *
  656. * @author Feross Aboukhadijeh <http://feross.org>
  657. * @license MIT
  658. */
  659. /* eslint-disable no-proto */
  660.  
  661.  
  662.  
  663. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  664. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  665. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  666.  
  667. exports.Buffer = Buffer
  668. exports.SlowBuffer = SlowBuffer
  669. exports.INSPECT_MAX_BYTES = 50
  670.  
  671. /**
  672. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  673. * === true Use Uint8Array implementation (fastest)
  674. * === false Use Object implementation (most compatible, even IE6)
  675. *
  676. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  677. * Opera 11.6+, iOS 4.2+.
  678. *
  679. * Due to various browser bugs, sometimes the Object implementation will be used even
  680. * when the browser supports typed arrays.
  681. *
  682. * Note:
  683. *
  684. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  685. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  686. *
  687. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  688. *
  689. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  690. * incorrect length in some situations.
  691.  
  692. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  693. * get the Object implementation, which is slower but behaves correctly.
  694. */
  695. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  696. ? global.TYPED_ARRAY_SUPPORT
  697. : typedArraySupport()
  698.  
  699. /*
  700. * Export kMaxLength after typed array support is determined.
  701. */
  702. exports.kMaxLength = kMaxLength()
  703.  
  704. function typedArraySupport () {
  705. try {
  706. var arr = new Uint8Array(1)
  707. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  708. return arr.foo() === 42 && // typed array instances can be augmented
  709. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  710. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  711. } catch (e) {
  712. return false
  713. }
  714. }
  715.  
  716. function kMaxLength () {
  717. return Buffer.TYPED_ARRAY_SUPPORT
  718. ? 0x7fffffff
  719. : 0x3fffffff
  720. }
  721.  
  722. function createBuffer (that, length) {
  723. if (kMaxLength() < length) {
  724. throw new RangeError('Invalid typed array length')
  725. }
  726. if (Buffer.TYPED_ARRAY_SUPPORT) {
  727. // Return an augmented `Uint8Array` instance, for best performance
  728. that = new Uint8Array(length)
  729. that.__proto__ = Buffer.prototype
  730. } else {
  731. // Fallback: Return an object instance of the Buffer class
  732. if (that === null) {
  733. that = new Buffer(length)
  734. }
  735. that.length = length
  736. }
  737.  
  738. return that
  739. }
  740.  
  741. /**
  742. * The Buffer constructor returns instances of `Uint8Array` that have their
  743. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  744. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  745. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  746. * returns a single octet.
  747. *
  748. * The `Uint8Array` prototype remains unmodified.
  749. */
  750.  
  751. function Buffer (arg, encodingOrOffset, length) {
  752. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  753. return new Buffer(arg, encodingOrOffset, length)
  754. }
  755.  
  756. // Common case.
  757. if (typeof arg === 'number') {
  758. if (typeof encodingOrOffset === 'string') {
  759. throw new Error(
  760. 'If encoding is specified then the first argument must be a string'
  761. )
  762. }
  763. return allocUnsafe(this, arg)
  764. }
  765. return from(this, arg, encodingOrOffset, length)
  766. }
  767.  
  768. Buffer.poolSize = 8192 // not used by this implementation
  769.  
  770. // TODO: Legacy, not needed anymore. Remove in next major version.
  771. Buffer._augment = function (arr) {
  772. arr.__proto__ = Buffer.prototype
  773. return arr
  774. }
  775.  
  776. function from (that, value, encodingOrOffset, length) {
  777. if (typeof value === 'number') {
  778. throw new TypeError('"value" argument must not be a number')
  779. }
  780.  
  781. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  782. return fromArrayBuffer(that, value, encodingOrOffset, length)
  783. }
  784.  
  785. if (typeof value === 'string') {
  786. return fromString(that, value, encodingOrOffset)
  787. }
  788.  
  789. return fromObject(that, value)
  790. }
  791.  
  792. /**
  793. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  794. * if value is a number.
  795. * Buffer.from(str[, encoding])
  796. * Buffer.from(array)
  797. * Buffer.from(buffer)
  798. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  799. **/
  800. Buffer.from = function (value, encodingOrOffset, length) {
  801. return from(null, value, encodingOrOffset, length)
  802. }
  803.  
  804. if (Buffer.TYPED_ARRAY_SUPPORT) {
  805. Buffer.prototype.__proto__ = Uint8Array.prototype
  806. Buffer.__proto__ = Uint8Array
  807. if (typeof Symbol !== 'undefined' && Symbol.species &&
  808. Buffer[Symbol.species] === Buffer) {
  809. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  810. Object.defineProperty(Buffer, Symbol.species, {
  811. value: null,
  812. configurable: true
  813. })
  814. }
  815. }
  816.  
  817. function assertSize (size) {
  818. if (typeof size !== 'number') {
  819. throw new TypeError('"size" argument must be a number')
  820. } else if (size < 0) {
  821. throw new RangeError('"size" argument must not be negative')
  822. }
  823. }
  824.  
  825. function alloc (that, size, fill, encoding) {
  826. assertSize(size)
  827. if (size <= 0) {
  828. return createBuffer(that, size)
  829. }
  830. if (fill !== undefined) {
  831. // Only pay attention to encoding if it's a string. This
  832. // prevents accidentally sending in a number that would
  833. // be interpretted as a start offset.
  834. return typeof encoding === 'string'
  835. ? createBuffer(that, size).fill(fill, encoding)
  836. : createBuffer(that, size).fill(fill)
  837. }
  838. return createBuffer(that, size)
  839. }
  840.  
  841. /**
  842. * Creates a new filled Buffer instance.
  843. * alloc(size[, fill[, encoding]])
  844. **/
  845. Buffer.alloc = function (size, fill, encoding) {
  846. return alloc(null, size, fill, encoding)
  847. }
  848.  
  849. function allocUnsafe (that, size) {
  850. assertSize(size)
  851. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  852. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  853. for (var i = 0; i < size; ++i) {
  854. that[i] = 0
  855. }
  856. }
  857. return that
  858. }
  859.  
  860. /**
  861. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  862. * */
  863. Buffer.allocUnsafe = function (size) {
  864. return allocUnsafe(null, size)
  865. }
  866. /**
  867. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  868. */
  869. Buffer.allocUnsafeSlow = function (size) {
  870. return allocUnsafe(null, size)
  871. }
  872.  
  873. function fromString (that, string, encoding) {
  874. if (typeof encoding !== 'string' || encoding === '') {
  875. encoding = 'utf8'
  876. }
  877.  
  878. if (!Buffer.isEncoding(encoding)) {
  879. throw new TypeError('"encoding" must be a valid string encoding')
  880. }
  881.  
  882. var length = byteLength(string, encoding) | 0
  883. that = createBuffer(that, length)
  884.  
  885. var actual = that.write(string, encoding)
  886.  
  887. if (actual !== length) {
  888. // Writing a hex string, for example, that contains invalid characters will
  889. // cause everything after the first invalid character to be ignored. (e.g.
  890. // 'abxxcd' will be treated as 'ab')
  891. that = that.slice(0, actual)
  892. }
  893.  
  894. return that
  895. }
  896.  
  897. function fromArrayLike (that, array) {
  898. var length = array.length < 0 ? 0 : checked(array.length) | 0
  899. that = createBuffer(that, length)
  900. for (var i = 0; i < length; i += 1) {
  901. that[i] = array[i] & 255
  902. }
  903. return that
  904. }
  905.  
  906. function fromArrayBuffer (that, array, byteOffset, length) {
  907. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  908.  
  909. if (byteOffset < 0 || array.byteLength < byteOffset) {
  910. throw new RangeError('\'offset\' is out of bounds')
  911. }
  912.  
  913. if (array.byteLength < byteOffset + (length || 0)) {
  914. throw new RangeError('\'length\' is out of bounds')
  915. }
  916.  
  917. if (byteOffset === undefined && length === undefined) {
  918. array = new Uint8Array(array)
  919. } else if (length === undefined) {
  920. array = new Uint8Array(array, byteOffset)
  921. } else {
  922. array = new Uint8Array(array, byteOffset, length)
  923. }
  924.  
  925. if (Buffer.TYPED_ARRAY_SUPPORT) {
  926. // Return an augmented `Uint8Array` instance, for best performance
  927. that = array
  928. that.__proto__ = Buffer.prototype
  929. } else {
  930. // Fallback: Return an object instance of the Buffer class
  931. that = fromArrayLike(that, array)
  932. }
  933. return that
  934. }
  935.  
  936. function fromObject (that, obj) {
  937. if (Buffer.isBuffer(obj)) {
  938. var len = checked(obj.length) | 0
  939. that = createBuffer(that, len)
  940.  
  941. if (that.length === 0) {
  942. return that
  943. }
  944.  
  945. obj.copy(that, 0, 0, len)
  946. return that
  947. }
  948.  
  949. if (obj) {
  950. if ((typeof ArrayBuffer !== 'undefined' &&
  951. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  952. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  953. return createBuffer(that, 0)
  954. }
  955. return fromArrayLike(that, obj)
  956. }
  957.  
  958. if (obj.type === 'Buffer' && isArray(obj.data)) {
  959. return fromArrayLike(that, obj.data)
  960. }
  961. }
  962.  
  963. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  964. }
  965.  
  966. function checked (length) {
  967. // Note: cannot use `length < kMaxLength()` here because that fails when
  968. // length is NaN (which is otherwise coerced to zero.)
  969. if (length >= kMaxLength()) {
  970. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  971. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  972. }
  973. return length | 0
  974. }
  975.  
  976. function SlowBuffer (length) {
  977. if (+length != length) { // eslint-disable-line eqeqeq
  978. length = 0
  979. }
  980. return Buffer.alloc(+length)
  981. }
  982.  
  983. Buffer.isBuffer = function isBuffer (b) {
  984. return !!(b != null && b._isBuffer)
  985. }
  986.  
  987. Buffer.compare = function compare (a, b) {
  988. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  989. throw new TypeError('Arguments must be Buffers')
  990. }
  991.  
  992. if (a === b) return 0
  993.  
  994. var x = a.length
  995. var y = b.length
  996.  
  997. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  998. if (a[i] !== b[i]) {
  999. x = a[i]
  1000. y = b[i]
  1001. break
  1002. }
  1003. }
  1004.  
  1005. if (x < y) return -1
  1006. if (y < x) return 1
  1007. return 0
  1008. }
  1009.  
  1010. Buffer.isEncoding = function isEncoding (encoding) {
  1011. switch (String(encoding).toLowerCase()) {
  1012. case 'hex':
  1013. case 'utf8':
  1014. case 'utf-8':
  1015. case 'ascii':
  1016. case 'latin1':
  1017. case 'binary':
  1018. case 'base64':
  1019. case 'ucs2':
  1020. case 'ucs-2':
  1021. case 'utf16le':
  1022. case 'utf-16le':
  1023. return true
  1024. default:
  1025. return false
  1026. }
  1027. }
  1028.  
  1029. Buffer.concat = function concat (list, length) {
  1030. if (!isArray(list)) {
  1031. throw new TypeError('"list" argument must be an Array of Buffers')
  1032. }
  1033.  
  1034. if (list.length === 0) {
  1035. return Buffer.alloc(0)
  1036. }
  1037.  
  1038. var i
  1039. if (length === undefined) {
  1040. length = 0
  1041. for (i = 0; i < list.length; ++i) {
  1042. length += list[i].length
  1043. }
  1044. }
  1045.  
  1046. var buffer = Buffer.allocUnsafe(length)
  1047. var pos = 0
  1048. for (i = 0; i < list.length; ++i) {
  1049. var buf = list[i]
  1050. if (!Buffer.isBuffer(buf)) {
  1051. throw new TypeError('"list" argument must be an Array of Buffers')
  1052. }
  1053. buf.copy(buffer, pos)
  1054. pos += buf.length
  1055. }
  1056. return buffer
  1057. }
  1058.  
  1059. function byteLength (string, encoding) {
  1060. if (Buffer.isBuffer(string)) {
  1061. return string.length
  1062. }
  1063. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  1064. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  1065. return string.byteLength
  1066. }
  1067. if (typeof string !== 'string') {
  1068. string = '' + string
  1069. }
  1070.  
  1071. var len = string.length
  1072. if (len === 0) return 0
  1073.  
  1074. // Use a for loop to avoid recursion
  1075. var loweredCase = false
  1076. for (;;) {
  1077. switch (encoding) {
  1078. case 'ascii':
  1079. case 'latin1':
  1080. case 'binary':
  1081. return len
  1082. case 'utf8':
  1083. case 'utf-8':
  1084. case undefined:
  1085. return utf8ToBytes(string).length
  1086. case 'ucs2':
  1087. case 'ucs-2':
  1088. case 'utf16le':
  1089. case 'utf-16le':
  1090. return len * 2
  1091. case 'hex':
  1092. return len >>> 1
  1093. case 'base64':
  1094. return base64ToBytes(string).length
  1095. default:
  1096. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  1097. encoding = ('' + encoding).toLowerCase()
  1098. loweredCase = true
  1099. }
  1100. }
  1101. }
  1102. Buffer.byteLength = byteLength
  1103.  
  1104. function slowToString (encoding, start, end) {
  1105. var loweredCase = false
  1106.  
  1107. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  1108. // property of a typed array.
  1109.  
  1110. // This behaves neither like String nor Uint8Array in that we set start/end
  1111. // to their upper/lower bounds if the value passed is out of range.
  1112. // undefined is handled specially as per ECMA-262 6th Edition,
  1113. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  1114. if (start === undefined || start < 0) {
  1115. start = 0
  1116. }
  1117. // Return early if start > this.length. Done here to prevent potential uint32
  1118. // coercion fail below.
  1119. if (start > this.length) {
  1120. return ''
  1121. }
  1122.  
  1123. if (end === undefined || end > this.length) {
  1124. end = this.length
  1125. }
  1126.  
  1127. if (end <= 0) {
  1128. return ''
  1129. }
  1130.  
  1131. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  1132. end >>>= 0
  1133. start >>>= 0
  1134.  
  1135. if (end <= start) {
  1136. return ''
  1137. }
  1138.  
  1139. if (!encoding) encoding = 'utf8'
  1140.  
  1141. while (true) {
  1142. switch (encoding) {
  1143. case 'hex':
  1144. return hexSlice(this, start, end)
  1145.  
  1146. case 'utf8':
  1147. case 'utf-8':
  1148. return utf8Slice(this, start, end)
  1149.  
  1150. case 'ascii':
  1151. return asciiSlice(this, start, end)
  1152.  
  1153. case 'latin1':
  1154. case 'binary':
  1155. return latin1Slice(this, start, end)
  1156.  
  1157. case 'base64':
  1158. return base64Slice(this, start, end)
  1159.  
  1160. case 'ucs2':
  1161. case 'ucs-2':
  1162. case 'utf16le':
  1163. case 'utf-16le':
  1164. return utf16leSlice(this, start, end)
  1165.  
  1166. default:
  1167. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  1168. encoding = (encoding + '').toLowerCase()
  1169. loweredCase = true
  1170. }
  1171. }
  1172. }
  1173.  
  1174. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  1175. // Buffer instances.
  1176. Buffer.prototype._isBuffer = true
  1177.  
  1178. function swap (b, n, m) {
  1179. var i = b[n]
  1180. b[n] = b[m]
  1181. b[m] = i
  1182. }
  1183.  
  1184. Buffer.prototype.swap16 = function swap16 () {
  1185. var len = this.length
  1186. if (len % 2 !== 0) {
  1187. throw new RangeError('Buffer size must be a multiple of 16-bits')
  1188. }
  1189. for (var i = 0; i < len; i += 2) {
  1190. swap(this, i, i + 1)
  1191. }
  1192. return this
  1193. }
  1194.  
  1195. Buffer.prototype.swap32 = function swap32 () {
  1196. var len = this.length
  1197. if (len % 4 !== 0) {
  1198. throw new RangeError('Buffer size must be a multiple of 32-bits')
  1199. }
  1200. for (var i = 0; i < len; i += 4) {
  1201. swap(this, i, i + 3)
  1202. swap(this, i + 1, i + 2)
  1203. }
  1204. return this
  1205. }
  1206.  
  1207. Buffer.prototype.swap64 = function swap64 () {
  1208. var len = this.length
  1209. if (len % 8 !== 0) {
  1210. throw new RangeError('Buffer size must be a multiple of 64-bits')
  1211. }
  1212. for (var i = 0; i < len; i += 8) {
  1213. swap(this, i, i + 7)
  1214. swap(this, i + 1, i + 6)
  1215. swap(this, i + 2, i + 5)
  1216. swap(this, i + 3, i + 4)
  1217. }
  1218. return this
  1219. }
  1220.  
  1221. Buffer.prototype.toString = function toString () {
  1222. var length = this.length | 0
  1223. if (length === 0) return ''
  1224. if (arguments.length === 0) return utf8Slice(this, 0, length)
  1225. return slowToString.apply(this, arguments)
  1226. }
  1227.  
  1228. Buffer.prototype.equals = function equals (b) {
  1229. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  1230. if (this === b) return true
  1231. return Buffer.compare(this, b) === 0
  1232. }
  1233.  
  1234. Buffer.prototype.inspect = function inspect () {
  1235. var str = ''
  1236. var max = exports.INSPECT_MAX_BYTES
  1237. if (this.length > 0) {
  1238. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  1239. if (this.length > max) str += ' ... '
  1240. }
  1241. return '<Buffer ' + str + '>'
  1242. }
  1243.  
  1244. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  1245. if (!Buffer.isBuffer(target)) {
  1246. throw new TypeError('Argument must be a Buffer')
  1247. }
  1248.  
  1249. if (start === undefined) {
  1250. start = 0
  1251. }
  1252. if (end === undefined) {
  1253. end = target ? target.length : 0
  1254. }
  1255. if (thisStart === undefined) {
  1256. thisStart = 0
  1257. }
  1258. if (thisEnd === undefined) {
  1259. thisEnd = this.length
  1260. }
  1261.  
  1262. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  1263. throw new RangeError('out of range index')
  1264. }
  1265.  
  1266. if (thisStart >= thisEnd && start >= end) {
  1267. return 0
  1268. }
  1269. if (thisStart >= thisEnd) {
  1270. return -1
  1271. }
  1272. if (start >= end) {
  1273. return 1
  1274. }
  1275.  
  1276. start >>>= 0
  1277. end >>>= 0
  1278. thisStart >>>= 0
  1279. thisEnd >>>= 0
  1280.  
  1281. if (this === target) return 0
  1282.  
  1283. var x = thisEnd - thisStart
  1284. var y = end - start
  1285. var len = Math.min(x, y)
  1286.  
  1287. var thisCopy = this.slice(thisStart, thisEnd)
  1288. var targetCopy = target.slice(start, end)
  1289.  
  1290. for (var i = 0; i < len; ++i) {
  1291. if (thisCopy[i] !== targetCopy[i]) {
  1292. x = thisCopy[i]
  1293. y = targetCopy[i]
  1294. break
  1295. }
  1296. }
  1297.  
  1298. if (x < y) return -1
  1299. if (y < x) return 1
  1300. return 0
  1301. }
  1302.  
  1303. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  1304. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  1305. //
  1306. // Arguments:
  1307. // - buffer - a Buffer to search
  1308. // - val - a string, Buffer, or number
  1309. // - byteOffset - an index into `buffer`; will be clamped to an int32
  1310. // - encoding - an optional encoding, relevant is val is a string
  1311. // - dir - true for indexOf, false for lastIndexOf
  1312. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  1313. // Empty buffer means no match
  1314. if (buffer.length === 0) return -1
  1315.  
  1316. // Normalize byteOffset
  1317. if (typeof byteOffset === 'string') {
  1318. encoding = byteOffset
  1319. byteOffset = 0
  1320. } else if (byteOffset > 0x7fffffff) {
  1321. byteOffset = 0x7fffffff
  1322. } else if (byteOffset < -0x80000000) {
  1323. byteOffset = -0x80000000
  1324. }
  1325. byteOffset = +byteOffset // Coerce to Number.
  1326. if (isNaN(byteOffset)) {
  1327. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  1328. byteOffset = dir ? 0 : (buffer.length - 1)
  1329. }
  1330.  
  1331. // Normalize byteOffset: negative offsets start from the end of the buffer
  1332. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  1333. if (byteOffset >= buffer.length) {
  1334. if (dir) return -1
  1335. else byteOffset = buffer.length - 1
  1336. } else if (byteOffset < 0) {
  1337. if (dir) byteOffset = 0
  1338. else return -1
  1339. }
  1340.  
  1341. // Normalize val
  1342. if (typeof val === 'string') {
  1343. val = Buffer.from(val, encoding)
  1344. }
  1345.  
  1346. // Finally, search either indexOf (if dir is true) or lastIndexOf
  1347. if (Buffer.isBuffer(val)) {
  1348. // Special case: looking for empty string/buffer always fails
  1349. if (val.length === 0) {
  1350. return -1
  1351. }
  1352. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  1353. } else if (typeof val === 'number') {
  1354. val = val & 0xFF // Search for a byte value [0-255]
  1355. if (Buffer.TYPED_ARRAY_SUPPORT &&
  1356. typeof Uint8Array.prototype.indexOf === 'function') {
  1357. if (dir) {
  1358. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  1359. } else {
  1360. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  1361. }
  1362. }
  1363. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  1364. }
  1365.  
  1366. throw new TypeError('val must be string, number or Buffer')
  1367. }
  1368.  
  1369. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  1370. var indexSize = 1
  1371. var arrLength = arr.length
  1372. var valLength = val.length
  1373.  
  1374. if (encoding !== undefined) {
  1375. encoding = String(encoding).toLowerCase()
  1376. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  1377. encoding === 'utf16le' || encoding === 'utf-16le') {
  1378. if (arr.length < 2 || val.length < 2) {
  1379. return -1
  1380. }
  1381. indexSize = 2
  1382. arrLength /= 2
  1383. valLength /= 2
  1384. byteOffset /= 2
  1385. }
  1386. }
  1387.  
  1388. function read (buf, i) {
  1389. if (indexSize === 1) {
  1390. return buf[i]
  1391. } else {
  1392. return buf.readUInt16BE(i * indexSize)
  1393. }
  1394. }
  1395.  
  1396. var i
  1397. if (dir) {
  1398. var foundIndex = -1
  1399. for (i = byteOffset; i < arrLength; i++) {
  1400. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  1401. if (foundIndex === -1) foundIndex = i
  1402. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  1403. } else {
  1404. if (foundIndex !== -1) i -= i - foundIndex
  1405. foundIndex = -1
  1406. }
  1407. }
  1408. } else {
  1409. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  1410. for (i = byteOffset; i >= 0; i--) {
  1411. var found = true
  1412. for (var j = 0; j < valLength; j++) {
  1413. if (read(arr, i + j) !== read(val, j)) {
  1414. found = false
  1415. break
  1416. }
  1417. }
  1418. if (found) return i
  1419. }
  1420. }
  1421.  
  1422. return -1
  1423. }
  1424.  
  1425. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  1426. return this.indexOf(val, byteOffset, encoding) !== -1
  1427. }
  1428.  
  1429. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  1430. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  1431. }
  1432.  
  1433. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  1434. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  1435. }
  1436.  
  1437. function hexWrite (buf, string, offset, length) {
  1438. offset = Number(offset) || 0
  1439. var remaining = buf.length - offset
  1440. if (!length) {
  1441. length = remaining
  1442. } else {
  1443. length = Number(length)
  1444. if (length > remaining) {
  1445. length = remaining
  1446. }
  1447. }
  1448.  
  1449. // must be an even number of digits
  1450. var strLen = string.length
  1451. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  1452.  
  1453. if (length > strLen / 2) {
  1454. length = strLen / 2
  1455. }
  1456. for (var i = 0; i < length; ++i) {
  1457. var parsed = parseInt(string.substr(i * 2, 2), 16)
  1458. if (isNaN(parsed)) return i
  1459. buf[offset + i] = parsed
  1460. }
  1461. return i
  1462. }
  1463.  
  1464. function utf8Write (buf, string, offset, length) {
  1465. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  1466. }
  1467.  
  1468. function asciiWrite (buf, string, offset, length) {
  1469. return blitBuffer(asciiToBytes(string), buf, offset, length)
  1470. }
  1471.  
  1472. function latin1Write (buf, string, offset, length) {
  1473. return asciiWrite(buf, string, offset, length)
  1474. }
  1475.  
  1476. function base64Write (buf, string, offset, length) {
  1477. return blitBuffer(base64ToBytes(string), buf, offset, length)
  1478. }
  1479.  
  1480. function ucs2Write (buf, string, offset, length) {
  1481. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  1482. }
  1483.  
  1484. Buffer.prototype.write = function write (string, offset, length, encoding) {
  1485. // Buffer#write(string)
  1486. if (offset === undefined) {
  1487. encoding = 'utf8'
  1488. length = this.length
  1489. offset = 0
  1490. // Buffer#write(string, encoding)
  1491. } else if (length === undefined && typeof offset === 'string') {
  1492. encoding = offset
  1493. length = this.length
  1494. offset = 0
  1495. // Buffer#write(string, offset[, length][, encoding])
  1496. } else if (isFinite(offset)) {
  1497. offset = offset | 0
  1498. if (isFinite(length)) {
  1499. length = length | 0
  1500. if (encoding === undefined) encoding = 'utf8'
  1501. } else {
  1502. encoding = length
  1503. length = undefined
  1504. }
  1505. // legacy write(string, encoding, offset, length) - remove in v0.13
  1506. } else {
  1507. throw new Error(
  1508. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  1509. )
  1510. }
  1511.  
  1512. var remaining = this.length - offset
  1513. if (length === undefined || length > remaining) length = remaining
  1514.  
  1515. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  1516. throw new RangeError('Attempt to write outside buffer bounds')
  1517. }
  1518.  
  1519. if (!encoding) encoding = 'utf8'
  1520.  
  1521. var loweredCase = false
  1522. for (;;) {
  1523. switch (encoding) {
  1524. case 'hex':
  1525. return hexWrite(this, string, offset, length)
  1526.  
  1527. case 'utf8':
  1528. case 'utf-8':
  1529. return utf8Write(this, string, offset, length)
  1530.  
  1531. case 'ascii':
  1532. return asciiWrite(this, string, offset, length)
  1533.  
  1534. case 'latin1':
  1535. case 'binary':
  1536. return latin1Write(this, string, offset, length)
  1537.  
  1538. case 'base64':
  1539. // Warning: maxLength not taken into account in base64Write
  1540. return base64Write(this, string, offset, length)
  1541.  
  1542. case 'ucs2':
  1543. case 'ucs-2':
  1544. case 'utf16le':
  1545. case 'utf-16le':
  1546. return ucs2Write(this, string, offset, length)
  1547.  
  1548. default:
  1549. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  1550. encoding = ('' + encoding).toLowerCase()
  1551. loweredCase = true
  1552. }
  1553. }
  1554. }
  1555.  
  1556. Buffer.prototype.toJSON = function toJSON () {
  1557. return {
  1558. type: 'Buffer',
  1559. data: Array.prototype.slice.call(this._arr || this, 0)
  1560. }
  1561. }
  1562.  
  1563. function base64Slice (buf, start, end) {
  1564. if (start === 0 && end === buf.length) {
  1565. return base64.fromByteArray(buf)
  1566. } else {
  1567. return base64.fromByteArray(buf.slice(start, end))
  1568. }
  1569. }
  1570.  
  1571. function utf8Slice (buf, start, end) {
  1572. end = Math.min(buf.length, end)
  1573. var res = []
  1574.  
  1575. var i = start
  1576. while (i < end) {
  1577. var firstByte = buf[i]
  1578. var codePoint = null
  1579. var bytesPerSequence = (firstByte > 0xEF) ? 4
  1580. : (firstByte > 0xDF) ? 3
  1581. : (firstByte > 0xBF) ? 2
  1582. : 1
  1583.  
  1584. if (i + bytesPerSequence <= end) {
  1585. var secondByte, thirdByte, fourthByte, tempCodePoint
  1586.  
  1587. switch (bytesPerSequence) {
  1588. case 1:
  1589. if (firstByte < 0x80) {
  1590. codePoint = firstByte
  1591. }
  1592. break
  1593. case 2:
  1594. secondByte = buf[i + 1]
  1595. if ((secondByte & 0xC0) === 0x80) {
  1596. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  1597. if (tempCodePoint > 0x7F) {
  1598. codePoint = tempCodePoint
  1599. }
  1600. }
  1601. break
  1602. case 3:
  1603. secondByte = buf[i + 1]
  1604. thirdByte = buf[i + 2]
  1605. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  1606. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  1607. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  1608. codePoint = tempCodePoint
  1609. }
  1610. }
  1611. break
  1612. case 4:
  1613. secondByte = buf[i + 1]
  1614. thirdByte = buf[i + 2]
  1615. fourthByte = buf[i + 3]
  1616. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  1617. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  1618. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  1619. codePoint = tempCodePoint
  1620. }
  1621. }
  1622. }
  1623. }
  1624.  
  1625. if (codePoint === null) {
  1626. // we did not generate a valid codePoint so insert a
  1627. // replacement char (U+FFFD) and advance only 1 byte
  1628. codePoint = 0xFFFD
  1629. bytesPerSequence = 1
  1630. } else if (codePoint > 0xFFFF) {
  1631. // encode to utf16 (surrogate pair dance)
  1632. codePoint -= 0x10000
  1633. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  1634. codePoint = 0xDC00 | codePoint & 0x3FF
  1635. }
  1636.  
  1637. res.push(codePoint)
  1638. i += bytesPerSequence
  1639. }
  1640.  
  1641. return decodeCodePointsArray(res)
  1642. }
  1643.  
  1644. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1645. // the lowest limit is Chrome, with 0x10000 args.
  1646. // We go 1 magnitude less, for safety
  1647. var MAX_ARGUMENTS_LENGTH = 0x1000
  1648.  
  1649. function decodeCodePointsArray (codePoints) {
  1650. var len = codePoints.length
  1651. if (len <= MAX_ARGUMENTS_LENGTH) {
  1652. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1653. }
  1654.  
  1655. // Decode in chunks to avoid "call stack size exceeded".
  1656. var res = ''
  1657. var i = 0
  1658. while (i < len) {
  1659. res += String.fromCharCode.apply(
  1660. String,
  1661. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1662. )
  1663. }
  1664. return res
  1665. }
  1666.  
  1667. function asciiSlice (buf, start, end) {
  1668. var ret = ''
  1669. end = Math.min(buf.length, end)
  1670.  
  1671. for (var i = start; i < end; ++i) {
  1672. ret += String.fromCharCode(buf[i] & 0x7F)
  1673. }
  1674. return ret
  1675. }
  1676.  
  1677. function latin1Slice (buf, start, end) {
  1678. var ret = ''
  1679. end = Math.min(buf.length, end)
  1680.  
  1681. for (var i = start; i < end; ++i) {
  1682. ret += String.fromCharCode(buf[i])
  1683. }
  1684. return ret
  1685. }
  1686.  
  1687. function hexSlice (buf, start, end) {
  1688. var len = buf.length
  1689.  
  1690. if (!start || start < 0) start = 0
  1691. if (!end || end < 0 || end > len) end = len
  1692.  
  1693. var out = ''
  1694. for (var i = start; i < end; ++i) {
  1695. out += toHex(buf[i])
  1696. }
  1697. return out
  1698. }
  1699.  
  1700. function utf16leSlice (buf, start, end) {
  1701. var bytes = buf.slice(start, end)
  1702. var res = ''
  1703. for (var i = 0; i < bytes.length; i += 2) {
  1704. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1705. }
  1706. return res
  1707. }
  1708.  
  1709. Buffer.prototype.slice = function slice (start, end) {
  1710. var len = this.length
  1711. start = ~~start
  1712. end = end === undefined ? len : ~~end
  1713.  
  1714. if (start < 0) {
  1715. start += len
  1716. if (start < 0) start = 0
  1717. } else if (start > len) {
  1718. start = len
  1719. }
  1720.  
  1721. if (end < 0) {
  1722. end += len
  1723. if (end < 0) end = 0
  1724. } else if (end > len) {
  1725. end = len
  1726. }
  1727.  
  1728. if (end < start) end = start
  1729.  
  1730. var newBuf
  1731. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1732. newBuf = this.subarray(start, end)
  1733. newBuf.__proto__ = Buffer.prototype
  1734. } else {
  1735. var sliceLen = end - start
  1736. newBuf = new Buffer(sliceLen, undefined)
  1737. for (var i = 0; i < sliceLen; ++i) {
  1738. newBuf[i] = this[i + start]
  1739. }
  1740. }
  1741.  
  1742. return newBuf
  1743. }
  1744.  
  1745. /*
  1746. * Need to make sure that buffer isn't trying to write out of bounds.
  1747. */
  1748. function checkOffset (offset, ext, length) {
  1749. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1750. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1751. }
  1752.  
  1753. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1754. offset = offset | 0
  1755. byteLength = byteLength | 0
  1756. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1757.  
  1758. var val = this[offset]
  1759. var mul = 1
  1760. var i = 0
  1761. while (++i < byteLength && (mul *= 0x100)) {
  1762. val += this[offset + i] * mul
  1763. }
  1764.  
  1765. return val
  1766. }
  1767.  
  1768. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1769. offset = offset | 0
  1770. byteLength = byteLength | 0
  1771. if (!noAssert) {
  1772. checkOffset(offset, byteLength, this.length)
  1773. }
  1774.  
  1775. var val = this[offset + --byteLength]
  1776. var mul = 1
  1777. while (byteLength > 0 && (mul *= 0x100)) {
  1778. val += this[offset + --byteLength] * mul
  1779. }
  1780.  
  1781. return val
  1782. }
  1783.  
  1784. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1785. if (!noAssert) checkOffset(offset, 1, this.length)
  1786. return this[offset]
  1787. }
  1788.  
  1789. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1790. if (!noAssert) checkOffset(offset, 2, this.length)
  1791. return this[offset] | (this[offset + 1] << 8)
  1792. }
  1793.  
  1794. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1795. if (!noAssert) checkOffset(offset, 2, this.length)
  1796. return (this[offset] << 8) | this[offset + 1]
  1797. }
  1798.  
  1799. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1800. if (!noAssert) checkOffset(offset, 4, this.length)
  1801.  
  1802. return ((this[offset]) |
  1803. (this[offset + 1] << 8) |
  1804. (this[offset + 2] << 16)) +
  1805. (this[offset + 3] * 0x1000000)
  1806. }
  1807.  
  1808. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1809. if (!noAssert) checkOffset(offset, 4, this.length)
  1810.  
  1811. return (this[offset] * 0x1000000) +
  1812. ((this[offset + 1] << 16) |
  1813. (this[offset + 2] << 8) |
  1814. this[offset + 3])
  1815. }
  1816.  
  1817. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1818. offset = offset | 0
  1819. byteLength = byteLength | 0
  1820. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1821.  
  1822. var val = this[offset]
  1823. var mul = 1
  1824. var i = 0
  1825. while (++i < byteLength && (mul *= 0x100)) {
  1826. val += this[offset + i] * mul
  1827. }
  1828. mul *= 0x80
  1829.  
  1830. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1831.  
  1832. return val
  1833. }
  1834.  
  1835. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1836. offset = offset | 0
  1837. byteLength = byteLength | 0
  1838. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1839.  
  1840. var i = byteLength
  1841. var mul = 1
  1842. var val = this[offset + --i]
  1843. while (i > 0 && (mul *= 0x100)) {
  1844. val += this[offset + --i] * mul
  1845. }
  1846. mul *= 0x80
  1847.  
  1848. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1849.  
  1850. return val
  1851. }
  1852.  
  1853. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1854. if (!noAssert) checkOffset(offset, 1, this.length)
  1855. if (!(this[offset] & 0x80)) return (this[offset])
  1856. return ((0xff - this[offset] + 1) * -1)
  1857. }
  1858.  
  1859. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1860. if (!noAssert) checkOffset(offset, 2, this.length)
  1861. var val = this[offset] | (this[offset + 1] << 8)
  1862. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1863. }
  1864.  
  1865. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1866. if (!noAssert) checkOffset(offset, 2, this.length)
  1867. var val = this[offset + 1] | (this[offset] << 8)
  1868. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1869. }
  1870.  
  1871. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1872. if (!noAssert) checkOffset(offset, 4, this.length)
  1873.  
  1874. return (this[offset]) |
  1875. (this[offset + 1] << 8) |
  1876. (this[offset + 2] << 16) |
  1877. (this[offset + 3] << 24)
  1878. }
  1879.  
  1880. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1881. if (!noAssert) checkOffset(offset, 4, this.length)
  1882.  
  1883. return (this[offset] << 24) |
  1884. (this[offset + 1] << 16) |
  1885. (this[offset + 2] << 8) |
  1886. (this[offset + 3])
  1887. }
  1888.  
  1889. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1890. if (!noAssert) checkOffset(offset, 4, this.length)
  1891. return ieee754.read(this, offset, true, 23, 4)
  1892. }
  1893.  
  1894. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1895. if (!noAssert) checkOffset(offset, 4, this.length)
  1896. return ieee754.read(this, offset, false, 23, 4)
  1897. }
  1898.  
  1899. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1900. if (!noAssert) checkOffset(offset, 8, this.length)
  1901. return ieee754.read(this, offset, true, 52, 8)
  1902. }
  1903.  
  1904. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1905. if (!noAssert) checkOffset(offset, 8, this.length)
  1906. return ieee754.read(this, offset, false, 52, 8)
  1907. }
  1908.  
  1909. function checkInt (buf, value, offset, ext, max, min) {
  1910. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1911. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1912. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1913. }
  1914.  
  1915. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1916. value = +value
  1917. offset = offset | 0
  1918. byteLength = byteLength | 0
  1919. if (!noAssert) {
  1920. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1921. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1922. }
  1923.  
  1924. var mul = 1
  1925. var i = 0
  1926. this[offset] = value & 0xFF
  1927. while (++i < byteLength && (mul *= 0x100)) {
  1928. this[offset + i] = (value / mul) & 0xFF
  1929. }
  1930.  
  1931. return offset + byteLength
  1932. }
  1933.  
  1934. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1935. value = +value
  1936. offset = offset | 0
  1937. byteLength = byteLength | 0
  1938. if (!noAssert) {
  1939. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1940. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1941. }
  1942.  
  1943. var i = byteLength - 1
  1944. var mul = 1
  1945. this[offset + i] = value & 0xFF
  1946. while (--i >= 0 && (mul *= 0x100)) {
  1947. this[offset + i] = (value / mul) & 0xFF
  1948. }
  1949.  
  1950. return offset + byteLength
  1951. }
  1952.  
  1953. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1954. value = +value
  1955. offset = offset | 0
  1956. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1957. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1958. this[offset] = (value & 0xff)
  1959. return offset + 1
  1960. }
  1961.  
  1962. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1963. if (value < 0) value = 0xffff + value + 1
  1964. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  1965. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1966. (littleEndian ? i : 1 - i) * 8
  1967. }
  1968. }
  1969.  
  1970. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1971. value = +value
  1972. offset = offset | 0
  1973. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1974. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1975. this[offset] = (value & 0xff)
  1976. this[offset + 1] = (value >>> 8)
  1977. } else {
  1978. objectWriteUInt16(this, value, offset, true)
  1979. }
  1980. return offset + 2
  1981. }
  1982.  
  1983. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1984. value = +value
  1985. offset = offset | 0
  1986. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1987. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1988. this[offset] = (value >>> 8)
  1989. this[offset + 1] = (value & 0xff)
  1990. } else {
  1991. objectWriteUInt16(this, value, offset, false)
  1992. }
  1993. return offset + 2
  1994. }
  1995.  
  1996. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1997. if (value < 0) value = 0xffffffff + value + 1
  1998. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  1999. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  2000. }
  2001. }
  2002.  
  2003. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  2004. value = +value
  2005. offset = offset | 0
  2006. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  2007. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2008. this[offset + 3] = (value >>> 24)
  2009. this[offset + 2] = (value >>> 16)
  2010. this[offset + 1] = (value >>> 8)
  2011. this[offset] = (value & 0xff)
  2012. } else {
  2013. objectWriteUInt32(this, value, offset, true)
  2014. }
  2015. return offset + 4
  2016. }
  2017.  
  2018. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  2019. value = +value
  2020. offset = offset | 0
  2021. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  2022. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2023. this[offset] = (value >>> 24)
  2024. this[offset + 1] = (value >>> 16)
  2025. this[offset + 2] = (value >>> 8)
  2026. this[offset + 3] = (value & 0xff)
  2027. } else {
  2028. objectWriteUInt32(this, value, offset, false)
  2029. }
  2030. return offset + 4
  2031. }
  2032.  
  2033. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  2034. value = +value
  2035. offset = offset | 0
  2036. if (!noAssert) {
  2037. var limit = Math.pow(2, 8 * byteLength - 1)
  2038.  
  2039. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  2040. }
  2041.  
  2042. var i = 0
  2043. var mul = 1
  2044. var sub = 0
  2045. this[offset] = value & 0xFF
  2046. while (++i < byteLength && (mul *= 0x100)) {
  2047. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  2048. sub = 1
  2049. }
  2050. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  2051. }
  2052.  
  2053. return offset + byteLength
  2054. }
  2055.  
  2056. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  2057. value = +value
  2058. offset = offset | 0
  2059. if (!noAssert) {
  2060. var limit = Math.pow(2, 8 * byteLength - 1)
  2061.  
  2062. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  2063. }
  2064.  
  2065. var i = byteLength - 1
  2066. var mul = 1
  2067. var sub = 0
  2068. this[offset + i] = value & 0xFF
  2069. while (--i >= 0 && (mul *= 0x100)) {
  2070. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  2071. sub = 1
  2072. }
  2073. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  2074. }
  2075.  
  2076. return offset + byteLength
  2077. }
  2078.  
  2079. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  2080. value = +value
  2081. offset = offset | 0
  2082. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  2083. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  2084. if (value < 0) value = 0xff + value + 1
  2085. this[offset] = (value & 0xff)
  2086. return offset + 1
  2087. }
  2088.  
  2089. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  2090. value = +value
  2091. offset = offset | 0
  2092. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  2093. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2094. this[offset] = (value & 0xff)
  2095. this[offset + 1] = (value >>> 8)
  2096. } else {
  2097. objectWriteUInt16(this, value, offset, true)
  2098. }
  2099. return offset + 2
  2100. }
  2101.  
  2102. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  2103. value = +value
  2104. offset = offset | 0
  2105. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  2106. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2107. this[offset] = (value >>> 8)
  2108. this[offset + 1] = (value & 0xff)
  2109. } else {
  2110. objectWriteUInt16(this, value, offset, false)
  2111. }
  2112. return offset + 2
  2113. }
  2114.  
  2115. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  2116. value = +value
  2117. offset = offset | 0
  2118. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  2119. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2120. this[offset] = (value & 0xff)
  2121. this[offset + 1] = (value >>> 8)
  2122. this[offset + 2] = (value >>> 16)
  2123. this[offset + 3] = (value >>> 24)
  2124. } else {
  2125. objectWriteUInt32(this, value, offset, true)
  2126. }
  2127. return offset + 4
  2128. }
  2129.  
  2130. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  2131. value = +value
  2132. offset = offset | 0
  2133. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  2134. if (value < 0) value = 0xffffffff + value + 1
  2135. if (Buffer.TYPED_ARRAY_SUPPORT) {
  2136. this[offset] = (value >>> 24)
  2137. this[offset + 1] = (value >>> 16)
  2138. this[offset + 2] = (value >>> 8)
  2139. this[offset + 3] = (value & 0xff)
  2140. } else {
  2141. objectWriteUInt32(this, value, offset, false)
  2142. }
  2143. return offset + 4
  2144. }
  2145.  
  2146. function checkIEEE754 (buf, value, offset, ext, max, min) {
  2147. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  2148. if (offset < 0) throw new RangeError('Index out of range')
  2149. }
  2150.  
  2151. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  2152. if (!noAssert) {
  2153. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  2154. }
  2155. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  2156. return offset + 4
  2157. }
  2158.  
  2159. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  2160. return writeFloat(this, value, offset, true, noAssert)
  2161. }
  2162.  
  2163. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  2164. return writeFloat(this, value, offset, false, noAssert)
  2165. }
  2166.  
  2167. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  2168. if (!noAssert) {
  2169. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  2170. }
  2171. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  2172. return offset + 8
  2173. }
  2174.  
  2175. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  2176. return writeDouble(this, value, offset, true, noAssert)
  2177. }
  2178.  
  2179. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  2180. return writeDouble(this, value, offset, false, noAssert)
  2181. }
  2182.  
  2183. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  2184. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  2185. if (!start) start = 0
  2186. if (!end && end !== 0) end = this.length
  2187. if (targetStart >= target.length) targetStart = target.length
  2188. if (!targetStart) targetStart = 0
  2189. if (end > 0 && end < start) end = start
  2190.  
  2191. // Copy 0 bytes; we're done
  2192. if (end === start) return 0
  2193. if (target.length === 0 || this.length === 0) return 0
  2194.  
  2195. // Fatal error conditions
  2196. if (targetStart < 0) {
  2197. throw new RangeError('targetStart out of bounds')
  2198. }
  2199. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  2200. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  2201.  
  2202. // Are we oob?
  2203. if (end > this.length) end = this.length
  2204. if (target.length - targetStart < end - start) {
  2205. end = target.length - targetStart + start
  2206. }
  2207.  
  2208. var len = end - start
  2209. var i
  2210.  
  2211. if (this === target && start < targetStart && targetStart < end) {
  2212. // descending copy from end
  2213. for (i = len - 1; i >= 0; --i) {
  2214. target[i + targetStart] = this[i + start]
  2215. }
  2216. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  2217. // ascending copy from start
  2218. for (i = 0; i < len; ++i) {
  2219. target[i + targetStart] = this[i + start]
  2220. }
  2221. } else {
  2222. Uint8Array.prototype.set.call(
  2223. target,
  2224. this.subarray(start, start + len),
  2225. targetStart
  2226. )
  2227. }
  2228.  
  2229. return len
  2230. }
  2231.  
  2232. // Usage:
  2233. // buffer.fill(number[, offset[, end]])
  2234. // buffer.fill(buffer[, offset[, end]])
  2235. // buffer.fill(string[, offset[, end]][, encoding])
  2236. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  2237. // Handle string cases:
  2238. if (typeof val === 'string') {
  2239. if (typeof start === 'string') {
  2240. encoding = start
  2241. start = 0
  2242. end = this.length
  2243. } else if (typeof end === 'string') {
  2244. encoding = end
  2245. end = this.length
  2246. }
  2247. if (val.length === 1) {
  2248. var code = val.charCodeAt(0)
  2249. if (code < 256) {
  2250. val = code
  2251. }
  2252. }
  2253. if (encoding !== undefined && typeof encoding !== 'string') {
  2254. throw new TypeError('encoding must be a string')
  2255. }
  2256. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  2257. throw new TypeError('Unknown encoding: ' + encoding)
  2258. }
  2259. } else if (typeof val === 'number') {
  2260. val = val & 255
  2261. }
  2262.  
  2263. // Invalid ranges are not set to a default, so can range check early.
  2264. if (start < 0 || this.length < start || this.length < end) {
  2265. throw new RangeError('Out of range index')
  2266. }
  2267.  
  2268. if (end <= start) {
  2269. return this
  2270. }
  2271.  
  2272. start = start >>> 0
  2273. end = end === undefined ? this.length : end >>> 0
  2274.  
  2275. if (!val) val = 0
  2276.  
  2277. var i
  2278. if (typeof val === 'number') {
  2279. for (i = start; i < end; ++i) {
  2280. this[i] = val
  2281. }
  2282. } else {
  2283. var bytes = Buffer.isBuffer(val)
  2284. ? val
  2285. : utf8ToBytes(new Buffer(val, encoding).toString())
  2286. var len = bytes.length
  2287. for (i = 0; i < end - start; ++i) {
  2288. this[i + start] = bytes[i % len]
  2289. }
  2290. }
  2291.  
  2292. return this
  2293. }
  2294.  
  2295. // HELPER FUNCTIONS
  2296. // ================
  2297.  
  2298. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  2299.  
  2300. function base64clean (str) {
  2301. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  2302. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  2303. // Node converts strings with length < 2 to ''
  2304. if (str.length < 2) return ''
  2305. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  2306. while (str.length % 4 !== 0) {
  2307. str = str + '='
  2308. }
  2309. return str
  2310. }
  2311.  
  2312. function stringtrim (str) {
  2313. if (str.trim) return str.trim()
  2314. return str.replace(/^\s+|\s+$/g, '')
  2315. }
  2316.  
  2317. function toHex (n) {
  2318. if (n < 16) return '0' + n.toString(16)
  2319. return n.toString(16)
  2320. }
  2321.  
  2322. function utf8ToBytes (string, units) {
  2323. units = units || Infinity
  2324. var codePoint
  2325. var length = string.length
  2326. var leadSurrogate = null
  2327. var bytes = []
  2328.  
  2329. for (var i = 0; i < length; ++i) {
  2330. codePoint = string.charCodeAt(i)
  2331.  
  2332. // is surrogate component
  2333. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  2334. // last char was a lead
  2335. if (!leadSurrogate) {
  2336. // no lead yet
  2337. if (codePoint > 0xDBFF) {
  2338. // unexpected trail
  2339. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  2340. continue
  2341. } else if (i + 1 === length) {
  2342. // unpaired lead
  2343. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  2344. continue
  2345. }
  2346.  
  2347. // valid lead
  2348. leadSurrogate = codePoint
  2349.  
  2350. continue
  2351. }
  2352.  
  2353. // 2 leads in a row
  2354. if (codePoint < 0xDC00) {
  2355. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  2356. leadSurrogate = codePoint
  2357. continue
  2358. }
  2359.  
  2360. // valid surrogate pair
  2361. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  2362. } else if (leadSurrogate) {
  2363. // valid bmp char, but last char was a lead
  2364. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  2365. }
  2366.  
  2367. leadSurrogate = null
  2368.  
  2369. // encode utf8
  2370. if (codePoint < 0x80) {
  2371. if ((units -= 1) < 0) break
  2372. bytes.push(codePoint)
  2373. } else if (codePoint < 0x800) {
  2374. if ((units -= 2) < 0) break
  2375. bytes.push(
  2376. codePoint >> 0x6 | 0xC0,
  2377. codePoint & 0x3F | 0x80
  2378. )
  2379. } else if (codePoint < 0x10000) {
  2380. if ((units -= 3) < 0) break
  2381. bytes.push(
  2382. codePoint >> 0xC | 0xE0,
  2383. codePoint >> 0x6 & 0x3F | 0x80,
  2384. codePoint & 0x3F | 0x80
  2385. )
  2386. } else if (codePoint < 0x110000) {
  2387. if ((units -= 4) < 0) break
  2388. bytes.push(
  2389. codePoint >> 0x12 | 0xF0,
  2390. codePoint >> 0xC & 0x3F | 0x80,
  2391. codePoint >> 0x6 & 0x3F | 0x80,
  2392. codePoint & 0x3F | 0x80
  2393. )
  2394. } else {
  2395. throw new Error('Invalid code point')
  2396. }
  2397. }
  2398.  
  2399. return bytes
  2400. }
  2401.  
  2402. function asciiToBytes (str) {
  2403. var byteArray = []
  2404. for (var i = 0; i < str.length; ++i) {
  2405. // Node's code seems to be doing this and not & 0x7F..
  2406. byteArray.push(str.charCodeAt(i) & 0xFF)
  2407. }
  2408. return byteArray
  2409. }
  2410.  
  2411. function utf16leToBytes (str, units) {
  2412. var c, hi, lo
  2413. var byteArray = []
  2414. for (var i = 0; i < str.length; ++i) {
  2415. if ((units -= 2) < 0) break
  2416.  
  2417. c = str.charCodeAt(i)
  2418. hi = c >> 8
  2419. lo = c % 256
  2420. byteArray.push(lo)
  2421. byteArray.push(hi)
  2422. }
  2423.  
  2424. return byteArray
  2425. }
  2426.  
  2427. function base64ToBytes (str) {
  2428. return base64.toByteArray(base64clean(str))
  2429. }
  2430.  
  2431. function blitBuffer (src, dst, offset, length) {
  2432. for (var i = 0; i < length; ++i) {
  2433. if ((i + offset >= dst.length) || (i >= src.length)) break
  2434. dst[i + offset] = src[i]
  2435. }
  2436. return i
  2437. }
  2438.  
  2439. function isnan (val) {
  2440. return val !== val // eslint-disable-line no-self-compare
  2441. }
  2442.  
  2443. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  2444.  
  2445. /***/ }),
  2446.  
  2447. /***/ "./node_modules/qrcode/lib/browser.js":
  2448. /*!********************************************!*\
  2449. !*** ./node_modules/qrcode/lib/browser.js ***!
  2450. \********************************************/
  2451. /*! no static exports found */
  2452. /***/ (function(module, exports, __webpack_require__) {
  2453.  
  2454.  
  2455. var canPromise = __webpack_require__(/*! ./can-promise */ "./node_modules/qrcode/lib/can-promise.js")
  2456.  
  2457. var QRCode = __webpack_require__(/*! ./core/qrcode */ "./node_modules/qrcode/lib/core/qrcode.js")
  2458. var CanvasRenderer = __webpack_require__(/*! ./renderer/canvas */ "./node_modules/qrcode/lib/renderer/canvas.js")
  2459. var SvgRenderer = __webpack_require__(/*! ./renderer/svg-tag.js */ "./node_modules/qrcode/lib/renderer/svg-tag.js")
  2460.  
  2461. function renderCanvas (renderFunc, canvas, text, opts, cb) {
  2462. var args = [].slice.call(arguments, 1)
  2463. var argsNum = args.length
  2464. var isLastArgCb = typeof args[argsNum - 1] === 'function'
  2465.  
  2466. if (!isLastArgCb && !canPromise()) {
  2467. throw new Error('Callback required as last argument')
  2468. }
  2469.  
  2470. if (isLastArgCb) {
  2471. if (argsNum < 2) {
  2472. throw new Error('Too few arguments provided')
  2473. }
  2474.  
  2475. if (argsNum === 2) {
  2476. cb = text
  2477. text = canvas
  2478. canvas = opts = undefined
  2479. } else if (argsNum === 3) {
  2480. if (canvas.getContext && typeof cb === 'undefined') {
  2481. cb = opts
  2482. opts = undefined
  2483. } else {
  2484. cb = opts
  2485. opts = text
  2486. text = canvas
  2487. canvas = undefined
  2488. }
  2489. }
  2490. } else {
  2491. if (argsNum < 1) {
  2492. throw new Error('Too few arguments provided')
  2493. }
  2494.  
  2495. if (argsNum === 1) {
  2496. text = canvas
  2497. canvas = opts = undefined
  2498. } else if (argsNum === 2 && !canvas.getContext) {
  2499. opts = text
  2500. text = canvas
  2501. canvas = undefined
  2502. }
  2503.  
  2504. return new Promise(function (resolve, reject) {
  2505. try {
  2506. var data = QRCode.create(text, opts)
  2507. resolve(renderFunc(data, canvas, opts))
  2508. } catch (e) {
  2509. reject(e)
  2510. }
  2511. })
  2512. }
  2513.  
  2514. try {
  2515. var data = QRCode.create(text, opts)
  2516. cb(null, renderFunc(data, canvas, opts))
  2517. } catch (e) {
  2518. cb(e)
  2519. }
  2520. }
  2521.  
  2522. exports.create = QRCode.create
  2523. exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render)
  2524. exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)
  2525.  
  2526. // only svg for now.
  2527. exports.toString = renderCanvas.bind(null, function (data, _, opts) {
  2528. return SvgRenderer.render(data, opts)
  2529. })
  2530.  
  2531.  
  2532. /***/ }),
  2533.  
  2534. /***/ "./node_modules/qrcode/lib/can-promise.js":
  2535. /*!************************************************!*\
  2536. !*** ./node_modules/qrcode/lib/can-promise.js ***!
  2537. \************************************************/
  2538. /*! no static exports found */
  2539. /***/ (function(module, exports) {
  2540.  
  2541. // can-promise has a crash in some versions of react native that dont have
  2542. // standard global objects
  2543. // https://github.com/soldair/node-qrcode/issues/157
  2544.  
  2545. module.exports = function () {
  2546. return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
  2547. }
  2548.  
  2549.  
  2550. /***/ }),
  2551.  
  2552. /***/ "./node_modules/qrcode/lib/core/alignment-pattern.js":
  2553. /*!***********************************************************!*\
  2554. !*** ./node_modules/qrcode/lib/core/alignment-pattern.js ***!
  2555. \***********************************************************/
  2556. /*! no static exports found */
  2557. /***/ (function(module, exports, __webpack_require__) {
  2558.  
  2559. /**
  2560. * Alignment pattern are fixed reference pattern in defined positions
  2561. * in a matrix symbology, which enables the decode software to re-synchronise
  2562. * the coordinate mapping of the image modules in the event of moderate amounts
  2563. * of distortion of the image.
  2564. *
  2565. * Alignment patterns are present only in QR Code symbols of version 2 or larger
  2566. * and their number depends on the symbol version.
  2567. */
  2568.  
  2569. var getSymbolSize = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js").getSymbolSize
  2570.  
  2571. /**
  2572. * Calculate the row/column coordinates of the center module of each alignment pattern
  2573. * for the specified QR Code version.
  2574. *
  2575. * The alignment patterns are positioned symmetrically on either side of the diagonal
  2576. * running from the top left corner of the symbol to the bottom right corner.
  2577. *
  2578. * Since positions are simmetrical only half of the coordinates are returned.
  2579. * Each item of the array will represent in turn the x and y coordinate.
  2580. * @see {@link getPositions}
  2581. *
  2582. * @param {Number} version QR Code version
  2583. * @return {Array} Array of coordinate
  2584. */
  2585. exports.getRowColCoords = function getRowColCoords (version) {
  2586. if (version === 1) return []
  2587.  
  2588. var posCount = Math.floor(version / 7) + 2
  2589. var size = getSymbolSize(version)
  2590. var intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2
  2591. var positions = [size - 7] // Last coord is always (size - 7)
  2592.  
  2593. for (var i = 1; i < posCount - 1; i++) {
  2594. positions[i] = positions[i - 1] - intervals
  2595. }
  2596.  
  2597. positions.push(6) // First coord is always 6
  2598.  
  2599. return positions.reverse()
  2600. }
  2601.  
  2602. /**
  2603. * Returns an array containing the positions of each alignment pattern.
  2604. * Each array's element represent the center point of the pattern as (x, y) coordinates
  2605. *
  2606. * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
  2607. * and filtering out the items that overlaps with finder pattern
  2608. *
  2609. * @example
  2610. * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
  2611. * The alignment patterns, therefore, are to be centered on (row, column)
  2612. * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
  2613. * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
  2614. * and are not therefore used for alignment patterns.
  2615. *
  2616. * var pos = getPositions(7)
  2617. * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
  2618. *
  2619. * @param {Number} version QR Code version
  2620. * @return {Array} Array of coordinates
  2621. */
  2622. exports.getPositions = function getPositions (version) {
  2623. var coords = []
  2624. var pos = exports.getRowColCoords(version)
  2625. var posLength = pos.length
  2626.  
  2627. for (var i = 0; i < posLength; i++) {
  2628. for (var j = 0; j < posLength; j++) {
  2629. // Skip if position is occupied by finder patterns
  2630. if ((i === 0 && j === 0) || // top-left
  2631. (i === 0 && j === posLength - 1) || // bottom-left
  2632. (i === posLength - 1 && j === 0)) { // top-right
  2633. continue
  2634. }
  2635.  
  2636. coords.push([pos[i], pos[j]])
  2637. }
  2638. }
  2639.  
  2640. return coords
  2641. }
  2642.  
  2643.  
  2644. /***/ }),
  2645.  
  2646. /***/ "./node_modules/qrcode/lib/core/alphanumeric-data.js":
  2647. /*!***********************************************************!*\
  2648. !*** ./node_modules/qrcode/lib/core/alphanumeric-data.js ***!
  2649. \***********************************************************/
  2650. /*! no static exports found */
  2651. /***/ (function(module, exports, __webpack_require__) {
  2652.  
  2653. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  2654.  
  2655. /**
  2656. * Array of characters available in alphanumeric mode
  2657. *
  2658. * As per QR Code specification, to each character
  2659. * is assigned a value from 0 to 44 which in this case coincides
  2660. * with the array index
  2661. *
  2662. * @type {Array}
  2663. */
  2664. var ALPHA_NUM_CHARS = [
  2665. '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  2666. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
  2667. 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  2668. ' ', '$', '%', '*', '+', '-', '.', '/', ':'
  2669. ]
  2670.  
  2671. function AlphanumericData (data) {
  2672. this.mode = Mode.ALPHANUMERIC
  2673. this.data = data
  2674. }
  2675.  
  2676. AlphanumericData.getBitsLength = function getBitsLength (length) {
  2677. return 11 * Math.floor(length / 2) + 6 * (length % 2)
  2678. }
  2679.  
  2680. AlphanumericData.prototype.getLength = function getLength () {
  2681. return this.data.length
  2682. }
  2683.  
  2684. AlphanumericData.prototype.getBitsLength = function getBitsLength () {
  2685. return AlphanumericData.getBitsLength(this.data.length)
  2686. }
  2687.  
  2688. AlphanumericData.prototype.write = function write (bitBuffer) {
  2689. var i
  2690.  
  2691. // Input data characters are divided into groups of two characters
  2692. // and encoded as 11-bit binary codes.
  2693. for (i = 0; i + 2 <= this.data.length; i += 2) {
  2694. // The character value of the first character is multiplied by 45
  2695. var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45
  2696.  
  2697. // The character value of the second digit is added to the product
  2698. value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1])
  2699.  
  2700. // The sum is then stored as 11-bit binary number
  2701. bitBuffer.put(value, 11)
  2702. }
  2703.  
  2704. // If the number of input data characters is not a multiple of two,
  2705. // the character value of the final character is encoded as a 6-bit binary number.
  2706. if (this.data.length % 2) {
  2707. bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6)
  2708. }
  2709. }
  2710.  
  2711. module.exports = AlphanumericData
  2712.  
  2713.  
  2714. /***/ }),
  2715.  
  2716. /***/ "./node_modules/qrcode/lib/core/bit-buffer.js":
  2717. /*!****************************************************!*\
  2718. !*** ./node_modules/qrcode/lib/core/bit-buffer.js ***!
  2719. \****************************************************/
  2720. /*! no static exports found */
  2721. /***/ (function(module, exports) {
  2722.  
  2723. function BitBuffer () {
  2724. this.buffer = []
  2725. this.length = 0
  2726. }
  2727.  
  2728. BitBuffer.prototype = {
  2729.  
  2730. get: function (index) {
  2731. var bufIndex = Math.floor(index / 8)
  2732. return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
  2733. },
  2734.  
  2735. put: function (num, length) {
  2736. for (var i = 0; i < length; i++) {
  2737. this.putBit(((num >>> (length - i - 1)) & 1) === 1)
  2738. }
  2739. },
  2740.  
  2741. getLengthInBits: function () {
  2742. return this.length
  2743. },
  2744.  
  2745. putBit: function (bit) {
  2746. var bufIndex = Math.floor(this.length / 8)
  2747. if (this.buffer.length <= bufIndex) {
  2748. this.buffer.push(0)
  2749. }
  2750.  
  2751. if (bit) {
  2752. this.buffer[bufIndex] |= (0x80 >>> (this.length % 8))
  2753. }
  2754.  
  2755. this.length++
  2756. }
  2757. }
  2758.  
  2759. module.exports = BitBuffer
  2760.  
  2761.  
  2762. /***/ }),
  2763.  
  2764. /***/ "./node_modules/qrcode/lib/core/bit-matrix.js":
  2765. /*!****************************************************!*\
  2766. !*** ./node_modules/qrcode/lib/core/bit-matrix.js ***!
  2767. \****************************************************/
  2768. /*! no static exports found */
  2769. /***/ (function(module, exports, __webpack_require__) {
  2770.  
  2771. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  2772.  
  2773. /**
  2774. * Helper class to handle QR Code symbol modules
  2775. *
  2776. * @param {Number} size Symbol size
  2777. */
  2778. function BitMatrix (size) {
  2779. if (!size || size < 1) {
  2780. throw new Error('BitMatrix size must be defined and greater than 0')
  2781. }
  2782.  
  2783. this.size = size
  2784. this.data = BufferUtil.alloc(size * size)
  2785. this.reservedBit = BufferUtil.alloc(size * size)
  2786. }
  2787.  
  2788. /**
  2789. * Set bit value at specified location
  2790. * If reserved flag is set, this bit will be ignored during masking process
  2791. *
  2792. * @param {Number} row
  2793. * @param {Number} col
  2794. * @param {Boolean} value
  2795. * @param {Boolean} reserved
  2796. */
  2797. BitMatrix.prototype.set = function (row, col, value, reserved) {
  2798. var index = row * this.size + col
  2799. this.data[index] = value
  2800. if (reserved) this.reservedBit[index] = true
  2801. }
  2802.  
  2803. /**
  2804. * Returns bit value at specified location
  2805. *
  2806. * @param {Number} row
  2807. * @param {Number} col
  2808. * @return {Boolean}
  2809. */
  2810. BitMatrix.prototype.get = function (row, col) {
  2811. return this.data[row * this.size + col]
  2812. }
  2813.  
  2814. /**
  2815. * Applies xor operator at specified location
  2816. * (used during masking process)
  2817. *
  2818. * @param {Number} row
  2819. * @param {Number} col
  2820. * @param {Boolean} value
  2821. */
  2822. BitMatrix.prototype.xor = function (row, col, value) {
  2823. this.data[row * this.size + col] ^= value
  2824. }
  2825.  
  2826. /**
  2827. * Check if bit at specified location is reserved
  2828. *
  2829. * @param {Number} row
  2830. * @param {Number} col
  2831. * @return {Boolean}
  2832. */
  2833. BitMatrix.prototype.isReserved = function (row, col) {
  2834. return this.reservedBit[row * this.size + col]
  2835. }
  2836.  
  2837. module.exports = BitMatrix
  2838.  
  2839.  
  2840. /***/ }),
  2841.  
  2842. /***/ "./node_modules/qrcode/lib/core/byte-data.js":
  2843. /*!***************************************************!*\
  2844. !*** ./node_modules/qrcode/lib/core/byte-data.js ***!
  2845. \***************************************************/
  2846. /*! no static exports found */
  2847. /***/ (function(module, exports, __webpack_require__) {
  2848.  
  2849. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  2850. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  2851.  
  2852. function ByteData (data) {
  2853. this.mode = Mode.BYTE
  2854. this.data = BufferUtil.from(data)
  2855. }
  2856.  
  2857. ByteData.getBitsLength = function getBitsLength (length) {
  2858. return length * 8
  2859. }
  2860.  
  2861. ByteData.prototype.getLength = function getLength () {
  2862. return this.data.length
  2863. }
  2864.  
  2865. ByteData.prototype.getBitsLength = function getBitsLength () {
  2866. return ByteData.getBitsLength(this.data.length)
  2867. }
  2868.  
  2869. ByteData.prototype.write = function (bitBuffer) {
  2870. for (var i = 0, l = this.data.length; i < l; i++) {
  2871. bitBuffer.put(this.data[i], 8)
  2872. }
  2873. }
  2874.  
  2875. module.exports = ByteData
  2876.  
  2877.  
  2878. /***/ }),
  2879.  
  2880. /***/ "./node_modules/qrcode/lib/core/error-correction-code.js":
  2881. /*!***************************************************************!*\
  2882. !*** ./node_modules/qrcode/lib/core/error-correction-code.js ***!
  2883. \***************************************************************/
  2884. /*! no static exports found */
  2885. /***/ (function(module, exports, __webpack_require__) {
  2886.  
  2887. var ECLevel = __webpack_require__(/*! ./error-correction-level */ "./node_modules/qrcode/lib/core/error-correction-level.js")
  2888.  
  2889. var EC_BLOCKS_TABLE = [
  2890. // L M Q H
  2891. 1, 1, 1, 1,
  2892. 1, 1, 1, 1,
  2893. 1, 1, 2, 2,
  2894. 1, 2, 2, 4,
  2895. 1, 2, 4, 4,
  2896. 2, 4, 4, 4,
  2897. 2, 4, 6, 5,
  2898. 2, 4, 6, 6,
  2899. 2, 5, 8, 8,
  2900. 4, 5, 8, 8,
  2901. 4, 5, 8, 11,
  2902. 4, 8, 10, 11,
  2903. 4, 9, 12, 16,
  2904. 4, 9, 16, 16,
  2905. 6, 10, 12, 18,
  2906. 6, 10, 17, 16,
  2907. 6, 11, 16, 19,
  2908. 6, 13, 18, 21,
  2909. 7, 14, 21, 25,
  2910. 8, 16, 20, 25,
  2911. 8, 17, 23, 25,
  2912. 9, 17, 23, 34,
  2913. 9, 18, 25, 30,
  2914. 10, 20, 27, 32,
  2915. 12, 21, 29, 35,
  2916. 12, 23, 34, 37,
  2917. 12, 25, 34, 40,
  2918. 13, 26, 35, 42,
  2919. 14, 28, 38, 45,
  2920. 15, 29, 40, 48,
  2921. 16, 31, 43, 51,
  2922. 17, 33, 45, 54,
  2923. 18, 35, 48, 57,
  2924. 19, 37, 51, 60,
  2925. 19, 38, 53, 63,
  2926. 20, 40, 56, 66,
  2927. 21, 43, 59, 70,
  2928. 22, 45, 62, 74,
  2929. 24, 47, 65, 77,
  2930. 25, 49, 68, 81
  2931. ]
  2932.  
  2933. var EC_CODEWORDS_TABLE = [
  2934. // L M Q H
  2935. 7, 10, 13, 17,
  2936. 10, 16, 22, 28,
  2937. 15, 26, 36, 44,
  2938. 20, 36, 52, 64,
  2939. 26, 48, 72, 88,
  2940. 36, 64, 96, 112,
  2941. 40, 72, 108, 130,
  2942. 48, 88, 132, 156,
  2943. 60, 110, 160, 192,
  2944. 72, 130, 192, 224,
  2945. 80, 150, 224, 264,
  2946. 96, 176, 260, 308,
  2947. 104, 198, 288, 352,
  2948. 120, 216, 320, 384,
  2949. 132, 240, 360, 432,
  2950. 144, 280, 408, 480,
  2951. 168, 308, 448, 532,
  2952. 180, 338, 504, 588,
  2953. 196, 364, 546, 650,
  2954. 224, 416, 600, 700,
  2955. 224, 442, 644, 750,
  2956. 252, 476, 690, 816,
  2957. 270, 504, 750, 900,
  2958. 300, 560, 810, 960,
  2959. 312, 588, 870, 1050,
  2960. 336, 644, 952, 1110,
  2961. 360, 700, 1020, 1200,
  2962. 390, 728, 1050, 1260,
  2963. 420, 784, 1140, 1350,
  2964. 450, 812, 1200, 1440,
  2965. 480, 868, 1290, 1530,
  2966. 510, 924, 1350, 1620,
  2967. 540, 980, 1440, 1710,
  2968. 570, 1036, 1530, 1800,
  2969. 570, 1064, 1590, 1890,
  2970. 600, 1120, 1680, 1980,
  2971. 630, 1204, 1770, 2100,
  2972. 660, 1260, 1860, 2220,
  2973. 720, 1316, 1950, 2310,
  2974. 750, 1372, 2040, 2430
  2975. ]
  2976.  
  2977. /**
  2978. * Returns the number of error correction block that the QR Code should contain
  2979. * for the specified version and error correction level.
  2980. *
  2981. * @param {Number} version QR Code version
  2982. * @param {Number} errorCorrectionLevel Error correction level
  2983. * @return {Number} Number of error correction blocks
  2984. */
  2985. exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
  2986. switch (errorCorrectionLevel) {
  2987. case ECLevel.L:
  2988. return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
  2989. case ECLevel.M:
  2990. return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
  2991. case ECLevel.Q:
  2992. return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
  2993. case ECLevel.H:
  2994. return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
  2995. default:
  2996. return undefined
  2997. }
  2998. }
  2999.  
  3000. /**
  3001. * Returns the number of error correction codewords to use for the specified
  3002. * version and error correction level.
  3003. *
  3004. * @param {Number} version QR Code version
  3005. * @param {Number} errorCorrectionLevel Error correction level
  3006. * @return {Number} Number of error correction codewords
  3007. */
  3008. exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
  3009. switch (errorCorrectionLevel) {
  3010. case ECLevel.L:
  3011. return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
  3012. case ECLevel.M:
  3013. return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
  3014. case ECLevel.Q:
  3015. return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
  3016. case ECLevel.H:
  3017. return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
  3018. default:
  3019. return undefined
  3020. }
  3021. }
  3022.  
  3023.  
  3024. /***/ }),
  3025.  
  3026. /***/ "./node_modules/qrcode/lib/core/error-correction-level.js":
  3027. /*!****************************************************************!*\
  3028. !*** ./node_modules/qrcode/lib/core/error-correction-level.js ***!
  3029. \****************************************************************/
  3030. /*! no static exports found */
  3031. /***/ (function(module, exports) {
  3032.  
  3033. exports.L = { bit: 1 }
  3034. exports.M = { bit: 0 }
  3035. exports.Q = { bit: 3 }
  3036. exports.H = { bit: 2 }
  3037.  
  3038. function fromString (string) {
  3039. if (typeof string !== 'string') {
  3040. throw new Error('Param is not a string')
  3041. }
  3042.  
  3043. var lcStr = string.toLowerCase()
  3044.  
  3045. switch (lcStr) {
  3046. case 'l':
  3047. case 'low':
  3048. return exports.L
  3049.  
  3050. case 'm':
  3051. case 'medium':
  3052. return exports.M
  3053.  
  3054. case 'q':
  3055. case 'quartile':
  3056. return exports.Q
  3057.  
  3058. case 'h':
  3059. case 'high':
  3060. return exports.H
  3061.  
  3062. default:
  3063. throw new Error('Unknown EC Level: ' + string)
  3064. }
  3065. }
  3066.  
  3067. exports.isValid = function isValid (level) {
  3068. return level && typeof level.bit !== 'undefined' &&
  3069. level.bit >= 0 && level.bit < 4
  3070. }
  3071.  
  3072. exports.from = function from (value, defaultValue) {
  3073. if (exports.isValid(value)) {
  3074. return value
  3075. }
  3076.  
  3077. try {
  3078. return fromString(value)
  3079. } catch (e) {
  3080. return defaultValue
  3081. }
  3082. }
  3083.  
  3084.  
  3085. /***/ }),
  3086.  
  3087. /***/ "./node_modules/qrcode/lib/core/finder-pattern.js":
  3088. /*!********************************************************!*\
  3089. !*** ./node_modules/qrcode/lib/core/finder-pattern.js ***!
  3090. \********************************************************/
  3091. /*! no static exports found */
  3092. /***/ (function(module, exports, __webpack_require__) {
  3093.  
  3094. var getSymbolSize = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js").getSymbolSize
  3095. var FINDER_PATTERN_SIZE = 7
  3096.  
  3097. /**
  3098. * Returns an array containing the positions of each finder pattern.
  3099. * Each array's element represent the top-left point of the pattern as (x, y) coordinates
  3100. *
  3101. * @param {Number} version QR Code version
  3102. * @return {Array} Array of coordinates
  3103. */
  3104. exports.getPositions = function getPositions (version) {
  3105. var size = getSymbolSize(version)
  3106.  
  3107. return [
  3108. // top-left
  3109. [0, 0],
  3110. // top-right
  3111. [size - FINDER_PATTERN_SIZE, 0],
  3112. // bottom-left
  3113. [0, size - FINDER_PATTERN_SIZE]
  3114. ]
  3115. }
  3116.  
  3117.  
  3118. /***/ }),
  3119.  
  3120. /***/ "./node_modules/qrcode/lib/core/format-info.js":
  3121. /*!*****************************************************!*\
  3122. !*** ./node_modules/qrcode/lib/core/format-info.js ***!
  3123. \*****************************************************/
  3124. /*! no static exports found */
  3125. /***/ (function(module, exports, __webpack_require__) {
  3126.  
  3127. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js")
  3128.  
  3129. var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)
  3130. var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)
  3131. var G15_BCH = Utils.getBCHDigit(G15)
  3132.  
  3133. /**
  3134. * Returns format information with relative error correction bits
  3135. *
  3136. * The format information is a 15-bit sequence containing 5 data bits,
  3137. * with 10 error correction bits calculated using the (15, 5) BCH code.
  3138. *
  3139. * @param {Number} errorCorrectionLevel Error correction level
  3140. * @param {Number} mask Mask pattern
  3141. * @return {Number} Encoded format information bits
  3142. */
  3143. exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
  3144. var data = ((errorCorrectionLevel.bit << 3) | mask)
  3145. var d = data << 10
  3146.  
  3147. while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
  3148. d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH))
  3149. }
  3150.  
  3151. // xor final data with mask pattern in order to ensure that
  3152. // no combination of Error Correction Level and data mask pattern
  3153. // will result in an all-zero data string
  3154. return ((data << 10) | d) ^ G15_MASK
  3155. }
  3156.  
  3157.  
  3158. /***/ }),
  3159.  
  3160. /***/ "./node_modules/qrcode/lib/core/galois-field.js":
  3161. /*!******************************************************!*\
  3162. !*** ./node_modules/qrcode/lib/core/galois-field.js ***!
  3163. \******************************************************/
  3164. /*! no static exports found */
  3165. /***/ (function(module, exports, __webpack_require__) {
  3166.  
  3167. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  3168.  
  3169. var EXP_TABLE = BufferUtil.alloc(512)
  3170. var LOG_TABLE = BufferUtil.alloc(256)
  3171. /**
  3172. * Precompute the log and anti-log tables for faster computation later
  3173. *
  3174. * For each possible value in the galois field 2^8, we will pre-compute
  3175. * the logarithm and anti-logarithm (exponential) of this value
  3176. *
  3177. * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
  3178. */
  3179. ;(function initTables () {
  3180. var x = 1
  3181. for (var i = 0; i < 255; i++) {
  3182. EXP_TABLE[i] = x
  3183. LOG_TABLE[x] = i
  3184.  
  3185. x <<= 1 // multiply by 2
  3186.  
  3187. // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
  3188. // This means that when a number is 256 or larger, it should be XORed with 0x11D.
  3189. if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
  3190. x ^= 0x11D
  3191. }
  3192. }
  3193.  
  3194. // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
  3195. // stay inside the bounds (because we will mainly use this table for the multiplication of
  3196. // two GF numbers, no more).
  3197. // @see {@link mul}
  3198. for (i = 255; i < 512; i++) {
  3199. EXP_TABLE[i] = EXP_TABLE[i - 255]
  3200. }
  3201. }())
  3202.  
  3203. /**
  3204. * Returns log value of n inside Galois Field
  3205. *
  3206. * @param {Number} n
  3207. * @return {Number}
  3208. */
  3209. exports.log = function log (n) {
  3210. if (n < 1) throw new Error('log(' + n + ')')
  3211. return LOG_TABLE[n]
  3212. }
  3213.  
  3214. /**
  3215. * Returns anti-log value of n inside Galois Field
  3216. *
  3217. * @param {Number} n
  3218. * @return {Number}
  3219. */
  3220. exports.exp = function exp (n) {
  3221. return EXP_TABLE[n]
  3222. }
  3223.  
  3224. /**
  3225. * Multiplies two number inside Galois Field
  3226. *
  3227. * @param {Number} x
  3228. * @param {Number} y
  3229. * @return {Number}
  3230. */
  3231. exports.mul = function mul (x, y) {
  3232. if (x === 0 || y === 0) return 0
  3233.  
  3234. // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
  3235. // @see {@link initTables}
  3236. return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
  3237. }
  3238.  
  3239.  
  3240. /***/ }),
  3241.  
  3242. /***/ "./node_modules/qrcode/lib/core/kanji-data.js":
  3243. /*!****************************************************!*\
  3244. !*** ./node_modules/qrcode/lib/core/kanji-data.js ***!
  3245. \****************************************************/
  3246. /*! no static exports found */
  3247. /***/ (function(module, exports, __webpack_require__) {
  3248.  
  3249. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  3250. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js")
  3251.  
  3252. function KanjiData (data) {
  3253. this.mode = Mode.KANJI
  3254. this.data = data
  3255. }
  3256.  
  3257. KanjiData.getBitsLength = function getBitsLength (length) {
  3258. return length * 13
  3259. }
  3260.  
  3261. KanjiData.prototype.getLength = function getLength () {
  3262. return this.data.length
  3263. }
  3264.  
  3265. KanjiData.prototype.getBitsLength = function getBitsLength () {
  3266. return KanjiData.getBitsLength(this.data.length)
  3267. }
  3268.  
  3269. KanjiData.prototype.write = function (bitBuffer) {
  3270. var i
  3271.  
  3272. // In the Shift JIS system, Kanji characters are represented by a two byte combination.
  3273. // These byte values are shifted from the JIS X 0208 values.
  3274. // JIS X 0208 gives details of the shift coded representation.
  3275. for (i = 0; i < this.data.length; i++) {
  3276. var value = Utils.toSJIS(this.data[i])
  3277.  
  3278. // For characters with Shift JIS values from 0x8140 to 0x9FFC:
  3279. if (value >= 0x8140 && value <= 0x9FFC) {
  3280. // Subtract 0x8140 from Shift JIS value
  3281. value -= 0x8140
  3282.  
  3283. // For characters with Shift JIS values from 0xE040 to 0xEBBF
  3284. } else if (value >= 0xE040 && value <= 0xEBBF) {
  3285. // Subtract 0xC140 from Shift JIS value
  3286. value -= 0xC140
  3287. } else {
  3288. throw new Error(
  3289. 'Invalid SJIS character: ' + this.data[i] + '\n' +
  3290. 'Make sure your charset is UTF-8')
  3291. }
  3292.  
  3293. // Multiply most significant byte of result by 0xC0
  3294. // and add least significant byte to product
  3295. value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff)
  3296.  
  3297. // Convert result to a 13-bit binary string
  3298. bitBuffer.put(value, 13)
  3299. }
  3300. }
  3301.  
  3302. module.exports = KanjiData
  3303.  
  3304.  
  3305. /***/ }),
  3306.  
  3307. /***/ "./node_modules/qrcode/lib/core/mask-pattern.js":
  3308. /*!******************************************************!*\
  3309. !*** ./node_modules/qrcode/lib/core/mask-pattern.js ***!
  3310. \******************************************************/
  3311. /*! no static exports found */
  3312. /***/ (function(module, exports) {
  3313.  
  3314. /**
  3315. * Data mask pattern reference
  3316. * @type {Object}
  3317. */
  3318. exports.Patterns = {
  3319. PATTERN000: 0,
  3320. PATTERN001: 1,
  3321. PATTERN010: 2,
  3322. PATTERN011: 3,
  3323. PATTERN100: 4,
  3324. PATTERN101: 5,
  3325. PATTERN110: 6,
  3326. PATTERN111: 7
  3327. }
  3328.  
  3329. /**
  3330. * Weighted penalty scores for the undesirable features
  3331. * @type {Object}
  3332. */
  3333. var PenaltyScores = {
  3334. N1: 3,
  3335. N2: 3,
  3336. N3: 40,
  3337. N4: 10
  3338. }
  3339.  
  3340. /**
  3341. * Check if mask pattern value is valid
  3342. *
  3343. * @param {Number} mask Mask pattern
  3344. * @return {Boolean} true if valid, false otherwise
  3345. */
  3346. exports.isValid = function isValid (mask) {
  3347. return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
  3348. }
  3349.  
  3350. /**
  3351. * Returns mask pattern from a value.
  3352. * If value is not valid, returns undefined
  3353. *
  3354. * @param {Number|String} value Mask pattern value
  3355. * @return {Number} Valid mask pattern or undefined
  3356. */
  3357. exports.from = function from (value) {
  3358. return exports.isValid(value) ? parseInt(value, 10) : undefined
  3359. }
  3360.  
  3361. /**
  3362. * Find adjacent modules in row/column with the same color
  3363. * and assign a penalty value.
  3364. *
  3365. * Points: N1 + i
  3366. * i is the amount by which the number of adjacent modules of the same color exceeds 5
  3367. */
  3368. exports.getPenaltyN1 = function getPenaltyN1 (data) {
  3369. var size = data.size
  3370. var points = 0
  3371. var sameCountCol = 0
  3372. var sameCountRow = 0
  3373. var lastCol = null
  3374. var lastRow = null
  3375.  
  3376. for (var row = 0; row < size; row++) {
  3377. sameCountCol = sameCountRow = 0
  3378. lastCol = lastRow = null
  3379.  
  3380. for (var col = 0; col < size; col++) {
  3381. var module = data.get(row, col)
  3382. if (module === lastCol) {
  3383. sameCountCol++
  3384. } else {
  3385. if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
  3386. lastCol = module
  3387. sameCountCol = 1
  3388. }
  3389.  
  3390. module = data.get(col, row)
  3391. if (module === lastRow) {
  3392. sameCountRow++
  3393. } else {
  3394. if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
  3395. lastRow = module
  3396. sameCountRow = 1
  3397. }
  3398. }
  3399.  
  3400. if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5)
  3401. if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5)
  3402. }
  3403.  
  3404. return points
  3405. }
  3406.  
  3407. /**
  3408. * Find 2x2 blocks with the same color and assign a penalty value
  3409. *
  3410. * Points: N2 * (m - 1) * (n - 1)
  3411. */
  3412. exports.getPenaltyN2 = function getPenaltyN2 (data) {
  3413. var size = data.size
  3414. var points = 0
  3415.  
  3416. for (var row = 0; row < size - 1; row++) {
  3417. for (var col = 0; col < size - 1; col++) {
  3418. var last = data.get(row, col) +
  3419. data.get(row, col + 1) +
  3420. data.get(row + 1, col) +
  3421. data.get(row + 1, col + 1)
  3422.  
  3423. if (last === 4 || last === 0) points++
  3424. }
  3425. }
  3426.  
  3427. return points * PenaltyScores.N2
  3428. }
  3429.  
  3430. /**
  3431. * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
  3432. * preceded or followed by light area 4 modules wide
  3433. *
  3434. * Points: N3 * number of pattern found
  3435. */
  3436. exports.getPenaltyN3 = function getPenaltyN3 (data) {
  3437. var size = data.size
  3438. var points = 0
  3439. var bitsCol = 0
  3440. var bitsRow = 0
  3441.  
  3442. for (var row = 0; row < size; row++) {
  3443. bitsCol = bitsRow = 0
  3444. for (var col = 0; col < size; col++) {
  3445. bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col)
  3446. if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++
  3447.  
  3448. bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row)
  3449. if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++
  3450. }
  3451. }
  3452.  
  3453. return points * PenaltyScores.N3
  3454. }
  3455.  
  3456. /**
  3457. * Calculate proportion of dark modules in entire symbol
  3458. *
  3459. * Points: N4 * k
  3460. *
  3461. * k is the rating of the deviation of the proportion of dark modules
  3462. * in the symbol from 50% in steps of 5%
  3463. */
  3464. exports.getPenaltyN4 = function getPenaltyN4 (data) {
  3465. var darkCount = 0
  3466. var modulesCount = data.data.length
  3467.  
  3468. for (var i = 0; i < modulesCount; i++) darkCount += data.data[i]
  3469.  
  3470. var k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10)
  3471.  
  3472. return k * PenaltyScores.N4
  3473. }
  3474.  
  3475. /**
  3476. * Return mask value at given position
  3477. *
  3478. * @param {Number} maskPattern Pattern reference value
  3479. * @param {Number} i Row
  3480. * @param {Number} j Column
  3481. * @return {Boolean} Mask value
  3482. */
  3483. function getMaskAt (maskPattern, i, j) {
  3484. switch (maskPattern) {
  3485. case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
  3486. case exports.Patterns.PATTERN001: return i % 2 === 0
  3487. case exports.Patterns.PATTERN010: return j % 3 === 0
  3488. case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
  3489. case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
  3490. case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
  3491. case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
  3492. case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
  3493.  
  3494. default: throw new Error('bad maskPattern:' + maskPattern)
  3495. }
  3496. }
  3497.  
  3498. /**
  3499. * Apply a mask pattern to a BitMatrix
  3500. *
  3501. * @param {Number} pattern Pattern reference number
  3502. * @param {BitMatrix} data BitMatrix data
  3503. */
  3504. exports.applyMask = function applyMask (pattern, data) {
  3505. var size = data.size
  3506.  
  3507. for (var col = 0; col < size; col++) {
  3508. for (var row = 0; row < size; row++) {
  3509. if (data.isReserved(row, col)) continue
  3510. data.xor(row, col, getMaskAt(pattern, row, col))
  3511. }
  3512. }
  3513. }
  3514.  
  3515. /**
  3516. * Returns the best mask pattern for data
  3517. *
  3518. * @param {BitMatrix} data
  3519. * @return {Number} Mask pattern reference number
  3520. */
  3521. exports.getBestMask = function getBestMask (data, setupFormatFunc) {
  3522. var numPatterns = Object.keys(exports.Patterns).length
  3523. var bestPattern = 0
  3524. var lowerPenalty = Infinity
  3525.  
  3526. for (var p = 0; p < numPatterns; p++) {
  3527. setupFormatFunc(p)
  3528. exports.applyMask(p, data)
  3529.  
  3530. // Calculate penalty
  3531. var penalty =
  3532. exports.getPenaltyN1(data) +
  3533. exports.getPenaltyN2(data) +
  3534. exports.getPenaltyN3(data) +
  3535. exports.getPenaltyN4(data)
  3536.  
  3537. // Undo previously applied mask
  3538. exports.applyMask(p, data)
  3539.  
  3540. if (penalty < lowerPenalty) {
  3541. lowerPenalty = penalty
  3542. bestPattern = p
  3543. }
  3544. }
  3545.  
  3546. return bestPattern
  3547. }
  3548.  
  3549.  
  3550. /***/ }),
  3551.  
  3552. /***/ "./node_modules/qrcode/lib/core/mode.js":
  3553. /*!**********************************************!*\
  3554. !*** ./node_modules/qrcode/lib/core/mode.js ***!
  3555. \**********************************************/
  3556. /*! no static exports found */
  3557. /***/ (function(module, exports, __webpack_require__) {
  3558.  
  3559. var VersionCheck = __webpack_require__(/*! ./version-check */ "./node_modules/qrcode/lib/core/version-check.js")
  3560. var Regex = __webpack_require__(/*! ./regex */ "./node_modules/qrcode/lib/core/regex.js")
  3561.  
  3562. /**
  3563. * Numeric mode encodes data from the decimal digit set (0 - 9)
  3564. * (byte values 30HEX to 39HEX).
  3565. * Normally, 3 data characters are represented by 10 bits.
  3566. *
  3567. * @type {Object}
  3568. */
  3569. exports.NUMERIC = {
  3570. id: 'Numeric',
  3571. bit: 1 << 0,
  3572. ccBits: [10, 12, 14]
  3573. }
  3574.  
  3575. /**
  3576. * Alphanumeric mode encodes data from a set of 45 characters,
  3577. * i.e. 10 numeric digits (0 - 9),
  3578. * 26 alphabetic characters (A - Z),
  3579. * and 9 symbols (SP, $, %, *, +, -, ., /, :).
  3580. * Normally, two input characters are represented by 11 bits.
  3581. *
  3582. * @type {Object}
  3583. */
  3584. exports.ALPHANUMERIC = {
  3585. id: 'Alphanumeric',
  3586. bit: 1 << 1,
  3587. ccBits: [9, 11, 13]
  3588. }
  3589.  
  3590. /**
  3591. * In byte mode, data is encoded at 8 bits per character.
  3592. *
  3593. * @type {Object}
  3594. */
  3595. exports.BYTE = {
  3596. id: 'Byte',
  3597. bit: 1 << 2,
  3598. ccBits: [8, 16, 16]
  3599. }
  3600.  
  3601. /**
  3602. * The Kanji mode efficiently encodes Kanji characters in accordance with
  3603. * the Shift JIS system based on JIS X 0208.
  3604. * The Shift JIS values are shifted from the JIS X 0208 values.
  3605. * JIS X 0208 gives details of the shift coded representation.
  3606. * Each two-byte character value is compacted to a 13-bit binary codeword.
  3607. *
  3608. * @type {Object}
  3609. */
  3610. exports.KANJI = {
  3611. id: 'Kanji',
  3612. bit: 1 << 3,
  3613. ccBits: [8, 10, 12]
  3614. }
  3615.  
  3616. /**
  3617. * Mixed mode will contain a sequences of data in a combination of any of
  3618. * the modes described above
  3619. *
  3620. * @type {Object}
  3621. */
  3622. exports.MIXED = {
  3623. bit: -1
  3624. }
  3625.  
  3626. /**
  3627. * Returns the number of bits needed to store the data length
  3628. * according to QR Code specifications.
  3629. *
  3630. * @param {Mode} mode Data mode
  3631. * @param {Number} version QR Code version
  3632. * @return {Number} Number of bits
  3633. */
  3634. exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
  3635. if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
  3636.  
  3637. if (!VersionCheck.isValid(version)) {
  3638. throw new Error('Invalid version: ' + version)
  3639. }
  3640.  
  3641. if (version >= 1 && version < 10) return mode.ccBits[0]
  3642. else if (version < 27) return mode.ccBits[1]
  3643. return mode.ccBits[2]
  3644. }
  3645.  
  3646. /**
  3647. * Returns the most efficient mode to store the specified data
  3648. *
  3649. * @param {String} dataStr Input data string
  3650. * @return {Mode} Best mode
  3651. */
  3652. exports.getBestModeForData = function getBestModeForData (dataStr) {
  3653. if (Regex.testNumeric(dataStr)) return exports.NUMERIC
  3654. else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
  3655. else if (Regex.testKanji(dataStr)) return exports.KANJI
  3656. else return exports.BYTE
  3657. }
  3658.  
  3659. /**
  3660. * Return mode name as string
  3661. *
  3662. * @param {Mode} mode Mode object
  3663. * @returns {String} Mode name
  3664. */
  3665. exports.toString = function toString (mode) {
  3666. if (mode && mode.id) return mode.id
  3667. throw new Error('Invalid mode')
  3668. }
  3669.  
  3670. /**
  3671. * Check if input param is a valid mode object
  3672. *
  3673. * @param {Mode} mode Mode object
  3674. * @returns {Boolean} True if valid mode, false otherwise
  3675. */
  3676. exports.isValid = function isValid (mode) {
  3677. return mode && mode.bit && mode.ccBits
  3678. }
  3679.  
  3680. /**
  3681. * Get mode object from its name
  3682. *
  3683. * @param {String} string Mode name
  3684. * @returns {Mode} Mode object
  3685. */
  3686. function fromString (string) {
  3687. if (typeof string !== 'string') {
  3688. throw new Error('Param is not a string')
  3689. }
  3690.  
  3691. var lcStr = string.toLowerCase()
  3692.  
  3693. switch (lcStr) {
  3694. case 'numeric':
  3695. return exports.NUMERIC
  3696. case 'alphanumeric':
  3697. return exports.ALPHANUMERIC
  3698. case 'kanji':
  3699. return exports.KANJI
  3700. case 'byte':
  3701. return exports.BYTE
  3702. default:
  3703. throw new Error('Unknown mode: ' + string)
  3704. }
  3705. }
  3706.  
  3707. /**
  3708. * Returns mode from a value.
  3709. * If value is not a valid mode, returns defaultValue
  3710. *
  3711. * @param {Mode|String} value Encoding mode
  3712. * @param {Mode} defaultValue Fallback value
  3713. * @return {Mode} Encoding mode
  3714. */
  3715. exports.from = function from (value, defaultValue) {
  3716. if (exports.isValid(value)) {
  3717. return value
  3718. }
  3719.  
  3720. try {
  3721. return fromString(value)
  3722. } catch (e) {
  3723. return defaultValue
  3724. }
  3725. }
  3726.  
  3727.  
  3728. /***/ }),
  3729.  
  3730. /***/ "./node_modules/qrcode/lib/core/numeric-data.js":
  3731. /*!******************************************************!*\
  3732. !*** ./node_modules/qrcode/lib/core/numeric-data.js ***!
  3733. \******************************************************/
  3734. /*! no static exports found */
  3735. /***/ (function(module, exports, __webpack_require__) {
  3736.  
  3737. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  3738.  
  3739. function NumericData (data) {
  3740. this.mode = Mode.NUMERIC
  3741. this.data = data.toString()
  3742. }
  3743.  
  3744. NumericData.getBitsLength = function getBitsLength (length) {
  3745. return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
  3746. }
  3747.  
  3748. NumericData.prototype.getLength = function getLength () {
  3749. return this.data.length
  3750. }
  3751.  
  3752. NumericData.prototype.getBitsLength = function getBitsLength () {
  3753. return NumericData.getBitsLength(this.data.length)
  3754. }
  3755.  
  3756. NumericData.prototype.write = function write (bitBuffer) {
  3757. var i, group, value
  3758.  
  3759. // The input data string is divided into groups of three digits,
  3760. // and each group is converted to its 10-bit binary equivalent.
  3761. for (i = 0; i + 3 <= this.data.length; i += 3) {
  3762. group = this.data.substr(i, 3)
  3763. value = parseInt(group, 10)
  3764.  
  3765. bitBuffer.put(value, 10)
  3766. }
  3767.  
  3768. // If the number of input digits is not an exact multiple of three,
  3769. // the final one or two digits are converted to 4 or 7 bits respectively.
  3770. var remainingNum = this.data.length - i
  3771. if (remainingNum > 0) {
  3772. group = this.data.substr(i)
  3773. value = parseInt(group, 10)
  3774.  
  3775. bitBuffer.put(value, remainingNum * 3 + 1)
  3776. }
  3777. }
  3778.  
  3779. module.exports = NumericData
  3780.  
  3781.  
  3782. /***/ }),
  3783.  
  3784. /***/ "./node_modules/qrcode/lib/core/polynomial.js":
  3785. /*!****************************************************!*\
  3786. !*** ./node_modules/qrcode/lib/core/polynomial.js ***!
  3787. \****************************************************/
  3788. /*! no static exports found */
  3789. /***/ (function(module, exports, __webpack_require__) {
  3790.  
  3791. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  3792. var GF = __webpack_require__(/*! ./galois-field */ "./node_modules/qrcode/lib/core/galois-field.js")
  3793.  
  3794. /**
  3795. * Multiplies two polynomials inside Galois Field
  3796. *
  3797. * @param {Buffer} p1 Polynomial
  3798. * @param {Buffer} p2 Polynomial
  3799. * @return {Buffer} Product of p1 and p2
  3800. */
  3801. exports.mul = function mul (p1, p2) {
  3802. var coeff = BufferUtil.alloc(p1.length + p2.length - 1)
  3803.  
  3804. for (var i = 0; i < p1.length; i++) {
  3805. for (var j = 0; j < p2.length; j++) {
  3806. coeff[i + j] ^= GF.mul(p1[i], p2[j])
  3807. }
  3808. }
  3809.  
  3810. return coeff
  3811. }
  3812.  
  3813. /**
  3814. * Calculate the remainder of polynomials division
  3815. *
  3816. * @param {Buffer} divident Polynomial
  3817. * @param {Buffer} divisor Polynomial
  3818. * @return {Buffer} Remainder
  3819. */
  3820. exports.mod = function mod (divident, divisor) {
  3821. var result = BufferUtil.from(divident)
  3822.  
  3823. while ((result.length - divisor.length) >= 0) {
  3824. var coeff = result[0]
  3825.  
  3826. for (var i = 0; i < divisor.length; i++) {
  3827. result[i] ^= GF.mul(divisor[i], coeff)
  3828. }
  3829.  
  3830. // remove all zeros from buffer head
  3831. var offset = 0
  3832. while (offset < result.length && result[offset] === 0) offset++
  3833. result = result.slice(offset)
  3834. }
  3835.  
  3836. return result
  3837. }
  3838.  
  3839. /**
  3840. * Generate an irreducible generator polynomial of specified degree
  3841. * (used by Reed-Solomon encoder)
  3842. *
  3843. * @param {Number} degree Degree of the generator polynomial
  3844. * @return {Buffer} Buffer containing polynomial coefficients
  3845. */
  3846. exports.generateECPolynomial = function generateECPolynomial (degree) {
  3847. var poly = BufferUtil.from([1])
  3848. for (var i = 0; i < degree; i++) {
  3849. poly = exports.mul(poly, [1, GF.exp(i)])
  3850. }
  3851.  
  3852. return poly
  3853. }
  3854.  
  3855.  
  3856. /***/ }),
  3857.  
  3858. /***/ "./node_modules/qrcode/lib/core/qrcode.js":
  3859. /*!************************************************!*\
  3860. !*** ./node_modules/qrcode/lib/core/qrcode.js ***!
  3861. \************************************************/
  3862. /*! no static exports found */
  3863. /***/ (function(module, exports, __webpack_require__) {
  3864.  
  3865. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  3866. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js")
  3867. var ECLevel = __webpack_require__(/*! ./error-correction-level */ "./node_modules/qrcode/lib/core/error-correction-level.js")
  3868. var BitBuffer = __webpack_require__(/*! ./bit-buffer */ "./node_modules/qrcode/lib/core/bit-buffer.js")
  3869. var BitMatrix = __webpack_require__(/*! ./bit-matrix */ "./node_modules/qrcode/lib/core/bit-matrix.js")
  3870. var AlignmentPattern = __webpack_require__(/*! ./alignment-pattern */ "./node_modules/qrcode/lib/core/alignment-pattern.js")
  3871. var FinderPattern = __webpack_require__(/*! ./finder-pattern */ "./node_modules/qrcode/lib/core/finder-pattern.js")
  3872. var MaskPattern = __webpack_require__(/*! ./mask-pattern */ "./node_modules/qrcode/lib/core/mask-pattern.js")
  3873. var ECCode = __webpack_require__(/*! ./error-correction-code */ "./node_modules/qrcode/lib/core/error-correction-code.js")
  3874. var ReedSolomonEncoder = __webpack_require__(/*! ./reed-solomon-encoder */ "./node_modules/qrcode/lib/core/reed-solomon-encoder.js")
  3875. var Version = __webpack_require__(/*! ./version */ "./node_modules/qrcode/lib/core/version.js")
  3876. var FormatInfo = __webpack_require__(/*! ./format-info */ "./node_modules/qrcode/lib/core/format-info.js")
  3877. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  3878. var Segments = __webpack_require__(/*! ./segments */ "./node_modules/qrcode/lib/core/segments.js")
  3879. var isArray = __webpack_require__(/*! isarray */ "./node_modules/qrcode/node_modules/isarray/index.js")
  3880.  
  3881. /**
  3882. * QRCode for JavaScript
  3883. *
  3884. * modified by Ryan Day for nodejs support
  3885. * Copyright (c) 2011 Ryan Day
  3886. *
  3887. * Licensed under the MIT license:
  3888. * http://www.opensource.org/licenses/mit-license.php
  3889. *
  3890. //---------------------------------------------------------------------
  3891. // QRCode for JavaScript
  3892. //
  3893. // Copyright (c) 2009 Kazuhiko Arase
  3894. //
  3895. // URL: http://www.d-project.com/
  3896. //
  3897. // Licensed under the MIT license:
  3898. // http://www.opensource.org/licenses/mit-license.php
  3899. //
  3900. // The word "QR Code" is registered trademark of
  3901. // DENSO WAVE INCORPORATED
  3902. // http://www.denso-wave.com/qrcode/faqpatent-e.html
  3903. //
  3904. //---------------------------------------------------------------------
  3905. */
  3906.  
  3907. /**
  3908. * Add finder patterns bits to matrix
  3909. *
  3910. * @param {BitMatrix} matrix Modules matrix
  3911. * @param {Number} version QR Code version
  3912. */
  3913. function setupFinderPattern (matrix, version) {
  3914. var size = matrix.size
  3915. var pos = FinderPattern.getPositions(version)
  3916.  
  3917. for (var i = 0; i < pos.length; i++) {
  3918. var row = pos[i][0]
  3919. var col = pos[i][1]
  3920.  
  3921. for (var r = -1; r <= 7; r++) {
  3922. if (row + r <= -1 || size <= row + r) continue
  3923.  
  3924. for (var c = -1; c <= 7; c++) {
  3925. if (col + c <= -1 || size <= col + c) continue
  3926.  
  3927. if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
  3928. (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
  3929. (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
  3930. matrix.set(row + r, col + c, true, true)
  3931. } else {
  3932. matrix.set(row + r, col + c, false, true)
  3933. }
  3934. }
  3935. }
  3936. }
  3937. }
  3938.  
  3939. /**
  3940. * Add timing pattern bits to matrix
  3941. *
  3942. * Note: this function must be called before {@link setupAlignmentPattern}
  3943. *
  3944. * @param {BitMatrix} matrix Modules matrix
  3945. */
  3946. function setupTimingPattern (matrix) {
  3947. var size = matrix.size
  3948.  
  3949. for (var r = 8; r < size - 8; r++) {
  3950. var value = r % 2 === 0
  3951. matrix.set(r, 6, value, true)
  3952. matrix.set(6, r, value, true)
  3953. }
  3954. }
  3955.  
  3956. /**
  3957. * Add alignment patterns bits to matrix
  3958. *
  3959. * Note: this function must be called after {@link setupTimingPattern}
  3960. *
  3961. * @param {BitMatrix} matrix Modules matrix
  3962. * @param {Number} version QR Code version
  3963. */
  3964. function setupAlignmentPattern (matrix, version) {
  3965. var pos = AlignmentPattern.getPositions(version)
  3966.  
  3967. for (var i = 0; i < pos.length; i++) {
  3968. var row = pos[i][0]
  3969. var col = pos[i][1]
  3970.  
  3971. for (var r = -2; r <= 2; r++) {
  3972. for (var c = -2; c <= 2; c++) {
  3973. if (r === -2 || r === 2 || c === -2 || c === 2 ||
  3974. (r === 0 && c === 0)) {
  3975. matrix.set(row + r, col + c, true, true)
  3976. } else {
  3977. matrix.set(row + r, col + c, false, true)
  3978. }
  3979. }
  3980. }
  3981. }
  3982. }
  3983.  
  3984. /**
  3985. * Add version info bits to matrix
  3986. *
  3987. * @param {BitMatrix} matrix Modules matrix
  3988. * @param {Number} version QR Code version
  3989. */
  3990. function setupVersionInfo (matrix, version) {
  3991. var size = matrix.size
  3992. var bits = Version.getEncodedBits(version)
  3993. var row, col, mod
  3994.  
  3995. for (var i = 0; i < 18; i++) {
  3996. row = Math.floor(i / 3)
  3997. col = i % 3 + size - 8 - 3
  3998. mod = ((bits >> i) & 1) === 1
  3999.  
  4000. matrix.set(row, col, mod, true)
  4001. matrix.set(col, row, mod, true)
  4002. }
  4003. }
  4004.  
  4005. /**
  4006. * Add format info bits to matrix
  4007. *
  4008. * @param {BitMatrix} matrix Modules matrix
  4009. * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
  4010. * @param {Number} maskPattern Mask pattern reference value
  4011. */
  4012. function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
  4013. var size = matrix.size
  4014. var bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern)
  4015. var i, mod
  4016.  
  4017. for (i = 0; i < 15; i++) {
  4018. mod = ((bits >> i) & 1) === 1
  4019.  
  4020. // vertical
  4021. if (i < 6) {
  4022. matrix.set(i, 8, mod, true)
  4023. } else if (i < 8) {
  4024. matrix.set(i + 1, 8, mod, true)
  4025. } else {
  4026. matrix.set(size - 15 + i, 8, mod, true)
  4027. }
  4028.  
  4029. // horizontal
  4030. if (i < 8) {
  4031. matrix.set(8, size - i - 1, mod, true)
  4032. } else if (i < 9) {
  4033. matrix.set(8, 15 - i - 1 + 1, mod, true)
  4034. } else {
  4035. matrix.set(8, 15 - i - 1, mod, true)
  4036. }
  4037. }
  4038.  
  4039. // fixed module
  4040. matrix.set(size - 8, 8, 1, true)
  4041. }
  4042.  
  4043. /**
  4044. * Add encoded data bits to matrix
  4045. *
  4046. * @param {BitMatrix} matrix Modules matrix
  4047. * @param {Buffer} data Data codewords
  4048. */
  4049. function setupData (matrix, data) {
  4050. var size = matrix.size
  4051. var inc = -1
  4052. var row = size - 1
  4053. var bitIndex = 7
  4054. var byteIndex = 0
  4055.  
  4056. for (var col = size - 1; col > 0; col -= 2) {
  4057. if (col === 6) col--
  4058.  
  4059. while (true) {
  4060. for (var c = 0; c < 2; c++) {
  4061. if (!matrix.isReserved(row, col - c)) {
  4062. var dark = false
  4063.  
  4064. if (byteIndex < data.length) {
  4065. dark = (((data[byteIndex] >>> bitIndex) & 1) === 1)
  4066. }
  4067.  
  4068. matrix.set(row, col - c, dark)
  4069. bitIndex--
  4070.  
  4071. if (bitIndex === -1) {
  4072. byteIndex++
  4073. bitIndex = 7
  4074. }
  4075. }
  4076. }
  4077.  
  4078. row += inc
  4079.  
  4080. if (row < 0 || size <= row) {
  4081. row -= inc
  4082. inc = -inc
  4083. break
  4084. }
  4085. }
  4086. }
  4087. }
  4088.  
  4089. /**
  4090. * Create encoded codewords from data input
  4091. *
  4092. * @param {Number} version QR Code version
  4093. * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
  4094. * @param {ByteData} data Data input
  4095. * @return {Buffer} Buffer containing encoded codewords
  4096. */
  4097. function createData (version, errorCorrectionLevel, segments) {
  4098. // Prepare data buffer
  4099. var buffer = new BitBuffer()
  4100.  
  4101. segments.forEach(function (data) {
  4102. // prefix data with mode indicator (4 bits)
  4103. buffer.put(data.mode.bit, 4)
  4104.  
  4105. // Prefix data with character count indicator.
  4106. // The character count indicator is a string of bits that represents the
  4107. // number of characters that are being encoded.
  4108. // The character count indicator must be placed after the mode indicator
  4109. // and must be a certain number of bits long, depending on the QR version
  4110. // and data mode
  4111. // @see {@link Mode.getCharCountIndicator}.
  4112. buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version))
  4113.  
  4114. // add binary data sequence to buffer
  4115. data.write(buffer)
  4116. })
  4117.  
  4118. // Calculate required number of bits
  4119. var totalCodewords = Utils.getSymbolTotalCodewords(version)
  4120. var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
  4121. var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
  4122.  
  4123. // Add a terminator.
  4124. // If the bit string is shorter than the total number of required bits,
  4125. // a terminator of up to four 0s must be added to the right side of the string.
  4126. // If the bit string is more than four bits shorter than the required number of bits,
  4127. // add four 0s to the end.
  4128. if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
  4129. buffer.put(0, 4)
  4130. }
  4131.  
  4132. // If the bit string is fewer than four bits shorter, add only the number of 0s that
  4133. // are needed to reach the required number of bits.
  4134.  
  4135. // After adding the terminator, if the number of bits in the string is not a multiple of 8,
  4136. // pad the string on the right with 0s to make the string's length a multiple of 8.
  4137. while (buffer.getLengthInBits() % 8 !== 0) {
  4138. buffer.putBit(0)
  4139. }
  4140.  
  4141. // Add pad bytes if the string is still shorter than the total number of required bits.
  4142. // Extend the buffer to fill the data capacity of the symbol corresponding to
  4143. // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
  4144. // and 00010001 (0x11) alternately.
  4145. var remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8
  4146. for (var i = 0; i < remainingByte; i++) {
  4147. buffer.put(i % 2 ? 0x11 : 0xEC, 8)
  4148. }
  4149.  
  4150. return createCodewords(buffer, version, errorCorrectionLevel)
  4151. }
  4152.  
  4153. /**
  4154. * Encode input data with Reed-Solomon and return codewords with
  4155. * relative error correction bits
  4156. *
  4157. * @param {BitBuffer} bitBuffer Data to encode
  4158. * @param {Number} version QR Code version
  4159. * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
  4160. * @return {Buffer} Buffer containing encoded codewords
  4161. */
  4162. function createCodewords (bitBuffer, version, errorCorrectionLevel) {
  4163. // Total codewords for this QR code version (Data + Error correction)
  4164. var totalCodewords = Utils.getSymbolTotalCodewords(version)
  4165.  
  4166. // Total number of error correction codewords
  4167. var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
  4168.  
  4169. // Total number of data codewords
  4170. var dataTotalCodewords = totalCodewords - ecTotalCodewords
  4171.  
  4172. // Total number of blocks
  4173. var ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel)
  4174.  
  4175. // Calculate how many blocks each group should contain
  4176. var blocksInGroup2 = totalCodewords % ecTotalBlocks
  4177. var blocksInGroup1 = ecTotalBlocks - blocksInGroup2
  4178.  
  4179. var totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks)
  4180.  
  4181. var dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks)
  4182. var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1
  4183.  
  4184. // Number of EC codewords is the same for both groups
  4185. var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1
  4186.  
  4187. // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
  4188. var rs = new ReedSolomonEncoder(ecCount)
  4189.  
  4190. var offset = 0
  4191. var dcData = new Array(ecTotalBlocks)
  4192. var ecData = new Array(ecTotalBlocks)
  4193. var maxDataSize = 0
  4194. var buffer = BufferUtil.from(bitBuffer.buffer)
  4195.  
  4196. // Divide the buffer into the required number of blocks
  4197. for (var b = 0; b < ecTotalBlocks; b++) {
  4198. var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2
  4199.  
  4200. // extract a block of data from buffer
  4201. dcData[b] = buffer.slice(offset, offset + dataSize)
  4202.  
  4203. // Calculate EC codewords for this data block
  4204. ecData[b] = rs.encode(dcData[b])
  4205.  
  4206. offset += dataSize
  4207. maxDataSize = Math.max(maxDataSize, dataSize)
  4208. }
  4209.  
  4210. // Create final data
  4211. // Interleave the data and error correction codewords from each block
  4212. var data = BufferUtil.alloc(totalCodewords)
  4213. var index = 0
  4214. var i, r
  4215.  
  4216. // Add data codewords
  4217. for (i = 0; i < maxDataSize; i++) {
  4218. for (r = 0; r < ecTotalBlocks; r++) {
  4219. if (i < dcData[r].length) {
  4220. data[index++] = dcData[r][i]
  4221. }
  4222. }
  4223. }
  4224.  
  4225. // Apped EC codewords
  4226. for (i = 0; i < ecCount; i++) {
  4227. for (r = 0; r < ecTotalBlocks; r++) {
  4228. data[index++] = ecData[r][i]
  4229. }
  4230. }
  4231.  
  4232. return data
  4233. }
  4234.  
  4235. /**
  4236. * Build QR Code symbol
  4237. *
  4238. * @param {String} data Input string
  4239. * @param {Number} version QR Code version
  4240. * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
  4241. * @param {MaskPattern} maskPattern Mask pattern
  4242. * @return {Object} Object containing symbol data
  4243. */
  4244. function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
  4245. var segments
  4246.  
  4247. if (isArray(data)) {
  4248. segments = Segments.fromArray(data)
  4249. } else if (typeof data === 'string') {
  4250. var estimatedVersion = version
  4251.  
  4252. if (!estimatedVersion) {
  4253. var rawSegments = Segments.rawSplit(data)
  4254.  
  4255. // Estimate best version that can contain raw splitted segments
  4256. estimatedVersion = Version.getBestVersionForData(rawSegments,
  4257. errorCorrectionLevel)
  4258. }
  4259.  
  4260. // Build optimized segments
  4261. // If estimated version is undefined, try with the highest version
  4262. segments = Segments.fromString(data, estimatedVersion || 40)
  4263. } else {
  4264. throw new Error('Invalid data')
  4265. }
  4266.  
  4267. // Get the min version that can contain data
  4268. var bestVersion = Version.getBestVersionForData(segments,
  4269. errorCorrectionLevel)
  4270.  
  4271. // If no version is found, data cannot be stored
  4272. if (!bestVersion) {
  4273. throw new Error('The amount of data is too big to be stored in a QR Code')
  4274. }
  4275.  
  4276. // If not specified, use min version as default
  4277. if (!version) {
  4278. version = bestVersion
  4279.  
  4280. // Check if the specified version can contain the data
  4281. } else if (version < bestVersion) {
  4282. throw new Error('\n' +
  4283. 'The chosen QR Code version cannot contain this amount of data.\n' +
  4284. 'Minimum version required to store current data is: ' + bestVersion + '.\n'
  4285. )
  4286. }
  4287.  
  4288. var dataBits = createData(version, errorCorrectionLevel, segments)
  4289.  
  4290. // Allocate matrix buffer
  4291. var moduleCount = Utils.getSymbolSize(version)
  4292. var modules = new BitMatrix(moduleCount)
  4293.  
  4294. // Add function modules
  4295. setupFinderPattern(modules, version)
  4296. setupTimingPattern(modules)
  4297. setupAlignmentPattern(modules, version)
  4298.  
  4299. // Add temporary dummy bits for format info just to set them as reserved.
  4300. // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
  4301. // since the masking operation must be performed only on the encoding region.
  4302. // These blocks will be replaced with correct values later in code.
  4303. setupFormatInfo(modules, errorCorrectionLevel, 0)
  4304.  
  4305. if (version >= 7) {
  4306. setupVersionInfo(modules, version)
  4307. }
  4308.  
  4309. // Add data codewords
  4310. setupData(modules, dataBits)
  4311.  
  4312. if (isNaN(maskPattern)) {
  4313. // Find best mask pattern
  4314. maskPattern = MaskPattern.getBestMask(modules,
  4315. setupFormatInfo.bind(null, modules, errorCorrectionLevel))
  4316. }
  4317.  
  4318. // Apply mask pattern
  4319. MaskPattern.applyMask(maskPattern, modules)
  4320.  
  4321. // Replace format info bits with correct values
  4322. setupFormatInfo(modules, errorCorrectionLevel, maskPattern)
  4323.  
  4324. return {
  4325. modules: modules,
  4326. version: version,
  4327. errorCorrectionLevel: errorCorrectionLevel,
  4328. maskPattern: maskPattern,
  4329. segments: segments
  4330. }
  4331. }
  4332.  
  4333. /**
  4334. * QR Code
  4335. *
  4336. * @param {String | Array} data Input data
  4337. * @param {Object} options Optional configurations
  4338. * @param {Number} options.version QR Code version
  4339. * @param {String} options.errorCorrectionLevel Error correction level
  4340. * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
  4341. */
  4342. exports.create = function create (data, options) {
  4343. if (typeof data === 'undefined' || data === '') {
  4344. throw new Error('No input text')
  4345. }
  4346.  
  4347. var errorCorrectionLevel = ECLevel.M
  4348. var version
  4349. var mask
  4350.  
  4351. if (typeof options !== 'undefined') {
  4352. // Use higher error correction level as default
  4353. errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M)
  4354. version = Version.from(options.version)
  4355. mask = MaskPattern.from(options.maskPattern)
  4356.  
  4357. if (options.toSJISFunc) {
  4358. Utils.setToSJISFunction(options.toSJISFunc)
  4359. }
  4360. }
  4361.  
  4362. return createSymbol(data, version, errorCorrectionLevel, mask)
  4363. }
  4364.  
  4365.  
  4366. /***/ }),
  4367.  
  4368. /***/ "./node_modules/qrcode/lib/core/reed-solomon-encoder.js":
  4369. /*!**************************************************************!*\
  4370. !*** ./node_modules/qrcode/lib/core/reed-solomon-encoder.js ***!
  4371. \**************************************************************/
  4372. /*! no static exports found */
  4373. /***/ (function(module, exports, __webpack_require__) {
  4374.  
  4375. var BufferUtil = __webpack_require__(/*! ../utils/buffer */ "./node_modules/qrcode/lib/utils/typedarray-buffer.js")
  4376. var Polynomial = __webpack_require__(/*! ./polynomial */ "./node_modules/qrcode/lib/core/polynomial.js")
  4377. var Buffer = __webpack_require__(/*! buffer */ "./node_modules/node-libs-browser/node_modules/buffer/index.js").Buffer
  4378.  
  4379. function ReedSolomonEncoder (degree) {
  4380. this.genPoly = undefined
  4381. this.degree = degree
  4382.  
  4383. if (this.degree) this.initialize(this.degree)
  4384. }
  4385.  
  4386. /**
  4387. * Initialize the encoder.
  4388. * The input param should correspond to the number of error correction codewords.
  4389. *
  4390. * @param {Number} degree
  4391. */
  4392. ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
  4393. // create an irreducible generator polynomial
  4394. this.degree = degree
  4395. this.genPoly = Polynomial.generateECPolynomial(this.degree)
  4396. }
  4397.  
  4398. /**
  4399. * Encodes a chunk of data
  4400. *
  4401. * @param {Buffer} data Buffer containing input data
  4402. * @return {Buffer} Buffer containing encoded data
  4403. */
  4404. ReedSolomonEncoder.prototype.encode = function encode (data) {
  4405. if (!this.genPoly) {
  4406. throw new Error('Encoder not initialized')
  4407. }
  4408.  
  4409. // Calculate EC for this data block
  4410. // extends data size to data+genPoly size
  4411. var pad = BufferUtil.alloc(this.degree)
  4412. var paddedData = Buffer.concat([data, pad], data.length + this.degree)
  4413.  
  4414. // The error correction codewords are the remainder after dividing the data codewords
  4415. // by a generator polynomial
  4416. var remainder = Polynomial.mod(paddedData, this.genPoly)
  4417.  
  4418. // return EC data blocks (last n byte, where n is the degree of genPoly)
  4419. // If coefficients number in remainder are less than genPoly degree,
  4420. // pad with 0s to the left to reach the needed number of coefficients
  4421. var start = this.degree - remainder.length
  4422. if (start > 0) {
  4423. var buff = BufferUtil.alloc(this.degree)
  4424. remainder.copy(buff, start)
  4425.  
  4426. return buff
  4427. }
  4428.  
  4429. return remainder
  4430. }
  4431.  
  4432. module.exports = ReedSolomonEncoder
  4433.  
  4434.  
  4435. /***/ }),
  4436.  
  4437. /***/ "./node_modules/qrcode/lib/core/regex.js":
  4438. /*!***********************************************!*\
  4439. !*** ./node_modules/qrcode/lib/core/regex.js ***!
  4440. \***********************************************/
  4441. /*! no static exports found */
  4442. /***/ (function(module, exports) {
  4443.  
  4444. var numeric = '[0-9]+'
  4445. var alphanumeric = '[A-Z $%*+\\-./:]+'
  4446. var kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
  4447. '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
  4448. '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
  4449. '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+'
  4450. kanji = kanji.replace(/u/g, '\\u')
  4451.  
  4452. var byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+'
  4453.  
  4454. exports.KANJI = new RegExp(kanji, 'g')
  4455. exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g')
  4456. exports.BYTE = new RegExp(byte, 'g')
  4457. exports.NUMERIC = new RegExp(numeric, 'g')
  4458. exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g')
  4459.  
  4460. var TEST_KANJI = new RegExp('^' + kanji + '$')
  4461. var TEST_NUMERIC = new RegExp('^' + numeric + '$')
  4462. var TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$')
  4463.  
  4464. exports.testKanji = function testKanji (str) {
  4465. return TEST_KANJI.test(str)
  4466. }
  4467.  
  4468. exports.testNumeric = function testNumeric (str) {
  4469. return TEST_NUMERIC.test(str)
  4470. }
  4471.  
  4472. exports.testAlphanumeric = function testAlphanumeric (str) {
  4473. return TEST_ALPHANUMERIC.test(str)
  4474. }
  4475.  
  4476.  
  4477. /***/ }),
  4478.  
  4479. /***/ "./node_modules/qrcode/lib/core/segments.js":
  4480. /*!**************************************************!*\
  4481. !*** ./node_modules/qrcode/lib/core/segments.js ***!
  4482. \**************************************************/
  4483. /*! no static exports found */
  4484. /***/ (function(module, exports, __webpack_require__) {
  4485.  
  4486. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  4487. var NumericData = __webpack_require__(/*! ./numeric-data */ "./node_modules/qrcode/lib/core/numeric-data.js")
  4488. var AlphanumericData = __webpack_require__(/*! ./alphanumeric-data */ "./node_modules/qrcode/lib/core/alphanumeric-data.js")
  4489. var ByteData = __webpack_require__(/*! ./byte-data */ "./node_modules/qrcode/lib/core/byte-data.js")
  4490. var KanjiData = __webpack_require__(/*! ./kanji-data */ "./node_modules/qrcode/lib/core/kanji-data.js")
  4491. var Regex = __webpack_require__(/*! ./regex */ "./node_modules/qrcode/lib/core/regex.js")
  4492. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js")
  4493. var dijkstra = __webpack_require__(/*! dijkstrajs */ "./node_modules/dijkstrajs/dijkstra.js")
  4494.  
  4495. /**
  4496. * Returns UTF8 byte length
  4497. *
  4498. * @param {String} str Input string
  4499. * @return {Number} Number of byte
  4500. */
  4501. function getStringByteLength (str) {
  4502. return unescape(encodeURIComponent(str)).length
  4503. }
  4504.  
  4505. /**
  4506. * Get a list of segments of the specified mode
  4507. * from a string
  4508. *
  4509. * @param {Mode} mode Segment mode
  4510. * @param {String} str String to process
  4511. * @return {Array} Array of object with segments data
  4512. */
  4513. function getSegments (regex, mode, str) {
  4514. var segments = []
  4515. var result
  4516.  
  4517. while ((result = regex.exec(str)) !== null) {
  4518. segments.push({
  4519. data: result[0],
  4520. index: result.index,
  4521. mode: mode,
  4522. length: result[0].length
  4523. })
  4524. }
  4525.  
  4526. return segments
  4527. }
  4528.  
  4529. /**
  4530. * Extracts a series of segments with the appropriate
  4531. * modes from a string
  4532. *
  4533. * @param {String} dataStr Input string
  4534. * @return {Array} Array of object with segments data
  4535. */
  4536. function getSegmentsFromString (dataStr) {
  4537. var numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr)
  4538. var alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr)
  4539. var byteSegs
  4540. var kanjiSegs
  4541.  
  4542. if (Utils.isKanjiModeEnabled()) {
  4543. byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr)
  4544. kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr)
  4545. } else {
  4546. byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr)
  4547. kanjiSegs = []
  4548. }
  4549.  
  4550. var segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs)
  4551.  
  4552. return segs
  4553. .sort(function (s1, s2) {
  4554. return s1.index - s2.index
  4555. })
  4556. .map(function (obj) {
  4557. return {
  4558. data: obj.data,
  4559. mode: obj.mode,
  4560. length: obj.length
  4561. }
  4562. })
  4563. }
  4564.  
  4565. /**
  4566. * Returns how many bits are needed to encode a string of
  4567. * specified length with the specified mode
  4568. *
  4569. * @param {Number} length String length
  4570. * @param {Mode} mode Segment mode
  4571. * @return {Number} Bit length
  4572. */
  4573. function getSegmentBitsLength (length, mode) {
  4574. switch (mode) {
  4575. case Mode.NUMERIC:
  4576. return NumericData.getBitsLength(length)
  4577. case Mode.ALPHANUMERIC:
  4578. return AlphanumericData.getBitsLength(length)
  4579. case Mode.KANJI:
  4580. return KanjiData.getBitsLength(length)
  4581. case Mode.BYTE:
  4582. return ByteData.getBitsLength(length)
  4583. }
  4584. }
  4585.  
  4586. /**
  4587. * Merges adjacent segments which have the same mode
  4588. *
  4589. * @param {Array} segs Array of object with segments data
  4590. * @return {Array} Array of object with segments data
  4591. */
  4592. function mergeSegments (segs) {
  4593. return segs.reduce(function (acc, curr) {
  4594. var prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null
  4595. if (prevSeg && prevSeg.mode === curr.mode) {
  4596. acc[acc.length - 1].data += curr.data
  4597. return acc
  4598. }
  4599.  
  4600. acc.push(curr)
  4601. return acc
  4602. }, [])
  4603. }
  4604.  
  4605. /**
  4606. * Generates a list of all possible nodes combination which
  4607. * will be used to build a segments graph.
  4608. *
  4609. * Nodes are divided by groups. Each group will contain a list of all the modes
  4610. * in which is possible to encode the given text.
  4611. *
  4612. * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
  4613. * The group for '12345' will contain then 3 objects, one for each
  4614. * possible encoding mode.
  4615. *
  4616. * Each node represents a possible segment.
  4617. *
  4618. * @param {Array} segs Array of object with segments data
  4619. * @return {Array} Array of object with segments data
  4620. */
  4621. function buildNodes (segs) {
  4622. var nodes = []
  4623. for (var i = 0; i < segs.length; i++) {
  4624. var seg = segs[i]
  4625.  
  4626. switch (seg.mode) {
  4627. case Mode.NUMERIC:
  4628. nodes.push([seg,
  4629. { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
  4630. { data: seg.data, mode: Mode.BYTE, length: seg.length }
  4631. ])
  4632. break
  4633. case Mode.ALPHANUMERIC:
  4634. nodes.push([seg,
  4635. { data: seg.data, mode: Mode.BYTE, length: seg.length }
  4636. ])
  4637. break
  4638. case Mode.KANJI:
  4639. nodes.push([seg,
  4640. { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
  4641. ])
  4642. break
  4643. case Mode.BYTE:
  4644. nodes.push([
  4645. { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
  4646. ])
  4647. }
  4648. }
  4649.  
  4650. return nodes
  4651. }
  4652.  
  4653. /**
  4654. * Builds a graph from a list of nodes.
  4655. * All segments in each node group will be connected with all the segments of
  4656. * the next group and so on.
  4657. *
  4658. * At each connection will be assigned a weight depending on the
  4659. * segment's byte length.
  4660. *
  4661. * @param {Array} nodes Array of object with segments data
  4662. * @param {Number} version QR Code version
  4663. * @return {Object} Graph of all possible segments
  4664. */
  4665. function buildGraph (nodes, version) {
  4666. var table = {}
  4667. var graph = {'start': {}}
  4668. var prevNodeIds = ['start']
  4669.  
  4670. for (var i = 0; i < nodes.length; i++) {
  4671. var nodeGroup = nodes[i]
  4672. var currentNodeIds = []
  4673.  
  4674. for (var j = 0; j < nodeGroup.length; j++) {
  4675. var node = nodeGroup[j]
  4676. var key = '' + i + j
  4677.  
  4678. currentNodeIds.push(key)
  4679. table[key] = { node: node, lastCount: 0 }
  4680. graph[key] = {}
  4681.  
  4682. for (var n = 0; n < prevNodeIds.length; n++) {
  4683. var prevNodeId = prevNodeIds[n]
  4684.  
  4685. if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
  4686. graph[prevNodeId][key] =
  4687. getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
  4688. getSegmentBitsLength(table[prevNodeId].lastCount, node.mode)
  4689.  
  4690. table[prevNodeId].lastCount += node.length
  4691. } else {
  4692. if (table[prevNodeId]) table[prevNodeId].lastCount = node.length
  4693.  
  4694. graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
  4695. 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost
  4696. }
  4697. }
  4698. }
  4699.  
  4700. prevNodeIds = currentNodeIds
  4701. }
  4702.  
  4703. for (n = 0; n < prevNodeIds.length; n++) {
  4704. graph[prevNodeIds[n]]['end'] = 0
  4705. }
  4706.  
  4707. return { map: graph, table: table }
  4708. }
  4709.  
  4710. /**
  4711. * Builds a segment from a specified data and mode.
  4712. * If a mode is not specified, the more suitable will be used.
  4713. *
  4714. * @param {String} data Input data
  4715. * @param {Mode | String} modesHint Data mode
  4716. * @return {Segment} Segment
  4717. */
  4718. function buildSingleSegment (data, modesHint) {
  4719. var mode
  4720. var bestMode = Mode.getBestModeForData(data)
  4721.  
  4722. mode = Mode.from(modesHint, bestMode)
  4723.  
  4724. // Make sure data can be encoded
  4725. if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
  4726. throw new Error('"' + data + '"' +
  4727. ' cannot be encoded with mode ' + Mode.toString(mode) +
  4728. '.\n Suggested mode is: ' + Mode.toString(bestMode))
  4729. }
  4730.  
  4731. // Use Mode.BYTE if Kanji support is disabled
  4732. if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
  4733. mode = Mode.BYTE
  4734. }
  4735.  
  4736. switch (mode) {
  4737. case Mode.NUMERIC:
  4738. return new NumericData(data)
  4739.  
  4740. case Mode.ALPHANUMERIC:
  4741. return new AlphanumericData(data)
  4742.  
  4743. case Mode.KANJI:
  4744. return new KanjiData(data)
  4745.  
  4746. case Mode.BYTE:
  4747. return new ByteData(data)
  4748. }
  4749. }
  4750.  
  4751. /**
  4752. * Builds a list of segments from an array.
  4753. * Array can contain Strings or Objects with segment's info.
  4754. *
  4755. * For each item which is a string, will be generated a segment with the given
  4756. * string and the more appropriate encoding mode.
  4757. *
  4758. * For each item which is an object, will be generated a segment with the given
  4759. * data and mode.
  4760. * Objects must contain at least the property "data".
  4761. * If property "mode" is not present, the more suitable mode will be used.
  4762. *
  4763. * @param {Array} array Array of objects with segments data
  4764. * @return {Array} Array of Segments
  4765. */
  4766. exports.fromArray = function fromArray (array) {
  4767. return array.reduce(function (acc, seg) {
  4768. if (typeof seg === 'string') {
  4769. acc.push(buildSingleSegment(seg, null))
  4770. } else if (seg.data) {
  4771. acc.push(buildSingleSegment(seg.data, seg.mode))
  4772. }
  4773.  
  4774. return acc
  4775. }, [])
  4776. }
  4777.  
  4778. /**
  4779. * Builds an optimized sequence of segments from a string,
  4780. * which will produce the shortest possible bitstream.
  4781. *
  4782. * @param {String} data Input string
  4783. * @param {Number} version QR Code version
  4784. * @return {Array} Array of segments
  4785. */
  4786. exports.fromString = function fromString (data, version) {
  4787. var segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled())
  4788.  
  4789. var nodes = buildNodes(segs)
  4790. var graph = buildGraph(nodes, version)
  4791. var path = dijkstra.find_path(graph.map, 'start', 'end')
  4792.  
  4793. var optimizedSegs = []
  4794. for (var i = 1; i < path.length - 1; i++) {
  4795. optimizedSegs.push(graph.table[path[i]].node)
  4796. }
  4797.  
  4798. return exports.fromArray(mergeSegments(optimizedSegs))
  4799. }
  4800.  
  4801. /**
  4802. * Splits a string in various segments with the modes which
  4803. * best represent their content.
  4804. * The produced segments are far from being optimized.
  4805. * The output of this function is only used to estimate a QR Code version
  4806. * which may contain the data.
  4807. *
  4808. * @param {string} data Input string
  4809. * @return {Array} Array of segments
  4810. */
  4811. exports.rawSplit = function rawSplit (data) {
  4812. return exports.fromArray(
  4813. getSegmentsFromString(data, Utils.isKanjiModeEnabled())
  4814. )
  4815. }
  4816.  
  4817.  
  4818. /***/ }),
  4819.  
  4820. /***/ "./node_modules/qrcode/lib/core/utils.js":
  4821. /*!***********************************************!*\
  4822. !*** ./node_modules/qrcode/lib/core/utils.js ***!
  4823. \***********************************************/
  4824. /*! no static exports found */
  4825. /***/ (function(module, exports) {
  4826.  
  4827. var toSJISFunction
  4828. var CODEWORDS_COUNT = [
  4829. 0, // Not used
  4830. 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
  4831. 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
  4832. 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
  4833. 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
  4834. ]
  4835.  
  4836. /**
  4837. * Returns the QR Code size for the specified version
  4838. *
  4839. * @param {Number} version QR Code version
  4840. * @return {Number} size of QR code
  4841. */
  4842. exports.getSymbolSize = function getSymbolSize (version) {
  4843. if (!version) throw new Error('"version" cannot be null or undefined')
  4844. if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
  4845. return version * 4 + 17
  4846. }
  4847.  
  4848. /**
  4849. * Returns the total number of codewords used to store data and EC information.
  4850. *
  4851. * @param {Number} version QR Code version
  4852. * @return {Number} Data length in bits
  4853. */
  4854. exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
  4855. return CODEWORDS_COUNT[version]
  4856. }
  4857.  
  4858. /**
  4859. * Encode data with Bose-Chaudhuri-Hocquenghem
  4860. *
  4861. * @param {Number} data Value to encode
  4862. * @return {Number} Encoded value
  4863. */
  4864. exports.getBCHDigit = function (data) {
  4865. var digit = 0
  4866.  
  4867. while (data !== 0) {
  4868. digit++
  4869. data >>>= 1
  4870. }
  4871.  
  4872. return digit
  4873. }
  4874.  
  4875. exports.setToSJISFunction = function setToSJISFunction (f) {
  4876. if (typeof f !== 'function') {
  4877. throw new Error('"toSJISFunc" is not a valid function.')
  4878. }
  4879.  
  4880. toSJISFunction = f
  4881. }
  4882.  
  4883. exports.isKanjiModeEnabled = function () {
  4884. return typeof toSJISFunction !== 'undefined'
  4885. }
  4886.  
  4887. exports.toSJIS = function toSJIS (kanji) {
  4888. return toSJISFunction(kanji)
  4889. }
  4890.  
  4891.  
  4892. /***/ }),
  4893.  
  4894. /***/ "./node_modules/qrcode/lib/core/version-check.js":
  4895. /*!*******************************************************!*\
  4896. !*** ./node_modules/qrcode/lib/core/version-check.js ***!
  4897. \*******************************************************/
  4898. /*! no static exports found */
  4899. /***/ (function(module, exports) {
  4900.  
  4901. /**
  4902. * Check if QR Code version is valid
  4903. *
  4904. * @param {Number} version QR Code version
  4905. * @return {Boolean} true if valid version, false otherwise
  4906. */
  4907. exports.isValid = function isValid (version) {
  4908. return !isNaN(version) && version >= 1 && version <= 40
  4909. }
  4910.  
  4911.  
  4912. /***/ }),
  4913.  
  4914. /***/ "./node_modules/qrcode/lib/core/version.js":
  4915. /*!*************************************************!*\
  4916. !*** ./node_modules/qrcode/lib/core/version.js ***!
  4917. \*************************************************/
  4918. /*! no static exports found */
  4919. /***/ (function(module, exports, __webpack_require__) {
  4920.  
  4921. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/core/utils.js")
  4922. var ECCode = __webpack_require__(/*! ./error-correction-code */ "./node_modules/qrcode/lib/core/error-correction-code.js")
  4923. var ECLevel = __webpack_require__(/*! ./error-correction-level */ "./node_modules/qrcode/lib/core/error-correction-level.js")
  4924. var Mode = __webpack_require__(/*! ./mode */ "./node_modules/qrcode/lib/core/mode.js")
  4925. var VersionCheck = __webpack_require__(/*! ./version-check */ "./node_modules/qrcode/lib/core/version-check.js")
  4926. var isArray = __webpack_require__(/*! isarray */ "./node_modules/qrcode/node_modules/isarray/index.js")
  4927.  
  4928. // Generator polynomial used to encode version information
  4929. var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)
  4930. var G18_BCH = Utils.getBCHDigit(G18)
  4931.  
  4932. function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
  4933. for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
  4934. if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
  4935. return currentVersion
  4936. }
  4937. }
  4938.  
  4939. return undefined
  4940. }
  4941.  
  4942. function getReservedBitsCount (mode, version) {
  4943. // Character count indicator + mode indicator bits
  4944. return Mode.getCharCountIndicator(mode, version) + 4
  4945. }
  4946.  
  4947. function getTotalBitsFromDataArray (segments, version) {
  4948. var totalBits = 0
  4949.  
  4950. segments.forEach(function (data) {
  4951. var reservedBits = getReservedBitsCount(data.mode, version)
  4952. totalBits += reservedBits + data.getBitsLength()
  4953. })
  4954.  
  4955. return totalBits
  4956. }
  4957.  
  4958. function getBestVersionForMixedData (segments, errorCorrectionLevel) {
  4959. for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
  4960. var length = getTotalBitsFromDataArray(segments, currentVersion)
  4961. if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
  4962. return currentVersion
  4963. }
  4964. }
  4965.  
  4966. return undefined
  4967. }
  4968.  
  4969. /**
  4970. * Returns version number from a value.
  4971. * If value is not a valid version, returns defaultValue
  4972. *
  4973. * @param {Number|String} value QR Code version
  4974. * @param {Number} defaultValue Fallback value
  4975. * @return {Number} QR Code version number
  4976. */
  4977. exports.from = function from (value, defaultValue) {
  4978. if (VersionCheck.isValid(value)) {
  4979. return parseInt(value, 10)
  4980. }
  4981.  
  4982. return defaultValue
  4983. }
  4984.  
  4985. /**
  4986. * Returns how much data can be stored with the specified QR code version
  4987. * and error correction level
  4988. *
  4989. * @param {Number} version QR Code version (1-40)
  4990. * @param {Number} errorCorrectionLevel Error correction level
  4991. * @param {Mode} mode Data mode
  4992. * @return {Number} Quantity of storable data
  4993. */
  4994. exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
  4995. if (!VersionCheck.isValid(version)) {
  4996. throw new Error('Invalid QR Code version')
  4997. }
  4998.  
  4999. // Use Byte mode as default
  5000. if (typeof mode === 'undefined') mode = Mode.BYTE
  5001.  
  5002. // Total codewords for this QR code version (Data + Error correction)
  5003. var totalCodewords = Utils.getSymbolTotalCodewords(version)
  5004.  
  5005. // Total number of error correction codewords
  5006. var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)
  5007.  
  5008. // Total number of data codewords
  5009. var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8
  5010.  
  5011. if (mode === Mode.MIXED) return dataTotalCodewordsBits
  5012.  
  5013. var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version)
  5014.  
  5015. // Return max number of storable codewords
  5016. switch (mode) {
  5017. case Mode.NUMERIC:
  5018. return Math.floor((usableBits / 10) * 3)
  5019.  
  5020. case Mode.ALPHANUMERIC:
  5021. return Math.floor((usableBits / 11) * 2)
  5022.  
  5023. case Mode.KANJI:
  5024. return Math.floor(usableBits / 13)
  5025.  
  5026. case Mode.BYTE:
  5027. default:
  5028. return Math.floor(usableBits / 8)
  5029. }
  5030. }
  5031.  
  5032. /**
  5033. * Returns the minimum version needed to contain the amount of data
  5034. *
  5035. * @param {Segment} data Segment of data
  5036. * @param {Number} [errorCorrectionLevel=H] Error correction level
  5037. * @param {Mode} mode Data mode
  5038. * @return {Number} QR Code version
  5039. */
  5040. exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
  5041. var seg
  5042.  
  5043. var ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M)
  5044.  
  5045. if (isArray(data)) {
  5046. if (data.length > 1) {
  5047. return getBestVersionForMixedData(data, ecl)
  5048. }
  5049.  
  5050. if (data.length === 0) {
  5051. return 1
  5052. }
  5053.  
  5054. seg = data[0]
  5055. } else {
  5056. seg = data
  5057. }
  5058.  
  5059. return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
  5060. }
  5061.  
  5062. /**
  5063. * Returns version information with relative error correction bits
  5064. *
  5065. * The version information is included in QR Code symbols of version 7 or larger.
  5066. * It consists of an 18-bit sequence containing 6 data bits,
  5067. * with 12 error correction bits calculated using the (18, 6) Golay code.
  5068. *
  5069. * @param {Number} version QR Code version
  5070. * @return {Number} Encoded version info bits
  5071. */
  5072. exports.getEncodedBits = function getEncodedBits (version) {
  5073. if (!VersionCheck.isValid(version) || version < 7) {
  5074. throw new Error('Invalid QR Code version')
  5075. }
  5076.  
  5077. var d = version << 12
  5078.  
  5079. while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
  5080. d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH))
  5081. }
  5082.  
  5083. return (version << 12) | d
  5084. }
  5085.  
  5086.  
  5087. /***/ }),
  5088.  
  5089. /***/ "./node_modules/qrcode/lib/renderer/canvas.js":
  5090. /*!****************************************************!*\
  5091. !*** ./node_modules/qrcode/lib/renderer/canvas.js ***!
  5092. \****************************************************/
  5093. /*! no static exports found */
  5094. /***/ (function(module, exports, __webpack_require__) {
  5095.  
  5096. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/renderer/utils.js")
  5097.  
  5098. function clearCanvas (ctx, canvas, size) {
  5099. ctx.clearRect(0, 0, canvas.width, canvas.height)
  5100.  
  5101. if (!canvas.style) canvas.style = {}
  5102. canvas.height = size
  5103. canvas.width = size
  5104. canvas.style.height = size + 'px'
  5105. canvas.style.width = size + 'px'
  5106. }
  5107.  
  5108. function getCanvasElement () {
  5109. try {
  5110. return document.createElement('canvas')
  5111. } catch (e) {
  5112. throw new Error('You need to specify a canvas element')
  5113. }
  5114. }
  5115.  
  5116. exports.render = function render (qrData, canvas, options) {
  5117. var opts = options
  5118. var canvasEl = canvas
  5119.  
  5120. if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
  5121. opts = canvas
  5122. canvas = undefined
  5123. }
  5124.  
  5125. if (!canvas) {
  5126. canvasEl = getCanvasElement()
  5127. }
  5128.  
  5129. opts = Utils.getOptions(opts)
  5130. var size = Utils.getImageWidth(qrData.modules.size, opts)
  5131.  
  5132. var ctx = canvasEl.getContext('2d')
  5133. var image = ctx.createImageData(size, size)
  5134. Utils.qrToImageData(image.data, qrData, opts)
  5135.  
  5136. clearCanvas(ctx, canvasEl, size)
  5137. ctx.putImageData(image, 0, 0)
  5138.  
  5139. return canvasEl
  5140. }
  5141.  
  5142. exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
  5143. var opts = options
  5144.  
  5145. if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
  5146. opts = canvas
  5147. canvas = undefined
  5148. }
  5149.  
  5150. if (!opts) opts = {}
  5151.  
  5152. var canvasEl = exports.render(qrData, canvas, opts)
  5153.  
  5154. var type = opts.type || 'image/png'
  5155. var rendererOpts = opts.rendererOpts || {}
  5156.  
  5157. return canvasEl.toDataURL(type, rendererOpts.quality)
  5158. }
  5159.  
  5160.  
  5161. /***/ }),
  5162.  
  5163. /***/ "./node_modules/qrcode/lib/renderer/svg-tag.js":
  5164. /*!*****************************************************!*\
  5165. !*** ./node_modules/qrcode/lib/renderer/svg-tag.js ***!
  5166. \*****************************************************/
  5167. /*! no static exports found */
  5168. /***/ (function(module, exports, __webpack_require__) {
  5169.  
  5170. var Utils = __webpack_require__(/*! ./utils */ "./node_modules/qrcode/lib/renderer/utils.js")
  5171.  
  5172. function getColorAttrib (color, attrib) {
  5173. var alpha = color.a / 255
  5174. var str = attrib + '="' + color.hex + '"'
  5175.  
  5176. return alpha < 1
  5177. ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
  5178. : str
  5179. }
  5180.  
  5181. function svgCmd (cmd, x, y) {
  5182. var str = cmd + x
  5183. if (typeof y !== 'undefined') str += ' ' + y
  5184.  
  5185. return str
  5186. }
  5187.  
  5188. function qrToPath (data, size, margin) {
  5189. var path = ''
  5190. var moveBy = 0
  5191. var newRow = false
  5192. var lineLength = 0
  5193.  
  5194. for (var i = 0; i < data.length; i++) {
  5195. var col = Math.floor(i % size)
  5196. var row = Math.floor(i / size)
  5197.  
  5198. if (!col && !newRow) newRow = true
  5199.  
  5200. if (data[i]) {
  5201. lineLength++
  5202.  
  5203. if (!(i > 0 && col > 0 && data[i - 1])) {
  5204. path += newRow
  5205. ? svgCmd('M', col + margin, 0.5 + row + margin)
  5206. : svgCmd('m', moveBy, 0)
  5207.  
  5208. moveBy = 0
  5209. newRow = false
  5210. }
  5211.  
  5212. if (!(col + 1 < size && data[i + 1])) {
  5213. path += svgCmd('h', lineLength)
  5214. lineLength = 0
  5215. }
  5216. } else {
  5217. moveBy++
  5218. }
  5219. }
  5220.  
  5221. return path
  5222. }
  5223.  
  5224. exports.render = function render (qrData, options, cb) {
  5225. var opts = Utils.getOptions(options)
  5226. var size = qrData.modules.size
  5227. var data = qrData.modules.data
  5228. var qrcodesize = size + opts.margin * 2
  5229.  
  5230. var bg = !opts.color.light.a
  5231. ? ''
  5232. : '<path ' + getColorAttrib(opts.color.light, 'fill') +
  5233. ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>'
  5234.  
  5235. var path =
  5236. '<path ' + getColorAttrib(opts.color.dark, 'stroke') +
  5237. ' d="' + qrToPath(data, size, opts.margin) + '"/>'
  5238.  
  5239. var viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"'
  5240.  
  5241. var width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" '
  5242.  
  5243. var svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n'
  5244.  
  5245. if (typeof cb === 'function') {
  5246. cb(null, svgTag)
  5247. }
  5248.  
  5249. return svgTag
  5250. }
  5251.  
  5252.  
  5253. /***/ }),
  5254.  
  5255. /***/ "./node_modules/qrcode/lib/renderer/utils.js":
  5256. /*!***************************************************!*\
  5257. !*** ./node_modules/qrcode/lib/renderer/utils.js ***!
  5258. \***************************************************/
  5259. /*! no static exports found */
  5260. /***/ (function(module, exports) {
  5261.  
  5262. function hex2rgba (hex) {
  5263. if (typeof hex === 'number') {
  5264. hex = hex.toString()
  5265. }
  5266.  
  5267. if (typeof hex !== 'string') {
  5268. throw new Error('Color should be defined as hex string')
  5269. }
  5270.  
  5271. var hexCode = hex.slice().replace('#', '').split('')
  5272. if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
  5273. throw new Error('Invalid hex color: ' + hex)
  5274. }
  5275.  
  5276. // Convert from short to long form (fff -> ffffff)
  5277. if (hexCode.length === 3 || hexCode.length === 4) {
  5278. hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
  5279. return [c, c]
  5280. }))
  5281. }
  5282.  
  5283. // Add default alpha value
  5284. if (hexCode.length === 6) hexCode.push('F', 'F')
  5285.  
  5286. var hexValue = parseInt(hexCode.join(''), 16)
  5287.  
  5288. return {
  5289. r: (hexValue >> 24) & 255,
  5290. g: (hexValue >> 16) & 255,
  5291. b: (hexValue >> 8) & 255,
  5292. a: hexValue & 255,
  5293. hex: '#' + hexCode.slice(0, 6).join('')
  5294. }
  5295. }
  5296.  
  5297. exports.getOptions = function getOptions (options) {
  5298. if (!options) options = {}
  5299. if (!options.color) options.color = {}
  5300.  
  5301. var margin = typeof options.margin === 'undefined' ||
  5302. options.margin === null ||
  5303. options.margin < 0 ? 4 : options.margin
  5304.  
  5305. var width = options.width && options.width >= 21 ? options.width : undefined
  5306. var scale = options.scale || 4
  5307.  
  5308. return {
  5309. width: width,
  5310. scale: width ? 4 : scale,
  5311. margin: margin,
  5312. color: {
  5313. dark: hex2rgba(options.color.dark || '#000000ff'),
  5314. light: hex2rgba(options.color.light || '#ffffffff')
  5315. },
  5316. type: options.type,
  5317. rendererOpts: options.rendererOpts || {}
  5318. }
  5319. }
  5320.  
  5321. exports.getScale = function getScale (qrSize, opts) {
  5322. return opts.width && opts.width >= qrSize + opts.margin * 2
  5323. ? opts.width / (qrSize + opts.margin * 2)
  5324. : opts.scale
  5325. }
  5326.  
  5327. exports.getImageWidth = function getImageWidth (qrSize, opts) {
  5328. var scale = exports.getScale(qrSize, opts)
  5329. return Math.floor((qrSize + opts.margin * 2) * scale)
  5330. }
  5331.  
  5332. exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
  5333. var size = qr.modules.size
  5334. var data = qr.modules.data
  5335. var scale = exports.getScale(size, opts)
  5336. var symbolSize = Math.floor((size + opts.margin * 2) * scale)
  5337. var scaledMargin = opts.margin * scale
  5338. var palette = [opts.color.light, opts.color.dark]
  5339.  
  5340. for (var i = 0; i < symbolSize; i++) {
  5341. for (var j = 0; j < symbolSize; j++) {
  5342. var posDst = (i * symbolSize + j) * 4
  5343. var pxColor = opts.color.light
  5344.  
  5345. if (i >= scaledMargin && j >= scaledMargin &&
  5346. i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
  5347. var iSrc = Math.floor((i - scaledMargin) / scale)
  5348. var jSrc = Math.floor((j - scaledMargin) / scale)
  5349. pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]
  5350. }
  5351.  
  5352. imgData[posDst++] = pxColor.r
  5353. imgData[posDst++] = pxColor.g
  5354. imgData[posDst++] = pxColor.b
  5355. imgData[posDst] = pxColor.a
  5356. }
  5357. }
  5358. }
  5359.  
  5360.  
  5361. /***/ }),
  5362.  
  5363. /***/ "./node_modules/qrcode/lib/utils/typedarray-buffer.js":
  5364. /*!************************************************************!*\
  5365. !*** ./node_modules/qrcode/lib/utils/typedarray-buffer.js ***!
  5366. \************************************************************/
  5367. /*! no static exports found */
  5368. /***/ (function(module, exports, __webpack_require__) {
  5369.  
  5370. "use strict";
  5371. /**
  5372. * Implementation of a subset of node.js Buffer methods for the browser.
  5373. * Based on https://github.com/feross/buffer
  5374. */
  5375.  
  5376. /* eslint-disable no-proto */
  5377.  
  5378.  
  5379.  
  5380. var isArray = __webpack_require__(/*! isarray */ "./node_modules/qrcode/node_modules/isarray/index.js")
  5381.  
  5382. function typedArraySupport () {
  5383. // Can typed array instances be augmented?
  5384. try {
  5385. var arr = new Uint8Array(1)
  5386. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5387. return arr.foo() === 42
  5388. } catch (e) {
  5389. return false
  5390. }
  5391. }
  5392.  
  5393. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  5394.  
  5395. var K_MAX_LENGTH = Buffer.TYPED_ARRAY_SUPPORT
  5396. ? 0x7fffffff
  5397. : 0x3fffffff
  5398.  
  5399. function Buffer (arg, offset, length) {
  5400. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5401. return new Buffer(arg, offset, length)
  5402. }
  5403.  
  5404. if (typeof arg === 'number') {
  5405. return allocUnsafe(this, arg)
  5406. }
  5407.  
  5408. return from(this, arg, offset, length)
  5409. }
  5410.  
  5411. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5412. Buffer.prototype.__proto__ = Uint8Array.prototype
  5413. Buffer.__proto__ = Uint8Array
  5414.  
  5415. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5416. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5417. Buffer[Symbol.species] === Buffer) {
  5418. Object.defineProperty(Buffer, Symbol.species, {
  5419. value: null,
  5420. configurable: true,
  5421. enumerable: false,
  5422. writable: false
  5423. })
  5424. }
  5425. }
  5426.  
  5427. function checked (length) {
  5428. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  5429. // length is NaN (which is otherwise coerced to zero.)
  5430. if (length >= K_MAX_LENGTH) {
  5431. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5432. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  5433. }
  5434. return length | 0
  5435. }
  5436.  
  5437. function isnan (val) {
  5438. return val !== val // eslint-disable-line no-self-compare
  5439. }
  5440.  
  5441. function createBuffer (that, length) {
  5442. var buf
  5443. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5444. buf = new Uint8Array(length)
  5445. buf.__proto__ = Buffer.prototype
  5446. } else {
  5447. // Fallback: Return an object instance of the Buffer class
  5448. buf = that
  5449. if (buf === null) {
  5450. buf = new Buffer(length)
  5451. }
  5452. buf.length = length
  5453. }
  5454.  
  5455. return buf
  5456. }
  5457.  
  5458. function allocUnsafe (that, size) {
  5459. var buf = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5460.  
  5461. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5462. for (var i = 0; i < size; ++i) {
  5463. buf[i] = 0
  5464. }
  5465. }
  5466.  
  5467. return buf
  5468. }
  5469.  
  5470. function fromString (that, string) {
  5471. var length = byteLength(string) | 0
  5472. var buf = createBuffer(that, length)
  5473.  
  5474. var actual = buf.write(string)
  5475.  
  5476. if (actual !== length) {
  5477. // Writing a hex string, for example, that contains invalid characters will
  5478. // cause everything after the first invalid character to be ignored. (e.g.
  5479. // 'abxxcd' will be treated as 'ab')
  5480. buf = buf.slice(0, actual)
  5481. }
  5482.  
  5483. return buf
  5484. }
  5485.  
  5486. function fromArrayLike (that, array) {
  5487. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5488. var buf = createBuffer(that, length)
  5489. for (var i = 0; i < length; i += 1) {
  5490. buf[i] = array[i] & 255
  5491. }
  5492. return buf
  5493. }
  5494.  
  5495. function fromArrayBuffer (that, array, byteOffset, length) {
  5496. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5497. throw new RangeError('\'offset\' is out of bounds')
  5498. }
  5499.  
  5500. if (array.byteLength < byteOffset + (length || 0)) {
  5501. throw new RangeError('\'length\' is out of bounds')
  5502. }
  5503.  
  5504. var buf
  5505. if (byteOffset === undefined && length === undefined) {
  5506. buf = new Uint8Array(array)
  5507. } else if (length === undefined) {
  5508. buf = new Uint8Array(array, byteOffset)
  5509. } else {
  5510. buf = new Uint8Array(array, byteOffset, length)
  5511. }
  5512.  
  5513. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5514. // Return an augmented `Uint8Array` instance, for best performance
  5515. buf.__proto__ = Buffer.prototype
  5516. } else {
  5517. // Fallback: Return an object instance of the Buffer class
  5518. buf = fromArrayLike(that, buf)
  5519. }
  5520.  
  5521. return buf
  5522. }
  5523.  
  5524. function fromObject (that, obj) {
  5525. if (Buffer.isBuffer(obj)) {
  5526. var len = checked(obj.length) | 0
  5527. var buf = createBuffer(that, len)
  5528.  
  5529. if (buf.length === 0) {
  5530. return buf
  5531. }
  5532.  
  5533. obj.copy(buf, 0, 0, len)
  5534. return buf
  5535. }
  5536.  
  5537. if (obj) {
  5538. if ((typeof ArrayBuffer !== 'undefined' &&
  5539. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5540. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5541. return createBuffer(that, 0)
  5542. }
  5543. return fromArrayLike(that, obj)
  5544. }
  5545.  
  5546. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  5547. return fromArrayLike(that, obj.data)
  5548. }
  5549. }
  5550.  
  5551. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5552. }
  5553.  
  5554. function utf8ToBytes (string, units) {
  5555. units = units || Infinity
  5556. var codePoint
  5557. var length = string.length
  5558. var leadSurrogate = null
  5559. var bytes = []
  5560.  
  5561. for (var i = 0; i < length; ++i) {
  5562. codePoint = string.charCodeAt(i)
  5563.  
  5564. // is surrogate component
  5565. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  5566. // last char was a lead
  5567. if (!leadSurrogate) {
  5568. // no lead yet
  5569. if (codePoint > 0xDBFF) {
  5570. // unexpected trail
  5571. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  5572. continue
  5573. } else if (i + 1 === length) {
  5574. // unpaired lead
  5575. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  5576. continue
  5577. }
  5578.  
  5579. // valid lead
  5580. leadSurrogate = codePoint
  5581.  
  5582. continue
  5583. }
  5584.  
  5585. // 2 leads in a row
  5586. if (codePoint < 0xDC00) {
  5587. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  5588. leadSurrogate = codePoint
  5589. continue
  5590. }
  5591.  
  5592. // valid surrogate pair
  5593. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  5594. } else if (leadSurrogate) {
  5595. // valid bmp char, but last char was a lead
  5596. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  5597. }
  5598.  
  5599. leadSurrogate = null
  5600.  
  5601. // encode utf8
  5602. if (codePoint < 0x80) {
  5603. if ((units -= 1) < 0) break
  5604. bytes.push(codePoint)
  5605. } else if (codePoint < 0x800) {
  5606. if ((units -= 2) < 0) break
  5607. bytes.push(
  5608. codePoint >> 0x6 | 0xC0,
  5609. codePoint & 0x3F | 0x80
  5610. )
  5611. } else if (codePoint < 0x10000) {
  5612. if ((units -= 3) < 0) break
  5613. bytes.push(
  5614. codePoint >> 0xC | 0xE0,
  5615. codePoint >> 0x6 & 0x3F | 0x80,
  5616. codePoint & 0x3F | 0x80
  5617. )
  5618. } else if (codePoint < 0x110000) {
  5619. if ((units -= 4) < 0) break
  5620. bytes.push(
  5621. codePoint >> 0x12 | 0xF0,
  5622. codePoint >> 0xC & 0x3F | 0x80,
  5623. codePoint >> 0x6 & 0x3F | 0x80,
  5624. codePoint & 0x3F | 0x80
  5625. )
  5626. } else {
  5627. throw new Error('Invalid code point')
  5628. }
  5629. }
  5630.  
  5631. return bytes
  5632. }
  5633.  
  5634. function byteLength (string) {
  5635. if (Buffer.isBuffer(string)) {
  5636. return string.length
  5637. }
  5638. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5639. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5640. return string.byteLength
  5641. }
  5642. if (typeof string !== 'string') {
  5643. string = '' + string
  5644. }
  5645.  
  5646. var len = string.length
  5647. if (len === 0) return 0
  5648.  
  5649. return utf8ToBytes(string).length
  5650. }
  5651.  
  5652. function blitBuffer (src, dst, offset, length) {
  5653. for (var i = 0; i < length; ++i) {
  5654. if ((i + offset >= dst.length) || (i >= src.length)) break
  5655. dst[i + offset] = src[i]
  5656. }
  5657. return i
  5658. }
  5659.  
  5660. function utf8Write (buf, string, offset, length) {
  5661. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  5662. }
  5663.  
  5664. function from (that, value, offset, length) {
  5665. if (typeof value === 'number') {
  5666. throw new TypeError('"value" argument must not be a number')
  5667. }
  5668.  
  5669. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5670. return fromArrayBuffer(that, value, offset, length)
  5671. }
  5672.  
  5673. if (typeof value === 'string') {
  5674. return fromString(that, value, offset)
  5675. }
  5676.  
  5677. return fromObject(that, value)
  5678. }
  5679.  
  5680. Buffer.prototype.write = function write (string, offset, length) {
  5681. // Buffer#write(string)
  5682. if (offset === undefined) {
  5683. length = this.length
  5684. offset = 0
  5685. // Buffer#write(string, encoding)
  5686. } else if (length === undefined && typeof offset === 'string') {
  5687. length = this.length
  5688. offset = 0
  5689. // Buffer#write(string, offset[, length])
  5690. } else if (isFinite(offset)) {
  5691. offset = offset | 0
  5692. if (isFinite(length)) {
  5693. length = length | 0
  5694. } else {
  5695. length = undefined
  5696. }
  5697. }
  5698.  
  5699. var remaining = this.length - offset
  5700. if (length === undefined || length > remaining) length = remaining
  5701.  
  5702. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  5703. throw new RangeError('Attempt to write outside buffer bounds')
  5704. }
  5705.  
  5706. return utf8Write(this, string, offset, length)
  5707. }
  5708.  
  5709. Buffer.prototype.slice = function slice (start, end) {
  5710. var len = this.length
  5711. start = ~~start
  5712. end = end === undefined ? len : ~~end
  5713.  
  5714. if (start < 0) {
  5715. start += len
  5716. if (start < 0) start = 0
  5717. } else if (start > len) {
  5718. start = len
  5719. }
  5720.  
  5721. if (end < 0) {
  5722. end += len
  5723. if (end < 0) end = 0
  5724. } else if (end > len) {
  5725. end = len
  5726. }
  5727.  
  5728. if (end < start) end = start
  5729.  
  5730. var newBuf
  5731. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5732. newBuf = this.subarray(start, end)
  5733. // Return an augmented `Uint8Array` instance
  5734. newBuf.__proto__ = Buffer.prototype
  5735. } else {
  5736. var sliceLen = end - start
  5737. newBuf = new Buffer(sliceLen, undefined)
  5738. for (var i = 0; i < sliceLen; ++i) {
  5739. newBuf[i] = this[i + start]
  5740. }
  5741. }
  5742.  
  5743. return newBuf
  5744. }
  5745.  
  5746. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  5747. if (!start) start = 0
  5748. if (!end && end !== 0) end = this.length
  5749. if (targetStart >= target.length) targetStart = target.length
  5750. if (!targetStart) targetStart = 0
  5751. if (end > 0 && end < start) end = start
  5752.  
  5753. // Copy 0 bytes; we're done
  5754. if (end === start) return 0
  5755. if (target.length === 0 || this.length === 0) return 0
  5756.  
  5757. // Fatal error conditions
  5758. if (targetStart < 0) {
  5759. throw new RangeError('targetStart out of bounds')
  5760. }
  5761. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  5762. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  5763.  
  5764. // Are we oob?
  5765. if (end > this.length) end = this.length
  5766. if (target.length - targetStart < end - start) {
  5767. end = target.length - targetStart + start
  5768. }
  5769.  
  5770. var len = end - start
  5771. var i
  5772.  
  5773. if (this === target && start < targetStart && targetStart < end) {
  5774. // descending copy from end
  5775. for (i = len - 1; i >= 0; --i) {
  5776. target[i + targetStart] = this[i + start]
  5777. }
  5778. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  5779. // ascending copy from start
  5780. for (i = 0; i < len; ++i) {
  5781. target[i + targetStart] = this[i + start]
  5782. }
  5783. } else {
  5784. Uint8Array.prototype.set.call(
  5785. target,
  5786. this.subarray(start, start + len),
  5787. targetStart
  5788. )
  5789. }
  5790.  
  5791. return len
  5792. }
  5793.  
  5794. Buffer.prototype.fill = function fill (val, start, end) {
  5795. // Handle string cases:
  5796. if (typeof val === 'string') {
  5797. if (typeof start === 'string') {
  5798. start = 0
  5799. end = this.length
  5800. } else if (typeof end === 'string') {
  5801. end = this.length
  5802. }
  5803. if (val.length === 1) {
  5804. var code = val.charCodeAt(0)
  5805. if (code < 256) {
  5806. val = code
  5807. }
  5808. }
  5809. } else if (typeof val === 'number') {
  5810. val = val & 255
  5811. }
  5812.  
  5813. // Invalid ranges are not set to a default, so can range check early.
  5814. if (start < 0 || this.length < start || this.length < end) {
  5815. throw new RangeError('Out of range index')
  5816. }
  5817.  
  5818. if (end <= start) {
  5819. return this
  5820. }
  5821.  
  5822. start = start >>> 0
  5823. end = end === undefined ? this.length : end >>> 0
  5824.  
  5825. if (!val) val = 0
  5826.  
  5827. var i
  5828. if (typeof val === 'number') {
  5829. for (i = start; i < end; ++i) {
  5830. this[i] = val
  5831. }
  5832. } else {
  5833. var bytes = Buffer.isBuffer(val)
  5834. ? val
  5835. : new Buffer(val)
  5836. var len = bytes.length
  5837. for (i = 0; i < end - start; ++i) {
  5838. this[i + start] = bytes[i % len]
  5839. }
  5840. }
  5841.  
  5842. return this
  5843. }
  5844.  
  5845. Buffer.concat = function concat (list, length) {
  5846. if (!isArray(list)) {
  5847. throw new TypeError('"list" argument must be an Array of Buffers')
  5848. }
  5849.  
  5850. if (list.length === 0) {
  5851. return createBuffer(null, 0)
  5852. }
  5853.  
  5854. var i
  5855. if (length === undefined) {
  5856. length = 0
  5857. for (i = 0; i < list.length; ++i) {
  5858. length += list[i].length
  5859. }
  5860. }
  5861.  
  5862. var buffer = allocUnsafe(null, length)
  5863. var pos = 0
  5864. for (i = 0; i < list.length; ++i) {
  5865. var buf = list[i]
  5866. if (!Buffer.isBuffer(buf)) {
  5867. throw new TypeError('"list" argument must be an Array of Buffers')
  5868. }
  5869. buf.copy(buffer, pos)
  5870. pos += buf.length
  5871. }
  5872. return buffer
  5873. }
  5874.  
  5875. Buffer.byteLength = byteLength
  5876.  
  5877. Buffer.prototype._isBuffer = true
  5878. Buffer.isBuffer = function isBuffer (b) {
  5879. return !!(b != null && b._isBuffer)
  5880. }
  5881.  
  5882. module.exports.alloc = function (size) {
  5883. var buffer = new Buffer(size)
  5884. buffer.fill(0)
  5885. return buffer
  5886. }
  5887.  
  5888. module.exports.from = function (data) {
  5889. return new Buffer(data)
  5890. }
  5891.  
  5892.  
  5893. /***/ }),
  5894.  
  5895. /***/ "./node_modules/qrcode/node_modules/isarray/index.js":
  5896. /*!***********************************************************!*\
  5897. !*** ./node_modules/qrcode/node_modules/isarray/index.js ***!
  5898. \***********************************************************/
  5899. /*! no static exports found */
  5900. /***/ (function(module, exports) {
  5901.  
  5902. var toString = {}.toString;
  5903.  
  5904. module.exports = Array.isArray || function (arr) {
  5905. return toString.call(arr) == '[object Array]';
  5906. };
  5907.  
  5908.  
  5909. /***/ }),
  5910.  
  5911. /***/ "./node_modules/webpack/buildin/global.js":
  5912. /*!***********************************!*\
  5913. !*** (webpack)/buildin/global.js ***!
  5914. \***********************************/
  5915. /*! no static exports found */
  5916. /***/ (function(module, exports) {
  5917.  
  5918. var g;
  5919.  
  5920. // This works in non-strict mode
  5921. g = (function() {
  5922. return this;
  5923. })();
  5924.  
  5925. try {
  5926. // This works if eval is allowed (see CSP)
  5927. g = g || new Function("return this")();
  5928. } catch (e) {
  5929. // This works if the window reference is available
  5930. if (typeof window === "object") g = window;
  5931. }
  5932.  
  5933. // g can still be undefined, but nothing to do about it...
  5934. // We return undefined, instead of nothing here, so it's
  5935. // easier to handle this case. if(!global) { ...}
  5936.  
  5937. module.exports = g;
  5938.  
  5939.  
  5940. /***/ }),
  5941.  
  5942. /***/ "./src/Index.ts":
  5943. /*!**********************!*\
  5944. !*** ./src/Index.ts ***!
  5945. \**********************/
  5946. /*! exports provided: FuckXianyuCode */
  5947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5948.  
  5949. "use strict";
  5950. __webpack_require__.r(__webpack_exports__);
  5951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FuckXianyuCode", function() { return FuckXianyuCode; });
  5952. /* harmony import */ var iclipboard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! iclipboard */ "./node_modules/iclipboard/esm/index.js");
  5953. /* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! qrcode */ "./node_modules/qrcode/lib/browser.js");
  5954. /* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(qrcode__WEBPACK_IMPORTED_MODULE_1__);
  5955.  
  5956.  
  5957. var FuckXianyuCode = /** @class */ (function () {
  5958. function FuckXianyuCode() {
  5959. var _this = this;
  5960. this.replaceXianyuCode = function () {
  5961. var text = document.body.innerText;
  5962. var tkl = text.match(/[$|€|¥|₰][A-Za-z0-9]+[$|€|¥|₰]/g);
  5963. tkl && tkl.length > 0 && tkl.forEach(function (x) {
  5964. if (fetch) {
  5965. fetch("https://jckhj8su.demo.wood-is.top/tkl/tkljm?apikey=ZwuJXDIBef&tkl=" + x).then(function (res) {
  5966. res.json().then(function (data) {
  5967. var content = data.content, url = data.url;
  5968. document.body.innerHTML = document.body.innerHTML.replace(x, "<span title=\"" + content + "\" onclick=\"fuckXyCode.alertXianyuModal('" + url + "')\" style=\"color: red; padding: 0 .5em; font-weight: 500; cursor: pointer;\">" + x + "</span>");
  5969. });
  5970. });
  5971. }
  5972. });
  5973. };
  5974. this.alertXianyuModal = function (url) {
  5975. var viewDom = document.getElementById("viewGoods");
  5976. viewDom && viewDom.remove();
  5977. var div = document.createElement("div");
  5978. div.setAttribute("id", "viewGoods");
  5979. div.innerHTML = "\n <style>\n .actionBtn{\n width: 60px;\n height: 30px;\n color: white;\n background: red;\n display: inline-block;\n text-align: center;\n line-height: 30px;\n float: right;\n cursor: pointer;\n }\n\n #fuckXyCodeIframe{\n width: 350px;\n height: 540px;\n background: white;\n }\n\n #fuckXyCodeIframe::-webkit-scrollbar { \n width: 0 !important \n }\n </style>\n <div>\n <span onclick=\"document.getElementById('viewGoods').remove()\" class=\"actionBtn\" style=\"width: 60px; background: red\">\n \u5173\u95ED\n </span>&nbsp;&nbsp;\n <span onclick=\"fuckXyCode.copyUrl('" + url + "')\" class=\"actionBtn\" style=\"margin-right:.5em; width: 100px;background: green\">\n \u590D\u5236 URL\n </span>&nbsp;&nbsp;\n <span onclick=\"fuckXyCode.showQrCode('" + url + "')\" class=\"actionBtn\" style=\"margin-right:.5em; width: 100px;background: orange\">\n \u751F\u6210\u4E8C\u7EF4\u7801\n </span>\n </div>\n <iframe src=" + url + "\" id=\"fuckXyCodeIframe\" />";
  5980. div.style.position = "fixed";
  5981. div.style.bottom = "3em";
  5982. div.style.right = "4em";
  5983. document.body.appendChild(div);
  5984. };
  5985. this.copyUrl = function (url) {
  5986. if (Object(iclipboard__WEBPACK_IMPORTED_MODULE_0__["copy"])(url)) {
  5987. _this.showToast("复制成功");
  5988. }
  5989. };
  5990. this.showToast = function (msg, duration) {
  5991. if (duration === void 0) { duration = 3000; }
  5992. var m = document.createElement('div');
  5993. m.innerHTML = msg;
  5994. m.style.cssText = "box-shadow: 1px 1px 4px rgba(0,0,0,0.5);font-size: .32rem;color: black;background-color: white;padding: 10px 15px;margin: 0 0 0 -60px;border-radius: 4px;position: fixed; top: 50%;left: 50%;width: 130px;text-align: center;";
  5995. document.body.appendChild(m);
  5996. setTimeout(function () {
  5997. var d = 0.5;
  5998. m.style.opacity = '0';
  5999. setTimeout(function () { document.body.removeChild(m); }, d * 1000);
  6000. }, duration);
  6001. };
  6002. this.showQrCode = function (url) {
  6003. var qrcodeEle = document.createElement("div");
  6004. qrcodeEle.setAttribute("id", "fkxyQrcode");
  6005. qrcodeEle.innerHTML = "<div style=\"width: 60px; color: white; background: red; cursor: pointer; padding: .5em\" onclick=\"fuckXyCode.closeQrcode()\">\u5173\u95ED</div>";
  6006. qrcodeEle.style.cssText = "position: fixed;bottom: 10em;right: 450px;text-align: center;";
  6007. qrcode__WEBPACK_IMPORTED_MODULE_1___default.a.toCanvas(url, { errorCorrectionLevel: 'L' }, function (err, canvas) {
  6008. if (err)
  6009. throw err;
  6010. qrcodeEle.appendChild(canvas);
  6011. document.body.appendChild(qrcodeEle);
  6012. });
  6013. };
  6014. this.closeQrcode = function () {
  6015. var _a;
  6016. (_a = document.getElementById("fkxyQrcode")) === null || _a === void 0 ? void 0 : _a.remove();
  6017. };
  6018. this.replaceXianyuCode();
  6019. }
  6020. return FuckXianyuCode;
  6021. }());
  6022.  
  6023.  
  6024.  
  6025. /***/ })
  6026.  
  6027. /******/ });
  6028. });
  6029.  
  6030. window.fuckXyCode = new FuckXyCode.FuckXianyuCode()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址