@mescius/wijmo.barcode 5.20261.45-nightly.d20251218.t163151 → 5.20261.45-nightly.d20260105.t163143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +19 -19
- package/index.js +2 -2
- package/package.json +2 -2
package/es2015-commonjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.barcode")),alignmentMap={center:"middle",left:"start",right:"end"};class SVGRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.scale=i;this.color="rgb(0,0,0)";this.addGroup()}setColor(t){this.color=t}setBackgroundColor(t){const{dom:e}=this;e.style.backgroundColor=t}addGroup(){const{dom:t}=this;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)}drawRect(t){const{g:e,scale:i,color:o}=this,r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("x",(t.x*i).toString());r.setAttribute("y",(t.y*i).toString());r.setAttribute("width",(t.width*i).toString());r.setAttribute("height",(t.height*i).toString());r.style.fill=o;e.appendChild(r)}drawText(t){const{g:e,scale:i,color:o,style:r}=this,s=document.createElementNS("http://www.w3.org/2000/svg","text");s.style.fill=o;s.style.fontSize=r.fontSize;s.style.fontFamily=r.fontFamily;s.style.fontStyle=t.fontStyle||r.fontStyle;s.style.fontWeight=t.fontWeight||r.fontWeight;s.style.textDecoration=t.textDecoration||r.textDecoration;s.style.textAnchor=alignmentMap[t.textAlign||r.textAlign];s.textContent=t.text;s.textContent=this.clipString(t,s);const n=this._measureText(s);s.setAttribute("y",(t.y*i+Math.abs(n.y)).toString());s.setAttribute("x",(t.x*i).toString());e.appendChild(s)}clipString(t,e){const{scale:i}=this;let{text:o,maxWidth:r}=t;const s=this._measureText(e);r*=i;if(s.width>r){const e=Math.floor(r/s.width*o.length);return t.text.substr(0,e)}return o}clear(){const{dom:t}=this;t.removeChild(this.g);this.addGroup()}_measureText(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);const i=t.getBBox();document.body.removeChild(e);return i}getDataUrl(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)}}exports.SVGRenderContext=SVGRenderContext;class CanvasRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=i}setColor(t){this.ctx.fillStyle=t}setBackgroundColor(t){const{ctx:e,dom:i}=this;e.save();e.fillStyle=t;e.fillRect(0,0,i.width,i.height);e.restore()}drawRect(t){const{ctx:e,scale:i}=this;e.fillRect(t.x*i,t.y*i,t.width*i,t.height*i)}drawText(t){const{ctx:e,style:i,scale:o}=this;e.save();e.font=`${t.fontStyle||i.fontStyle} ${t.fontWeight||i.fontWeight} ${i.fontSize} ${i.fontFamily}`;e.textAlign=t.textAlign||i.textAlign;e.textBaseline="bottom";const r=t.x*o,s=t.y*o,n=this.clipString(t);e.fillText(n,r,s+i.fontHeight);this.drawTextDecorationLine(n,r,s,t.textDecoration||i.textDecoration);e.restore()}clipString(t){const{ctx:e,scale:i}=this;let{text:o,maxWidth:r}=t;const s=e.measureText(o);r*=i;if(s.width>r){const e=Math.floor(r/s.width*o.length);return t.text.substr(0,e)}return o}drawTextDecorationLine(t,e,i,o){let r;switch(o){case"underline":r=.9;break;case"overline":r=.1;break;case"line-through":r=.5;break;default:return}const{ctx:s,style:{fontHeight:n}}=this;let a=s.measureText(t).width;switch(s.textAlign){case"center":e-=a/2;break;case"right":e-=a}s.lineWidth=1;s.beginPath();let h=n*r+i;s.moveTo(e,h);s.lineTo(e+a,h);s.stroke()}clear(){const{ctx:t,dom:e}=this;t.clearRect(0,0,e.width,e.height)}getImageData(){const{ctx:t,dom:e}=this;return t.getImageData(0,0,e.width,e.height)}getDataUrl(){return this.dom.toDataURL()}}exports.CanvasRenderContext=CanvasRenderContext;var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode=exports._errorCode||(exports._errorCode={}));class BaseException extends Error{constructor(t){super();this.code=t||_errorCode.Unknown}}exports.BaseException=BaseException;exports.ErrorCode=_errorCode;class InvalidOptionsException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidOptions);this.name="InvalidOptionsException";this.message=`${JSON.stringify(t)} is not valid options. ${e}`;this.descriptor={source:t,message:this.message}}}exports.InvalidOptionsException=InvalidOptionsException;class InvalidBarcodeTypeException extends BaseException{constructor(t){super(_errorCode.InvalidBarcodeType);this.name="InvalidBarcodeTypeException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}exports.InvalidBarcodeTypeException=InvalidBarcodeTypeException;class InvalidRenderException extends BaseException{constructor(t){super(_errorCode.InvalidRenderType);this.name="InvalidRenderException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}exports.InvalidRenderException=InvalidRenderException;class MethodNotImplementException extends BaseException{constructor(t,e){super(_errorCode.MethodNotImplement);this.name="MethodNotImplementException";this.message=`${t} is not a method! ${e}`;this.descriptor={source:t,message:this.message}}}exports.MethodNotImplementException=MethodNotImplementException;class InvalidTextException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidText);this.name="InvalidTextException";this.message=t?`${t} is invalid. ${e}`:"Text is required.";this.descriptor={source:t,message:this.message}}}exports.InvalidTextException=InvalidTextException;class InvalidCharacterException extends BaseException{constructor(t){super(_errorCode.InvalidCharacter);this.name="InvalidCharacterException";this.message=t+" is invalid.";this.descriptor={source:t,message:this.message}}}exports.InvalidCharacterException=InvalidCharacterException;class TextTooLongException extends BaseException{constructor(){super(_errorCode.TextTooLong);this.name="TextTooLongException";this.message="Text is too long to encode";this.descriptor={source:null,message:this.message}}}exports.TextTooLongException=TextTooLongException;class GroupSizeOverflowException extends BaseException{constructor(t){super(_errorCode.GroupSizeOverflow);this.name="GroupSizeOverflowException";this.message=`Group size is ${t}. The max group size is 9.`;this.descriptor={source:t,message:this.message}}}exports.GroupSizeOverflowException=GroupSizeOverflowException;function createRenderDom(t,e){let i;if("svg"===t){i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg")}else i=document.createElement("canvas");i.setAttribute("width",e.width);i.setAttribute("height",e.height);return i}class BarcodeRender{constructor(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;let i=this.style.unitValue;this.size={width:e.size.width*i,height:e.size.height*i};let o=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(o,this.style,i);break;case"canvas":this.context=new CanvasRenderContext(o,this.style,i);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(o);this.renderDom=o}render(){const{style:t,barcode:{shapes:e}}=this,i=this.context;i.clear();i.setColor(t.color);i.setBackgroundColor(t.backgroundColor);e.forEach(t=>{"rect"===t.type&&i.drawRect(t);"text"===t.type&&i.drawText(t)});return this}getImageData(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()}getDataUrl(){return this.context.getDataUrl()}destroy(){this.container&&this.container.removeChild(this.renderDom)}getSize(){return this.size}}exports.BarcodeRender=BarcodeRender;function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t="",e=1,i){let o=0,r=t.length,s=0;for(;o<r;){i(t.substring(o,o+e),s);o+=e;s++}}function sliceArray(t=[],e=1,i){let o=0,r=t.length,s=0;for(;o<r;){i(t.slice(o,o+e),s);o+=e;s++}}function str2Array(t=""){return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t=""){let e=str2Array(t),i=[];e.forEach(t=>{if("0"===t)i.push(0);else if(i[i.length-1]&&0!==i[i.length]){let t=i.pop();i.push(++t)}else i.push(1)});return i}function convertRadix(t,e=2){return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t="",e=0){if("number"==typeof t)return t;let i=parseFloat(t);return isNaN(i)?e:i}function getUnit(t=""){let e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e="length"){let i=0;t.forEach(t=>{t[e]>i&&(i=t[e])});return i}function assign(t,...e){if(isFunction(Object.assign))return Object.assign(t,...e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");let i=Object(t);for(let t=0;t<e.length;t++){let o=e[t];if(null!=o)for(let t in o)Object.prototype.hasOwnProperty.call(o,t)&&(i[t]=o[t])}return i}function deepMerge(t,...e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach(e=>{if(e)for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(null!=e[i]&&"object"==typeof e[i]&&"object"==typeof t[i]?t[i]=deepMerge({},t[i]||{},e[i]):t[i]=e[i])});return t}function deepMergeAll(...t){return deepMerge({},...t)}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);let i=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==i.length||0==e)return"";if(i.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");let o="";for(let t=0;t<e;t++)o+=i;return o}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(let i=0;i<t.length;i++)t[i]=e;return t}function strPadStart(t,e,i){if(isFunction(t.padStart))return t.padStart(e,i);e>>=0;i=String(void 0!==i?i:" ");if(t.length>e)return t;(e-=t.length)>i.length&&(i+=strRepeat(i,e/i.length));return i.slice(0,e)+String(t)}const plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){let i,o;if(isFinite(e)){i=0;o=e}else{i=e.from;o=e.to+1}for(;i<o;i++)t(i)}function toZeroOnePattern(t,e){const i=e?isEven:isOdd;return t.reduce((t,e,o)=>{i(o)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t},"")}function range(t,e){const i=[];for(;t<e;){i.push(t);t++}i.push(e);return i}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});const e=Object.keys(t).reduce((e,i)=>{e[t[i]]=i;return e},{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}exports.Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};class Option{constructor(t={}){this.originConfig=t;this.type=t.type;this.penddingMerge=[]}static setCustomDefaultOptions(t){Option.CustomDefaultOptions=t}spawn(t){return new Option(exports.Utils.deepMergeAll(this.originConfig,t))}merge(t){this.penddingMerge.unshift(t)}_getUnitValue(t){t=exports.Utils.fixSize2PixelDefault(t);return exports.Utils.convertUnit(t)}getMergedOption(){return exports.Utils.deepMergeAll(Option.DefaultOptions,...this.penddingMerge,Option.CustomDefaultOptions,this.originConfig)}getConfig(t){const e=this.getMergedOption();let{text:i,quietZone:o,height:r,labelPosition:s,desiredSize:n,showLabel:a,font:h,backgroundColor:l,color:c,renderType:d,unitSize:p,hideExtraChecksum:u}=e;const g={text:i,isLabelBottom:!1,hideExtraChecksum:u};if(!exports.Utils.isDefined(i))throw new InvalidTextException;g.text+="";exports.Utils.isDefined(s)&&(g.isLabelBottom="top"!==s);h=exports.Utils.deepMergeAll(h);h.fontSize=exports.Utils.fixSize2PixelDefault(h.fontSize);const f=exports.Utils.measureText(i,h);g.showLabel=a;t=t||this._getUnitValue(p);const x=a?f/t:0;g.fontSizeInUnit=x;const m={};for(let e in o)if(o.hasOwnProperty(e)){let i=o[e];if(exports.Utils.isNumberLike(i)){const t=+i;m[e]=t}else{let o=exports.Utils.convertUnit(i);m[e]=o/t}}g.quietZone=m;if(n){g.containerWidth=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(n.width));g.containerHeight=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(n.height));g.desiredSize=n}if(exports.Utils.isDefined(r))if(n){let e=a?g.containerHeight-f:g.containerHeight;g.height=e/t-m.top-m.bottom}else exports.Utils.isNumberLike(r)?g.height=+r-x-m.top-m.bottom:g.height=exports.Utils.convertUnit(r)/t-x-m.top-m.bottom;return{config:e,encodeConfig:g,style:exports.Utils.deepMergeAll({backgroundColor:l,color:c,renderType:d,unitValue:t,fontSize:h.fontSize,fontHeight:f},h)}}getOriginConfig(){return this.originConfig}getType(){return this.type}}Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};exports.Option=Option;function _getProtos(t){var e=[];if(t&&t instanceof Function){let i=t;e.push(i);for(;i;){const t=Object.getPrototypeOf(i);if(!t||t===Object||t===Function.prototype)break;i=t;e.push(i)}}return e}function _getDefaultConfig(t,e){var i=[{type:e}];_getProtos(t).forEach(t=>{t.DefaultConfig&&i.unshift(t.DefaultConfig)});return exports.Utils.deepMergeAll(Option.DefaultOptions,...i,Option.CustomDefaultOptions)}exports._getDefaultConfig=_getDefaultConfig;class _EnumDictionary{constructor(t,e){this._keys={};this._values={};for(let r in t)if("string"==typeof t[r]){var i=parseInt(r),o=e(t[i]);this._keys[i]=o;this._values[o]=i}}getEnumByString(t){var e=this._values[t];if(void 0===e)throw`Unknown Barcode internal value '${t}'`;return e}getStringByEnum(t){return this._keys[t]}}exports._EnumDictionary=_EnumDictionary;class Area{constructor(t=0,e=0){this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}append(t){this.children.push(t)}_makeRect(t,e,i,o){return{x:t,y:e,height:o,width:i,type:"rect"}}toShapes(){const{x:t,y:e,width:i,height:o,style:{border:r,margin:s}}=this,n=[],a=r.left+r.right+i,h=r.top+r.bottom+o,l=t+s.left,c=e+s.top;r.top&&n.push(this._makeRect(l,c,a,r.top));r.right&&n.push(this._makeRect(l+a-r.right,c,r.right,h));r.bottom&&n.push(this._makeRect(l,c+h-r.bottom,a,r.bottom));r.left&&n.push(this._makeRect(l,c,r.left,h));return n}getSize(){const{width:t,height:e,offsetBox:i}=this;return{width:t+i.width,height:e+i.height}}visiable(){return this.width>0&&this.height>0}setX(t){this.x=t;this._updateBox()}setY(t){this.y=t;this._updateBox()}updateContentSize(t,e){this.width=t;this.height=e;this._updateBox()}_fixOpt(t,e){if(exports.Utils.isNumberLike(t[e])){const i=t[e];t[e]={top:i,right:i,bottom:i,left:i}}}setStyle(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=exports.Utils.deepMergeAll(this.style,t);this._updateBox()}_updateBox(){const{x:t,y:e,width:i,height:o,style:{padding:r,border:s,margin:n}}=this;this.offsetBox={x:t+r.left+s.left+n.left,y:e+r.top+s.top+n.top,width:n.left+s.left+s.right+n.right,height:n.top+s.top+s.bottom+n.bottom};const a=i-r.left-r.right,h=o-r.top-r.bottom;this.contentBox={width:a>=0?a:0,height:h>=0?h:0}}}exports.Area=Area;class HorizontalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this;let i=super.toShapes();const o=e.y;let r=0;t.forEach(t=>{const s=e.x+r;t.toShapes().forEach(t=>{t.x+=s;t.y+=o;i.push(t)});const n=t.getSize();r+=n.width});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.height=Math.max(i.height,t.height);t.width+=i.width;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}exports.HorizontalLayoutArea=HorizontalLayoutArea;class VerticalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this;let i=super.toShapes();const o=e.x;let r=0;t.forEach(t=>{const s=e.y+r;t.toShapes().forEach(t=>{t.x+=o;t.y+=s;i.push(t)});const n=t.getSize();r+=n.height});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.width=Math.max(i.width,t.width);t.height+=i.height;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}exports.VerticalLayoutArea=VerticalLayoutArea;class MatrixSymbolArea extends Area{constructor(t,e,i){super(t,e);this._xPosition=0;this._yPosition=0;this._lastMaxHeight=0;this._rowHeight=0;this._rowHeight=i}append(t,e){if(!t||!e)return;this._autoWrap(t);const{children:i,_xPosition:o,_yPosition:r}=this,s={width:t,height:e,x:o,y:r};i.push(s);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}_autoWrap(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}}_checkNeedWrap(t){const{_xPosition:e,contentBox:{width:i}}=this;return i-e-t<0}space(t=1){this._autoWrap(t);this._xPosition+=t}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e}=this,i=super.toShapes();e.forEach(e=>{e.x+=t.x;e.y+=t.y;e.type="rect";i.push(e)});return i}}exports.MatrixSymbolArea=MatrixSymbolArea;class SymbolArea extends Area{constructor(t,e){super(t,e);this._lastIsBar=!1;this._cacheNumber=0;this._position=0}append(t,e,i){if(!t)return;const{children:o,_position:r}=this,s={width:t,x:r,barHeight:e,offsetY:i};o.push(s);this._position+=t}space(t=1){this._position+=t}_appendModule(t){const e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++}_flash(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}}fromPattern(t){exports.Utils.str2Array(t).forEach(t=>this._appendModule(t));this._flash()}getContentBox(){return this.contentBox}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,contentBox:{height:i}}=this,o=super.toShapes();e.forEach(e=>{o.push({type:"rect",x:e.x+t.x,y:t.y+(e.offsetY||0),width:e.width,height:e.barHeight||i})});return o}}exports.SymbolArea=SymbolArea;class LabelArea extends Area{constructor(t,e,i){super(t,e);this._textAlign=i}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,_textAlign:i,contentBox:{width:o}}=this,r=super.toShapes();e.forEach(e=>{let s=t.x;switch(i){case"center":s+=o/2;break;case"right":s+=o}r.push({x:s+(e.x||0),y:t.y+(e.y||0),textAlign:i,maxWidth:o,type:"text",text:e.text})});return r}}exports.LabelArea=LabelArea;class MatrixBuilder{constructor(t,e){this.data=[];this.data=[];this.row=t;this.col=e}add(t,e,i){(this.data[t]||exports.Utils.fillArray(new Array(this.col),null))[e]=i;this.data[t]=[]}toMatrix(){const t=[];exports.Utils.loop(e=>{t.push(this.data[e]||exports.Utils.fillArray(new Array(this.col),null))},this.row);return t}}exports.MatrixBuilder=MatrixBuilder;class BitBuffer{constructor(t=[]){this.buffer=t;this.length=8*t.length;this.index=0}putBit(t){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1}putBitAt(t,e){const{length:i}=this,o=new BitBuffer;for(let r=0;r<i;r++)r===e?o.putBit(t):o.putBit(this.getAt(r));this.buffer=o.buffer;this.length=o.length}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBits(t){this.put(parseInt(t,2),t.length)}getAt(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)}getBuffer(){return this.buffer}getGroupedBits(t){let e=0;const i=[];for(;e<this.length;){let o="",r=e,s=e+t;for(;r<s;r++)o+=this.getAt(r)?1:0;e=s;i.push(parseInt(o,2))}return i}next(){this.index++;return this.getAt(this.index-1)}}exports.BitBuffer=BitBuffer;class BarcodeEncoder{constructor(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}validate(){}applyDesiredSize(t){const{config:e,encodeConfig:i,style:o}=this._option.getConfig(t);this.config=e;this.encodeConfig=i;this.style=o;this.useDesiredSize=!!i.desiredSize}afterApplyDesiredSize(){}toSymbol(){this.validate();const t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)}}exports.BarcodeEncoder=BarcodeEncoder;class TwoDimensionalBarcode extends BarcodeEncoder{adjustDesiredSize(){const{width:t,height:e}=this.size,{desiredSize:i,containerWidth:o,containerHeight:r}=this.encodeConfig;let s=Math.min(o/t,r/e);if(i.forceRounding){s=~~s;s=s<1?1:s}this.applyDesiredSize(s)}convertToShape(t,e){const{quietZone:i}=this.encodeConfig,o=t[0].length+i.right+i.left,r=t.length+i.top+i.bottom,s=new VerticalLayoutArea,n=new MatrixSymbolArea(o,r,1);n.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});s.append(n);if(!e){t.forEach(t=>{t.forEach(t=>{t?n.append(1,1):n.space()})});this.shapes=s.toShapes()}this.size=s.getSize()}}exports.TwoDimensionalBarcode=TwoDimensionalBarcode;class OneDimensionalBarcode extends BarcodeEncoder{constructor(t){t.merge(OneDimensionalBarcode.DefaultConfig);super(t);this.label=""}adjustDesiredSize(){const{width:t}=this.size;let{desiredSize:e,containerWidth:i}=this.encodeConfig,o=i/t;if(e.forceRounding){o=~~o;o=o<1?1:o}this.applyDesiredSize(o)}convertToShape(t,e){let{label:i,encodeConfig:{quietZone:o,isLabelBottom:r,height:s,showLabel:n,fontSizeInUnit:a},style:{textAlign:h}}=this,l=0;i&&n&&(l=a);const c=t.length+o.right+o.left,d=s+o.top+o.bottom,p=new VerticalLayoutArea,u=new SymbolArea(c,d);u.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});const g=u.getSize(),f=new LabelArea(g.width,l,h);if(r){p.append(u);p.append(f)}else{p.append(f);p.append(u)}if(!e){u.fromPattern(t);f.append({text:i});this.shapes=p.toShapes()}this.size=p.getSize()}}OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};exports.OneDimensionalBarcode=OneDimensionalBarcode;const FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";exports.Constants={FNC1:"Ï",FNC2:"Ê",FNC3:"É",DataMatrixFNC1:" ",DataMatrixMacro05:" ",DataMatrixMacro06:" "};exports.encoders={};class Barcode{constructor(...t){let e,i,o;if(t.length>=3)[e,i,o]=t;else if(2===t.length)exports.Utils.isFunction(t[1])?[i,o]=t:[e,i]=t;else{if(1!==t.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");[i]=t}this.dom="string"==typeof e?document.querySelector(e):e;this.callback=o&&o.bind(this);this.setOption(i)}static getImageData(t={}){return new Barcode(t).getImageData()}static getDataUrl(t={}){return new Barcode(t).getDataUrl()}static setDefaultOptions(t={}){Option.setCustomDefaultOptions(t)}static registerEncoder(t,e){exports.encoders[t]=e;Barcode.supportType.push(t)}static registerPlugin(t,e){exports.Utils.registerPlugin(t,e)}mergeOption(t){const e=this.option.spawn(t);this.update(e);return this}setOption(t){this.update(new Option(t));return this}getOption(){return this.option.getMergedOption()}update(t){const e=t.getType(),i=exports.encoders[e];if(!i)throw new InvalidBarcodeTypeException(e);const o=new i(t);this.destroy();const r=new BarcodeRender(this.dom,o);r.render();this.render=r;this.option=t;exports.Utils.isFunction(this.callback)&&this.callback()}refresh(){this.render.render();exports.Utils.isFunction(this.callback)&&this.callback()}getImageData(){return this.render.getImageData()}getDataUrl(){return this.render.getDataUrl()}getSize(){return this.render.getSize()}destroy(){if(this.render){this.render.destroy();this.render=null}}}Barcode.supportType=[];Barcode.constants=exports.Constants;Barcode.ErrorCode=exports.ErrorCode;exports.Barcode=Barcode;Barcode.registerPlugin("measureText",(function(t,e){const i=document.createElement("span");i.style.visibility="hidden";i.style.position="absolute";i.style.lineHeight="normal";i.textContent=t;Object.keys(e).forEach(t=>{i.style[t]=e[t]});document.body.appendChild(i);const o=i.getBoundingClientRect();document.body.removeChild(i);return o.height}));Barcode.registerPlugin("convertUnit",(function(t){const e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);const i=e.getBoundingClientRect();document.body.removeChild(e);return i.width}));exports.BarcodeClsNames={hostElement:"wj-barcode"};var RenderType,LabelPosition,NarrowToWideRatio;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType=exports.RenderType||(exports.RenderType={}));!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition=exports.LabelPosition||(exports.LabelPosition={}));!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio=exports.NarrowToWideRatio||(exports.NarrowToWideRatio={}));class _RenderTypeConvertor{static stringToEnum(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw`Unknown Barcode internal renderType '${t}'`}static enumToString(t){return RenderType[wijmo_1.asEnum(t,RenderType)].toLowerCase()}}exports._RenderTypeConvertor=_RenderTypeConvertor;class _LabelPositionConvertor{static stringToEnum(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw`Unknown Barcode internal labelPosition '${t}'`}static enumToString(t){return LabelPosition[wijmo_1.asEnum(t,LabelPosition)].toLowerCase()}}exports._LabelPositionConvertor=_LabelPositionConvertor;class _NarrowWideRatioConvertor{static stringToEnum(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw`Unknown nwRatio internal value '${t}'`}static enumToString(t){let e;switch(wijmo_1.asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e}}exports._NarrowWideRatioConvertor=_NarrowWideRatioConvertor;class BarcodeBase extends wijmo_1.Control{constructor(t,e){super(t,null,!0);this._state={};this._isUpd=0;this._isValid=!0;this._aw=!1;this._wZoom=1;this.isValidChanged=new wijmo_1.Event;let i=this.getTemplate();this.applyTemplate(`${exports.BarcodeClsNames.hostElement} ${wijmo_1.ControlClsNames.hostElement}`,i,{});wijmo_1.isIE()||(this.hostElement.style.lineHeight="0px");this._state=this._getDefaults();this._isUpd++;this.initialize(e);this._updateSize();this._isUpd--;this._mergeOptions({});this.invalidate()}static get controlTemplate(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate}static set controlTemplate(t){BarcodeBase._ctrlTemplate=t}initialize(t){this._isUpd++;try{super.initialize(t)}finally{this._isUpd--}!this._isUpd&&t&&Object.keys(t).length&&this._mergeOptions({})}static _getClassDefaults(){let t=this.type;return _getDefaultConfig(exports.encoders[t],t)}_getDefaults(){let t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return exports.Utils.deepMergeAll(t._defaults)}get value(){return this._getProp("text")}set value(t){this._setProp("text",t)}get quietZone(){return this._getProp("quietZone")}set quietZone(t){this._setProp("quietZone",t)}get renderType(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))}set renderType(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))}get color(){return this._getProp("color")}set color(t){this._setProp("color",t)}get backgroundColor(){return this._getProp("backgroundColor")}set backgroundColor(t){this._setProp("backgroundColor",t)}get hideExtraChecksum(){return this._getProp("hideExtraChecksum")}set hideExtraChecksum(t){this._setProp("hideExtraChecksum",t)}get font(){return this._getProp("font")}set font(t){this._setProp("font",t)}get isValid(){return this._isValid}onIsValidChanged(t){this.isValidChanged.raise(this,t)}refresh(t=!0){super.refresh(t);t?this._updateSize():this._bc.refresh()}getImageData(){return this._bc.getImageData()}getDataUrl(){return this._bc.getDataUrl()}getSize(){var t=new wijmo_1.Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t}_mergeOptions(t){let e,i=this._bc,o=_copyObj(this._state,t);if(!this._isUpd){let t=o.text;if(null==t||""===t){if(i){i.destroy();this._bc=i=null}}else try{i?i.setOption(o):this._bc=i=new Barcode(this.hostElement,o)}catch(t){e=t}}let r=!0;if(e){if(i){i.destroy();this._bc=i=null}if(e.code!==_errorCode.InvalidText)throw e;r=!1}this._state=o;this._setValid(r)}_setValid(t){if(this._isValid!==t){this._isValid=t;wijmo_1.toggleClass(this.hostElement,wijmo_1.ControlStateClsNames.invalid,!t);this.onIsValidChanged()}}_setProp(t,e){this._mergeOptions({[t]:e})}_getProp(t){let e=this._bc;return this._state[t]||e&&e.getOption()[t]}_updateSize(t=!0){if(!this.hostElement)return;let e=BarcodeBase._getContentSize(this.hostElement),i=this._prevSz,o=null,r=null,s=1,n=!0;if(this._getAw()){s=this._getWzoom();r=e.height/s;n=t&&r===this._prevH;this._prevH=r;i=this._prevSz=null}else if(t){if(!i||!e.equals(i)){o={width:e.width+"px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}}else{o={width:"0px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}n||this._mergeOptions({desiredSize:o,height:r,unitSize:s})}static _getContentSize(t){let e=getComputedStyle(t);return new wijmo_1.Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))}_getAw(){return this._aw}_setAw(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}}_getWzoom(){return this._wZoom}_setWzoom(t){wijmo_1.asNumber(t);wijmo_1.assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}}}BarcodeBase._ctrlTemplate="";exports.BarcodeBase=BarcodeBase;const _copyObj="function"==typeof Object.assign?Object.assign:function(t,...e){for(let i of e)if(null!=i)for(let e in i)t[e]=i[e];return t};wijmo_1._registerModule("wijmo.barcode",selfModule);
|
|
14
|
+
"use strict";var __importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.hasOwnProperty.call(t,i)&&(e[i]=t[i]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.barcode")),alignmentMap={center:"middle",left:"start",right:"end"};class SVGRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.scale=i;this.color="rgb(0,0,0)";this.addGroup()}setColor(t){this.color=t}setBackgroundColor(t){const{dom:e}=this;e.style.backgroundColor=t}addGroup(){const{dom:t}=this;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)}drawRect(t){const{g:e,scale:i,color:o}=this,r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("x",(t.x*i).toString());r.setAttribute("y",(t.y*i).toString());r.setAttribute("width",(t.width*i).toString());r.setAttribute("height",(t.height*i).toString());r.style.fill=o;e.appendChild(r)}drawText(t){const{g:e,scale:i,color:o,style:r}=this,s=document.createElementNS("http://www.w3.org/2000/svg","text");s.style.fill=o;s.style.fontSize=r.fontSize;s.style.fontFamily=r.fontFamily;s.style.fontStyle=t.fontStyle||r.fontStyle;s.style.fontWeight=t.fontWeight||r.fontWeight;s.style.textDecoration=t.textDecoration||r.textDecoration;s.style.textAnchor=alignmentMap[t.textAlign||r.textAlign];s.textContent=t.text;s.textContent=this.clipString(t,s);const n=this._measureText(s);s.setAttribute("y",(t.y*i+Math.abs(n.y)).toString());s.setAttribute("x",(t.x*i).toString());e.appendChild(s)}clipString(t,e){const{scale:i}=this;let{text:o,maxWidth:r}=t;const s=this._measureText(e);r*=i;if(s.width>r){const e=Math.floor(r/s.width*o.length);return t.text.substr(0,e)}return o}clear(){const{dom:t}=this;t.removeChild(this.g);this.addGroup()}_measureText(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);const i=t.getBBox();document.body.removeChild(e);return i}getDataUrl(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)}}exports.SVGRenderContext=SVGRenderContext;class CanvasRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=i}setColor(t){this.ctx.fillStyle=t}setBackgroundColor(t){const{ctx:e,dom:i}=this;e.save();e.fillStyle=t;e.fillRect(0,0,i.width,i.height);e.restore()}drawRect(t){const{ctx:e,scale:i}=this;e.fillRect(t.x*i,t.y*i,t.width*i,t.height*i)}drawText(t){const{ctx:e,style:i,scale:o}=this;e.save();e.font=`${t.fontStyle||i.fontStyle} ${t.fontWeight||i.fontWeight} ${i.fontSize} ${i.fontFamily}`;e.textAlign=t.textAlign||i.textAlign;e.textBaseline="bottom";const r=t.x*o,s=t.y*o,n=this.clipString(t);e.fillText(n,r,s+i.fontHeight);this.drawTextDecorationLine(n,r,s,t.textDecoration||i.textDecoration);e.restore()}clipString(t){const{ctx:e,scale:i}=this;let{text:o,maxWidth:r}=t;const s=e.measureText(o);r*=i;if(s.width>r){const e=Math.floor(r/s.width*o.length);return t.text.substr(0,e)}return o}drawTextDecorationLine(t,e,i,o){let r;switch(o){case"underline":r=.9;break;case"overline":r=.1;break;case"line-through":r=.5;break;default:return}const{ctx:s,style:{fontHeight:n}}=this,a=s.measureText(t).width;switch(s.textAlign){case"center":e-=a/2;break;case"right":e-=a}s.lineWidth=1;s.beginPath();const h=n*r+i;s.moveTo(e,h);s.lineTo(e+a,h);s.stroke()}clear(){const{ctx:t,dom:e}=this;t.clearRect(0,0,e.width,e.height)}getImageData(){const{ctx:t,dom:e}=this;return t.getImageData(0,0,e.width,e.height)}getDataUrl(){return this.dom.toDataURL()}}exports.CanvasRenderContext=CanvasRenderContext;var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode=exports._errorCode||(exports._errorCode={}));class BaseException extends Error{constructor(t){super();this.code=t||_errorCode.Unknown}}exports.BaseException=BaseException;exports.ErrorCode=_errorCode;class InvalidOptionsException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidOptions);this.name="InvalidOptionsException";this.message=`${JSON.stringify(t)} is not valid options. ${e}`;this.descriptor={source:t,message:this.message}}}exports.InvalidOptionsException=InvalidOptionsException;class InvalidBarcodeTypeException extends BaseException{constructor(t){super(_errorCode.InvalidBarcodeType);this.name="InvalidBarcodeTypeException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}exports.InvalidBarcodeTypeException=InvalidBarcodeTypeException;class InvalidRenderException extends BaseException{constructor(t){super(_errorCode.InvalidRenderType);this.name="InvalidRenderException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}exports.InvalidRenderException=InvalidRenderException;class MethodNotImplementException extends BaseException{constructor(t,e){super(_errorCode.MethodNotImplement);this.name="MethodNotImplementException";this.message=`${t} is not a method! ${e}`;this.descriptor={source:t,message:this.message}}}exports.MethodNotImplementException=MethodNotImplementException;class InvalidTextException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidText);this.name="InvalidTextException";this.message=t?`${t} is invalid. ${e}`:"Text is required.";this.descriptor={source:t,message:this.message}}}exports.InvalidTextException=InvalidTextException;class InvalidCharacterException extends BaseException{constructor(t){super(_errorCode.InvalidCharacter);this.name="InvalidCharacterException";this.message=t+" is invalid.";this.descriptor={source:t,message:this.message}}}exports.InvalidCharacterException=InvalidCharacterException;class TextTooLongException extends BaseException{constructor(){super(_errorCode.TextTooLong);this.name="TextTooLongException";this.message="Text is too long to encode";this.descriptor={source:null,message:this.message}}}exports.TextTooLongException=TextTooLongException;class GroupSizeOverflowException extends BaseException{constructor(t){super(_errorCode.GroupSizeOverflow);this.name="GroupSizeOverflowException";this.message=`Group size is ${t}. The max group size is 9.`;this.descriptor={source:t,message:this.message}}}exports.GroupSizeOverflowException=GroupSizeOverflowException;function createRenderDom(t,e){let i;if("svg"===t){i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg")}else i=document.createElement("canvas");i.setAttribute("width",e.width);i.setAttribute("height",e.height);return i}class BarcodeRender{constructor(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;const i=this.style.unitValue;this.size={width:e.size.width*i,height:e.size.height*i};const o=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(o,this.style,i);break;case"canvas":this.context=new CanvasRenderContext(o,this.style,i);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(o);this.renderDom=o}render(){const{style:t,barcode:{shapes:e}}=this,i=this.context;i.clear();i.setColor(t.color);i.setBackgroundColor(t.backgroundColor);e.forEach(t=>{"rect"===t.type&&i.drawRect(t);"text"===t.type&&i.drawText(t)});return this}getImageData(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()}getDataUrl(){return this.context.getDataUrl()}destroy(){this.container&&this.container.removeChild(this.renderDom)}getSize(){return this.size}}exports.BarcodeRender=BarcodeRender;function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t="",e=1,i){let o=0,r=t.length,s=0;for(;o<r;){i(t.substring(o,o+e),s);o+=e;s++}}function sliceArray(t=[],e=1,i){let o=0,r=t.length,s=0;for(;o<r;){i(t.slice(o,o+e),s);o+=e;s++}}function str2Array(t=""){return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t=""){const e=str2Array(t),i=[];e.forEach(t=>{if("0"===t)i.push(0);else if(i[i.length-1]&&0!==i[i.length]){let t=i.pop();i.push(++t)}else i.push(1)});return i}function convertRadix(t,e=2){return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t="",e=0){if("number"==typeof t)return t;const i=parseFloat(t);return isNaN(i)?e:i}function getUnit(t=""){const e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e="length"){let i=0;t.forEach(t=>{t[e]>i&&(i=t[e])});return i}function assign(t,...e){if(isFunction(Object.assign))return Object.assign(t,...e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");const i=Object(t);for(let t=0;t<e.length;t++){const o=e[t];if(null!=o)for(const t in o)Object.prototype.hasOwnProperty.call(o,t)&&(i[t]=o[t])}return i}function deepMerge(t,...e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach(e=>{if(e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(null!=e[i]&&"object"==typeof e[i]&&"object"==typeof t[i]?t[i]=deepMerge({},t[i]||{},e[i]):t[i]=e[i])});return t}function deepMergeAll(...t){return deepMerge({},...t)}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);const i=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==i.length||0==e)return"";if(i.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");let o="";for(let t=0;t<e;t++)o+=i;return o}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&Number.isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(let i=0;i<t.length;i++)t[i]=e;return t}function strPadStart(t,e,i){if(isFunction(t.padStart))return t.padStart(e,i);e>>=0;i=String(void 0!==i?i:" ");if(t.length>e)return t;(e-=t.length)>i.length&&(i+=strRepeat(i,e/i.length));return i.slice(0,e)+String(t)}const plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){let i,o;if(isFinite(e)){i=0;o=e}else{i=e.from;o=e.to+1}for(;i<o;i++)t(i)}function toZeroOnePattern(t,e){const i=e?isEven:isOdd;return t.reduce((t,e,o)=>{i(o)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t},"")}function range(t,e){const i=[];for(;t<e;){i.push(t);t++}i.push(e);return i}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});const e=Object.keys(t).reduce((e,i)=>{e[t[i]]=i;return e},{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}exports.Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};class Option{constructor(t={}){this.originConfig=t;this.type=t.type;this.penddingMerge=[]}static setCustomDefaultOptions(t){Option.CustomDefaultOptions=t}spawn(t){return new Option(exports.Utils.deepMergeAll(this.originConfig,t))}merge(t){this.penddingMerge.unshift(t)}_getUnitValue(t){t=exports.Utils.fixSize2PixelDefault(t);return exports.Utils.convertUnit(t)}getMergedOption(){return exports.Utils.deepMergeAll(Option.DefaultOptions,...this.penddingMerge,Option.CustomDefaultOptions,this.originConfig)}getConfig(t){const e=this.getMergedOption();let{text:i,quietZone:o,height:r,labelPosition:s,desiredSize:n,showLabel:a,font:h,backgroundColor:l,color:c,renderType:d,unitSize:p,hideExtraChecksum:u}=e;const g={text:i,isLabelBottom:!1,hideExtraChecksum:u};if(!exports.Utils.isDefined(i))throw new InvalidTextException;g.text+="";exports.Utils.isDefined(s)&&(g.isLabelBottom="top"!==s);h=exports.Utils.deepMergeAll(h);h.fontSize=exports.Utils.fixSize2PixelDefault(h.fontSize);const f=exports.Utils.measureText(i,h);g.showLabel=a;t=t||this._getUnitValue(p);const x=a?f/t:0;g.fontSizeInUnit=x;const m={};for(const e in o)if(o.hasOwnProperty(e)){const i=o[e];if(exports.Utils.isNumberLike(i)){const t=+i;m[e]=t}else{const o=exports.Utils.convertUnit(i);m[e]=o/t}}g.quietZone=m;if(n){g.containerWidth=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(n.width));g.containerHeight=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(n.height));g.desiredSize=n}if(exports.Utils.isDefined(r))if(n){const e=a?g.containerHeight-f:g.containerHeight;g.height=e/t-m.top-m.bottom}else exports.Utils.isNumberLike(r)?g.height=+r-x-m.top-m.bottom:g.height=exports.Utils.convertUnit(r)/t-x-m.top-m.bottom;return{config:e,encodeConfig:g,style:exports.Utils.deepMergeAll({backgroundColor:l,color:c,renderType:d,unitValue:t,fontSize:h.fontSize,fontHeight:f},h)}}getOriginConfig(){return this.originConfig}getType(){return this.type}}Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};exports.Option=Option;function _getProtos(t){var e=[];if(t&&t instanceof Function){let i=t;e.push(i);for(;i;){const t=Object.getPrototypeOf(i);if(!t||t===Object||t===Function.prototype)break;i=t;e.push(i)}}return e}function _getDefaultConfig(t,e){var i=[{type:e}];_getProtos(t).forEach(t=>{t.DefaultConfig&&i.unshift(t.DefaultConfig)});return exports.Utils.deepMergeAll(Option.DefaultOptions,...i,Option.CustomDefaultOptions)}exports._getDefaultConfig=_getDefaultConfig;class _EnumDictionary{constructor(t,e){this._keys={};this._values={};for(const i in t)if("string"==typeof t[i]){const o=parseInt(i),r=e(t[o]);this._keys[o]=r;this._values[r]=o}}getEnumByString(t){var e=this._values[t];if(void 0===e)throw`Unknown Barcode internal value '${t}'`;return e}getStringByEnum(t){return this._keys[t]}}exports._EnumDictionary=_EnumDictionary;class Area{constructor(t=0,e=0){this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}append(t){this.children.push(t)}_makeRect(t,e,i,o){return{x:t,y:e,height:o,width:i,type:"rect"}}toShapes(){const{x:t,y:e,width:i,height:o,style:{border:r,margin:s}}=this,n=[],a=r.left+r.right+i,h=r.top+r.bottom+o,l=t+s.left,c=e+s.top;r.top&&n.push(this._makeRect(l,c,a,r.top));r.right&&n.push(this._makeRect(l+a-r.right,c,r.right,h));r.bottom&&n.push(this._makeRect(l,c+h-r.bottom,a,r.bottom));r.left&&n.push(this._makeRect(l,c,r.left,h));return n}getSize(){const{width:t,height:e,offsetBox:i}=this;return{width:t+i.width,height:e+i.height}}visiable(){return this.width>0&&this.height>0}setX(t){this.x=t;this._updateBox()}setY(t){this.y=t;this._updateBox()}updateContentSize(t,e){this.width=t;this.height=e;this._updateBox()}_fixOpt(t,e){if(exports.Utils.isNumberLike(t[e])){const i=t[e];t[e]={top:i,right:i,bottom:i,left:i}}}setStyle(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=exports.Utils.deepMergeAll(this.style,t);this._updateBox()}_updateBox(){const{x:t,y:e,width:i,height:o,style:{padding:r,border:s,margin:n}}=this;this.offsetBox={x:t+r.left+s.left+n.left,y:e+r.top+s.top+n.top,width:n.left+s.left+s.right+n.right,height:n.top+s.top+s.bottom+n.bottom};const a=i-r.left-r.right,h=o-r.top-r.bottom;this.contentBox={width:a>=0?a:0,height:h>=0?h:0}}}exports.Area=Area;class HorizontalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this,i=super.toShapes(),o=e.y;let r=0;t.forEach(t=>{const s=e.x+r;t.toShapes().forEach(t=>{t.x+=s;t.y+=o;i.push(t)});const n=t.getSize();r+=n.width});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.height=Math.max(i.height,t.height);t.width+=i.width;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}exports.HorizontalLayoutArea=HorizontalLayoutArea;class VerticalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this,i=super.toShapes(),o=e.x;let r=0;t.forEach(t=>{const s=e.y+r;t.toShapes().forEach(t=>{t.x+=o;t.y+=s;i.push(t)});const n=t.getSize();r+=n.height});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.width=Math.max(i.width,t.width);t.height+=i.height;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}exports.VerticalLayoutArea=VerticalLayoutArea;class MatrixSymbolArea extends Area{constructor(t,e,i){super(t,e);this._xPosition=0;this._yPosition=0;this._lastMaxHeight=0;this._rowHeight=0;this._rowHeight=i}append(t,e){if(!t||!e)return;this._autoWrap(t);const{children:i,_xPosition:o,_yPosition:r}=this,s={width:t,height:e,x:o,y:r};i.push(s);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}_autoWrap(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}}_checkNeedWrap(t){const{_xPosition:e,contentBox:{width:i}}=this;return i-e-t<0}space(t=1){this._autoWrap(t);this._xPosition+=t}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e}=this,i=super.toShapes();e.forEach(e=>{e.x+=t.x;e.y+=t.y;e.type="rect";i.push(e)});return i}}exports.MatrixSymbolArea=MatrixSymbolArea;class SymbolArea extends Area{constructor(t,e){super(t,e);this._lastIsBar=!1;this._cacheNumber=0;this._position=0}append(t,e,i){if(!t)return;const{children:o,_position:r}=this,s={width:t,x:r,barHeight:e,offsetY:i};o.push(s);this._position+=t}space(t=1){this._position+=t}_appendModule(t){const e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++}_flash(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}}fromPattern(t){exports.Utils.str2Array(t).forEach(t=>{this._appendModule(t)});this._flash()}getContentBox(){return this.contentBox}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,contentBox:{height:i}}=this,o=super.toShapes();e.forEach(e=>{o.push({type:"rect",x:e.x+t.x,y:t.y+(e.offsetY||0),width:e.width,height:e.barHeight||i})});return o}}exports.SymbolArea=SymbolArea;class LabelArea extends Area{constructor(t,e,i){super(t,e);this._textAlign=i}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,_textAlign:i,contentBox:{width:o}}=this,r=super.toShapes();e.forEach(e=>{let s=t.x;switch(i){case"center":s+=o/2;break;case"right":s+=o}r.push({x:s+(e.x||0),y:t.y+(e.y||0),textAlign:i,maxWidth:o,type:"text",text:e.text})});return r}}exports.LabelArea=LabelArea;class MatrixBuilder{constructor(t,e){this.data=[];this.data=[];this.row=t;this.col=e}add(t,e,i){(this.data[t]||exports.Utils.fillArray(new Array(this.col),null))[e]=i;this.data[t]=[]}toMatrix(){const t=[];exports.Utils.loop(e=>{t.push(this.data[e]||exports.Utils.fillArray(new Array(this.col),null))},this.row);return t}}exports.MatrixBuilder=MatrixBuilder;class BitBuffer{constructor(t=[]){this.buffer=t;this.length=8*t.length;this.index=0}putBit(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1}putBitAt(t,e){const{length:i}=this,o=new BitBuffer;for(let r=0;r<i;r++)r===e?o.putBit(t):o.putBit(this.getAt(r));this.buffer=o.buffer;this.length=o.length}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBits(t){this.put(parseInt(t,2),t.length)}getAt(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)}getBuffer(){return this.buffer}getGroupedBits(t){let e=0;const i=[];for(;e<this.length;){let o="",r=e,s=e+t;for(;r<s;r++)o+=this.getAt(r)?1:0;e=s;i.push(parseInt(o,2))}return i}next(){this.index++;return this.getAt(this.index-1)}}exports.BitBuffer=BitBuffer;class BarcodeEncoder{constructor(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}validate(){}applyDesiredSize(t){const{config:e,encodeConfig:i,style:o}=this._option.getConfig(t);this.config=e;this.encodeConfig=i;this.style=o;this.useDesiredSize=!!i.desiredSize}afterApplyDesiredSize(){}toSymbol(){this.validate();const t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)}}exports.BarcodeEncoder=BarcodeEncoder;class TwoDimensionalBarcode extends BarcodeEncoder{adjustDesiredSize(){const{width:t,height:e}=this.size,{desiredSize:i,containerWidth:o,containerHeight:r}=this.encodeConfig;let s=Math.min(o/t,r/e);if(i.forceRounding){s=~~s;s=s<1?1:s}this.applyDesiredSize(s)}convertToShape(t,e){const{quietZone:i}=this.encodeConfig,o=t[0].length+i.right+i.left,r=t.length+i.top+i.bottom,s=new VerticalLayoutArea,n=new MatrixSymbolArea(o,r,1);n.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});s.append(n);if(!e){t.forEach(t=>{t.forEach(t=>{t?n.append(1,1):n.space()})});this.shapes=s.toShapes()}this.size=s.getSize()}}exports.TwoDimensionalBarcode=TwoDimensionalBarcode;class OneDimensionalBarcode extends BarcodeEncoder{constructor(t){t.merge(OneDimensionalBarcode.DefaultConfig);super(t);this.label=""}adjustDesiredSize(){const{width:t}=this.size,{desiredSize:e,containerWidth:i}=this.encodeConfig;let o=i/t;if(e.forceRounding){o=~~o;o=o<1?1:o}this.applyDesiredSize(o)}convertToShape(t,e){const{label:i,encodeConfig:{quietZone:o,isLabelBottom:r,height:s,showLabel:n,fontSizeInUnit:a},style:{textAlign:h}}=this;let l=0;i&&n&&(l=a);const c=t.length+o.right+o.left,d=s+o.top+o.bottom,p=new VerticalLayoutArea,u=new SymbolArea(c,d);u.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});const g=u.getSize(),f=new LabelArea(g.width,l,h);if(r){p.append(u);p.append(f)}else{p.append(f);p.append(u)}if(!e){u.fromPattern(t);f.append({text:i});this.shapes=p.toShapes()}this.size=p.getSize()}}OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};exports.OneDimensionalBarcode=OneDimensionalBarcode;const FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";exports.Constants={FNC1:"Ï",FNC2:"Ê",FNC3:"É",DataMatrixFNC1:" ",DataMatrixMacro05:" ",DataMatrixMacro06:" "};exports.encoders={};class Barcode{constructor(...t){let e,i,o;if(t.length>=3)[e,i,o]=t;else if(2===t.length)exports.Utils.isFunction(t[1])?[i,o]=t:[e,i]=t;else{if(1!==t.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");[i]=t}this.dom="string"==typeof e?document.querySelector(e):e;this.callback=o&&o.bind(this);this.setOption(i)}static getImageData(t={}){return new Barcode(t).getImageData()}getImageData(){return this.render.getImageData()}static getDataUrl(t={}){return new Barcode(t).getDataUrl()}getDataUrl(){return this.render.getDataUrl()}static setDefaultOptions(t={}){Option.setCustomDefaultOptions(t)}static registerEncoder(t,e){exports.encoders[t]=e;Barcode.supportType.push(t)}static registerPlugin(t,e){exports.Utils.registerPlugin(t,e)}mergeOption(t){const e=this.option.spawn(t);this.update(e);return this}setOption(t){this.update(new Option(t));return this}getOption(){return this.option.getMergedOption()}update(t){const e=t.getType(),i=exports.encoders[e];if(!i)throw new InvalidBarcodeTypeException(e);const o=new i(t);this.destroy();const r=new BarcodeRender(this.dom,o);r.render();this.render=r;this.option=t;exports.Utils.isFunction(this.callback)&&this.callback()}refresh(){this.render.render();exports.Utils.isFunction(this.callback)&&this.callback()}getSize(){return this.render.getSize()}destroy(){if(this.render){this.render.destroy();this.render=null}}}Barcode.supportType=[];Barcode.constants=exports.Constants;Barcode.ErrorCode=exports.ErrorCode;exports.Barcode=Barcode;Barcode.registerPlugin("measureText",(t,e)=>{const i=document.createElement("span");i.style.visibility="hidden";i.style.position="absolute";i.style.lineHeight="normal";i.textContent=t;Object.keys(e).forEach(t=>{i.style[t]=e[t]});document.body.appendChild(i);const o=i.getBoundingClientRect();document.body.removeChild(i);return o.height});Barcode.registerPlugin("convertUnit",t=>{const e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);const i=e.getBoundingClientRect();document.body.removeChild(e);return i.width});exports.BarcodeClsNames={hostElement:"wj-barcode"};var RenderType,LabelPosition,NarrowToWideRatio;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType=exports.RenderType||(exports.RenderType={}));!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition=exports.LabelPosition||(exports.LabelPosition={}));!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio=exports.NarrowToWideRatio||(exports.NarrowToWideRatio={}));class _RenderTypeConvertor{static stringToEnum(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw`Unknown Barcode internal renderType '${t}'`}static enumToString(t){return RenderType[wijmo_1.asEnum(t,RenderType)].toLowerCase()}}exports._RenderTypeConvertor=_RenderTypeConvertor;class _LabelPositionConvertor{static stringToEnum(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw`Unknown Barcode internal labelPosition '${t}'`}static enumToString(t){return LabelPosition[wijmo_1.asEnum(t,LabelPosition)].toLowerCase()}}exports._LabelPositionConvertor=_LabelPositionConvertor;class _NarrowWideRatioConvertor{static stringToEnum(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw`Unknown nwRatio internal value '${t}'`}static enumToString(t){let e;switch(wijmo_1.asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e}}exports._NarrowWideRatioConvertor=_NarrowWideRatioConvertor;class BarcodeBase extends wijmo_1.Control{constructor(t,e){super(t,null,!0);this._state={};this._isUpd=0;this._isValid=!0;this._aw=!1;this._wZoom=1;this.isValidChanged=new wijmo_1.Event;const i=this.getTemplate();this.applyTemplate(`${exports.BarcodeClsNames.hostElement} ${wijmo_1.ControlClsNames.hostElement}`,i,{});wijmo_1.isIE()||(this.hostElement.style.lineHeight="0px");this._state=this._getDefaults();this._isUpd++;this.initialize(e);this._updateSize();this._isUpd--;this._mergeOptions({});this.invalidate()}static get controlTemplate(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate}static set controlTemplate(t){BarcodeBase._ctrlTemplate=t}initialize(t){this._isUpd++;try{super.initialize(t)}finally{this._isUpd--}!this._isUpd&&t&&Object.keys(t).length&&this._mergeOptions({})}static _getClassDefaults(){const t=this.type;return _getDefaultConfig(exports.encoders[t],t)}_getDefaults(){const t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return exports.Utils.deepMergeAll(t._defaults)}get value(){return this._getProp("text")}set value(t){this._setProp("text",t)}get quietZone(){return this._getProp("quietZone")}set quietZone(t){this._setProp("quietZone",t)}get renderType(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))}set renderType(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))}get color(){return this._getProp("color")}set color(t){this._setProp("color",t)}get backgroundColor(){return this._getProp("backgroundColor")}set backgroundColor(t){this._setProp("backgroundColor",t)}get hideExtraChecksum(){return this._getProp("hideExtraChecksum")}set hideExtraChecksum(t){this._setProp("hideExtraChecksum",t)}get font(){return this._getProp("font")}set font(t){this._setProp("font",t)}get isValid(){return this._isValid}onIsValidChanged(t){this.isValidChanged.raise(this,t)}refresh(t=!0){super.refresh(t);t?this._updateSize():this._bc.refresh()}getImageData(){return this._bc.getImageData()}getDataUrl(){return this._bc.getDataUrl()}getSize(){var t=new wijmo_1.Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t}_mergeOptions(t){let e,i=this._bc,o=_copyObj(this._state,t);if(!this._isUpd){const t=o.text;if(null==t||""===t){if(i){i.destroy();this._bc=i=null}}else try{i?i.setOption(o):this._bc=i=new Barcode(this.hostElement,o)}catch(t){e=t}}let r=!0;if(e){if(i){i.destroy();this._bc=i=null}if(e.code!==_errorCode.InvalidText)throw e;r=!1}this._state=o;this._setValid(r)}_setValid(t){if(this._isValid!==t){this._isValid=t;wijmo_1.toggleClass(this.hostElement,wijmo_1.ControlStateClsNames.invalid,!t);this.onIsValidChanged()}}_setProp(t,e){this._mergeOptions({[t]:e})}_getProp(t){const e=this._bc;return this._state[t]||e&&e.getOption()[t]}_updateSize(t=!0){if(!this.hostElement)return;let e=BarcodeBase._getContentSize(this.hostElement),i=this._prevSz,o=null,r=null,s=1,n=!0;if(this._getAw()){s=this._getWzoom();r=e.height/s;n=t&&r===this._prevH;this._prevH=r;i=this._prevSz=null}else if(t){if(!i||!e.equals(i)){o={width:e.width+"px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}}else{o={width:"0px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}n||this._mergeOptions({desiredSize:o,height:r,unitSize:s})}static _getContentSize(t){const e=getComputedStyle(t);return new wijmo_1.Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))}_getAw(){return this._aw}_setAw(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}}_getWzoom(){return this._wZoom}_setWzoom(t){wijmo_1.asNumber(t);wijmo_1.assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}}}BarcodeBase._ctrlTemplate="";exports.BarcodeBase=BarcodeBase;const _copyObj="function"==typeof Object.assign?Object.assign:(t,...e)=>{for(const i of e)if(null!=i)for(const e in i)t[e]=i[e];return t};wijmo_1._registerModule("wijmo.barcode",selfModule);
|
package/es2015-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import{asEnum,Control,Size,Event,toggleClass,asNumber,assert,isIE,ControlStateClsNames,ControlClsNames,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.barcode";const alignmentMap={center:"middle",left:"start",right:"end"};export class SVGRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.scale=i;this.color="rgb(0,0,0)";this.addGroup()}setColor(t){this.color=t}setBackgroundColor(t){const{dom:e}=this;e.style.backgroundColor=t}addGroup(){const{dom:t}=this;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)}drawRect(t){const{g:e,scale:i,color:s}=this,r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("x",(t.x*i).toString());r.setAttribute("y",(t.y*i).toString());r.setAttribute("width",(t.width*i).toString());r.setAttribute("height",(t.height*i).toString());r.style.fill=s;e.appendChild(r)}drawText(t){const{g:e,scale:i,color:s,style:r}=this,o=document.createElementNS("http://www.w3.org/2000/svg","text");o.style.fill=s;o.style.fontSize=r.fontSize;o.style.fontFamily=r.fontFamily;o.style.fontStyle=t.fontStyle||r.fontStyle;o.style.fontWeight=t.fontWeight||r.fontWeight;o.style.textDecoration=t.textDecoration||r.textDecoration;o.style.textAnchor=alignmentMap[t.textAlign||r.textAlign];o.textContent=t.text;o.textContent=this.clipString(t,o);const n=this._measureText(o);o.setAttribute("y",(t.y*i+Math.abs(n.y)).toString());o.setAttribute("x",(t.x*i).toString());e.appendChild(o)}clipString(t,e){const{scale:i}=this;let{text:s,maxWidth:r}=t;const o=this._measureText(e);r*=i;if(o.width>r){const e=Math.floor(r/o.width*s.length);return t.text.substr(0,e)}return s}clear(){const{dom:t}=this;t.removeChild(this.g);this.addGroup()}_measureText(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);const i=t.getBBox();document.body.removeChild(e);return i}getDataUrl(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)}}export class CanvasRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=i}setColor(t){this.ctx.fillStyle=t}setBackgroundColor(t){const{ctx:e,dom:i}=this;e.save();e.fillStyle=t;e.fillRect(0,0,i.width,i.height);e.restore()}drawRect(t){const{ctx:e,scale:i}=this;e.fillRect(t.x*i,t.y*i,t.width*i,t.height*i)}drawText(t){const{ctx:e,style:i,scale:s}=this;e.save();e.font=`${t.fontStyle||i.fontStyle} ${t.fontWeight||i.fontWeight} ${i.fontSize} ${i.fontFamily}`;e.textAlign=t.textAlign||i.textAlign;e.textBaseline="bottom";const r=t.x*s,o=t.y*s,n=this.clipString(t);e.fillText(n,r,o+i.fontHeight);this.drawTextDecorationLine(n,r,o,t.textDecoration||i.textDecoration);e.restore()}clipString(t){const{ctx:e,scale:i}=this;let{text:s,maxWidth:r}=t;const o=e.measureText(s);r*=i;if(o.width>r){const e=Math.floor(r/o.width*s.length);return t.text.substr(0,e)}return s}drawTextDecorationLine(t,e,i,s){let r;switch(s){case"underline":r=.9;break;case"overline":r=.1;break;case"line-through":r=.5;break;default:return}const{ctx:o,style:{fontHeight:n}}=this;let a=o.measureText(t).width;switch(o.textAlign){case"center":e-=a/2;break;case"right":e-=a}o.lineWidth=1;o.beginPath();let h=n*r+i;o.moveTo(e,h);o.lineTo(e+a,h);o.stroke()}clear(){const{ctx:t,dom:e}=this;t.clearRect(0,0,e.width,e.height)}getImageData(){const{ctx:t,dom:e}=this;return t.getImageData(0,0,e.width,e.height)}getDataUrl(){return this.dom.toDataURL()}}export var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode||(_errorCode={}));export class BaseException extends Error{constructor(t){super();this.code=t||_errorCode.Unknown}}export const ErrorCode=_errorCode;export class InvalidOptionsException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidOptions);this.name="InvalidOptionsException";this.message=`${JSON.stringify(t)} is not valid options. ${e}`;this.descriptor={source:t,message:this.message}}}export class InvalidBarcodeTypeException extends BaseException{constructor(t){super(_errorCode.InvalidBarcodeType);this.name="InvalidBarcodeTypeException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}export class InvalidRenderException extends BaseException{constructor(t){super(_errorCode.InvalidRenderType);this.name="InvalidRenderException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}export class MethodNotImplementException extends BaseException{constructor(t,e){super(_errorCode.MethodNotImplement);this.name="MethodNotImplementException";this.message=`${t} is not a method! ${e}`;this.descriptor={source:t,message:this.message}}}export class InvalidTextException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidText);this.name="InvalidTextException";this.message=t?`${t} is invalid. ${e}`:"Text is required.";this.descriptor={source:t,message:this.message}}}export class InvalidCharacterException extends BaseException{constructor(t){super(_errorCode.InvalidCharacter);this.name="InvalidCharacterException";this.message=t+" is invalid.";this.descriptor={source:t,message:this.message}}}export class TextTooLongException extends BaseException{constructor(){super(_errorCode.TextTooLong);this.name="TextTooLongException";this.message="Text is too long to encode";this.descriptor={source:null,message:this.message}}}export class GroupSizeOverflowException extends BaseException{constructor(t){super(_errorCode.GroupSizeOverflow);this.name="GroupSizeOverflowException";this.message=`Group size is ${t}. The max group size is 9.`;this.descriptor={source:t,message:this.message}}}function createRenderDom(t,e){let i;if("svg"===t){i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg")}else i=document.createElement("canvas");i.setAttribute("width",e.width);i.setAttribute("height",e.height);return i}export class BarcodeRender{constructor(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;let i=this.style.unitValue;this.size={width:e.size.width*i,height:e.size.height*i};let s=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(s,this.style,i);break;case"canvas":this.context=new CanvasRenderContext(s,this.style,i);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(s);this.renderDom=s}render(){const{style:t,barcode:{shapes:e}}=this,i=this.context;i.clear();i.setColor(t.color);i.setBackgroundColor(t.backgroundColor);e.forEach(t=>{"rect"===t.type&&i.drawRect(t);"text"===t.type&&i.drawText(t)});return this}getImageData(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()}getDataUrl(){return this.context.getDataUrl()}destroy(){this.container&&this.container.removeChild(this.renderDom)}getSize(){return this.size}}function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t="",e=1,i){let s=0,r=t.length,o=0;for(;s<r;){i(t.substring(s,s+e),o);s+=e;o++}}function sliceArray(t=[],e=1,i){let s=0,r=t.length,o=0;for(;s<r;){i(t.slice(s,s+e),o);s+=e;o++}}function str2Array(t=""){return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t=""){let e=str2Array(t),i=[];e.forEach(t=>{if("0"===t)i.push(0);else if(i[i.length-1]&&0!==i[i.length]){let t=i.pop();i.push(++t)}else i.push(1)});return i}function convertRadix(t,e=2){return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t="",e=0){if("number"==typeof t)return t;let i=parseFloat(t);return isNaN(i)?e:i}function getUnit(t=""){let e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e="length"){let i=0;t.forEach(t=>{t[e]>i&&(i=t[e])});return i}function assign(t,...e){if(isFunction(Object.assign))return Object.assign(t,...e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");let i=Object(t);for(let t=0;t<e.length;t++){let s=e[t];if(null!=s)for(let t in s)Object.prototype.hasOwnProperty.call(s,t)&&(i[t]=s[t])}return i}function deepMerge(t,...e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach(e=>{if(e)for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(null!=e[i]&&"object"==typeof e[i]&&"object"==typeof t[i]?t[i]=deepMerge({},t[i]||{},e[i]):t[i]=e[i])});return t}function deepMergeAll(...t){return deepMerge({},...t)}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);let i=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==i.length||0==e)return"";if(i.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");let s="";for(let t=0;t<e;t++)s+=i;return s}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(let i=0;i<t.length;i++)t[i]=e;return t}function strPadStart(t,e,i){if(isFunction(t.padStart))return t.padStart(e,i);e>>=0;i=String(void 0!==i?i:" ");if(t.length>e)return t;(e-=t.length)>i.length&&(i+=strRepeat(i,e/i.length));return i.slice(0,e)+String(t)}const plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){let i,s;if(isFinite(e)){i=0;s=e}else{i=e.from;s=e.to+1}for(;i<s;i++)t(i)}function toZeroOnePattern(t,e){const i=e?isEven:isOdd;return t.reduce((t,e,s)=>{i(s)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t},"")}function range(t,e){const i=[];for(;t<e;){i.push(t);t++}i.push(e);return i}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});const e=Object.keys(t).reduce((e,i)=>{e[t[i]]=i;return e},{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}export const Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};export class Option{constructor(t={}){this.originConfig=t;this.type=t.type;this.penddingMerge=[]}static setCustomDefaultOptions(t){Option.CustomDefaultOptions=t}spawn(t){return new Option(Utils.deepMergeAll(this.originConfig,t))}merge(t){this.penddingMerge.unshift(t)}_getUnitValue(t){t=Utils.fixSize2PixelDefault(t);return Utils.convertUnit(t)}getMergedOption(){return Utils.deepMergeAll(Option.DefaultOptions,...this.penddingMerge,Option.CustomDefaultOptions,this.originConfig)}getConfig(t){const e=this.getMergedOption();let{text:i,quietZone:s,height:r,labelPosition:o,desiredSize:n,showLabel:a,font:h,backgroundColor:l,color:c,renderType:d,unitSize:u,hideExtraChecksum:p}=e;const g={text:i,isLabelBottom:!1,hideExtraChecksum:p};if(!Utils.isDefined(i))throw new InvalidTextException;g.text+="";Utils.isDefined(o)&&(g.isLabelBottom="top"!==o);h=Utils.deepMergeAll(h);h.fontSize=Utils.fixSize2PixelDefault(h.fontSize);const f=Utils.measureText(i,h);g.showLabel=a;t=t||this._getUnitValue(u);const m=a?f/t:0;g.fontSizeInUnit=m;const x={};for(let e in s)if(s.hasOwnProperty(e)){let i=s[e];if(Utils.isNumberLike(i)){const t=+i;x[e]=t}else{let s=Utils.convertUnit(i);x[e]=s/t}}g.quietZone=x;if(n){g.containerWidth=Utils.convertUnit(Utils.fixSize2PixelDefault(n.width));g.containerHeight=Utils.convertUnit(Utils.fixSize2PixelDefault(n.height));g.desiredSize=n}if(Utils.isDefined(r))if(n){let e=a?g.containerHeight-f:g.containerHeight;g.height=e/t-x.top-x.bottom}else Utils.isNumberLike(r)?g.height=+r-m-x.top-x.bottom:g.height=Utils.convertUnit(r)/t-m-x.top-x.bottom;return{config:e,encodeConfig:g,style:Utils.deepMergeAll({backgroundColor:l,color:c,renderType:d,unitValue:t,fontSize:h.fontSize,fontHeight:f},h)}}getOriginConfig(){return this.originConfig}getType(){return this.type}}Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};function _getProtos(t){var e=[];if(t&&t instanceof Function){let i=t;e.push(i);for(;i;){const t=Object.getPrototypeOf(i);if(!t||t===Object||t===Function.prototype)break;i=t;e.push(i)}}return e}export function _getDefaultConfig(t,e){var i=[{type:e}];_getProtos(t).forEach(t=>{t.DefaultConfig&&i.unshift(t.DefaultConfig)});return Utils.deepMergeAll(Option.DefaultOptions,...i,Option.CustomDefaultOptions)}export class _EnumDictionary{constructor(t,e){this._keys={};this._values={};for(let r in t)if("string"==typeof t[r]){var i=parseInt(r),s=e(t[i]);this._keys[i]=s;this._values[s]=i}}getEnumByString(t){var e=this._values[t];if(void 0===e)throw`Unknown Barcode internal value '${t}'`;return e}getStringByEnum(t){return this._keys[t]}}export class Area{constructor(t=0,e=0){this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}append(t){this.children.push(t)}_makeRect(t,e,i,s){return{x:t,y:e,height:s,width:i,type:"rect"}}toShapes(){const{x:t,y:e,width:i,height:s,style:{border:r,margin:o}}=this,n=[],a=r.left+r.right+i,h=r.top+r.bottom+s,l=t+o.left,c=e+o.top;r.top&&n.push(this._makeRect(l,c,a,r.top));r.right&&n.push(this._makeRect(l+a-r.right,c,r.right,h));r.bottom&&n.push(this._makeRect(l,c+h-r.bottom,a,r.bottom));r.left&&n.push(this._makeRect(l,c,r.left,h));return n}getSize(){const{width:t,height:e,offsetBox:i}=this;return{width:t+i.width,height:e+i.height}}visiable(){return this.width>0&&this.height>0}setX(t){this.x=t;this._updateBox()}setY(t){this.y=t;this._updateBox()}updateContentSize(t,e){this.width=t;this.height=e;this._updateBox()}_fixOpt(t,e){if(Utils.isNumberLike(t[e])){const i=t[e];t[e]={top:i,right:i,bottom:i,left:i}}}setStyle(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=Utils.deepMergeAll(this.style,t);this._updateBox()}_updateBox(){const{x:t,y:e,width:i,height:s,style:{padding:r,border:o,margin:n}}=this;this.offsetBox={x:t+r.left+o.left+n.left,y:e+r.top+o.top+n.top,width:n.left+o.left+o.right+n.right,height:n.top+o.top+o.bottom+n.bottom};const a=i-r.left-r.right,h=s-r.top-r.bottom;this.contentBox={width:a>=0?a:0,height:h>=0?h:0}}}export class HorizontalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this;let i=super.toShapes();const s=e.y;let r=0;t.forEach(t=>{const o=e.x+r;t.toShapes().forEach(t=>{t.x+=o;t.y+=s;i.push(t)});const n=t.getSize();r+=n.width});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.height=Math.max(i.height,t.height);t.width+=i.width;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}export class VerticalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this;let i=super.toShapes();const s=e.x;let r=0;t.forEach(t=>{const o=e.y+r;t.toShapes().forEach(t=>{t.x+=s;t.y+=o;i.push(t)});const n=t.getSize();r+=n.height});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.width=Math.max(i.width,t.width);t.height+=i.height;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}export class MatrixSymbolArea extends Area{constructor(t,e,i){super(t,e);this._xPosition=0;this._yPosition=0;this._lastMaxHeight=0;this._rowHeight=0;this._rowHeight=i}append(t,e){if(!t||!e)return;this._autoWrap(t);const{children:i,_xPosition:s,_yPosition:r}=this,o={width:t,height:e,x:s,y:r};i.push(o);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}_autoWrap(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}}_checkNeedWrap(t){const{_xPosition:e,contentBox:{width:i}}=this;return i-e-t<0}space(t=1){this._autoWrap(t);this._xPosition+=t}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e}=this,i=super.toShapes();e.forEach(e=>{e.x+=t.x;e.y+=t.y;e.type="rect";i.push(e)});return i}}export class SymbolArea extends Area{constructor(t,e){super(t,e);this._lastIsBar=!1;this._cacheNumber=0;this._position=0}append(t,e,i){if(!t)return;const{children:s,_position:r}=this,o={width:t,x:r,barHeight:e,offsetY:i};s.push(o);this._position+=t}space(t=1){this._position+=t}_appendModule(t){const e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++}_flash(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}}fromPattern(t){Utils.str2Array(t).forEach(t=>this._appendModule(t));this._flash()}getContentBox(){return this.contentBox}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,contentBox:{height:i}}=this,s=super.toShapes();e.forEach(e=>{s.push({type:"rect",x:e.x+t.x,y:t.y+(e.offsetY||0),width:e.width,height:e.barHeight||i})});return s}}export class LabelArea extends Area{constructor(t,e,i){super(t,e);this._textAlign=i}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,_textAlign:i,contentBox:{width:s}}=this,r=super.toShapes();e.forEach(e=>{let o=t.x;switch(i){case"center":o+=s/2;break;case"right":o+=s}r.push({x:o+(e.x||0),y:t.y+(e.y||0),textAlign:i,maxWidth:s,type:"text",text:e.text})});return r}}export class MatrixBuilder{constructor(t,e){this.data=[];this.data=[];this.row=t;this.col=e}add(t,e,i){(this.data[t]||Utils.fillArray(new Array(this.col),null))[e]=i;this.data[t]=[]}toMatrix(){const t=[];Utils.loop(e=>{t.push(this.data[e]||Utils.fillArray(new Array(this.col),null))},this.row);return t}}export class BitBuffer{constructor(t=[]){this.buffer=t;this.length=8*t.length;this.index=0}putBit(t){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1}putBitAt(t,e){const{length:i}=this,s=new BitBuffer;for(let r=0;r<i;r++)r===e?s.putBit(t):s.putBit(this.getAt(r));this.buffer=s.buffer;this.length=s.length}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBits(t){this.put(parseInt(t,2),t.length)}getAt(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)}getBuffer(){return this.buffer}getGroupedBits(t){let e=0;const i=[];for(;e<this.length;){let s="",r=e,o=e+t;for(;r<o;r++)s+=this.getAt(r)?1:0;e=o;i.push(parseInt(s,2))}return i}next(){this.index++;return this.getAt(this.index-1)}}export class BarcodeEncoder{constructor(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}validate(){}applyDesiredSize(t){const{config:e,encodeConfig:i,style:s}=this._option.getConfig(t);this.config=e;this.encodeConfig=i;this.style=s;this.useDesiredSize=!!i.desiredSize}afterApplyDesiredSize(){}toSymbol(){this.validate();const t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)}}export class TwoDimensionalBarcode extends BarcodeEncoder{adjustDesiredSize(){const{width:t,height:e}=this.size,{desiredSize:i,containerWidth:s,containerHeight:r}=this.encodeConfig;let o=Math.min(s/t,r/e);if(i.forceRounding){o=~~o;o=o<1?1:o}this.applyDesiredSize(o)}convertToShape(t,e){const{quietZone:i}=this.encodeConfig,s=t[0].length+i.right+i.left,r=t.length+i.top+i.bottom,o=new VerticalLayoutArea,n=new MatrixSymbolArea(s,r,1);n.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});o.append(n);if(!e){t.forEach(t=>{t.forEach(t=>{t?n.append(1,1):n.space()})});this.shapes=o.toShapes()}this.size=o.getSize()}}export class OneDimensionalBarcode extends BarcodeEncoder{constructor(t){t.merge(OneDimensionalBarcode.DefaultConfig);super(t);this.label=""}adjustDesiredSize(){const{width:t}=this.size;let{desiredSize:e,containerWidth:i}=this.encodeConfig,s=i/t;if(e.forceRounding){s=~~s;s=s<1?1:s}this.applyDesiredSize(s)}convertToShape(t,e){let{label:i,encodeConfig:{quietZone:s,isLabelBottom:r,height:o,showLabel:n,fontSizeInUnit:a},style:{textAlign:h}}=this,l=0;i&&n&&(l=a);const c=t.length+s.right+s.left,d=o+s.top+s.bottom,u=new VerticalLayoutArea,p=new SymbolArea(c,d);p.setStyle({padding:{top:s.top,right:s.right,bottom:s.bottom,left:s.left}});const g=p.getSize(),f=new LabelArea(g.width,l,h);if(r){u.append(p);u.append(f)}else{u.append(f);u.append(p)}if(!e){p.fromPattern(t);f.append({text:i});this.shapes=u.toShapes()}this.size=u.getSize()}}OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};const FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";export const Constants={FNC1:"Ï",FNC2:"Ê",FNC3:"É",DataMatrixFNC1:" ",DataMatrixMacro05:" ",DataMatrixMacro06:" "};export const encoders={};export class Barcode{constructor(...t){let e,i,s;if(t.length>=3)[e,i,s]=t;else if(2===t.length)Utils.isFunction(t[1])?[i,s]=t:[e,i]=t;else{if(1!==t.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");[i]=t}this.dom="string"==typeof e?document.querySelector(e):e;this.callback=s&&s.bind(this);this.setOption(i)}static getImageData(t={}){return new Barcode(t).getImageData()}static getDataUrl(t={}){return new Barcode(t).getDataUrl()}static setDefaultOptions(t={}){Option.setCustomDefaultOptions(t)}static registerEncoder(t,e){encoders[t]=e;Barcode.supportType.push(t)}static registerPlugin(t,e){Utils.registerPlugin(t,e)}mergeOption(t){const e=this.option.spawn(t);this.update(e);return this}setOption(t){this.update(new Option(t));return this}getOption(){return this.option.getMergedOption()}update(t){const e=t.getType(),i=encoders[e];if(!i)throw new InvalidBarcodeTypeException(e);const s=new i(t);this.destroy();const r=new BarcodeRender(this.dom,s);r.render();this.render=r;this.option=t;Utils.isFunction(this.callback)&&this.callback()}refresh(){this.render.render();Utils.isFunction(this.callback)&&this.callback()}getImageData(){return this.render.getImageData()}getDataUrl(){return this.render.getDataUrl()}getSize(){return this.render.getSize()}destroy(){if(this.render){this.render.destroy();this.render=null}}}Barcode.supportType=[];Barcode.constants=Constants;Barcode.ErrorCode=ErrorCode;Barcode.registerPlugin("measureText",(function(t,e){const i=document.createElement("span");i.style.visibility="hidden";i.style.position="absolute";i.style.lineHeight="normal";i.textContent=t;Object.keys(e).forEach(t=>{i.style[t]=e[t]});document.body.appendChild(i);const s=i.getBoundingClientRect();document.body.removeChild(i);return s.height}));Barcode.registerPlugin("convertUnit",(function(t){const e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);const i=e.getBoundingClientRect();document.body.removeChild(e);return i.width}));export const BarcodeClsNames={hostElement:"wj-barcode"};export var RenderType;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType||(RenderType={}));export var LabelPosition;!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition||(LabelPosition={}));export var NarrowToWideRatio;!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio||(NarrowToWideRatio={}));export class _RenderTypeConvertor{static stringToEnum(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw`Unknown Barcode internal renderType '${t}'`}static enumToString(t){return RenderType[asEnum(t,RenderType)].toLowerCase()}}export class _LabelPositionConvertor{static stringToEnum(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw`Unknown Barcode internal labelPosition '${t}'`}static enumToString(t){return LabelPosition[asEnum(t,LabelPosition)].toLowerCase()}}export class _NarrowWideRatioConvertor{static stringToEnum(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw`Unknown nwRatio internal value '${t}'`}static enumToString(t){let e;switch(asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e}}export class BarcodeBase extends Control{constructor(t,e){super(t,null,!0);this._state={};this._isUpd=0;this._isValid=!0;this._aw=!1;this._wZoom=1;this.isValidChanged=new Event;let i=this.getTemplate();this.applyTemplate(`${BarcodeClsNames.hostElement} ${ControlClsNames.hostElement}`,i,{});isIE()||(this.hostElement.style.lineHeight="0px");this._state=this._getDefaults();this._isUpd++;this.initialize(e);this._updateSize();this._isUpd--;this._mergeOptions({});this.invalidate()}static get controlTemplate(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate}static set controlTemplate(t){BarcodeBase._ctrlTemplate=t}initialize(t){this._isUpd++;try{super.initialize(t)}finally{this._isUpd--}!this._isUpd&&t&&Object.keys(t).length&&this._mergeOptions({})}static _getClassDefaults(){let t=this.type;return _getDefaultConfig(encoders[t],t)}_getDefaults(){let t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return Utils.deepMergeAll(t._defaults)}get value(){return this._getProp("text")}set value(t){this._setProp("text",t)}get quietZone(){return this._getProp("quietZone")}set quietZone(t){this._setProp("quietZone",t)}get renderType(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))}set renderType(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))}get color(){return this._getProp("color")}set color(t){this._setProp("color",t)}get backgroundColor(){return this._getProp("backgroundColor")}set backgroundColor(t){this._setProp("backgroundColor",t)}get hideExtraChecksum(){return this._getProp("hideExtraChecksum")}set hideExtraChecksum(t){this._setProp("hideExtraChecksum",t)}get font(){return this._getProp("font")}set font(t){this._setProp("font",t)}get isValid(){return this._isValid}onIsValidChanged(t){this.isValidChanged.raise(this,t)}refresh(t=!0){super.refresh(t);t?this._updateSize():this._bc.refresh()}getImageData(){return this._bc.getImageData()}getDataUrl(){return this._bc.getDataUrl()}getSize(){var t=new Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t}_mergeOptions(t){let e,i=this._bc,s=_copyObj(this._state,t);if(!this._isUpd){let t=s.text;if(null==t||""===t){if(i){i.destroy();this._bc=i=null}}else try{i?i.setOption(s):this._bc=i=new Barcode(this.hostElement,s)}catch(t){e=t}}let r=!0;if(e){if(i){i.destroy();this._bc=i=null}if(e.code!==_errorCode.InvalidText)throw e;r=!1}this._state=s;this._setValid(r)}_setValid(t){if(this._isValid!==t){this._isValid=t;toggleClass(this.hostElement,ControlStateClsNames.invalid,!t);this.onIsValidChanged()}}_setProp(t,e){this._mergeOptions({[t]:e})}_getProp(t){let e=this._bc;return this._state[t]||e&&e.getOption()[t]}_updateSize(t=!0){if(!this.hostElement)return;let e=BarcodeBase._getContentSize(this.hostElement),i=this._prevSz,s=null,r=null,o=1,n=!0;if(this._getAw()){o=this._getWzoom();r=e.height/o;n=t&&r===this._prevH;this._prevH=r;i=this._prevSz=null}else if(t){if(!i||!e.equals(i)){s={width:e.width+"px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}}else{s={width:"0px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}n||this._mergeOptions({desiredSize:s,height:r,unitSize:o})}static _getContentSize(t){let e=getComputedStyle(t);return new Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))}_getAw(){return this._aw}_setAw(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}}_getWzoom(){return this._wZoom}_setWzoom(t){asNumber(t);assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}}}BarcodeBase._ctrlTemplate="";const _copyObj="function"==typeof Object.assign?Object.assign:function(t,...e){for(let i of e)if(null!=i)for(let e in i)t[e]=i[e];return t};_registerModule("wijmo.barcode",selfModule);
|
|
14
|
+
import{asEnum,Control,Size,Event,toggleClass,asNumber,assert,isIE,ControlStateClsNames,ControlClsNames,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.barcode";const alignmentMap={center:"middle",left:"start",right:"end"};export class SVGRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.scale=i;this.color="rgb(0,0,0)";this.addGroup()}setColor(t){this.color=t}setBackgroundColor(t){const{dom:e}=this;e.style.backgroundColor=t}addGroup(){const{dom:t}=this;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)}drawRect(t){const{g:e,scale:i,color:s}=this,o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x",(t.x*i).toString());o.setAttribute("y",(t.y*i).toString());o.setAttribute("width",(t.width*i).toString());o.setAttribute("height",(t.height*i).toString());o.style.fill=s;e.appendChild(o)}drawText(t){const{g:e,scale:i,color:s,style:o}=this,r=document.createElementNS("http://www.w3.org/2000/svg","text");r.style.fill=s;r.style.fontSize=o.fontSize;r.style.fontFamily=o.fontFamily;r.style.fontStyle=t.fontStyle||o.fontStyle;r.style.fontWeight=t.fontWeight||o.fontWeight;r.style.textDecoration=t.textDecoration||o.textDecoration;r.style.textAnchor=alignmentMap[t.textAlign||o.textAlign];r.textContent=t.text;r.textContent=this.clipString(t,r);const n=this._measureText(r);r.setAttribute("y",(t.y*i+Math.abs(n.y)).toString());r.setAttribute("x",(t.x*i).toString());e.appendChild(r)}clipString(t,e){const{scale:i}=this;let{text:s,maxWidth:o}=t;const r=this._measureText(e);o*=i;if(r.width>o){const e=Math.floor(o/r.width*s.length);return t.text.substr(0,e)}return s}clear(){const{dom:t}=this;t.removeChild(this.g);this.addGroup()}_measureText(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);const i=t.getBBox();document.body.removeChild(e);return i}getDataUrl(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)}}export class CanvasRenderContext{constructor(t,e,i){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=i}setColor(t){this.ctx.fillStyle=t}setBackgroundColor(t){const{ctx:e,dom:i}=this;e.save();e.fillStyle=t;e.fillRect(0,0,i.width,i.height);e.restore()}drawRect(t){const{ctx:e,scale:i}=this;e.fillRect(t.x*i,t.y*i,t.width*i,t.height*i)}drawText(t){const{ctx:e,style:i,scale:s}=this;e.save();e.font=`${t.fontStyle||i.fontStyle} ${t.fontWeight||i.fontWeight} ${i.fontSize} ${i.fontFamily}`;e.textAlign=t.textAlign||i.textAlign;e.textBaseline="bottom";const o=t.x*s,r=t.y*s,n=this.clipString(t);e.fillText(n,o,r+i.fontHeight);this.drawTextDecorationLine(n,o,r,t.textDecoration||i.textDecoration);e.restore()}clipString(t){const{ctx:e,scale:i}=this;let{text:s,maxWidth:o}=t;const r=e.measureText(s);o*=i;if(r.width>o){const e=Math.floor(o/r.width*s.length);return t.text.substr(0,e)}return s}drawTextDecorationLine(t,e,i,s){let o;switch(s){case"underline":o=.9;break;case"overline":o=.1;break;case"line-through":o=.5;break;default:return}const{ctx:r,style:{fontHeight:n}}=this,a=r.measureText(t).width;switch(r.textAlign){case"center":e-=a/2;break;case"right":e-=a}r.lineWidth=1;r.beginPath();const h=n*o+i;r.moveTo(e,h);r.lineTo(e+a,h);r.stroke()}clear(){const{ctx:t,dom:e}=this;t.clearRect(0,0,e.width,e.height)}getImageData(){const{ctx:t,dom:e}=this;return t.getImageData(0,0,e.width,e.height)}getDataUrl(){return this.dom.toDataURL()}}export var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode||(_errorCode={}));export class BaseException extends Error{constructor(t){super();this.code=t||_errorCode.Unknown}}export const ErrorCode=_errorCode;export class InvalidOptionsException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidOptions);this.name="InvalidOptionsException";this.message=`${JSON.stringify(t)} is not valid options. ${e}`;this.descriptor={source:t,message:this.message}}}export class InvalidBarcodeTypeException extends BaseException{constructor(t){super(_errorCode.InvalidBarcodeType);this.name="InvalidBarcodeTypeException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}export class InvalidRenderException extends BaseException{constructor(t){super(_errorCode.InvalidRenderType);this.name="InvalidRenderException";this.message=t+" is not support!";this.descriptor={source:t,message:this.message}}}export class MethodNotImplementException extends BaseException{constructor(t,e){super(_errorCode.MethodNotImplement);this.name="MethodNotImplementException";this.message=`${t} is not a method! ${e}`;this.descriptor={source:t,message:this.message}}}export class InvalidTextException extends BaseException{constructor(t,e=""){super(_errorCode.InvalidText);this.name="InvalidTextException";this.message=t?`${t} is invalid. ${e}`:"Text is required.";this.descriptor={source:t,message:this.message}}}export class InvalidCharacterException extends BaseException{constructor(t){super(_errorCode.InvalidCharacter);this.name="InvalidCharacterException";this.message=t+" is invalid.";this.descriptor={source:t,message:this.message}}}export class TextTooLongException extends BaseException{constructor(){super(_errorCode.TextTooLong);this.name="TextTooLongException";this.message="Text is too long to encode";this.descriptor={source:null,message:this.message}}}export class GroupSizeOverflowException extends BaseException{constructor(t){super(_errorCode.GroupSizeOverflow);this.name="GroupSizeOverflowException";this.message=`Group size is ${t}. The max group size is 9.`;this.descriptor={source:t,message:this.message}}}function createRenderDom(t,e){let i;if("svg"===t){i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg")}else i=document.createElement("canvas");i.setAttribute("width",e.width);i.setAttribute("height",e.height);return i}export class BarcodeRender{constructor(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;const i=this.style.unitValue;this.size={width:e.size.width*i,height:e.size.height*i};const s=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(s,this.style,i);break;case"canvas":this.context=new CanvasRenderContext(s,this.style,i);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(s);this.renderDom=s}render(){const{style:t,barcode:{shapes:e}}=this,i=this.context;i.clear();i.setColor(t.color);i.setBackgroundColor(t.backgroundColor);e.forEach(t=>{"rect"===t.type&&i.drawRect(t);"text"===t.type&&i.drawText(t)});return this}getImageData(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()}getDataUrl(){return this.context.getDataUrl()}destroy(){this.container&&this.container.removeChild(this.renderDom)}getSize(){return this.size}}function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t="",e=1,i){let s=0,o=t.length,r=0;for(;s<o;){i(t.substring(s,s+e),r);s+=e;r++}}function sliceArray(t=[],e=1,i){let s=0,o=t.length,r=0;for(;s<o;){i(t.slice(s,s+e),r);s+=e;r++}}function str2Array(t=""){return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t=""){const e=str2Array(t),i=[];e.forEach(t=>{if("0"===t)i.push(0);else if(i[i.length-1]&&0!==i[i.length]){let t=i.pop();i.push(++t)}else i.push(1)});return i}function convertRadix(t,e=2){return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t="",e=0){if("number"==typeof t)return t;const i=parseFloat(t);return isNaN(i)?e:i}function getUnit(t=""){const e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e="length"){let i=0;t.forEach(t=>{t[e]>i&&(i=t[e])});return i}function assign(t,...e){if(isFunction(Object.assign))return Object.assign(t,...e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");const i=Object(t);for(let t=0;t<e.length;t++){const s=e[t];if(null!=s)for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(i[t]=s[t])}return i}function deepMerge(t,...e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach(e=>{if(e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(null!=e[i]&&"object"==typeof e[i]&&"object"==typeof t[i]?t[i]=deepMerge({},t[i]||{},e[i]):t[i]=e[i])});return t}function deepMergeAll(...t){return deepMerge({},...t)}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);const i=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==i.length||0==e)return"";if(i.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");let s="";for(let t=0;t<e;t++)s+=i;return s}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&Number.isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(let i=0;i<t.length;i++)t[i]=e;return t}function strPadStart(t,e,i){if(isFunction(t.padStart))return t.padStart(e,i);e>>=0;i=String(void 0!==i?i:" ");if(t.length>e)return t;(e-=t.length)>i.length&&(i+=strRepeat(i,e/i.length));return i.slice(0,e)+String(t)}const plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){let i,s;if(isFinite(e)){i=0;s=e}else{i=e.from;s=e.to+1}for(;i<s;i++)t(i)}function toZeroOnePattern(t,e){const i=e?isEven:isOdd;return t.reduce((t,e,s)=>{i(s)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t},"")}function range(t,e){const i=[];for(;t<e;){i.push(t);t++}i.push(e);return i}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});const e=Object.keys(t).reduce((e,i)=>{e[t[i]]=i;return e},{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}export const Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};export class Option{constructor(t={}){this.originConfig=t;this.type=t.type;this.penddingMerge=[]}static setCustomDefaultOptions(t){Option.CustomDefaultOptions=t}spawn(t){return new Option(Utils.deepMergeAll(this.originConfig,t))}merge(t){this.penddingMerge.unshift(t)}_getUnitValue(t){t=Utils.fixSize2PixelDefault(t);return Utils.convertUnit(t)}getMergedOption(){return Utils.deepMergeAll(Option.DefaultOptions,...this.penddingMerge,Option.CustomDefaultOptions,this.originConfig)}getConfig(t){const e=this.getMergedOption();let{text:i,quietZone:s,height:o,labelPosition:r,desiredSize:n,showLabel:a,font:h,backgroundColor:l,color:c,renderType:d,unitSize:u,hideExtraChecksum:p}=e;const g={text:i,isLabelBottom:!1,hideExtraChecksum:p};if(!Utils.isDefined(i))throw new InvalidTextException;g.text+="";Utils.isDefined(r)&&(g.isLabelBottom="top"!==r);h=Utils.deepMergeAll(h);h.fontSize=Utils.fixSize2PixelDefault(h.fontSize);const f=Utils.measureText(i,h);g.showLabel=a;t=t||this._getUnitValue(u);const m=a?f/t:0;g.fontSizeInUnit=m;const x={};for(const e in s)if(s.hasOwnProperty(e)){const i=s[e];if(Utils.isNumberLike(i)){const t=+i;x[e]=t}else{const s=Utils.convertUnit(i);x[e]=s/t}}g.quietZone=x;if(n){g.containerWidth=Utils.convertUnit(Utils.fixSize2PixelDefault(n.width));g.containerHeight=Utils.convertUnit(Utils.fixSize2PixelDefault(n.height));g.desiredSize=n}if(Utils.isDefined(o))if(n){const e=a?g.containerHeight-f:g.containerHeight;g.height=e/t-x.top-x.bottom}else Utils.isNumberLike(o)?g.height=+o-m-x.top-x.bottom:g.height=Utils.convertUnit(o)/t-m-x.top-x.bottom;return{config:e,encodeConfig:g,style:Utils.deepMergeAll({backgroundColor:l,color:c,renderType:d,unitValue:t,fontSize:h.fontSize,fontHeight:f},h)}}getOriginConfig(){return this.originConfig}getType(){return this.type}}Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};function _getProtos(t){var e=[];if(t&&t instanceof Function){let i=t;e.push(i);for(;i;){const t=Object.getPrototypeOf(i);if(!t||t===Object||t===Function.prototype)break;i=t;e.push(i)}}return e}export function _getDefaultConfig(t,e){var i=[{type:e}];_getProtos(t).forEach(t=>{t.DefaultConfig&&i.unshift(t.DefaultConfig)});return Utils.deepMergeAll(Option.DefaultOptions,...i,Option.CustomDefaultOptions)}export class _EnumDictionary{constructor(t,e){this._keys={};this._values={};for(const i in t)if("string"==typeof t[i]){const s=parseInt(i),o=e(t[s]);this._keys[s]=o;this._values[o]=s}}getEnumByString(t){var e=this._values[t];if(void 0===e)throw`Unknown Barcode internal value '${t}'`;return e}getStringByEnum(t){return this._keys[t]}}export class Area{constructor(t=0,e=0){this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}append(t){this.children.push(t)}_makeRect(t,e,i,s){return{x:t,y:e,height:s,width:i,type:"rect"}}toShapes(){const{x:t,y:e,width:i,height:s,style:{border:o,margin:r}}=this,n=[],a=o.left+o.right+i,h=o.top+o.bottom+s,l=t+r.left,c=e+r.top;o.top&&n.push(this._makeRect(l,c,a,o.top));o.right&&n.push(this._makeRect(l+a-o.right,c,o.right,h));o.bottom&&n.push(this._makeRect(l,c+h-o.bottom,a,o.bottom));o.left&&n.push(this._makeRect(l,c,o.left,h));return n}getSize(){const{width:t,height:e,offsetBox:i}=this;return{width:t+i.width,height:e+i.height}}visiable(){return this.width>0&&this.height>0}setX(t){this.x=t;this._updateBox()}setY(t){this.y=t;this._updateBox()}updateContentSize(t,e){this.width=t;this.height=e;this._updateBox()}_fixOpt(t,e){if(Utils.isNumberLike(t[e])){const i=t[e];t[e]={top:i,right:i,bottom:i,left:i}}}setStyle(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=Utils.deepMergeAll(this.style,t);this._updateBox()}_updateBox(){const{x:t,y:e,width:i,height:s,style:{padding:o,border:r,margin:n}}=this;this.offsetBox={x:t+o.left+r.left+n.left,y:e+o.top+r.top+n.top,width:n.left+r.left+r.right+n.right,height:n.top+r.top+r.bottom+n.bottom};const a=i-o.left-o.right,h=s-o.top-o.bottom;this.contentBox={width:a>=0?a:0,height:h>=0?h:0}}}export class HorizontalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this,i=super.toShapes(),s=e.y;let o=0;t.forEach(t=>{const r=e.x+o;t.toShapes().forEach(t=>{t.x+=r;t.y+=s;i.push(t)});const n=t.getSize();o+=n.width});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.height=Math.max(i.height,t.height);t.width+=i.width;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}export class VerticalLayoutArea extends Area{toShapes(){this._updateContentSize();const{children:t,offsetBox:e}=this,i=super.toShapes(),s=e.x;let o=0;t.forEach(t=>{const r=e.y+o;t.toShapes().forEach(t=>{t.x+=s;t.y+=r;i.push(t)});const n=t.getSize();o+=n.height});return i}getSize(){this._updateContentSize();return super.getSize()}_updateContentSize(){const{children:t,style:{padding:e}}=this,i=t.reduce((t,e)=>{const i=e.getSize();t.width=Math.max(i.width,t.width);t.height+=i.height;return t},{width:0,height:0});this.updateContentSize(i.width+e.left+e.right,i.height+e.top+e.bottom)}}export class MatrixSymbolArea extends Area{constructor(t,e,i){super(t,e);this._xPosition=0;this._yPosition=0;this._lastMaxHeight=0;this._rowHeight=0;this._rowHeight=i}append(t,e){if(!t||!e)return;this._autoWrap(t);const{children:i,_xPosition:s,_yPosition:o}=this,r={width:t,height:e,x:s,y:o};i.push(r);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}_autoWrap(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}}_checkNeedWrap(t){const{_xPosition:e,contentBox:{width:i}}=this;return i-e-t<0}space(t=1){this._autoWrap(t);this._xPosition+=t}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e}=this,i=super.toShapes();e.forEach(e=>{e.x+=t.x;e.y+=t.y;e.type="rect";i.push(e)});return i}}export class SymbolArea extends Area{constructor(t,e){super(t,e);this._lastIsBar=!1;this._cacheNumber=0;this._position=0}append(t,e,i){if(!t)return;const{children:s,_position:o}=this,r={width:t,x:o,barHeight:e,offsetY:i};s.push(r);this._position+=t}space(t=1){this._position+=t}_appendModule(t){const e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++}_flash(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}}fromPattern(t){Utils.str2Array(t).forEach(t=>{this._appendModule(t)});this._flash()}getContentBox(){return this.contentBox}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,contentBox:{height:i}}=this,s=super.toShapes();e.forEach(e=>{s.push({type:"rect",x:e.x+t.x,y:t.y+(e.offsetY||0),width:e.width,height:e.barHeight||i})});return s}}export class LabelArea extends Area{constructor(t,e,i){super(t,e);this._textAlign=i}toShapes(){if(!this.visiable())return[];const{offsetBox:t,children:e,_textAlign:i,contentBox:{width:s}}=this,o=super.toShapes();e.forEach(e=>{let r=t.x;switch(i){case"center":r+=s/2;break;case"right":r+=s}o.push({x:r+(e.x||0),y:t.y+(e.y||0),textAlign:i,maxWidth:s,type:"text",text:e.text})});return o}}export class MatrixBuilder{constructor(t,e){this.data=[];this.data=[];this.row=t;this.col=e}add(t,e,i){(this.data[t]||Utils.fillArray(new Array(this.col),null))[e]=i;this.data[t]=[]}toMatrix(){const t=[];Utils.loop(e=>{t.push(this.data[e]||Utils.fillArray(new Array(this.col),null))},this.row);return t}}export class BitBuffer{constructor(t=[]){this.buffer=t;this.length=8*t.length;this.index=0}putBit(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1}putBitAt(t,e){const{length:i}=this,s=new BitBuffer;for(let o=0;o<i;o++)o===e?s.putBit(t):s.putBit(this.getAt(o));this.buffer=s.buffer;this.length=s.length}put(t,e){for(let i=0;i<e;i+=1)this.putBit(1==(t>>>e-i-1&1))}putBits(t){this.put(parseInt(t,2),t.length)}getAt(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)}getBuffer(){return this.buffer}getGroupedBits(t){let e=0;const i=[];for(;e<this.length;){let s="",o=e,r=e+t;for(;o<r;o++)s+=this.getAt(o)?1:0;e=r;i.push(parseInt(s,2))}return i}next(){this.index++;return this.getAt(this.index-1)}}export class BarcodeEncoder{constructor(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}validate(){}applyDesiredSize(t){const{config:e,encodeConfig:i,style:s}=this._option.getConfig(t);this.config=e;this.encodeConfig=i;this.style=s;this.useDesiredSize=!!i.desiredSize}afterApplyDesiredSize(){}toSymbol(){this.validate();const t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)}}export class TwoDimensionalBarcode extends BarcodeEncoder{adjustDesiredSize(){const{width:t,height:e}=this.size,{desiredSize:i,containerWidth:s,containerHeight:o}=this.encodeConfig;let r=Math.min(s/t,o/e);if(i.forceRounding){r=~~r;r=r<1?1:r}this.applyDesiredSize(r)}convertToShape(t,e){const{quietZone:i}=this.encodeConfig,s=t[0].length+i.right+i.left,o=t.length+i.top+i.bottom,r=new VerticalLayoutArea,n=new MatrixSymbolArea(s,o,1);n.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});r.append(n);if(!e){t.forEach(t=>{t.forEach(t=>{t?n.append(1,1):n.space()})});this.shapes=r.toShapes()}this.size=r.getSize()}}export class OneDimensionalBarcode extends BarcodeEncoder{constructor(t){t.merge(OneDimensionalBarcode.DefaultConfig);super(t);this.label=""}adjustDesiredSize(){const{width:t}=this.size,{desiredSize:e,containerWidth:i}=this.encodeConfig;let s=i/t;if(e.forceRounding){s=~~s;s=s<1?1:s}this.applyDesiredSize(s)}convertToShape(t,e){const{label:i,encodeConfig:{quietZone:s,isLabelBottom:o,height:r,showLabel:n,fontSizeInUnit:a},style:{textAlign:h}}=this;let l=0;i&&n&&(l=a);const c=t.length+s.right+s.left,d=r+s.top+s.bottom,u=new VerticalLayoutArea,p=new SymbolArea(c,d);p.setStyle({padding:{top:s.top,right:s.right,bottom:s.bottom,left:s.left}});const g=p.getSize(),f=new LabelArea(g.width,l,h);if(o){u.append(p);u.append(f)}else{u.append(f);u.append(p)}if(!e){p.fromPattern(t);f.append({text:i});this.shapes=u.toShapes()}this.size=u.getSize()}}OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};const FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";export const Constants={FNC1:"Ï",FNC2:"Ê",FNC3:"É",DataMatrixFNC1:" ",DataMatrixMacro05:" ",DataMatrixMacro06:" "};export const encoders={};export class Barcode{constructor(...t){let e,i,s;if(t.length>=3)[e,i,s]=t;else if(2===t.length)Utils.isFunction(t[1])?[i,s]=t:[e,i]=t;else{if(1!==t.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");[i]=t}this.dom="string"==typeof e?document.querySelector(e):e;this.callback=s&&s.bind(this);this.setOption(i)}static getImageData(t={}){return new Barcode(t).getImageData()}getImageData(){return this.render.getImageData()}static getDataUrl(t={}){return new Barcode(t).getDataUrl()}getDataUrl(){return this.render.getDataUrl()}static setDefaultOptions(t={}){Option.setCustomDefaultOptions(t)}static registerEncoder(t,e){encoders[t]=e;Barcode.supportType.push(t)}static registerPlugin(t,e){Utils.registerPlugin(t,e)}mergeOption(t){const e=this.option.spawn(t);this.update(e);return this}setOption(t){this.update(new Option(t));return this}getOption(){return this.option.getMergedOption()}update(t){const e=t.getType(),i=encoders[e];if(!i)throw new InvalidBarcodeTypeException(e);const s=new i(t);this.destroy();const o=new BarcodeRender(this.dom,s);o.render();this.render=o;this.option=t;Utils.isFunction(this.callback)&&this.callback()}refresh(){this.render.render();Utils.isFunction(this.callback)&&this.callback()}getSize(){return this.render.getSize()}destroy(){if(this.render){this.render.destroy();this.render=null}}}Barcode.supportType=[];Barcode.constants=Constants;Barcode.ErrorCode=ErrorCode;Barcode.registerPlugin("measureText",(t,e)=>{const i=document.createElement("span");i.style.visibility="hidden";i.style.position="absolute";i.style.lineHeight="normal";i.textContent=t;Object.keys(e).forEach(t=>{i.style[t]=e[t]});document.body.appendChild(i);const s=i.getBoundingClientRect();document.body.removeChild(i);return s.height});Barcode.registerPlugin("convertUnit",t=>{const e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);const i=e.getBoundingClientRect();document.body.removeChild(e);return i.width});export const BarcodeClsNames={hostElement:"wj-barcode"};export var RenderType;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType||(RenderType={}));export var LabelPosition;!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition||(LabelPosition={}));export var NarrowToWideRatio;!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio||(NarrowToWideRatio={}));export class _RenderTypeConvertor{static stringToEnum(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw`Unknown Barcode internal renderType '${t}'`}static enumToString(t){return RenderType[asEnum(t,RenderType)].toLowerCase()}}export class _LabelPositionConvertor{static stringToEnum(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw`Unknown Barcode internal labelPosition '${t}'`}static enumToString(t){return LabelPosition[asEnum(t,LabelPosition)].toLowerCase()}}export class _NarrowWideRatioConvertor{static stringToEnum(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw`Unknown nwRatio internal value '${t}'`}static enumToString(t){let e;switch(asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e}}export class BarcodeBase extends Control{constructor(t,e){super(t,null,!0);this._state={};this._isUpd=0;this._isValid=!0;this._aw=!1;this._wZoom=1;this.isValidChanged=new Event;const i=this.getTemplate();this.applyTemplate(`${BarcodeClsNames.hostElement} ${ControlClsNames.hostElement}`,i,{});isIE()||(this.hostElement.style.lineHeight="0px");this._state=this._getDefaults();this._isUpd++;this.initialize(e);this._updateSize();this._isUpd--;this._mergeOptions({});this.invalidate()}static get controlTemplate(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate}static set controlTemplate(t){BarcodeBase._ctrlTemplate=t}initialize(t){this._isUpd++;try{super.initialize(t)}finally{this._isUpd--}!this._isUpd&&t&&Object.keys(t).length&&this._mergeOptions({})}static _getClassDefaults(){const t=this.type;return _getDefaultConfig(encoders[t],t)}_getDefaults(){const t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return Utils.deepMergeAll(t._defaults)}get value(){return this._getProp("text")}set value(t){this._setProp("text",t)}get quietZone(){return this._getProp("quietZone")}set quietZone(t){this._setProp("quietZone",t)}get renderType(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))}set renderType(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))}get color(){return this._getProp("color")}set color(t){this._setProp("color",t)}get backgroundColor(){return this._getProp("backgroundColor")}set backgroundColor(t){this._setProp("backgroundColor",t)}get hideExtraChecksum(){return this._getProp("hideExtraChecksum")}set hideExtraChecksum(t){this._setProp("hideExtraChecksum",t)}get font(){return this._getProp("font")}set font(t){this._setProp("font",t)}get isValid(){return this._isValid}onIsValidChanged(t){this.isValidChanged.raise(this,t)}refresh(t=!0){super.refresh(t);t?this._updateSize():this._bc.refresh()}getImageData(){return this._bc.getImageData()}getDataUrl(){return this._bc.getDataUrl()}getSize(){var t=new Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t}_mergeOptions(t){let e,i=this._bc,s=_copyObj(this._state,t);if(!this._isUpd){const t=s.text;if(null==t||""===t){if(i){i.destroy();this._bc=i=null}}else try{i?i.setOption(s):this._bc=i=new Barcode(this.hostElement,s)}catch(t){e=t}}let o=!0;if(e){if(i){i.destroy();this._bc=i=null}if(e.code!==_errorCode.InvalidText)throw e;o=!1}this._state=s;this._setValid(o)}_setValid(t){if(this._isValid!==t){this._isValid=t;toggleClass(this.hostElement,ControlStateClsNames.invalid,!t);this.onIsValidChanged()}}_setProp(t,e){this._mergeOptions({[t]:e})}_getProp(t){const e=this._bc;return this._state[t]||e&&e.getOption()[t]}_updateSize(t=!0){if(!this.hostElement)return;let e=BarcodeBase._getContentSize(this.hostElement),i=this._prevSz,s=null,o=null,r=1,n=!0;if(this._getAw()){r=this._getWzoom();o=e.height/r;n=t&&o===this._prevH;this._prevH=o;i=this._prevSz=null}else if(t){if(!i||!e.equals(i)){s={width:e.width+"px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}}else{s={width:"0px",height:e.height+"px",forceRounding:!1};n=!1;this._prevSz=e;this._prevH=null}n||this._mergeOptions({desiredSize:s,height:o,unitSize:r})}static _getContentSize(t){const e=getComputedStyle(t);return new Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))}_getAw(){return this._aw}_setAw(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}}_getWzoom(){return this._wZoom}_setWzoom(t){asNumber(t);assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}}}BarcodeBase._ctrlTemplate="";const _copyObj="function"==typeof Object.assign?Object.assign:(t,...e)=>{for(const i of e)if(null!=i)for(const e in i)t[e]=i[e];return t};_registerModule("wijmo.barcode",selfModule);
|
package/es5-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}();import{asEnum,Control,Size,Event,toggleClass,asNumber,assert,isIE,ControlStateClsNames,ControlClsNames,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.barcode";var alignmentMap={center:"middle",left:"start",right:"end"},SVGRenderContext=function(){function SVGRenderContext(t,e,o){this.dom=t;this.style=e;this.scale=o;this.color="rgb(0,0,0)";this.addGroup()}SVGRenderContext.prototype.setColor=function(t){this.color=t};SVGRenderContext.prototype.setBackgroundColor=function(t){this.dom.style.backgroundColor=t};SVGRenderContext.prototype.addGroup=function(){var t=this.dom;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)};SVGRenderContext.prototype.drawRect=function(t){var e=this.g,o=this.scale,r=this.color,i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x",(t.x*o).toString());i.setAttribute("y",(t.y*o).toString());i.setAttribute("width",(t.width*o).toString());i.setAttribute("height",(t.height*o).toString());i.style.fill=r;e.appendChild(i)};SVGRenderContext.prototype.drawText=function(t){var e=this.g,o=this.scale,r=this.color,i=this.style,n=document.createElementNS("http://www.w3.org/2000/svg","text");n.style.fill=r;n.style.fontSize=i.fontSize;n.style.fontFamily=i.fontFamily;n.style.fontStyle=t.fontStyle||i.fontStyle;n.style.fontWeight=t.fontWeight||i.fontWeight;n.style.textDecoration=t.textDecoration||i.textDecoration;n.style.textAnchor=alignmentMap[t.textAlign||i.textAlign];n.textContent=t.text;n.textContent=this.clipString(t,n);var a=this._measureText(n);n.setAttribute("y",(t.y*o+Math.abs(a.y)).toString());n.setAttribute("x",(t.x*o).toString());e.appendChild(n)};SVGRenderContext.prototype.clipString=function(t,e){var o=this.scale,r=t.text,i=t.maxWidth,n=this._measureText(e);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};SVGRenderContext.prototype.clear=function(){this.dom.removeChild(this.g);this.addGroup()};SVGRenderContext.prototype._measureText=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);var o=t.getBBox();document.body.removeChild(e);return o};SVGRenderContext.prototype.getDataUrl=function(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)};return SVGRenderContext}();export{SVGRenderContext};var CanvasRenderContext=function(){function CanvasRenderContext(t,e,o){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=o}CanvasRenderContext.prototype.setColor=function(t){this.ctx.fillStyle=t};CanvasRenderContext.prototype.setBackgroundColor=function(t){var e=this.ctx,o=this.dom;e.save();e.fillStyle=t;e.fillRect(0,0,o.width,o.height);e.restore()};CanvasRenderContext.prototype.drawRect=function(t){var e=this.ctx,o=this.scale;e.fillRect(t.x*o,t.y*o,t.width*o,t.height*o)};CanvasRenderContext.prototype.drawText=function(t){var e=this.ctx,o=this.style,r=this.scale;e.save();e.font=(t.fontStyle||o.fontStyle)+" "+(t.fontWeight||o.fontWeight)+" "+o.fontSize+" "+o.fontFamily;e.textAlign=t.textAlign||o.textAlign;e.textBaseline="bottom";var i=t.x*r,n=t.y*r,a=this.clipString(t);e.fillText(a,i,n+o.fontHeight);this.drawTextDecorationLine(a,i,n,t.textDecoration||o.textDecoration);e.restore()};CanvasRenderContext.prototype.clipString=function(t){var e=this.ctx,o=this.scale,r=t.text,i=t.maxWidth,n=e.measureText(r);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};CanvasRenderContext.prototype.drawTextDecorationLine=function(t,e,o,r){var i;switch(r){case"underline":i=.9;break;case"overline":i=.1;break;case"line-through":i=.5;break;default:return}var n=this.ctx,a=this.style.fontHeight,s=n.measureText(t).width;switch(n.textAlign){case"center":e-=s/2;break;case"right":e-=s}n.lineWidth=1;n.beginPath();var c=a*i+o;n.moveTo(e,c);n.lineTo(e+s,c);n.stroke()};CanvasRenderContext.prototype.clear=function(){var t=this.ctx,e=this.dom;t.clearRect(0,0,e.width,e.height)};CanvasRenderContext.prototype.getImageData=function(){var t=this.ctx,e=this.dom;return t.getImageData(0,0,e.width,e.height)};CanvasRenderContext.prototype.getDataUrl=function(){return this.dom.toDataURL()};return CanvasRenderContext}();export{CanvasRenderContext};export var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode||(_errorCode={}));var BaseException=function(t){__extends(BaseException,t);function BaseException(e){var o=t.call(this)||this;o.code=e||_errorCode.Unknown;return o}return BaseException}(Error);export{BaseException};export var ErrorCode=_errorCode;var InvalidOptionsException=function(t){__extends(InvalidOptionsException,t);function InvalidOptionsException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidOptions)||this;r.name="InvalidOptionsException";r.message=JSON.stringify(e)+" is not valid options. "+o;r.descriptor={source:e,message:r.message};return r}return InvalidOptionsException}(BaseException);export{InvalidOptionsException};var InvalidBarcodeTypeException=function(t){__extends(InvalidBarcodeTypeException,t);function InvalidBarcodeTypeException(e){var o=t.call(this,_errorCode.InvalidBarcodeType)||this;o.name="InvalidBarcodeTypeException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidBarcodeTypeException}(BaseException);export{InvalidBarcodeTypeException};var InvalidRenderException=function(t){__extends(InvalidRenderException,t);function InvalidRenderException(e){var o=t.call(this,_errorCode.InvalidRenderType)||this;o.name="InvalidRenderException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidRenderException}(BaseException);export{InvalidRenderException};var MethodNotImplementException=function(t){__extends(MethodNotImplementException,t);function MethodNotImplementException(e,o){var r=t.call(this,_errorCode.MethodNotImplement)||this;r.name="MethodNotImplementException";r.message=e+" is not a method! "+o;r.descriptor={source:e,message:r.message};return r}return MethodNotImplementException}(BaseException);export{MethodNotImplementException};var InvalidTextException=function(t){__extends(InvalidTextException,t);function InvalidTextException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidText)||this;r.name="InvalidTextException";r.message=e?e+" is invalid. "+o:"Text is required.";r.descriptor={source:e,message:r.message};return r}return InvalidTextException}(BaseException);export{InvalidTextException};var InvalidCharacterException=function(t){__extends(InvalidCharacterException,t);function InvalidCharacterException(e){var o=t.call(this,_errorCode.InvalidCharacter)||this;o.name="InvalidCharacterException";o.message=e+" is invalid.";o.descriptor={source:e,message:o.message};return o}return InvalidCharacterException}(BaseException);export{InvalidCharacterException};var TextTooLongException=function(t){__extends(TextTooLongException,t);function TextTooLongException(){var e=t.call(this,_errorCode.TextTooLong)||this;e.name="TextTooLongException";e.message="Text is too long to encode";e.descriptor={source:null,message:e.message};return e}return TextTooLongException}(BaseException);export{TextTooLongException};var GroupSizeOverflowException=function(t){__extends(GroupSizeOverflowException,t);function GroupSizeOverflowException(e){var o=t.call(this,_errorCode.GroupSizeOverflow)||this;o.name="GroupSizeOverflowException";o.message="Group size is "+e+". The max group size is 9.";o.descriptor={source:e,message:o.message};return o}return GroupSizeOverflowException}(BaseException);export{GroupSizeOverflowException};function createRenderDom(t,e){var o;"svg"===t?(o=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"):o=document.createElement("canvas");o.setAttribute("width",e.width);o.setAttribute("height",e.height);return o}var BarcodeRender=function(){function BarcodeRender(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;var o=this.style.unitValue;this.size={width:e.size.width*o,height:e.size.height*o};var r=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(r,this.style,o);break;case"canvas":this.context=new CanvasRenderContext(r,this.style,o);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(r);this.renderDom=r}BarcodeRender.prototype.render=function(){var t=this.style,e=this.barcode.shapes,o=this.context;o.clear();o.setColor(t.color);o.setBackgroundColor(t.backgroundColor);e.forEach((function(t){"rect"===t.type&&o.drawRect(t);"text"===t.type&&o.drawText(t)}));return this};BarcodeRender.prototype.getImageData=function(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()};BarcodeRender.prototype.getDataUrl=function(){return this.context.getDataUrl()};BarcodeRender.prototype.destroy=function(){this.container&&this.container.removeChild(this.renderDom)};BarcodeRender.prototype.getSize=function(){return this.size};return BarcodeRender}();export{BarcodeRender};function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t,e,o){void 0===t&&(t="");void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.substring(r,r+e),n);r+=e;n++}}function sliceArray(t,e,o){void 0===t&&(t=[]);void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.slice(r,r+e),n);r+=e;n++}}function str2Array(t){void 0===t&&(t="");return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t){void 0===t&&(t="");var e=str2Array(t),o=[];e.forEach((function(t){if("0"===t)o.push(0);else if(o[o.length-1]&&0!==o[o.length]){var e=o.pop();o.push(++e)}else o.push(1)}));return o}function convertRadix(t,e){void 0===e&&(e=2);return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t,e){void 0===t&&(t="");void 0===e&&(e=0);if("number"==typeof t)return t;var o=parseFloat(t);return isNaN(o)?e:o}function getUnit(t){void 0===t&&(t="");var e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e){void 0===e&&(e="length");var o=0;t.forEach((function(t){t[e]>o&&(o=t[e])}));return o}function assign(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(isFunction(Object.assign))return Object.assign.apply(Object,[t].concat(e));if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=0;i<e.length;i++){var n=e[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r}function deepMerge(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach((function(e){if(e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(null!=e[o]&&"object"==typeof e[o]&&"object"==typeof t[o]?t[o]=deepMerge({},t[o]||{},e[o]):t[o]=e[o])}));return t}function deepMergeAll(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return deepMerge.apply(void 0,[{}].concat(t))}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);var o=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==o.length||0==e)return"";if(o.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="",i=0;i<e;i++)r+=o;return r}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(var o=0;o<t.length;o++)t[o]=e;return t}function strPadStart(t,e,o){if(isFunction(t.padStart))return t.padStart(e,o);e>>=0;o=String(void 0!==o?o:" ");if(t.length>e)return t;(e-=t.length)>o.length&&(o+=strRepeat(o,e/o.length));return o.slice(0,e)+String(t)}var plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){var o,r;if(isFinite(e)){o=0;r=e}else{o=e.from;r=e.to+1}for(;o<r;o++)t(o)}function toZeroOnePattern(t,e){var o=e?isEven:isOdd;return t.reduce((function(t,e,r){o(r)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t}),"")}function range(t,e){for(var o=[];t<e;){o.push(t);t++}o.push(e);return o}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});var e=Object.keys(t).reduce((function(e,o){e[t[o]]=o;return e}),{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}export var Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};var Option=function(){function Option(t){void 0===t&&(t={});this.originConfig=t;this.type=t.type;this.penddingMerge=[]}Option.setCustomDefaultOptions=function(t){Option.CustomDefaultOptions=t};Option.prototype.spawn=function(t){return new Option(Utils.deepMergeAll(this.originConfig,t))};Option.prototype.merge=function(t){this.penddingMerge.unshift(t)};Option.prototype._getUnitValue=function(t){t=Utils.fixSize2PixelDefault(t);return Utils.convertUnit(t)};Option.prototype.getMergedOption=function(){return Utils.deepMergeAll.apply(Utils,[Option.DefaultOptions].concat(this.penddingMerge,[Option.CustomDefaultOptions,this.originConfig]))};Option.prototype.getConfig=function(t){var e=this.getMergedOption(),o=e.text,r=e.quietZone,i=e.height,n=e.labelPosition,a=e.desiredSize,s=e.showLabel,c=e.font,u=e.backgroundColor,p=e.color,h=e.renderType,l=e.unitSize,d={text:o,isLabelBottom:!1,hideExtraChecksum:e.hideExtraChecksum};if(!Utils.isDefined(o))throw new InvalidTextException;d.text+="";Utils.isDefined(n)&&(d.isLabelBottom="top"!==n);(c=Utils.deepMergeAll(c)).fontSize=Utils.fixSize2PixelDefault(c.fontSize);var f=Utils.measureText(o,c);d.showLabel=s;t=t||this._getUnitValue(l);var g=s?f/t:0;d.fontSizeInUnit=g;var y={};for(var v in r)if(r.hasOwnProperty(v)){var x=r[v];if(Utils.isNumberLike(x)){var m=+x;y[v]=m}else{var b=Utils.convertUnit(x);y[v]=b/t}}d.quietZone=y;if(a){d.containerWidth=Utils.convertUnit(Utils.fixSize2PixelDefault(a.width));d.containerHeight=Utils.convertUnit(Utils.fixSize2PixelDefault(a.height));d.desiredSize=a}if(Utils.isDefined(i))if(a){var _=s?d.containerHeight-f:d.containerHeight;d.height=_/t-y.top-y.bottom}else Utils.isNumberLike(i)?d.height=+i-g-y.top-y.bottom:d.height=Utils.convertUnit(i)/t-g-y.top-y.bottom;return{config:e,encodeConfig:d,style:Utils.deepMergeAll({backgroundColor:u,color:p,renderType:h,unitValue:t,fontSize:c.fontSize,fontHeight:f},c)}};Option.prototype.getOriginConfig=function(){return this.originConfig};Option.prototype.getType=function(){return this.type};Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};return Option}();export{Option};function _getProtos(t){var e=[];if(t&&t instanceof Function){var o=t;e.push(o);for(;o;){var r=Object.getPrototypeOf(o);if(!r||r===Object||r===Function.prototype)break;o=r;e.push(o)}}return e}export function _getDefaultConfig(t,e){var o=[{type:e}];_getProtos(t).forEach((function(t){t.DefaultConfig&&o.unshift(t.DefaultConfig)}));return Utils.deepMergeAll.apply(Utils,[Option.DefaultOptions].concat(o,[Option.CustomDefaultOptions]))}var _EnumDictionary=function(){function _EnumDictionary(t,e){this._keys={};this._values={};for(var o in t)if("string"==typeof t[o]){var r=parseInt(o),i=e(t[r]);this._keys[r]=i;this._values[i]=r}}_EnumDictionary.prototype.getEnumByString=function(t){var e=this._values[t];if(void 0===e)throw"Unknown Barcode internal value '"+t+"'";return e};_EnumDictionary.prototype.getStringByEnum=function(t){return this._keys[t]};return _EnumDictionary}();export{_EnumDictionary};var Area=function(){function Area(t,e){void 0===t&&(t=0);void 0===e&&(e=0);this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}Area.prototype.append=function(t){this.children.push(t)};Area.prototype._makeRect=function(t,e,o,r){return{x:t,y:e,height:r,width:o,type:"rect"}};Area.prototype.toShapes=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.border,s=n.margin,c=[],u=a.left+a.right+r,p=a.top+a.bottom+i,h=e+s.left,l=o+s.top;a.top&&c.push(this._makeRect(h,l,u,a.top));a.right&&c.push(this._makeRect(h+u-a.right,l,a.right,p));a.bottom&&c.push(this._makeRect(h,l+p-a.bottom,u,a.bottom));a.left&&c.push(this._makeRect(h,l,a.left,p));return c};Area.prototype.getSize=function(){var t=this.width,e=this.height,o=this.offsetBox;return{width:t+o.width,height:e+o.height}};Area.prototype.visiable=function(){return this.width>0&&this.height>0};Area.prototype.setX=function(t){this.x=t;this._updateBox()};Area.prototype.setY=function(t){this.y=t;this._updateBox()};Area.prototype.updateContentSize=function(t,e){this.width=t;this.height=e;this._updateBox()};Area.prototype._fixOpt=function(t,e){if(Utils.isNumberLike(t[e])){var o=t[e];t[e]={top:o,right:o,bottom:o,left:o}}};Area.prototype.setStyle=function(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=Utils.deepMergeAll(this.style,t);this._updateBox()};Area.prototype._updateBox=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.padding,s=n.border,c=n.margin;this.offsetBox={x:e+a.left+s.left+c.left,y:o+a.top+s.top+c.top,width:c.left+s.left+s.right+c.right,height:c.top+s.top+s.bottom+c.bottom};var u=r-a.left-a.right,p=i-a.top-a.bottom;this.contentBox={width:u>=0?u:0,height:p>=0?p:0}};return Area}();export{Area};var HorizontalLayoutArea=function(t){__extends(HorizontalLayoutArea,t);function HorizontalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}HorizontalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.y,n=0;e.forEach((function(t){var e=o.x+n;t.toShapes().forEach((function(t){t.x+=e;t.y+=i;r.push(t)}));var a=t.getSize();n+=a.width}));return r};HorizontalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};HorizontalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.height=Math.max(o.height,t.height);t.width+=o.width;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return HorizontalLayoutArea}(Area);export{HorizontalLayoutArea};var VerticalLayoutArea=function(t){__extends(VerticalLayoutArea,t);function VerticalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}VerticalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.x,n=0;e.forEach((function(t){var e=o.y+n;t.toShapes().forEach((function(t){t.x+=i;t.y+=e;r.push(t)}));var a=t.getSize();n+=a.height}));return r};VerticalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};VerticalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.width=Math.max(o.width,t.width);t.height+=o.height;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return VerticalLayoutArea}(Area);export{VerticalLayoutArea};var MatrixSymbolArea=function(t){__extends(MatrixSymbolArea,t);function MatrixSymbolArea(e,o,r){var i=t.call(this,e,o)||this;i._xPosition=0;i._yPosition=0;i._lastMaxHeight=0;i._rowHeight=0;i._rowHeight=r;return i}MatrixSymbolArea.prototype.append=function(t,e){if(t&&e){this._autoWrap(t);var o=this.children,r={width:t,height:e,x:this._xPosition,y:this._yPosition};o.push(r);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}};MatrixSymbolArea.prototype._autoWrap=function(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}};MatrixSymbolArea.prototype._checkNeedWrap=function(t){var e=this._xPosition;return this.contentBox.width-e-t<0};MatrixSymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._autoWrap(t);this._xPosition+=t};MatrixSymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=t.prototype.toShapes.call(this);o.forEach((function(t){t.x+=e.x;t.y+=e.y;t.type="rect";r.push(t)}));return r};return MatrixSymbolArea}(Area);export{MatrixSymbolArea};var SymbolArea=function(t){__extends(SymbolArea,t);function SymbolArea(e,o){var r=t.call(this,e,o)||this;r._lastIsBar=!1;r._cacheNumber=0;r._position=0;return r}SymbolArea.prototype.append=function(t,e,o){if(t){var r=this.children,i={width:t,x:this._position,barHeight:e,offsetY:o};r.push(i);this._position+=t}};SymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._position+=t};SymbolArea.prototype._appendModule=function(t){var e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++};SymbolArea.prototype._flash=function(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}};SymbolArea.prototype.fromPattern=function(t){var e=this;Utils.str2Array(t).forEach((function(t){return e._appendModule(t)}));this._flash()};SymbolArea.prototype.getContentBox=function(){return this.contentBox};SymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this.contentBox.height,i=t.prototype.toShapes.call(this);o.forEach((function(t){i.push({type:"rect",x:t.x+e.x,y:e.y+(t.offsetY||0),width:t.width,height:t.barHeight||r})}));return i};return SymbolArea}(Area);export{SymbolArea};var LabelArea=function(t){__extends(LabelArea,t);function LabelArea(e,o,r){var i=t.call(this,e,o)||this;i._textAlign=r;return i}LabelArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this._textAlign,i=this.contentBox.width,n=t.prototype.toShapes.call(this);o.forEach((function(t){var o=e.x;switch(r){case"center":o+=i/2;break;case"right":o+=i}n.push({x:o+(t.x||0),y:e.y+(t.y||0),textAlign:r,maxWidth:i,type:"text",text:t.text})}));return n};return LabelArea}(Area);export{LabelArea};var MatrixBuilder=function(){function MatrixBuilder(t,e){this.data=[];this.data=[];this.row=t;this.col=e}MatrixBuilder.prototype.add=function(t,e,o){(this.data[t]||Utils.fillArray(new Array(this.col),null))[e]=o;this.data[t]=[]};MatrixBuilder.prototype.toMatrix=function(){var t=this,e=[];Utils.loop((function(o){e.push(t.data[o]||Utils.fillArray(new Array(t.col),null))}),this.row);return e};return MatrixBuilder}();export{MatrixBuilder};var BitBuffer=function(){function BitBuffer(t){void 0===t&&(t=[]);this.buffer=t;this.length=8*t.length;this.index=0}BitBuffer.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1};BitBuffer.prototype.putBitAt=function(t,e){for(var o=this.length,r=new BitBuffer,i=0;i<o;i++)i===e?r.putBit(t):r.putBit(this.getAt(i));this.buffer=r.buffer;this.length=r.length};BitBuffer.prototype.put=function(t,e){for(var o=0;o<e;o+=1)this.putBit(1==(t>>>e-o-1&1))};BitBuffer.prototype.putBits=function(t){this.put(parseInt(t,2),t.length)};BitBuffer.prototype.getAt=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)};BitBuffer.prototype.getBuffer=function(){return this.buffer};BitBuffer.prototype.getGroupedBits=function(t){for(var e=0,o=[];e<this.length;){for(var r="",i=e,n=e+t;i<n;i++)r+=this.getAt(i)?1:0;e=n;o.push(parseInt(r,2))}return o};BitBuffer.prototype.next=function(){this.index++;return this.getAt(this.index-1)};return BitBuffer}();export{BitBuffer};var BarcodeEncoder=function(){function BarcodeEncoder(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}BarcodeEncoder.prototype.validate=function(){};BarcodeEncoder.prototype.applyDesiredSize=function(t){var e=this._option.getConfig(t),o=e.config,r=e.encodeConfig,i=e.style;this.config=o;this.encodeConfig=r;this.style=i;this.useDesiredSize=!!r.desiredSize};BarcodeEncoder.prototype.afterApplyDesiredSize=function(){};BarcodeEncoder.prototype.toSymbol=function(){this.validate();var t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)};return BarcodeEncoder}();export{BarcodeEncoder};var TwoDimensionalBarcode=function(t){__extends(TwoDimensionalBarcode,t);function TwoDimensionalBarcode(){return null!==t&&t.apply(this,arguments)||this}TwoDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size,e=t.width,o=t.height,r=this.encodeConfig,i=r.desiredSize,n=r.containerWidth,a=r.containerHeight,s=Math.min(n/e,a/o);i.forceRounding&&(s=(s=~~s)<1?1:s);this.applyDesiredSize(s)};TwoDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.encodeConfig.quietZone,r=t[0].length+o.right+o.left,i=t.length+o.top+o.bottom,n=new VerticalLayoutArea,a=new MatrixSymbolArea(r,i,1);a.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});n.append(a);if(!e){t.forEach((function(t){t.forEach((function(t){t?a.append(1,1):a.space()}))}));this.shapes=n.toShapes()}this.size=n.getSize()};return TwoDimensionalBarcode}(BarcodeEncoder);export{TwoDimensionalBarcode};var OneDimensionalBarcode=function(t){__extends(OneDimensionalBarcode,t);function OneDimensionalBarcode(e){var o=this;e.merge(OneDimensionalBarcode.DefaultConfig);(o=t.call(this,e)||this).label="";return o}OneDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size.width,e=this.encodeConfig,o=e.desiredSize,r=e.containerWidth/t;o.forceRounding&&(r=(r=~~r)<1?1:r);this.applyDesiredSize(r)};OneDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.label,r=this.encodeConfig,i=r.quietZone,n=r.isLabelBottom,a=r.height,s=r.showLabel,c=r.fontSizeInUnit,u=this.style.textAlign,p=0;o&&s&&(p=c);var h=t.length+i.right+i.left,l=a+i.top+i.bottom,d=new VerticalLayoutArea,f=new SymbolArea(h,l);f.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});var g=f.getSize(),y=new LabelArea(g.width,p,u);if(n){d.append(f);d.append(y)}else{d.append(y);d.append(f)}if(!e){f.fromPattern(t);y.append({text:o});this.shapes=d.toShapes()}this.size=d.getSize()};OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};return OneDimensionalBarcode}(BarcodeEncoder);export{OneDimensionalBarcode};var FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";export var Constants={FNC1:FNC1,FNC2:FNC2,FNC3:FNC3,DataMatrixFNC1:DataMatrixFNC1,DataMatrixMacro05:DataMatrixMacro05,DataMatrixMacro06:DataMatrixMacro06};export var encoders={};var Barcode=function(){function Barcode(){for(var t,e,o,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(r.length>=3)t=r[0],e=r[1],o=r[2];else if(2===r.length)Utils.isFunction(r[1])?(e=r[0],o=r[1]):(t=r[0],e=r[1]);else{if(1!==r.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");e=r[0]}this.dom="string"==typeof t?document.querySelector(t):t;this.callback=o&&o.bind(this);this.setOption(e)}Barcode.getImageData=function(t){void 0===t&&(t={});return new Barcode(t).getImageData()};Barcode.getDataUrl=function(t){void 0===t&&(t={});return new Barcode(t).getDataUrl()};Barcode.setDefaultOptions=function(t){void 0===t&&(t={});Option.setCustomDefaultOptions(t)};Barcode.registerEncoder=function(t,e){encoders[t]=e;Barcode.supportType.push(t)};Barcode.registerPlugin=function(t,e){Utils.registerPlugin(t,e)};Barcode.prototype.mergeOption=function(t){var e=this.option.spawn(t);this.update(e);return this};Barcode.prototype.setOption=function(t){this.update(new Option(t));return this};Barcode.prototype.getOption=function(){return this.option.getMergedOption()};Barcode.prototype.update=function(t){var e=t.getType(),o=encoders[e];if(!o)throw new InvalidBarcodeTypeException(e);var r=new o(t);this.destroy();var i=new BarcodeRender(this.dom,r);i.render();this.render=i;this.option=t;Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.refresh=function(){this.render.render();Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.getImageData=function(){return this.render.getImageData()};Barcode.prototype.getDataUrl=function(){return this.render.getDataUrl()};Barcode.prototype.getSize=function(){return this.render.getSize()};Barcode.prototype.destroy=function(){if(this.render){this.render.destroy();this.render=null}};Barcode.supportType=[];Barcode.constants=Constants;Barcode.ErrorCode=ErrorCode;return Barcode}();export{Barcode};Barcode.registerPlugin("measureText",(function(t,e){var o=document.createElement("span");o.style.visibility="hidden";o.style.position="absolute";o.style.lineHeight="normal";o.textContent=t;Object.keys(e).forEach((function(t){o.style[t]=e[t]}));document.body.appendChild(o);var r=o.getBoundingClientRect();document.body.removeChild(o);return r.height}));Barcode.registerPlugin("convertUnit",(function(t){var e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);var o=e.getBoundingClientRect();document.body.removeChild(e);return o.width}));export var BarcodeClsNames={hostElement:"wj-barcode"};export var RenderType;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType||(RenderType={}));export var LabelPosition;!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition||(LabelPosition={}));export var NarrowToWideRatio;!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio||(NarrowToWideRatio={}));var _RenderTypeConvertor=function(){function _RenderTypeConvertor(){}_RenderTypeConvertor.stringToEnum=function(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw"Unknown Barcode internal renderType '"+t+"'"};_RenderTypeConvertor.enumToString=function(t){return RenderType[asEnum(t,RenderType)].toLowerCase()};return _RenderTypeConvertor}();export{_RenderTypeConvertor};var _LabelPositionConvertor=function(){function _LabelPositionConvertor(){}_LabelPositionConvertor.stringToEnum=function(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw"Unknown Barcode internal labelPosition '"+t+"'"};_LabelPositionConvertor.enumToString=function(t){return LabelPosition[asEnum(t,LabelPosition)].toLowerCase()};return _LabelPositionConvertor}();export{_LabelPositionConvertor};var _NarrowWideRatioConvertor=function(){function _NarrowWideRatioConvertor(){}_NarrowWideRatioConvertor.stringToEnum=function(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw"Unknown nwRatio internal value '"+t+"'"};_NarrowWideRatioConvertor.enumToString=function(t){var e;switch(asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e};return _NarrowWideRatioConvertor}();export{_NarrowWideRatioConvertor};var BarcodeBase=function(t){__extends(BarcodeBase,t);function BarcodeBase(e,o){var r=t.call(this,e,null,!0)||this;r._state={};r._isUpd=0;r._isValid=!0;r._aw=!1;r._wZoom=1;r.isValidChanged=new Event;var i=r.getTemplate();r.applyTemplate(BarcodeClsNames.hostElement+" "+ControlClsNames.hostElement,i,{});isIE()||(r.hostElement.style.lineHeight="0px");r._state=r._getDefaults();r._isUpd++;r.initialize(o);r._updateSize();r._isUpd--;r._mergeOptions({});r.invalidate();return r}Object.defineProperty(BarcodeBase,"controlTemplate",{get:function(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate},set:function(t){BarcodeBase._ctrlTemplate=t},enumerable:!0,configurable:!0});BarcodeBase.prototype.initialize=function(e){this._isUpd++;try{t.prototype.initialize.call(this,e)}finally{this._isUpd--}!this._isUpd&&e&&Object.keys(e).length&&this._mergeOptions({})};BarcodeBase._getClassDefaults=function(){var t=this.type;return _getDefaultConfig(encoders[t],t)};BarcodeBase.prototype._getDefaults=function(){var t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return Utils.deepMergeAll(t._defaults)};Object.defineProperty(BarcodeBase.prototype,"value",{get:function(){return this._getProp("text")},set:function(t){this._setProp("text",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"quietZone",{get:function(){return this._getProp("quietZone")},set:function(t){this._setProp("quietZone",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"renderType",{get:function(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))},set:function(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"color",{get:function(){return this._getProp("color")},set:function(t){this._setProp("color",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"backgroundColor",{get:function(){return this._getProp("backgroundColor")},set:function(t){this._setProp("backgroundColor",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"hideExtraChecksum",{get:function(){return this._getProp("hideExtraChecksum")},set:function(t){this._setProp("hideExtraChecksum",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"font",{get:function(){return this._getProp("font")},set:function(t){this._setProp("font",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"isValid",{get:function(){return this._isValid},enumerable:!0,configurable:!0});BarcodeBase.prototype.onIsValidChanged=function(t){this.isValidChanged.raise(this,t)};BarcodeBase.prototype.refresh=function(e){void 0===e&&(e=!0);t.prototype.refresh.call(this,e);e?this._updateSize():this._bc.refresh()};BarcodeBase.prototype.getImageData=function(){return this._bc.getImageData()};BarcodeBase.prototype.getDataUrl=function(){return this._bc.getDataUrl()};BarcodeBase.prototype.getSize=function(){var t=new Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t};BarcodeBase.prototype._mergeOptions=function(t){var e,o=this._bc,r=_copyObj(this._state,t);if(!this._isUpd){var i=r.text;if(null==i||""===i){if(o){o.destroy();this._bc=o=null}}else try{o?o.setOption(r):this._bc=o=new Barcode(this.hostElement,r)}catch(t){e=t}}var n=!0;if(e){if(o){o.destroy();this._bc=o=null}if(e.code!==_errorCode.InvalidText)throw e;n=!1}this._state=r;this._setValid(n)};BarcodeBase.prototype._setValid=function(t){if(this._isValid!==t){this._isValid=t;toggleClass(this.hostElement,ControlStateClsNames.invalid,!t);this.onIsValidChanged()}};BarcodeBase.prototype._setProp=function(t,e){var o;this._mergeOptions(((o={})[t]=e,o))};BarcodeBase.prototype._getProp=function(t){var e=this._bc;return this._state[t]||e&&e.getOption()[t]};BarcodeBase.prototype._updateSize=function(t){void 0===t&&(t=!0);if(this.hostElement){var e=BarcodeBase._getContentSize(this.hostElement),o=this._prevSz,r=null,i=null,n=1,a=!0;if(this._getAw()){n=this._getWzoom();i=e.height/n;a=t&&i===this._prevH;this._prevH=i;o=this._prevSz=null}else if(t){if(!o||!e.equals(o)){r={width:e.width+"px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}}else{r={width:"0px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}a||this._mergeOptions({desiredSize:r,height:i,unitSize:n})}};BarcodeBase._getContentSize=function(t){var e=getComputedStyle(t);return new Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))};BarcodeBase.prototype._getAw=function(){return this._aw};BarcodeBase.prototype._setAw=function(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}};BarcodeBase.prototype._getWzoom=function(){return this._wZoom};BarcodeBase.prototype._setWzoom=function(t){asNumber(t);assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}};BarcodeBase._ctrlTemplate="";return BarcodeBase}(Control);export{BarcodeBase};var _copyObj="function"==typeof Object.assign?Object.assign:function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(null!=n)for(var a in n)t[a]=n[a]}return t};_registerModule("wijmo.barcode",selfModule);
|
|
14
|
+
var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}();import{asEnum,Control,Size,Event,toggleClass,asNumber,assert,isIE,ControlStateClsNames,ControlClsNames,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.barcode";var alignmentMap={center:"middle",left:"start",right:"end"},SVGRenderContext=function(){function SVGRenderContext(t,e,o){this.dom=t;this.style=e;this.scale=o;this.color="rgb(0,0,0)";this.addGroup()}SVGRenderContext.prototype.setColor=function(t){this.color=t};SVGRenderContext.prototype.setBackgroundColor=function(t){this.dom.style.backgroundColor=t};SVGRenderContext.prototype.addGroup=function(){var t=this.dom;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)};SVGRenderContext.prototype.drawRect=function(t){var e=this.g,o=this.scale,r=this.color,i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x",(t.x*o).toString());i.setAttribute("y",(t.y*o).toString());i.setAttribute("width",(t.width*o).toString());i.setAttribute("height",(t.height*o).toString());i.style.fill=r;e.appendChild(i)};SVGRenderContext.prototype.drawText=function(t){var e=this.g,o=this.scale,r=this.color,i=this.style,n=document.createElementNS("http://www.w3.org/2000/svg","text");n.style.fill=r;n.style.fontSize=i.fontSize;n.style.fontFamily=i.fontFamily;n.style.fontStyle=t.fontStyle||i.fontStyle;n.style.fontWeight=t.fontWeight||i.fontWeight;n.style.textDecoration=t.textDecoration||i.textDecoration;n.style.textAnchor=alignmentMap[t.textAlign||i.textAlign];n.textContent=t.text;n.textContent=this.clipString(t,n);var a=this._measureText(n);n.setAttribute("y",(t.y*o+Math.abs(a.y)).toString());n.setAttribute("x",(t.x*o).toString());e.appendChild(n)};SVGRenderContext.prototype.clipString=function(t,e){var o=this.scale,r=t.text,i=t.maxWidth,n=this._measureText(e);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};SVGRenderContext.prototype.clear=function(){this.dom.removeChild(this.g);this.addGroup()};SVGRenderContext.prototype._measureText=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);var o=t.getBBox();document.body.removeChild(e);return o};SVGRenderContext.prototype.getDataUrl=function(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)};return SVGRenderContext}();export{SVGRenderContext};var CanvasRenderContext=function(){function CanvasRenderContext(t,e,o){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=o}CanvasRenderContext.prototype.setColor=function(t){this.ctx.fillStyle=t};CanvasRenderContext.prototype.setBackgroundColor=function(t){var e=this.ctx,o=this.dom;e.save();e.fillStyle=t;e.fillRect(0,0,o.width,o.height);e.restore()};CanvasRenderContext.prototype.drawRect=function(t){var e=this.ctx,o=this.scale;e.fillRect(t.x*o,t.y*o,t.width*o,t.height*o)};CanvasRenderContext.prototype.drawText=function(t){var e=this.ctx,o=this.style,r=this.scale;e.save();e.font=(t.fontStyle||o.fontStyle)+" "+(t.fontWeight||o.fontWeight)+" "+o.fontSize+" "+o.fontFamily;e.textAlign=t.textAlign||o.textAlign;e.textBaseline="bottom";var i=t.x*r,n=t.y*r,a=this.clipString(t);e.fillText(a,i,n+o.fontHeight);this.drawTextDecorationLine(a,i,n,t.textDecoration||o.textDecoration);e.restore()};CanvasRenderContext.prototype.clipString=function(t){var e=this.ctx,o=this.scale,r=t.text,i=t.maxWidth,n=e.measureText(r);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};CanvasRenderContext.prototype.drawTextDecorationLine=function(t,e,o,r){var i;switch(r){case"underline":i=.9;break;case"overline":i=.1;break;case"line-through":i=.5;break;default:return}var n=this.ctx,a=this.style.fontHeight,s=n.measureText(t).width;switch(n.textAlign){case"center":e-=s/2;break;case"right":e-=s}n.lineWidth=1;n.beginPath();var c=a*i+o;n.moveTo(e,c);n.lineTo(e+s,c);n.stroke()};CanvasRenderContext.prototype.clear=function(){var t=this.ctx,e=this.dom;t.clearRect(0,0,e.width,e.height)};CanvasRenderContext.prototype.getImageData=function(){var t=this.ctx,e=this.dom;return t.getImageData(0,0,e.width,e.height)};CanvasRenderContext.prototype.getDataUrl=function(){return this.dom.toDataURL()};return CanvasRenderContext}();export{CanvasRenderContext};export var _errorCode;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode||(_errorCode={}));var BaseException=function(t){__extends(BaseException,t);function BaseException(e){var o=t.call(this)||this;o.code=e||_errorCode.Unknown;return o}return BaseException}(Error);export{BaseException};export var ErrorCode=_errorCode;var InvalidOptionsException=function(t){__extends(InvalidOptionsException,t);function InvalidOptionsException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidOptions)||this;r.name="InvalidOptionsException";r.message=JSON.stringify(e)+" is not valid options. "+o;r.descriptor={source:e,message:r.message};return r}return InvalidOptionsException}(BaseException);export{InvalidOptionsException};var InvalidBarcodeTypeException=function(t){__extends(InvalidBarcodeTypeException,t);function InvalidBarcodeTypeException(e){var o=t.call(this,_errorCode.InvalidBarcodeType)||this;o.name="InvalidBarcodeTypeException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidBarcodeTypeException}(BaseException);export{InvalidBarcodeTypeException};var InvalidRenderException=function(t){__extends(InvalidRenderException,t);function InvalidRenderException(e){var o=t.call(this,_errorCode.InvalidRenderType)||this;o.name="InvalidRenderException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidRenderException}(BaseException);export{InvalidRenderException};var MethodNotImplementException=function(t){__extends(MethodNotImplementException,t);function MethodNotImplementException(e,o){var r=t.call(this,_errorCode.MethodNotImplement)||this;r.name="MethodNotImplementException";r.message=e+" is not a method! "+o;r.descriptor={source:e,message:r.message};return r}return MethodNotImplementException}(BaseException);export{MethodNotImplementException};var InvalidTextException=function(t){__extends(InvalidTextException,t);function InvalidTextException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidText)||this;r.name="InvalidTextException";r.message=e?e+" is invalid. "+o:"Text is required.";r.descriptor={source:e,message:r.message};return r}return InvalidTextException}(BaseException);export{InvalidTextException};var InvalidCharacterException=function(t){__extends(InvalidCharacterException,t);function InvalidCharacterException(e){var o=t.call(this,_errorCode.InvalidCharacter)||this;o.name="InvalidCharacterException";o.message=e+" is invalid.";o.descriptor={source:e,message:o.message};return o}return InvalidCharacterException}(BaseException);export{InvalidCharacterException};var TextTooLongException=function(t){__extends(TextTooLongException,t);function TextTooLongException(){var e=t.call(this,_errorCode.TextTooLong)||this;e.name="TextTooLongException";e.message="Text is too long to encode";e.descriptor={source:null,message:e.message};return e}return TextTooLongException}(BaseException);export{TextTooLongException};var GroupSizeOverflowException=function(t){__extends(GroupSizeOverflowException,t);function GroupSizeOverflowException(e){var o=t.call(this,_errorCode.GroupSizeOverflow)||this;o.name="GroupSizeOverflowException";o.message="Group size is "+e+". The max group size is 9.";o.descriptor={source:e,message:o.message};return o}return GroupSizeOverflowException}(BaseException);export{GroupSizeOverflowException};function createRenderDom(t,e){var o;"svg"===t?(o=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"):o=document.createElement("canvas");o.setAttribute("width",e.width);o.setAttribute("height",e.height);return o}var BarcodeRender=function(){function BarcodeRender(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;var o=this.style.unitValue;this.size={width:e.size.width*o,height:e.size.height*o};var r=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(r,this.style,o);break;case"canvas":this.context=new CanvasRenderContext(r,this.style,o);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(r);this.renderDom=r}BarcodeRender.prototype.render=function(){var t=this.style,e=this.barcode.shapes,o=this.context;o.clear();o.setColor(t.color);o.setBackgroundColor(t.backgroundColor);e.forEach((function(t){"rect"===t.type&&o.drawRect(t);"text"===t.type&&o.drawText(t)}));return this};BarcodeRender.prototype.getImageData=function(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()};BarcodeRender.prototype.getDataUrl=function(){return this.context.getDataUrl()};BarcodeRender.prototype.destroy=function(){this.container&&this.container.removeChild(this.renderDom)};BarcodeRender.prototype.getSize=function(){return this.size};return BarcodeRender}();export{BarcodeRender};function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t,e,o){void 0===t&&(t="");void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.substring(r,r+e),n);r+=e;n++}}function sliceArray(t,e,o){void 0===t&&(t=[]);void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.slice(r,r+e),n);r+=e;n++}}function str2Array(t){void 0===t&&(t="");return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t){void 0===t&&(t="");var e=str2Array(t),o=[];e.forEach((function(t){if("0"===t)o.push(0);else if(o[o.length-1]&&0!==o[o.length]){var e=o.pop();o.push(++e)}else o.push(1)}));return o}function convertRadix(t,e){void 0===e&&(e=2);return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t,e){void 0===t&&(t="");void 0===e&&(e=0);if("number"==typeof t)return t;var o=parseFloat(t);return isNaN(o)?e:o}function getUnit(t){void 0===t&&(t="");var e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e){void 0===e&&(e="length");var o=0;t.forEach((function(t){t[e]>o&&(o=t[e])}));return o}function assign(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(isFunction(Object.assign))return Object.assign.apply(Object,[t].concat(e));if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=0;i<e.length;i++){var n=e[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r}function deepMerge(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach((function(e){if(e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(null!=e[o]&&"object"==typeof e[o]&&"object"==typeof t[o]?t[o]=deepMerge({},t[o]||{},e[o]):t[o]=e[o])}));return t}function deepMergeAll(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return deepMerge.apply(void 0,[{}].concat(t))}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);var o=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==o.length||0==e)return"";if(o.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="",i=0;i<e;i++)r+=o;return r}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&Number.isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(var o=0;o<t.length;o++)t[o]=e;return t}function strPadStart(t,e,o){if(isFunction(t.padStart))return t.padStart(e,o);e>>=0;o=String(void 0!==o?o:" ");if(t.length>e)return t;(e-=t.length)>o.length&&(o+=strRepeat(o,e/o.length));return o.slice(0,e)+String(t)}var plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){var o,r;if(isFinite(e)){o=0;r=e}else{o=e.from;r=e.to+1}for(;o<r;o++)t(o)}function toZeroOnePattern(t,e){var o=e?isEven:isOdd;return t.reduce((function(t,e,r){o(r)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t}),"")}function range(t,e){for(var o=[];t<e;){o.push(t);t++}o.push(e);return o}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});var e=Object.keys(t).reduce((function(e,o){e[t[o]]=o;return e}),{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}export var Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};var Option=function(){function Option(t){void 0===t&&(t={});this.originConfig=t;this.type=t.type;this.penddingMerge=[]}Option.setCustomDefaultOptions=function(t){Option.CustomDefaultOptions=t};Option.prototype.spawn=function(t){return new Option(Utils.deepMergeAll(this.originConfig,t))};Option.prototype.merge=function(t){this.penddingMerge.unshift(t)};Option.prototype._getUnitValue=function(t){t=Utils.fixSize2PixelDefault(t);return Utils.convertUnit(t)};Option.prototype.getMergedOption=function(){return Utils.deepMergeAll.apply(Utils,[Option.DefaultOptions].concat(this.penddingMerge,[Option.CustomDefaultOptions,this.originConfig]))};Option.prototype.getConfig=function(t){var e=this.getMergedOption(),o=e.text,r=e.quietZone,i=e.height,n=e.labelPosition,a=e.desiredSize,s=e.showLabel,c=e.font,u=e.backgroundColor,p=e.color,h=e.renderType,l=e.unitSize,d={text:o,isLabelBottom:!1,hideExtraChecksum:e.hideExtraChecksum};if(!Utils.isDefined(o))throw new InvalidTextException;d.text+="";Utils.isDefined(n)&&(d.isLabelBottom="top"!==n);(c=Utils.deepMergeAll(c)).fontSize=Utils.fixSize2PixelDefault(c.fontSize);var f=Utils.measureText(o,c);d.showLabel=s;t=t||this._getUnitValue(l);var g=s?f/t:0;d.fontSizeInUnit=g;var y={};for(var v in r)if(r.hasOwnProperty(v)){var x=r[v];if(Utils.isNumberLike(x)){var m=+x;y[v]=m}else{var b=Utils.convertUnit(x);y[v]=b/t}}d.quietZone=y;if(a){d.containerWidth=Utils.convertUnit(Utils.fixSize2PixelDefault(a.width));d.containerHeight=Utils.convertUnit(Utils.fixSize2PixelDefault(a.height));d.desiredSize=a}if(Utils.isDefined(i))if(a){var _=s?d.containerHeight-f:d.containerHeight;d.height=_/t-y.top-y.bottom}else Utils.isNumberLike(i)?d.height=+i-g-y.top-y.bottom:d.height=Utils.convertUnit(i)/t-g-y.top-y.bottom;return{config:e,encodeConfig:d,style:Utils.deepMergeAll({backgroundColor:u,color:p,renderType:h,unitValue:t,fontSize:c.fontSize,fontHeight:f},c)}};Option.prototype.getOriginConfig=function(){return this.originConfig};Option.prototype.getType=function(){return this.type};Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};return Option}();export{Option};function _getProtos(t){var e=[];if(t&&t instanceof Function){var o=t;e.push(o);for(;o;){var r=Object.getPrototypeOf(o);if(!r||r===Object||r===Function.prototype)break;o=r;e.push(o)}}return e}export function _getDefaultConfig(t,e){var o=[{type:e}];_getProtos(t).forEach((function(t){t.DefaultConfig&&o.unshift(t.DefaultConfig)}));return Utils.deepMergeAll.apply(Utils,[Option.DefaultOptions].concat(o,[Option.CustomDefaultOptions]))}var _EnumDictionary=function(){function _EnumDictionary(t,e){this._keys={};this._values={};for(var o in t)if("string"==typeof t[o]){var r=parseInt(o),i=e(t[r]);this._keys[r]=i;this._values[i]=r}}_EnumDictionary.prototype.getEnumByString=function(t){var e=this._values[t];if(void 0===e)throw"Unknown Barcode internal value '"+t+"'";return e};_EnumDictionary.prototype.getStringByEnum=function(t){return this._keys[t]};return _EnumDictionary}();export{_EnumDictionary};var Area=function(){function Area(t,e){void 0===t&&(t=0);void 0===e&&(e=0);this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}Area.prototype.append=function(t){this.children.push(t)};Area.prototype._makeRect=function(t,e,o,r){return{x:t,y:e,height:r,width:o,type:"rect"}};Area.prototype.toShapes=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.border,s=n.margin,c=[],u=a.left+a.right+r,p=a.top+a.bottom+i,h=e+s.left,l=o+s.top;a.top&&c.push(this._makeRect(h,l,u,a.top));a.right&&c.push(this._makeRect(h+u-a.right,l,a.right,p));a.bottom&&c.push(this._makeRect(h,l+p-a.bottom,u,a.bottom));a.left&&c.push(this._makeRect(h,l,a.left,p));return c};Area.prototype.getSize=function(){var t=this.width,e=this.height,o=this.offsetBox;return{width:t+o.width,height:e+o.height}};Area.prototype.visiable=function(){return this.width>0&&this.height>0};Area.prototype.setX=function(t){this.x=t;this._updateBox()};Area.prototype.setY=function(t){this.y=t;this._updateBox()};Area.prototype.updateContentSize=function(t,e){this.width=t;this.height=e;this._updateBox()};Area.prototype._fixOpt=function(t,e){if(Utils.isNumberLike(t[e])){var o=t[e];t[e]={top:o,right:o,bottom:o,left:o}}};Area.prototype.setStyle=function(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=Utils.deepMergeAll(this.style,t);this._updateBox()};Area.prototype._updateBox=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.padding,s=n.border,c=n.margin;this.offsetBox={x:e+a.left+s.left+c.left,y:o+a.top+s.top+c.top,width:c.left+s.left+s.right+c.right,height:c.top+s.top+s.bottom+c.bottom};var u=r-a.left-a.right,p=i-a.top-a.bottom;this.contentBox={width:u>=0?u:0,height:p>=0?p:0}};return Area}();export{Area};var HorizontalLayoutArea=function(t){__extends(HorizontalLayoutArea,t);function HorizontalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}HorizontalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.y,n=0;e.forEach((function(t){var e=o.x+n;t.toShapes().forEach((function(t){t.x+=e;t.y+=i;r.push(t)}));var a=t.getSize();n+=a.width}));return r};HorizontalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};HorizontalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.height=Math.max(o.height,t.height);t.width+=o.width;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return HorizontalLayoutArea}(Area);export{HorizontalLayoutArea};var VerticalLayoutArea=function(t){__extends(VerticalLayoutArea,t);function VerticalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}VerticalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.x,n=0;e.forEach((function(t){var e=o.y+n;t.toShapes().forEach((function(t){t.x+=i;t.y+=e;r.push(t)}));var a=t.getSize();n+=a.height}));return r};VerticalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};VerticalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.width=Math.max(o.width,t.width);t.height+=o.height;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return VerticalLayoutArea}(Area);export{VerticalLayoutArea};var MatrixSymbolArea=function(t){__extends(MatrixSymbolArea,t);function MatrixSymbolArea(e,o,r){var i=t.call(this,e,o)||this;i._xPosition=0;i._yPosition=0;i._lastMaxHeight=0;i._rowHeight=0;i._rowHeight=r;return i}MatrixSymbolArea.prototype.append=function(t,e){if(t&&e){this._autoWrap(t);var o=this.children,r={width:t,height:e,x:this._xPosition,y:this._yPosition};o.push(r);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}};MatrixSymbolArea.prototype._autoWrap=function(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}};MatrixSymbolArea.prototype._checkNeedWrap=function(t){var e=this._xPosition;return this.contentBox.width-e-t<0};MatrixSymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._autoWrap(t);this._xPosition+=t};MatrixSymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=t.prototype.toShapes.call(this);o.forEach((function(t){t.x+=e.x;t.y+=e.y;t.type="rect";r.push(t)}));return r};return MatrixSymbolArea}(Area);export{MatrixSymbolArea};var SymbolArea=function(t){__extends(SymbolArea,t);function SymbolArea(e,o){var r=t.call(this,e,o)||this;r._lastIsBar=!1;r._cacheNumber=0;r._position=0;return r}SymbolArea.prototype.append=function(t,e,o){if(t){var r=this.children,i={width:t,x:this._position,barHeight:e,offsetY:o};r.push(i);this._position+=t}};SymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._position+=t};SymbolArea.prototype._appendModule=function(t){var e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++};SymbolArea.prototype._flash=function(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}};SymbolArea.prototype.fromPattern=function(t){var e=this;Utils.str2Array(t).forEach((function(t){e._appendModule(t)}));this._flash()};SymbolArea.prototype.getContentBox=function(){return this.contentBox};SymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this.contentBox.height,i=t.prototype.toShapes.call(this);o.forEach((function(t){i.push({type:"rect",x:t.x+e.x,y:e.y+(t.offsetY||0),width:t.width,height:t.barHeight||r})}));return i};return SymbolArea}(Area);export{SymbolArea};var LabelArea=function(t){__extends(LabelArea,t);function LabelArea(e,o,r){var i=t.call(this,e,o)||this;i._textAlign=r;return i}LabelArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this._textAlign,i=this.contentBox.width,n=t.prototype.toShapes.call(this);o.forEach((function(t){var o=e.x;switch(r){case"center":o+=i/2;break;case"right":o+=i}n.push({x:o+(t.x||0),y:e.y+(t.y||0),textAlign:r,maxWidth:i,type:"text",text:t.text})}));return n};return LabelArea}(Area);export{LabelArea};var MatrixBuilder=function(){function MatrixBuilder(t,e){this.data=[];this.data=[];this.row=t;this.col=e}MatrixBuilder.prototype.add=function(t,e,o){(this.data[t]||Utils.fillArray(new Array(this.col),null))[e]=o;this.data[t]=[]};MatrixBuilder.prototype.toMatrix=function(){var t=this,e=[];Utils.loop((function(o){e.push(t.data[o]||Utils.fillArray(new Array(t.col),null))}),this.row);return e};return MatrixBuilder}();export{MatrixBuilder};var BitBuffer=function(){function BitBuffer(t){void 0===t&&(t=[]);this.buffer=t;this.length=8*t.length;this.index=0}BitBuffer.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1};BitBuffer.prototype.putBitAt=function(t,e){for(var o=this.length,r=new BitBuffer,i=0;i<o;i++)i===e?r.putBit(t):r.putBit(this.getAt(i));this.buffer=r.buffer;this.length=r.length};BitBuffer.prototype.put=function(t,e){for(var o=0;o<e;o+=1)this.putBit(1==(t>>>e-o-1&1))};BitBuffer.prototype.putBits=function(t){this.put(parseInt(t,2),t.length)};BitBuffer.prototype.getAt=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)};BitBuffer.prototype.getBuffer=function(){return this.buffer};BitBuffer.prototype.getGroupedBits=function(t){for(var e=0,o=[];e<this.length;){for(var r="",i=e,n=e+t;i<n;i++)r+=this.getAt(i)?1:0;e=n;o.push(parseInt(r,2))}return o};BitBuffer.prototype.next=function(){this.index++;return this.getAt(this.index-1)};return BitBuffer}();export{BitBuffer};var BarcodeEncoder=function(){function BarcodeEncoder(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}BarcodeEncoder.prototype.validate=function(){};BarcodeEncoder.prototype.applyDesiredSize=function(t){var e=this._option.getConfig(t),o=e.config,r=e.encodeConfig,i=e.style;this.config=o;this.encodeConfig=r;this.style=i;this.useDesiredSize=!!r.desiredSize};BarcodeEncoder.prototype.afterApplyDesiredSize=function(){};BarcodeEncoder.prototype.toSymbol=function(){this.validate();var t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)};return BarcodeEncoder}();export{BarcodeEncoder};var TwoDimensionalBarcode=function(t){__extends(TwoDimensionalBarcode,t);function TwoDimensionalBarcode(){return null!==t&&t.apply(this,arguments)||this}TwoDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size,e=t.width,o=t.height,r=this.encodeConfig,i=r.desiredSize,n=r.containerWidth,a=r.containerHeight,s=Math.min(n/e,a/o);i.forceRounding&&(s=(s=~~s)<1?1:s);this.applyDesiredSize(s)};TwoDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.encodeConfig.quietZone,r=t[0].length+o.right+o.left,i=t.length+o.top+o.bottom,n=new VerticalLayoutArea,a=new MatrixSymbolArea(r,i,1);a.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});n.append(a);if(!e){t.forEach((function(t){t.forEach((function(t){t?a.append(1,1):a.space()}))}));this.shapes=n.toShapes()}this.size=n.getSize()};return TwoDimensionalBarcode}(BarcodeEncoder);export{TwoDimensionalBarcode};var OneDimensionalBarcode=function(t){__extends(OneDimensionalBarcode,t);function OneDimensionalBarcode(e){var o=this;e.merge(OneDimensionalBarcode.DefaultConfig);(o=t.call(this,e)||this).label="";return o}OneDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size.width,e=this.encodeConfig,o=e.desiredSize,r=e.containerWidth/t;o.forceRounding&&(r=(r=~~r)<1?1:r);this.applyDesiredSize(r)};OneDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.label,r=this.encodeConfig,i=r.quietZone,n=r.isLabelBottom,a=r.height,s=r.showLabel,c=r.fontSizeInUnit,u=this.style.textAlign,p=0;o&&s&&(p=c);var h=t.length+i.right+i.left,l=a+i.top+i.bottom,d=new VerticalLayoutArea,f=new SymbolArea(h,l);f.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});var g=f.getSize(),y=new LabelArea(g.width,p,u);if(n){d.append(f);d.append(y)}else{d.append(y);d.append(f)}if(!e){f.fromPattern(t);y.append({text:o});this.shapes=d.toShapes()}this.size=d.getSize()};OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};return OneDimensionalBarcode}(BarcodeEncoder);export{OneDimensionalBarcode};var FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";export var Constants={FNC1:FNC1,FNC2:FNC2,FNC3:FNC3,DataMatrixFNC1:DataMatrixFNC1,DataMatrixMacro05:DataMatrixMacro05,DataMatrixMacro06:DataMatrixMacro06};export var encoders={};var Barcode=function(){function Barcode(){for(var t,e,o,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(r.length>=3)t=r[0],e=r[1],o=r[2];else if(2===r.length)Utils.isFunction(r[1])?(e=r[0],o=r[1]):(t=r[0],e=r[1]);else{if(1!==r.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");e=r[0]}this.dom="string"==typeof t?document.querySelector(t):t;this.callback=o&&o.bind(this);this.setOption(e)}Barcode.getImageData=function(t){void 0===t&&(t={});return new Barcode(t).getImageData()};Barcode.prototype.getImageData=function(){return this.render.getImageData()};Barcode.getDataUrl=function(t){void 0===t&&(t={});return new Barcode(t).getDataUrl()};Barcode.prototype.getDataUrl=function(){return this.render.getDataUrl()};Barcode.setDefaultOptions=function(t){void 0===t&&(t={});Option.setCustomDefaultOptions(t)};Barcode.registerEncoder=function(t,e){encoders[t]=e;Barcode.supportType.push(t)};Barcode.registerPlugin=function(t,e){Utils.registerPlugin(t,e)};Barcode.prototype.mergeOption=function(t){var e=this.option.spawn(t);this.update(e);return this};Barcode.prototype.setOption=function(t){this.update(new Option(t));return this};Barcode.prototype.getOption=function(){return this.option.getMergedOption()};Barcode.prototype.update=function(t){var e=t.getType(),o=encoders[e];if(!o)throw new InvalidBarcodeTypeException(e);var r=new o(t);this.destroy();var i=new BarcodeRender(this.dom,r);i.render();this.render=i;this.option=t;Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.refresh=function(){this.render.render();Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.getSize=function(){return this.render.getSize()};Barcode.prototype.destroy=function(){if(this.render){this.render.destroy();this.render=null}};Barcode.supportType=[];Barcode.constants=Constants;Barcode.ErrorCode=ErrorCode;return Barcode}();export{Barcode};Barcode.registerPlugin("measureText",(function(t,e){var o=document.createElement("span");o.style.visibility="hidden";o.style.position="absolute";o.style.lineHeight="normal";o.textContent=t;Object.keys(e).forEach((function(t){o.style[t]=e[t]}));document.body.appendChild(o);var r=o.getBoundingClientRect();document.body.removeChild(o);return r.height}));Barcode.registerPlugin("convertUnit",(function(t){var e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);var o=e.getBoundingClientRect();document.body.removeChild(e);return o.width}));export var BarcodeClsNames={hostElement:"wj-barcode"};export var RenderType;!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType||(RenderType={}));export var LabelPosition;!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition||(LabelPosition={}));export var NarrowToWideRatio;!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio||(NarrowToWideRatio={}));var _RenderTypeConvertor=function(){function _RenderTypeConvertor(){}_RenderTypeConvertor.stringToEnum=function(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw"Unknown Barcode internal renderType '"+t+"'"};_RenderTypeConvertor.enumToString=function(t){return RenderType[asEnum(t,RenderType)].toLowerCase()};return _RenderTypeConvertor}();export{_RenderTypeConvertor};var _LabelPositionConvertor=function(){function _LabelPositionConvertor(){}_LabelPositionConvertor.stringToEnum=function(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw"Unknown Barcode internal labelPosition '"+t+"'"};_LabelPositionConvertor.enumToString=function(t){return LabelPosition[asEnum(t,LabelPosition)].toLowerCase()};return _LabelPositionConvertor}();export{_LabelPositionConvertor};var _NarrowWideRatioConvertor=function(){function _NarrowWideRatioConvertor(){}_NarrowWideRatioConvertor.stringToEnum=function(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw"Unknown nwRatio internal value '"+t+"'"};_NarrowWideRatioConvertor.enumToString=function(t){var e;switch(asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e};return _NarrowWideRatioConvertor}();export{_NarrowWideRatioConvertor};var BarcodeBase=function(t){__extends(BarcodeBase,t);function BarcodeBase(e,o){var r=t.call(this,e,null,!0)||this;r._state={};r._isUpd=0;r._isValid=!0;r._aw=!1;r._wZoom=1;r.isValidChanged=new Event;var i=r.getTemplate();r.applyTemplate(BarcodeClsNames.hostElement+" "+ControlClsNames.hostElement,i,{});isIE()||(r.hostElement.style.lineHeight="0px");r._state=r._getDefaults();r._isUpd++;r.initialize(o);r._updateSize();r._isUpd--;r._mergeOptions({});r.invalidate();return r}Object.defineProperty(BarcodeBase,"controlTemplate",{get:function(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate},set:function(t){BarcodeBase._ctrlTemplate=t},enumerable:!0,configurable:!0});BarcodeBase.prototype.initialize=function(e){this._isUpd++;try{t.prototype.initialize.call(this,e)}finally{this._isUpd--}!this._isUpd&&e&&Object.keys(e).length&&this._mergeOptions({})};BarcodeBase._getClassDefaults=function(){var t=this.type;return _getDefaultConfig(encoders[t],t)};BarcodeBase.prototype._getDefaults=function(){var t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return Utils.deepMergeAll(t._defaults)};Object.defineProperty(BarcodeBase.prototype,"value",{get:function(){return this._getProp("text")},set:function(t){this._setProp("text",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"quietZone",{get:function(){return this._getProp("quietZone")},set:function(t){this._setProp("quietZone",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"renderType",{get:function(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))},set:function(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"color",{get:function(){return this._getProp("color")},set:function(t){this._setProp("color",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"backgroundColor",{get:function(){return this._getProp("backgroundColor")},set:function(t){this._setProp("backgroundColor",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"hideExtraChecksum",{get:function(){return this._getProp("hideExtraChecksum")},set:function(t){this._setProp("hideExtraChecksum",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"font",{get:function(){return this._getProp("font")},set:function(t){this._setProp("font",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"isValid",{get:function(){return this._isValid},enumerable:!0,configurable:!0});BarcodeBase.prototype.onIsValidChanged=function(t){this.isValidChanged.raise(this,t)};BarcodeBase.prototype.refresh=function(e){void 0===e&&(e=!0);t.prototype.refresh.call(this,e);e?this._updateSize():this._bc.refresh()};BarcodeBase.prototype.getImageData=function(){return this._bc.getImageData()};BarcodeBase.prototype.getDataUrl=function(){return this._bc.getDataUrl()};BarcodeBase.prototype.getSize=function(){var t=new Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t};BarcodeBase.prototype._mergeOptions=function(t){var e,o=this._bc,r=_copyObj(this._state,t);if(!this._isUpd){var i=r.text;if(null==i||""===i){if(o){o.destroy();this._bc=o=null}}else try{o?o.setOption(r):this._bc=o=new Barcode(this.hostElement,r)}catch(t){e=t}}var n=!0;if(e){if(o){o.destroy();this._bc=o=null}if(e.code!==_errorCode.InvalidText)throw e;n=!1}this._state=r;this._setValid(n)};BarcodeBase.prototype._setValid=function(t){if(this._isValid!==t){this._isValid=t;toggleClass(this.hostElement,ControlStateClsNames.invalid,!t);this.onIsValidChanged()}};BarcodeBase.prototype._setProp=function(t,e){var o;this._mergeOptions(((o={})[t]=e,o))};BarcodeBase.prototype._getProp=function(t){var e=this._bc;return this._state[t]||e&&e.getOption()[t]};BarcodeBase.prototype._updateSize=function(t){void 0===t&&(t=!0);if(this.hostElement){var e=BarcodeBase._getContentSize(this.hostElement),o=this._prevSz,r=null,i=null,n=1,a=!0;if(this._getAw()){n=this._getWzoom();i=e.height/n;a=t&&i===this._prevH;this._prevH=i;o=this._prevSz=null}else if(t){if(!o||!e.equals(o)){r={width:e.width+"px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}}else{r={width:"0px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}a||this._mergeOptions({desiredSize:r,height:i,unitSize:n})}};BarcodeBase._getContentSize=function(t){var e=getComputedStyle(t);return new Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))};BarcodeBase.prototype._getAw=function(){return this._aw};BarcodeBase.prototype._setAw=function(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}};BarcodeBase.prototype._getWzoom=function(){return this._wZoom};BarcodeBase.prototype._setWzoom=function(t){asNumber(t);assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}};BarcodeBase._ctrlTemplate="";return BarcodeBase}(Control);export{BarcodeBase};var _copyObj="function"==typeof Object.assign?Object.assign:function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(null!=n)for(var a in n)t[a]=n[a]}return t};_registerModule("wijmo.barcode",selfModule);
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -24,31 +24,31 @@ import * as selfModule from '@mescius/wijmo.barcode';
|
|
|
24
24
|
* Defines the options to set the size of the quiet zone on all the sides of the barcode symbol.
|
|
25
25
|
*
|
|
26
26
|
* The default unit of it will be Pixel if value type is number.
|
|
27
|
-
*/
|
|
27
|
+
*/
|
|
28
28
|
export interface IQuietZone {
|
|
29
29
|
/**
|
|
30
30
|
* The size of the quiet zone on the left side of the barcode symbol.
|
|
31
31
|
*
|
|
32
32
|
* The default value for this property is <b>0</b>.
|
|
33
|
-
|
|
33
|
+
*/
|
|
34
34
|
left?: string | number;
|
|
35
35
|
/**
|
|
36
36
|
* The size of the quiet zone on the right side of the barcode symbol.
|
|
37
37
|
*
|
|
38
38
|
* The default value for this property is <b>0</b>.
|
|
39
|
-
|
|
39
|
+
*/
|
|
40
40
|
right?: string | number;
|
|
41
41
|
/**
|
|
42
42
|
* The size of the quiet zone on the top side of the barcode symbol.
|
|
43
43
|
*
|
|
44
44
|
* The default value for this property is <b>0</b>.
|
|
45
|
-
|
|
45
|
+
*/
|
|
46
46
|
top?: string | number;
|
|
47
47
|
/**
|
|
48
48
|
* The size of the quiet zone on the bottom of the barcode symbol.
|
|
49
49
|
*
|
|
50
50
|
* The default value for this property is <b>0</b>.
|
|
51
|
-
|
|
51
|
+
*/
|
|
52
52
|
bottom?: string | number;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -59,7 +59,7 @@ export interface IQuietZoneWithAddOn extends IQuietZone {
|
|
|
59
59
|
* Add on is the size of quiet zone between main symbol and add on symbol.
|
|
60
60
|
*
|
|
61
61
|
* The default value for this property is <b>0</b>.
|
|
62
|
-
|
|
62
|
+
*/
|
|
63
63
|
addOn?: string | number;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -70,37 +70,37 @@ export interface IBarcodeFont {
|
|
|
70
70
|
* Gets or Sets the family of the font for the barcode value.
|
|
71
71
|
*
|
|
72
72
|
* The default value for this property is <b>sans-serif</b>.
|
|
73
|
-
|
|
73
|
+
*/
|
|
74
74
|
fontFamily?: string;
|
|
75
75
|
/**
|
|
76
76
|
* Gets or Sets the style of the font for the barcode value.
|
|
77
77
|
*
|
|
78
78
|
* The default value for this property is <b>normal</b>.
|
|
79
|
-
|
|
79
|
+
*/
|
|
80
80
|
fontStyle?: string;
|
|
81
81
|
/**
|
|
82
82
|
* Gets or Sets the weight of the font for the barcode value.
|
|
83
83
|
*
|
|
84
84
|
* The default value for this property is <b>normal</b>.
|
|
85
|
-
|
|
85
|
+
*/
|
|
86
86
|
fontWeight?: string;
|
|
87
87
|
/**
|
|
88
88
|
* Gets or Sets the decoration for the text in the barcode value.
|
|
89
89
|
*
|
|
90
90
|
* The default value for this property is <b>none</b>.
|
|
91
|
-
|
|
91
|
+
*/
|
|
92
92
|
textDecoration?: string;
|
|
93
93
|
/**
|
|
94
94
|
* Gets or Sets the alignment of the text in the barcode value.
|
|
95
95
|
*
|
|
96
96
|
* The default value for this property is <b>center</b>.
|
|
97
|
-
|
|
97
|
+
*/
|
|
98
98
|
textAlign?: string;
|
|
99
99
|
/**
|
|
100
100
|
* Gets or Sets the size of font for the barcode value.
|
|
101
101
|
*
|
|
102
102
|
* The default value for this property is <b>12px</b>.
|
|
103
|
-
|
|
103
|
+
*/
|
|
104
104
|
fontSize?: number | string;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
@@ -496,23 +496,23 @@ export declare class Barcode {
|
|
|
496
496
|
private option;
|
|
497
497
|
private render;
|
|
498
498
|
static getImageData(option?: {}): any;
|
|
499
|
+
getImageData(): any;
|
|
499
500
|
static getDataUrl(option?: {}): any;
|
|
501
|
+
getDataUrl(): any;
|
|
500
502
|
static setDefaultOptions(option?: {}): void;
|
|
501
503
|
static registerEncoder(name: any, encoder: any): void;
|
|
502
504
|
static registerPlugin(name: any, fn: any): void;
|
|
503
505
|
constructor(...args: any[]);
|
|
504
506
|
mergeOption(option: any): this;
|
|
505
507
|
/**
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
* set barcode options
|
|
509
|
+
* @access public
|
|
510
|
+
* @param {object} option
|
|
511
|
+
*/
|
|
510
512
|
setOption(option: any): this;
|
|
511
513
|
getOption(): any;
|
|
512
514
|
private update;
|
|
513
515
|
refresh(): void;
|
|
514
|
-
getImageData(): any;
|
|
515
|
-
getDataUrl(): any;
|
|
516
516
|
getSize(): any;
|
|
517
517
|
destroy(): void;
|
|
518
518
|
}
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o in t)Object.hasOwnProperty.call(t,o)&&(e[o]=t[o]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.barcode")),alignmentMap={center:"middle",left:"start",right:"end"},SVGRenderContext=function(){function SVGRenderContext(t,e,o){this.dom=t;this.style=e;this.scale=o;this.color="rgb(0,0,0)";this.addGroup()}SVGRenderContext.prototype.setColor=function(t){this.color=t};SVGRenderContext.prototype.setBackgroundColor=function(t){this.dom.style.backgroundColor=t};SVGRenderContext.prototype.addGroup=function(){var t=this.dom;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)};SVGRenderContext.prototype.drawRect=function(t){var e=this.g,o=this.scale,r=this.color,i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x",(t.x*o).toString());i.setAttribute("y",(t.y*o).toString());i.setAttribute("width",(t.width*o).toString());i.setAttribute("height",(t.height*o).toString());i.style.fill=r;e.appendChild(i)};SVGRenderContext.prototype.drawText=function(t){var e=this.g,o=this.scale,r=this.color,i=this.style,n=document.createElementNS("http://www.w3.org/2000/svg","text");n.style.fill=r;n.style.fontSize=i.fontSize;n.style.fontFamily=i.fontFamily;n.style.fontStyle=t.fontStyle||i.fontStyle;n.style.fontWeight=t.fontWeight||i.fontWeight;n.style.textDecoration=t.textDecoration||i.textDecoration;n.style.textAnchor=alignmentMap[t.textAlign||i.textAlign];n.textContent=t.text;n.textContent=this.clipString(t,n);var a=this._measureText(n);n.setAttribute("y",(t.y*o+Math.abs(a.y)).toString());n.setAttribute("x",(t.x*o).toString());e.appendChild(n)};SVGRenderContext.prototype.clipString=function(t,e){var o=this.scale,r=t.text,i=t.maxWidth,n=this._measureText(e);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};SVGRenderContext.prototype.clear=function(){this.dom.removeChild(this.g);this.addGroup()};SVGRenderContext.prototype._measureText=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);var o=t.getBBox();document.body.removeChild(e);return o};SVGRenderContext.prototype.getDataUrl=function(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)};return SVGRenderContext}();exports.SVGRenderContext=SVGRenderContext;var _errorCode,CanvasRenderContext=function(){function CanvasRenderContext(t,e,o){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=o}CanvasRenderContext.prototype.setColor=function(t){this.ctx.fillStyle=t};CanvasRenderContext.prototype.setBackgroundColor=function(t){var e=this.ctx,o=this.dom;e.save();e.fillStyle=t;e.fillRect(0,0,o.width,o.height);e.restore()};CanvasRenderContext.prototype.drawRect=function(t){var e=this.ctx,o=this.scale;e.fillRect(t.x*o,t.y*o,t.width*o,t.height*o)};CanvasRenderContext.prototype.drawText=function(t){var e=this.ctx,o=this.style,r=this.scale;e.save();e.font=(t.fontStyle||o.fontStyle)+" "+(t.fontWeight||o.fontWeight)+" "+o.fontSize+" "+o.fontFamily;e.textAlign=t.textAlign||o.textAlign;e.textBaseline="bottom";var i=t.x*r,n=t.y*r,a=this.clipString(t);e.fillText(a,i,n+o.fontHeight);this.drawTextDecorationLine(a,i,n,t.textDecoration||o.textDecoration);e.restore()};CanvasRenderContext.prototype.clipString=function(t){var e=this.ctx,o=this.scale,r=t.text,i=t.maxWidth,n=e.measureText(r);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};CanvasRenderContext.prototype.drawTextDecorationLine=function(t,e,o,r){var i;switch(r){case"underline":i=.9;break;case"overline":i=.1;break;case"line-through":i=.5;break;default:return}var n=this.ctx,a=this.style.fontHeight,s=n.measureText(t).width;switch(n.textAlign){case"center":e-=s/2;break;case"right":e-=s}n.lineWidth=1;n.beginPath();var p=a*i+o;n.moveTo(e,p);n.lineTo(e+s,p);n.stroke()};CanvasRenderContext.prototype.clear=function(){var t=this.ctx,e=this.dom;t.clearRect(0,0,e.width,e.height)};CanvasRenderContext.prototype.getImageData=function(){var t=this.ctx,e=this.dom;return t.getImageData(0,0,e.width,e.height)};CanvasRenderContext.prototype.getDataUrl=function(){return this.dom.toDataURL()};return CanvasRenderContext}();exports.CanvasRenderContext=CanvasRenderContext;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode=exports._errorCode||(exports._errorCode={}));var BaseException=function(t){__extends(BaseException,t);function BaseException(e){var o=t.call(this)||this;o.code=e||_errorCode.Unknown;return o}return BaseException}(Error);exports.BaseException=BaseException;exports.ErrorCode=_errorCode;var InvalidOptionsException=function(t){__extends(InvalidOptionsException,t);function InvalidOptionsException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidOptions)||this;r.name="InvalidOptionsException";r.message=JSON.stringify(e)+" is not valid options. "+o;r.descriptor={source:e,message:r.message};return r}return InvalidOptionsException}(BaseException);exports.InvalidOptionsException=InvalidOptionsException;var InvalidBarcodeTypeException=function(t){__extends(InvalidBarcodeTypeException,t);function InvalidBarcodeTypeException(e){var o=t.call(this,_errorCode.InvalidBarcodeType)||this;o.name="InvalidBarcodeTypeException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidBarcodeTypeException}(BaseException);exports.InvalidBarcodeTypeException=InvalidBarcodeTypeException;var InvalidRenderException=function(t){__extends(InvalidRenderException,t);function InvalidRenderException(e){var o=t.call(this,_errorCode.InvalidRenderType)||this;o.name="InvalidRenderException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidRenderException}(BaseException);exports.InvalidRenderException=InvalidRenderException;var MethodNotImplementException=function(t){__extends(MethodNotImplementException,t);function MethodNotImplementException(e,o){var r=t.call(this,_errorCode.MethodNotImplement)||this;r.name="MethodNotImplementException";r.message=e+" is not a method! "+o;r.descriptor={source:e,message:r.message};return r}return MethodNotImplementException}(BaseException);exports.MethodNotImplementException=MethodNotImplementException;var InvalidTextException=function(t){__extends(InvalidTextException,t);function InvalidTextException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidText)||this;r.name="InvalidTextException";r.message=e?e+" is invalid. "+o:"Text is required.";r.descriptor={source:e,message:r.message};return r}return InvalidTextException}(BaseException);exports.InvalidTextException=InvalidTextException;var InvalidCharacterException=function(t){__extends(InvalidCharacterException,t);function InvalidCharacterException(e){var o=t.call(this,_errorCode.InvalidCharacter)||this;o.name="InvalidCharacterException";o.message=e+" is invalid.";o.descriptor={source:e,message:o.message};return o}return InvalidCharacterException}(BaseException);exports.InvalidCharacterException=InvalidCharacterException;var TextTooLongException=function(t){__extends(TextTooLongException,t);function TextTooLongException(){var e=t.call(this,_errorCode.TextTooLong)||this;e.name="TextTooLongException";e.message="Text is too long to encode";e.descriptor={source:null,message:e.message};return e}return TextTooLongException}(BaseException);exports.TextTooLongException=TextTooLongException;var GroupSizeOverflowException=function(t){__extends(GroupSizeOverflowException,t);function GroupSizeOverflowException(e){var o=t.call(this,_errorCode.GroupSizeOverflow)||this;o.name="GroupSizeOverflowException";o.message="Group size is "+e+". The max group size is 9.";o.descriptor={source:e,message:o.message};return o}return GroupSizeOverflowException}(BaseException);exports.GroupSizeOverflowException=GroupSizeOverflowException;function createRenderDom(t,e){var o;"svg"===t?(o=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"):o=document.createElement("canvas");o.setAttribute("width",e.width);o.setAttribute("height",e.height);return o}var BarcodeRender=function(){function BarcodeRender(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;var o=this.style.unitValue;this.size={width:e.size.width*o,height:e.size.height*o};var r=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(r,this.style,o);break;case"canvas":this.context=new CanvasRenderContext(r,this.style,o);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(r);this.renderDom=r}BarcodeRender.prototype.render=function(){var t=this.style,e=this.barcode.shapes,o=this.context;o.clear();o.setColor(t.color);o.setBackgroundColor(t.backgroundColor);e.forEach((function(t){"rect"===t.type&&o.drawRect(t);"text"===t.type&&o.drawText(t)}));return this};BarcodeRender.prototype.getImageData=function(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()};BarcodeRender.prototype.getDataUrl=function(){return this.context.getDataUrl()};BarcodeRender.prototype.destroy=function(){this.container&&this.container.removeChild(this.renderDom)};BarcodeRender.prototype.getSize=function(){return this.size};return BarcodeRender}();exports.BarcodeRender=BarcodeRender;function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t,e,o){void 0===t&&(t="");void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.substring(r,r+e),n);r+=e;n++}}function sliceArray(t,e,o){void 0===t&&(t=[]);void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.slice(r,r+e),n);r+=e;n++}}function str2Array(t){void 0===t&&(t="");return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t){void 0===t&&(t="");var e=str2Array(t),o=[];e.forEach((function(t){if("0"===t)o.push(0);else if(o[o.length-1]&&0!==o[o.length]){var e=o.pop();o.push(++e)}else o.push(1)}));return o}function convertRadix(t,e){void 0===e&&(e=2);return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t,e){void 0===t&&(t="");void 0===e&&(e=0);if("number"==typeof t)return t;var o=parseFloat(t);return isNaN(o)?e:o}function getUnit(t){void 0===t&&(t="");var e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e){void 0===e&&(e="length");var o=0;t.forEach((function(t){t[e]>o&&(o=t[e])}));return o}function assign(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(isFunction(Object.assign))return Object.assign.apply(Object,[t].concat(e));if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=0;i<e.length;i++){var n=e[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r}function deepMerge(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach((function(e){if(e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(null!=e[o]&&"object"==typeof e[o]&&"object"==typeof t[o]?t[o]=deepMerge({},t[o]||{},e[o]):t[o]=e[o])}));return t}function deepMergeAll(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return deepMerge.apply(void 0,[{}].concat(t))}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);var o=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==o.length||0==e)return"";if(o.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="",i=0;i<e;i++)r+=o;return r}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(var o=0;o<t.length;o++)t[o]=e;return t}function strPadStart(t,e,o){if(isFunction(t.padStart))return t.padStart(e,o);e>>=0;o=String(void 0!==o?o:" ");if(t.length>e)return t;(e-=t.length)>o.length&&(o+=strRepeat(o,e/o.length));return o.slice(0,e)+String(t)}var plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){var o,r;if(isFinite(e)){o=0;r=e}else{o=e.from;r=e.to+1}for(;o<r;o++)t(o)}function toZeroOnePattern(t,e){var o=e?isEven:isOdd;return t.reduce((function(t,e,r){o(r)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t}),"")}function range(t,e){for(var o=[];t<e;){o.push(t);t++}o.push(e);return o}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});var e=Object.keys(t).reduce((function(e,o){e[t[o]]=o;return e}),{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}exports.Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};var Option=function(){function Option(t){void 0===t&&(t={});this.originConfig=t;this.type=t.type;this.penddingMerge=[]}Option.setCustomDefaultOptions=function(t){Option.CustomDefaultOptions=t};Option.prototype.spawn=function(t){return new Option(exports.Utils.deepMergeAll(this.originConfig,t))};Option.prototype.merge=function(t){this.penddingMerge.unshift(t)};Option.prototype._getUnitValue=function(t){t=exports.Utils.fixSize2PixelDefault(t);return exports.Utils.convertUnit(t)};Option.prototype.getMergedOption=function(){return exports.Utils.deepMergeAll.apply(exports.Utils,[Option.DefaultOptions].concat(this.penddingMerge,[Option.CustomDefaultOptions,this.originConfig]))};Option.prototype.getConfig=function(t){var e=this.getMergedOption(),o=e.text,r=e.quietZone,i=e.height,n=e.labelPosition,a=e.desiredSize,s=e.showLabel,p=e.font,c=e.backgroundColor,u=e.color,l=e.renderType,h=e.unitSize,d={text:o,isLabelBottom:!1,hideExtraChecksum:e.hideExtraChecksum};if(!exports.Utils.isDefined(o))throw new InvalidTextException;d.text+="";exports.Utils.isDefined(n)&&(d.isLabelBottom="top"!==n);(p=exports.Utils.deepMergeAll(p)).fontSize=exports.Utils.fixSize2PixelDefault(p.fontSize);var f=exports.Utils.measureText(o,p);d.showLabel=s;t=t||this._getUnitValue(h);var g=s?f/t:0;d.fontSizeInUnit=g;var x={};for(var y in r)if(r.hasOwnProperty(y)){var v=r[y];if(exports.Utils.isNumberLike(v)){var m=+v;x[y]=m}else{var _=exports.Utils.convertUnit(v);x[y]=_/t}}d.quietZone=x;if(a){d.containerWidth=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(a.width));d.containerHeight=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(a.height));d.desiredSize=a}if(exports.Utils.isDefined(i))if(a){var b=s?d.containerHeight-f:d.containerHeight;d.height=b/t-x.top-x.bottom}else exports.Utils.isNumberLike(i)?d.height=+i-g-x.top-x.bottom:d.height=exports.Utils.convertUnit(i)/t-g-x.top-x.bottom;return{config:e,encodeConfig:d,style:exports.Utils.deepMergeAll({backgroundColor:c,color:u,renderType:l,unitValue:t,fontSize:p.fontSize,fontHeight:f},p)}};Option.prototype.getOriginConfig=function(){return this.originConfig};Option.prototype.getType=function(){return this.type};Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};return Option}();exports.Option=Option;function _getProtos(t){var e=[];if(t&&t instanceof Function){var o=t;e.push(o);for(;o;){var r=Object.getPrototypeOf(o);if(!r||r===Object||r===Function.prototype)break;o=r;e.push(o)}}return e}function _getDefaultConfig(t,e){var o=[{type:e}];_getProtos(t).forEach((function(t){t.DefaultConfig&&o.unshift(t.DefaultConfig)}));return exports.Utils.deepMergeAll.apply(exports.Utils,[Option.DefaultOptions].concat(o,[Option.CustomDefaultOptions]))}exports._getDefaultConfig=_getDefaultConfig;var _EnumDictionary=function(){function _EnumDictionary(t,e){this._keys={};this._values={};for(var o in t)if("string"==typeof t[o]){var r=parseInt(o),i=e(t[r]);this._keys[r]=i;this._values[i]=r}}_EnumDictionary.prototype.getEnumByString=function(t){var e=this._values[t];if(void 0===e)throw"Unknown Barcode internal value '"+t+"'";return e};_EnumDictionary.prototype.getStringByEnum=function(t){return this._keys[t]};return _EnumDictionary}();exports._EnumDictionary=_EnumDictionary;var Area=function(){function Area(t,e){void 0===t&&(t=0);void 0===e&&(e=0);this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}Area.prototype.append=function(t){this.children.push(t)};Area.prototype._makeRect=function(t,e,o,r){return{x:t,y:e,height:r,width:o,type:"rect"}};Area.prototype.toShapes=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.border,s=n.margin,p=[],c=a.left+a.right+r,u=a.top+a.bottom+i,l=e+s.left,h=o+s.top;a.top&&p.push(this._makeRect(l,h,c,a.top));a.right&&p.push(this._makeRect(l+c-a.right,h,a.right,u));a.bottom&&p.push(this._makeRect(l,h+u-a.bottom,c,a.bottom));a.left&&p.push(this._makeRect(l,h,a.left,u));return p};Area.prototype.getSize=function(){var t=this.width,e=this.height,o=this.offsetBox;return{width:t+o.width,height:e+o.height}};Area.prototype.visiable=function(){return this.width>0&&this.height>0};Area.prototype.setX=function(t){this.x=t;this._updateBox()};Area.prototype.setY=function(t){this.y=t;this._updateBox()};Area.prototype.updateContentSize=function(t,e){this.width=t;this.height=e;this._updateBox()};Area.prototype._fixOpt=function(t,e){if(exports.Utils.isNumberLike(t[e])){var o=t[e];t[e]={top:o,right:o,bottom:o,left:o}}};Area.prototype.setStyle=function(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=exports.Utils.deepMergeAll(this.style,t);this._updateBox()};Area.prototype._updateBox=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.padding,s=n.border,p=n.margin;this.offsetBox={x:e+a.left+s.left+p.left,y:o+a.top+s.top+p.top,width:p.left+s.left+s.right+p.right,height:p.top+s.top+s.bottom+p.bottom};var c=r-a.left-a.right,u=i-a.top-a.bottom;this.contentBox={width:c>=0?c:0,height:u>=0?u:0}};return Area}();exports.Area=Area;var HorizontalLayoutArea=function(t){__extends(HorizontalLayoutArea,t);function HorizontalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}HorizontalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.y,n=0;e.forEach((function(t){var e=o.x+n;t.toShapes().forEach((function(t){t.x+=e;t.y+=i;r.push(t)}));var a=t.getSize();n+=a.width}));return r};HorizontalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};HorizontalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.height=Math.max(o.height,t.height);t.width+=o.width;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return HorizontalLayoutArea}(Area);exports.HorizontalLayoutArea=HorizontalLayoutArea;var VerticalLayoutArea=function(t){__extends(VerticalLayoutArea,t);function VerticalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}VerticalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.x,n=0;e.forEach((function(t){var e=o.y+n;t.toShapes().forEach((function(t){t.x+=i;t.y+=e;r.push(t)}));var a=t.getSize();n+=a.height}));return r};VerticalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};VerticalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.width=Math.max(o.width,t.width);t.height+=o.height;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return VerticalLayoutArea}(Area);exports.VerticalLayoutArea=VerticalLayoutArea;var MatrixSymbolArea=function(t){__extends(MatrixSymbolArea,t);function MatrixSymbolArea(e,o,r){var i=t.call(this,e,o)||this;i._xPosition=0;i._yPosition=0;i._lastMaxHeight=0;i._rowHeight=0;i._rowHeight=r;return i}MatrixSymbolArea.prototype.append=function(t,e){if(t&&e){this._autoWrap(t);var o=this.children,r={width:t,height:e,x:this._xPosition,y:this._yPosition};o.push(r);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}};MatrixSymbolArea.prototype._autoWrap=function(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}};MatrixSymbolArea.prototype._checkNeedWrap=function(t){var e=this._xPosition;return this.contentBox.width-e-t<0};MatrixSymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._autoWrap(t);this._xPosition+=t};MatrixSymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=t.prototype.toShapes.call(this);o.forEach((function(t){t.x+=e.x;t.y+=e.y;t.type="rect";r.push(t)}));return r};return MatrixSymbolArea}(Area);exports.MatrixSymbolArea=MatrixSymbolArea;var SymbolArea=function(t){__extends(SymbolArea,t);function SymbolArea(e,o){var r=t.call(this,e,o)||this;r._lastIsBar=!1;r._cacheNumber=0;r._position=0;return r}SymbolArea.prototype.append=function(t,e,o){if(t){var r=this.children,i={width:t,x:this._position,barHeight:e,offsetY:o};r.push(i);this._position+=t}};SymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._position+=t};SymbolArea.prototype._appendModule=function(t){var e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++};SymbolArea.prototype._flash=function(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}};SymbolArea.prototype.fromPattern=function(t){var e=this;exports.Utils.str2Array(t).forEach((function(t){return e._appendModule(t)}));this._flash()};SymbolArea.prototype.getContentBox=function(){return this.contentBox};SymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this.contentBox.height,i=t.prototype.toShapes.call(this);o.forEach((function(t){i.push({type:"rect",x:t.x+e.x,y:e.y+(t.offsetY||0),width:t.width,height:t.barHeight||r})}));return i};return SymbolArea}(Area);exports.SymbolArea=SymbolArea;var LabelArea=function(t){__extends(LabelArea,t);function LabelArea(e,o,r){var i=t.call(this,e,o)||this;i._textAlign=r;return i}LabelArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this._textAlign,i=this.contentBox.width,n=t.prototype.toShapes.call(this);o.forEach((function(t){var o=e.x;switch(r){case"center":o+=i/2;break;case"right":o+=i}n.push({x:o+(t.x||0),y:e.y+(t.y||0),textAlign:r,maxWidth:i,type:"text",text:t.text})}));return n};return LabelArea}(Area);exports.LabelArea=LabelArea;var MatrixBuilder=function(){function MatrixBuilder(t,e){this.data=[];this.data=[];this.row=t;this.col=e}MatrixBuilder.prototype.add=function(t,e,o){(this.data[t]||exports.Utils.fillArray(new Array(this.col),null))[e]=o;this.data[t]=[]};MatrixBuilder.prototype.toMatrix=function(){var t=this,e=[];exports.Utils.loop((function(o){e.push(t.data[o]||exports.Utils.fillArray(new Array(t.col),null))}),this.row);return e};return MatrixBuilder}();exports.MatrixBuilder=MatrixBuilder;var BitBuffer=function(){function BitBuffer(t){void 0===t&&(t=[]);this.buffer=t;this.length=8*t.length;this.index=0}BitBuffer.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1};BitBuffer.prototype.putBitAt=function(t,e){for(var o=this.length,r=new BitBuffer,i=0;i<o;i++)i===e?r.putBit(t):r.putBit(this.getAt(i));this.buffer=r.buffer;this.length=r.length};BitBuffer.prototype.put=function(t,e){for(var o=0;o<e;o+=1)this.putBit(1==(t>>>e-o-1&1))};BitBuffer.prototype.putBits=function(t){this.put(parseInt(t,2),t.length)};BitBuffer.prototype.getAt=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)};BitBuffer.prototype.getBuffer=function(){return this.buffer};BitBuffer.prototype.getGroupedBits=function(t){for(var e=0,o=[];e<this.length;){for(var r="",i=e,n=e+t;i<n;i++)r+=this.getAt(i)?1:0;e=n;o.push(parseInt(r,2))}return o};BitBuffer.prototype.next=function(){this.index++;return this.getAt(this.index-1)};return BitBuffer}();exports.BitBuffer=BitBuffer;var BarcodeEncoder=function(){function BarcodeEncoder(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}BarcodeEncoder.prototype.validate=function(){};BarcodeEncoder.prototype.applyDesiredSize=function(t){var e=this._option.getConfig(t),o=e.config,r=e.encodeConfig,i=e.style;this.config=o;this.encodeConfig=r;this.style=i;this.useDesiredSize=!!r.desiredSize};BarcodeEncoder.prototype.afterApplyDesiredSize=function(){};BarcodeEncoder.prototype.toSymbol=function(){this.validate();var t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)};return BarcodeEncoder}();exports.BarcodeEncoder=BarcodeEncoder;var TwoDimensionalBarcode=function(t){__extends(TwoDimensionalBarcode,t);function TwoDimensionalBarcode(){return null!==t&&t.apply(this,arguments)||this}TwoDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size,e=t.width,o=t.height,r=this.encodeConfig,i=r.desiredSize,n=r.containerWidth,a=r.containerHeight,s=Math.min(n/e,a/o);i.forceRounding&&(s=(s=~~s)<1?1:s);this.applyDesiredSize(s)};TwoDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.encodeConfig.quietZone,r=t[0].length+o.right+o.left,i=t.length+o.top+o.bottom,n=new VerticalLayoutArea,a=new MatrixSymbolArea(r,i,1);a.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});n.append(a);if(!e){t.forEach((function(t){t.forEach((function(t){t?a.append(1,1):a.space()}))}));this.shapes=n.toShapes()}this.size=n.getSize()};return TwoDimensionalBarcode}(BarcodeEncoder);exports.TwoDimensionalBarcode=TwoDimensionalBarcode;var OneDimensionalBarcode=function(t){__extends(OneDimensionalBarcode,t);function OneDimensionalBarcode(e){var o=this;e.merge(OneDimensionalBarcode.DefaultConfig);(o=t.call(this,e)||this).label="";return o}OneDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size.width,e=this.encodeConfig,o=e.desiredSize,r=e.containerWidth/t;o.forceRounding&&(r=(r=~~r)<1?1:r);this.applyDesiredSize(r)};OneDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.label,r=this.encodeConfig,i=r.quietZone,n=r.isLabelBottom,a=r.height,s=r.showLabel,p=r.fontSizeInUnit,c=this.style.textAlign,u=0;o&&s&&(u=p);var l=t.length+i.right+i.left,h=a+i.top+i.bottom,d=new VerticalLayoutArea,f=new SymbolArea(l,h);f.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});var g=f.getSize(),x=new LabelArea(g.width,u,c);if(n){d.append(f);d.append(x)}else{d.append(x);d.append(f)}if(!e){f.fromPattern(t);x.append({text:o});this.shapes=d.toShapes()}this.size=d.getSize()};OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};return OneDimensionalBarcode}(BarcodeEncoder);exports.OneDimensionalBarcode=OneDimensionalBarcode;var FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";exports.Constants={FNC1:FNC1,FNC2:FNC2,FNC3:FNC3,DataMatrixFNC1:DataMatrixFNC1,DataMatrixMacro05:DataMatrixMacro05,DataMatrixMacro06:DataMatrixMacro06};exports.encoders={};var RenderType,LabelPosition,NarrowToWideRatio,Barcode=function(){function Barcode(){for(var t,e,o,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(r.length>=3)t=r[0],e=r[1],o=r[2];else if(2===r.length)exports.Utils.isFunction(r[1])?(e=r[0],o=r[1]):(t=r[0],e=r[1]);else{if(1!==r.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");e=r[0]}this.dom="string"==typeof t?document.querySelector(t):t;this.callback=o&&o.bind(this);this.setOption(e)}Barcode.getImageData=function(t){void 0===t&&(t={});return new Barcode(t).getImageData()};Barcode.getDataUrl=function(t){void 0===t&&(t={});return new Barcode(t).getDataUrl()};Barcode.setDefaultOptions=function(t){void 0===t&&(t={});Option.setCustomDefaultOptions(t)};Barcode.registerEncoder=function(t,e){exports.encoders[t]=e;Barcode.supportType.push(t)};Barcode.registerPlugin=function(t,e){exports.Utils.registerPlugin(t,e)};Barcode.prototype.mergeOption=function(t){var e=this.option.spawn(t);this.update(e);return this};Barcode.prototype.setOption=function(t){this.update(new Option(t));return this};Barcode.prototype.getOption=function(){return this.option.getMergedOption()};Barcode.prototype.update=function(t){var e=t.getType(),o=exports.encoders[e];if(!o)throw new InvalidBarcodeTypeException(e);var r=new o(t);this.destroy();var i=new BarcodeRender(this.dom,r);i.render();this.render=i;this.option=t;exports.Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.refresh=function(){this.render.render();exports.Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.getImageData=function(){return this.render.getImageData()};Barcode.prototype.getDataUrl=function(){return this.render.getDataUrl()};Barcode.prototype.getSize=function(){return this.render.getSize()};Barcode.prototype.destroy=function(){if(this.render){this.render.destroy();this.render=null}};Barcode.supportType=[];Barcode.constants=exports.Constants;Barcode.ErrorCode=exports.ErrorCode;return Barcode}();exports.Barcode=Barcode;Barcode.registerPlugin("measureText",(function(t,e){var o=document.createElement("span");o.style.visibility="hidden";o.style.position="absolute";o.style.lineHeight="normal";o.textContent=t;Object.keys(e).forEach((function(t){o.style[t]=e[t]}));document.body.appendChild(o);var r=o.getBoundingClientRect();document.body.removeChild(o);return r.height}));Barcode.registerPlugin("convertUnit",(function(t){var e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);var o=e.getBoundingClientRect();document.body.removeChild(e);return o.width}));exports.BarcodeClsNames={hostElement:"wj-barcode"};!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType=exports.RenderType||(exports.RenderType={}));!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition=exports.LabelPosition||(exports.LabelPosition={}));!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio=exports.NarrowToWideRatio||(exports.NarrowToWideRatio={}));var _RenderTypeConvertor=function(){function _RenderTypeConvertor(){}_RenderTypeConvertor.stringToEnum=function(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw"Unknown Barcode internal renderType '"+t+"'"};_RenderTypeConvertor.enumToString=function(t){return RenderType[wijmo_1.asEnum(t,RenderType)].toLowerCase()};return _RenderTypeConvertor}();exports._RenderTypeConvertor=_RenderTypeConvertor;var _LabelPositionConvertor=function(){function _LabelPositionConvertor(){}_LabelPositionConvertor.stringToEnum=function(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw"Unknown Barcode internal labelPosition '"+t+"'"};_LabelPositionConvertor.enumToString=function(t){return LabelPosition[wijmo_1.asEnum(t,LabelPosition)].toLowerCase()};return _LabelPositionConvertor}();exports._LabelPositionConvertor=_LabelPositionConvertor;var _NarrowWideRatioConvertor=function(){function _NarrowWideRatioConvertor(){}_NarrowWideRatioConvertor.stringToEnum=function(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw"Unknown nwRatio internal value '"+t+"'"};_NarrowWideRatioConvertor.enumToString=function(t){var e;switch(wijmo_1.asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e};return _NarrowWideRatioConvertor}();exports._NarrowWideRatioConvertor=_NarrowWideRatioConvertor;var BarcodeBase=function(t){__extends(BarcodeBase,t);function BarcodeBase(e,o){var r=t.call(this,e,null,!0)||this;r._state={};r._isUpd=0;r._isValid=!0;r._aw=!1;r._wZoom=1;r.isValidChanged=new wijmo_1.Event;var i=r.getTemplate();r.applyTemplate(exports.BarcodeClsNames.hostElement+" "+wijmo_1.ControlClsNames.hostElement,i,{});wijmo_1.isIE()||(r.hostElement.style.lineHeight="0px");r._state=r._getDefaults();r._isUpd++;r.initialize(o);r._updateSize();r._isUpd--;r._mergeOptions({});r.invalidate();return r}Object.defineProperty(BarcodeBase,"controlTemplate",{get:function(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate},set:function(t){BarcodeBase._ctrlTemplate=t},enumerable:!0,configurable:!0});BarcodeBase.prototype.initialize=function(e){this._isUpd++;try{t.prototype.initialize.call(this,e)}finally{this._isUpd--}!this._isUpd&&e&&Object.keys(e).length&&this._mergeOptions({})};BarcodeBase._getClassDefaults=function(){var t=this.type;return _getDefaultConfig(exports.encoders[t],t)};BarcodeBase.prototype._getDefaults=function(){var t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return exports.Utils.deepMergeAll(t._defaults)};Object.defineProperty(BarcodeBase.prototype,"value",{get:function(){return this._getProp("text")},set:function(t){this._setProp("text",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"quietZone",{get:function(){return this._getProp("quietZone")},set:function(t){this._setProp("quietZone",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"renderType",{get:function(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))},set:function(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"color",{get:function(){return this._getProp("color")},set:function(t){this._setProp("color",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"backgroundColor",{get:function(){return this._getProp("backgroundColor")},set:function(t){this._setProp("backgroundColor",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"hideExtraChecksum",{get:function(){return this._getProp("hideExtraChecksum")},set:function(t){this._setProp("hideExtraChecksum",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"font",{get:function(){return this._getProp("font")},set:function(t){this._setProp("font",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"isValid",{get:function(){return this._isValid},enumerable:!0,configurable:!0});BarcodeBase.prototype.onIsValidChanged=function(t){this.isValidChanged.raise(this,t)};BarcodeBase.prototype.refresh=function(e){void 0===e&&(e=!0);t.prototype.refresh.call(this,e);e?this._updateSize():this._bc.refresh()};BarcodeBase.prototype.getImageData=function(){return this._bc.getImageData()};BarcodeBase.prototype.getDataUrl=function(){return this._bc.getDataUrl()};BarcodeBase.prototype.getSize=function(){var t=new wijmo_1.Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t};BarcodeBase.prototype._mergeOptions=function(t){var e,o=this._bc,r=_copyObj(this._state,t);if(!this._isUpd){var i=r.text;if(null==i||""===i){if(o){o.destroy();this._bc=o=null}}else try{o?o.setOption(r):this._bc=o=new Barcode(this.hostElement,r)}catch(t){e=t}}var n=!0;if(e){if(o){o.destroy();this._bc=o=null}if(e.code!==_errorCode.InvalidText)throw e;n=!1}this._state=r;this._setValid(n)};BarcodeBase.prototype._setValid=function(t){if(this._isValid!==t){this._isValid=t;wijmo_1.toggleClass(this.hostElement,wijmo_1.ControlStateClsNames.invalid,!t);this.onIsValidChanged()}};BarcodeBase.prototype._setProp=function(t,e){var o;this._mergeOptions(((o={})[t]=e,o))};BarcodeBase.prototype._getProp=function(t){var e=this._bc;return this._state[t]||e&&e.getOption()[t]};BarcodeBase.prototype._updateSize=function(t){void 0===t&&(t=!0);if(this.hostElement){var e=BarcodeBase._getContentSize(this.hostElement),o=this._prevSz,r=null,i=null,n=1,a=!0;if(this._getAw()){n=this._getWzoom();i=e.height/n;a=t&&i===this._prevH;this._prevH=i;o=this._prevSz=null}else if(t){if(!o||!e.equals(o)){r={width:e.width+"px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}}else{r={width:"0px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}a||this._mergeOptions({desiredSize:r,height:i,unitSize:n})}};BarcodeBase._getContentSize=function(t){var e=getComputedStyle(t);return new wijmo_1.Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))};BarcodeBase.prototype._getAw=function(){return this._aw};BarcodeBase.prototype._setAw=function(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}};BarcodeBase.prototype._getWzoom=function(){return this._wZoom};BarcodeBase.prototype._setWzoom=function(t){wijmo_1.asNumber(t);wijmo_1.assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}};BarcodeBase._ctrlTemplate="";return BarcodeBase}(wijmo_1.Control);exports.BarcodeBase=BarcodeBase;var _copyObj="function"==typeof Object.assign?Object.assign:function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(null!=n)for(var a in n)t[a]=n[a]}return t};wijmo_1._registerModule("wijmo.barcode",selfModule);
|
|
14
|
+
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(t,e){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};return function(t,e){extendStatics(t,e);function __(){this.constructor=t}t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}}(),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var o in t)Object.hasOwnProperty.call(t,o)&&(e[o]=t[o]);e.default=t;return e};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.barcode")),alignmentMap={center:"middle",left:"start",right:"end"},SVGRenderContext=function(){function SVGRenderContext(t,e,o){this.dom=t;this.style=e;this.scale=o;this.color="rgb(0,0,0)";this.addGroup()}SVGRenderContext.prototype.setColor=function(t){this.color=t};SVGRenderContext.prototype.setBackgroundColor=function(t){this.dom.style.backgroundColor=t};SVGRenderContext.prototype.addGroup=function(){var t=this.dom;this.g=document.createElementNS("http://www.w3.org/2000/svg","g");this.g.setAttribute("shape-rendering","crispEdges");t.appendChild(this.g)};SVGRenderContext.prototype.drawRect=function(t){var e=this.g,o=this.scale,r=this.color,i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x",(t.x*o).toString());i.setAttribute("y",(t.y*o).toString());i.setAttribute("width",(t.width*o).toString());i.setAttribute("height",(t.height*o).toString());i.style.fill=r;e.appendChild(i)};SVGRenderContext.prototype.drawText=function(t){var e=this.g,o=this.scale,r=this.color,i=this.style,n=document.createElementNS("http://www.w3.org/2000/svg","text");n.style.fill=r;n.style.fontSize=i.fontSize;n.style.fontFamily=i.fontFamily;n.style.fontStyle=t.fontStyle||i.fontStyle;n.style.fontWeight=t.fontWeight||i.fontWeight;n.style.textDecoration=t.textDecoration||i.textDecoration;n.style.textAnchor=alignmentMap[t.textAlign||i.textAlign];n.textContent=t.text;n.textContent=this.clipString(t,n);var a=this._measureText(n);n.setAttribute("y",(t.y*o+Math.abs(a.y)).toString());n.setAttribute("x",(t.x*o).toString());e.appendChild(n)};SVGRenderContext.prototype.clipString=function(t,e){var o=this.scale,r=t.text,i=t.maxWidth,n=this._measureText(e);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};SVGRenderContext.prototype.clear=function(){this.dom.removeChild(this.g);this.addGroup()};SVGRenderContext.prototype._measureText=function(t){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.style.visibility="hidden";e.style.position="absolute";t.setAttribute("x",0);t.setAttribute("y",0);e.appendChild(t);document.body.appendChild(e);var o=t.getBBox();document.body.removeChild(e);return o};SVGRenderContext.prototype.getDataUrl=function(){return"data:image/svg+xml;base64,"+btoa(this.dom.outerHTML)};return SVGRenderContext}();exports.SVGRenderContext=SVGRenderContext;var _errorCode,CanvasRenderContext=function(){function CanvasRenderContext(t,e,o){this.dom=t;this.style=e;this.ctx=this.dom.getContext("2d");this.scale=o}CanvasRenderContext.prototype.setColor=function(t){this.ctx.fillStyle=t};CanvasRenderContext.prototype.setBackgroundColor=function(t){var e=this.ctx,o=this.dom;e.save();e.fillStyle=t;e.fillRect(0,0,o.width,o.height);e.restore()};CanvasRenderContext.prototype.drawRect=function(t){var e=this.ctx,o=this.scale;e.fillRect(t.x*o,t.y*o,t.width*o,t.height*o)};CanvasRenderContext.prototype.drawText=function(t){var e=this.ctx,o=this.style,r=this.scale;e.save();e.font=(t.fontStyle||o.fontStyle)+" "+(t.fontWeight||o.fontWeight)+" "+o.fontSize+" "+o.fontFamily;e.textAlign=t.textAlign||o.textAlign;e.textBaseline="bottom";var i=t.x*r,n=t.y*r,a=this.clipString(t);e.fillText(a,i,n+o.fontHeight);this.drawTextDecorationLine(a,i,n,t.textDecoration||o.textDecoration);e.restore()};CanvasRenderContext.prototype.clipString=function(t){var e=this.ctx,o=this.scale,r=t.text,i=t.maxWidth,n=e.measureText(r);i*=o;if(n.width>i){var a=Math.floor(i/n.width*r.length);return t.text.substr(0,a)}return r};CanvasRenderContext.prototype.drawTextDecorationLine=function(t,e,o,r){var i;switch(r){case"underline":i=.9;break;case"overline":i=.1;break;case"line-through":i=.5;break;default:return}var n=this.ctx,a=this.style.fontHeight,s=n.measureText(t).width;switch(n.textAlign){case"center":e-=s/2;break;case"right":e-=s}n.lineWidth=1;n.beginPath();var p=a*i+o;n.moveTo(e,p);n.lineTo(e+s,p);n.stroke()};CanvasRenderContext.prototype.clear=function(){var t=this.ctx,e=this.dom;t.clearRect(0,0,e.width,e.height)};CanvasRenderContext.prototype.getImageData=function(){var t=this.ctx,e=this.dom;return t.getImageData(0,0,e.width,e.height)};CanvasRenderContext.prototype.getDataUrl=function(){return this.dom.toDataURL()};return CanvasRenderContext}();exports.CanvasRenderContext=CanvasRenderContext;!function(t){t[t.Unknown=0]="Unknown";t[t.InvalidOptions=1]="InvalidOptions";t[t.InvalidBarcodeType=2]="InvalidBarcodeType";t[t.InvalidRenderType=3]="InvalidRenderType";t[t.MethodNotImplement=4]="MethodNotImplement";t[t.InvalidText=5]="InvalidText";t[t.InvalidCharacter=6]="InvalidCharacter";t[t.TextTooLong=7]="TextTooLong";t[t.GroupSizeOverflow=8]="GroupSizeOverflow"}(_errorCode=exports._errorCode||(exports._errorCode={}));var BaseException=function(t){__extends(BaseException,t);function BaseException(e){var o=t.call(this)||this;o.code=e||_errorCode.Unknown;return o}return BaseException}(Error);exports.BaseException=BaseException;exports.ErrorCode=_errorCode;var InvalidOptionsException=function(t){__extends(InvalidOptionsException,t);function InvalidOptionsException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidOptions)||this;r.name="InvalidOptionsException";r.message=JSON.stringify(e)+" is not valid options. "+o;r.descriptor={source:e,message:r.message};return r}return InvalidOptionsException}(BaseException);exports.InvalidOptionsException=InvalidOptionsException;var InvalidBarcodeTypeException=function(t){__extends(InvalidBarcodeTypeException,t);function InvalidBarcodeTypeException(e){var o=t.call(this,_errorCode.InvalidBarcodeType)||this;o.name="InvalidBarcodeTypeException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidBarcodeTypeException}(BaseException);exports.InvalidBarcodeTypeException=InvalidBarcodeTypeException;var InvalidRenderException=function(t){__extends(InvalidRenderException,t);function InvalidRenderException(e){var o=t.call(this,_errorCode.InvalidRenderType)||this;o.name="InvalidRenderException";o.message=e+" is not support!";o.descriptor={source:e,message:o.message};return o}return InvalidRenderException}(BaseException);exports.InvalidRenderException=InvalidRenderException;var MethodNotImplementException=function(t){__extends(MethodNotImplementException,t);function MethodNotImplementException(e,o){var r=t.call(this,_errorCode.MethodNotImplement)||this;r.name="MethodNotImplementException";r.message=e+" is not a method! "+o;r.descriptor={source:e,message:r.message};return r}return MethodNotImplementException}(BaseException);exports.MethodNotImplementException=MethodNotImplementException;var InvalidTextException=function(t){__extends(InvalidTextException,t);function InvalidTextException(e,o){void 0===o&&(o="");var r=t.call(this,_errorCode.InvalidText)||this;r.name="InvalidTextException";r.message=e?e+" is invalid. "+o:"Text is required.";r.descriptor={source:e,message:r.message};return r}return InvalidTextException}(BaseException);exports.InvalidTextException=InvalidTextException;var InvalidCharacterException=function(t){__extends(InvalidCharacterException,t);function InvalidCharacterException(e){var o=t.call(this,_errorCode.InvalidCharacter)||this;o.name="InvalidCharacterException";o.message=e+" is invalid.";o.descriptor={source:e,message:o.message};return o}return InvalidCharacterException}(BaseException);exports.InvalidCharacterException=InvalidCharacterException;var TextTooLongException=function(t){__extends(TextTooLongException,t);function TextTooLongException(){var e=t.call(this,_errorCode.TextTooLong)||this;e.name="TextTooLongException";e.message="Text is too long to encode";e.descriptor={source:null,message:e.message};return e}return TextTooLongException}(BaseException);exports.TextTooLongException=TextTooLongException;var GroupSizeOverflowException=function(t){__extends(GroupSizeOverflowException,t);function GroupSizeOverflowException(e){var o=t.call(this,_errorCode.GroupSizeOverflow)||this;o.name="GroupSizeOverflowException";o.message="Group size is "+e+". The max group size is 9.";o.descriptor={source:e,message:o.message};return o}return GroupSizeOverflowException}(BaseException);exports.GroupSizeOverflowException=GroupSizeOverflowException;function createRenderDom(t,e){var o;"svg"===t?(o=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"):o=document.createElement("canvas");o.setAttribute("width",e.width);o.setAttribute("height",e.height);return o}var BarcodeRender=function(){function BarcodeRender(t,e){this.container=t;e.toSymbol();this.barcode=e;this.style=e.style;var o=this.style.unitValue;this.size={width:e.size.width*o,height:e.size.height*o};var r=createRenderDom(this.style.renderType,this.size);switch(this.style.renderType){case"svg":this.context=new SVGRenderContext(r,this.style,o);break;case"canvas":this.context=new CanvasRenderContext(r,this.style,o);break;default:throw new InvalidRenderException(this.style.renderType)}t&&t.appendChild(r);this.renderDom=r}BarcodeRender.prototype.render=function(){var t=this.style,e=this.barcode.shapes,o=this.context;o.clear();o.setColor(t.color);o.setBackgroundColor(t.backgroundColor);e.forEach((function(t){"rect"===t.type&&o.drawRect(t);"text"===t.type&&o.drawText(t)}));return this};BarcodeRender.prototype.getImageData=function(){if(!this.context.getImageData)throw new MethodNotImplementException("getImageData","You are working with svg render.");return this.context.getImageData()};BarcodeRender.prototype.getDataUrl=function(){return this.context.getDataUrl()};BarcodeRender.prototype.destroy=function(){this.container&&this.container.removeChild(this.renderDom)};BarcodeRender.prototype.getSize=function(){return this.size};return BarcodeRender}();exports.BarcodeRender=BarcodeRender;function isFunction(t){return"function"==typeof t}function isWindow(t){return!!t&&t===t.window}function isDefined(t){return void 0!==t}function isNaN(t){return isFunction(Number.isNaN)?Number.isNaN(t):t!=t}function isNumberLike(t){return!isNaN(+t)}function sliceString(t,e,o){void 0===t&&(t="");void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.substring(r,r+e),n);r+=e;n++}}function sliceArray(t,e,o){void 0===t&&(t=[]);void 0===e&&(e=1);for(var r=0,i=t.length,n=0;r<i;){o(t.slice(r,r+e),n);r+=e;n++}}function str2Array(t){void 0===t&&(t="");return isFunction(Array.from)?Array.from(t):Array.prototype.slice.call(t)}function combineTruthy(t){void 0===t&&(t="");var e=str2Array(t),o=[];e.forEach((function(t){if("0"===t)o.push(0);else if(o[o.length-1]&&0!==o[o.length]){var e=o.pop();o.push(++e)}else o.push(1)}));return o}function convertRadix(t,e){void 0===e&&(e=2);return(t=+t).toString(e)}function isEven(t){return t%2==0}function isOdd(t){return t%2==1}function toNumber(t,e){void 0===t&&(t="");void 0===e&&(e=0);if("number"==typeof t)return t;var o=parseFloat(t);return isNaN(o)?e:o}function getUnit(t){void 0===t&&(t="");var e=/[a-zA-Z]+/.exec(t);return e?e[0]:"px"}function getMaxValue(t,e){void 0===e&&(e="length");var o=0;t.forEach((function(t){t[e]>o&&(o=t[e])}));return o}function assign(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(isFunction(Object.assign))return Object.assign.apply(Object,[t].concat(e));if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(t),i=0;i<e.length;i++){var n=e[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r}function deepMerge(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(null==t)throw new TypeError("Cannot convert undefined or null to object");e.forEach((function(e){if(e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(null!=e[o]&&"object"==typeof e[o]&&"object"==typeof t[o]?t[o]=deepMerge({},t[o]||{},e[o]):t[o]=e[o])}));return t}function deepMergeAll(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return deepMerge.apply(void 0,[{}].concat(t))}function strRepeat(t,e){if(isFunction(t.repeat))return t.repeat(e);var o=""+t;(e=+e)!=e&&(e=0);if(e<0)throw new RangeError("repeat count must be non-negative");if(e==1/0)throw new RangeError("repeat count must be less than infinity");e=Math.floor(e);if(0==o.length||0==e)return"";if(o.length*e>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="",i=0;i<e;i++)r+=o;return r}function isInteger(t){return isFunction(Number.isInteger)?Number.isInteger(t):"number"==typeof t&&Number.isFinite(t)&&Math.floor(t)===t}function fillArray(t,e){if(isFunction(t.fill))return t.fill(e);for(var o=0;o<t.length;o++)t[o]=e;return t}function strPadStart(t,e,o){if(isFunction(t.padStart))return t.padStart(e,o);e>>=0;o=String(void 0!==o?o:" ");if(t.length>e)return t;(e-=t.length)>o.length&&(o+=strRepeat(o,e/o.length));return o.slice(0,e)+String(t)}var plugins={};function registerPlugin(t,e){plugins[t]=e}function _defaultMeasureText(t,e){return 1.4*toNumber(e.fontSize,12)}function measureText(t,e){return isFunction(plugins.measureText)?plugins.measureText(t,e):_defaultMeasureText(t,e)}function _defaultConvertUnit(t){return toNumber(t,12)}function convertUnit(t){return isFunction(plugins.convertUnit)?isNumberLike(t)?toNumber(t,12):plugins.convertUnit(t):_defaultConvertUnit(t)}function fixSize2PixelDefault(t){return isNumberLike(t)?t+"px":t}function loop(t,e){var o,r;if(isFinite(e)){o=0;r=e}else{o=e.from;r=e.to+1}for(;o<r;o++)t(o)}function toZeroOnePattern(t,e){var o=e?isEven:isOdd;return t.reduce((function(t,e,r){o(r)?t+=strRepeat("1",e):t+=strRepeat("0",e);return t}),"")}function range(t,e){for(var o=[];t<e;){o.push(t);t++}o.push(e);return o}function makeEnums(t){Object.defineProperty(t,"has",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return this.$br[t]}});var e=Object.keys(t).reduce((function(e,o){e[t[o]]=o;return e}),{});Object.defineProperty(t,"$br",{configurable:!1,enumerable:!1,writable:!1,value:e})}function isNumberString(t){return/^[0-9]+$/.test(t)}exports.Utils={isFunction:isFunction,isWindow:isWindow,isDefined:isDefined,isNaN:isNaN,isNumberLike:isNumberLike,sliceString:sliceString,sliceArray:sliceArray,str2Array:str2Array,combineTruthy:combineTruthy,convertRadix:convertRadix,isEven:isEven,isOdd:isOdd,toNumber:toNumber,getUnit:getUnit,getMaxValue:getMaxValue,assign:assign,deepMerge:deepMerge,deepMergeAll:deepMergeAll,strRepeat:strRepeat,isInteger:isInteger,fillArray:fillArray,strPadStart:strPadStart,registerPlugin:registerPlugin,measureText:measureText,convertUnit:convertUnit,fixSize2PixelDefault:fixSize2PixelDefault,loop:loop,toZeroOnePattern:toZeroOnePattern,range:range,makeEnums:makeEnums,isNumberString:isNumberString};var Option=function(){function Option(t){void 0===t&&(t={});this.originConfig=t;this.type=t.type;this.penddingMerge=[]}Option.setCustomDefaultOptions=function(t){Option.CustomDefaultOptions=t};Option.prototype.spawn=function(t){return new Option(exports.Utils.deepMergeAll(this.originConfig,t))};Option.prototype.merge=function(t){this.penddingMerge.unshift(t)};Option.prototype._getUnitValue=function(t){t=exports.Utils.fixSize2PixelDefault(t);return exports.Utils.convertUnit(t)};Option.prototype.getMergedOption=function(){return exports.Utils.deepMergeAll.apply(exports.Utils,[Option.DefaultOptions].concat(this.penddingMerge,[Option.CustomDefaultOptions,this.originConfig]))};Option.prototype.getConfig=function(t){var e=this.getMergedOption(),o=e.text,r=e.quietZone,i=e.height,n=e.labelPosition,a=e.desiredSize,s=e.showLabel,p=e.font,c=e.backgroundColor,u=e.color,l=e.renderType,h=e.unitSize,d={text:o,isLabelBottom:!1,hideExtraChecksum:e.hideExtraChecksum};if(!exports.Utils.isDefined(o))throw new InvalidTextException;d.text+="";exports.Utils.isDefined(n)&&(d.isLabelBottom="top"!==n);(p=exports.Utils.deepMergeAll(p)).fontSize=exports.Utils.fixSize2PixelDefault(p.fontSize);var f=exports.Utils.measureText(o,p);d.showLabel=s;t=t||this._getUnitValue(h);var g=s?f/t:0;d.fontSizeInUnit=g;var x={};for(var y in r)if(r.hasOwnProperty(y)){var v=r[y];if(exports.Utils.isNumberLike(v)){var m=+v;x[y]=m}else{var _=exports.Utils.convertUnit(v);x[y]=_/t}}d.quietZone=x;if(a){d.containerWidth=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(a.width));d.containerHeight=exports.Utils.convertUnit(exports.Utils.fixSize2PixelDefault(a.height));d.desiredSize=a}if(exports.Utils.isDefined(i))if(a){var b=s?d.containerHeight-f:d.containerHeight;d.height=b/t-x.top-x.bottom}else exports.Utils.isNumberLike(i)?d.height=+i-g-x.top-x.bottom:d.height=exports.Utils.convertUnit(i)/t-g-x.top-x.bottom;return{config:e,encodeConfig:d,style:exports.Utils.deepMergeAll({backgroundColor:c,color:u,renderType:l,unitValue:t,fontSize:p.fontSize,fontHeight:f},p)}};Option.prototype.getOriginConfig=function(){return this.originConfig};Option.prototype.getType=function(){return this.type};Option.DefaultOptions={renderType:"canvas",unitSize:"1px",color:"rgb(0,0,0)",backgroundColor:"rgb(255,255,255)",font:{fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",textDecoration:"none",textAlign:"center",fontSize:"12px"},hideExtraChecksum:!1,quietZone:{top:0,right:0,bottom:0,left:0}};Option.CustomDefaultOptions={};return Option}();exports.Option=Option;function _getProtos(t){var e=[];if(t&&t instanceof Function){var o=t;e.push(o);for(;o;){var r=Object.getPrototypeOf(o);if(!r||r===Object||r===Function.prototype)break;o=r;e.push(o)}}return e}function _getDefaultConfig(t,e){var o=[{type:e}];_getProtos(t).forEach((function(t){t.DefaultConfig&&o.unshift(t.DefaultConfig)}));return exports.Utils.deepMergeAll.apply(exports.Utils,[Option.DefaultOptions].concat(o,[Option.CustomDefaultOptions]))}exports._getDefaultConfig=_getDefaultConfig;var _EnumDictionary=function(){function _EnumDictionary(t,e){this._keys={};this._values={};for(var o in t)if("string"==typeof t[o]){var r=parseInt(o),i=e(t[r]);this._keys[r]=i;this._values[i]=r}}_EnumDictionary.prototype.getEnumByString=function(t){var e=this._values[t];if(void 0===e)throw"Unknown Barcode internal value '"+t+"'";return e};_EnumDictionary.prototype.getStringByEnum=function(t){return this._keys[t]};return _EnumDictionary}();exports._EnumDictionary=_EnumDictionary;var Area=function(){function Area(t,e){void 0===t&&(t=0);void 0===e&&(e=0);this.x=0;this.y=0;this.style={padding:{top:0,right:0,bottom:0,left:0},border:{top:0,right:0,bottom:0,left:0},margin:{top:0,right:0,bottom:0,left:0}};this.width=t;this.height=e;this.children=[];this._updateBox()}Area.prototype.append=function(t){this.children.push(t)};Area.prototype._makeRect=function(t,e,o,r){return{x:t,y:e,height:r,width:o,type:"rect"}};Area.prototype.toShapes=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.border,s=n.margin,p=[],c=a.left+a.right+r,u=a.top+a.bottom+i,l=e+s.left,h=o+s.top;a.top&&p.push(this._makeRect(l,h,c,a.top));a.right&&p.push(this._makeRect(l+c-a.right,h,a.right,u));a.bottom&&p.push(this._makeRect(l,h+u-a.bottom,c,a.bottom));a.left&&p.push(this._makeRect(l,h,a.left,u));return p};Area.prototype.getSize=function(){var t=this.width,e=this.height,o=this.offsetBox;return{width:t+o.width,height:e+o.height}};Area.prototype.visiable=function(){return this.width>0&&this.height>0};Area.prototype.setX=function(t){this.x=t;this._updateBox()};Area.prototype.setY=function(t){this.y=t;this._updateBox()};Area.prototype.updateContentSize=function(t,e){this.width=t;this.height=e;this._updateBox()};Area.prototype._fixOpt=function(t,e){if(exports.Utils.isNumberLike(t[e])){var o=t[e];t[e]={top:o,right:o,bottom:o,left:o}}};Area.prototype.setStyle=function(t){this._fixOpt(t,"padding");this._fixOpt(t,"border");this._fixOpt(t,"margin");this.style=exports.Utils.deepMergeAll(this.style,t);this._updateBox()};Area.prototype._updateBox=function(){var t=this,e=t.x,o=t.y,r=t.width,i=t.height,n=t.style,a=n.padding,s=n.border,p=n.margin;this.offsetBox={x:e+a.left+s.left+p.left,y:o+a.top+s.top+p.top,width:p.left+s.left+s.right+p.right,height:p.top+s.top+s.bottom+p.bottom};var c=r-a.left-a.right,u=i-a.top-a.bottom;this.contentBox={width:c>=0?c:0,height:u>=0?u:0}};return Area}();exports.Area=Area;var HorizontalLayoutArea=function(t){__extends(HorizontalLayoutArea,t);function HorizontalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}HorizontalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.y,n=0;e.forEach((function(t){var e=o.x+n;t.toShapes().forEach((function(t){t.x+=e;t.y+=i;r.push(t)}));var a=t.getSize();n+=a.width}));return r};HorizontalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};HorizontalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.height=Math.max(o.height,t.height);t.width+=o.width;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return HorizontalLayoutArea}(Area);exports.HorizontalLayoutArea=HorizontalLayoutArea;var VerticalLayoutArea=function(t){__extends(VerticalLayoutArea,t);function VerticalLayoutArea(){return null!==t&&t.apply(this,arguments)||this}VerticalLayoutArea.prototype.toShapes=function(){this._updateContentSize();var e=this.children,o=this.offsetBox,r=t.prototype.toShapes.call(this),i=o.x,n=0;e.forEach((function(t){var e=o.y+n;t.toShapes().forEach((function(t){t.x+=i;t.y+=e;r.push(t)}));var a=t.getSize();n+=a.height}));return r};VerticalLayoutArea.prototype.getSize=function(){this._updateContentSize();return t.prototype.getSize.call(this)};VerticalLayoutArea.prototype._updateContentSize=function(){var t=this.children,e=this.style.padding,o=t.reduce((function(t,e){var o=e.getSize();t.width=Math.max(o.width,t.width);t.height+=o.height;return t}),{width:0,height:0});this.updateContentSize(o.width+e.left+e.right,o.height+e.top+e.bottom)};return VerticalLayoutArea}(Area);exports.VerticalLayoutArea=VerticalLayoutArea;var MatrixSymbolArea=function(t){__extends(MatrixSymbolArea,t);function MatrixSymbolArea(e,o,r){var i=t.call(this,e,o)||this;i._xPosition=0;i._yPosition=0;i._lastMaxHeight=0;i._rowHeight=0;i._rowHeight=r;return i}MatrixSymbolArea.prototype.append=function(t,e){if(t&&e){this._autoWrap(t);var o=this.children,r={width:t,height:e,x:this._xPosition,y:this._yPosition};o.push(r);this._xPosition+=t;this._rowHeight||(this._lastMaxHeight=Math.max(this._lastMaxHeight,e))}};MatrixSymbolArea.prototype._autoWrap=function(t){if(this._checkNeedWrap(t)){this._yPosition+=this._rowHeight||this._lastMaxHeight;this._xPosition=0;this._lastMaxHeight=0}};MatrixSymbolArea.prototype._checkNeedWrap=function(t){var e=this._xPosition;return this.contentBox.width-e-t<0};MatrixSymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._autoWrap(t);this._xPosition+=t};MatrixSymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=t.prototype.toShapes.call(this);o.forEach((function(t){t.x+=e.x;t.y+=e.y;t.type="rect";r.push(t)}));return r};return MatrixSymbolArea}(Area);exports.MatrixSymbolArea=MatrixSymbolArea;var SymbolArea=function(t){__extends(SymbolArea,t);function SymbolArea(e,o){var r=t.call(this,e,o)||this;r._lastIsBar=!1;r._cacheNumber=0;r._position=0;return r}SymbolArea.prototype.append=function(t,e,o){if(t){var r=this.children,i={width:t,x:this._position,barHeight:e,offsetY:o};r.push(i);this._position+=t}};SymbolArea.prototype.space=function(t){void 0===t&&(t=1);this._position+=t};SymbolArea.prototype._appendModule=function(t){var e="1"===t;if(e!==this._lastIsBar){this._flash();this._lastIsBar=e}this._cacheNumber++};SymbolArea.prototype._flash=function(){if(this._cacheNumber>0){this._lastIsBar?this.append(this._cacheNumber):this.space(this._cacheNumber);this._cacheNumber=0}};SymbolArea.prototype.fromPattern=function(t){var e=this;exports.Utils.str2Array(t).forEach((function(t){e._appendModule(t)}));this._flash()};SymbolArea.prototype.getContentBox=function(){return this.contentBox};SymbolArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this.contentBox.height,i=t.prototype.toShapes.call(this);o.forEach((function(t){i.push({type:"rect",x:t.x+e.x,y:e.y+(t.offsetY||0),width:t.width,height:t.barHeight||r})}));return i};return SymbolArea}(Area);exports.SymbolArea=SymbolArea;var LabelArea=function(t){__extends(LabelArea,t);function LabelArea(e,o,r){var i=t.call(this,e,o)||this;i._textAlign=r;return i}LabelArea.prototype.toShapes=function(){if(!this.visiable())return[];var e=this.offsetBox,o=this.children,r=this._textAlign,i=this.contentBox.width,n=t.prototype.toShapes.call(this);o.forEach((function(t){var o=e.x;switch(r){case"center":o+=i/2;break;case"right":o+=i}n.push({x:o+(t.x||0),y:e.y+(t.y||0),textAlign:r,maxWidth:i,type:"text",text:t.text})}));return n};return LabelArea}(Area);exports.LabelArea=LabelArea;var MatrixBuilder=function(){function MatrixBuilder(t,e){this.data=[];this.data=[];this.row=t;this.col=e}MatrixBuilder.prototype.add=function(t,e,o){(this.data[t]||exports.Utils.fillArray(new Array(this.col),null))[e]=o;this.data[t]=[]};MatrixBuilder.prototype.toMatrix=function(){var t=this,e=[];exports.Utils.loop((function(o){e.push(t.data[o]||exports.Utils.fillArray(new Array(t.col),null))}),this.row);return e};return MatrixBuilder}();exports.MatrixBuilder=MatrixBuilder;var BitBuffer=function(){function BitBuffer(t){void 0===t&&(t=[]);this.buffer=t;this.length=8*t.length;this.index=0}BitBuffer.prototype.putBit=function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0);t&&(this.buffer[e]|=128>>>this.length%8);this.length+=1};BitBuffer.prototype.putBitAt=function(t,e){for(var o=this.length,r=new BitBuffer,i=0;i<o;i++)i===e?r.putBit(t):r.putBit(this.getAt(i));this.buffer=r.buffer;this.length=r.length};BitBuffer.prototype.put=function(t,e){for(var o=0;o<e;o+=1)this.putBit(1==(t>>>e-o-1&1))};BitBuffer.prototype.putBits=function(t){this.put(parseInt(t,2),t.length)};BitBuffer.prototype.getAt=function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)};BitBuffer.prototype.getBuffer=function(){return this.buffer};BitBuffer.prototype.getGroupedBits=function(t){for(var e=0,o=[];e<this.length;){for(var r="",i=e,n=e+t;i<n;i++)r+=this.getAt(i)?1:0;e=n;o.push(parseInt(r,2))}return o};BitBuffer.prototype.next=function(){this.index++;return this.getAt(this.index-1)};return BitBuffer}();exports.BitBuffer=BitBuffer;var BarcodeEncoder=function(){function BarcodeEncoder(t){this._option=t;this.shapes=[];this.size={width:0,height:0};this.applyDesiredSize()}BarcodeEncoder.prototype.validate=function(){};BarcodeEncoder.prototype.applyDesiredSize=function(t){var e=this._option.getConfig(t),o=e.config,r=e.encodeConfig,i=e.style;this.config=o;this.encodeConfig=r;this.style=i;this.useDesiredSize=!!r.desiredSize};BarcodeEncoder.prototype.afterApplyDesiredSize=function(){};BarcodeEncoder.prototype.toSymbol=function(){this.validate();var t=this.calculateData();if(this.useDesiredSize){this.convertToShape(t,!0);this.adjustDesiredSize();this.afterApplyDesiredSize()}this.convertToShape(t)};return BarcodeEncoder}();exports.BarcodeEncoder=BarcodeEncoder;var TwoDimensionalBarcode=function(t){__extends(TwoDimensionalBarcode,t);function TwoDimensionalBarcode(){return null!==t&&t.apply(this,arguments)||this}TwoDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size,e=t.width,o=t.height,r=this.encodeConfig,i=r.desiredSize,n=r.containerWidth,a=r.containerHeight,s=Math.min(n/e,a/o);i.forceRounding&&(s=(s=~~s)<1?1:s);this.applyDesiredSize(s)};TwoDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.encodeConfig.quietZone,r=t[0].length+o.right+o.left,i=t.length+o.top+o.bottom,n=new VerticalLayoutArea,a=new MatrixSymbolArea(r,i,1);a.setStyle({padding:{top:o.top,right:o.right,bottom:o.bottom,left:o.left}});n.append(a);if(!e){t.forEach((function(t){t.forEach((function(t){t?a.append(1,1):a.space()}))}));this.shapes=n.toShapes()}this.size=n.getSize()};return TwoDimensionalBarcode}(BarcodeEncoder);exports.TwoDimensionalBarcode=TwoDimensionalBarcode;var OneDimensionalBarcode=function(t){__extends(OneDimensionalBarcode,t);function OneDimensionalBarcode(e){var o=this;e.merge(OneDimensionalBarcode.DefaultConfig);(o=t.call(this,e)||this).label="";return o}OneDimensionalBarcode.prototype.adjustDesiredSize=function(){var t=this.size.width,e=this.encodeConfig,o=e.desiredSize,r=e.containerWidth/t;o.forceRounding&&(r=(r=~~r)<1?1:r);this.applyDesiredSize(r)};OneDimensionalBarcode.prototype.convertToShape=function(t,e){var o=this.label,r=this.encodeConfig,i=r.quietZone,n=r.isLabelBottom,a=r.height,s=r.showLabel,p=r.fontSizeInUnit,c=this.style.textAlign,u=0;o&&s&&(u=p);var l=t.length+i.right+i.left,h=a+i.top+i.bottom,d=new VerticalLayoutArea,f=new SymbolArea(l,h);f.setStyle({padding:{top:i.top,right:i.right,bottom:i.bottom,left:i.left}});var g=f.getSize(),x=new LabelArea(g.width,u,c);if(n){d.append(f);d.append(x)}else{d.append(x);d.append(f)}if(!e){f.fromPattern(t);x.append({text:o});this.shapes=d.toShapes()}this.size=d.getSize()};OneDimensionalBarcode.DefaultConfig={height:60,showLabel:!0,labelPosition:"bottom"};return OneDimensionalBarcode}(BarcodeEncoder);exports.OneDimensionalBarcode=OneDimensionalBarcode;var FNC1="Ï",FNC2="Ê",FNC3="É",DataMatrixFNC1=" ",DataMatrixMacro05=" ",DataMatrixMacro06=" ";exports.Constants={FNC1:FNC1,FNC2:FNC2,FNC3:FNC3,DataMatrixFNC1:DataMatrixFNC1,DataMatrixMacro05:DataMatrixMacro05,DataMatrixMacro06:DataMatrixMacro06};exports.encoders={};var RenderType,LabelPosition,NarrowToWideRatio,Barcode=function(){function Barcode(){for(var t,e,o,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(r.length>=3)t=r[0],e=r[1],o=r[2];else if(2===r.length)exports.Utils.isFunction(r[1])?(e=r[0],o=r[1]):(t=r[0],e=r[1]);else{if(1!==r.length)throw new MethodNotImplementException("constructor","The arguments is invalid.");e=r[0]}this.dom="string"==typeof t?document.querySelector(t):t;this.callback=o&&o.bind(this);this.setOption(e)}Barcode.getImageData=function(t){void 0===t&&(t={});return new Barcode(t).getImageData()};Barcode.prototype.getImageData=function(){return this.render.getImageData()};Barcode.getDataUrl=function(t){void 0===t&&(t={});return new Barcode(t).getDataUrl()};Barcode.prototype.getDataUrl=function(){return this.render.getDataUrl()};Barcode.setDefaultOptions=function(t){void 0===t&&(t={});Option.setCustomDefaultOptions(t)};Barcode.registerEncoder=function(t,e){exports.encoders[t]=e;Barcode.supportType.push(t)};Barcode.registerPlugin=function(t,e){exports.Utils.registerPlugin(t,e)};Barcode.prototype.mergeOption=function(t){var e=this.option.spawn(t);this.update(e);return this};Barcode.prototype.setOption=function(t){this.update(new Option(t));return this};Barcode.prototype.getOption=function(){return this.option.getMergedOption()};Barcode.prototype.update=function(t){var e=t.getType(),o=exports.encoders[e];if(!o)throw new InvalidBarcodeTypeException(e);var r=new o(t);this.destroy();var i=new BarcodeRender(this.dom,r);i.render();this.render=i;this.option=t;exports.Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.refresh=function(){this.render.render();exports.Utils.isFunction(this.callback)&&this.callback()};Barcode.prototype.getSize=function(){return this.render.getSize()};Barcode.prototype.destroy=function(){if(this.render){this.render.destroy();this.render=null}};Barcode.supportType=[];Barcode.constants=exports.Constants;Barcode.ErrorCode=exports.ErrorCode;return Barcode}();exports.Barcode=Barcode;Barcode.registerPlugin("measureText",(function(t,e){var o=document.createElement("span");o.style.visibility="hidden";o.style.position="absolute";o.style.lineHeight="normal";o.textContent=t;Object.keys(e).forEach((function(t){o.style[t]=e[t]}));document.body.appendChild(o);var r=o.getBoundingClientRect();document.body.removeChild(o);return r.height}));Barcode.registerPlugin("convertUnit",(function(t){var e=document.createElement("div");e.style.visibility="hidden";e.style.position="fixed";e.style.padding="0";e.style.border="0";e.style.width=t;document.body.appendChild(e);var o=e.getBoundingClientRect();document.body.removeChild(e);return o.width}));exports.BarcodeClsNames={hostElement:"wj-barcode"};!function(t){t[t.Canvas=0]="Canvas";t[t.Svg=1]="Svg"}(RenderType=exports.RenderType||(exports.RenderType={}));!function(t){t[t.Top=0]="Top";t[t.Bottom=1]="Bottom"}(LabelPosition=exports.LabelPosition||(exports.LabelPosition={}));!function(t){t[t.OneToTwo=0]="OneToTwo";t[t.OneToThree=1]="OneToThree"}(NarrowToWideRatio=exports.NarrowToWideRatio||(exports.NarrowToWideRatio={}));var _RenderTypeConvertor=function(){function _RenderTypeConvertor(){}_RenderTypeConvertor.stringToEnum=function(t){switch(t){case"canvas":return RenderType.Canvas;case"svg":return RenderType.Svg}throw"Unknown Barcode internal renderType '"+t+"'"};_RenderTypeConvertor.enumToString=function(t){return RenderType[wijmo_1.asEnum(t,RenderType)].toLowerCase()};return _RenderTypeConvertor}();exports._RenderTypeConvertor=_RenderTypeConvertor;var _LabelPositionConvertor=function(){function _LabelPositionConvertor(){}_LabelPositionConvertor.stringToEnum=function(t){switch(t){case"top":return LabelPosition.Top;case"bottom":return LabelPosition.Bottom}throw"Unknown Barcode internal labelPosition '"+t+"'"};_LabelPositionConvertor.enumToString=function(t){return LabelPosition[wijmo_1.asEnum(t,LabelPosition)].toLowerCase()};return _LabelPositionConvertor}();exports._LabelPositionConvertor=_LabelPositionConvertor;var _NarrowWideRatioConvertor=function(){function _NarrowWideRatioConvertor(){}_NarrowWideRatioConvertor.stringToEnum=function(t){switch(t.toString()){case"2":return NarrowToWideRatio.OneToTwo;case"3":return NarrowToWideRatio.OneToThree}throw"Unknown nwRatio internal value '"+t+"'"};_NarrowWideRatioConvertor.enumToString=function(t){var e;switch(wijmo_1.asEnum(t,NarrowToWideRatio)){case NarrowToWideRatio.OneToTwo:e="2";break;case NarrowToWideRatio.OneToThree:e="3"}return e};return _NarrowWideRatioConvertor}();exports._NarrowWideRatioConvertor=_NarrowWideRatioConvertor;var BarcodeBase=function(t){__extends(BarcodeBase,t);function BarcodeBase(e,o){var r=t.call(this,e,null,!0)||this;r._state={};r._isUpd=0;r._isValid=!0;r._aw=!1;r._wZoom=1;r.isValidChanged=new wijmo_1.Event;var i=r.getTemplate();r.applyTemplate(exports.BarcodeClsNames.hostElement+" "+wijmo_1.ControlClsNames.hostElement,i,{});wijmo_1.isIE()||(r.hostElement.style.lineHeight="0px");r._state=r._getDefaults();r._isUpd++;r.initialize(o);r._updateSize();r._isUpd--;r._mergeOptions({});r.invalidate();return r}Object.defineProperty(BarcodeBase,"controlTemplate",{get:function(){BarcodeBase._ctrlTemplate||(BarcodeBase._ctrlTemplate="");return BarcodeBase._ctrlTemplate},set:function(t){BarcodeBase._ctrlTemplate=t},enumerable:!0,configurable:!0});BarcodeBase.prototype.initialize=function(e){this._isUpd++;try{t.prototype.initialize.call(this,e)}finally{this._isUpd--}!this._isUpd&&e&&Object.keys(e).length&&this._mergeOptions({})};BarcodeBase._getClassDefaults=function(){var t=this.type;return _getDefaultConfig(exports.encoders[t],t)};BarcodeBase.prototype._getDefaults=function(){var t=this.constructor;t._defaults||(t._defaults=t._getClassDefaults());return exports.Utils.deepMergeAll(t._defaults)};Object.defineProperty(BarcodeBase.prototype,"value",{get:function(){return this._getProp("text")},set:function(t){this._setProp("text",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"quietZone",{get:function(){return this._getProp("quietZone")},set:function(t){this._setProp("quietZone",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"renderType",{get:function(){return _RenderTypeConvertor.stringToEnum(this._getProp("renderType"))},set:function(t){this._setProp("renderType",_RenderTypeConvertor.enumToString(t))},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"color",{get:function(){return this._getProp("color")},set:function(t){this._setProp("color",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"backgroundColor",{get:function(){return this._getProp("backgroundColor")},set:function(t){this._setProp("backgroundColor",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"hideExtraChecksum",{get:function(){return this._getProp("hideExtraChecksum")},set:function(t){this._setProp("hideExtraChecksum",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"font",{get:function(){return this._getProp("font")},set:function(t){this._setProp("font",t)},enumerable:!0,configurable:!0});Object.defineProperty(BarcodeBase.prototype,"isValid",{get:function(){return this._isValid},enumerable:!0,configurable:!0});BarcodeBase.prototype.onIsValidChanged=function(t){this.isValidChanged.raise(this,t)};BarcodeBase.prototype.refresh=function(e){void 0===e&&(e=!0);t.prototype.refresh.call(this,e);e?this._updateSize():this._bc.refresh()};BarcodeBase.prototype.getImageData=function(){return this._bc.getImageData()};BarcodeBase.prototype.getDataUrl=function(){return this._bc.getDataUrl()};BarcodeBase.prototype.getSize=function(){var t=new wijmo_1.Size,e=this._bc.getSize();if(e){t.width=e.width;t.height=e.height}return t};BarcodeBase.prototype._mergeOptions=function(t){var e,o=this._bc,r=_copyObj(this._state,t);if(!this._isUpd){var i=r.text;if(null==i||""===i){if(o){o.destroy();this._bc=o=null}}else try{o?o.setOption(r):this._bc=o=new Barcode(this.hostElement,r)}catch(t){e=t}}var n=!0;if(e){if(o){o.destroy();this._bc=o=null}if(e.code!==_errorCode.InvalidText)throw e;n=!1}this._state=r;this._setValid(n)};BarcodeBase.prototype._setValid=function(t){if(this._isValid!==t){this._isValid=t;wijmo_1.toggleClass(this.hostElement,wijmo_1.ControlStateClsNames.invalid,!t);this.onIsValidChanged()}};BarcodeBase.prototype._setProp=function(t,e){var o;this._mergeOptions(((o={})[t]=e,o))};BarcodeBase.prototype._getProp=function(t){var e=this._bc;return this._state[t]||e&&e.getOption()[t]};BarcodeBase.prototype._updateSize=function(t){void 0===t&&(t=!0);if(this.hostElement){var e=BarcodeBase._getContentSize(this.hostElement),o=this._prevSz,r=null,i=null,n=1,a=!0;if(this._getAw()){n=this._getWzoom();i=e.height/n;a=t&&i===this._prevH;this._prevH=i;o=this._prevSz=null}else if(t){if(!o||!e.equals(o)){r={width:e.width+"px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}}else{r={width:"0px",height:e.height+"px",forceRounding:!1};a=!1;this._prevSz=e;this._prevH=null}a||this._mergeOptions({desiredSize:r,height:i,unitSize:n})}};BarcodeBase._getContentSize=function(t){var e=getComputedStyle(t);return new wijmo_1.Size(t.offsetWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth),t.offsetHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderTopWidth)-parseFloat(e.borderBottomWidth))};BarcodeBase.prototype._getAw=function(){return this._aw};BarcodeBase.prototype._setAw=function(t){if(this._aw!==t){this._aw=t;this._updateSize(!1)}};BarcodeBase.prototype._getWzoom=function(){return this._wZoom};BarcodeBase.prototype._setWzoom=function(t){wijmo_1.asNumber(t);wijmo_1.assert(t>=1,"autoWidthZoom value should be equal or greater than 1");if(this._wZoom!==t){this._wZoom=t;this._getAw()&&this._updateSize()}};BarcodeBase._ctrlTemplate="";return BarcodeBase}(wijmo_1.Control);exports.BarcodeBase=BarcodeBase;var _copyObj="function"==typeof Object.assign?Object.assign:function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];for(var r=0,i=e;r<i.length;r++){var n=i[r];if(null!=n)for(var a in n)t[a]=n[a]}return t};wijmo_1._registerModule("wijmo.barcode",selfModule);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mescius/wijmo.barcode",
|
|
3
|
-
"version": "5.20261.45-nightly.
|
|
3
|
+
"version": "5.20261.45-nightly.d20260105.t163143",
|
|
4
4
|
"description": "UI library for pure JS, Angular, React, Vue and more...",
|
|
5
5
|
"author": "MESCIUS inc",
|
|
6
6
|
"license": "Commercial",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@mescius/wijmo": "5.20261.45-nightly.
|
|
10
|
+
"@mescius/wijmo": "5.20261.45-nightly.d20260105.t163143"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://developer.mescius.com/wijmo",
|
|
13
13
|
"bugs": {
|