mini_program_gizwits_sdk 3.7.21-cozev5 → 3.7.22-cozev5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22,4 +22,4 @@ n.mode.CTRGladman=function(){var e=n.lib.BlockCipherMode.extend();function t(e){
|
|
|
22
22
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
23
23
|
* @license MIT
|
|
24
24
|
*/
|
|
25
|
-
var n=i(70),s=i(71),r=i(72);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,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return u(this,e,t,i)}function u(e,t,i,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,i,n){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===i&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,i):new Uint8Array(t,i,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,i,n):"string"==typeof t?function(e,t,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,i),s=(e=a(e,n)).write(t,i);s!==n&&(e=e.slice(0,s));return e}(e,t,i):function(e,t){if(c.isBuffer(t)){var i=0|f(t.length);return 0===(e=a(e,i)).length||t.copy(e,0,0,i),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):h(e,t);if("Buffer"===t.type&&r(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 d(e,t){if(l(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function h(e,t){var i=t.length<0?0:0|f(t.length);e=a(e,i);for(var n=0;n<i;n+=1)e[n]=255&t[n];return e}function f(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 i=e.length;if(0===i)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return K(e).length;default:if(n)return G(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,i){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return k(this,t,i);case"utf8":case"utf-8":return A(this,t,i);case"ascii":return E(this,t,i);case"latin1":case"binary":return B(this,t,i);case"base64":return C(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,i);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function _(e,t,i,n,s){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(s)return-1;i=e.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:y(e,t,i,n,s);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):y(e,[t],i,n,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,i,n,s){var r,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,i/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(s){var l=-1;for(r=i;r<a;r++)if(u(e,r)===u(t,-1===l?0:r-l)){if(-1===l&&(l=r),r-l+1===c)return l*o}else-1!==l&&(r-=r-l),l=-1}else for(i+c>a&&(i=a-c),r=i;r>=0;r--){for(var d=!0,h=0;h<c;h++)if(u(e,r+h)!==u(t,h)){d=!1;break}if(d)return r}return-1}function m(e,t,i,n){i=Number(i)||0;var s=e.length-i;n?(n=Number(n))>s&&(n=s):n=s;var r=t.length;if(r%2!=0)throw new TypeError("Invalid hex string");n>r/2&&(n=r/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[i+o]=a}return o}function D(e,t,i,n){return F(G(t,e.length-i),e,i,n)}function S(e,t,i,n){return F(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,n)}function b(e,t,i,n){return S(e,t,i,n)}function w(e,t,i,n){return F(K(t),e,i,n)}function I(e,t,i,n){return F(function(e,t){for(var i,n,s,r=[],o=0;o<e.length&&!((t-=2)<0);++o)i=e.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(t,e.length-i),e,i,n)}function C(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function A(e,t,i){i=Math.min(e.length,i);for(var n=[],s=t;s<i;){var r,o,a,c,u=e[s],l=null,d=u>239?4:u>223?3:u>191?2:1;if(s+d<=i)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(r=e[s+1]))&&(c=(31&u)<<6|63&r)>127&&(l=c);break;case 3:r=e[s+1],o=e[s+2],128==(192&r)&&128==(192&o)&&(c=(15&u)<<12|(63&r)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:r=e[s+1],o=e[s+2],a=e[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&r)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),s+=d}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var i="",n=0;for(;n<t;)i+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return i}(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,i){return u(null,e,t,i)},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,i){return function(e,t,i,n){return l(t),t<=0?a(e,t):void 0!==i?"string"==typeof n?a(e,t).fill(i,n):a(e,t).fill(i):a(e,t)}(null,e,t,i)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(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 i=e.length,n=t.length,s=0,r=Math.min(i,n);s<r;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?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(!r(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=c.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=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)g(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)g(this,t,t+3),g(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)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):v.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="",i=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,i,n,s){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(this===e)return 0;for(var r=(s>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0),a=Math.min(r,o),u=this.slice(n,s),l=e.slice(t,i),d=0;d<a;++d)if(u[d]!==l[d]){r=u[d],o=l[d];break}return r<o?-1:o<r?1:0},c.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},c.prototype.indexOf=function(e,t,i){return _(this,e,t,i,!0)},c.prototype.lastIndexOf=function(e,t,i){return _(this,e,t,i,!1)},c.prototype.write=function(e,t,i,n){if(void 0===t)n="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)n=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var s=this.length-t;if((void 0===i||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var r=!1;;)switch(n){case"hex":return m(this,e,t,i);case"utf8":case"utf-8":return D(this,e,t,i);case"ascii":return S(this,e,t,i);case"latin1":case"binary":return b(this,e,t,i);case"base64":return w(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(e,t,i){var n="";i=Math.min(e.length,i);for(var s=t;s<i;++s)n+=String.fromCharCode(127&e[s]);return n}function B(e,t,i){var n="";i=Math.min(e.length,i);for(var s=t;s<i;++s)n+=String.fromCharCode(e[s]);return n}function k(e,t,i){var n=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>n)&&(i=n);for(var s="",r=t;r<i;++r)s+=H(e[r]);return s}function T(e,t,i){for(var n=e.slice(t,i),s="",r=0;r<n.length;r+=2)s+=String.fromCharCode(n[r]+256*n[r+1]);return s}function O(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,i,n,s,r){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<r)throw new RangeError('"value" argument is out of bounds');if(i+n>e.length)throw new RangeError("Index out of range")}function P(e,t,i,n){t<0&&(t=65535+t+1);for(var s=0,r=Math.min(e.length-i,2);s<r;++s)e[i+s]=(t&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function L(e,t,i,n){t<0&&(t=4294967295+t+1);for(var s=0,r=Math.min(e.length-i,4);s<r;++s)e[i+s]=t>>>8*(n?s:3-s)&255}function M(e,t,i,n,s,r){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function R(e,t,i,n,r){return r||M(e,0,i,4),s.write(e,t,i,n,23,4),i+4}function N(e,t,i,n,r){return r||M(e,0,i,8),s.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){var i,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)(i=this.subarray(e,t)).__proto__=c.prototype;else{var s=t-e;i=new c(s,void 0);for(var r=0;r<s;++r)i[r]=this[r+e]}return i},c.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e],s=1,r=0;++r<t&&(s*=256);)n+=this[e+r]*s;return n},c.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},c.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||O(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||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e],s=1,r=0;++r<t&&(s*=256);)n+=this[e+r]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=t,s=1,r=this[e+--n];n>0&&(s*=256);)r+=this[e+--n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return t||O(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||O(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||O(e,4,this.length),s.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),s.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),s.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),s.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,i,n){(e=+e,t|=0,i|=0,n)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var s=1,r=0;for(this[t]=255&e;++r<i&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUIntBE=function(e,t,i,n){(e=+e,t|=0,i|=0,n)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var s=i-1,r=1;for(this[t+s]=255&e;--s>=0&&(r*=256);)this[t+s]=e/r&255;return t+i},c.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||x(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,i){return e=+e,t|=0,i||x(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||x(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t|=0,!n){var s=Math.pow(2,8*i-1);x(this,e,t,i,s-1,-s)}var r=0,o=1,a=0;for(this[t]=255&e;++r<i&&(o*=256);)e<0&&0===a&&0!==this[t+r-1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+i},c.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t|=0,!n){var s=Math.pow(2,8*i-1);x(this,e,t,i,s-1,-s)}var r=i-1,o=1,a=0;for(this[t+r]=255&e;--r>=0&&(o*=256);)e<0&&0===a&&0!==this[t+r+1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||x(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,i){return e=+e,t|=0,i||x(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||x(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,i){return R(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return R(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return N(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return N(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=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-i&&(n=e.length-t+i);var s,r=n-i;if(this===e&&i<t&&t<n)for(s=r-1;s>=0;--s)e[s+t]=this[s+i];else if(r<1e3||!c.TYPED_ARRAY_SUPPORT)for(s=0;s<r;++s)e[s+t]=this[s+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+r),t);return r},c.prototype.fill=function(e,t,i,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===e.length){var s=e.charCodeAt(0);s<256&&(e=s)}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<i)throw new RangeError("Out of range index");if(i<=t)return this;var r;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(r=t;r<i;++r)this[r]=e;else{var o=c.isBuffer(e)?e:G(new c(e,n).toString()),a=o.length;for(r=0;r<i-t;++r)this[r+t]=o[r%a]}return this};var U=/[^+\/0-9A-Za-z-_]/g;function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function G(e,t){var i;t=t||1/0;for(var n=e.length,s=null,r=[],o=0;o<n;++o){if((i=e.charCodeAt(o))>55295&&i<57344){if(!s){if(i>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(t-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(t-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((t-=1)<0)break;r.push(i)}else if(i<2048){if((t-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;r.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function K(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,i,n){for(var s=0;s<n&&!(s+i>=t.length||s>=e.length);++s)t[s+i]=e[s];return s}}).call(this,i(15))},function(e,t,i){"use strict";t.byteLength=function(e){var t=u(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,n=u(e),o=n[0],a=n[1],c=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,a)),l=0,d=a>0?o-4:o;for(i=0;i<d;i+=4)t=s[e.charCodeAt(i)]<<18|s[e.charCodeAt(i+1)]<<12|s[e.charCodeAt(i+2)]<<6|s[e.charCodeAt(i+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=s[e.charCodeAt(i)]<<2|s[e.charCodeAt(i+1)]>>4,c[l++]=255&t);1===a&&(t=s[e.charCodeAt(i)]<<10|s[e.charCodeAt(i+1)]<<4|s[e.charCodeAt(i+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},t.fromByteArray=function(e){for(var t,i=e.length,s=i%3,r=[],o=0,a=i-s;o<a;o+=16383)r.push(l(e,o,o+16383>a?a:o+16383));1===s?(t=e[i-1],r.push(n[t>>2]+n[t<<4&63]+"==")):2===s&&(t=(e[i-2]<<8)+e[i-1],r.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return r.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],s[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 i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,i){for(var s,r,o=[],a=t;a<i;a+=3)s=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(r=s)>>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]);return o.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,i,n,s){var r,o,a=8*s-n-1,c=(1<<a)-1,u=c>>1,l=-7,d=i?s-1:0,h=i?-1:1,f=e[t+d];for(d+=h,r=f&(1<<-l)-1,f>>=-l,l+=a;l>0;r=256*r+e[t+d],d+=h,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=n;l>0;o=256*o+e[t+d],d+=h,l-=8);if(0===r)r=1-u;else{if(r===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),r-=u}return(f?-1:1)*o*Math.pow(2,r-n)},t.write=function(e,t,i,n,s,r){var o,a,c,u=8*r-s-1,l=(1<<u)-1,d=l>>1,h=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:r-1,p=n?1:-1,v=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=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(t*c-1)*Math.pow(2,s),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,s),o=0));s>=8;e[i+f]=255&a,f+=p,a/=256,s-=8);for(o=o<<s|a,u+=s;u>0;e[i+f]=255&o,f+=p,o/=256,u-=8);e[i+f-p]|=128*v}},function(e,t){var i={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(74)),r=n(i(30));t.default=(0,r.default)("crc-32",s.default)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let n=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(n=new Int32Array(n));t.default=(e,t)=>{let i=0===t?0:-1^~~t;for(let t=0;t<e.length;t++)i=n[255&(i^e[t])]^i>>>8;return-1^i}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{}o.pack=()=>{const e=parseInt(`${Date.now()/1e3}`,10),t=(0,r.fillString)(e.toString(2),40);return[0,0,0,3,8,0,0,89].concat((0,r.completeBlock)(t))},t.default=o},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CancelSync=t.DeletePackage=t.SyncPackage=t.RequestSync=void 0;const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e),this.state=0,this.len=0}}t.RequestSync=o,o.pack=()=>[0,0,0,3,3,0,0,113];class a extends s.default{constructor(e){super(e),this.id=0,this.timestemp=0,this.payloadLen=0}}t.SyncPackage=a,a.pack=e=>{let t=e.toString(2);return t=(0,r.fillString)(t,16),[0,0,0,3,5].concat([0,0,115]).concat((0,r.completeBlock)(t))};class c extends s.default{}t.DeletePackage=c,c.pack=e=>{let t=e.toString(2);return t=(0,r.fillString)(t,16),[0,0,0,3,5].concat([0,0,117]).concat((0,r.completeBlock)(t))};class u extends s.default{constructor(e){super(e),this.state=0}}t.CancelSync=u,u.pack=()=>[0,0,0,3,3,0,0,119]},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(20)),o=s(i(1)),a=i(3);class c extends o.default{}c.pack=(e,t,i)=>n(void 0,void 0,void 0,(function*(){const n=yield r.default.getConfigFile(e);if(n){const e="var_len"===n.protocolType,s=[0,0,0,3],r=[0];let o=[0];const c=[0,147];let u=[0,0,0,0],l=[2];if(t){o=[1];const e=(0,a.fillString)(t.length.toString(16),4),i=(0,a.hexStrint2byte)(e),n=(0,a.string2Bytes)(t);u=u.concat(i).concat(n)}if(e){l=[18];let e="";if(i){const t=i.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:1}),{});n.entities[0].attrs.map(i=>{e=t[i.name]?`1${e}`:`0${e}`})}else n.entities[0].attrs.map(()=>{e=`1${e}`});e=(0,a.fillString)(e,8*Math.ceil(e.length/8)),l=l.concat((0,a.hexStrint2byte)(parseInt(e,2).toString(16)))}const d=o.concat(c).concat(u).concat(l);return r[0]=d.length,s.concat(r).concat(d)}return null})),t.default=c},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e),this.result=!1,this.didLength=0,this.did=""}}o.pack=({passcode:e})=>{let t=[0];const i=(0,r.hexStrint2byte)((0,r.fillString)(e.length.toString(16),4)),n=(0,r.string2Bytes)(e),s=[0].concat([0,8]).concat(i).concat(n);return t=(0,r.hexStrint2byte)(s.length.toString(16)),[0,0,0,3].concat(t).concat(s)},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.reportEvent=void 0;const r=i(16),o=i(5),a=s(i(7));const c=new class{constructor(){wx.getSystemInfoAsync({success:e=>{this.app={wxSdkVersion:e.SDKVersion,gizwitsSdkVersion:r.version,appID:"unknown",bluetoothEnabled:e.bluetoothEnabled,locationEnabled:e.locationEnabled,wifiEnabled:e.wifiEnabled},this.mobile={brand:e.brand,model:e.model,pixelRatio:e.pixelRatio,systemVersion:e.system,platform:e.platform}}})}updateAppId(e){this.app.appID=e}};t.reportEvent=function({device:e,eventID:t,eventType:i,success:s,failureType:r}){return n(this,void 0,void 0,(function*(){c.updateAppId((0,o.getGlobalData)("appID")||"unknown");const n=`/v2/products/${e.productKey}/devices/bluetooth-connect-data`,u=new Date,l={origin:"MINI-WX",mobileInfo:c.mobile,userInfo:null,appInfo:c.app,eventID:t,eventType:i,monitorTarget:{device:e,success:s,failureType:r},time:u,timeStamp:Math.floor(u.getTime()/1e3)};return(0,a.default)(n,{data:l,method:"POST"},!0)}))}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.moduleSoftVersion="",this.moduleHardVersion="",this.mcuSoftVersion="",this.mcuHardVersion="",this.businessVersion="";let t=0;t+=8}}r.pack=()=>[0,0,0,3,3,0,0,19],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.type="MCU",this.state=0,this.version=0}}r.pack=e=>[0,0,0,3,4,0,0,65,"MCU"===e?2:1],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(21),r=n(i(1)),o=i(3);class a extends r.default{constructor(e){super(e),this.state=0,this.processedLen=0,this.processedCrc32="",this.packageMaxLen=20}}a.pack=(e,t,i,n,r)=>{const a=(0,o.string2Bytes)(e),c=e.length,u=(0,o.string2Bytes)((0,o.fillString)(t,8)),l=(0,o.hexStrint2byte)(i),d=(0,o.hexStrint2byte)((0,o.fillString)(r.toString(16),8)),h=(0,o.hexStrint2byte)((0,o.fillString)(n.toString(16),8));let f=[0];f=f.concat([0,67],[c],a,u,l,h,d);const p=(0,s.getVariableLength)(f);return[0,0,0,3].concat(p,f)},t.default=a},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e)}}o.pack=e=>[0,0,0,3,7,0,0,69,...(0,r.hexStrint2byte)((0,r.fillString)(e.toString(16),8))],t.default=o},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(19),r=i(21),o=n(i(1)),a=i(3);class c extends o.default{constructor(e){super(e),this.packageNum=0,this.state=0;let t=0;t+=2}}c.pack=(e,t)=>{const i=(0,a.hexStrint2byte)((0,a.fillString)(t.toString(16),4)),n=(0,a.hexStrint2byte)((0,a.fillString)(e.length.toString(16),4)),o=(0,a.fillString)((0,s.crc16modbus)(new Uint8Array(e)).toString(16),4),c=(0,a.hexStrint2byte)(o);let u=[0];u=u.concat([0,71],i,n,c,e);const l=(0,r.getVariableLength)(u);return[0,0,0,3].concat(l,u)},t.default=c},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.state=0}}r.pack=e=>[0,0,0,3],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.state=0}}r.pack=e=>[0,0,0,3,4,0,0,80,e],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(34);class o extends s.default{constructor(e){super(e),this.parse=()=>{const e=[];let t=0;for(;t<this.payload.length;){const i=this.payload[t];if(0===i||t+1+i>this.payload.length)break;const n=this.payload.slice(t+1,t+1+i);let s="";for(let e=0;e<n.length;e++)s+="%"+("0"+n[e].toString(16)).slice(-2);let r="";try{console.log("utf8str",s),r=decodeURIComponent(s)}catch(e){console.error("decodeURIComponent error",e,s)}t+=1+i,e.push({ssid:r,rssi:this.payload[t]-100}),t+=1}return e}}}o.pack=()=>{const e=[4,69,...[r.snManager.getSn()],0];return new Uint8Array(e)},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=void 0;const r=s(i(4)),o=s(i(6)),a=s(i(7)),c=i(9),u=i(22);t.default=class{constructor({appID:e,token:t,uid:i,limitSocketNum:s=!0}){this._bindingDevices=null,this._connections={},this.updateToken=({token:e,uid:t})=>{this.token=e,this.uid=t},this._getDevice=e=>{if(null===this._bindingDevices)return r.default.GIZ_SDK_SDK_NOT_INITIALIZED;const t=this._bindingDevices[e];return null==t?r.default.GIZ_OPENAPI_DEVICE_NOT_BOUND:t},this._getConnect=e=>{const t=this._getWebsocketConnInfo(e);return this._connections[t]},this._getDeviceAndConnect=e=>{const t=this._getDevice(e);if((0,c.isError)(t))return t;const i=this._getConnect(t);return null==i?r.default.GIZ_SDK_DEVICE_NOT_SUBSCRIBED:[t,i]},this.connectDevice=e=>{const t=this._getWebsocketConnInfo(e);let i=this._connections[t];if(null==i){const e=Object.keys(this._connections).length;if(0!==this._maxSocketNum&&e>=this._maxSocketNum)return{success:!1,errorCode:r.default.MAX_CONNECT};i=new l({appID:this.appID,token:this.token,uid:this.uid,wsInfo:t,onDeviceStatusChanged:this._handleDeviceStatusChanged,onBindingChanged:this._handleBindingChanged,onSocketStatusChanged:this._handleSocketStatusChanged}),this._connections[t]=i}return i._addSubDid(e.did),null==i._websocket?i._connectWS():i.ready&&i._subDevices([e.did]),{success:!0}},this.connectDevices=e=>{const t={};e.forEach(e=>{const i=this._getWebsocketConnInfo(e);t[i]||(t[i]=[]),t[i].push(e.did)});const i=Object.keys(t).filter(e=>null==this._connections[e]).length,n=Object.keys(this._connections).length;return 0!==this._maxSocketNum&&n+i>this._maxSocketNum?{success:!1,errorCode:r.default.MAX_CONNECT}:(Object.entries(t).forEach(([e,t])=>{let i=this._connections[e];null==i&&(i=new l({appID:this.appID,token:this.token,uid:this.uid,wsInfo:e,onDeviceStatusChanged:this._handleDeviceStatusChanged,onBindingChanged:this._handleBindingChanged,onSocketStatusChanged:this._handleSocketStatusChanged}),this._connections[e]=i),i._addSubDid(...t),null==i._websocket?i._connectWS():i.ready&&i._subDevices(t)}),{success:!0})},this.disConnectDevice=e=>{const t=this._getWebsocketConnInfo(e);let i=this._connections[t];return i&&i._unSubDevices([e.did]),{success:!0}},this.disConnectDevices=e=>{const t={};return e.forEach(e=>{const i=this._getWebsocketConnInfo(e);t[i]||(t[i]=[]),t[i].push(e.did)}),Object.entries(t).forEach(([e,t])=>{const i=this._connections[e];i&&i._unSubDevices(t)}),{success:!0}},this.connect=e=>{const t=this._getDevice(e);if((0,c.isError)(t))return t;const i=this.connectDevice(t);return i.success?null:i.errorCode},this.send=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_raw",data:{did:e,raw:t}})},this.writeData=(e,t)=>n(this,void 0,void 0,(function*(){const i=yield(0,u.updateDevicesStatus)({data:[{id:e.did,product_key:e.productKey,mac:e.mac,qos:0,property:t}]});if(i.success){const e=i.data.data[0];return e.error?{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE.errorCode,message:e.msg}:{success:!0}}return{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE}})),this.write=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_write",data:{did:e,attrs:t}})},this.readStatus=(e,t)=>n(this,void 0,void 0,(function*(){const t=yield(0,u.getDevicesStatus)(e.did);if(t.success){return{success:!0,data:t.data.data.property}}return{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE,data:{}}})),this.read=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_read",data:{did:e,names:t}})},this.destory=()=>{Object.values(this._connections).forEach(e=>e.destory())},this.subscribeDeviceStatus=e=>{this._onDeviceStatusChanged=e},this.subscribeBindingChanged=e=>{this._onBindingChanged=e},this.subscribeSocketStatus=e=>{this._onSocketStatusChanged=e},this._handleDeviceStatusChanged=e=>{this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._handleBindingChanged=()=>{this._onBindingChanged&&this._onBindingChanged()},this._handleSocketStatusChanged=(...e)=>{this._onSocketStatusChanged&&this._onSocketStatusChanged(...e)},this._getBindingList=(e=20,t=0,i=[])=>n(this,void 0,void 0,(function*(){const n=`/app/bindings?show_disabled=0&limit=${e}&skip=${t}`,{err:s,data:r}=yield(0,a.default)(`${n}`,{method:"GET"});if(s)return{err:s};const o=[...i,...(null==r?void 0:r.devices)||[]];return r&&r.devices.length===e?yield this._getBindingList(e,e+t,o):o})),this._getWebsocketConnInfo=e=>e.host?`wss://wx${e.host}`:"wss://wxstage.gizwits.com",this.appID=e,this.token=t,this.uid=i;const o=wx.getSystemInfoSync().SDKVersion;this._maxSocketNum=s?-1===(0,c.compareWXSDKVersion)(o||"1.0.0","1.7.0")?1:5:0}init(){var e,t;return n(this,void 0,void 0,(function*(){try{const i=yield this._getBindingList();return(null===(e=i.err)||void 0===e?void 0:e.errorCode)?{errorCode:null===(t=i.err)||void 0===t?void 0:t.errorCode,errorMessage:"getting binding list failed"}:(this._bindingDevices=i.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.did]:t}),{}),null)}catch(e){return r.default.GIZ_SDK_OTHERWISE}}))}};class l{constructor({appID:e,token:t,uid:i,wsInfo:s,onDeviceStatusChanged:r,onBindingChanged:a,onSocketStatusChanged:c}){this.ready=!1,this.commType="attrs_v4",this._heartbeatInterval=60,this._keepaliveTime=180,this._loginIntveral=5e3,this.autoSubscribe=!1,this._websocket=null,this._loginFailedTimes=0,this._subDids=new Set,this._socketRespHandleMap={},this._waitSends=[],this.destory=()=>{this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId),this._checkConnectTimerId&&clearInterval(this._checkConnectTimerId),this.close()},this._networkChange=e=>n(this,void 0,void 0,(function*(){o.default.log("network change",e)})),this._appShow=()=>n(this,void 0,void 0,(function*(){o.default.log("app show")})),this._addSubDid=(...e)=>{e.forEach(e=>this._subDids.add(e))},this._removeSubDid=(...e)=>{e.forEach(e=>this._subDids.delete(e))},this._connectWS=()=>{o.default.log("GIZ_SDK: start connect ws"),this._websocket=wx.connectSocket({url:this._wsUrl,fail:e=>{o.default.error("GIZ_SDK: connectSocket error",new Error(JSON.stringify(e)))}}),this._websocket.onClose(this.handleClose),this._websocket.onOpen(this.handleOpen),this._websocket.onError(this.handleError),this._websocket.onMessage(this.handleMessage),this._checkConnectTimerId||(this._checkConnectTimerId=setInterval(()=>{this._websocket||this._connectWS()},1e3))},this._subDevices=e=>{const t={cmd:"subscribe_req",data:e.map(e=>({did:e}))};this._send(t)},this._unSubDevices=e=>{e.map(e=>this._removeSubDid(e))},this._send=(e,t=!1)=>(o.default.log("GIZ_SDK: Socket send",e,t),new Promise(i=>{this._websocket?t||this.ready?this._websocket&&(t||this.ready)&&this._websocket.send({data:JSON.stringify(e),complete:e=>{o.default.log("GIZ_SDK: socket send res",e),o.default.log("resres",e);let t=!1;"sendSocketMessage:ok"===e.errMsg&&(t=!0),i({success:t,message:e.errMsg})},fail:e=>{o.default.error("GIZ_SDK: Socket send error",new Error(JSON.stringify(e))),i({success:!1,message:e.errMsg})}}):i({success:!1,message:"Socket not ready"}):i({success:!1,message:"Socket not init"})})),this.close=()=>{this.ready=!1,this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId),this._websocket&&(this._websocket.close({}),this._websocket=null),this._currentSocketStatus&&(this._currentSocketStatus=!1,this._handleSocketStatusChanged(!1))},this.handleClose=e=>{o.default.error("GIZ_SDK: socket close",new Error(JSON.stringify(e))),this.close(),this._stopPing()},this.handleOpen=()=>{o.default.log(" socket open"),this._login()},this.handleMessage=({data:e})=>{o.default.log("GIZ_SDK: message",e);const t=JSON.parse(e),i=this._socketRespHandleMap[t.cmd];i&&i(t.data)},this.handleError=e=>{o.default.error("GIZ_SDK: socket error",new Error(JSON.stringify(e))),this.close(),this._stopPing()},this._login=()=>{const e={cmd:"login_req",data:{appid:this.appID,uid:this.uid,token:this.token,p0_type:this.commType,heartbeat_interval:this._keepaliveTime,auto_subscribe:this.autoSubscribe}};this._send(e,!0)},this._tryLoginAgain=()=>{this._loginFailedTimes+=1,setTimeout(()=>{this._login()},this._loginFailedTimes*this._loginIntveral)},this._startPing=()=>{this._heartbeatTimerId=setInterval(()=>{this._send({cmd:"ping"})},1e3*this._heartbeatInterval)},this._stopPing=()=>{this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId)},this.pongResp=()=>{},this._currentSocketStatus=!1,this._loginResp=e=>{1==e.success?(this._loginFailedTimes=0,this.ready=!0,this._startPing(),this._subDevices([...this._subDids]),this._currentSocketStatus=!0,this._handleSocketStatusChanged(this._currentSocketStatus),this._consumeWaitSends()):this._loginFailedTimes<3?(o.default.log("GIZ_SDK: Login failed, will try again, please wait..."),this._tryLoginAgain()):(o.default.error("GIZ_SDK: Login failed",new Error("m2m socket login failed")),this.close())},this._consumeWaitSends=()=>{let e=this._waitSends.pop();for(;e;)this._send(e),e=this._waitSends.pop()},this._handleSocketStatusChanged=e=>{this._onSocketStatusChanged&&this._onSocketStatusChanged([...this._subDids],e)},this._subscribeResp=e=>{o.default.log("GIZ_SDK: subscribe_res",e),e&&e.success&&e.success.forEach(e=>this._send({cmd:"c2s_read",data:{did:e.did}})),o.default.debug("GIZ_SDK: subscribe_res",e)},this._onlineResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged({did:e.did,attrs:Object.assign({is_online:e.online},e)})},this._rawChangedResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._statusChangedResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._isSub=e=>this._subDids.has(e),this._invalidMsgResp=e=>{1003===e.error_code&&this._login(),o.default.error("GIZ_SDK: s2c_invalid_msg",new Error(JSON.stringify(e)))},this._bindingChangedResp=e=>{!e.bind&&e.did&&this._removeSubDid(e.did),this._onBindingChanged&&this._onBindingChanged()},this.appID=e,this.token=t,this.uid=i,this._wsUrl=`${s}/ws/app/v1`,this._heartbeatTimerId=void 0,this._loginFailedTimes=0,this._onDeviceStatusChanged=r,this._onBindingChanged=a,this._onSocketStatusChanged=c,this._socketRespHandleMap={pong:this.pongResp,login_res:this._loginResp,subscribe_res:this._subscribeResp,s2c_online_status:this._onlineResp,s2c_raw:this._rawChangedResp,s2c_noti:this._statusChangedResp,s2c_invalid_msg:this._invalidMsgResp,s2c_binding_changed:this._bindingChangedResp},wx.onNetworkStatusChange(this._networkChange),wx.onAppShow(this._appShow)}}t.Connection=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(12),s=({SSID:e,password:t,pk:i})=>{let s=(0,n.MD5)(e+t).toString();s=n.enc.Hex.parse(s);let r=n.enc.Utf8.parse(i),o=n.AES.encrypt(r,s,{iv:s,mode:n.mode.ECB,padding:n.pad.ZeroPadding});return(0,n.MD5)(o.ciphertext).toString()};t.default=({SSID:e,password:t,pks:i})=>{const n=[];return i.map(i=>{const r=s({SSID:e,password:t,pk:i});n.push(r)}),n}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psKeySign=void 0;const n=i(12);t.psKeySign=e=>{const t=Math.round((new Date).getTime()/1e3),i=e+t;return{Signature:(0,n.MD5)(i).toString(),timestamp:t}}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WxAnonymousLogin=t.AnonymousLogin=void 0;const s=i(7);t.AnonymousLogin=function({uid:e}){return n(this,void 0,void 0,(function*(){return(0,s.cozeApiRequest)("/v3/users/oauth/anonymous",{data:{openid:e},method:"POST"})}))},t.WxAnonymousLogin=function({code:e}){return n(this,void 0,void 0,(function*(){return(0,s.cozeApiRequest)(`/v3/users/oauth/wechat?code=${e}`,{method:"POST"})}))}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(4)),o=s(i(6)),a=s(i(93)),c=s(i(23)),u=s(i(24)),l=i(5);class d extends c.default{constructor(){super(...arguments),this.disableSendUDP=!1,this.sendMessageInterval=null,this.UDPSocketHandler=null,this.destroy=()=>{this.cleanTimeout(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.sendMessageInterval=null,this.UDPSocketHandler&&(this.UDPSocketHandler.offError(),this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.close())},this.configDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>(u.default.appendEvent({name:"START_DISCOVER_DEVICE",message:""}),u.default.appendEvent({name:"DISCOVER_DEVICE_SUCCESS",message:""}),u.default.appendEvent({name:"START_CONNECT_DEVICE",message:""}),u.default.appendEvent({name:"CONNECT_DEVICE_SUCCESS",message:""}),new Promise((s,c)=>{o.default.debug("GIZ_SDK: start config device");let d=!1,h=0;const f=(0,l.getGlobalData)("uid"),p=a.default.pack(e,t,f);this.UDPSocketHandler=wx.createUDPSocket(),this.UDPSocketHandler.bind(),this.disableSendUDP=!1,u.default.appendEvent({name:"START_SEND_WIFI_CONFIG",message:""});let v=!1;const g=()=>{try{!this.disableSendUDP&&this.UDPSocketHandler.send({address:"10.10.100.254",port:12414,message:p,offset:0,length:p.byteLength}),v||(v=!0,u.default.appendEvent({name:"START_SEND_WIFI_CONFIG_SUCCESS",message:""}))}catch(e){}};this.sendMessageInterval=setInterval(()=>{g()},2e3),this.UDPSocketHandler.onError(e=>{h+=1,h>2&&(this.destroy(),u.default.appendEvent({name:"START_SEND_WIFI_CONFIG_FAIL",message:""}),c({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:e.errMsg}}))});const _=()=>n(this,void 0,void 0,(function*(){if(!d){this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.offError(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.disableSendUDP=!0,d=!0;try{s({success:!0,data:[]})}catch(e){c(e)}}}));this.UDPSocketHandler.onMessage(e=>{_()}),wx.onNetworkStatusChange(()=>n(this,void 0,void 0,(function*(){!d&&wx.getConnectedWifi({success:e=>n(this,void 0,void 0,(function*(){-1===e.wifi.SSID.indexOf(i)&&_()}))})})))})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,productKey:i,softAPSSIDPrefix:s})=>{const r=this.ssid,o=this.password;return u.default.init({productKey:i,timeout:e,isBind:t,ssid:this.ssid,mode:0}),u.default.appendEvent({name:"START_WIFI_CONFIG",message:""}),new Promise((t,i)=>n(this,void 0,void 0,(function*(){this.destroy(),this.initDeviceOnboardingDeploy(t,i),this.startTimeoutTimer(e);try{yield this.configDevice({ssid:r,password:o,softAPSSIDPrefix:s});u.default.appendEvent({name:"WIFI_CONFIG_SUCCESS",message:""}),t({success:!0,data:[]})}catch(e){i(e)}finally{this.destroy()}})))}}}t.default=d},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e)}}o.pack=(e,t,i)=>{const n=[],[s,o]=(0,r.formatCodesFromStr)(e),[a,c]=(0,r.formatCodesFromStr)(t),[u,l]=(0,r.formatCodesFromStr)(i),d=[0].concat([0,1],o,s,c,a,l,u);let h=d.length;for(;h>0;)n.push(h),h-=255;const f=[0,0,0,3].concat(n).concat(d),p=new ArrayBuffer(f.length),v=new Uint8Array(p);for(let e=0;e<p.byteLength;e++)v[e]=f[e];return v},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(4)),o=i(9),a=s(i(6)),c=s(i(95)),u=s(i(13)),l=i(33),d=s(i(23)),h=s(i(24)),f=i(5),p=s(i(1));class v extends d.default{constructor(e,t,i,s,d,v){super(e,t,i,s,d),this.retryTimes=0,this.maxRetryTimes=3,this.sendBLEConfigCmd=({bleDeviceId:e,arrayBuffer:t,serviceUUIDSuffix:i="abd0",characteristicUUIDSuffix:s="abd5",bleHandle:r,mac:u,eventCallBack:d})=>{let f=null,v=null;const g=()=>null===v?(f&&clearInterval(f),!0):!this.hasTimeoutHandler();return new Promise((s,_)=>n(this,void 0,void 0,(function*(){try{a.default.debug("GIZ_SDK: ssid info: ",t),v=setTimeout(()=>{f&&clearInterval(f),v=null,s(!1)},5e4),a.default.debug("GIZ_SDK: createBLEConnection start: ",e),yield r.disableScan(),h.default.appendEvent({name:"START_CONNECT_DEVICE",message:""});const n=yield(0,l.retryConnect)(e,i,1e4);if(!n.success)return h.default.appendEvent({name:"CONNECT_DEVICE_FAIL",message:JSON.stringify(n)}),void s(!1);null==d||d({event:"GIZ_CONNECT_SUCCESS",mac:u}),r.enableScan(),a.default.debug("GIZ_SDK: createBLEConnection end, res:",n);const{serviceId:_,characteristics:y,characteristicId:m}=n.data;for(let t=0;t<y.length;t++){const i=y[t];(i.properties.notify||i.properties.indicate)&&(yield(0,l.notifyBLECharacteristicValueChange)(e,_,i.uuid))}null==d||d({event:"GIZ_CONFIG_SEND_SUCCESS",mac:u});const D=e=>{const t=(0,o.ab2hex)(e.value),i=new p.default(e.value);switch(console.debug("protocol",i),i.cmd){case 65:a.default.debug("GIZ_SDK: 收到设备返回ack",t),null==d||d({event:"GIZ_CONFIG_RECV_SUCCESS",mac:u}),h.default.appendEvent({name:"WIFI_CONFIG_RECV_SUCCESS",message:""});break;case 66:{const t=new c.default(e.value);console.debug("wifiprotocol",t),3===t.state&&(r.removeEventListener("GizBleDeviceData",D),t.log.includes("Incorrect WiFi password")?(null==d||d({event:"GIZ_CONFIG_PASSWORD_ERROR",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_PASSWORD_ERROR",message:""})):(null==d||d({event:"GIZ_CONFIG_FAIL",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_FAIL",message:""})),s(!1)),10===t.state&&(r.removeEventListener("GizBleDeviceData",D),s(!0),null==d||d({event:"GIZ_CONFIG_CONNECT_SUCCESS",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_CONNECT_SUCCESS",message:""}));break}}};if(r.addEventListener("GizBleDeviceData",D),wx.onBLECharacteristicValueChange(D),a.default.debug("GIZ_SDK: on notifyBLECharacteristicValueChange success"),g())return;h.default.appendEvent({name:"START_SEND_WIFI_CONFIG",message:""});const S=yield(0,l.unpackWriteBLECharacteristicValue)(e,_,m,t);S.errCode?h.default.appendEvent({name:"START_SEND_WIFI_CONFIG_FAIL",message:JSON.stringify(S)}):h.default.appendEvent({name:"START_SEND_WIFI_CONFIG_SUCCESS",message:""}),f=setInterval(()=>{g()||(0,l.unpackWriteBLECharacteristicValue)(e,_,m,t)},2e3),a.default.debug("GIZ_SDK: unpackWriteBLECharacteristicValue end")}catch(e){_(!1),a.default.debug("GIZ_SDK: sendBLEConfigCmd error",e)}}))).catch(e=>{a.default.debug("GIZ_SDK: sendBLEConfigCmd error",e)}).finally(()=>{v&&clearTimeout(v),f&&clearInterval(f),this.bleHandle.disConnectDevice(e)})},this.destroy=()=>{this.cleanTimeout()},this.isValidBleDevice=(e,t)=>0!==e.bleWorkStatus&&(!!this.specialProductKeys.includes(e.productKey)&&(a.default.debug(`GIZ_SDK: isValidBleDevice mac: ${e.mac} pk: ${e.productKey} name: ${e.name}`),a.default.debug(`GIZ_SDK: softAPSSIDPrefix: ${t} ismatch : ${e.name&&e.name.startsWith(t)}`),!t||e.name&&e.name.startsWith(t)||e.localName&&e.localName.startsWith(t))),this.enableBluetoothDevicesDescovery=()=>n(this,void 0,void 0,(function*(){return(yield(0,l.getBluetoothAdapterState)()).available?(yield(0,l.startBluetoothDevicesDiscovery)(),{success:!0}):{success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON.errorCode,errorMessage:"蓝牙状态不可用"}}})),this.enableAndGetBluetoothDevices=(e,t)=>n(this,void 0,void 0,(function*(){const e=yield this.enableBluetoothDevicesDescovery();if(!e.success)return e;a.default.debug("GIZ_SDK: start enableAndGetBluetoothDevices");let i=this.bleHandle.scanList.filter(e=>e.mac.toUpperCase()==(null==t?void 0:t.toUpperCase()));return a.default.debug("GIZ_SDK: getBluetoothDevices success",i),{success:!0,bleDevices:i}})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i,productKey:s,eventCallBack:r=(e=>{}),mac:o=""})=>(h.default.init({productKey:s,timeout:e,isBind:t,ssid:this.ssid,mode:3}),h.default.appendEvent({name:"START_WIFI_CONFIG",message:""}),this.eventCallBack=r,new Promise((t,s)=>n(this,void 0,void 0,(function*(){var n;this.bleHandle.scanList=[];try{const e=yield(0,l.getConnectedBluetoothDevices)();e.length>0&&e.forEach(e=>{this.bleHandle.disConnectDevice(e.deviceId)})}catch(e){a.default.debug("GIZ_SDK: getConnectedBluetoothDevices error",e)}null===(n=this.eventCallBack)||void 0===n||n.call(this,{event:"GIZ_CONFIG_START",mac:o});const r=this.ssid,c=this.password;this.destroy(),this.initDeviceOnboardingDeploy(t,s),this.startTimeoutTimer(e);try{const n=((yield this.configBLEDevice({ssid:r,password:c,timeout:1e3*e,softAPSSIDPrefix:i,mac:o})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",localName:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));h.default.appendEvent({name:"WIFI_CONFIG_SUCCESS",message:JSON.stringify(n)}),t({success:!0,data:n})}catch(e){console.error("GIZ_SDK: setDeviceOnboardingDeploy error",e),h.default.appendEvent({name:"WIFI_CONFIG_FAIL",message:`${e}`}),t({success:!1,data:e})}finally{this.destroy()}})))),this.configBLEDevice=({ssid:e,password:t,softAPSSIDPrefix:i,mac:s})=>new Promise((d,p)=>n(this,void 0,void 0,(function*(){a.default.debug("GIZ_SDK: start config ble device"),yield(0,l.startBluetoothDevicesDiscovery)(!0),h.default.appendEvent({name:"START_DISCOVER_DEVICE",message:""});const v=yield this.enableAndGetBluetoothDevices(i,s).catch(e=>(h.default.appendEvent({name:"DISCOVER_DEVICE_FAIL",message:JSON.stringify(e)}),{success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:JSON.stringify(e)}}));if(!(0,o.isWXDevicesResult)(v))return p(v);let g=v.bleDevices;a.default.debug("GIZ_SDK: enableAndGetBluetoothDevices success, target devices: ",g);let _=null;const y=(0,f.getGlobalData)("uid"),m=c.default.pack(e,t,y),D=()=>n(this,void 0,void 0,(function*(){var e;if(a.default.debug("GIZ_SDK: startConfigDevice"),this.hasTimeoutHandler())if(_=g.find(e=>e.mac.toUpperCase()==(null==s?void 0:s.toUpperCase())),_&&(null===(e=this.eventCallBack)||void 0===e||e.call(this,{event:"GIZ_DISCOVER_SUCCESS",mac:_.mac}),h.default.appendEvent({name:"DISCOVER_DEVICE_SUCCESS",message:JSON.stringify(_)}),a.default.debug("GIZ_SDK: startConfigDevice, target device: ",_)),_){if(h.default.updateProductKey(_.productKey),!0===(yield this.sendBLEConfigCmd({bleDeviceId:_.bleDeviceID,arrayBuffer:m.buffer,bleHandle:this.bleHandle,eventCallBack:this.eventCallBack,mac:_.mac})))try{const e=yield this.searchDevice({mac:_.mac,productKey:_.productKey});d(e)}catch(e){p(e),a.default.error("GIZ_SDK: searchDevice error",new Error(JSON.stringify(e)))}else p({success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_DEVICE_SEND_FAILED.errorCode,errorMessage:r.default.GIZ_SDK_BLE_DEVICE_SEND_FAILED.errorMessage}})}else{if(this.retryTimes++,this.retryTimes<=this.maxRetryTimes)return yield(0,u.default)(2e3),g=this.bleHandle.scanList.filter(e=>e.mac.toUpperCase()==(null==s?void 0:s.toUpperCase())),console.log("this.bleHandle.scanList",this.bleHandle.scanList),void(yield D());this.retryTimes=0,p({success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_DEVICE_NOT_FOUND.errorCode,errorMessage:r.default.GIZ_SDK_BLE_DEVICE_NOT_FOUND.errorMessage}})}}));yield D()}))),this.bleHandle=v}}t.default=v},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(9),r=n(i(1)),o=i(34),a=i(3);class c extends r.default{constructor(e){super(e),this.state=-1,this.logLen=0,this.log="",this.logBytes=new Uint8Array,this.state=this.payload[0],this.logLen=this.payload[1],this.logLen>0&&(this.logBytes=this.payload.slice(2,2+this.logLen),this.log=(0,s.getPayloadAsUtf8String)(this.logBytes))}}c.pack=(e,t,i)=>{const n=o.snManager.getSn(),s=Math.floor(Date.now()/1e3),r=[n],[c,u]=(0,a.formatCodesFromStr)(e);let l=[],d=0;i&&([l,d]=(0,a.formatCodesFromStr)(i));const[h,f]=(0,a.formatCodesFromStr)(t),p=[s>>24&255,s>>16&255,s>>8&255,255&s],v=[u,...c,0,f,...h,d,...l];console.debug("contentcontentcontentcontent",u,e);const g=[4,64,...r,...[v.length+4],...p,...v];return new Uint8Array(g)},t.default=c},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(97),o=i(98),a=i(99),c=i(101),u=s(i(23));class l extends u.default{constructor(e,t,i,s,u,l){super(e,t,i,s,u),this.address="",this.destroy=()=>{this.cleanTimeout()},this.configDevice=({ssid:e,password:t,bssid:i,address:s})=>n(this,void 0,void 0,(function*(){const{SSIDTLV:n,isSSIDIncludedCH:u}=(0,a.formatSSID)(e),l=(0,o.formatData)(i,"BSSID"),d=(0,o.formatData)(t,"pwd"),h=(0,o.formatData)(s,"address"),f=(0,r.disposeData)(n,u,d,h,l);return console.log(f,"DATA"),(0,c.transceive)(f),yield this.searchDevice({mac:"",productKey:""})})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0})=>{const i=this.ssid,s=this.password;return new Promise((r,o)=>n(this,void 0,void 0,(function*(){console.log("ssid0",i,s,this.bssid,this.address),this.destroy(),this.initDeviceOnboardingDeploy(r,o),this.startTimeoutTimer(e),console.log("ssid",i,s,this.bssid,this.address);try{const e=((yield this.configDevice({ssid:i,password:s,bssid:this.bssid,address:this.address})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,localName:"",name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));if(t)try{r(yield this.bindDevices(e))}catch(e){o(e)}else r({success:!0,data:e})}catch(e){o(e)}finally{this.destroy()}})))},this.address=l}}t.default=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disposeData=void 0;t.disposeData=(e,t,i,n,s)=>{const r=(()=>{const e=new ArrayBuffer(1),t=new Uint8Array(e);return t[0]=1,t})(),o=(e=>{const t=new ArrayBuffer(1),i=new Uint8Array(t);return i[0]=0,e&&(i[0]=1),i})(t),a=(()=>{const e=new ArrayBuffer(2),t=new Uint8Array(e);return t[0]=parseInt("0x55",16),t[1]=parseInt("0xaa",16),t})(),c=Uint8Array.from([...r,...o,...a]),u=Uint8Array.from([...e,...i,...n,...s]);return console.log(c.buffer,"uint8Array_sign.buffer",c),console.log(u.buffer,"uint8Array_others.buffer",u),{ArrayBuffer_sign:c.buffer,ArrayBuffer_others:u.buffer}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatData=void 0;t.formatData=(e,t)=>{const i=0===e.length,n="BSSID"===t?e.split(":"):e.split("");let s=0,r=null,o=0;switch(t){case"BSSID":s=i?3:n.length+2,r="b",o=i?0:n.length;break;case"pwd":s=e.length+2,r="p",o=e.length;break;case"address":s=i?3:n.length+2,r="i",o=i?0:n.length}const a=new ArrayBuffer(s),c=new Uint8Array(a);return c[0]=r.charCodeAt(0),c[1]=o,i?c[2]=0:n.forEach((e,i)=>{const n="BSSID"===t?parseInt(e,16):e.charCodeAt(0);c[i+2]=n}),console.log(a,c,"formatData",t),c}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.formatSSID=void 0;const s=i(3),r=n(i(100));t.formatSSID=e=>{const t={SSIDTLV:null,isSSIDIncludedCH:(0,r.default)(e)},[i,n]=(0,s.formatCodesFromStr)(e),o=parseInt((0,s.arrayToString)([n]),16);if(o<=127){const e=new ArrayBuffer(o+2),n=new Uint8Array(e);n[0]="s".charCodeAt(0),n[1]=o,i.forEach((e,t)=>{n[t+2]=e}),t.SSIDTLV=n}else{const e=parseInt(n/255)+1,s=new ArrayBuffer(o+2+e),r=new Uint8Array(s);if(r[0]="s".charCodeAt(0),r[1]=128+e,1===e)r[2]=o;else{r[e]=255,r[e+1]=o-255*(e-1);for(let t=e;t>=1;t--)0===r[e-t]&&(r[e-t]=255)}i.forEach((t,i)=>{r[i+2+e]=t}),t.SSIDTLV=r}return t}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return/.*[\u4e00-\u9fa5]+.*$/.test(e)}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.transceive=void 0;const s=i(102),r=i(103);t.transceive=e=>{const t=wx.getNFCAdapter();t.startDiscovery(),t.onDiscovered(i=>n(void 0,void 0,void 0,(function*(){console.log(i,"onDiscovered");let n=!0;const{success:o,nfcA:a}=yield(0,s.nfcAConnect)(t);if(o){const t=e.ArrayBuffer_others.byteLength,i=parseInt(t%4),s=parseInt(t/4);let o=s;const c=new Uint8Array(e.ArrayBuffer_others);for(let e=0;e<=4*s-4;e+=4){if(o>0){const t=new ArrayBuffer(6),i=new Uint8Array(t),u=49+s-o;i[0]=parseInt("0xa2",16),i[1]=u,i[2]=c[0+e],i[3]=c[1+e],i[4]=c[2+e],i[5]=c[3+e];const{transceiveSuccess:l}=yield(0,r.nfcATransceive)(a,t);if(o-=1,!l){n=!1,wx.hideLoading(),wx.showToast({title:"NFC写入失败!",icon:"error",duration:2e3});break}}if(0!==i&&n){const e=new ArrayBuffer(6),n=new Uint8Array(e),o=49+s;switch(n[0]=parseInt("0xa2",16),n[1]=o,i){case 1:n[2]=c[t-1];break;case 2:n[2]=c[t-2],n[3]=c[t-1];break;case 3:n[2]=c[t-3],n[3]=c[t-2],n[4]=c[t-1]}const{transceiveSuccess:u}=yield(0,r.nfcATransceive)(a,e);u||(wx.hideLoading(),wx.showToast({title:"NFC写入失败!",icon:"error",duration:2e3}))}}const u=new ArrayBuffer(6),l=new Uint8Array(u),d=new Uint8Array(e.ArrayBuffer_sign);l[0]=parseInt("0xa2",16),l[1]=48,l[2]=d[0],l[3]=d[1],l[4]=d[2],l[5]=d[3];const{transceiveSuccess:h}=yield(0,r.nfcATransceive)(a,u);wx.hideLoading(),wx.showToast(h?{title:"NFC写入成功!",icon:"success",duration:2e3}:{title:"NFC写入失败!",icon:"error",duration:2e3}),a.close()}else wx.hideLoading(),wx.showToast({title:"NFC连接失败!",icon:"error",duration:2e3})})))}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nfcAConnect=void 0;t.nfcAConnect=e=>new Promise(t=>{const i=e.getNfcA();i.connect({success(){t({success:!0,nfcA:i})},fail(){t({success:!1,nfcA:i})}})})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nfcATransceive=void 0;t.nfcATransceive=(e,t)=>new Promise(i=>{e.transceive({data:t,success:e=>{console.log("success",e),i({transceiveSuccess:!0})},fail:e=>{console.log("fail",e),i({transceiveSuccess:!1})}})})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OtaStatus=void 0,function(e){e.CHECKING="CHECKING",e.LATEST="LATEST",e.UPDATE_AVAILABLE="UPDATE_AVAILABLE",e.UPDATING="UPDATING",e.UPDATE_SUCCESS="UPDATE_SUCCESS"}(t.OtaStatus||(t.OtaStatus={}))}]);
|
|
25
|
+
var n=i(70),s=i(71),r=i(72);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,i){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,i);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return u(this,e,t,i)}function u(e,t,i,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,i,n){if(t.byteLength,i<0||t.byteLength<i)throw new RangeError("'offset' is out of bounds");if(t.byteLength<i+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===i&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,i):new Uint8Array(t,i,n);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,i,n):"string"==typeof t?function(e,t,i){"string"==typeof i&&""!==i||(i="utf8");if(!c.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,i),s=(e=a(e,n)).write(t,i);s!==n&&(e=e.slice(0,s));return e}(e,t,i):function(e,t){if(c.isBuffer(t)){var i=0|f(t.length);return 0===(e=a(e,i)).length||t.copy(e,0,0,i),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):h(e,t);if("Buffer"===t.type&&r(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 d(e,t){if(l(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var i=0;i<t;++i)e[i]=0;return e}function h(e,t){var i=t.length<0?0:0|f(t.length);e=a(e,i);for(var n=0;n<i;n+=1)e[n]=255&t[n];return e}function f(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 i=e.length;if(0===i)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return K(e).length;default:if(n)return G(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,i){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return k(this,t,i);case"utf8":case"utf-8":return A(this,t,i);case"ascii":return E(this,t,i);case"latin1":case"binary":return B(this,t,i);case"base64":return C(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,i);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function _(e,t,i,n,s){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(s)return-1;i=e.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:y(e,t,i,n,s);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):y(e,[t],i,n,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,i,n,s){var r,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,i/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(s){var l=-1;for(r=i;r<a;r++)if(u(e,r)===u(t,-1===l?0:r-l)){if(-1===l&&(l=r),r-l+1===c)return l*o}else-1!==l&&(r-=r-l),l=-1}else for(i+c>a&&(i=a-c),r=i;r>=0;r--){for(var d=!0,h=0;h<c;h++)if(u(e,r+h)!==u(t,h)){d=!1;break}if(d)return r}return-1}function m(e,t,i,n){i=Number(i)||0;var s=e.length-i;n?(n=Number(n))>s&&(n=s):n=s;var r=t.length;if(r%2!=0)throw new TypeError("Invalid hex string");n>r/2&&(n=r/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[i+o]=a}return o}function D(e,t,i,n){return F(G(t,e.length-i),e,i,n)}function S(e,t,i,n){return F(function(e){for(var t=[],i=0;i<e.length;++i)t.push(255&e.charCodeAt(i));return t}(t),e,i,n)}function b(e,t,i,n){return S(e,t,i,n)}function w(e,t,i,n){return F(K(t),e,i,n)}function I(e,t,i,n){return F(function(e,t){for(var i,n,s,r=[],o=0;o<e.length&&!((t-=2)<0);++o)i=e.charCodeAt(o),n=i>>8,s=i%256,r.push(s),r.push(n);return r}(t,e.length-i),e,i,n)}function C(e,t,i){return 0===t&&i===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,i))}function A(e,t,i){i=Math.min(e.length,i);for(var n=[],s=t;s<i;){var r,o,a,c,u=e[s],l=null,d=u>239?4:u>223?3:u>191?2:1;if(s+d<=i)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(r=e[s+1]))&&(c=(31&u)<<6|63&r)>127&&(l=c);break;case 3:r=e[s+1],o=e[s+2],128==(192&r)&&128==(192&o)&&(c=(15&u)<<12|(63&r)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:r=e[s+1],o=e[s+2],a=e[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&r)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),s+=d}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var i="",n=0;for(;n<t;)i+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return i}(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,i){return u(null,e,t,i)},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,i){return function(e,t,i,n){return l(t),t<=0?a(e,t):void 0!==i?"string"==typeof n?a(e,t).fill(i,n):a(e,t).fill(i):a(e,t)}(null,e,t,i)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(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 i=e.length,n=t.length,s=0,r=Math.min(i,n);s<r;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?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(!r(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var i;if(void 0===t)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=c.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=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)g(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)g(this,t,t+3),g(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)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):v.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="",i=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,i,n,s){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(this===e)return 0;for(var r=(s>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0),a=Math.min(r,o),u=this.slice(n,s),l=e.slice(t,i),d=0;d<a;++d)if(u[d]!==l[d]){r=u[d],o=l[d];break}return r<o?-1:o<r?1:0},c.prototype.includes=function(e,t,i){return-1!==this.indexOf(e,t,i)},c.prototype.indexOf=function(e,t,i){return _(this,e,t,i,!0)},c.prototype.lastIndexOf=function(e,t,i){return _(this,e,t,i,!1)},c.prototype.write=function(e,t,i,n){if(void 0===t)n="utf8",i=this.length,t=0;else if(void 0===i&&"string"==typeof t)n=t,i=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(i)?(i|=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}var s=this.length-t;if((void 0===i||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var r=!1;;)switch(n){case"hex":return m(this,e,t,i);case"utf8":case"utf-8":return D(this,e,t,i);case"ascii":return S(this,e,t,i);case"latin1":case"binary":return b(this,e,t,i);case"base64":return w(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,i);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),r=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(e,t,i){var n="";i=Math.min(e.length,i);for(var s=t;s<i;++s)n+=String.fromCharCode(127&e[s]);return n}function B(e,t,i){var n="";i=Math.min(e.length,i);for(var s=t;s<i;++s)n+=String.fromCharCode(e[s]);return n}function k(e,t,i){var n=e.length;(!t||t<0)&&(t=0),(!i||i<0||i>n)&&(i=n);for(var s="",r=t;r<i;++r)s+=H(e[r]);return s}function T(e,t,i){for(var n=e.slice(t,i),s="",r=0;r<n.length;r+=2)s+=String.fromCharCode(n[r]+256*n[r+1]);return s}function O(e,t,i){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>i)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,i,n,s,r){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<r)throw new RangeError('"value" argument is out of bounds');if(i+n>e.length)throw new RangeError("Index out of range")}function P(e,t,i,n){t<0&&(t=65535+t+1);for(var s=0,r=Math.min(e.length-i,2);s<r;++s)e[i+s]=(t&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function L(e,t,i,n){t<0&&(t=4294967295+t+1);for(var s=0,r=Math.min(e.length-i,4);s<r;++s)e[i+s]=t>>>8*(n?s:3-s)&255}function M(e,t,i,n,s,r){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function R(e,t,i,n,r){return r||M(e,0,i,4),s.write(e,t,i,n,23,4),i+4}function N(e,t,i,n,r){return r||M(e,0,i,8),s.write(e,t,i,n,52,8),i+8}c.prototype.slice=function(e,t){var i,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)(i=this.subarray(e,t)).__proto__=c.prototype;else{var s=t-e;i=new c(s,void 0);for(var r=0;r<s;++r)i[r]=this[r+e]}return i},c.prototype.readUIntLE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e],s=1,r=0;++r<t&&(s*=256);)n+=this[e+r]*s;return n},c.prototype.readUIntBE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},c.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||O(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||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=this[e],s=1,r=0;++r<t&&(s*=256);)n+=this[e+r]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||O(e,t,this.length);for(var n=t,s=1,r=this[e+--n];n>0&&(s*=256);)r+=this[e+--n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},c.prototype.readInt32LE=function(e,t){return t||O(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||O(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||O(e,4,this.length),s.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),s.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),s.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),s.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,i,n){(e=+e,t|=0,i|=0,n)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var s=1,r=0;for(this[t]=255&e;++r<i&&(s*=256);)this[t+r]=e/s&255;return t+i},c.prototype.writeUIntBE=function(e,t,i,n){(e=+e,t|=0,i|=0,n)||x(this,e,t,i,Math.pow(2,8*i)-1,0);var s=i-1,r=1;for(this[t+s]=255&e;--s>=0&&(r*=256);)this[t+s]=e/r&255;return t+i},c.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||x(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,i){return e=+e,t|=0,i||x(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||x(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t|=0,!n){var s=Math.pow(2,8*i-1);x(this,e,t,i,s-1,-s)}var r=0,o=1,a=0;for(this[t]=255&e;++r<i&&(o*=256);)e<0&&0===a&&0!==this[t+r-1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+i},c.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t|=0,!n){var s=Math.pow(2,8*i-1);x(this,e,t,i,s-1,-s)}var r=i-1,o=1,a=0;for(this[t+r]=255&e;--r>=0&&(o*=256);)e<0&&0===a&&0!==this[t+r+1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+i},c.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||x(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,i){return e=+e,t|=0,i||x(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||x(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||x(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):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,i){return R(this,e,t,!0,i)},c.prototype.writeFloatBE=function(e,t,i){return R(this,e,t,!1,i)},c.prototype.writeDoubleLE=function(e,t,i){return N(this,e,t,!0,i)},c.prototype.writeDoubleBE=function(e,t,i){return N(this,e,t,!1,i)},c.prototype.copy=function(e,t,i,n){if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=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-i&&(n=e.length-t+i);var s,r=n-i;if(this===e&&i<t&&t<n)for(s=r-1;s>=0;--s)e[s+t]=this[s+i];else if(r<1e3||!c.TYPED_ARRAY_SUPPORT)for(s=0;s<r;++s)e[s+t]=this[s+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+r),t);return r},c.prototype.fill=function(e,t,i,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,i=this.length):"string"==typeof i&&(n=i,i=this.length),1===e.length){var s=e.charCodeAt(0);s<256&&(e=s)}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<i)throw new RangeError("Out of range index");if(i<=t)return this;var r;if(t>>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(r=t;r<i;++r)this[r]=e;else{var o=c.isBuffer(e)?e:G(new c(e,n).toString()),a=o.length;for(r=0;r<i-t;++r)this[r+t]=o[r%a]}return this};var U=/[^+\/0-9A-Za-z-_]/g;function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function G(e,t){var i;t=t||1/0;for(var n=e.length,s=null,r=[],o=0;o<n;++o){if((i=e.charCodeAt(o))>55295&&i<57344){if(!s){if(i>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&r.push(239,191,189);continue}s=i;continue}if(i<56320){(t-=3)>-1&&r.push(239,191,189),s=i;continue}i=65536+(s-55296<<10|i-56320)}else s&&(t-=3)>-1&&r.push(239,191,189);if(s=null,i<128){if((t-=1)<0)break;r.push(i)}else if(i<2048){if((t-=2)<0)break;r.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;r.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;r.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return r}function K(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,i,n){for(var s=0;s<n&&!(s+i>=t.length||s>=e.length);++s)t[s+i]=e[s];return s}}).call(this,i(15))},function(e,t,i){"use strict";t.byteLength=function(e){var t=u(e),i=t[0],n=t[1];return 3*(i+n)/4-n},t.toByteArray=function(e){var t,i,n=u(e),o=n[0],a=n[1],c=new r(function(e,t,i){return 3*(t+i)/4-i}(0,o,a)),l=0,d=a>0?o-4:o;for(i=0;i<d;i+=4)t=s[e.charCodeAt(i)]<<18|s[e.charCodeAt(i+1)]<<12|s[e.charCodeAt(i+2)]<<6|s[e.charCodeAt(i+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=s[e.charCodeAt(i)]<<2|s[e.charCodeAt(i+1)]>>4,c[l++]=255&t);1===a&&(t=s[e.charCodeAt(i)]<<10|s[e.charCodeAt(i+1)]<<4|s[e.charCodeAt(i+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},t.fromByteArray=function(e){for(var t,i=e.length,s=i%3,r=[],o=0,a=i-s;o<a;o+=16383)r.push(l(e,o,o+16383>a?a:o+16383));1===s?(t=e[i-1],r.push(n[t>>2]+n[t<<4&63]+"==")):2===s&&(t=(e[i-2]<<8)+e[i-1],r.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return r.join("")};for(var n=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a<c;++a)n[a]=o[a],s[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 i=e.indexOf("=");return-1===i&&(i=t),[i,i===t?0:4-i%4]}function l(e,t,i){for(var s,r,o=[],a=t;a<i;a+=3)s=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(r=s)>>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]);return o.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,i,n,s){var r,o,a=8*s-n-1,c=(1<<a)-1,u=c>>1,l=-7,d=i?s-1:0,h=i?-1:1,f=e[t+d];for(d+=h,r=f&(1<<-l)-1,f>>=-l,l+=a;l>0;r=256*r+e[t+d],d+=h,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=n;l>0;o=256*o+e[t+d],d+=h,l-=8);if(0===r)r=1-u;else{if(r===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),r-=u}return(f?-1:1)*o*Math.pow(2,r-n)},t.write=function(e,t,i,n,s,r){var o,a,c,u=8*r-s-1,l=(1<<u)-1,d=l>>1,h=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:r-1,p=n?1:-1,v=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=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(t*c-1)*Math.pow(2,s),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,s),o=0));s>=8;e[i+f]=255&a,f+=p,a/=256,s-=8);for(o=o<<s|a,u+=s;u>0;e[i+f]=255&o,f+=p,o/=256,u-=8);e[i+f-p]|=128*v}},function(e,t){var i={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==i.call(e)}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(74)),r=n(i(30));t.default=(0,r.default)("crc-32",s.default)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let n=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"!=typeof Int32Array&&(n=new Int32Array(n));t.default=(e,t)=>{let i=0===t?0:-1^~~t;for(let t=0;t<e.length;t++)i=n[255&(i^e[t])]^i>>>8;return-1^i}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{}o.pack=()=>{const e=parseInt(`${Date.now()/1e3}`,10),t=(0,r.fillString)(e.toString(2),40);return[0,0,0,3,8,0,0,89].concat((0,r.completeBlock)(t))},t.default=o},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CancelSync=t.DeletePackage=t.SyncPackage=t.RequestSync=void 0;const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e),this.state=0,this.len=0}}t.RequestSync=o,o.pack=()=>[0,0,0,3,3,0,0,113];class a extends s.default{constructor(e){super(e),this.id=0,this.timestemp=0,this.payloadLen=0}}t.SyncPackage=a,a.pack=e=>{let t=e.toString(2);return t=(0,r.fillString)(t,16),[0,0,0,3,5].concat([0,0,115]).concat((0,r.completeBlock)(t))};class c extends s.default{}t.DeletePackage=c,c.pack=e=>{let t=e.toString(2);return t=(0,r.fillString)(t,16),[0,0,0,3,5].concat([0,0,117]).concat((0,r.completeBlock)(t))};class u extends s.default{constructor(e){super(e),this.state=0}}t.CancelSync=u,u.pack=()=>[0,0,0,3,3,0,0,119]},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(20)),o=s(i(1)),a=i(3);class c extends o.default{}c.pack=(e,t,i)=>n(void 0,void 0,void 0,(function*(){const n=yield r.default.getConfigFile(e);if(n){const e="var_len"===n.protocolType,s=[0,0,0,3],r=[0];let o=[0];const c=[0,147];let u=[0,0,0,0],l=[2];if(t){o=[1];const e=(0,a.fillString)(t.length.toString(16),4),i=(0,a.hexStrint2byte)(e),n=(0,a.string2Bytes)(t);u=u.concat(i).concat(n)}if(e){l=[18];let e="";if(i){const t=i.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:1}),{});n.entities[0].attrs.map(i=>{e=t[i.name]?`1${e}`:`0${e}`})}else n.entities[0].attrs.map(()=>{e=`1${e}`});e=(0,a.fillString)(e,8*Math.ceil(e.length/8)),l=l.concat((0,a.hexStrint2byte)(parseInt(e,2).toString(16)))}const d=o.concat(c).concat(u).concat(l);return r[0]=d.length,s.concat(r).concat(d)}return null})),t.default=c},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e),this.result=!1,this.didLength=0,this.did=""}}o.pack=({passcode:e})=>{let t=[0];const i=(0,r.hexStrint2byte)((0,r.fillString)(e.length.toString(16),4)),n=(0,r.string2Bytes)(e),s=[0].concat([0,8]).concat(i).concat(n);return t=(0,r.hexStrint2byte)(s.length.toString(16)),[0,0,0,3].concat(t).concat(s)},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.reportEvent=void 0;const r=i(16),o=i(5),a=s(i(7));const c=new class{constructor(){wx.getSystemInfoAsync({success:e=>{this.app={wxSdkVersion:e.SDKVersion,gizwitsSdkVersion:r.version,appID:"unknown",bluetoothEnabled:e.bluetoothEnabled,locationEnabled:e.locationEnabled,wifiEnabled:e.wifiEnabled},this.mobile={brand:e.brand,model:e.model,pixelRatio:e.pixelRatio,systemVersion:e.system,platform:e.platform}}})}updateAppId(e){this.app.appID=e}};t.reportEvent=function({device:e,eventID:t,eventType:i,success:s,failureType:r}){return n(this,void 0,void 0,(function*(){c.updateAppId((0,o.getGlobalData)("appID")||"unknown");const n=`/v2/products/${e.productKey}/devices/bluetooth-connect-data`,u=new Date,l={origin:"MINI-WX",mobileInfo:c.mobile,userInfo:null,appInfo:c.app,eventID:t,eventType:i,monitorTarget:{device:e,success:s,failureType:r},time:u,timeStamp:Math.floor(u.getTime()/1e3)};return(0,a.default)(n,{data:l,method:"POST"},!0)}))}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.moduleSoftVersion="",this.moduleHardVersion="",this.mcuSoftVersion="",this.mcuHardVersion="",this.businessVersion="";let t=0;t+=8}}r.pack=()=>[0,0,0,3,3,0,0,19],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.type="MCU",this.state=0,this.version=0}}r.pack=e=>[0,0,0,3,4,0,0,65,"MCU"===e?2:1],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(21),r=n(i(1)),o=i(3);class a extends r.default{constructor(e){super(e),this.state=0,this.processedLen=0,this.processedCrc32="",this.packageMaxLen=20}}a.pack=(e,t,i,n,r)=>{const a=(0,o.string2Bytes)(e),c=e.length,u=(0,o.string2Bytes)((0,o.fillString)(t,8)),l=(0,o.hexStrint2byte)(i),d=(0,o.hexStrint2byte)((0,o.fillString)(r.toString(16),8)),h=(0,o.hexStrint2byte)((0,o.fillString)(n.toString(16),8));let f=[0];f=f.concat([0,67],[c],a,u,l,h,d);const p=(0,s.getVariableLength)(f);return[0,0,0,3].concat(p,f)},t.default=a},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e)}}o.pack=e=>[0,0,0,3,7,0,0,69,...(0,r.hexStrint2byte)((0,r.fillString)(e.toString(16),8))],t.default=o},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(19),r=i(21),o=n(i(1)),a=i(3);class c extends o.default{constructor(e){super(e),this.packageNum=0,this.state=0;let t=0;t+=2}}c.pack=(e,t)=>{const i=(0,a.hexStrint2byte)((0,a.fillString)(t.toString(16),4)),n=(0,a.hexStrint2byte)((0,a.fillString)(e.length.toString(16),4)),o=(0,a.fillString)((0,s.crc16modbus)(new Uint8Array(e)).toString(16),4),c=(0,a.hexStrint2byte)(o);let u=[0];u=u.concat([0,71],i,n,c,e);const l=(0,r.getVariableLength)(u);return[0,0,0,3].concat(l,u)},t.default=c},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.state=0}}r.pack=e=>[0,0,0,3],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1));class r extends s.default{constructor(e){super(e),this.state=0}}r.pack=e=>[0,0,0,3,4,0,0,80,e],t.default=r},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(34);class o extends s.default{constructor(e){super(e),this.parse=()=>{const e=[];let t=0;for(;t<this.payload.length;){const i=this.payload[t];if(0===i||t+1+i>this.payload.length)break;const n=this.payload.slice(t+1,t+1+i);let s="";for(let e=0;e<n.length;e++)s+="%"+("0"+n[e].toString(16)).slice(-2);let r="";try{console.log("utf8str",s),r=decodeURIComponent(s)}catch(e){console.error("decodeURIComponent error",e,s)}t+=1+i,e.push({ssid:r,rssi:this.payload[t]-100}),t+=1}return e}}}o.pack=()=>{const e=[4,69,...[r.snManager.getSn()],0];return new Uint8Array(e)},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=void 0;const r=s(i(4)),o=s(i(6)),a=s(i(7)),c=i(9),u=i(22);t.default=class{constructor({appID:e,token:t,uid:i,limitSocketNum:s=!0}){this._bindingDevices=null,this._connections={},this.updateToken=({token:e,uid:t})=>{this.token=e,this.uid=t},this._getDevice=e=>{if(null===this._bindingDevices)return r.default.GIZ_SDK_SDK_NOT_INITIALIZED;const t=this._bindingDevices[e];return null==t?r.default.GIZ_OPENAPI_DEVICE_NOT_BOUND:t},this._getConnect=e=>{const t=this._getWebsocketConnInfo(e);return this._connections[t]},this._getDeviceAndConnect=e=>{const t=this._getDevice(e);if((0,c.isError)(t))return t;const i=this._getConnect(t);return null==i?r.default.GIZ_SDK_DEVICE_NOT_SUBSCRIBED:[t,i]},this.connectDevice=e=>{const t=this._getWebsocketConnInfo(e);let i=this._connections[t];if(null==i){const e=Object.keys(this._connections).length;if(0!==this._maxSocketNum&&e>=this._maxSocketNum)return{success:!1,errorCode:r.default.MAX_CONNECT};i=new l({appID:this.appID,token:this.token,uid:this.uid,wsInfo:t,onDeviceStatusChanged:this._handleDeviceStatusChanged,onBindingChanged:this._handleBindingChanged,onSocketStatusChanged:this._handleSocketStatusChanged}),this._connections[t]=i}return i._addSubDid(e.did),null==i._websocket?i._connectWS():i.ready&&i._subDevices([e.did]),{success:!0}},this.connectDevices=e=>{const t={};e.forEach(e=>{const i=this._getWebsocketConnInfo(e);t[i]||(t[i]=[]),t[i].push(e.did)});const i=Object.keys(t).filter(e=>null==this._connections[e]).length,n=Object.keys(this._connections).length;return 0!==this._maxSocketNum&&n+i>this._maxSocketNum?{success:!1,errorCode:r.default.MAX_CONNECT}:(Object.entries(t).forEach(([e,t])=>{let i=this._connections[e];null==i&&(i=new l({appID:this.appID,token:this.token,uid:this.uid,wsInfo:e,onDeviceStatusChanged:this._handleDeviceStatusChanged,onBindingChanged:this._handleBindingChanged,onSocketStatusChanged:this._handleSocketStatusChanged}),this._connections[e]=i),i._addSubDid(...t),null==i._websocket?i._connectWS():i.ready&&i._subDevices(t)}),{success:!0})},this.disConnectDevice=e=>{const t=this._getWebsocketConnInfo(e);let i=this._connections[t];return i&&i._unSubDevices([e.did]),{success:!0}},this.disConnectDevices=e=>{const t={};return e.forEach(e=>{const i=this._getWebsocketConnInfo(e);t[i]||(t[i]=[]),t[i].push(e.did)}),Object.entries(t).forEach(([e,t])=>{const i=this._connections[e];i&&i._unSubDevices(t)}),{success:!0}},this.connect=e=>{const t=this._getDevice(e);if((0,c.isError)(t))return t;const i=this.connectDevice(t);return i.success?null:i.errorCode},this.send=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_raw",data:{did:e,raw:t}})},this.writeData=(e,t)=>n(this,void 0,void 0,(function*(){const i=yield(0,u.updateDevicesStatus)({data:[{id:e.did,product_key:e.productKey,mac:e.mac,qos:0,property:t}]});if(i.success){const e=i.data.data[0];return e.error?{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE.errorCode,message:e.msg}:{success:!0}}return{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE}})),this.write=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_write",data:{did:e,attrs:t}})},this.readStatus=(e,t)=>n(this,void 0,void 0,(function*(){const t=yield(0,u.getDevicesStatus)(e.did);if(t.success){return{success:!0,data:t.data.data.property}}return{success:!1,errorCode:r.default.GIZ_SDK_OTHERWISE,data:{}}})),this.read=(e,t)=>{const i=this._getDeviceAndConnect(e);return(0,c.isError)(i)?i:i[1]._send({cmd:"c2s_read",data:{did:e,names:t}})},this.destory=()=>{Object.values(this._connections).forEach(e=>e.destory())},this.subscribeDeviceStatus=e=>{this._onDeviceStatusChanged=e},this.subscribeBindingChanged=e=>{this._onBindingChanged=e},this.subscribeSocketStatus=e=>{this._onSocketStatusChanged=e},this._handleDeviceStatusChanged=e=>{this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._handleBindingChanged=()=>{this._onBindingChanged&&this._onBindingChanged()},this._handleSocketStatusChanged=(...e)=>{this._onSocketStatusChanged&&this._onSocketStatusChanged(...e)},this._getBindingList=(e=20,t=0,i=[])=>n(this,void 0,void 0,(function*(){const n=`/app/bindings?show_disabled=0&limit=${e}&skip=${t}`,{err:s,data:r}=yield(0,a.default)(`${n}`,{method:"GET"});if(s)return{err:s};const o=[...i,...(null==r?void 0:r.devices)||[]];return r&&r.devices.length===e?yield this._getBindingList(e,e+t,o):o})),this._getWebsocketConnInfo=e=>e.host?`wss://wx${e.host}`:"wss://wxstage.gizwits.com",this.appID=e,this.token=t,this.uid=i;const o=wx.getSystemInfoSync().SDKVersion;this._maxSocketNum=s?-1===(0,c.compareWXSDKVersion)(o||"1.0.0","1.7.0")?1:5:0}init(){var e,t;return n(this,void 0,void 0,(function*(){try{const i=yield this._getBindingList();return(null===(e=i.err)||void 0===e?void 0:e.errorCode)?{errorCode:null===(t=i.err)||void 0===t?void 0:t.errorCode,errorMessage:"getting binding list failed"}:(this._bindingDevices=i.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.did]:t}),{}),null)}catch(e){return r.default.GIZ_SDK_OTHERWISE}}))}};class l{constructor({appID:e,token:t,uid:i,wsInfo:s,onDeviceStatusChanged:r,onBindingChanged:a,onSocketStatusChanged:c}){this.ready=!1,this.commType="attrs_v4",this._heartbeatInterval=60,this._keepaliveTime=180,this._loginIntveral=5e3,this.autoSubscribe=!1,this._websocket=null,this._loginFailedTimes=0,this._subDids=new Set,this._socketRespHandleMap={},this._waitSends=[],this.destory=()=>{this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId),this._checkConnectTimerId&&clearInterval(this._checkConnectTimerId),this.close()},this._networkChange=e=>n(this,void 0,void 0,(function*(){o.default.log("network change",e)})),this._appShow=()=>n(this,void 0,void 0,(function*(){o.default.log("app show")})),this._addSubDid=(...e)=>{e.forEach(e=>this._subDids.add(e))},this._removeSubDid=(...e)=>{e.forEach(e=>this._subDids.delete(e))},this._connectWS=()=>{o.default.log("GIZ_SDK: start connect ws"),this._websocket=wx.connectSocket({url:this._wsUrl,fail:e=>{o.default.error("GIZ_SDK: connectSocket error",new Error(JSON.stringify(e)))}}),this._websocket.onClose(this.handleClose),this._websocket.onOpen(this.handleOpen),this._websocket.onError(this.handleError),this._websocket.onMessage(this.handleMessage),this._checkConnectTimerId||(this._checkConnectTimerId=setInterval(()=>{this._websocket||this._connectWS()},1e3))},this._subDevices=e=>{const t={cmd:"subscribe_req",data:e.map(e=>({did:e}))};this._send(t)},this._unSubDevices=e=>{e.map(e=>this._removeSubDid(e))},this._send=(e,t=!1)=>(o.default.log("GIZ_SDK: Socket send",e,t),new Promise(i=>{this._websocket?t||this.ready?this._websocket&&(t||this.ready)&&this._websocket.send({data:JSON.stringify(e),complete:e=>{o.default.log("GIZ_SDK: socket send res",e),o.default.log("resres",e);let t=!1;"sendSocketMessage:ok"===e.errMsg&&(t=!0),i({success:t,message:e.errMsg})},fail:e=>{o.default.error("GIZ_SDK: Socket send error",new Error(JSON.stringify(e))),i({success:!1,message:e.errMsg})}}):i({success:!1,message:"Socket not ready"}):i({success:!1,message:"Socket not init"})})),this.close=()=>{this.ready=!1,this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId),this._websocket&&(this._websocket.close({}),this._websocket=null),this._currentSocketStatus&&(this._currentSocketStatus=!1,this._handleSocketStatusChanged(!1))},this.handleClose=e=>{o.default.error("GIZ_SDK: socket close",new Error(JSON.stringify(e))),this.close(),this._stopPing()},this.handleOpen=()=>{o.default.log(" socket open"),this._login()},this.handleMessage=({data:e})=>{o.default.log("GIZ_SDK: message",e);const t=JSON.parse(e),i=this._socketRespHandleMap[t.cmd];i&&i(t.data)},this.handleError=e=>{o.default.error("GIZ_SDK: socket error",new Error(JSON.stringify(e))),this.close(),this._stopPing()},this._login=()=>{const e={cmd:"login_req",data:{appid:this.appID,uid:this.uid,token:this.token,p0_type:this.commType,heartbeat_interval:this._keepaliveTime,auto_subscribe:this.autoSubscribe}};this._send(e,!0)},this._tryLoginAgain=()=>{this._loginFailedTimes+=1,setTimeout(()=>{this._login()},this._loginFailedTimes*this._loginIntveral)},this._startPing=()=>{this._heartbeatTimerId=setInterval(()=>{this._send({cmd:"ping"})},1e3*this._heartbeatInterval)},this._stopPing=()=>{this._heartbeatTimerId&&clearInterval(this._heartbeatTimerId)},this.pongResp=()=>{},this._currentSocketStatus=!1,this._loginResp=e=>{1==e.success?(this._loginFailedTimes=0,this.ready=!0,this._startPing(),this._subDevices([...this._subDids]),this._currentSocketStatus=!0,this._handleSocketStatusChanged(this._currentSocketStatus),this._consumeWaitSends()):this._loginFailedTimes<3?(o.default.log("GIZ_SDK: Login failed, will try again, please wait..."),this._tryLoginAgain()):(o.default.error("GIZ_SDK: Login failed",new Error("m2m socket login failed")),this.close())},this._consumeWaitSends=()=>{let e=this._waitSends.pop();for(;e;)this._send(e),e=this._waitSends.pop()},this._handleSocketStatusChanged=e=>{this._onSocketStatusChanged&&this._onSocketStatusChanged([...this._subDids],e)},this._subscribeResp=e=>{o.default.log("GIZ_SDK: subscribe_res",e),e&&e.success&&e.success.forEach(e=>this._send({cmd:"c2s_read",data:{did:e.did}})),o.default.debug("GIZ_SDK: subscribe_res",e)},this._onlineResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged({did:e.did,attrs:Object.assign({is_online:e.online},e)})},this._rawChangedResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._statusChangedResp=e=>{this._isSub(e.did)&&this._onDeviceStatusChanged&&this._onDeviceStatusChanged(e)},this._isSub=e=>this._subDids.has(e),this._invalidMsgResp=e=>{1003===e.error_code&&this._login(),o.default.error("GIZ_SDK: s2c_invalid_msg",new Error(JSON.stringify(e)))},this._bindingChangedResp=e=>{!e.bind&&e.did&&this._removeSubDid(e.did),this._onBindingChanged&&this._onBindingChanged()},this.appID=e,this.token=t,this.uid=i,this._wsUrl=`${s}/ws/app/v1`,this._heartbeatTimerId=void 0,this._loginFailedTimes=0,this._onDeviceStatusChanged=r,this._onBindingChanged=a,this._onSocketStatusChanged=c,this._socketRespHandleMap={pong:this.pongResp,login_res:this._loginResp,subscribe_res:this._subscribeResp,s2c_online_status:this._onlineResp,s2c_raw:this._rawChangedResp,s2c_noti:this._statusChangedResp,s2c_invalid_msg:this._invalidMsgResp,s2c_binding_changed:this._bindingChangedResp},wx.onNetworkStatusChange(this._networkChange),wx.onAppShow(this._appShow)}}t.Connection=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(12),s=({SSID:e,password:t,pk:i})=>{let s=(0,n.MD5)(e+t).toString();s=n.enc.Hex.parse(s);let r=n.enc.Utf8.parse(i),o=n.AES.encrypt(r,s,{iv:s,mode:n.mode.ECB,padding:n.pad.ZeroPadding});return(0,n.MD5)(o.ciphertext).toString()};t.default=({SSID:e,password:t,pks:i})=>{const n=[];return i.map(i=>{const r=s({SSID:e,password:t,pk:i});n.push(r)}),n}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psKeySign=void 0;const n=i(12);t.psKeySign=e=>{const t=Math.round((new Date).getTime()/1e3),i=e+t;return{Signature:(0,n.MD5)(i).toString(),timestamp:t}}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.WxAnonymousLogin=t.AnonymousLogin=void 0;const s=i(7);t.AnonymousLogin=function({uid:e}){return n(this,void 0,void 0,(function*(){return(0,s.cozeApiRequest)("/v3/users/oauth/anonymous",{data:{openid:e},method:"POST"})}))},t.WxAnonymousLogin=function({code:e}){return n(this,void 0,void 0,(function*(){return(0,s.cozeApiRequest)(`/v3/users/oauth/wechat?code=${e}`,{method:"POST"})}))}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(4)),o=s(i(6)),a=s(i(93)),c=s(i(23)),u=s(i(24)),l=i(5);class d extends c.default{constructor(){super(...arguments),this.disableSendUDP=!1,this.sendMessageInterval=null,this.UDPSocketHandler=null,this.destroy=()=>{this.cleanTimeout(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.sendMessageInterval=null,this.UDPSocketHandler&&(this.UDPSocketHandler.offError(),this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.close())},this.configDevice=({ssid:e,password:t,softAPSSIDPrefix:i})=>(u.default.appendEvent({name:"START_DISCOVER_DEVICE",message:""}),u.default.appendEvent({name:"DISCOVER_DEVICE_SUCCESS",message:""}),u.default.appendEvent({name:"START_CONNECT_DEVICE",message:""}),u.default.appendEvent({name:"CONNECT_DEVICE_SUCCESS",message:""}),new Promise((s,c)=>{o.default.debug("GIZ_SDK: start config device");let d=!1,h=0;const f=(0,l.getGlobalData)("uid"),p=a.default.pack(e,t,f);this.UDPSocketHandler=wx.createUDPSocket(),this.UDPSocketHandler.bind(),this.disableSendUDP=!1,u.default.appendEvent({name:"START_SEND_WIFI_CONFIG",message:""});let v=!1;const g=()=>{try{!this.disableSendUDP&&this.UDPSocketHandler.send({address:"10.10.100.254",port:12414,message:p,offset:0,length:p.byteLength}),v||(v=!0,u.default.appendEvent({name:"START_SEND_WIFI_CONFIG_SUCCESS",message:""}))}catch(e){}};this.sendMessageInterval=setInterval(()=>{g()},2e3),this.UDPSocketHandler.onError(e=>{h+=1,h>2&&(this.destroy(),u.default.appendEvent({name:"START_SEND_WIFI_CONFIG_FAIL",message:""}),c({success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:e.errMsg}}))});const _=()=>n(this,void 0,void 0,(function*(){if(!d){this.UDPSocketHandler.offMessage(),this.UDPSocketHandler.offError(),this.sendMessageInterval&&clearInterval(this.sendMessageInterval),this.disableSendUDP=!0,d=!0;try{s({success:!0,data:[]})}catch(e){c(e)}}}));this.UDPSocketHandler.onMessage(e=>{_()}),wx.onNetworkStatusChange(()=>n(this,void 0,void 0,(function*(){!d&&wx.getConnectedWifi({success:e=>n(this,void 0,void 0,(function*(){-1===e.wifi.SSID.indexOf(i)&&_()}))})})))})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,productKey:i,softAPSSIDPrefix:s})=>{const r=this.ssid,o=this.password;return u.default.init({productKey:i,timeout:e,isBind:t,ssid:this.ssid,mode:0}),u.default.appendEvent({name:"START_WIFI_CONFIG",message:""}),new Promise((t,i)=>n(this,void 0,void 0,(function*(){this.destroy(),this.initDeviceOnboardingDeploy(t,i),this.startTimeoutTimer(e);try{yield this.configDevice({ssid:r,password:o,softAPSSIDPrefix:s});u.default.appendEvent({name:"WIFI_CONFIG_SUCCESS",message:""}),t({success:!0,data:[]})}catch(e){i(e)}finally{this.destroy()}})))}}}t.default=d},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(1)),r=i(3);class o extends s.default{constructor(e){super(e)}}o.pack=(e,t,i)=>{const n=[],[s,o]=(0,r.formatCodesFromStr)(e),[a,c]=(0,r.formatCodesFromStr)(t),[u,l]=(0,r.formatCodesFromStr)(i),d=[0].concat([0,1],o,s,c,a,l,u);let h=d.length;for(;h>0;)n.push(h),h-=255;const f=[0,0,0,3].concat(n).concat(d),p=new ArrayBuffer(f.length),v=new Uint8Array(p);for(let e=0;e<p.byteLength;e++)v[e]=f[e];return v},t.default=o},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(4)),o=i(9),a=s(i(6)),c=s(i(95)),u=s(i(13)),l=i(33),d=s(i(23)),h=s(i(24)),f=i(5);class p extends d.default{constructor(e,t,i,s,d,p){super(e,t,i,s,d),this.retryTimes=0,this.maxRetryTimes=3,this.sendBLEConfigCmd=({bleDeviceId:e,arrayBuffer:t,serviceUUIDSuffix:i="abd0",characteristicUUIDSuffix:s="abd5",bleHandle:r,mac:u,eventCallBack:d})=>{let f=null,p=null;const v=()=>null===p?(f&&clearInterval(f),!0):!this.hasTimeoutHandler();return new Promise((s,g)=>n(this,void 0,void 0,(function*(){try{a.default.debug("GIZ_SDK: ssid info: ",t),p=setTimeout(()=>{f&&clearInterval(f),p=null,s(!1)},5e4),a.default.debug("GIZ_SDK: createBLEConnection start: ",e),yield r.disableScan(),h.default.appendEvent({name:"START_CONNECT_DEVICE",message:""});const n=yield(0,l.retryConnect)(e,i,1e4);if(!n.success)return h.default.appendEvent({name:"CONNECT_DEVICE_FAIL",message:JSON.stringify(n)}),void s(!1);null==d||d({event:"GIZ_CONNECT_SUCCESS",mac:u}),r.enableScan(),a.default.debug("GIZ_SDK: createBLEConnection end, res:",n);const{serviceId:g,characteristics:_,characteristicId:y}=n.data;for(let t=0;t<_.length;t++){const i=_[t];(i.properties.notify||i.properties.indicate)&&(yield(0,l.notifyBLECharacteristicValueChange)(e,g,i.uuid))}null==d||d({event:"GIZ_CONFIG_SEND_SUCCESS",mac:u});const m=(t,i)=>{if(console.debug("curDevice",t,e),t.deviceId!==e)return;const n=(0,o.ab2hex)(i.raw),l=i;switch(console.debug("protocol",l),l.cmd){case 65:a.default.debug("GIZ_SDK: 收到设备返回ack",n),null==d||d({event:"GIZ_CONFIG_RECV_SUCCESS",mac:u}),h.default.appendEvent({name:"WIFI_CONFIG_RECV_SUCCESS",message:""});break;case 66:{const e=new c.default(i.raw);console.debug("wifiprotocol",e),3===e.state&&(r.removeEventListener("GizBleDeviceData",m),e.log.includes("Incorrect WiFi password")?(null==d||d({event:"GIZ_CONFIG_PASSWORD_ERROR",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_PASSWORD_ERROR",message:""})):(null==d||d({event:"GIZ_CONFIG_FAIL",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_FAIL",message:""})),s(!1)),10===e.state&&(r.removeEventListener("GizBleDeviceData",m),s(!0),null==d||d({event:"GIZ_CONFIG_CONNECT_SUCCESS",mac:u}),h.default.appendEvent({name:"GIZ_CONFIG_CONNECT_SUCCESS",message:""}));break}}};if(r.addEventListener("GizBleDeviceData",m),a.default.debug("GIZ_SDK: on notifyBLECharacteristicValueChange success"),v())return;h.default.appendEvent({name:"START_SEND_WIFI_CONFIG",message:""});const D=yield(0,l.unpackWriteBLECharacteristicValue)(e,g,y,t);D.errCode?h.default.appendEvent({name:"START_SEND_WIFI_CONFIG_FAIL",message:JSON.stringify(D)}):h.default.appendEvent({name:"START_SEND_WIFI_CONFIG_SUCCESS",message:""}),f=setInterval(()=>{v()||(0,l.unpackWriteBLECharacteristicValue)(e,g,y,t)},2e3),a.default.debug("GIZ_SDK: unpackWriteBLECharacteristicValue end")}catch(e){g(!1),a.default.debug("GIZ_SDK: sendBLEConfigCmd error",e)}}))).catch(e=>{a.default.debug("GIZ_SDK: sendBLEConfigCmd error",e)}).finally(()=>{p&&clearTimeout(p),f&&clearInterval(f),this.bleHandle.disConnectDevice(e)})},this.destroy=()=>{this.cleanTimeout()},this.isValidBleDevice=(e,t)=>0!==e.bleWorkStatus&&(!!this.specialProductKeys.includes(e.productKey)&&(a.default.debug(`GIZ_SDK: isValidBleDevice mac: ${e.mac} pk: ${e.productKey} name: ${e.name}`),a.default.debug(`GIZ_SDK: softAPSSIDPrefix: ${t} ismatch : ${e.name&&e.name.startsWith(t)}`),!t||e.name&&e.name.startsWith(t)||e.localName&&e.localName.startsWith(t))),this.enableBluetoothDevicesDescovery=()=>n(this,void 0,void 0,(function*(){return(yield(0,l.getBluetoothAdapterState)()).available?(yield(0,l.startBluetoothDevicesDiscovery)(),{success:!0}):{success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON.errorCode,errorMessage:"蓝牙状态不可用"}}})),this.enableAndGetBluetoothDevices=(e,t)=>n(this,void 0,void 0,(function*(){const e=yield this.enableBluetoothDevicesDescovery();if(!e.success)return e;a.default.debug("GIZ_SDK: start enableAndGetBluetoothDevices");let i=this.bleHandle.scanList.filter(e=>e.mac.toUpperCase()==(null==t?void 0:t.toUpperCase()));return a.default.debug("GIZ_SDK: getBluetoothDevices success",i),{success:!0,bleDevices:i}})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0,softAPSSIDPrefix:i,productKey:s,eventCallBack:r=(e=>{}),mac:o=""})=>(h.default.init({productKey:s,timeout:e,isBind:t,ssid:this.ssid,mode:3}),h.default.appendEvent({name:"START_WIFI_CONFIG",message:""}),this.eventCallBack=r,new Promise((t,s)=>n(this,void 0,void 0,(function*(){var n;this.bleHandle.scanList=[];try{const e=yield(0,l.getConnectedBluetoothDevices)();e.length>0&&e.forEach(e=>{this.bleHandle.disConnectDevice(e.deviceId)})}catch(e){a.default.debug("GIZ_SDK: getConnectedBluetoothDevices error",e)}null===(n=this.eventCallBack)||void 0===n||n.call(this,{event:"GIZ_CONFIG_START",mac:o});const r=this.ssid,c=this.password;this.destroy(),this.initDeviceOnboardingDeploy(t,s),this.startTimeoutTimer(e);try{const n=((yield this.configBLEDevice({ssid:r,password:c,timeout:1e3*e,softAPSSIDPrefix:i,mac:o})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,name:"",localName:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));h.default.appendEvent({name:"WIFI_CONFIG_SUCCESS",message:JSON.stringify(n)}),t({success:!0,data:n})}catch(e){console.error("GIZ_SDK: setDeviceOnboardingDeploy error",e),h.default.appendEvent({name:"WIFI_CONFIG_FAIL",message:`${e}`}),t({success:!1,data:e})}finally{this.destroy()}})))),this.configBLEDevice=({ssid:e,password:t,softAPSSIDPrefix:i,mac:s})=>new Promise((d,p)=>n(this,void 0,void 0,(function*(){a.default.debug("GIZ_SDK: start config ble device"),yield(0,l.startBluetoothDevicesDiscovery)(!0),h.default.appendEvent({name:"START_DISCOVER_DEVICE",message:""});const v=yield this.enableAndGetBluetoothDevices(i,s).catch(e=>(h.default.appendEvent({name:"DISCOVER_DEVICE_FAIL",message:JSON.stringify(e)}),{success:!1,err:{errorCode:r.default.WECHAT_ERROR.errorCode,errorMessage:JSON.stringify(e)}}));if(!(0,o.isWXDevicesResult)(v))return p(v);let g=v.bleDevices;a.default.debug("GIZ_SDK: enableAndGetBluetoothDevices success, target devices: ",g);let _=null;const y=(0,f.getGlobalData)("uid"),m=c.default.pack(e,t,y),D=()=>n(this,void 0,void 0,(function*(){var e;if(a.default.debug("GIZ_SDK: startConfigDevice"),this.hasTimeoutHandler())if(_=g.find(e=>e.mac.toUpperCase()==(null==s?void 0:s.toUpperCase())),_&&(null===(e=this.eventCallBack)||void 0===e||e.call(this,{event:"GIZ_DISCOVER_SUCCESS",mac:_.mac}),h.default.appendEvent({name:"DISCOVER_DEVICE_SUCCESS",message:JSON.stringify(_)}),a.default.debug("GIZ_SDK: startConfigDevice, target device: ",_)),_){if(h.default.updateProductKey(_.productKey),!0===(yield this.sendBLEConfigCmd({bleDeviceId:_.bleDeviceID,arrayBuffer:m.buffer,bleHandle:this.bleHandle,eventCallBack:this.eventCallBack,mac:_.mac})))try{const e=yield this.searchDevice({mac:_.mac,productKey:_.productKey});d(e)}catch(e){p(e),a.default.error("GIZ_SDK: searchDevice error",new Error(JSON.stringify(e)))}else p({success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_DEVICE_SEND_FAILED.errorCode,errorMessage:r.default.GIZ_SDK_BLE_DEVICE_SEND_FAILED.errorMessage}})}else{if(this.retryTimes++,this.retryTimes<=this.maxRetryTimes)return yield(0,u.default)(2e3),g=this.bleHandle.scanList.filter(e=>e.mac.toUpperCase()==(null==s?void 0:s.toUpperCase())),console.log("this.bleHandle.scanList",this.bleHandle.scanList),void(yield D());this.retryTimes=0,p({success:!1,err:{errorCode:r.default.GIZ_SDK_BLE_DEVICE_NOT_FOUND.errorCode,errorMessage:r.default.GIZ_SDK_BLE_DEVICE_NOT_FOUND.errorMessage}})}}));yield D()}))),this.bleHandle=p}}t.default=p},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(9),r=n(i(1)),o=i(34),a=i(3);class c extends r.default{constructor(e){super(e),this.state=-1,this.logLen=0,this.log="",this.logBytes=new Uint8Array,this.state=this.payload[0],this.logLen=this.payload[1],this.logLen>0&&(this.logBytes=this.payload.slice(2,2+this.logLen),this.log=(0,s.getPayloadAsUtf8String)(this.logBytes))}}c.pack=(e,t,i)=>{const n=o.snManager.getSn(),s=Math.floor(Date.now()/1e3),r=[n],[c,u]=(0,a.formatCodesFromStr)(e);let l=[],d=0;i&&([l,d]=(0,a.formatCodesFromStr)(i));const[h,f]=(0,a.formatCodesFromStr)(t),p=[s>>24&255,s>>16&255,s>>8&255,255&s],v=[u,...c,0,f,...h,d,...l];console.debug("contentcontentcontentcontent",u,e);const g=[4,64,...r,...[v.length+4],...p,...v];return new Uint8Array(g)},t.default=c},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(97),o=i(98),a=i(99),c=i(101),u=s(i(23));class l extends u.default{constructor(e,t,i,s,u,l){super(e,t,i,s,u),this.address="",this.destroy=()=>{this.cleanTimeout()},this.configDevice=({ssid:e,password:t,bssid:i,address:s})=>n(this,void 0,void 0,(function*(){const{SSIDTLV:n,isSSIDIncludedCH:u}=(0,a.formatSSID)(e),l=(0,o.formatData)(i,"BSSID"),d=(0,o.formatData)(t,"pwd"),h=(0,o.formatData)(s,"address"),f=(0,r.disposeData)(n,u,d,h,l);return console.log(f,"DATA"),(0,c.transceive)(f),yield this.searchDevice({mac:"",productKey:""})})),this.setDeviceOnboardingDeploy=({timeout:e,isBind:t=!0})=>{const i=this.ssid,s=this.password;return new Promise((r,o)=>n(this,void 0,void 0,(function*(){console.log("ssid0",i,s,this.bssid,this.address),this.destroy(),this.initDeviceOnboardingDeploy(r,o),this.startTimeoutTimer(e),console.log("ssid",i,s,this.bssid,this.address);try{const e=((yield this.configDevice({ssid:i,password:s,bssid:this.bssid,address:this.address})).data||[]).map(e=>({mac:e.mac,productKey:e.product_key,did:e.did,localName:"",name:"",isBind:!1,connectType:"NONE",isBleOnline:!1,isLanOnline:!1,isOnline:!1}));if(t)try{r(yield this.bindDevices(e))}catch(e){o(e)}else r({success:!0,data:e})}catch(e){o(e)}finally{this.destroy()}})))},this.address=l}}t.default=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disposeData=void 0;t.disposeData=(e,t,i,n,s)=>{const r=(()=>{const e=new ArrayBuffer(1),t=new Uint8Array(e);return t[0]=1,t})(),o=(e=>{const t=new ArrayBuffer(1),i=new Uint8Array(t);return i[0]=0,e&&(i[0]=1),i})(t),a=(()=>{const e=new ArrayBuffer(2),t=new Uint8Array(e);return t[0]=parseInt("0x55",16),t[1]=parseInt("0xaa",16),t})(),c=Uint8Array.from([...r,...o,...a]),u=Uint8Array.from([...e,...i,...n,...s]);return console.log(c.buffer,"uint8Array_sign.buffer",c),console.log(u.buffer,"uint8Array_others.buffer",u),{ArrayBuffer_sign:c.buffer,ArrayBuffer_others:u.buffer}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatData=void 0;t.formatData=(e,t)=>{const i=0===e.length,n="BSSID"===t?e.split(":"):e.split("");let s=0,r=null,o=0;switch(t){case"BSSID":s=i?3:n.length+2,r="b",o=i?0:n.length;break;case"pwd":s=e.length+2,r="p",o=e.length;break;case"address":s=i?3:n.length+2,r="i",o=i?0:n.length}const a=new ArrayBuffer(s),c=new Uint8Array(a);return c[0]=r.charCodeAt(0),c[1]=o,i?c[2]=0:n.forEach((e,i)=>{const n="BSSID"===t?parseInt(e,16):e.charCodeAt(0);c[i+2]=n}),console.log(a,c,"formatData",t),c}},function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.formatSSID=void 0;const s=i(3),r=n(i(100));t.formatSSID=e=>{const t={SSIDTLV:null,isSSIDIncludedCH:(0,r.default)(e)},[i,n]=(0,s.formatCodesFromStr)(e),o=parseInt((0,s.arrayToString)([n]),16);if(o<=127){const e=new ArrayBuffer(o+2),n=new Uint8Array(e);n[0]="s".charCodeAt(0),n[1]=o,i.forEach((e,t)=>{n[t+2]=e}),t.SSIDTLV=n}else{const e=parseInt(n/255)+1,s=new ArrayBuffer(o+2+e),r=new Uint8Array(s);if(r[0]="s".charCodeAt(0),r[1]=128+e,1===e)r[2]=o;else{r[e]=255,r[e+1]=o-255*(e-1);for(let t=e;t>=1;t--)0===r[e-t]&&(r[e-t]=255)}i.forEach((t,i)=>{r[i+2+e]=t}),t.SSIDTLV=r}return t}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return/.*[\u4e00-\u9fa5]+.*$/.test(e)}},function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.transceive=void 0;const s=i(102),r=i(103);t.transceive=e=>{const t=wx.getNFCAdapter();t.startDiscovery(),t.onDiscovered(i=>n(void 0,void 0,void 0,(function*(){console.log(i,"onDiscovered");let n=!0;const{success:o,nfcA:a}=yield(0,s.nfcAConnect)(t);if(o){const t=e.ArrayBuffer_others.byteLength,i=parseInt(t%4),s=parseInt(t/4);let o=s;const c=new Uint8Array(e.ArrayBuffer_others);for(let e=0;e<=4*s-4;e+=4){if(o>0){const t=new ArrayBuffer(6),i=new Uint8Array(t),u=49+s-o;i[0]=parseInt("0xa2",16),i[1]=u,i[2]=c[0+e],i[3]=c[1+e],i[4]=c[2+e],i[5]=c[3+e];const{transceiveSuccess:l}=yield(0,r.nfcATransceive)(a,t);if(o-=1,!l){n=!1,wx.hideLoading(),wx.showToast({title:"NFC写入失败!",icon:"error",duration:2e3});break}}if(0!==i&&n){const e=new ArrayBuffer(6),n=new Uint8Array(e),o=49+s;switch(n[0]=parseInt("0xa2",16),n[1]=o,i){case 1:n[2]=c[t-1];break;case 2:n[2]=c[t-2],n[3]=c[t-1];break;case 3:n[2]=c[t-3],n[3]=c[t-2],n[4]=c[t-1]}const{transceiveSuccess:u}=yield(0,r.nfcATransceive)(a,e);u||(wx.hideLoading(),wx.showToast({title:"NFC写入失败!",icon:"error",duration:2e3}))}}const u=new ArrayBuffer(6),l=new Uint8Array(u),d=new Uint8Array(e.ArrayBuffer_sign);l[0]=parseInt("0xa2",16),l[1]=48,l[2]=d[0],l[3]=d[1],l[4]=d[2],l[5]=d[3];const{transceiveSuccess:h}=yield(0,r.nfcATransceive)(a,u);wx.hideLoading(),wx.showToast(h?{title:"NFC写入成功!",icon:"success",duration:2e3}:{title:"NFC写入失败!",icon:"error",duration:2e3}),a.close()}else wx.hideLoading(),wx.showToast({title:"NFC连接失败!",icon:"error",duration:2e3})})))}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nfcAConnect=void 0;t.nfcAConnect=e=>new Promise(t=>{const i=e.getNfcA();i.connect({success(){t({success:!0,nfcA:i})},fail(){t({success:!1,nfcA:i})}})})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nfcATransceive=void 0;t.nfcATransceive=(e,t)=>new Promise(i=>{e.transceive({data:t,success:e=>{console.log("success",e),i({transceiveSuccess:!0})},fail:e=>{console.log("fail",e),i({transceiveSuccess:!1})}})})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OtaStatus=void 0,function(e){e.CHECKING="CHECKING",e.LATEST="LATEST",e.UPDATE_AVAILABLE="UPDATE_AVAILABLE",e.UPDATING="UPDATING",e.UPDATE_SUCCESS="UPDATE_SUCCESS"}(t.OtaStatus||(t.OtaStatus={}))}]);
|