JsBarcode.all.js 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ([
  88. /* 0 */
  89. /***/ (function(module, exports, __webpack_require__) {
  90. "use strict";
  91. var _barcodes = __webpack_require__(1);
  92. var _barcodes2 = _interopRequireDefault(_barcodes);
  93. var _merge = __webpack_require__(36);
  94. var _merge2 = _interopRequireDefault(_merge);
  95. var _linearizeEncodings = __webpack_require__(37);
  96. var _linearizeEncodings2 = _interopRequireDefault(_linearizeEncodings);
  97. var _fixOptions = __webpack_require__(38);
  98. var _fixOptions2 = _interopRequireDefault(_fixOptions);
  99. var _getRenderProperties = __webpack_require__(39);
  100. var _getRenderProperties2 = _interopRequireDefault(_getRenderProperties);
  101. var _optionsFromStrings = __webpack_require__(41);
  102. var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
  103. var _ErrorHandler = __webpack_require__(49);
  104. var _ErrorHandler2 = _interopRequireDefault(_ErrorHandler);
  105. var _exceptions = __webpack_require__(48);
  106. var _defaults = __webpack_require__(42);
  107. var _defaults2 = _interopRequireDefault(_defaults);
  108. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  109. // The protype of the object returned from the JsBarcode() call
  110. // Help functions
  111. var API = function API() {};
  112. // The first call of the library API
  113. // Will return an object with all barcodes calls and the data that is used
  114. // by the renderers
  115. // Default values
  116. // Exceptions
  117. // Import all the barcodes
  118. var JsBarcode = function JsBarcode(element, text, options) {
  119. var api = new API();
  120. if (typeof element === "undefined") {
  121. throw Error("No element to render on was provided.");
  122. }
  123. // Variables that will be pased through the API calls
  124. api._renderProperties = (0, _getRenderProperties2.default)(element);
  125. api._encodings = [];
  126. api._options = _defaults2.default;
  127. api._errorHandler = new _ErrorHandler2.default(api);
  128. // If text is set, use the simple syntax (render the barcode directly)
  129. if (typeof text !== "undefined") {
  130. options = options || {};
  131. if (!options.format) {
  132. options.format = autoSelectBarcode();
  133. }
  134. api.options(options)[options.format](text, options).render();
  135. }
  136. return api;
  137. };
  138. // To make tests work TODO: remove
  139. JsBarcode.getModule = function (name) {
  140. return _barcodes2.default[name];
  141. };
  142. // Register all barcodes
  143. for (var name in _barcodes2.default) {
  144. if (_barcodes2.default.hasOwnProperty(name)) {
  145. // Security check if the propery is a prototype property
  146. registerBarcode(_barcodes2.default, name);
  147. }
  148. }
  149. function registerBarcode(barcodes, name) {
  150. API.prototype[name] = API.prototype[name.toUpperCase()] = API.prototype[name.toLowerCase()] = function (text, options) {
  151. var api = this;
  152. return api._errorHandler.wrapBarcodeCall(function () {
  153. // Ensure text is options.text
  154. options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
  155. var newOptions = (0, _merge2.default)(api._options, options);
  156. newOptions = (0, _optionsFromStrings2.default)(newOptions);
  157. var Encoder = barcodes[name];
  158. var encoded = encode(text, Encoder, newOptions);
  159. api._encodings.push(encoded);
  160. return api;
  161. });
  162. };
  163. }
  164. // encode() handles the Encoder call and builds the binary string to be rendered
  165. function encode(text, Encoder, options) {
  166. // Ensure that text is a string
  167. text = "" + text;
  168. var encoder = new Encoder(text, options);
  169. // If the input is not valid for the encoder, throw error.
  170. // If the valid callback option is set, call it instead of throwing error
  171. if (!encoder.valid()) {
  172. throw new _exceptions.InvalidInputException(encoder.constructor.name, text);
  173. }
  174. // Make a request for the binary data (and other infromation) that should be rendered
  175. var encoded = encoder.encode();
  176. // Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
  177. // Convert to [1-1, 1-2, 2, 3-1, 3-2]
  178. encoded = (0, _linearizeEncodings2.default)(encoded);
  179. // Merge
  180. for (var i = 0; i < encoded.length; i++) {
  181. encoded[i].options = (0, _merge2.default)(options, encoded[i].options);
  182. }
  183. return encoded;
  184. }
  185. function autoSelectBarcode() {
  186. // If CODE128 exists. Use it
  187. if (_barcodes2.default["CODE128"]) {
  188. return "CODE128";
  189. }
  190. // Else, take the first (probably only) barcode
  191. return Object.keys(_barcodes2.default)[0];
  192. }
  193. // Sets global encoder options
  194. // Added to the api by the JsBarcode function
  195. API.prototype.options = function (options) {
  196. this._options = (0, _merge2.default)(this._options, options);
  197. return this;
  198. };
  199. // Will create a blank space (usually in between barcodes)
  200. API.prototype.blank = function (size) {
  201. var zeroes = new Array(size + 1).join("0");
  202. this._encodings.push({ data: zeroes });
  203. return this;
  204. };
  205. // Initialize JsBarcode on all HTML elements defined.
  206. API.prototype.init = function () {
  207. // Should do nothing if no elements where found
  208. if (!this._renderProperties) {
  209. return;
  210. }
  211. // Make sure renderProperies is an array
  212. if (!Array.isArray(this._renderProperties)) {
  213. this._renderProperties = [this._renderProperties];
  214. }
  215. var renderProperty;
  216. for (var i in this._renderProperties) {
  217. renderProperty = this._renderProperties[i];
  218. var options = (0, _merge2.default)(this._options, renderProperty.options);
  219. if (options.format == "auto") {
  220. options.format = autoSelectBarcode();
  221. }
  222. this._errorHandler.wrapBarcodeCall(function () {
  223. var text = options.value;
  224. var Encoder = _barcodes2.default[options.format.toUpperCase()];
  225. var encoded = encode(text, Encoder, options);
  226. render(renderProperty, encoded, options);
  227. });
  228. }
  229. };
  230. // The render API call. Calls the real render function.
  231. API.prototype.render = function () {
  232. if (!this._renderProperties) {
  233. throw new _exceptions.NoElementException();
  234. }
  235. if (Array.isArray(this._renderProperties)) {
  236. for (var i = 0; i < this._renderProperties.length; i++) {
  237. render(this._renderProperties[i], this._encodings, this._options);
  238. }
  239. } else {
  240. render(this._renderProperties, this._encodings, this._options);
  241. }
  242. return this;
  243. };
  244. API.prototype._defaults = _defaults2.default;
  245. // Prepares the encodings and calls the renderer
  246. function render(renderProperties, encodings, options) {
  247. encodings = (0, _linearizeEncodings2.default)(encodings);
  248. for (var i = 0; i < encodings.length; i++) {
  249. encodings[i].options = (0, _merge2.default)(options, encodings[i].options);
  250. (0, _fixOptions2.default)(encodings[i].options);
  251. }
  252. (0, _fixOptions2.default)(options);
  253. var Renderer = renderProperties.renderer;
  254. var renderer = new Renderer(renderProperties.element, encodings, options);
  255. renderer.render();
  256. if (renderProperties.afterRender) {
  257. renderProperties.afterRender();
  258. }
  259. }
  260. // Export to browser
  261. if (typeof window !== "undefined") {
  262. window.JsBarcode = JsBarcode;
  263. }
  264. // Export to jQuery
  265. /*global jQuery */
  266. if (typeof jQuery !== 'undefined') {
  267. jQuery.fn.JsBarcode = function (content, options) {
  268. var elementArray = [];
  269. jQuery(this).each(function () {
  270. elementArray.push(this);
  271. });
  272. return JsBarcode(elementArray, content, options);
  273. };
  274. }
  275. // Export to commonJS
  276. module.exports = JsBarcode;
  277. /***/ }),
  278. /* 1 */
  279. /***/ (function(module, exports, __webpack_require__) {
  280. "use strict";
  281. Object.defineProperty(exports, "__esModule", {
  282. value: true
  283. });
  284. var _CODE = __webpack_require__(2);
  285. var _CODE2 = __webpack_require__(4);
  286. var _EAN_UPC = __webpack_require__(12);
  287. var _ITF = __webpack_require__(22);
  288. var _MSI = __webpack_require__(26);
  289. var _pharmacode = __webpack_require__(33);
  290. var _codabar = __webpack_require__(34);
  291. var _GenericBarcode = __webpack_require__(35);
  292. exports.default = {
  293. CODE39: _CODE.CODE39,
  294. CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C,
  295. EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2, UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE,
  296. ITF14: _ITF.ITF14,
  297. ITF: _ITF.ITF,
  298. MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110,
  299. pharmacode: _pharmacode.pharmacode,
  300. codabar: _codabar.codabar,
  301. GenericBarcode: _GenericBarcode.GenericBarcode
  302. };
  303. /***/ }),
  304. /* 2 */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. Object.defineProperty(exports, "__esModule", {
  308. value: true
  309. });
  310. exports.CODE39 = undefined;
  311. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  312. var _Barcode2 = __webpack_require__(3);
  313. var _Barcode3 = _interopRequireDefault(_Barcode2);
  314. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  315. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  316. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  317. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  318. // https://en.wikipedia.org/wiki/Code_39#Encoding
  319. var CODE39 = function (_Barcode) {
  320. _inherits(CODE39, _Barcode);
  321. function CODE39(data, options) {
  322. _classCallCheck(this, CODE39);
  323. data = data.toUpperCase();
  324. // Calculate mod43 checksum if enabled
  325. if (options.mod43) {
  326. data += getCharacter(mod43checksum(data));
  327. }
  328. return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data, options));
  329. }
  330. _createClass(CODE39, [{
  331. key: "encode",
  332. value: function encode() {
  333. // First character is always a *
  334. var result = getEncoding("*");
  335. // Take every character and add the binary representation to the result
  336. for (var i = 0; i < this.data.length; i++) {
  337. result += getEncoding(this.data[i]) + "0";
  338. }
  339. // Last character is always a *
  340. result += getEncoding("*");
  341. return {
  342. data: result,
  343. text: this.text
  344. };
  345. }
  346. }, {
  347. key: "valid",
  348. value: function valid() {
  349. return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
  350. }
  351. }]);
  352. return CODE39;
  353. }(_Barcode3.default);
  354. // All characters. The position in the array is the (checksum) value
  355. var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%", "*"];
  356. // The decimal representation of the characters, is converted to the
  357. // corresponding binary with the getEncoding function
  358. var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385, 29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770];
  359. // Get the binary representation of a character by converting the encodings
  360. // from decimal to binary
  361. function getEncoding(character) {
  362. return getBinary(characterValue(character));
  363. }
  364. function getBinary(characterValue) {
  365. return encodings[characterValue].toString(2);
  366. }
  367. function getCharacter(characterValue) {
  368. return characters[characterValue];
  369. }
  370. function characterValue(character) {
  371. return characters.indexOf(character);
  372. }
  373. function mod43checksum(data) {
  374. var checksum = 0;
  375. for (var i = 0; i < data.length; i++) {
  376. checksum += characterValue(data[i]);
  377. }
  378. checksum = checksum % 43;
  379. return checksum;
  380. }
  381. exports.CODE39 = CODE39;
  382. /***/ }),
  383. /* 3 */
  384. /***/ (function(module, exports, __webpack_require__) {
  385. "use strict";
  386. Object.defineProperty(exports, "__esModule", {
  387. value: true
  388. });
  389. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  390. var Barcode = function Barcode(data, options) {
  391. _classCallCheck(this, Barcode);
  392. this.data = data;
  393. this.text = options.text || data;
  394. this.options = options;
  395. };
  396. exports.default = Barcode;
  397. /***/ }),
  398. /* 4 */
  399. /***/ (function(module, exports, __webpack_require__) {
  400. "use strict";
  401. Object.defineProperty(exports, "__esModule", {
  402. value: true
  403. });
  404. exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined;
  405. var _CODE128_AUTO = __webpack_require__(5);
  406. var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO);
  407. var _CODE128A = __webpack_require__(9);
  408. var _CODE128A2 = _interopRequireDefault(_CODE128A);
  409. var _CODE128B = __webpack_require__(10);
  410. var _CODE128B2 = _interopRequireDefault(_CODE128B);
  411. var _CODE128C = __webpack_require__(11);
  412. var _CODE128C2 = _interopRequireDefault(_CODE128C);
  413. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  414. exports.CODE128 = _CODE128_AUTO2.default;
  415. exports.CODE128A = _CODE128A2.default;
  416. exports.CODE128B = _CODE128B2.default;
  417. exports.CODE128C = _CODE128C2.default;
  418. /***/ }),
  419. /* 5 */
  420. /***/ (function(module, exports, __webpack_require__) {
  421. "use strict";
  422. Object.defineProperty(exports, "__esModule", {
  423. value: true
  424. });
  425. var _CODE2 = __webpack_require__(6);
  426. var _CODE3 = _interopRequireDefault(_CODE2);
  427. var _auto = __webpack_require__(8);
  428. var _auto2 = _interopRequireDefault(_auto);
  429. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  430. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  431. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  432. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  433. var CODE128AUTO = function (_CODE) {
  434. _inherits(CODE128AUTO, _CODE);
  435. function CODE128AUTO(data, options) {
  436. _classCallCheck(this, CODE128AUTO);
  437. // ASCII value ranges 0-127, 200-211
  438. if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
  439. var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
  440. } else {
  441. var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
  442. }
  443. return _possibleConstructorReturn(_this);
  444. }
  445. return CODE128AUTO;
  446. }(_CODE3.default);
  447. exports.default = CODE128AUTO;
  448. /***/ }),
  449. /* 6 */
  450. /***/ (function(module, exports, __webpack_require__) {
  451. "use strict";
  452. Object.defineProperty(exports, "__esModule", {
  453. value: true
  454. });
  455. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  456. var _Barcode2 = __webpack_require__(3);
  457. var _Barcode3 = _interopRequireDefault(_Barcode2);
  458. var _constants = __webpack_require__(7);
  459. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  461. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  462. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  463. // This is the master class,
  464. // it does require the start code to be included in the string
  465. var CODE128 = function (_Barcode) {
  466. _inherits(CODE128, _Barcode);
  467. function CODE128(data, options) {
  468. _classCallCheck(this, CODE128);
  469. // Get array of ascii codes from data
  470. var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
  471. _this.bytes = data.split('').map(function (char) {
  472. return char.charCodeAt(0);
  473. });
  474. return _this;
  475. }
  476. _createClass(CODE128, [{
  477. key: 'valid',
  478. value: function valid() {
  479. // ASCII value ranges 0-127, 200-211
  480. return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
  481. );
  482. }
  483. // The public encoding function
  484. }, {
  485. key: 'encode',
  486. value: function encode() {
  487. var bytes = this.bytes;
  488. // Remove the start code from the bytes and set its index
  489. var startIndex = bytes.shift() - 105;
  490. // Get start set by index
  491. var startSet = _constants.SET_BY_CODE[startIndex];
  492. if (startSet === undefined) {
  493. throw new RangeError('The encoding does not start with a start character.');
  494. }
  495. if (this.shouldEncodeAsEan128() === true) {
  496. bytes.unshift(_constants.FNC1);
  497. }
  498. // Start encode with the right type
  499. var encodingResult = CODE128.next(bytes, 1, startSet);
  500. return {
  501. text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
  502. data:
  503. // Add the start bits
  504. CODE128.getBar(startIndex) +
  505. // Add the encoded bits
  506. encodingResult.result +
  507. // Add the checksum
  508. CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
  509. // Add the end bits
  510. CODE128.getBar(_constants.STOP)
  511. };
  512. }
  513. // GS1-128/EAN-128
  514. }, {
  515. key: 'shouldEncodeAsEan128',
  516. value: function shouldEncodeAsEan128() {
  517. var isEAN128 = this.options.ean128 || false;
  518. if (typeof isEAN128 === 'string') {
  519. isEAN128 = isEAN128.toLowerCase() === 'true';
  520. }
  521. return isEAN128;
  522. }
  523. // Get a bar symbol by index
  524. }], [{
  525. key: 'getBar',
  526. value: function getBar(index) {
  527. return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
  528. }
  529. // Correct an index by a set and shift it from the bytes array
  530. }, {
  531. key: 'correctIndex',
  532. value: function correctIndex(bytes, set) {
  533. if (set === _constants.SET_A) {
  534. var charCode = bytes.shift();
  535. return charCode < 32 ? charCode + 64 : charCode - 32;
  536. } else if (set === _constants.SET_B) {
  537. return bytes.shift() - 32;
  538. } else {
  539. return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
  540. }
  541. }
  542. }, {
  543. key: 'next',
  544. value: function next(bytes, pos, set) {
  545. if (!bytes.length) {
  546. return { result: '', checksum: 0 };
  547. }
  548. var nextCode = void 0,
  549. index = void 0;
  550. // Special characters
  551. if (bytes[0] >= 200) {
  552. index = bytes.shift() - 105;
  553. var nextSet = _constants.SWAP[index];
  554. // Swap to other set
  555. if (nextSet !== undefined) {
  556. nextCode = CODE128.next(bytes, pos + 1, nextSet);
  557. }
  558. // Continue on current set but encode a special character
  559. else {
  560. // Shift
  561. if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
  562. // Convert the next character so that is encoded correctly
  563. bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
  564. }
  565. nextCode = CODE128.next(bytes, pos + 1, set);
  566. }
  567. }
  568. // Continue encoding
  569. else {
  570. index = CODE128.correctIndex(bytes, set);
  571. nextCode = CODE128.next(bytes, pos + 1, set);
  572. }
  573. // Get the correct binary encoding and calculate the weight
  574. var enc = CODE128.getBar(index);
  575. var weight = index * pos;
  576. return {
  577. result: enc + nextCode.result,
  578. checksum: weight + nextCode.checksum
  579. };
  580. }
  581. }]);
  582. return CODE128;
  583. }(_Barcode3.default);
  584. exports.default = CODE128;
  585. /***/ }),
  586. /* 7 */
  587. /***/ (function(module, exports, __webpack_require__) {
  588. "use strict";
  589. Object.defineProperty(exports, "__esModule", {
  590. value: true
  591. });
  592. var _SET_BY_CODE;
  593. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  594. // constants for internal usage
  595. var SET_A = exports.SET_A = 0;
  596. var SET_B = exports.SET_B = 1;
  597. var SET_C = exports.SET_C = 2;
  598. // Special characters
  599. var SHIFT = exports.SHIFT = 98;
  600. var START_A = exports.START_A = 103;
  601. var START_B = exports.START_B = 104;
  602. var START_C = exports.START_C = 105;
  603. var MODULO = exports.MODULO = 103;
  604. var STOP = exports.STOP = 106;
  605. var FNC1 = exports.FNC1 = 207;
  606. // Get set by start code
  607. var SET_BY_CODE = exports.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
  608. // Get next set by code
  609. var SWAP = exports.SWAP = {
  610. 101: SET_A,
  611. 100: SET_B,
  612. 99: SET_C
  613. };
  614. var A_START_CHAR = exports.A_START_CHAR = String.fromCharCode(208); // START_A + 105
  615. var B_START_CHAR = exports.B_START_CHAR = String.fromCharCode(209); // START_B + 105
  616. var C_START_CHAR = exports.C_START_CHAR = String.fromCharCode(210); // START_C + 105
  617. // 128A (Code Set A)
  618. // ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
  619. var A_CHARS = exports.A_CHARS = "[\x00-\x5F\xC8-\xCF]";
  620. // 128B (Code Set B)
  621. // ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
  622. var B_CHARS = exports.B_CHARS = "[\x20-\x7F\xC8-\xCF]";
  623. // 128C (Code Set C)
  624. // 00–99 (encodes two digits with a single code point) and FNC1
  625. var C_CHARS = exports.C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
  626. // CODE128 includes 107 symbols:
  627. // 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
  628. // Each symbol consist of three black bars (1) and three white spaces (0).
  629. var BARS = exports.BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000, 10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000, 11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010, 11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000, 11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100, 10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110, 10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 11010010000, 11010011100, 1100011101011];
  630. /***/ }),
  631. /* 8 */
  632. /***/ (function(module, exports, __webpack_require__) {
  633. "use strict";
  634. Object.defineProperty(exports, "__esModule", {
  635. value: true
  636. });
  637. var _constants = __webpack_require__(7);
  638. // Match Set functions
  639. var matchSetALength = function matchSetALength(string) {
  640. return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
  641. };
  642. var matchSetBLength = function matchSetBLength(string) {
  643. return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
  644. };
  645. var matchSetC = function matchSetC(string) {
  646. return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
  647. };
  648. // CODE128A or CODE128B
  649. function autoSelectFromAB(string, isA) {
  650. var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
  651. var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
  652. if (untilC) {
  653. return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
  654. }
  655. var chars = string.match(new RegExp('^' + ranges + '+'))[0];
  656. if (chars.length === string.length) {
  657. return string;
  658. }
  659. return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
  660. }
  661. // CODE128C
  662. function autoSelectFromC(string) {
  663. var cMatch = matchSetC(string);
  664. var length = cMatch.length;
  665. if (length === string.length) {
  666. return string;
  667. }
  668. string = string.substring(length);
  669. // Select A/B depending on the longest match
  670. var isA = matchSetALength(string) >= matchSetBLength(string);
  671. return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
  672. }
  673. // Detect Code Set (A, B or C) and format the string
  674. exports.default = function (string) {
  675. var newString = void 0;
  676. var cLength = matchSetC(string).length;
  677. // Select 128C if the string start with enough digits
  678. if (cLength >= 2) {
  679. newString = _constants.C_START_CHAR + autoSelectFromC(string);
  680. } else {
  681. // Select A/B depending on the longest match
  682. var isA = matchSetALength(string) > matchSetBLength(string);
  683. newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
  684. }
  685. return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
  686. function (match, char) {
  687. return String.fromCharCode(203) + char;
  688. });
  689. };
  690. /***/ }),
  691. /* 9 */
  692. /***/ (function(module, exports, __webpack_require__) {
  693. "use strict";
  694. Object.defineProperty(exports, "__esModule", {
  695. value: true
  696. });
  697. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  698. var _CODE2 = __webpack_require__(6);
  699. var _CODE3 = _interopRequireDefault(_CODE2);
  700. var _constants = __webpack_require__(7);
  701. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  702. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  703. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  704. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  705. var CODE128A = function (_CODE) {
  706. _inherits(CODE128A, _CODE);
  707. function CODE128A(string, options) {
  708. _classCallCheck(this, CODE128A);
  709. return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
  710. }
  711. _createClass(CODE128A, [{
  712. key: 'valid',
  713. value: function valid() {
  714. return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
  715. }
  716. }]);
  717. return CODE128A;
  718. }(_CODE3.default);
  719. exports.default = CODE128A;
  720. /***/ }),
  721. /* 10 */
  722. /***/ (function(module, exports, __webpack_require__) {
  723. "use strict";
  724. Object.defineProperty(exports, "__esModule", {
  725. value: true
  726. });
  727. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  728. var _CODE2 = __webpack_require__(6);
  729. var _CODE3 = _interopRequireDefault(_CODE2);
  730. var _constants = __webpack_require__(7);
  731. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  732. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  733. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  734. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  735. var CODE128B = function (_CODE) {
  736. _inherits(CODE128B, _CODE);
  737. function CODE128B(string, options) {
  738. _classCallCheck(this, CODE128B);
  739. return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
  740. }
  741. _createClass(CODE128B, [{
  742. key: 'valid',
  743. value: function valid() {
  744. return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
  745. }
  746. }]);
  747. return CODE128B;
  748. }(_CODE3.default);
  749. exports.default = CODE128B;
  750. /***/ }),
  751. /* 11 */
  752. /***/ (function(module, exports, __webpack_require__) {
  753. "use strict";
  754. Object.defineProperty(exports, "__esModule", {
  755. value: true
  756. });
  757. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  758. var _CODE2 = __webpack_require__(6);
  759. var _CODE3 = _interopRequireDefault(_CODE2);
  760. var _constants = __webpack_require__(7);
  761. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  762. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  763. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  764. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  765. var CODE128C = function (_CODE) {
  766. _inherits(CODE128C, _CODE);
  767. function CODE128C(string, options) {
  768. _classCallCheck(this, CODE128C);
  769. return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
  770. }
  771. _createClass(CODE128C, [{
  772. key: 'valid',
  773. value: function valid() {
  774. return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
  775. }
  776. }]);
  777. return CODE128C;
  778. }(_CODE3.default);
  779. exports.default = CODE128C;
  780. /***/ }),
  781. /* 12 */
  782. /***/ (function(module, exports, __webpack_require__) {
  783. "use strict";
  784. Object.defineProperty(exports, "__esModule", {
  785. value: true
  786. });
  787. exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
  788. var _EAN = __webpack_require__(13);
  789. var _EAN2 = _interopRequireDefault(_EAN);
  790. var _EAN3 = __webpack_require__(17);
  791. var _EAN4 = _interopRequireDefault(_EAN3);
  792. var _EAN5 = __webpack_require__(18);
  793. var _EAN6 = _interopRequireDefault(_EAN5);
  794. var _EAN7 = __webpack_require__(19);
  795. var _EAN8 = _interopRequireDefault(_EAN7);
  796. var _UPC = __webpack_require__(20);
  797. var _UPC2 = _interopRequireDefault(_UPC);
  798. var _UPCE = __webpack_require__(21);
  799. var _UPCE2 = _interopRequireDefault(_UPCE);
  800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  801. exports.EAN13 = _EAN2.default;
  802. exports.EAN8 = _EAN4.default;
  803. exports.EAN5 = _EAN6.default;
  804. exports.EAN2 = _EAN8.default;
  805. exports.UPC = _UPC2.default;
  806. exports.UPCE = _UPCE2.default;
  807. /***/ }),
  808. /* 13 */
  809. /***/ (function(module, exports, __webpack_require__) {
  810. "use strict";
  811. Object.defineProperty(exports, "__esModule", {
  812. value: true
  813. });
  814. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  815. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  816. var _constants = __webpack_require__(14);
  817. var _EAN2 = __webpack_require__(15);
  818. var _EAN3 = _interopRequireDefault(_EAN2);
  819. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  820. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  821. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  822. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  823. // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
  824. // Calculate the checksum digit
  825. // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
  826. var checksum = function checksum(number) {
  827. var res = number.substr(0, 12).split('').map(function (n) {
  828. return +n;
  829. }).reduce(function (sum, a, idx) {
  830. return idx % 2 ? sum + a * 3 : sum + a;
  831. }, 0);
  832. return (10 - res % 10) % 10;
  833. };
  834. var EAN13 = function (_EAN) {
  835. _inherits(EAN13, _EAN);
  836. function EAN13(data, options) {
  837. _classCallCheck(this, EAN13);
  838. // Add checksum if it does not exist
  839. if (data.search(/^[0-9]{12}$/) !== -1) {
  840. data += checksum(data);
  841. }
  842. // Adds a last character to the end of the barcode
  843. var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options));
  844. _this.lastChar = options.lastChar;
  845. return _this;
  846. }
  847. _createClass(EAN13, [{
  848. key: 'valid',
  849. value: function valid() {
  850. return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
  851. }
  852. }, {
  853. key: 'leftText',
  854. value: function leftText() {
  855. return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6);
  856. }
  857. }, {
  858. key: 'leftEncode',
  859. value: function leftEncode() {
  860. var data = this.data.substr(1, 6);
  861. var structure = _constants.EAN13_STRUCTURE[this.data[0]];
  862. return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure);
  863. }
  864. }, {
  865. key: 'rightText',
  866. value: function rightText() {
  867. return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
  868. }
  869. }, {
  870. key: 'rightEncode',
  871. value: function rightEncode() {
  872. var data = this.data.substr(7, 6);
  873. return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR');
  874. }
  875. // The "standard" way of printing EAN13 barcodes with guard bars
  876. }, {
  877. key: 'encodeGuarded',
  878. value: function encodeGuarded() {
  879. var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this);
  880. // Extend data with left digit & last character
  881. if (this.options.displayValue) {
  882. data.unshift({
  883. data: '000000000000',
  884. text: this.text.substr(0, 1),
  885. options: { textAlign: 'left', fontSize: this.fontSize }
  886. });
  887. if (this.options.lastChar) {
  888. data.push({
  889. data: '00'
  890. });
  891. data.push({
  892. data: '00000',
  893. text: this.options.lastChar,
  894. options: { fontSize: this.fontSize }
  895. });
  896. }
  897. }
  898. return data;
  899. }
  900. }]);
  901. return EAN13;
  902. }(_EAN3.default);
  903. exports.default = EAN13;
  904. /***/ }),
  905. /* 14 */
  906. /***/ (function(module, exports, __webpack_require__) {
  907. "use strict";
  908. Object.defineProperty(exports, "__esModule", {
  909. value: true
  910. });
  911. // Standard start end and middle bits
  912. var SIDE_BIN = exports.SIDE_BIN = '101';
  913. var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
  914. var BINARIES = exports.BINARIES = {
  915. 'L': [// The L (left) type of encoding
  916. '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
  917. 'G': [// The G type of encoding
  918. '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
  919. 'R': [// The R (right) type of encoding
  920. '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
  921. 'O': [// The O (odd) encoding for UPC-E
  922. '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
  923. 'E': [// The E (even) encoding for UPC-E
  924. '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
  925. };
  926. // Define the EAN-2 structure
  927. var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
  928. // Define the EAN-5 structure
  929. var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
  930. // Define the EAN-13 structure
  931. var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];
  932. /***/ }),
  933. /* 15 */
  934. /***/ (function(module, exports, __webpack_require__) {
  935. "use strict";
  936. Object.defineProperty(exports, "__esModule", {
  937. value: true
  938. });
  939. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  940. var _constants = __webpack_require__(14);
  941. var _encoder = __webpack_require__(16);
  942. var _encoder2 = _interopRequireDefault(_encoder);
  943. var _Barcode2 = __webpack_require__(3);
  944. var _Barcode3 = _interopRequireDefault(_Barcode2);
  945. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  946. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  947. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  948. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  949. // Base class for EAN8 & EAN13
  950. var EAN = function (_Barcode) {
  951. _inherits(EAN, _Barcode);
  952. function EAN(data, options) {
  953. _classCallCheck(this, EAN);
  954. // Make sure the font is not bigger than the space between the guard bars
  955. var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data, options));
  956. _this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options.fontSize;
  957. // Make the guard bars go down half the way of the text
  958. _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
  959. return _this;
  960. }
  961. _createClass(EAN, [{
  962. key: 'encode',
  963. value: function encode() {
  964. return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
  965. }
  966. }, {
  967. key: 'leftText',
  968. value: function leftText(from, to) {
  969. return this.text.substr(from, to);
  970. }
  971. }, {
  972. key: 'leftEncode',
  973. value: function leftEncode(data, structure) {
  974. return (0, _encoder2.default)(data, structure);
  975. }
  976. }, {
  977. key: 'rightText',
  978. value: function rightText(from, to) {
  979. return this.text.substr(from, to);
  980. }
  981. }, {
  982. key: 'rightEncode',
  983. value: function rightEncode(data, structure) {
  984. return (0, _encoder2.default)(data, structure);
  985. }
  986. }, {
  987. key: 'encodeGuarded',
  988. value: function encodeGuarded() {
  989. var textOptions = { fontSize: this.fontSize };
  990. var guardOptions = { height: this.guardHeight };
  991. return [{ data: _constants.SIDE_BIN, options: guardOptions }, { data: this.leftEncode(), text: this.leftText(), options: textOptions }, { data: _constants.MIDDLE_BIN, options: guardOptions }, { data: this.rightEncode(), text: this.rightText(), options: textOptions }, { data: _constants.SIDE_BIN, options: guardOptions }];
  992. }
  993. }, {
  994. key: 'encodeFlat',
  995. value: function encodeFlat() {
  996. var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this.rightEncode(), _constants.SIDE_BIN];
  997. return {
  998. data: data.join(''),
  999. text: this.text
  1000. };
  1001. }
  1002. }]);
  1003. return EAN;
  1004. }(_Barcode3.default);
  1005. exports.default = EAN;
  1006. /***/ }),
  1007. /* 16 */
  1008. /***/ (function(module, exports, __webpack_require__) {
  1009. "use strict";
  1010. Object.defineProperty(exports, "__esModule", {
  1011. value: true
  1012. });
  1013. var _constants = __webpack_require__(14);
  1014. // Encode data string
  1015. var encode = function encode(data, structure, separator) {
  1016. var encoded = data.split('').map(function (val, idx) {
  1017. return _constants.BINARIES[structure[idx]];
  1018. }).map(function (val, idx) {
  1019. return val ? val[data[idx]] : '';
  1020. });
  1021. if (separator) {
  1022. var last = data.length - 1;
  1023. encoded = encoded.map(function (val, idx) {
  1024. return idx < last ? val + separator : val;
  1025. });
  1026. }
  1027. return encoded.join('');
  1028. };
  1029. exports.default = encode;
  1030. /***/ }),
  1031. /* 17 */
  1032. /***/ (function(module, exports, __webpack_require__) {
  1033. "use strict";
  1034. Object.defineProperty(exports, "__esModule", {
  1035. value: true
  1036. });
  1037. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1038. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  1039. var _EAN2 = __webpack_require__(15);
  1040. var _EAN3 = _interopRequireDefault(_EAN2);
  1041. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1042. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1043. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1044. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  1045. // http://www.barcodeisland.com/ean8.phtml
  1046. // Calculate the checksum digit
  1047. var checksum = function checksum(number) {
  1048. var res = number.substr(0, 7).split('').map(function (n) {
  1049. return +n;
  1050. }).reduce(function (sum, a, idx) {
  1051. return idx % 2 ? sum + a : sum + a * 3;
  1052. }, 0);
  1053. return (10 - res % 10) % 10;
  1054. };
  1055. var EAN8 = function (_EAN) {
  1056. _inherits(EAN8, _EAN);
  1057. function EAN8(data, options) {
  1058. _classCallCheck(this, EAN8);
  1059. // Add checksum if it does not exist
  1060. if (data.search(/^[0-9]{7}$/) !== -1) {
  1061. data += checksum(data);
  1062. }
  1063. return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
  1064. }
  1065. _createClass(EAN8, [{
  1066. key: 'valid',
  1067. value: function valid() {
  1068. return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
  1069. }
  1070. }, {
  1071. key: 'leftText',
  1072. value: function leftText() {
  1073. return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4);
  1074. }
  1075. }, {
  1076. key: 'leftEncode',
  1077. value: function leftEncode() {
  1078. var data = this.data.substr(0, 4);
  1079. return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(this, data, 'LLLL');
  1080. }
  1081. }, {
  1082. key: 'rightText',
  1083. value: function rightText() {
  1084. return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4);
  1085. }
  1086. }, {
  1087. key: 'rightEncode',
  1088. value: function rightEncode() {
  1089. var data = this.data.substr(4, 4);
  1090. return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(this, data, 'RRRR');
  1091. }
  1092. }]);
  1093. return EAN8;
  1094. }(_EAN3.default);
  1095. exports.default = EAN8;
  1096. /***/ }),
  1097. /* 18 */
  1098. /***/ (function(module, exports, __webpack_require__) {
  1099. "use strict";
  1100. Object.defineProperty(exports, "__esModule", {
  1101. value: true
  1102. });
  1103. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1104. var _constants = __webpack_require__(14);
  1105. var _encoder = __webpack_require__(16);
  1106. var _encoder2 = _interopRequireDefault(_encoder);
  1107. var _Barcode2 = __webpack_require__(3);
  1108. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1109. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1110. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1111. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1112. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  1113. // https://en.wikipedia.org/wiki/EAN_5#Encoding
  1114. var checksum = function checksum(data) {
  1115. var result = data.split('').map(function (n) {
  1116. return +n;
  1117. }).reduce(function (sum, a, idx) {
  1118. return idx % 2 ? sum + a * 9 : sum + a * 3;
  1119. }, 0);
  1120. return result % 10;
  1121. };
  1122. var EAN5 = function (_Barcode) {
  1123. _inherits(EAN5, _Barcode);
  1124. function EAN5(data, options) {
  1125. _classCallCheck(this, EAN5);
  1126. return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
  1127. }
  1128. _createClass(EAN5, [{
  1129. key: 'valid',
  1130. value: function valid() {
  1131. return this.data.search(/^[0-9]{5}$/) !== -1;
  1132. }
  1133. }, {
  1134. key: 'encode',
  1135. value: function encode() {
  1136. var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
  1137. return {
  1138. data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
  1139. text: this.text
  1140. };
  1141. }
  1142. }]);
  1143. return EAN5;
  1144. }(_Barcode3.default);
  1145. exports.default = EAN5;
  1146. /***/ }),
  1147. /* 19 */
  1148. /***/ (function(module, exports, __webpack_require__) {
  1149. "use strict";
  1150. Object.defineProperty(exports, "__esModule", {
  1151. value: true
  1152. });
  1153. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1154. var _constants = __webpack_require__(14);
  1155. var _encoder = __webpack_require__(16);
  1156. var _encoder2 = _interopRequireDefault(_encoder);
  1157. var _Barcode2 = __webpack_require__(3);
  1158. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1160. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1161. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1162. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  1163. // https://en.wikipedia.org/wiki/EAN_2#Encoding
  1164. var EAN2 = function (_Barcode) {
  1165. _inherits(EAN2, _Barcode);
  1166. function EAN2(data, options) {
  1167. _classCallCheck(this, EAN2);
  1168. return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
  1169. }
  1170. _createClass(EAN2, [{
  1171. key: 'valid',
  1172. value: function valid() {
  1173. return this.data.search(/^[0-9]{2}$/) !== -1;
  1174. }
  1175. }, {
  1176. key: 'encode',
  1177. value: function encode() {
  1178. // Choose the structure based on the number mod 4
  1179. var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
  1180. return {
  1181. // Start bits + Encode the two digits with 01 in between
  1182. data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
  1183. text: this.text
  1184. };
  1185. }
  1186. }]);
  1187. return EAN2;
  1188. }(_Barcode3.default);
  1189. exports.default = EAN2;
  1190. /***/ }),
  1191. /* 20 */
  1192. /***/ (function(module, exports, __webpack_require__) {
  1193. "use strict";
  1194. Object.defineProperty(exports, "__esModule", {
  1195. value: true
  1196. });
  1197. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1198. exports.checksum = checksum;
  1199. var _encoder = __webpack_require__(16);
  1200. var _encoder2 = _interopRequireDefault(_encoder);
  1201. var _Barcode2 = __webpack_require__(3);
  1202. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1203. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1204. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1205. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1206. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  1207. // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
  1208. var UPC = function (_Barcode) {
  1209. _inherits(UPC, _Barcode);
  1210. function UPC(data, options) {
  1211. _classCallCheck(this, UPC);
  1212. // Add checksum if it does not exist
  1213. if (data.search(/^[0-9]{11}$/) !== -1) {
  1214. data += checksum(data);
  1215. }
  1216. var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
  1217. _this.displayValue = options.displayValue;
  1218. // Make sure the font is not bigger than the space between the guard bars
  1219. if (options.fontSize > options.width * 10) {
  1220. _this.fontSize = options.width * 10;
  1221. } else {
  1222. _this.fontSize = options.fontSize;
  1223. }
  1224. // Make the guard bars go down half the way of the text
  1225. _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
  1226. return _this;
  1227. }
  1228. _createClass(UPC, [{
  1229. key: "valid",
  1230. value: function valid() {
  1231. return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
  1232. }
  1233. }, {
  1234. key: "encode",
  1235. value: function encode() {
  1236. if (this.options.flat) {
  1237. return this.flatEncoding();
  1238. } else {
  1239. return this.guardedEncoding();
  1240. }
  1241. }
  1242. }, {
  1243. key: "flatEncoding",
  1244. value: function flatEncoding() {
  1245. var result = "";
  1246. result += "101";
  1247. result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
  1248. result += "01010";
  1249. result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
  1250. result += "101";
  1251. return {
  1252. data: result,
  1253. text: this.text
  1254. };
  1255. }
  1256. }, {
  1257. key: "guardedEncoding",
  1258. value: function guardedEncoding() {
  1259. var result = [];
  1260. // Add the first digit
  1261. if (this.displayValue) {
  1262. result.push({
  1263. data: "00000000",
  1264. text: this.text.substr(0, 1),
  1265. options: { textAlign: "left", fontSize: this.fontSize }
  1266. });
  1267. }
  1268. // Add the guard bars
  1269. result.push({
  1270. data: "101" + (0, _encoder2.default)(this.data[0], "L"),
  1271. options: { height: this.guardHeight }
  1272. });
  1273. // Add the left side
  1274. result.push({
  1275. data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
  1276. text: this.text.substr(1, 5),
  1277. options: { fontSize: this.fontSize }
  1278. });
  1279. // Add the middle bits
  1280. result.push({
  1281. data: "01010",
  1282. options: { height: this.guardHeight }
  1283. });
  1284. // Add the right side
  1285. result.push({
  1286. data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
  1287. text: this.text.substr(6, 5),
  1288. options: { fontSize: this.fontSize }
  1289. });
  1290. // Add the end bits
  1291. result.push({
  1292. data: (0, _encoder2.default)(this.data[11], "R") + "101",
  1293. options: { height: this.guardHeight }
  1294. });
  1295. // Add the last digit
  1296. if (this.displayValue) {
  1297. result.push({
  1298. data: "00000000",
  1299. text: this.text.substr(11, 1),
  1300. options: { textAlign: "right", fontSize: this.fontSize }
  1301. });
  1302. }
  1303. return result;
  1304. }
  1305. }]);
  1306. return UPC;
  1307. }(_Barcode3.default);
  1308. // Calulate the checksum digit
  1309. // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
  1310. function checksum(number) {
  1311. var result = 0;
  1312. var i;
  1313. for (i = 1; i < 11; i += 2) {
  1314. result += parseInt(number[i]);
  1315. }
  1316. for (i = 0; i < 11; i += 2) {
  1317. result += parseInt(number[i]) * 3;
  1318. }
  1319. return (10 - result % 10) % 10;
  1320. }
  1321. exports.default = UPC;
  1322. /***/ }),
  1323. /* 21 */
  1324. /***/ (function(module, exports, __webpack_require__) {
  1325. "use strict";
  1326. Object.defineProperty(exports, "__esModule", {
  1327. value: true
  1328. });
  1329. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1330. var _encoder = __webpack_require__(16);
  1331. var _encoder2 = _interopRequireDefault(_encoder);
  1332. var _Barcode2 = __webpack_require__(3);
  1333. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1334. var _UPC = __webpack_require__(20);
  1335. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1336. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1337. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1338. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
  1339. // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
  1340. //
  1341. // UPC-E documentation:
  1342. // https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
  1343. var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
  1344. var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
  1345. var UPCE = function (_Barcode) {
  1346. _inherits(UPCE, _Barcode);
  1347. function UPCE(data, options) {
  1348. _classCallCheck(this, UPCE);
  1349. var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
  1350. // Code may be 6 or 8 digits;
  1351. // A 7 digit code is ambiguous as to whether the extra digit
  1352. // is a UPC-A check or number system digit.
  1353. _this.isValid = false;
  1354. if (data.search(/^[0-9]{6}$/) !== -1) {
  1355. _this.middleDigits = data;
  1356. _this.upcA = expandToUPCA(data, "0");
  1357. _this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
  1358. _this.isValid = true;
  1359. } else if (data.search(/^[01][0-9]{7}$/) !== -1) {
  1360. _this.middleDigits = data.substring(1, data.length - 1);
  1361. _this.upcA = expandToUPCA(_this.middleDigits, data[0]);
  1362. if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
  1363. _this.isValid = true;
  1364. } else {
  1365. // checksum mismatch
  1366. return _possibleConstructorReturn(_this);
  1367. }
  1368. } else {
  1369. return _possibleConstructorReturn(_this);
  1370. }
  1371. _this.displayValue = options.displayValue;
  1372. // Make sure the font is not bigger than the space between the guard bars
  1373. if (options.fontSize > options.width * 10) {
  1374. _this.fontSize = options.width * 10;
  1375. } else {
  1376. _this.fontSize = options.fontSize;
  1377. }
  1378. // Make the guard bars go down half the way of the text
  1379. _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
  1380. return _this;
  1381. }
  1382. _createClass(UPCE, [{
  1383. key: 'valid',
  1384. value: function valid() {
  1385. return this.isValid;
  1386. }
  1387. }, {
  1388. key: 'encode',
  1389. value: function encode() {
  1390. if (this.options.flat) {
  1391. return this.flatEncoding();
  1392. } else {
  1393. return this.guardedEncoding();
  1394. }
  1395. }
  1396. }, {
  1397. key: 'flatEncoding',
  1398. value: function flatEncoding() {
  1399. var result = "";
  1400. result += "101";
  1401. result += this.encodeMiddleDigits();
  1402. result += "010101";
  1403. return {
  1404. data: result,
  1405. text: this.text
  1406. };
  1407. }
  1408. }, {
  1409. key: 'guardedEncoding',
  1410. value: function guardedEncoding() {
  1411. var result = [];
  1412. // Add the UPC-A number system digit beneath the quiet zone
  1413. if (this.displayValue) {
  1414. result.push({
  1415. data: "00000000",
  1416. text: this.text[0],
  1417. options: { textAlign: "left", fontSize: this.fontSize }
  1418. });
  1419. }
  1420. // Add the guard bars
  1421. result.push({
  1422. data: "101",
  1423. options: { height: this.guardHeight }
  1424. });
  1425. // Add the 6 UPC-E digits
  1426. result.push({
  1427. data: this.encodeMiddleDigits(),
  1428. text: this.text.substring(1, 7),
  1429. options: { fontSize: this.fontSize }
  1430. });
  1431. // Add the end bits
  1432. result.push({
  1433. data: "010101",
  1434. options: { height: this.guardHeight }
  1435. });
  1436. // Add the UPC-A check digit beneath the quiet zone
  1437. if (this.displayValue) {
  1438. result.push({
  1439. data: "00000000",
  1440. text: this.text[7],
  1441. options: { textAlign: "right", fontSize: this.fontSize }
  1442. });
  1443. }
  1444. return result;
  1445. }
  1446. }, {
  1447. key: 'encodeMiddleDigits',
  1448. value: function encodeMiddleDigits() {
  1449. var numberSystem = this.upcA[0];
  1450. var checkDigit = this.upcA[this.upcA.length - 1];
  1451. var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
  1452. return (0, _encoder2.default)(this.middleDigits, parity);
  1453. }
  1454. }]);
  1455. return UPCE;
  1456. }(_Barcode3.default);
  1457. function expandToUPCA(middleDigits, numberSystem) {
  1458. var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
  1459. var expansion = EXPANSIONS[lastUpcE];
  1460. var result = "";
  1461. var digitIndex = 0;
  1462. for (var i = 0; i < expansion.length; i++) {
  1463. var c = expansion[i];
  1464. if (c === 'X') {
  1465. result += middleDigits[digitIndex++];
  1466. } else {
  1467. result += c;
  1468. }
  1469. }
  1470. result = '' + numberSystem + result;
  1471. return '' + result + (0, _UPC.checksum)(result);
  1472. }
  1473. exports.default = UPCE;
  1474. /***/ }),
  1475. /* 22 */
  1476. /***/ (function(module, exports, __webpack_require__) {
  1477. "use strict";
  1478. Object.defineProperty(exports, "__esModule", {
  1479. value: true
  1480. });
  1481. exports.ITF14 = exports.ITF = undefined;
  1482. var _ITF = __webpack_require__(23);
  1483. var _ITF2 = _interopRequireDefault(_ITF);
  1484. var _ITF3 = __webpack_require__(25);
  1485. var _ITF4 = _interopRequireDefault(_ITF3);
  1486. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1487. exports.ITF = _ITF2.default;
  1488. exports.ITF14 = _ITF4.default;
  1489. /***/ }),
  1490. /* 23 */
  1491. /***/ (function(module, exports, __webpack_require__) {
  1492. "use strict";
  1493. Object.defineProperty(exports, "__esModule", {
  1494. value: true
  1495. });
  1496. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1497. var _constants = __webpack_require__(24);
  1498. var _Barcode2 = __webpack_require__(3);
  1499. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1500. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1501. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1502. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1503. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1504. var ITF = function (_Barcode) {
  1505. _inherits(ITF, _Barcode);
  1506. function ITF() {
  1507. _classCallCheck(this, ITF);
  1508. return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
  1509. }
  1510. _createClass(ITF, [{
  1511. key: 'valid',
  1512. value: function valid() {
  1513. return this.data.search(/^([0-9]{2})+$/) !== -1;
  1514. }
  1515. }, {
  1516. key: 'encode',
  1517. value: function encode() {
  1518. var _this2 = this;
  1519. // Calculate all the digit pairs
  1520. var encoded = this.data.match(/.{2}/g).map(function (pair) {
  1521. return _this2.encodePair(pair);
  1522. }).join('');
  1523. return {
  1524. data: _constants.START_BIN + encoded + _constants.END_BIN,
  1525. text: this.text
  1526. };
  1527. }
  1528. // Calculate the data of a number pair
  1529. }, {
  1530. key: 'encodePair',
  1531. value: function encodePair(pair) {
  1532. var second = _constants.BINARIES[pair[1]];
  1533. return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
  1534. return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
  1535. }).join('');
  1536. }
  1537. }]);
  1538. return ITF;
  1539. }(_Barcode3.default);
  1540. exports.default = ITF;
  1541. /***/ }),
  1542. /* 24 */
  1543. /***/ (function(module, exports, __webpack_require__) {
  1544. "use strict";
  1545. Object.defineProperty(exports, "__esModule", {
  1546. value: true
  1547. });
  1548. var START_BIN = exports.START_BIN = '1010';
  1549. var END_BIN = exports.END_BIN = '11101';
  1550. var BINARIES = exports.BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010'];
  1551. /***/ }),
  1552. /* 25 */
  1553. /***/ (function(module, exports, __webpack_require__) {
  1554. "use strict";
  1555. Object.defineProperty(exports, "__esModule", {
  1556. value: true
  1557. });
  1558. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1559. var _ITF2 = __webpack_require__(23);
  1560. var _ITF3 = _interopRequireDefault(_ITF2);
  1561. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1562. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1563. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1564. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1565. // Calculate the checksum digit
  1566. var checksum = function checksum(data) {
  1567. var res = data.substr(0, 13).split('').map(function (num) {
  1568. return parseInt(num, 10);
  1569. }).reduce(function (sum, n, idx) {
  1570. return sum + n * (3 - idx % 2 * 2);
  1571. }, 0);
  1572. return Math.ceil(res / 10) * 10 - res;
  1573. };
  1574. var ITF14 = function (_ITF) {
  1575. _inherits(ITF14, _ITF);
  1576. function ITF14(data, options) {
  1577. _classCallCheck(this, ITF14);
  1578. // Add checksum if it does not exist
  1579. if (data.search(/^[0-9]{13}$/) !== -1) {
  1580. data += checksum(data);
  1581. }
  1582. return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data, options));
  1583. }
  1584. _createClass(ITF14, [{
  1585. key: 'valid',
  1586. value: function valid() {
  1587. return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data);
  1588. }
  1589. }]);
  1590. return ITF14;
  1591. }(_ITF3.default);
  1592. exports.default = ITF14;
  1593. /***/ }),
  1594. /* 26 */
  1595. /***/ (function(module, exports, __webpack_require__) {
  1596. "use strict";
  1597. Object.defineProperty(exports, "__esModule", {
  1598. value: true
  1599. });
  1600. exports.MSI1110 = exports.MSI1010 = exports.MSI11 = exports.MSI10 = exports.MSI = undefined;
  1601. var _MSI = __webpack_require__(27);
  1602. var _MSI2 = _interopRequireDefault(_MSI);
  1603. var _MSI3 = __webpack_require__(28);
  1604. var _MSI4 = _interopRequireDefault(_MSI3);
  1605. var _MSI5 = __webpack_require__(30);
  1606. var _MSI6 = _interopRequireDefault(_MSI5);
  1607. var _MSI7 = __webpack_require__(31);
  1608. var _MSI8 = _interopRequireDefault(_MSI7);
  1609. var _MSI9 = __webpack_require__(32);
  1610. var _MSI10 = _interopRequireDefault(_MSI9);
  1611. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1612. exports.MSI = _MSI2.default;
  1613. exports.MSI10 = _MSI4.default;
  1614. exports.MSI11 = _MSI6.default;
  1615. exports.MSI1010 = _MSI8.default;
  1616. exports.MSI1110 = _MSI10.default;
  1617. /***/ }),
  1618. /* 27 */
  1619. /***/ (function(module, exports, __webpack_require__) {
  1620. "use strict";
  1621. Object.defineProperty(exports, "__esModule", {
  1622. value: true
  1623. });
  1624. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1625. var _Barcode2 = __webpack_require__(3);
  1626. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1627. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1628. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1629. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1630. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
  1631. // https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup
  1632. var MSI = function (_Barcode) {
  1633. _inherits(MSI, _Barcode);
  1634. function MSI(data, options) {
  1635. _classCallCheck(this, MSI);
  1636. return _possibleConstructorReturn(this, (MSI.__proto__ || Object.getPrototypeOf(MSI)).call(this, data, options));
  1637. }
  1638. _createClass(MSI, [{
  1639. key: "encode",
  1640. value: function encode() {
  1641. // Start bits
  1642. var ret = "110";
  1643. for (var i = 0; i < this.data.length; i++) {
  1644. // Convert the character to binary (always 4 binary digits)
  1645. var digit = parseInt(this.data[i]);
  1646. var bin = digit.toString(2);
  1647. bin = addZeroes(bin, 4 - bin.length);
  1648. // Add 100 for every zero and 110 for every 1
  1649. for (var b = 0; b < bin.length; b++) {
  1650. ret += bin[b] == "0" ? "100" : "110";
  1651. }
  1652. }
  1653. // End bits
  1654. ret += "1001";
  1655. return {
  1656. data: ret,
  1657. text: this.text
  1658. };
  1659. }
  1660. }, {
  1661. key: "valid",
  1662. value: function valid() {
  1663. return this.data.search(/^[0-9]+$/) !== -1;
  1664. }
  1665. }]);
  1666. return MSI;
  1667. }(_Barcode3.default);
  1668. function addZeroes(number, n) {
  1669. for (var i = 0; i < n; i++) {
  1670. number = "0" + number;
  1671. }
  1672. return number;
  1673. }
  1674. exports.default = MSI;
  1675. /***/ }),
  1676. /* 28 */
  1677. /***/ (function(module, exports, __webpack_require__) {
  1678. "use strict";
  1679. Object.defineProperty(exports, "__esModule", {
  1680. value: true
  1681. });
  1682. var _MSI2 = __webpack_require__(27);
  1683. var _MSI3 = _interopRequireDefault(_MSI2);
  1684. var _checksums = __webpack_require__(29);
  1685. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1686. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1687. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1688. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1689. var MSI10 = function (_MSI) {
  1690. _inherits(MSI10, _MSI);
  1691. function MSI10(data, options) {
  1692. _classCallCheck(this, MSI10);
  1693. return _possibleConstructorReturn(this, (MSI10.__proto__ || Object.getPrototypeOf(MSI10)).call(this, data + (0, _checksums.mod10)(data), options));
  1694. }
  1695. return MSI10;
  1696. }(_MSI3.default);
  1697. exports.default = MSI10;
  1698. /***/ }),
  1699. /* 29 */
  1700. /***/ (function(module, exports, __webpack_require__) {
  1701. "use strict";
  1702. Object.defineProperty(exports, "__esModule", {
  1703. value: true
  1704. });
  1705. exports.mod10 = mod10;
  1706. exports.mod11 = mod11;
  1707. function mod10(number) {
  1708. var sum = 0;
  1709. for (var i = 0; i < number.length; i++) {
  1710. var n = parseInt(number[i]);
  1711. if ((i + number.length) % 2 === 0) {
  1712. sum += n;
  1713. } else {
  1714. sum += n * 2 % 10 + Math.floor(n * 2 / 10);
  1715. }
  1716. }
  1717. return (10 - sum % 10) % 10;
  1718. }
  1719. function mod11(number) {
  1720. var sum = 0;
  1721. var weights = [2, 3, 4, 5, 6, 7];
  1722. for (var i = 0; i < number.length; i++) {
  1723. var n = parseInt(number[number.length - 1 - i]);
  1724. sum += weights[i % weights.length] * n;
  1725. }
  1726. return (11 - sum % 11) % 11;
  1727. }
  1728. /***/ }),
  1729. /* 30 */
  1730. /***/ (function(module, exports, __webpack_require__) {
  1731. "use strict";
  1732. Object.defineProperty(exports, "__esModule", {
  1733. value: true
  1734. });
  1735. var _MSI2 = __webpack_require__(27);
  1736. var _MSI3 = _interopRequireDefault(_MSI2);
  1737. var _checksums = __webpack_require__(29);
  1738. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1739. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1740. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1741. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1742. var MSI11 = function (_MSI) {
  1743. _inherits(MSI11, _MSI);
  1744. function MSI11(data, options) {
  1745. _classCallCheck(this, MSI11);
  1746. return _possibleConstructorReturn(this, (MSI11.__proto__ || Object.getPrototypeOf(MSI11)).call(this, data + (0, _checksums.mod11)(data), options));
  1747. }
  1748. return MSI11;
  1749. }(_MSI3.default);
  1750. exports.default = MSI11;
  1751. /***/ }),
  1752. /* 31 */
  1753. /***/ (function(module, exports, __webpack_require__) {
  1754. "use strict";
  1755. Object.defineProperty(exports, "__esModule", {
  1756. value: true
  1757. });
  1758. var _MSI2 = __webpack_require__(27);
  1759. var _MSI3 = _interopRequireDefault(_MSI2);
  1760. var _checksums = __webpack_require__(29);
  1761. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1762. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1763. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1764. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1765. var MSI1010 = function (_MSI) {
  1766. _inherits(MSI1010, _MSI);
  1767. function MSI1010(data, options) {
  1768. _classCallCheck(this, MSI1010);
  1769. data += (0, _checksums.mod10)(data);
  1770. data += (0, _checksums.mod10)(data);
  1771. return _possibleConstructorReturn(this, (MSI1010.__proto__ || Object.getPrototypeOf(MSI1010)).call(this, data, options));
  1772. }
  1773. return MSI1010;
  1774. }(_MSI3.default);
  1775. exports.default = MSI1010;
  1776. /***/ }),
  1777. /* 32 */
  1778. /***/ (function(module, exports, __webpack_require__) {
  1779. "use strict";
  1780. Object.defineProperty(exports, "__esModule", {
  1781. value: true
  1782. });
  1783. var _MSI2 = __webpack_require__(27);
  1784. var _MSI3 = _interopRequireDefault(_MSI2);
  1785. var _checksums = __webpack_require__(29);
  1786. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1787. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1788. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1789. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1790. var MSI1110 = function (_MSI) {
  1791. _inherits(MSI1110, _MSI);
  1792. function MSI1110(data, options) {
  1793. _classCallCheck(this, MSI1110);
  1794. data += (0, _checksums.mod11)(data);
  1795. data += (0, _checksums.mod10)(data);
  1796. return _possibleConstructorReturn(this, (MSI1110.__proto__ || Object.getPrototypeOf(MSI1110)).call(this, data, options));
  1797. }
  1798. return MSI1110;
  1799. }(_MSI3.default);
  1800. exports.default = MSI1110;
  1801. /***/ }),
  1802. /* 33 */
  1803. /***/ (function(module, exports, __webpack_require__) {
  1804. "use strict";
  1805. Object.defineProperty(exports, "__esModule", {
  1806. value: true
  1807. });
  1808. exports.pharmacode = undefined;
  1809. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1810. var _Barcode2 = __webpack_require__(3);
  1811. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1812. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1813. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1814. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1815. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
  1816. // http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
  1817. var pharmacode = function (_Barcode) {
  1818. _inherits(pharmacode, _Barcode);
  1819. function pharmacode(data, options) {
  1820. _classCallCheck(this, pharmacode);
  1821. var _this = _possibleConstructorReturn(this, (pharmacode.__proto__ || Object.getPrototypeOf(pharmacode)).call(this, data, options));
  1822. _this.number = parseInt(data, 10);
  1823. return _this;
  1824. }
  1825. _createClass(pharmacode, [{
  1826. key: "encode",
  1827. value: function encode() {
  1828. var z = this.number;
  1829. var result = "";
  1830. // http://i.imgur.com/RMm4UDJ.png
  1831. // (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
  1832. while (!isNaN(z) && z != 0) {
  1833. if (z % 2 === 0) {
  1834. // Even
  1835. result = "11100" + result;
  1836. z = (z - 2) / 2;
  1837. } else {
  1838. // Odd
  1839. result = "100" + result;
  1840. z = (z - 1) / 2;
  1841. }
  1842. }
  1843. // Remove the two last zeroes
  1844. result = result.slice(0, -2);
  1845. return {
  1846. data: result,
  1847. text: this.text
  1848. };
  1849. }
  1850. }, {
  1851. key: "valid",
  1852. value: function valid() {
  1853. return this.number >= 3 && this.number <= 131070;
  1854. }
  1855. }]);
  1856. return pharmacode;
  1857. }(_Barcode3.default);
  1858. exports.pharmacode = pharmacode;
  1859. /***/ }),
  1860. /* 34 */
  1861. /***/ (function(module, exports, __webpack_require__) {
  1862. "use strict";
  1863. Object.defineProperty(exports, "__esModule", {
  1864. value: true
  1865. });
  1866. exports.codabar = undefined;
  1867. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1868. var _Barcode2 = __webpack_require__(3);
  1869. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1870. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1871. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1872. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1873. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding specification:
  1874. // http://www.barcodeisland.com/codabar.phtml
  1875. var codabar = function (_Barcode) {
  1876. _inherits(codabar, _Barcode);
  1877. function codabar(data, options) {
  1878. _classCallCheck(this, codabar);
  1879. if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) {
  1880. data = "A" + data + "A";
  1881. }
  1882. var _this = _possibleConstructorReturn(this, (codabar.__proto__ || Object.getPrototypeOf(codabar)).call(this, data.toUpperCase(), options));
  1883. _this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
  1884. return _this;
  1885. }
  1886. _createClass(codabar, [{
  1887. key: "valid",
  1888. value: function valid() {
  1889. return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
  1890. }
  1891. }, {
  1892. key: "encode",
  1893. value: function encode() {
  1894. var result = [];
  1895. var encodings = this.getEncodings();
  1896. for (var i = 0; i < this.data.length; i++) {
  1897. result.push(encodings[this.data.charAt(i)]);
  1898. // for all characters except the last, append a narrow-space ("0")
  1899. if (i !== this.data.length - 1) {
  1900. result.push("0");
  1901. }
  1902. }
  1903. return {
  1904. text: this.text,
  1905. data: result.join('')
  1906. };
  1907. }
  1908. }, {
  1909. key: "getEncodings",
  1910. value: function getEncodings() {
  1911. return {
  1912. "0": "101010011",
  1913. "1": "101011001",
  1914. "2": "101001011",
  1915. "3": "110010101",
  1916. "4": "101101001",
  1917. "5": "110101001",
  1918. "6": "100101011",
  1919. "7": "100101101",
  1920. "8": "100110101",
  1921. "9": "110100101",
  1922. "-": "101001101",
  1923. "$": "101100101",
  1924. ":": "1101011011",
  1925. "/": "1101101011",
  1926. ".": "1101101101",
  1927. "+": "1011011011",
  1928. "A": "1011001001",
  1929. "B": "1001001011",
  1930. "C": "1010010011",
  1931. "D": "1010011001"
  1932. };
  1933. }
  1934. }]);
  1935. return codabar;
  1936. }(_Barcode3.default);
  1937. exports.codabar = codabar;
  1938. /***/ }),
  1939. /* 35 */
  1940. /***/ (function(module, exports, __webpack_require__) {
  1941. "use strict";
  1942. Object.defineProperty(exports, "__esModule", {
  1943. value: true
  1944. });
  1945. exports.GenericBarcode = undefined;
  1946. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1947. var _Barcode2 = __webpack_require__(3);
  1948. var _Barcode3 = _interopRequireDefault(_Barcode2);
  1949. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1950. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1951. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1952. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1953. var GenericBarcode = function (_Barcode) {
  1954. _inherits(GenericBarcode, _Barcode);
  1955. function GenericBarcode(data, options) {
  1956. _classCallCheck(this, GenericBarcode);
  1957. return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
  1958. }
  1959. // Return the corresponding binary numbers for the data provided
  1960. _createClass(GenericBarcode, [{
  1961. key: "encode",
  1962. value: function encode() {
  1963. return {
  1964. data: "10101010101010101010101010101010101010101",
  1965. text: this.text
  1966. };
  1967. }
  1968. // Resturn true/false if the string provided is valid for this encoder
  1969. }, {
  1970. key: "valid",
  1971. value: function valid() {
  1972. return true;
  1973. }
  1974. }]);
  1975. return GenericBarcode;
  1976. }(_Barcode3.default);
  1977. exports.GenericBarcode = GenericBarcode;
  1978. /***/ }),
  1979. /* 36 */
  1980. /***/ (function(module, exports, __webpack_require__) {
  1981. "use strict";
  1982. Object.defineProperty(exports, "__esModule", {
  1983. value: true
  1984. });
  1985. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  1986. exports.default = function (old, replaceObj) {
  1987. return _extends({}, old, replaceObj);
  1988. };
  1989. /***/ }),
  1990. /* 37 */
  1991. /***/ (function(module, exports, __webpack_require__) {
  1992. "use strict";
  1993. Object.defineProperty(exports, "__esModule", {
  1994. value: true
  1995. });
  1996. exports.default = linearizeEncodings;
  1997. // Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
  1998. // Convert to [1-1, 1-2, 2, 3-1, 3-2]
  1999. function linearizeEncodings(encodings) {
  2000. var linearEncodings = [];
  2001. function nextLevel(encoded) {
  2002. if (Array.isArray(encoded)) {
  2003. for (var i = 0; i < encoded.length; i++) {
  2004. nextLevel(encoded[i]);
  2005. }
  2006. } else {
  2007. encoded.text = encoded.text || "";
  2008. encoded.data = encoded.data || "";
  2009. linearEncodings.push(encoded);
  2010. }
  2011. }
  2012. nextLevel(encodings);
  2013. return linearEncodings;
  2014. }
  2015. /***/ }),
  2016. /* 38 */
  2017. /***/ (function(module, exports, __webpack_require__) {
  2018. "use strict";
  2019. Object.defineProperty(exports, "__esModule", {
  2020. value: true
  2021. });
  2022. exports.default = fixOptions;
  2023. function fixOptions(options) {
  2024. // Fix the margins
  2025. options.marginTop = options.marginTop || options.margin;
  2026. options.marginBottom = options.marginBottom || options.margin;
  2027. options.marginRight = options.marginRight || options.margin;
  2028. options.marginLeft = options.marginLeft || options.margin;
  2029. return options;
  2030. }
  2031. /***/ }),
  2032. /* 39 */
  2033. /***/ (function(module, exports, __webpack_require__) {
  2034. "use strict";
  2035. Object.defineProperty(exports, "__esModule", {
  2036. value: true
  2037. });
  2038. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* global HTMLImageElement */
  2039. /* global HTMLCanvasElement */
  2040. /* global SVGElement */
  2041. var _getOptionsFromElement = __webpack_require__(40);
  2042. var _getOptionsFromElement2 = _interopRequireDefault(_getOptionsFromElement);
  2043. var _renderers = __webpack_require__(43);
  2044. var _renderers2 = _interopRequireDefault(_renderers);
  2045. var _exceptions = __webpack_require__(48);
  2046. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2047. // Takes an element and returns an object with information about how
  2048. // it should be rendered
  2049. // This could also return an array with these objects
  2050. // {
  2051. // element: The element that the renderer should draw on
  2052. // renderer: The name of the renderer
  2053. // afterRender (optional): If something has to done after the renderer
  2054. // completed, calls afterRender (function)
  2055. // options (optional): Options that can be defined in the element
  2056. // }
  2057. function getRenderProperties(element) {
  2058. // If the element is a string, query select call again
  2059. if (typeof element === "string") {
  2060. return querySelectedRenderProperties(element);
  2061. }
  2062. // If element is array. Recursivly call with every object in the array
  2063. else if (Array.isArray(element)) {
  2064. var returnArray = [];
  2065. for (var i = 0; i < element.length; i++) {
  2066. returnArray.push(getRenderProperties(element[i]));
  2067. }
  2068. return returnArray;
  2069. }
  2070. // If element, render on canvas and set the uri as src
  2071. else if (typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLImageElement) {
  2072. return newCanvasRenderProperties(element);
  2073. }
  2074. // If SVG
  2075. else if (element && element.nodeName && element.nodeName.toLowerCase() === 'svg' || typeof SVGElement !== 'undefined' && element instanceof SVGElement) {
  2076. return {
  2077. element: element,
  2078. options: (0, _getOptionsFromElement2.default)(element),
  2079. renderer: _renderers2.default.SVGRenderer
  2080. };
  2081. }
  2082. // If canvas (in browser)
  2083. else if (typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLCanvasElement) {
  2084. return {
  2085. element: element,
  2086. options: (0, _getOptionsFromElement2.default)(element),
  2087. renderer: _renderers2.default.CanvasRenderer
  2088. };
  2089. }
  2090. // If canvas (in node)
  2091. else if (element && element.getContext) {
  2092. return {
  2093. element: element,
  2094. renderer: _renderers2.default.CanvasRenderer
  2095. };
  2096. } else if (element && (typeof element === "undefined" ? "undefined" : _typeof(element)) === 'object' && !element.nodeName) {
  2097. return {
  2098. element: element,
  2099. renderer: _renderers2.default.ObjectRenderer
  2100. };
  2101. } else {
  2102. throw new _exceptions.InvalidElementException();
  2103. }
  2104. }
  2105. function querySelectedRenderProperties(string) {
  2106. var selector = document.querySelectorAll(string);
  2107. if (selector.length === 0) {
  2108. return undefined;
  2109. } else {
  2110. var returnArray = [];
  2111. for (var i = 0; i < selector.length; i++) {
  2112. returnArray.push(getRenderProperties(selector[i]));
  2113. }
  2114. return returnArray;
  2115. }
  2116. }
  2117. function newCanvasRenderProperties(imgElement) {
  2118. var canvas = document.createElement('canvas');
  2119. return {
  2120. element: canvas,
  2121. options: (0, _getOptionsFromElement2.default)(imgElement),
  2122. renderer: _renderers2.default.CanvasRenderer,
  2123. afterRender: function afterRender() {
  2124. imgElement.setAttribute("src", canvas.toDataURL());
  2125. }
  2126. };
  2127. }
  2128. exports.default = getRenderProperties;
  2129. /***/ }),
  2130. /* 40 */
  2131. /***/ (function(module, exports, __webpack_require__) {
  2132. "use strict";
  2133. Object.defineProperty(exports, "__esModule", {
  2134. value: true
  2135. });
  2136. var _optionsFromStrings = __webpack_require__(41);
  2137. var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
  2138. var _defaults = __webpack_require__(42);
  2139. var _defaults2 = _interopRequireDefault(_defaults);
  2140. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2141. function getOptionsFromElement(element) {
  2142. var options = {};
  2143. for (var property in _defaults2.default) {
  2144. if (_defaults2.default.hasOwnProperty(property)) {
  2145. // jsbarcode-*
  2146. if (element.hasAttribute("jsbarcode-" + property.toLowerCase())) {
  2147. options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase());
  2148. }
  2149. // data-*
  2150. if (element.hasAttribute("data-" + property.toLowerCase())) {
  2151. options[property] = element.getAttribute("data-" + property.toLowerCase());
  2152. }
  2153. }
  2154. }
  2155. options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value");
  2156. // Since all atributes are string they need to be converted to integers
  2157. options = (0, _optionsFromStrings2.default)(options);
  2158. return options;
  2159. }
  2160. exports.default = getOptionsFromElement;
  2161. /***/ }),
  2162. /* 41 */
  2163. /***/ (function(module, exports, __webpack_require__) {
  2164. "use strict";
  2165. Object.defineProperty(exports, "__esModule", {
  2166. value: true
  2167. });
  2168. exports.default = optionsFromStrings;
  2169. // Convert string to integers/booleans where it should be
  2170. function optionsFromStrings(options) {
  2171. var intOptions = ["width", "height", "textMargin", "fontSize", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight"];
  2172. for (var intOption in intOptions) {
  2173. if (intOptions.hasOwnProperty(intOption)) {
  2174. intOption = intOptions[intOption];
  2175. if (typeof options[intOption] === "string") {
  2176. options[intOption] = parseInt(options[intOption], 10);
  2177. }
  2178. }
  2179. }
  2180. if (typeof options["displayValue"] === "string") {
  2181. options["displayValue"] = options["displayValue"] != "false";
  2182. }
  2183. return options;
  2184. }
  2185. /***/ }),
  2186. /* 42 */
  2187. /***/ (function(module, exports, __webpack_require__) {
  2188. "use strict";
  2189. Object.defineProperty(exports, "__esModule", {
  2190. value: true
  2191. });
  2192. var defaults = {
  2193. width: 2,
  2194. height: 100,
  2195. format: "auto",
  2196. displayValue: true,
  2197. fontOptions: "",
  2198. font: "monospace",
  2199. text: undefined,
  2200. textAlign: "center",
  2201. textPosition: "bottom",
  2202. textMargin: 2,
  2203. fontSize: 20,
  2204. background: "#ffffff",
  2205. lineColor: "#000000",
  2206. margin: 10,
  2207. marginTop: undefined,
  2208. marginBottom: undefined,
  2209. marginLeft: undefined,
  2210. marginRight: undefined,
  2211. valid: function valid() {}
  2212. };
  2213. exports.default = defaults;
  2214. /***/ }),
  2215. /* 43 */
  2216. /***/ (function(module, exports, __webpack_require__) {
  2217. "use strict";
  2218. Object.defineProperty(exports, "__esModule", {
  2219. value: true
  2220. });
  2221. var _canvas = __webpack_require__(44);
  2222. var _canvas2 = _interopRequireDefault(_canvas);
  2223. var _svg = __webpack_require__(46);
  2224. var _svg2 = _interopRequireDefault(_svg);
  2225. var _object = __webpack_require__(47);
  2226. var _object2 = _interopRequireDefault(_object);
  2227. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2228. exports.default = { CanvasRenderer: _canvas2.default, SVGRenderer: _svg2.default, ObjectRenderer: _object2.default };
  2229. /***/ }),
  2230. /* 44 */
  2231. /***/ (function(module, exports, __webpack_require__) {
  2232. "use strict";
  2233. Object.defineProperty(exports, "__esModule", {
  2234. value: true
  2235. });
  2236. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2237. var _merge = __webpack_require__(36);
  2238. var _merge2 = _interopRequireDefault(_merge);
  2239. var _shared = __webpack_require__(45);
  2240. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2241. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2242. var CanvasRenderer = function () {
  2243. function CanvasRenderer(canvas, encodings, options) {
  2244. _classCallCheck(this, CanvasRenderer);
  2245. this.canvas = canvas;
  2246. this.encodings = encodings;
  2247. this.options = options;
  2248. }
  2249. _createClass(CanvasRenderer, [{
  2250. key: "render",
  2251. value: function render() {
  2252. // Abort if the browser does not support HTML5 canvas
  2253. if (!this.canvas.getContext) {
  2254. throw new Error('The browser does not support canvas.');
  2255. }
  2256. this.prepareCanvas();
  2257. for (var i = 0; i < this.encodings.length; i++) {
  2258. var encodingOptions = (0, _merge2.default)(this.options, this.encodings[i].options);
  2259. this.drawCanvasBarcode(encodingOptions, this.encodings[i]);
  2260. this.drawCanvasText(encodingOptions, this.encodings[i]);
  2261. this.moveCanvasDrawing(this.encodings[i]);
  2262. }
  2263. this.restoreCanvas();
  2264. }
  2265. }, {
  2266. key: "prepareCanvas",
  2267. value: function prepareCanvas() {
  2268. // Get the canvas context
  2269. var ctx = this.canvas.getContext("2d");
  2270. ctx.save();
  2271. (0, _shared.calculateEncodingAttributes)(this.encodings, this.options, ctx);
  2272. var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings);
  2273. var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings);
  2274. this.canvas.width = totalWidth + this.options.marginLeft + this.options.marginRight;
  2275. this.canvas.height = maxHeight;
  2276. // Paint the canvas
  2277. ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  2278. if (this.options.background) {
  2279. ctx.fillStyle = this.options.background;
  2280. ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
  2281. }
  2282. ctx.translate(this.options.marginLeft, 0);
  2283. }
  2284. }, {
  2285. key: "drawCanvasBarcode",
  2286. value: function drawCanvasBarcode(options, encoding) {
  2287. // Get the canvas context
  2288. var ctx = this.canvas.getContext("2d");
  2289. var binary = encoding.data;
  2290. // Creates the barcode out of the encoded binary
  2291. var yFrom;
  2292. if (options.textPosition == "top") {
  2293. yFrom = options.marginTop + options.fontSize + options.textMargin;
  2294. } else {
  2295. yFrom = options.marginTop;
  2296. }
  2297. ctx.fillStyle = options.lineColor;
  2298. for (var b = 0; b < binary.length; b++) {
  2299. var x = b * options.width + encoding.barcodePadding;
  2300. if (binary[b] === "1") {
  2301. ctx.fillRect(x, yFrom, options.width, options.height);
  2302. } else if (binary[b]) {
  2303. ctx.fillRect(x, yFrom, options.width, options.height * binary[b]);
  2304. }
  2305. }
  2306. }
  2307. }, {
  2308. key: "drawCanvasText",
  2309. value: function drawCanvasText(options, encoding) {
  2310. // Get the canvas context
  2311. var ctx = this.canvas.getContext("2d");
  2312. var font = options.fontOptions + " " + options.fontSize + "px " + options.font;
  2313. // Draw the text if displayValue is set
  2314. if (options.displayValue) {
  2315. var x, y;
  2316. if (options.textPosition == "top") {
  2317. y = options.marginTop + options.fontSize - options.textMargin;
  2318. } else {
  2319. y = options.height + options.textMargin + options.marginTop + options.fontSize;
  2320. }
  2321. ctx.font = font;
  2322. // Draw the text in the correct X depending on the textAlign option
  2323. if (options.textAlign == "left" || encoding.barcodePadding > 0) {
  2324. x = 0;
  2325. ctx.textAlign = 'left';
  2326. } else if (options.textAlign == "right") {
  2327. x = encoding.width - 1;
  2328. ctx.textAlign = 'right';
  2329. }
  2330. // In all other cases, center the text
  2331. else {
  2332. x = encoding.width / 2;
  2333. ctx.textAlign = 'center';
  2334. }
  2335. ctx.fillText(encoding.text, x, y);
  2336. }
  2337. }
  2338. }, {
  2339. key: "moveCanvasDrawing",
  2340. value: function moveCanvasDrawing(encoding) {
  2341. var ctx = this.canvas.getContext("2d");
  2342. ctx.translate(encoding.width, 0);
  2343. }
  2344. }, {
  2345. key: "restoreCanvas",
  2346. value: function restoreCanvas() {
  2347. // Get the canvas context
  2348. var ctx = this.canvas.getContext("2d");
  2349. ctx.restore();
  2350. }
  2351. }]);
  2352. return CanvasRenderer;
  2353. }();
  2354. exports.default = CanvasRenderer;
  2355. /***/ }),
  2356. /* 45 */
  2357. /***/ (function(module, exports, __webpack_require__) {
  2358. "use strict";
  2359. Object.defineProperty(exports, "__esModule", {
  2360. value: true
  2361. });
  2362. exports.getTotalWidthOfEncodings = exports.calculateEncodingAttributes = exports.getBarcodePadding = exports.getEncodingHeight = exports.getMaximumHeightOfEncodings = undefined;
  2363. var _merge = __webpack_require__(36);
  2364. var _merge2 = _interopRequireDefault(_merge);
  2365. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2366. function getEncodingHeight(encoding, options) {
  2367. return options.height + (options.displayValue && encoding.text.length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
  2368. }
  2369. function getBarcodePadding(textWidth, barcodeWidth, options) {
  2370. if (options.displayValue && barcodeWidth < textWidth) {
  2371. if (options.textAlign == "center") {
  2372. return Math.floor((textWidth - barcodeWidth) / 2);
  2373. } else if (options.textAlign == "left") {
  2374. return 0;
  2375. } else if (options.textAlign == "right") {
  2376. return Math.floor(textWidth - barcodeWidth);
  2377. }
  2378. }
  2379. return 0;
  2380. }
  2381. function calculateEncodingAttributes(encodings, barcodeOptions, context) {
  2382. for (var i = 0; i < encodings.length; i++) {
  2383. var encoding = encodings[i];
  2384. var options = (0, _merge2.default)(barcodeOptions, encoding.options);
  2385. // Calculate the width of the encoding
  2386. var textWidth;
  2387. if (options.displayValue) {
  2388. textWidth = messureText(encoding.text, options, context);
  2389. } else {
  2390. textWidth = 0;
  2391. }
  2392. var barcodeWidth = encoding.data.length * options.width;
  2393. encoding.width = Math.ceil(Math.max(textWidth, barcodeWidth));
  2394. encoding.height = getEncodingHeight(encoding, options);
  2395. encoding.barcodePadding = getBarcodePadding(textWidth, barcodeWidth, options);
  2396. }
  2397. }
  2398. function getTotalWidthOfEncodings(encodings) {
  2399. var totalWidth = 0;
  2400. for (var i = 0; i < encodings.length; i++) {
  2401. totalWidth += encodings[i].width;
  2402. }
  2403. return totalWidth;
  2404. }
  2405. function getMaximumHeightOfEncodings(encodings) {
  2406. var maxHeight = 0;
  2407. for (var i = 0; i < encodings.length; i++) {
  2408. if (encodings[i].height > maxHeight) {
  2409. maxHeight = encodings[i].height;
  2410. }
  2411. }
  2412. return maxHeight;
  2413. }
  2414. function messureText(string, options, context) {
  2415. var ctx;
  2416. if (context) {
  2417. ctx = context;
  2418. } else if (typeof document !== "undefined") {
  2419. ctx = document.createElement("canvas").getContext("2d");
  2420. } else {
  2421. // If the text cannot be messured we will return 0.
  2422. // This will make some barcode with big text render incorrectly
  2423. return 0;
  2424. }
  2425. ctx.font = options.fontOptions + " " + options.fontSize + "px " + options.font;
  2426. // Calculate the width of the encoding
  2427. var measureTextResult = ctx.measureText(string);
  2428. if (!measureTextResult) {
  2429. // Some implementations don't implement measureText and return undefined.
  2430. // If the text cannot be measured we will return 0.
  2431. // This will make some barcode with big text render incorrectly
  2432. return 0;
  2433. }
  2434. var size = measureTextResult.width;
  2435. return size;
  2436. }
  2437. exports.getMaximumHeightOfEncodings = getMaximumHeightOfEncodings;
  2438. exports.getEncodingHeight = getEncodingHeight;
  2439. exports.getBarcodePadding = getBarcodePadding;
  2440. exports.calculateEncodingAttributes = calculateEncodingAttributes;
  2441. exports.getTotalWidthOfEncodings = getTotalWidthOfEncodings;
  2442. /***/ }),
  2443. /* 46 */
  2444. /***/ (function(module, exports, __webpack_require__) {
  2445. "use strict";
  2446. Object.defineProperty(exports, "__esModule", {
  2447. value: true
  2448. });
  2449. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2450. var _merge = __webpack_require__(36);
  2451. var _merge2 = _interopRequireDefault(_merge);
  2452. var _shared = __webpack_require__(45);
  2453. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2454. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2455. var svgns = "http://www.w3.org/2000/svg";
  2456. var SVGRenderer = function () {
  2457. function SVGRenderer(svg, encodings, options) {
  2458. _classCallCheck(this, SVGRenderer);
  2459. this.svg = svg;
  2460. this.encodings = encodings;
  2461. this.options = options;
  2462. this.document = options.xmlDocument || document;
  2463. }
  2464. _createClass(SVGRenderer, [{
  2465. key: "render",
  2466. value: function render() {
  2467. var currentX = this.options.marginLeft;
  2468. this.prepareSVG();
  2469. for (var i = 0; i < this.encodings.length; i++) {
  2470. var encoding = this.encodings[i];
  2471. var encodingOptions = (0, _merge2.default)(this.options, encoding.options);
  2472. var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
  2473. this.setGroupOptions(group, encodingOptions);
  2474. this.drawSvgBarcode(group, encodingOptions, encoding);
  2475. this.drawSVGText(group, encodingOptions, encoding);
  2476. currentX += encoding.width;
  2477. }
  2478. }
  2479. }, {
  2480. key: "prepareSVG",
  2481. value: function prepareSVG() {
  2482. // Clear the SVG
  2483. while (this.svg.firstChild) {
  2484. this.svg.removeChild(this.svg.firstChild);
  2485. }
  2486. (0, _shared.calculateEncodingAttributes)(this.encodings, this.options);
  2487. var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings);
  2488. var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings);
  2489. var width = totalWidth + this.options.marginLeft + this.options.marginRight;
  2490. this.setSvgAttributes(width, maxHeight);
  2491. if (this.options.background) {
  2492. this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute("style", "fill:" + this.options.background + ";");
  2493. }
  2494. }
  2495. }, {
  2496. key: "drawSvgBarcode",
  2497. value: function drawSvgBarcode(parent, options, encoding) {
  2498. var binary = encoding.data;
  2499. // Creates the barcode out of the encoded binary
  2500. var yFrom;
  2501. if (options.textPosition == "top") {
  2502. yFrom = options.fontSize + options.textMargin;
  2503. } else {
  2504. yFrom = 0;
  2505. }
  2506. var barWidth = 0;
  2507. var x = 0;
  2508. for (var b = 0; b < binary.length; b++) {
  2509. x = b * options.width + encoding.barcodePadding;
  2510. if (binary[b] === "1") {
  2511. barWidth++;
  2512. } else if (barWidth > 0) {
  2513. this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent);
  2514. barWidth = 0;
  2515. }
  2516. }
  2517. // Last draw is needed since the barcode ends with 1
  2518. if (barWidth > 0) {
  2519. this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent);
  2520. }
  2521. }
  2522. }, {
  2523. key: "drawSVGText",
  2524. value: function drawSVGText(parent, options, encoding) {
  2525. var textElem = this.document.createElementNS(svgns, 'text');
  2526. // Draw the text if displayValue is set
  2527. if (options.displayValue) {
  2528. var x, y;
  2529. textElem.setAttribute("style", "font:" + options.fontOptions + " " + options.fontSize + "px " + options.font);
  2530. if (options.textPosition == "top") {
  2531. y = options.fontSize - options.textMargin;
  2532. } else {
  2533. y = options.height + options.textMargin + options.fontSize;
  2534. }
  2535. // Draw the text in the correct X depending on the textAlign option
  2536. if (options.textAlign == "left" || encoding.barcodePadding > 0) {
  2537. x = 0;
  2538. textElem.setAttribute("text-anchor", "start");
  2539. } else if (options.textAlign == "right") {
  2540. x = encoding.width - 1;
  2541. textElem.setAttribute("text-anchor", "end");
  2542. }
  2543. // In all other cases, center the text
  2544. else {
  2545. x = encoding.width / 2;
  2546. textElem.setAttribute("text-anchor", "middle");
  2547. }
  2548. textElem.setAttribute("x", x);
  2549. textElem.setAttribute("y", y);
  2550. textElem.appendChild(this.document.createTextNode(encoding.text));
  2551. parent.appendChild(textElem);
  2552. }
  2553. }
  2554. }, {
  2555. key: "setSvgAttributes",
  2556. value: function setSvgAttributes(width, height) {
  2557. var svg = this.svg;
  2558. svg.setAttribute("width", width + "px");
  2559. svg.setAttribute("height", height + "px");
  2560. svg.setAttribute("x", "0px");
  2561. svg.setAttribute("y", "0px");
  2562. svg.setAttribute("viewBox", "0 0 " + width + " " + height);
  2563. svg.setAttribute("xmlns", svgns);
  2564. svg.setAttribute("version", "1.1");
  2565. svg.setAttribute("style", "transform: translate(0,0)");
  2566. }
  2567. }, {
  2568. key: "createGroup",
  2569. value: function createGroup(x, y, parent) {
  2570. var group = this.document.createElementNS(svgns, 'g');
  2571. group.setAttribute("transform", "translate(" + x + ", " + y + ")");
  2572. parent.appendChild(group);
  2573. return group;
  2574. }
  2575. }, {
  2576. key: "setGroupOptions",
  2577. value: function setGroupOptions(group, options) {
  2578. group.setAttribute("style", "fill:" + options.lineColor + ";");
  2579. }
  2580. }, {
  2581. key: "drawRect",
  2582. value: function drawRect(x, y, width, height, parent) {
  2583. var rect = this.document.createElementNS(svgns, 'rect');
  2584. rect.setAttribute("x", x);
  2585. rect.setAttribute("y", y);
  2586. rect.setAttribute("width", width);
  2587. rect.setAttribute("height", height);
  2588. parent.appendChild(rect);
  2589. return rect;
  2590. }
  2591. }]);
  2592. return SVGRenderer;
  2593. }();
  2594. exports.default = SVGRenderer;
  2595. /***/ }),
  2596. /* 47 */
  2597. /***/ (function(module, exports, __webpack_require__) {
  2598. "use strict";
  2599. Object.defineProperty(exports, "__esModule", {
  2600. value: true
  2601. });
  2602. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2603. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2604. var ObjectRenderer = function () {
  2605. function ObjectRenderer(object, encodings, options) {
  2606. _classCallCheck(this, ObjectRenderer);
  2607. this.object = object;
  2608. this.encodings = encodings;
  2609. this.options = options;
  2610. }
  2611. _createClass(ObjectRenderer, [{
  2612. key: "render",
  2613. value: function render() {
  2614. this.object.encodings = this.encodings;
  2615. }
  2616. }]);
  2617. return ObjectRenderer;
  2618. }();
  2619. exports.default = ObjectRenderer;
  2620. /***/ }),
  2621. /* 48 */
  2622. /***/ (function(module, exports, __webpack_require__) {
  2623. "use strict";
  2624. Object.defineProperty(exports, "__esModule", {
  2625. value: true
  2626. });
  2627. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2628. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  2629. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  2630. var InvalidInputException = function (_Error) {
  2631. _inherits(InvalidInputException, _Error);
  2632. function InvalidInputException(symbology, input) {
  2633. _classCallCheck(this, InvalidInputException);
  2634. var _this = _possibleConstructorReturn(this, (InvalidInputException.__proto__ || Object.getPrototypeOf(InvalidInputException)).call(this));
  2635. _this.name = "InvalidInputException";
  2636. _this.symbology = symbology;
  2637. _this.input = input;
  2638. _this.message = '"' + _this.input + '" is not a valid input for ' + _this.symbology;
  2639. return _this;
  2640. }
  2641. return InvalidInputException;
  2642. }(Error);
  2643. var InvalidElementException = function (_Error2) {
  2644. _inherits(InvalidElementException, _Error2);
  2645. function InvalidElementException() {
  2646. _classCallCheck(this, InvalidElementException);
  2647. var _this2 = _possibleConstructorReturn(this, (InvalidElementException.__proto__ || Object.getPrototypeOf(InvalidElementException)).call(this));
  2648. _this2.name = "InvalidElementException";
  2649. _this2.message = "Not supported type to render on";
  2650. return _this2;
  2651. }
  2652. return InvalidElementException;
  2653. }(Error);
  2654. var NoElementException = function (_Error3) {
  2655. _inherits(NoElementException, _Error3);
  2656. function NoElementException() {
  2657. _classCallCheck(this, NoElementException);
  2658. var _this3 = _possibleConstructorReturn(this, (NoElementException.__proto__ || Object.getPrototypeOf(NoElementException)).call(this));
  2659. _this3.name = "NoElementException";
  2660. _this3.message = "No element to render on.";
  2661. return _this3;
  2662. }
  2663. return NoElementException;
  2664. }(Error);
  2665. exports.InvalidInputException = InvalidInputException;
  2666. exports.InvalidElementException = InvalidElementException;
  2667. exports.NoElementException = NoElementException;
  2668. /***/ }),
  2669. /* 49 */
  2670. /***/ (function(module, exports, __webpack_require__) {
  2671. "use strict";
  2672. Object.defineProperty(exports, "__esModule", {
  2673. value: true
  2674. });
  2675. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2676. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2677. /*eslint no-console: 0 */
  2678. var ErrorHandler = function () {
  2679. function ErrorHandler(api) {
  2680. _classCallCheck(this, ErrorHandler);
  2681. this.api = api;
  2682. }
  2683. _createClass(ErrorHandler, [{
  2684. key: "handleCatch",
  2685. value: function handleCatch(e) {
  2686. // If babel supported extending of Error in a correct way instanceof would be used here
  2687. if (e.name === "InvalidInputException") {
  2688. if (this.api._options.valid !== this.api._defaults.valid) {
  2689. this.api._options.valid(false);
  2690. } else {
  2691. throw e.message;
  2692. }
  2693. } else {
  2694. throw e;
  2695. }
  2696. this.api.render = function () {};
  2697. }
  2698. }, {
  2699. key: "wrapBarcodeCall",
  2700. value: function wrapBarcodeCall(func) {
  2701. try {
  2702. var result = func.apply(undefined, arguments);
  2703. this.api._options.valid(true);
  2704. return result;
  2705. } catch (e) {
  2706. this.handleCatch(e);
  2707. return this.api;
  2708. }
  2709. }
  2710. }]);
  2711. return ErrorHandler;
  2712. }();
  2713. exports.default = ErrorHandler;
  2714. /***/ })
  2715. /******/ ]);