PageSourceSearch

https://www.directex.com/static/js/4385.9be19dc4.chunk.js

js directex.com collected 2026-10-04 03:07:12 UTC 551,868 bytes, 3 lines download raw bytes

vendor: 4,440 bytes, lines 1-2
1/*! For license information please see 4385.9be19dc4.chunk.js.LICENSE.txt */
2"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[4385],{24385:(t,e,i)=>{i.d(e,{IC:()=>mt,pH:()=>T,vi:()=>Ut});var r=i(98294),n=i(5901),s=i(39473).hp;const o="undefined"==typeof self,a=o?{}:self;let h,l,c,u,d;if("undefined"!=typeof navigator&&(h=navigator,l=h.userAgent,c=h.platform,u=h.mediaDevices),!o){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:h.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},e={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:c,search:"Win"},Mac:{str:c},Linux:{str:c}};let i="unknownBrowser",r=0,n="unknownOS";for(let e in t){const n=t[e]||{};let s=n.str||l,o=n.search||e,a=n.verStr||l,h=n.verSearch||e;if(h instanceof Array||(h=[h]),-1!=s.indexOf(o)){i=e;for(let t of h){let e=a.indexOf(t);if(-1!=e){r=parseFloat(a.substring(e+t.length+1));break}}break}}for(let t in e){const i=e[t]||{};let r=i.str||l,s=i.search||t;if(-1!=r.indexOf(s)){n=t;break}}"Linux"==n&&-1!=l.indexOf("Windows NT")&&(n="HarmonyOS"),d={browser:i,version:r,OS:n}}o&&(d={browser:"ssr",version:0,OS:"ssr"});const f="undefined"!=typeof WebAssembly&&l&&!(/Safari/.test(l)&&!/Chrome/.test(l)&&/\(.+\s11_2_([2-6]).*\)/.test(l)),g=!("undefined"==typeof Worker),_=!(!u||!u.getUserMedia),p=async()=>{let t=!1;if(_)try{(await u.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===d.browser&&d.version>66||"Safari"===d.browser&&d.version>13||"OPR"===d.browser&&d.version>43||"Edge"===d.browser&&d.version;const m=(()=>{if(!o&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"})(),v=" is not allowed to change after `createInstance` or `loadWasm` is called.",y=!o&&document.currentScript&&(document.currentScript.getAttribute("data-license")||document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||document.currentScript.getAttribute("data-organizationID"))||"",S=!o&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword")||"",C=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let e=0;e<t.length;++e){if(!o){let i=document.createElement("a");i.href=t[e],t[e]=i.href}t[e].endsWith("/")||(t[e]+="/")}}return t};var w,b,x,T,E,I;(I=w||(w={}))[I.IPF_Binary=0]="IPF_Binary",I[I.IPF_BinaryInverted=1]="IPF_BinaryInverted",I[I.IPF_GrayScaled=2]="IPF_GrayScaled",I[I.IPF_NV21=3]="IPF_NV21",I[I.IPF_RGB_565=4]="IPF_RGB_565",I[I.IPF_RGB_555=5]="IPF_RGB_555",I[I.IPF_RGB_888=6]="IPF_RGB_888",I[I.IPF_ARGB_8888=7]="IPF_ARGB_8888",I[I.IPF_RGB_161616=8]="IPF_RGB_161616",I[I.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",I[I.IPF_ABGR_8888=10]="IPF_ABGR_8888",I[I.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",I[I.IPF_BGR_888=12]="IPF_BGR_888",function(t){t[t.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",t[t.DBR_SUCCESS=0]="DBR_SUCCESS",t[t.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",t[t.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",t[t.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",t[t.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",t[t.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",t[t.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",t[t.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",t[t.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",t[t.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",t[t.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",t[t.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",t[t.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",t[t.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",t[t.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",t[t.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",t[t.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",t[t.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",t[t.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",t[t.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",t[t.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",t[t.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",t[t.DBR_PAGE_
2NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",t[t.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",t[t.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",t[t.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",t[t.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",t[t.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",t[t.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",t[t.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",t[t.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",t[t.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",t[t.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",t[t.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",t[t.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",t[t.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",t[t.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",t[t.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",t[t.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",t[t.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",t[t.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",t[t.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",t[t.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",t[t.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",t[t.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",t[t.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",t[t.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",t[t.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",t[t.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",t[t.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",t[t.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",t[t.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",t[t.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",t[t.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",t[t.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",t[t.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",t[t.DBR_PANORAMA_LICENSE_INVALID=-10060]="DBR_PANORAMA_LICENSE_INVALID",t[t.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",t[t.DBR_PHARMACODE_LICENSE_INVALID=-10062]="DBR_PHARMACODE_LICENSE_INVALID",t[t.DBR_IMAGE_ORIENTATION_INVALID=-10063]="DBR_IMAGE_ORIENTATION_INVALID",t[t.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",t[t.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",t[t.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",t[t.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(b||(b={})),function(t){t[t.IMRDT_IMAGE=1]="IMRDT_IMAGE",t[t.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",t[t.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",t[t.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",t[t.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",t[t.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(x||(x={})),function(t){t[t.BF_ALL=-29360129]="BF_ALL",t[t.BF_ONED=3147775]="BF_ONED",t[t.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",t[t.BF_CODE_39=1]="BF_CODE_39",t[t.BF_CODE_128=2]="BF_CODE_128",t[t.BF_CODE_93=4]="BF_CODE_93",t[t.BF_CODABAR=8]="BF_CODABAR",t[t.BF_ITF=16]="BF_ITF",t[t.BF_EAN_13=32]="BF_EAN_13",t[t.BF_EAN_8=64]="BF_EAN_8",t[t.BF_UPC_A=128]="BF_UPC_A",t[t.BF_UPC_E=256]="BF_UPC_E",t[t.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",t[t.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",t[t.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",t[t.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",t[t.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",t[t.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",t[t.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",t[t.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",t[t.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",t[t.BF_PATCHCODE=262144]="BF_PATCHCODE",t[t.BF_PDF417=33554432]="BF_PDF417",t[t.BF_QR_CODE=67108864]="BF_QR_CODE",t[t.BF_DATAMATRIX=134217728]="B
2F_DATAMATRIX",t[t.BF_AZTEC=268435456]="BF_AZTEC",t[t.BF_MAXICODE=536870912]="BF_MAXICODE",t[t.BF_MICRO_QR=1073741824]="BF_MICRO_QR",t[t.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",t[t.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",t[t.BF_MSI_CODE=1048576]="BF_MSI_CODE",t[t.BF_CODE_11=2097152]="BF_CODE_11",t[t.BF_NULL=0]="BF_NULL"}(T||(T={})),function(t){t[t.IRT_NO_RESULT=0]="IRT_NO_RESULT",t[t.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",t[t.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",t[t.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",t[t.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",t[t.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",t[t.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",t[t.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",t[t.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",t[t.IRT_CONTOUR=256]="IRT_CONTOUR",t[t.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",t[t.IRT_FORM=1024]="IRT_FORM",t[t.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",t[t.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",t[t.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(E||(E={}));const O=t=>t&&"object"==typeof t&&"function"==typeof t.then;class R extends Promise{constructor(t){let e,i;super(((t,r)=>{e=t,i=r})),this._s="pending",this.resolve=t=>{this.isPending&&(O(t)?this.task=t:(this._s="fulfilled",e(t)))},this.reject=t=>{this.isPending&&(this._s="rejected",i(t))},this.task=t}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(t){let e;this._task=t,O(t)?e=t:"function"==typeof t&&(e=new Promise(t)),e&&(async()=>{try{const i=await e;t===this._task&&this.resolve(i)}catch(e){t===this._task&&this.reject(e)}})()}get isEmpty(){return null==this._task}}const D=["iPhone","iPad","Android","HarmonyOS"].includes(d.OS)?2048:4096;class A{static get version(){return this._version}static get license(){return this._license}static set license(t){((t,e)=>{const i=t;if(!i._pLoad.isEmpty)throw new Error("`license`"+v);i._license=e})(A,t)}static get productKeys(){return this._license}static set productKeys(t){A.license=t}static get handshakeCode(){return this._license}static set handshakeCode(t){A.license=t}static get organizationID(){return this._license}static set organizationID(t){A.license=t}static set sessionPassword(t){((t,e)=>{const i=t;if(!i._pLoad.isEmpty)throw new Error("`sessionPassword`"+v);i._sessionPassword=e})(A,t)}static get sessionPassword(){return this._sessionPassword}static async detectEnvironment(){return await(async()=>({wasm:f,worker:g,getUserMedia:_,camera:await p(),browser:d.browser,version:d.version,OS:d.OS}))()}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(t){if(!this._pLoad.isEmpty)throw new Error("`engineResourcePath` is not allowed to change after `createInstance` or `loadWasm` is called.");A._engineResourcePath=(t=>{if(null==t&&(t="./"),!o){let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(t)}static get licenseServer(){return this._licenseServer}static set licenseServer(t){((t,e)=>{const i=t;if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+v);i._licenseServer=C(e)})(A,t)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(t){((t,e)=>{const i=t;if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+v);i._deviceFriendlyName=e||""})(A,t)}static get _bUseFullFeature(){return this.__bUseFullFeature}static set _bUseFullFeature(t){if(!this._pLoad.isEmpty)throw new Error("`_bUseFullFeature` is not allowed to change after `createInstance` or `loadWasm` is called.");A.__bUseFullFeature=t}static isImageSource(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&"getImage"in t}static isDSImage(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&"data"in t&&"width"in t&&"height"in t&&"pixelFormat"in t}static isDCEFrame(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&"data"in t&&"region"in t&&"sx"in t&&"sy"in t&&"width"in t&&"height"in t&&("colorMode"in t||"pixelFormat"in t)&&"timeSpent"in t&&"timeStamp"in t&&"isCropped"in t&&"toCanvas"in t&&"_sWidth"in t&&"_sHeight"in t&&"_bUseWebGL"in t}get ifSaveOriginalImageInACanvas(){return this._ifSaveOriginalImageInACanvas}set ifSaveOriginalImageInACanvas(t){this._ifSaveOriginalImageInACanvas=t}getOriginalImageInACanvas(){return!this.oriCanvas&&this.oriCanvasData?this.oriCanvasData.toCanvas():this.oriCanvas}set region(t){this._region=t,this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}get region(){return this._region}static isWasmLoaded(){return this._pLoad.isFulfilled}isContextDestroyed(){return this.bDestroyed}static get lastErrorCode(){return this._lastErrorCode}static get lastErrorString(){return this._lastErrorString}get lastErrorCode(){return this._lastErrorCode}get lastErrorString(){return this._lastErrorString}static get defaultUIElementURL(){var t;return null===(t=A._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",A.engineResourcePath)}static set defaultUIElementURL(t){A._defaultUIElementURL=t}static _fireHTTPSWarnning(){A.onWarning&&location&&"https:"!==location.protocol&&setTimeout((()=>{A.onWarning&&A.onWarning({id:2,message:"Not connected via SSL (HTTPS), the SDK may not work correctly."})}),0)}get soundSource(){return this._soundSource}set soundSource(t){this._soundSource=t,this.beepSound=new r.t({src:[this._soundSource],onplayerror:(t,e)=>{n.warn(`Sound '${t}' playback failure: ${e}`)}})}get whenToPlaySoundforSuccessfulRead(){return!0===this.bPlaySoundOnSuccessfulRead?"frame":this.bPlaySoundOnSuccessfulRead?this.bPlaySoundOnSuccessfulRead:"never"}set whenToPlaySoundforSuccessfulRead(t){this.bPlaySoundOnSuccessfulRead="never"!==t&&t}get whenToVibrateforSuccessfulRead(){return!0===this.bVibrateOnSuccessfulRead?"frame":this.bVibrateOnSuccessfulRead?this.bVibrateOnSuccessfulRead:"never"}set whenToVibrateforSuccessfulRead(t){this.bVibrateOnSuccessfulRead="never"!==t&&t}set dce(t){this._dce=t}get dce(){return!this._dce||this._dce.isDisposed||this._dce.disposed?null:this._dce}set maxCvsSideLength(t){this._maxCvsSideLength=t,this._dceControler&&this._dceControler.setDisiredValue(this,"maxCv
2sSideLength",t)}get maxCvsSideLength(){return this._maxCvsSideLength}async _registerDCEControler(){if(!this.dce)return;A._onLog&&A._onLog("_registerDCEControler()");const t=this.dce;this._dceControler=t._createControler();const e=this._dceControler;e.register(this),e.setDisiredValue(this,"refreshInterval",200),e.setDisiredValue(this,"maxCvsSideLength",this._maxCvsSideLength),this._styleIdBeforeVerification=this.dce.createDrawingStyle({fillStyle:"rgba(248,252,0,0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill"});try{ResizeObserver}catch(t){"ReferenceError"===t.name&&window&&(window.ResizeObserver=void 0)}const i=t.getUIElement(),r=this.dce.constructor;if("@engineResourcePath/dce.ui.html"===r._defaultUIElementURL)try{i?i===e._innerSetUI&&(await t.setUIElement(`${r.engineResourcePath}dce.ui.html`),e._innerSetUI=t.getUIElement()):(await t.setUIElement(`${r.engineResourcePath}dbr.ui.html`),e._innerSetUI=t.getUIElement())}catch(e){await t.setUIElement(r.defaultUIElementURL)}else i||await t.setUIElement(r.defaultUIElementURL);this.callbackCameraChange=()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0},this.callbackResolutionChange=()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0},this.callbackCameraClose=()=>{this.stopScanning(!0),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._bPauseScan=!1},this.callbackSingleFrameAcquired=async t=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null);let e=await this._decode_DCEFrame(t,{bCopyData:!1}),i=null;if(e&&e.length){const{sx:r,sy:n,width:s,height:o,_sWidth:a,_sHeight:h}=t;i=e.map((t=>({localizationResult:JSON.parse(JSON.stringify(t.localizationResult))}))),A.recalculateResultLocation(i,r,n,a,h,s,o)}if(this._drawResults(i,e),await this.clearMapDecodeRecord(),this.onImageRead&&this.dce.isOpen()&&!this._bPauseScan){let t=this._cloneDecodeResults(e);this.onImageRead(t)}if(this.onUniqueRead&&this.dce.isOpen()&&!this._bPauseScan)for(let t of e)this.onUniqueRead(t.barcodeText,this._cloneDecodeResults(t))},t.on("cameraChange",this.callbackCameraChange),t.on("resolutionChange",this.callbackResolutionChange),t.on("cameraClose",this.callbackCameraClose),t.on("singleFrameAcquired",this.callbackSingleFrameAcquired)}_logoutDCEControler(){this.dce&&this._dceControler&&(A._onLog&&A._onLog("_logoutDCEControler()"),this._dceControler.logout(this),this.dce.off("cameraChange",this.callbackCameraChange),this.dce.off("resolutionChange",this.callbackResolutionChange),this.dce.off("cameraClose",this.callbackCameraClose),this.dce.off("singleFrameAcquired",this.callbackSingleFrameAcquired),this._dceControler=null,this.dce=null)}async setImageSource(t,e){if(null==t)return this._imgSource=null,this._logoutDCEControler(),void(this._drawingItemNamespace=null);if(t&&t.isCameraEnhancer)this.dce=t,await this._registerDCEControler(),this._imgSource=null;else{if(!A.isImageSource(t))throw new Error("Invalid value.");this._logoutDCEControler(),this._imgSource=t}e&&e.resultsHighlightBaseShapes&&(this._drawingItemNamespace=e.resultsHighlightBaseShapes)}static async loadWasm(){if(this._pLoad.isEmpty){let{lt:t,l:e,ls:i,sp:r,rmk:s}=(t=>{const e=t;if(e._pLoad.isEmpty){let i,r,s=e._license||"",o=JSON.parse(JSON.stringify(e._licenseServer)),h=e._sessionPassword,l=0;if(s.startsWith("t")||s.startsWith("f"))l=0;else if(0===s.length||s.startsWith("P")||s.startsWith("L")||s.startsWith("Y")||s.startsWith("A"))l=1;else{l=2;const e=s.indexOf(":");if(-1!=e&&(s=s.substring(e+1)),s.startsWith("DLS2")){let e;try{let t=s.substring(4);t=atob(t),e=JSON.parse(t)}catch(t){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(s=e.handshakeCode?e.handshakeCode:e.organizationID?e.organizationID:"","number"==typeof s&&(s=JSON.stringify(s)),0===o.length){let t=[];e.mainServerURL&&(t[0]=e.mainServerURL),e.standbyServerURL&&(t[1]=e.standbyServerURL),o=C(t)}!h&&e.sessionPassword&&(h=e.sessionPassword),i=e.remark}("200001"===s||s.startsWith("200001-"))&&(o&&o.length||(s="")),s||(l=1)}
vendor: 5,353 bytes, line 2
2if(l&&(a.crypto||(r="Please upgrade your browser to support online key."),a.crypto.subtle||(r="Require https to use online key in this browser.")),r){if(1!==l)throw new Error(r);l=0,n.warn(r),e._lastErrorCode=-1,e._lastErrorString=r}return 1===l&&(s="",n.warn("Applying for a public trial license ...")),{lt:l,l:s,ls:o,sp:h,rmk:i}}throw new Error("Can't preprocess license again"+v)})(A);this._pLoad.task=async(o,a)=>{let h=A.engineResourcePath+A._workerName;A.engineResourcePath.startsWith(location.origin)||(h=await fetch(h).then((t=>t.blob())).then((t=>URL.createObjectURL(t)))),A._dbrWorker=new Worker(h),URL.revokeObjectURL(h),A._dbrWorker.onerror=t=>{let e=new Error(t.message);a(e)},A._dbrWorker.onmessage=async e=>{let i=e.data?e.data:e;switch(i.type){case"log":A._onLog&&A._onLog(i.message);break;case"load":{i.message&&(i.message=i.message.replace("(https://www.dynamsoft.com/purchase-center/)","(https://www.dynamsoft.com/store/dynamsoft-barcode-reader/#javascript)"));let e,r=!1;1===t&&(r=!0,i.message||(i.message="Using a temporary license. [Register for a 30-day trial license >>>](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&deploymenttype=browser)")),i.success?(A._dbrWorker.onerror=null,A._version=i.version+"(JS "+A._jsVersion+"."+A._jsEditVersion+")",A._onLog&&A._onLog("load dbr worker success"),i.message&&n.warn(i.message)):(e=new Error(i.message),e.stack=i.stack+"\n"+e.stack,e.ltsErrorCode=i.ltsErrorCode,r||111==i.ltsErrorCode&&-1!=i.message.toLowerCase().indexOf("trial license")&&(r=!0)),r&&A.showDialog(i.success?"warn":"error",i.message),i.success?o():a(e);break}case"task":{let t=i.id,r=i.body;try{A._taskCallbackMap.get(t)(r),A._taskCallbackMap.delete(t)}catch(e){throw A._taskCallbackMap.delete(t),e}break}default:A._onLog&&A._onLog(e)}},A._dbrWorker.postMessage({type:"loadWasm",engineResourcePath:A.engineResourcePath,bUseFullFeature:A._bUseFullFeature,bd:A._bWasmDebug,v:A._jsVersion,brtk:!!t,bptk:1===t,l:e,dm:location.origin.startsWith("http")?location.origin:"https://localhost",os:d,cv:A.authCacheVersion,fn:A.deviceFriendlyName,ls:i,sp:r,rmk:s})}}await this._pLoad}static async showDialog(t,e){await(async(t,e,i)=>{if(!t._bNeverShowDialog)try{let r=await fetch(t.engineResourcePath+"dls.license.dialog.html");if(!r.ok)throw Error("Get license dialog fail. Network Error: "+r.statusText);let n=await r.text();if(!n.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let s=document.createElement("div");s.innerHTML=n;let o=[];for(let t=0;t<s.childElementCount;++t){let e=s.children[t];e instanceof HTMLStyleElement&&(o.push(e),document.head.append(e))}let a=1==s.childElementCount?s.children[0]:s;a.remove();let h,l,c,u,d,f=[a],g=a.children;for(let t of g)f.push(t);for(let t=0;t<f.length;++t)for(let e of f[t].children)f.push(e);for(let t of f)if(!h&&t.classList.contains("dls-license-mask"))h=t,t.addEventListener("click",(e=>{if(t==e.target){a.remove();for(let t of o)t.remove()}}));else if(!l&&t.classList.contains("dls-license-icon-close"))l=t,t.addEventListener("click",(()=>{a.remove();for(let t of o)t.remove()}));else if(!c&&t.classList.contains("dls-license-icon-error"))c=t,"error"!=e&&t.remove();else if(!u&&t.classList.contains("dls-license-icon-warn"))u=t,"warn"!=e&&t.remove();else if(!d&&t.classList.contains("dls-license-msg-content")){d=t;let e=i;for(;e;){let i=e.indexOf("["),r=e.indexOf("]",i),n=e.indexOf("(",r),s=e.indexOf(")",n);if(-1==i||-1==r||-1==n||-1==s){t.appendChild(new Text(e));break}i>0&&t.appendChild(new Text(e.substring(0,i)));let o=document.createElement("a"),a=e.substring(i+1,r);o.innerText=a;let h=e.substring(n+1,s);o.setAttribute("href",h),o.setAttribute("target","_blank"),t.appendChild(o),e=e.substring(s+1)}}document.body.appendChild(a)}catch(e){t._onLog&&t._onLog(e.message||e)}})(this,t,e)}static async createInstanceInWorker(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return await A.loadWasm(),await new Promise(((e,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(t=>{if(t.success)return e(t.instanceID);{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}})),A._dbrWorker.postMessage({type:"createInstance",id:r,bScanner:t})}))}constructor(){this._instanceID=void 0,this._ifSaveOriginalImageInACanvas=!1,this.oriCanvas=null,this.oriCanvasData=null,this.canvas=null,this.bFilterRegionInJs=!1,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._timeGetMessage=null,this.decodeRecords={},this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString="",this._lastInnerDecodeDuration=0,this.intervalTime=0,this._intervalGetVideoFrame=0,this.array_getFrameTimeCost=[],this.array_decodeFrameTimeCost=[],this._indexCurrentDecodingFrame=0,this._arrPolygons=[],this._bPauseScan=!1,this._intervalDetectVideoPause=1e3,this._soundSource="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij/////
2//////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",this.bPlaySoundOnSuccessfulRead=!1,this.bVibrateOnSuccessfulRead=!1,this.vibrateDuration=300,this.captureAndDecodeInParallel=!0,this.autoSuggestTip=!1,this.suggestTipFrameArray=[],this.suggestTipFrameLimit=[5,3],this.noIntermediateResultsCount=0,this.noIntermediateResultsTipLimit=100,this.tinyBarcodeTipModuleSizeLimit=3,this.hugeBarcodeTipLimit=.9,this.autoZoomInFrameArray=[],this.autoZoomInFrameLimit=[5,3],this.autoZoomInStepRate=1/3,this.autoZoomInMaxStep=1.5,this.autoZoomInMaxTimes=5,this.autoZoomInMinStep=Math.pow(10,1/this.autoZoomInMaxTimes),this.autoZoomInIdealModuleSize=6,this.autoZoomOutFrameCount=0,this.autoZoomOutFrameLimit=3,this.autoZoomOutStepRate=1/3,this.autoZoomOutMinValue=1,this.autoZoomOutMinStep=2,this.autoZoomOutStepRate_2=.05,this.autoZoomOutMinValue_2=2,this.frameArrayInIdealZoom=[],this.frameLimitInIdealZoom=[5,3],this.enableZoomOutInIdealZoom=!1,this.nextActionInIdealZoom="focus",this.autoFocusFrameArray=[],this.autoFocusFrameLimit=[5,3],this.autoZoomIdealArea=[0,.05],this.autoZoomTargetBorder=.9,this.autoZoomDetectionArea=.5,this.autoZoom=!1,this.autoFocus=!1,this._resultHighlightingDuration=-1,this._dce=null,this._imgSource=null,this._maxCvsSideLength=D,this._promiseStartScan=null,this.beepSound=new r.t({src:[this._soundSource],onplayerror:(t,e)=>{n.warn(`Sound '${t}' playback failure: ${e}`)}})}static async createInstance(){const t=new A;return t._instanceID=await A.createInstanceInWorker(),A._fireHTTPSWarnning(),t}async clearMapDecodeRecord(){return await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})}))}async decode(t){A._onLog&&A._onLog("decode(source: any)"),A._onLog&&(this._timeStartDecode=Date.now());{let e={};return!this.region||this.region instanceof Array||(e.region=JSON.parse(JSON.stringify(this.region))),t instanceof Blob?await this._decode_Blob(t,e):t instanceof ArrayBuffer?await this._decode_ArrayBuffer(t,e):t instanceof Uint8Array||t instanceof Uint8ClampedArray?await this._decode_Uint8Array(t,e):t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?await this._decode_Image(t,e):t instanceof HTMLCanvasElement?await this._decode_Canvas(t,e):t instanceof HTMLVideoElement?await this._decode_Video(t,e):"string"==typeof t?"data:image/"==t.substring(0,11)?await this._decode_Base64(t,e):await this._decode_Url(t,e):A.isDCEFrame(t)?(e.bCopyData=!0,await this._decode_DCEFrame(t,e)):A.isDSImage(t)?(e.bCopyData=!0,await this._decode_DSImage(t,e)):await Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}}async decodeBase64String(t){let e={};return!this.region||this.region instanceof Array||(e.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(t,e)}async decodeUrl(t){let e={};return!this.region||this.region instanceof Array||(e.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(t,e)}async _decodeBuffer_Uint8Array(t,e,i,r,n,s,o){return await new Promise(((a,h)=>{let l=A._nextTaskID++;A._taskCallbackMap.set(l,(t=>{if(t.success){let e,i=A._onLog?Date.now():0;A._onLog&&A._onLog("worker return result: "+i),this._lastInnerDecodeDuration=t.duration;try{e=this._handleRetJsonString(t.decodeReturn)}catch(t){return h(t)}if(A._onLog){let t=Date.now();A._onLog("DBR getting message from worker timestamp: "+i),A._onLog("From DBR staring decoding to entering worker costs: "+(this._timeEnterInnerDBR-this._timeStartDecode)),A._onLog("From DBR entering worker to returning message from worker costs: "+(i-this._timeEnterInnerDBR)),A._onLog("Handling results from DBR worker costs: "+(t-i)),A._onLog("Total decoding image costs: "+(t-this._timeStartDecode))}return a(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,h(e)}})),this._timeEnterInnerDBR=Date.now(),A._onLog&&A._onLog("Sending buffer to worker timestamp:"+this._timeEnterInnerDBR),A._dbrWorker.postMessage({type:"decodeBuffer",id:l,instanceID:this._instanceID,body:{buffer:t,width:e,height:i,stride:r,format:n,orientation:s,config:o}},[t.buffer]),A._onLog&&o&&o.timeStamp&&A._onLog("Delay of decoding image: "+(this._timeEnterInnerDBR-o.timeStamp))}))}async _decodeBuffer_Blob(t,e,i,r,n,s,o){A._onLog&&A._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)");const a=t.arrayBuffer?await t.arrayBuffer():await new Promise(((e,i)=>{let r=new FileReader;r.readAsArrayBuffer(t),r.onload=()=>{e(r.result)},r.onerror=()=>{i(r.error)}}));return await this._decodeBuffer_Uint8Array(new Uint8Array(a),e,i,r,n,s,o)}async decodeBuffer(t,e,i,r,n,s,o){let a;return A._onLog&&A._onLog("decodeBuffer(buffer,width,height,stride,format)"),A._onLog&&(this._timeStartDecode=Date.now()),t instanceof Uint8Array||t instanceof Uint8ClampedArray?a=await this._decodeBuffer_Uint8Array(t,e,i,r,n,s,o):t instanceof ArrayBuffer?a=await this._decodeBuffer_Uint8Array(new Uint8Array(t),e,i,r,n,s,o):t instanceof Blob&&(a=await this._decodeBuffer_Blob(t,e,i,r,n,s,o)),a}async _decodeFileInMemory_Uint8Array(t){return await new Promise(((e,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(t=>{if(t.success){let r;this._lastInnerDecodeDuration=t.duration;try{r=this._handleRetJsonString(t.decodeReturn)}catch(t){return i(t)}return e(r)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}})),A._dbrWorker.postMessage({type:"decodeFileInMemory",id:r,instanceID:this._instanceID,body:{bytes:t}})}))}async getRuntimeSettings(){return await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success){let e=JSON.parse(i.results);
vendor: 1,984 bytes, line 2
2return null!=this.userDefinedRegion&&(e.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),t(e)}{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})}))}async updateRuntimeSettings(t){let e;if("string"==typeof t)if("speed"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,e.region=t.region,e.deblurLevel=3,e.expectedBarcodesCount=0,e.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,e.region=t.region,e.deblurLevel=5,e.expectedBarcodesCount=512,e.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,e.region=t.region}else if("dense"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,e.region=t.region,e.deblurLevel=9,e.expectedBarcodesCount=0,e.localizationModes=[2,8,0,0,0,0,0,0]}else if("distance"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,e.region=t.region,e.deblurLevel=3,e.expectedBarcodesCount=0,e.localizationModes=[2,8,0,0,0,0,0,0]}else e=JSON.parse(t);else{if("object"!=typeof t)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");
vendor: 20,817 bytes, line 2
2if(e=JSON.parse(JSON.stringify(t)),e.region instanceof Array){let t=e.region;[t.regionLeft,t.regionTop,t.regionLeft,t.regionBottom,t.regionMeasuredByPercentage].some((t=>void 0!==t))&&(e.region={regionLeft:t.regionLeft||0,regionTop:t.regionTop||0,regionRight:t.regionRight||0,regionBottom:t.regionBottom||0,regionMeasuredByPercentage:t.regionMeasuredByPercentage||0})}}if(!A._bUseFullFeature){if(e.barcodeFormatIds&~(T.BF_ONED|T.BF_QR_CODE|T.BF_PDF417|T.BF_DATAMATRIX)||0!=e.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=e.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(this.bFilterRegionInJs){let t=e.region;if(t instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(t)),(t.regionLeft||t.regionTop||t.regionRight||t.regionBottom||t.regionMeasuredByPercentage)&&(t.regionLeft||t.regionTop||100!=t.regionRight||100!=t.regionBottom||!t.regionMeasuredByPercentage)?this.region=t:this.region=null,e.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return(this.autoZoom||this.autoFocus)&&(e.intermediateResultTypes|=E.IRT_TYPED_BARCODE_ZONE),await new Promise(((t,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(e=>{if(e.success){try{this._handleRetJsonString(e.updateReturn)}catch(t){i(t)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}})),A._dbrWorker.postMessage({type:"updateRuntimeSettings",id:r,instanceID:this._instanceID,body:{settings:JSON.stringify(e)}})}))}async resetRuntimeSettings(){return this.userDefinedRegion=null,this.region=null,this.maxCvsSideLength=D,await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})}))}async _resetRuntimeSettingsToCppDefault(){return this.userDefinedRegion=null,this.region=null,this.maxCvsSideLength=D,await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t();{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"resetRuntimeSettingsToCppDefault",id:i,instanceID:this._instanceID})}))}async outputRuntimeSettingsToString(){if(!A._bUseFullFeature)throw Error("outputRuntimeSettingsToString() is not supported in the compact version. Please try the full-featured version.");return await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t(i.results);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"outputRuntimeSettingsToString",id:i,instanceID:this._instanceID})}))}async initRuntimeSettingsWithString(t){if(!A._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof t);else{if("object"!=typeof t)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");t=JSON.stringify(t)}return await new Promise(((e,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(t=>{if(t.success){try{this._handleRetJsonString(t.initReturn)}catch(t){i(t)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}})),A._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:r,instanceID:this._instanceID,body:{settings:t}})}))}async _decode_Blob(t,e){A._onLog&&A._onLog("_decode_Blob(blob: Blob)");let i=null,r=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(t)}catch(t){}i||(r=await function(t){return new Promise(((e,i)=>{let r=URL.createObjectURL(t),n=new Image;n.src=r,n.onload=()=>{URL.revokeObjectURL(n.src),e(n)},n.onerror=t=>{i(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}}))}(t));let n=await this._decode_Image(i||r,e);return i&&i.close(),n}async _decode_ArrayBuffer(t,e){return await this._decode_Blob(new Blob([t]),e)}async _decode_Uint8Array(t,e){return await this._decode_Blob(new Blob([t]),e)}async _decode_Image(t,e){A._onLog&&A._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),e=e||{};let i,r,n=t instanceof HTMLImageElement?t.naturalWidth:t.width,s=t instanceof HTMLImageElement?t.naturalHeight:t.height,o=Math.max(n,s);if(o>this._maxCvsSideLength){let t=this._maxCvsSideLength/o;i=Math.round(n*t),r=Math.round(s*t)}else i=n,r=s;this.canvas||(this.canvas=document.createElement("canvas"));const a=this.canvas;a.width===i&&a.height===r||(a.width=i,a.height=r),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(t,0,0,n,s,0,0,i,r);let h=await this._decode_Canvas(a,e);if(this.ifSaveOriginalImageInACanvas){const e=document.createElement("canvas");e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),this.oriCanvas=e,this.oriCanvasData=null}return A.recalculateResultLocation(h,0,0,n,s,i,r),h}async _decode_Canvas(t,e){if(A._onLog&&A._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";if(0===t.width||0===t.height)throw Error("The width or height of the 'canvas' is 0.");this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=t,this.oriCanvasData=null);let i=(t.ctx2d||t.getContext("2d",{willReadFrequently:!0})).getImageData(0,0,t.width,t.height).data;return await this._decodeBuffer_Uint8Array(i,t.width,t.height,4*t.width,w.IPF_ABGR_8888,0,e)}async _decode_Video(t,e){if(A._onLog&&A._onLog("_decode_Video(video)"),!(t instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";e=e||{};let i,r,n=t.videoWidth,s=t.videoHeight,o=Math.max(n,s);if(o>this._maxCvsSideLength){let t=this._maxCvsSideLength/o;i=Math.round(n*t),r=Math.round(s*t)}else i=n,r=s;this.canvas||(this.canvas=document.createElement("canvas"));const a=this.canvas;a.width===i&&a.height===r||(a.width=i,a.height=r),a.ctx2d||(a.ctx2d=a.getContext("2d",{willReadFrequently:!0})),a.ctx2d.drawImage(t,0,0,n,s,0,0,i,r);let h=await this._decode_Canvas(a,e);if(this.ifSaveOriginalImageInACanvas){const e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0),this.oriCanvas=e,this.oriCanvasData=null}return A.recalculateResultLocation(h,0,0,n,s,i,r),h}async _decode_DCEFrame(t,e){if(A._onLog&&A._onLog("_decode_DCEFrame(dceFrame)"),!A.isDCEFrame(t))return[];let i=[];this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:t.width,height:t.height,colorMode:t.colorMode,pixelFormat:t.pixelFormat,data:new Uint8Array(t.data),toCanvas:t.toCanvas});const{width:r,height:n,colorMode:s,pixelFormat:o,stride:a,timeStamp:h}=t;let l;l=e&&e.bCopyData?new Uint8Array(t.data):t.data;let c=null;if(e?(c=JSON.parse(JSON.stringify(e)),c.timeStamp=h):c={timeStamp:h},o&&a)if("grey"===o)i=await this._decodeBuffer_Uint8Array(l,r,n,a,w.IPF_GrayScaled,0,c);else if("rgba"===o)i=await this._decodeBuffer_Uint8Array(l,r,n,a,w.IPF_ABGR_8888,0,c);else{if("bgra"!==o)throw new Error(`Pixel format '${o}' is not supported to decode.`);i=await this._decodeBuffer_Uint8Array(l,r,n,a,w.IPF_ARGB_8888,0,c)}else if("grey"===s)i=await this._decodeBuffer_Uint8Array(l,r,n,r,w.IPF_GrayScaled,0,c);else if("rgba"===s)i=await this._decodeBuffer_Uint8Array(l,r,n,4*r,w.IPF_ABGR_8888,0,c);else{if("bgra"!==s)throw new Error(`Color mode '${s}' is not supported to decode.`);i=await this._decodeBuffer_Uint8Array(l,r,n,4*r,w.IPF_ARGB_8888,0,c)}return i}async _decode_DSImage(t,e){if(A._onLog&&A._onLog("_decode_DSImage(dsImage)"),!A.isDSImage(t))return null;this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:t.width,height:t.height,pixelFormat:t.pixelFormat.toLowerCase(),data:new Uint8Array(t.data),toCanvas:function(){const t=document.createElement("canvas");let e;switch(t.width=this.width,t.height=this.height,this.pixelFormat){case"grey":e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t<e.length;t+=4)e[t]=this.data[t/4],e[t+1]=this.data[t/4],e[t+2]=this.data[t/4],e[t+3]=255;break;case"rgb":e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t<e.length;t+=4)e[t]=this.data[t],e[t+1]=this.data[t+1],e[t+2]=this.data[t+2],e[t+3]=255;break;case"bgr":e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t<e.length;t+=4)e[t]=this.data[t],e[t+1]=this.data[t+1],e[t+2]=this.data[t+2],e[t+3]=255;break;case"rgba":case"bgra":e=new Uint8ClampedArray(this.data);break;default:throw new Error("The content of 2D Canvas is currently limited to the sRGB color space.")}const i=new ImageData(e,this.width,this.height);return t.getContext("2d").putImageData(i,0,0),t}});const{width:i,height:r}=t;let n,s,o,a=t.pixelFormat.toLowerCase();switch(n=e&&e.bCopyData?new Uint8Array(t.data):t.data,a){case"grey":o=w.IPF_GrayScaled,s=i;break;case"rgb":o=w.IPF_BGR_888,s=3*i;break;case"bgr":o=w.IPF_RGB_888,s=3*i;break;case"rgba":o=w.IPF_ABGR_8888,s=4*i;break;case"bgra":o=w.IPF_ARGB_8888,s=4*i;break;default:throw new Error("The pixel format is not supported to decode.")}return await this._decodeBuffer_Uint8Array(n,i,r,s,o,0,e)}async _decode_Base64(t,e){if(A._onLog&&A._onLog("_decode_Base64(base64Str)"),"string"!=typeof t)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'string'.");"data:image/"==t.substring(0,11)&&(t=t.substring(t.indexOf(",")+1));{let i=atob(t),r=i.length,n=new Uint8Array(r);for(;r--;)n[r]=i.charCodeAt(r);return await this._decode_Blob(new Blob([n]),e)}}async _decode_Url(t,e){if(A._onLog&&A._onLog("_decode_Url(url)"),"string"!=typeof t)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'string'.");{let i=await new Promise(((e,i)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="blob",r.send(),r.onloadend=async()=>{e(r.response)},r.onerror=()=>{i(new Error("Network Error: "+r.statusText))}}));return await this._decode_Blob(i,e)}}async _decode_FilePath(t,e){throw A._onLog&&A._onLog("_decode_FilePath(path)"),Error("'_decode_FilePath(path, config)': The method is only supported in node environment.")}static recalculateResultLocation(t,e,i,r,n,s,o){if(t.length>0)for(let a of t){let t=a.localizationResult;2==t.resultCoordinateType&&(t.x1*=.01*s,t.x2*=.01*s,t.x3*=.01*s,t.x4*=.01*s,t.y1*=.01*o,t.y2*=.01*o,t.y3*=.01*o,t.y4*=.01*o);let h=s/r,l=o/n;t.x1=t.x1/h+e,t.x2=t.x2/h+e,t.x3=t.x3/h+e,t.x4=t.x4/h+e,t.y1=t.y1/l+i,t.y2=t.y2/l+i,t.y3=t.y3/l+i,t.y4=t.y4/l+i,2==t.resultCoordinateType&&(t.x1*=100/r,t.x2*=100/r,t.x3*=100/r,t.x4*=100/r,t.y1*=100/n,t.y2*=100/n,t.y3*=100/n,t.y4*=100/n),t.x1=Math.round(t.x1),t.x2=Math.round(t.x2),t.x3=Math.round(t.x3),t.x4=Math.round(t.x4),t.y1=Math.round(t.y1),t.y2=Math.round(t.y2),t.y3=Math.round(t.y3),t.y4=Math.round(t.y4)}}static BarcodeReaderException(t,e){let i,r=b.DBR_UNKNOWN;return"number"==typeof t?(r=t,i=new Error(e)):i=new Error(t),i.code=r,i}_handleRetJsonString(t){let e=b;if(t.textResults){for(let e=0;e<t.textResults.length;e++){let i=t.textResults[e];try{let e=i.barcodeText,r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);try{i.barcodeText=decodeURIComponent(escape(r))}catch(t){i.barcodeText=r}}catch(t){i.barcodeText=""}if(null!=i.exception){A._setWarnnedEx.has(i.exception)||(A._setWarnnedEx.add(i.exception),n.warn(i.exception));let t={};i.exception.split(";").forEach((e=>{let i=e.indexOf(":");t[e.substring(0,i)]=e.substring(i+1)})),i.exception=t}}return t.decodeRecords?this.decodeRecords=t.decodeRecords:this.decodeRecords={},this._lastErrorCode=t.exception,this._lastErrorString=t.description,t.exception&&!A._setWarnnedEx.has(t.description)&&(A._setWarnnedEx.add(t.description),n.warn(t.description)),t.textResults}if(t.exception==e.DBR_SUCCESS)return t.data;throw A.BarcodeReaderException(t.exception,t.description)}async setModeArgument(t,e,i,r){return await new Promise(((n,s)=>{let o=A._nextTaskID++;A._taskCallbackMap.set(o,(t=>{if(t.success){try{this._handleRetJsonString(t.setReturn)}catch(t){return s(t)}return n()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,s(e)}})),A._dbrWorker.postMessage({type:"setModeArgument",id:o,instanceID:this._instanceID,body:{modeName:t,index:e,argumentName:i,argumentValue:r}})}))}async getModeArgument(t,e,i){return await new Promise(((r,n)=>{let s=A._nextTaskID++;A._taskCallbackMap.set(s,(t=>{if(t.success){let e;try{e=this._handleRetJsonString(t.getReturn)}catch(t){return n(t)}return r(e)}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,n(e)}})),A._dbrWorker.postMessage({type:"getModeArgument",id:s,instanceID:this._instanceID,body:{modeName:t,index:e,argumentName:i}})}))}async getIntermediateResults(){return await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t(i.results);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID,body:{isCharge:!0}})}))}async getIntermediateCanvas(){let t=await this.getIntermediateResults(),e=[];for(let i of t)if(i.dataType==x.IMRDT_IMAGE)for(let t of i.results){const i=t.bytes;let r;switch(A._onLog&&A._onLog(" "+i.length+" "+i.byteLength+" "+t.width+" "+t.height+" "+t.stride+" "+t.format),t.format){case w.IPF_ABGR_8888:r=new Uint8ClampedArray(i);break;case w.IPF_RGB_888:{const t=i.length/3;r=new Uint8ClampedArray(4*t);for(let e=0;e<t;++e)r[4*e]=i[3*e+2],r[4*e+1]=i[3*e+1],r[4*e+2]=i[3*e],r[4*e+3]=255;break}case w.IPF_GrayScaled:{const t=i.length;r=new Uint8ClampedArray(4*t);for(let e=0;e<t;e++)r[4*e]=r[4*e+1]=r[4*e+2]=i[e],r[4*e+3]=255;break}case w.IPF_Binary:case w.IPF_BinaryInverted:{const e=i.length,n=t.width,s=t.height,o=t.stride;r=new Uint8ClampedArray(n*s*4);for(let t=0;t<e;t++){let e=i[t],s=t%o*8,a=Math.floor(t/o);for(let t=0;t<8;t++){let i=s+t,o=4*(a*n+i);if(i>=n)break;r[o]=r[o+1]=r[o+2]=(128&e)/128*255,r[o+3]=255,e<<=1}}break}default:n.warn("unknow intermediate image",t)}if(!r)continue;let s=new ImageData(r,t.width,t.height),o=document.createElement("canvas");o.width=t.width,o.height=t.height,o.getContext("2d").putImageData(s,0,0),e.push(o)}return e}async getScanSettings(){return await new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success){let e=i.results;return e.intervalTime=this.intervalTime,e.whenToPlaySoundforSuccessfulRead=this.whenToPlaySoundforSuccessfulRead,e.soundOnSuccessfullRead=this.soundSource,e.whenToVibrateforSuccessfulRead=this.whenToVibrateforSuccessfulRead,e.vibrateDuration=this.vibrateDuration,e.captureAndDecodeInParallel=this.captureAndDecodeInParallel,e.autoZoom=this.autoZoom,e.autoFocus=this.autoFocus,e.autoSuggestTip=this.autoSuggestTip,t(e)}{let t=new Error(i.message);return t.stack+="\n"+i.stack,e(t)}})),A._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})}))}async updateScanSettings(t){if(!t)return;const e=JSON.parse(JSON.stringify(t));if(e.autoZoom||e.autoFocus||e.autoSuggestTip){if(!A._bUseFullFeature)throw new Error("'autoZoom', 'autoFocus' and 'autoSuggestTip' are not supported in the compact version. Please try the full-featured version.");const t=await this.getRuntimeSettings();t.intermediateResultTypes|=E.IRT_TYPED_BARCODE_ZONE,await this.updateRuntimeSettings(t)}return e.hasOwnProperty("intervalTime")&&(this.intervalTime=Math.max(e.intervalTime,0),delete e.intervalTime),e.hasOwnProperty("whenToPlaySoundforSuccessfulRead")&&(this.whenToPlaySoundforSuccessfulRead=e.whenToPlaySoundforSuccessfulRead,delete e.whenToPlaySoundforSuccessfulRead),e.hasOwnProperty("soundOnSuccessfullRead")&&(this.soundSource=e.soundOnSuccessfullRead,delete e.soundOnSuccessfullRead),e.hasOwnProperty("whenToVibrateforSuccessfulRead")&&(this.whenToVibrateforSuccessfulRead=e.whenToVibrateforSuccessfulRead,delete e.whenToVibrateforSuccessfulRead),e.hasOwnProperty("vibrateDuration")&&(this.vibrateDuration=e.vibrateDuration,delete e.vibrateDuration),e.hasOwnProperty("captureAndDecodeInParallel")&&(this.captureAndDecodeInParallel=e.captureAndDecodeInParallel,delete e.captureAndDecodeInParallel),e.hasOwnProperty("autoZoom")&&(this.autoZoom&&this.autoZoom!=e.autoZoom&&this.dce&&this.dce.setZoom({factor:1}).catch((()=>{})),this.autoZoom=e.autoZoom,delete e.autoZoom),e.hasOwnProperty("autoFocus")&&(this.autoFocus=e.autoFocus,this.dce&&this.dce.setFocus({mode:"continuous"}).catch((()=>{})),delete e.autoFocus),e.hasOwnProperty("autoSuggestTip")&&(this.autoSuggestTip=e.autoSuggestTip,delete e.autoFocus),await new Promise(((t,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(e=>{if(e.success)return t();{let t=new Error(e.message);return t.stack+="\n"+e.stack,i(t)}})),A._dbrWorker.postMessage({type:"updateScanSettings",id:r,instanceID:this._instanceID,body:{settings:e}})}))}_cloneDecodeResults(t){if(t instanceof Array){let e=[];for(let i of t)e.push(this._cloneDecodeResults(i));return e}{let e=t,i=JSON.parse(JSON.stringify(e,((t,e)=>"oriVideoCanvas"==t||"searchRegionCanvas"==t?void 0:e)));return i}}async _loopReadVideo(){if(this.bDestroyed)return this.dce&&this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),void this._drawResults(null);if(this.dce&&!this.dce.isOpen())return this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),void await this.clearMapDecodeRecord();if(!this.dce&&!this._imgSource||this._bPauseScan)return A._onLog&&A._onLog("Scan is paused, or imageSource is not set. Ask in 1s."),await this.clearMapDecodeRecord(),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this._intervalDetectVideoPause));A._onLog&&A._onLog("======= once read ======="),A._onLog&&(this._timeStartDecode=Date.now());let t=null,e=null;if(this.dce)t=this._getVideoFrame();else if(this._imgSource&&(e=await this._imgSource.getImage(),!A.isDSImage(e)))throw new Error("Invalid DSImage.");if(!t&&!e)return A._onLog&&A._onLog("Get invalid frame."),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0));(async()=>{let i=[];if(t){i=await this._decode_DCEFrame(t,{bScanner:!0,bCopyData:!1});let e=null;if(i&&i.length){const{sx:r,sy:n,width:s,height:o,_sWidth:a,_sHeight:h}=t;e=i.map((t=>({resultState:t.resultState,localizationResult:JSON.parse(JSON.stringify(t.localizationResult))}))),A.recalculateResultLocation(e,r,n,a,h,s,o)}0==this._resultHighlightingDuration?this._drawResults(null):this._drawResults(e,i),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._resultHighlightingDuration>0&&(this._clearResultsCanvasTimeoutId=setTimeout((()=>{this.bDestroyed||this._drawResults(null)}),this._resultHighlightingDuration))}else e&&(i=await this._decode_DSImage(e,{bScanner:!0,bCopyData:!1}));return i})().then((t=>{if(A._onLog&&A._onLog(t),this.dce&&this.captureAndDecodeInParallel){let t=this.array_decodeFrameTimeCost,e=this.array_getFrameTimeCost;const i=()=>{let i=0;if(e&&e.length){let r=Math.min(...t),n=Math.max(...e);r&&n&&(i=r-n)}else i=0;return i>0?i:0};(()=>{for(;t.length>=5;)t.shift();t.push(this._lastInnerDecodeDuration)})(),this._intervalGetVideoFrame=i()+this.intervalTime}if((this.dce&&this.dce.isOpen()||this._imgSource)&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&t.length){let e=!1;!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead?e=t.some((t=>t.resultState>=0)):"unique"===this.bPlaySoundOnSuccessfulRead&&(e=t.some((t=>0==t.resultState))),e&&this.beepSound&&(this.beepSound.stop(),this.beepSound.play())}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&t.length){let e=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead?e=t.some((t=>t.resultState>=0)):"unique"===this.bVibrateOnSuccessfulRead&&(e=t.some((t=>0==t.resultState))),e)try{navigator.vibrate(this.vibrateDuration)}catch(t){n.warn("Vibration not allowed. User interaction required: "+(t.message||t))}}if(this.onImageRead){t=t.filter((t=>t.resultState>=0));const e=this._cloneDecodeResults(t);this.onImageRead(e)}if(this.onUniqueRead){t=t.filter((t=>0==t.resultState));const e=this._cloneDecodeResults(t);for(let t of e)this.onUniqueRead(t.barcodeText,t)}}
vendor: 40,003 bytes, line 2
2this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.intervalTime?this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this.intervalTime):this._loopReadVideo()})).catch((t=>{this.dce&&this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),A._onLog&&A._onLog(t.message||t),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this.dce&&(this.dce.startFetchingLoop(),this._dceControler&&this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"})),this._loopReadVideo()}),Math.max(this.intervalTime,1e3)),"platform error"==t.message||n.warn(t.message)}))}_getVideoFrame(){if(!this.dce)return null;let t;if(this.captureAndDecodeInParallel){if(A._onLog&&A._onLog("Get frame in parallel."),this._dceControler&&this._dceControler.setDisiredValue(this,"loopInterval",this._intervalGetVideoFrame),!this.dce.numberOfFramesInBuffer)return this._dceControler&&this._dceControler.setDisiredValue(this,"loopInterval",0),null;t=this.dce.getFrameFromBuffer();const e=t=>{if(!t)return;let e=t.timeSpent,i=this.array_getFrameTimeCost;for(;i.length>=5;)i.shift();i.push(e)};e(t)}else A._onLog&&A._onLog("Get frame in serial."),this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),t=this.dce.getFrame();return t}_drawResults(t,e){if(!this.dce||this.dce.disposed||this._bPauseScan||!this._drawingItemNamespace||!this._drawingItemNamespace.DT_Polygon)return;if(!this._dbrDrawingLayer){if(!this.dce.isOpen())return;if(!(this.dce.singleFrameMode||this.dce.video&&this.dce._videoTrack))return;const e=t=>this.dce.getDrawingLayers().some((e=>e.getId()===t));if(!e(3)&&!(null==t?void 0:t.length))return;this._dbrDrawingLayer=this.dce.getDrawingLayer(3)}const i=this._dbrDrawingLayer;t||(t=[]);let r=this._arrPolygons;for(let n=0;n<t.length;n++){let s,o=t[n].localizationResult;r[n]?(s=r[n],i.hasDrawingItem(s)||i.addDrawingItem(s),s.set("vertices",[{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}]),(s.set||s.setAttribute).call(s,"vertices",[{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}])):(s=new this._drawingItemNamespace.DT_Polygon([{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}]),i.addDrawingItem(s),r[n]=s),-1===t[n].resultState?(s.styleId=this._styleIdBeforeVerification,s._mapStyle.set("default",this.dce.getDrawingStyle(this._styleIdBeforeVerification)),s._mapStyle.set("selected",this.dce.getDrawingStyle(this._styleIdBeforeVerification))):(s.styleId=null,s._mapStyle.set("default",this.dce.getDrawingStyle(3)),s._mapStyle.set("selected",this.dce.getDrawingStyle(7))),e&&e[n]?s.addNote({name:"Barcode_Result",content:e[n]},!0):s.addNote({name:"Barcode_Result",content:t[n]},!0)}for(let e=t.length;e<r.length;e++)r[e].deleteNote("Barcode_Result"),i.removeDrawingItem(r[e]);i.renderAll()}async startScanning(t){if(!this.dce&&!this._imgSource)throw new Error("'imageSource' is not set. call 'setImageSource()' before 'startScanning()'.");if(this._promiseStartScan&&this._promiseStartScan.isPending)return this._promiseStartScan;this._promiseStartScan=new R;let e=null;if(this.dce){if(this.dce.isOpen())if(t&&this.dce.appendAndShowUI(),this.dce.playCallbackInfo)e=JSON.parse(JSON.stringify(this.dce.playCallbackInfo));else{const t=this.dce.getSelectedCamera();e={width:this.dce.video.videoWidth,height:this.dce.video.videoHeight,deviceId:t&&t.deviceId}}else if(e=await this.dce.open(t),!this._promiseStartScan)return null;this._dceControler&&(this._dceControler.clearUserDisiredAction({user:this,actionName:"close"}),this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!0),this.dce.ifShowScanRegionLaser&&this.dce.showScanRegionLaser())}return this._bPauseScan=!1,this.dce&&this.dce.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this.dce&&(this.dce.startFetchingLoop(),this._dceControler&&this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"})),this._loopReadVideo()}),0)),this._promiseStartScan.resolve(e),e}stopScanning(t){this.dce&&(this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this._dceControler&&(this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!1),this.dce.ifShowScanRegionLaser||this.dce.hideScanRegionLaser(),this._dceControler.setDisiredAction(this,"close",[t]))),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._promiseStartScan=null}pauseScanning(t){if(this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),t&&t.keepResultsHighlighted||this._drawResults(null),this._bPauseScan=!0,this.dce){if(this.dce.singleFrameMode)throw new Error("'pauseScanning()' is unavailable when property 'singleFrameMode' of the 'CameraEnhancer' instance is true.");this._dceControler&&(this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!1),this.dce.ifShowScanRegionLaser||this.dce.hideScanRegionLaser(),this._dceControler.setDisiredAction(this,"stopFetchingLoop"))}}resumeScanning(){if(this._bPauseScan=!1,this.dce){if(this.dce.singleFrameMode)throw new Error("'resumeScanning()' is unavailable when property 'singleFrameMode' of the 'CameraEnhancer' instance is true.");this.dce.startFetchingLoop(),this._dceControler&&(this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"}),this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!0),this.dce.ifShowScanRegionLaser&&this.dce.showScanRegionLaser())}}destroyContext(){if(A._onLog&&A._onLog("destroyContext()"),this.bDestroyed)return;this.bDestroyed=!0,(this.dce||this._promiseStartScan)&&this.stopScanning(),this.setImageSource(null);let t=A._nextTaskID++;A._taskCallbackMap.set(t,(t=>{if(!t.success){let e=new Error(t.message);throw e.stack=t.stack+"\n"+e.stack,e}})),A._dbrWorker.postMessage({type:"destroyContext",id:t,instanceID:this._instanceID})}}A._jsVersion="9.6.40",A._jsEditVersion="20240108",A._version=`loading...(JS ${A._jsVersion}.${A._jsEditVersion})`,A._license=y,A._sessionPassword=S,A.browserInfo=d,A._workerName=`dbr-${A._jsVersion}.browser.worker.js`,A._engineResourcePath=m,A._licenseServer=[],A._deviceFriendlyName="",A._isShowRelDecodeTimeInResults=!1,A._bWasmDebug=!1,A._bNeverShowDialog=!1,A.__bUseFullFeature=!0,A._nextTaskID=0,A._taskCallbackMap=new Map,A._pLoad=new R,A._lastErrorCode=0,A._lastErrorString="",A._setWarnnedEx=new Set,A._defaultUIElementURL="@engineResourcePath/dbr.ui.html","function"==typeof SuppressedError&&SuppressedError;var M={653:(t,e,i)=>{var r,o,a,h,l,c,u,d,f,g,_,p,m,v,y,S,C,w,b,x,T,E=E||{version:"5.2.1"};if(e.fabric=E,"undefined"!=typeof document&&"undefined"!=typeof window)document instanceof("undefined"!=typeof HTMLDocument?HTMLDocument:Document)?E.document=document:E.document=document.implementation.createHTMLDocument(""),E.window=window;else{var I=new(i(192).JSDOM)(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"),{features:{FetchExternalResources:["img"]},resources:"usable"}).window;E.document=I.document,E.jsdomImplForWrapper=i(898).implForWrapper,E.nodeCanvas=i(245).Canvas,E.window=I,DOMParser=E.window.DOMParser}function O(t,e){var i=t.canvas,r=e.targetCanvas,n=r.getContext("2d");n.translate(0,r.height),n.scale(1,-1);var s=i.height-r.height;n.drawImage(i,0,s,r.width,r.height,0,0,r.width,r.height)}function R(t,e){var i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,n=e.destinationHeight,s=r*n*4,o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,r,n,t.RGBA,t.UNSIGNED_BYTE,o);var h=new ImageData(a,r,n);i.putImageData(h,0,0)}E.isTouchSupported="ontouchstart"in E.window||"ontouchstart"in E.document||E.window&&E.window.navigator&&E.window.navigator.maxTouchPoints>0,E.isLikelyNode=void 0!==s&&"undefined"==typeof window,E.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"],E.DPI=96,E.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)",E.commaWsp="(?:\\s+,?\\s*|,\\s*)",E.rePathCommand=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,E.reNonWord=/[ \n\.,;!\?\-]/,E.fontPaths={},E.iMatrix=[1,0,0,1,0,0],E.svgNS="http://www.w3.org/2000/svg",E.perfLimitSizeTotal=2097152,E.maxCacheSideLimit=4096,E.minCacheSideLimit=256,E.charWidthsCache={},E.textureSize=2048,E.disableStyleCopyPaste=!1,E.enableGLFiltering=!0,E.devicePixelRatio=E.window.devicePixelRatio||E.window.webkitDevicePixelRatio||E.window.mozDevicePixelRatio||1,E.browserShadowBlurConstant=1,E.arcToSegmentsCache={},E.boundsOfCurveCache={},E.cachesBoundsOfCurve=!0,E.forceGLPutImageData=!1,E.initFilterBackend=function(){return E.enableGLFiltering&&E.isWebglSupported&&E.isWebglSupported(E.textureSize)?(n.log("max texture size: "+E.maxTextureSize),new E.WebglFilterBackend({tileSize:E.textureSize})):E.Canvas2dFilterBackend?new E.Canvas2dFilterBackend:void 0},"undefined"!=typeof document&&"undefined"!=typeof window&&(window.fabric=E),function(){function t(t,e){if(this.__eventListeners[t]){var i=this.__eventListeners[t];e?i[i.indexOf(e)]=!1:E.util.array.fill(i,!1)}}function e(t,e){var i=function(){e.apply(this,arguments),this.off(t,i)}.bind(this);this.on(t,i)}E.Observable={fire:function(t,e){if(!this.__eventListeners)return this;var i=this.__eventListeners[t];if(!i)return this;for(var r=0,n=i.length;r<n;r++)i[r]&&i[r].call(this,e||{});return this.__eventListeners[t]=i.filter((function(t){return!1!==t})),this},on:function(t,e){if(this.__eventListeners||(this.__eventListeners={}),1===arguments.length)for(var i in t)this.on(i,t[i]);else this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e);return this},once:function(t,i){if(1===arguments.length)for(var r in t)e.call(this,r,t[r]);else e.call(this,t,i);return this},off:function(e,i){if(!this.__eventListeners)return this;if(0===arguments.length)for(e in this.__eventListeners)t.call(this,e);else if(1===arguments.length&&"object"==typeof arguments[0])for(var r in e)t.call(this,r,e[r]);else t.call(this,e,i);return this}}}(),E.Collection={_objects:[],add:function(){if(this._objects.push.apply(this._objects,arguments),this._onObjectAdded)for(var t=0,e=arguments.length;t<e;t++)this._onObjectAdded(arguments[t]);return this.renderOnAddRemove&&this.requestRenderAll(),this},insertAt:function(t,e,i){var r=this._objects;return i?r[e]=t:r.splice(e,0,t),this._onObjectAdded&&this._onObjectAdded(t),this.renderOnAddRemove&&this.requestRenderAll(),this},remove:function(){for(var t,e=this._objects,i=!1,r=0,n=arguments.length;r<n;r++)-1!==(t=e.indexOf(arguments[r]))&&(i=!0,e.splice(t,1),this._onObjectRemoved&&this._onObjectRemoved(arguments[r]));return this.renderOnAddRemove&&i&&this.requestRenderAll(),this},forEachObject:function(t,e){for(var i=this.getObjects(),r=0,n=i.length;r<n;r++)t.call(e,i[r],r,i);return this},getObjects:function(t){return void 0===t?this._objects.concat():this._objects.filter((function(e){return e.type===t}))},item:function(t){return this._objects[t]},isEmpty:function(){return 0===this._objects.length},size:function(){return this._objects.length},contains:function(t,e){return this._objects.indexOf(t)>-1||!!e&&this._objects.some((function(e){return"function"==typeof e.contains&&e.contains(t,!0)}))},complexity:function(){return this._objects.reduce((function(t,e){return t+(e.complexity?e.complexity():0)}),0)}},E.CommonMethods={_setOptions:function(t){for(var e in t)this.set(e,t[e])},_initGradient:function(t,e){!t||!t.colorStops||t instanceof E.Gradient||this.set(e,new E.Gradient(t))},_initPattern:function(t,e,i){!t||!t.source||t instanceof E.Pattern?i&&i():this.set(e,new E.Pattern(t,i))},_setObject:function(t){for(var e in t)this._set(e,t[e])},set:function(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this},_set:function(t,e){this[t]=e},toggle:function(t){var e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this},get:function(t){return this[t]}},r=e,o=Math.sqrt,a=Math.atan2,h=Math.pow,l=Math.PI/180,c=Math.PI/2,E.util={cos:function(t){if(0===t)return 1;switch(t<0&&(t=-t),t/c){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},sin:function(t){if(0===t)return 0;var e=1;switch(t<0&&(e=-1),t/c){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)},removeFromArray:function(t,e){var i=t.indexOf(e);return-1!==i&&t.splice(i,1),t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*l},radiansToDegrees:function(t){return t/l},rotatePoint:function(t,e,i){var r=new E.Point(t.x-e.x,t.y-e.y),n=E.util.rotateVector(r,i);return new E.Point(n.x,n.y).addEquals(e)},rotateVector:function(t,e){var i=E.util.sin(e),r=E.util.cos(e);return{x:t.x*r-t.y*i,y:t.x*i+t.y*r}},createVector:function(t,e){return new E.Point(e.x-t.x,e.y-t.y)},calcAngleBetweenVectors:function(t,e){return Math.acos((t.x*e.x+t.y*e.y)/(Math.hypot(t.x,t.y)*Math.hypot(e.x,e.y)))},getHatVector:function(t){return new E.Point(t.x,t.y).multiply(1/Math.hypot(t.x,t.y))},getBisector:function(t,e,i){var r=E.util.createVector(t,e),n=E.util.createVector(t,i),s=E.util.calcAngleBetweenVectors(r,n),o=s*(0===E.util.calcAngleBetweenVectors(E.util.rotateVector(r,s),n)?1:-1)/2;return{vector:E.util.getHatVector(E.util.rotateVector(r,o)),angle:s}},projectStrokeOnPoints:function(t,e,i){var r=[],n=e.strokeWidth/2,s=e.strokeUniform?new E.Point(1/e.scaleX,1/e.scaleY):new E.Point(1,1),o=function(t){var e=n/Math.hypot(t.x,t.y);return new E.Point(t.x*e*s.x,t.y*e*s.y)};return t.length<=1||t.forEach((function(a,h){var l,c,u=new E.Point(a.x,a.y);0===h?(c=t[h+1],l=i?o(E.util.createVector(c,u)).addEquals(u):t[t.length-1]):h===t.length-1?(l=t[h-1],c=i?o(E.util.createVector(l,u)).addEquals(u):t[0]):(l=t[h-1],c=t[h+1]);var d,f,g=E.util.getBisector(u,l,c),_=g.vector,p=g.angle;if("miter"===e.strokeLineJoin&&(d=-n/Math.sin(p/2),f=new E.Point(_.x*d*s.x,_.y*d*s.y),Math.hypot(f.x,f.y)/n<=e.strokeMiterLimit))return r.push(u.add(f)),void r.push(u.subtract(f));d=-n*Math.SQRT2,f=new E.Point(_.x*d*s.x,_.y*d*s.y),r.push(u.add(f)),r.push(u.subtract(f))})),r},transformPoint:function(t,e,i){return i?new E.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y):new E.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t,e){if(e)for(var i=0;i<t.length;i++)t[i]=E.util.transformPoint(t[i],e);var r=[t[0].x,t[1].x,t[2].x,t[3].x],n=E.util.array.min(r),s=E.util.array.max(r)-n,o=[t[0].y,t[1].y,t[2].y,t[3].y],a=E.util.array.min(o);return{left:n,top:a,width:s,height:E.util.array.max(o)-a}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=E.util.transformPoint({x:t[4],y:t[5]},i,!0);return i[4]=-r.x,i[5]=-r.y,i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);switch(e||(e=E.Text.DEFAULT_SVG_FONT_SIZE),i[0]){case"mm":return r*E.DPI/25.4;case"cm":return r*E.DPI/2.54;case"in":return r*E.DPI;case"pt":return r*E.DPI/72;case"pc":return r*E.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return!1},getKlass:function(t,e){return t=E.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1)),E.util.resolveNamespace(e)[t]},getSvgAttributes:function(t){var e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":e=e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);break;case"radialGradient":e=e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);break;case"stop":e=e.concat(["offset","stop-color","stop-opacity"])}return e},resolveNamespace:function(t){if(!t)return E;var e,i=t.split("."),n=i.length,s=r||E.window;for(e=0;e<n;++e)s=s[i[e]];return s},loadImage:function(t,e,i,r){if(t){var n=E.util.createImage(),s=function(){e&&e.call(i,n,!1),n=n.onload=n.onerror=null};n.onload=s,n.onerror=function(){E.log("Error loading "+n.src),e&&e.call(i,null,!0),n=n.onload=n.onerror=null},0!==t.indexOf("data")&&null!=r&&(n.crossOrigin=r),"data:image/svg"===t.substring(0,14)&&(n.onload=null,E.util.loadImageInDom(n,s)),n.src=t}else e&&e.call(i,t)},loadImageInDom:function(t,e){var i=E.document.createElement("div");i.style.width=i.style.height="1px",i.style.left=i.style.top="-100%",i.style.position="absolute",i.appendChild(t),E.document.querySelector("body").appendChild(i),t.onload=function(){e(),i.parentNode.removeChild(i),i=null}},enlivenObjects:function(t,e,i,r){var n=[],s=0,o=(t=t||[]).length;function a(){++s===o&&e&&e(n.filter((function(t){return t})))}o?t.forEach((function(t,e){t&&t.type?E.util.getKlass(t.type,i).fromObject(t,(function(i,s){s||(n[e]=i),r&&r(t,i,s),a()})):a()})):e&&e(n)},enlivenObjectEnlivables:function(t,e,i){var r=E.Object.ENLIVEN_PROPS.filter((function(e){return!!t[e]}));E.util.enlivenObjects(r.map((function(e){return t[e]})),(function(t){var n={};r.forEach((function(i,r){n[i]=t[r],e&&(e[i]=t[r])})),i&&i(n)}))},enlivenPatterns:function(t,e){function i(){++n===s&&e&&e(r)}var r=[],n=0,s=(t=t||[]).length;s?t.forEach((function(t,e){t&&t.source?new E.Pattern(t,(function(t){r[e]=t,i()})):(r[e]=t,i())})):e&&e(r)},groupSVGElements:function(t,e,i){var r;return t&&1===t.length?t[0]:(e&&(e.width&&e.height?e.centerPoint={x:e.width/2,y:e.height/2}:(delete e.width,delete e.height)),r=new E.Group(t,e),void 0!==i&&(r.sourcePath=i),r)},populateWithProperties:function(t,e,i){if(i&&Array.isArray(i))for(var r=0,n=i.length;r<n;r++)i[r]in t&&(e[i[r]]=t[i[r]])},createCanvasElement:function(){return E.document.createElement("canvas")},copyCanvasElement:function(t){var e=E.util.createCanvasElement();return e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0),e},toDataURL:function(t,e,i){return t.toDataURL("image/"+e,i)},createImage:function(){return E.document.createElement("img")},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var e=a(t[1],t[0]),i=h(t[0],2)+h(t[1],2),r=o(i),n=(t[0]*t[3]-t[2]*t[1])/r,s=a(t[0]*t[2]+t[1]*t[3],i);return{angle:e/l,scaleX:r,scaleY:n,skewX:s/l,skewY:0,translateX:t[4],translateY:t[5]}},calcRotateMatrix:function(t){if(!t.angle)return E.iMatrix.concat();var e=E.util.degreesToRadians(t.angle),i=E.util.cos(e),r=E.util.sin(e);return[i,r,-r,i,0,0]},calcDimensionsMatrix:function(t){var e=void 0===t.scaleX?1:t.scaleX,i=void 0===t.scaleY?1:t.scaleY,r=[t.flipX?-e:e,0,0,t.flipY?-i:i,0,0],n=E.util.multiplyTransformMatrices,s=E.util.degreesToRadians;return t.skewX&&(r=n(r,[1,0,Math.tan(s(t.skewX)),1],!0)),t.skewY&&(r=n(r,[1,Math.tan(s(t.skewY)),0,1],!0)),r},composeMatrix:function(t){var e=[1,0,0,1,t.translateX||0,t.translateY||0],i=E.util.multiplyTransformMatrices;return t.angle&&(e=i(e,E.util.calcRotateMatrix(t))),(1!==t.scaleX||1!==t.scaleY||t.skewX||t.skewY||t.flipX||t.flipY)&&(e=i(e,E.util.calcDimensionsMatrix(t))),e},resetObjectTransform:function(t){t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},saveObjectTransform:function(t){return{scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}},isTransparent:function(t,e,i,r){r>0&&(e>r?e-=r:e=0,i>r?i-=r:i=0);var n,s=!0,o=t.getImageData(e,i,2*r||1,2*r||1),a=o.data.length;for(n=3;n<a&&0!=(s=o.data[n]<=0);n+=4);return o=null,s},parsePreserveAspectRatioAttribute:function(t){var e,i="meet",r=t.split(" ");return r&&r.length&&("meet"!==(i=r.pop())&&"slice"!==i?(e=i,i="meet"):r.length&&(e=r.pop())),{meetOrSlice:i,alignX:"none"!==e?e.slice(1,4):"none",alignY:"none"!==e?e.slice(5,8):"none"}},clearFabricFontCache:function(t){(t=(t||"").toLowerCase())?E.charWidthsCache[t]&&delete E.charWidthsCache[t]:E.charWidthsCache={}},limitDimsByArea:function(t,e){var i=Math.sqrt(e*t),r=Math.floor(e/i);return{x:Math.floor(i),y:r}},capValue:function(t,e,i){return Math.max(t,Math.min(e,i))},findScaleToFit:function(t,e){return Math.min(e.width/t.width,e.height/t.height)},findScaleToCover:function(t,e){return Math.max(e.width/t.width,e.height/t.height)},matrixToSVG:function(t){return"matrix("+t.map((function(t){return E.util.toFixed(t,E.Object.NUM_FRACTION_DIGITS)})).join(" ")+")"},removeTransformFromObject:function(t,e){var i=E.util.invertTransform(e),r=E.util.multiplyTransformMatrices(i,t.calcOwnMatrix());E.util.applyTransformToObject(t,r)},addTransformToObject:function(t,e){E.util.applyTransformToObject(t,E.util.multiplyTransformMatrices(e,t.calcOwnMatrix()))},applyTransformToObject:function(t,e){var i=E.util.qrDecompose(e),r=new E.Point(i.translateX,i.translateY);t.flipX=!1,t.flipY=!1,t.set("scaleX",i.scaleX),t.set("scaleY",i.scaleY),t.skewX=i.skewX,t.skewY=i.skewY,t.angle=i.angle,t.setPositionByOrigin(r,"center","center")},sizeAfterTransform:function(t,e,i){var r=t/2,n=e/2,s=[{x:-r,y:-n},{x:r,y:-n},{x:-r,y:n},{x:r,y:n}],o=E.util.calcDimensionsMatrix(i),a=E.util.makeBoundingBoxFromPoints(s,o);return{x:a.width,y:a.height}},mergeClipPaths:function(t,e){var i=t,r=e;i.inverted&&!r.inverted&&(i=e,r=t),E.util.applyTransformToObject(r,E.util.multiplyTransformMatrices(E.util.invertTransform(i.calcTransformMatrix()),r.calcTransformMatrix()));var n=i.inverted&&r.inverted;return n&&(i.inverted=r.inverted=!1),new E.Group([i],{clipPath:r,inverted:n})}},function(){var t=Array.prototype.join,e={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},i={m:"l",M:"L"};function r(t,e,i,r,n,s,o,a,h,l,c){var u=E.util.cos(t),d=E.util.sin(t),f=E.util.cos(e),g=E.util.sin(e),_=i*n*f-r*s*g+o,p=r*n*f+i*s*g+a;return["C",l+h*(-i*n*d-r*s*u),c+h*(-r*n*d+i*s*u),_+h*(i*n*g+r*s*f),p+h*(r*n*g-i*s*f),_,p]}function n(t,e,i,r){var n=Math.atan2(e,t),s=Math.atan2(r,i);return s>=n?s-n:2*Math.PI-(n-s)}function s(t,e,i){for(var s=i[1],o=i[2],a=i[3],h=i[4],l=i[5],c=function(t,e,i,s,o,a,h){var l=Math.PI,c=h*l/180,u=E.util.sin(c),d=E.util.cos(c),f=0,g=0,_=-d*t*.5-u*e*.5,p=-d*e*.5+u*t*.5,m=(i=Math.abs(i))*i,v=(s=Math.abs(s))*s,y=p*p,S=_*_,C=m*v-m*y-v*S,w=0;if(C<0){var b=Math.sqrt(1-C/(m*v));i*=b,s*=b}else w=(o===a?-1:1)*Math.sqrt(C/(m*y+v*S));var x=w*i*p/s,T=-w*s*_/i,I=d*x-u*T+.5*t,O=u*x+d*T+.5*e,R=n(1,0,(_-x)/i,(p-T)/s),D=n((_-x)/i,(p-T)/s,(-_-x)/i,(-p-T)/s);0===a&&D>0?D-=2*l:1===a&&D<0&&(D+=2*l);for(var A=Math.ceil(Math.abs(D/l*2)),M=[],L=D/A,F=8/3*Math.sin(L/4)*Math.sin(L/4)/Math.sin(L/2),P=R+L,k=0;k<A;k++)M[k]=r(R,P,d,u,i,s,I,O,F,f,g),f=M[k][5],g=M[k][6],R=P,P+=L;return M}(i[6]-t,i[7]-e,s,o,h,l,a),u=0,d=c.length;u<d;u++)c[u][1]+=t,c[u][2]+=e,c[u][3]+=t,c[u][4]+=e,c[u][5]+=t,c[u][6]+=e;return c}function o(t,e,i,r){return Math.sqrt((i-t)*(i-t)+(r-e)*(r-e))}function a(t,e,i,r,n,s,o,a){return function(h){var l,c=(l=h)*l*l,u=function(t){return 3*t*t*(1-t)}(h),d=function(t){return 3*t*(1-t)*(1-t)}(h),f=function(t){return(1-t)*(1-t)*(1-t)}(h);return{x:o*c+n*u+i*d+t*f,y:a*c+s*u+r*d+e*f}}}function h(t,e,i,r,n,s,o,a){return function(h){var l=1-h,c=3*l*l*(i-t)+6*l*h*(n-i)+3*h*h*(o-n),u=3*l*l*(r-e)+6*l*h*(s-r)+3*h*h*(a-s);return Math.atan2(u,c)}}function l(t,e,i,r,n,s){return function(o){var a,h=(a=o)*a,l=function(t){return 2*t*(1-t)}(o),c=function(t){return(1-t)*(1-t)}(o);return{x:n*h+i*l+t*c,y:s*h+r*l+e*c}}}function c(t,e,i,r,n,s){return function(o){var a=1-o,h=2*a*(i-t)+2*o*(n-i),l=2*a*(r-e)+2*o*(s-r);return Math.atan2(l,h)}}function u(t,e,i){var r,n,s={x:e,y:i},a=0;for(n=1;n<=100;n+=1)r=t(n/100),a+=o(s.x,s.y,r.x,r.y),s=r;return a}function d(t){for(var e,i,r,n,s=0,d=t.length,f=0,g=0,_=0,p=0,m=[],v=0;v<d;v++){switch(r={x:f,y:g,command:(e=t[v])[0]},e[0]){case"M":r.length=0,_=f=e[1],p=g=e[2];break;case"L":r.length=o(f,g,e[1],e[2]),f=e[1],g=e[2];break;case"C":i=a(f,g,e[1],e[2],e[3],e[4],e[5],e[6]),n=h(f,g,e[1],e[2],e[3],e[4],e[5],e[6]),r.iterator=i,r.angleFinder=n,r.length=u(i,f,g),f=e[5],g=e[6];break;case"Q":i=l(f,g,e[1],e[2],e[3],e[4]),n=c(f,g,e[1],e[2],e[3],e[4]),r.iterator=i,r.angleFinder=n,r.length=u(i,f,g),f=e[3],g=e[4];break;case"Z":case"z":r.destX=_,r.destY=p,r.length=o(f,g,_,p),f=_,g=p}s+=r.length,m.push(r)}return m.push({length:s,x:f,y:g}),m}E.util.joinPath=function(t){return t.map((function(t){return t.join(" ")})).join(" ")},E.util.parsePath=function(t){var r,n,s,o,a,h=[],l=[],c=E.rePathCommand,u="[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*",d="("+u+")"+E.commaWsp,f="([01])"+E.commaWsp+"?",g=new RegExp(d+"?"+d+"?"+d+f+f+d+"?("+u+")","g");if(!t||!t.match)return h;for(var _,p=0,m=(a=t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi)).length;p<m;p++){o=(r=a[p]).slice(1).trim(),l.length=0;var v=r.charAt(0);if(_=[v],"a"===v.toLowerCase())for(var y;y=g.exec(o);)for(var S=1;S<y.length;S++)l.push(y[S]);else for(;s=c.exec(o);)l.push(s[0]);S=0;for(var C=l.length;S<C;S++)n=parseFloat(l[S]),isNaN(n)||_.push(n);var w=e[v.toLowerCase()],b=i[v]||v;if(_.length-1>w)for(var x=1,T=_.length;x<T;x+=w)h.push([v].concat(_.slice(x,x+w))),v=b;else h.push(_)}return h},E.util.makePathSimpler=function(t){var e,i,r,n,o,a,h=0,l=0,c=t.length,u=0,d=0,f=[];for(i=0;i<c;++i){switch(r=!1,(e=t[i].slice(0))[0]){case"l":e[0]="L",e[1]+=h,e[2]+=l;case"L":h=e[1],l=e[2];break;case"h":e[1]+=h;case"H":e[0]="L",e[2]=l,h=e[1];break;case"v":e[1]+=l;case"V":e[0]="L",l=e[1],e[1]=h,e[2]=l;break;case"m":e[0]="M",e[1]+=h,e[2]+=l;case"M":h=e[1],l=e[2],u=e[1],d=e[2];break;case"c":e[0]="C",e[1]+=h,e[2]+=l,e[3]+=h,e[4]+=l,e[5]+=h,e[6]+=l;case"C":o=e[3],a=e[4],h=e[5],l=e[6];break;case"s":e[0]="S",e[1]+=h,e[2]+=l,e[3]+=h,e[4]+=l;case"S":"C"===n?(o=2*h-o,a=2*l-a):(o=h,a=l),h=e[3],l=e[4],e[0]="C",e[5]=e[3],e[6]=e[4],e[3]=e[1],e[4]=e[2],e[1]=o,e[2]=a,o=e[3],a=e[4];break;case"q":e[0]="Q",e[1]+=h,e[2]+=l,e[3]+=h,e[4]+=l;case"Q":o=e[1],a=e[2],h=e[3],l=e[4];break;case"t":e[0]="T",e[1]+=h,e[2]+=l;case"T":"Q"===n?(o=2*h-o,a=2*l-a):(o=h,a=l),e[0]="Q",h=e[1],l=e[2],e[1]=o,e[2]=a,e[3]=h,e[4]=l;break;case"a":e[0]="A",e[6]+=h,e[7]+=l;case"A":r=!0,f=f.concat(s(h,l,e)),h=e[6],l=e[7];break;case"z":case"Z":h=u,l=d}r||f.push(e),n=e[0]}return f},E.util.getSmoothPathFromPoints=function(t,e){var i,r=[],n=new E.Point(t[0].x,t[0].y),s=new E.Point(t[1].x,t[1].y),o=t.length,a=1,h=0,l=o>2;for(e=e||0,l&&(a=t[2].x<s.x?-1:t[2].x===s.x?0:1,h=t[2].y<s.y?-1:t[2].y===s.y?0:1),r.push(["M",n.x-a*e,n.y-h*e]),i=1;i<o;i++){if(!n.eq(s)){var c=n.midPointFrom(s);r.push(["Q",n.x,n.y,c.x,c.y])}n=t[i],i+1<t.length&&(s=t[i+1])}return l&&(a=n.x>t[i-2].x?1:n.x===t[i-2].x?0:-1,h=n.y>t[i-2].y?1:n.y===t[i-2].y?0:-1),r.push(["L",n.x+a*e,n.y+h*e]),r},E.util.getPathSegmentsInfo=d,E.util.getBoundsOfCurve=function(e,i,r,n,s,o,a,h){var l;if(E.cachesBoundsOfCurve&&(l=t.call(arguments),E.boundsOfCurveCache[l]))return E.boundsOfCurveCache[l];var c,u,d,f,g,_,p,m,v=Math.sqrt,y=Math.min,S=Math.max,C=Math.abs,w=[],b=[[],[]];u=6*e-12*r+6*s,c=-3*e+9*r-9*s+3*a,d=3*r-3*e;for(var x=0;x<2;++x)if(x>0&&(u=6*i-12*n+6*o,c=-3*i+9*n-9*o+3*h,d=3*n-3*i),C(c)<1e-12){if(C(u)<1e-12)continue;0<(f=-d/u)&&f<1&&w.push(f)}else(p=u*u-4*d*c)<0||(0<(g=(-u+(m=v(p)))/(2*c))&&g<1&&w.push(g),0<(_=(-u-m)/(2*c))&&_<1&&w.push(_));for(var T,I,O,R=w.length,D=R;R--;)T=(O=1-(f=w[R]))*O*O*e+3*O*O*f*r+3*O*f*f*s+f*f*f*a,b[0][R]=T,I=O*O*O*i+3*O*O*f*n+3*O*f*f*o+f*f*f*h,b[1][R]=I;b[0][D]=e,b[1][D]=i,b[0][D+1]=a,b[1][D+1]=h;var A=[{x:y.apply(null,b[0]),y:y.apply(null,b[1])},{x:S.apply(null,b[0]),y:S.apply(null,b[1])}];return E.cachesBoundsOfCurve&&(E.boundsOfCurveCache[l]=A),A},E.util.getPointOnPath=function(t,e,i){i||(i=d(t));for(var r=0;e-i[r].length>0&&r<i.length-2;)e-=i[r].length,r++;var n,s=i[r],a=e/s.length,h=s.command,l=t[r];switch(h){case"M":return{x:s.x,y:s.y,angle:0};case"Z":case"z":return(n=new E.Point(s.x,s.y).lerp(new E.Point(s.destX,s.destY),a)).angle=Math.atan2(s.destY-s.y,s.destX-s.x),n;case"L":return(n=new E.Point(s.x,s.y).lerp(new E.Point(l[1],l[2]),a)).angle=Math.atan2(l[2]-s.y,l[1]-s.x),n;case"C":case"Q":return function(t,e){for(var i,r,n,s=0,a=0,h=t.iterator,l={x:t.x,y:t.y},c=.01,u=t.angleFinder;a<e&&c>1e-4;)i=h(s),n=s,(r=o(l.x,l.y,i.x,i.y))+a>e?(s-=c,c/=2):(l=i,s+=c,a+=r);return i.angle=u(n),i}(s,e)}},E.util.transformPath=function(t,e,i){return i&&(e=E.util.multiplyTransformMatrices(e,[1,0,0,1,-i.x,-i.y])),t.map((function(t){for(var i=t.slice(0),r={},n=1;n<t.length-1;n+=2)r.x=t[n],r.y=t[n+1],r=E.util.transformPoint(r,e),i[n]=r.x,i[n+1]=r.y;return i}))}}(),function(){var t=Array.prototype.slice;function e(t,e,i){if(t&&0!==t.length){var r=t.length-1,n=e?t[r][e]:t[r];if(e)for(;r--;)i(t[r][e],n)&&(n=t[r][e]);else for(;r--;)i(t[r],n)&&(n=t[r]);return n}}E.util.array={fill:function(t,e){for(var i=t.length;i--;)t[i]=e;return t},invoke:function(e,i){for(var r=t.call(arguments,2),n=[],s=0,o=e.length;s<o;s++)n[s]=r.length?e[s][i].apply(e[s],r):e[s][i].call(e[s]);return n},min:function(t,i){return e(t,i,(function(t,e){return t<e}))},max:function(t,i){return e(t,i,(function(t,e){return t>=e}))}}}(),function(){function t(e,i,r){if(r)if(!E.isLikelyNode&&i instanceof Element)e=i;else if(i instanceof Array){e=[];for(var n=0,s=i.length;n<s;n++)e[n]=t({},i[n],r)}else if(i&&"object"==typeof i)for(var o in i)"canvas"===o||"group"===o?e[o]=null:i.hasOwnProperty(o)&&(e[o]=t({},i[o],r));else e=i;else for(var o in i)e[o]=i[o];return e}E.util.object={extend:t,clone:function(e,i){return t({},e,i)}},E.util.object.extend(E.util,E.Observable)}(),function(){function t(t,e){var i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";var r=t.charCodeAt(e+1);if(56320>r||r>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";var n=t.charCodeAt(e-1);if(55296>n||n>56319)throw"Low surrogate without preceding high surrogate";return!1}E.util.string={camelize:function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},capitalize:function(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:function(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},graphemeSplit:function(e){var i,r=0,n=[];for(r=0;r<e.length;r++)!1!==(i=t(e,r))&&n.push(i);return n}}}(),function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1})if("toString"===t)return!1;return!0}(),r=function(t,e,r){for(var n in e)n in t.prototype&&"function"==typeof t.prototype[n]&&(e[n]+"").indexOf("callSuper")>-1?t.prototype[n]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=r;var n=e[t].apply(this,arguments);if(this.constructor.superclass=i,"initialize"!==t)return n}}(n):t.prototype[n]=e[n],i&&(e.toString!==Object.prototype.toString&&(t.prototype.toString=e.toString),e.valueOf!==Object.prototype.valueOf&&(t.prototype.valueOf=e.valueOf))};function s(){}function o(e){for(var i=null,r=this;r.constructor.superclass;){var s=r.constructor.superclass.prototype[e];if(r[e]!==s){i=s;break}r=r.constructor.superclass.prototype}return i?arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this):n.log("tried to callSuper "+e+", method not found in prototype chain",this)}E.util.createClass=function(){var i=null,n=t.call(arguments,0);function a(){this.initialize.apply(this,arguments)}"function"==typeof n[0]&&(i=n.shift()),a.superclass=i,a.subclasses=[],i&&(s.prototype=i.prototype,a.prototype=new s,i.subclasses.push(a));for(var h=0,l=n.length;h<l;h++)r(a,n[h],i);return a.prototype.initialize||(a.prototype.initialize=e),a.prototype.constructor=a,a.prototype.callSuper=o,a}}(),u=!!E.document.createElement("div").attachEvent,d=["touchstart","touchmove","touchend"],E.util.addListener=function(t,e,i,r){t&&t.addEventListener(e,i,!u&&r)},E.util.removeListener=function(t,e,i,r){t&&t.removeEventListener(e,i,!u&&r)},E.util.getPointer=function(t){var e=t.target,i=E.util.getScrollLeftTop(e),r=function(t){var e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return{x:r.clientX+i.left,y:r.clientY+i.top}},E.util.isTouchEvent=function(t){return d.indexOf(t.type)>-1||"touch"===t.pointerType},g="string"==typeof(f=E.document.createElement("div")).style.opacity,_="string"==typeof f.style.filter,p=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,m=function(t){return t},g?m=function(t,e){return t.style.opacity=e,t}:_&&(m=function(t,e){var i=t.style;return t.currentStyle&&!t.currentStyle.hasLayout&&(i.zoom=1),p.test(i.filter)?(e=e>=.9999?"":"alpha(opacity="+100*e+")",i.filter=i.filter.replace(p,e)):i.filter+=" alpha(opacity="+100*e+")",t}),E.util.setStyle=function(t,e){var i=t.style;if(!i)return t;if("string"==typeof e)return t.style.cssText+=";"+e,e.indexOf("opacity")>-1?m(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t;for(var r in e)"opacity"===r?m(t,e[r]):i["float"===r||"cssFloat"===r?void 0===i.styleFloat?"cssFloat":"styleFloat":r]=e[r];return t},function(){var t,e,i,r,n=Array.prototype.slice,s=function(t){return n.call(t,0)};try{t=s(E.document.childNodes)instanceof Array}catch(t){}function o(t,e){var i=E.document.createElement(t);for(var r in e)"class"===r?i.className=e[r]:"for"===r?i.htmlFor=e[r]:i.setAttribute(r,e[r]);return i}function a(t){for(var e=0,i=0,r=E.document.documentElement,n=E.document.body||{scrollLeft:0,scrollTop:0};t&&(t.parentNode||t.host)&&((t=t.parentNode||t.host)===E.document?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=t.scrollLeft||0,i+=t.scrollTop||0),1!==t.nodeType||"fixed"!==t.style.position););return{left:e,top:i}}t||(s=function(t){for(var e=new Array(t.length),i=t.length;i--;)e[i]=t[i];return e}),e=E.document.defaultView&&E.document.defaultView.getComputedStyle?function(t,e){var i=E.document.defaultView.getComputedStyle(t,null);return i?i[e]:void 0}:function(t,e){var i=t.style[e];return!i&&t.currentStyle&&(i=t.currentStyle[e]),i},i=E.document.documentElement.style,r="userSelect"in i?"userSelect":"MozUserSelect"in i?"MozUserSelect":"WebkitUserSelect"in i?"WebkitUserSelect":"KhtmlUserSelect"in i?"KhtmlUserSelect":"",E.util.makeElementUnselectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=E.util.falseFunction),r?t.style[r]="none":"string"==typeof t.unselectable&&(t.unselectable="on"),t},E.util.makeElementSelectable=function(t){return void 0!==t.onselectstart&&(t.onselectstart=null),r?t.style[r]="":"string"==typeof t.unselectable&&(t.unselectable=""),t},E.util.setImageSmoothing=function(t,e){t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled,t.imageSmoothingEnabled=e},E.util.getById=function(t){return"string"==typeof t?E.document.getElementById(t):t},E.util.toArray=s,E.util.addClass=function(t,e){t&&-1===(" "+t.className+" ").indexOf(" "+e+" ")&&(t.className+=(t.className?" ":"")+e)},E.util.makeElement=o,E.util.wrapElement=function(t,e,i){return"string"==typeof e&&(e=o(e,i)),t.parentNode&&t.parentNode.replaceChild(e,t),e.appendChild(t),e},E.util.getScrollLeftTop=a,E.util.getElementOffset=function(t){var i,r,n=t&&t.ownerDocument,s={left:0,top:0},o={left:0,top:0},h={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!n)return o;for(var l in h)o[h[l]]+=parseInt(e(t,l),10)||0;return i=n.documentElement,void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect()),r=a(t),{left:s.left+r.left-(i.clientLeft||0)+o.left,top:s.top+r.top-(i.clientTop||0)+o.top}},E.util.getNodeCanvas=function(t){var e=E.jsdomImplForWrapper(t);return e._canvas||e._image},E.util.cleanUpJsdomNode=function(t){if(E.isLikelyNode){var e=E.jsdomImplForWrapper(t);e&&(e._image=null,e._canvas=null,e._currentSrc=null,e._attributes=null,e._classList=null)}}}(),function(){function t(){}E.util.request=function(e,i){i||(i={});var r=i.method?i.method.toUpperCase():"GET",n=i.onComplete||function(){},s=new E.window.XMLHttpRequest,o=i.body||i.parameters;return s.onreadystatechange=function(){4===s.readyState&&(n(s),s.onreadystatechange=t)},"GET"===r&&(o=null,"string"==typeof i.parameters&&(e=function(t,e){return t+(/\?/.test(t)?"&":"?")+e}(e,i.parameters))),s.open(r,e,!0),"POST"!==r&&"PUT"!==r||s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(o),s}}(),E.log=n.log,E.warn=n.warn,function(){var t=E.util.object.extend,e=E.util.object.clone,i=[];function r(){return!1}function n(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}E.util.object.extend(i,{cancelAll:function(){var t=this.splice(0);return t.forEach((function(t){t.cancel()})),t},cancelByCanvas:function(t){if(!t)return[];var e=this.filter((function(e){return"object"==typeof e.target&&e.target.canvas===t}));return e.forEach((function(t){t.cancel()})),e},cancelByTarget:function(t){var e=this.findAnimationsByTarget(t);return e.forEach((function(t){t.cancel()})),e},findAnimationIndex:function(t){return this.indexOf(this.findAnimation(t))},findAnimation:function(t){return this.find((function(e){return e.cancel===t}))},findAnimationsByTarget:function(t){return t?this.filter((function(e){return e.target===t})):[]}});var s=E.window.requestAnimationFrame||E.window.webkitRequestAnimationFrame||E.window.mozRequestAnimationFrame||E.window.oRequestAnimationFrame||E.window.msRequestAnimationFrame||function(t){return E.window.setTimeout(t,1e3/60)},o=E.window.cancelAnimationFrame||E.window.clearTimeout;function a(){return s.apply(E.window,arguments)}E.util.animate=function(i){i||(i={});var s,o=!1,h=function(){var t=E.runningAnimations.indexOf(s);return t>-1&&E.runningAnimations.splice(t,1)[0]};return s=t(e(i),{cancel:function(){return o=!0,h()},currentValue:"startValue"in i?i.startValue:0,completionRate:0,durationRate:0}),E.runningAnimations.push(s),a((function(t){var e,l=t||+new Date,c=i.duration||500,u=l+c,d=i.onChange||r,f=i.abort||r,g=i.onComplete||r,_=i.easing||n,p="startValue"in i&&i.startValue.length>0,m="startValue"in i?i.startValue:0,v="endValue"in i?i.endValue:100,y=i.byValue||(p?m.map((function(t,e){return v[e]-m[e]})):v-m);i.onStart&&i.onStart(),function t(i){var r=(e=i||+new Date)>u?c:e-l,n=r/c,S=p?m.map((function(t,e){return _(r,m[e],y[e],c)})):_(r,m,y,c),C=p?Math.abs((S[0]-m[0])/y[0]):Math.abs((S-m)/y);if(s.currentValue=p?S.slice():S,s.completionRate=C,s.durationRate=n,!o){if(!f(S,C,n))return e>u?(s.currentValue=p?v.slice():v,s.completionRate=1,s.durationRate=1,d(p?v.slice():v,1,1),g(v,1,1),void h()):(d(S,C,n),void a(t));h()}}(l)})),s.cancel},E.util.requestAnimFrame=a,E.util.cancelAnimFrame=function(){return o.apply(E.window,arguments)},E.runningAnimations=i}(),function(){function t(t,e,i){var r="rgba("+parseInt(t[0]+i*(e[0]-t[0]),10)+","+parseInt(t[1]+i*(e[1]-t[1]),10)+","+parseInt(t[2]+i*(e[2]-t[2]),10);return(r+=","+(t&&e?parseFloat(t[3]+i*(e[3]-t[3])):1))+")"}E.util.animateColor=function(e,i,r,n){var s=new E.Color(e).getSource(),o=new E.Color(i).getSource(),a=n.onComplete,h=n.onChange;return n=n||{},E.util.animate(E.util.object.extend(n,{duration:r||500,startValue:s,endValue:o,byValue:o,easing:function(e,i,r,s){return t(i,r,n.colorEasing?n.colorEasing(e,s):1-Math.cos(e/s*(Math.PI/2)))},onComplete:function(e,i,r){if(a)return a(t(o,o,0),i,r)},onChange:function(e,i,r){if(h){if(Array.isArray(e))return h(t(e,e,0),i,r);h(e,i,r)}}}))}}(),function(){function t(t,e,i,r){return t<Math.abs(e)?(t=e,r=i/4):r=0===e&&0===t?i/(2*Math.PI)*Math.asin(1):i/(2*Math.PI)*Math.asin(e/t),{a:t,c:e,p:i,s:r}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,n){return i-r(n-t,0,i,n)+e}function r(t,e,i,r){return(t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}E
vendor: 4,703 bytes, line 2
2.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:function(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,i,r){return i*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,i,r){return i*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,i,r){return 0===t?e:i*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,i,r){return t===r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,i,r){return 0===t?e:t===r?e+i:(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,i,r){return(t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(i,r,n,s){var o=0;return 0===i?r:1==(i/=s)?r+n:(o||(o=.3*s),-e(t(n,n,o,1.70158),i,s)+r)},easeOutElastic:function(e,i,r,n){var s=0;if(0===e)return i;if(1==(e/=n))return i+r;s||(s=.3*n);var o=t(r,r,s,1.70158);return o.a*Math.pow(2,-10*e)*Math.sin((e*n-o.s)*(2*Math.PI)/o.p)+o.c+i},easeInOutElastic:function(i,r,n,s){var o=0;if(0===i)return r;if(2==(i/=s/2))return r+n;o||(o=s*(.3*1.5));var a=t(n,n,o,1.70158);return i<1?-.5*e(a,i,s)+r:a.a*Math.pow(2,-10*(i-=1))*Math.sin((i*s-a.s)*(2*Math.PI)/a.p)*.5+a.c+r},easeInBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*(t/=r)*t*((n+1)*t-n)+e},easeOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),i*((t=t/r-1)*t*((n+1)*t+n)+1)+e},easeInOutBack:function(t,e,i,r,n){return void 0===n&&(n=1.70158),(t/=r/2)<1?i/2*(t*t*((1+(n*=1.525))*t-n))+e:i/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},easeInBounce:i,easeOutBounce:r,easeInOutBounce:function(t,e,n,s){return t<s/2?.5*i(2*t,0,n,s)+e:.5*r(2*t-s,0,n,s)+.5*n+e}}}(),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n=e.util.toFixed,s=e.util.parseUnit,o=e.util.multiplyTransformMatrices,a={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing"},h={stroke:"strokeOpacity",fill:"fillOpacity"},l="font-size",c="clip-path";function u(t){return t in a?a[t]:t}function d(t,i,r,n){var a,h=Array.isArray(i);if("fill"!==t&&"stroke"!==t||"none"!==i){if("strokeUniform"===t)return"non-scaling-stroke"===i;if("strokeDashArray"===t)i="none"===i?null:i.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)i=r&&r.transformMatrix?o(r.transformMatrix,e.parseTransformAttribute(i)):e.parseTransformAttribute(i);else if("visible"===t)i="none"!==i&&"hidden"!==i,r&&!1===r.visible&&(i=!1);else if("opacity"===t)i=parseFloat(i),r&&void 0!==r.opacity&&(i*=r.opacity);else if("textAnchor"===t)i="start"===i?"left":"end"===i?"right":"center";else if("charSpacing"===t)a=s(i,n)/n*1e3;else if("paintFirst"===t){var l=i.indexOf("fill"),c=i.indexOf("stroke");i="fill",(l>-1&&c>-1&&c<l||-1===l&&c>-1)&&(i="stroke")}else{if("href"===t||"xlink:href"===t||"font"===t)return i;if("imageSmoothing"===t)return"optimizeQuality"===i;a=h?i.map(s):s(i,n)}}else i="";return!h&&isNaN(a)?i:a}function f(t){return new RegExp("^("+t.join("|")+")\\b","i")}function g(t,e){var i,r,n,s,o=[];for(n=0,s=e.length;n<s;n++)i=e[n],r=t.getElementsByTagName(i),o=o.concat(Array.prototype.slice.call(r));return o}function 
vendor: 12,316 bytes, line 2
2_(t,e){var i,r=!0;return(i=p(t,e.pop()))&&e.length&&(r=function(t,e){for(var i,r=!0;t.parentNode&&1===t.parentNode.nodeType&&e.length;)r&&(i=e.pop()),r=p(t=t.parentNode,i);return 0===e.length}(t,e)),i&&r&&0===e.length}function p(t,e){var i,r,n=t.nodeName,s=t.getAttribute("class"),o=t.getAttribute("id");if(i=new RegExp("^"+n,"i"),e=e.replace(i,""),o&&e.length&&(i=new RegExp("#"+o+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"")),s&&e.length)for(r=(s=s.split(" ")).length;r--;)i=new RegExp("\\."+s[r]+"(?![a-zA-Z\\-]+)","i"),e=e.replace(i,"");return 0===e.length}function m(t,e){var i;if(t.getElementById&&(i=t.getElementById(e)),i)return i;var r,n,s,o=t.getElementsByTagName("*");for(n=0,s=o.length;n<s;n++)if(e===(r=o[n]).getAttribute("id"))return r}e.svgValidTagNamesRegEx=f(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),e.svgViewBoxElementsRegEx=f(["symbol","image","marker","pattern","view","svg"]),e.svgInvalidAncestorsRegEx=f(["pattern","defs","symbol","metadata","clipPath","mask","desc"]),e.svgValidParentsRegEx=f(["symbol","g","a","svg","clipPath","defs"]),e.cssRules={},e.gradientDefs={},e.clipPaths={},e.parseTransformAttribute=function(){function t(t,i,r){t[r]=Math.tan(e.util.degreesToRadians(i[0]))}var i=e.iMatrix,r=e.reNum,n=e.commaWsp,s="(?:(?:(matrix)\\s*\\(\\s*("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")"+n+"("+r+")\\s*\\))|(?:(translate)\\s*\\(\\s*("+r+")(?:"+n+"("+r+"))?\\s*\\))|(?:(scale)\\s*\\(\\s*("+r+")(?:"+n+"("+r+"))?\\s*\\))|(?:(rotate)\\s*\\(\\s*("+r+")(?:"+n+"("+r+")"+n+"("+r+"))?\\s*\\))|(?:(skewX)\\s*\\(\\s*("+r+")\\s*\\))|(?:(skewY)\\s*\\(\\s*("+r+")\\s*\\)))",o=new RegExp("^\\s*(?:(?:"+s+"(?:"+n+"*"+s+")*)?)\\s*$"),a=new RegExp(s,"g");return function(r){var n=i.concat(),h=[];if(!r||r&&!o.test(r))return n;r.replace(a,(function(r){var o=new RegExp(s).exec(r).filter((function(t){return!!t})),a=o[1],l=o.slice(2).map(parseFloat);switch(a){case"translate":!function(t,e){t[4]=e[0],2===e.length&&(t[5]=e[1])}(n,l);break;case"rotate":l[0]=e.util.degreesToRadians(l[0]),function(t,i){var r=e.util.cos(i[0]),n=e.util.sin(i[0]),s=0,o=0;3===i.length&&(s=i[1],o=i[2]),t[0]=r,t[1]=n,t[2]=-n,t[3]=r,t[4]=s-(r*s-n*o),t[5]=o-(n*s+r*o)}(n,l);break;case"scale":!function(t,e){var i=e[0],r=2===e.length?e[1]:e[0];t[0]=i,t[3]=r}(n,l);break;case"skewX":t(n,l,2);break;case"skewY":t(n,l,1);break;case"matrix":n=l}h.push(n.concat()),n=i.concat()}));for(var l=h[0];h.length>1;)h.shift(),l=e.util.multiplyTransformMatrices(l,h[0]);return l}}();var v=new RegExp("^\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*,?\\s*("+e.reNum+"+)\\s*$");function y(t){if(!e.svgViewBoxElementsRegEx.test(t.nodeName))return{};var i,r,n,o,a,h,l=t.getAttribute("viewBox"),c=1,u=1,d=t.getAttribute("width"),f=t.getAttribute("height"),g=t.getAttribute("x")||0,_=t.getAttribute("y")||0,p=t.getAttribute("preserveAspectRatio")||"",m=!l||!(l=l.match(v)),y=!d||!f||"100%"===d||"100%"===f,S=m&&y,C={},w="",b=0,x=0;if(C.width=0,C.height=0,C.toBeParsed=S,m&&(g||_)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(w=" translate("+s(g)+" "+s(_)+") ",a=(t.getAttribute("transform")||"")+w,t.setAttribute("transform",a),t.removeAttribute("x"),t.removeAttribute("y")),S)return C;if(m)return C.width=s(d),C.height=s(f),C;if(i=-parseFloat(l[1]),r=-parseFloat(l[2]),n=parseFloat(l[3]),o=parseFloat(l[4]),C.minX=i,C.minY=r,C.viewBoxWidth=n,C.viewBoxHeight=o,y?(C.width=n,C.height=o):(C.width=s(d),C.height=s(f),c=C.width/n,u=C.height/o),"none"!==(p=e.util.parsePreserveAspectRatioAttribute(p)).alignX&&("meet"===p.meetOrSlice&&(u=c=c>u?u:c),"slice"===p.meetOrSlice&&(u=c=c>u?c:u),b=C.width-n*c,x=C.height-o*c,"Mid"===p.alignX&&(b/=2),"Mid"===p.alignY&&(x/=2),"Min"===p.alignX&&(b=0),"Min"===p.alignY&&(x=0)),1===c&&1===u&&0===i&&0===r&&0===g&&0===_)return C;if((g||_)&&"#document"!==t.parentNode.nodeName&&(w=" translate("+s(g)+" "+s(_)+") "),a=w+" matrix("+c+" 0 0 "+u+" "+(i*c+b)+" "+(r*u+x)+") ","svg"===t.nodeName){for(h=t.ownerDocument.createElementNS(e.svgNS,"g");t.firstChild;)h.appendChild(t.firstChild);t.appendChild(h)}else(h=t).removeAttribute("x"),h.removeAttribute("y"),a=h.getAttribute("transform")+a;return h.setAttribute("transform",a),C}function S(t,e){var i="xlink:href",r=m(t,e.getAttribute(i).slice(1));if(r&&r.getAttribute(i)&&S(t,r),["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"].forEach((function(t){r&&!e.hasAttribute(t)&&r.hasAttribute(t)&&e.setAttribute(t,r.getAttribute(t))})),!e.children.length)for(var n=r.cloneNode(!0);n.firstChild;)e.appendChild(n.firstChild);e.removeAttribute(i)}e.parseSVGDocument=function(t,i,n,s){if(t){!function(t){for(var i=g(t,["use","svg:use"]),r=0;i.length&&r<i.length;){var n=i[r],s=n.getAttribute("xlink:href")||n.getAttribute("href");if(null===s)return;var o,a,h,l,c=s.slice(1),u=n.getAttribute("x")||0,d=n.getAttribute("y")||0,f=m(t,c).cloneNode(!0),_=(f.getAttribute("transform")||"")+" translate("+u+", "+d+")",p=i.length,v=e.svgNS;if(y(f),/^svg$/i.test(f.nodeName)){var S=f.ownerDocument.createElementNS(v,"g");for(a=0,l=(h=f.attributes).length;a<l;a++)o=h.item(a),S.setAttributeNS(v,o.nodeName,o.nodeValue);for(;f.firstChild;)S.appendChild(f.firstChild);f=S}for(a=0,l=(h=n.attributes).length;a<l;a++)"x"!==(o=h.item(a)).nodeName&&"y"!==o.nodeName&&"xlink:href"!==o.nodeName&&"href"!==o.nodeName&&("transform"===o.nodeName?_=o.nodeValue+" "+_:f.setAttribute(o.nodeName,o.nodeValue));f.setAttribute("transform",_),f.setAttribute("instantiated_by_use","1"),f.removeAttribute("id"),n.parentNode.replaceChild(f,n),i.length===p&&r++}}(t);var o,a,h=e.Object.__uid++,l=y(t),c=e.util.toArray(t.getElementsByTagName("*"));if(l.crossOrigin=s&&s.crossOrigin,l.svgUid=h,0===c.length&&e.isLikelyNode){var u=[];for(o=0,a=(c=t.selectNodes('//*[name(.)!="svg"]')).length;o<a;o++)u[o]=c[o];c=u}var d=c.filter((function(t){return y(t),e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))&&!function(t,e){for(;t&&(t=t.parentNode);)if(t.nodeName&&e.test(t.nodeName.replace("svg:",""))&&!t.getAttribute("instantiated_by_use"))return!0;return!1}(t,e.svgInvalidAncestorsRegEx)}));if(!d||d&&!d.length)i&&i([],{});else{var f={};c.filter((function(t){return"clipPath"===t.nodeName.replace("svg:","")})).forEach((function(t){var i=t.getAttribute("id");f[i]=e.util.toArray(t.getElementsByTagName("*")).filter((function(t){return e.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:",""))}))})),e.gradientDefs[h]=e.getGradientDefs(t),e.cssRules[h]=e.getCSSRules(t),e.clipPaths[h]=f,e.parseElements(d,(function(t,r){i&&(i(t,l,r,c),delete e.gradientDefs[h],delete e.cssRules[h],delete e.clipPaths[h])}),r(l),n,s)}}};var C=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(C);if(i){var r=i[1],n=i[3],o=i[4],a=i[5],h=i[6];r&&(e.fontStyle=r),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),o&&(e.fontSize=s(o)),h&&(e.fontFamily=h),a&&(e.lineHeight="normal"===a?1:a)}},getGradientDefs:function(t){var e,i=g(t,["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"]),r=0,n={};for(r=i.length;r--;)(e=i[r]).getAttribute("xlink:href")&&S(t,e),n[e.getAttribute("id")]=e;return n},parseAttributes:function(t,r,o){if(t){var a,f,g,p={};void 0===o&&(o=t.getAttribute("svgUid")),t.parentNode&&e.svgValidParentsRegEx.test(t.parentNode.nodeName)&&(p=e.parseAttributes(t.parentNode,r,o));var m=r.reduce((function(e,i){return(a=t.getAttribute(i))&&(e[i]=a),e}),{}),v=i(function(t,i){var r={};for(var n in e.cssRules[i])if(_(t,n.split(" ")))for(var s in e.cssRules[i][n])r[s]=e.cssRules[i][n][s];return r}(t,o),e.parseStyleAttribute(t));m=i(m,v),v[c]&&t.setAttribute(c,v[c]),f=g=p.fontSize||e.Text.DEFAULT_SVG_FONT_SIZE,m[l]&&(m[l]=f=s(m[l],g));var y,S,C={};for(var w in m)S=d(y=u(w),m[w],p,f),C[y]=S;C&&C.font&&e.parseFontDeclaration(C.font,C);var b=i(p,C);return e.svgValidParentsRegEx.test(t.nodeName)?b:function(t){for(var i in h)if(void 0!==t[h[i]]&&""!==t[i]){if(void 0===t[i]){if(!e.Object.prototype[i])continue;t[i]=e.Object.prototype[i]}if(0!==t[i].indexOf("url(")){var r=new e.Color(t[i]);t[i]=r.setAlpha(n(r.getAlpha()*t[h[i]],2)).toRgba()}}return t}(b)}},parseElements:function(t,i,r,n,s){new e.ElementsParser(t,i,r,n,s).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");return i?("string"==typeof i?function(t,e){var i,r;t.replace(/;\s*$/,"").split(";").forEach((function(t){var n=t.split(":");i=n[0].trim().toLowerCase(),r=n[1].trim(),e[i]=r}))}(i,e):function(t,e){var i,r;for(var n in t)void 0!==t[n]&&(i=n.toLowerCase(),r=t[n],e[i]=r)}(i,e),e):e},parsePointsAttribute:function(t){if(!t)return null;var e,i,r=[];for(e=0,i=(t=(t=t.replace(/,/g," ").trim()).split(/\s+/)).length;e<i;e+=2)r.push({x:parseFloat(t[e]),y:parseFloat(t[e+1])});return r},getCSSRules:function(t){var i,r,n=t.getElementsByTagName("style"),s={};for(i=0,r=n.length;i<r;i++){var o=n[i].textContent;""!==(o=o.replace(/\/\*[\s\S]*?\*\//g,"")).trim()&&o.split("}").filter((function(t){return t.trim()})).forEach((function(t){var n=t.split("{"),o={},a=n[1].trim().split(";").filter((function(t){return t.trim()}));for(i=0,r=a.length;i<r;i++){var h=a[i].split(":"),l=h[0].trim(),c=h[1].trim();o[l]=c}(t=n[0].trim()).split(",").forEach((function(t){""!==(t=t.replace(/^svg/i,"").trim())&&(s[t]?e.util.object.extend(s[t],o):s[t]=e.util.object.clone(o))}))}))}return s},loadSVGFromURL:function(t,i,r,n){t=t.replace(/^\n\s*/,"").trim(),new e.util.request(t,{method:"get",onComplete:function(t){var s=t.responseXML;if(!s||!s.documentElement)return i&&i(null),!1;e.parseSVGDocument(s.documentElement,(function(t,e,r,n){i&&i(t,e,r,n)}),r,n)}})},loadSVGFromString:function(t,i,r,n){var s=(new e.window.DOMParser).parseFromString(t.trim(),"text/xml");e.parseSVGDocument(s.documentElement,(function(t,e,r,n){i(t,e,r,n)}),r,n)}})}(e),E.ElementsParser=function(t,e,i,r,n,s){this.elements=t,this.callback=e,this.options=i,this.reviver=r,this.svgUid=i&&i.svgUid||0,this.parsingOptions=n,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=s},(v=E.ElementsParser.prototype).parse=function(){this.instances=new Array(this.elements.length),this.numElements=this.elements.length,this.createObjects()},v.createObjects=function(){var t=this;this.elements.forEach((function(e,i){e.setAttribute("svgUid",t.svgUid),t.createObject(e,i)}))},v.findTag=function(t){return E[E.util.string.capitalize(t.tagName.replace("svg:",""))]},v.createObject=function(t,e){var i=this.findTag(t);if(i&&i.fromElement)try{i.fromElement(t,this.createCallback(e,t),this.options)}catch(t){E.log(t)}else this.checkIfDone()},v.createCallback=function(t,e){var i=this;return function(r){var n;i.resolveGradient(r,e,"fill"),i.resolveGradient(r,e,"stroke"),r instanceof E.Image&&r._originalElement&&(n=r.parsePreserveAspectRatioAttribute(e)),r._removeTransformMatrix(n),i.resolveClipPath(r,e),i.reviver&&i.reviver(e,r),i.instances[t]=r,i.checkIfDone()}},v.extractPropertyDefinition=function(t,e,i){var r=t[e],n=this.regexUrl;if(n.test(r)){n.lastIndex=0;var s=n.exec(r)[1];return n.lastIndex=0,E[i][this.svgUid][s]}},v.resolveGradient=function(t,e,i){var r=this.extractPropertyDefinition(t,i,"gradientDefs");if(r){var n=e.getAttribute(i+"-opacity"),s=E.Gradient.fromElement(r,t,n,this.options);t.set(i,s)}},v.createClipPathCallback=function(t,e){return function(t){t._removeTransformMatrix(),t.fillRule=t.clipRule,e.push(t)}},v.resolveClipPath=function(t,e){var i,r,n,s,o=this.extractPropertyDefinition(t,"clipPath","clipPaths");if(o){n=[],r=E.util.invertTransform(t.calcTransformMatrix());for(var a=o[0].parentNode,h=e;h.parentNode&&h.getAttribute("clip-path")!==t.clipPath;)h=h.parentNode;h.parentNode.appendChild(a);for(var l=0;l<o.length;l++)i=o[l],this.findTag(i).fromElement(i,this.createClipPathCallback(t,n),this.options);o=1===n.length?n[0]:new E.Group(n),s=E.util.multiplyTransformMatrices(r,o.calcTransformMatrix()),o.clipPath&&this.resolveClipPath(o,h);var c=E.util.qrDecompose(s);o.flipX=!1,o.flipY=!1,o.set("scaleX",c.scaleX),o.set("scaleY",c.scaleY),o.angle=c.angle,o.skewX=c.skewX,o.skewY=0,o.setPositionByOrigin({x:c.translateX,y:c.translateY},"center","center"),t.clipPath=o}else delete t.clipPath},v
vendor: 11,336 bytes, line 2
2.checkIfDone=function(){0==--this.numElements&&(this.instances=this.instances.filter((function(t){return null!=t})),this.callback(this.instances,this.elements))},function(t){var e=t.fabric||(t.fabric={});function i(t,e){this.x=t,this.y=e}e.Point?e.warn("fabric.Point is already defined"):(e.Point=i,i.prototype={type:"point",constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){return this.x+=t.x,this.y+=t.y,this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){return this.x+=t,this.y+=t,this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){return this.x-=t.x,this.y-=t.y,this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){return this.x-=t,this.y-=t,this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){return this.x/=t,this.y/=t,this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return void 0===e&&(e=.5),e=Math.max(Math.min(1,e),0),new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return this.lerp(t)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setFromPoint:function(t){return this.x=t.x,this.y=t.y,this},swap:function(t){var e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i},clone:function(){return new i(this.x,this.y)}})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){this.status=t,this.points=[]}e.Intersection?e.warn("fabric.Intersection is already defined"):(e.Intersection=i,e.Intersection.prototype={constructor:i,appendPoint:function(t){return this.points.push(t),this},appendPoints:function(t){return this.points=this.points.concat(t),this}},e.Intersection.intersectLineLine=function(t,r,n,s){var o,a=(s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x),h=(r.x-t.x)*(t.y-n.y)-(r.y-t.y)*(t.x-n.x),l=(s.y-n.y)*(r.x-t.x)-(s.x-n.x)*(r.y-t.y);if(0!==l){var c=a/l,u=h/l;0<=c&&c<=1&&0<=u&&u<=1?(o=new i("Intersection")).appendPoint(new e.Point(t.x+c*(r.x-t.x),t.y+c*(r.y-t.y))):o=new i}else o=new i(0===a||0===h?"Coincident":"Parallel");return o},e.Intersection.intersectLinePolygon=function(t,e,r){var n,s,o,a,h=new i,l=r.length;for(a=0;a<l;a++)n=r[a],s=r[(a+1)%l],o=i.intersectLineLine(t,e,n,s),h.appendPoints(o.points);return h.points.length>0&&(h.status="Intersection"),h},e.Intersection.intersectPolygonPolygon=function(t,e){var r,n=new i,s=t.length;for(r=0;r<s;r++){var o=t[r],a=t[(r+1)%s],h=i.intersectLinePolygon(o,a,e);n.appendPoints(h.points)}return n.points.length>0&&(n.status="Intersection"),n},e.Intersection.intersectPolygonRectangle=function(t,r,n){var s=r.min(n),o=r.max(n),a=new e.Point(o.x,s.y),h=new e.Point(s.x,o.y),l=i.intersectLinePolygon(s,a,t),c=i.intersectLinePolygon(a,o,t),u=i.intersectLinePolygon(o,h,t),d=i.intersectLinePolygon(h,s,t),f=new i;return f.appendPoints(l.points),f.appendPoints(c.points),f.appendPoints(u.points),f.appendPoints(d.points),f.points.length>0&&(f.status="Intersection"),f})}(e),function(t){var e=t.fabric||(t.fabric={});function i(t){t?this._tryParsingColor(t):this.setSource([0,0,0,1])}function r(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}e.Color?e.warn("fabric.Color is already defined."):(e.Color=i,e.Color.prototype={_tryParsingColor:function(t){var e;t in i.colorNameMap&&(t=i.colorNameMap[t]),"transparent"===t&&(e=[255,255,255,0]),e||(e=i.sourceFromHex(t)),e||(e=i.sourceFromRgb(t)),e||(e=i.sourceFromHsl(t)),e||(e=[0,0,0,1]),e&&this.setSource(e)},_rgbToHsl:function(t,i,r){t/=255,i/=255,r/=255;var n,s,o,a=e.util.array.max([t,i,r]),h=e.util.array.min([t,i,r]);if(o=(a+h)/2,a===h)n=s=0;else{var l=a-h;switch(s=o>.5?l/(2-a-h):l/(a+h),a){case t:n=(i-r)/l+(i<r?6:0);break;case i:n=(r-t)/l+2;break;case r:n=(t-i)/l+4}n/=6}return[Math.round(360*n),Math.round(100*s),Math.round(100*o)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t,e,i,r=this.getSource();return t=1===(t=r[0].toString(16)).length?"0"+t:t,e=1===(e=r[1].toString(16)).length?"0"+e:e,i=1===(i=r[2].toString(16)).length?"0"+i:i,t.toUpperCase()+e.toUpperCase()+i.toUpperCase()},toHexa:function(){var t,e=this.getSource();return t=1===(t=(t=Math.round(255*e[3])).toString(16)).length?"0"+t:t,this.toHex()+t.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();return e[3]=t,this.setSource(e),this},toGrayscale:function(){var t=this.getSource(),e=parseInt((.3*t[0]+.59*t[1]+.11*t[2]).toFixed(0),10),i=t[3];return this.setSource([e,e,e,i]),this},toBlackWhite:function(t){var e=this.getSource(),i=(.3*e[0]+.59*e[1]+.11*e[2]).toFixed(0),r=e[3];return t=t||127,i=Number(i)<Number(t)?0:255,this.setSource([i,i,i,r]),this},overlayWith:function(t){t instanceof i||(t=new i(t));var e,r=[],n=this.getAlpha(),s=this.getSource(),o=t.getSource();for(e=0;e<3;e++)r.push(Math.round(.5*s[e]+.5*o[e]));return r[3]=n,this.setSource(r),this}},e.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i,e.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i,e.Color.reHex=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,e.Color.colorNameMap={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"},e.Color.fromRgb=function(t){return i.fromSource(i.sourceFromRgb(t))},e.Color.sourceFromRgb=function(t){var e=t.match(i.reRGBa);if(e){var r=parseInt(e[1],10)/(/%$/.test(e[1])?100:1)*(/%$/.test(e[1])?255:1),n=parseInt(e[2],10)/(/%$/.test(e[2])?100:1)*(/%$/.test(e[2])?255:1),s=parseInt(e[3],10)/(/%$/.test(e[3])?100:1)*(/%$/.test(e[3])?255:1);return[parseInt(r,10),parseInt(n,10),parseInt(s,10),e[4]?parseFloat(e[4]):1]}},e.Color.fromRgba=i.fromRgb,e.Color.fromHsl=function(t){return i.fromSource(i.sourceFromHsl(t))},e.Color.sourceFromHsl=function(t){var e=t.match(i.reHSLa);if(e){var n,s,o,a=(parseFloat(e[1])%360+360)%360/360,h=parseFloat(e[2])/(/%$/.test(e[2])?100:1),l=parseFloat(e[3])/(/%$/.test(e[3])?100:1);if(0===h)n=s=o=l;else{var c=l<=.5?l*(h+1):l+h-l*h,u=2*l-c;n=r(u,c,a+1/3),s=r(u,c,a),o=r(u,c,a-1/3)}return[Math.round(255*n),Math.round(255*s),Math.round(255*o),e[4]?parseFloat(e[4]):1]}},e.Color.fromHsla=i.fromHsl,e.Color.fromHex=function(t){return i.fromSource(i.sourceFromHex(t))},e.Color.sourceFromHex=function(t){if(t.match(i.reHex)){var e=t.slice(t.indexOf("#")+1),r=3===e.length||4===e.length,n=8===e.length||4===e.length,s=r?e.charAt(0)+e.charAt(0):e.substring(0,2),o=r?e.charAt(1)+e.charAt(1):e.substring(2,4),a=r?e.charAt(2)+e.charAt(2):e.substring(4,6),h=n?r?e.charAt(3)+e.charAt(3):e.substring(6,8):"FF";return[parseInt(s,16),parseInt(o,16),parseInt(a,16),parseFloat((parseInt(h,16)/255).toFixed(2))]}},e.Color.fromSource=function(t){var e=new i;return e.setSource(t),e})}(e),function(t){var e=t.fabric||(t.fabric={}),i=["e","se","s","sw","w","nw","n","ne","e"],r=["ns","nesw","ew","nwse"],n={},s="left",o="top",a="right",h="bottom",l="center",c={top:h,bottom:o,left:a,right:s,center:l},u=e.util.radiansToDegrees,d=Math.sign||function(t){return(t>0)-(t<0)||+t};function f(t,e){var i=t.angle+u(Math.atan2(e.y,e.x))+360;return Math.round(i%360/45)}function g(t,i){var r=i.transform.target,n=r.canvas,s=e.util.object.clone(i);s.target=r,n&&n.fire("object:"+t,s),r.fire(t,i)}function 
vendor: 52,553 bytes, line 2
2_(t,e){var i=e.canvas,r=t[i.uniScaleKey];return i.uniformScaling&&!r||!i.uniformScaling&&r}function p(t){return t.originX===l&&t.originY===l}function m(t,e,i){var r=t.lockScalingX,n=t.lockScalingY;return!((!r||!n)&&(e||!r&&!n||!i)&&(!r||"x"!==e)&&(!n||"y"!==e))}function v(t,e,i,r){return{e:t,transform:e,pointer:{x:i,y:r}}}function y(t){return function(e,i,r,n){var s=i.target,o=s.getCenterPoint(),a=s.translateToOriginPoint(o,i.originX,i.originY),h=t(e,i,r,n);return s.setPositionByOrigin(a,i.originX,i.originY),h}}function S(t,e){return function(i,r,n,s){var o=e(i,r,n,s);return o&&g(t,v(i,r,n,s)),o}}function C(t,i,r,n,s){var o=t.target,a=o.controls[t.corner],h=o.canvas.getZoom(),l=o.padding/h,c=o.toLocalPoint(new e.Point(n,s),i,r);return c.x>=l&&(c.x-=l),c.x<=-l&&(c.x+=l),c.y>=l&&(c.y-=l),c.y<=l&&(c.y+=l),c.x-=a.offsetX,c.y-=a.offsetY,c}function w(t){return t.flipX!==t.flipY}function b(t,e,i,r,n){if(0!==t[e]){var s=n/t._getTransformedDimensions()[r]*t[i];t.set(i,s)}}function x(t,e,i,r){var n,l=e.target,c=l._getTransformedDimensions(0,l.skewY),d=C(e,e.originX,e.originY,i,r),f=Math.abs(2*d.x)-c.x,g=l.skewX;f<2?n=0:(n=u(Math.atan2(f/l.scaleX,c.y/l.scaleY)),e.originX===s&&e.originY===h&&(n=-n),e.originX===a&&e.originY===o&&(n=-n),w(l)&&(n=-n));var _=g!==n;if(_){var p=l._getTransformedDimensions().y;l.set("skewX",n),b(l,"skewY","scaleY","y",p)}return _}function T(t,e,i,r){var n,l=e.target,c=l._getTransformedDimensions(l.skewX,0),d=C(e,e.originX,e.originY,i,r),f=Math.abs(2*d.y)-c.y,g=l.skewY;f<2?n=0:(n=u(Math.atan2(f/l.scaleY,c.x/l.scaleX)),e.originX===s&&e.originY===h&&(n=-n),e.originX===a&&e.originY===o&&(n=-n),w(l)&&(n=-n));var _=g!==n;if(_){var p=l._getTransformedDimensions().x;l.set("skewY",n),b(l,"skewX","scaleX","x",p)}return _}function E(t,e,i,r,n){n=n||{};var s,o,a,h,l,u,f=e.target,g=f.lockScalingX,v=f.lockScalingY,y=n.by,S=_(t,f),w=m(f,y,S),b=e.gestureScale;if(w)return!1;if(b)o=e.scaleX*b,a=e.scaleY*b;else{if(s=C(e,e.originX,e.originY,i,r),l="y"!==y?d(s.x):1,u="x"!==y?d(s.y):1,e.signX||(e.signX=l),e.signY||(e.signY=u),f.lockScalingFlip&&(e.signX!==l||e.signY!==u))return!1;if(h=f._getTransformedDimensions(),S&&!y){var x=Math.abs(s.x)+Math.abs(s.y),T=e.original,E=x/(Math.abs(h.x*T.scaleX/f.scaleX)+Math.abs(h.y*T.scaleY/f.scaleY));o=T.scaleX*E,a=T.scaleY*E}else o=Math.abs(s.x*f.scaleX/h.x),a=Math.abs(s.y*f.scaleY/h.y);p(e)&&(o*=2,a*=2),e.signX!==l&&"y"!==y&&(e.originX=c[e.originX],o*=-1,e.signX=l),e.signY!==u&&"x"!==y&&(e.originY=c[e.originY],a*=-1,e.signY=u)}var I=f.scaleX,O=f.scaleY;return y?("x"===y&&f.set("scaleX",o),"y"===y&&f.set("scaleY",a)):(!g&&f.set("scaleX",o),!v&&f.set("scaleY",a)),I!==f.scaleX||O!==f.scaleY}n.scaleCursorStyleHandler=function(t,e,r){var n=_(t,r),s="";if(0!==e.x&&0===e.y?s="x":0===e.x&&0!==e.y&&(s="y"),m(r,s,n))return"not-allowed";var o=f(r,e);return i[o]+"-resize"},n.skewCursorStyleHandler=function(t,e,i){var n="not-allowed";if(0!==e.x&&i.lockSkewingY)return n;if(0!==e.y&&i.lockSkewingX)return n;var s=f(i,e)%4;return r[s]+"-resize"},n.scaleSkewCursorStyleHandler=function(t,e,i){return t[i.canvas.altActionKey]?n.skewCursorStyleHandler(t,e,i):n.scaleCursorStyleHandler(t,e,i)},n.rotationWithSnapping=S("rotating",y((function(t,e,i,r){var n=e,s=n.target,o=s.translateToOriginPoint(s.getCenterPoint(),n.originX,n.originY);if(s.lockRotation)return!1;var a,h=Math.atan2(n.ey-o.y,n.ex-o.x),l=Math.atan2(r-o.y,i-o.x),c=u(l-h+n.theta);if(s.snapAngle>0){var d=s.snapAngle,f=s.snapThreshold||d,g=Math.ceil(c/d)*d,_=Math.floor(c/d)*d;Math.abs(c-_)<f?c=_:Math.abs(c-g)<f&&(c=g)}return c<0&&(c=360+c),c%=360,a=s.angle!==c,s.angle=c,a}))),n.scalingEqually=S("scaling",y((function(t,e,i,r){return E(t,e,i,r)}))),n.scalingX=S("scaling",y((function(t,e,i,r){return E(t,e,i,r,{by:"x"})}))),n.scalingY=S("scaling",y((function(t,e,i,r){return E(t,e,i,r,{by:"y"})}))),n.scalingYOrSkewingX=function(t,e,i,r){return t[e.target.canvas.altActionKey]?n.skewHandlerX(t,e,i,r):n.scalingY(t,e,i,r)},n.scalingXOrSkewingY=function(t,e,i,r){return t[e.target.canvas.altActionKey]?n.skewHandlerY(t,e,i,r):n.scalingX(t,e,i,r)},n.changeWidth=S("resizing",y((function(t,e,i,r){var n=e.target,s=C(e,e.originX,e.originY,i,r),o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=p(e)?2:1,h=n.width,l=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(l,0)),h!==l}))),n.skewHandlerX=function(t,e,i,r){var n,h=e.target,c=h.skewX,u=e.originY;return!h.lockSkewingX&&(0===c?n=C(e,l,l,i,r).x>0?s:a:(c>0&&(n=u===o?s:a),c<0&&(n=u===o?a:s),w(h)&&(n=n===s?a:s)),e.originX=n,S("skewing",y(x))(t,e,i,r))},n.skewHandlerY=function(t,e,i,r){var n,a=e.target,c=a.skewY,u=e.originX;return!a.lockSkewingY&&(0===c?n=C(e,l,l,i,r).y>0?o:h:(c>0&&(n=u===s?o:h),c<0&&(n=u===s?h:o),w(a)&&(n=n===o?h:o)),e.originY=n,S("skewing",y(T))(t,e,i,r))},n.dragHandler=function(t,e,i,r){var n=e.target,s=i-e.offsetX,o=r-e.offsetY,a=!n.get("lockMovementX")&&n.left!==s,h=!n.get("lockMovementY")&&n.top!==o;return a&&n.set("left",s),h&&n.set("top",o),(a||h)&&g("moving",v(t,e,i,r)),a||h},n.scaleOrSkewActionName=function(t,e,i){var r=t[i.canvas.altActionKey];return 0===e.x?r?"skewX":"scaleY":0===e.y?r?"skewY":"scaleX":void 0},n.rotationStyleHandler=function(t,e,i){return i.lockRotation?"not-allowed":e.cursorStyle},n.fireEvent=g,n.wrapWithFixedAnchor=y,n.wrapWithFireEvent=S,n.getLocalPoint=C,e.controlsUtils=n}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians,r=e.controlsUtils;r.renderCircleControl=function(t,e,i,r,n){r=r||{};var s,o=this.sizeX||r.cornerSize||n.cornerSize,a=this.sizeY||r.cornerSize||n.cornerSize,h=void 0!==r.transparentCorners?r.transparentCorners:n.transparentCorners,l=h?"stroke":"fill",c=!h&&(r.cornerStrokeColor||n.cornerStrokeColor),u=e,d=i;t.save(),t.fillStyle=r.cornerColor||n.cornerColor,t.strokeStyle=r.cornerStrokeColor||n.cornerStrokeColor,o>a?(s=o,t.scale(1,a/o),d=i*o/a):a>o?(s=a,t.scale(o/a,1),u=e*a/o):s=o,t.lineWidth=1,t.beginPath(),t.arc(u,d,s/2,0,2*Math.PI,!1),t[l](),c&&t.stroke(),t.restore()},r.renderSquareControl=function(t,e,r,n,s){n=n||{};var o=this.sizeX||n.cornerSize||s.cornerSize,a=this.sizeY||n.cornerSize||s.cornerSize,h=void 0!==n.transparentCorners?n.transparentCorners:s.transparentCorners,l=h?"stroke":"fill",c=!h&&(n.cornerStrokeColor||s.cornerStrokeColor),u=o/2,d=a/2;t.save(),t.fillStyle=n.cornerColor||s.cornerColor,t.strokeStyle=n.cornerStrokeColor||s.cornerStrokeColor,t.lineWidth=1,t.translate(e,r),t.rotate(i(s.angle)),t[l+"Rect"](-u,-d,o,a),c&&t.strokeRect(-u,-d,o,a),t.restore()}}(e),function(t){var e=t.fabric||(t.fabric={});e.Control=function(t){for(var e in t)this[e]=t[e]},e.Control.prototype={visible:!0,actionName:"scale",angle:0,x:0,y:0,offsetX:0,offsetY:0,sizeX:null,sizeY:null,touchSizeX:null,touchSizeY:null,cursorStyle:"crosshair",withConnection:!1,actionHandler:function(){},mouseDownHandler:function(){},mouseUpHandler:function(){},getActionHandler:function(){return this.actionHandler},getMouseDownHandler:function(){return this.mouseDownHandler},getMouseUpHandler:function(){return this.mouseUpHandler},cursorStyleHandler:function(t,e){return e.cursorStyle},getActionName:function(t,e){return e.actionName},getVisibility:function(t,e){var i=t._controlsVisibility;return i&&void 0!==i[e]?i[e]:this.visible},setVisibility:function(t){this.visible=t},positionHandler:function(t,i){return e.util.transformPoint({x:this.x*t.x+this.offsetX,y:this.y*t.y+this.offsetY},i)},calcCornerCoords:function(t,i,r,n,s){var o,a,h,l,c=s?this.touchSizeX:this.sizeX,u=s?this.touchSizeY:this.sizeY;if(c&&u&&c!==u){var d=Math.atan2(u,c),f=Math.sqrt(c*c+u*u)/2,g=d-e.util.degreesToRadians(t),_=Math.PI/2-d-e.util.degreesToRadians(t);o=f*e.util.cos(g),a=f*e.util.sin(g),h=f*e.util.cos(_),l=f*e.util.sin(_)}else f=.7071067812*(c&&u?c:i),g=e.util.degreesToRadians(45-t),o=h=f*e.util.cos(g),a=l=f*e.util.sin(g);return{tl:{x:r-l,y:n-h},tr:{x:r+o,y:n-a},bl:{x:r-o,y:n+a},br:{x:r+l,y:n+h}}},render:function(t,i,r,n,s){"circle"===((n=n||{}).cornerStyle||s.cornerStyle)?e.controlsUtils.renderCircleControl.call(this,t,i,r,n,s):e.controlsUtils.renderSquareControl.call(this,t,i,r,n,s)}}}(e),function(){function t(t,e){var i,r,n,s,o=t.getAttribute("style"),a=t.getAttribute("offset")||0;if(a=(a=parseFloat(a)/(/%$/.test(a)?100:1))<0?0:a>1?1:a,o){var h=o.split(/\s*;\s*/);for(""===h[h.length-1]&&h.pop(),s=h.length;s--;){var l=h[s].split(/\s*:\s*/),c=l[0].trim(),u=l[1].trim();"stop-color"===c?i=u:"stop-opacity"===c&&(n=u)}}return i||(i=t.getAttribute("stop-color")||"rgb(0,0,0)"),n||(n=t.getAttribute("stop-opacity")),r=(i=new E.Color(i)).getAlpha(),n=isNaN(parseFloat(n))?1:parseFloat(n),n*=r*e,{offset:a,color:i.toRgb(),opacity:n}}var e=E.util.object.clone;E.Gradient=E.util.createClass({offsetX:0,offsetY:0,gradientTransform:null,gradientUnits:"pixels",type:"linear",initialize:function(t){t||(t={}),t.coords||(t.coords={});var e,i=this;Object.keys(t).forEach((function(e){i[e]=t[e]})),this.id?this.id+="_"+E.Object.__uid++:this.id=E.Object.__uid++,e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0},"radial"===this.type&&(e.r1=t.coords.r1||0,e.r2=t.coords.r2||0),this.coords=e,this.colorStops=t.colorStops.slice()},addColorStop:function(t){for(var e in t){var i=new E.Color(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(t){var e={type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform};return E.util.populateWithProperties(this,e,t),e},toSVG:function(t,i){var r,n,s,o,a=e(this.coords,!0),h=(i=i||{},e(this.colorStops,!0)),l=a.r1>a.r2,c=this.gradientTransform?this.gradientTransform.concat():E.iMatrix.concat(),u=-this.offsetX,d=-this.offsetY,f=!!i.additionalTransform,g="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox";if(h.sort((function(t,e){return t.offset-e.offset})),"objectBoundingBox"===g?(u/=t.width,d/=t.height):(u+=t.width/2,d+=t.height/2),"path"===t.type&&"percentage"!==this.gradientUnits&&(u-=t.pathOffset.x,d-=t.pathOffset.y),c[4]-=u,c[5]-=d,o='id="SVGID_'+this.id+'" gradientUnits="'+g+'"',o+=' gradientTransform="'+(f?i.additionalTransform+" ":"")+E.util.matrixToSVG(c)+'" ',"linear"===this.type?s=["<linearGradient ",o,' x1="',a.x1,'" y1="',a.y1,'" x2="',a.x2,'" y2="',a.y2,'">\n']:"radial"===this.type&&(s=["<radialGradient ",o,' cx="',l?a.x1:a.x2,'" cy="',l?a.y1:a.y2,'" r="',l?a.r1:a.r2,'" fx="',l?a.x2:a.x1,'" fy="',l?a.y2:a.y1,'">\n']),"radial"===this.type){if(l)for((h=h.concat()).reverse(),r=0,n=h.length;r<n;r++)h[r].offset=1-h[r].offset;var _=Math.min(a.r1,a.r2);if(_>0){var p=_/Math.max(a.r1,a.r2);for(r=0,n=h.length;r<n;r++)h[r].offset+=p*(1-h[r].offset)}}for(r=0,n=h.length;r<n;r++){var m=h[r];s.push("<stop ",'offset="',100*m.offset+"%",'" style="stop-color:',m.color,void 0!==m.opacity?";stop-opacity: "+m.opacity:";",'"/>\n')}return s.push("linear"===this.type?"</linearGradient>\n":"</radialGradient>\n"),s.join("")},toLive:function(t){var e,i,r,n=E.util.object.clone(this.coords);if(this.type){for("linear"===this.type?e=t.createLinearGradient(n.x1,n.y1,n.x2,n.y2):"radial"===this.type&&(e=t.createRadialGradient(n.x1,n.y1,n.r1,n.x2,n.y2,n.r2)),i=0,r=this.colorStops.length;i<r;i++){var s=this.colorStops[i].color,o=this.colorStops[i].opacity,a=this.colorStops[i].offset;void 0!==o&&(s=new E.Color(s).setAlpha(o).toRgba()),e.addColorStop(a,s)}return e}}}),E.util.object.extend(E.Gradient,{fromElement:function(e,i,r,n){var s=parseFloat(r)/(/%$/.test(r)?100:1);s=s<0?0:s>1?1:s,isNaN(s)&&(s=1);var o,a,h,l,c=e.getElementsByTagName("stop"),u="userSpaceOnUse"===e.getAttribute("gradientUnits")?"pixels":"percentage",d=e.getAttribute("gradientTransform")||"",f=[],g=0,_=0;for("linearGradient"===e.nodeName||"LINEARGRADIENT"===e.nodeName?(o="linear",a=function(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}(e)):(o="radial",a=function(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}(e)),h=c.length;h--;)f.push(t(c[h],s));return l=E.parseTransformAttribute(d),function(t,e,i,r){var n,s;Object.keys(e).forEach((function(t){"Infinity"===(n=e[t])?s=1:"-Infinity"===n?s=0:(s=parseFloat(e[t],10),"string"==typeof n&&/^(\d+\.\d+)%|(\d+)%$/.test(n)&&(s*=.01,"pixels"===r&&("x1"!==t&&"x2"!==t&&"r2"!==t||(s*=i.viewBoxWidth||i.width),"y1"!==t&&"y2"!==t||(s*=i.viewBoxHeight||i.height)))),e[t]=s}))}(0,a,n,u),"pixels"===u&&(g=-i.left,_=-i.top),new E.Gradient({id:e.getAttribute("id"),type:o,coords:a,colorStops:f,gradientUnits:u,gradientTransform:l,offsetX:g,offsetY:_})}})}(),y=E.util.toFixed,E.Pattern=E.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,crossOrigin:"",patternTransform:null,initialize:function(t,e){if(t||(t={}),this.id=E.Object.__uid++,this.setOptions(t),!t.source||t.source&&"string"!=typeof t.source)e&&e(this);else{var i=this;this.source=E.util.createImage(),E.util.loadImage(t.source,(function(t,r){i.source=t,e&&e(i,r)}),null,this.crossOrigin)}},toObject:function(t){var e,i,r=E.Object.NUM_FRACTION_DIGITS;return"string"==typeof this.source.src?e=this.source.src:"object"==typeof this.source&&this.source.toDataURL&&(e=this.source.toDataURL()),i={type:"pattern",source:e,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:y(this.offsetX,r),offsetY:y(this.offsetY,r),patternTransform:this.patternTransform?this.patternTransform.concat():null},E.util.populateWithProperties(this,i,t),i},toSVG:function(t){var e="function"==typeof this.source?this.source():this.source,i=e.width/t.width,r=e.height/t.height,n=this.offsetX/t.width,s=this.offsetY/t.height,o="";return"repeat-x"!==this.repeat&&"no-repeat"!==this.repeat||(r=1,s&&(r+=Math.abs(s))),"repeat-y"!==this.repeat&&"no-repeat"!==this.repeat||(i=1,n&&(i+=Math.abs(n))),e.src?o=e.src:e.toDataURL&&(o=e.toDataURL()),'<pattern id="SVGID_'+this.id+'" x="'+n+'" y="'+s+'" width="'+i+'" height="'+r+'">\n<image x="0" y="0" width="'+e.width+'" height="'+e.height+'" xlink:href="'+o+'"></image>\n</pattern>\n'},setOptions:function(t){for(var e in t)this[e]=t[e]},toLive:function(t){var e=this.source;if(!e)return"";if(void 0!==e.src){if(!e.complete)return"";if(0===e.naturalWidth||0===e.naturalHeight)return""}return t.createPattern(e,this.repeat)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.toFixed;e.Shadow?e.warn("fabric.Shadow is already defined."):(e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(t){for(var i in"string"==typeof t&&(t=this._parseShadow(t)),t)this[i]=t[i];this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),r=e.Shadow.reOffsetsAndBlur.exec(i)||[];return{color:(i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)").trim(),offsetX:parseFloat(r[1],10)||0,offsetY:parseFloat(r[2],10)||0,blur:parseFloat(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var r=40,n=40,s=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=new e.Color(this.color);return t.width&&t.height&&(r=100*i((Math.abs(o.x)+this.blur)/t.width,s)+20,n=100*i((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),'<filter id="SVGID_'+this.id+'" y="-'+n+'%" height="'+(100+2*n)+'%" x="-'+r+'%" width="'+(100+2*r)+'%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,s)+'"></feGaussianBlur>\n\t<feOffset dx="'+i(o.x,s)+'" dy="'+i(o.y,s)+'" result="oBlur" ></feOffset>\n\t<feFlood flood-color="'+a.toRgb()+'" flood-opacity="'+a.getAlpha()+'"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n'},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var t={},i=e.Shadow.prototype;return["color","blur","offsetX","offsetY","affectStroke","nonScaling"].forEach((function(e){this[e]!==i[e]&&(t[e]=this[e])}),this),t}}),e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/)}(e),function(){if(E.StaticCanvas)E.warn("fabric.StaticCanvas is already defined.");else{var t=E.util.object.extend,e=E.util.getElementOffset,i=E.util.removeFromArray,r=E.util.toFixed,n=E.util.transformPoint,s=E.util.invertTransform,o=E.util.getNodeCanvas,a=E.util.createCanvasElement,h=new Error("Could not initialize `canvas` element");E.StaticCanvas=E.util.createClass(E.CommonMethods,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:E.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(t,e){var i=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(t),this._initOptions(e),this.interactive||this._initRetinaScaling(),e.overlayImage&&this.setOverlayImage(e.overlayImage,i),e.backgroundImage&&this.setBackgroundImage(e.backgroundImage,i),e.backgroundColor&&this.setBackgroundColor(e.backgroundColor,i),e.overlayColor&&this.setOverlayColor(e.overlayColor,i),this.calcOffset()},_isRetinaScaling:function(){return E.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,E.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var t=E.devicePixelRatio;this.__initRetinaScaling(t,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(t,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(t,e,i){e.setAttribute("width",this.width*t),e.setAttribute("height",this.height*t),i.scale(t,t)},calcOffset:function(){return this._offset=e(this.lowerCanvasEl),this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},__setBgOverlayImage:function(t,e,i,r){return"string"==typeof e?E.util.loadImage(e,(function(e,n){if(e){var s=new E.Image(e,r);this[t]=s,s.canvas=this}i&&i(e,n)}),this,r&&r.crossOrigin):(r&&e.setOptions(r),this[t]=e,e&&(e.canvas=this),i&&i(e,!1)),this},__setBgOverlayColor:function(t,e,i){return this[t]=e,this._initGradient(e,t),this._initPattern(e,t,i),this},_createCanvasElement:function(){var t=a();if(!t)throw h;if(t.style||(t.style={}),void 0===t.getContext)throw h;return t},_initOptions:function(t){var e=this.lowerCanvasEl;this._setOptions(t),this.width=this.width||parseInt(e.width,10)||0,this.height=this.height||parseInt(e.height,10)||0,this.lowerCanvasEl.style&&(e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(t){t&&t.getContext?this.lowerCanvasEl=t:this.lowerCanvasEl=E.util.getById(t)||this._createCanvasElement(),E.util.addClass(this.lowerCanvasEl,"lower-canvas"),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;for(var r in e=e||{},t)i=t[r],e.cssOnly||(this._setBackstoreDimension(r,t[r]),i+="px",this.hasLostContext=!0),e.backstoreOnly||this._setCssDimension(r,i);return this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop),this._initRetinaScaling(),this.calcOffset(),e.cssOnly||this.requestRenderAll(),this},_setBackstoreDimension:function(t,e){return this.lowerCanvasEl[t]=e,this.upperCanvasEl&&(this.upperCanvasEl[t]=e),this.cacheCanvasEl&&(this.cacheCanvasEl[t]=e),this[t]=e,this},_setCssDimension:function(t,e){return this.lowerCanvasEl.style[t]=e,this.upperCanvasEl&&(this.upperCanvasEl.style[t]=e),this.wrapperEl&&(this.wrapperEl.style[t]=e),this},getZoom:function(){return this.viewportTransform[0]},setViewportTransform:function(t){var e,i,r,n=this._activeObject,s=this.backgroundImage,o=this.overlayImage;for(this.viewportTransform=t,i=0,r=this._objects.length;i<r;i++)(e=this._objects[i]).group||e.setCoords(!0);return n&&n.setCoords(),s&&s.setCoords(!0),o&&o.setCoords(!0),this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll(),this},zoomToPoint:function(t,e){var i=t,r=this.viewportTransform.slice(0);t=n(t,s(this.viewportTransform)),r[0]=e,r[3]=e;var o=n(t,r);return r[4]+=i.x-o.x,r[5]+=i.y-o.y,this.setViewportTransform(r)},setZoom:function(t){return this.zoomToPoint(new E.Point(0,0),t),this},absolutePan:function(t){var e=this.viewportTransform.slice(0);return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)},relativePan:function(t){return this.absolutePan(new E.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},_onObjectAdded:function(t){this.stateful&&t.setupState(),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added")},_onObjectRemoved:function(t){this.fire("object:removed",{target:t}),t.fire("removed"),delete t.canvas},clearContext:function(t){return t.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this.remove.apply(this,this.getObjects()),this.backgroundImage=null,this.overlayImage=null,this.backgroundColor="",this.overlayColor="",this._hasITextHandlers&&(this.off("mouse:up",this._mouseUpITextHandler),this._iTextInstances=null,this._hasITextHandlers=!1),this.clearContext(this.contextContainer),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll(),this},renderAll:function(){var t=this.contextContainer;return this.renderCanvas(t,this._objects),this},renderAndReset:function(){this.isRendering=0,this.renderAll()},requestRenderAll:function(){return this.isRendering||(this.isRendering=E.util.requestAnimFrame(this.renderAndResetBound)),this},calcViewportBoundaries:function(){var t={},e=this.width,i=this.height,r=s(this.viewportTransform);return t.tl=n({x:0,y:0},r),t.br=n({x:e,y:i},r),t.tr=new E.Point(t.br.x,t.tl.y),t.bl=new E.Point(t.tl.x,t.br.y),this.vptCoords=t,t},cancelRequestedRender:function(){this.isRendering&&(E.util.cancelAnimFrame(this.isRendering),this.isRendering=0)},renderCanvas:function(t,e){var i=this.viewportTransform,r=this.clipPath;this.cancelRequestedRender(),this.calcViewportBoundaries(),this.clearContext(t),E.util.setImageSmoothing(t,this.imageSmoothingEnabled),this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),!this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),r&&(r.canvas=this,r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t)),this._renderOverlay(t),this.controlsAboveOverlay&&this.interactive&&this.drawControls(t),this.fire("after:render",{ctx:t})},drawClipPathOnCanvas:function(t){var e=this.viewportTransform,i=this.clipPath;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t.globalCompositeOperation="destination-in",i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},_renderObjects:function(t,e){var i,r;for(i=0,r=e.length;i<r;++i)e[i]&&e[i].render(t)},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"],r=this[e+"Image"],n=this.viewportTransform,s=this[e+"Vpt"];if(i||r){if(i){t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=i.toLive?i.toLive(t,this):i,s&&t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);var o=i.gradientTransform||i.patternTransform;o&&t.transform(o[0],o[1],o[2],o[3],o[4],o[5]),t.fill(),t.restore()}r&&(t.save(),s&&t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.render(t),t.restore())}},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},getCenter:function(){return{top:this.height/2,left:this.width/2}},getCenterPoint:function(){return new E.Point(this.width/2,this.height/2)},centerObjectH:function(t){return this._centerObject(t,new E.Point(this.getCenterPoint().x,t.getCenterPoint().y))},centerObjectV:function(t){return this._centerObject(t,new E.Point(t.getCenterPoint().x,this.getCenterPoint().y))},centerObject:function(t){var e=this.getCenterPoint();return this._centerObject(t,e)},viewportCenterObject:function(t){var e=this.getVpCenter();return this._centerObject(t,e)},viewportCenterObjectH:function(t){var e=this.getVpCenter();return this._centerObject(t,new E.Point(e.x,t.getCenterPoint().y)),this},viewportCenterObjectV:function(t){var e=this.getVpCenter();return this._centerObject(t,new E.Point(t.getCenterPoint().x,e.y))},getVpCenter:function(){var t=this.getCenterPoint(),e=s(this.viewportTransform);return n(t,e)},_centerObject:function(t,e){return t.setPositionByOrigin(e,"center","center"),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll(),this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var r=this.clipPath,n={version:E.version,objects:this._toObjects(e,i)};return r&&!r.excludeFromExport&&(n.clipPath=this._toObject(this.clipPath,e,i)),t(n,this.__serializeBgOverlay(e,i)),E.util.populateWithProperties(this,n,i),n},_toObjects:function(t,e){return this._objects.filter((function(t){return!t.excludeFromExport})).map((function(i){return this._toObject(i,t,e)}),this)},_toObject:function(t,e,i){var r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);var n=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=r),n},__serializeBgOverlay:function(t,e){var i={},r=this.backgroundImage,n=this.overlayImage,s=this.backgroundColor,o=this.overlayColor;return s&&s.toObject?s.excludeFromExport||(i.background=s.toObject(e)):s&&(i.background=s),o&&o.toObject?o.excludeFromExport||(i.overlay=o.toObject(e)):o&&(i.overlay=o),r&&!r.excludeFromExport&&(i.backgroundImage=this._toObject(r,t,e)),n&&!n.excludeFromExport&&(i.overlayImage=this._toObject(n,t,e)),i},svgViewportTransformation:!0,toSVG:function(t,e){t||(t={}),t.reviver=e;var i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'+this.clipPath.clipPathId+')" >\n'),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push("</g>\n"),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")},_setSVGPreamble:function(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i,n=e.width||this.width,s=e.height||this.height,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=E.Object.NUM_FRACTION_DIGITS;e.viewBox?o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" ':this.svgViewportTransformation&&(i=this.viewportTransform,o='viewBox="'+r(-i[4]/i[0],a)+" "+r(-i[5]/i[3],a)+" "+r(this.width/i[0],a)+" "+r(this.height/i[3],a)+'" '),t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',n,'" ','height="',s,'" ',o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",E.version,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")},createSVGClipPathMarkup:function(t){var e=this.clipPath;return e?(e.clipPathId="CLIPPATH_"+E.Object.__uid++,'<clipPath id="'+e.clipPathId+'" >\n'+this.clipPath.toClipPathSVG(t.reviver)+"</clipPath>\n"):""},createSVGRefElementsMarkup:function(){var t=this;return["background","overlay"].map((function(e){var i=t[e+"Color"];if(i&&i.toLive){var r=t[e+"Vpt"],n=t.viewportTransform,s={width:t.width/(r?n[0]:1),height:t.height/(r?n[3]:1)};return i.toSVG(s,{additionalTransform:r?E.util.matrixToSVG(n):""})}})).join("")},createSVGFontFacesMarkup:function(){var t,e,i,r,n,s,o,a,h="",l={},c=E.fontPaths,u=[];for(this._objects.forEach((function t(e){u.push(e),e._objects&&e._objects.forEach(t)})),o=0,a=u.length;o<a;o++)if(e=(t=u[o]).fontFamily,-1!==t.type.indexOf("text")&&!l[e]&&c[e]&&(l[e]=!0,t.styles))for(n in i=t.styles)for(s in r=i[n])!l[e=r[s].fontFamily]&&c[e]&&(l[e]=!0);for(var d in l)h+=["\t\t@font-face {\n","\t\t\tfont-family: '",d,"';\n","\t\t\tsrc: url('",c[d],"');\n","\t\t}\n"].join("");return h&&(h=['\t<style type="text/css">',"<![CDATA[\n",h,"]]>","</style>\n"].join("")),h},_setSVGObjects:function(t,e){var i,r,n,s=this._objects;for(r=0,n=s.length;r<n;r++)(i=s[r]).excludeFromExport||this._setSVGObject(t,i,e)},_setSVGObject:function(t,e,i){t.push(e.toSVG(i))},_setSVGBgOverlayImage:function(t,e,i){this[e]&&!this[e].excludeFromExport&&this[e].toSVG&&t.push(this[e].toSVG(i))},_setSVGBgOverlayColor:function(t,e){var i=this[e+"Color"],r=this.viewportTransform,n=this.width,s=this.height;if(i)if(i.toLive){var o=i.repeat,a=E.util.invertTransform(r),h=this[e+"Vpt"]?E.util.matrixToSVG(a):"";t.push('<rect transform="'+h+" translate(",n/2,",",s/2,')"',' x="',i.offsetX-n/2,'" y="',i.offsetY-s/2,'" ','width="',"repeat-y"===o||"no-repeat"===o?i.source.width:n,'" height="',"repeat-x"===o||"no-repeat"===o?i.source.height:s,'" fill="url(#SVGID_'+i.id+')"',"></rect>\n")}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',"></rect>\n")},sendToBack:function(t){if(!t)return this;var e,r,n,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(e=(n=s._objects).length;e--;)r=n[e],i(this._objects,r),this._objects.unshift(r);else i(this._objects,t),this._objects.unshift(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(t){if(!t)return this;var e,r,n,s=this._activeObject;if(t===s&&"activeSelection"===t.type)for(n=s._objects,e=0;e<n.length;e++)r=n[e],i(this._objects,r),this._objects.push(r);else i(this._objects,t),this._objects.push(t);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(t,e){if(!t)return this;var r,n,s,o,a,h=this._activeObject,l=0;if(t===h&&"activeSelection"===t.type)for(a=h._objects,r=0;r<a.length;r++)n=a[r],(s=this._objects.indexOf(n))>0+l&&(o=s-1,i(this._objects,n),this._objects.splice(o,0,n)),l++;else 0!==(s=this._objects.indexOf(t))&&(o=this._findNewLowerIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(t,e,i){var r,n;if(i){for(r=e,n=e-1;n>=0;--n)if(t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t)){r=n;break}}else r=e-1;return r},bringForward:function(t,e){if(!t)return this;var r,n,s,o,a,h=this._activeObject,l=0;if(t===h&&"activeSelection"===t.type)for(r=(a=h._objects).length;r--;)n=a[r],(s=this._objects.indexOf(n))<this._objects.length-1-l&&(o=s+1,i(this._objects,n),this._objects.splice(o,0,n)),l++;else(s=this._objects.indexOf(t))!==this._objects.length-1&&(o=this._findNewUpperIndex(t,s,e),i(this._objects,t),this._objects.splice(o,0,t));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(t,e,i){var r,n,s;if(i){for(r=e,n=e+1,s=this._objects.length;n<s;++n)if(t.intersectsWithObject(this._objects[n])||t.isContainedWithinObject(this._objects[n])||this._objects[n].isContainedWithinObject(t)){r=n;break}}else r=e+1;return r},moveTo:function(t,e){return i(this._objects,t),this._objects.splice(e,0,t),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&(E.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),E.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),E.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): { objects: "+this._objects.length+" }>"}}),t(E.StaticCanvas.prototype,E.Observable),t(E.StaticCanvas.prototype,E.Collection),t(E.StaticCanvas.prototype,E.DataURLExporter),t(E.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=a();if(!e||!e.getContext)return null;var i=e.getContext("2d");return i&&"setLineDash"===t?void 0!==i.setLineDash:null}}),E.StaticCanvas.prototype.toJSON=E.StaticCanvas.prototype.toObject,E.isLikelyNode&&(E.StaticCanvas.prototype.createPNGStream=function(){var t=o(this.lowerCanvasEl);return t&&t.createPNGStream()},E.StaticCanvas.prototype.createJPEGStream=function(t){var e=o(this.lowerCanvasEl);return e&&e.createJPEGStream(t)})}}(),E.BaseBrush=E.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])},_saveAndTransform:function(t){var e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])},_setShadow:function(){if(this.shadow){var t=this.canvas,e=this.shadow,i=t.contextTop,r=t.getZoom();t&&t._isRetinaScaling()&&(r*=E.devicePixelRatio),i.shadowColor=e.color,i.shadowBlur=e.blur*r,i.shadowOffsetX=e.offsetX*r,i.shadowOffsetY=e.offsetY*r}},needsFullRender:function(){return new E.Color(this.color).getAlpha()<1||!!this.shadow},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_isOutSideCanvas:function(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}),E.PencilBrush=E.util.createClass(E.BaseBrush,{decimate:.4,drawStraightLine:!1,straightLineKey:"shiftKey",initialize:function(t){this.canvas=t,this._points=[]},needsFullRender:function(){return this.callSuper("needsFullRender")||this._hasStraightLine},_drawSegment:function(t,e,i){var r=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,r.x,r.y),r},onMouseDown:function(t,e){this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],this._prepareForDrawing(t),this._captureDrawingPath(t),this._render())},onMouseMove:function(t,e){if(this.canvas._isMainEvent(e.e)&&(this.drawStraightLine=e.e[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._captureDrawingPath(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{var i=this._points,r=i.length,n=this.canvas.contextTop;this._saveAndTransform(n),this.oldEnd&&(n.beginPath(),n.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=this._drawSegment(n,i[r-2],i[r-1],!0),n.stroke(),n.restore()}},onMouseUp:function(t){return!this.canvas._isMainEvent(t.e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)},_prepareForDrawing:function(t){var e=new E.Point(t.x,t.y);this._reset(),this._addPoint(e),this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1])||(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),0))},_reset:function(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1},_captureDrawingPath:function(t){var e=new E.Point(t.x,t.y);return this._addPoint(e)},_render:function(t){var e,i,r=this._points[0],n=this._points[1];if(t=t||this.canvas.contextTop,this._saveAndTransform(t),t.beginPath(),2===this._points.length&&r.x===n.x&&r.y===n.y){var s=this.width/1e3;r=new E.Point(r.x,r.y),n=new E.Point(n.x,n.y),r.x-=s,n.x+=s}for(t.moveTo(r.x,r.y),e=1,i=this._points.length;e<i;e++)this._drawSegment(t,r,n),r=this._points[e],n=this._points[e+1];t.lineTo(r.x,r.y),t.stroke(),t.restore()},convertPointsToSVGPath:function(t){var e=this.width/1e3;return E.util.getSmoothPathFromPoints(t,e)},_isEmptySVGPath:function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===E.util.joinPath(t)},createPath:function(t){var e=new E.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.shadow=new E.Shadow(this.shadow)),e},decimatePoints:function(t,e){if(t.length<=2)return t;var i,r=this.canvas.getZoom(),n=Math.pow(e/r,2),s=t.length-1,o=t[0],a=[o];for(i=1;i<s-1;i++)Math.pow(o.x-t[i].x,2)+Math.pow(o.y-t[i].y,2)>=n&&(o=t[i],a.push(o));return a.push(t[s]),a},_finalizeAndAddPath:function(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));var t=this.convertPointsToSVGPath(this._points);if(this._isEmptySVGPath(t))this.canvas.requestRenderAll();else{var e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}}),E.CircleBrush=E.util.createClass(E.BaseBrush,{width:10,initialize:function(t){this.canvas=t,this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()},dot:function(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()},onMouseDown:function(t){this.points.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)},_render:function(){var t,e,i=this.canvas.contextTop,r=this.points;for(this._saveAndTransform(i),t=0,e=r.length;t<e;t++)this.dot(i,r[t]);i.restore()},onMouseMove:function(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(t),this._render()):this.drawDot(t))},onMouseUp:function(){var t,e,i=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;var r=[];for(t=0,e=this.points.length;t<e;t++){var n=this.points[t],s=new E.Circle({radius:n.radius,left:n.x,top:n.y,originX:"center",originY:"center",fill:n.fill});this.shadow&&(s.shadow=new E.Shadow(this.shadow)),r.push(s)}var o=new E.Group(r);o.canvas=this.canvas,this.canvas.fire("before:path:created",{path:o}),this.canvas.add(o),this.canvas.fire("path:created",{path:o}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=i,this.canvas.requestRenderAll()},addPoint:function(t){var e=new E.Point(t.x,t.y),i=E.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=new E.Color(this.color).setAlpha(E.util.getRandomInt(0,100)/100).toRgba();return e.radius=i,e.fill=r,this.points.push(e),e}}),E.SprayBrush=E.util.createClass(E.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:!1,optimizeOverlapping:!0,initialize:function(t){this.canvas=t,this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0,this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.render(this.sprayChunkPoints)},onMouseMove:function(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.addSprayChunk(t),this.render(this.sprayChunkPoints))},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;for(var e=[],i=0,r=this.sprayChunks.length;i<r;i++)for(var n=this.sprayChunks[i],s=0,o=n.length;s<o;s++){var a=new E.Rect({width:n[s].width,height:n[s].width,left:n[s].x+1,top:n[s].y+1,originX:"center",originY:"center",fill:this.color});e.push(a)}this.optimizeOverlapping&&(e=this._getOptimizedRects(e));var h=new E.Group(e);this.shadow&&h.set("shadow",new E.Shadow(this.shadow)),this.canvas.fire("before:path:created",{path:h}),this.canvas.add(h),this.canvas.fire("path:created",{path:h}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.requestRenderAll()},_getOptimizedRects:function(t){var e,i,r,n={};for(i=0,r=t.length;i<r;i++)n[e=t[i].left+""+t[i].top]||(n[e]=t[i]);var s=[];for(e in n)s.push(n[e]);return s},render:function(t){var e,i,r=this.canvas.contextTop;for(r.fillStyle=this.color,this._saveAndTransform(r),e=0,i=t.length;e<i;e++){var n=t[e];void 0!==n.opacity&&(r.globalAlpha=n.opacity),r.fillRect(n.x,n.y,n.width,n.width)}r.restore()},_render:function(){var t,e,i=this.canvas.contextTop;for(i.fillStyle=this.color,this._saveAndTransform(i),t=0,e=this.sprayChunks.length;t<e;t++)this.render(this.sprayChunks[t]);i.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];var e,i,r,n,s=this.width/2;for(n=0;n<this.density;n++){e=E.util.getRandomInt(t.x-s,t.x+s),i=E.util.getRandomInt(t.y-s,t.y+s),r=this.dotWidthVariance?E.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth;var o=new E.Point(e,i);o.width=r,this.randomOpacity&&(o.opacity=E.util.getRandomInt(0,100)/100),this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}}),E.PatternBrush=E.util.createClass(E.PencilBrush,{getPatternSrc:function(){var t=E.util.createCanvasElement(),e=t.getContext("2d");return t.width=t.height=25,e.fillStyle=this.color,e.beginPath(),e.arc(10,10,10,0,2*Math.PI,!1),e.closePath(),e.fill(),t},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(t){return t.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(t){this.callSuper("_setBrushStyles",t),t.strokeStyle=this.getPattern(t)},createPath:function(t){var e=this.callSuper("createPath",t),i=e._getLeftTopCoords().scalarAdd(e.strokeWidth/2);return e.stroke=new E.Pattern({source:this.source||this.getPatternSrcFunction(),offsetX:-i.x,offsetY:-i.y}),e}}),function(){var t=E.util.getPointer,e=E.util.degreesToRadians,i=E.util.isTouchEvent;for(var r in E.Canvas=E.util.createClass(E.StaticCanvas,{initialize:function(t,e){e||(e={}),this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(t,e),this._initInteractive(),this._createCacheCanvas()},uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",interactive:!0,selection:!0,selectionKey:"shiftKey",altSelectionKey:null,selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",containerClass:"canvas-container",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,isDrawingMode:!1,preserveObjectStacking:!1,snapAngle:0,snapThreshold:null,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,targets:[],enablePointerEvents:!1,_hoveredTarget:null,_hoveredTargets:[],_initInteractive:function(){this._currentTransform=null,this._groupSelector=null,this._initWrapperElement(),this._createUpperCanvas(),this._initEventListeners(),this._initRetinaScaling(),this.freeDrawingBrush=E.PencilBrush&&new E.PencilBrush(this),this.calcOffset()},_chooseObjectsToRender:function(){var t,e,i,r=this.getActiveObjects();if(r.length>0&&!this.preserveObjectStacking){e=[],i=[];for(var n=0,s=this._objects.length;n<s;n++)t=this._objects[n],-1===r.indexOf(t)?e.push(t):i.push(t);r.length>1&&(this._activeObject._objects=i),e.push.apply(e,i)}else e=this._objects;return e},renderAll:function(){!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1);var t=this.contextContainer;return this.renderCanvas(t,this._chooseObjectsToRender()),this},renderTopLayer:function(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()},renderTop:function(){var t=this.contextTop;return this.clearContext(t),this.renderTopLayer(t),this.fire("after:render"),this},_normalizePointer:function(t,e){var i=t.calcTransformMatrix(),r=E.util.invertTransform(i),n=this.restorePointerVpt(e);return E.util.transformPoint(n,r)},isTargetTransparent:function(t,e,i){if(t.shouldCache()&&t._cacheCanvas&&t!==this._activeObject){var r=this._normalizePointer(t,{x:e,y:i}),n=Math.max(t.cacheTranslationX+r.x*t.zoomX,0),s=Math.max(t.cacheTranslationY+r.y*t.zoomY,0);return E.util.isTransparent(t._cacheContext,Math.round(n),Math.round(s),this.targetFindTolerance)}var o=this.contextCache,a=t.selectionBackgroundColor,h=this.viewportTransform;return t.selectionBackgroundColor="",this.clearContext(o),o.save(),o.transform(h[0],h[1],h[2],h[3],h[4],h[5]),t.render(o),o.restore(),t.selectionBackgroundColor=a,E.util.isTransparent(o,e,i,this.targetFindTolerance)},_isSelectionKeyPressed:function(t){return Array.isArray(this.selectionKey)?!!this.selectionKey.find((function(e){return!0===t[e]})):t[this.selectionKey]},_shouldClearSelection:function(t,e){var i=this.getActiveObjects(),r=this._activeObject;return!e||e&&r&&i.length>1&&-1===i.indexOf(e)&&r!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&r&&r!==e},_shouldCenterTransform:function(t,e,i){var r;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?r=this.centeredScaling||t.centeredScaling:"rotate"===e&&(r=this.centeredRotation||t.centeredRotation),r?!i:i},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};return"ml"===e||"tl"===e||"bl"===e?i.x="right":"mr"!==e&&"tr"!==e&&"br"!==e||(i.x="left"),"tl"===e||"mt"===e||"tr"===e?i.y="bottom":"bl"!==e&&"mb"!==e&&"br"!==e||(i.y="top"),i},_getActionFromCorner:function(t,e,i,r){if(!e||!t)return"drag";var n=r.controls[e];return n.getActionName(i,n,r)},_setupCurrentTransform:function(t,i,r){if(i){var n=this.getPointer(t),s=i.__corner,o=i.controls[s],a=r&&s?o.getActionHandler(t,i,o):E.controlsUtils.dragHandler,h=this._getActionFromCorner(r,s,t,i),l=this._getOriginFromCorner(i,s),c=t[this.centeredKey],u={target:i,action:h,actionHandler:a,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:n.x-i.left,offsetY:n.y-i.top,originX:l.x,originY:l.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:e(i.angle),width:i.width*i.scaleX,shiftKey:t.shiftKey,altKey:c,original:E.util.saveObjectTransform(i)};this._shouldCenterTransform(i,h,c)&&(u.originX="center",u.originY="center"),u.original.originX=l.x,u.original.originY=l.y,this._currentTransform=u,this._beforeTransform(t)}},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_drawSelection:function(t){var e=this._groupSelector,i=new E.Point(e.ex,e.ey),r=E.util.transformPoint(i,this.viewportTransform),n=new E.Point(e.ex+e.left,e.ey+e.top),s=E.util.transformPoint(n,this.viewportTransform),o=Math.min(r.x,s.x),a=Math.min(r.y,s.y),h=Math.max(r.x,s.x),l=Math.max(r.y,s.y),c=this.selectionLineWidth/2;this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(o,a,h-o,l-a)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,o+=c,a+=c,h-=c,l-=c,E.Object.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(o,a,h-o,l-a))},findTarget:function(t,e){if(!this.skipTargetFind){var r,n,s=this.getPointer(t,!0),o=this._activeObject,a=this.getActiveObjects(),h=i(t),l=a.length>1&&!e||1===a.length;if(this.targets=[],l&&o._findTargetCorner(s,h))return o;if(a.length>1&&!e&&o===this._searchPossibleTargets([o],s))return o;if(1===a.length&&o===this._searchPossibleTargets([o],s)){if(!this.preserveObjectStacking)return o;r=o,n=this.targets,this.targets=[]}var c=this._searchPossibleTargets(this._objects,s);return t[this.altSelectionKey]&&c&&r&&c!==r&&(c=r,this.targets=n),c}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&e.containsPoint(t)){if(!this.perPixelTargetFind&&!e.perPixelTargetFind||e.isEditing)return!0;if(!this.isTargetTransparent(e,i.x,i.y))return!0}},_searchPossibleTargets:function(t,e){for(var i,r,n=t.length;n--;){var s=t[n],o=s.group?this._normalizePointer(s.group,e):e;if(this._checkTarget(o,s,e)){(i=t[n]).subTargetCheck&&i instanceof E.Group&&(r=this._searchPossibleTargets(i._objects,e))&&this.targets.push(r);break}}return i},restorePointerVpt:function(t){return E.util.transformPoint(t,E.util.invertTransform(this.viewportTransform))},getPointer:function(e,i){if(this._absolutePointer&&!i)return this._absolutePointer;if(this._pointer&&i)return this._pointer;var r,n=t(e),s=this.upperCanvasEl,o=s.getBoundingClientRect(),a=o.width||0,h=o.height||0;a&&h||("top"in o&&"bottom"in o&&(h=Math.abs(o.top-o.bottom)),"right"in o&&"left"in o&&(a=Math.abs(o.right-o.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,i||(n=this.restorePointerVpt(n));var l=this.getRetinaScaling();return 1!==l&&(n.x/=l,n.y/=l),r=0===a||0===h?{width:1,height:1}:{width:s.width/a,height:s.height/h},{x:n.x*r.width,y:n.y*r.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,""),e=this.lowerCanvasEl,i=this.upperCanvasEl;i?i.className="":(i=this._createCanvasElement(),this.upperCanvasEl=i),E.util.addClass(i,"upper-canvas "+t),this.wrapperEl.appendChild(i),this._copyCanvasStyle(e,i),this._applyCanvasStyle(i),this.contextTop=i.getContext("2d")},getTopContext:function(){return this.contextTop},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement(),this.cacheCanvasEl.setAttribute("width",this.width),this.cacheCanvasEl.setAttribute("height",this.height),this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=E.util.wrapElement(this.lowerCanvasEl,"div",{class:this.containerClass}),E.util.setStyle(this.wrapperEl,{width:this.width+"px",height:this.height+"px",position:"relative"}),E.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.width||t.width,i=this.height||t.height;E.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0,"touch-action":this.allowTouchScrolling?"manipulation":"none","-ms-touch-action":this.allowTouchScrolling?"manipulation":"none"}),t.width=e,t.height=i,E.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop}
vendor: 14,630 bytes, line 2
2,getSelectionElement:function(){return this.upperCanvasEl},getActiveObject:function(){return this._activeObject},getActiveObjects:function(){var t=this._activeObject;return t?"activeSelection"===t.type&&t._objects?t._objects.slice(0):[t]:[]},_onObjectRemoved:function(t){t===this._activeObject&&(this.fire("before:selection:cleared",{target:t}),this._discardActiveObject(),this.fire("selection:cleared",{target:t}),t.fire("deselected")),t===this._hoveredTarget&&(this._hoveredTarget=null,this._hoveredTargets=[]),this.callSuper("_onObjectRemoved",t)},_fireSelectionEvents:function(t,e){var i=!1,r=this.getActiveObjects(),n=[],s=[];t.forEach((function(t){-1===r.indexOf(t)&&(i=!0,t.fire("deselected",{e,target:t}),s.push(t))})),r.forEach((function(r){-1===t.indexOf(r)&&(i=!0,r.fire("selected",{e,target:r}),n.push(r))})),t.length>0&&r.length>0?i&&this.fire("selection:updated",{e,selected:n,deselected:s}):r.length>0?this.fire("selection:created",{e,selected:n}):t.length>0&&this.fire("selection:cleared",{e,deselected:s})},setActiveObject:function(t,e){var i=this.getActiveObjects();return this._setActiveObject(t,e),this._fireSelectionEvents(i,e),this},_setActiveObject:function(t,e){return this._activeObject!==t&&!!this._discardActiveObject(e,t)&&!t.onSelect({e})&&(this._activeObject=t,!0)},_discardActiveObject:function(t,e){var i=this._activeObject;if(i){if(i.onDeselect({e:t,object:e}))return!1;this._activeObject=null}return!0},discardActiveObject:function(t){var e=this.getActiveObjects(),i=this.getActiveObject();return e.length&&this.fire("before:selection:cleared",{target:i,e:t}),this._discardActiveObject(t),this._fireSelectionEvents(e,t),this},dispose:function(){var t=this.wrapperEl;return this.removeListeners(),t.removeChild(this.upperCanvasEl),t.removeChild(this.lowerCanvasEl),this.contextCache=null,this.contextTop=null,["upperCanvasEl","cacheCanvasEl"].forEach(function(t){E.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this)),t.parentNode&&t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl),delete this.wrapperEl,E.StaticCanvas.prototype.dispose.call(this),this},clear:function(){return this.discardActiveObject(),this.clearContext(this.contextTop),this.callSuper("clear")},drawControls:function(t){var e=this._activeObject;e&&e._renderControls(t)},_toObject:function(t,e,i){var r=this._realizeGroupTransformOnObject(t),n=this.callSuper("_toObject",t,e,i);return this._unwindGroupTransformOnObject(t,r),n},_realizeGroupTransformOnObject:function(t){if(t.group&&"activeSelection"===t.group.type&&this._activeObject===t.group){var e={};return["angle","flipX","flipY","left","scaleX","scaleY","skewX","skewY","top"].forEach((function(i){e[i]=t[i]})),E.util.addTransformToObject(t,this._activeObject.calcOwnMatrix()),e}return null},_unwindGroupTransformOnObject:function(t,e){e&&t.set(e)},_setSVGObject:function(t,e,i){var r=this._realizeGroupTransformOnObject(e);this.callSuper("_setSVGObject",t,e,i),this._unwindGroupTransformOnObject(e,r)},setViewportTransform:function(t){this.renderOnAddRemove&&this._activeObject&&this._activeObject.isEditing&&this._activeObject.clearContextTop(),E.StaticCanvas.prototype.setViewportTransform.call(this,t)}}),E.StaticCanvas)"prototype"!==r&&(E.Canvas[r]=E.StaticCanvas[r])}(),function(){var t=E.util.addListener,e=E.util.removeListener,i={passive:!1};function r(t,e){return t.button&&t.button===e-1}E.util.object.extend(E.Canvas.prototype,{mainTouchId:null,_initEventListeners:function(){this.removeListeners(),this._bindEvents(),this.addOrRemove(t,"add")},_getEventPrefix:function(){return this.enablePointerEvents?"pointer":"mouse"},addOrRemove:function(t,e){var r=this.upperCanvasEl,n=this._getEventPrefix();t(E.window,"resize",this._onResize),t(r,n+"down",this._onMouseDown),t(r,n+"move",this._onMouseMove,i),t(r,n+"out",this._onMouseOut),t(r,n+"enter",this._onMouseEnter),t(r,"wheel",this._onMouseWheel),t(r,"contextmenu",this._onContextMenu),t(r,"dblclick",this._onDoubleClick),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,i),"undefined"!=typeof eventjs&&e in eventjs&&(eventjs[e](r,"gesture",this._onGesture),eventjs[e](r,"drag",this._onDrag),eventjs[e](r,"orientation",this._onOrientationChange),eventjs[e](r,"shake",this._onShake),eventjs[e](r,"longpress",this._onLongPress))},removeListeners:function(){this.addOrRemove(e,"remove");var t=this._getEventPrefix();e(E.document,t+"up",this._onMouseUp),e(E.document,"touchend",this._onTouchEnd,i),e(E.document,t+"move",this._onMouseMove,i),e(E.document,"touchmove",this._onMouseMove,i)},_bindEvents:function(){this.eventsBound||(this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onResize=this._onResize.bind(this),this._onGesture=this._onGesture.bind(this),this._onDrag=this._onDrag.bind(this),this._onShake=this._onShake.bind(this),this._onLongPress=this._onLongPress.bind(this),this._onOrientationChange=this._onOrientationChange.bind(this),this._onMouseWheel=this._onMouseWheel.bind(this),this._onMouseOut=this._onMouseOut.bind(this),this._onMouseEnter=this._onMouseEnter.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this._onDoubleClick=this._onDoubleClick.bind(this),this._onDragOver=this._onDragOver.bind(this),this._onDragEnter=this._simpleEventHandler.bind(this,"dragenter"),this._onDragLeave=this._simpleEventHandler.bind(this,"dragleave"),this._onDrop=this._onDrop.bind(this),this.eventsBound=!0)},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t){this.__onMouseWheel(t)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t}),this._hoveredTarget=null,e&&e.fire("mouseout",{e:t});var i=this;this._hoveredTargets.forEach((function(r){i.fire("mouse:out",{target:e,e:t}),r&&e.fire("mouseout",{e:t})})),this._hoveredTargets=[],this._iTextInstances&&this._iTextInstances.forEach((function(t){t.isEditing&&t.hiddenTextarea.focus()}))},_onMouseEnter:function(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",{target:null,e:t}),this._hoveredTarget=null,this._hoveredTargets=[])},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onDragOver:function(t){t.preventDefault();var e=this._simpleEventHandler("dragover",t);this._fireEnterLeaveEvents(e,t)},_onDrop:function(t){return this._simpleEventHandler("drop:before",t),this._simpleEventHandler("drop",t)},_onContextMenu:function(t){return this.stopContextMenu&&(t.stopPropagation(),t.preventDefault()),!1},_onDoubleClick:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),this._resetTransformEventData(t)},getPointerId:function(t){var e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1},_isMainEvent:function(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)},_onTouchStart:function(r){r.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(r)),this.__onMouseDown(r),this._resetTransformEventData();var n=this.upperCanvasEl,s=this._getEventPrefix();t(E.document,"touchend",this._onTouchEnd,i),t(E.document,"touchmove",this._onMouseMove,i),e(n,s+"down",this._onMouseDown)},_onMouseDown:function(r){this.__onMouseDown(r),this._resetTransformEventData();var n=this.upperCanvasEl,s=this._getEventPrefix();e(n,s+"move",this._onMouseMove,i),t(E.document,s+"up",this._onMouseUp),t(E.document,s+"move",this._onMouseMove,i)},_onTouchEnd:function(r){if(!(r.touches.length>0)){this.__onMouseUp(r),this._resetTransformEventData(),this.mainTouchId=null;var n=this._getEventPrefix();e(E.document,"touchend",this._onTouchEnd,i),e(E.document,"touchmove",this._onMouseMove,i);var s=this;this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((function(){t(s.upperCanvasEl,n+"down",s._onMouseDown),s._willAddMouseDown=0}),400)}},_onMouseUp:function(r){this.__onMouseUp(r),this._resetTransformEventData();var n=this.upperCanvasEl,s=this._getEventPrefix();this._isMainEvent(r)&&(e(E.document,s+"up",this._onMouseUp),e(E.document,s+"move",this._onMouseMove,i),t(n,s+"move",this._onMouseMove,i))},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t){var e=this._activeObject;return!!(!!e!=!!t||e&&t&&e!==t)||(e&&e.isEditing,!1)},__onMouseUp:function(t){var e,i=this._currentTransform,n=this._groupSelector,s=!1,o=!n||0===n.left&&0===n.top;if(this._cacheTransformEventData(t),e=this._target,this._handleEvent(t,"up:before"),r(t,3))this.fireRightClick&&this._handleEvent(t,"up",3,o);else{if(r(t,2))return this.fireMiddleClick&&this._handleEvent(t,"up",2,o),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)this._onMouseUpInDrawingMode(t);else if(this._isMainEvent(t)){if(i&&(this._finalizeCurrentTransform(t),s=i.actionPerformed),!o){var a=e===this._activeObject;this._maybeGroupObjects(t),s||(s=this._shouldRender(e)||!a&&e===this._activeObject)}var h,l;if(e){if(h=e._findTargetCorner(this.getPointer(t,!0),E.util.isTouchEvent(t)),e.selectable&&e!==this._activeObject&&"up"===e.activeOn)this.setActiveObject(e,t),s=!0;else{var c=e.controls[h],u=c&&c.getMouseUpHandler(t,e,c);u&&u(t,i,(l=this.getPointer(t)).x,l.y)}e.isMoving=!1}if(i&&(i.target!==e||i.corner!==h)){var d=i.target&&i.target.controls[i.corner],f=d&&d.getMouseUpHandler(t,e,c);l=l||this.getPointer(t),f&&f(t,i,l.x,l.y)}this._setCursorFromEvent(t,e),this._handleEvent(t,"up",1,o),this._groupSelector=null,this._currentTransform=null,e&&(e.__corner=0),s?this.requestRenderAll():o||this.renderTop()}}},_simpleEventHandler:function(t,e){var i=this.findTarget(e),r=this.targets,n={e,target:i,subTargets:r};if(this.fire(t,n),i&&i.fire(t,n),!r)return i;for(var s=0;s<r.length;s++)r[s].fire(t,n);return i},_handleEvent:function(t,e,i,r){var n=this._target,s=this.targets||[],o={e:t,target:n,subTargets:s,button:i||1,isClick:r||!1,pointer:this._pointer,absolutePointer:this._absolutePointer,transform:this._currentTransform};"up"===e&&(o.currentTarget=this.findTarget(t),o.currentSubTargets=this.targets),this.fire("mouse:"+e,o),n&&n.fire("mouse"+e,o);for(var a=0;a<s.length;a++)s[a].fire("mouse"+e,o)},_finalizeCurrentTransform:function(t){var e=this._currentTransform,i=e.target,r={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),(e.actionPerformed||this.stateful&&i.hasStateChanged())&&this._fire("modified",r)},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&this.discardActiveObject(t).requestRenderAll();var e=this.getPointer(t);this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down")},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=this.getPointer(t);this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")},_onMouseUpInDrawingMode:function(t){var e=this.getPointer(t);this._isCurrentlyDrawing=this.freeDrawingBrush.onMouseUp({e:t,pointer:e}),this._handleEvent(t,"up")},__onMouseDown:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"down:before");var e=this._target;if(r(t,3))this.fireRightClick&&this._handleEvent(t,"down",3);else if(r(t,2))this.fireMiddleClick&&this._handleEvent(t,"down",2);else if(this.isDrawingMode)this._onMouseDownInDrawingMode(t);else if(this._isMainEvent(t)&&!this._currentTransform){var i=this._pointer;this._previousPointer=i;var n=this._shouldRender(e),s=this._shouldGroup(t,e);if(this._shouldClearSelection(t,e)?this.discardActiveObject(t):s&&(this._handleGrouping(t,e),e=this._activeObject),!this.selection||e&&(e.selectable||e.isEditing||e===this._activeObject)||(this._groupSelector={ex:this._absolutePointer.x,ey:this._absolutePointer.y,top:0,left:0}),e){var o=e===this._activeObject;e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);var a=e._findTargetCorner(this.getPointer(t,!0),E.util.isTouchEvent(t));if(e.__corner=a,e===this._activeObject&&(a||!s)){this._setupCurrentTransform(t,e,o);var h=e.controls[a],l=(i=this.getPointer(t),h&&h.getMouseDownHandler(t,e,h));l&&l(t,this._currentTransform,i.x,i.y)}}this._handleEvent(t,"down"),(n||s)&&this.requestRenderAll()}},_resetTransformEventData:function(){this._target=null,this._pointer=null,this._absolutePointer=null},_cacheTransformEventData:function(t){this._resetTransformEventData(),this._pointer=this.getPointer(t,!0),this._absolutePointer=this.restorePointerVpt(this._pointer),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)||null},_beforeTransform:function(t){var e=this._currentTransform;this.stateful&&e.target.saveState(),this.fire("before:transform",{e:t,transform:e})},__onMouseMove:function(t){var e,i;if(this._handleEvent(t,"move:before"),this._cacheTransformEventData(t),this.isDrawingMode)this._onMouseMoveInDrawingMode(t);else if(this._isMainEvent(t)){var r=this._groupSelector;r?(i=this._absolutePointer,r.left=i.x-r.ex,r.top=i.y-r.ey,this.renderTop()):this._currentTransform?this._transformObject(t):(e=this.findTarget(t)||null,this._setCursorFromEvent(t,e),this._fireOverOutEvents(e,t)),this._handleEvent(t,"move"),this._resetTransformEventData()}},_fireOverOutEvents:function(t,e){var i=this._hoveredTarget,r=this._hoveredTargets,n=this.targets,s=Math.max(r.length,n.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"mouseout",canvasEvtOut:"mouse:out",evtIn:"mouseover",canvasEvtIn:"mouse:over"});for(var o=0;o<s;o++)this.fireSyntheticInOutEvents(n[o],e,{oldTarget:r[o],evtOut:"mouseout",evtIn:"mouseover"});this._hoveredTarget=t,this._hoveredTargets=this.targets.concat()},_fireEnterLeaveEvents:function(t,e){var i=this._draggedoverTarget,r=this._hoveredTargets,n=this.targets,s=Math.max(r.length,n.length);this.fireSyntheticInOutEvents(t,e,{oldTarget:i,evtOut:"dragleave",evtIn:"dragenter"});for(var o=0;o<s;o++)this.fireSyntheticInOutEvents(n[o],e,{oldTarget:r[o],evtOut:"dragleave",evtIn:"dragenter"});this._draggedoverTarget=t}
vendor: 4,594 bytes, line 2
2,fireSyntheticInOutEvents:function(t,e,i){var r,n,s,o=i.oldTarget,a=o!==t,h=i.canvasEvtIn,l=i.canvasEvtOut;a&&(r={e,target:t,previousTarget:o},n={e,target:o,nextTarget:t}),s=t&&a,o&&a&&(l&&this.fire(l,n),o.fire(i.evtOut,n)),s&&(h&&this.fire(h,r),t.fire(i.evtIn,r))},__onMouseWheel:function(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=!1,i.shiftKey=t.shiftKey,i.altKey=t[this.centeredKey],this._performTransformAction(t,i,e),i.actionPerformed&&this.requestRenderAll()},_performTransformAction:function(t,e,i){var r=i.x,n=i.y,s=e.action,o=!1,a=e.actionHandler;a&&(o=a(t,e,r,n)),"drag"===s&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o},_fire:E.controlsUtils.fireEvent,_setCursorFromEvent:function(t,e){if(!e)return this.setCursor(this.defaultCursor),!1;var i=e.hoverCursor||this.hoverCursor,r=this._activeObject&&"activeSelection"===this._activeObject.type?this._activeObject:null,n=(!r||!r.contains(e))&&e._findTargetCorner(this.getPointer(t,!0));n?this.setCursor(this.getCornerCursor(n,e,t)):(e.subTargetCheck&&this.targets.concat().reverse().map((function(t){i=t.hoverCursor||i})),this.setCursor(i))},getCornerCursor:function(t,e,i){var r=e.controls[t];return r.cursorStyleHandler(i,r,e)}})}(),S=Math.min,C=Math.max,E.util.object.extend(E.Canvas.prototype,{_shouldGroup:function(t,e){var i=this._activeObject;return i&&this._isSelectionKeyPressed(t)&&e&&e.selectable&&this.selection&&(i!==e||"activeSelection"===i.type)&&!e.onSelect({e:t})},_handleGrouping:function(t,e){var i=this._activeObject;i.__corner||(e!==i||(e=this.findTarget(t,!0))&&e.selectable)&&(i&&"activeSelection"===i.type?this._updateActiveSelection(e,t):this._createActiveSelection(e,t))},_updateActiveSelection:function(t,e){var i=this._activeObject,r=i._objects.slice(0);i.contains(t)?(i.removeWithUpdate(t),this._hoveredTarget=t,this._hoveredTargets=this.targets.concat(),1===i.size()&&this._setActiveObject(i.item(0),e)):(i.addWithUpdate(t),this._hoveredTarget=i,this._hoveredTargets=this.targets.concat()),this._fireSelectionEvents(r,e)},_createActiveSelection:function(t,e){var i=this.getActiveObjects(),r=this._createGroup(t);this._hoveredTarget=r,this._setActiveObject(r,e),this._fireSelectionEvents(i,e)},_createGroup:function(t){var e=this._objects,i=e.indexOf(this._activeObject)<e.indexOf(t)?[this._activeObject,t]:[t,this._activeObject];return this._activeObject.isEditing&&this._activeObject.exitEditing(),new E.ActiveSelection(i,{canvas:this})},_groupSelectedObjects:function(t){var e,i=this._collectObjects(t);1===i.length?this.setActiveObject(i[0],t):i.length>1&&(e=new E.ActiveSelection(i.reverse(),{canvas:this}),this.setActiveObject(e,t))},_collectObjects:function(t){for(var e,i=[],r=this._groupSelector.ex,n=this._groupSelector.ey,s=r+this._groupSelector.left,o=n+this._groupSelector.top,a=new E.Point(S(r,s),S(n,o)),h=new E.Point(C(r,s),C(n,o)),l=!this.selectionFullyContained,c=r===s&&n===o,u=this._objects.length;u--&&!((e=this._objects[u])&&e.selectable&&e.visible&&(l&&e.intersectsWithRect(a,h,!0)||e.isContainedWithinRect(a,h,!0)||l&&e.containsPoint(a,null,!0)||l&&e.containsPoint(h,null,!0))&&(i.push(e),c)););return i.length>1&&(i=i.filter((function(e){return!e.onSelect({e:t})}))),i},_maybeGroupObjects:function(t){this.selection&&this._groupSelector&&this._groupSelectedObjects(t),this.setCursor(this.defaultCursor),this._groupSelector=null}}),E.util.object.extend(E.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,r=(t.multiplier||1)*(t.enableRetinaScaling?this.getRetinaScaling():1),n=this.toCanvasElement(r,t);return E.util.toDataURL(n,e,i)},toCanvasElement:function(t,e){t=t||1;var i=((e=e||{}).width||this.width)*t,r=(e.height||this.height)*t,n=this.getZoom(),s=this.width,o=this.height,a=n*t,h=this.viewportTransform,l=(h[4]-(e.left||0))*t,c=(h[5]-(e.top||0))*t,u=this.interactive,d=[a,0,0,a,l,c],f=this.enableRetinaScaling,g=E.util.createCanvasElement(),_=this.contextTop;return g.width=i,g.height=r,this.contextTop=null,this.enableRetinaScaling=!1,this.interactive=!1,this.viewportTransform=d,this.width=i,this.height=r,this.calcViewportBoundaries(),this.renderCanvas(g.getContext("2d"),this._objects),this.viewportTransform=h,this.width=s,this.height=o,this.calcViewportBoundaries(),this.interactive=u,this.enableRetinaScaling=f,this.contextTop=_,g}}),E.util.object.extend(E.StaticCanvas.prototype,{loadFromJSON:function(t,e,
vendor: 5,814 bytes, line 2
2i){if(t){var r="string"==typeof t?JSON.parse(t):E.util.object.clone(t),n=this,s=r.clipPath,o=this.renderOnAddRemove;return this.renderOnAddRemove=!1,delete r.clipPath,this._enlivenObjects(r.objects,(function(t){n.clear(),n._setBgOverlay(r,(function(){s?n._enlivenObjects([s],(function(i){n.clipPath=i[0],n.__setupCanvas.call(n,r,t,o,e)})):n.__setupCanvas.call(n,r,t,o,e)}))}),i),this}},__setupCanvas:function(t,e,i,r){var n=this;e.forEach((function(t,e){n.insertAt(t,e)})),this.renderOnAddRemove=i,delete t.objects,delete t.backgroundImage,delete t.overlayImage,delete t.background,delete t.overlay,this._setOptions(t),this.renderAll(),r&&r()},_setBgOverlay:function(t,e){var i={backgroundColor:!1,overlayColor:!1,backgroundImage:!1,overlayImage:!1};if(t.backgroundImage||t.overlayImage||t.background||t.overlay){var r=function(){i.backgroundImage&&i.overlayImage&&i.backgroundColor&&i.overlayColor&&e&&e()};this.__setBgOverlay("backgroundImage",t.backgroundImage,i,r),this.__setBgOverlay("overlayImage",t.overlayImage,i,r),this.__setBgOverlay("backgroundColor",t.background,i,r),this.__setBgOverlay("overlayColor",t.overlay,i,r)}else e&&e()},__setBgOverlay:function(t,e,i,r){var n=this;if(!e)return i[t]=!0,void(r&&r());"backgroundImage"===t||"overlayImage"===t?E.util.enlivenObjects([e],(function(e){n[t]=e[0],i[t]=!0,r&&r()})):this["set"+E.util.string.capitalize(t,!0)](e,(function(){i[t]=!0,r&&r()}))},_enlivenObjects:function(t,e,i){t&&0!==t.length?E.util.enlivenObjects(t,(function(t){e&&e(t)}),null,i):e&&e([])},_toDataURL:function(t,e){this.clone((function(i){e(i.toDataURL(t))}))},_toDataURLWithMultiplier:function(t,e,i){this.clone((function(r){i(r.toDataURLWithMultiplier(t,e))}))},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData((function(e){e.loadFromJSON(i,(function(){t&&t(e)}))}))},cloneWithoutData:function(t){var e=E.util.createCanvasElement();e.width=this.width,e.height=this.height;var i=new E.Canvas(e);this.backgroundImage?(i.setBackgroundImage(this.backgroundImage.src,(function(){i.renderAll(),t&&t(i)})),i.backgroundImageOpacity=this.backgroundImageOpacity,i.backgroundImageStretch=this.backgroundImageStretch):t&&t(i)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n=e.util.toFixed,s=e.util.string.capitalize,o=e.util.degreesToRadians,a=!e.isLikelyNode;e.Object||(e.Object=e.util.createClass(e.CommonMethods,{type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,touchCornerSize:24,transparentCorners:!0,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgb(178,204,255)",borderDashArray:null,cornerColor:"rgb(178,204,255)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:!1,centeredRotation:!0,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,minScaleLimit:0,selectable:!0,evented:!0,visible:!0,hasControls:!0,hasBorders:!0,perPixelTargetFind:!1,includeDefaultValues:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,excludeFromExport:!1,objectCaching:a,statefullCache:!1,noScaleCache:!0,strokeUniform:!1,dirty:!0,__corner:0,paintFirst:"fill",activeOn:"down",stateProperties:"top left width height scaleX scaleY flipX flipY originX originY transformMatrix stroke strokeWidth strokeDashArray strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit angle opacity fill globalCompositeOperation shadow visible backgroundColor skewX skewY fillRule paintFirst clipPath strokeUniform".split(" "),cacheProperties:"fill stroke strokeWidth strokeDashArray width height paintFirst strokeUniform strokeLineCap strokeDashOffset strokeLineJoin strokeMiterLimit backgroundColor clipPath".split(" "),colorProperties:"fill stroke backgroundColor".split(" "),clipPath:void 0,inverted:!1,absolutePositioned:!1,initialize:function(t){t&&this.setOptions(t)},_createCacheCanvas:function(){this._cacheProperties={},this._cacheCanvas=e.util.createCanvasElement(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0},_limitCacheSize:function(t){var i=e.perfLimitSizeTotal,r=t.width,n=t.height,s=e.maxCacheSideLimit,o=e.minCacheSideLimit;if(r<=s&&n<=s&&r*n<=i)return r<o&&(t.width=o),n<o&&(t.height=o),t;var a=r/n,h=e.util.limitDimsByArea(a,i),l=e.util.capValue,c=l(o,h.x,s),u=l(o,h.y,s);return r>c&&(t.zoomX/=r/c,t.width=c,t.capped=!0),n>u&&(t.zoomY/=n/u,t.height=u,t.capped=!0),t},_getCacheCanvasDimensions:function(){var t=this.getTotalObjectScaling(),e=this._getTransformedDimensions(0,0),i=e.x*t.scaleX/this.scaleX,r=e.y*t.scaleY/this.scaleY;return{width:i+2,height:r+2,zoomX:t.scaleX,zoomY:t.scaleY,x:i,y:r}},_updateCacheCanvas:function(){var t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){var i=t._currentTransform.target,r=t._currentTransform.action;if(this===i&&r.slice&&"scale"===r.slice(0,5))return!1}var n,s,o=this._cacheCanvas,a=this._limitCacheSize(this._getCacheCanvasDimensions()),h=e.minCacheSideLimit,l=a.width,c=a.height,u=a.zoomX,d=a.zoomY,f=l!==this.cacheWidth||c!==this.cacheHeight,g=this.zoomX!==u||this.zoomY!==d,_=f||g,p=0,m=0,v=!1;if(f){var y=this._cacheCanvas.width,S=this._cacheCanvas.height,C=l>y||c>S;v=C||(l<.9*y||c<.9*S)&&y>h&&S>h,C&&!a.capped&&(l>h||c>h)&&(p=.1*l,m=.1*c)}return this instanceof e.Text&&this.path&&(_=!0,v=!0,p+=this.getHeightOfLine(0)*this.zoomX,m+=this.getHeightOfLine(0)*this.zoomY),!!_&&(v?(o.width=Math.ceil(l+p),o.height=Math.ceil(c+m
vendor: 11,954 bytes, line 2
2)):(this._cacheContext.setTransform(1,0,0,1,0,0),this._cacheContext.clearRect(0,0,o.width,o.height)),n=a.x/2,s=a.y/2,this.cacheTranslationX=Math.round(o.width/2-n)+n,this.cacheTranslationY=Math.round(o.height/2-s)+s,this.cacheWidth=l,this.cacheHeight=c,this._cacheContext.translate(this.cacheTranslationX,this.cacheTranslationY),this._cacheContext.scale(u,d),this.zoomX=u,this.zoomY=d,!0)},setOptions:function(t){this._setOptions(t),this._initGradient(t.fill,"fill"),this._initGradient(t.stroke,"stroke"),this._initPattern(t.fill,"fill"),this._initPattern(t.stroke,"stroke")},transform:function(t){var e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,r={type:this.type,version:e.version,originX:this.originX,originY:this.originY,left:n(this.left,i),top:n(this.top,i),width:n(this.width,i),height:n(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:n(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeDashOffset:this.strokeDashOffset,strokeLineJoin:this.strokeLineJoin,strokeUniform:this.strokeUniform,strokeMiterLimit:n(this.strokeMiterLimit,i),scaleX:n(this.scaleX,i),scaleY:n(this.scaleY,i),angle:n(this.angle,i),flipX:this.flipX,flipY:this.flipY,opacity:n(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,backgroundColor:this.backgroundColor,fillRule:this.fillRule,paintFirst:this.paintFirst,globalCompositeOperation:this.globalCompositeOperation,skewX:n(this.skewX,i),skewY:n(this.skewY,i)};return this.clipPath&&!this.clipPath.excludeFromExport&&(r.clipPath=this.clipPath.toObject(t),r.clipPath.inverted=this.clipPath.inverted,r.clipPath.absolutePositioned=this.clipPath.absolutePositioned),e.util.populateWithProperties(this,r,t),this.includeDefaultValues||(r=this._removeDefaultValues(r)),r},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype;return i.stateProperties.forEach((function(e){"left"!==e&&"top"!==e&&(t[e]===i[e]&&delete t[e],Array.isArray(t[e])&&Array.isArray(i[e])&&0===t[e].length&&0===i[e].length&&delete t[e])})),t},toString:function(){return"#<fabric."+s(this.type)+">"},getObjectScaling:function(){if(!this.group)return{scaleX:this.scaleX,scaleY:this.scaleY};var t=e.util.qrDecompose(this.calcTransformMatrix());return{scaleX:Math.abs(t.scaleX),scaleY:Math.abs(t.scaleY)}},getTotalObjectScaling:function(){var t=this.getObjectScaling(),e=t.scaleX,i=t.scaleY;if(this.canvas){var r=this.canvas.getZoom(),n=this.canvas.getRetinaScaling();e*=r*n,i*=r*n}return{scaleX:e,scaleY:i}},getObjectOpacity:function(){var t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t},_set:function(t,i){var r="scaleX"===t||"scaleY"===t,n=this[t]!==i,s=!1;return r&&(i=this._constrainScale(i)),"scaleX"===t&&i<0?(this.flipX=!this.flipX,i*=-1):"scaleY"===t&&i<0?(this.flipY=!this.flipY,i*=-1):"shadow"!==t||!i||i instanceof e.Shadow?"dirty"===t&&this.group&&this.group.set("dirty",i):i=new e.Shadow(i),this[t]=i,n&&(s=this.group&&this.group.isOnACache(),this.cacheProperties.indexOf(t)>-1?(this.dirty=!0,s&&this.group.set("dirty",!0)):s&&this.stateProperties.indexOf(t)>-1&&this.group.set("dirty",!0)),this},setOnGroup:function(){},getViewportTransform:function(){return this.canvas&&this.canvas.viewportTransform?this.canvas.viewportTransform:e.iMatrix.concat()},isNotVisible:function(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible},render:function(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t,this),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.dirty=!1,this.drawObject(t),this.objectCaching&&this.statefullCache&&this.saveState({propertySet:"cacheProperties"})),t.restore())},renderCache:function(t){t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&(this.statefullCache&&this.saveState({propertySet:"cacheProperties"}),this.drawObject(this._cacheContext,t.forClipping),this.dirty=!1)},_removeCacheCanvas:function(){this._cacheCanvas=null,this._cacheContext=null,this.cacheWidth=0,this.cacheHeight=0},hasStroke:function(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth},hasFill:function(){return this.fill&&"transparent"!==this.fill},needsItsOwnCache:function(){return!("stroke"!==this.paintFirst||!this.hasFill()||!this.hasStroke()||"object"!=typeof this.shadow)||!!this.clipPath},shouldCache:function(){return this.ownCaching=this.needsItsOwnCache()||this.objectCaching&&(!this.group||!this.group.isOnACache()),this.ownCaching},willDrawShadow:function(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)},drawClipPathOnCache:function(t,i){if(t.save(),i.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",i.absolutePositioned){var r=e.util.invertTransform(this.calcTransformMatrix());t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}i.transform(t),t.scale(1/i.zoomX,1/i.zoomY),t.drawImage(i._cacheCanvas,-i.cacheTranslationX,-i.cacheTranslationY),t.restore()},drawObject:function(t,e){var i=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath),this.fill=i,this.stroke=r},_drawClipPath:function(t,e){e&&(e.canvas=this.canvas,e.shouldCache(),e._transformDone=!0,e.renderCache({forClipping:!0}),this.drawClipPathOnCache(t,e))},drawCacheOnCanvas:function(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)},isCacheDirty:function(t){if(this.isNotVisible())return!1;if(this._cacheCanvas&&this._cacheContext&&!t&&this._updateCacheCanvas())return!0;if(this.dirty||this.clipPath&&this.clipPath.absolutePositioned||this.statefullCache&&this.hasStateChanged("cacheProperties")){if(this._cacheCanvas&&this._cacheContext&&!t){var e=this.cacheWidth/this.zoomX,i=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-e/2,-i/2,e,i)}return!0}return!1},_renderBackground:function(t){if(this.backgroundColor){var e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}},_setOpacity:function(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity},_setStrokeStyles:function(t,e){var i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)},_setFillStyles:function(t,e){var i=e.fill;i&&(i.toLive?(t.fillStyle=i.toLive(t,this),this._applyPatternGradientTransform(t,e.fill)):t.fillStyle=i)},_setClippingProperties:function(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"},_setLineDash:function(t,e){e&&0!==e.length&&(1&e.length&&e.push.apply(e,e),t.setLineDash(e))},_renderControls:function(t,i){var r,n,s,a=this.getViewportTransform(),h=this.calcTransformMatrix();n=void 0!==(i=i||{}).hasBorders?i.hasBorders:this.hasBorders,s=void 0!==i.hasControls?i.hasControls:this.hasControls,h=e.util.multiplyTransformMatrices(a,h),r=e.util.qrDecompose(h),t.save(),t.translate(r.translateX,r.translateY),t.lineWidth=1*this.borderScaleFactor,this.group||(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(r.angle-=180),t.rotate(o(this.group?r.angle:this.angle)),i.forActiveSelection||this.group?n&&this.drawBordersInGroup(t,r,i):n&&this.drawBorders(t,i),s&&this.drawControls(t,i),t.restore()},_setShadow:function(t){if(this.shadow){var i,r=this.shadow,n=this.canvas,s=n&&n.viewportTransform[0]||1,o=n&&n.viewportTransform[3]||1;i=r.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),n&&n._isRetinaScaling()&&(s*=e.devicePixelRatio,o*=e.devicePixelRatio),t.shadowColor=r.color,t.shadowBlur=r.blur*e.browserShadowBlurConstant*(s+o)*(i.scaleX+i.scaleY)/4,t.shadowOffsetX=r.offsetX*s*i.scaleX,t.shadowOffsetY=r.offsetY*o*i.scaleY}},_removeShadow:function(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)},_applyPatternGradientTransform:function(t,e){if(!e||!e.toLive)return{offsetX:0,offsetY:0};var i=e.gradientTransform||e.patternTransform,r=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,r,n):t.transform(1,0,0,1,r,n),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:r,offsetY:n}},_renderPaintInOrder:function(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))},_render:function(){},_renderFill:function(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())},_renderStroke:function(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform&&this.group){var e=this.getObjectScaling();t.scale(1/e.scaleX,1/e.scaleY)}else this.strokeUniform&&t.scale(1/this.scaleX,1/this.scaleY);this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}},_applyPatternForTransformedGradient:function(t,i){var r,n=this._limitCacheSize(this._getCacheCanvasDimensions()),s=e.util.createCanvasElement(),o=this.canvas.getRetinaScaling(),a=n.x/this.scaleX/o,h=n.y/this.scaleY/o;s.width=a,s.height=h,(r=s.getContext("2d")).beginPath(),r.moveTo(0,0),r.lineTo(a,0),r.lineTo(a,h),r.lineTo(0,h),r.closePath(),r.translate(a/2,h/2),r.scale(n.zoomX/this.scaleX/o,n.zoomY/this.scaleY/o),this._applyPatternGradientTransform(r,i),r.fillStyle=i.toLive(t),r.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(o*this.scaleX/n.zoomX,o*this.scaleY/n.zoomY),t.strokeStyle=r.createPattern(s,"no-repeat")},_findCenterFromElement:function(){return{x:this.left+this.width/2,y:this.top+this.height/2}},_assignTransformMatrixProps:function(){if(this.transformMatrix){var t=e.util.qrDecompose(this.transformMatrix);this.flipX=!1,this.flipY=!1,this.set("scaleX",t.scaleX),this.set("scaleY",t.scaleY),this.angle=t.angle,this.skewX=t.skewX,this.skewY=0}},_removeTransformMatrix:function(t){var i=this._findCenterFromElement();this.transformMatrix&&(this._assignTransformMatrixProps(),i=e.util.transformPoint(i,this.transformMatrix)),this.transformMatrix=null,t&&(this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this.cropX=t.cropX,this.cropY=t.cropY,i.x+=t.offsetLeft,i.y+=t.offsetTop,this.width=t.width,this.height=t.height),this.setPositionByOrigin(i,"center","center")},clone:function(t,i){var r=this.toObject(i);this.constructor.fromObject?this.constructor.fromObject(r,t):e.Object._fromObject("Object",r,t)},cloneAsImage:function(t,i){var r=this.toCanvasElement(i);return t&&t(new e.Image(r)),this},toCanvasElement:function(t){t||(t={});var i=e.util,r=i.saveObjectTransform(this),n=this.group,s=this.shadow,o=Math.abs,a=(t.multiplier||1)*(t.enableRetinaScaling?e.devicePixelRatio:1);delete this.group,t.withoutTransform&&i.resetObjectTransform(this),t.withoutShadow&&(this.shadow=null);var h,l,c,u,d=e.util.createCanvasElement(),f=this.getBoundingRect(!0,!0),g=this.shadow,
vendor: 12,643 bytes, line 2
2_={x:0,y:0};g&&(l=g.blur,h=g.nonScaling?{scaleX:1,scaleY:1}:this.getObjectScaling(),_.x=2*Math.round(o(g.offsetX)+l)*o(h.scaleX),_.y=2*Math.round(o(g.offsetY)+l)*o(h.scaleY)),c=f.width+_.x,u=f.height+_.y,d.width=Math.ceil(c),d.height=Math.ceil(u);var p=new e.StaticCanvas(d,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1});"jpeg"===t.format&&(p.backgroundColor="#fff"),this.setPositionByOrigin(new e.Point(p.width/2,p.height/2),"center","center");var m=this.canvas;p.add(this);var v=p.toCanvasElement(a||1,t);return this.shadow=s,this.set("canvas",m),n&&(this.group=n),this.set(r).setCoords(),p._objects=[],p.dispose(),p=null,v},toDataURL:function(t){return t||(t={}),e.util.toDataURL(this.toCanvasElement(t),t.format||"png",t.quality||1)},isType:function(t){return arguments.length>1?Array.from(arguments).includes(this.type):this.type===t},complexity:function(){return 1},toJSON:function(t){return this.toObject(t)},rotate:function(t){var e=("center"!==this.originX||"center"!==this.originY)&&this.centeredRotation;return e&&this._setOriginToCenter(),this.set("angle",t),e&&this._resetOrigin(),this},centerH:function(){return this.canvas&&this.canvas.centerObjectH(this),this},viewportCenterH:function(){return this.canvas&&this.canvas.viewportCenterObjectH(this),this},centerV:function(){return this.canvas&&this.canvas.centerObjectV(this),this},viewportCenterV:function(){return this.canvas&&this.canvas.viewportCenterObjectV(this),this},center:function(){return this.canvas&&this.canvas.centerObject(this),this},viewportCenter:function(){return this.canvas&&this.canvas.viewportCenterObject(this),this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var r=new e.Point(i.x,i.y),n=this._getLeftTopCoords();return this.angle&&(r=e.util.rotatePoint(r,n,o(-this.angle))),{x:r.x-n.x,y:r.y-n.y}},_setupCompositeOperation:function(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)},dispose:function(){e.runningAnimations&&e.runningAnimations.cancelByTarget(this)}}),e.util.createAccessors&&e.util.createAccessors(e.Object),i(e.Object.prototype,e.Observable),e.Object.NUM_FRACTION_DIGITS=2,e.Object.ENLIVEN_PROPS=["clipPath"],e.Object._fromObject=function(t,i,n,s){var o=e[t];i=r(i,!0),e.util.enlivenPatterns([i.fill,i.stroke],(function(t){void 0!==t[0]&&(i.fill=t[0]),void 0!==t[1]&&(i.stroke=t[1]),e.util.enlivenObjectEnlivables(i,i,(function(){var t=s?new o(i[s],i):new o(i);n&&n(t)}))}))},e.Object.__uid=0)}(e),w=E.util.degreesToRadians,b={left:-.5,center:0,right:.5},x={top:-.5,center:0,bottom:.5},E.util.object.extend(E.Object.prototype,{translateToGivenOrigin:function(t,e,i,r,n){var s,o,a,h=t.x,l=t.y;return"string"==typeof e?e=b[e]:e-=.5,"string"==typeof r?r=b[r]:r-=.5,"string"==typeof i?i=x[i]:i-=.5,"string"==typeof n?n=x[n]:n-=.5,o=n-i,((s=r-e)||o)&&(a=this._getTransformedDimensions(),h=t.x+s*a.x,l=t.y+o*a.y),new E.Point(h,l)},translateToCenterPoint:function(t,e,i){var r=this.translateToGivenOrigin(t,e,i,"center","center");return this.angle?E.util.rotatePoint(r,t,w(this.angle)):r},translateToOriginPoint:function(t,e,i){var r=this.translateToGivenOrigin(t,"center","center",e,i);return this.angle?E.util.rotatePoint(r,t,w(this.angle)):r},getCenterPoint:function(){var t=new E.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(t,e,i){var r,n,s=this.getCenterPoint();return r=void 0!==e&&void 0!==i?this.translateToGivenOrigin(s,"center","center",e,i):new E.Point(this.left,this.top),n=new E.Point(t.x,t.y),this.angle&&(n=E.util.rotatePoint(n,s,-w(this.angle))),n.subtractEquals(r)},setPositionByOrigin:function(t,e,i){var r=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(r,this.originX,this.originY);this.set("left",n.x),this.set("top",n.y)},adjustPosition:function(t){var e,i,r=w(this.angle),n=this.getScaledWidth(),s=E.util.cos(r)*n,o=E.util.sin(r)*n;e="string"==typeof this.originX?b[this.originX]:this.originX-.5,i="string"==typeof t?b[t]:t-.5,this.left+=s*(i-e),this.top+=o*(i-e),this.setCoords(),this.originX=t},_setOriginToCenter:function(){this._originalOriginX=this.originX,this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center",this.originY="center",this.left=t.x,this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX,this.originY=this._originalOriginY,this.left=t.x,this.top=t.y,this._originalOriginX=null,this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}}),function(){var t=E.util,e=t.degreesToRadians,i=t.multiplyTransformMatrices,r=t.transformPoint;t.object.extend(E.Object.prototype,{oCoords:null,aCoords:null,lineCoords:null,ownMatrixCache:null,matrixCache:null,controls:{},_getCoords:function(t,e){return e?t?this.calcACoords():this.calcLineCoords():(this.aCoords&&this.lineCoords||this.setCoords(!0),t?this.aCoords:this.lineCoords)},getCoords:function(t,e){return i=this._getCoords(t,e),[new E.Point(i.tl.x,i.tl.y),new E.Point(i.tr.x,i.tr.y),new E.Point(i.br.x,i.br.y),new E.Point(i.bl.x,i.bl.y)];var i},intersectsWithRect:function(t,e,i,r){var n=this.getCoords(i,r);return"Intersection"===E.Intersection.intersectPolygonRectangle(n,t,e).status},intersectsWithObject:function(t,e,i){return"Intersection"===E.Intersection.intersectPolygonPolygon(this.getCoords(e,i),t.getCoords(e,i)).status||t.isContainedWithinObject(this,e,i)||this.isContainedWithinObject(t,e,i)},isContainedWithinObject:function(t,e,i){for(var r=this.getCoords(e,i),n=e?t.aCoords:t.lineCoords,s=0,o=t._getImageLines(n);s<4;s++)if(!t.containsPoint(r[s],o))return!1;return!0},isContainedWithinRect:function(t,e,i,r){var n=this.getBoundingRect(i,r);return n.left>=t.x&&n.left+n.width<=e.x&&n.top>=t.y&&n.top+n.height<=e.y},containsPoint:function(t,e,i,r){var n=this._getCoords(i,r),s=(e=e||this._getImageLines(n),this._findCrossPoints(t,e));return 0!==s&&s%2==1},isOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.getCoords(!0,t).some((function(t){return t.x<=i.x&&t.x>=e.x&&t.y<=i.y&&t.y>=e.y}))||!!this.intersectsWithRect(e,i,!0,t)||this._containsCenterOfCanvas(e,i,t)},_containsCenterOfCanvas:function(t,e,i){var r={x:(t.x+e.x)/2,y:(t.y+e.y)/2};return!!this.containsPoint(r,null,!0,i)},isPartiallyOnScreen:function(t){if(!this.canvas)return!1;var e=this.canvas.vptCoords.tl,i=this.canvas.vptCoords.br;return!!this.intersectsWithRect(e,i,!0,t)||this.getCoords(!0,t).every((function(t){return(t.x>=i.x||t.x<=e.x)&&(t.y>=i.y||t.y<=e.y)}))&&this._containsCenterOfCanvas(e,i,t)},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,r,n,s=0;for(var o in e)if(!((n=e[o]).o.y<t.y&&n.d.y<t.y||n.o.y>=t.y&&n.d.y>=t.y||(n.o.x===n.d.x&&n.o.x>=t.x?r=n.o.x:(i=(n.d.y-n.o.y)/(n.d.x-n.o.x),r=-(t.y-0*t.x-(n.o.y-i*n.o.x))/(0-i)),r>=t.x&&(s+=1),2!==s)))break;return s},getBoundingRect:function(e,i){var r=this.getCoords(e,i);return t.makeBoundingBoxFromPoints(r)},getScaledWidth:function(){return this._getTransformedDimensions().x},getScaledHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t},scale:function(t){return this._set("scaleX",t),this._set("scaleY",t),this.setCoords()},scaleToWidth:function(t,e){var i=this.getBoundingRect(e).width/this.getScaledWidth();return this.scale(t/this.width/i)},scaleToHeight:function(t,e){var i=this.getBoundingRect(e).height/this.getScaledHeight();return this.scale(t/this.height/i)},calcLineCoords:function(){var i=this.getViewportTransform(),n=this.padding,s=e(this.angle),o=t.cos(s)*n,a=t.sin(s)*n,h=o+a,l=o-a,c=this.calcACoords(),u={tl:r(c.tl,i),tr:r(c.tr,i),bl:r(c.bl,i),br:r(c.br,i)};return n&&(u.tl.x-=l,u.tl.y-=h,u.tr.x+=h,u.tr.y-=l,u.bl.x-=h,u.bl.y+=l,u.br.x+=l,u.br.y+=h),u},calcOCoords:function(){var t=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),r=this.getViewportTransform(),n=i(r,e),s=i(n,t),o=(s=i(s,[1/r[0],0,0,1/r[3],0,0]),this._calculateCurrentDimensions()),a={};return this.forEachControl((function(t,e,i){a[e]=t.positionHandler(o,s,i)})),a},calcACoords:function(){var t=this._calcRotateMatrix(),e=this._calcTranslateMatrix(),n=i(e,t),s=this._getTransformedDimensions(),o=s.x/2,a=s.y/2;return{tl:r({x:-o,y:-a},n),tr:r({x:o,y:-a},n),bl:r({x:-o,y:a},n),br:r({x:o,y:a},n)}},setCoords:function(t){return this.aCoords=this.calcACoords(),this.lineCoords=this.group?this.aCoords:this.calcLineCoords(),t||(this.oCoords=this.calcOCoords(),this._setCornerCoords&&this._setCornerCoords()),this},_calcRotateMatrix:function(){return t.calcRotateMatrix(this)},_calcTranslateMatrix:function(){var t=this.getCenterPoint();return[1,0,0,1,t.x,t.y]},transformMatrixKey:function(t){var e="_",i="";return!t&&this.group&&(i=this.group.transformMatrixKey(t)+e),i+this.top+e+this.left+e+this.scaleX+e+this.scaleY+e+this.skewX+e+this.skewY+e+this.angle+e+this.originX+e+this.originY+e+this.width+e+this.height+e+this.strokeWidth+this.flipX+this.flipY},calcTransformMatrix:function(t){var e=this.calcOwnMatrix();if(t||!this.group)return e;var r=this.transformMatrixKey(t),n=this.matrixCache||(this.matrixCache={});return n.key===r?n.value:(this.group&&(e=i(this.group.calcTransformMatrix(!1),e)),n.key=r,n.value=e,e)},calcOwnMatrix:function(){var e=this.transformMatrixKey(!0),i=this.ownMatrixCache||(this.ownMatrixCache={});if(i.key===e)return i.value;var r=this._calcTranslateMatrix(),n={angle:this.angle,translateX:r[4],translateY:r[5],scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY};return i.key=e,i.value=t.composeMatrix(n),i.value},_getNonTransformedDimensions:function(){var t=this.strokeWidth;return{x:this.width+t,y:this.height+t}},_getTransformedDimensions:function(e,i){void 0===e&&(e=this.skewX),void 0===i&&(i=this.skewY);var r,n,s,o=0===e&&0===i;if(this.strokeUniform?(n=this.width,s=this.height):(n=(r=this._getNonTransformedDimensions()).x,s=r.y),o)return this._finalizeDimensions(n*this.scaleX,s*this.scaleY);var a=t.sizeAfterTransform(n,s,{scaleX:this.scaleX,scaleY:this.scaleY,skewX:e,skewY:i});return this._finalizeDimensions(a.x,a.y)},_finalizeDimensions:function(t,e){return this.strokeUniform?{x:t+this.strokeWidth,y:e+this.strokeWidth}:{x:t,y:e}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform(),e=this._getTransformedDimensions();return r(e,t,!0).scalarAdd(2*this.padding)}})}(),E.util.object.extend(E.Object.prototype,{sendToBack:function(){return this.group?E.StaticCanvas.prototype.sendToBack.call(this.group,this):this.canvas&&this.canvas.sendToBack(this),this},bringToFront:function(){return this.group?E.StaticCanvas.prototype.bringToFront.call(this.group,this):this.canvas&&this.canvas.bringToFront(this),this},sendBackwards:function(t){return this.group?E.StaticCanvas.prototype.sendBackwards.call(this.group,this,t):this.canvas&&this.canvas.sendBackwards(this,t),this},bringForward:function(t){return this.group?E.StaticCanvas.prototype.bringForward.call(this.group,this,t):this.canvas&&this.canvas.bringForward(this,t),this},moveTo:function(t){return this.group&&"activeSelection"!==this.group.type?E.StaticCanvas.prototype.moveTo.call(this.group,this,t):this.canvas&&this.canvas.moveTo(this,t),this}}),function(){function t(t,e){if(e){if(e.toLive)return t+": url(#SVGID_"+e.id+"); ";var i=new E.Color(e),r=t+": "+i.toRgb()+"; ",n=i.getAlpha();return 1!==n&&(r+=t+"-opacity: "+n.toString()+"; "),r}return t+": none; "}var e=E.util.toFixed;E.util.object.extend(E.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",n=this.strokeDashArray?this.strokeDashArray.join(" "):"none",s=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",h=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0!==this.opacity?this.opacity:"1",c=this.visible?"":" visibility: hidden;",u=e?"":this.getSvgFilter(),d=t("fill",this.fill);return[t("stroke",this.stroke),"stroke-width: ",r,"; ","stroke-dasharray: ",n,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",s,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",h,"; ",d,"fill-rule: ",i,";
2 ","opacity: ",l,";",u,c].join("")},getSvgSpanStyles:function(e,i){var r="; ",n=e.fontFamily?"font-family: "+(-1===e.fontFamily.indexOf("'")&&-1===e.fontFamily.indexOf('"')?"'"+e.fontFamily+"'":e.fontFamily)+r:"",s=e.strokeWidth?"stroke-width: "+e.strokeWidth+r:"",o=e.fontSize?"font-size: "+e.fontSize+"px"+r:"",a=e.fontStyle?"font-style: "+e.fontStyle+r:"",h=e.fontWeight?"font-weight: "+e.fontWeight+r:"",l=e.fill?t("fill",e.fill):"",c=e.stroke?t("stroke",e.stroke):"",u=this.getSvgTextDecoration(e);return u&&(u="text-decoration: "+u+r),[c,s,n,o,a,h,u,l,e.deltaY?"baseline-shift: "+-e.deltaY+"; ":"",i?"white-space: pre; ":""].join("")},getSvgTextDecoration:function(t){return["overline","underline","line-through"].filter((function(e){return t[e.replace("-","")]})).join(" ")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgCommons:function(){return[this.id?'id="'+this.id+'" ':"",this.clipPath?'clip-path="url(#'+this.clipPath.clipPathId+')" ':""].join("")},getSvgTransform:function(t,e){var i=t?this.calcTransformMatrix():this.calcOwnMatrix();return'transform="'+E.util.matrixToSVG(i)+(e||"")+'" '},_setSVGBg:function(t){if(this.backgroundColor){var i=E.Object.NUM_FRACTION_DIGITS;t.push("\t\t<rect ",this._getFillAttributes(this.backgroundColor),' x="',e(-this.width/2,i),'" y="',e(-this.height/2,i),'" width="',e(this.width,i),'" height="',e(this.height,i),'"></rect>\n')}},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})},toClipPathSVG:function(t){return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})},_createBaseClipPathSVGMarkup:function(t,e){var i=(e=e||{}
vendor: 7,314 bytes, line 2
2).reviver,r=e.additionalTransform||"",n=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=n,i?i(t.join("")):t.join("")},_createBaseSVGMarkup:function(t,e){var i,r,n=(e=e||{}).noStyle,s=e.reviver,o=n?"":'style="'+this.getSvgStyles()+'" ',a=e.withShadow?'style="'+this.getSvgFilter()+'" ':"",h=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=h&&h.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,g=[],_=t.indexOf("COMMON_PARTS"),p=e.additionalTransform;return h&&(h.clipPathId="CLIPPATH_"+E.Object.__uid++,r='<clipPath id="'+h.clipPathId+'" >\n'+h.toClipPathSVG(s)+"</clipPath>\n"),c&&g.push("<g ",a,this.getSvgCommons()," >\n"),g.push("<g ",this.getSvgTransform(!1),c?"":a+this.getSvgCommons()," >\n"),i=[o,l,n?"":this.addPaintOrder()," ",p?'transform="'+p+'" ':""].join(""),t[_]=i,d&&d.toLive&&g.push(d.toSVG(this)),u&&u.toLive&&g.push(u.toSVG(this)),f&&g.push(f.toSVG(this)),h&&g.push(r),g.push(t.join("")),g.push("</g>\n"),c&&g.push("</g>\n"),s?s(g.join("")):g.join("")},addPaintOrder:function(){return"fill"!==this.paintFirst?' paint-order="'+this.paintFirst+'" ':""}})}(),function(){var t=E.util.object.extend,e="stateProperties";function i(e,i,r){var n={};r.forEach((function(t){n[t]=e[t]})),t(e[i],n,!0)}function r(t,e,i){if(t===e)return!0;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var n=0,s=t.length;n<s;n++)if(!r(t[n],e[n]))return!1;return!0}if(t&&"object"==typeof t){var o,a=Object.keys(t);if(!e||"object"!=typeof e||!i&&a.length!==Object.keys(e).length)return!1;for(n=0,s=a.length;n<s;n++)if("canvas"!==(o=a[n])&&"group"!==o&&!r(t[o],e[o]))return!1;return!0}}E.util.object.extend(E.Object.prototype,{hasStateChanged:function(t){var i="_"+(t=t||e);return Object.keys(this[i]).length<this[t].length||!r(this[i],this,!0)},saveState:function(t){var r=t&&t.propertySet||e,n="_"+r;return this[n]?(i(this,n,this[r]),t&&t.stateProperties&&i(this,n,t.stateProperties),this):this.setupState(t)},setupState:function(t){var i=(t=t||{}).propertySet||e;return t.propertySet=i,this["_"+i]={},this.saveState(t),this}})}(),function(){var t=E.util.degreesToRadians;E.util.object.extend(E.Object.prototype,{_findTargetCorner:function(t,e){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var i,r,n,s=t.x,o=t.y,a=Object.keys(this.oCoords),h=a.length-1;for(this.__corner=0;h>=0;h--)if(n=a[h],this.isControlVisible(n)&&(r=this._getImageLines(e?this.oCoords[n].touchCorner:this.oCoords[n].corner),0!==(i=this._findCrossPoints({x:s,y:o},r))&&i%2==1))return this.__corner=n,n;return!1},forEachControl:function(t){for(var e in this.controls)t(this.controls[e],e,this)},_setCornerCoords:function(){var t=this.oCoords;for(var e in t){var i=this.controls[e];t[e].corner=i.calcCornerCoords(this.angle,this.cornerSize,t[e].x,t[e].y,!1),t[e].touchCorner=i.calcCornerCoords(this.angle,this.touchCornerSize,t[e].x,t[e].y,!0)}},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;e.save();var i=this.getCenterPoint(),r=this._calculateCurrentDimensions(),n=this.canvas.viewportTransform;return e.translate(i.x,i.y),e.scale(1/n[0],1/n[3]),e.rotate(t(this.angle)),e.fillStyle=this.selectionBackgroundColor,e.fillRect(-r.x/2,-r.y/2,r.x,r.y),e.restore(),this},drawBorders:function(t,e){e=e||{};var i=this._calculateCurrentDimensions(),r=this.borderScaleFactor,n=i.x+r,s=i.y+r,o=void 0!==e.hasControls?e.hasControls:this.hasControls,a=!1;return t.save(),t.strokeStyle=e.borderColor||this.borderColor,this._setLineDash(t,e.borderDashArray||this.borderDashArray),t.strokeRect(-n/2,-s/2,n,s),o&&(t.beginPath(),this.forEachControl((function(e,i,r){e.withConnection&&e.getVisibility(r,i)&&(a=!0,t.moveTo(e.x*n,e.y*s),t.lineTo(e.x*n+e.offsetX,e.y*s+e.offsetY))})),a&&t.stroke()),t.restore(),this},drawBordersInGroup:function(t,e,i){i=i||{};var r=E.util.sizeAfterTransform(this.width,this.height,e),n=this.strokeWidth,s=this.strokeUniform,o=this.borderScaleFactor,a=r.x+n*(s?this.canvas.getZoom():e.scaleX)+o,h=r.y+n*(s?this.canvas.getZoom():e.scaleY)+o;return t.save(),this._setLineDash(t,i.borderDashArray||this.borderDashArray),t.strokeStyle=i.borderColor||this.borderColor,t.strokeRect(-a/2,-h/2,a,h),t.restore(),this},drawControls:function(t,e){e=e||{},t.save();var i,r,n=this.canvas.getRetinaScaling();return t.setTransform(n,0,0,n,0,0),t.strokeStyle=t.fillStyle=e.cornerColor||this.cornerColor,this.transparentCorners||(t.strokeStyle=e.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(t,e.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl((function(n,s,o){r=o.oCoords[s],n.getVisibility(o,s)&&(i&&(r=E.util.transformPoint(r,i)),n.render(t,r.x,r.y,e,o))})),t.restore(),this},isControlVisible:function(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)},setControlVisible:function(t,e){return this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e,this},setControlsVisibility:function(t){for(var e in t||(t={}),t)this.setControlVisible(e,t[e]);return this},onDeselect:function(){},onSelect:function(){}})}(),E.util.object.extend(E.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return E.util.animate({target:this,startValue:t.left,endValue:this.getCenterPoint().x,duration:this.FX_DURATION,onChange:function(e){t.set("left",e),s.requestRenderAll(),n()},onComplete:function(){t.setCoords(),r()}})},fxCenterObjectV:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return E.util.animate({target:this,startValue:t.top,endValue:this.getCenterPoint().y,duration:this.FX_DURATION,onChange:function(e){t.set("top",e),s.requestRenderAll(),n()},onComplete:function(){t.setCoords(),r()}})},fxRemove:function(t,e){var i=function(){},r=(e=e||{}).onComplete||i,n=e.onChange||i,s=this;return E.util.animate({target:this,startValue:t.opacity,endValue:0,duration:this.FX_DURATION,onChange:function(e){t.set("opacity",e),s.requestRenderAll(),n()},onComplete:function(){s.remove(t),r()}})}}),E.util.object.extend(E.Object.prototype,{animate:function(){if(arguments[0]&&"object"==typeof arguments[0]){var t,e,i=[],r=[];for(t in arguments[0])i.push(t);for(var n=0,s=i.length;n<s;n++)t=i[n],e=n!==s-1,r.push(this._animate(t,arguments[0][t],arguments[1],e));return r}return this._animate.apply(this,arguments)},_animate:function(t,e,i,r){var n,s=this;e=e.toString(),i=i?E.util.object.clone(i):{},~t.indexOf(".")&&(n=t.split("."));var o=s.colorProperties.indexOf(t)>-1||n&&s.colorProperties.indexOf(n[1])>-1,a=n?this.get(n[0])[n[1]]:this.get(t);"from"in i||(i.from=a),o||(e=~e.indexOf("=")?a+parseFloat(e.replace("=","")):parseFloat(e));var h={target:this,startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(t,e,r){return i.abort.call(s,t,e,r)},onChange:function(e,o,a){n?s[n[0]][n[1]]=e:s.set(t,e),r||i.onChange&&i.onChange(e,o,a)},onComplete:function(t,e,n){r||(s.setCoords(),i.onComplete&&i.onComplete(t,e,n))}};return o?E.util.animateColor(h.startValue,h.endValue,h.duration,h):E
vendor: 21,321 bytes, line 2
2.util.animate(h)}}),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,n={x1:1,x2:1,y1:1,y2:1};function s(t,e){var i=t.origin,r=t.axis1,n=t.axis2,s=t.dimension,o=e.nearest,a=e.center,h=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(r),this.get(n));case a:return Math.min(this.get(r),this.get(n))+.5*this.get(s);case h:return Math.max(this.get(r),this.get(n))}}}e.Line?e.warn("fabric.Line is already defined"):(e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,cacheProperties:e.Object.prototype.cacheProperties.concat("x1","x2","y1","y2"),initialize:function(t,e){t||(t=[0,0,0,0]),this.callSuper("initialize",e),this.set("x1",t[0]),this.set("y1",t[1]),this.set("x2",t[2]),this.set("y2",t[3]),this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={}),this.width=Math.abs(this.x2-this.x1),this.height=Math.abs(this.y2-this.y1),this.left="left"in t?t.left:this._getLeftToOriginX(),this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){return this.callSuper("_set",t,e),void 0!==n[t]&&this._setWidthHeight(),this},_getLeftToOriginX:s({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:s({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t){t.beginPath();var e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;var i=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i},_findCenterFromElement:function(){return{x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2}},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},_getNonTransformedDimensions:function(){var t=this.callSuper("_getNonTransformedDimensions");return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,r=e*this.height*.5;return{x1:i,x2:t*this.width*-.5,y1:r,y2:e*this.height*-.5}},_toSVG:function(){var t=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="',t.x1,'" y1="',t.y1,'" x2="',t.x2,'" y2="',t.y2,'" />\n']}}),e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" ")),e.Line.fromElement=function(t,r,n){n=n||{};var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),o=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];r(new e.Line(o,i(s,n)))},e.Line.fromObject=function(t,i){var n=r(t,!0);n.points=[t.x1,t.y1,t.x2,t.y2],e.Object._fromObject("Line",n,(function(t){delete t.points,i&&i(t)}),"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.degreesToRadians;e.Circle?e.warn("fabric.Circle is already defined."):(e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:360,cacheProperties:e.Object.prototype.cacheProperties.concat("radius","startAngle","endAngle"),_set:function(t,e){return this.callSuper("_set",t,e),"radius"===t&&this.setRadius(e),this},toObject:function(t){return this.callSuper("toObject",["radius","startAngle","endAngle"].concat(t))},_toSVG:function(){var t,r=(this.endAngle-this.startAngle)%360;if(0===r)t=["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',this.radius,'" />\n'];else{var n=i(this.startAngle),s=i(this.endAngle),o=this.radius;t=['<path d="M '+e.util.cos(n)*o+" "+e.util.sin(n)*o," A "+o+" "+o," 0 ",+(r>180?"1":"0")+" 1"," "+e.util.cos(s)*o+" "+e.util.sin(s)*o,'" ',"COMMON_PARTS"," />\n"]}return t},_render:function(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),!1),this._renderPaintInOrder(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){return this.radius=t,this.set("width",2*t).set("height",2*t)}}),e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" ")),e.Circle.fromElement=function(t,i){var r,n=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in(r=n)&&r.radius>=0))throw new Error("value of `r` attribute is required and can not be negative");n.left=(n.left||0)-n.radius,n.top=(n.top||0)-n.radius,i(new e.Circle(n))},e.Circle.fromObject=function(t,i){e.Object._fromObject("Circle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={});e.Triangle?e.warn("fabric.Triangle is already defined"):(e.Triangle=e.util.createClass(e.Object,{type:"triangle",width:100,height:100,_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)},_toSVG:function(){var t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',[-t+" "+e,"0 "+-e,t+" "+e].join(","),'" />']}}),e.Triangle.fromObject=function(t,i){return e.Object._fromObject("Triangle",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=2*Math.PI;e.Ellipse?e.warn("fabric.Ellipse is already defined."):(e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this.set("rx",t&&t.rx||0),this.set("ry",t&&t.ry||0)},_set:function(t,e){switch(this.callSuper("_set",t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" ','rx="',this.rx,'" ry="',this.ry,'" />\n']},_render:function(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,i,!1),t.restore(),this._renderPaintInOrder(t)}}),e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" ")),e.Ellipse.fromElement=function(t,i){var r=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,i(new e.Ellipse(r))},e.Ellipse.fromObject=function(t,i){e.Object._fromObject("Ellipse",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Rect?e.warn("fabric.Rect is already defined"):(e.Rect=e.util.createClass(e.Object,{stateProperties:e.Object.prototype.stateProperties.concat("rx","ry"),type:"rect",rx:0,ry:0,cacheProperties:e.Object.prototype.cacheProperties.concat("rx","ry"),initialize:function(t){this.callSuper("initialize",t),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(t){var e=this.rx?Math.min(this.rx,this.width/2):0,i=this.ry?Math.min(this.ry,this.height/2):0,r=this.width,n=this.height,s=-this.width/2,o=-this.height/2,a=0!==e||0!==i,h=.4477152502;t.beginPath(),t.moveTo(s+e,o),t.lineTo(s+r-e,o),a&&t.bezierCurveTo(s+r-h*e,o,s+r,o+h*i,s+r,o+i),t.lineTo(s+r,o+n-i),a&&t.bezierCurveTo(s+r,o+n-h*i,s+r-h*e,o+n,s+r-e,o+n),t.lineTo(s+e,o+n),a&&t.bezierCurveTo(s+h*e,o+n,s,o+n-h*i,s,o+n-i),t.lineTo(s,o+i),a&&t.bezierCurveTo(s,o+h*i,s+h*e,o,s+e,o),t.closePath(),this._renderPaintInOrder(t)},toObject:function(t){return this.callSuper("toObject",["rx","ry"].concat(t))},_toSVG:function(){return["<rect ","COMMON_PARTS",'x="',-this.width/2,'" y="',-this.height/2,'" rx="',this.rx,'" ry="',this.ry,'" width="',this.width,'" height="',this.height,'" />\n']}}),e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" ")),e.Rect.fromElement=function(t,r,n){if(!t)return r(null);n=n||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0,s.top=s.top||0,s.height=s.height||0,s.width=s.width||0;var o=new e.Rect(i(n?e.util.object.clone(n):{},s));o.visible=o.visible&&o.width>0&&o.height>0,r(o)},e.Rect.fromObject=function(t,i){return e.Object._fromObject("Rect",t,i)})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,n=e.util.array.max,s=e.util.toFixed,o=e.util.projectStrokeOnPoints;e.Polyline?e.warn("fabric.Polyline is already defined"):(e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,exactBoundingBox:!1,cacheProperties:e.Object.prototype.cacheProperties.concat("points"),initialize:function(t,e){e=e||{},this.points=t||[],this.callSuper("initialize",e),this._setPositionDimensions(e)},_projectStrokeOnPoints:function(){return o(this.points,this,!0)},_setPositionDimensions:function(t){var e,i=this._calcDimensions(t),r=this.exactBoundingBox?this.strokeWidth:0;this.width=i.width-r,this.height=i.height-r,t.fromSVG||(e=this.translateToGivenOrigin({x:i.left-this.strokeWidth/2+r/2,y:i.top-this.strokeWidth/2+r/2},"left","top",this.originX,this.originY)),void 0===t.left&&(this.left=t.fromSVG?i.left:e.x),void 0===t.top&&(this.top=t.fromSVG?i.top:e.y),this.pathOffset={x:i.left+this.width/2+r/2,y:i.top+this.height/2+r/2}},_calcDimensions:function(){var t=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,e=r(t,"x")||0,i=r(t,"y")||0;return{left:e,top:i,width:(n(t,"x")||0)-e,height:(n(t,"y")||0)-i}},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},_toSVG:function(){for(var t=[],i=this.pathOffset.x,r=this.pathOffset.y,n=e.Object.NUM_FRACTION_DIGITS,o=0,a=this.points.length;o<a;o++)t.push(s(this.points[o].x-i,n),",",s(this.points[o].y-r,n)," ");return["<"+this.type+" ","COMMON_PARTS",'points="',t.join(""),'" />\n']},commonRender:function(t){var e,i=this.points.length,r=this.pathOffset.x,n=this.pathOffset.y;if(!i||isNaN(this.points[i-1].y))return!1;t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-n);for(var s=0;s<i;s++)e=this.points[s],t.lineTo(e.x-r,e.y-n);return!0},_render:function(t){this.commonRender(t)&&this._renderPaintInOrder(t)},complexity:function(){return this.get("points").length}}),e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polyline.fromElementGenerator=function(t){return function(r,n,s){if(!r)return n(null);s||(s={});var o=e.parsePointsAttribute(r.getAttribute("points")),a=e.parseAttributes(r,e[t].ATTRIBUTE_NAMES);a.fromSVG=!0,n(new e[t](o,i(a,s)))}},e.Polyline.fromElement=e.Polyline.fromElementGenerator("Polyline"),e.Polyline.fromObject=function(t,i){return e.Object._fromObject("Polyline",t,i,"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.projectStrokeOnPoints;e.Polygon?e.warn("fabric.Polygon is already defined"):(e.Polygon=e.util.createClass(e.Polyline,{type:"polygon",_projectStrokeOnPoints:function(){return i(this.points,this)},_render:function(t){this.commonRender(t)&&(t.closePath(),this._renderPaintInOrder(t))}}),e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(),e.Polygon.fromElement=e.Polyline.fromElementGenerator("Polygon"),e.Polygon.fromObject=function(t,i){e.Object._fromObject("Polygon",t,i,"points")})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.array.min,r=e.util.array.max,n=e.util.object.extend,s=e.util.object.clone,o=e.util.toFixed;e.Path?e.warn("fabric.Path is already defined"):(e.Path=e.util.createClass(e.Object,{type:"path",path:null,cacheProperties:e.Object.prototype.cacheProperties.concat("path","fillRule"),stateProperties:e.Object.prototype.stateProperties.concat("path"),initialize:function(t,e){delete(e=s(e||{})).path,this.callSuper("initialize",e),this._setPath(t||[],e)},_setPath:function(t,i){this.path=e.util.makePathSimpler(Array.isArray(t)?t:e.util.parsePath(t)),e.Polyline.prototype._setPositionDimensions.call(this,i||{})},_renderPathCommands:function(t){var e,i=0,r=0,n=0,s=0,o=0,a=0,h=-this.pathOffset.x,l=-this.pathOffset.y;t.beginPath();for(var c=0,u=this.path.length;c<u;++c)switch((e=this.path[c])[0]){case"L":n=e[1],s=e[2],t.lineTo(n+h,s+l);break;case"M":i=n=e[1],r=s=e[2],t.moveTo(n+h,s+l);break;case"C":n=e[5],s=e[6],o=e[3],a=e[4],t.bezierCurveTo(e[1]+h,e[2]+l,o+h,a+l,n+h,s+l);break;case"Q":t.quadraticCurveTo(e[1]+h,e[2]+l,e[3]+h,e[4]+l),n=e[3],s=e[4],o=e[1],a=e[2];break;case"z":case"Z":n=i,s=r,t.closePath()}},_render:function(t){this._renderPathCommands(t),this._renderPaintInOrder(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){return n(this.callSuper("toObject",t),{path:this.path.map((function(t){return t.slice()}))})},toDatalessObject:function(t){var e=this.toObject(["sourcePath"].concat(t));return e.sourcePath&&delete e.path,e},_toSVG:function(){return["<path ","COMMON_PARTS",'d="',e.util.joinPath(this.path),'" stroke-linecap="round" ',"/>\n"]},_getOffsetTransform:function(){var t=e.Object.NUM_FRACTION_DIGITS;return" translate("+o(-this.pathOffset.x,t)+", "+o(-this.pathOffset.y,t)+")"},toClipPathSVG:function(t){var e=this._getOffsetTransform();return"\t"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},toSVG:function(t){var e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var t,n,s=[],o=[],a=0,h=0,l=0,c=0,u=0,d=this.path.length;u<d;++u){switch((t=this.path[u])[0]){case"L":l=t[1],c=t[2],n=[];break;case"M":a=l=t[1],h=c=t[2],n=[];break;case"C":n=e.util.getBoundsOfCurve(l,c,t[1],t[2],t[3],t[4],t[5],t[6]),l=t[5],c=t[6];break;case"Q":n=e.util.getBoundsOfCurve(l,c,t[1],t[2],t[1],t[2],t[3],t[4]),l=t[3],c=t[4];break;case"z":case"Z":l=a,c=h}n.forEach((function(t){s.push(t.x),o.push(t.y)})),s.push(l),o.push(c)}var f=i(s)||0,g=i(o)||0;return{left:f,top:g,width:(r(s)||0)-f,height:(r(o)||0)-g}}}),e.Path.fromObject=function(t,i){if("string"==typeof t.sourcePath){var r=t.sourcePath;e.loadSVGFromURL(r,(function(e){var r=e[0];r.setOptions(t),i&&i(r)}))}else e.Object._fromObject("Path",t,i,"path")},e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]),e.Path.fromElement=function(t,i,r){var s=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);s.fromSVG=!0,i(new e.Path(s.d,n(s,r)))})}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.array.min,r=e.util.array.max;e.Group||(e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(t,e,i){e=e||{},this._objects=[],i&&this.callSuper("initialize",e),this._objects=t||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;if(i)this._updateObjectsACoords();else{var n=e&&e.centerPoint;void 0!==e.originX&&(this.originX=e.originX),void 0!==e.originY&&(this.originY=e.originY),n||this._calcBounds(),this._updateObjectsCoords(n),delete e.centerPoint,this.callSuper("initialize",e)}this.setCoords()},_updateObjectsACoords:function(){for(var t=this._objects.length;t--;)this._objects[t].setCoords(!0)},_updateObjectsCoords:function(t){t=t||this.getCenterPoint();for(var e=this._objects.length;e--;)this._updateObjectCoords(this._objects[e],t)},_updateObjectCoords:function(t,e){var i=t.left,r=t.top;t.set({left:i-e.x,top:r-e.y}),t.group=this,t.setCoords(!0)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){var i=!!this.group;return this._restoreObjectsState(),e.util.resetObjectTransform(this),t&&(i&&e.util.removeTransformFromObject(t,this.group.calcTransformMatrix()),this._objects.push(t),t.group=this,t._set("canvas",this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,i?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(t){return this._restoreObjectsState(),e.util.resetObjectTransform(this),this.remove(t),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(t){this.dirty=!0,t.group=this,t._set("canvas",this.canvas)},_onObjectRemoved:function(t){this.dirty=!0,delete t.group},_set:function(t,i){var r=this._objects.length;if(this.useSetOnGroup)for(;r--;)this._objects[r].setOnGroup(t,i);if("canvas"===t)for(;r--;)this._objects[r]._set(t,i);e.Object.prototype._set.call(this,t,i)},toObject:function(t){var i=this.includeDefaultValues,r=this._objects.filter((function(t){return!t.excludeFromExport})).map((function(e){var r=e.includeDefaultValues;e.includeDefaultValues=i;var n=e.toObject(t);return e.includeDefaultValues=r,n})),n=e.Object.prototype.toObject.call(this,t);return n.objects=r,n},toDatalessObject:function(t){var i,r=this.sourcePath;if(r)i=r;else{var n=this.includeDefaultValues;i=this._objects.map((function(e){var i=e.includeDefaultValues;e.includeDefaultValues=n;var r=e.toDatalessObject(t);return e.includeDefaultValues=i,r}))}var s=e.Object.prototype.toDatalessObject.call(this,t);return s.objects=i,s},render:function(t){this._transformDone=!0,this.callSuper("render",t),this._transformDone=!1},shouldCache:function(){var t=e.Object.prototype.shouldCache.call(this);if(t)for(var i=0,r=this._objects.length;i<r;i++)if(this._objects[i].willDrawShadow())return this.ownCaching=!1,!1;return t},willDrawShadow:function(){if(e.Object.prototype.willDrawShadow.call(this))return!0;for(var t=0,i=this._objects.length;t<i;t++)if(this._objects[t].willDrawShadow())return!0;return!1},isOnACache:function(){return this.ownCaching||this.group&&this.group.isOnACache()},drawObject:function(t){for(var e=0,i=this._objects.length;e<i;e++)this._objects[e].render(t);this._drawClipPath(t,this.clipPath)},isCacheDirty:function(t){if(this.callSuper("isCacheDirty",t))return!0;if(!this.statefullCache)return!1;for(var e=0,i=this._objects.length;e<i;e++)if(this._objects[e].isCacheDirty(!0)){if(this._cacheCanvas){var r=this.cacheWidth/this.zoomX,n=this.cacheHeight/this.zoomY;this._cacheContext.clearRect(-r/2,-n/2,r,n)}return!0}return!1},_restoreObjectsState:function(){var t=this.calcOwnMatrix();return this._objects.forEach((function(i){e.util.addTransformToObject(i,t),delete i.group,i.setCoords()})),this},destroy:function(){return this._objects.forEach((function(t){t.set("dirty",!0)})),this._restoreObjectsState()},dispose:function(){this.callSuper("dispose"),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[]},toActiveSelection:function(){if(this.canvas){var t=this._objects,i=this.canvas;this._objects=[];var r=this.toObject();delete r.objects;var n=new e.ActiveSelection([]);return n.set(r),n.type="activeSelection",i.remove(this),t.forEach((function(t){t.group=n,t.dirty=!0,i.add(t)})),n.canvas=i,n._objects=t,i._activeObject=n,n.setCoords(),n}},ungroupOnCanvas:function(){return this._restoreObjectsState()},setObjectsCoords:function(){return this.forEachObject((function(t){t.setCoords(!0)})),this},_calcBounds:function(t){for(var e,i,r,n,s=[],o=[],a=["tr","br","bl","tl"],h=0,l=this._objects.length,c=a.length;h<l;++h){for(r=(e=this._objects[h]).calcACoords(),n=0;n<c;n++)i=a[n],s.push(r[i].x),o.push(r[i].y);e.aCoords=r}this._getBounds(s,o,t)},_getBounds:function(t,n,s){var o=new e.Point(i(t),i(n)),a=new e.Point(r(t),r(n)),h=o.y||0,l=o.x||0,c=a.x-o.x||0,u=a.y-o.y||0;this.width=c,this.height=u,s||this.setPositionByOrigin({x:l,y:h},"left","top")},_toSVG:function(t){for(var e=["<g ","COMMON_PARTS"," >\n"],i=0,r=this._objects.length;i<r;i++)e.push("\t\t",this._objects[i].toSVG(t));return e.push("</g>\n"),e},getSvgStyles:function(){var t=void 0!==this.opacity&&1!==this.opacity?"opacity: "+this.opacity+";":"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")},toClipPathSVG:function(t){for(var e=[],i=0,r=this._objects.length;i<r;i++)e.push("\t",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}}),e.Group.fromObject=function(t,i){var r=t.objects,n=e.util.object.clone(t,!0);delete n.objects,"string"!=typeof r?e.util.enlivenObjects(r,(function(r){var n=e.util.object.clone(t,!0);delete n.objects,e.util.enlivenObjectEnlivables(t,n,(function(){i&&i(new e.Group(r,n,!0))}))})):e.loadSVGFromURL(r,(function(s){var o=e.util.groupSVGElements(s,t,r);o.set(n),i&&i(o)}))})}(e),function(t){var e=t.fabric||(t.fabric={});e.ActiveSelection||(e.ActiveSelection=e.util.createClass(e.Group,{type:"activeSelection",initialize:function(t,i){i=i||{},this._objects=t||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;i.originX&&(this.originX=i.originX),i.originY&&(this.originY=i.originY),this._calcBounds(),this._updateObjectsCoords(),e.Object.prototype.initialize.call(this,i),this.setCoords()},toGroup:function(){var t=this._objects.concat();this._objects=[];var i=e.Object.prototype.toObject.call(this),r=new e.Group([]);if(delete i.type,r.set(i),t.forEach((function(t){t.canvas.remove(t),t.group=r})),r._objects=t,!this.canvas)return r;var n=this.canvas;return n.add(r),n._activeObject=r,r.setCoords(),r},onDeselect:function(){return this.destroy(),!1},toString:function(){return"#<fabric.ActiveSelection: ("+this.complexity()+")>"},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,this.callSuper("_renderControls",t,e),void 0===(i=i||{}).hasControls&&(i.hasControls=!1),i.forActiveSelection=!0;for(var r=0,n=this._objects.length;r<n;r++)this._objects[r]._renderControls(t,i);t.restore()}}),e.ActiveSelection.fromObject=function(t,i){e.util.enlivenObjects(t.objects,(function(r){delete t.objects,i&&i(new e.ActiveSelection(r,t,!0))}))})}(e),function(t){var e=
vendor: 30,635 bytes, line 2
2E.util.object.extend;t.fabric||(t.fabric={}),t.fabric.Image?E.warn("fabric.Image is already defined."):(E.Image=E.util.createClass(E.Object,{type:"image",strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:E.Object.prototype.stateProperties.concat("cropX","cropY"),cacheProperties:E.Object.prototype.cacheProperties.concat("cropX","cropY"),cacheKey:"",cropX:0,cropY:0,imageSmoothing:!0,initialize:function(t,e){e||(e={}),this.filters=[],this.cacheKey="texture"+E.Object.__uid++,this.callSuper("initialize",e),this._initElement(t,e)},getElement:function(){return this._element||{}},setElement:function(t,e){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._element=t,this._originalElement=t,this._initConfig(e),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(t){var e=E.filterBackend;e&&e.evictCachesForKey&&e.evictCachesForKey(t)},dispose:function(){this.callSuper("dispose"),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+"_filtered"),this._cacheContext=void 0,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(function(t){E.util.cleanUpJsdomNode(this[t]),this[t]=void 0}.bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var t=this.getElement();return{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}},_stroke:function(t){if(this.stroke&&0!==this.strokeWidth){var e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}},toObject:function(t){var i=[];this.filters.forEach((function(t){t&&i.push(t.toObject())}));var r=e(this.callSuper("toObject",["cropX","cropY"].concat(t)),{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:i});return this.resizeFilter&&(r.resizeFilter=this.resizeFilter.toObject()),r},hasCrop:function(){return this.cropX||this.cropY||this.width<this._element.width||this.height<this._element.height},_toSVG:function(){var t,e=[],i=[],r=this._element,n=-this.width/2,s=-this.height/2,o="",a="";if(!r)return[];if(this.hasCrop()){var h=E.Object.__uid++;e.push('<clipPath id="imageCrop_'+h+'">\n','\t<rect x="'+n+'" y="'+s+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+h+')" '}if(this.imageSmoothing||(a='" image-rendering="optimizeSpeed'),i.push("\t<image ","COMMON_PARTS",'xlink:href="',this.getSvgSrc(!0),'" x="',n-this.cropX,'" y="',s-this.cropY,'" width="',r.width||r.naturalWidth,'" height="',r.height||r.height,a,'"',o,"></image>\n"),this.stroke||this.strokeDashArray){var l=this.fill;this.fill=null,t=["\t<rect ",'x="',n,'" y="',s,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n'],this.fill=l}return"fill"!==this.paintFirst?e.concat(t,i):e.concat(i,t)},getSrc:function(t){var e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src"):e.src:this.src||""},setSrc:function(t,e,i){return E.util.loadImage(t,(function(t,r){this.setElement(t,i),this._setWidthHeight(),e&&e(this,r)}),this,i&&i.crossOrigin),this},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},applyResizeFilters:function(){var t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),r=i.scaleX,n=i.scaleY,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||r>e&&n>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=n);E.filterBackend||(E.filterBackend=E.initFilterBackend());var o=E.util.createCanvasElement(),a=this._filteredEl?this.cacheKey+"_filtered":this.cacheKey,h=s.width,l=s.height;o.width=h,o.height=l,this._element=o,this._lastScaleX=t.scaleX=r,this._lastScaleY=t.scaleY=n,E.filterBackend.applyFilters([t],s,h,l,this._element,a),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height},applyFilters:function(t){if(t=(t=t||this.filters||[]).filter((function(t){return t&&!t.isNeutralState()})),this.set("dirty",!0),this.removeTexture(this.cacheKey+"_filtered"),0===t.length)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var e=this._originalElement,i=e.naturalWidth||e.width,r=e.naturalHeight||e.height;if(this._element===this._originalElement){var n=E.util.createCanvasElement();n.width=i,n.height=r,this._element=n,this._filteredEl=n}else this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,r),this._lastScaleX=1,this._lastScaleY=1;return E.filterBackend||(E.filterBackend=E.initFilterBackend()),E.filterBackend.applyFilters(t,this._originalElement,i,r,this._element,this.cacheKey),this._originalElement.width===this._element.width&&this._originalElement.height===this._element.height||(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(t){E.util.setImageSmoothing(t,this.imageSmoothing),!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)},drawCacheOnCanvas:function(t){E.util.setImageSmoothing(t,this.imageSmoothing),E.Object.prototype.drawCacheOnCanvas.call(this,t)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(t){var e=this._element;if(e){var i=this._filterScalingX,r=this._filterScalingY,n=this.width,s=this.height,o=Math.min,a=Math.max,h=a(this.cropX,0),l=a(this.cropY,0),c=e.naturalWidth||e.width,u=e.naturalHeight||e.height,d=h*i,f=l*r,g=o(n*i,c-d),_=o(s*r,u-f),p=-n/2,m=-s/2,v=o(n,c/i-h),y=o(s,u/r-l);e&&t.drawImage(e,d,f,g,_,p,m,v,y)}},_needsResize:function(){var t=this.getTotalObjectScaling();return t.scaleX!==this._lastScaleX||t.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(t,e){this.setElement(E.util.getById(t),e),E.util.addClass(this.getElement(),E.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={}),this.setOptions(t),this._setWidthHeight(t)},_initFilters:function(t,e){t&&t.length?E.util.enlivenObjects(t,(function(t){e&&e(t)}),"fabric.Image.filters"):e&&e()},_setWidthHeight:function(t){t||(t={});var e=this.getElement();this.width=t.width||e.naturalWidth||e.width||0,this.height=t.height||e.naturalHeight||e.height||0},parsePreserveAspectRatioAttribute:function(){var t,e=E.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||""),i=this._element.width,r=this._element.height,n=1,s=1,o=0,a=0,h=0,l=0,c=this.width,u=this.height,d={width:c,height:u};return!e||"none"===e.alignX&&"none"===e.alignY?(n=c/i,s=u/r):("meet"===e.meetOrSlice&&(t=(c-i*(n=s=E.util.findScaleToFit(this._element,d)))/2,"Min"===e.alignX&&(o=-t),"Max"===e.alignX&&(o=t),t=(u-r*s)/2,"Min"===e.alignY&&(a=-t),"Max"===e.alignY&&(a=t)),"slice"===e.meetOrSlice&&(t=i-c/(n=s=E.util.findScaleToCover(this._element,d)),"Mid"===e.alignX&&(h=t/2),"Max"===e.alignX&&(h=t),t=r-u/s,"Mid"===e.alignY&&(l=t/2),"Max"===e.alignY&&(l=t),i=c/n,r=u/s)),{width:i,height:r,scaleX:n,scaleY:s,offsetLeft:o,offsetTop:a,cropX:h,cropY:l}}}),E.Image.CSS_CANVAS="canvas-img",E.Image.prototype.getSvgSrc=E.Image.prototype.getSrc,E.Image.fromObject=function(t,e){var i=E.util.object.clone(t);E.util.loadImage(i.src,(function(t,r){r?e&&e(null,!0):E.Image.prototype._initFilters.call(i,i.filters,(function(r){i.filters=r||[],E.Image.prototype._initFilters.call(i,[i.resizeFilter],(function(r){i.resizeFilter=r[0],E.util.enlivenObjectEnlivables(i,i,(function(){var r=new E.Image(t,i);e(r,!1)}))}))}))}),null,i.crossOrigin)},E.Image.fromURL=function(t,e,i){E.util.loadImage(t,(function(t,r){e&&e(new E.Image(t,i),r)}),null,i&&i.crossOrigin)},E.Image.ATTRIBUTE_NAMES=E.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href crossOrigin image-rendering".split(" ")),E.Image.fromElement=function(t,i,r){var n=E.parseAttributes(t,E.Image.ATTRIBUTE_NAMES);E.Image.fromURL(n["xlink:href"],i,e(r?E.util.object.clone(r):{},n))})}(e),E.util.object.extend(E.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.angle%360;return t>0?90*Math.round((t-1)/90):90*Math.round(t/90)},straighten:function(){return this.rotate(this._getAngleValueForStraighten())},fxStraighten:function(t){var e=function(){},i=(t=t||{}).onComplete||e,r=t.onChange||e,n=this;return E.util.animate({target:this,startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){n.rotate(t),r()},onComplete:function(){n.setCoords(),i()}})}}),E.util.object.extend(E.StaticCanvas.prototype,{straightenObject:function(t){return t.straighten(),this.requestRenderAll(),this},fxStraightenObject:function(t){return t.fxStraighten({onChange:this.requestRenderAllBound})}}),function(){function t(t,e){var i="precision "+e+" float;\nvoid main(){}",r=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(r,i),t.compileShader(r),!!t.getShaderParameter(r,t.COMPILE_STATUS)}function e(t){t&&t.tileSize&&(this.tileSize=t.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}E.isWebglSupported=function(e){if(E.isLikelyNode)return!1;e=e||E.WebglFilterBackend.prototype.tileSize;var i=document.createElement("canvas"),r=i.getContext("webgl")||i.getContext("experimental-webgl"),n=!1;if(r){E.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE),n=E.maxTextureSize>=e;for(var s=["highp","mediump","lowp"],o=0;o<3;o++)if(t(r,s[o])){E.webGlPrecision=s[o];break}}return this.isSupported=n,n},E.WebglFilterBackend=e,e.prototype={tileSize:2048,resources:{},setupGLContext:function(t,e){this.dispose(),this.createWebGLCanvas(t,e),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(t,e)},chooseFastestCopyGLTo2DMethod:function(t,e){var i,r=void 0!==window.performance;try{new ImageData(1,1),i=!0}catch(t){i=!1}var n="undefined"!=typeof ArrayBuffer,s="undefined"!=typeof Uint8ClampedArray;if(r&&i&&n&&s){var o=E.util.createCanvasElement(),a=new ArrayBuffer(t*e*4);if(E.forceGLPutImageData)return this.imageBuffer=a,void(this.copyGLTo2D=R);var h,l,c={imageBuffer:a,destinationWidth:t,destinationHeight:e,targetCanvas:o};o.width=t,o.height=e,h=window.performance.now(),O.call(c,this.gl,c),l=window.performance.now()-h,h=window.performance.now(),R.call(c,this.gl,c),l>window.performance.now()-h?(this.imageBuffer=a,this.copyGLTo2D=R):this.copyGLTo2D=O}},createWebGLCanvas:function(t,e){var i=E.util.createCanvasElement();i.width=t,i.height=e;var r={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},n=i.getContext("webgl",r);n||(n=i.getContext("experimental-webgl",r)),n&&(n.clearColor(0,0,0,0),this.canvas=i,this.gl=n)},applyFilters:function(t,e,i,r,n,s){var o,a=this.gl;s&&(o=this.getCachedTexture(s,e));var h={originalWidth:e.width||e.originalWidth,originalHeight:e.height||e.originalHeight,sourceWidth:i,sourceHeight:r,destinationWidth:i,destinationHeight:r,context:a,sourceTexture:this.createTexture(a,i,r,!o&&e),targetTexture:this.createTexture(a,i,r),originalTexture:o||this.createTexture(a,i,r,!o&&e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},l=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,l),t.forEach((function(t){t&&t.applyTo(h)})),function(t){var e=t.targetCanvas,i=e.width,r=e.height,n=t.destinationWidth,s=t.destinationHeight;i===n&&r===s||(e.width=n,e.height=s)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(l),n.getContext("2d").setTransform(1,0,0,1,0,0),h},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(t,e,i,r){var n=t.createTexture();return t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),r?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),n},getCachedTexture:function(t,e){if(this.textureCache[t])return this.textureCache[t];var i=this.createTexture(this.gl,e.width,e.height,e);return this.textureCache[t]=i,i},evictCachesForKey:function(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])},copyGLTo2D:O,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var t=this.gl,e={renderer:"",vendor:""};if(!t)return e;var i=t.getExtension("WEBGL_debug_renderer_info");if(i){var r=t.getParameter(i.UNMASKED_RENDERER_WEBGL),n=t.getParameter(i.UNMASKED_VENDOR_WEBGL);r&&(e.renderer=r.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}}(),function(){var t=function(){};function e(){}E.Canvas2dFilterBackend=e,e.prototype={evictCachesForKey:t,dispose:t,clearWebGLCaches:t,resources:{},applyFilters:function(t,e,i,r,n){var s=n.getContext("2d");s.drawImage(e,0,0,i,r);var o={sourceWidth:i,sourceHeight:r,imageData:s.getImageData(0,0,i,r),originalEl:e,originalImageData:s.getImageData(0,0,i,r),canvasEl:n,ctx:s,filterBackend:this};return t.forEach((function(t){t.applyTo(o)})),o.imageData.width===i&&o.imageData.height===r||(n.width=o.imageData.width,n.height=o.imageData.height),s.putImageData(o.imageData,0,0),o}}}(),E.Image=E.Image||{},E.Image.filters=E.Image.filters||{},E.Image.filters.BaseFilter=E.util.createClass({type:"BaseFilter",vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvoid main() {\nvTexCoord = aPosition;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\n}",initialize:function(t){t&&this.setOptions(t)},setOptions:function(t){for(var e in t)this[e]=t[e]},createProgram:function(t,e,i){e=e||this.fragmentSource,i=i||this.vertexSource,"highp"!==E.webGlPrecision&&(e=e.replace(/precision highp float/g,"precision "+E.webGlPrecision+" float"));var r=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Vertex shader compile error for "+this.type+": "+t.getShaderInfoLog(r));var n=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error("Fragment shader compile error for "+this.type+": "+t.getShaderInfoLog(n));var s=t.createProgram();if(t.attachShader(s,r),t.attachShader(s,n),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))throw new Error('Shader link error for "${this.type}" '+t.getProgramInfoLog(s));var o=this.getAttributeLocations(t,s),a=this.getUniformLocations(t,s)||{};return a.uStepW=t.getUniformLocation(s,"uStepW"),a.uStepH=t.getUniformLocation(s,"uStepH"),{program:s,attributeLocations:o,uniformLocations:a}},getAttributeLocations:function(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}},getUniformLocations:function(){return{}},sendAttributeData:function(t,e,i){var r=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)},_setupFrameBuffer:function(t){var e,i,r=t.context;t.passes>1?(e=t.destinationWidth,i=t.destinationHeight,t.sourceWidth===e&&t.sourceHeight===i||(r.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(r,e,i)),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t.targetTexture,0)):(r.bindFramebuffer(r.FRAMEBUFFER,null),r.finish())},_swapTextures:function(t){t.passes--,t.pass++;var e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e},isNeutralState:function(){var t=this.mainParameter,e=E.Image.filters[this.type].prototype;if(t){if(Array.isArray(e[t])){for(var i=e[t].length;i--;)if(this[t][i]!==e[t][i])return!1;return!0}return e[t]===this[t]}return!1},applyTo:function(t){t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},retrieveShader:function(t){return t.programCache.hasOwnProperty(this.type)||(t.programCache[this.type]=this.createProgram(t.context)),t.programCache[this.type]},applyToWebGL:function(t){var e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)},unbindAdditionalTexture:function(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(t){this[this.mainParameter]=t},sendUniformData:function(){},createHelpLayer:function(t){if(!t.helpLayer){var e=document.createElement("canvas");e.width=t.sourceWidth,e.height=t.sourceHeight,t.helpLayer=e}},toObject:function(){var t={type:this.type},e=this.mainParameter;return e&&(t[e]=this[e]),t},toJSON:function(){return this.toObject()}}),E.Image.filters.BaseFilter.fromObject=function(t,e){var i=new E.Image.filters[t.type](t);return e&&e(i),i},function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.ColorMatrix=r(i.BaseFilter,{type:"ColorMatrix",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nuniform mat4 uColorMatrix;\nuniform vec4 uConstants;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor *= uColorMatrix;\ncolor += uConstants;\ngl_FragColor = color;\n}",matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:"matrix",colorsOnly:!0,initialize:function(t){this.callSuper("initialize",t),this.matrix=this.matrix.slice(0)},applyTo2d:function(t){var e,i,r,n,s,o=t.imageData.data,a=o.length,h=this.matrix,l=this.colorsOnly;for(s=0;s<a;s+=4)e=o[s],i=o[s+1],r=o[s+2],l?(o[s]=e*h[0]+i*h[1]+r*h[2]+255*h[4],o[s+1]=e*h[5]+i*h[6]+r*h[7]+255*h[9],o[s+2]=e*h[10]+i*h[11]+r*h[12]+255*h[14]):(n=o[s+3],o[s]=e*h[0]+i*h[1]+r*h[2]+n*h[3]+255*h[4],o[s+1]=e*h[5]+i*h[6]+r*h[7]+n*h[8]+255*h[9],o[s+2]=e*h[10]+i*h[11]+r*h[12]+n*h[13]+255*h[14],o[s+3]=e*h[15]+i*h[16]+r*h[17]+n*h[18]+255*h[19])},getUniformLocations:function(t,e){return{uColorMatrix:t.getUniformLocation(e,"uColorMatrix"),uConstants:t.getUniformLocation(e,"uConstants")}},sendUniformData:function(t,e){var i=this.matrix,r=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],n=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,r),t.uniform4fv(e.uConstants,n)}}),e.Image.filters.ColorMatrix.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Brightness=r(i.BaseFilter,{type:"Brightness",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBrightness;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += uBrightness;\ngl_FragColor = color;\n}",brightness:0,mainParameter:"brightness",applyTo2d:function(t){if(0!==this.brightness){var e,i=t.imageData.data,r=i.length,n=Math.round(255*this.brightness);for(e=0;e<r;e+=4)i[e]=i[e]+n,i[e+1]=i[e+1]+n,i[e+2]=i[e+2]+n}},getUniformLocations:function(t,e){return{uBrightness:t.getUniformLocation(e,"uBrightness")}},sendUniformData:function(t,e){t.uniform1f(e.uBrightness,this.brightness)}}),e.Image.filters.Brightness.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Convolute=n(r.BaseFilter,{type:"Convolute",opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_3_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[9];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 3.0; h+=1.0) {\nfor (float w = 0.0; w < 3.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_5_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_5_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[25];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 5.0; h+=1.0) {\nfor (float w = 0.0; w < 5.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_7_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_7_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[49];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 7.0; h+=1.0) {\nfor (float w = 0.0; w < 7.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}",Convolute_9_1:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 0);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n}\n}\ngl_FragColor = color;\n}",Convolute_9_0:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uMatrix[81];\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = vec4(0, 0, 0, 1);\nfor (float h = 0.0; h < 9.0; h+=1.0) {\nfor (float w = 0.0; w < 9.0; w+=1.0) {\nvec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\ncolor.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n}\n}\nfloat alpha = texture2D(uTexture, vTexCoord).a;\ngl_FragColor = color;\ngl_FragColor.a = alpha;\n}"},retrieveShader:function(t){var e=Math.sqrt(this.matrix.length),i=this.type+"_"+e+"_"+(this.opaque?1:0),r=this.fragmentSource[i];return t.programCache.hasOwnProperty(i)||(t.programCache[i]=this.createProgram(t.context,r)),t.programCache[i]},applyTo2d:function(t){var e,i,r,n,s,o,a,h,l,c,u,d,f,g=t.imageData,_=g.data,p=this.matrix,m=Math.round(Math.sqrt(p.length)),v=Math.floor(m/2),y=g.width,S=g.height,C=t.ctx.createImageData(y,S),w=C.data,b=this.opaque?1:0;for(u=0;u<S;u++)for(c=0;c<y;c++){for(s=4*(u*y+c),e=0,i=0,r=0,n=0,f=0;f<m;f++)for(d=0;d<m;d++)o=c+d-v,(a=u+f-v)<0||a>=S||o<0||o>=y||(h=4*(a*y+o),l=p[f*m+d],e+=_[h]*l,i+=_[h+1]*l,r+=_[h+2]*l,b||(n+=_[h+3]*l));w[s]=e,w[s+1]=i,w[s+2]=r,w[s+3]=b?_[s+3]:n}t.imageData=C},getUniformLocations:function(t,e){return{uMatrix:t.getUniformLocation(e,"uMatrix"),uOpaque:t.getUniformLocation(e,"uOpaque"),uHalfSize:t.getUniformLocation(e,"uHalfSize"),uSize:t.getUniformLocation(e,"uSize")}},sendUniformData:function(t,e){t.uniform1fv(e.uMatrix,this.matrix)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}}),e.Image.filters.Convolute.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Grayscale=r(i.BaseFilter,{type:"Grayscale",fragmentSource:{average:"precision highp float;\nuniform sampler2D uTexture;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat average = (color.r + color.b + color.g) / 3.0;\ngl_FragColor = vec4(average, average, average, color.a);\n}",lightness:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\ngl_FragColor = vec4(average, average, average, col.a);\n}",luminosity:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uMode;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 col = texture2D(uTexture, vTexCoord);\nfloat average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\ngl_FragColor = vec4(average, average, average, col.a);\n}"},mode:"average",mainParameter:"mode",applyTo2d:function(t){var e,i,r=t.imageData.data,n=r.length,s=this.mode;for(e=0;e<n;e+=4)"average"===s?i=(r[e]+r[e+1]+r[e+2])/3:"lightness"===s?i=(Math.min(r[e],r[e+1],r[e+2])+Math.max(r[e],r[e+1],r[e+2]))/2:"luminosity"===s&&(i=.21*r[e]+.72*r[e+1]+.07*r[e+2]),r[e]=i,r[e+1]=i,r[e+2]=i},retrieveShader:function(t){var e=this.type+"_"+this.mode;if(!t.programCache.hasOwnProperty(e)){var i=this.fragmentSource[this.mode];t.programCache[e]=this.createProgram(t.context,i)}return t.programCache[e]},getUniformLocations:function(t,e){return{uMode:t.getUniformLocation(e,"uMode")}},sendUniformData:function(t,e){t.uniform1i(e.uMode,1)},isNeutralState:function(){return!1}}),e.Image.filters.Grayscale.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Invert=r(i.BaseFilter,{type:"Invert",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform int uInvert;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nif (uInvert == 1) {\ngl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n} else {\ngl_FragColor = color;\n}\n}",invert:!0,mainParameter:"invert",applyTo2d:function(t){var e,i=t.imageData.data,r=i.length;for(e=0;e<r;e+=4)i[e]=255-i[e],i[e+1]=255-i[e+1],i[e+2]=255-i[e+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(t,e){return{uInvert:t.getUniformLocation(e,"uInvert")}},sendUniformData:function(t,e){t.uniform1i(e.uInvert,this.invert)}}),e.Image.filters.Invert.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.Noise=n(r.BaseFilter,{type:"Noise",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uStepH;\nuniform float uNoise;\nuniform float uSeed;\nvarying vec2 vTexCoord;\nfloat rand(vec2 co, float seed, float vScale) {\nreturn fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n}\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ncolor.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\ngl_FragColor = color;\n}",mainParameter:"noise",noise:0,applyTo2d:function(t){if(0!==this.noise){var e,i,r=t.imageData.data,n=r.length,s=this.noise;for(e=0,n=r.length;e<n;e+=4)i=(.5-Math.random())*s,r[e]+=i,r[e+1]+=i,r[e+2]+=i}},getUniformLocations:function(t,e){return{uNoise:t.getUniformLocation(e,"uNoise"),uSeed:t.getUniformLocation(e,"uSeed")}},sendUniformData:function(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}}),e.Image.filters.Noise.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Pixelate=r(i.BaseFilter,{type:"Pixelate",blocksize:4,mainParameter:"blocksize",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uBlocksize;\nuniform float uStepW;\nuniform float uStepH;\nvarying vec2 vTexCoord;\nvoid main() {\nfloat blockW = uBlocksize * uStepW;\nfloat blockH = uBlocksize * uStepW;\nint posX = int(vTexCoord.x / blockW);\nint posY = int(vTexCoord.y / blockH);\nfloat fposX = float(posX);\nfloat fposY = float(posY);\nvec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\nvec4 color = texture2D(uTexture, squareCoords);\ngl_FragColor = color;\n}",applyTo2d:function(t){var e,i,r,n,s,o,a,h,l,c,u,d=t.imageData,f=d.data,g=d.height,_=d.width;for(i=0;i<g;i+=this.blocksize)for(r=0;r<_;r+=this.blocksize)for(n=f[e=4*i*_+4*r],s=f[e+1],o=f[e+2],a=f[e+3],c=Math.min(i+this.blocksize,g),u=Math.min(r+this.blocksize,_),h=i;h<c;h++)for(l=r;l<u;l++)f[e=4*h*_
vendor: 7,660 bytes, line 2
2+4*l]=n,f[e+1]=s,f[e+2]=o,f[e+3]=a},isNeutralState:function(){return 1===this.blocksize},getUniformLocations:function(t,e){return{uBlocksize:t.getUniformLocation(e,"uBlocksize"),uStepW:t.getUniformLocation(e,"uStepW"),uStepH:t.getUniformLocation(e,"uStepH")}},sendUniformData:function(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}),e.Image.filters.Pixelate.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.Image.filters,n=e.util.createClass;r.RemoveColor=n(r.BaseFilter,{type:"RemoveColor",color:"#FFFFFF",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\ngl_FragColor = texture2D(uTexture, vTexCoord);\nif(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\ngl_FragColor.a = 0.0;\n}\n}",distance:.02,useAlpha:!1,applyTo2d:function(t){var i,r,n,s,o=t.imageData.data,a=255*this.distance,h=new e.Color(this.color).getSource(),l=[h[0]-a,h[1]-a,h[2]-a],c=[h[0]+a,h[1]+a,h[2]+a];for(i=0;i<o.length;i+=4)r=o[i],n=o[i+1],s=o[i+2],r>l[0]&&n>l[1]&&s>l[2]&&r<c[0]&&n<c[1]&&s<c[2]&&(o[i+3]=0)},getUniformLocations:function(t,e){return{uLow:t.getUniformLocation(e,"uLow"),uHigh:t.getUniformLocation(e,"uHigh")}},sendUniformData:function(t,i){var r=new e.Color(this.color).getSource(),n=parseFloat(this.distance),s=[0+r[0]/255-n,0+r[1]/255-n,0+r[2]/255-n,1],o=[r[0]/255+n,r[1]/255+n,r[2]/255+n,1];t.uniform4fv(i.uLow,s),t.uniform4fv(i.uHigh,o)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,distance:this.distance})}}),e.Image.filters.RemoveColor.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass,n={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var s in n)i[s]=r(i.ColorMatrix,{type:s,matrix:n[s],mainParameter:!1,colorsOnly:!0}),e.Image.filters[s].fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric,i=e.Image.filters,r=e.util.createClass;i.BlendColor=r(i.BaseFilter,{type:"BlendColor",color:"#F95C63",mode:"multiply",alpha:1,fragmentSource:{multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",diff:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"if (uColor.r < 0.5) {\ngl_FragColor.r *= 2.0 * uColor.r;\n} else {\ngl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n}\nif (uColor.g < 0.5) {\ngl_FragColor.g *= 2.0 * uColor.g;\n} else {\ngl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n}\nif (uColor.b < 0.5) {\ngl_FragColor.b *= 2.0 * uColor.b;\n} else {\ngl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n}\n",tint:"gl_FragColor.rgb *= (1.0 - uColor.a);\ngl_FragColor.rgb += uColor.rgb;\n"},buildSource:function(t){return"precision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\ngl_FragColor = color;\nif (color.a > 0.0) {\n"+this.fragmentSource[t]+"}\n}"},retrieveShader:function(t){var e,i=this.type+"_"+this.mode;return t.programCache.hasOwnProperty(i)||(e=this.buildSource(this.mode),t.programCache[i]=this.createProgram(t.context,e)),t.programCache[i]},applyTo2d:function(t){var i,r,n,s,o,a,h,l=t.imageData.data,c=l.length,u=1-this.alpha;i=(h=new e.Color(this.color).getSource())[0]*this.alpha,r=h[1]*this.alpha,n=h[2]*this.alpha;for(var d=0;d<c;d+=4)switch(s=l[d],o=l[d+1],a=l[d+2],this.mode){case"multiply":l[d]=s*i/255,l[d+1]=o*r/255,l[d+2]=a*n/255;break;case"screen":l[d]=255-(255-s)*(255-i)/255,l[d+1]=255-(255-o)*(255-r)/255,l[d+2]=255-(255-a)*(255-n)/255;break;case"add":l[d]=s+i,l[d+1]=o+r,l[d+2]=a+n;break;case"diff":case"difference":l[d]=Math.abs(s-i),l[d+1]=Math.abs(o-r),l[d+2]=Math.abs(a-n);break;case"subtract":l[d]=s-i,l[d+1]=o-r,l[d+2]=a-n;break;case"darken":l[d]=Math.min(s,i),l[d+1]=Math.min(o,r),l[d+2]=Math.min(a,n);break;case"lighten":l[d]=Math.max(s,i),l[d+1]=Math.max(o,r),l[d+2]=Math.max(a,n);break;case"overlay":l[d]=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,l[d+1]=r<128?2*o*r/255:255-2*(255-o)*(255-r)/255,l[d+2]=n<128?2*a*n/255:255-2*(255-a)*(255-n)/255;break;case"exclusion":l[d]=i+s-2*i*s/255,l[d+1]=r+o-2*r*o/255,l[d+2]=n+a-2*n*a/255;break;case"tint":l[d]=i+s*u,l[d+1]=r+o*u,l[d+2]=n+a*u}},getUniformLocations:function(t,e){return{uColor:t.getUniformLocation(e,"uColor")}},sendUniformData:function(t,i){var r=new e.Color(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(i.uColor,r)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendColor.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric,i=e.Image.filters,r=e.util.createClass;i.BlendImage=r(i.BaseFilter,{type:"BlendImage",image:null,mode:"multiply",alpha:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:{multiply:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.rgba *= color2.rgba;\ngl_FragColor = color;\n}",mask:"precision highp float;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform vec4 uColor;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec4 color2 = texture2D(uImage, vTexCoord2);\ncolor.a = color2.a;\ngl_FragColor = color;\n}"},retrieveShader:function(t){var e=this.type+"_"+this.mode,i=this.fragmentSource[this.mode];return t.programCache.hasOwnProperty(e)||(t.programCache[e]=this.createProgram(t.context,i)),t.programCache[e]},applyToWebGL:function(t){var e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),this.callSuper("applyToWebGL",t),this.unbindAdditionalTexture(e,e.TEXTURE1)},createTexture:function(t,e){return t.getCachedTexture(e.cacheKey,e._element)},calculateMatrix:function(){var t=this.image,e=t._element.width,i=t._element.height;return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]},applyTo2d:function(t){var i,r,n,s,o,a,h,l,c,u,d,f=t.imageData,g=t.filterBackend.resources,
vendor: 6,122 bytes, line 2
2_=f.data,p=_.length,m=f.width,v=f.height,y=this.image;g.blendImage||(g.blendImage=e.util.createCanvasElement()),u=(c=g.blendImage).getContext("2d"),c.width!==m||c.height!==v?(c.width=m,c.height=v):u.clearRect(0,0,m,v),u.setTransform(y.scaleX,0,0,y.scaleY,y.left,y.top),u.drawImage(y._element,0,0,m,v),d=u.getImageData(0,0,m,v).data;for(var S=0;S<p;S+=4)switch(o=_[S],a=_[S+1],h=_[S+2],l=_[S+3],i=d[S],r=d[S+1],n=d[S+2],s=d[S+3],this.mode){case"multiply":_[S]=o*i/255,_[S+1]=a*r/255,_[S+2]=h*n/255,_[S+3]=l*s/255;break;case"mask":_[S+3]=s}},getUniformLocations:function(t,e){return{uTransformMatrix:t.getUniformLocation(e,"uTransformMatrix"),uImage:t.getUniformLocation(e,"uImage")}},sendUniformData:function(t,e){var i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),e.Image.filters.BlendImage.fromObject=function(t,i){e.Image.fromObject(t.image,(function(r){var n=e.util.object.clone(t);n.image=r,i(new e.Image.filters.BlendImage(n))}))}}(e),function(t){var e=t.fabric||(t.fabric={}),i=Math.pow,r=Math.floor,n=Math.sqrt,s=Math.abs,o=Math.round,a=Math.sin,h=Math.ceil,l=e.Image.filters,c=e.util.createClass;l.Resize=c(l.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(t,e){return{uDelta:t.getUniformLocation(e,"uDelta"),uTaps:t.getUniformLocation(e,"uTaps")}},sendUniformData:function(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)},retrieveShader:function(t){var e=this.getFilterWindow(),i=this.type+"_"+e;if(!t.programCache.hasOwnProperty(i)){var r=this.generateShader(e);t.programCache[i]=this.createProgram(t.context,r)}return t.programCache[i]},getFilterWindow:function(){var t=this.tempScale;return Math.ceil(this.lanczosLobes/t)},getTaps:function(){for(var t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),r=new Array(i),n=1;n<=i;n++)r[n-1]=t(n*e);return r},generateShader:function(t){for(var e=new Array(t),i=this.fragmentSourceTOP,r=1;r<=t;r++)e[r-1]=r+".0 * uDelta";return i+="uniform float uTaps["+t+"];\n",i+="void main() {\n",i+="  vec4 color = texture2D(uTexture, vTexCoord);\n",i+="  float sum = 1.0;\n",e.forEach((function(t,e){i+="  color += texture2D(uTexture, vTexCoord + "+t+") * uTaps["+e+"];\n",i+="  color += texture2D(uTexture, vTexCoord - "+t+") * uTaps["+e+"];\n",i+="  sum += 2.0 * uTaps["+e+"];\n"})),i+="  gl_FragColor = color / sum;\n",i+="}"},fragmentSourceTOP:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\n",applyTo:function(t){t.webgl?(t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t),t.sourceHeight=t.destinationHeight):this.applyTo2d(t)},isNeutralState:function(){return 1===this.scaleX&&1===this.scaleY},lanczosCreate:function(t){return function(e){if(e>=t||e<=-t)return 0;if(e<1.1920929e-7&&e>-1.1920929e-7)return 1;var i=(e*=Math.PI)/t;return a(e)/e*a(i)/i}},applyTo2d:function(t){var e=t.imageData,i=this.scaleX,r=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/r;var n,s=e.width,a=e.height,h=o(s*i),l=o(a*r);"sliceHack"===this.resizeType?n=this.sliceByTwo(t,s,a,h,l):"hermite"===this.resizeType?n=this.hermiteFastResize(t,s,a,h,l):"bilinear"===this.resizeType?n=this.bilinearFiltering(t,s,a,h,l):"lanczos"===this.resizeType&&(n=this.lanczosResize(t,s,a,h,l)),t.imageData=n},sliceByTwo:function(t,i,n,s,o){var a,h,l=t.imageData,c=.5,u=!1,d=!1,f=i*c,g=n*c,_=e.filterBackend.resources,p=0,m=0,v=i,y=0;for(_.sliceByTwo||(_.sliceByTwo=document.createElement("canvas")),((a=_.sliceByTwo).width<1.5*i||a.height<n)&&(a.width=1.5*i,a.height=n),(h=a.getContext("2d")).clearRect(0,0,1.5*i,n),h.putImageData(l,0,0),s=r(s),o=r(o);!u||!d;)i=f,n=g,s<r(f*c)?f=r(f*c):(f=s,u=!0),o<r(g*c)?g=r(g*c):(g=o,d=!0),h.drawImage(a,p,m,i,n,v,y,f,g),p=v,m=y,y+=g;return h.getImageData(p,m,s,o)},lanczosResize:function(t,e,o,a,l){var c=t.imageData.data,u=t.ctx.createImageData(a,l),d=u.data,f=this.lanczosCreate(this.lanczosLobes),g=this.rcpScaleX,_=this.rcpScaleY,p=2/this.rcpScaleX,m=2/this.rcpScaleY,v=h(g*this.lanczosLobes/2),y=h(_*this.lanczosLobes/2),S={},C={},w={};return function t(h){var b,x,T,E,I,O,R,D,A,M,L;for(C.x=(h+.5)*g,w.x=r(C.x),b=0;b<l;b++){for(C.y=(b+.5)*_,w.y=r(C.y),I=0,O=0,R=0,D=0,A=0,x=w.x-v;x<=w.x+v;x++)if(!(x<0||x>=e)){M=r(1e3*s(x-C.x)),S[M]||(S[M]={});for(var F=w.y-y;F<=w.y+y;F++)F<0||F>=o||(L=r(1e3*s(F-C.y)),S[M][L]||(S[M][L]=f(n(i(M*p,2)+i(L*m,2))/1e3)),(T=S[M][L])>0&&(I+=T,O+=T*c[E=4*(F*e+x)],R+=T*c[E+1],D+=T*c[E+2],A+=T*c[E+3]))}d[E=4*(b*a+h)]=O/I,d[E+1]=R/I,d[E+2]=D/I,d[E+3]=A/I}return++h<a?t(h):u}(0)},bilinearFiltering:function(t,e,i,n,s){var o,a,h,l,c,u,d,f,g,_=0,p=this.rcpScaleX,m=this.rcpScaleY,v=4*(e-1),y=t.imageData.data,S=t.ctx.createImageData(n,s),C=S.data;for(h=0;h<s;h++)for(l=0;l<n;l++)for(c=p*l-(o=r(p*l)),u=m*h-(a=r(m*h)),g=4*(a*e+o),d=0;d<4;d++)f=y[g+d]*(1-c)*(1-u)+y[g+4+d]*c*(1-u)+y[g+v+d]*u*(1-c)+y[g+v+4+d]*c*u,C[_++]=f;return S},hermiteFastResize:function(t,e,i,o,a){for(var l=this.rcpScaleX,c=this.rcpScaleY,u=h(l/2),d=h(c/2),f=t.imageData.data,g=t.ctx.createImageData(o,a),_=g.data,p=0;p<a;p++)for(var m=0;m<o;m++){for(var v=4*(m+p*o),y=0,S=0,C=0,w=0,b=0,x=0,T=0,E=(p+.5)*c,I=r(p*c);I<(p+1)*c;I++)for(var O=s(E-(I+.5))/d,R=(m+.5)*l,D=O*O,A=r(m*l);A<(m+1)*l;A++){var M=s(R-(A+.5))/u,L=n(D+M*M);L>1&&L<-1||(y=2*L*L*L-3*L*L+1)>0&&(T+=y*f[3+(M=4*(A+I*e))],C+=y,f[M+3]<255&&(y=y*f[M+3]/250),w+=y*f[M],b+=y*f[M+1],x+=y*f[M+2],S+=y)}_[v]=w/S,_[v+1]=b/S,_[v+2]=x/S,_[v+3]=T/C
vendor: 13,522 bytes, line 2
2}return g},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),e.Image.filters.Resize.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Contrast=r(i.BaseFilter,{type:"Contrast",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uContrast;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\ncolor.rgb = contrastF * (color.rgb - 0.5) + 0.5;\ngl_FragColor = color;\n}",contrast:0,mainParameter:"contrast",applyTo2d:function(t){if(0!==this.contrast){var e,i=t.imageData.data,r=i.length,n=Math.floor(255*this.contrast),s=259*(n+255)/(255*(259-n));for(e=0;e<r;e+=4)i[e]=s*(i[e]-128)+128,i[e+1]=s*(i[e+1]-128)+128,i[e+2]=s*(i[e+2]-128)+128}},getUniformLocations:function(t,e){return{uContrast:t.getUniformLocation(e,"uContrast")}},sendUniformData:function(t,e){t.uniform1f(e.uContrast,this.contrast)}}),e.Image.filters.Contrast.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Saturation=r(i.BaseFilter,{type:"Saturation",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uSaturation;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat rgMax = max(color.r, color.g);\nfloat rgbMax = max(rgMax, color.b);\ncolor.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\ncolor.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\ncolor.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\ngl_FragColor = color;\n}",saturation:0,mainParameter:"saturation",applyTo2d:function(t){if(0!==this.saturation){var e,i,r=t.imageData.data,n=r.length,s=-this.saturation;for(e=0;e<n;e+=4)i=Math.max(r[e],r[e+1],r[e+2]),r[e]+=i!==r[e]?(i-r[e])*s:0,r[e+1]+=i!==r[e+1]?(i-r[e+1])*s:0,r[e+2]+=i!==r[e+2]?(i-r[e+2])*s:0}},getUniformLocations:function(t,e){return{uSaturation:t.getUniformLocation(e,"uSaturation")}},sendUniformData:function(t,e){t.uniform1f(e.uSaturation,-this.saturation)}}),e.Image.filters.Saturation.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Vibrance=r(i.BaseFilter,{type:"Vibrance",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform float uVibrance;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nfloat max = max(color.r, max(color.g, color.b));\nfloat avg = (color.r + color.g + color.b) / 3.0;\nfloat amt = (abs(max - avg) * 2.0) * uVibrance;\ncolor.r += max != color.r ? (max - color.r) * amt : 0.00;\ncolor.g += max != color.g ? (max - color.g) * amt : 0.00;\ncolor.b += max != color.b ? (max - color.b) * amt : 0.00;\ngl_FragColor = color;\n}",vibrance:0,mainParameter:"vibrance",applyTo2d:function(t){if(0!==this.vibrance){var e,i,r,n,s=t.imageData.data,o=s.length,a=-this.vibrance;for(e=0;e<o;e+=4)i=Math.max(s[e],s[e+1],s[e+2]),r=(s[e]+s[e+1]+s[e+2])/3,n=2*Math.abs(i-r)/255*a,s[e]+=i!==s[e]?(i-s[e])*n:0,s[e+1]+=i!==s[e+1]?(i-s[e+1])*n:0,s[e+2]+=i!==s[e+2]?(i-s[e+2])*n:0}},getUniformLocations:function(t,e){return{uVibrance:t.getUniformLocation(e,"uVibrance")}},sendUniformData:function(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}}),e.Image.filters.Vibrance.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Blur=r(i.BaseFilter,{type:"Blur",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec2 uDelta;\nvarying vec2 vTexCoord;\nconst float nSamples = 15.0;\nvec3 v3offset = vec3(12.9898, 78.233, 151.7182);\nfloat random(vec3 scale) {\nreturn fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n}\nvoid main() {\nvec4 color = vec4(0.0);\nfloat total = 0.0;\nfloat offset = random(v3offset);\nfor (float t = -nSamples; t <= nSamples; t++) {\nfloat percent = (t + offset - 0.5) / nSamples;\nfloat weight = 1.0 - abs(percent);\ncolor += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\ntotal += weight;\n}\ngl_FragColor = color / total;\n}",blur:0,mainParameter:"blur",applyTo:function(t){t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)},applyTo2d:function(t){t.imageData=this.simpleBlur(t)},simpleBlur:function(t){var i,r,n=t.filterBackend.resources,s=t.imageData.width,o=t.imageData.height;n.blurLayer1||(n.blurLayer1=e.util.createCanvasElement(),n.blurLayer2=e.util.createCanvasElement()),i=n.blurLayer1,r=n.blurLayer2,i.width===s&&i.height===o||(r.width=i.width=s,r.height=i.height=o);var a,h,l,c,u=i.getContext("2d"),d=r.getContext("2d"),f=.06*this.blur*.5;for(u.putImageData(t.imageData,0,0),d.clearRect(0,0,s,o),c=-15;c<=15;c++)l=f*(h=c/15)*s+(a=(Math.random()-.5)/4),d.globalAlpha=1-Math.abs(h),d.drawImage(i,l,a),u.drawImage(r,0,0),d.globalAlpha=1,d.clearRect(0,0,r.width,r.height);for(c=-15;c<=15;c++)l=f*(h=c/15)*o+(a=(Math.random()-.5)/4),d.globalAlpha=1-Math.abs(h),d.drawImage(i,a,l),u.drawImage(r,0,0),d.globalAlpha=1,d.clearRect(0,0,r.width,r.height);t.ctx.drawImage(i,0,0);var g=t.ctx.getImageData(0,0,i.width,i.height);return u.globalAlpha=1,u.clearRect(0,0,i.width,i.height),g},getUniformLocations:function(t,e){return{delta:t.getUniformLocation(e,"uDelta")}},sendUniformData:function(t,e){var i=this.chooseRightDelta();t.uniform2fv(e.delta,i)},chooseRightDelta:function(){var t,e=1,i=[0,0];return this.horizontal?this.aspectRatio>1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),t=e*this.blur*.12,this.horizontal?i[0]=t:i[1]=t,i}}),i.Blur.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Gamma=r(i.BaseFilter,{type:"Gamma",fragmentSource:"precision highp float;\nuniform sampler2D uTexture;\nuniform vec3 uGamma;\nvarying vec2 vTexCoord;\nvoid main() {\nvec4 color = texture2D(uTexture, vTexCoord);\nvec3 correction = (1.0 / uGamma);\ncolor.r = pow(color.r, correction.r);\ncolor.g = pow(color.g, correction.g);\ncolor.b = pow(color.b, correction.b);\ngl_FragColor = color;\ngl_FragColor.rgb *= color.a;\n}",gamma:[1,1,1],mainParameter:"gamma",initialize:function(t){this.gamma=[1,1,1],i.BaseFilter.prototype.initialize.call(this,t)},applyTo2d:function(t){var e,i=t.imageData.data,r=this.gamma,n=i.length,s=1/r[0],o=1/r[1],a=1/r[2];for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),e=0,n=256;e<n;e++)this.rVals[e]=255*Math.pow(e/255,s),this.gVals[e]=255*Math.pow(e/255,o),this.bVals[e]=255*Math.pow(e/255,a);for(e=0,n=i.length;e<n;e+=4)i[e]=this.rVals[i[e]],i[e+1]=this.gVals[i[e+1]],i[e+2]=this.bVals[i[e+2]]},getUniformLocations:function(t,e){return{uGamma:t.getUniformLocation(e,"uGamma")}},sendUniformData:function(t,e){t.uniform3fv(e.uGamma,this.gamma)}}),e.Image.filters.Gamma.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.Composed=r(i.BaseFilter,{type:"Composed",subFilters:[],initialize:function(t){this.callSuper("initialize",t),this.subFilters=this.subFilters.slice(0)},applyTo:function(t){t.passes+=this.subFilters.length-1,this.subFilters.forEach((function(e){e.applyTo(t)}))},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{subFilters:this.subFilters.map((function(t){return t.toObject()}))})},isNeutralState:function(){return!this.subFilters.some((function(t){return!t.isNeutralState()}))}}),e.Image.filters.Composed.fromObject=function(t,i){var r=(t.subFilters||[]).map((function(t){return new e.Image.filters[t.type](t)})),n=new e.Image.filters.Composed({subFilters:r});return i&&i(n),n}}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.Image.filters,r=e.util.createClass;i.HueRotation=r(i.ColorMatrix,{type:"HueRotation",rotation:0,mainParameter:"rotation",calculateMatrix:function(){var t=this.rotation*Math.PI,i=e.util.cos(t),r=e.util.sin(t),n=1/3,s=Math.sqrt(n)*r,o=1-i;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=i+o/3,this.matrix[1]=n*o-s,this.matrix[2]=n*o+s,this.matrix[5]=n*o+s,this.matrix[6]=i+n*o,this.matrix[7]=n*o-s,this.matrix[10]=n*o-s,this.matrix[11]=n*o+s,this.matrix[12]=i+n*o},isNeutralState:function(t){return this.calculateMatrix(),i.BaseFilter.prototype.isNeutralState.call(this,t)},applyTo:function(t){this.calculateMatrix(),i.BaseFilter.prototype.applyTo.call(this,t)}}),e.Image.filters.HueRotation.fromObject=e.Image.filters.BaseFilter.fromObject}(e),function(t){var e=t.fabric||(t.fabric={}),i=e.util.object.clone;if(e.Text)e.warn("fabric.Text is already defined");else{var r="fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign".split(" ");e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:["fontSize","fontWeight","fontFamily","fontStyle","lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:"left",fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stateProperties:e.Object.prototype.stateProperties.concat(r),cacheProperties:e.Object.prototype.cacheProperties.concat(r),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:"left",pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:"ltr",_styleProperties:["stroke","strokeWidth","fill","fontFamily","fontSize","fontWeight","fontStyle","underline","overline","linethrough","deltaY","textBackgroundColor"],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(t,e){this.styles=e&&e.styles||{},this.text=t,this.__skipDimension=!0,this.callSuper("initialize",e),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:"_dimensionAffectingProps"})},setPathInfo:function(){var t=this.path;t&&(t.segmentsInfo=e.util.getPathSegmentsInfo(t.path))},getMeasuringContext:function(){return e._measuringContext||(e._measuringContext=this.canvas&&this.canvas.contextCache||e.util.createCanvasElement().getContext("2d")),e._measuringContext},_splitText:function(){var t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t},initDimensions:function(){this.__skipDimension||(this._splitText(),this._clearCache(),this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.saveState({propertySet:"_dimensionAffectingProps"}))},enlargeSpaces:function(){for(var t,e,i,r,n,s,o,a=0,h=this._textLines.length;a<h;a++)if(("justify"===this.textAlign||a!==h-1&&!this.isEndOfWrapping(a))&&(r=0,n=this._textLines[a],(e=this.getLineWidth(a))<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){i=o.length,t=(this.width-e)/i;for(var l=0,c=n.length;l<=c;l++)s=this.__charBounds[a][l],this._reSpaceAndTab.test(n[l])?(s.width+=t,s.kernedWidth+=t,s.left+=r,r+=t):s.left+=r}},isEndOfWrapping:function(t){return t===this._textLines.length-1},missingNewlineOffset:function(){return 1},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_getCacheCanvasDimensions:function(){var t=this.callSuper("_getCacheCanvasDimensions"),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t},_render:function(t){var e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")},_renderText:function(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))},_setTextStyles:function(t,e,i){if(t.textBaseline="alphabetical",this.path)switch(this.pathAlign){case"center":t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline="bottom"}t.font=this._getFontDeclaration(e,i)},calcTextWidth:function(){for(var t=this.getLineWidth(0),e=1,i=this._textLines.length;e<i;e++){var r=this.getLineWidth(e);r>t&&(t=r)}return t},_renderTextLine:function(t,e,i,r,n,s){this._renderChars(t,e,i,r,n,s)},_renderTextLinesBackground:function(t){if(this.textBackgroundColor||this.styleHas("textBackgroundColor")){for(var e,i,r,n,s,o,a,h=t.fillStyle,l=this._getLeftOffset(),c=this._getTopOffset(),u=0,d=0,f=this.path,g=0,
vendor: 107,493 bytes, line 2
2_=this._textLines.length;g<_;g++)if(e=this.getHeightOfLine(g),this.textBackgroundColor||this.styleHas("textBackgroundColor",g)){r=this._textLines[g],i=this._getLineLeftOffset(g),d=0,u=0,n=this.getValueOfPropertyAt(g,0,"textBackgroundColor");for(var p=0,m=r.length;p<m;p++)s=this.__charBounds[g][p],o=this.getValueOfPropertyAt(g,p,"textBackgroundColor"),f?(t.save(),t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillStyle=o,o&&t.fillRect(-s.width/2,-e/this.lineHeight*(1-this._fontSizeFraction),s.width,e/this.lineHeight),t.restore()):o!==n?(a=l+i+u,"rtl"===this.direction&&(a=this.width-a-d),t.fillStyle=n,n&&t.fillRect(a,c,d,e/this.lineHeight),u=s.left,d=s.width,n=o):d+=s.kernedWidth;o&&!f&&(a=l+i+u,"rtl"===this.direction&&(a=this.width-a-d),t.fillStyle=o,t.fillRect(a,c,d,e/this.lineHeight)),c+=e}else c+=e;t.fillStyle=h,this._removeShadow(t)}},getFontCache:function(t){var i=t.fontFamily.toLowerCase();e.charWidthsCache[i]||(e.charWidthsCache[i]={});var r=e.charWidthsCache[i],n=t.fontStyle.toLowerCase()+"_"+(t.fontWeight+"").toLowerCase();return r[n]||(r[n]={}),r[n]},_measureChar:function(t,e,i,r){var n,s,o,a,h=this.getFontCache(e),l=i+t,c=this._getFontDeclaration(e)===this._getFontDeclaration(r),u=e.fontSize/this.CACHE_FONT_SIZE;if(i&&void 0!==h[i]&&(o=h[i]),void 0!==h[t]&&(a=n=h[t]),c&&void 0!==h[l]&&(a=(s=h[l])-o),void 0===n||void 0===o||void 0===s){var d=this.getMeasuringContext();this._setTextStyles(d,e,!0)}return void 0===n&&(a=n=d.measureText(t).width,h[t]=n),void 0===o&&c&&i&&(o=d.measureText(i).width,h[i]=o),c&&void 0===s&&(s=d.measureText(l).width,h[l]=s,a=s-o),{width:n*u,kernedWidth:a*u}},getHeightOfChar:function(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")},measureLine:function(t){var e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e},_measureLine:function(t){var i,r,n,s,o,a,h=0,l=this._textLines[t],c=new Array(l.length),u=0,d=this.path,f="right"===this.pathSide;for(this.__charBounds[t]=c,i=0;i<l.length;i++)r=l[i],s=this._getGraphemeBox(r,t,i,n),c[i]=s,h+=s.kernedWidth,n=r;if(c[i]={left:s?s.left+s.width:0,width:0,kernedWidth:0,height:this.fontSize},d){switch(a=d.segmentsInfo[d.segmentsInfo.length-1].length,(o=e.util.getPointOnPath(d.path,0,d.segmentsInfo)).x+=d.pathOffset.x,o.y+=d.pathOffset.y,this.textAlign){case"left":u=f?a-h:0;break;case"center":u=(a-h)/2;break;case"right":u=f?0:a-h}for(u+=this.pathStartOffset*(f?-1:1),i=f?l.length-1:0;f?i>=0:i<l.length;f?i--:i++)s=c[i],u>a?u%=a:u<0&&(u+=a),this._setGraphemeOnPath(u,s,o),u+=s.kernedWidth}return{width:h,numOfSpaces:0}},_setGraphemeOnPath:function(t,i,r){var n=t+i.kernedWidth/2,s=this.path,o=e.util.getPointOnPath(s.path,n,s.segmentsInfo);i.renderLeft=o.x-r.x,i.renderTop=o.y-r.y,i.angle=o.angle+("right"===this.pathSide?Math.PI:0)},_getGraphemeBox:function(t,e,i,r,n){var s,o=this.getCompleteStyleDeclaration(e,i),a=r?this.getCompleteStyleDeclaration(e,i-1):{},h=this._measureChar(t,o,r,a),l=h.kernedWidth,c=h.width;0!==this.charSpacing&&(c+=s=this._getWidthOfCharSpacing(),l+=s);var u={width:c,left:0,height:o.fontSize,kernedWidth:l,deltaY:o.deltaY};if(i>0&&!n){var d=this.__charBounds[e][i-1];u.left=d.left+d.width+h.kernedWidth-h.width}return u},getHeightOfLine:function(t){if(this.__lineHeights[t])return this.__lineHeights[t];for(var e=this._textLines[t],i=this.getHeightOfChar(t,0),r=1,n=e.length;r<n;r++)i=Math.max(this.getHeightOfChar(t,r),i);return this.__lineHeights[t]=i*this.lineHeight*this._fontSizeMult},calcTextHeight:function(){for(var t,e=0,i=0,r=this._textLines.length;i<r;i++)t=this.getHeightOfLine(i),e+=i===r-1?t/this.lineHeight:t;return e},_getLeftOffset:function(){return"ltr"===this.direction?-this.width/2:this.width/2},_getTopOffset:function(){return-this.height/2},_renderTextCommon:function(t,e){t.save();for(var i=0,r=this._getLeftOffset(),n=this._getTopOffset(),s=0,o=this._textLines.length;s<o;s++){var a=this.getHeightOfLine(s),h=a/this.lineHeight,l=this._getLineLeftOffset(s);this._renderTextLine(e,t,this._textLines[s],r+l,n+i+h,s),i+=a}t.restore()},_renderTextFill:function(t){(this.fill||this.styleHas("fill"))&&this._renderTextCommon(t,"fillText")},_renderTextStroke:function(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())},_renderChars:function(t,e,i,r,n,s){var o,a,h,l,c,u=this.getHeightOfLine(s),d=-1!==this.textAlign.indexOf("justify"),f="",g=0,_=this.path,p=!d&&0===this.charSpacing&&this.isEmptyStyles(s)&&!_,m="ltr"===this.direction,v="ltr"===this.direction?1:-1,y=e.canvas.getAttribute("dir");if(e.save(),y!==this.direction&&(e.canvas.setAttribute("dir",m?"ltr":"rtl"),e.direction=m?"ltr":"rtl",e.textAlign=m?"left":"right"),n-=u*this._fontSizeFraction/this.lineHeight,p)return this._renderChar(t,e,s,0,i.join(""),r,n,u),void e.restore();for(var S=0,C=i.length-1;S<=C;S++)l=S===C||this.charSpacing||_,f+=i[S],h=this.__charBounds[s][S],0===g?(r+=v*(h.kernedWidth-h.width),g+=h.width):g+=h.kernedWidth,d&&!l&&this._reSpaceAndTab.test(i[S])&&(l=!0),l||(o=o||this.getCompleteStyleDeclaration(s,S),a=this.getCompleteStyleDeclaration(s,S+1),l=this._hasStyleChanged(o,a)),l&&(_?(e.save(),e.translate(h.renderLeft,h.renderTop),e.rotate(h.angle),this._renderChar(t,e,s,S,f,-g/2,0,u),e.restore()):(c=r,this._renderChar(t,e,s,S,f,c,n,u)),f="",o=a,r+=v*g,g=0);e.restore()},_applyPatternGradientTransformText:function(t){var i,r=e.util.createCanvasElement(),n=this.width+this.strokeWidth,s=this.height+this.strokeWidth;return r.width=n,r.height=s,(i=r.getContext("2d")).beginPath(),i.moveTo(0,0),i.lineTo(n,0),i.lineTo(n,s),i.lineTo(0,s),i.closePath(),i.translate(n/2,s/2),i.fillStyle=t.toLive(i),this._applyPatternGradientTransform(i,t),i.fill(),i.createPattern(r,"no-repeat")},handleFiller:function(t,e,i){var r,n;return i.toLive?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?(r=-this.width/2,n=-this.height/2,t.translate(r,n),t[e]=this._applyPatternGradientTransformText(i),{offsetX:r,offsetY:n}):(t[e]=i.toLive(t,this),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})},_setStrokeStyles:function(t,e){return t.lineWidth=e.strokeWidth,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",e.stroke)},_setFillStyles:function(t,e){return this.handleFiller(t,"fillStyle",e.fill)},_renderChar:function(t,e,i,r,n,s,o){var a,h,l=this._getStyleDeclaration(i,r),c=this.getCompleteStyleDeclaration(i,r),u="fillText"===t&&c.fill,d="strokeText"===t&&c.stroke&&c.strokeWidth;(d||u)&&(e.save(),u&&(a=this._setFillStyles(e,c)),d&&(h=this._setStrokeStyles(e,c)),e.font=this._getFontDeclaration(c),l&&l.textBackgroundColor&&this._removeShadow(e),l&&l.deltaY&&(o+=l.deltaY),u&&e.fillText(n,s-a.offsetX,o-a.offsetY),d&&e.strokeText(n,s-h.offsetX,o-h.offsetY),e.restore())},setSuperscript:function(t,e){return this._setScript(t,e,this.superscript)},setSubscript:function(t,e){return this._setScript(t,e,this.subscript)},_setScript:function(t,e,i){var r=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"fontSize"),s=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"deltaY"),o={fontSize:n*i.size,deltaY:s+n*i.baseline};return this.setSelectionStyles(o,t,e),this},_hasStyleChanged:function(t,e){return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.deltaY!==e.deltaY},_hasStyleChangedForSvg:function(t,e){return this._hasStyleChanged(t,e)||t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough},_getLineLeftOffset:function(t){var e=this.getLineWidth(t),i=this.width-e,r=this.textAlign,n=this.direction,s=0,o=this.isEndOfWrapping(t);return"justify"===r||"justify-center"===r&&!o||"justify-right"===r&&!o||"justify-left"===r&&!o?0:("center"===r&&(s=i/2),"right"===r&&(s=i),"justify-center"===r&&(s=i/2),"justify-right"===r&&(s=i),"rtl"===n&&(s-=i),s)},_clearCache:function(){this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]},_shouldClearDimensionCache:function(){var t=this._forceClearCache;return t||(t=this.hasStateChanged("_dimensionAffectingProps")),t&&(this.dirty=!0,this._forceClearCache=!1),t},getLineWidth:function(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];var e=this.measureLine(t).width;return this.__lineWidths[t]=e,e},_getWidthOfCharSpacing:function(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0},getValueOfPropertyAt:function(t,e,i){var r=this._getStyleDeclaration(t,e);return r&&void 0!==r[i]?r[i]:this[i]},_renderTextDecoration:function(t,e){if(this[e]||this.styleHas(e)){for(var i,r,n,s,o,a,h,l,c,u,d,f,g,_,p,m,v=this._getLeftOffset(),y=this._getTopOffset(),S=this.path,C=this._getWidthOfCharSpacing(),w=this.offsets[e],b=0,x=this._textLines.length;b<x;b++)if(i=this.getHeightOfLine(b),this[e]||this.styleHas(e,b)){h=this._textLines[b],_=i/this.lineHeight,s=this._getLineLeftOffset(b),u=0,d=0,l=this.getValueOfPropertyAt(b,0,e),m=this.getValueOfPropertyAt(b,0,"fill"),c=y+_*(1-this._fontSizeFraction),r=this.getHeightOfChar(b,0),o=this.getValueOfPropertyAt(b,0,"deltaY");for(var T=0,E=h.length;T<E;T++)if(f=this.__charBounds[b][T],g=this.getValueOfPropertyAt(b,T,e),p=this.getValueOfPropertyAt(b,T,"fill"),n=this.getHeightOfChar(b,T),a=this.getValueOfPropertyAt(b,T,"deltaY"),S&&g&&p)t.save(),t.fillStyle=m,t.translate(f.renderLeft,f.renderTop),t.rotate(f.angle),t.fillRect(-f.kernedWidth/2,w*n+a,f.kernedWidth,this.fontSize/15),t.restore();else if((g!==l||p!==m||n!==r||a!==o)&&d>0){var I=v+s+u;"rtl"===this.direction&&(I=this.width-I-d),l&&m&&(t.fillStyle=m,t.fillRect(I,c+w*r+o,d,this.fontSize/15)),u=f.left,d=f.width,l=g,m=p,r=n,o=a}else d+=f.kernedWidth;I=v+s+u,"rtl"===this.direction&&(I=this.width-I-d),t.fillStyle=p,g&&p&&t.fillRect(I,c+w*r+o,d-C,this.fontSize/15),y+=i}else y+=i;this._removeShadow(t)}},_getFontDeclaration:function(t,i){var r=t||this,n=this.fontFamily,s=e.Text.genericFonts.indexOf(n.toLowerCase())>-1,o=void 0===n||n.indexOf("'")>-1||n.indexOf(",")>-1||n.indexOf('"')>-1||s?r.fontFamily:'"'+r.fontFamily+'"';return[e.isLikelyNode?r.fontWeight:r.fontStyle,e.isLikelyNode?r.fontStyle:r.fontWeight,i?this.CACHE_FONT_SIZE+"px":r.fontSize+"px",o].join(" ")},render:function(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._shouldClearDimensionCache()&&this.initDimensions(),this.callSuper("render",t)))},_splitTextIntoLines:function(t){for(var i=t.split(this._reNewline),r=new Array(i.length),n=["\n"],s=[],o=0;o<i.length;o++)r[o]=e.util.string.graphemeSplit(i[o]),s=s.concat(r[o],n);return s.pop(),{_unwrappedLines:r,lines:i,graphemeText:s,graphemeLines:r}},toObject:function(t){var e=r.concat(t),n=this.callSuper("toObject",e);return n.styles=i(this.styles,!0),n.path&&(n.path=this.path.toObject()),n},set:function(t,e){this.callSuper("set",t,e);var i=!1,r=!1;if("object"==typeof t)for(var n in t)"path"===n&&this.setPathInfo(),i=i||-1!==this._dimensionAffectingProps.indexOf(n),r=r||"path"===n;else i=-1!==this._dimensionAffectingProps.indexOf(t),r="path"===t;return r&&this.setPathInfo(),i&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor".split(" ")),e.Text.DEFAULT_SVG_FONT_SIZE=16,e.Text.fromElement=function(t,r,n){if(!t)return r(null);var s=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES),o=s.textAnchor||"left";if((n=e.util.object.extend(n?i(n):{},s)).top=n.top||0,n.left=n.left||0,s.textDecoration){var a=s.textDecoration;-1!==a.indexOf("underline")&&(n.underline=!0),-1!==a.indexOf("overline")&&(n.overline=!0),-1!==a.indexOf("line-through")&&(n.linethrough=!0),delete n.textDecoration}"dx"in s&&(n.left+=s.dx),"dy"in s&&(n.top+=s.dy),"fontSize"in n||(n.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE);var h="";"textContent"in t?h=t.textContent:"firstChild"in t&&null!==t.firstChild&&"data"in t.firstChild&&null!==t.firstChild.data&&(h=t.firstChild.data),h=h.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var l=n.strokeWidth;n.strokeWidth=0;var c=new e.Text(h,n),u=c.getScaledHeight()/c.height,d=((c.height+c.strokeWidth)*c.lineHeight-c.height)*u,f=c.getScaledHeight()+d,g=0;"center"===o&&(g=c.getScaledWidth()/2),"right"===o&&(g=c.getScaledWidth()),c.set({left:c.left-g,top:c.top-(f-c.fontSize*(.07+c._fontSizeFraction))/c.lineHeight,strokeWidth:void 0!==l?l:1}),r(c)},e.Text.fromObject=function(t,r){var n=i(t),s=t.path;return delete n.path,e.Object._fromObject("Text",n,(function(t){s?e.Object._fromObject("Path",s,(function(e){t.set("path",e),r(t)}),"path"):r(t)}),"text")},e.Text.genericFonts=["sans-serif","serif","cursive","fantasy","monospace"],e.util.createAccessors&&e.util.createAccessors(e.Text)}}(e),E.util.object.extend(E.Text.prototype,{isEmptyStyles:function(t){if(!this.styles)return!0;if(void 0!==t&&!this.styles[t])return!0;var e=void 0===t?this.styles:{line:this.styles[t]};for(var i in e)for(var r in e[i])for(var n in e[i][r])return!1;return!0},styleHas:function(t,e){if(!this.styles||!t||""===t)return!1;if(void 0!==e&&!this.styles[e])return!1;var i=void 0===e?this.styles:{0:this.styles[e]};for(var r in i)for(var n in i[r])if(void 0!==i[r][n][t])return!0;return!1},cleanStyle:function(t){if(!this.styles||!t||""===t)return!1;var e,i,r=this.styles,n=0,s=!0,o=0;for(var a in r){for(var h in e=0,r[a]){var l;n++,(l=r[a][h]).hasOwnProperty(t)?(i?l[t]!==i&&(s=!1):i=l[t],l[t]===this[t]&&delete l[t]):s=!1,0!==Object.keys(l).length?e++:delete r[a][h]}0===e&&delete r[a]}for(var c=0;c<this._textLines.length;c++)o+=this._textLines[c].length;s&&n===o&&(this[t]=i,this.removeStyle(t))},removeStyle:function(t){if(this.styles&&t&&""!==t){var e,i,r,n=this.styles;for(i in n){for(r in e=n[i])delete e[r][t],0===Object.keys(e[r]).length&&delete e[r];0===Object.keys(e).length&&delete n[i]}}},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);this._getLineStyle(i.lineIndex)||this._setLineStyle(i.lineIndex),this._getStyleDeclaration(i.lineIndex,i.charIndex)||this._setStyleDeclaration(i.lineIndex,i.charIndex,{}),E.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},get2DCursorLocation:function(t,e){void 0===t&&(t=this.selectionStart);for(var i=e?this._unwrappedTextLines:this._textLines,r=i.length,n=0;n<r;n++){if(t<=i[n].length)return{lineIndex:n,charIndex:t};t-=i[n].length+this.missingNewlineOffset(n)}return{lineIndex:n-1,charIndex:i[n-1].length<t?i[n-1].length:t}},getSelectionStyles:function(t,e,i){void 0===t&&(t=this.selectionStart||0),void 0===e&&(e=this.selectionEnd||t);for(var r=[],n=t;n<e;n++)r.push(this.getStyleAtPosition(n,i));return r},getStyleAtPosition:function(t,e){var i=this.get2DCursorLocation(t);return(e?this.getCompleteStyleDeclaration(i.lineIndex,i.charIndex):this._getStyleDeclaration(i.lineIndex,i.charIndex))||{}},setSelectionStyles:function(t,e,i){void 0===e&&(e=this.selectionStart||0),void 0===i&&(i=this.selectionEnd||e);for(var r=e;r<i;r++)this._extendStyles(r,t);return this._forceClearCache=!0,this},_getStyleDeclaration:function(t,e){var i=this.styles&&this.styles[t];return i?i[e]:null},getCompleteStyleDeclaration:function(t,e){for(var i,r=this._getStyleDeclaration(t,e)||{},n={},s=0;s<this._styleProperties.length;s++)n[i=this._styleProperties[s]]=void 0===r[i]?this[i]:r[i];return n},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return!!this.styles[t]},_setLineStyle:function(t){this.styles[t]={}},_deleteLineStyle:function(t){delete this.styles[t]}}),function(){function t(t){t.textDecoration&&(t.textDecoration.indexOf("underline")>-1&&(t.underline=!0),t.textDecoration.indexOf("line-through")>-1&&(t.linethrough=!0),t.textDecoration.indexOf("overline")>-1&&(t.overline=!0),delete t.textDecoration)}E.IText=E.util.createClass(E.Text,E.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:!1,__widthOfSpace:[],inCompositionMode:!1,initialize:function(t,e){this.callSuper("initialize",t,e),this.initBehavior()},setSelectionStart:function(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)},setSelectionEnd:function(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)},_updateAndFire:function(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()},_fireSelectionChanged:function(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})},initDimensions:function(){this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this.callSuper("initDimensions")},render:function(t){this.clearContextTop(),this.callSuper("render",t),this.cursorOffsetCache={},this.renderCursorOrSelection()},_render:function(t){this.callSuper("_render",t)},clearContextTop:function(t){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var e=this.canvas.contextTop,i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e),this._clearTextArea(e),t||e.restore()}},renderCursorOrSelection:function(){if(this.isEditing&&this.canvas&&this.canvas.contextTop){var t=this._getCursorBoundaries(),e=this.canvas.contextTop;this.clearContextTop(!0),this.selectionStart===this.selectionEnd?this.renderCursor(t,e):this.renderSelection(t,e),e.restore()}},_clearTextArea:function(t){var e=this.width+4,i=this.height+4;t.clearRect(-e/2,-i/2,e,i)},_getCursorBoundaries:function(t){void 0===t&&(t=this.selectionStart);var e=this._getLeftOffset(),i=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t);return{left:e,top:i,leftOffset:r.left,topOffset:r.top}},_getCursorBoundariesOffsets:function(t){if(this.cursorOffsetCache&&"top"in this.cursorOffsetCache)return this.cursorOffsetCache;var e,i,r,n,s=0,o=0,a=this.get2DCursorLocation(t);r=a.charIndex,i=a.lineIndex;for(var h=0;h<i;h++)s+=this.getHeightOfLine(h);e=this._getLineLeftOffset(i);var l=this.__charBounds[i][r];return l&&(o=l.left),0!==this.charSpacing&&r===this._textLines[i].length&&(o-=this._getWidthOfCharSpacing()),n={top:s,left:e+(o>0?o:0)},"rtl"===this.direction&&(n.left*=-1),this.cursorOffsetCache=n,this.cursorOffsetCache},renderCursor:function(t,e){var i=this.get2DCursorLocation(),r=i.lineIndex,n=i.charIndex>0?i.charIndex-1:0,s=this.getValueOfPropertyAt(r,n,"fontSize"),o=this.scaleX*this.canvas.getZoom(),a=this.cursorWidth/o,h=t.topOffset,l=this.getValueOfPropertyAt(r,n,"deltaY");h+=(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-s*(1-this._fontSizeFraction),this.inCompositionMode&&this.renderSelection(t,e),e.fillStyle=this.cursorColor||this.getValueOfPropertyAt(r,n,"fill"),e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity,e.fillRect(t.left+t.leftOffset-a/2,h+t.top+l,a,s)},renderSelection:function(t,e){for(var i=this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,r=this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd,n=-1!==this.textAlign.indexOf("justify"),s=this.get2DCursorLocation(i),o=this.get2DCursorLocation(r),a=s.lineIndex,h=o.lineIndex,l=s.charIndex<0?0:s.charIndex,c=o.charIndex<0?0:o.charIndex,u=a;u<=h;u++){var d,f=this._getLineLeftOffset(u)||0,g=this.getHeightOfLine(u),_=0,p=0;if(u===a&&(_=this.__charBounds[a][l].left),u>=a&&u<h)p=n&&!this.isEndOfWrapping(u)?this.width:this.getLineWidth(u)||5;else if(u===h)if(0===c)p=this.__charBounds[h][c].left;else{var m=this._getWidthOfCharSpacing();p=this.__charBounds[h][c-1].left+this.__charBounds[h][c-1].width-m}d=g,(this.lineHeight<1||u===h&&this.lineHeight>1)&&(g/=this.lineHeight);var v=t.left+f+_,y=p-_,S=g,C=0;this.inCompositionMode?(e.fillStyle=this.compositionColor||"black",S=1,C=g):e.fillStyle=this.selectionColor,"rtl"===this.direction&&(v=this.width-v-y),e.fillRect(v,t.top+t.topOffset+C,y,S),t.topOffset+=d}},getCurrentCharFontSize:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")},getCurrentCharColor:function(){var t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fill")},_getCurrentCharIndex:function(){var t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}}),E.IText.fromObject=function(e,i){if(t(e),e.styles)for(var r in e.styles)for(var n in e.styles[r])t(e.styles[r][n]);E.Object._fromObject("IText",e,i,"text")}}(),T=E.util.object.clone,E.util.object.extend(E.IText.prototype,{initBehavior:function(){this.initAddedHandler(),this.initRemovedHandler(),this.initCursorSelectionHandlers(),this.initDoubleClickSimulation(),this.mouseMoveHandler=this.mouseMoveHandler.bind(this)},onDeselect:function(){this.isEditing&&this.exitEditing(),this.selected=!1},initAddedHandler:function(){var t=this;this.on("added",(function(){var e=t.canvas;e&&(e._hasITextHandlers||(e._hasITextHandlers=!0,t._initCanvasHandlers(e)),e._iTextInstances=e._iTextInstances||[],e._iTextInstances.push(t))}))},initRemovedHandler:function(){var t=this;this.on("removed",(function(){var e=t.canvas;e&&(e._iTextInstances=e._iTextInstances||[],E.util.removeFromArray(e._iTextInstances,t),0===e._iTextInstances.length&&(e._hasITextHandlers=!1,t._removeCanvasHandlers(e)))}))},_initCanvasHandlers:function(t){t._mouseUpITextHandler=function(){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.__isMousedown=!1}))},t.on("mouse:up",t._mouseUpITextHandler)},_removeCanvasHandlers:function(t){t.off("mouse:up",t._mouseUpITextHandler)},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,r){var n;return n={isAborted:!1,abort:function(){this.isAborted=!0}},t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){n.isAborted||t[r]()},onChange:function(){t.canvas&&t.selectionStart===t.selectionEnd&&t.renderCursorOrSelection()},abort:function(){return n.isAborted}}),n},_onTickComplete:function(){var t=this;this._cursorTimeout1&&clearTimeout(this._cursorTimeout1),this._cursorTimeout1=setTimeout((function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")}),100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this.abortCursorAnimation(),this._currentCursorOpacity=1,this._cursorTimeout2=setTimeout((function(){e._tick()}),i)},abortCursorAnimation:function(){var t=this._currentTickState||this._currentTickCompleteState,e=this.canvas;this._currentTickState&&this._currentTickState.abort(),this._currentTickCompleteState&&this._currentTickCompleteState.abort(),clearTimeout(this._cursorTimeout1),clearTimeout(this._cursorTimeout2),this._currentCursorOpacity=0,t&&e&&e.clearContext(e.contextTop||e.contextContainer)},selectAll:function(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this},getSelectedText:function(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},findLineBoundaryLeft:function(t){for(var e=0,i=t-1;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e},findLineBoundaryRight:function(t){for(var e=0,i=t;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e},searchWordBoundary:function(t,e){for(var i=this._text,r=this._reSpace.test(i[t])?t-1:t,n=i[r],s=E.reNonWord;!s.test(n)&&r>0&&r<i.length;)n=i[r+=e];return s.test(n)&&(r+=1===e?0:1),r},selectWord:function(t){t=t||this.selectionStart;var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()},selectLine:function(t){t=t||this.selectionStart;var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this},enterEditing:function(t){if(!this.isEditing&&this.editable)return this.canvas&&(this.canvas.calcOffset(),this.exitEditingOnOthers(this.canvas)),this.isEditing=!0,this.initHiddenTextarea(t),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick(),this.fire("editing:entered"),this._fireSelectionChanged(),this.canvas?(this.canvas.fire("text:editing:entered",{target:this}),this.initMouseMoveHandler(),this.canvas.requestRenderAll(),this):this},exitEditingOnOthers:function(t){t._iTextInstances&&t._iTextInstances.forEach((function(t){t.selected=!1,t.isEditing&&t.exitEditing()}))},initMouseMoveHandler:function(){this.canvas.on("mouse:move",this.mouseMoveHandler)},mouseMoveHandler:function(t){if(this.__isMousedown&&this.isEditing){var e=this.getSelectionStartFromPointer(t.e),i=this.selectionStart,r=this.selectionEnd;(e===this.__selectionStartOnMouseDown&&i!==r||i!==e&&r!==e)&&(e>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=e):(this.selectionStart=e,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===r||(this.restartCursorIfNeeded(),this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}},_setEditingProps:function(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0},fromStringToGraphemeSelection:function(t,e,i){var r=i.slice(0,t),n=E.util.string.graphemeSplit(r).length;if(t===e)return{selectionStart:n,selectionEnd:n};var s=i.slice(t,e);return{selectionStart:n,selectionEnd:n+E.util.string.graphemeSplit(s).length}},fromGraphemeToStringSelection:function(t,e,i){var r=i.slice(0,t).join("").length;return t===e?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+i.slice(t,e).join("").length}},_updateTextarea:function(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){var t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}},updateFromTextArea:function(){if(this.hiddenTextarea){this.cursorOffsetCache={},this.text=this.hiddenTextarea.value,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords());var t=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value);this.selectionEnd=this.selectionStart=t.selectionEnd,this.inCompositionMode||(this.selectionStart=t.selectionStart),this.updateTextareaPosition()}},updateTextareaPosition:function(){if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}},_calcTextareaPosition:function(){if(!this.canvas)return{x:1,y:1};var t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),r=i.lineIndex,n=i.charIndex,s=this.getValueOfPropertyAt(r,n,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+s},l=this.canvas.getRetinaScaling(),c=this.canvas.upperCanvasEl,u=c.width/l,d=c.height/l,f=u-s,g=d-s,_=c.clientWidth/u,p=c.clientHeight/d;return h=E.util.transformPoint(h,a),(h=E.util.transformPoint(h,this.canvas.viewportTransform)).x*=_,h.y*=p,h.x<0&&(h.x=0),h.x>f&&(h.x=f),h.y<0&&(h.y=0),h.y>g&&(h.y=g),h.x+=this.canvas._offset.left,h.y+=this.canvas._offset.top,{left:h.x+"px",top:h.y+"px",fontSize:s+"px",charHeight:s}},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor))},exitEditing:function(){var t=this._textBeforeEdit!==this.text,e=this.hiddenTextarea;return this.selected=!1,this.isEditing=!1,this.selectionEnd=this.selectionStart,e&&(e.blur&&e.blur(),e.parentNode&&e.parentNode.removeChild(e)),this.hiddenTextarea=null,this.abortCursorAnimation(),this._restoreEditingProps(),this._currentCursorOpacity=0,this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.off("mouse:move",this.mouseMoveHandler),this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this},_removeExtraneousStyles:function(){for(var t in this.styles)this._textLines[t]||delete this.styles[t]},removeStyleFromTo:function(t,e){var i,r,n=this.get2DCursorLocation(t,!0),s=this.get2DCursorLocation(e,!0),o=n.lineIndex,a=n.charIndex,h=s.lineIndex,l=s.charIndex;if(o!==h){if(this.styles[o])for(i=a;i<this._unwrappedTextLines[o].length;i++)delete this.styles[o][i];if(this.styles[h])for(i=l;i<this._unwrappedTextLines[h].length;i++)(r=this.styles[h][i])&&(this.styles[o]||(this.styles[o]={}),this.styles[o][a+i-l]=r);for(i=o+1;i<=h;i++)delete this.styles[i];this.shiftLineStyles(h,o-h)}else if(this.styles[o]){r=this.styles[o];var c,u,d=l-a;for(i=a;i<l;i++)delete r[i];for(u in this.styles[o])(c=parseInt(u,10))>=l&&(r[c-d]=r[u],delete r[u])}},shiftLineStyles:function(t,e){var i=T(this.styles);for(var r in this.styles){var n=parseInt(r,10);n>t&&(this.styles[n+e]=i[n],i[n-e]||delete this.styles[n])}},restartCursorIfNeeded:function(){this._currentTickState&&!this._currentTickState.isAborted&&this._currentTickCompleteState&&!this._currentTickCompleteState.isAborted||this.initDelayedCursor()},insertNewlineStyleObject:function(t,e,i,r){var n,s={},o=!1,a=this._unwrappedTextLines[t].length===e;for(var h in i||(i=1),this.shiftLineStyles(t,i),this.styles[t]&&(n=this.styles[t][0===e?e:e-1]),this.styles[t]){var l=parseInt(h,10);l>=e&&(o=!0,s[l-e]=this.styles[t][h],a&&0===e||delete this.styles[t][h])}var c=!1;for(o&&!a&&(this.styles[t+i]=s,c=!0),c&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:T(r[i-1])}:n?this.styles[t+i]={0:T(n)}:delete this.styles[t+i],i--;this._forceClearCache=!0},insertCharStyleObject:function(t,e,i,r){this.styles||(this.styles={});var n=this.styles[t],s=n?T(n):{};for(var o in i||(i=1),s){var a=parseInt(o,10);a>=e&&(n[a+i]=s[a],s[a-i]||delete n[a])}if(this._forceClearCache=!0,r)for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=T(r[i]));else if(n)for(var h=n[e?e-1:1];h&&i--;)this.styles[t][e+i]=T(h)},insertNewStyleBlock:function(t,e,i){for(var r=this.get2DCursorLocation(e,!0),n=[0],s=0,o=0;o<t.length;o++)"\n"===t[o]?n[++s]=0:n[s]++;for(n[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,n[0],i),i=i&&i.slice(n[0]+1)),s&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+n[0],s),o=1;o<s;o++)n[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,n[o],i):i&&this.styles[r.lineIndex+o]&&i[0]&&(this.styles[r.lineIndex+o][0]=i[0]),i=i&&i.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,n[o],i)},setSelectionStartEndWithShift:function(t,e,i){i<=t?(e===t?this._selectionDirection="left":"right"===this._selectionDirection&&(this._selectionDirection="left",this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?"right"===this._selectionDirection?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection="right":"left"===this._selectionDirection&&(this._selectionDirection="right",this.selectionStart=e),this.selectionEnd=i)},setSelectionInBoundaries:function(){var t=this.text.length;this.selectionStart>t?this.selectionStart=t:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>t?this.selectionEnd=t:this.selectionEnd<0&&(this.selectionEnd=0)}}),E.util.object.extend(E.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(t){if(this.canvas){this.__newClickTime=+new Date;var e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),this._stopEvent(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))},tripleClickHandler:function(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(t.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(t){!this.canvas||!this.editable||t.e.button&&1!==t.e.button||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(t){if(this.__isMousedown=!1,!(!this.editable||this.group||t.transform&&t.transform.actionPerformed||t.e.button&&1!==t.e.button)){if(this.canvas){var e=this.canvas._activeObject;if(e&&e!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(t.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(t){for(var e,i=this.getLocalPointer(t),r=0,n=0,s=0,o=0,a=0,h=0,l=this._textLines.length;h<l&&s<=i.y;h++)s+=this.getHeightOfLine(h)*this.scaleY,a=h,h>0&&(o+=this._textLines[h-1].length+this.missingNewlineOffset(h-1));n=this._getLineLeftOffset(a)*this.scaleX,e=this._textLines[a],"rtl"===this.direction&&(i.x=this.width*this.scaleX-i.x+n);for(var c=0,u=e.length;c<u&&(r=n,(n+=this.__charBounds[a][c].kernedWidth*this.scaleX)<=i.x);c++)o++;return this._getNewSelectionStartFromOffset(i,r,n,o,u)},_getNewSelectionStartFromOffset:function(t,e,i,r,n){var s=t.x-e,o=i-t.x,a=r+(o>s||o<0?0:1);return this.flipX&&(a=n-a),a>this._text.length&&(a=this._text.length),a}}),E.util.object.extend(E.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=E.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var t=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+t.top+"; left: "+t.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uff70top: "+t.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):E.document.body.appendChild(this.hiddenTextarea),E.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),E.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),E.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),E.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),E.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),E.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),E.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),E.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),E.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(E.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(this.isEditing){var e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())},onInput:function(t){var e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),this.isEditing){var i,r,n,s,o,a=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,h=this._text.length,l=a.length,c=l-h,u=this.selectionStart,d=this.selectionEnd,f=u!==d;if(""===this.hiddenTextarea.value)return this.styles={},this.updateFromTextArea(),this.fire("changed"),void(this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll()));var g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),_=u>g.selectionStart;f?(i=this._text.slice(u,d),c+=d-u):l<h&&(i=_?this._text.slice(d+c,d):this._text.slice(u,u-c)),r=a.slice(g.selectionEnd-c,g.selectionEnd),i&&i.length&&(r.length&&(n=this.getSelectionStyles(u,u+1,!1),n=r.map((function(){return n[0]}))),f?(s=u,o=d):_?(s=d-i.length,o=d):(s=d,o=d+i.length),this.removeStyleFromTo(s,o)),r.length&&(e&&r.join("")===E.copiedText&&!E.disableStyleCopyPaste&&(n=E.copiedTextStyle),this.insertNewStyleBlock(r,u,n)),this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())}},onCompositionStart:function(){this.inCompositionMode=!0},onCompositionEnd:function(){this.inCompositionMode=!1},onCompositionUpdate:function(t){this.compositionStart=t.target.selectionStart,this.compositionEnd=t.target.selectionEnd,this.updateTextareaPosition()},copy:function(){this.selectionStart!==this.selectionEnd&&(E.copiedText=this.getSelectedText(),E.disableStyleCopyPaste?E.copiedTextStyle=null:E.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0)},paste:function(){this.fromPaste=!0},_getClipboardData:function(t){return t&&t.clipboardData||E.window.clipboardData},_getWidthBeforeCursor:function(t,e){var i,r=this._getLineLeftOffset(t);return e>0&&(r+=(i=this.__charBounds[t][e-1]).left+i.width),r},getDownCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),n=r.lineIndex;if(n===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;var s=r.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n+1,o);return this._textLines[n].slice(s).length+a+1+this.missingNewlineOffset(n)},_getSelectionForOffset:function(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(t,e){var i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),n=r.lineIndex;if(0===n||t.metaKey||33===t.keyCode)return-i;var s=r.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n-1,o),h=this._textLines[n].slice(0,s),l=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+a-h.length+(1-l)},_getIndexOnLine:function(t,e){for(var i,r,n=this._textLines[t],s=this._getLineLeftOffset(t),o=0,a=0,h=n.length;a<h;a++)if((s+=i=this.__charBounds[t][a].width)>e){r=!0;var l=s-i,c=s,u=Math.abs(l-e);o=Math.abs(c-e)<u?a:a-1;break}return r||(o=n.length-1),o},moveCursorDown:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)},moveCursorUp:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)},_moveCursorUpOrDown:function(t,e){var i=this["get"+t+"CursorOffset"](e,"right"===this._selectionDirection);e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(t){var e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t},moveCursorWithoutShift:function(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t},moveCursorLeft:function(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)},_move:function(t,e,i){var r;if(t.altKey)r=this["findWordBoundary"+i](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;r=this["findLineBoundary"+i](this[e])}if(void 0!==typeof r&&this[e]!==r)return this[e]=r,!0},_moveLeft:function(t,e){return this._move(t,e,"Left")},_moveRight:function(t,e){return this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){var e=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e},moveCursorLeftWithShift:function(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection="left",this._moveLeft(t,"selectionStart")):void 0},moveCursorRight:function(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)},_moveCursorLeftOrRight:function(t,e){var i="moveCursor"+t+"With";this._currentCursorOpacity=1,e.shiftKey?i+="Shift":i+="outShift",this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection="right",this._moveRight(t,"selectionEnd")):void 0},moveCursorRightWithoutShift:function(t){var e=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e},removeChars:function(t,e){void 0===e&&(e=t+1),this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(t,e,i,r){void 0===r&&(r=i),r>i&&this.removeStyleFromTo(i,r);var n=E.util.string.graphemeSplit(t);this.insertNewStyleBlock(n,i,e),this._text=[].concat(this._text.slice(0,i),n,this._text.slice(r)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var t=E.util.toFixed,e=/  +/g;E.util.object.extend(E.Text.prototype,{_toSVG:function(){var t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)},toSVG:function(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(t){var e=this.getSvgTextDecoration(this);return[t.textBgRects.join(""),'\t\t<text xml:space="preserve" ',this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",e?'text-decoration="'+e+'" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",t.textSpans.join(""),"</text>\n"]},_getSVGTextAndBg:function(t,e){var i,r=[],n=[],s=t;this._setSVGBg(n);for(var o=0,a=this._textLines.length;o<a;o++)i=this._getLineLeftOffset(o),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(n,o,e+i,s),this._setSVGTextLineText(r,o,e+i,s),s+=this.getHeightOfLine(o);return{textSpans:r,textBgRects:n}},_createTextCharSpan:function(i,r,n,s){var o=i!==i.trim()||i.match(e),a=this.getSvgSpanStyles(r,o),h=a?'style="'+a+'"':"",l=r.deltaY,c="",u=E.Object.NUM_FRACTION_DIGITS;return l&&(c=' dy="'+t(l,u)+'" '),['<tspan x="',t(n,u),'" y="',t(s,u),'" ',c,h,">",E.util.string.escapeXml(i),"</tspan>"].join("")},_setSVGTextLineText:function(t,e,i,r){var n,s,o,a,h,l=this.getHeightOfLine(e),c=-1!==this.textAlign.indexOf("justify"),u="",d=0,f=this._textLines[e];r+=l*(1-this._fontSizeFraction)/this.lineHeight;for(var g=0,_=f.length-1;g<=_;g++)h=g===_||this.charSpacing,u+=f[g],o=this.__charBounds[e][g],0===d?(i+=o.kernedWidth-o.width,d+=o.width):d+=o.kernedWidth,c&&!h&&this._reSpaceAndTab.test(f[g])&&(h=!0),h||(n=n||this.getCompleteStyleDeclaration(e,g),s=this.getCompleteStyleDeclaration(e,g+1),h=this._hasStyleChangedForSvg(n,s)),h&&(a=this._getStyleDeclaration(e,g)||{},t.push(this._createTextCharSpan(u,a,i,r)),u="",n=s,i+=d,d=0)},_pushTextBgRect:function(e,i,r,n,s,o){var a=E.Object.NUM_FRACTION_DIGITS;e.push("\t\t<rect ",this._getFillAttributes(i),' x="',t(r,a),'" y="',t(n,a),'" width="',t(s,a),'" height="',t(o,a),'"></rect>\n')},_setSVGTextLineBg:function(t,e,i,r){for(var n,s,o=this._textLines[e],a=this.getHeightOfLine(e)/this.lineHeight,h=0,l=0,c=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),u=0,d=o.length;u<d;u++)n=this.__charBounds[e][u],(s=this.getValueOfPropertyAt(e,u,"textBackgroundColor"))!==c?(c&&this._pushTextBgRect(t,c,i+l,r,h,a),l=n.left,h=n.width,c=s):h+=n.kernedWidth;s&&this._pushTextBgRect(t,s,i+l,r,h,a)},_getFillAttributes:function(t){var e=t&&"string"==typeof t?new E.Color(t):"";return e&&e.getSource()&&1!==e.getAlpha()?'opacity="'+e.getAlpha()+'" fill="'+e.setAlpha(1).toRgb()+'"':'fill="'+t+'"'},_getSVGLineTopOffset:function(t){for(var e,i=0,r=0;r<t;r++)i+=this.getHeightOfLine(r);return e=this.getHeightOfLine(r),{lineTop:i,offset:(this._fontSizeMult-this._fontSizeFraction)*e/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(t){return E.Object.prototype.getSvgStyles.call(this,t)+" white-space: pre;"}})}(),function(t){var e=t.fabric||(t.fabric={});e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:e.Text.prototype._dimensionAffectingProps.concat("width"),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),-1!==this.textAlign.indexOf("justify")&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(t){for(var e=0,i=0,r=0,n={},s=0;s<t.graphemeLines.length;s++)"\n"===t.graphemeText[r]&&s>0?(i=0,r++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[r])&&s>0&&(i++,r++),n[s]={line:e,offset:i},r+=t.graphemeLines[s].length,i+=t.graphemeLines[s].length;return n},styleHas:function(t,i){if(this._styleMap&&!this.isWrapping){var r=this._styleMap[i];r&&(i=r.line)}return e.Text.prototype.styleHas.call(this,t,i)},isEmptyStyles:function(t){if(!this.styles)return!0;var e,i,r=0,n=!1,s=this._styleMap[t],o=this._styleMap[t+1];for(var a in s&&(t=s.line,r=s.offset),o&&(n=o.line===t,e=o.offset),i=void 0===t?this.styles:{line:this.styles[t]})for(var h in i[a])if(h>=r&&(!n||h<e))for(var l in i[a][h])return!1;return!0},_getStyleDeclaration:function(t,e){if(this._styleMap&&!this.isWrapping){var i=this._styleMap[t];if(!i)return null;t=i.line,e=i.offset+e}return this.callSuper("_getStyleDeclaration",t,e)},_setStyleDeclaration:function(t,e,i){var r=this._styleMap[t];t=r.line,e=r.offset+e,this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line,e=i.offset+e,delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return!!this.styles[e.line]},_setLineStyle:function(t){var e=this._styleMap[t];this.styles[e.line]={}},_wrapText:function(t,e){var i,r=[];for(this.isWrapping=!0,i=0;i<t.length;i++)r=r.concat(this._wrapLine(t[i],i,e));return this.isWrapping=!1,r},_measureWord:function(t,e,i){var r,n=0;i=i||0;for(var s=0,o=t.length;s<o;s++)n+=this._getGraphemeBox(t[s],e,s+i,r,!0).kernedWidth,r=t[s];return n},_wrapLine:function(t,i,r,n){var s=0,o=this.splitByGrapheme,a=[],h=[],l=o?e.util.string.graphemeSplit(t):t.split(this._wordJoiners),c="",u=0,d=o?"":" ",f=0,g=0,_=0,p=!0,m=this._getWidthOfCharSpacing();n=n||0,0===l.length&&l.push([]),r-=n;for(var v=0;v<l.length;v++)c=o?l[v]:e.util.string.graphemeSplit(l[v]),f=this._measureWord(c,i,u),u+=c.length,(s+=g+f-m)>r&&!p?(a.push(h),h=[],s=f,p=!0):s+=m,p||o||h.push(d),h=h.concat(c),g=o?0:this._measureWord([d],i,u),u++,p=!1,f>_&&(_=f);return v&&a.push(h),_+n>this.dynamicMinWidth&&(this.dynamicMinWidth=_-m+n),a},isEndOfWrapping:function(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line},missingNewlineOffset:function(t){return this.splitByGrapheme?this.isEndOfWrapping(t)?1:0:1},_splitTextIntoLines:function(t){for(var i=e.Text.prototype._splitTextIntoLines.call(this,t),r=this._wrapText(i.lines,this.width),n=new Array(r.length),s=0;s<r.length;s++)n[s]=r[s].join("");return i.lines=n,i.graphemeLines=r,i},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var t={};for(var e in this._styleMap)this._textLines[e]&&(t[this._styleMap[e].line]=1);for(var e in this.styles)t[e]||delete this.styles[e]},toObject:function(t){return this.callSuper("toObject",["minWidth","splitByGrapheme"].concat(t))}}),e.Textbox.fromObject=function(t,i){return e.Object._fromObject("Textbox",t,i,"text")}}(e),function(){var t=E.controlsUtils,e=t.scaleSkewCursorStyleHandler,i=t.scaleCursorStyleHandler,r=t.scalingEqually,n=t.scalingYOrSkewingX,s=t.scalingXOrSkewingY,o=t.scaleOrSkewActionName,a=E.Object.prototype.controls;if(a.ml=new E.Control({x:-.5,y:0,cursorStyleHandler:e,actionHandler:s,getActionName:o}),a.mr=new E.Control({x:.5,y:0,cursorStyleHandler:e,actionHandler:s,getActionName:o}),a.mb=new E.Control({x:0,y:.5,cursorStyleHandler:e,actionHandler:n,getActionName:o}),a.mt=new E.Control({x:0,y:-.5,cursorStyleHandler:e,actionHandler:n,getActionName:o}),a.tl=new E.Control({x:-.5,y:-.5,cursorStyleHandler:i,actionHandler:r}),a.tr=new E.Control({x:.5,y:-.5,cursorStyleHandler:i,actionHandler:r}),a.bl=new E.Control({x:-.5,y:.5,cursorStyleHandler:i,actionHandler:r}),a.br=new E.Control({x:.5,y:.5,cursorStyleHandler:i,actionHandler:r}),a.mtr=new E.Control({x:0,y:-.5,actionHandler:t.rotationWithSnapping,cursorStyleHandler:t.rotationStyleHandler,offsetY:-40,withConnection:!0,actionName:"rotate"}),E.Textbox){var h=E.Textbox.prototype.controls={};h.mtr=a.mtr,h.tr=a.tr,h.br=a.br,h.tl=a.tl,h.bl=a.bl,h.mt=a.mt,h.mb=a.mb,h.mr=new E.Control({x:.5,y:0,actionHandler:t.changeWidth,cursorStyleHandler:e,actionName:"resizing"}),h.ml=new E.Control({x:-.5,y:0,actionHandler:t.changeWidth,cursorStyleHandler:e,actionName:"resizing"})}}()},192:()=>{},898:()=>{},245:()=>{}},L={};function F(t){var e=L[t];if(void 0!==e)return e.exports;var i=L[t]={exports:{}};return M[t](i,i.exports,F),i.exports}F.d=(t,e)=>{for(var i in e)F.o(e,i)&&!F.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},F.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var P={};(()=>{let t;F.d(P,{R:()=>t}),t="undefined"!=typeof document&&"undefined"!=typeof window?F(653).fabric:{version:"5.2.1"}})();var k=P.R;const B="undefined"==typeof self;let N,j,U,V,G;if("undefined"!=typeof navigator&&(N=navigator,j=N.userAgent,U=N.platform,V=N.mediaDevices),!B){const t={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:N.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},e={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:U,search:"Win"},Mac:{str:U},Linux:{str:U}};let i="unknownBrowser",r=0,n="unknownOS";for(let e in t){const n=t[e]||{};let s=n.str||j,o=n.search||e,a=n.verStr||j,h=n.verSearch||e;if(h instanceof Array||(h=[h]),-1!=s.indexOf(o)){i=e;for(let t of h){let e=a.indexOf(t);if(-1!=e){r=parseFloat(a.substring(e+t.length+1));break}}break}}for(let t in e){const i=e[t]||{};let r=i.str||j,s=i.search||t;if(-1!=r.indexOf(s)){n=t;break}}"Linux"==n&&-1!=j.indexOf("Windows NT")&&(n="HarmonyOS"),G={browser:i,version:r,OS:n}}B&&(G={browser:"ssr",version:0,OS:"ssr"});const W="undefined"!=typeof WebAssembly&&j&&!(/Safari/.test(j)&&!/Chrome/.test(j)&&/\(.+\s11_2_([2-6]).*\)/.test(j)),H=!("undefined"==typeof Worker),Y=!(!V||!V.getUserMedia),X=async()=>{let t=!1;if(Y)try{(await V.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()})),t=!0}catch(t){}return t};"Chrome"===G.browser&&G.version>66||"Safari"===G.browser&&G.version>13||"OPR"===G.browser&&G.version>43||"Edge"===G.browser&&G.version;const z=(()=>{if(!B&&document.currentScript){let t=document.currentScript.src,e=t.indexOf("?");if(-1!=e)t=t.substring(0,e);else{let e=t.indexOf("#");-1!=e&&(t=t.substring(0,e))}return t.substring(0,t.lastIndexOf("/")+1)}return"./"})();class Z{get mediaType(){return this._mediaType}get drawingLayerId(){return this._drawingLayerId}constructor(t,e){this._zIndex=null,this._drawingLayer=null,this._drawingLayerId=null,this._mapStyle=new Map,this.mapEvent_Callbacks=new Map([["selected",new Map],["deselected",new Map],["mousedown",new Map],["mouseup",new Map],["dblclick",new Map],["mouseover",new Map],["mouseout",new Map]]),this.mapNoteName_Content=new Map([]),this.isDrawingItem=!0,this._setFabricObject(t),this._mediaType=t.type,this.styleSelector="default",this.styleId=e}_setFabricObject(t){this._fabricObject=t,this._fabricObject.on("selected",(()=>{this.styleSelector="selected"})),this._fabricObject.on("deselected",(()=>{this._fabricObject.canvas&&this._fabricObject.canvas.getActiveObjects().includes(this._fabricObject)?this.styleSelector="selected":this.styleSelector="default","textbox"===this._fabricObject.type&&(this._fabricObject.isEditing&&this._fabricObject.exitEditing(),this._fabricObject.selected=!1)})),t.getDrawingItem=()=>this}_getFabricObject(){return this._fabricObject}_on(t,e){if(!e)return;const i=t.toLowerCase(),r=this.mapEvent_Callbacks.get(i);if(!r)throw new Error(`Event '${t}' does not exist.`);let n=r.get(e);n||(n=t=>{const i=t.e;if(!i)return void(e&&e.apply(this,[{targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null}]));const r={targetItem:this,itemClientX:null,itemClientY:null,itemPageX:null,itemPageY:null};if(this._drawingLayer){let t,e,n,s;const o=i.target.getBoundingClientRect();t=o.left,e=o.top,n=t+window.scrollX,s=e+window.scrollY;const a=this._drawingLayer.fabricCanvas.lowerCanvasEl.width,h=this._drawingLayer.fabricCanvas.lowerCanvasEl.height,l=parseFloat(window.getComputedStyle(this._drawingLayer.fabricCanvas.lowerCanvasEl).width),c=parseFloat(window.getComputedStyle(this._drawingLayer.fabricCanvas.lowerCanvasEl).height),u=l/c,d=a/h,f=this._drawingLayer._getObjectFit();let g,_,p,m,v=1;if("contain"===f)u<d?(v=l/a,g=t+this.get("x")*v,_=e+this.get("y")*v+(c-h*v)/2,p=n+this.get("x")*v,m=s+this.get("y")*v+(c-h*v)/2):(v=c/h,g=t+this.get("x")*v+(l-a*v)/2,_=e+this.get("y")*v,p=n+this.get("x")*v+(l-a*v)/2,m=s+this.get("y")*v);else if("cover"===f)if(u<d){v=c/h;let i=this.get("x")*v-(a*v-l)/2;i=Math.max(i,0),i=Math.min(i,l),g=t+i,_=e+this.get("y")*v,p=n+i,m=s+this.get("y")*v}else{v=l/a;let i=this.get("y")*v-(h*v-c)/2;i=Math.max(i,0),i=Math.min(i,c),g=t+this.get("x")*v,_=e+i,p=n+this.get("x")*v,m=s+i}r.itemClientX=Math.round(g),r.itemClientY=Math.round(_),r.itemPageX=Math.round(p),r.itemPageY=Math.round(m)}for(let t of Object.getOwnPropertyNames(r))Object.defineProperty(i,t,{value:r[t],writable:!0});e&&e.apply(this,[i])},r.set(e,n),this._fabricObject.on("dblclick"===i?"mousedblclick":i,n))}on(t,e){this._on(t,e)}_off(t,e){const i=t.toLowerCase(),r=this.mapEvent_Callbacks.get(i);if(!r)throw new Error(`Event '${t}' does not exist.`);let n=r.get(e);n&&(r.delete(e),this._fabricObject.off("dblclick"===i?"mousedblclick":i,n))}off(t,e){this._off(t,e)}_setEditable(t){const e=this._fabricObject;t?(e.selectable=!0,e.hasControls=!0,e.hoverCursor=null):(e.selectable=!1,e.hasControls=!1,e.hoverCursor="default")}hasNote(t){return this.mapNoteName_Content.has(t)}addNote(t,e){if(this.hasNote(t.name)&&!e)throw new Error("A note with the same name already exists, please use a different name.");const i=t.content?JSON.parse(JSON.stringify(t.content)):t.content;this.mapNoteName_Content.set(t.name,[i])}getNote(t){const e=this.mapNoteName_Content.get(t);return e?1===e.length?{name:t,content:e[0]?JSON.parse(JSON.stringify(e[0])):e[0]}:{name:t,content:JSON.parse(JSON.stringify(e))}:null}getNotes(){const t=[];for(let e of this.mapNoteName_Content){let i=1===e[1].length?e[1][0]:e[1];i=i?JSON.parse(JSON.stringify(i)):i,t.push({name:e[0],content:i})}return t}updateNote(t,e,i){const r=this.mapNoteName_Content.get(t);if(!r)throw new Error("The note name does not exist.");i||(r.length=0),e=e?JSON.parse(JSON.stringify(e)):e,r.push(e)}deleteNote(t){this.mapNoteName_Content.delete(t)}clearNotes(){this.mapNoteName_Content.clear()}_extendSet(t,e){return!1}_extendGet(t){}set(t,e){if(!this._extendSet(t,e))if("x"===t){const t=this._fabricObject.group;t?(this._fabricObject.set("left",e-t.left-t.width/2),t.addWithUpdate()):this._fabricObject.set("left",e)}else if("y"===t){const t=this._fabricObject.group;t?(this._fabricObject.set("top",e-t.top-t.height/2),t.addWithUpdate()):this._fabricObject.set("top",e)}else"styleId"===t?this.styleId=e:this._fabricObject.set(t,e);["vertices","startPoint","endPoint","x","y","left","top","width","height","scaleX","scaleY","skewX","skewY","padding","angle","strokeWidth"].includes(t)&&this._fabricObject.setCoords()}get(t){let e=this._extendGet(t);if(void 0===e)if("x"===t){const t=this._fabricObject.group;e=t?this._fabricObject.get("left")+t.left+t.width/2:this._fabricObject.get("left")}else if("y"===t){const t=this._fabricObject.group;e=t?this._fabricObject.get("top")+t.top+t.height/2:this._fabricObject.get("top")}else e=["type","mediaType"].includes(t)?this.mediaType:"styleSelector"===t?this.styleSelector:"styleId"===t?this.styleId:"drawingLayerId"===t?this.drawingLayerId:this._fabricObject.get(t);return e}setAttribute(t,e){this.set(t,e)}getAttribute(t){return this.get(t)}}function J(t,e,i){let r=i.points[this.pointIndex].x-i.pathOffset.x,n=i.points[this.pointIndex].y-i.pathOffset.y;return k.util.transformPoint({x:r,y:n},i.calcTransformMatrix())}function K(t){let e=new k.Point(t.strokeUniform?1/t.scaleX:1,t.strokeUniform?1/t.scaleY:1).multiply(t.strokeWidth);return new k.Point(t.width+e.x,t.height+e.y)}function q(t,e,i,r){let n=e.target,s=n.controls[n.__corner],o=n.toLocalPoint(new k.Point(i,r),"center","center"),a=K(n),h=n._getTransformedDimensions(0,0),l={x:o.x*a.x/h.x+n.pathOffset.x,y:o.y*a.y/h.y+n.pathOffset.y};return n.points[s.pointIndex]=l,!0}function Q(t,e){return function(i,r,n,s){let o=r.target,a=k.util.transformPoint({x:o.points[t].x-o.pathOffset.x,y:o.points[t].y-o.pathOffset.y},o.calcTransformMatrix()),h=e(i,r,n,s);o._setPositionDimensions({});let l=K(o),c=(o.points[t].x-o.pathOffset.x)/l.x,u=(o.points[t].y-o.pathOffset.y)/l.y;return o.setPositionByOrigin(a,c+.5,u+.5),h}}Z.arrMediaTypes=["rect","arc","polygon","image","text","line","path"],Z.arrStyleSelectors=["default","selected"];class $ extends Z{constructor(t,e){super(new k.Polygon(t,{objectCaching:!1}),e);const i=this._fabricObject;let r=i.points.length-1;i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new k.Control({positionHandler:J,actionHandler:Q(i>0?i-1:r,q),actionName:"modifyPolygon",pointIndex:i}),t}),{})}_extendSet(t,e){if("vertices"===t){const t=this._fabricObject;if(t.group){const i=t.group;t.points=e.map((t=>({x:t.x-i.left-i.width/2,y:t.y-i.top-i.height/2}))),i.addWithUpdate()}else t.points=e;const i=t.points.length-1;return t.controls=t.points.reduce((function(t,e,r){return t["p"+r]=new k.Control({positionHandler:J,actionHandler:Q(r>0?r-1:i,q),actionName:"modifyPolygon",pointIndex:r}),t}),{}),t._setPositionDimensions({}),!0}}_extendGet(t){if("vertices"===t){const t=[],e=this._fabricObject;if(e.selectable&&!e.group)for(let i in e.oCoords)t.push({x:e.oCoords[i].x,y:e.oCoords[i].y});else for(let i of e.points){let r=i.x-e.pathOffset.x,n=i.y-e.pathOffset.y;const s=k.util.transformPoint({x:r,y:n},e.calcTransformMatrix());t.push({x:s.x,y:s.y})}return t}}}const tt=t=>{let e=(t=>t.split("\n").map((t=>t.split("\t"))))(t);return(t=>{for(let e=0;;e++){let i=-1;for(let r=0;r<t.length;r++){let n=t[r][e];void 0!==n&&n.length>i&&(i=n.length)}if(-1===i)break;for(let r=0;r<t.length;r++){if(e>=t[r].length-1)continue;let n=" ".repeat(i+2-t[r][e].length);t[r][e]=t[r][e].concat(n)}}})(e),(t=>{let e="";for(let i=0;i<t.length;i++)e=e.concat(...t[i],i===t.length-1?"":"\n");return e})(e)};class et extends Z{constructor(t,e,i,r,n){if("number"!=typeof r||r<=0)throw new RangeError("Invalid width.");super(new k.Textbox(tt(t),{left:e,top:i,width:r}),n),this._mediaType="text",this._text=t}_extendSet(t,e){if("text"===t)return this._text=e,this._fabricObject.set("text",tt(e)),!0}_extendGet(t){if("text"===t)return this._text}}"undefined"!=typeof document&&"undefined"!=typeof window&&(k.StaticCanvas.prototype.dispose=function(){return this.isRendering&&(k.util.cancelAnimFrame(this.isRendering),this.isRendering=0),this.forEachObject((function(t){t.dispose&&t.dispose()})),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove("lower-canvas"),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute("width",this.width),this.lowerCanvasEl.setAttribute("height",this.height),k.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},k.Object.prototype.transparentCorners=!1,k.Object.prototype.cornerSize=20,k.Object.prototype.touchCornerSize=100,k.Object.prototype.cornerColor="rgb(254,142,20)",k.Object.prototype.cornerStyle="circle",k.Object.prototype.strokeUniform=!0,k.Object.prototype.hasBorders=!1,k.Canvas.prototype.containerClass="",k.Canvas.prototype.getPointer=function(t,e){if(this._absolutePointer&&!e)return this._absolutePointer;if(this._pointer&&e)return this._pointer;var i,r=this.upperCanvasEl,n=k.util.getPointer(t,r),s=r.getBoundingClientRect(),o=s.width||0,a=s.height||0;o&&a||("top"in s&&"bottom"in s&&(a=Math.abs(s.top-s.bottom)),"right"in s&&"left"in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=this.restorePointerVpt(n));var h=this.getRetinaScaling();if(1!==h&&(n.x/=h,n.y/=h),0!==o&&0!==a){var l=window.getComputedStyle(r).objectFit,c=r.width,u=r.height,d=o,f=a;i={width:c/d,height:u/f};var g,_,p=c/u,m=d/f;return"contain"===l?p>m?(g=d,_=d/p,{x:n.x*i.width,y:(n.y-(f-_)/2)*i.width}):(g=f*p,_=f,{x:(n.x-(d-g)/2)*i.height,y:n.y*i.height}):"cover"===l?p>m?{x:(c-i.height*d)/2+n.x*i.height,y:n.y*i.height}:{x:n.x*i.width,y:(u-i.width*f)/2+n.y*i.width}:{x:n.x*i.width,y:n.y*i.height}}return i={width:1,height:1},{x:n.x*i.width,y:n.y*i.height}},k.Canvas.prototype._onTouchStart=function(t){var e=this.findTarget(t);!this.allowTouchScrolling&&t.cancelable&&t.preventDefault&&t.preventDefault(),e&&t.cancelable&&t.preventDefault&&t.preventDefault(),null===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),this._resetTransformEventData();var i=this.upperCanvasEl,r=this._getEventPrefix();k.util.addListener(k.document,"touchend",this._onTouchEnd,{passive:!1}),k.util.addListener(k.document,"touchmove",this._onMouseMove,{passive:!1}),k.util.removeListener(i,r+"down",this._onMouseDown)},k.Textbox.prototype._wrapLine=function(t,e,i,r){const n=t.match(/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/g),s=!(!n||!n.length);var o=0,a=this.splitByGrapheme||s,h=[],l=[],c=a?k.util.string.graphemeSplit(t):t.split(this._wordJoiners),u="",d=0,f=a?"":" ",g=0,_=0,p=0,m=!0,v=this._getWidthOfCharSpacing();r=r||0,0===c.length&&c.push([]),i-=r;for(var y=0;y<c.length;y++)u=a?c[y]:k.util.string.graphemeSplit(c[y]),g=this._measureWord(u,e,d),d+=u.length,(o+=_+g-v)>i&&!m?(h.push(l),l=[],o=g,m=!0):o+=v,m||a||l.push(f),l=l.concat(u),_=a?0:this._measureWord([f],e,d),d++,m=!1,g>p&&(p=g);return y&&h.push(l),p+r>this.dynamicMinWidth&&(this.dynamicMinWidth=p-v+r),h});class it{constructor(t,e,i,r){let n,s;switch(this.mapMediaType_Style=new Map,this.mode="viewer",this.onSelectionChange=null,this._arrDrwaingItem=[],this._arrFabricObject=[],this._visible=!0,t.hasOwnProperty("getFabricCanvas")?this.fabricCanvas=t.getFabricCanvas():(this.fabricCanvas=new k.Canvas(t,Object.assign(r,{allowTouchScrolling:!0})),this.fabricCanvas.setDimensions({width:"100%",height:"100%"},{cssOnly:!0}),this.fabricCanvas.lowerCanvasEl.className="",this.fabricCanvas.upperCanvasEl.className="",this.fabricCanvas.on("selection:created",(function(t){const e=t.selected,i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let r of e){const e=r.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{t.onSelectionChange&&t.onSelectionChange(i,[])}),0)}})),this.fabricCanvas.on("before:selection:cleared",(function(t){const e=this.getActiveObjects(),i=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!i.includes(e)&&i.push(e)}for(let t of i){const i=[];for(let r of e){const e=r.getDrawingItem();e._drawingLayer===t&&i.push(e)}setTimeout((()=>{const e=[];for(let r of i)t.hasDrawingItem(r)&&e.push(r);e.length>0&&t.onSelectionChange&&t.onSelectionChange([],e)}),0)}})),this.fabricCanvas.on("selection:updated",(function(t){const e=t.selected,i=t.deselected,r=[];for(let t of e){const e=t.getDrawingItem()._drawingLayer;e&&!r.includes(e)&&r.push(e)}for(let t of i){const e=t.getDrawingItem()._drawingLayer;e&&!r.includes(e)&&r.push(e)}for(let t of r){const r=[],n=[];for(let i of e){const e=i.getDrawingItem();e._drawingLayer===t&&r.push(e)}for(let e of i){const i=e.getDrawingItem();i._drawingLayer===t&&n.push(i)}setTimeout((()=>{t.onSelectionChange&&t.onSelectionChange(r,n)}),0)}})),this.fabricCanvas.wrapperEl.style.position="absolute",t.getFabricCanvas=()=>this.fabricCanvas),this.id=e,this._mapDrawingStyles=i,e){case 1:n=i.get(1),s=i.get(5);break;case 2:n=i.get(2),s=i.get(6);break;case 3:n=i.get(3),s=i.get(7);break;default:n=i.get(4),s=i.get(8)}for(let t of Z.arrMediaTypes)this.mapMediaType_Style.set(t,{default:n,selected:s})}getId(){return this.id}_getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=this._mapDrawingStyles.get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}setVisible(t){if(t){for(let t of this._arrFabricObject)t.visible=!0;this._visible=!0}else{for(let t of this._arrFabricObject)t.visible=!1;this._visible=!1}this.fabricCanvas.renderAll()}isVisible(){return this._visible}_getItemCurrentStyleId(t){return t.styleId?t.styleId:this.mapMediaType_Style.get(t._mediaType)[t.styleSelector].styleId}_getItemCurrentStyle(t){return t.styleId?this._getDrawingStyle(t.styleId):t._mapStyle.get(t.styleSelector)||null}_changeMediaTypeCurStyleInStyleSelector(t,e,i,r){let n;switch(t){case"rect":n=this.fabricCanvas.getObjects("rect");break;case"arc":n=this.fabricCanvas.getObjects("circle");break;case"polygon":n=this.fabricCanvas.getObjects("polygon");break;case"image":n=this.fabricCanvas.getObjects("image");break;case"text":n=this.fabricCanvas.getObjects("textbox");break;case"line":n=this.fabricCanvas.getObjects("line");break;case"path":n=this.fabricCanvas.getObjects("path")}for(let t of n){if(!this._arrFabricObject.includes(t))continue;const r=t.getDrawingItem();r.styleSelector===e&&this._changeItemStyle(r,i,!0)}r||this.fabricCanvas.renderAll()}_changeItemStyle(t,e,i){if(!t||!e)return;const r=t._getFabricObject();"number"==typeof t.styleId&&(e=this._getDrawingStyle(t.styleId)),r.strokeWidth=e.lineWidth,"fill"===e.paintMode?(r.fill=e.fillStyle,r.stroke=e.fillStyle):"stroke"===e.paintMode?(r.fill="transparent",r.stroke=e.strokeStyle):"strokeAndFill"===e.paintMode&&(r.fill=e.fillStyle,r.stroke=e.strokeStyle),r.fontFamily&&(r.fontFamily=e.fontFamily),r.fontSize&&(r.fontSize=e.fontSize),r.group||(r.dirty=!0),i||this.fabricCanvas.renderAll()}_updateGroupItem(t,e,i){if(!t||!e)return;const r=t.getChildItems();if("add"===i){if(r.includes(e))return;const i=e._getFabricObject();if(this.fabricCanvas.getObjects().includes(i)){if(!this._arrFabricObject.includes(i))throw new Error("Existed in other drawing layers.");e._zIndex=null}else{let i;if(e.styleId)i=this._getDrawingStyle(e.styleId);else{i=this.mapMediaType_Style.get(e._mediaType)[t.styleSelector];const r=()=>{this._changeItemStyle(e,this.mapMediaType_Style.get(e._mediaType).selected,!0)},n=()=>{this._changeItemStyle(e,this.mapMediaType_Style.get(e._mediaType).default,!0)};e._on("selected",r),e._on("deselected",n),e._funcChangeStyleToSelected=r,e._funcChangeStyleToDefault=n}e._drawingLayer=this,e._drawingLayerId=this.id,this._changeItemStyle(e,i,!0)}t._fabricObject.addWithUpdate(e._getFabricObject())}else{if("remove"!==i)return;if(!r.includes(e))return;e._zIndex=null,e._drawingLayer=null,e._drawingLayerId=null,e._off("selected",e._funcChangeStyleToSelected),e._off("deselected",e._funcChangeStyleToDefault),e._funcChangeStyleToSelected=null,e._funcChangeStyleToDefault=null,t._fabricObject.removeWithUpdate(e._getFabricObject())}this.fabricCanvas.renderAll()}_addDrawingItem(t,e){let i=t._getFabricObject();const r=this.fabricCanvas.getObjects();let n,s;if(r.includes(i)){if(this._arrFabricObject.includes(i))return;throw new Error("Existed in other drawing layers.")}if("group"===t._mediaType){n=t.getChildItems();for(let t of n)if(t._drawingLayer&&t._drawingLayer!==this)throw new Error("The childItems of DT_Group have existed in other drawing layers.")}if(e&&"object"==typeof e&&!Array.isArray(e))for(let t in e)i.set(t,e[t]);if(n){for(let t of n){const e=this.mapMediaType_Style.get(t._mediaType);for(let i of Z.arrStyleSelectors)t._mapStyle.set(i,e[i]);if(t.styleId)s=this._getDrawingStyle(t.styleId);else{s=e.default;const i=()=>{this._changeItemStyle(t,this.mapMediaType_Style.get(t._mediaType).selected,!0)},r=()=>{this._changeItemStyle(t,this.mapMediaType_Style.get(t._mediaType).default,!0)};t._on("selected",i),t._on("deselected",r),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=r}t._drawingLayer=this,t._drawingLayerId=this.id,this._changeItemStyle(t,s,!0)}i.dirty=!0,this.fabricCanvas.renderAll()}else{const e=this.mapMediaType_Style.get(t._mediaType);for(let i of Z.arrStyleSelectors)t._mapStyle.set(i,e[i]);if(t.styleId)s=this._getDrawingStyle(t.styleId);else{s=e.default;const i=()=>{this._changeItemStyle(t,this.mapMediaType_Style.get(t._mediaType).selected)},r=()=>{this._changeItemStyle(t,this.mapMediaType_Style.get(t._mediaType).default)};t._on("selected",i),t._on("deselected",r),t._funcChangeStyleToSelected=i,t._funcChangeStyleToDefault=r}this._changeItemStyle(t,s)}t._zIndex=this.id,t._drawingLayer=this,t._drawingLayerId=this.id;const o=this._arrFabricObject.length;let a=r.length;if(o)a=r.indexOf(this._arrFabricObject[o-1])+1;else for(let e=0;e<r.length;e++)if(t._zIndex<r[e].getDrawingItem()._zIndex){a=e;break}this._arrDrwaingItem.push(t),this._arrFabricObject.push(i),this._visible?i.visible=!0:i.visible=!1,this.fabricCanvas.insertAt(i,a,!1)}addDrawingItem(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");if("viewer"===this.mode)t._setEditable(!1);else{if("editor"!==this.mode)throw new Error("Illegal 'mode'.");t._setEditable(!0)}this._addDrawingItem(t)}addDrawingItems(t){for(let e of t)this.addDrawingItem(e)}removeDrawingItem(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");if(!this.hasDrawingItem(t))return;if(t._zIndex=null,t._drawingLayer=null,t._drawingLayerId=null,"group"===t._mediaType){const e=t.getChildItems();for(let t of e)t._zIndex=null,t._drawingLayer=null,t._drawingLayerId=null,t._off("selected",t._funcChangeStyleToSelected),t._off("deselected",t._funcChangeStyleToDefault),t._funcChangeStyleToSelected=null,t._funcChangeStyleToDefault=null,t._mapStyle.clear()}else t._off("selected",t._funcChangeStyleToSelected),t._off("deselected",t._funcChangeStyleToDefault),t._funcChangeStyleToSelected=null,t._funcChangeStyleToDefault=null,t._mapStyle.clear();const e=t._getFabricObject();"selected"===t.styleSelector&&(e.group?e.group.removeWithUpdate(e):this.fabricCanvas._activeObject=null,t.styleSelector="default"),this.fabricCanvas.remove(e),this._arrDrwaingItem.splice(this._arrDrwaingItem.indexOf(t),1),this._arrFabricObject.splice(this._arrFabricObject.indexOf(e),1)}removeDrawingItems(t){for(let e of t)this.removeDrawingItem(e)}setDrawingItems(t){this.clearDrawingItems(),this.addDrawingItems(t)}getDrawingItems(t){return t&&"function"==typeof t?this._arrDrwaingItem.filter(t):Array.from(this._arrDrwaingItem)}getSelectedDrawingItems(){const t=this.fabricCanvas.getActiveObjects(),e=[];for(let i of t)this._arrFabricObject.includes(i)&&e.push(i.getDrawingItem());return e}hasDrawingItem(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");return this._arrDrwaingItem.includes(t)}clearDrawingItems(){this.removeDrawingItems(Array.from(this._arrDrwaingItem))}setDrawingStyle(t,e,i){e=e?e.toLocaleLowerCase():"all",i=i?i.toLocaleLowerCase():"all";let r,n=this._getDrawingStyle(t);if("all"===e){const t=this.mapMediaType_Style.keys();for(let e of t)if(r=this.mapMediaType_Style.get(e),"all"===i)for(let t of Z.arrStyleSelectors){this._changeMediaTypeCurStyleInStyleSelector(e,t,n,!0),r[t]=n;for(let e of this._arrDrwaingItem)e._mapStyle.set(t,n)}else{this._changeMediaTypeCurStyleInStyleSelector(e,i,n,!0),r[i]=n;for(let t of this._arrDrwaingItem)t._mapStyle.set(i,n)}this.fabricCanvas.renderAll()}else if(r=this.mapMediaType_Style.get(e),"all"===i)for(let t of Z.arrStyleSelectors){this._changeMediaTypeCurStyleInStyleSelector(e,t,n,!0),r[t]=n;for(let i of this._arrDrwaingItem)i._mediaType===e&&i._mapStyle.set(t,n)}else{this._changeMediaTypeCurStyleInStyleSelector(e,i,n,!0),r[i]=n;for(let t of this._arrDrwaingItem)t._mediaType===e&&t._mapStyle.set(i,n)}}setMode(t){if("viewer"===(t=t.toLocaleLowerCase())){for(let t of this._arrDrwaingItem)t._setEditable(!1);this.fabricCanvas.discardActiveObject(),this.fabricCanvas.renderAll(),this.mode="viewer"}else{if("editor"!==t)throw new RangeError("Invalid value.");for(let t of this._arrDrwaingItem)t._setEditable(!0);this.mode="editor"}this._manager._switchPointerEvent()}getMode(){return this.mode}_setDimensions(t,e){this.fabricCanvas.setDimensions(t,e)}_setObjectFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);this.fabricCanvas.lowerCanvasEl.style.objectFit=t,this.fabricCanvas.upperCanvasEl.style.objectFit=t}_getObjectFit(){return this.fabricCanvas.lowerCanvasEl.style.objectFit}renderAll(){for(let t of this._arrDrwaingItem){const e=this._getItemCurrentStyle(t);this._changeItemStyle(t,e,!0)}this.fabricCanvas.renderAll()}dispose(){this.clearDrawingItems(),1===this._manager._arrDrawingLayer.length&&(this.fabricCanvas.wrapperEl.style.pointerEvents="none",this.fabricCanvas.dispose(),this._arrDrwaingItem.length=0,this._arrFabricObject.length=0)}}class rt{constructor(){this._arrDrawingLayer=[],this._mapDrawingStyles=new Map([[1,{id:1,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[2,{id:2,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[3,{id:3,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[4,{id:4,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}],[5,{id:5,lineWidth:4,fillStyle:"rgba(73, 173, 245, 0.3)",strokeStyle:"rgba(73, 173, 245, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[6,{id:6,lineWidth:2,fillStyle:"rgba(73, 245, 73, 0.3)",strokeStyle:"rgba(73, 245, 73, 0.9)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[7,{id:7,lineWidth:2,fillStyle:"rgba(254, 180, 32, 0.3)",strokeStyle:"rgba(254, 180, 32, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}],[8,{id:8,lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"strokeAndFill",fontFamily:"consolas",fontSize:40}]]),this._defaultStyleTemplate={lineWidth:2,fillStyle:"rgba(245, 236, 73, 0.3)",strokeStyle:"rgba(245, 236, 73, 1)",paintMode:"stroke",fontFamily:"consolas",fontSize:40}}createDrawingStyle(t){if(!t)throw new Error("Invalid style definition.");let e;if(t.hasOwnProperty("id")){if(this._mapDrawingStyles.has(t.id))throw new Error("Existing drawing style id.");e=t.id}else{let t=100;for(;this._mapDrawingStyles.has(t);)t++;e=t}const i=JSON.parse(JSON.stringify(t));i.id=e;for(let t in this._defaultStyleTemplate)i.hasOwnProperty(t)||(i[t]=this._defaultStyleTemplate[t]);return this._mapDrawingStyles.set(e,i),i.id}_getDrawingStyle(t,e){if("number"!=typeof t)throw new Error("Invalid style id.");const i=this._mapDrawingStyles.get(t);return i?e?JSON.parse(JSON.stringify(i)):i:null}getDrawingStyle(t){return this._getDrawingStyle(t,!0)}getDrawingStyles(){return JSON.parse(JSON.stringify(Array.from(this._mapDrawingStyles.values())))}_updateDrawingStyle(t,e){const i=this._mapDrawingStyles.get(t);if(i)for(let t in e)i.hasOwnProperty(t)&&(i[t]=e[t])}updateDrawingStyle(t,e){this._updateDrawingStyle(t,e);for(let t of this._arrDrawingLayer)t.renderAll()}createDrawingLayer(t,e){const i=t=>{for(let e of this._arrDrawingLayer)if(e.getId()===t)return!0;return!1};if(void 0===e){for(let t=100;;t++)if(!i(t)){e=t;break}}else if(i(e))throw new Error("Existed drawing layer id.");const r=new it(t,e,this._mapDrawingStyles,{enableRetinaScaling:!1});return r._manager=this,this._arrDrawingLayer.push(r),this._switchPointerEvent(),r}deleteDrawingLayer(t){const e=this.getDrawingLayer(t);if(!e)return;const i=this._arrDrawingLayer;e.dispose(),i.splice(i.indexOf(e),1),this._switchPointerEvent()}clearDrawingLayers(){for(let t of this._arrDrawingLayer)t.dispose();this._arrDrawingLayer.length=0}getDrawingLayer(t){for(let e of this._arrDrawingLayer)if(e.getId()===t)return e;return null}getDrawingLayers(){return Array.from(this._arrDrawingLayer)}getSelectedDrawingItems(){if(!this._arrDrawingLayer.length)return;const t=this._arrDrawingLayer[0].fabricCanvas.getActiveObjects(),e=[];for(let i of t)e.push(i.getDrawingItem());return e}setDimensions(t,e){this._arrDrawingLayer.length&&this._arrDrawingLayer[0]._setDimensions(t,e)}setObjectFit(t){for(let e of this._arrDrawingLayer)e&&e._setObjectFit(t)}getObjectFit(){return this._arrDrawingLayer.length?this._arrDrawingLayer[0]._getObjectFit():null}setVisible(t){this._arrDrawingLayer.length&&(this._arrDrawingLayer[0].fabricCanvas.wrapperEl.style.display=t?"block":"none")}_switchPointerEvent(){if(this._arrDrawingLayer.length)for(let t of this._arrDrawingLayer)t.getMode()}}class nt{constructor(t){this._controlTarget=null,this._arrUsers=[],this._mapAction_UserArgs=new Map,this._mapProperty_UserValue=new Map,this._mapAction_Callbacks=new Map,this._controlTarget=t}setControlTarget(t){this._controlTarget=t}getControlTarget(){return this._controlTarget}register(t){this._arrUsers.includes(t)||this._arrUsers.push(t)}logout(t){const e=this._arrUsers.indexOf(t);-1!==e&&(this.clearUserDisiredAction({user:t}),this.clearUserDisiredValue({user:t}),this._arrUsers.splice(e,1))}getRegisteredUsers(){return this._arrUsers}ifUserExisted(t){return this._arrUsers.includes(t)}setDisiredValue(t,e,i,r){if(!this._arrUsers.includes(t))throw new Error("Unregistered user.");r&&(this._controlTarget[e]=i),this._mapProperty_UserValue.get(e)?this._mapProperty_UserValue.get(e).set(t,i):this._mapProperty_UserValue.set(e,new Map([[t,i]]))}clearUserDisiredValue(t){if(t&&(t.user||t.property)){if(t.property&&t.user){const e=this._mapProperty_UserValue.get(t.property);if(!e)return;e.delete(t.user)}else if(t.property)this._mapProperty_UserValue.delete(t.property);else if(t.user)for(let e of this._mapProperty_UserValue.values())e.delete(t.user)}else this._mapProperty_UserValue=new Map}getValue(t){if(!this._controlTarget)throw new Error("Control target is not set.");return this._controlTarget[t]}getPropertyDisiredValue(t){if(this._mapProperty_UserValue.get(t)){const e=[],i=this._mapProperty_UserValue.get(t);for(let t of i.values())e.push(t);return e}return null}setDisiredAction(t,e,i,r){if(!this._arrUsers.includes(t))throw new Error("Unregistered user.");return i||(i=[]),r?this._controlTarget[e](...i):(this._mapAction_UserArgs.get(e)?this._mapAction_UserArgs.get(e).set(t,i):this._mapAction_UserArgs.set(e,new Map([[t,i]])),this._render(e))}clearUserDisiredAction(t){if(t&&(t.user||t.actionName)){if(t.actionName&&t.user){const e=this._mapAction_UserArgs.get(t.actionName);if(!e)return;e.delete(t.user)}else if(t.actionName)this._mapAction_UserArgs.delete(t.actionName);else if(t.user)for(let e of this._mapAction_UserArgs.values())e.delete(t.user);this.render()}else this._mapAction_UserArgs=new Map}addCallback(t,e){const i=this._mapAction_Callbacks.get(t);i?i.push(e):this._mapAction_Callbacks.set(t,[e])}removeCallback(t,e){const i=this._mapAction_Callbacks.get(t);if(!i)return;const r=i.indexOf(e);-1!==r&&i.splice(r,1)}clearCallback(t){t?this._mapAction_Callbacks.delete(t):this._mapAction_Callbacks.clear()}_fireCallback(t){const e=this._mapAction_Callbacks.get(t);if(e)for(let t of e){if(!t)return;setTimeout(t.bind(this._controlTarget),0)}}_render(t){const e=this._mapAction_UserArgs.get(t);if(!e)throw new Error("Unrecorded action.");if(e.size===this._arrUsers.length){let i=[];for(let t of e.values())t.length>0&&(i=t);if(this._controlTarget[t]){const e=this._controlTarget[t](...i);return this._mapAction_UserArgs.delete(t),this._fireCallback(t),e}}}render(t){if(t)return this._render(t);for(let t of this._mapAction_UserArgs.keys())this._render(t)}}class st{static multiply(t,e){const i=[];for(let r=0;r<3;r++){const n=e.slice(3*r,3*r+3);for(let e=0;e<3;e++){const r=[t[e],t[e+3],t[e+6]].reduce(((t,e,i)=>t+e*n[i]),0);i.push(r)}}return i}static identity(){return[1,0,0,0,1,0,0,0,1]}static translate(t,e,i){return st.multiply(t,[1,0,0,0,1,0,e,i,1])}static rotate(t,e){var i=Math.cos(e),r=Math.sin(e);return st.multiply(t,[i,-r,0,r,i,0,0,0,1])}static scale(t,e,i){return st.multiply(t,[e,0,0,0,i,0,0,0,1])}}var ot;!function(t){t.GREY="grey",t.GREY32="grey32",t.RGBA="rgba",t.RBGA="rbga",t.GRBA="grba",t.GBRA="gbra",t.BRGA="brga",t.BGRA="bgra"}(ot||(ot={}));const at=(t,e,i,r)=>{if(!i)return t;let n=e+Math.round((t-e)/i)*i;return r&&(n=Math.min(n,r)),n};class ht{static getVersion(){return this._version}static async detectEnvironment(){return await(async()=>({wasm:W,worker:H,getUserMedia:Y,camera:await X(),browser:G.browser,version:G.version,OS:G.OS}))()}static set engineResourcePath(t){if(this._hasEngineResourceLoaded)throw new Error("`engineResourcePath` is not allowed to change after `createInstance` is called.");ht._engineResourcePath=(t=>{if(null==t&&(t="./"),!B){let e=document.createElement("a");e.href=t,t=e.href}return t.endsWith("/")||(t+="/"),t})(t)}static get engineResourcePath(){return this._engineResourcePath}static isStorageAvailable(t){let e;try{e=window[t];const i="__storage_test__";return e.setItem(i,i),e.removeItem(i),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}static isDCEFrame(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&"data"in t&&"region"in t&&"sx"in t&&"sy"in t&&"width"in t&&"height"in t&&("colorMode"in t||"pixelFormat"in t)&&"timeSpent"in t&&"timeStamp"in t&&"isCropped"in t&&"toCanvas"in t&&"_sWidth"in t&&"_sHeight"in t&&"_bUseWebGL"in t}static async testCameraAccess(){try{if(!navigator||!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)return{ok:!1,message:"Insecure context."};(await navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach((t=>{t.stop()}))}catch(t){if("OverconstrainedError"===t.name||"NotFoundError"===t.name)return{ok:!1,message:"No camera detected."};if("NotAllowedError"===t.name)return{ok:!1,message:"No permission to access camera."};if("AbortError"===t.name)return{ok:!1,message:"Some problem occurred which prevented the device from being used."};if("NotReadableError"===t.name)return{ok:!1,message:"A hardware error occurred."};if("SecurityError"===t.name)return{ok:!1,message:"User media support is disabled."};throw t}return{ok:!0,message:"Successfully accessed the camera."}}set maxCvsSideLength(t){if(t<=0)throw new Error("Invalid value.");this._maxCvsSideLength=t}get maxCvsSideLength(){if(void 0!==this._maxCvsSideLength)return this._maxCvsSideLength;if(this._controler){const t=this._controler.getPropertyDisiredValue("maxCvsSideLength");if(t&&1===t.length)return t[0]}return this._defaultMaxCvsSideLength}static set defaultUIElementURL(t){ht._defaultUIElementURL=t}static get defaultUIElementURL(){var t;return null===(t=ht._defaultUIElementURL)||void 0===t?void 0:t.replace("@engineResourcePath/",ht.engineResourcePath)}getUIElement(){return this.UIElement}async setUIElement(t){if(this._bOpen)throw new Error("It is not allowed to change the UIElement when the camera is open.");if("string"==typeof t||t instanceof String){if(!t.trim().startsWith("<")){let e=await fetch(t);if(!e.ok)throw Error("setUIElement(elementOrUrl): Network Error: "+e.statusText);t=await e.text()}if(!t.trim().startsWith("<"))throw Error("setUIElement(elementOrUrl): Can't get valid HTMLElement.");let e=document.createElement("div");e.innerHTML=t;for(let t=0;t<e.childElementCount;++t){let i=e.children[t];i instanceof HTMLStyleElement&&(this.styleEls.push(i),document.head.append(i))}(t=1==e.childElementCount?e.children[0]:e).remove()}this.UIElement=t,this._uiOriginalState={display:t&&t.style.display,inDom:document.body.contains(t)}}appendAndShowUI(){this.UIElement&&(this.UIElement.parentNode||(this.UIElement.style.position="fixed",this.UIElement.style.left="0",this.UIElement.style.top="0",document.body.append(this.UIElement)),"none"==this.UIElement.style.display&&(this.UIElement.style.display=""))}hideUI(){this.UIElement&&(this.UIElement.style.display="none")}get singleFrameMode(){return this._singleFrameMode}set singleFrameMode(t){var e;if("boolean"!=typeof t&&!["image","camera"].includes(t))throw new Error("Invalid value.");if(this._bOpen)throw new Error("It is not allowed to change `singleFrameMode` when the camera is open.");this._singleFrameMode=t;const i=null===(e=this._singleFrameInputContainer)||void 0===e?void 0:e.firstElementChild;i&&("camera"===t?(i.setAttribute("capture",""),i.setAttribute("accept","image/*")):1!=t&&"image"!==t||(i.removeAttribute("capture"),i.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")))}set frameColorMode(t){this._framePixelFormat=t}get frameColorMode(){if(void 0!==this._framePixelFormat)return this._framePixelFormat;if(this._controler){const t=this._controler.getPropertyDisiredValue("framePixelFormat")||this._controler.getPropertyDisiredValue("frameColorMode");if(t&&1===t.length)return t[0]}return this._defaultFramePixelFormat}set framePixelFormat(t){this._framePixelFormat=t}get framePixelFormat(){if(void 0!==this._framePixelFormat)return this._framePixelFormat;if(this._controler){const t=this._controler.getPropertyDisiredValue("framePixelFormat")||this._controler.getPropertyDisiredValue("frameColorMode");if(t&&1===t.length)return t[0]}return this._defaultFramePixelFormat}set bOpen(t){if(this._bOpen=t,t){this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t);this._updateDrawingLayersSize(),this.ifShowScanRegionMask?this.showScanRegionMask():this.hideScanRegionMask(),this.ifShowScanRegionLaser?this.showScanRegionLaser():this.hideScanRegionLaser(),this.showViewDecorator(),this.showScanRegionOverlays(),this._drawingLayersManager.setVisible(!0)}else this._softwareScale=1}set ifSaveLastUsedCamera(t){t?ht.isStorageAvailable("localStorage")?this._ifSaveLastUsedCamera=!0:(this._ifSaveLastUsedCamera=!1,n.warn("Local storage is unavailable")):this._ifSaveLastUsedCamera=!1}get ifSaveLastUsedCamera(){return this._ifSaveLastUsedCamera}get video(){return this._video}setVideoFit(t){if(t=t.toLowerCase(),!["contain","cover"].includes(t))throw new Error(`Unsupported value '${t}'.`);if(this.videoFit=t,this._video&&(this._video.style.objectFit=t,!this._isSingleFrameModeEnabled())){this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t);this._updateVideoContainerStyle(),this._drawingLayersManager.setObjectFit(t)}}getVideoFit(){return this.videoFit}_showElClassName(){this._videoContainer&&this._videoContainer.classList.add("div-video-container"),this._cvsScanRegion&&this._cvsScanRegion.classList.add("cvs-scan-region-mask"),this._cvsViewDecorator&&this._cvsViewDecorator.classList.add("cvs-view-decorator"),this._scanRegionOverlayContainer&&this._scanRegionOverlayContainer.classList.add("div-scan-region-overlay-container"),this._layerBaseCvs&&this._layerBaseCvs.classList.add("cvs-drawing-layer-base"),this._layerBaseCvs&&this._layerBaseCvs.parentElement.classList.add("div-drawing-layer-container"),this._cvsOriginalImage&&this._cvsOriginalImage.classList.add("cvs-original-image"),this._cvsSingleFrameMode&&this._cvsSingleFrameMode.classList.add("cvs-single-frame"),this._singleFrameInputContainer&&this._singleFrameInputContainer.classList.add("div-single-frame-input-container")}_hideElClassName(){this._videoContainer&&(this._videoContainer.className=""),this._cvsScanRegion&&(this._cvsScanRegion.className=""),this._cvsViewDecorator&&(this._cvsViewDecorator.className=""),this._scanRegionOverlayContainer&&(this._scanRegionOverlayContainer.className=""),this._layerBaseCvs&&(this._layerBaseCvs.className=""),this._layerBaseCvs&&(this._layerBaseCvs.className=""),this._cvsOriginalImage&&(this._cvsOriginalImage.className=""),this._cvsSingleFrameMode&&(this._cvsSingleFrameMode.className=""),this._singleFrameInputContainer&&(this._singleFrameInputContainer.className="")}set ifShowScanRegionMask(t){this._bShowScanRegionMask=t,t?this.showScanRegionMask():this.hideScanRegionMask()}get ifShowScanRegionMask(){return this._bShowScanRegionMask}showScanRegionMask(){this._cvsScanRegion&&("none"==this._cvsScanRegion.style.display&&(this._cvsScanRegion.style.display=""),this._recordedStates.maskShow=!0)}hideScanRegionMask(){this._cvsScanRegion&&(this._cvsScanRegion.style.display="none",this._recordedStates.maskShow=!1)}set ifShowScanRegionLaser(t){this._bShowScanRegionLaser=t,t?this.showScanRegionLaser():this.hideScanRegionLaser()}get ifShowScanRegionLaser(){if(void 0!==this._bShowScanRegionLaser)return this._bShowScanRegionLaser;if(this._controler){const t=this._controler.getPropertyDisiredValue("ifShowScanRegionLaser");if(t&&t.length){let e=0;for(let i of t)i||e++;return e!==this._controler.getRegisteredUsers().length}}return this._defaultBShowScanRegionLaser}showScanRegionLaser(){this._divScanLight&&("none"==this._divScanLight.style.display&&(this._divScanLight.style.display="block"),this._recordedStates.laserShow=!0)}hideScanRegionLaser(){this._divScanLight&&(this._divScanLight.style.display="none",this._recordedStates.laserShow=!1)}_checkValidRegion(t){return!(null!==t&&(!t||!(t.hasOwnProperty("regionLeft")&&t.hasOwnProperty("regionTop")&&t.hasOwnProperty("regionRight")&&t.hasOwnProperty("regionBottom")&&t.hasOwnProperty("regionMeasuredByPercentage"))||t.regionLeft<0||t.regionTop<0||t.regionRight<0||t.regionBottom<0||t.regionMeasuredByPercentage&&(t.regionLeft>100||t.regionTop>100||t.regionRight>100||t.regionBottom>100)))}set scanRegion(t){if(!this._checkValidRegion(t))throw new Error("Invalid region.");this._scanRegion=JSON.parse(JSON.stringify(t)),this._updateScanRegionCanvas(),this._updateScanAreaDiv();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t)}setScanRegion(t){this.scanRegion=t}getScanRegion(){return JSON.parse(JSON.stringify(this._scanRegion))}_calculateCvsSize(){var t,e;let i,r,n;if(this._isSingleFrameModeEnabled()?(i=this._imgWidth,r=this._imgHeight,n="contain"):(i=null===(t=this._video)||void 0===t?void 0:t.videoWidth,r=null===(e=this._video)||void 0===e?void 0:e.videoHeight,n=this.getVideoFit()),!i||!r)throw new Error("Invalid content dimensions.");return{width:i,height:r,objectFit:n}}addScanRegionOverlayCanvas(){this._assertOpen();const t=document.createElement("canvas");if(this._updateScanRegionOverlay(t),!this._scanRegionOverlayContainer){const t=document.createElement("div");if(this._scanRegionOverlayContainer=t,t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.overflow="hidden",t.style.pointerEvents="none",this._layerBaseCvs)this._layerBaseCvs.parentElement.after(t);else if(this._cvsScanRegion)this._cvsScanRegion.after(t);else if(this._cvsOriginalImage)this._cvsOriginalImage.after(t);else if(this._cvsSingleFrameMode)this._cvsSingleFrameMode.after(t);else{if(!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(t)}this._recordedStates.overlayShow=!0}return this._scanRegionOverlayContainer.append(t),this._arrScanRegionOverlays.push(t),t}removeScanRegionOverlayCanvas(t){const e=this._arrScanRegionOverlays.indexOf(t);-1!==e&&(t.remove(),this._arrScanRegionOverlays.splice(e,1))}_updateScanRegionOverlay(t){if(!t)return;let e;try{e=this._calculateCvsSize()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}const{width:i,height:r,objectFit:n}=e;if(i<=0||r<=0)return t.width=0,void(t.height=0);const s=this._getRegionInPixels(i,r,this._scanRegion),o=this.getFrameSize(i,r,this._scanRegion,this.maxCvsSideLength),a=o.dWidth,h=o.dHeight;t.width==a&&t.height==h||(t.width=a,t.height=h);const l=window.getComputedStyle(this._elContainer),c=parseFloat(l.width),u=parseFloat(l.height),d=c/u,f=i/r;let g,_,p,m,v=1;"contain"===n?(f>d?(v=c/i,g=0,_=(u-r*v)/2):(v=u/r,g=(c-i*v)/2,_=0),g+=s.regionLeft*v,_+=s.regionTop*v,p=(s.regionRight-s.regionLeft)*v,m=(s.regionBottom-s.regionTop)*v):"cover"===n?(f>d?(v=u/r,g=s.regionLeft*v-(i*v-c)/2,_=s.regionTop*v):(v=c/i,g=s.regionLeft*v,_=s.regionTop*v-(r*v-u)/2),p=(s.regionRight-s.regionLeft)*v,m=(s.regionBottom-s.regionTop)*v):(g=0,_=0,p=0,m=0),t.style.position="absolute",t.style.left=g+"px",t.style.top=_+"px",t.style.width=p+"px",t.style.height=m+"px"}showScanRegionOverlays(){this._scanRegionOverlayContainer&&("none"==this._scanRegionOverlayContainer.style.display&&(this._scanRegionOverlayContainer.style.display=""),this._recordedStates.overlayShow=!0)}hideScanRegionOverlays(){this._scanRegionOverlayContainer&&(this._scanRegionOverlayContainer.style.display="none",this._recordedStates.overlayShow=!1)}setViewDecorator(t,e){if(!t)return void(this._cvsViewDecorator&&(this._cvsViewDecorator.remove(),this._cvsViewDecorator=null));if(!e)throw new Error("Invalid area.");this._assertOpen();let i=[];if("string"==typeof t?i.push(t):Array.isArray(t)&&(i=JSON.parse(JSON.stringify(t))),!this._cvsViewDecorator){if(this._cvsViewDecorator=document.createElement("canvas"),this._scanRegionOverlayContainer)this._scanRegionOverlayContainer.after(this._cvsViewDecorator);else if(this._layerBaseCvs)this._layerBaseCvs.parentElement.after(this._cvsViewDecorator);else if(this._cvsScanRegion)this._cvsScanRegion.after(this._cvsViewDecorator);else if(this._cvsOriginalImage)this._cvsOriginalImage.after(this._cvsViewDecorator);else if(this._cvsSingleFrameMode)this._cvsSingleFrameMode.after(this._cvsViewDecorator);else{if(!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(this._cvsViewDecorator)}this._recordedStates.decoratorShow=!0}this._decoratorArea=JSON.parse(JSON.stringify(e)),this._decoratorType.length=0;const r=["rectangle","focus"],n=["crossline","crosshair"];let s=!1,o=!1;for(let t of i)t=t.toLowerCase(),r.includes(t)&&!s&&(s=!0,this._decoratorType.push(t)),n.includes(t)&&!o&&(o=!0,!this._decoratorType.includes(t)&&this._decoratorType.push(t));this._updateViewDecorator()}getViewDecorator(){return{type:JSON.parse(JSON.stringify(this._decoratorType)),area:JSON.parse(JSON.stringify(this._decoratorArea)),canvas:this._cvsViewDecorator}}showViewDecorator(){this._cvsViewDecorator&&("none"==this._cvsViewDecorator.style.display&&(this._cvsViewDecorator.style.display=""),this._recordedStates.decoratorShow=!0)}hideViewDecorator(){this._cvsViewDecorator&&(this._cvsViewDecorator.style.display="none",this._recordedStates.decoratorShow=!1)}setViewDecoratorLineWidth(t,e){if("string"!=typeof t)throw new Error("The 'type' should be a string.");if(t=t.toLowerCase(),!this._viewDecoratorInfo.hasOwnProperty(t))throw new Error(`The type of '${t}' doesn't exist.`);if(!this._viewDecoratorInfo[t].hasOwnProperty("lineWidth"))throw new Error(`It is not allowed to change the property 'lineWidth' when the decorator type is '${t}'.`);this._viewDecoratorInfo[t].lineWidth=e,this._updateViewDecorator()}setViewDecoratorStrokeStyle(t,e){if("string"!=typeof t)throw new Error("The 'type' should be a string.");if(t=t.toLowerCase(),!this._viewDecoratorInfo.hasOwnProperty(t))throw new Error(`The type of '${t}' doesn't exist.`);if(!this._viewDecoratorInfo[t].hasOwnProperty("strokeStyle"))throw new Error(`It is not allowed to change the property 'strokeStyle' when the decorator type is '${t}'.`);this._viewDecoratorInfo[t].strokeStyle=e,this._updateViewDecorator()}setViewDecoratorFillStyle(t,e){if("string"!=typeof t)throw new Error("The 'type' should be a string.");if(t=t.toLowerCase(),!this._viewDecoratorInfo.hasOwnProperty(t))throw new Error(`The type of '${t}' doesn't exist.`);if(!this._viewDecoratorInfo[t].hasOwnProperty("fillStyle"))throw new Error(`It is not allowed to change the property 'fillStyle' when the decorator type is '${t}'.`);this._viewDecoratorInfo[t].fillStyle=e,this._updateViewDecorator()}setViewDecoratorMaskFillStyle(t,e){if("string"!=typeof t)throw new Error("The 'type' should be a string.");if(t=t.toLowerCase(),!this._viewDecoratorInfo.hasOwnProperty(t))throw new Error(`The type of '${t}' doesn't exist.`);if(!this._viewDecoratorInfo[t].hasOwnProperty("maskFillStyle"))throw new Error(`It is not allowed to change the property 'maskFillStyle' when the decorator type is '${t}'.`);this._viewDecoratorInfo[t].maskFillStyle=e,this._updateViewDecorator()}_updateViewDecorator(){if(!this._bOpen)return;if(!this._cvsViewDecorator||!this._decoratorArea)return;let t;if(this._isSingleFrameModeEnabled())t="contain";else{if(!this._video)return;t=this.getVideoFit()}const e=this._cvsViewDecorator;e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.left="0",e.style.top="0",e.style.objectFit=t,e.style.pointerEvents="none";const i=this.getVisibleRegion(!0);if(!i)return;const r=i.regionRight-i.regionLeft,n=i.regionBottom-i.regionTop;if(e.width==r&&e.height==n||(e.width=r,e.height=n),r<=0||n<=0)return;const s=e.getContext("2d");s.clearRect(0,0,e.width,e.height);const o=this._decoratorArea.x/100*r,a=this._decoratorArea.y/100*n,h=this._decoratorArea.width/100*r,l=this._decoratorArea.height/100*n;for(let t of this._decoratorType){if("rectangle"===t){s.fillStyle=this._viewDecoratorInfo.rectangle.maskFillStyle,s.fillRect(0,0,e.width,e.height),s.clearRect(Math.round(o),Math.round(a),Math.round(h),Math.round(l)),s.fillStyle=this._viewDecoratorInfo.rectangle.fillStyle,s.fillRect(Math.round(o),Math.round(a),Math.round(h),Math.round(l)),s.lineWidth=this._viewDecoratorInfo.rectangle.lineWidth,s.strokeStyle=this._viewDecoratorInfo.rectangle.strokeStyle;const t=s.lineWidth/2;s.strokeRect(Math.round(o-t),Math.round(a-t),Math.round(h+s.lineWidth),Math.round(l+s.lineWidth))}if("focus"===t){s.fillStyle=this._viewDecoratorInfo.focus.maskFillStyle,s.fillRect(0,0,e.width,e.height),s.clearRect(Math.round(o),Math.round(a),Math.round(h),Math.round(l)),s.fillStyle=this._viewDecoratorInfo.focus.fillStyle,s.fillRect(Math.round(o),Math.round(a),Math.round(h),Math.round(l)),s.lineWidth=this._viewDecoratorInfo.focus.lineWidth,s.strokeStyle=this._viewDecoratorInfo.focus.strokeStyle;const t=s.lineWidth/2,i=[0,.25,.75,1],r=[0,.25,.75,1];s.beginPath();for(let t=0;t<i.length;t++)if(0==t||3==t)for(let e=0;e<r.length;e+=2)s.moveTo(Math.round(o+i[t]*h),Math.round(a+r[e]*l)),s.lineTo(Math.round(o+i[t]*h),Math.round(a+r[e+1]*l));for(let e=0;e<r.length;e++)if(0==e||3==e)for(let n=0;n<i.length;n+=2)s.moveTo(Math.round(o+i[n]*h-t),Math.round(a+r[e]*l)),s.lineTo(Math.round(o+i[n+1]*h+t),Math.round(a+r[e]*l));s.stroke()}if("crossline"===t&&(s.beginPath(),s.lineWidth=this._viewDecoratorInfo.crossline.lineWidth,s.strokeStyle=this._viewDecoratorInfo.crossline.strokeStyle,s.moveTo(Math.round(o),Math.round(a+l/2)),s.lineTo(Math.round(o+h),Math.round(a+l/2)),s.moveTo(Math.round(o+h/2),Math.round(a)),s.lineTo(Math.round(o+h/2),Math.round(a+l)),s.stroke()),"crosshair"===t){s.beginPath();const t=.05*Math.min(h,l);s.lineWidth=this._viewDecoratorInfo.crosshair.lineWidth,s.strokeStyle=this._viewDecoratorInfo.crosshair.strokeStyle,s.moveTo(Math.round(o+(h-t)/2),Math.round(a+l/2)),s.lineTo(Math.round(o+(h+t)/2),Math.round(a+l/2)),s.moveTo(Math.round(o+h/2),Math.round(a+(l-t)/2)),s.lineTo(Math.round(o+h/2),Math.round(a+(l+t)/2)),s.stroke()}}}getVisibleRegion(t){let e;this._assertOpen();try{e=this._calculateCvsSize()}catch(t){if("Invalid content dimensions."===(t.message||t))return null;throw t}const{width:i,height:r,objectFit:n}=e;let s=(()=>{const t=parseFloat(window.getComputedStyle(this._elContainer).width),e=parseFloat(window.getComputedStyle(this._elContainer).height);let s,o={regionBottom:r,regionRight:i,regionLeft:0,regionTop:0,regionMeasuredByPercentage:!1};return"cover"===n?t/e<i/r?(s=e/r,o.regionLeft=Math.floor((i-t/s)/2),o.regionRight=Math.ceil(i-o.regionLeft),o.regionTop=0,o.regionBottom=r):(s=t/i,o.regionTop=Math.floor((r-e/s)/2),o.regionBottom=Math.ceil(r-o.regionTop),o.regionLeft=0,o.regionRight=i):"none"===n&&(t<i&&e<r?(o.regionLeft=Math.floor((i-t)/2),o.regionRight=Math.ceil(i-o.regionLeft),o.regionTop=Math.floor((r-e)/2),o.regionBottom=Math.ceil(r-o.regionTop)):t<i?(o.regionLeft=Math.floor((i-t)/2),o.regionRight=Math.ceil(i-o.regionLeft),o.regionTop=0,o.regionBottom=r):e<r&&(o.regionTop=Math.floor((r-e)/2),o.regionBottom=Math.ceil(r-o.regionTop),o.regionLeft=0,o.regionRight=i)),o})();return t?s.regionMeasuredByPercentage=!1:(s.regionBottom=Math.ceil(s.regionBottom/r*100),s.regionRight=Math.ceil(s.regionRight/i*100),s.regionLeft=Math.floor(s.regionLeft/i*100),s.regionTop=Math.floor(s.regionTop/r*100),s.regionMeasuredByPercentage=!0),s}setScanRegionMaskStyle(t){t&&(t.fillStyle&&(this.regionMaskFillStyle=t.fillStyle),t.strokeStyle&&(this.regionMaskStrokeStyle=t.strokeStyle),t.lineWidth&&(this.regionMaskLineWidth=t.lineWidth),this._updateScanRegionCanvas())}_getRegionInPixels(t,e,i){if(!(t<=0||e<=0))return i?i.regionMeasuredByPercentage?{regionLeft:Math.round(i.regionLeft/100*t),regionTop:Math.round(i.regionTop/100*e),regionRight:Math.round(i.regionRight/100*t),regionBottom:Math.round(i.regionBottom/100*e),regionMeasuredByPercentage:!1}:JSON.parse(JSON.stringify(i)):{regionLeft:0,regionTop:0,regionRight:t,regi
2onBottom:e,regionMeasuredByPercentage:!1}}_updateScanRegionCanvas(){if(!this._bOpen)return;let t;try{t=this._calculateCvsSize()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}const{width:e,height:i,objectFit:r}=t;if(e<=0||i<=0)return void(this._cvsScanRegion&&(this._cvsScanRegion.width=0,this._cvsScanRegion.height=0));const n=this._getRegionInPixels(e,i,this._scanRegion);if(!this._cvsScanRegion){if(this._cvsScanRegion=document.createElement("canvas"),this._cvsOriginalImage)this._cvsOriginalImage.after(this._cvsScanRegion);else if(this._cvsSingleFrameMode)this._cvsSingleFrameMode.after(this._cvsScanRegion);else{if(!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(this._cvsScanRegion)}this._recordedStates.maskShow=!0}const s=this._cvsScanRegion;s.style.position="absolute",s.style.width="100%",s.style.height="100%",s.style.left="0",s.style.top="0",s.style.objectFit=r,s.style.pointerEvents="none",s.width==e&&s.height==i||(s.width=e,s.height=i);const o=s.getContext("2d");if(o.clearRect(0,0,s.width,s.height),0!=n.regionLeft||n.regionRight!=e||0!=n.regionTop||n.regionBottom!=i){const t=n.regionLeft,e=n.regionTop,i=n.regionRight-n.regionLeft,r=n.regionBottom-n.regionTop;o.fillStyle=this.regionMaskFillStyle,o.fillRect(0,0,s.width,s.height),o.clearRect(Math.round(t),Math.round(e),Math.round(i),Math.round(r)),o.strokeStyle=this.regionMaskStrokeStyle,o.lineWidth=this.regionMaskLineWidth;const a=o.lineWidth/2;o.strokeRect(Math.round(t-a),Math.round(e-a),Math.round(i+o.lineWidth),Math.round(r+o.lineWidth))}}_updateScanAreaDiv(){if(!this._bOpen)return;let t;try{t=this._calculateCvsSize()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}const{width:e,height:i,objectFit:r}=t;if(!this._divScanArea)return;if(e<=0||i<=0)return this._divScanArea.style.width="0",void(this._divScanArea.style.height="0");const n=this._getRegionInPixels(e,i,this._scanRegion),s=window.getComputedStyle(this._elContainer),o=parseFloat(s.width),a=parseFloat(s.height),h=o/a,l=e/i;let c,u,d,f,g=1;if("contain"===r)h<l?(g=o/e,c=0,u=(a-i*g)/2):(g=a/i,c=(o-e*g)/2,u=0),c+=n.regionLeft*g,u+=n.regionTop*g,d=(n.regionRight-n.regionLeft)*g,f=(n.regionBottom-n.regionTop)*g;else if("cover"===r)if(h<l){g=a/i,c=n.regionLeft*g-(e*g-o)/2,c=Math.max(c,0),c=Math.min(c,parseFloat(s.width)),u=n.regionTop*g;let t=n.regionRight*g-(e*g-o)/2;t=Math.max(t,0),t=Math.min(t,parseFloat(s.width)),d=t-c,f=(n.regionBottom-n.regionTop)*g}else{g=o/e,c=n.regionLeft*g,u=n.regionTop*g-(i*g-a)/2,u=Math.max(u,0),u=Math.min(u,parseFloat(s.height));let t=n.regionBottom*g-(i*g-a)/2;t=Math.max(t,0),t=Math.min(t,parseFloat(s.height)),d=(n.regionRight-n.regionLeft)*g,f=t-u}else c=0,u=0,d=0,f=0;this._divScanArea.style.left=c+"px",this._divScanArea.style.top=u+"px",this._divScanArea.style.width=d+"px",this._divScanArea.style.height=f+"px"}set croppingRegions(t){this._croppingRegions=t,this._bFetchingLoopStarted&&(this.bIncreaseRegionIndexAuto&&(this._croppingRegionIndex=0),this._fetchingLoop(!1))}get croppingRegions(){if(void 0!==this._croppingRegions)return this._croppingRegions;if(this._controler){const t=this._controler.getPropertyDisiredValue("croppingRegions");if(t&&1===t.length)return t[0]}return this._defaultCroppingRegions}set croppingRegionIndex(t){t<0?(this.bIncreaseRegionIndexAuto=!0,this._croppingRegionIndex=0):(this.bIncreaseRegionIndexAuto=!1,this._croppingRegionIndex=t)}get croppingRegionIndex(){return this._croppingRegionIndex}set loopInterval(t){if(t<0)throw new Error("'Invalid value.");this._loopInterval=t,this._bFetchingLoopStarted&&this._fetchingLoop(!1)}get loopInterval(){if(void 0!==this._loopInterval)return this._loopInterval;if(this._controler){const t=this._controler.getPropertyDisiredValue("loopInterval");if(t&&1===t.length)return t[0]}return this._defaultLoopInterval}set maxNumberOfFramesInBuffer(t){if(t<=0)throw new Error("Invalid value.");for(this._maxNumberOfFramesInBuffer=t;this._frameQueue&&this._frameQueue.length>this.maxNumberOfFramesInBuffer;)this._frameQueue.shift()}get maxNumberOfFramesInBuffer(){if(void 0!==this._maxNumberOfFramesInBuffer)return this._maxNumberOfFramesInBuffer;if(this._controler){const t=this._controler.getPropertyDisiredValue("maxNumberOfFramesInBuffer");if(t&&1===t.length)return t[0]}return this._defaultMaxNumberOfFramesInBuffer}get numberOfFramesInBuffer(){return this._frameQueue.length}set refreshInterval(t){this._refreshInterval=t}get refreshInterval(){if(void 0!==this._refreshInterval)return this._refreshInterval;if(this._controler){const t=this._controler.getPropertyDisiredValue("refreshInterval");if(t&&1===t.length)return t[0]}return this._defaultRefreshInterval}static async createInstance(t){let e=new ht;("string"==typeof t||t instanceof String)&&(t=JSON.parse(t));for(let i in t)e[i]=t[i];return this._hasEngineResourceLoaded=!0,ht.onWarning&&(location&&"file:"===location.protocol?setTimeout((()=>{ht.onWarning&&ht.onWarning({id:1,message:"The page is opened over file:// and Dynamsoft Camera Enhancer may not work properly. Please open the page via https://."})}),0):!1!==window.isSecureContext&&navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||setTimeout((()=>{ht.onWarning&&ht.onWarning({id:2,message:"Dynamsoft Camera Enhancer may not work properly in a non-secure context. Please open the page via https://."})}),0)),e._drawingLayersManager=new rt,e}static async playVideo(t,e,i){if(!t)throw new Error("Invalid 'videoEl'.");if(!e)throw new Error("Invalid 'source'.");return"string"==typeof e||e instanceof String?t.src=e:t.srcObject=e,new Promise(((e,r)=>{let n,s;const o=()=>{t.removeEventListener("loadstart",l),t.removeEventListener("abort",c),t.removeEventListener("play",u),t.removeEventListener("error",d)},a=()=>{n&&clearTimeout(n),s&&clearTimeout(s),o(),e(t)},h=t=>{n&&clearTimeout(n),s&&clearTimeout(s),o(),r(t)},l=()=>{t.addEventListener("abort",c,{once:!0})},c=()=>{const t=new Error("Video playing was interrupted.");t.name="AbortError",h(t)},u=()=>{a()},d=()=>{h(new Error(`Video error ${t.error.code}: ${t.error.message}.`))};t.addEventListener("loadstart",l,{once:!0}),t.autoplay&&["iPhone","iPad","Mac"].includes(G.OS)&&(!i||i&&i>2e3)?(t.addEventListener("play",u,{once:!0}),t.addEventListener("error",d,{once:!0}),s=setTimeout((()=>{t.removeEventListener("play",u),t.removeEventListener("error",d),t.play().then((()=>{a()})).catch((t=>{h(t)}))}),1e3)):(t.load(),t.play().then((()=>{a()})).catch((t=>{h(t)}))),i&&(n=setTimeout((()=>{o(),r(new Error("Failed to play video. Timeout."))}
vendor: 11,321 bytes, line 2
2),i))}))}static findBestRearCameraInIOS(t){if(!t||!t.length)return null;const e=["\ud6c4\uba74","\u80cc\u9762","\u5f8c\u7f6e","\u540e\u7f6e","\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07","\u092c\u0948\u0915","\u062e\u0644\u0641\u064a\u0629","\u05d0\u05d7\u05d5\u05e8\u05d9\u05ea","\u0437\u0430\u0434\u043d\u044f\u044f","\u0437\u0430\u0434\u043d\u0435\u0439","\u0437\u0430\u0434\u043d\u0430","\u03c0\u03af\u03c3\u03c9","zadn\xed","zadn\xe1","tylny","trasera","traseira","taka","stra\u017enja","spate","sau","r\xfcck","posteriore","posterior","h\xe1ts\xf3","belakang","baksidan","bakre","bak","bagside","back","a\u0440\u0442\u049b\u044b","arri\xe8re","arka","achterzijde"],i=["\ud2b8\ub9ac\ud50c","\u4e09\u955c\u5934","\u4e09\u93e1\u982d","\u30c8\u30ea\u30d7\u30eb","\u0e2a\u0e32\u0e21","\u091f\u094d\u0930\u093f\u092a\u0932","\u062b\u0644\u0627\u062b\u064a\u0629","\u05de\u05e9\u05d5\u05dc\u05e9\u05ea","\u04af\u0448\u0442\u0456\u043a","\u0442\u0440\u043e\u0439\u043d\u0430\u044f","\u0442\u0440\u043e\u0439\u043d\u0430","\u043f\u043e\u0442\u0440\u043e\u0454\u043d\u0430","\u03c4\u03c1\u03b9\u03c0\u03bb\u03ae","\xfc\xe7l\xfc","tr\xf3jobiektywowy","trostruka","trojn\xfd","trojit\xe1","trippelt","trippel","tripl\u0103","triple","tripla","tiga","kolmois","ba camera"],r=["\ub4c0\uc5bc \uc640\uc774\ub4dc","\u96d9\u5ee3\u89d2","\u53cc\u5e7f\u89d2","\u30c7\u30e5\u30a2\u30eb\u5e83\u89d2","\u0e04\u0e39\u0e48\u0e14\u0e49\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e21\u0e38\u0e21\u0e01\u0e27\u0e49\u0e32\u0e07","\u0921\u094d\u092f\u0941\u0905\u0932 \u0935\u093e\u0907\u0921","\u0645\u0632\u062f\u0648\u062c\u0629 \u0639\u0631\u064a\u0636\u0629","\u05db\u05e4\u05d5\u05dc\u05d4 \u05e8\u05d7\u05d1\u05d4","\u049b\u043e\u0441 \u043a\u0435\u04a3 \u0431\u04b1\u0440\u044b\u0448\u0442\u044b","\u0437\u0434\u0432\u043e\u0454\u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u043a\u0443\u0442\u043d\u0430","\u0434\u0432\u043e\u0439\u043d\u0430\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0430\u044f","\u0434\u0432\u043e\u0439\u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e\u044a\u0433\u044a\u043b\u043d\u0430","\u03b4\u03b9\u03c0\u03bb\u03ae \u03b5\u03c5\u03c1\u03b5\u03af\u03b1","\xe7ift geni\u015f","laajakulmainen kaksois","k\xe9p r\u1ed9ng m\u1eb7t sau","kett\u0151s, sz\xe9les l\xe1t\xf3sz\xf6g\u0171","grande angular dupla","ganda","dwuobiektywowy","dwikamera","dvostruka \u0161iroka","du\xe1ln\xed \u0161iroko\xfahl\xfd","du\xe1lna \u0161irokouhl\xe1","dupla grande-angular","dubl\u0103","dubbel vidvinkel","dual-weitwinkel","dual wide","dual con gran angular","dual","double","doppia con grandangolo","doble","dobbelt vidvinkelkamera"],n=t.filter((t=>{const i=t.label.toLowerCase();return e.some((t=>i.includes(t)))}));if(!n.length)return null;const s=n.find((t=>{const e=t.label.toLowerCase();return i.some((t=>e.includes(t)))}));if(s)return s.deviceId;const o=n.find((t=>{const e=t.label.toLowerCase();return r.some((t=>e.includes(t)))}));return o?o.deviceId:n[0].deviceId}static findBestRearCamera(t){if(!t||!t.length)return null;if(["iPhone","iPad","Mac"].includes(G.OS))return ht.findBestRearCameraInIOS(t);const e=["\ud6c4","\u80cc\u9762","\u80cc\u7f6e","\u5f8c\u9762","\u5f8c\u7f6e","\u540e\u9762","\u540e\u7f6e","\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07","\u0e2b\u0e25\u0e31\u0e07","\u092c\u0948\u0915","\u062e\u0644\u0641\u064a\u0629","\u05d0\u05d7\u05d5\u05e8\u05d9\u05ea","\u0437\u0430\u0434\u043d\u044f\u044f","\u0437\u0430\u0434\u043d\u044f","\u0437\u0430\u0434\u043d\u0435\u0439","\u0437\u0430\u0434\u043d\u0430","\u03c0\u03af\u03c3\u03c9","zadn\xed","zadn\xe1","tylny","tr\xe1s","trasera","traseira","taka","stra\u017enja","spate","sau","r\xfcck","rear","posteriore","posterior","h\xe1ts\xf3","darrere","belakang","baksidan","bakre","bak","bagside","back","a\u0440\u0442\u049b\u044b","arri\xe8re","arka","achterzijde"];for(let i of t){const t=i.label.toLowerCase();if(t&&e.some((e=>t.includes(e)))&&/\b0(\b)?/.test(t))return i.deviceId}return["Android","HarmonyOS"].includes(G.OS)?t[t.length-1].deviceId:null}constructor(){this._maxCvsSideLength=void 0,this._defaultMaxCvsSideLength=null,this._predefinedResolutions=[{width:160,height:120},{width:320,height:240},{width:480,height:360},{width:640,height:480},{width:800,height:600},{width:960,height:720},{width:1280,height:720},{width:1920,height:1080},{width:2560,height:1440},{width:3840,height:2160}],this._mapCameraResolutions=new Map,this._bWebGLSupported=!0,this.extraBindings=[],this._cvsSingleFrameMode=null,this._cvsOriginalImage=null,this._imgWidth=0,this._imgHeight=0,this._singleFrameInputContainer=null,this._clickIptSingleFrameMode=()=>{if(!this._isSingleFrameModeEnabled())return;if(this.getDrawingLayers().some((t=>"editor"==t.getMode())))return;let t;if(this._singleFrameInputContainer)t=this._singleFrameInputContainer.firstElementChild;else{t=document.createElement("input"),t.setAttribute("type","file"),"camera"===this.singleFrameMode?(t.setAttribute("capture",""),t.setAttribute("accept","image/*")):1!=this.singleFrameMode&&"image"!==this.singleFrameMode||(t.removeAttribute("capture"),t.setAttribute("accept",".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp")),t.addEventListener("change",(async()=>{const e=t.files[0];t.value="";const i=await(async t=>{let e=null,i=null;if("undefined"!=typeof createImageBitmap)try{if(e=await createImageBitmap(t),e)return e}catch(t){}var r;return e||(i=await(r=t,new Promise(((t,e)=>{let i=URL.createObjectURL(r),n=new Image;n.src=i,n.onload=()=>{URL.revokeObjectURL(n.src),t(n)},n.onerror=t=>{e(new Error("Can't convert blob to image : "+(t instanceof Event?t.type:t)))}})))),i})(e),r=i instanceof HTMLImageElement?i.naturalWidth:i.width,s=i instanceof HTMLImageElement?i.naturalHeight:i.height;this._imgWidth=r,this._imgHeight=s;const o=t=>{const e=Date.now();if(0===r||0===s)return null;if(t instanceof HTMLImageElement&&!t.complete)throw new Error("The source is not loaded.");const i=this._scanRegion,n=this.getFrameSize(r,s,i,this.maxCvsSideLength);if(!n)return null;let o=!0;r===n.sWidth&&s===n.sHeight&&(o=!1);const a=this.mapPixelFormatString_Enum.get(this.framePixelFormat.toLowerCase()),h={data:null,region:i?JSON.parse(JSON.stringify(i)):null,sx:n.sx,sy:n.sy,width:n.dWidth,height:n.dHeight,colorMode:null,pixelFormat:null,timeSpent:null,timeStamp:null,isCropped:o,toCanvas:this._toCanvas,_sWidth:n.sWidth,_sHeight:n.sHeight,_bUseWebGL:null},l=this._getImageData(t,r,s,n,null,{pixelFormat:a});if(!l)return null;const c=Date.now();return ht._onLog&&ht._onLog("DCE: _getVideoData(region?) END: "+c),h.data=l.data,h.pixelFormat=h.colorMode=l.pixelFormat,h._bUseWebGL=l._bUseWebGL,h.timeSpent=c-e,h.timeStamp=c,l.pixelFormat===ot.GREY?h.stride=h.width:h.stride=4*h.width,h};(t=>{let e=this._cvsSingleFrameMode;if(!e){if(e=document.createElement("canvas"),!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(e),e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.left="0",e.style.top="0",e.style.objectFit="contain",e.style.pointerEvents="none",this._cvsSingleFrameMode=e}e.width==r&&e.height==s||(e.width=r,e.height=s);const i=e.getContext("2d");i.clearRect(0,0,e.width,e.height),i.drawImage(t,0,0)})(i),this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t);let a;this._updateDrawingLayersSize();try{a=o(i)}catch(t){throw t}const h=this.mapCameraEvents.get("singleframeacquired");for(let t of h)if(t)try{const e={data:new Uint8Array(a.data),region:JSON.parse(JSON.stringify(a.region)),sx:a.sx,sy:a.sy,width:a.width,height:a.height,stride:a.stride,colorMode:a.colorMode,pixelFormat:a.pixelFormat,timeSpent:a.timeSpent,timeStamp:a.timeStamp,isCropped:a.isCropped,toCanvas:a.toCanvas,_sWidth:a._sWidth,_sHeight:a._sHeight,_bUseWebGL:a._bUseWebGL};await t.apply(this,[e])}catch(t){n.error(t)}})),t.style.position="absolute",t.style.top="-9999px",t.style.backgroundColor="transparent",t.style.color="transparent";const e=document.createElement("div");e.append(t),e.style.position="absolute",e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.style.pointerEvents="none",this._elContainer.prepend(e),this._singleFrameInputContainer=e}null==t||t.click()},this.styleEls=[],this._framePixelFormat=void 0,this._defaultFramePixelFormat="rgba",this.mapPixelFormatString_Enum=new Map([["grey",ot.GREY],["grey32",ot.GREY32],["rgba",ot.RGBA],["rbga",ot.RBGA],["grba",ot.GRBA],["gbra",ot.GBRA],["brga",ot.BRGA],["bgra",ot.BGRA]]),this.shaderPixelFormat=ot.RGBA,this.maxVideoCvsLength=3,this._reusedCvs=null,this._reusedWebGLCvs=null,this._tempDataContainer=null,this._webGLTexture=null,this._webGLProgramInfo=null,this._webGLBuffers=null,this._softwareScale=1,this._scaleCenter={x:0,y:0},this._focusParameters={maxTimeout:400,minTimeout:300,kTimeout:void 0,oldDistance:null,fds:null,isDoingFocus:0,taskBackToContinous:null,curFocusTaskId:0,focusCancelableTime:1500,defaultFocusAreaSizeRatio:6,focusBackToContinousTime:5e3,tapFocusMinDistance:null,tapFocusMaxDistance:null,_focusArea:null},this._tapFocusEnabled=!0,this._focusSupported=!0,this._tapDoFocus=async t=>{if(this._touchMoved)return void(this._touchMoved=!1);if(!this._tapFocusEnabled)return;if(!this._bOpen)return;if(this._isSingleFrameModeEnabled())return;if(!this._video||this._video.paused)return;if(!this._videoTrack)return;if(!this._focusSupported)return;if(this.getDrawingLayers().some((t=>"editor"==t.getMode())))return;if(!this._focusParameters.fds&&(this._focusParameters.fds=(await this.getCapabilities()).focusDistance,!this._focusParameters.fds))return void(this._focusSupported=!1);if(null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),1==this._focusParameters.isDoingFocus)return;let e,i,r,n;if(this._focusParameters.taskBackToContinous&&(clearTimeout(this._focusParameters.taskBackToContinous),this._focusParameters.taskBackToContinous=null),t instanceof MouseEvent)e=t.clientX,i=t.clientY;else{if(!(t instanceof TouchEvent))throw new Error("Unknown event type.");if(!t.changedTouches.length)return;e=t.changedTouches[0].clientX,i=t.changedTouches[0].clientY}const s=this.getVideoFit(),o=this._video.videoWidth,a=this._video.videoHeight,h=this._elContainer.getBoundingClientRect(),l=h.left,c=h.top,u=window.getComputedStyle(this._elContainer),d=parseFloat(u.width),f=parseFloat(u.height),g=d/f,_=o/a;let p=1;if("contain"===s)_>g?(p=d/o,r=(e-l)/p,n=(i-c-(f-d/_)/2)/p):(p=f/a,n=(i-c)/p,r=(e-l-(d-f*_)/2)/p);else{if("cover"!==s)throw new Error("Unsupported object-fit.");_>g?(p=f/a,n=(i-c)/p,r=(e-l+(f*_-d)/2)/p):(p=d/o,r=(e-l)/p,n=(i-c+(d/_-f)/2)/p)}const m={x:r+"px",y:n+"px"},v=2*Math.round(Math.min(o,a)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px",y=v;await this._setLocalFocus(m,v,y,this._focusParameters.tapFocusMinDistance,this._focusParameters.tapFocusMaxDistance),this._focusParameters.taskBackToContinous=setTimeout((()=>{this._videoTrack&&this._videoTrack.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch((()=>{}))}),this._focusParameters.focusBackToContinousTime)},this._touchMoved=!1,this._touchMoveEvent=()=>{this._touchMoved=!0}
2,this._recordedStates={},this.playCallbackInfo=null,this._toCanvas=function(){const t=document.createElement("canvas");let e;if(t.width=this.width,t.height=this.height,"grey"===(this.pixelFormat||this.colorMode)){e=new Uint8ClampedArray(this.width*this.height*4);for(let t=0;t<e.length;t+=4)e[t]=this.data[t/4],e[t+1]=this.data[t/4],e[t+2]=this.data[t/4],e[t+3]=255}else e=new Uint8ClampedArray(this.data.buffer);const i=new ImageData(e,this.width,this.height);return t.getContext("2d").putImageData(i,0,0),t},this._onCameraSelChange=async()=>{await this.selectCamera(this._selCam.value),this._bOpen||this.stop()},this._onResolutionSelChange=async()=>{let t,e;if(this._selRsl&&-1!=this._selRsl.selectedIndex){let i=this._selRsl.options[this._selRsl.selectedIndex];t=i.getAttribute("data-width"),e=i.getAttribute("data-height")}await this.setResolution(t,e),this._bOpen||this.stop()},this._onCloseBtnClick=()=>{this.close(!0)},this._bOpen=!1,this.isCameraEnhancer=!0,this.isDisposed=!1,this.disposed=!1,this.videoSrc=null,this.cameraOpenTimeout=4e3,this.videoSettings={video:{width:{ideal:1280},height:{ideal:720},facingMode:{ideal:"environment"}}},this.iPlayRound=0,this.promisePlay=null,this._ifSaveLastUsedCamera=!1,this.ifSkipCameraInspection=!1,this._allCameras=[],this._currentCamera=null,this._videoTrack=null,this._lastDeviceId=void 0,this._vc_bPlayingVideoBeforeHide=!1,this._ev_documentHideEvent=()=>{if(!this._isSingleFrameModeEnabled())if("visible"===document.visibilityState){if(ht._onLog&&ht._onLog("DCE: document visible."),this._bOpen&&this._vc_bPlayingVideoBeforeHide)if(this.videoSrc)this._video.play();else if(this._video.srcObject){const t=this._video.srcObject.getTracks()[0];if(this._video.srcObject.active&&t)if(t.muted&&["iPhone","iPad","Mac"].includes(G.OS)){if(G.version>=17)return void ht.playVideo(this._video,this._video.srcObject,this.cameraOpenTimeout);this.play()}else this._video.play();else this.play()}}else if("hidden"===document.visibilityState)if(ht._onLog&&ht._onLog("DCE: document hidden."),["iPhone","iPad","Mac"].includes(G.OS)){if(this._vc_bPlayingVideoBeforeHide=!0,G.version>=17)return;this._video&&this._video.pause()}else this._video&&!this._video.paused?(this._vc_bPlayingVideoBeforeHide=!0,this._video.pause()):this._vc_bPlayingVideoBeforeHide=!1},this.containerClassName="dce-video-container",this._elContainer=null,this._videoContainer=null,this._video=null,this.videoFit="contain",this._cvsScanRegion=null,this._divScanArea=null,this._divScanLight=null,this._bgLoading=null,this._selCam=null,this._bgCamera=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this.regionMaskFillStyle="rgba(0,0,0,0.5)",this.regionMaskStrokeStyle="rgb(254,142,20)",this.regionMaskLineWidth=2,this._bShowScanRegionMask=!0,this._bShowScanRegionLaser=void 0,this._defaultBShowScanRegionLaser=!1,this._scanRegion=null,this._arrScanRegionOverlays=[],this._layerBaseCvs=null,this._drawingLayerOfTip=null,this._tipArgs={x:void 0,y:void 0,width:void 0,duration:void 0,autoShowSuggestedTip:void 0},this._hideTipTimeoutId=null,this.onTipSuggested=null,this._cvsViewDecorator=null,this._decoratorType=[],this._decoratorArea=null,this._viewDecoratorInfo={rectangle:{lineWidth:4,strokeStyle:"rgb(254,142,20)",fillStyle:"transparent",maskFillStyle:"transparent"},focus:{lineWidth:4,strokeStyle:"rgb(254,142,20)",fillStyle:"transparent",maskFillStyle:"transparent"},crossline:{lineWidth:2,strokeStyle:"rgb(254,142,20)"},crosshair:{lineWidth:4,strokeStyle:"rgb(254,142,20)"}},this._croppingRegions=void 0,this._defaultCroppingRegions=[null],this.bIncreaseRegionIndexAuto=!0,this._croppingRegionIndex=0,this._loopInterval=void 0,this._defaultLoopInterval=0,this._maxNumberOfFramesInBuffer=void 0,this._defaultMaxNumberOfFramesInBuffer=1,this._frameQueue=[],this._bFetchingLoopStarted=!1,this._refreshInterval=void 0,this._defaultRefreshInterval=-1,this._updateLayersTimeout=500,this._updateLayers=()=>{this._cvsScanRegion&&(this._cvsScanRegion.style.display="none"),this._divScanLight&&(this._divScanLight.style.display="none"),this._cvsViewDecorator&&(this._cvsViewDecorator.style.display="none");for(let t of this._arrScanRegionOverlays)t&&(t.style.display="none");this._resizeTimeoutId&&clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=setTimeout((()=>
vendor: 2,623 bytes, line 2
2{if(!this.isDisposed||!this.disposed){this.ifShowScanRegionMask&&this.showScanRegionMask(),this.ifShowScanRegionLaser&&this.showScanRegionLaser(),this._cvsViewDecorator&&this.showViewDecorator(),this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&(t.style.display="",this._updateScanRegionOverlay(t));this._updateDrawingLayersSize(),this._updateVideoContainerStyle()}}),this._updateLayersTimeout)},this._windowResizeListener=()=>{this._windowWidth!==document.documentElement.clientWidth&&(this._windowWidth=document.documentElement.clientWidth,this._updateLayers())},this.mapCameraEvents=new Map([["cameraopen",[]],["cameraclose",[]],["camerachange",[]],["resolutionchange",[]],["played",[]],["singleframeacquired",[]],["frameaddedtobuffer",[]]]),this._controler=null,navigator&&navigator.mediaDevices&&navigator.mediaDevices.getUserMedia?this._singleFrameMode=!1:this._singleFrameMode=!0}_isSingleFrameModeEnabled(){return 0!=this.singleFrameMode}async play(t,e,i,r){let n;if(this._video&&this.videoSrc){ht._onLog&&(n=Date.now(),ht._onLog("DCE: start loading static video: "+n));const t=await ht.playVideo(this._video,this.videoSrc,this.cameraOpenTimeout);if(ht._onLog&&ht._onLog("DCE: finish loading static video. Costs: "+(Date.now()-n)),!this._video)return t.pause(),this.playCallbackInfo={width:0,height:0,deviceId:null},{width:0,height:0,deviceId:null};const e={width:this._video.videoWidth,height:this._video.videoHeight,deviceId:this._currentCamera&&this._currentCamera.deviceId};this.playCallbackInfo=JSON.parse(JSON.stringify(e));const i=this.mapCameraEvents.get("played");for(let t of i){if(!t)continue;const i=JSON.parse(JSON.stringify(e));setTimeout((()=>{this.isDisposed&&this.disposed||t.apply(this,[i])}),0)}return this._recordedStates.videoPlaying=!0,e}if(this._isSingleFrameModeEnabled())return r&&r.notTriggerSingleFrameClick||this._clickIptSingleFrameMode(),this.playCallbackInfo={width:0,height:0,deviceId:null},{width:0,height:0,deviceId:null};if(!this._video)throw new Error("'video' is null or undefined.");const s=++this.iPlayRound;if(this.promisePlay&&(await this.promisePlay,s<this.iPlayRound))return this.playCallbackInfo={width:this._video.videoWidth,height:this._video.videoHeight,deviceId:this._currentCamera&&this._currentCamera.deviceId},{width:this._video.videoWidth,height:this._video.videoHeight,deviceId:this._currentCamera&&this._currentCamera.deviceId};this.promisePlay=(async()=>{var n;try{this._video&&this._video.srcObject&&this.stop(),ht._onLog&&ht._onLog("DCE: ======before video========");const s=()=>
2{if(!this._video)throw h&&h.getTracks().forEach((t=>{t.stop()})),this._videoTrack=null,this._currentCamera=null,new Error("'video' is null or undefined.")},o=this.getVideoSettings();let a,h;if("boolean"==typeof o.video&&(o.video={}),t)delete o.video.facingMode,o.video.deviceId={exact:t};else if(o.video.deviceId);else if(this._lastDeviceId)delete o.video.facingMode,o.video.deviceId={exact:this._lastDeviceId};else if(this.ifSaveLastUsedCamera&&ht.isStorageAvailable&&window.localStorage.getItem("dce_last_camera_id")){delete o.video.facingMode,o.video.deviceId={ideal:window.localStorage.getItem("dce_last_camera_id")};const t=JSON.parse(window.localStorage.getItem("dce_last_apply_width")),e=JSON.parse(window.localStorage.getItem("dce_last_apply_height"));t&&e&&(o.video.width=t,o.video.height=e)}else if(this.ifSkipCameraInspection);else if(o.video.facingMode){if(await this.getAllCameras(!1),!this._video)throw new Error("'video' is null or undefined.");let t=o.video.facingMode;if(t instanceof Array&&t.length&&(t=t[0]),t=t.exact||t.ideal||t,"environment"===t){a=!0;const t=ht.findBestRearCamera(this._allCameras);t&&(delete o.video.facingMode,o.video.deviceId={exact:t})}}e&&(o.video.width={ideal:e}),i&&(o.video.height={ideal:i}),ht._onLog&&ht._onLog("DCE: ======try getUserMedia========");let l=[0,500],c=null;const u=async t=>{for(let e of l){e&&await new Promise((t=>setTimeout(t,e))),s();try{ht._onLog&&ht._onLog("DCE: ask "+JSON.stringify(t)),h=await navigator.mediaDevices.getUserMedia(t);break}catch(t){if(s(),"NotFoundError"===t.name||"NotAllowedError"===t.name)throw t;c=t,ht._onLog&&ht._onLog("DCE: "+t.message||0)}}s()};let d;if(await u(o),h||(ht._onLog&&ht._onLog("DCE: ======try getUserMedia again========"),d=JSON.parse(JSON.stringify(o)),"object"==typeof d.video&&(["iPhone","iPad"].includes(G.OS)?(e>=1280||i>=1280?d.video.width=1280:e>=640||i>=640?d.video.width=640:(e<640||i<640)&&(d.video.width=320),delete d.video.height):a&&!o.video.deviceId?(delete d.video.facingMode,this._allCameras.length&&(d.video.deviceId={ideal:this._allCameras[this._allCameras.length-1].deviceId})):d.video=!0),ht._onLog&&ht._onLog("DCE: "+d),await u(d)),h||(l=[1e3,2e3],await u(o)),h||await u(d),!h)throw c;const f=()=>{const t=h.getVideoTracks();let e,i;if(t.length&&(e=this._videoTrack=t[0]),this._video&&e){const t=e.getSettings();if(t)for(let r of this._allCameras)if(t.deviceId===r.deviceId){r._checked=!0,r.label=e.label,i=r;break}}this._currentCamera=i};if(await this.getAllCameras(!1),s(),a&&!this.ifSkipCameraInspection){f();const t=ht.findBestRearCamera(this._allCameras),e=null===(n=this._currentCamera)||void 0===n?void 0:n.deviceId;t&&t!=e&&(h.getTracks().forEach((t=>{t.stop()})),l=[0,500,1e3,2e3],o.video.deviceId={exact:t},await u(o))}ht._onLog&&ht._onLog("DCE: ======play video========"),s(),await ht.playVideo(this._video,h,this.cameraOpenTimeout),s(),ht._onLog&&ht._onLog("DCE: ======played video========"),this._bgLoading&&(this._bgLoading.style.animationPlayState="paused");const g="got "+this._video.videoWidth+"x"+this._video.videoHeight;this._optGotRsl&&(this._optGotRsl.setAttribute("data-width",this._video.videoWidth),this._optGotRsl.setAttribute("data-height",this._video.videoHeight),this._optGotRsl.innerText=g,this._selRsl&&this._optGotRsl.parentNode==this._selRsl&&(this._selRsl.value="got")),ht._onLog&&ht._onLog("DCE: got "+g),f(),this._renderSelCameraInfo();const _={width:this._video.videoWidth,height:this._video.videoHeight,deviceId:this._currentCamera&&this._currentCamera.deviceId};if(_.deviceId&&(this._lastDeviceId=_.deviceId,this.ifSaveLastUsedCamera&&ht.isStorageAvailable&&(window.localStorage.setItem("dce_last_camera_id",this._lastDeviceId),o.video.width&&o.video.height&&(window.localStorage.setItem("dce_last_apply_width",JSON.stringify(o.video.width)),window.localStorage.setItem("dce_last_apply_height",JSON.stringify(o.video.height))))),!r||!r.notTriggerPlayedEvent){const t=this.mapCameraEvents.get("played");for(let e of t){if(!e)continue;const t=JSON.parse(JSON.stringify(_));setTimeout((()=>{this.isDisposed&&this.disposed||e.apply(this,[t])}),0)}}return this.promisePlay=null,_}catch(t){throw this.promisePlay=null,this._bgLoading&&(this._bgLoading.style.display="none"),"NotFoundError"===t.name&&(DOMException?t=new DOMException("No camera available, please use a device with an accessible camera.",t.name):(t=new Error("No camera available, please use a device with an accessible camera.")).name="NotFoundError"),t}})(),ht._onLog&&(n=Date.now(),ht._onLog("DCE: start opening camera: "+n));const o=await this.promisePlay;return ht._onLog&&ht._onLog("DCE: finish opening camera. Costs: "+(Date.now()-n)),this.playCallbackInfo=JSON.parse(JSON.stringify(o)),this._recordedStates.videoPlaying=!0,o}async resume(){this._assertOpen(),this._video&&(await this._video.play(),this._recordedStates.videoPlaying=!0),this.ifShowScanRegionLaser&&this.showScanRegionLaser()}pause(){this._assertOpen(),this._video&&(this._video.pause(),this._recordedStates.videoPlaying=!1),this.ifShowScanRegionLaser&&this.hideScanRegionLaser()}isPaused(){var t;return!this._isSingleFrameModeEnabled()&&!0===(null===(t=this._video)||void 0===t?void 0:t.paused)}_bindUI(){if(!this.UIElement)throw new Error("Need to define `UIElement` before opening.");const t=[this.UIElement];for(let e=0;e<t.length;++e)for(let i of t[e].children)t.push(i);for(let e of t){if(!this._video&&e.classList.contains(this.containerClassName)){this._elContainer=e;const t=document.createElement("video");t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%",t.style.objectFit=this.getVideoFit(),t.setAttribute("autoplay","true"),t.setAttribute("playsinline","true"),t.setAttribute("muted","true"),["iPhone","iPad","Mac"].includes(G.OS)&&G.version>=17&&t.setAttribute("poster","data:image/gif;base64,R0lGODlhAQABAIEAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAgEAAEEBAA7"),this._video=t;const i=document.createElement("div");i.append(t),i.style.position="absolute",i.style.left="0",i.style.top="0",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",this._videoContainer=i,e.prepend(i)}else!this._divScanArea&&e.classList.contains("dce-scanarea")?this._divScanArea=e:!this._divScanLight&&e.classList.contains("dce-scanlight")?this._divScanLight=e:!this._bgLoading&&e.classList.contains("dce-bg-loading")?this._bgLoading=e:!this._bgCamera&&e.classList.contains("dce-bg-camera")?this._bgCamera=e:!this._selCam&&e.classList.contains("dce-sel-camera")?this._selCam=e:!this._selRsl&&e.classList.contains("dce-sel-resolution")?(this._selRsl=e,this.videoSrc||this._isSingleFrameModeEnabled()||this._selRsl.options.length||(this._selRsl.innerHTML=[this._optGotRsl?"":'<option class="dce-opt-gotResolution" value="got"></option>','<option data-width="1920" data-height="1080">ask 1920x1080</option>','<option data-width="1280" data-height="720">ask 1280x720</option>','<option data-width="640" data-height="480">ask 640x480</option>'].join(""),this._optGotRsl=this._optGotRsl||this._selRsl.options[0])):!this._optGotRsl&&e.classList.contains("dce-opt-gotResolution")?this._optGotRsl=e:!this._btnClose&&e.classList.contains("dce-btn-close")?this._btnClose=e:!this._selMinLtr&&e.classList.contains("dlr-sel-minletter")?(this._selMinLtr=e,this._selMinLtr.options.length||(this._selMinLtr.innerHTML=[this._optGotMinLtr?"":'<option class="dlr-opt-gotMinLtr" value="got"></option>','<option value="0" selected>any letter</option>','<option value="3">3+ letters</option>','<option value="5">5+ letters</option>','<option value="8">8+ letters</option>','<option value="12">12+ letters</option>','<option value="17">17+ letters</option>','<option value="30">30+ letters</option>','<option value="50">50+ letters</option>','<option value="80">80+ letters</option>','<option value="120">120+ letters</option>'].join(""),this._optGotMinLtr=this._optGotMinLtr||this._selMinLtr.options[0])):!this._optGotMinLtr&&e.classList.contains("dlr-opt-gotMinLtr")&&(this._optGotMinLtr=e);
vendor: 63,144 bytes, line 2
2if(this.extraBindings&&this.extraBindings.length)for(let i of this.extraBindings)try{i(e)}catch(t){}}if(!this._video)throw this._unbindUI(),Error(`Can not find the video container element with class '${this.containerClassName}'`);this._isSingleFrameModeEnabled()||this.videoSrc?(this._isSingleFrameModeEnabled()&&(this._elContainer&&(this._elContainer.addEventListener("click",this._clickIptSingleFrameMode),this._elContainer.setAttribute("title","Take a photo")),this._bgCamera&&(this._bgCamera.style.display="block")),this._selCam&&(this._selCam.style.display="none"),this._selRsl&&(this._selRsl.style.display="none"),this._selMinLtr&&(this._selMinLtr.style.display="none")):(this._elContainer&&(["Android","HarmonyOS"].includes(G.OS)?(this._elContainer.addEventListener("touchend",this._tapDoFocus),this._elContainer.addEventListener("touchmove",this._touchMoveEvent)):this._elContainer.addEventListener("click",this._tapDoFocus)),this._selCam&&(this._selCam.style.display="block",this._selCam.addEventListener("change",this._onCameraSelChange)),this._selRsl&&(this._selRsl.style.display="block",this._selRsl.addEventListener("change",this._onResolutionSelChange)),this._selMinLtr&&(this._selMinLtr.style.display="block"),this._bgLoading&&(this._bgLoading.style.display="block")),this._btnClose&&this._btnClose.addEventListener("click",this._onCloseBtnClick),document.addEventListener("visibilitychange",this._ev_documentHideEvent),window.ResizeObserver&&(this._resizeObserver||(this._resizeObserver=new ResizeObserver((t=>{for(let e of t)e.target===this._elContainer&&this._updateLayers()}))),this._elContainer&&this._resizeObserver.observe(this._elContainer)),this._windowWidth=document.documentElement.clientWidth,window.addEventListener("resize",this._windowResizeListener)}_unbindUI(){this._isSingleFrameModeEnabled()?(this._elContainer&&(this._elContainer.removeEventListener("click",this._clickIptSingleFrameMode),this._elContainer.removeAttribute("title")),this._bgCamera&&(this._bgCamera.style.display="none")):this._bgLoading&&(this._bgLoading.style.display="none"),this._elContainer&&(this._elContainer.removeEventListener("click",this._tapDoFocus),this._elContainer.removeEventListener("touchend",this._tapDoFocus),this._elContainer.removeEventListener("touchmove",this._touchMoveEvent)),this._selCam&&this._selCam.removeEventListener("change",this._onCameraSelChange),this._selRsl&&this._selRsl.removeEventListener("change",this._onResolutionSelChange),this._btnClose&&this._btnClose.removeEventListener("click",this._onCloseBtnClick),this.hideScanRegionLaser(),this.hideViewDecorator(),this.hideScanRegionOverlays(),this._drawingLayersManager.setVisible(!1),this._hideOriginalImageCvs(),this._videoContainer&&this._videoContainer.remove(),this._video=null,this._videoContainer=null,this._elContainer=null,this._selCam=null,this._selRsl=null,this._optGotRsl=null,this._btnClose=null,this._selMinLtr=null,this._optGotMinLtr=null,this._divScanArea=null,this._divScanLight=null,this._cvsScanRegion&&(this._cvsScanRegion.remove(),this._cvsScanRegion=null),this._singleFrameInputContainer&&(this._singleFrameInputContainer.remove(),this._singleFrameInputContainer=null),this._cvsSingleFrameMode&&(this._cvsSingleFrameMode.remove(),this._cvsSingleFrameMode=null),document.removeEventListener("visibilitychange",this._ev_documentHideEvent),window.ResizeObserver&&this._resizeObserver&&this._resizeObserver.disconnect(),window.removeEventListener("resize",this._windowResizeListener)}_assertOpen(){if(!this._bOpen)throw Error("The camera is not open.")}async open(t){this.UIElement||await this.setUIElement(ht.defaultUIElementURL),this._bindUI(),t&&this.appendAndShowUI();let e=await this.play();this.bOpen=!0,this._focusParameters.fds=null,this._focusParameters.kTimeout=void 0,this._focusSupported=!0,this._tapFocusEnabled&&!this._isSingleFrameModeEnabled()&&(this._focusParameters.fds=(await this.getCapabilities()).focusDistance,this._focusParameters.fds||(this._focusSupported=!1,this._tapFocusEnabled=!1));const i=this.mapCameraEvents.get("cameraopen");for(let t of i){if(!t)continue;const i=JSON.parse(JSON.stringify(e));setTimeout((()=>{this.isDisposed&&this.disposed||t.apply(this,[i])}),0)}return e}close(t){if(!this._video)return;this.stop(),this._hideOriginalImage(!1),this.hideTip(),this._unbindUI(),t&&this.hideUI(),this.stopFetchingLoop(),this.bOpen=!1;const e=this.mapCameraEvents.get("cameraclose");for(let t of e){if(!t)continue;const e={width:0,height:0,deviceId:null};setTimeout((()=>{this.isDisposed&&this.disposed||t.apply(this,[e])}),0)}}stop(){this._video&&this._video.srcObject&&(ht._onLog&&ht._onLog("DCE: ======stop video========"),this._video.srcObject.getTracks().forEach((t=>{t.stop()})),this._video.srcObject=null,this._videoTrack=null,this._currentCamera=null),this._video&&this.videoSrc&&(ht._onLog&&ht._onLog("DCE: ======stop existing video========"),this._video.pause(),this._video.currentTime=0),this._bgLoading&&(this._bgLoading.style.animationPlayState=""),this._frameQueue.length=0,this._reusedCvs&&this._reusedCvs.ctx2d&&this._reusedCvs.ctx2d.clearRect(0,0,this._reusedCvs.width,this._reusedCvs.height),this.forceLoseContext()}async getAllCameras(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind));if(t&&e&&e.length&&!e[0].deviceId){let t=await navigator.mediaDevices.getUserMedia({video:!0});e=(await navigator.mediaDevices.enumerateDevices()).filter((t=>"videoinput"===t.kind)),t.getTracks().forEach((t=>{t.stop()}))}const i=[],r=[];if(this._allCameras)for(let t of this._allCameras)t._checked&&r.push(t);for(let t=0;t<e.length;t++){let n,s=e[t];for(let t of r)if(s.deviceId==t.deviceId){n=t;break}n||(n={deviceId:s.deviceId,label:s.label?s.label:"camera "+t,_checked:!1}),n.deviceId&&i.push(n)}return this._allCameras=i,ht._onLog&&ht._onLog("DCE: "+JSON.stringify(this._allCameras)),i}_renderSelCameraInfo(){if(!this._selCam)return;let t;this._selCam.textContent="";for(let e of this._allCameras){const i=document.createElement("option");i.value=e.deviceId,i.innerText=e.label,this._selCam.append(i),e.deviceId&&this._currentCamera&&this._currentCamera.deviceId==e.deviceId&&(t=i)}this._selCam.value=t?t.value:""}getSelectedCamera(){if(!this._bOpen){let t="";const e=this.videoSettings.video.deviceId;e&&(t=e.exact||e.ideal||e);for(let e of this._allCameras)if(e.deviceId===t)return JSON.parse(JSON.stringify(e));return{deviceId:t,label:"",_checked:!1}}return this._currentCamera}async selectCamera(t){let e="";if(t&&(e=t.deviceId||t),this.videoSettings.video.deviceId={exact:e},!this._bOpen||this._video.paused)return null;let i=null;this._currentCamera&&(i=this._currentCamera.deviceId);const r=this._video.videoWidth,n=this._video.videoHeight,s=await this.play(t.deviceId||t);if(this._focusParameters.fds=null,this._focusParameters.kTimeout=void 0,this._focusSupported=!0,this._tapFocusEnabled&&!this._isSingleFrameModeEnabled()&&(this._focusParameters.fds=(await this.getCapabilities()).focusDistance,this._focusParameters.fds||(this._focusSupported=!1,this._tapFocusEnabled=!1)),i!==s.deviceId){const t=this.mapCameraEvents.get("camerachange");for(let e of t){if(!e)continue;const t=JSON.parse(JSON.stringify(s));setTimeout((()=>{this.isDisposed&&this.disposed||e.apply(this,[t])}),0)}}if(r!==s.width||n!==s.height){this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t);this._updateDrawingLayersSize(),this._updateVideoContainerStyle();const t=this.mapCameraEvents.get("resolutionchange");for(let e of t){if(!e)continue;const t=JSON.parse(JSON.stringify(s));setTimeout((()=>{this.isDisposed&&this.disposed||e.apply(this,[t])}),0)}}return s}getResolution(){if(this._bOpen)return[this._video.videoWidth,this._video.videoHeight];{let t=0,e=0;const i=this.videoSettings.video.width,r=this.videoSettings.video.height;return i&&(t=i.exact||i.ideal||i),r&&(e=r.exact||r.ideal||r),[t,e]}}async setResolution(t,e){let i,r;if(t instanceof Array?(i=t[0],r=t[1]):(i=t,r=e),this.videoSettings.video.width={ideal:i},this.videoSettings.video.height={ideal:r},!this._bOpen||this._video.paused)return null;const n=this._video.videoWidth,s=this._video.videoHeight,o=await this.play(null,i,r);if(n!==o.width||s!==o.height){this._updateScanRegionCanvas(),this._updateScanAreaDiv(),this._updateViewDecorator();for(let t of this._arrScanRegionOverlays)t&&this._updateScanRegionOverlay(t);this._updateDrawingLayersSize(),this._updateVideoContainerStyle();const t=this.mapCameraEvents.get("resolutionchange");for(let e of t){if(!e)continue;const t=JSON.parse(JSON.stringify(o));setTimeout((()=>{this.isDisposed&&this.disposed||e.apply(this,[t])}),0)}}return o}async getResolutions(t){var e,i;let r="";const n=(t,e)=>{const i=this._mapCameraResolutions.get(t);if(!i||!i.length)return!1;for(let t of i)if(t[0]===e.width&&t[1]===e.height)return!0;return!1},s=async(t,e,i)=>{const r={video:{deviceId:{exact:t},width:{ideal:e},height:{ideal:i}}};let n=null;try{n=await navigator.mediaDevices.getUserMedia(r)}catch(t){return null}if(!n)return null;const s=n.getVideoTracks();let o=null;try{const t=s[0].getSettings();o={width:t.width,height:t.height}}catch(t){const e=document.createElement("video");e.srcObject=n,o={width:e.videoWidth,height:e.videoHeight},e.srcObject=null}return s.forEach((t=>{t.stop()})),o};if(!this._bOpen){const o=null===(i=null===(e=this.videoSettings)||void 0===e?void 0:e.video)||void 0===i?void 0:i.deviceId;if(!o)return null;if(r=o.hasOwnProperty("exact")?this.videoSettings.video.deviceId.exact:o.hasOwnProperty("ideal")?this.videoSettings.video.deviceId.ideal:this.videoSettings.video.deviceId,!r)return null;let a=this._mapCameraResolutions.get(r);if(a&&!t)return this._mapCameraResolutions.get(r);this._mapCameraResolutions.set(r,[]),a=this._mapCameraResolutions.get(r);for(let t of this._predefinedResolutions){const e=await s(r,t.width,t.height);e&&!n(r,e)&&a.push([e.width,e.height])}return a}if(this._currentCamera){r=this._currentCamera.deviceId;let e=this._mapCameraResolutions.get(r);if(e&&!t)return this._mapCameraResolutions.get(r);this._mapCameraResolutions.set(r,[]),e=this._mapCameraResolutions.get(r);let i=this._videoTrack;for(let t of this._predefinedResolutions){await i.applyConstraints({width:{ideal:t.width},height:{ideal:t.height}});const s=i.getSettings(),o={width:s.width,height:s.height};n(r,o)||e.push([o.width,o.height])}return this._video.srcObject.getTracks().forEach((t=>{t.stop()})),await this.play(r,null,null,{notTriggerPlayedEvent:!0}),e}return null}on(t,e){if(!e)return;const i=this.mapCameraEvents.get(t.toLowerCase());if(!i)throw new Error(`Event '${t}' does not exist.`);i.includes(e)||i.push(e)}off(t,e){const i=this.mapCameraEvents.get(t.toLowerCase());if(!i)throw new Error(`Event '${t}' does not exist.`);const r=i.indexOf(e);-1!==r&&i.splice(r,1)}offAll(t){if(t){if("string"==typeof t){const e=this.mapCameraEvents.get(t);e&&(e.length=0)}}else for(let t of this.mapCameraEvents.values())t&&(t.length=0)}getVideoSettings(){return JSON.parse(JSON.stringify(this.videoSettings))}updateVideoSettings(t){if(this.videoSettings=JSON.parse(JSON.stringify(t)),this._lastDeviceId=null,this._bOpen)return this.play()}isOpen(){return this._bOpen}getCapabilities(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getCapabilities()' is unavailable in singleFrameMode.");return this._videoTrack&&this._videoTrack.getCapabilities?this._videoTrack.getCapabilities():{}}getCameraSettings(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getCameraSettings()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getSettings():null}getConstraints(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getConstraints()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getConstraints():null}async applyConstraints(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'applyConstraints()' is unavailable in singleFrameMode.");if(!this._videoTrack)throw new Error('"_videoTrack" is null.');if(!this._videoTrack.applyConstraints)throw Error("Not supported.");return await this._videoTrack.applyConstraints(t)}async turnOnTorch(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'turnOnTorch()' is unavailable in singleFrameMode.");if(this.getCapabilities().torch)return await this._videoTrack.applyConstraints({advanced:[{torch:!0}]});throw Error("Not supported.")}async turnOffTorch(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'turnOffTorch()' is unavailable in singleFrameMode.");if(this.getCapabilities().torch)return await this._videoTrack.applyConstraints({advanced:[{torch:!1}]});throw Error("Not supported.")}async setColorTemperature(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setColorTemperature()' is unavailable in singleFrameMode.");let e=this.getCapabilities().colorTemperature;if(!e)throw Error("Not supported.");return t<e.min?t=e.min:t>e.max&&(t=e.max),await this._videoTrack.applyConstraints({advanced:[{colorTemperature:t,whiteBalanceMode:"manual"}]})}getColorTemperature(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getColorTemperature()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getSettings().colorTemperature||0:null}async setExposureCompensation(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setExposureCompensation()' is unavailable in singleFrameMode.");let e=this.getCapabilities().exposureCompensation;if(!e)throw Error("Not supported.");return t<e.min?t=e.min:t>e.max&&(t=e.max),await this._videoTrack.applyConstraints({advanced:[{exposureCompensation:t}]})}getExposureCompensation(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getExposureCompensation()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getSettings().exposureCompensation||0:null}async _setHardwareScale(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_setHardwareScale()' is unavailable in singleFrameMode.");if(t<1)throw new RangeError("Invalid value.");if(!this._videoTrack)return;const e=this.getCapabilities().zoom;if(!e)throw new Error("Not supported.");return t<e.min?t=e.min:t>e.max&&(t=e.max),t=at(t,e.min,e.step,e.max),await this._videoTrack.applyConstraints({advanced:[{zoom:t}]}),t}_getHardwareScale(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_getHardwareScale()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getSettings().zoom||1:null}_setSoftwareScale(t,e){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_setSoftwareScale()' is unavailable in singleFrameMode.");if(t<1)throw new RangeError("Invalid value.");e&&this._setScaleCenter(e),this._softwareScale=t,this._scaleVideo(t,e)}_getSoftwareScale(){return this._softwareScale}_setScaleCenter(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_setScaleCenter()' is unavailable in singleFrameMode.");if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid center.");const e=this._video.videoWidth,i=this._video.videoHeight;let r=0,n=0;if(t.x.endsWith("px"))r=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid scale center.");r=parseFloat(t.x)/100*e}if(t.y.endsWith("px"))n=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid scale center.");n=parseFloat(t.y)/100*i}this._scaleCenter={x:r,y:n}}_resetScaleCenter(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_resetScaleCenter()' is unavailable in singleFrameMode.");const t=this._video.videoWidth,e=this._video.videoHeight;this._scaleCenter={x:t/2,y:e/2}}_isVideoCenter(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_isVideoCenter()' is unavailable in singleFrameMode.");return t&&t.x==this._video.videoWidth/2&&t.y==this._video.videoHeight/2}async _setZoom(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setZoom()' is unavailable in singleFrameMode.");if(t<1)throw new RangeError("Invalid value.");this._resetScaleCenter();try{if(this._isVideoCenter(this._scaleCenter)){const e=await this._setHardwareScale(t);let i=this._getHardwareScale();1==i&&1!=e&&(i=e),t>i?this._setSoftwareScale(t/i):this._setSoftwareScale(1)}else await this._setHardwareScale(1),this._setSoftwareScale(t)}catch(e){if("Not supported."!==(e.message||e))throw e;this._setSoftwareScale(t)}}async setZoom(t){if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("Illegal type of argument.");if("number"==typeof t)return this._setZoom(t);if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setZoom()' is unavailable in singleFrameMode.");if(t){if("number"!=typeof t.factor)throw new TypeError("Illegal type of 'factor'.");if(t.factor<1)throw new RangeError("Invalid value.");t.centerPoint?this._setScaleCenter(t.centerPoint):this._resetScaleCenter();try{if(this._isVideoCenter(this._scaleCenter)){const e=await this._setHardwareScale(t.factor);let i=this._getHardwareScale();1==i&&1!=e&&(i=e),t.factor>i?this._setSoftwareScale(t.factor/i):this._setSoftwareScale(1)}else await this._setHardwareScale(1),this._setSoftwareScale(t.factor)}catch(e){if("Not supported."!==(e.message||e))throw e;this._setSoftwareScale(t.factor)}}}getZoom(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getZoom()' is unavailable in singleFrameMode.");return this._videoTrack?this._getHardwareScale()*this._softwareScale:null}getZoomSettings(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getZoom()' is unavailable in singleFrameMode.");return this._videoTrack?{factor:this._getHardwareScale()*this._softwareScale}:null}async resetZoom(){await this.setZoom({factor:1})}async setFrameRate(t){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setFrameRate()' is unavailable in singleFrameMode.");let e=this.getCapabilities().frameRate;if(!e)throw Error("Not supported.");return t<e.min?t=e.min:t>e.max&&(t=e.max),await this._videoTrack.applyConstraints({width:{ideal:Math.max(this._video.videoWidth,this._video.videoHeight)},frameRate:t})}getFrameRate(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getFrameRate()' is unavailable in singleFrameMode.");return this._videoTrack?this._videoTrack.getSettings().frameRate:null}async _setFocus(t,e){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setFocus()' is unavailable in singleFrameMode.");if("string"!=typeof t)throw Error("Invalid focus mode.");t=t.toLowerCase();const i=this.getCapabilities().focusMode,r=this.getCapabilities().focusDistance;if(!i)throw Error("Not supported.");if(!i.includes(t))throw Error("Unsupported mode.");if(e>=0){if(!r)throw Error("Manual focus unsupported.");return e<r.min?e=r.min:e>r.max&&(e=r.max),e=at(e,r.min,r.step,r.max),await this._videoTrack.applyConstraints({advanced:[{focusMode:t,focusDistance:e}]})}return await this._videoTrack.applyConstraints({advanced:[{focusMode:t}]})}async setFocus(t,e){if("string"==typeof t)return this._setFocus(t,e);if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'setFocus()' is unavailable in singleFrameMode.");if(!t)return;const i=this.getCapabilities(),r=i.focusMode,n=i.focusDistance;if(!r)throw Error("Not supported.");if("string"!=typeof t.mode)throw Error("Invalid focus mode.");const s=t.mode.toLowerCase();if(!r.includes(s))throw Error("Unsupported focus mode.");if("manual"!==s)return this._focusParameters._focusArea=null,await this._videoTrack.applyConstraints({advanced:[{focusMode:s}]});if(!n)throw Error("Manual focus unsupported.");if(t.hasOwnProperty("distance")){let e=t.distance;return e<n.min?e=n.min:e>n.max&&(e=n.max),e=at(e,n.min,n.step,n.max),this._focusParameters._focusArea=null,await this._videoTrack.applyConstraints({advanced:[{focusMode:s,focusDistance:e}]})}if(!t.area)throw new Error("'distance' or 'area' should be specified in 'manual' mode.");{const e=t.area.centerPoint;let i=t.area.width,r=t.area.height;if(!i||!r){const t=this._video.videoWidth,e=this._video.videoHeight;i||(i=2*Math.round(Math.min(t,e)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px"),r||(r=2*Math.round(Math.min(t,e)/this._focusParameters.defaultFocusAreaSizeRatio/2)+"px")}this._focusParameters._focusArea={centerPoint:{x:e.x,y:e.y},width:i,height:r},await this._setLocalFocus(e,i,r)}}getFocus(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_getHardwareScale()' is unavailable in singleFrameMode.");if(!this._videoTrack)return null;const t=this._videoTrack.getSettings().focusMode;return t?"continuous"===t?{mode:t}:{mode:t,distance:this._videoTrack.getSettings().focusDistance}:null}getFocusSettings(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_getHardwareScale()' is unavailable in singleFrameMode.");if(!this._videoTrack)return null;const t=this._videoTrack.getSettings(),e=t.focusMode;return e?"manual"===e?this._focusParameters._focusArea?{mode:"manual",area:JSON.parse(JSON.stringify(this._focusParameters._focusArea))}:{mode:"manual",distance:t.focusDistance}:{mode:e}:null}async _setFocusAndGetContract(t,e){const i=t=>{if(!this._bOpen||!this._videoTrack||this.video.paused||t.focusTaskId!=this._focusParameters.curFocusTaskId){this._bOpen&&this._videoTrack&&!this.video.paused||(this._focusParameters.isDoingFocus=0);const e=new Error(`Focus task ${t.focusTaskId} canceled.`);throw e.name="DeprecatedTaskError",e}1===this._focusParameters.isDoingFocus&&Date.now()-t.timeStart>this._focusParameters.focusCancelableTime&&(this._focusParameters.isDoingFocus=-1)};let r;e=at(e,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),await this._videoTrack.applyConstraints({advanced:[{focusMode:"manual",focusDistance:e}]}),i(t),r=null==this._focusParameters.oldDistance?this._focusParameters.kTimeout*Math.max(Math.abs(1/this._focusParameters.fds.min-1/e),Math.abs(1/this._focusParameters.fds.max-1/e))+this._focusParameters.minTimeout:this._focusParameters.kTimeout*Math.abs(1/this._focusParameters.oldDistance-1/e)+this._focusParameters.minTimeout,this._focusParameters.oldDistance=e,await new Promise((t=>{setTimeout(t,r)})),i(t);let n=t.focusL-t.focusW/2,s=t.focusT-t.focusH/2,o=t.focusW,a=t.focusH;if(n>=this.video.videoWidth||s>=this.video.videoHeight)throw new Error("Invalid area.");n+o>this.video.videoWidth&&(o=this.video.videoWidth-n),s+a>this.video.videoHeight&&(a=this.video.videoHeight-s);const h=this._getImageData(this.video,this.video.videoWidth,this.video.videoHeight,{sx:n,sy:s,sWidth:o,sHeight:a,dWidth:o,dHeight:a},null,{pixelFormat:ot.RGBA});if(!h)return this._setFocusAndGetContract(t,e);const l=h.data;let c=0;for(let t=0,e=l.length-8;t<e;++t){let e=l[t]-l[t+8];++t;let i=l[t]-l[t+8];++t;let r=l[t]-l[t+8];++t,c+=e*e+i*i+r*r}return-c}async _doFocusDetail(t,e,i,r,n,s,o){let a;if(e=at(e,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),r=at(r,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s?s=at(s,this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max):(s=at(Math.sqrt((e||this._focusParameters.fds.step)*(r||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),o=await this._setFocusAndGetContract(t,s)),o<=i&&o<=n?a=3:i<n&&i<o?a=1:n<i&&n<o&&(a=2),(r-e)/2<=this._focusParameters.fds.step)return 3===a||(1===a?await this._videoTrack.applyConstraints({advanced:[{focusMode:"manual",focusDistance:e}]}):2===a&&await this._videoTrack.applyConstraints({advanced:[{focusMode:"manual",focusDistance:r}]})),!0;if(1===a)return await this._doFocusDetail(t,e,i,s,o);if(2===a)return await this._doFocusDetail(t,s,o,r,n);if(3!==a)return i=await this._setFocusAndGetContract(t,e),n=await this._setFocusAndGetContract(t,r),await this._doFocusDetail(t,e,i,r,n);let h=at(Math.sqrt((e||this._focusParameters.fds.step)*(s||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),l=at(Math.sqrt((r||this._focusParameters.fds.step)*(s||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max);if(Math.abs(1/this._focusParameters.oldDistance-1/h)<=Math.abs(1/this._focusParameters.oldDistance-1/l)){let a=await this._setFocusAndGetContract(t,h);if(a<o)return await this._doFocusDetail(t,e,i,s,o,h,a);if(a==o)return await this._doFocusDetail(t,h,a,s,o);let c=await this._setFocusAndGetContract(t,l);if(a>o&&o<c)return await this._doFocusDetail(t,h,a,l,c,s,o);if(o==c)return await this._doFocusDetail(t,s,o,l,c);if(o>c)return await this._doFocusDetail(t,s,o,r,n,l,c)}else{let a=await this._setFocusAndGetContract(t,l);if(o>a)return await this._doFocusDetail(t,s,o,r,n,l,a);if(o==a)return await this._doFocusDetail(t,s,o,l,a);let c=await this._setFocusAndGetContract(t,h);if(c>o&&o<a)return await this._doFocusDetail(t,h,c,l,a,s,o);if(c==o)return await this._doFocusDetail(t,h,c,s,o);if(c<o)return await this._doFocusDetail(t,e,i,s,o,h,c)}return!1}async _setLocalFocus(t,e,i,r,n){if(1==this._focusParameters.isDoingFocus)return!1;if(!t||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("Invalid centerPoint.");if(!e||"string"!=typeof e)throw new Error("Invalid width.");if(!i||"string"!=typeof i)throw new Error("Invalid height.");const s=this._video.videoWidth,o=this._video.videoHeight;let a=0,h=0;if(t.x.endsWith("px"))a=parseFloat(t.x);else{if(!t.x.endsWith("%"))throw new Error("Invalid centerPoint.");a=parseFloat(t.x)/100*s}if(t.y.endsWith("px"))h=parseFloat(t.y);else{if(!t.y.endsWith("%"))throw new Error("Invalid centerPoint.");h=parseFloat(t.y)/100*o}let l=0;if(e.endsWith("px"))l=parseFloat(e);else{if(!e.endsWith("%"))throw new Error("Invalid width.");l=parseFloat(e)/100*s}let c=0;if(i.endsWith("px"))c=parseFloat(i);else{if(!i.endsWith("%"))throw new Error("Invalid height.");c=parseFloat(i)/100*o}if(1!==this._softwareScale){const t=this._softwareScale,e=this._scaleCenter;l/=t,c/=t,a=(1-1/t)*e.x+a/t,h=(1-1/t)*e.y+h/t}if(!this._focusSupported)throw new Error("Manual focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=(await this.getCapabilities()).focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,new Error("Manual focus unsupported.");null==this._focusParameters.kTimeout&&(this._focusParameters.kTimeout=(this._focusParameters.maxTimeout-this._focusParameters.minTimeout)/(1/this._focusParameters.fds.min-1/this._focusParameters.fds.max)),this._focusParameters.isDoingFocus=1;const u={focusL:a,focusT:h,focusW:l,focusH:c,focusTaskId:++this._focusParameters.curFocusTaskId,timeStart:Date.now()},d=async(t,e,i)=>{try{(null==e||e<this._focusParameters.fds.min)&&(e=this._focusParameters.fds.min),(null==i||i>this._focusParameters.fds.max)&&(i=this._focusParameters.fds.max),this._focusParameters.oldDistance=null;let r=at(Math.sqrt(i*(e||this._focusParameters.fds.step)),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),n=at(Math.sqrt((e||this._focusParameters.fds.step)*r),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),s=at(Math.sqrt(r*i),this._focusParameters.fds.min,this._focusParameters.fds.step,this._focusParameters.fds.max),o=await this._setFocusAndGetContract(t,s),a=await this._setFocusAndGetContract(t,n),h=await this._setFocusAndGetContract(t,r);if(a>h&&h<o){const e=await this._doFocusDetail(t,n,a,s,o,r,h);return this._focusParameters.isDoingFocus=0,e}if(a<h&&a<o){let i=await this._setFocusAndGetContract(t,e);const s=await this._doFocusDetail(t,e,i,r,h,n,a);return this._focusParameters.isDoingFocus=0,s}if(h>o&&a>o){let e=await this._setFocusAndGetContract(t,i);const n=await this._doFocusDetail(t,r,h,i,e,s,o);return this._focusParameters.isDoingFocus=0,n}if(a==h&&h<o){const e=await this._doFocusDetail(t,n,a,r,h);return this._focusParameters.isDoingFocus=0,e}if(h==o&&a>h){const e=await this._doFocusDetail(t,r,h,s,o);return this._focusParameters.isDoingFocus=0,e}return d(t,e,i)}catch(t){if("DeprecatedTaskError"!==t.name)throw t}};return d(u,r,n)}async enableTapToFocus(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'enableTapToFocus()' is unavailable in singleFrameMode.");if(!this._videoTrack)throw new Error("Video is not playing.");if(!this._focusSupported)throw new Error("Tapping to focus unsupported.");if(!this._focusParameters.fds&&(this._focusParameters.fds=(await this.getCapabilities()).focusDistance,!this._focusParameters.fds))throw this._focusSupported=!1,this._tapFocusEnabled=!1,new Error("Tapping to focus unsupported.");this._tapFocusEnabled=!0}disableTapToFocus(){this._tapFocusEnabled=!1}isTapToFocusEnabled(){return this._tapFocusEnabled}_updateVideoContainerStyle(){if(!this._video)return;if(this._isSingleFrameModeEnabled())return;const t=this._getSoftwareScale(),e=this._videoContainer;if("contain"===this.videoFit&&t>1){const t=this._video.videoWidth,i=this._video.videoHeight,r=window.getComputedStyle(this._elContainer),n=parseFloat(r.width),s=parseFloat(r.height),o=t/i;if(n/s<o){let t=n/o;e.style.left="0",e.style.top=(s-t)/2/s*100+"%",e.style.width="100%",e.style.height=t/s*100+"%"}else{let t=s*o;e.style.left=(n-t)/2/n*100+"%",e.style.top="0",e.style.width=t/n*100+"%",e.style.height="100%"}}else e.style.left="0",e.style.top="0",e.style.width="100%",e.style.height="100%"}_scaleVideo(t,e){if(this._video&&!this._isSingleFrameModeEnabled()){if(t<1)throw new RangeError("Invalid scale value.");if(e&&this._setScaleCenter(e),1===t)this._video.style.transform="";else{const e=this.getVideoFit(),i=this._video.videoWidth,r=this._video.videoHeight,n=window.getComputedStyle(this._elContainer),s=parseFloat(n.width),o=parseFloat(n.height),a=s/o,h=i/r;let l=1;"contain"===e?l=a<h?s/(i/t):o/(r/t):"cover"===e&&(l=h>a?o/(i/t):s/(r/t));const c=l*(1-1/t)*(i/2-this._scaleCenter.x),u=l*(1-1/t)*(r/2-this._scaleCenter.y);this._video.style.transform=`translate(${c}px, ${u}px) scale(${t})`}this._updateVideoContainerStyle()}}getFrameSize(t,e,i,r){if(!t||!e)return null;let n,s,o,a,h=t,l=e;const c={regionLeft:0,regionTop:0,regionRight:h,regionBottom:l,regionMeasuredByPercentage:!1};i?(i.regionMeasuredByPercentage?(c.regionLeft=i.regionLeft*h/100,c.regionTop=i.regionTop*l/100,c.regionRight=i.regionRight*h/100,c.regionBottom=i.regionBottom*l/100):(c.regionLeft=i.regionLeft,c.regionTop=i.regionTop,c.regionRight=i.regionRight,c.regionBottom=i.regionBottom),n=Math.round(c.regionLeft),s=Math.round(c.regionTop),h=Math.round(c.regionRight-c.regionLeft),l=Math.round(c.regionBottom-c.regionTop)):(n=0,s=0,h=Math.round(h),l=Math.round(l));const u=Math.max(h,l);if(r&&r>0&&u>r){const t=r/u;h>l?(o=r,a=Math.round(l*t)):(o=Math.round(h*t),a=r)}else o=h,a=l;return o<=0||a<=0?null:{sx:n,sy:s,sWidth:h,sHeight:l,dWidth:o,dHeight:a}}getFrame(){if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'getFrame()' is unavailable in singleFrameMode.");return this._getVideoData()}getImage(){return this.getFrame()}_drawImage(t,e,i,r,n,s,o){if(this.isDisposed&&this.disposed)throw Error("The 'CameraEnhancer' instance has been disposed.");if(!i||!r)return null;if(e instanceof HTMLVideoElement&&4!==e.readyState||e instanceof HTMLImageElement&&!e.complete)throw new Error("The source is not loaded.");let a;ht._onLog&&(a=Date.now(),ht._onLog("DCE: _drawImage(), START: "+a));let h=0,l=0,c=i,u=r,d=0,f=0,g=i,_=r;n&&(n.sx&&(h=Math.round(n.sx)),n.sy&&(l=Math.round(n.sy)),n.sWidth&&(c=Math.round(n.sWidth)),n.sHeight&&(u=Math.round(n.sHeight)),n.dx&&(d=Math.round(n.dx)),n.dy&&(f=Math.round(n.dy)),n.dWidth&&(g=Math.round(n.dWidth)),n.dHeight&&(_=Math.round(n.dHeight)));let p=ot.RGBA;o&&o.pixelFormat&&(p=o.pixelFormat);const m=t;if(!o||!o.bUseWebGL){ht._onLog&&ht._onLog("DCE: _drawImage() in context2d."),m.ctx2d||(m.ctx2d=m.getContext("2d",{willReadFrequently:!0}));const t=m.ctx2d;if(!t)throw new Error("Unable to get 'CanvasRenderingContext2D' from canvas.");return(m.width<d+g||m.height<f+_)&&(m.width=d+g,m.height=f+_),t.drawImage(e,h,l,c,u,d,f,g,_),ht._onLog&&ht._onLog("DCE: _drawImage() in context2d end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:ot.RGBA,_bUseWebGL:!1}}ht._onLog&&ht._onLog("DCE: _drawImage() in WebGL.");try{(m.width<d+g||m.height<f+_)&&(m.width=d+g,m.height=f+_,m.ctxWebGL&&m.ctxWebGL.viewport(0,0,d+g,f+_));const t=m.ctxWebGL||m.getContext("webgl",{antialias:!1})||m.getContext("experimental-webgl",{antialias:!1});if(!t){ht._onLog&&ht._onLog("DCE: WebGL unavailable.");const t=new Error("WebGL error: unable to initialize WebGL. Your browser or machine may not support it.");throw t.name="WebGLError",t}if(!m.ctxWebGL||p!==this.shaderPixelFormat){m.ctxWebGL=t;const e=t=>{const e=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,e),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);const i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),{positions:e,texCoords:i}},i=t=>{const e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e},r=(t,e)=>{const i=t.createProgram();if(e.forEach((e=>t.attachShader(i,e))),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS)){const e=new Error(`An error occured linking the program: ${t.getProgramInfoLog(i)}.`);throw e.name="WebGLError",e}return t.useProgram(i),i},n=(t,e,i)=>{const r=t.createShader(e);if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS)){const e=new Error(`An error occured compiling the shader: ${t.getShaderInfoLog(r)}.`);throw e.name="WebGLError",e}return r},s="\n                        attribute vec2 a_position;\n                        attribute vec2 a_texCoord;\n    \n                        uniform mat3 u_matrix;\n                        uniform mat3 u_textureMatrix;\n    \n                        varying vec2 v_texCoord;\n                        void main(void) {\n                        gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1.0);\n                        v_texCoord = vec4((u_textureMatrix * vec3(a_texCoord, 1)).xy, 0, 1.0).xy;\n                        }\n                    ";let o="rgb";["rgba","rbga","grba","gbra","brga","bgra"].includes(p)&&(o=p.slice(0,3));const a=`\n                        precision mediump float;\n                        varying vec2 v_texCoord;\n                        uniform sampler2D u_image;\n                        uniform float uColorFactor;\n    \n                        void main() {\n                            vec4 sample = texture2D(u_image, v_texCoord);\n                            float grey = 0.21 * sample.r + 0.71 * sample.g + 0.07 * sample.b;\n                            gl_FragColor = vec4(sample.${o} * (1.0 - uColorFactor) + (grey * uColorFactor), sample.a);\n                        }\n                    `,h=r(t,[n(t,t.VERTEX_SHADER,s),n(t,t.FRAGMENT_SHADER,a)]);this._webGLProgramInfo={program:h,attribLocations:{vertexPosition:t.getAttribLocation(h,"a_position"),texPosition:t.getAttribLocation(h,"a_texCoord")},uniformLocations:{uSampler:t.getUniformLocation(h,"u_image"),uColorFactor:t.getUniformLocation(h,"uColorFactor"),uMatrix:t.getUniformLocation(h,"u_matrix"),uTextureMatrix:t.getUniformLocation(h,"u_textureMatrix")}},this._webGLBuffers=e(t),this._webGLTexture=i(t),this.shaderPixelFormat=p}const n=(t,e,i)=>{t.bindBuffer(t.ARRAY_BUFFER,e),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0)},o=(t,e,i)=>{const r=t.RGBA,n=t.RGBA,s=t.UNSIGNED_BYTE;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,r,n,s,i)},v=(t,e,s,o)=>{t.clearColor(0,0,0,1),t.clearDepth(1),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),n(t,s.positions,e.attribLocations.vertexPosition),n(t,s.texCoords,e.attribLocations.texPosition),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.uniform1i(e.uniformLocations.uSampler,0),t.uniform1f(e.uniformLocations.uColorFactor,[ot.GREY,ot.GREY32].includes(p)?1:0);let a,m,v=st.translate(st.identity(),-1,-1);v=st.scale(v,2,2),v=st.scale(v,1/t.canvas.width,1/t.canvas.height),a=st.translate(v,d,f),a=st.scale(a,g,_),t.uniformMatrix3fv(e.uniformLocations.uMatrix,!1,a),m=st.translate(st.identity(),h/i,l/r),m=st.scale(m,c/i,u/r),t.uniformMatrix3fv(e.uniformLocations.uTextureMatrix,!1,m),t.drawArrays(t.TRIANGLES,0,6)};let y;if(o(t,this._webGLTexture,e),v(t,this._webGLProgramInfo,this._webGLBuffers,this._webGLTexture),s){if(s.length<g*_*4)throw new Error("Unexpected size of the 'bufferContainer'.");y=s}else y=new Uint8Array(g*_*4);if(t.readPixels(d,f,g,_,t.RGBA,t.UNSIGNED_BYTE,y),255!==y[3]){ht._onLog&&ht._onLog("DCE: WebGL drawing incorrect."),this._bWebGLSupported=!1;const t=new Error("WebGL error: incorrect WebGL drawing.");throw t.name="WebGLError",t}return ht._onLog&&ht._onLog("DCE: _drawImage() in WebGL end. Costs: "+(Date.now()-a)),{context:t,pixelFormat:p===ot.GREY?ot.GREY32:p,_bUseWebGL:!0}}catch(t){throw this._bWebGLSupported=!1,t.name="WebGLError",t}}_readCvsData(t,e,i){let r,n=0,s=0,o=t.canvas.width,a=t.canvas.height;if(e&&(e.x&&(n=e.x),e.y&&(s=e.y),e.width&&(o=e.width),e.height&&(a=e.height)),t instanceof WebGLRenderingContext){const e=t;if(i){if(i.length<o*a*4)throw new Error("Unexpected size of the 'bufferContainer'.");e.readPixels(n,s,o,a,e.RGBA,e.UNSIGNED_BYTE,i),r=new Uint8Array(i.buffer,0,o*a*4)}else r=new Uint8Array(o*a*4),e.readPixels(n,s,o,a,e.RGBA,e.UNSIGNED_BYTE,r)}else if(t instanceof CanvasRenderingContext2D){let e;if(e=t.getImageData(n,s,o,a),r=new Uint8Array(e.data.buffer),i){if(i.length<r.length)throw new Error("Unexpected size of the 'bufferContainer'.");i.set(r)}}return r}_transformPixelFormat(t,e,i,r){let n,s;if(ht._onLog&&(n=Date.now(),ht._onLog("DCE: _transformPixelFormat(), START: "+n)),e===i)return ht._onLog&&ht._onLog("DCE: _transformPixelFormat() end. Costs: "+(Date.now()-n)),r?new Uint8Array(t):t;const o=[ot.RGBA,ot.RBGA,ot.GRBA,ot.GBRA,ot.BRGA,ot.BGRA];if(o.includes(e))if(i===ot.GREY){s=new Uint8Array(t.length/4);for(let e=0;e<t.length;e+=4){const i=.21*t[e]+.71*t[e+1]+.07*t[e+2];s[e/4]=i}}else if(i===ot.GREY32){s=r?new Uint8Array(t):t;for(let e=0;e<t.length;e+=4){const i=.21*t[e]+.71*t[e+1]+.07*t[e+2];s[e]=i,s[e+1]=i,s[e+2]=i}}else{if(!o.includes(i))throw new Error("Unable to transform.");if(r){s=new Uint8Array(t);const r=e.indexOf("r"),n=e.indexOf("g"),o=e.indexOf("b"),a=i.indexOf("r"),h=i.indexOf("g"),l=i.indexOf("b");for(let e=0;e<t.length;e+=4)s[e+a]=t[e+r],s[e+h]=t[e+n],s[e+l]=t[e+o]}else{s=t;const r=e.indexOf("r"),n=e.indexOf("g"),o=e.indexOf("b"),a=i.indexOf("r"),h=i.indexOf("g"),l=i.indexOf("b");for(let e=0;e<t.length;e+=4){let i=[t[e],t[e+1],t[e+2]];s[e+a]=i[r],s[e+h]=i[n],s[e+l]=i[o]}}}else if(e===ot.GREY){if(i!==ot.GREY32)throw new Error("Unable to transform.");s=new Uint8Array(4*t.length);for(let e=0;e<t.length;e++)s[4*e]=t[e],s[4*e+1]=t[e],s[4*e+2]=t[e],s[4*e+3]=255}else{if(e!==ot.GREY32)throw new Error("Unable to transform.");if(i!==ot.GREY)throw new Error("Unable to transform.");s=new Uint8Array(t.length/4);for(let e=0;e<t.length;e+=4)s[e/4]=t[e]}return ht._onLog&&ht._onLog("DCE: _transformPixelFormat() end. Costs: "+(Date.now()-n)),s}_getImageData(t,e,i,r,n,s){if(this.isDisposed&&this.disposed)throw Error("The 'CameraEnhancer' instance has been disposed.");if(!e||!i)return null;if(r.sx>e||r.sy>i||r.sx+r.sWidth>e||r.sy+r.sHeight>i)throw new Error("Invalid position.");if(t instanceof HTMLVideoElement&&4!==t.readyState||t instanceof HTMLImageElement&&!t.complete)throw new Error("The source is not loaded.");let o;ht._onLog&&(o=Date.now(),ht._onLog("DCE: _getImageData(), START: "+o));const a=Math.round(r.sx),h=Math.round(r.sy),l=Math.round(r.sWidth),c=Math.round(r.sHeight),u=Math.round(r.dWidth),d=Math.round(r.dHeight);let f=ot.RGBA;s&&s.pixelFormat&&(f=s.pixelFormat);let g,_,p,m=this._bWebGLSupported;s&&0==s.bUseWebGL&&(m=!1),m?(this._reusedWebGLCvs||(this._reusedWebGLCvs=document.createElement("canvas")),g=this._reusedWebGLCvs):(this._reusedCvs||(this._reusedCvs=document.createElement("canvas")),g=this._reusedCvs);try{if(m)if(ht._onLog&&ht._onLog("DCE: _getImageData() in WebGL."),n)if(f===ot.GREY){if(p=new Uint8Array(u*d*4),_=this._drawImage(g,t,e,i,{sx:a,sy:h,sWidth:l,sHeight:c,dWidth:u,dHeight:d},p,{pixelFormat:f,bUseWebGL:m}),p=this._transformPixelFormat(p,_.pixelFormat,f),n){if(n.length<p.length)throw new Error("Unexpected size of the 'bufferContainer'.");n.set(p)}}else _=this._drawImage(g,t,e,i,{sx:a,sy:h,sWidth:l,sHeight:c,dWidth:u,dHeight:d},n,{pixelFormat:f,bUseWebGL:m}),p=new Uint8Array(n.buffer,0,u*d*4),p=this._transformPixelFormat(p,_.pixelFormat,f);else f===ot.GREY?((!this._tempDataContainer||this._tempDataContainer.length<u*d*4)&&(this._tempDataContainer=new Uint8Array(u*d*4)),p=new Uint8Array(this._tempDataContainer.buffer,0,u*d*4)):p=new Uint8Array(u*d*4),_=this._drawImage(g,t,e,i,{sx:a,sy:h,sWidth:l,sHeight:c,dWidth:u,dHeight:d},p,{pixelFormat:f,bUseWebGL:m}),p=this._transformPixelFormat(p,_.pixelFormat,f);else if(ht._onLog&&ht._onLog("DCE: _getImageData() in context2d."),_=this._drawImage(g,t,e,i,{sx:a,sy:h,sWidth:l,sHeight:c,dWidth:u,dHeight:d},null,{pixelFormat:ot.RGBA,bUseWebGL:m}),p=this._readCvsData(_.context,{width:u,height:d},null),p=this._transformPixelFormat(p,_.pixelFormat,f),n){if(n.length<p.length)throw new Error("Unexpected size of the 'bufferContainer'.");n.set(p)}}catch(r){if("WebGLError"===r.name)return ht._onLog&&ht._onLog("DCE: _getImageData() in WebGL failed, try again in context2d."),this.forceLoseContext(),this._bWebGLSupported=!1,this._getImageData(t,e,i,{sx:a,sy:h,sWidth:l,sHeight:c,dWidth:u,dHeight:d},n,s);throw r}return ht._onLog&&ht._onLog("DCE: _getImageData() end. Costs: "+(Date.now()-o)),{data:p,pixelFormat:f,_bUseWebGL:_._bUseWebGL}}forceLoseContext(){if(!this._reusedWebGLCvs)return;const t=this._reusedWebGLCvs.ctxWebGL;t&&!t.isContextLost()&&t.getExtension("WEBGL_lose_context")&&t.getExtension("WEBGL_lose_context").loseContext(),this._webGLTexture=null,this._webGLProgramInfo=null,this._webGLBuffers=null,this._reusedWebGLCvs=null}_getVideoData(t,e){if(this.isDisposed&&this.disposed)throw Error("The 'CameraEnhancer' instance has been disposed.");if(this._assertOpen(),this._isSingleFrameModeEnabled())throw new Error("'_getVideoData()' is unavailable in singleFrameMode.");if(!this._video||4!==this._video.readyState)return null;const i=Date.now();ht._onLog&&ht._onLog("DCE: _getVideoData() START: "+i);let r=this._scanRegion;e&&e.hasOwnProperty("region")&&(r=e.region);let n=this.mapPixelFormatString_Enum.get(this.framePixelFormat.toLowerCase());e&&e.pixelFormat&&(n=this.mapPixelFormatString_Enum.get(e.pixelFormat.toLowerCase()));let s=this._softwareScale;e&&e.scale&&(s=e.scale);const o=this._video.videoWidth,a=this._video.videoHeight;let h=this._scaleCenter;if(e&&e.scaleCenter){if("string"!=typeof e.scaleCenter.x||"string"!=typeof e.scaleCenter.y)throw new Error("Invalid scale center.");let t=0,i=0;if(e.scaleCenter.x.endsWith("px"))t=parseFloat(e.scaleCenter.x);else{if(!e.scaleCenter.x.endsWith("%"))throw new Error("Invalid scale center.");t=parseFloat(e.scaleCenter.x)/100*o}if(e.scaleCenter.y.endsWith("px"))i=parseFloat(e.scaleCenter.y);else{if(!e.scaleCenter.y.endsWith("%"))throw new Error("Invalid scale center.");i=parseFloat(e.scaleCenter.y)/100*a}h.x=Math.round(t),h.y=Math.round(i)}if(0===o||0===a)return null;const l=this.getFrameSize(o,a,r,this.maxCvsSideLength);if(!l)return null;let c=!0;o===l.sWidth&&a===l.sHeight&&(c=!1);const u={data:null,region:r?JSON.parse(JSON.stringify(r)):null,sx:l.sx,sy:l.sy,width:l.dWidth,height:l.dHeight,colorMode:null,pixelFormat:null,timeSpent:null,timeStamp:null,isCropped:c,toCanvas:this._toCanvas,_sWidth:l.sWidth,_sHeight:l.sHeight,_bUseWebGL:null};1!==s&&(l.sWidth=Math.round(l.sWidth/s),l.sHeight=Math.round(l.sHeight/s),l.sx=Math.round((1-1/s)*h.x+l.sx/s),l.sy=Math.round((1-1/s)*h.y+l.sy/s));const d=this._getImageData(this._video,o,a,l,t,{pixelFormat:n});if(!d)return null;const f=Date.now();return ht._onLog&&ht._onLog("DCE: _getVideoData() END: "+f),u.data=d.data,u.pixelFormat=u.colorMode=d.pixelFormat,u._bUseWebGL=d._bUseWebGL,u.timeSpent=f-i,u.timeStamp=f,d.pixelFormat===ot.GREY?u.stride=u.width:u.stride=4*u.width,u}getCurrentRegion(){let t=null;if(this._scanRegion)t=this._scanRegion;else if(this.croppingRegions){if(this._croppingRegionIndex>=this.croppingRegions.length||this._croppingRegionIndex<0)throw new Error("The 'croppingRegionIndex' is out of bounds.");t=this.croppingRegions[this._croppingRegionIndex],this.bIncreaseRegionIndexAuto&&++this._croppingRegionIndex>=this.croppingRegions.length&&(this._croppingRegionIndex=0)}return t}_fetchingLoop(t){if(this.isDisposed&&this.disposed)return;if(!this._bOpen||!this.isFetchingLoopStarted())return void this.stopFetchingLoop();const e=()=>{ht._onLog&&ht._onLog("DCE: start fetching a frame into buffer: "+Date.now());const t=this.getCurrentRegion();let e=this._getVideoData(null,{region:t});if(!e)return void(ht._onLog&&ht._onLog("DCE: get a invalid frame, abandon it: "+Date.now()));for(;this._frameQueue&&this._frameQueue.length>=this.maxNumberOfFramesInBuffer;)this._frameQueue.shift();this._frameQueue.push(e),ht._onLog&&ht._onLog("DCE: finish fetching a frame into buffer: "+Date.now());const i=this.mapCameraEvents.get("frameaddedtobuffer");for(let t of i)t&&setTimeout((()=>{this.isDisposed&&this.disposed||t.apply(this)}),0)},i=()=>{this.isDisposed&&this.disposed||(this._frameLoopTimeoutId2&&clearTimeout(this._frameLoopTimeoutId2),this.refreshInterval<=0||(this._frameLoopTimeoutId2=setTimeout((()=>{this.isDisposed&&this.disposed||(this._bOpen&&this.isFetchingLoopStarted()?(ht._onLog&&ht._onLog("DCE: second timeout executes: "+Date.now()),e(),i()):this.stopFetchingLoop())}),this.refreshInterval)))};t&&(this._frameQueue.length<this.maxNumberOfFramesInBuffer?(e(),this.refreshInterval>0&&i()):0===this.refreshInterval&&e()),this._frameLoopTimeoutId&&clearTimeout(this._frameLoopTimeoutId),this._frameLoopTimeoutId=setTimeout((()=>{this.isDisposed&&this.disposed||this._fetchingLoop(!0)}),this.loopInterval)}startFetchingLoop(){if(this.isDisposed&&this.disposed)throw Error("The 'CameraEnhancer' instance has been disposed.");if(this._assertOpen(),this._isSingleFrameModeEnabled())throw Error("'startFetchingLoop()' is unavailable in singleFrameMode.");this.isFetchingLoopStarted()||(this._bFetchingLoopStarted=!0,this._recordedStates.fetchingLoopStart=!0,ht._onLog&&ht._onLog("DCE: start fetching loop: "+Date.now()),this._fetchingLoop(!0))}isFetchingLoopStarted(){return this._bFetchingLoopStarted}stopFetchingLoop(){this._bFetchingLoopStarted&&(ht._onLog&&ht._onLog("DCE: stop fetching loop: "+Date.now()),this._frameLoopTimeoutId&&clearTimeout(this._frameLoopTimeoutId),this._frameQueue.length=0,this._bFetchingLoopStarted=!1,this._recordedStates.fetchingLoopStart=!1)}getFrameFromBuffer(t){return this._frameQueue&&this._frameQueue.length?t?t<this._frameQueue.length?(this._frameLoopTimeoutId2&&clearTimeout(this._frameLoopTimeoutId2),this._frameQueue.splice(t,1)[0]):void 0:(this._frameLoopTimeoutId2&&clearTimeout(this._frameLoopTimeoutId2),this._frameQueue.pop()):null}clearFrameBuffer(){this._frameQueue&&(this._frameQueue.length=0)}_createDrawingLayerBaseCvs(){let t;this._assertOpen();try{t=this._calculateCvsSize()}catch(t){throw t}let{width:e,height:i,objectFit:r}=t;(e<=0||i<=0)&&(e=2,i=2);const n=document.createElement("canvas");if(n.width==e&&n.height==i||(n.width=e,n.height=i),n.style.objectFit=r,this._cvsScanRegion)this._cvsScanRegion.after(n);else if(this._cvsOriginalImage)this._cvsOriginalImage.after(n);else if(this._cvsSingleFrameMode)this._cvsSingleFrameMode.after(n);else{if(!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(n)}return n}_updateDrawingLayersSize(t){let e;try{e=t&&t.width&&t.height&&t.objectFit?{width:t.width,height:t.height,objectFit:t.objectFit}:this._calculateCvsSize()}catch(t){if("Invalid content dimensions."===(t.message||t))return;throw t}const{width:i,height:r,objectFit:n}=e;this._drawingLayersManager.setDimensions({width:i,height:r},{backstoreOnly:!0}),this._drawingLayersManager.setObjectFit(n)}_createDrawingLayer(t){this._layerBaseCvs||(this._layerBaseCvs=this._createDrawingLayerBaseCvs());const e=this._layerBaseCvs;return this._drawingLayersManager.createDrawingLayer(e,t)}deleteDrawingLayer(t){this._drawingLayersManager.deleteDrawingLayer(t),this._drawingLayersManager.getDrawingLayers().length||this._layerBaseCvs&&(this._layerBaseCvs.remove(),this._layerBaseCvs=null)}createDrawingLayer(){return this._createDrawingLayer()}getDrawingLayer(t){return this._drawingLayersManager.getDrawingLayer(t)||([1,2,3].includes(t)?this._createDrawingLayer(t):null)}getDrawingLayers(){return this._drawingLayersManager.getDrawingLayers().filter((t=>t.getId()>=0))}getSelectedDrawingItems(){return this._drawingLayersManager.getSelectedDrawingItems()}createDrawingStyle(t){return this._drawingLayersManager.createDrawingStyle(t)}getDrawingStyle(t){return this._drawingLayersManager.getDrawingStyle(t)}getDrawingStyles(){return this._drawingLayersManager.getDrawingStyles()}updateDrawingStyle(t,e){return this._drawingLayersManager.updateDrawingStyle(t,e)}clearDrawingLayers(){const t=this.getDrawingLayers();for(let e of t)this.deleteDrawingLayer(e.getId())}showTip(t,e,i,r){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];this._assertOpen(),this._tipArgs.x=t,this._tipArgs.y=e,this._tipArgs.width=i,this._tipArgs.autoShowSuggestedTip=!!s,this._drawingLayerOfTip||(this._drawingLayerOfTip=this._createDrawingLayer(-1)),this._tipStyleId||(this._tipStyleId=this.createDrawingStyle({fillStyle:"#FFFFFF",paintMode:"fill",fontFamily:"Open Sans",fontSize:40})),this._drawingLayerOfTip.clearDrawingItems();const o=new et(r||"",t,e,i,this._tipStyleId);o._fabricObject.paddingTop=15,o._fabricObject.calcTextHeight=function(){for(var t=0,e=0,i=this._textLines.length;e<i;e++)t+=this.getHeightOfLine(e);return t+2*this.paddingTop},o._fabricObject._getTopOffset=function(){return-this.height/2+this.getHeightOfLine(0)*(1-1/this.lineHeight)/2+this.paddingTop},o.setAttribute("backgroundColor","rgba(50, 50, 52, .8)"),o.setAttribute("lineHeight",1.3),o.setAttribute("textAlign","center"),this._drawingLayerOfTip.addDrawingItem(o),this._hideTipTimeoutId&&clearTimeout(this._hideTipTimeoutId),this._tipArgs.duration=void 0===n?3e3:n,this._tipArgs.duration>0&&(this._hideTipTimeoutId=setTimeout((()=>{this.isDisposed&&this.disposed||this._hideTip()}),this._tipArgs.duration))}_hideTip(){this._drawingLayerOfTip&&(this.deleteDrawingLayer(this._drawingLayerOfTip.getId()),this._drawingLayerOfTip=null,this._hideTipTimeoutId&&clearTimeout(this._hideTipTimeoutId))}hideTip(){this._hideTip(),this._tipArgs.x=null,this._tipArgs.y=null,this._tipArgs.width=null,this._tipArgs.autoShowSuggestedTip=null}updateTipMessage(t){if(!this._drawingLayerOfTip)throw new Error("The Tip is not showing.");this._drawingLayerOfTip.getDrawingItems()[0].setAttribute("text",t),this._drawingLayerOfTip.renderAll(),this._tipArgs.duration>0&&(this._hideTipTimeoutId&&clearTimeout(this._hideTipTimeoutId),this._hideTipTimeoutId=setTimeout((()=>{this.isDisposed&&this.disposed||this._hideTip()}),this._tipArgs.duration))}suggestTip(t,e){this._tipArgs.autoShowSuggestedTip&&(this._drawingLayerOfTip?this.updateTipMessage(e):void 0!==this._tipArgs.x&&this.showTip(this._tipArgs.x,this._tipArgs.y,this._tipArgs.width,e,this._tipArgs.duration)),this.onTipSuggested&&setTimeout((()=>{this.isDisposed&&this.disposed||this.onTipSuggested.apply(this,[t,e])}),0)}_createControler(){if(this._controler||(this._controler=new nt(this)),this._controler)return this._controler}_destroyControler(){this._controler=null}setOriginalImage(t,e,i){if(!t||!e||!i)throw new Error("Invalid arguments");this._originalImageData={imageData:t,width:e,height:i};let r=this._cvsOriginalImage;r||(r=document.createElement("canvas"),r.style.position="absolute",r.style.width="100%",r.style.height="100%",r.style.left="0",r.style.top="0",r.style.backgroundColor="white",r.style.objectFit="contain",this._cvsOriginalImage=r),r.width===e&&r.height===i||(r.width=e,r.height=i);const n=r.getContext("2d");n.clearRect(0,0,r.width,r.height),t instanceof Uint8Array||t instanceof Uint8ClampedArray?(t instanceof Uint8Array&&(t=new Uint8ClampedArray(t.buffer)),n.putImageData(new ImageData(t,e,i),0,0)):t instanceof HTMLCanvasElement&&n.drawImage(t,0,0),document.body.contains(r)&&""===r.style.display&&this._updateDrawingLayersSize({width:e,height:i,objectFit:"contain"})}getOriginalImage(){return this._originalImageData?Object.assign({},this._originalImageData):null}async deleteOriginalImage(){await this.hideOriginalImage(),this._cvsOriginalImage&&(this._cvsOriginalImage.remove(),this._cvsOriginalImage=null),this._originalImageData=null}_showOriginalImageCvs(){this._cvsOriginalImage&&"none"==this._cvsOriginalImage.style.display&&(this._cvsOriginalImage.style.display="")}_hideOriginalImageCvs(){this._cvsOriginalImage&&(this._cvsOriginalImage.style.display="none")}showOriginalImage(){if(!this._originalImageData)throw new Error("No original image is set.");const t=this._cvsOriginalImage;if(""===t.style.display&&document.body.contains(t))return;const{width:e,height:i}=this._originalImageData;if(this._updateDrawingLayersSize({width:e,height:i,objectFit:"contain"}),this._bOpen&&(this._video&&!this._video.paused&&this._video.pause(),this._bFetchingLoopStarted&&(this.stopFetchingLoop(),this._recordedStates.fetchingLoopStart=!0),this.ifShowScanRegionMask&&this._cvsScanRegion&&(this._cvsScanRegion.style.display="none"),this.ifShowScanRegionLaser&&this._divScanLight&&(this._divScanLight.style.display="none"),this._cvsViewDecorator&&(this._cvsViewDecorator.style.display="none"),this._scanRegionOverlayContainer&&(this._scanRegionOverlayContainer.style.display="none"),this._selCam&&(this._selCam.parentElement.style.display="none")),!document.body.contains(t))if(this._cvsSingleFrameMode)this._cvsSingleFrameMode.after(t);else{if(!this._videoContainer)throw new Error("Unable to find video element");this._videoContainer.after(t)}this._showOriginalImageCvs()}async _hideOriginalImage(t){this._originalImageData&&this._cvsOriginalImage&&"none"!==this._cvsOriginalImage.style.display&&(this._updateDrawingLayersSize(),this._bOpen&&t&&(this._video&&this._recordedStates.videoPlaying&&await this.play(null,null,null,{notTriggerSingleFrameClick:!0}),this._recordedStates.fetchingLoopStart&&!this._isSingleFrameModeEnabled()&&this.startFetchingLoop(),this.ifShowScanRegionMask&&this._cvsScanRegion&&this._recordedStates.maskShow&&this.showScanRegionMask(),this.ifShowScanRegionLaser&&this._divScanLight&&this._recordedStates.laserShow&&this.showScanRegionLaser(),this._cvsViewDecorator&&this._recordedStates.decoratorShow&&this.showViewDecorator(),this._scanRegionOverlayContainer&&this._recordedStates.overlayShow&&this.showScanRegionOverlays()),this._selCam&&(this._selCam.parentElement.style.display=""),this._hideOriginalImageCvs())}async hideOriginalImage(){return this._hideOriginalImage(!0)}transformCoord(t){if(!this.isOpen())throw new Error("Unavailable when the camera is not open.");if(this._isSingleFrameModeEnabled()&&!this._cvsSingleFrameMode)throw new Error("No image is selected. ");const e=this._elContainer.getBoundingClientRect();let i,r,n,s,o,a=e.left,h=e.top,l=a+window.scrollX,c=h+window.scrollY;this._isSingleFrameModeEnabled()?(i=this._cvsSingleFrameMode.width,r=this._cvsSingleFrameMode.height,n=parseFloat(window.getComputedStyle(this._cvsSingleFrameMode).width),s=parseFloat(window.getComputedStyle(this._cvsSingleFrameMode).height),o="contain"):(i=this.video.videoWidth,r=this.video.videoHeight,n=parseFloat(window.getComputedStyle(this._elContainer).width),s=parseFloat(window.getComputedStyle(this._elContainer).height),o=this.videoFit);const u=n/s,d=i/r;let f,g,_,p,m=1;if("contain"===o)u<d?(m=n/i,f=a+t.x*m,g=h+t.y*m+(s-r*m)/2,_=l+t.x*m,p=c+t.y*m+(s-r*m)/2):(m=s/r,f=a+t.x*m+(n-i*m)/2,g=h+t.y*m,_=l+t.x*m+(n-i*m)/2,p=c+t.y*m);else if("cover"===o)if(u<d){m=s/r;let e=t.x*m-(i*m-n)/2;e=Math.max(e,0),e=Math.min(e,n),f=a+e,g=h+t.y*m,_=l+e,p=c+t.y*m}else{m=n/i;let e=t.y*m-(r*m-s)/2;e=Math.max(e,0),e=Math.min(e,s),f=a+t.x*m,g=h+e,_=l+t.x*m,p=c+e}return{clientX:f,clientY:g,pageX:_,pageY:p}}convertToPageCoordinates(t){const e=this.transformCoord(t);return{x:e.pageX,y:e.pageY}}convertToClientCoordinates(t){const e=this.transformCoord(t);return{x:e.clientX,y:e.clientY}}dispose(t){this.UIElement&&(this._uiOriginalState&&this._uiOriginalState.inDom?this.UIElement.style.display=this._uiOriginalState.display:this.UIElement.style.display="none"),this.clearDrawingLayers(),this.close(),this.forceLoseContext(),this.setViewDecorator(null,null),this._scanRegionOverlayContainer&&this._scanRegionOverlayContainer.remove(),this._arrScanRegionOverlays.length=0,t&&this.UIElement&&this.UIElement.remove(),this.__proto__=null;for(let t in this)delete this[t];Object.defineProperty(this,"isCameraEnhancer",{value:!0}),Object.defineProperty(this,"isDisposed",{value:!0}),Object.defineProperty(this,"disposed",{value:!0})}}ht._jsVersion="3.3.10",ht._jsEditVersion="20240130",ht._version="JS "+ht._jsVersion+"."+ht._jsEditVersion,ht.browserInfo=G,ht._hasEngineResourceLoaded=!1,ht._engineResourcePath=z,ht._defaultUIElementURL="@engineResourcePath/dce.ui.html";const lt={DT_Arc:class extends Z{constructor(t,e,i,r,n,s){super(new k.Circle({left:t,top:e,radius:i,startAngle:r,endAngle:n}),s),this._mediaType="arc"}},DT_Polygon:$,DT_Rect:class extends Z{constructor(t,e,i,r,n){super(new k.Rect({left:t,top:e,width:i,height:r}),n)}},DT_Image:class extends Z{constructor(t,e,i,r){super(new k.Image(t,{left:e,top:i}),r),this.image=t}_extendSet(t,e){if("image"===t){if(e instanceof HTMLImageElement)return this._fabricObject.setElement(e),this.image=e,!0;if(e instanceof HTMLCanvasElement){const t=new Image;return t.src=e.toDataURL(),this._fabricObject.setElement(t),this.image=e,!0}throw new Error("Unsupported value.")}}_extendGet(t){if("image"===t)return this.image}},DT_Text:et,DT_Line:class extends ${constructor(t,e,i){super([t,e],i),this._mediaType="line"}_extendSet(t,e){if("startPoint"===t||"endPoint"===t){e="startPoint"===t?[e,this.get("endPoint")]:[this.get("startPoint"),e];const i=this._fabricObject;if(i.group){const t=i.group;i.points=e.map((e=>({x:e.x-t.left-t.width/2,y:e.y-t.top-t.height/2}))),t.addWithUpdate()}else i.points=e;const r=i.points.length-1;return i.controls=i.points.reduce((function(t,e,i){return t["p"+i]=new k.Control({positionHandler:J,actionHandler:Q(i>0?i-1:r,q),actionName:"modifyPolygon",pointIndex:i}),t}),{}),i._setPositionDimensions({}),!0}}_extendGet(t){if("startPoint"===t||"endPoint"===t){const e=[],i=this._fabricObject;if(i.selectable&&!i.group)for(let t in i.oCoords)e.push({x:i.oCoords[t].x,y:i.oCoords[t].y});else for(let t of i.points){let r=t.x-i.pathOffset.x,n=t.y-i.pathOffset.y;const s=k.util.transformPoint({x:r,y:n},i.calcTransformMatrix());e.push({x:s.x,y:s.y})}return"startPoint"===t?e[0]:e[1]}}},DT_Group:class extends Z{constructor(t){super(new k.Group(t.map((t=>t._getFabricObject())))),this._fabricObject.on("selected",(()=>{this.styleSelector="selected";const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("selected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)})),this._fabricObject.on("deselected",(()=>{this.styleSelector="default";const t=this._fabricObject._objects;for(let e of t)setTimeout((()=>{e&&e.fire("deselected")}),0);setTimeout((()=>{this._fabricObject&&this._fabricObject.canvas&&(this._fabricObject.dirty=!0,this._fabricObject.canvas.renderAll())}),0)}))}getChildItems(){return this._fabricObject._objects.map((t=>t.getDrawingItem()))}addChildItem(t){if(!t||!t.isDrawingItem)throw TypeError("Illegal drawing item.");this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"add"):this._fabricObject.addWithUpdate(t._getFabricObject())}removeChildItem(t){t&&t.isDrawingItem&&(this._drawingLayer?this._drawingLayer._updateGroupItem(this,t,"remove"):this._fabricObject.removeWithUpdate(t._getFabricObject()))}}};function ct(t,e,i){return(i.x-t.x)*(e.y-t.y)==(e.x-t.x)*(i.y-t.y)&&Math.min(t.x,e.x)<=i.x&&i.x<=Math.max(t.x,e.x)&&Math.min(t.y,e.y)<=i.y&&i.y<=Math.max(t.y,e.y)}function ut(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function dt(t,e,i,r){let n=t[0]*(i[1]-e[1])+e[0]*(t[1]-i[1])+i[0]*(e[1]-t[1]),s=t[0]*(r[1]-e[1])+e[0]*(t[1]-r[1])+r[0]*(e[1]-t[1]);return!((n^s)>=0&&0!==n&&0!==s||(n=i[0]*(t[1]-r[1])+r[0]*(i[1]-t[1])+t[0]*(r[1]-i[1]),s=i[0]*(e[1]-r[1])+r[0]*(i[1]-e[1])+e[0]*(r[1]-i[1]),(n^s)>=0&&0!==n&&0!==s))}var ft,gt,_t,pt,mt,vt,yt,St,Ct,wt,bt,xt,Tt,Et,It,Ot,Rt,Dt,At,Mt,Lt,Ft,Pt,kt,Bt,Nt,jt;class Ut extends A{static set _onLog(t){!function(t,e,i,r,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");n?n.value=i:e.set(t,i)}(Ut,ft,t,0,gt),ht._onLog=t}static get _onLog(){return function(t,e,i,r){if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r?r.value:e.get(t)}(Ut,ft,0,gt)}static get version(){return this._version+`(DCE ${ht.getVersion()})`}static _fireHTTPSWarnning(){Ut.onWarning&&location&&"https:"!==location.protocol&&setTimeout((()=>{Ut.onWarning&&Ut.onWarning({id:2,message:"Not connected via SSL (HTTPS), the SDK may not work correctly."})}),0)}static async testCameraAccess(){return ht.testCameraAccess()}_fireResolutionWarning(){if(!this.singleFrameMode&&this.onWarning&&this.dce.isOpen()){const t=this.dce.getConstraints();t&&t.width<1280&&t.height<720&&setTimeout((()=>{this.onWarning&&this.onWarning({id:3,message:"Camera resolution too low, please use a higher resolution (720P or better)."})}),0)}}getUIElement(){return this.dce.getUIElement()}async setUIElement(t){await this.dce.setUIElement(t)}get singleFrameMode(){return this.dce.singleFrameMode}set singleFrameMode(t){if("boolean"!=typeof t&&!["image","camera"].includes(t))throw new Error("Invalid value.");this.dce.singleFrameMode=t,t&&(this.dce.ifShowScanRegionLaser=!1,(async()=>
vendor: 20,534 bytes, line 2
2{let t=await this.getScanSettings();t.oneDTrustFrameCount=1,await this.updateScanSettings(t)})())}get onUnduplicatedRead(){return this.onUniqueRead}set onUnduplicatedRead(t){this.onUniqueRead=t}get video(){return this.dce&&this.dce.video}set videoSrc(t){this.dce&&(this.dce.videoSrc=t)}get videoSrc(){return this.dce&&this.dce.videoSrc}set cameraOpenTimeout(t){this.dce&&(this.dce.cameraOpenTimeout=t)}get cameraOpenTimeout(){return this.dce&&this.dce.cameraOpenTimeout}set onTipSuggested(t){this.dce&&(this.dce.onTipSuggested=t)}get onTipSuggested(){return this.dce&&this.dce.onTipSuggested}_assertOpen(){if(!this.dce.isOpen())throw Error("The scanner is not open.")}set barcodeFillStyle(t){this._barcodeFillStyle=t,this.dce&&this.dce.updateDrawingStyle(3,{fillStyle:t})}get barcodeFillStyle(){return this._barcodeFillStyle}set barcodeStrokeStyle(t){this._barcodeStrokeStyle=t,this.dce&&this.dce.updateDrawingStyle(3,{strokeStyle:t})}get barcodeStrokeStyle(){return this._barcodeStrokeStyle}set barcodeLineWidth(t){this._barcodeLineWidth=t,this.dce&&this.dce.updateDrawingStyle(3,{lineWidth:t})}get barcodeLineWidth(){return this._barcodeLineWidth}set barcodeFillStyleBeforeVerification(t){this._barcodeFillStyleBeforeVerification=t,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{fillStyle:t})}get barcodeFillStyleBeforeVerification(){return this._barcodeFillStyleBeforeVerification}set barcodeStrokeStyleBeforeVerification(t){this._barcodeStrokeStyleBeforeVerification=t,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{strokeStyle:t})}get barcodeStrokeStyleBeforeVerification(){return this._barcodeStrokeStyleBeforeVerification}set barcodeLineWidthBeforeVerification(t){this._barcodeLineWidthBeforeVerification=t,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{lineWidth:t})}get barcodeLineWidthBeforeVerification(){return this._barcodeLineWidthBeforeVerification}set regionMaskFillStyle(t){this.dce.setScanRegionMaskStyle({fillStyle:t})}get regionMaskFillStyle(){return this.dce.regionMaskFillStyle}set regionMaskStrokeStyle(t){this.dce.setScanRegionMaskStyle({strokeStyle:t})}get regionMaskStrokeStyle(){return this.dce.regionMaskStrokeStyle}set regionMaskLineWidth(t){this.dce.setScanRegionMaskStyle({lineWidth:t})}get regionMaskLineWidth(){return this.dce.regionMaskLineWidth}set region(t){this._region=t,this.dce&&(t?t instanceof Array||this.dce.setScanRegion(t):this.dce.setScanRegion(null)),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}get region(){return this._region}set ifSaveOriginalImageInACanvas(t){this._ifSaveOriginalImageInACanvas=t,this.dce.framePixelFormat=t?"rgba":"grey"}get ifSaveOriginalImageInACanvas(){return this._ifSaveOriginalImageInACanvas}async createDCEInstance(){this.dce||(A._onLog&&A._onLog("createDCEInstance()"),ht.defaultUIElementURL=null,this.dce=await ht.createInstance(),this.dce.cameraOpenTimeout<15e3&&(this.dce.cameraOpenTimeout=15e3),this.dce.refreshInterval=200,this.dce.framePixelFormat="grey",this.dce.maxCvsSideLength=this.maxCvsSideLength,this._drawingItemNamespace=lt,["iPhone","iPad","Android","HarmonyOS"].includes(A.browserInfo.OS)||this.dce.setResolution(1920,1080),this._styleIdBeforeVerification=this.dce.createDrawingStyle({fillStyle:"rgba(248,252,0,0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill"}),this.barcodeLineWidth=this._barcodeLineWidth,this.dce.on("cameraChange",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0})),this.dce.on("resolutionChange",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0})),this.dce.on("cameraClose",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._bPauseScan=!1})),this.dce.on("singleFrameAcquired",(async t=>{if(!t)return;if(!t.data)return;let e;this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:t.width,height:t.height,pixelFormat:t.pixelFormat,data:new Uint8Array(t.data),toCanvas:t.toCanvas});const{data:i,sx:r,sy:n,width:s,height:o,stride:a,pixelFormat:h,timeStamp:l,_sWidth:c,_sHeight:u}=t,d={timeStamp:l};if("grey"===h)e=await this._decodeBuffer_Uint8Array(i,s,o,a,w.IPF_GrayScaled,0,d);else if("rgba"===h)e=await this._decodeBuffer_Uint8Array(i,s,o,a,w.IPF_ABGR_8888,0,d);else{if("bgra"!==h)throw new Error(`Pixel format '${h}' is not supported.`);e=await this._decodeBuffer_Uint8Array(i,s,o,a,w.IPF_ARGB_8888,0,d)}if(await this.clearMapDecodeRecord(),A.recalculateResultLocation(e,r,n,c,u,s,o),this._drawResults(e),this.onFrameRead&&this.isOpen()&&!this._bPauseScan){let t=this._cloneDecodeResults(e);this.onFrameRead(t)}if(this.onUniqueRead&&this.isOpen()&&!this._bPauseScan)for(let t of e)this.onUniqueRead(t.barcodeText,this._cloneDecodeResults(t))})))}set maxCvsSideLength(t){this._maxCvsSideLength=t,this.dce.maxCvsSideLength=t}get maxCvsSideLength(){return this._maxCvsSideLength}constructor(){super(),this._barcodeFillStyle="rgba(254,180,32,0.3)",this._barcodeStrokeStyle="rgba(254,180,32,0.9)",this._barcodeLineWidth=1,this._barcodeFillStyleBeforeVerification="rgba(248,252,0,0.2)",this._barcodeStrokeStyleBeforeVerification="transparent",this._barcodeLineWidthBeforeVerification=2,this.bFilterRegionInJs=!0,this._onPlayed=null}static async createInstance(t){const e=new Ut;e._instanceID=await Ut.createInstanceInWorker(!0),await e.createDCEInstance(),"string"==typeof t&&(t=JSON.parse(t));for(let i in t)e[i]=t[i];return await e.dce.setUIElement(Ut.defaultUIElementURL),e.singleFrameMode&&n.warn("The `navigator.mediaDevices.getUserMedia` is unavailable. automatically change to `singleFrameMode`."),Ut._fireHTTPSWarnning(),e.singleFrameMode||await e.updateRuntimeSettings("single"),e}async decodeCurrentFrame(t){this._assertOpen();let e=null;t&&t.region&&(e=t.region);const i=this.dce._getVideoData(null,{region:e});return this._decode_DCEFrame(i)}async updateRuntimeSettings(t){let e;if("string"==typeof t)if("speed"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region),e.expectedBarcodesCount=0,e.localizationModes=[2,0,0,0,0,0,0,0],e.barcodeZoneMinDistanceToImageBorders=9}else if("balance"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region),e.expectedBarcodesCount=512,e.deblurLevel=3,e.localizationModes=[2,16,0,0,0,0,0,0],e.barcodeZoneMinDistanceToImageBorders=9,e.timeout=1e5}else if("coverage"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region),e.expectedBarcodesCount=512,e.deblurLevel=5,e.scaleDownThreshold=1e5,e.localizationModes=[2,16,4,8,0,0,0,0],e.barcodeZoneMinDistanceToImageBorders=9,e.timeout=1e5}else if("single"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region)}else if("dense"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region),e.expectedBarcodesCount=0,e.deblurLevel=7,e.scaleDownThreshold=1e5,e.localizationModes=[2,8,0,0,0,0,0,0],e.minResultConfidence=0,e.barcodeZoneMinDistanceToImageBorders=9,e.timeout=1e5}else if("distance"==t){let t=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,e=await this.getRuntimeSettings(),e.barcodeFormatIds=t.barcodeFormatIds,e.barcodeFormatIds_2=t.barcodeFormatIds_2,t.region&&(e.region=t.region),e.expectedBarcodesCount=0,e.scaleDownThreshold=1e5,e.localizationModes=[2,8,0,0,0,0,0,0],e.barcodeZoneMinDistanceToImageBorders=9,e.timeout=1e5}else e=JSON.parse(t);else{if("object"!=typeof t)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");if(e=JSON.parse(JSON.stringify(t)),e.region instanceof Array){let i=t.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some((t=>void 0!==t))&&(e.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!A._bUseFullFeature){if(e.barcodeFormatIds&~(T.BF_ONED|T.BF_QR_CODE|T.BF_PDF417|T.BF_DATAMATRIX)||0!=e.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=e.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}{let t=e.region;if(this.bFilterRegionInJs?this.userDefinedRegion=JSON.parse(JSON.stringify(t)):this.userDefinedRegion=null,t instanceof Array)if(t.length){for(let e=0;e<t.length;++e){let i=t[e];i&&((i.regionLeft||i.regionTop||i.regionRight||i.regionBottom||i.regionMeasuredByPercentage)&&(i.regionLeft||i.regionTop||100!=i.regionRight||100!=i.regionBottom||!i.regionMeasuredByPercentage)||(t[e]=null))}this.region=t}else this.region=null;else t&&(t.regionLeft||t.regionTop||t.regionRight||t.regionBottom||t.regionMeasuredByPercentage)&&(t.regionLeft||t.regionTop||100!=t.regionRight||100!=t.regionBottom||!t.regionMeasuredByPercentage)?this.region=t:this.region=null;this.bFilterRegionInJs&&(e.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0})}(this.autoZoom||this.autoFocus)&&(e.intermediateResultTypes|=E.IRT_TYPED_BARCODE_ZONE),await new Promise(((t,i)=>{let r=A._nextTaskID++;A._taskCallbackMap.set(r,(e=>{if(e.success){try{this._handleRetJsonString(e.updateReturn)}catch(t){i(t)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}})),A._dbrWorker.postMessage({type:"updateRuntimeSettings",id:r,instanceID:this._instanceID,body:{settings:JSON.stringify(e)}})})),"string"==typeof t&&["speed","balance","coverage","dense","distance"].includes(t)&&(await this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","1"),await this.setModeArgument("BinarizationModes",0,"BlockSizeX","0"),await this.setModeArgument("BinarizationModes",0,"BlockSizeY","0"))}_bindUI(){if(!this.getUIElement())throw new Error("Need to define `UIElement` before opening.");if(this.dce._bindUI(),!this.dce.video)throw this._unbindUI(),Error("Can not find the video container element with class 'dce-video-container'")}_unbindUI(){this.dce._unbindUI()}set onPlayed(t){this.dce.off("played",this._onPlayed),this._onPlayed=t,this.dce.on("played",this._onPlayed)}get onPlayed(){return this._onPlayed}async getAllCameras(){return this.dce.getAllCameras()}async getCurrentCamera(){return this.dce.getSelectedCamera()}async setCurrentCamera(t){const e=await this.dce.selectCamera(t);return this._fireResolutionWarning(),e}getResolution(){return this.dce.getResolution()}async setResolution(t,e){const i=await this.dce.setResolution(t,e);return this._fireResolutionWarning(),i}getVideoSettings(){return this.dce.getVideoSettings()}updateVideoSettings(t){return this.dce.updateVideoSettings(t)}isOpen(){return this.dce&&this.dce.isOpen()}setVideoFit(t){return this.dce&&this.dce.setVideoFit(t)}getVideoFit(){return this.dce&&this.dce.getVideoFit()}set ifShowScanRegionMask(t){this.dce&&(this.dce.ifShowScanRegionMask=t)}get ifShowScanRegionMask(){return this.dce&&this.dce.ifShowScanRegionMask}set ifSaveLastUsedCamera(t){this.dce&&(this.dce.ifSaveLastUsedCamera=t)}get ifSaveLastUsedCamera(){return this.dce&&this.dce.ifSaveLastUsedCamera}set ifSkipCameraInspection(t){this.dce&&(this.dce.ifSkipCameraInspection=t)}get ifSkipCameraInspection(){return this.dce&&this.dce.ifSkipCameraInspection}stop(){this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.dce.stop(),this.dce.ifShowScanRegionLaser=!1,this.dce.hideViewDecorator(),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}pause(){this.dce.pause()}async play(t,e,i){this.dce.ifShowScanRegionLaser=!0;const r=await this.dce.play(t,e,i);return this._fireResolutionWarning(),r}pauseScan(t){this._assertOpen(),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),t&&t.keepResultsHighlighted||this._drawResults(null),this._bPauseScan=!0,this.dce.ifShowScanRegionLaser=!1,this.dce.stopFetchingLoop()}resumeScan(){this._assertOpen(),this._bPauseScan=!1,this.dce.ifShowScanRegionLaser=!0}getCapabilities(){return this.dce.getCapabilities()}getCameraSettings(){return this.dce.getCameraSettings()}getConstraints(){return this.dce.getConstraints()}async applyConstraints(t){return this.dce.applyConstraints(t)}async turnOnTorch(){return this.dce.turnOnTorch()}async turnOffTorch(){return this.dce.turnOffTorch()}async setColorTemperature(t){return this.dce.setColorTemperature(t)}getColorTemperature(){return this.dce.getColorTemperature()}async setExposureCompensation(t){return this.dce.setExposureCompensation(t)}getExposureCompensation(){return this.dce.getExposureCompensation()}async setZoom(t){return this.dce.setZoom(t)}getZoomSettings(){return this.dce.getZoomSettings()}resetZoom(){return this.dce.resetZoom()}async setFrameRate(t){return this.dce.setFrameRate(t)}getFrameRate(){return this.dce.getFrameRate()}async setFocus(t,e){return this.dce.setFocus(t,e)}getFocus(){return this.dce.getFocus()}getFocusSettings(){return this.dce.getFocusSettings()}async _loopReadVideo(){if(this.bDestroyed)return this.dce&&this.dce.stopFetchingLoop(),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),void this._drawResults(null);if(!this.isOpen())return this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),void await this.clearMapDecodeRecord();if(!this.dce.video||this.dce.video.paused||this._bPauseScan)return A._onLog&&A._onLog("Video or scan is paused. Ask in 1s."),await this.clearMapDecodeRecord(),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this._intervalDetectVideoPause));A._onLog&&A._onLog("======= once read ======="),A._onLog&&(this._timeStartDecode=Date.now());const t=this._getVideoFrame();if(!t)return A._onLog&&A._onLog("Get invalid frame."),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0));(async()=>{t._bUseWebGL||"grey"!==t.pixelFormat||(this.dce.framePixelFormat="rgba");let e=[];this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:t.width,height:t.height,pixelFormat:t.pixelFormat,data:new Uint8Array(t.data),toCanvas:t.toCanvas});const{data:i,sx:r,sy:s,width:o,height:a,stride:h,pixelFormat:l,timeStamp:c,_sWidth:u,_sHeight:d}=t,f={timeStamp:c};if("grey"===l)e=await this._decodeBuffer_Uint8Array(i,o,a,h,w.IPF_GrayScaled,0,f);else if("rgba"===l)e=await this._decodeBuffer_Uint8Array(i,o,a,h,w.IPF_ABGR_8888,0,f);else{if("bgra"!==l)throw new Error(`Pixel format '${l}' is not supported.`);e=await this._decodeBuffer_Uint8Array(i,o,a,h,w.IPF_ARGB_8888,0,f)}if(A.recalculateResultLocation(e,r,s,u,d,o,a),0==this._resultHighlightingDuration?this._drawResults(null):this._drawResults(e),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._resultHighlightingDuration>0&&(this._clearResultsCanvasTimeoutId=setTimeout((()=>{this.bDestroyed||this._drawResults(null)}),this._resultHighlightingDuration)),this.isOpen()&&this.dce.video&&!this.dce.video.paused&&!this._bPauseScan&&(this.autoZoom||this.autoFocus||this.autoSuggestTip))if(e.length)this.autoZoomInFrameArray.length=0,this.autoZoomOutFrameCount=0,this.frameArrayInIdealZoom.length=0,this.suggestTipFrameArray.length=0,this.autoZoom&&this.autoFocus&&(this.nextActionInIdealZoom="focus"),this.autoFocusFrameArray.length=0,this.noIntermediateResultsCount=0;else{const t=async()=>new Promise(((t,e)=>{let i=A._nextTaskID++;A._taskCallbackMap.set(i,(i=>{if(i.success)return t(i.results);{let t=new Error(i.message);return t.stack=i.stack+"\n"+t.stack,e(t)}})),A._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID,body:{isCharge:!1}})})),e=await t(),i=(t,e,i,r,n,s,o)=>{let a=s/r,h=o/n;t.x1=t.x1/a+e,t.x2=t.x2/a+e,t.x3=t.x3/a+e,t.x4=t.x4/a+e,t.y1=t.y1/h+i,t.y2=t.y2/h+i,t.y3=t.y3/h+i,t.y4=t.y4/h+i},h=t=>{if(!t)return null;const e={};let n,h,l,c,f;{const t=this.video.videoWidth*(1-this.autoZoomDetectionArea)/2,e=this.video.videoWidth*(1+this.autoZoomDetectionArea)/2,i=e,r=t,n=this.video.videoHeight*(1-this.autoZoomDetectionArea)/2,s=n,o=this.video.videoHeight*(1+this.autoZoomDetectionArea)/2;f={x1:t,x2:e,x3:i,x4:r,y1:n,y2:s,y3:o,y4:o}}const g=(t,e)=>{const i=(t,e)=>{if(!t&&!e)throw new Error("Invalid arguments.");return function(t,e,i){let r=!1;const n=t.length;if(n<=2)return!1;for(let s=0;s<n;s++){const o=t[s],a=t[(s+1)%n];if(ct(o,a,{x:e,y:i}))return!0;ut(o.y-i)>0!=ut(a.y-i)>0&&ut(e-(i-o.y)*(o.x-a.x)/(o.y-a.y)-o.x)<0&&(r=!r)}return r}([{x:e.x1,y:e.y1},{x:e.x2,y:e.y2},{x:e.x3,y:e.y3},{x:e.x4,y:e.y4}],t.x,t.y)},r=(t,e)=>!!(dt([t[0],t[1]],[t[2],t[3]],[e.x1,e.y1],[e.x2,e.y2])||dt([t[0],t[1]],[t[2],t[3]],[e.x2,e.y2],[e.x3,e.y3])||dt([t[0],t[1]],[t[2],t[3]],[e.x3,e.y3],[e.x4,e.y4])||dt([t[0],t[1]],[t[2],t[3]],[e.x4,e.y4],[e.x1,e.y1]));return!!(i({x:t.x1,y:t.y1},e)||i({x:t.x2,y:t.y2},e)||i({x:t.x3,y:t.y3},e)||i({x:t.x4,y:t.y4},e))||!!(i({x:e.x1,y:e.y1},t)||i({x:e.x2,y:e.y2},t)||i({x:e.x3,y:e.y3},t)||i({x:e.x4,y:e.y4},t))||!!(r([e.x1,e.y1,e.x2,e.y2],t)||r([e.x2,e.y2,e.x3,e.y3],t)||r([e.x3,e.y3,e.x4,e.y4],t)||r([e.x4,e.y4,e.x1,e.y1],t))},_=[];for(let e of t){if(e.resultType!==E.IRT_TYPED_BARCODE_ZONE)continue;const t=e.scaleDownRatio;for(let n of e.results){if(!n)continue;const e={x1:n.x1=n.x1*t,x2:n.x2=n.x2*t,x3:n.x3=n.x3*t,x4:n.x4=n.x4*t,y1:n.y1=n.y1*t,y2:n.y2=n.y2*t,y3:n.y4=n.y3*t,y4:n.y4=n.y4*t};i(e,r,s,u,d,o,a),g(f,e)&&_.push(n)}}const p=(t=>{if(!t||!t.length)return null;const e=t=>{const e=(t.x1+t.x2+t.x3+t.x4)/4,i=(t.y1+t.y2+t.y3+t.y4)/4;return(e-o/2)*(e-o/2)+(i-a/2)*(i-a/2)};let i,r=t.filter((t=>t.barcodeFormat==T.BF_QR_CODE||t.barcodeFormat==T.BF_DATAMATRIX));if(r.length||(r=t.filter((t=>t.barcodeFormat==T.BF_ONED)),r.length||(r=t)),!r.length)return null;i=r[0];let n=e(i);if(1!=r.length)for(let t=1;t<r.length;t++){const s=e(r[t]);(r[t].confidence>1.1*i.confidence||r[t].confidence>.9*i.confidence&&s<n)&&(i=r[t],n=s)}return i})(_);if(!p)return null;const m=p.x1,v=p.x2,y=p.x3,S=p.x4,C=p.y1,w=p.y2,b=p.y3,x=p.y4;return n=Math.min(m,v,y,S),h=Math.max(m,v,y,S),l=Math.min(C,w,b,x),c=Math.max(C,w,b,x),e.x1=e.x4=n,e.x2=e.x3=h,e.y1=e.y2=l,e.y3=e.y4=c,e.result=p,e},l=h(e);if(l&&l.x1){if(this.autoZoomOutFrameCount=0,this.noIntermediateResultsCount=0,this.suggestTipFrameArray.push(!0),this.suggestTipFrameArray.splice(0,this.suggestTipFrameArray.length-this.suggestTipFrameLimit[0]),this.autoSuggestTip&&this.suggestTipFrameArray.filter((t=>!0===t)).length>=this.suggestTipFrameLimit[1]){this.suggestTipFrameArray.length=0;const t=l.x3-l.x1,e=l.y3-l.y1;l.result.moduleSize<this.tinyBarcodeTipModuleSizeLimit?this.dce&&this.dce.suggestTip("tiny-barcode","Please zoom in or move closer."):t>e?t>o*this.hugeBarcodeTipLimit?this.dce&&this.dce.suggestTip("huge-barco
2de","Please zoom out or move farther."):t>.6*o&&Math.max(this.video.videoWidth,this.video.videoHeight)<=1280&&Math.min(this.video.videoWidth,this.video.videoHeight)<=720&&this.dce&&this.dce.suggestTip("low-resolution","Please use a higher resolution."):t<=e&&(e>a*this.hugeBarcodeTipLimit?this.dce&&this.dce.suggestTip("huge-barcode","Please zoom out or move farther."):e>.6*a&&Math.max(this.video.videoWidth,this.video.videoHeight)<=1280&&Math.min(this.video.videoWidth,this.video.videoHeight)<=720&&this.dce&&this.dce.suggestTip("low-resolution","Please use a higher resolution."))}if(this.autoZoom){const t=this.autoZoomIdealArea[1];let e=(1-this.autoZoomTargetBorder)/2;const h=l.x1/u,c=(u-l.x3)/u,f=l.y1/d,g=(d-l.y3)/d;if(h>t&&c>t&&f>t&&g>t&&l.result.moduleSize<this.autoZoomInIdealModuleSize){if(this.autoZoomInFrameArray.push(!0),this.autoZoomInFrameArray.splice(0,this.autoZoomInFrameArray.length-this.autoZoomInFrameLimit[0]),this.frameArrayInIdealZoom.length=0,this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{}))),this.autoZoomInFrameArray.filter((t=>!0===t)).length>=this.autoZoomInFrameLimit[1]){this.autoZoomInFrameArray.length=0;const t=[(.5-e)/(.5-h),(.5-e)/(.5-c),(.5-e)/(.5-f),(.5-e)/(.5-g)].filter((t=>t>0)),i=Math.min(...t,this.autoZoomInIdealModuleSize/l.result.moduleSize),r=this.dce.getZoomSettings().factor;let s=Math.max(Math.pow(r*i,1/this.autoZoomInMaxTimes),this.autoZoomInMinStep);s=Math.min(s,i);const o=r*s;try{await this.setZoom({factor:o})}catch(t){const e=t.message||t;n.warn(e)}this.dce.clearFrameBuffer()}}else if(this.autoZoomInFrameArray.length=0,this.frameArrayInIdealZoom.push(!0),this.frameArrayInIdealZoom.splice(0,this.frameArrayInIdealZoom.length-this.frameLimitInIdealZoom[0]),this.frameArrayInIdealZoom.filter((t=>!0===t)).length>=this.frameLimitInIdealZoom[1])if(this.frameArrayInIdealZoom.length=0,"focus"===this.nextActionInIdealZoom&&this.autoFocus){i(l,r,s,u,d,o,a);try{await this.setFocus({mode:"manual",area:{centerPoint:{x:(l.x1+l.x3)/2+"px",y:(l.y1+l.y3)/2+"px"},width:l.x3-l.x1+"px",height:l.y3-l.y1+"px"}})}catch(t){const e=t.message||t;n.warn(e)}this.dce.clearFrameBuffer(),this.nextActionInIdealZoom="zoomOut"}else{if("zoomOut"!==this.nextActionInIdealZoom&&this.autoFocus)throw new Error("Invalid action.");if(this.enableZoomOutInIdealZoom){e=this.autoZoomIdealArea[1]+this.autoZoomOutStepRate_2;const t=[(.5-e)/(.5-h),(.5-e)/(.5-c),(.5-e)/(.5-f),(.5-e)/(.5-g)].filter((t=>t>0));let i=Math.min(...t)*this.dce.getZoomSettings().factor;try{await this.setZoom({factor:i})}catch(t){const e=t.message||t;n.warn(e)}this.dce.clearFrameBuffer(),this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{})))}}}else if(this.autoFocus&&(this.autoFocusFrameArray.push(!0),this.autoFocusFrameArray.splice(0,this.autoFocusFrameArray.length-this.autoFocusFrameLimit[0]),this.autoFocusFrameArray.filter((t=>!0===t)).length>=this.autoFocusFrameLimit[1])){this.autoFocusFrameArray.length=0;try{i(l,r,s,u,d,o,a),await this.setFocus({mode:"manual",area:{centerPoint:{x:(l.x1+l.x3)/2+"px",y:(l.y1+l.y3)/2+"px"},width:l.x3-l.x1+"px",height:l.y3-l.y1+"px"}})}catch(t){const e=t.message||t;n.warn(e)}this.dce.clearFrameBuffer()}}else if(this.noIntermediateResultsCount++,this.suggestTipFrameArray.push(!1),this.autoZoom){if(this.autoZoomInFrameArray.push(!1),this.autoZoomInFrameArray.splice(0,this.autoZoomInFrameArray.length-this.autoZoomInFrameLimit[0]),this.autoZoomOutFrameCount++,this.frameArrayInIdealZoom.push(!1),this.frameArrayInIdealZoom.splice(0,this.frameArrayInIdealZoom.length-this.frameLimitInIdealZoom[0]),this.autoZoomOutFrameCount>=this.autoZoomOutFrameLimit){this.autoZoomOutFrameCount=0;const t=this.getZoomSettings().factor;if(t>this.autoZoomOutMinValue){const e=Math.max((t-1)*this.autoZoomOutStepRate,this.autoZoomOutMinStep),i=Math.max(t-e,this.autoZoomOutMinValue);try{await this.setZoom({factor:i})}catch(t){const e=t.message||t;n.warn(e)}this.dce.clearFrameBuffer()}}this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{})))}else this.autoFocus&&(this.autoFocusFrameArray.length=0,this.setFocus({mode:"continuous"}).catch((()=>{})))}return e})().then((t=>{if(A._onLog&&A._onLog(t),this.captureAndDecodeInParallel){let t=this.array_decodeFrameTimeCost,e=this.array_getFrameTimeCost,i=this._indexCurrentDecodingFrame;const r=()=>{let r=0;if(this.region instanceof Array){let n=0,s=0;n=i+1>=this.region.length?0:i+1,s=n+1>=this.region.length?0:n+1,r=t[n]&&t[n].length&&e[s]&&e[s].length?Math.min(...t[n])-Math.max(...e[s]):0}else if(e&&e.length){let i=Math.min(...t),n=Math.max(...e);i&&n&&(r=i-n)}else r=0;return r>0?r:0};(()=>{if(this.region instanceof Array){for(t[i]&&t[i]instanceof Array||(t[i]=[]);t[i].length>=5;)t[i].shift();t[i].push(this._lastInnerDecodeDuration)}else{for(;t.length>=5;)t.shift();t.push(this._lastInnerDecodeDuration)}})(),this._intervalGetVideoFrame=r()+this.intervalTime,A._onLog&&A._onLog("Next fetching frame loop interval: "+this._intervalGetVideoFrame)}if(this.isOpen()&&this.dce.video&&!this.dce.video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&t.length){let e=!1;!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead?e=t.some((t=>t.resultState>=0)):"unique"===this.bPlaySoundOnSuccessfulRead&&(e=t.some((t=>0==t.resultState))),e&&this.beepSound&&(this.beepSound.stop(),this.beepSound.play())}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&t.length){let e=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead?e=t.some((t=>t.resultState>=0)):"unique"===this.bVibrateOnSuccessfulRead&&(e=t.some((t=>0==t.resultState))),e)try{navigator.vibrate(this.vibrateDuration)}catch(t){n.warn("Vibration not allowed. User interaction required: "+(t.message||t))}}if(this.onFrameRead){t=t.filter((t=>t.resultState>=0));const e=this._cloneDecodeResults(t);this.onFrameRead(e)}if(this.onUniqueRead){t=t.filter((t=>0==t.resultState));const e=this._cloneDecodeResults(t);for(let t of e)this.onUniqueRead(t.barcodeText,t)}}
vendor: 4,724 bytes, line 2
2this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.intervalTime?this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this.intervalTime):this._loopReadVideo()}))}_getVideoFrame(){if(!this.dce)return null;let t;if(this.captureAndDecodeInParallel){A._onLog&&A._onLog("Get frame in parallel.");let e=this.dce.isFetchingLoopStarted();if(this.dce.loopInterval=this._intervalGetVideoFrame,e||this.dce.startFetchingLoop(),!this.dce.numberOfFramesInBuffer)return this.dce.loopInterval=0,null;t=this.dce.getFrameFromBuffer();const i=t=>{if(!t)return;let e=t.timeSpent,i=this.array_getFrameTimeCost;for(;i.length>=5;)i.shift();i.push(e)};i(t)}else A._onLog&&A._onLog("Get frame in serial."),this.dce.stopFetchingLoop(),t=this.dce.getFrame();return t}async open(){this._bindUI();const t=await this.dce.open();return this._bPauseScan=!1,this.singleFrameMode||(this.dce&&(this.dce.ifShowScanRegionLaser=!0),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),t}async openVideo(){this._bindUI(),this.dce.ifShowScanRegionLaser=!1;const t=await this.dce.open();return this._bPauseScan=!0,this.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),t}close(){this._drawResults(null),this.dce.close(),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId)}async show(){this._bindUI();const t=await this.dce.open(!0);return this._bPauseScan=!1,this.singleFrameMode||(this.dce&&(this.dce.ifShowScanRegionLaser=!0),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),t}async showVideo(){this._bindUI(),this.dce.ifShowScanRegionLaser=!1;const t=await this.dce.open(!0);return this._bPauseScan=!0,this.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),t}hide(){this.dce.close(!0),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId)}showTip(t,e,i,r){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];this.dce&&this.dce.showTip(t,e,i,r,n,s)}hideTip(){this.dce&&this.dce.hideTip()}updateTipMessage(t){this.dce&&this.dce.updateTipMessage(t)}async enableTapToFocus(){this.dce&&this.dce.enableTapToFocus()}disableTapToFocus(){this.dce&&this.dce.disableTapToFocus()}isTapToFocusEnabled(){return this.dce.isTapToFocusEnabled()}convertToPageCoordinates(t){return this.dce.convertToPageCoordinates(t)}convertToClientCoordinates(t){return this.dce.convertToClientCoordinates(t)}destroyContext(){this.close(),this.dce&&this.dce.dispose(!1),this.bDestroyed||super.destroyContext()}}ft=Ut,gt={value:void 0},function(t){t[t.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",t[t.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",t[t.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",t[t.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",t[t.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",t[t.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",t[t.BICM_SKIP=0]="BICM_SKIP",t[t.BICM_REV=2147483648]="BICM_REV"}(_t||(_t={})),function(t){t[t.BCM_AUTO=1]="BCM_AUTO",t[t.BCM_GENERAL=2]="BCM_GENERAL",t[t.BCM_SKIP=0]="BCM_SKIP",t[t.BCM_REV=2147483648]="BCM_REV"}(pt||(pt={})),function(t){t[t.BF2_NULL=0]="BF2_NULL",t[t.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",t[t.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",t[t.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",t[t.BF2_POSTNET=2097152]="BF2_POSTNET",t[t.BF2_PLANET=4194304]="BF2_PLANET",t[t.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",t[t.BF2_RM4SCC=16777216]="BF2_RM4SCC",t[t.BF2_DOTCODE=2]="BF2_DOTCODE",t[t.BF2_PHARMACODE_ONE_TRACK=4]="BF2_PHARMACODE_ONE_TRACK",t[t.BF2_PHARMACODE_TWO_TRACK=8]="BF2_PHARMACODE_TWO_TRACK",t[t.BF2_PHARMACODE=12]="BF2_PHARMACODE",t[t.BF2_ALL=-1]="BF2_ALL"}(mt||(mt={})),function(t){t[t.BM_AUTO=1]="BM_AUTO",t[t.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",t[t.BM_SKIP=0]="BM_SKIP",t[t.BM_THRESHOLD=4]="BM_THRESHOLD",t[t.BM_REV=2147483648]="BM_REV"}(vt||(vt={})),function(t){t[t.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(yt||(yt={})),function(t){t[t.CFM_GENERAL=1]="CFM_GENERAL"}(St||(St={})),function(t){t[t.CCM_AUTO=1]="CCM_AUTO",t[t.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",t[t.CCM_SKIP=0]="CCM_SKIP",t[t.CCM_REV=2147483648]="CCM_REV"}(Ct||(Ct={}
2)),function(t){t[t.CICM_GENERAL=1]="CICM_GENERAL",t[t.CICM_SKIP=0]="CICM_SKIP",t[t.CICM_REV=2147483648]="CICM_REV"}(wt||(wt={})),function(t){t[t.CM_IGNORE=1]="CM_IGNORE",t[t.CM_OVERWRITE=2]="CM_OVERWRITE"}(bt||(bt={})),function(t){t[t.DM_SKIP=0]="DM_SKIP",t[t.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",t[t.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",t[t.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",t[t.DM_SMOOTHING=8]="DM_SMOOTHING",t[t.DM_MORPHING=16]="DM_MORPHING",t[t.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",t[t.DM_SHARPENING=64]="DM_SHARPENING",t[t.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",t[t.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING"}(xt||(xt={})),function(t){t[t.DRM_AUTO=1]="DRM_AUTO",t[t.DRM_GENERAL=2]="DRM_GENERAL",t[t.DRM_BROAD_WARP=4]="DRM_BROAD_WARP",t[t.DRM_LOCAL_REFERENCE=8]="DRM_LOCAL_REFERENCE",t[t.DRM_DEWRINKLE=16]="DRM_DEWRINKLE",t[t.DRM_SKIP=0]="DRM_SKIP",t[t.DRM_REV=2147483648]="DRM_REV"}(Tt||(Tt={})),function(t){t[t.DPMCRM_AUTO=1]="DPMCRM_AUTO",t[t.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",t[t.DPMCRM_SKIP=0]="DPMCRM_SKIP",t[t.DPMCRM_REV=2147483648]="DPMCRM_REV"}(Et||(Et={})),function(t){t[t.GTM_INVERTED=1]="GTM_INVERTED",t[t.GTM_ORIGINAL=2]="GTM_ORIGINAL",t[t.GTM_SKIP=0]="GTM_SKIP",t[t.GTM_REV=2147483648]="GTM_REV"}(It||(It={})),function(t){t[t.IPM_AUTO=1]="IPM_AUTO",t[t.IPM_GENERAL=2]="IPM_GENERAL",t[t.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",t[t.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",t[t.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",t[t.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",t[t.IPM_SKIP=0]="IPM_SKIP",t[t.IPM_REV=2147483648]="IPM_REV"}(Ot||(Ot={})),function(t){t[t.IRSM_MEMORY=1]="IRSM_MEMORY",t[t.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",t[t.IRSM_BOTH=4]="IRSM_BOTH"}(Rt||(Rt={})),function(t){t[t.LM_SKIP=0]="LM_SKIP",t[t.LM_AUTO=1]="LM_AUTO",t[t.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",t[t.LM_LINES=8]="LM_LINES",t[t.LM_STATISTICS=4]="LM_STATISTICS",t[t.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",t[t.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",t[t.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",t[t.LM_CENTRE=128]="LM_CENTRE",t[t.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",t[t.LM_REV=2147483648]="LM_REV"}(Dt||(Dt={})),function(t){t[t.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",t[t.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",t[t.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",t[t.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(At||(At={})),function(t){t[t.RPM_AUTO=1]="RPM_AUTO",t[t.RPM_GENERAL=2]="RPM_GENERAL",t[t.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",t[t.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",t[t.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",t[t.RPM_SKIP=0]="RPM_SKIP",t[t.RPM_REV=2147483648]="RPM_REV"}(Mt||(Mt={})),function(t){t[t.RCT_PIXEL=1]="RCT_PIXEL",t[t.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(Lt||(Lt={})),function(t){t[t.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",t[t.RT_RAW_TEXT=1]="RT_RAW_TEXT",t[t.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",t[t.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(Ft||(Ft={})),function(t){t[t.SUM_AUTO=1]="SUM_AUTO",t[t.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",t[t.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",t[t.SUM_SKIP=0]="SUM_SKIP",t[t.SUM_REV=2147483648]="SUM_REV"}(Pt||(Pt={})),function(t){t[t.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",t[t.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",t[t.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",t[t.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",t[t.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",t[t.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(kt||(kt={})),function(t){t[t.TFM_AUTO=1]="TFM_AUTO",t[t.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",t[t.TFM_SKIP=0]="TFM_SKIP",t[t.TFM_REV=2147483648]="TFM_REV"}(Bt||(Bt={})),function(t){t[t.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",t[t.TROM_POSITION=2]="TROM_POSITION",t[t.TROM_FORMAT=4]="TROM_FORMAT",t[t.TROM_SKIP=0]="TROM_SKIP",t[t.TROM_REV=2147483648]="TROM_REV"}(Nt||(Nt={})),function(t){t[t.TDM_AUTO=1]="TDM_AUTO",t[t.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",t[t.TDM_SKIP=0]="TDM_SKIP",t[t.TDM_REV=2147483648]="TDM_REV"}(jt||(jt={}))}}]);
3//# sourceMappingURL=4385.9be19dc4.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.