keillion-dynamsoft-javascript-barcode
Version:
Dynamsoft Barcode Reader JS is a recognition SDK which enables you to embed barcode reading functionality in your web, desktop, and mobile applications. With a few lines of JavaScript code, you can develop a robust application to scan a linear barcode, QR
11 lines • 524 kB
JavaScript
/*!
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @copyright Copyright 2022, Dynamsoft Corporation
* @author Dynamsoft
* @version 9.2.11 (js 20220727)
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/barcode-reader/sdk-javascript/
*/
const e="undefined"==typeof self;let t,i,r,n,s;if("undefined"!=typeof navigator&&(t=navigator,i=t.userAgent,r=t.platform,n=t.mediaDevices),!e){const e={init:function(){this.browser=this.searchString(this.dataBrowser)||"unknownBrowser",this.version=this.searchVersion(i)||this.searchVersion(t.appVersion)||0,this.OS=this.searchString(this.dataOS)||"unknownOS","Linux"==this.OS&&-1!=i.indexOf("Windows NT")&&(this.OS="HarmonyOS")},searchString:function(e){for(let t=0;t<e.length;t++){let i=e[t].string,r=e[t].prop;if(this.versionSearchString=e[t].versionSearch||e[t].identity,i){if(-1!=i.indexOf(e[t].subString))return e[t].identity}else if(r)return e[t].identity}},searchVersion:function(e){let t=e.indexOf(this.versionSearchString);if(-1!=t)return parseFloat(e.substring(t+this.versionSearchString.length+1))},dataBrowser:[{string:i,subString:"Edge",identity:"Edge"},{string:i,subString:"OPR",identity:"OPR"},{string:i,subString:"Chrome",identity:"Chrome"},{string:t.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{string:i,subString:"Firefox",identity:"Firefox"},{string:i,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"}],dataOS:[{string:i,subString:"HarmonyOS",identity:"HarmonyOS"},{string:i,subString:"Android",identity:"Android"},{string:i,subString:"iPhone",identity:"iPhone"},{string:r,subString:"Win",identity:"Windows"},{string:r,subString:"Mac",identity:"Mac"},{string:r,subString:"Linux",identity:"Linux"}]};e.init(),s={browser:e.browser,version:e.version,OS:e.OS}}e&&(s={browser:"ssr",version:0,OS:"ssr"});const o="undefined"!=typeof WebAssembly&&i&&!(/Safari/.test(i)&&!/Chrome/.test(i)&&/\(.+\s11_2_([2-6]).*\)/.test(i)),a=!("undefined"==typeof Worker),l=!(!n||!n.getUserMedia),h=async()=>{let e=!1;if(l)try{(await n.getUserMedia({video:!0})).getTracks().forEach((e=>{e.stop()})),e=!0}catch(e){}return e};"Chrome"===s.browser&&s.version>66||"Safari"===s.browser&&s.version>13||"OPR"===s.browser&&s.version>43||"Edge"===s.browser&&s.version;const c=(()=>{if(!e&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),u=" is not allowed to change after `createInstance` or `loadWasm` is called.",d=!e&&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"))||"",f=!e&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword")||"",g=t=>{if(null==t)t=[];else{t=t instanceof Array?[...t]:[t];for(let i=0;i<t.length;++i){if(!e){let e=document.createElement("a");e.href=t[i],t[i]=e.href}t[i].endsWith("/")||(t[i]+="/")}}return t};var _,p,m,v;!function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(_||(_={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(p||(p={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(m||(m={})),function(e){e[e.BF_ALL=4265607167]="BF_ALL",e[e.BF_ONED=3147775]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_CODE_11=2097152]="BF_CODE_11",e[e.BF_NULL=0]="BF_NULL"}(v||(v={}));const y=e=>e&&"object"==typeof e&&"function"==typeof e.then;var S=function(){this.init()};S.prototype={init:function(){var e=this||b;return e._counter=1e3,e._html5AudioPool=[],e.html5PoolSize=10,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.autoUnlock=!0,e._setup(),e},volume:function(e){var t=this||b;if(e=parseFloat(e),t.ctx||E(),void 0!==e&&e>=0&&e<=1){if(t._volume=e,t._muted)return t;t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e,b.ctx.currentTime);for(var i=0;i<t._howls.length;i++)if(!t._howls[i]._webAudio)for(var r=t._howls[i]._getSoundIds(),n=0;n<r.length;n++){var s=t._howls[i]._soundById(r[n]);s&&s._node&&(s._node.volume=s._volume*e)}return t}return t._volume},mute:function(e){var t=this||b;t.ctx||E(),t._muted=e,t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e?0:t._volume,b.ctx.currentTime);for(var i=0;i<t._howls.length;i++)if(!t._howls[i]._webAudio)for(var r=t._howls[i]._getSoundIds(),n=0;n<r.length;n++){var s=t._howls[i]._soundById(r[n]);s&&s._node&&(s._node.muted=!!e||s._muted)}return t},stop:function(){for(var e=this||b,t=0;t<e._howls.length;t++)e._howls[t].stop();return e},unload:function(){for(var e=this||b,t=e._howls.length-1;t>=0;t--)e._howls[t].unload();return e.usingWebAudio&&e.ctx&&void 0!==e.ctx.close&&(e.ctx.close(),e.ctx=null,E()),e},codecs:function(e){return(this||b)._codecs[e.replace(/^x-/,"")]},_setup:function(){var e=this||b;if(e.state=e.ctx&&e.ctx.state||"suspended",e._autoSuspend(),!e.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(e._canPlayEvent="canplay")}catch(t){e.noAudio=!0}else e.noAudio=!0;try{(new Audio).muted&&(e.noAudio=!0)}catch(e){}return e.noAudio||e._setupCodecs(),e},_setupCodecs:function(){var e=this||b,t=null;try{t="undefined"!=typeof Audio?new Audio:null}catch(t){return e}if(!t||"function"!=typeof t.canPlayType)return e;var i=t.canPlayType("audio/mpeg;").replace(/^no$/,""),r=e._navigator?e._navigator.userAgent:"",n=r.match(/OPR\/([0-6].)/g),s=n&&parseInt(n[0].split("/")[1],10)<33,o=-1!==r.indexOf("Safari")&&-1===r.indexOf("Chrome"),a=r.match(/Version\/(.*?) /),l=o&&a&&parseInt(a[1],10)<15;return e._codecs={mp3:!(s||!i&&!t.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!i,opus:!!t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(t.canPlayType('audio/wav; codecs="1"')||t.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!t.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!t.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/m4a;")||t.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(t.canPlayType("audio/x-m4b;")||t.canPlayType("audio/m4b;")||t.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(t.canPlayType("audio/x-mp4;")||t.canPlayType("audio/mp4;")||t.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(l||!t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(l||!t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!t.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(t.canPlayType("audio/x-flac;")||t.canPlayType("audio/flac;")).replace(/^no$/,"")},e},_unlockAudio:function(){var e=this||b;if(!e._audioUnlocked&&e.ctx){e._audioUnlocked=!1,e.autoUnlock=!1,e._mobileUnloaded||44100===e.ctx.sampleRate||(e._mobileUnloaded=!0,e.unload()),e._scratchBuffer=e.ctx.createBuffer(1,1,22050);var t=function(i){for(;e._html5AudioPool.length<e.html5PoolSize;)try{var r=new Audio;r._unlocked=!0,e._releaseHtml5Audio(r)}catch(i){e.noAudio=!0;break}for(var n=0;n<e._howls.length;n++)if(!e._howls[n]._webAudio)for(var s=e._howls[n]._getSoundIds(),o=0;o<s.length;o++){var a=e._howls[n]._soundById(s[o]);a&&a._node&&!a._node._unlocked&&(a._node._unlocked=!0,a._node.load())}e._autoResume();var l=e.ctx.createBufferSource();l.buffer=e._scratchBuffer,l.connect(e.ctx.destination),void 0===l.start?l.noteOn(0):l.start(0),"function"==typeof e.ctx.resume&&e.ctx.resume(),l.onended=function(){l.disconnect(0),e._audioUnlocked=!0,document.removeEventListener("touchstart",t,!0),document.removeEventListener("touchend",t,!0),document.removeEventListener("click",t,!0),document.removeEventListener("keydown",t,!0);for(var i=0;i<e._howls.length;i++)e._howls[i]._emit("unlock")}};return document.addEventListener("touchstart",t,!0),document.addEventListener("touchend",t,!0),document.addEventListener("click",t,!0),document.addEventListener("keydown",t,!0),e}},_obtainHtml5Audio:function(){var e=this||b;if(e._html5AudioPool.length)return e._html5AudioPool.pop();var t=(new Audio).play();return t&&"undefined"!=typeof Promise&&(t instanceof Promise||"function"==typeof t.then)&&t.catch((function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")})),new Audio},_releaseHtml5Audio:function(e){var t=this||b;return e._unlocked&&t._html5AudioPool.push(e),t},_autoSuspend:function(){var e=this;if(e.autoSuspend&&e.ctx&&void 0!==e.ctx.suspend&&b.usingWebAudio){for(var t=0;t<e._howls.length;t++)if(e._howls[t]._webAudio)for(var i=0;i<e._howls[t]._sounds.length;i++)if(!e._howls[t]._sounds[i]._paused)return e;return e._suspendTimer&&clearTimeout(e._suspendTimer),e._suspendTimer=setTimeout((function(){if(e.autoSuspend){e._suspendTimer=null,e.state="suspending";var t=function(){e.state="suspended",e._resumeAfterSuspend&&(delete e._resumeAfterSuspend,e._autoResume())};e.ctx.suspend().then(t,t)}}),3e4),e}},_autoResume:function(){var e=this;if(e.ctx&&void 0!==e.ctx.resume&&b.usingWebAudio)return"running"===e.state&&"interrupted"!==e.ctx.state&&e._suspendTimer?(clearTimeout(e._suspendTimer),e._suspendTimer=null):"suspended"===e.state||"running"===e.state&&"interrupted"===e.ctx.state?(e.ctx.resume().then((function(){e.state="running";for(var t=0;t<e._howls.length;t++)e._howls[t]._emit("resume")})),e._suspendTimer&&(clearTimeout(e._suspendTimer),e._suspendTimer=null)):"suspending"===e.state&&(e._resumeAfterSuspend=!0),e}};var b=new S,C=function(e){e.src&&0!==e.src.length?this.init(e):console.error("An array of source files must be passed with any new Howl.")};C.prototype={init:function(e){var t=this;return b.ctx||E(),t._autoplay=e.autoplay||!1,t._format="string"!=typeof e.format?e.format:[e.format],t._html5=e.html5||!1,t._muted=e.mute||!1,t._loop=e.loop||!1,t._pool=e.pool||5,t._preload="boolean"!=typeof e.preload&&"metadata"!==e.preload||e.preload,t._rate=e.rate||1,t._sprite=e.sprite||{},t._src="string"!=typeof e.src?e.src:[e.src],t._volume=void 0!==e.volume?e.volume:1,t._xhr={method:e.xhr&&e.xhr.method?e.xhr.method:"GET",headers:e.xhr&&e.xhr.headers?e.xhr.headers:null,withCredentials:!(!e.xhr||!e.xhr.withCredentials)&&e.xhr.withCredentials},t._duration=0,t._state="unloaded",t._sounds=[],t._endTimers={},t._queue=[],t._playLock=!1,t._onend=e.onend?[{fn:e.onend}]:[],t._onfade=e.onfade?[{fn:e.onfade}]:[],t._onload=e.onload?[{fn:e.onload}]:[],t._onloaderror=e.onloaderror?[{fn:e.onloaderror}]:[],t._onplayerror=e.onplayerror?[{fn:e.onplayerror}]:[],t._onpause=e.onpause?[{fn:e.onpause}]:[],t._onplay=e.onplay?[{fn:e.onplay}]:[],t._onstop=e.onstop?[{fn:e.onstop}]:[],t._onmute=e.onmute?[{fn:e.onmute}]:[],t._onvolume=e.onvolume?[{fn:e.onvolume}]:[],t._onrate=e.onrate?[{fn:e.onrate}]:[],t._onseek=e.onseek?[{fn:e.onseek}]:[],t._onunlock=e.onunlock?[{fn:e.onunlock}]:[],t._onresume=[],t._webAudio=b.usingWebAudio&&!t._html5,void 0!==b.ctx&&b.ctx&&b.autoUnlock&&b._unlockAudio(),b._howls.push(t),t._autoplay&&t._queue.push({event:"play",action:function(){t.play()}}),t._preload&&"none"!==t._preload&&t.load(),t},load:function(){var e=this,t=null;if(b.noAudio)e._emit("loaderror",null,"No audio support.");else{"string"==typeof e._src&&(e._src=[e._src]);for(var i=0;i<e._src.length;i++){var r,n;if(e._format&&e._format[i])r=e._format[i];else{if("string"!=typeof(n=e._src[i])){e._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}(r=/^data:audio\/([^;,]+);/i.exec(n))||(r=/\.([^.]+)$/.exec(n.split("?",1)[0])),r&&(r=r[1].toLowerCase())}if(r||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),r&&b.codecs(r)){t=e._src[i];break}}if(t)return e._src=t,e._state="loading","https:"===window.location.protocol&&"http:"===t.slice(0,5)&&(e._html5=!0,e._webAudio=!1),new w(e),e._webAudio&&x(e),e;e._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(e,t){var i=this,r=null;if("number"==typeof e)r=e,e=null;else{if("string"==typeof e&&"loaded"===i._state&&!i._sprite[e])return null;if(void 0===e&&(e="__default",!i._playLock)){for(var n=0,s=0;s<i._sounds.length;s++)i._sounds[s]._paused&&!i._sounds[s]._ended&&(n++,r=i._sounds[s]._id);1===n?e=null:r=null}}var o=r?i._soundById(r):i._inactiveSound();if(!o)return null;if(r&&!e&&(e=o._sprite||"__default"),"loaded"!==i._state){o._sprite=e,o._ended=!1;var a=o._id;return i._queue.push({event:"play",action:function(){i.play(a)}}),a}if(r&&!o._paused)return t||i._loadQueue("play"),o._id;i._webAudio&&b._autoResume();var l=Math.max(0,o._seek>0?o._seek:i._sprite[e][0]/1e3),h=Math.max(0,(i._sprite[e][0]+i._sprite[e][1])/1e3-l),c=1e3*h/Math.abs(o._rate),u=i._sprite[e][0]/1e3,d=(i._sprite[e][0]+i._sprite[e][1])/1e3;o._sprite=e,o._ended=!1;var f=function(){o._paused=!1,o._seek=l,o._start=u,o._stop=d,o._loop=!(!o._loop&&!i._sprite[e][2])};if(!(l>=d)){var g=o._node;if(i._webAudio){var _=function(){i._playLock=!1,f(),i._refreshBuffer(o);var e=o._muted||i._muted?0:o._volume;g.gain.setValueAtTime(e,b.ctx.currentTime),o._playStart=b.ctx.currentTime,void 0===g.bufferSource.start?o._loop?g.bufferSource.noteGrainOn(0,l,86400):g.bufferSource.noteGrainOn(0,l,h):o._loop?g.bufferSource.start(0,l,86400):g.bufferSource.start(0,l,h),c!==1/0&&(i._endTimers[o._id]=setTimeout(i._ended.bind(i,o),c)),t||setTimeout((function(){i._emit("play",o._id),i._loadQueue()}),0)};"running"===b.state&&"interrupted"!==b.ctx.state?_():(i._playLock=!0,i.once("resume",_),i._clearTimer(o._id))}else{var p=function(){g.currentTime=l,g.muted=o._muted||i._muted||b._muted||g.muted,g.volume=o._volume*b.volume(),g.playbackRate=o._rate;try{var r=g.play();if(r&&"undefined"!=typeof Promise&&(r instanceof Promise||"function"==typeof r.then)?(i._playLock=!0,f(),r.then((function(){i._playLock=!1,g._unlocked=!0,t?i._loadQueue():i._emit("play",o._id)})).catch((function(){i._playLock=!1,i._emit("playerror",o._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),o._ended=!0,o._paused=!0}))):t||(i._playLock=!1,f(),i._emit("play",o._id)),g.playbackRate=o._rate,g.paused)return void i._emit("playerror",o._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==e||o._loop?i._endTimers[o._id]=setTimeout(i._ended.bind(i,o),c):(i._endTimers[o._id]=function(){i._ended(o),g.removeEventListener("ended",i._endTimers[o._id],!1)},g.addEventListener("ended",i._endTimers[o._id],!1))}catch(e){i._emit("playerror",o._id,e)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===g.src&&(g.src=i._src,g.load());var m=window&&window.ejecta||!g.readyState&&b._navigator.isCocoonJS;if(g.readyState>=3||m)p();else{i._playLock=!0,i._state="loading";var v=function(){i._state="loaded",p(),g.removeEventListener(b._canPlayEvent,v,!1)};g.addEventListener(b._canPlayEvent,v,!1),i._clearTimer(o._id)}}return o._id}i._ended(o)},pause:function(e){var t=this;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"pause",action:function(){t.pause(e)}}),t;for(var i=t._getSoundIds(e),r=0;r<i.length;r++){t._clearTimer(i[r]);var n=t._soundById(i[r]);if(n&&!n._paused&&(n._seek=t.seek(i[r]),n._rateSeek=0,n._paused=!0,t._stopFade(i[r]),n._node))if(t._webAudio){if(!n._node.bufferSource)continue;void 0===n._node.bufferSource.stop?n._node.bufferSource.noteOff(0):n._node.bufferSource.stop(0),t._cleanBuffer(n._node)}else isNaN(n._node.duration)&&n._node.duration!==1/0||n._node.pause();arguments[1]||t._emit("pause",n?n._id:null)}return t},stop:function(e,t){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"stop",action:function(){i.stop(e)}}),i;for(var r=i._getSoundIds(e),n=0;n<r.length;n++){i._clearTimer(r[n]);var s=i._soundById(r[n]);s&&(s._seek=s._start||0,s._rateSeek=0,s._paused=!0,s._ended=!0,i._stopFade(r[n]),s._node&&(i._webAudio?s._node.bufferSource&&(void 0===s._node.bufferSource.stop?s._node.bufferSource.noteOff(0):s._node.bufferSource.stop(0),i._cleanBuffer(s._node)):isNaN(s._node.duration)&&s._node.duration!==1/0||(s._node.currentTime=s._start||0,s._node.pause(),s._node.duration===1/0&&i._clearSound(s._node))),t||i._emit("stop",s._id))}return i},mute:function(e,t){var i=this;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"mute",action:function(){i.mute(e,t)}}),i;if(void 0===t){if("boolean"!=typeof e)return i._muted;i._muted=e}for(var r=i._getSoundIds(t),n=0;n<r.length;n++){var s=i._soundById(r[n]);s&&(s._muted=e,s._interval&&i._stopFade(s._id),i._webAudio&&s._node?s._node.gain.setValueAtTime(e?0:s._volume,b.ctx.currentTime):s._node&&(s._node.muted=!!b._muted||e),i._emit("mute",s._id))}return i},volume:function(){var e,t,i,r=this,n=arguments;if(0===n.length)return r._volume;if(1===n.length||2===n.length&&void 0===n[1]){var s=r._getSoundIds(),o=s.indexOf(n[0]);o>=0?t=parseInt(n[0],10):e=parseFloat(n[0])}else n.length>=2&&(e=parseFloat(n[0]),t=parseInt(n[1],10));if(!(void 0!==e&&e>=0&&e<=1))return(i=t?r._soundById(t):r._sounds[0])?i._volume:0;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,n)}}),r;void 0===t&&(r._volume=e),t=r._getSoundIds(t);for(var a=0;a<t.length;a++)(i=r._soundById(t[a]))&&(i._volume=e,n[2]||r._stopFade(t[a]),r._webAudio&&i._node&&!i._muted?i._node.gain.setValueAtTime(e,b.ctx.currentTime):i._node&&!i._muted&&(i._node.volume=e*b.volume()),r._emit("volume",i._id));return r},fade:function(e,t,i,r){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"fade",action:function(){n.fade(e,t,i,r)}}),n;e=Math.min(Math.max(0,parseFloat(e)),1),t=Math.min(Math.max(0,parseFloat(t)),1),i=parseFloat(i),n.volume(e,r);for(var s=n._getSoundIds(r),o=0;o<s.length;o++){var a=n._soundById(s[o]);if(a){if(r||n._stopFade(s[o]),n._webAudio&&!a._muted){var l=b.ctx.currentTime,h=l+i/1e3;a._volume=e,a._node.gain.setValueAtTime(e,l),a._node.gain.linearRampToValueAtTime(t,h)}n._startFadeInterval(a,e,t,i,s[o],void 0===r)}}return n},_startFadeInterval:function(e,t,i,r,n,s){var o=this,a=t,l=i-t,h=Math.abs(l/.01),c=Math.max(4,h>0?r/h:r),u=Date.now();e._fadeTo=i,e._interval=setInterval((function(){var n=(Date.now()-u)/r;u=Date.now(),a+=l*n,a=Math.round(100*a)/100,a=l<0?Math.max(i,a):Math.min(i,a),o._webAudio?e._volume=a:o.volume(a,e._id,!0),s&&(o._volume=a),(i<t&&a<=i||i>t&&a>=i)&&(clearInterval(e._interval),e._interval=null,e._fadeTo=null,o.volume(i,e._id),o._emit("fade",e._id))}),c)},_stopFade:function(e){var t=this,i=t._soundById(e);return i&&i._interval&&(t._webAudio&&i._node.gain.cancelScheduledValues(b.ctx.currentTime),clearInterval(i._interval),i._interval=null,t.volume(i._fadeTo,e),i._fadeTo=null,t._emit("fade",e)),t},loop:function(){var e,t,i,r=this,n=arguments;if(0===n.length)return r._loop;if(1===n.length){if("boolean"!=typeof n[0])return!!(i=r._soundById(parseInt(n[0],10)))&&i._loop;e=n[0],r._loop=e}else 2===n.length&&(e=n[0],t=parseInt(n[1],10));for(var s=r._getSoundIds(t),o=0;o<s.length;o++)(i=r._soundById(s[o]))&&(i._loop=e,r._webAudio&&i._node&&i._node.bufferSource&&(i._node.bufferSource.loop=e,e&&(i._node.bufferSource.loopStart=i._start||0,i._node.bufferSource.loopEnd=i._stop,r.playing(s[o])&&(r.pause(s[o],!0),r.play(s[o],!0)))));return r},rate:function(){var e,t,i,r=this,n=arguments;if(0===n.length)t=r._sounds[0]._id;else if(1===n.length){var s=r._getSoundIds(),o=s.indexOf(n[0]);o>=0?t=parseInt(n[0],10):e=parseFloat(n[0])}else 2===n.length&&(e=parseFloat(n[0]),t=parseInt(n[1],10));if("number"!=typeof e)return(i=r._soundById(t))?i._rate:r._rate;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,n)}}),r;void 0===t&&(r._rate=e),t=r._getSoundIds(t);for(var a=0;a<t.length;a++)if(i=r._soundById(t[a])){r.playing(t[a])&&(i._rateSeek=r.seek(t[a]),i._playStart=r._webAudio?b.ctx.currentTime:i._playStart),i._rate=e,r._webAudio&&i._node&&i._node.bufferSource?i._node.bufferSource.playbackRate.setValueAtTime(e,b.ctx.currentTime):i._node&&(i._node.playbackRate=e);var l=r.seek(t[a]),h=(r._sprite[i._sprite][0]+r._sprite[i._sprite][1])/1e3-l,c=1e3*h/Math.abs(i._rate);!r._endTimers[t[a]]&&i._paused||(r._clearTimer(t[a]),r._endTimers[t[a]]=setTimeout(r._ended.bind(r,i),c)),r._emit("rate",i._id)}return r},seek:function(){var e,t,i=this,r=arguments;if(0===r.length)i._sounds.length&&(t=i._sounds[0]._id);else if(1===r.length){var n=i._getSoundIds(),s=n.indexOf(r[0]);s>=0?t=parseInt(r[0],10):i._sounds.length&&(t=i._sounds[0]._id,e=parseFloat(r[0]))}else 2===r.length&&(e=parseFloat(r[0]),t=parseInt(r[1],10));if(void 0===t)return 0;if("number"==typeof e&&("loaded"!==i._state||i._playLock))return i._queue.push({event:"seek",action:function(){i.seek.apply(i,r)}}),i;var o=i._soundById(t);if(o){if(!("number"==typeof e&&e>=0)){if(i._webAudio){var a=i.playing(t)?b.ctx.currentTime-o._playStart:0,l=o._rateSeek?o._rateSeek-o._seek:0;return o._seek+(l+a*Math.abs(o._rate))}return o._node.currentTime}var h=i.playing(t);h&&i.pause(t,!0),o._seek=e,o._ended=!1,i._clearTimer(t),i._webAudio||!o._node||isNaN(o._node.duration)||(o._node.currentTime=e);var c=function(){h&&i.play(t,!0),i._emit("seek",t)};if(h&&!i._webAudio){var u=function(){i._playLock?setTimeout(u,0):c()};setTimeout(u,0)}else c()}return i},playing:function(e){var t=this;if("number"==typeof e){var i=t._soundById(e);return!!i&&!i._paused}for(var r=0;r<t._sounds.length;r++)if(!t._sounds[r]._paused)return!0;return!1},duration:function(e){var t=this,i=t._duration,r=t._soundById(e);return r&&(i=t._sprite[r._sprite][1]/1e3),i},state:function(){return this._state},unload:function(){for(var e=this,t=e._sounds,i=0;i<t.length;i++)t[i]._paused||e.stop(t[i]._id),e._webAudio||(e._clearSound(t[i]._node),t[i]._node.removeEventListener("error",t[i]._errorFn,!1),t[i]._node.removeEventListener(b._canPlayEvent,t[i]._loadFn,!1),t[i]._node.removeEventListener("ended",t[i]._endFn,!1),b._releaseHtml5Audio(t[i]._node)),delete t[i]._node,e._clearTimer(t[i]._id);var r=b._howls.indexOf(e);r>=0&&b._howls.splice(r,1);var n=!0;for(i=0;i<b._howls.length;i++)if(b._howls[i]._src===e._src||e._src.indexOf(b._howls[i]._src)>=0){n=!1;break}return T&&n&&delete T[e._src],b.noAudio=!1,e._state="unloaded",e._sounds=[],e=null,null},on:function(e,t,i,r){var n=this["_on"+e];return"function"==typeof t&&n.push(r?{id:i,fn:t,once:r}:{id:i,fn:t}),this},off:function(e,t,i){var r=this,n=r["_on"+e],s=0;if("number"==typeof t&&(i=t,t=null),t||i)for(s=0;s<n.length;s++){var o=i===n[s].id;if(t===n[s].fn&&o||!t&&o){n.splice(s,1);break}}else if(e)r["_on"+e]=[];else{var a=Object.keys(r);for(s=0;s<a.length;s++)0===a[s].indexOf("_on")&&Array.isArray(r[a[s]])&&(r[a[s]]=[])}return r},once:function(e,t,i){return this.on(e,t,i,1),this},_emit:function(e,t,i){for(var r=this,n=r["_on"+e],s=n.length-1;s>=0;s--)n[s].id&&n[s].id!==t&&"load"!==e||(setTimeout(function(e){e.call(this,t,i)}.bind(r,n[s].fn),0),n[s].once&&r.off(e,n[s].fn,n[s].id));return r._loadQueue(e),r},_loadQueue:function(e){var t=this;if(t._queue.length>0){var i=t._queue[0];i.event===e&&(t._queue.shift(),t._loadQueue()),e||i.action()}return t},_ended:function(e){var t=this,i=e._sprite;if(!t._webAudio&&e._node&&!e._node.paused&&!e._node.ended&&e._node.currentTime<e._stop)return setTimeout(t._ended.bind(t,e),100),t;var r=!(!e._loop&&!t._sprite[i][2]);if(t._emit("end",e._id),!t._webAudio&&r&&t.stop(e._id,!0).play(e._id),t._webAudio&&r){t._emit("play",e._id),e._seek=e._start||0,e._rateSeek=0,e._playStart=b.ctx.currentTime;var n=1e3*(e._stop-e._start)/Math.abs(e._rate);t._endTimers[e._id]=setTimeout(t._ended.bind(t,e),n)}return t._webAudio&&!r&&(e._paused=!0,e._ended=!0,e._seek=e._start||0,e._rateSeek=0,t._clearTimer(e._id),t._cleanBuffer(e._node),b._autoSuspend()),t._webAudio||r||t.stop(e._id,!0),t},_clearTimer:function(e){var t=this;if(t._endTimers[e]){if("function"!=typeof t._endTimers[e])clearTimeout(t._endTimers[e]);else{var i=t._soundById(e);i&&i._node&&i._node.removeEventListener("ended",t._endTimers[e],!1)}delete t._endTimers[e]}return t},_soundById:function(e){for(var t=this,i=0;i<t._sounds.length;i++)if(e===t._sounds[i]._id)return t._sounds[i];return null},_inactiveSound:function(){var e=this;e._drain();for(var t=0;t<e._sounds.length;t++)if(e._sounds[t]._ended)return e._sounds[t].reset();return new w(e)},_drain:function(){var e=this,t=e._pool,i=0,r=0;if(!(e._sounds.length<t)){for(r=0;r<e._sounds.length;r++)e._sounds[r]._ended&&i++;for(r=e._sounds.length-1;r>=0;r--){if(i<=t)return;e._sounds[r]._ended&&(e._webAudio&&e._sounds[r]._node&&e._sounds[r]._node.disconnect(0),e._sounds.splice(r,1),i--)}}},_getSoundIds:function(e){if(void 0===e){for(var t=[],i=0;i<this._sounds.length;i++)t.push(this._sounds[i]._id);return t}return[e]},_refreshBuffer:function(e){return e._node.bufferSource=b.ctx.createBufferSource(),e._node.bufferSource.buffer=T[this._src],e._panner?e._node.bufferSource.connect(e._panner):e._node.bufferSource.connect(e._node),e._node.bufferSource.loop=e._loop,e._loop&&(e._node.bufferSource.loopStart=e._start||0,e._node.bufferSource.loopEnd=e._stop||0),e._node.bufferSource.playbackRate.setValueAtTime(e._rate,b.ctx.currentTime),this},_cleanBuffer:function(e){var t=b._navigator&&b._navigator.vendor.indexOf("Apple")>=0;if(!e.bufferSource)return this;if(b._scratchBuffer&&e.bufferSource&&(e.bufferSource.onended=null,e.bufferSource.disconnect(0),t))try{e.bufferSource.buffer=b._scratchBuffer}catch(e){}return e.bufferSource=null,this},_clearSound:function(e){/MSIE |Trident\//.test(b._navigator&&b._navigator.userAgent)||(e.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var w=function(e){this._parent=e,this.init()};w.prototype={init:function(){var e=this,t=e._parent;return e._muted=t._muted,e._loop=t._loop,e._volume=t._volume,e._rate=t._rate,e._seek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++b._counter,t._sounds.push(e),e.create(),e},create:function(){var e=this,t=e._parent,i=b._muted||e._muted||e._parent._muted?0:e._volume;return t._webAudio?(e._node=void 0===b.ctx.createGain?b.ctx.createGainNode():b.ctx.createGain(),e._node.gain.setValueAtTime(i,b.ctx.currentTime),e._node.paused=!0,e._node.connect(b.masterGain)):b.noAudio||(e._node=b._obtainHtml5Audio(),e._errorFn=e._errorListener.bind(e),e._node.addEventListener("error",e._errorFn,!1),e._loadFn=e._loadListener.bind(e),e._node.addEventListener(b._canPlayEvent,e._loadFn,!1),e._endFn=e._endListener.bind(e),e._node.addEventListener("ended",e._endFn,!1),e._node.src=t._src,e._node.preload=!0===t._preload?"auto":t._preload,e._node.volume=i*b.volume(),e._node.load()),e},reset:function(){var e=this,t=e._parent;return e._muted=t._muted,e._loop=t._loop,e._volume=t._volume,e._rate=t._rate,e._seek=0,e._rateSeek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++b._counter,e},_errorListener:function(){var e=this;e._parent._emit("loaderror",e._id,e._node.error?e._node.error.code:0),e._node.removeEventListener("error",e._errorFn,!1)},_loadListener:function(){var e=this,t=e._parent;t._duration=Math.ceil(10*e._node.duration)/10,0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue()),e._node.removeEventListener(b._canPlayEvent,e._loadFn,!1)},_endListener:function(){var e=this,t=e._parent;t._duration===1/0&&(t._duration=Math.ceil(10*e._node.duration)/10,t._sprite.__default[1]===1/0&&(t._sprite.__default[1]=1e3*t._duration),t._ended(e)),e._node.removeEventListener("ended",e._endFn,!1)}};var T={},x=function(e){var t=e._src;if(T[t])return e._duration=T[t].duration,void I(e);if(/^data:[^;]+;base64,/.test(t)){for(var i=atob(t.split(",")[1]),r=new Uint8Array(i.length),n=0;n<i.length;++n)r[n]=i.charCodeAt(n);O(r.buffer,e)}else{var s=new XMLHttpRequest;s.open(e._xhr.method,t,!0),s.withCredentials=e._xhr.withCredentials,s.responseType="arraybuffer",e._xhr.headers&&Object.keys(e._xhr.headers).forEach((function(t){s.setRequestHeader(t,e._xhr.headers[t])})),s.onload=function(){var t=(s.status+"")[0];"0"===t||"2"===t||"3"===t?O(s.response,e):e._emit("loaderror",null,"Failed loading audio file with status: "+s.status+".")},s.onerror=function(){e._webAudio&&(e._html5=!0,e._webAudio=!1,e._sounds=[],delete T[t],e.load())},A(s)}},A=function(e){try{e.send()}catch(t){e.onerror()}},O=function(e,t){var i=function(){t._emit("loaderror",null,"Decoding audio data failed.")},r=function(e){e&&t._sounds.length>0?(T[t._src]=e,I(t,e)):i()};"undefined"!=typeof Promise&&1===b.ctx.decodeAudioData.length?b.ctx.decodeAudioData(e).then(r).catch(i):b.ctx.decodeAudioData(e,r,i)},I=function(e,t){t&&!e._duration&&(e._duration=t.duration),0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue())},E=function(){if(b.usingWebAudio){try{"undefined"!=typeof AudioContext?b.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?b.ctx=new webkitAudioContext:b.usingWebAudio=!1}catch(e){b.usingWebAudio=!1}b.ctx||(b.usingWebAudio=!1);var e=/iP(hone|od|ad)/.test(b._navigator&&b._navigator.platform),t=b._navigator&&b._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),i=t?parseInt(t[1],10):null;if(e&&i&&i<9){var r=/safari/.test(b._navigator&&b._navigator.userAgent.toLowerCase());b._navigator&&!r&&(b.usingWebAudio=!1)}b.usingWebAudio&&(b.masterGain=void 0===b.ctx.createGain?b.ctx.createGainNode():b.ctx.createGain(),b.masterGain.gain.setValueAtTime(b._muted?0:b._volume,b.ctx.currentTime),b.masterGain.connect(b.ctx.destination)),b._setup()}};!function(e,t,i,r){var n;e.prototype._pos=[0,0,0],e.prototype._orientation=[0,0,-1,0,1,0],e.prototype.stereo=function(e){var t=this;if(!t.ctx||!t.ctx.listener)return t;for(var i=t._howls.length-1;i>=0;i--)t._howls[i].stereo(e);return t},e.prototype.pos=function(e,i,r){var n=this;return n.ctx&&n.ctx.listener?(i="number"!=typeof i?n._pos[1]:i,r="number"!=typeof r?n._pos[2]:r,"number"!=typeof e?n._pos:(n._pos=[e,i,r],void 0!==n.ctx.listener.positionX?(n.ctx.listener.positionX.setTargetAtTime(n._pos[0],t.ctx.currentTime,.1),n.ctx.listener.positionY.setTargetAtTime(n._pos[1],t.ctx.currentTime,.1),n.ctx.listener.positionZ.setTargetAtTime(n._pos[2],t.ctx.currentTime,.1)):n.ctx.listener.setPosition(n._pos[0],n._pos[1],n._pos[2]),n)):n},e.prototype.orientation=function(e,i,r,n,s,o){var a=this;if(!a.ctx||!a.ctx.listener)return a;var l=a._orientation;return i="number"!=typeof i?l[1]:i,r="number"!=typeof r?l[2]:r,n="number"!=typeof n?l[3]:n,s="number"!=typeof s?l[4]:s,o="number"!=typeof o?l[5]:o,"number"!=typeof e?l:(a._orientation=[e,i,r,n,s,o],void 0!==a.ctx.listener.forwardX?(a.ctx.listener.forwardX.setTargetAtTime(e,t.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(i,t.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(r,t.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(n,t.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(s,t.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(o,t.ctx.currentTime,.1)):a.ctx.listener.setOrientation(e,i,r,n,s,o),a)},i.prototype.init=(n=i.prototype.init,function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],n.call(this,e)}),i.prototype.stereo=function(e,i){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"stereo",action:function(){r.stereo(e,i)}}),r;var n=void 0===t.ctx.createStereoPanner?"spatial":"stereo";if(void 0===i){if("number"!=typeof e)return r._stereo;r._stereo=e,r._pos=[e,0,0]}for(var o=r._getSoundIds(i),a=0;a<o.length;a++){var l=r._soundById(o[a]);if(l){if("number"!=typeof e)return l._stereo;l._stereo=e,l._pos=[e,0,0],l._node&&(l._pannerAttr.panningModel="equalpower",l._panner&&l._panner.pan||s(l,n),"spatial"===n?void 0!==l._panner.positionX?(l._panner.positionX.setValueAtTime(e,t.ctx.currentTime),l._panner.positionY.setValueAtTime(0,t.ctx.currentTime),l._panner.positionZ.setValueAtTime(0,t.ctx.currentTime)):l._panner.setPosition(e,0,0):l._panner.pan.setValueAtTime(e,t.ctx.currentTime)),r._emit("stereo",l._id)}}return r},i.prototype.pos=function(e,i,r,n){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"pos",action:function(){o.pos(e,i,r,n)}}),o;if(i="number"!=typeof i?0:i,r="number"!=typeof r?-.5:r,void 0===n){if("number"!=typeof e)return o._pos;o._pos=[e,i,r]}for(var a=o._getSoundIds(n),l=0;l<a.length;l++){var h=o._soundById(a[l]);if(h){if("number"!=typeof e)return h._pos;h._pos=[e,i,r],h._node&&(h._panner&&!h._panner.pan||s(h,"spatial"),void 0!==h._panner.positionX?(h._panner.positionX.setValueAtTime(e,t.ctx.currentTime),h._panner.positionY.setValueAtTime(i,t.ctx.currentTime),h._panner.positionZ.setValueAtTime(r,t.ctx.currentTime)):h._panner.setPosition(e,i,r)),o._emit("pos",h._id)}}return o},i.prototype.orientation=function(e,i,r,n){var o=this;if(!o._webAudio)return o;if("loaded"!==o._state)return o._queue.push({event:"orientation",action:function(){o.orientation(e,i,r,n)}}),o;if(i="number"!=typeof i?o._orientation[1]:i,r="number"!=typeof r?o._orientation[2]:r,void 0===n){if("number"!=typeof e)return o._orientation;o._orientation=[e,i,r]}for(var a=o._getSoundIds(n),l=0;l<a.length;l++){var h=o._soundById(a[l]);if(h){if("number"!=typeof e)return h._orientation;h._orientation=[e,i,r],h._node&&(h._panner||(h._pos||(h._pos=o._pos||[0,0,-.5]),s(h,"spatial")),void 0!==h._panner.orientationX?(h._panner.orientationX.setValueAtTime(e,t.ctx.currentTime),h._panner.orientationY.setValueAtTime(i,t.ctx.currentTime),h._panner.orientationZ.setValueAtTime(r,t.ctx.currentTime)):h._panner.setOrientation(e,i,r)),o._emit("orientation",h._id)}}return o},i.prototype.pannerAttr=function(){var e,t,i,r=this,n=arguments;if(!r._webAudio)return r;if(0===n.length)return r._pannerAttr;if(1===n.length){if("object"!=typeof n[0])return(i=r._soundById(parseInt(n[0],10)))?i._pannerAttr:r._pannerAttr;e=n[0],void 0===t&&(e.pannerAttr||(e.pannerAttr={coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}),r._pannerAttr={coneInnerAngle:void 0!==e.pannerAttr.coneInnerAngle?e.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:void 0!==e.pannerAttr.coneOuterAngle?e.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:void 0!==e.pannerAttr.coneOuterGain?e.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:void 0!==e.pannerAttr.distanceModel?e.pannerAttr.distanceModel:r._distanceModel,maxDistance:void 0!==e.pannerAttr.maxDistance?e.pannerAttr.maxDistance:r._maxDistance,refDistance:void 0!==e.pannerAttr.refDistance?e.pannerAttr.refDistance:r._refDistance,rolloffFactor:void 0!==e.pannerAttr.rolloffFactor?e.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:void 0!==e.pannerAttr.panningModel?e.pannerAttr.panningModel:r._panningModel})}else 2===n.length&&(e=n[0],t=parseInt(n[1],10));for(var o=r._getSoundIds(t),a=0;a<o.length;a++)if(i=r._soundById(o[a])){var l=i._pannerAttr;l={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:l.coneOuterAngle,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:l.coneOuterGain,distanceModel:void 0!==e.distanceModel?e.distanceModel:l.distanceModel,maxDistance:void 0!==e.maxDistance?e.maxDistance:l.maxDistance,refDistance:void 0!==e.refDistance?e.refDistance:l.refDistance,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:l.rolloffFactor,panningModel:void 0!==e.panningModel?e.panningModel:l.panningModel};var h=i._panner;h||(i._pos||(i._pos=r._pos||[0,0,-.5]),s(i,"spatial"),h=i._panner),h.coneInnerAngle=l.coneInnerAngle,h.coneOuterAngle=l.coneOuterAngle,h.coneOuterGain=l.coneOuterGain,h.distanceModel=l.distanceModel,h.maxDistance=l.maxDistance,h.refDistance=l.refDistance,h.rolloffFactor=l.rolloffFactor,h.panningModel=l.panningModel}return r},r.prototype.init=function(e){return function(){var t=this,i=t._parent;t._orientation=i._orientation,t._stereo=i._stereo,t._pos=i._pos,t._pannerAttr=i._pannerAttr,e.call(this),t._stereo?i.stereo(t._stereo):t._pos&&i.pos(t._pos[0],t._pos[1],t._pos[2],t._id)}}(r.prototype.init),r.prototype.reset=function(e){return function(){var t=this,i=t._parent;return t._orientation=i._orientation,t._stereo=i._stereo,t._pos=i._pos,t._pannerAttr=i._pannerAttr,t._stereo?i.stereo(t._stereo):t._pos?i.pos(t._pos[0],t._pos[1],t._pos[2],t._id):t._panner&&(t._panner.disconnect(0),t._panner=void 0,i._refreshBuffer(t)),e.call(this)}}(r.prototype.reset);var s=function(e,i){"spatial"===(i=i||"spatial")?(e._panner=t.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,void 0!==e._panner.positionX?(e._panner.positionX.setValueAtTime(e._pos[0],t.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],t.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],t.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),void 0!==e._panner.orientationX?(e._panner.orientationX.setValueAtTime(e._orientation[0],t.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],t.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],t.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=t.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,t.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}}(S,b,C,w);const R="iPhone"==s.OS||"Android"==s.OS||"HarmonyOS"==s.OS?2048:4096;class D{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._bPauseScan=!1,this._intervalDetectVideoPause=1e3,this._soundSource="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",this.beepSound=new C({src:["data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"],onplayerror:(e,t)=>{console.warn(`Sound '${e}' playback failure: ${t}`)}}),this.bPlaySoundOnSuccessfulRead=!1,this.bVibrateOnSuccessfulRead=!1,this.vibrateDuration=300,this.captureAndDecodeInParallel=!0,this.barcodeFillStyle="rgba(254,180,32,0.3)",this.barcodeStrokeStyle="rgba(254,180,32,0.9)",this.barcodeLineWidth=1,this._dce=null,this._imgSource=null,this._maxCvsSideLength=R,this._tempSolutionStatus="closed"}static get version(){return this._version}static get license(){return this._license}static set license(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`license`"+u);i._license=t})(D,e)}static get productKeys(){return this._license}static set productKeys(e){D.license=e}static get handshakeCode(){return this._license}static set handshakeCode(e){D.license=e}static get organizationID(){return this._license}static set organizationID(e){D.license=e}static set sessionPassword(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`sessionPassword`"+u);i._sessionPassword=t})(D,e)}static get sessionPassword(){return this._sessionPassword}static async detectEnvironment(){return await(async()=>({wasm:o,worker:a,getUserMedia:l,camera:await h(),browser:s.browser,version:s.version,OS:s.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.");D._engineResourcePath=(t=>{if(null==t&&(t="./"),!e){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(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+u);i._licenseServer=g(t)})(D,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+u);i._deviceFriendlyName=t||""})(D,e)}static get _bUseFullFeature(){return this.__bUseFullFeature}static set _bUseFullFeature(e){if(!this._pLoad.isEmpty)throw new Error("`_bUseFullFeature` is not allowed to change after `createInstance` or `loadWasm` is called.");D.__bUseFullFeature=e}static isImageSource(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&"getImage"in e}static isDSImage(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&("data"in e&&("width"in e&&("height"in e&&"pixelFormat"in e)))}static isDCEFrame(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&("data"in e&&("region"in e&&("sx"in e&&("sy"in e&&("width"in e&&("height"in e&&("colorMode"in e&&("timeSpent"in e&&("timeStamp"i