Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keiser/echip-webusb

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keiser/echip-webusb - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

1

index.d.ts

@@ -56,2 +56,3 @@ // Generated by dts-bundle v0.7.3

}): Promise<void>;
performSetData(newData: Uint8Array[]): Promise<void>;
protected dispose(): void;

@@ -58,0 +59,0 @@ }

4

index.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EChip=t():e.EChip=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));class n{static info(e){this.enabled()&&console.info(e)}static warn(e){this.enabled()&&console.warn(e)}static error(e){this.enabled()&&console.error(e)}static enabled(){return!0===window.DEBUG_ECHIP}}},function(e,t,r){"use strict";(function(e){
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EChip=e():t.EChip=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=17)}([function(t,e,r){"use strict";r.d(e,"d",(function(){return i})),r.d(e,"a",(function(){return s})),r.d(e,"b",(function(){return o})),r.d(e,"c",(function(){return a}));var n=r(4);const i={dispose:()=>void 0};var s;!function(t){t.once=(t,e)=>{let r,n=!1;return r=t(t=>{e(t),r?r.dispose():n=!0}),n?(r.dispose(),i):r},t.toPromise=(e,r)=>r?r.isCancellationRequested?Promise.reject(new n.a):new Promise((i,s)=>{const o=t.once(r.onCancellationRequested,()=>{a.dispose(),s(new n.a)}),a=t.once(e,t=>{o.dispose(),i(t)})}):new Promise(r=>t.once(e,r))}(s||(s={}));class o{constructor(){this.listeners=new Set,this.addListener=t=>this.addListenerInner(t)}emit(t){for(const e of this.listeners)e(t)}addListenerInner(t){return this.listeners.add(t),{dispose:()=>this.listeners.delete(t)}}}class a extends o{constructor(){super(...arguments),this.addListener=t=>{const e=this.addListenerInner(t);return this.lastValue&&t(this.lastValue.value),e}}get hasEmitted(){return!!this.lastValue}emit(t){this.lastValue={value:t};for(const e of this.listeners)e(t)}}},function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));class n{static info(t){this.enabled()&&console.info(t)}static warn(t){this.enabled()&&console.warn(t)}static error(t){this.enabled()&&console.error(t)}static enabled(){return!0===window.DEBUG_ECHIP}}},function(t,e,r){"use strict";(function(t){
/*!

@@ -8,2 +8,2 @@ * The buffer module from node.js, for the browser.

*/
var n=r(8),i=r(9),s=r(10);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return u(this,e,t,r)}function u(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=l(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length?e:(t.copy(e,0,0,r),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):l(e,t);if("Buffer"===t.type&&s(t.data))return l(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function f(e,t){if(h(t),e=a(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function l(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(n)return W(e).length;t=(""+t).toLowerCase(),n=!0}}function w(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return B(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:g(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):g(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(e,t,r,n,i){var s,o=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=r;s<a;s++)if(u(e,s)===u(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===c)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var f=!0,l=0;l<c;l++)if(u(e,s+l)!==u(t,l)){f=!1;break}if(f)return s}return-1}function m(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function b(e,t,r,n){return F(W(t,e.length-r),e,r,n)}function D(e,t,r,n){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return D(e,t,r,n)}function A(e,t,r,n){return F(j(t),e,r,n)}function _(e,t,r,n){return F(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function B(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,c,u=e[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(s=e[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S));return r}(n)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return u(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,n){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return f(null,e)},c.allocUnsafeSlow=function(e){return f(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):w.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=e.slice(t,r),f=0;f<a;++f)if(u[f]!==h[f]){s=u[f],o=h[f];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return v(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return v(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return D(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function R(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function U(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=q(e[s]);return i}function P(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function C(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function N(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,s){return s||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,s){return s||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||C(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=c.isBuffer(e)?e:W(new c(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function q(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function j(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Y,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(7))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return i}));class n{constructor(){this.listeners=[]}on(e){return this.listeners.push(e),{dispose:()=>this.off(e)}}off(e){let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}emit(e){this.listeners.forEach(t=>t(e))}}class i extends Event{constructor(e,t){super(e),this.device=t.device}}},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return s}));var n=r(2);class i{constructor(e){this._opened=!1,this._claimedInterface=null,this.nodeUsbDevice=e,this.deviceClass=e.deviceDescriptor.bDeviceClass,this.deviceSubclass=e.deviceDescriptor.bDeviceSubClass,this.deviceProtocol=e.deviceDescriptor.bDeviceProtocol,this.vendorId=e.deviceDescriptor.idVendor,this.productId=e.deviceDescriptor.idProduct}get configuration(){return this.configurationTransform(this.nodeUsbDevice.configDescriptor)}get configurations(){return this.nodeUsbDevice.allConfigDescriptors.map(e=>this.configurationTransform(e))}get opened(){return this._opened}open(){try{this.nodeUsbDevice.open(),this._opened=!0}catch(e){return Promise.reject(e)}return Promise.resolve()}close(){try{this.nodeUsbDevice.close()}catch(e){return Promise.reject(e)}return Promise.resolve()}async selectConfiguration(e){return new Promise((t,r)=>{this.nodeUsbDevice.setConfiguration(e,e=>{if(e)return r(e);t()})})}async claimInterface(e){try{const t=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!t)throw new Error("Interface not found");return t.claim(),this._claimedInterface=t,Promise.resolve()}catch(e){return Promise.reject(e)}}releaseInterface(e){return new Promise((t,r)=>{const n=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!n)return r("Interface not found");n.release(e=>{if(e)return r(e);this._claimedInterface=null,t()})})}selectAlternateInterface(e,t){return new Promise((r,n)=>{const i=this.nodeUsbDevice.interfaces.find(t=>t.interfaceNumber===e);if(!i)return n("Interface not found");i.setAltSetting(t,e=>{if(e)return n(e);r()})})}controlTransferIn(e,t){return new Promise((r,n)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(e.requestType),e.request,e.value,e.index,t,(e,t)=>e?n(e.message):t?void r({data:new DataView(t),status:"ok"}):n("No buffer returned"))})}controlTransferOut(t,r){return new Promise((n,i)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(t.requestType),t.request,t.value,t.index,r?this.arrayBufferToBuffer(r):e.from(""),(e,t)=>{if(e)return i(e.message);n({bytesWritten:r?r.byteLength:0,status:"ok"})})})}transferIn(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"in"!==i.direction)return n("No endpoint found");i.transfer(t,(e,t)=>{if(e)return n(e.message);r({data:new DataView(t.buffer,0,t.length),status:"ok"})})})}transferOut(e,t){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(e);if(!i||"out"!==i.direction)return n("No endpoint found");i.transfer(this.arrayBufferToBuffer(t),e=>{if(e)return n(e.message);r({bytesWritten:t?t.byteLength:0,status:"ok"})})})}reset(){return new Promise((e,t)=>{this.nodeUsbDevice.reset(r=>{if(r)return void 0!==navigator.usb&&navigator.usb.dispatchEvent(new n.b("disconnect",{device:this.asWebUSBDevice()})),t(r);e()})})}asWebUSBDevice(){return this}configurationTransform(e){const t=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{configurationValue:e.bConfigurationValue,configurationName:"",interfaces:t.map(t=>this.interfaceTransform(e,t))}}interfaceTransform(e,t){const r=e.interfaces.reduce((e,t)=>e.concat(t),[]);return{interfaceNumber:t.bInterfaceNumber,alternate:this.interfaceAltTransform(t,this.nodeUsbDevice.interface(t.bInterfaceNumber)),alternates:r.map(e=>this.interfaceAltTransform(t,this.nodeUsbDevice.interface(e.bInterfaceNumber)))}}interfaceAltTransform(e,t){return{alternateSetting:e.bAlternateSetting,interfaceClass:e.bInterfaceClass,interfaceSubclass:e.bInterfaceSubClass,interfaceProtocol:e.bInterfaceProtocol,interfaceName:"",endpoints:t.endpoints.map(e=>this.endpointTransform(e))}}endpointTransform(e){return{endpointNumber:e.descriptor.bEndpointAddress,direction:e.direction,type:this.endpointTypeTransform(e.transferType),packetSize:e.descriptor.wMaxPacketSize}}endpointTypeTransform(e){if(void 0===window.node_usb)throw new Error("Node-USB not found");switch(e){case window.node_usb.LIBUSB_TRANSFER_TYPE_BULK:return"bulk";case window.node_usb.LIBUSB_TRANSFER_TYPE_INTERRUPT:return"interrupt";case window.node_usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:return"isochronous"}}requestTypeTransform(e){if(void 0===window.node_usb)throw new Error("Node-USB not found");switch(e){case"standard":return window.node_usb.LIBUSB_REQUEST_TYPE_STANDARD;case"class":return window.node_usb.LIBUSB_REQUEST_TYPE_CLASS;case"vendor":return window.node_usb.LIBUSB_REQUEST_TYPE_VENDOR}}arrayBufferToBuffer(t){return t instanceof ArrayBuffer?e.from(t):e.from("")}}function s(e){return new i(e)}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";(function(e){r.d(t,"a",(function(){return d}));var n=r(0),i=r(6),s=r(5);const o=64,a=500,c=200,u=1,h=e=>12===e[0]&&0!==e[7],f=()=>new Promise(e=>setTimeout(()=>{e()},c));class l{constructor(e){const t=new Uint8Array(e.buffer);this.commCommandBufferStatus=t[11],this.dataOutBufferStatus=t[12],this.dataInBufferStatus=t[13],this.detectKey=165===t[16],this.data=t.slice(16,t.length)}}class d{constructor(e,t=(e=>{})){this.mutex=new s.Mutex,this.searching=!1,this.usbDevice=e,this.onDetectKeys=t;const r=this.usbDevice.configurations[0].interfaces[0].alternates[u];this.interrupt=r.endpoints[0],this.bulkIn=r.endpoints[1],this.bulkOut=r.endpoints[2]}async claim(){const e=this.usbDevice.configurations[0],t=e.interfaces[0];try{void 0!==this.usbDevice.configuration&&this.usbDevice.configuration.configurationValue===e.configurationValue||await this.usbDevice.selectConfiguration(e.configurationValue),await this.usbDevice.claimInterface(t.interfaceNumber),await this.usbDevice.selectAlternateInterface(t.interfaceNumber,t.alternates[u].alternateSetting),await this.deviceReset()}catch(e){throw new Error("1-Wire Device interface cannot be claimed.")}return!0}async startSearch(){this.searching||(this.searching=!0,this.awaitKey())}async close(){this.searching=!1;let e=await this.mutex.acquire();try{this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]&&await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(e){console.log("Close: "+e)}e()}awaitKey(){setTimeout(async()=>{if(this.searching){let e=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(e){console.log("Await: "+e)}e(),this.awaitKey()}},a)}async keySearch(){let e=[];try{let t=await this.romSearch();if(t.result){for(h(t.key)&&e.push(t.key);t.result&&!t.lastDevice;)(t=await t.next()).result&&h(t.key)&&e.push(t.key);this.onDetectKeys(e)}}catch(e){await this.deviceReset()}}async deviceStatus(){let e=await this.usbDevice.transferIn(this.interrupt.endpointNumber,32);if(!e.data)throw new Error("1-Wire Device status read error.");return new l(e.data)}async bufferClear(){0!==(await this.deviceStatus()).commCommandBufferStatus&&await this.bufferClear()}async setSpeed(e){const t=e?2:1;if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:2,value:2,index:t})).status)throw new Error("1-Wire Device set speed failed.")}async reset(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:3147,index:1})).status)throw new Error("1-Wire Device reset request failed.");await this.bufferClear()}async deviceReset(){if(await this.usbDevice.reset(),"ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:0,value:0,index:0})).status)throw new Error("1-Wire Device reset failed.");await this.bufferClear()}async write(e,t=!1){try{if("ok"!==(await this.usbDevice.transferOut(this.bulkIn.endpointNumber,e.buffer)).status)throw new Error;if(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:4213,index:e.length}),t){let t=0;do{t+=(await this.read(e.length-t)).length}while(t<e.length)}}catch(e){throw new Error("1-Wire Device write failed.")}}async writeBit(e){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:545|e<<3,index:0})).status)throw new Error("1-Wire Device write bit failed.")}async read(e){let t=this.usbDevice.transferIn(this.bulkOut.endpointNumber,e),r=new Promise((e,t)=>setTimeout(()=>t(),c));try{let e=await Promise.race([t,r]);if("ok"!==e.status||!e.data)throw new Error;return new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength)}catch(e){throw new Error("1-Wire Device read failed.")}}async readBit(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:41,index:0})).status)throw new Error("1-Wire Device read bit transfer failed.");return(await this.read(1))[0]}async clearByte(){await this.read(1)}async romCommand(e=null,t=!1){let r=e?t?105:85:t?60:204,n=e?e.buffer:new Uint8Array(8).buffer,i=await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:101,index:r});if("ok"!==i.status)throw new Error("1-Wire Device rom transfer failed.");await this.setSpeed(t),i=await this.usbDevice.transferOut(this.bulkIn.endpointNumber,n)}async romMatch(e,t=!1){return this.romCommand(e,t)}async romSearch(e=0){await this.setSpeed(!1),await this.reset(),await this.write(new Uint8Array([240]),!0);let t=await this.romSubSearch({idBitNumber:1,lastZero:0,romByteNumber:0,romByteMask:1,searchResult:!1,idBit:0,cmpIdBit:0,searchDirection:0,romId:new Uint8Array(8),lastDevice:!1,lastDiscrepancy:e});return{result:t.searchResult,key:t.romId,lastDevice:t.lastDevice,next:async()=>this.romSearch(t.lastDiscrepancy)}}async romSubSearch(t){return t.idBit=await this.readBit(),t.cmpIdBit=await this.readBit(),1!==t.idBit||1!==t.cmpIdBit?(t.idBit!==t.cmpIdBit?t.searchDirection=t.idBit:(t.idBitNumber<t.lastDiscrepancy?t.searchDirection=(t.romId[t.romByteNumber]&t.romByteMask)>0?1:0:t.searchDirection=t.idBitNumber===t.lastDiscrepancy?1:0,0===t.searchDirection&&(t.lastZero=t.idBitNumber)),1===t.searchDirection?t.romId[t.romByteNumber]|=t.romByteMask:t.romId[t.romByteNumber]&=~t.romByteMask,await this.writeBit(t.searchDirection),t.idBitNumber++,t.romByteMask<<=1,t.romByteMask>=256&&(t.romByteNumber++,t.romByteMask=1),t.romByteNumber<8?this.romSubSearch(t):(t.idBitNumber>=65&&0===Object(i.a)(e.from(t.romId))&&(t.lastDiscrepancy=t.lastZero,0===t.lastDiscrepancy&&(t.lastDevice=!0),t.searchResult=!0),!1!==t.searchResult&&0!==t.romId[0]||(t.lastDiscrepancy=0,t.lastDevice=!0,t.searchResult=!1),t)):t}async keyWrite(e,t=0,r=new Uint8Array(0),n=!1){const i=255&t,s=(65280&t)>>8,a=r.length-1;console.log("Starting Write");const c=async(e,t=0,r=new Uint8Array(0),n=!1)=>{console.log(`Write: ${t} - ${r.byteLength}`);const a=async(e,t=0)=>{const r=Math.min(o,e.length-t),n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=e[t+i];await this.write(n),e.length-(t+r)>0&&await a(e,t+r)};await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(r),await this.reset(),await this.romMatch(e,n);const h=new Uint8Array([170]);await this.write(h);const f=await this.read(r.length);await this.clearByte(),f.length===r.length&&f.every((e,t)=>e===r[t])||await c(e,t,r,n)};await this.setSpeed(!1),await c(e,t,r,n),await this.reset(),await this.romMatch(e,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!0)}async keyWriteAll(e,t=[],r=!1){const i=async(e,t=0,r=[],n=!1)=>{const s=32*t;await this.keyWrite(e,s,r[t],n),r.length>t+1&&await i(e,t+1,r,n)},s=await this.mutex.acquire(),o=performance.now();try{await this.deviceReset(),await i(e,0,t,r),n.a.info("Write All Completed: "+Math.round(performance.now()-o)+"ms")}finally{s()}}async keyWriteDiff(e,t=[],r=[],i=!1){const s=async(e,t=0,r=[],n=[],i=!1)=>{const o=32*t;r[t].length===n[t].length&&r[t].every((e,r)=>e===n[t][r])||await this.keyWrite(e,o,r[t],i),r.length>t+1&&await s(e,t+1,r,n,i)};if(r.length!==t.length)throw new Error("Cannot perform diff on provided data");const o=await this.mutex.acquire(),a=performance.now();try{await this.deviceReset(),await s(e,0,t,r,i),n.a.info("Write Diff Completed: "+Math.round(performance.now()-a)+"ms")}finally{o()}}async keyReadAll(e,t=!1){const r=async(e,t=0)=>{const n=Math.min(o,e.length-t);(await this.read(n)).forEach(r=>e[t++]=r),t<e.length&&await r(e,t)},i=async(e=new Array(256),t=0)=>{e[t]=new Uint8Array(32);let n=new Uint8Array(32).fill(255);return await this.write(n),await r(e[t++]),t<e.length&&await i(e,t),e},s=async t=>{await this.setSpeed(!1),await this.reset(),await this.romMatch(e,t);const r=new Uint8Array([240,0,0]);return await this.write(r,!0),i()},a=await this.mutex.acquire(),c=performance.now();try{try{return await this.deviceReset(),await s(t)}catch(e){return n.a.warn("Read All "+(t?"Overdrive ":"")+"Failed: "+e.message),await this.deviceReset(),await s(!1)}}catch(e){n.a.error("Read All Failed: "+e.message),await this.deviceReset()}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(11);t.Mutex=n.default},function(e,t,r){"use strict";var n=r(1);var i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:e=>new n.Buffer(e);let s=[0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,157,195,33,127,252,162,64,30,95,1,227,189,62,96,130,220,35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,87,9,235,181,54,104,138,212,149,203,41,119,244,170,72,22,233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));const o=function(e,t){const r=(e,r)=>t(e,r)>>>0;return r.signed=t,r.unsigned=r,r.model=e,r}("dallas-1-wire",(function(e,t){n.Buffer.isBuffer(e)||(e=i(e));let r=~~t;for(let t=0;t<e.length;t++){const n=e[t];r=255&s[255&(r^n)]}return r}));t.a=o},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=u(e),n=r[0],o=r[1],a=new s(function(e,t,r){return 3*(t+r)/4-r}(0,n,o)),c=0,h=o>0?n-4:n,f=0;f<h;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===o&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,a[c++]=255&t);1===o&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(h(e,o,o+16383>a?a:o+16383));1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],i[o.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function h(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,d=e[t+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+e[t+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,w=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(t*c-1)*Math.pow(2,i),o+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*w}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._queue=[],this._pending=!1}return e.prototype.isLocked=function(){return this._pending},e.prototype.acquire=function(){var e=this,t=new Promise((function(t){return e._queue.push(t)}));return this._pending||this._dispatchNext(),t},e.prototype.runExclusive=function(e){return this.acquire().then((function(t){var r;try{r=e()}catch(e){throw t(),e}return Promise.resolve(r).then((function(e){return t(),e}),(function(e){throw t(),e}))}))},e.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},e}();t.default=n},function(e,t,r){"use strict";r.r(t);var n=r(3);class i{constructor(e,t){if(this.connectedDevices=[],this.vendorId=e,this.productId=t,void 0===navigator.usb){if(void 0===window.node_usb)throw new Error("Web-USB not supported in this browser")}else navigator.usb.addEventListener("connect",e=>{this.attached(e)}),navigator.usb.addEventListener("disconnect",e=>{this.detached(e)});this.checkDevices()}get isConnected(){return this.connectedDevices.length>0}async start(){await this.requestPermission()}async requestPermission(){if(this.checkNodeDevices())return;if(void 0===navigator.usb)throw new Error("Web-USB not supported in this browser");let e;try{e=await navigator.usb.requestDevice({filters:[{vendorId:this.vendorId,productId:this.productId}]})}catch(e){throw new Error("USB Device permission denied.")}e&&await this.connected(e)}async checkDevices(){if(this.checkNodeDevices())return;if(void 0===navigator.usb)throw new Error("Web-USB not supported in this browser");let e=await navigator.usb.getDevices();for(let t of e)this.matchesTarget(t)&&await this.connected(t)}async checkNodeDevices(){if(void 0===window.node_usb)return!1;let e;try{e=window.node_usb.findByIds(this.vendorId,this.productId)}catch(e){return!1}if(e){const t=Object(n.a)(e);return await this.connected(t),!0}return!1}async attached(e){e.device&&this.matchesTarget(e.device)&&await this.connected(e.device)}async detached(e){e.device&&this.matchesTarget(e.device)&&this.isConnectedDevices(e.device)&&await this.disconnected(e.device)}async connected(e){if(this.isConnectedDevices(e))throw new Error("USB Device already connected.");try{await e.open(),this.connectedDevices.push(e)}catch(e){throw new Error("USB Device cannot be opened.\n[Check driver installation.]")}}async disconnected(e){let t=this.connectedDevices.indexOf(e);if(t>=0){try{await e.close()}catch(e){}this.connectedDevices.splice(t,1)}}matchesTarget(e){return e.vendorId===this.vendorId&&e.productId===this.productId}isConnectedDevices(e){return this.connectedDevices.indexOf(e)>=0}}var s,o,a,c=r(0),u=r(2);class h{constructor(e){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new u.a,this.onDisconnectListener=e(()=>this.disconnected())}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}disconnected(){this.onDisconnectEvent.emit(null),this.dispose()}dispose(){this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0}}function f(e=[]){let t={machineData:{},rawData:e,validStructure:!1};if(0===e.length||!w(e))return t;for(let r=1;r<=8;r++)for(let n=0;n<3;n++){let i=32*r-2,s=10*n;if(1===e[i][s]){let r=A(e[i][s+1],e[i][s+2]);t.machineData[r]={position:{chest:g(e[i][s+3]),rom2:g(e[i][s+4]),rom1:g(e[i][s+5]),seat:g(e[i][s+6])},sets:[]};let n=e[i][s+7];l(e,t.machineData[r],n)}}return t.validStructure=!0,t}!function(e){e.dec="dec",e.int="int"}(s||(s={})),function(e){e.lb="lb",e.kg="kg",e.ne="ne",e.er="er"}(o||(o={})),function(e){e.power6r="power6r",e.a4206r="a4206r",e.a42010r="a42010r"}(a||(a={}));const l=(e,t,r)=>{let n=r%30,i=e[32*Math.floor(r/32)+31][n],c=e[r],u=_(c[7],c[8]),h={version:A(c[12],c[11],c[10],c[9]),serial:"",time:T(c[0],c[1],c[2],c[3]).toISOString(),resistance:_(c[4],c[5]),precision:s.int,units:o.lb,repetitions:c[6],peak:null,work:null,distance:null,seat:g(c[26]),rom2:g(c[27]),rom1:g(c[28]),chest:g(c[29]),test:null};if(h.serial=I(c[13],c[14],c[15],c[16],c[17],h.version),E(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=s.dec),96&c[17]){case 0:h.units=o.lb;break;case 32:h.units=o.kg;break;case 64:h.units=o.ne;break;case 96:h.units=o.er}if(b(h.version))if(h.repetitions>=252&&h.repetitions<=254){let e={type:a.power6r,low:null,high:null};switch(h.repetitions){case 254:e.type=a.power6r,e.low=O(c,18),e.high=O(c,24),h.repetitions=6;break;case 253:e.type=a.a4206r,h.repetitions=6;break;case 252:e.type=a.a42010r,h.repetitions=10}h.test=e}else D(h.version)&&(h.peak=_(c[20],c[21]),h.work=Math.round(_(c[22],c[23],c[24],c[25])/64*100)/100,12800==(65280&u)&&(h.distance=_(c[18],c[19])));t.sets||(t.sets=[]),t.sets.push(h),30!=(30&i)&&l(e,t,i)};function d(e){let t=P();let r=0,n=0;return Object.keys(e).forEach(i=>{if(r>24&&n>242)throw new Error("Data structure exceeds memory capacity.");const s=e[i],o=parseInt(i,16),a=32*Math.floor(r/3)+30,c=r%3*10;t[a][c]=1;const u=B(o);t[a][c+1]=u[0],t[a][c+2]=u[1],t[a][c+3]=m(s.position.chest),t[a][c+4]=m(s.position.rom2),t[a][c+5]=m(s.position.rom1),t[a][c+6]=m(s.position.seat),t[a][c+7]=n,s.sets.forEach((e,r)=>{let i=32*Math.floor(n/30)+n%30;p(o,e,s.position,t[i]);let a=32*Math.floor(n/30)+31,c=n%30;t[a][c]=r+1<s.sets.length?n+1:254,n++}),r++}),N(t),t}const p=(e,t,r,n)=>{const i=S(new Date(t.time)),o=B(t.resistance*(t.precision===s.dec?10:1));let c=t.repetitions;if(t.test)switch(t.test.type){case a.power6r:c=254;break;case a.a4206r:c=253;break;case a.a42010r:c=252}let u=B(e),h=B(parseInt(t.version,16)),f=R(t.serial),l=U(t.serial,t.version,t.precision,t.units);n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=o[0],n[5]=o[1],n[6]=c,n[7]=u[0],n[8]=u[1],n[9]=h[3],n[10]=h[2],n[11]=h[1],n[12]=h[0],n[13]=f[0],n[14]=f[1],n[15]=f[2],n[16]=f[3],n[17]=l,t.test?k(t.test,n):C(t,n)},w=e=>e.every((e,t)=>~~(t/2)%16==15?v(e):y(e)||v(e)),y=e=>e.every(e=>85===e),v=e=>{let t=0;for(let r of e)for(let e=0;e<8;e++){let e=(r^t)%2;t>>=1,r>>=1,e&&(t^=40961)}return 45057===t},g=e=>255===e?null:e,m=e=>null===e?255:e,b=e=>parseInt(e,16)>795179504,D=e=>parseInt(e,16)>851074185,E=e=>parseInt(e,16)>831409920,A=(...e)=>{let t="";return e.reverse().forEach(e=>t+=("00"+e.toString(16)).substr(-2).toUpperCase()),t},_=(...e)=>{let t=0;return e.forEach((e,r)=>t+=(255&e)<<8*r),t},B=e=>[255&e,(65280&e)>>8,(16711680&e)>>16,(4278190080&e)>>24],T=(...e)=>new Date(1e3*_(...e)),S=e=>B(e.getTime()/1e3),I=(e,t,r,n,i,s)=>{let o=(e=>("00"+(e.getUTCMonth()+1)).substr(-2)+("00"+e.getUTCDate()).substr(-2)+" "+e.getUTCFullYear()+" "+("00"+e.getUTCHours()).substr(-2)+("00"+e.getUTCMinutes()).substr(-2)+" "+("00"+e.getUTCSeconds()).substr(-2))(T(e,t,r,n));return E(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},R=e=>{const t=/(\d{2})(\d{2}) (\d{4}) (\d{2})(\d{2}) (\d{2})/.exec(e);if(null===t||7!==t.length)throw new Error("Invalid serial string.");const r=t.slice(1).map(e=>parseInt(e,10)),n=Date.UTC(r[2],r[0]-1,r[1],r[3],r[4],r[5]);return B(n/1e3)},U=(e,t,r,n)=>{let i=0;switch(i=E(t)?parseInt(e.substr(-2),10)-32:parseInt(e.substr(-2),10),r===s.dec&&(i|=128),n){case o.kg:i|=32;break;case o.ne:i|=64;break;case o.er:i|=96}return i},P=()=>{let e=new Array(256);for(let t=0;t<e.length;t++){e[t]=new Uint8Array(32);for(let r=0;r<e[t].length;r++)t>0&&(t%32==30||t%32==31)?r===e[t].length-1?e[t][r]=207:e[t][r]=255:e[t][r]=85}return e},C=(e,t)=>{const r=B(e.peak||0),n=B(64*(e.work||0)),i=B(e.distance||0);t[18]=i[0],t[19]=i[1],t[20]=r[0],t[21]=r[1],t[22]=n[0],t[23]=n[1],t[24]=n[2],t[25]=n[3],t[26]=m(e.seat),t[27]=m(e.rom2),t[28]=m(e.rom1),t[29]=m(e.chest)},k=(e,t)=>{e.low&&M(e.low,18,t),e.high&&M(e.high,24,t)},O=(e,t)=>({power:e[t]+((31&e[t+2])<<8),velocity:e[t+1]+((224&e[t+2])<<3),force:e[t+3]+((240&e[t+5])<<4),position:e[t+4]+((15&e[t+5])<<8)}),M=(e,t,r)=>{r[t++]=255&e.power,r[t++]=255&e.velocity,r[t++]=((7936&e.power)>>8)+((1792&e.velocity)>>3),r[t++]=255&e.force,r[t++]=255&e.position,r[t++]=((3840&e.position)>>8)+((3840&e.force)>>4)},N=e=>{e.forEach(e=>{if(!y(e)){let t=0;for(let r=0;r<30;r++){let n=e[r];for(let e=0;e<8;e++){let e=(n^t)%2;t>>=1,n>>=1,e&&(t^=40961)}}let r=B(65535^t);e[30]=r[0],e[31]=r[1]}})};class x extends h{constructor(e,t,r){super(r),this.echipId=e,this.owDevice=t,this.data=this.loadData(),c.a.info("EChip connected: "+this.id)}get id(){return this.echipId.reduce((e,t)=>e+=(15&t).toString(16)+(t>>4&15).toString(16),"").split("").reverse().join("")}destroy(){this.disconnected()}async getData(){return this.data}async clearData(){let e=d({});try{let t=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,t,!1)}catch(t){await this.owDevice.keyWriteAll(this.echipId,e,!1)}this.data=new Promise(t=>t(f(e)))}async setData(e){let t=d(e),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,r,!1),this.data=new Promise(e=>e(f(t)))}dispose(){super.dispose(),c.a.info("EChip disconnected: "+this.id)}async loadData(){let e=f(await this.owDevice.keyReadAll(this.echipId,!1));return e.validStructure||c.a.warn("Invalid Data Structure"),e}}var L=r(4);class Y{constructor(e,t){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new u.a,this.onDisconnectEvent=new u.a,this.activeKeys=new Map,this.onDisconnectListener=t(e=>this.disconnected(e)),this.usbDevice=e,this.owDevice=new L.a(e,e=>this.echipsDetected(e)),this.claimed=this.owDevice.claim().then(()=>(c.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(e){return this.onDisconnectEvent.on(e)}onEChipDetect(e){return this.onEChipDetectEvent.on(e)}echipsDetected(e){let t=[];e.forEach(e=>{let r=e.join();if(t.push(r),!this.activeKeys.has(r)){let t=new x(e,this.owDevice,e=>this.onDisconnect(e));this.activeKeys.set(r,t),this.onEChipDetectEvent.emit(t)}}),this.activeKeys.forEach((e,r)=>{t.includes(r)||(e.destroy(),this.activeKeys.delete(r))})}disconnected(e){this.usbDevice===e&&(this.onDisconnectEvent.emit(null),this.dispose())}async dispose(){await this.owDevice.close(),this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0,c.a.info("EChip Reader disconnected.")}}r.d(t,"EChipReaderWatcher",(function(){return j}));const q=1274,W=9360;class j extends i{constructor(){super(q,W),this.onConnectEvent=new u.a,this.onDisconnectEvent=new u.a}async stop(){await Promise.all(this.connectedDevices.map(e=>this.disconnected(e)))}onConnect(e){return this.onConnectEvent.on(e)}onDisconnect(e){return this.onDisconnectEvent.on(e)}async connected(e){await super.connected(e);const t=new Y(e,e=>this.onDisconnect(e));await t.claimed,this.onConnectEvent.emit(t)}async disconnected(e){await super.disconnected(e),this.onDisconnectEvent.emit(e)}}t.default=new j}])}));
var n=r(13),i=r(14),s=r(15);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(e,r),i=(t=a(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|d(e.length);return 0===(t=a(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):l(t,e);if("Buffer"===e.type&&s(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=a(t,e<0?0:0|d(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|d(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function d(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var h=-1;for(s=r;s<a;s++)if(u(t,s)===u(e,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===c)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+c>a&&(r=a-c),s=r;s>=0;s--){for(var f=!0,l=0;l<c;l++)if(u(t,s+l)!==u(e,l)){f=!1;break}if(f)return s}return-1}function g(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function b(t,e,r,n){return W(Y(e,t.length-r),t,r,n)}function E(t,e,r,n){return W(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function D(t,e,r,n){return E(t,e,r,n)}function A(t,e,r,n){return W(F(e),t,r,n)}function B(t,e,r,n){return W(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,c,u=t[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(s=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(h=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=_));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return h(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?T(this,0,t):w.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,i),h=t.slice(e,r),f=0;f<a;++f)if(u[f]!==h[f]){s=u[f],o=h[f];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return D(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function R(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function k(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=j(t[s]);return i}function x(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function U(t,e,r,n,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function O(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function L(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,s){return s||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,s){return s||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||U(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);U(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||U(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=c.isBuffer(t)?t:Y(new c(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function W(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(12))},function(t,e,r){"use strict";r.d(e,"a",(function(){return n})),r.d(e,"b",(function(){return i}));class n{constructor(){this.listeners=[]}on(t){return this.listeners.push(t),{dispose:()=>this.off(t)}}off(t){let e=this.listeners.indexOf(t);e>-1&&this.listeners.splice(e,1)}emit(t){this.listeners.forEach(e=>e(t))}}class i extends Event{constructor(t,e){super(t),this.device=e.device}}},function(t,e,r){"use strict";r.d(e,"a",(function(){return n}));class n extends Error{constructor(t="Operation cancelled"){super(t),this.message=t}}},function(t,e,r){"use strict";var n=r(0);class i{constructor(t){this.onCancel=new n.c,this.token=new s(this.onCancel.addListener),t&&(this.parentListener=t.onCancellationRequested(()=>this.cancel()))}cancel(){this.parentListener&&(this.parentListener.dispose(),this.parentListener=void 0),this.onCancel.hasEmitted||this.onCancel.emit()}}class s{constructor(t){this.onCancellationRequested=t,this.isRequested=!1,n.a.once(t,()=>this.isRequested=!0)}get isCancellationRequested(){return this.isRequested}cancellation(t){return n.a.toPromise(this.onCancellationRequested,t)}}s.None=new s(()=>n.d),s.Cancelled=new s(t=>(t(void 0),n.d));var o=r(4);r.d(e,"b",(function(){return a})),r.d(e,"a",(function(){return u}));var a,c=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};!function(t){t.Cooperative="optimistic",t.Aggressive="aggressive"}(a||(a={}));class u{constructor(t,e){this.duration=t,this.strategy=e,this.timeoutEmitter=new n.b,this.onTimeout=this.timeoutEmitter.addListener}execute(t){return c(this,void 0,void 0,(function*(){const e=new i,r=setTimeout(()=>e.cancel(),this.duration);try{return this.strategy===a.Cooperative?yield t({cancellation:e.token}):Promise.race([t({cancellation:e.token}),e.token.cancellation(e.token).then(()=>{throw new o.a(`Operation timed out after ${this.duration}ms`)})])}finally{e.cancel(),clearTimeout(r)}}))}}},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return s}));var n=r(3);class i{constructor(t){this._opened=!1,this._claimedInterface=null,this.nodeUsbDevice=t,this.deviceClass=t.deviceDescriptor.bDeviceClass,this.deviceSubclass=t.deviceDescriptor.bDeviceSubClass,this.deviceProtocol=t.deviceDescriptor.bDeviceProtocol,this.vendorId=t.deviceDescriptor.idVendor,this.productId=t.deviceDescriptor.idProduct}get configuration(){return this.configurationTransform(this.nodeUsbDevice.configDescriptor)}get configurations(){return this.nodeUsbDevice.allConfigDescriptors.map(t=>this.configurationTransform(t))}get opened(){return this._opened}open(){try{this.nodeUsbDevice.open(),this._opened=!0}catch(t){return Promise.reject(t)}return Promise.resolve()}close(){try{this.nodeUsbDevice.close()}catch(t){return Promise.reject(t)}return Promise.resolve()}async selectConfiguration(t){return new Promise((e,r)=>{this.nodeUsbDevice.setConfiguration(t,t=>{if(t)return r(t);e()})})}async claimInterface(t){try{const e=this.nodeUsbDevice.interfaces.find(e=>e.interfaceNumber===t);if(!e)throw new Error("Interface not found");return e.claim(),this._claimedInterface=e,Promise.resolve()}catch(t){return Promise.reject(t)}}releaseInterface(t){return new Promise((e,r)=>{const n=this.nodeUsbDevice.interfaces.find(e=>e.interfaceNumber===t);if(!n)return r("Interface not found");n.release(t=>{if(t)return r(t);this._claimedInterface=null,e()})})}selectAlternateInterface(t,e){return new Promise((r,n)=>{const i=this.nodeUsbDevice.interfaces.find(e=>e.interfaceNumber===t);if(!i)return n("Interface not found");i.setAltSetting(e,t=>{if(t)return n(t);r()})})}controlTransferIn(t,e){return new Promise((r,n)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(t.requestType),t.request,t.value,t.index,e,(t,e)=>t?n(t.message):e?void r({data:new DataView(e),status:"ok"}):n("No buffer returned"))})}controlTransferOut(e,r){return new Promise((n,i)=>{this.nodeUsbDevice.controlTransfer(this.requestTypeTransform(e.requestType),e.request,e.value,e.index,r?this.arrayBufferToBuffer(r):t.from(""),(t,e)=>{if(t)return i(t.message);n({bytesWritten:r?r.byteLength:0,status:"ok"})})})}transferIn(t,e){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(t);if(!i||"in"!==i.direction)return n("No endpoint found");i.transfer(e,(t,e)=>{if(t)return n(t.message);r({data:new DataView(e.buffer,0,e.length),status:"ok"})})})}transferOut(t,e){return new Promise((r,n)=>{if(!this._claimedInterface)return n("No interface claimed");const i=this._claimedInterface.endpoint(t);if(!i||"out"!==i.direction)return n("No endpoint found");i.transfer(this.arrayBufferToBuffer(e),t=>{if(t)return n(t.message);r({bytesWritten:e?e.byteLength:0,status:"ok"})})})}reset(){return new Promise((t,e)=>{this.nodeUsbDevice.reset(r=>{if(r)return void 0!==navigator.usb&&navigator.usb.dispatchEvent(new n.b("disconnect",{device:this.asWebUSBDevice()})),e(r);t()})})}asWebUSBDevice(){return this}configurationTransform(t){const e=t.interfaces.reduce((t,e)=>t.concat(e),[]);return{configurationValue:t.bConfigurationValue,configurationName:"",interfaces:e.map(e=>this.interfaceTransform(t,e))}}interfaceTransform(t,e){const r=t.interfaces.reduce((t,e)=>t.concat(e),[]);return{interfaceNumber:e.bInterfaceNumber,alternate:this.interfaceAltTransform(e,this.nodeUsbDevice.interface(e.bInterfaceNumber)),alternates:r.map(t=>this.interfaceAltTransform(e,this.nodeUsbDevice.interface(t.bInterfaceNumber)))}}interfaceAltTransform(t,e){return{alternateSetting:t.bAlternateSetting,interfaceClass:t.bInterfaceClass,interfaceSubclass:t.bInterfaceSubClass,interfaceProtocol:t.bInterfaceProtocol,interfaceName:"",endpoints:e.endpoints.map(t=>this.endpointTransform(t))}}endpointTransform(t){return{endpointNumber:t.descriptor.bEndpointAddress,direction:t.direction,type:this.endpointTypeTransform(t.transferType),packetSize:t.descriptor.wMaxPacketSize}}endpointTypeTransform(t){if(void 0===window.node_usb)throw new Error("Node-USB not found");switch(t){case window.node_usb.LIBUSB_TRANSFER_TYPE_BULK:return"bulk";case window.node_usb.LIBUSB_TRANSFER_TYPE_INTERRUPT:return"interrupt";case window.node_usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:return"isochronous"}}requestTypeTransform(t){if(void 0===window.node_usb)throw new Error("Node-USB not found");switch(t){case"standard":return window.node_usb.LIBUSB_REQUEST_TYPE_STANDARD;case"class":return window.node_usb.LIBUSB_REQUEST_TYPE_CLASS;case"vendor":return window.node_usb.LIBUSB_REQUEST_TYPE_VENDOR}}arrayBufferToBuffer(e){return e instanceof ArrayBuffer?t.from(e):t.from("")}}function s(t){return new i(t)}}).call(this,r(2).Buffer)},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return v}));var n=r(1),i=r(9),s=r(8),o=r(10),a=r(5),c=r(4);const u=64,h=500,f=200,l=1,d=t=>12===t[0]&&0!==t[7],p=o.a.timeout(f,a.b.Cooperative),w=o.a.handleType(c.a).retry().attempts(3);class y{constructor(t){const e=new Uint8Array(t.buffer);this.commCommandBufferStatus=e[11],this.dataOutBufferStatus=e[12],this.dataInBufferStatus=e[13],this.detectKey=165===e[16],this.data=e.slice(16,e.length)}}class v{constructor(t,e=(t=>{})){this.mutex=new s.Mutex,this.searching=!1,this.usbDevice=t,this.onDetectKeys=e;const r=this.usbDevice.configurations[0].interfaces[0].alternates[l];this.interrupt=r.endpoints[0],this.bulkIn=r.endpoints[1],this.bulkOut=r.endpoints[2]}async claim(){const t=this.usbDevice.configurations[0],e=t.interfaces[0];try{void 0!==this.usbDevice.configuration&&this.usbDevice.configuration.configurationValue===t.configurationValue||await this.usbDevice.selectConfiguration(t.configurationValue),await this.usbDevice.claimInterface(e.interfaceNumber),await this.usbDevice.selectAlternateInterface(e.interfaceNumber,e.alternates[l].alternateSetting),await this.deviceReset()}catch(t){throw new Error("1-Wire Device interface cannot be claimed.")}return!0}async startSearch(){this.searching||(this.searching=!0,this.awaitKey())}async close(){this.searching=!1;let t=await this.mutex.acquire();try{this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]&&await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(t){console.warn(`Close Error: ${t}`)}t()}async awaitKey(){if(!this.searching)return;let t=await this.mutex.acquire();try{await p.execute(async()=>this.keySearch())}catch(t){console.warn(`Await Key Error: ${t}`),await this.deviceReset()}t(),setTimeout(async()=>void this.awaitKey(),h)}async keySearch(){let t=[];try{let e=await this.romSearch();if(e.result){for(d(e.key)&&t.push(e.key);e.result&&!e.lastDevice;)(e=await e.next()).result&&d(e.key)&&t.push(e.key);this.onDetectKeys(t)}}catch(t){await this.deviceReset()}}async deviceStatus(){let t=await this.usbDevice.transferIn(this.interrupt.endpointNumber,32);if(!t.data)throw new Error("1-Wire Device status read error.");return new y(t.data)}async bufferClear(){0!==(await this.deviceStatus()).commCommandBufferStatus&&await this.bufferClear()}async setSpeed(t){const e=t?2:1;if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:2,value:2,index:e})).status)throw new Error("1-Wire Device set speed failed.")}async reset(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:3147,index:1})).status)throw new Error("1-Wire Device reset request failed.");await this.bufferClear()}async deviceReset(){await w.execute(async()=>{if(await this.usbDevice.reset(),"ok"!==(await p.execute(async()=>this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:0,value:0,index:0}))).status)throw new Error("1-Wire Device reset failed.");await this.bufferClear()})}async write(t,e=!1){try{if("ok"!==(await this.usbDevice.transferOut(this.bulkIn.endpointNumber,t.buffer)).status)throw new Error;if(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:4213,index:t.length}),e){let e=0;do{e+=(await this.read(t.length-e)).length}while(e<t.length)}}catch(t){throw new Error("1-Wire Device write failed.")}}async writeBit(t){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:545|t<<3,index:0})).status)throw new Error("1-Wire Device write bit failed.")}async read(t){let e=this.usbDevice.transferIn(this.bulkOut.endpointNumber,t),r=new Promise((t,e)=>setTimeout(()=>e(),f));try{let t=await Promise.race([e,r]);if("ok"!==t.status||!t.data)throw new Error;return new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength)}catch(t){throw new Error("1-Wire Device read failed.")}}async readBit(){if("ok"!==(await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:41,index:0})).status)throw new Error("1-Wire Device read bit transfer failed.");return(await this.read(1))[0]}async clearByte(){await this.read(1)}async romCommand(t=null,e=!1){let r=t?e?105:85:e?60:204,n=t?t.buffer:new Uint8Array(8).buffer,i=await this.usbDevice.controlTransferOut({requestType:"vendor",recipient:"device",request:1,value:101,index:r});if("ok"!==i.status)throw new Error("1-Wire Device rom transfer failed.");await this.setSpeed(e),i=await this.usbDevice.transferOut(this.bulkIn.endpointNumber,n)}async romMatch(t,e=!1){return this.romCommand(t,e)}async romSearch(t=0){await this.setSpeed(!1),await this.reset(),await this.write(new Uint8Array([240]),!0);let e=await this.romSubSearch({idBitNumber:1,lastZero:0,romByteNumber:0,romByteMask:1,searchResult:!1,idBit:0,cmpIdBit:0,searchDirection:0,romId:new Uint8Array(8),lastDevice:!1,lastDiscrepancy:t});return{result:e.searchResult,key:e.romId,lastDevice:e.lastDevice,next:async()=>this.romSearch(e.lastDiscrepancy)}}async romSubSearch(e){return e.idBit=await this.readBit(),e.cmpIdBit=await this.readBit(),1!==e.idBit||1!==e.cmpIdBit?(e.idBit!==e.cmpIdBit?e.searchDirection=e.idBit:(e.idBitNumber<e.lastDiscrepancy?e.searchDirection=(e.romId[e.romByteNumber]&e.romByteMask)>0?1:0:e.searchDirection=e.idBitNumber===e.lastDiscrepancy?1:0,0===e.searchDirection&&(e.lastZero=e.idBitNumber)),1===e.searchDirection?e.romId[e.romByteNumber]|=e.romByteMask:e.romId[e.romByteNumber]&=~e.romByteMask,await this.writeBit(e.searchDirection),e.idBitNumber++,e.romByteMask<<=1,e.romByteMask>=256&&(e.romByteNumber++,e.romByteMask=1),e.romByteNumber<8?this.romSubSearch(e):(e.idBitNumber>=65&&0===Object(i.a)(t.from(e.romId))&&(e.lastDiscrepancy=e.lastZero,0===e.lastDiscrepancy&&(e.lastDevice=!0),e.searchResult=!0),!1!==e.searchResult&&0!==e.romId[0]||(e.lastDiscrepancy=0,e.lastDevice=!0,e.searchResult=!1),e)):e}async keyWrite(t,e=0,r=new Uint8Array(0),n=!1){const i=255&e,s=(65280&e)>>8,o=r.length-1,a=async(t,e=0,r=new Uint8Array(0),n=!1)=>{const o=async(t,e=0)=>{const r=Math.min(u,t.length-e),n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t[e+i];await this.write(n),t.length-(e+r)>0&&await o(t,e+r)};await this.reset(),await this.romMatch(t,n);const c=new Uint8Array([15,i,s]);await this.write(c,!0),await o(r),await this.reset(),await this.romMatch(t,n);const h=new Uint8Array([170]);await this.write(h);const f=await this.read(r.length);await this.clearByte(),f.length===r.length&&f.every((t,e)=>t===r[e])||await a(t,e,r,n)};await this.setSpeed(n),await a(t,e,r,n),await this.reset(),await this.romMatch(t,n);const c=new Uint8Array([85,i,s,o]);await this.write(c,!0)}async keyWriteAll(t,e=[],r=!1){const i=async(t,e=0,r=[],n=!1)=>{const s=32*e;await this.keyWrite(t,s,r[e],n),r.length>e+1&&await i(t,e+1,r,n)},s=await this.mutex.acquire(),o=performance.now();try{await this.deviceReset(),await i(t,0,e,r),n.a.info("Write All Completed: "+Math.round(performance.now()-o)+"ms")}finally{s()}}async keyWriteDiff(t,e=[],r=[],i=!1){const s=async(t,e=0,r=[],n=[],i=!1)=>{const o=32*e;r[e].length===n[e].length&&r[e].every((t,r)=>t===n[e][r])||await this.keyWrite(t,o,r[e],i),r.length>e+1&&await s(t,e+1,r,n,i)};if(r.length!==e.length)throw new Error("Cannot perform diff on provided data");const o=await this.mutex.acquire(),a=performance.now();try{await this.deviceReset(),await s(t,0,e,r,i),n.a.info("Write Diff Completed: "+Math.round(performance.now()-a)+"ms")}finally{o()}}async keyReadAll(t,e=!1){const r=async(t,e=0)=>{const n=Math.min(u,t.length-e);(await this.read(n)).forEach(r=>t[e++]=r),e<t.length&&await r(t,e)},i=async(t=new Array(256),e=0)=>{t[e]=new Uint8Array(32);let n=new Uint8Array(32).fill(255);return await this.write(n),await r(t[e++]),e<t.length&&await i(t,e),t},s=async e=>{await this.setSpeed(e),await this.reset(),await this.romMatch(t,e);const r=new Uint8Array([240,0,0]);return await this.write(r,!0),i()},o=await this.mutex.acquire(),a=performance.now();try{try{return await this.deviceReset(),await s(e)}catch(t){return n.a.warn("Read All "+(e?"Overdrive ":"")+"Failed: "+t.message),await this.deviceReset(),await s(!1)}}catch(t){n.a.error("Read All Failed: "+t.message),await this.deviceReset()}finally{o(),n.a.info("Read All Completed: "+Math.round(performance.now()-a)+"ms")}}}}).call(this,r(2).Buffer)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(16);e.Mutex=n.default},function(t,e,r){"use strict";var n=r(2);var i=n.Buffer.from&&n.Buffer.alloc&&n.Buffer.allocUnsafe&&n.Buffer.allocUnsafeSlow?n.Buffer.from:t=>new n.Buffer(t);let s=[0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,157,195,33,127,252,162,64,30,95,1,227,189,62,96,130,220,35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,87,9,235,181,54,104,138,212,149,203,41,119,244,170,72,22,233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));const o=function(t,e){const r=(t,r)=>e(t,r)>>>0;return r.signed=e,r.unsigned=r,r.model=t,r}("dallas-1-wire",(function(t,e){n.Buffer.isBuffer(t)||(t=i(t));let r=~~e;for(let e=0;e<t.length;e++){const n=t[e];r=255&s[255&(r^n)]}return r}));e.a=o},function(t,e,r){"use strict";const n=()=>{let t,e;const r=new Promise((r,n)=>{t=r,e=n});return{resolve:t,reject:e,promise:r}};var i=r(0);class s extends Error{constructor(t,e){super(`Bulkhead capacity exceeded (0/${t} execution slots, 0/${e} available)`)}}var o=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};class a{constructor(t,e){this.capacity=t,this.queueCapacity=e,this.active=0,this.queue=[],this.onRejectEmitter=new i.b,this.onReject=this.onRejectEmitter.addListener}get executionSlots(){return this.capacity-this.active}get queueSlots(){return this.queueCapacity-this.queue.length}execute(t){return o(this,void 0,void 0,(function*(){if(this.active<this.capacity){this.active++;try{return yield t()}finally{this.active--,this.dequeue()}}if(this.queue.length<this.queueCapacity){const{resolve:e,reject:r,promise:i}=n();return this.queue.push({fn:t,resolve:e,reject:r}),i}throw this.onRejectEmitter.emit(),new s(this.capacity,this.queueCapacity)}))}dequeue(){const t=this.queue.shift();t&&Promise.resolve().then(()=>this.execute(t.fn)).then(t.resolve).catch(t.reject)}}var c=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};const u=t=>{if("error"in t)throw t.error;return"success"in t?t.success:t.value},h=(t,e,...r)=>c(void 0,void 0,void 0,(function*(){try{const n=yield e(...r);return t.resultFilter(n)?{value:n}:{success:n}}catch(e){if(!t.errorFilter(e))throw e;return{error:e}}}));class f extends Error{constructor(t="Execution prevented because the circuit breaker is open"){super(t)}}class l extends f{constructor(){super("Execution prevented because the circuit breaker is open")}}var d,p=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};!function(t){t[t.Closed=0]="Closed",t[t.Open=1]="Open",t[t.HalfOpen=2]="HalfOpen",t[t.Isolated=3]="Isolated"}(d||(d={}));class w{constructor(t){this.options=t,this.breakEmitter=new i.b,this.resetEmitter=new i.b,this.innerState={value:d.Closed},this.onBreak=this.breakEmitter.addListener,this.onReset=this.resetEmitter.addListener}get state(){return this.innerState.value}get lastFailure(){return this.innerLastFailure}isolate(){this.innerState.value!==d.Isolated&&(this.innerState={value:d.Isolated,counters:0},this.breakEmitter.emit({isolated:!0})),this.innerState.counters++;let t=!1;return{dispose:()=>{t||(t=!0,this.innerState.value!==d.Isolated||--this.innerState.counters||(this.innerState={value:d.Closed},this.resetEmitter.emit()))}}}execute(t){return p(this,void 0,void 0,(function*(){const e=this.innerState;switch(e.value){case d.Closed:const r=yield h(this.options,t);return"success"in r?this.options.breaker.success(e.value):(this.innerLastFailure=r,this.options.breaker.failure(e.value)&&this.open(r)),u(r);case d.HalfOpen:return yield e.test.catch(()=>void 0),this.execute(t);case d.Open:if(Date.now()-e.openedAt<this.options.halfOpenAfter)throw new f;const n=this.halfOpen(t);return this.innerState={value:d.HalfOpen,test:n},n;case d.Isolated:throw new l;default:throw new Error(`Unexpected circuit state ${e}`)}}))}halfOpen(t){return p(this,void 0,void 0,(function*(){try{const e=yield h(this.options,t);return"success"in e?(this.options.breaker.success(d.HalfOpen),this.close()):(this.innerLastFailure=e,this.options.breaker.failure(d.HalfOpen),this.open(e)),u(e)}catch(t){throw this.close(),t}}))}open(t){this.state!==d.Isolated&&this.state!==d.Open&&(this.innerState={value:d.Open,openedAt:Date.now()},this.breakEmitter.emit(t))}close(){this.state===d.HalfOpen&&(this.innerState={value:d.Closed},this.resetEmitter.emit())}}var y=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};class v{constructor(t,e){this.options=t,this.value=e,this.fallbackEmitter=new i.b,this.onFallback=this.fallbackEmitter.addListener}execute(t){return y(this,void 0,void 0,(function*(){const e=yield h(this.options,t);return"success"in e?e.success:(this.fallbackEmitter.emit(e),this.value())}))}}const m={generator:(t,e)=>{const[r,n]=t||[0,0],i=r+Math.random(),s=Math.pow(e.exponent,i)*Math.tanh(Math.sqrt(4*i)),o=Math.max(0,s-n);return[Math.min(o*(1/1.4)*e.initialDelay,e.maxDelay),[r+1,s]]},maxDelay:3e4,maxAttempts:1/0,exponent:2,initialDelay:128};class g{constructor(t){this.attempt=0,this.delay=0,this.options=t?Object.assign(Object.assign({},m),t):m}duration(){return this.delay}next(){if(this.attempt>=this.options.maxAttempts)return;const t=new g(this.options);return[t.delay,t.state]=this.options.generator(this.state,this.options),t.attempt=this.attempt+1,t}}class b{constructor(t,e,r){this.bias=t,this.backoffA=e,this.backoffB=r}duration(){switch(this.bias){case"a":return this.backoffA.duration();case"b":return this.backoffB.duration();case"max":return Math.max(this.backoffB.duration(),this.backoffA.duration());case"min":return Math.min(this.backoffB.duration(),this.backoffA.duration());default:throw new Error(`Unknown bias "${this.bias}" given to CompositeBackoff`)}}next(t){const e=this.backoffA.next(t),r=this.backoffB.next(t);return e&&r&&new b(this.bias,e,r)}}class E{constructor(t,e){this.interval=t,this.limit=e,this.index=0}duration(){return this.interval}next(){if(void 0===this.limit)return this;if(this.index>=this.limit-1)return;const t=new E(this.interval,this.limit);return t.index=this.index+1,t}}new E(0,0);class D{constructor(t,e){this.fn=t,this.state=e,this.current=0}duration(){return this.current}next(t){const e=this.fn(t,this.state);if(void 0===e)return;let r;return"number"==typeof e?(r=new D(this.fn,this.state)).current=e:(r=new D(this.fn,e.state)).current=e.delay,r}}class A{constructor(t,e=0){if(this.durations=t,this.index=e,e>=t.length)throw new RangeError(`IterableBackoff index 0 >= number of durations (${t.length})`)}duration(){return this.durations[this.index]}next(){return this.index<this.durations.length-1?new A(this.durations,this.index+1):void 0}}var B=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};const S=t=>new Promise(e=>setTimeout(e,t));class T{constructor(t){this.options=t,this.onRetryEmitter=new i.b,this.onGiveUpEmitter=new i.b,this.onRetry=this.onRetryEmitter.addListener,this.onGiveUp=this.onGiveUpEmitter.addListener}attempts(t){return this.composeBackoff("a",new E(1,t))}delay(t){return this.composeBackoff("b","number"==typeof t?new E(t):new A(t))}delegate(t){return this.composeBackoff("b",new D(t))}exponential(t){return this.composeBackoff("b",new g(t))}backoff(t){return this.composeBackoff("b",t)}execute(t){return B(this,void 0,void 0,(function*(){let e=this.options.backoff||new E(0,1);for(let r=0;;r++){const n=yield h(this.options,t,{attempt:r});if("success"in n)return n.success;if(!e){if(this.onGiveUpEmitter.emit(n),"error"in n)throw n.error;return n.value}{const t=e.duration(),i=S(t);this.onRetryEmitter.emit(Object.assign(Object.assign({},n),{delay:t})),yield i,e=e.next({attempt:r+1,result:n})}}}))}composeBackoff(t,e){return this.options.backoff&&(e=new b(t,this.options.backoff,e)),this.options=Object.assign(Object.assign({},this.options),{backoff:e}),this}}var _=r(5);r.d(e,"a",(function(){return P}));var R=function(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};const I=(t,e)=>e?r=>r instanceof t&&e(r):e=>e instanceof t,k=()=>!0,x=()=>!1;class P{constructor(t){this.options=t}static wrap(...t){return{execute(e){const r=(n,i)=>i===t.length?e(n):t[i].execute(t=>r(Object.assign(Object.assign({},n),t),i+1));return Promise.resolve(r({},0))}}}static bulkhead(t,e=0){return new a(t,e)}static handleAll(){return new P({errorFilter:k,resultFilter:x})}static handleType(t,e){return new P({errorFilter:I(t,e),resultFilter:x})}static handleWhen(t){return new P({errorFilter:t,resultFilter:x})}static handleResultType(t,e){return new P({errorFilter:x,resultFilter:I(t,e)})}static handleWhenResult(t){return new P({errorFilter:x,resultFilter:t})}static timeout(t,e){return new _.a(t,e)}orType(t,e){const r=I(t,e);return new P(Object.assign(Object.assign({},this.options),{errorFilter:t=>this.options.errorFilter(t)||r(t)}))}orWhen(t){return new P(Object.assign(Object.assign({},this.options),{errorFilter:e=>this.options.errorFilter(e)||t(e)}))}orWhenResult(t){return new P(Object.assign(Object.assign({},this.options),{resultFilter:e=>this.options.resultFilter(e)||t(e)}))}orResultType(t,e){const r=I(t,e);return new P(Object.assign(Object.assign({},this.options),{resultFilter:t=>this.options.resultFilter(t)||r(t)}))}retry(){return new T({errorFilter:this.options.errorFilter,resultFilter:this.options.resultFilter})}circuitBreaker(t,e){return new w(Object.assign(Object.assign({},this.options),{breaker:e,halfOpenAfter:t}))}fallback(t){return new v(this.options,"function"==typeof t?t:()=>t)}}P.noop={execute:t=>R(void 0,void 0,void 0,(function*(){return t(void 0)}))}},,function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){for(var e,r=u(t),n=r[0],o=r[1],a=new s(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),c=0,h=o>0?n-4:n,f=0;f<h;f+=4)e=i[t.charCodeAt(f)]<<18|i[t.charCodeAt(f+1)]<<12|i[t.charCodeAt(f+2)]<<6|i[t.charCodeAt(f+3)],a[c++]=e>>16&255,a[c++]=e>>8&255,a[c++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,a[c++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,a[c++]=e>>8&255,a[c++]=255&e);return a},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=0,a=r-i;o<a;o+=16383)s.push(h(t,o,o+16383>a?a:o+16383));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],i[o.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,s,o=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,d=t[e+f];for(f+=l,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+t[e+f],f+=l,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+t[e+f],f+=l,h-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,r,n,i,s){var o,a,c,u=8*s-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,w=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(o++,c/=2),o+f>=h?(a=0,o=h):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*w}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){this._queue=[],this._pending=!1}return t.prototype.isLocked=function(){return this._pending},t.prototype.acquire=function(){var t=this,e=new Promise((function(e){return t._queue.push(e)}));return this._pending||this._dispatchNext(),e},t.prototype.runExclusive=function(t){return this.acquire().then((function(e){var r;try{r=t()}catch(t){throw e(),t}return Promise.resolve(r).then((function(t){return e(),t}),(function(t){throw e(),t}))}))},t.prototype._dispatchNext=function(){this._queue.length>0?(this._pending=!0,this._queue.shift()(this._dispatchNext.bind(this))):this._pending=!1},t}();e.default=n},function(t,e,r){"use strict";r.r(e);var n=r(6);class i{constructor(t,e){if(this.connectedDevices=[],this.vendorId=t,this.productId=e,void 0===navigator.usb){if(void 0===window.node_usb)throw new Error("Web-USB not supported in this browser")}else navigator.usb.addEventListener("connect",t=>{this.attached(t)}),navigator.usb.addEventListener("disconnect",t=>{this.detached(t)});this.checkDevices()}get isConnected(){return this.connectedDevices.length>0}async start(){await this.requestPermission()}async requestPermission(){if(await this.checkNodeDevices())return;if(void 0===navigator.usb)throw new Error("Web-USB not supported in this browser");let t;try{t=await navigator.usb.requestDevice({filters:[{vendorId:this.vendorId,productId:this.productId}]})}catch(t){throw new Error("USB Device permission denied.")}t&&await this.connected(t)}async checkDevices(){if(await this.checkNodeDevices())return;if(void 0===navigator.usb)throw new Error("Web-USB not supported in this browser");let t=await navigator.usb.getDevices();for(let e of t)this.matchesTarget(e)&&await this.connected(e)}async checkNodeDevices(){if(void 0===window.node_usb)return!1;let t;try{t=window.node_usb.findByIds(this.vendorId,this.productId)}catch(t){return!1}if(t){const e=Object(n.a)(t);return await this.connected(e),!0}return!1}async attached(t){t.device&&this.matchesTarget(t.device)&&await this.connected(t.device)}async detached(t){t.device&&this.matchesTarget(t.device)&&this.isConnectedDevices(t.device)&&await this.disconnected(t.device)}async connected(t){if(this.isConnectedDevices(t))throw new Error("USB Device already connected.");try{await t.open(),this.connectedDevices.push(t)}catch(t){throw new Error("USB Device cannot be opened.\n[Check driver installation.]")}}async disconnected(t){let e=this.connectedDevices.indexOf(t);if(e>=0){try{await t.close()}catch(t){}this.connectedDevices.splice(e,1)}}matchesTarget(t){return t.vendorId===this.vendorId&&t.productId===this.productId}isConnectedDevices(t){return this.connectedDevices.indexOf(t)>=0}}var s,o,a,c=r(1),u=r(3);class h{constructor(t){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new u.a,this.onDisconnectListener=t(()=>this.disconnected())}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}disconnected(){this.onDisconnectEvent.emit(null),this.dispose()}dispose(){this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0}}!function(t){t.dec="dec",t.int="int"}(s||(s={})),function(t){t.lb="lb",t.kg="kg",t.ne="ne",t.er="er"}(o||(o={})),function(t){t.power6r="power6r",t.a4206r="a4206r",t.a42010r="a42010r"}(a||(a={}));const f=(t,e,r)=>{let n=r%30,i=t[32*Math.floor(r/32)+31][n],c=t[r],u=A(c[7],c[8]),h={version:D(c[12],c[11],c[10],c[9]),serial:"",time:S(c[0],c[1],c[2],c[3]).toISOString(),resistance:A(c[4],c[5]),precision:s.int,units:o.lb,repetitions:c[6],peak:null,work:null,distance:null,seat:v(c[26]),rom2:v(c[27]),rom1:v(c[28]),chest:v(c[29]),test:null};if(h.serial=_(c[13],c[14],c[15],c[16],c[17],h.version),E(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=s.dec),96&c[17]){case 0:h.units=o.lb;break;case 32:h.units=o.kg;break;case 64:h.units=o.ne;break;case 96:h.units=o.er}if(g(h.version))if(h.repetitions>=252&&h.repetitions<=254){let t={type:a.power6r,low:null,high:null};switch(h.repetitions){case 254:t.type=a.power6r,t.low=U(c,18),t.high=U(c,24),h.repetitions=6;break;case 253:t.type=a.a4206r,h.repetitions=6;break;case 252:t.type=a.a42010r,h.repetitions=10}h.test=t}else b(h.version)&&(h.peak=A(c[20],c[21]),h.work=Math.round(A(c[22],c[23],c[24],c[25])/64*100)/100,12800==(65280&u)&&(h.distance=A(c[18],c[19])));e.sets||(e.sets=[]),e.sets.push(h),30!=(30&i)&&f(t,e,i)};function l(t){let e=k();let r=0,n=0;return Object.keys(t).forEach(i=>{if(r>24&&n>242)throw new Error("Data structure exceeds memory capacity.");const s=t[i],o=parseInt(i,16),a=32*Math.floor(r/3)+30,c=r%3*10;e[a][c]=1;const u=B(o);e[a][c+1]=u[0],e[a][c+2]=u[1],e[a][c+3]=m(s.position.chest),e[a][c+4]=m(s.position.rom2),e[a][c+5]=m(s.position.rom1),e[a][c+6]=m(s.position.seat),e[a][c+7]=n,s.sets.forEach((t,r)=>{let i=32*Math.floor(n/30)+n%30;d(o,t,s.position,e[i]);let a=32*Math.floor(n/30)+31,c=n%30;e[a][c]=r+1<s.sets.length?n+1:254,n++}),r++}),O(e),e}const d=(t,e,r,n)=>{const i=T(new Date(e.time)),o=B(e.resistance*(e.precision===s.dec?10:1));let c=e.repetitions;if(e.test)switch(e.test.type){case a.power6r:c=254;break;case a.a4206r:c=253;break;case a.a42010r:c=252}let u=B(t),h=B(parseInt(e.version,16)),f=R(e.serial),l=I(e.serial,e.version,e.precision,e.units);n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=o[0],n[5]=o[1],n[6]=c,n[7]=u[0],n[8]=u[1],n[9]=h[3],n[10]=h[2],n[11]=h[1],n[12]=h[0],n[13]=f[0],n[14]=f[1],n[15]=f[2],n[16]=f[3],n[17]=l,e.test?P(e.test,n):x(e,n)},p=t=>t.every((t,e)=>~~(e/2)%16==15?y(t):w(t)||y(t)),w=t=>t.every(t=>85===t),y=t=>{let e=0;for(let r of t)for(let t=0;t<8;t++){let t=(r^e)%2;e>>=1,r>>=1,t&&(e^=40961)}return 45057===e},v=t=>255===t?null:t,m=t=>null===t?255:t,g=t=>parseInt(t,16)>795179504,b=t=>parseInt(t,16)>851074185,E=t=>parseInt(t,16)>831409920,D=(...t)=>{let e="";return t.reverse().forEach(t=>e+=("00"+t.toString(16)).substr(-2).toUpperCase()),e},A=(...t)=>{let e=0;return t.forEach((t,r)=>e+=(255&t)<<8*r),e},B=t=>[255&t,(65280&t)>>8,(16711680&t)>>16,(4278190080&t)>>24],S=(...t)=>new Date(1e3*A(...t)),T=t=>B(t.getTime()/1e3),_=(t,e,r,n,i,s)=>{let o=(t=>("00"+(t.getUTCMonth()+1)).substr(-2)+("00"+t.getUTCDate()).substr(-2)+" "+t.getUTCFullYear()+" "+("00"+t.getUTCHours()).substr(-2)+("00"+t.getUTCMinutes()).substr(-2)+" "+("00"+t.getUTCSeconds()).substr(-2))(S(t,e,r,n));return E(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},R=t=>{const e=/(\d{2})(\d{2}) (\d{4}) (\d{2})(\d{2}) (\d{2})/.exec(t);if(null===e||7!==e.length)throw new Error("Invalid serial string.");const r=e.slice(1).map(t=>parseInt(t,10)),n=Date.UTC(r[2],r[0]-1,r[1],r[3],r[4],r[5]);return B(n/1e3)},I=(t,e,r,n)=>{let i=0;switch(i=E(e)?parseInt(t.substr(-2),10)-32:parseInt(t.substr(-2),10),r===s.dec&&(i|=128),n){case o.kg:i|=32;break;case o.ne:i|=64;break;case o.er:i|=96}return i},k=()=>{let t=new Array(256);for(let e=0;e<t.length;e++){t[e]=new Uint8Array(32);for(let r=0;r<t[e].length;r++)e>0&&(e%32==30||e%32==31)?r===t[e].length-1?t[e][r]=207:t[e][r]=255:t[e][r]=85}return t},x=(t,e)=>{const r=B(t.peak||0),n=B(64*(t.work||0)),i=B(t.distance||0);e[18]=i[0],e[19]=i[1],e[20]=r[0],e[21]=r[1],e[22]=n[0],e[23]=n[1],e[24]=n[2],e[25]=n[3],e[26]=m(t.seat),e[27]=m(t.rom2),e[28]=m(t.rom1),e[29]=m(t.chest)},P=(t,e)=>{t.low&&C(t.low,18,e),t.high&&C(t.high,24,e)},U=(t,e)=>({power:t[e]+((31&t[e+2])<<8),velocity:t[e+1]+((224&t[e+2])<<3),force:t[e+3]+((240&t[e+5])<<4),position:t[e+4]+((15&t[e+5])<<8)}),C=(t,e,r)=>{r[e++]=255&t.power,r[e++]=255&t.velocity,r[e++]=((7936&t.power)>>8)+((1792&t.velocity)>>3),r[e++]=255&t.force,r[e++]=255&t.position,r[e++]=((3840&t.position)>>8)+((3840&t.force)>>4)},O=t=>{t.forEach(t=>{if(!w(t)){let e=0;for(let r=0;r<30;r++){let n=t[r];for(let t=0;t<8;t++){let t=(n^e)%2;e>>=1,n>>=1,t&&(e^=40961)}}let r=B(65535^e);t[30]=r[0],t[31]=r[1]}})};var L=r(10),M=r(5);const N=L.a.timeout(2e4,M.b.Cooperative),q=L.a.handleAll().retry().attempts(2),j=()=>Promise.resolve({machineData:{},rawData:[],validStructure:!1}),Y=(t,e)=>t.every((t,r)=>t.every((t,n)=>t===e[r][n]));class F extends h{constructor(t,e,r){super(r),this.echipId=t,this.owDevice=e,this.data=this.loadData(),c.a.info("EChip connected: "+this.id)}get id(){return this.echipId.reduce((t,e)=>t+=(15&e).toString(16)+(e>>4&15).toString(16),"").split("").reverse().join("")}destroy(){this.disconnected()}async getData(){return this.data}async clearData(){let t=l({});await q.execute(async()=>{await N.execute(async()=>this.performClearData(t))})}async performClearData(t){try{let e=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,e,!1)}catch(e){try{await this.owDevice.keyWriteAll(this.echipId,t,!1)}catch(t){throw this.data=j(),t}}if(await(this.data=this.loadData()),!Y(t,(await this.data).rawData))throw new Error("Write was unsuccesful. Data targets do not match.")}async setData(t){let e=l(t);await q.execute(async()=>{await N.execute(async()=>this.performSetData(e))})}async performSetData(t){let e=(await this.data).rawData;try{await this.owDevice.keyWriteDiff(this.echipId,t,e,!1)}catch(t){throw this.data=j(),t}if(await(this.data=this.loadData()),!Y(t,(await this.data).rawData))throw new Error("Write was unsuccesful. Data targets do not match.")}dispose(){super.dispose(),c.a.info("EChip disconnected: "+this.id)}async loadData(){return q.execute(async()=>N.execute(async()=>{let t=function(t=[]){let e={machineData:{},rawData:t,validStructure:!1};if(0===t.length||!p(t))return e;for(let r=1;r<=8;r++)for(let n=0;n<3;n++){let i=32*r-2,s=10*n;if(1===t[i][s]){let r=D(t[i][s+1],t[i][s+2]);e.machineData[r]={position:{chest:v(t[i][s+3]),rom2:v(t[i][s+4]),rom1:v(t[i][s+5]),seat:v(t[i][s+6])},sets:[]};let n=t[i][s+7];f(t,e.machineData[r],n)}}return e.validStructure=!0,e}(await this.owDevice.keyReadAll(this.echipId,!1));if(!t.validStructure)throw new Error("Invalid data structure.");return t}))}}var W=r(7);class V{constructor(t,e){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new u.a,this.onDisconnectEvent=new u.a,this.activeKeys=new Map,this.onDisconnectListener=e(t=>this.disconnected(t)),this.usbDevice=t,this.owDevice=new W.a(t,t=>this.echipsDetected(t)),this.claimed=this.owDevice.claim().then(()=>(c.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}onEChipDetect(t){return this.onEChipDetectEvent.on(t)}echipsDetected(t){let e=[];t.forEach(t=>{let r=t.join();if(e.push(r),!this.activeKeys.has(r)){let e=new F(t,this.owDevice,t=>this.onDisconnect(t));this.activeKeys.set(r,e),this.onEChipDetectEvent.emit(e)}}),this.activeKeys.forEach((t,r)=>{e.includes(r)||(t.destroy(),this.activeKeys.delete(r))})}disconnected(t){this.usbDevice===t&&(this.onDisconnectEvent.emit(null),this.dispose())}async dispose(){await this.owDevice.close(),this.onDisconnectListener&&(this.onDisconnectListener.dispose(),this.onDisconnectListener=null),this.disposed=!0,c.a.info("EChip Reader disconnected.")}}r.d(e,"EChipReaderWatcher",(function(){return H}));const K=1274,z=9360;class H extends i{constructor(){super(K,z),this.onConnectEvent=new u.a,this.onDisconnectEvent=new u.a}async stop(){await Promise.all(this.connectedDevices.map(t=>this.disconnected(t)))}onConnect(t){return this.onConnectEvent.on(t)}onDisconnect(t){return this.onDisconnectEvent.on(t)}async connected(t){await super.connected(t);const e=new V(t,t=>this.onDisconnect(t));await e.claimed,this.onConnectEvent.emit(e)}async disconnected(t){await super.disconnected(t),this.onDisconnectEvent.emit(t)}}e.default=new H}])}));
{
"name": "@keiser/echip-webusb",
"version": "1.3.2",
"version": "1.3.3",
"description": "Keiser Air eChip WebUSB Library",

@@ -28,2 +28,3 @@ "keywords": [

"async-mutex": "^0.1.4",
"cockatiel": "^0.1.1",
"crc": "^3.8.0"

@@ -30,0 +31,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc