keiser-echip-webusb
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,2 +8,2 @@ !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=10)}([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){ | ||
*/ | ||
var n=r(6),i=r(7),s=r(8);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 q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(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:g(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):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(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 v(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 m(t,e,r,n){return W(q(e,t.length-r),t,r,n)}function b(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 b(t,e,r,n)}function E(t,e,r,n){return W(j(e),t,r,n)}function A(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 B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function _(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<=R)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));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)w(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)w(this,e,e+3),w(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)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?_(this,0,t):function(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 I(this,e,r);case"utf8":case"utf-8":return _(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.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 y(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return y(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 v(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return D(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(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 R=4096;function S(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 T(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 I(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+=N(t[s]);return i}function U(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 k(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 M(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 x(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 O(t,e,r,n,s){return s||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function Y(t,e,r,n,s){return s||x(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)||k(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)||k(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||k(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||k(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||k(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||k(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):M(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||k(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):M(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);k(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);k(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||k(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||k(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||k(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||k(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):M(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||k(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):M(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return Y(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return Y(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:q(new c(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(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 j(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).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(5))},function(t,e,r){"use strict";(function(t){r.d(e,"a",function(){return d});var n=r(0),i=r(4),s=r(3);const o=64,a=500,c=200,u=1,h=t=>12===t[0]&&0!==t[7],f=()=>new Promise(t=>setTimeout(()=>{t()},c));class l{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 d{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[u];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{null!==this.usbDevice.configuration&&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[u].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(){if(this.searching=!1,this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]){let t=await this.mutex.acquire();try{await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(t){}t()}}awaitKey(){setTimeout(async()=>{if(this.searching){let t=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(t){}t(),this.awaitKey()}},a)}async keySearch(){let t=[],e=await this.romSearch();if(e.result){for(h(e.key)&&t.push(e.key);e.result&&!e.lastDevice;)(e=await e.next()).result&&h(e.key)&&t.push(e.key);this.onDetectKeys(t)}}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 l(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(){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(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(),c));try{let t=await Promise.race([e,r]);if(!(t instanceof USBInTransferResult)||"ok"!==t.status||void 0===t.data)throw new Error;return new Uint8Array(t.data.buffer)}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)(new t(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,a=r.length-1,c=async(t,e=0,r=new Uint8Array(0),n=!1)=>{const a=async(t,e=0)=>{const r=Math.min(o,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 a(t,e+r)};await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(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 c(t,e,r,n)};await this.setSpeed(!1),await c(t,e,r,n),await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!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(o,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(!1),await this.reset(),await this.romMatch(t,e);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(e)}catch(t){return n.a.warn("Read All "+(e?"Overdrive ":"")+"Failed: "+t.message),await this.deviceReset(),await s(!1)}}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(9);e.Mutex=n.default},function(t,e,r){"use strict";var n=r(1);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){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);class n{constructor(t,e){this.connectedDevices=[],this.vendorId=t,this.productId=e,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(){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&&this.connected(t)}async checkDevices(){(await navigator.usb.getDevices()).some(t=>!!this.matchesTarget(t)&&(this.connected(t),!0))}attached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.connected(t.device)}detached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.isConnectedDevices(t.device)&&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 i,s,o,a=r(0);class c{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 u{constructor(t){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new c,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 h(t){let e={machineData:{},rawData:t,validStructure:!1};if(!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=E(t[i][s+1],t[i][s+2]);e.machineData[r]={position:{chest:g(t[i][s+3]),rom2:g(t[i][s+4]),rom1:g(t[i][s+5]),seat:g(t[i][s+6])},sets:[]};let n=t[i][s+7];f(t,e.machineData[r],n)}}return e.validStructure=!0,e}!function(t){t.dec="dec",t.int="int"}(i||(i={})),function(t){t.lb="lb",t.kg="kg",t.ne="ne",t.er="er"}(s||(s={})),function(t){t.power6r="power6r",t.a4206r="a4206r",t.a42010r="a42010r"}(o||(o={}));const f=(t,e,r)=>{let n=r%30,a=t[32*Math.floor(r/32)+31][n],c=t[r],u=A(c[7],c[8]),h={version:E(c[12],c[11],c[10],c[9]),serial:"",time:_(c[0],c[1],c[2],c[3]).toISOString(),resistance:A(c[4],c[5]),precision:i.int,units:s.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=S(c[13],c[14],c[15],c[16],c[17],h.version),D(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=i.dec),96&c[17]){case 0:h.units=s.lb;break;case 32:h.units=s.kg;break;case 64:h.units=s.ne;break;case 96:h.units=s.er}if(m(h.version))if(h.repetitions>=252&&h.repetitions<=254){let t={type:o.power6r,low:null,high:null};switch(h.repetitions){case 254:t.type=o.power6r,t.low=C(c,18),t.high=C(c,24),h.repetitions=6;break;case 253:t.type=o.a4206r,h.repetitions=6;break;case 252:t.type=o.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&a)&&f(t,e,a)};function l(t){let e=U();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]=v(s.position.chest),e[a][c+4]=v(s.position.rom2),e[a][c+5]=v(s.position.rom1),e[a][c+6]=v(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++}),x(e),e}const d=(t,e,r,n)=>{const s=R(new Date(e.time)),a=B(e.resistance*(e.precision===i.dec?10:1));let c=e.repetitions;if(e.test)switch(e.test.type){case o.power6r:c=254;break;case o.a4206r:c=253;break;case o.a42010r:c=252}let u=B(t),h=B(parseInt(e.version,16)),f=T(e.serial),l=I(e.serial,e.version,e.precision,e.units);n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=a[0],n[5]=a[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?k(e.test,n):P(e,n)},p=t=>t.every(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},g=t=>255===t?null:t,v=t=>null===t?255:t,m=t=>parseInt(t,16)>795179504,b=t=>parseInt(t,16)>851074185,D=t=>parseInt(t,16)>831409920,E=(...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],_=(...t)=>new Date(1e3*A(...t)),R=t=>B(t.getTime()/1e3),S=(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))(_(t,e,r,n));return D(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},T=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 o=0;switch(o=D(e)?parseInt(t.substr(-2),10)-32:parseInt(t.substr(-2),10),r===i.dec&&(o|=128),n){case s.kg:o|=32;break;case s.ne:o|=64;break;case s.er:o|=96}return o},U=()=>{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},P=(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]=v(t.seat),e[27]=v(t.rom2),e[28]=v(t.rom1),e[29]=v(t.chest)},k=(t,e)=>{t.low&&M(t.low,18,e),t.high&&M(t.high,24,e)},C=(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)}),M=(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)},x=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]}})};class O extends u{constructor(t,e,r){super(r),this.echipId=t,this.owDevice=e,this.data=this.loadData(),a.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({});try{let e=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,e,!1)}catch(e){await this.owDevice.keyWriteAll(this.echipId,t,!1)}this.data=new Promise(e=>e(h(t)))}async setData(t){let e=l(t),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,r,!1),this.data=new Promise(t=>t(h(e)))}async dispose(){await super.dispose(),a.a.info("EChip disconnected: "+this.id)}async loadData(){let t=h(await this.owDevice.keyReadAll(this.echipId,!1));return t.validStructure||a.a.warn("Invalid Data Structure"),t}}var Y=r(2);class L{constructor(t,e){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new c,this.onDisconnectEvent=new c,this.activeKeys=new Map,this.onDisconnectListener=e(t=>this.disconnected(t)),this.usbDevice=t,this.owDevice=new Y.a(t,t=>this.echipsDetected(t)),this.claimed=this.owDevice.claim().then(()=>(a.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}onEChipDetect(t){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 O(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,a.a.info("EChip Reader disconnected.")}}r.d(e,"default",function(){return j});const N=1274,q=9360;class j extends n{constructor(){super(N,q),this.onConnectEvent=new c,this.onDisconnectEvent=new c}stop(){this.connectedDevices.forEach(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 L(t,t=>this.onDisconnect(t));await e.claimed,this.onConnectEvent.emit(e)}async disconnected(t){this.onDisconnectEvent.emit(t),await super.disconnected(t)}}}])}); | ||
var n=r(6),i=r(7),s=r(8);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 q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function w(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(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:g(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):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(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 v(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 m(t,e,r,n){return W(q(e,t.length-r),t,r,n)}function b(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 b(t,e,r,n)}function E(t,e,r,n){return W(j(e),t,r,n)}function A(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 B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function _(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<=R)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=R));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)w(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)w(this,e,e+3),w(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)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?_(this,0,t):function(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 I(this,e,r);case"utf8":case"utf-8":return _(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.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 y(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return y(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 v(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return D(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(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 R=4096;function S(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 T(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 I(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+=N(t[s]);return i}function U(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 k(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 M(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 x(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 O(t,e,r,n,s){return s||x(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function Y(t,e,r,n,s){return s||x(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)||k(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)||k(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||k(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||k(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||k(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||k(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):M(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||k(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):M(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);k(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);k(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||k(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||k(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||k(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||k(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):M(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||k(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):M(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return Y(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return Y(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:q(new c(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function N(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(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 j(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).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(5))},function(t,e,r){"use strict";(function(t){r.d(e,"a",function(){return d});var n=r(0),i=r(4),s=r(3);const o=64,a=500,c=200,u=1,h=t=>12===t[0]&&0!==t[7],f=()=>new Promise(t=>setTimeout(()=>{t()},c));class l{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 d{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[u];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{null!==this.usbDevice.configuration&&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[u].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(){if(this.searching=!1,this.usbDevice.configuration&&this.usbDevice.configuration.interfaces[0]){let t=await this.mutex.acquire();try{await this.usbDevice.releaseInterface(this.usbDevice.configuration.interfaces[0].interfaceNumber)}catch(t){}t()}}awaitKey(){setTimeout(async()=>{if(this.searching){let t=await this.mutex.acquire();try{await Promise.race([this.keySearch(),f()])}catch(t){}t(),this.awaitKey()}},a)}async keySearch(){let t=[],e=await this.romSearch();if(e.result){for(h(e.key)&&t.push(e.key);e.result&&!e.lastDevice;)(e=await e.next()).result&&h(e.key)&&t.push(e.key);this.onDetectKeys(t)}}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 l(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(){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(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(),c));try{let t=await Promise.race([e,r]);if(!(t instanceof USBInTransferResult)||"ok"!==t.status||void 0===t.data)throw new Error;return new Uint8Array(t.data.buffer)}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)(new t(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,a=r.length-1,c=async(t,e=0,r=new Uint8Array(0),n=!1)=>{const a=async(t,e=0)=>{const r=Math.min(o,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 a(t,e+r)};await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([15,i,s]);await this.write(u,!0),await a(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 c(t,e,r,n)};await this.setSpeed(!1),await c(t,e,r,n),await this.reset(),await this.romMatch(t,n);const u=new Uint8Array([85,i,s,a]);await this.write(u,!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(o,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(!1),await this.reset(),await this.romMatch(t,e);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(e)}catch(t){return n.a.warn("Read All "+(e?"Overdrive ":"")+"Failed: "+t.message),await this.deviceReset(),await s(!1)}}finally{a(),n.a.info("Read All Completed: "+Math.round(performance.now()-c)+"ms")}}}}).call(this,r(1).Buffer)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(9);e.Mutex=n.default},function(t,e,r){"use strict";var n=r(1);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){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);class n{constructor(t,e){this.connectedDevices=[],this.vendorId=t,this.productId=e,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(){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&&this.connected(t)}async checkDevices(){(await navigator.usb.getDevices()).some(t=>!!this.matchesTarget(t)&&(this.connected(t),!0))}attached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.connected(t.device)}detached(t){t instanceof USBConnectionEvent&&this.matchesTarget(t.device)&&this.isConnectedDevices(t.device)&&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 i,s,o,a=r(0);class c{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 u{constructor(t){this.disposed=!1,this.onDisconnectListener=null,this.onDisconnectEvent=new c,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 h(t){let e={machineData:{},rawData:t,validStructure:!1};if(!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=E(t[i][s+1],t[i][s+2]);e.machineData[r]={position:{chest:g(t[i][s+3]),rom2:g(t[i][s+4]),rom1:g(t[i][s+5]),seat:g(t[i][s+6])},sets:[]};let n=t[i][s+7];f(t,e.machineData[r],n)}}return e.validStructure=!0,e}!function(t){t.dec="dec",t.int="int"}(i||(i={})),function(t){t.lb="lb",t.kg="kg",t.ne="ne",t.er="er"}(s||(s={})),function(t){t.power6r="power6r",t.a4206r="a4206r",t.a42010r="a42010r"}(o||(o={}));const f=(t,e,r)=>{let n=r%30,a=t[32*Math.floor(r/32)+31][n],c=t[r],u=A(c[7],c[8]),h={version:E(c[12],c[11],c[10],c[9]),serial:"",time:_(c[0],c[1],c[2],c[3]).toISOString(),resistance:A(c[4],c[5]),precision:i.int,units:s.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=S(c[13],c[14],c[15],c[16],c[17],h.version),D(h.version))switch(128==(128&c[17])&&(h.resistance=h.resistance/10,h.precision=i.dec),96&c[17]){case 0:h.units=s.lb;break;case 32:h.units=s.kg;break;case 64:h.units=s.ne;break;case 96:h.units=s.er}if(m(h.version))if(h.repetitions>=252&&h.repetitions<=254){let t={type:o.power6r,low:null,high:null};switch(h.repetitions){case 254:t.type=o.power6r,t.low=C(c,18),t.high=C(c,24),h.repetitions=6;break;case 253:t.type=o.a4206r,h.repetitions=6;break;case 252:t.type=o.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&a)&&f(t,e,a)};function l(t){let e=U();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]=v(s.position.chest),e[a][c+4]=v(s.position.rom2),e[a][c+5]=v(s.position.rom1),e[a][c+6]=v(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++}),x(e),e}const d=(t,e,r,n)=>{const s=R(new Date(e.time)),a=B(e.resistance*(e.precision===i.dec?10:1));let c=e.repetitions;if(e.test)switch(e.test.type){case o.power6r:c=254;break;case o.a4206r:c=253;break;case o.a42010r:c=252}let u=B(t),h=B(parseInt(e.version,16)),f=T(e.serial),l=I(e.serial,e.version,e.precision,e.units);n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=a[0],n[5]=a[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?k(e.test,n):P(e,n)},p=t=>t.every(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},g=t=>255===t?null:t,v=t=>null===t?255:t,m=t=>parseInt(t,16)>795179504,b=t=>parseInt(t,16)>851074185,D=t=>parseInt(t,16)>831409920,E=(...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],_=(...t)=>new Date(1e3*A(...t)),R=t=>B(t.getTime()/1e3),S=(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))(_(t,e,r,n));return D(s)?o+=("00"+(32+(31&i)).toString()).substr(-2):(o+=((240&i)/16).toString(16),o+=(31&i).toString(16)),o},T=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 o=0;switch(o=D(e)?parseInt(t.substr(-2),10)-32:parseInt(t.substr(-2),10),r===i.dec&&(o|=128),n){case s.kg:o|=32;break;case s.ne:o|=64;break;case s.er:o|=96}return o},U=()=>{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},P=(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]=v(t.seat),e[27]=v(t.rom2),e[28]=v(t.rom1),e[29]=v(t.chest)},k=(t,e)=>{t.low&&M(t.low,18,e),t.high&&M(t.high,24,e)},C=(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)}),M=(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)},x=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]}})};class O extends u{constructor(t,e,r){super(r),this.echipId=t,this.owDevice=e,this.data=this.loadData(),a.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({});try{let e=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,t,e,!1)}catch(e){await this.owDevice.keyWriteAll(this.echipId,t,!1)}this.data=new Promise(e=>e(h(t)))}async setData(t){let e=l(t),r=(await this.data).rawData;await this.owDevice.keyWriteDiff(this.echipId,e,r,!1),this.data=new Promise(t=>t(h(e)))}async dispose(){await super.dispose(),a.a.info("EChip disconnected: "+this.id)}async loadData(){let t=h(await this.owDevice.keyReadAll(this.echipId,!1));return t.validStructure||a.a.warn("Invalid Data Structure"),t}}var Y=r(2);class L{constructor(t,e){this.disposed=!1,this.onDisconnectListener=null,this.onEChipDetectEvent=new c,this.onDisconnectEvent=new c,this.activeKeys=new Map,this.onDisconnectListener=e(t=>this.disconnected(t)),this.usbDevice=t,this.owDevice=new Y.a(t,t=>this.echipsDetected(t)),this.claimed=this.owDevice.claim().then(()=>(a.a.info("EChip Reader connected."),this.owDevice.startSearch(),!0))}get diposed(){return this.disposed}onDisconnect(t){return this.onDisconnectEvent.on(t)}onEChipDetect(t){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 O(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,a.a.info("EChip Reader disconnected.")}}r.d(e,"default",function(){return j});const N=1274,q=9360;class j extends n{constructor(){super(N,q),this.onConnectEvent=new c,this.onDisconnectEvent=new c}stop(){this.connectedDevices.forEach(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 L(t,t=>this.onDisconnect(t));await e.claimed,this.onConnectEvent.emit(e)}async disconnected(t){this.onDisconnectEvent.emit(t),await super.disconnected(t)}}}])}); |
{ | ||
"name": "keiser-echip-webusb", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Keiser Air eChip WebUSB Library", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"build": "webpack --config webpack/prod.config.js", | ||
"push": "npm run build && npm publish dist --dry-run" | ||
"push": "npm run build && npm publish dist" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": {}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61828
1