qiscus-sdk-core 2.12.6 → 2.13.1
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/qiscus-sdk-core.js +35635 -0
- package/dist/qiscus-sdk-core.js.map +1 -0
- package/dist/qiscus-sdk-core.min.js +5 -5
- package/dist/qiscus-sdk-core.min.js.map +1 -1
- package/lib/index.js +13 -1
- package/lib/lib/adapters/mqtt.js +49 -1
- package/package.json +3 -3
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
!function(t
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("QiscusSDKCore",[],t):"object"==typeof exports?exports.QiscusSDKCore=t():e.QiscusSDKCore=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=123)}([function(e,t,r){var n=r(134),o=r(33),i=/[T ]/,s=/:/,a=/^(\d{2})$/,u=[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],c=/^(\d{4})/,l=[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],f=/^-(\d{2})$/,p=/^-?(\d{3})$/,h=/^-?(\d{2})-?(\d{2})$/,d=/^-?W(\d{2})$/,m=/^-?W(\d{2})-?(\d{1})$/,y=/^(\d{2}([.,]\d*)?)$/,g=/^(\d{2}):?(\d{2}([.,]\d*)?)$/,v=/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,b=/([Z+-].*)$/,_=/^(Z)$/,w=/^([+-])(\d{2})$/,k=/^([+-])(\d{2}):?(\d{2})$/;function S(e,t,r){t=t||0,r=r||0;var n=new Date(0);n.setUTCFullYear(e,0,4);var o=7*t+r+1-(n.getUTCDay()||7);return n.setUTCDate(n.getUTCDate()+o),n}e.exports=function(e,t){if(o(e))return new Date(e.getTime());if("string"!=typeof e)return new Date(e);var r=(t||{}).additionalDigits;r=null==r?2:Number(r);var x=function(e){var t,r={},n=e.split(i);s.test(n[0])?(r.date=null,t=n[0]):(r.date=n[0],t=n[1]);if(t){var o=b.exec(t);o?(r.time=t.replace(o[1],""),r.timezone=o[1]):r.time=t}return r}(e),E=function(e,t){var r,n=u[t],o=l[t];if(r=c.exec(e)||o.exec(e)){var i=r[1];return{year:parseInt(i,10),restDateString:e.slice(i.length)}}if(r=a.exec(e)||n.exec(e)){var s=r[1];return{year:100*parseInt(s,10),restDateString:e.slice(s.length)}}return{year:null}}(x.date,r),T=E.year,A=function(e,t){if(null===t)return null;var r,n,o,i;if(0===e.length)return(n=new Date(0)).setUTCFullYear(t),n;if(r=f.exec(e))return n=new Date(0),o=parseInt(r[1],10)-1,n.setUTCFullYear(t,o),n;if(r=p.exec(e)){n=new Date(0);var s=parseInt(r[1],10);return n.setUTCFullYear(t,0,s),n}if(r=h.exec(e)){n=new Date(0),o=parseInt(r[1],10)-1;var a=parseInt(r[2],10);return n.setUTCFullYear(t,o,a),n}if(r=d.exec(e))return i=parseInt(r[1],10)-1,S(t,i);if(r=m.exec(e)){i=parseInt(r[1],10)-1;var u=parseInt(r[2],10)-1;return S(t,i,u)}return null}(E.restDateString,T);if(A){var I,C=A.getTime(),P=0;if(x.time&&(P=function(e){var t,r,n;if(t=y.exec(e))return(r=parseFloat(t[1].replace(",",".")))%24*36e5;if(t=g.exec(e))return r=parseInt(t[1],10),n=parseFloat(t[2].replace(",",".")),r%24*36e5+6e4*n;if(t=v.exec(e)){r=parseInt(t[1],10),n=parseInt(t[2],10);var o=parseFloat(t[3].replace(",","."));return r%24*36e5+6e4*n+1e3*o}return null}(x.time)),x.timezone)I=6e4*function(e){var t,r;if(t=_.exec(e))return 0;if(t=w.exec(e))return r=60*parseInt(t[2],10),"+"===t[1]?-r:r;if(t=k.exec(e))return r=60*parseInt(t[2],10)+parseInt(t[3],10),"+"===t[1]?-r:r;return 0}(x.timezone);else{var O=C+P,R=new Date(O);I=n(R);var M=new Date(O);M.setDate(R.getDate()+1);var D=n(M)-n(R);D>0&&(I+=D)}return new Date(C+P+I)}return new Date(e)}},function(e,t,r){var n=r(128)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){var n=r(57);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){function r(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var s=e.apply(t,n);function a(e){r(s,o,i,a,u,"next",e)}function u(e){r(s,o,i,a,u,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(57);function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}e.exports=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){(function(n){var o,i;
|
|
2
2
|
/*!
|
|
3
3
|
* is.js 0.8.0
|
|
4
4
|
* Author: Aras Atasaygin
|
|
5
|
-
*/i=this,void 0===(o=function(){return i.is=function(){var t={VERSION:"0.8.0",not:{},all:{},any:{}},e=Object.prototype.toString,r=Array.prototype.slice,o=Object.prototype.hasOwnProperty;function i(t){return function(){return!t.apply(null,r.call(arguments))}}function s(t){return function(){for(var e=l(arguments),r=e.length,n=0;n<r;n++)if(!t.call(null,e[n]))return!1;return!0}}function a(t){return function(){for(var e=l(arguments),r=e.length,n=0;n<r;n++)if(t.call(null,e[n]))return!0;return!1}}var u={"<":function(t,e){return t<e},"<=":function(t,e){return t<=e},">":function(t,e){return t>e},">=":function(t,e){return t>=e}};function c(t,e){var r=e+"",n=+(r.match(/\d+/)||NaN),o=r.match(/^[<>]=?|/)[0];return u[o]?u[o](t,n):t==n||n!=n}function l(e){var n=r.call(e);return 1===n.length&&t.array(n[0])&&(n=n[0]),n}t.arguments=function(t){return"[object Arguments]"===e.call(t)||null!=t&&"object"==typeof t&&"callee"in t},t.array=Array.isArray||function(t){return"[object Array]"===e.call(t)},t.boolean=function(t){return!0===t||!1===t||"[object Boolean]"===e.call(t)},t.char=function(e){return t.string(e)&&1===e.length},t.date=function(t){return"[object Date]"===e.call(t)},t.domNode=function(e){return t.object(e)&&e.nodeType>0},t.error=function(t){return"[object Error]"===e.call(t)},t.function=function(t){return"[object Function]"===e.call(t)||"function"==typeof t},t.json=function(t){return"[object Object]"===e.call(t)},t.nan=function(t){return t!=t},t.null=function(t){return null===t},t.number=function(r){return t.not.nan(r)&&"[object Number]"===e.call(r)},t.object=function(t){return Object(t)===t},t.regexp=function(t){return"[object RegExp]"===e.call(t)},t.sameType=function(r,n){var o=e.call(r);return o===e.call(n)&&("[object Number]"!==o||!t.any.nan(r,n)||t.all.nan(r,n))},t.sameType.api=["not"],t.string=function(t){return"[object String]"===e.call(t)},t.undefined=function(t){return void 0===t},t.windowObject=function(t){return null!=t&&"object"==typeof t&&"setInterval"in t},t.empty=function(e){if(t.object(e)){var r=Object.getOwnPropertyNames(e).length;return!!(0===r||1===r&&t.array(e)||2===r&&t.arguments(e))}return""===e},t.existy=function(t){return null!=t},t.falsy=function(t){return!t},t.truthy=i(t.falsy),t.above=function(e,r){return t.all.number(e,r)&&e>r},t.above.api=["not"],t.decimal=function(e){return t.number(e)&&e%1!=0},t.equal=function(e,r){return t.all.number(e,r)?e===r&&1/e==1/r:t.all.string(e,r)||t.all.regexp(e,r)?""+e==""+r:!!t.all.boolean(e,r)&&e===r},t.equal.api=["not"],t.even=function(e){return t.number(e)&&e%2==0},t.finite=isFinite||function(e){return t.not.infinite(e)&&t.not.nan(e)},t.infinite=function(t){return t===1/0||t===-1/0},t.integer=function(e){return t.number(e)&&e%1==0},t.negative=function(e){return t.number(e)&&e<0},t.odd=function(e){return t.number(e)&&e%2==1},t.positive=function(e){return t.number(e)&&e>0},t.under=function(e,r){return t.all.number(e,r)&&e<r},t.under.api=["not"],t.within=function(e,r,n){return t.all.number(e,r,n)&&e>r&&e<n},t.within.api=["not"];var f={affirmative:/^(?:1|t(?:rue)?|y(?:es)?|ok(?:ay)?)$/,alphaNumeric:/^[A-Za-z0-9]+$/,caPostalCode:/^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]\s?[0-9][A-Z][0-9]$/,creditCard:/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/,dateString:/^(1[0-2]|0?[1-9])([\/-])(3[01]|[12][0-9]|0?[1-9])(?:\2)(?:[0-9]{2})?[0-9]{2}$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,eppPhone:/^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$/,hexadecimal:/^(?:0x)?[0-9a-fA-F]+$/,hexColor:/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ipv4:/^(?:(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/,ipv6:/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,nanpPhone:/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,socialSecurityNumber:/^(?!000|666)[0-8][0-9]{2}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}$/,timeString:/^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/,ukPostCode:/^[A-Z]{1,2}[0-9RCHNQ][0-9A-Z]?\s?[0-9][ABD-HJLNP-UW-Z]{2}$|^[A-Z]{2}-?[0-9]{4}$/,url:/^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/i,usZipCode:/^[0-9]{5}(?:-[0-9]{4})?$/};function h(e,r){t[e]=function(t){return r[e].test(t)}}for(var p in f)f.hasOwnProperty(p)&&h(p,f);t.ip=function(e){return t.ipv4(e)||t.ipv6(e)},t.capitalized=function(e){if(t.not.string(e))return!1;for(var r=e.split(" "),n=0;n<r.length;n++){var o=r[n];if(o.length){var i=o.charAt(0);if(i!==i.toUpperCase())return!1}}return!0},t.endWith=function(e,r){if(t.not.string(e))return!1;r+="";var n=e.length-r.length;return n>=0&&e.indexOf(r,n)===n},t.endWith.api=["not"],t.include=function(t,e){return t.indexOf(e)>-1},t.include.api=["not"],t.lowerCase=function(e){return t.string(e)&&e===e.toLowerCase()},t.palindrome=function(e){if(t.not.string(e))return!1;for(var r=(e=e.replace(/[^a-zA-Z0-9]+/g,"").toLowerCase()).length-1,n=0,o=Math.floor(r/2);n<=o;n++)if(e.charAt(n)!==e.charAt(r-n))return!1;return!0},t.space=function(e){if(t.not.char(e))return!1;var r=e.charCodeAt(0);return r>8&&r<14||32===r},t.startWith=function(e,r){return t.string(e)&&0===e.indexOf(r)},t.startWith.api=["not"],t.upperCase=function(e){return t.string(e)&&e===e.toUpperCase()};var d=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],m=["january","february","march","april","may","june","july","august","september","october","november","december"];t.day=function(e,r){return t.date(e)&&r.toLowerCase()===d[e.getDay()]},t.day.api=["not"],t.dayLightSavingTime=function(t){var e=new Date(t.getFullYear(),0,1),r=new Date(t.getFullYear(),6,1),n=Math.max(e.getTimezoneOffset(),r.getTimezoneOffset());return t.getTimezoneOffset()<n},t.future=function(e){var r=new Date;return t.date(e)&&e.getTime()>r.getTime()},t.inDateRange=function(e,r,n){if(t.not.date(e)||t.not.date(r)||t.not.date(n))return!1;var o=e.getTime();return o>r.getTime()&&o<n.getTime()},t.inDateRange.api=["not"],t.inLastMonth=function(e){return t.inDateRange(e,new Date((new Date).setMonth((new Date).getMonth()-1)),new Date)},t.inLastWeek=function(e){return t.inDateRange(e,new Date((new Date).setDate((new Date).getDate()-7)),new Date)},t.inLastYear=function(e){return t.inDateRange(e,new Date((new Date).setFullYear((new Date).getFullYear()-1)),new Date)},t.inNextMonth=function(e){return t.inDateRange(e,new Date,new Date((new Date).setMonth((new Date).getMonth()+1)))},t.inNextWeek=function(e){return t.inDateRange(e,new Date,new Date((new Date).setDate((new Date).getDate()+7)))},t.inNextYear=function(e){return t.inDateRange(e,new Date,new Date((new Date).setFullYear((new Date).getFullYear()+1)))},t.leapYear=function(e){return t.number(e)&&(e%4==0&&e%100!=0||e%400==0)},t.month=function(e,r){return t.date(e)&&r.toLowerCase()===m[e.getMonth()]},t.month.api=["not"],t.past=function(e){var r=new Date;return t.date(e)&&e.getTime()<r.getTime()},t.quarterOfYear=function(e,r){return t.date(e)&&t.number(r)&&r===Math.floor((e.getMonth()+3)/3)},t.quarterOfYear.api=["not"],t.today=function(e){var r=(new Date).toDateString();return t.date(e)&&e.toDateString()===r},t.tomorrow=function(e){var r=new Date,n=new Date(r.setDate(r.getDate()+1)).toDateString();return t.date(e)&&e.toDateString()===n},t.weekend=function(e){return t.date(e)&&(6===e.getDay()||0===e.getDay())},t.weekday=i(t.weekend),t.year=function(e,r){return t.date(e)&&t.number(r)&&r===e.getFullYear()},t.year.api=["not"],t.yesterday=function(e){var r=new Date,n=new Date(r.setDate(r.getDate()-1)).toDateString();return t.date(e)&&e.toDateString()===n};var y=t.windowObject("object"==typeof n&&n)&&n,g=t.windowObject("object"==typeof self&&self)&&self,v=t.windowObject("object"==typeof this&&this)&&this,b=y||g||v||Function("return this")(),_=g&&g.document,w=b.is,k=g&&g.navigator,S=(k&&k.appVersion||"").toLowerCase(),x=(k&&k.userAgent||"").toLowerCase(),E=(k&&k.vendor||"").toLowerCase();return t.android=function(){return/android/.test(x)},t.android.api=["not"],t.androidPhone=function(){return/android/.test(x)&&/mobile/.test(x)},t.androidPhone.api=["not"],t.androidTablet=function(){return/android/.test(x)&&!/mobile/.test(x)},t.androidTablet.api=["not"],t.blackberry=function(){return/blackberry/.test(x)||/bb10/.test(x)},t.blackberry.api=["not"],t.chrome=function(t){var e=/google inc/.test(E)?x.match(/(?:chrome|crios)\/(\d+)/):null;return null!==e&&c(e[1],t)},t.chrome.api=["not"],t.desktop=function(){return t.not.mobile()&&t.not.tablet()},t.desktop.api=["not"],t.edge=function(t){var e=x.match(/edge\/(\d+)/);return null!==e&&c(e[1],t)},t.edge.api=["not"],t.firefox=function(t){var e=x.match(/(?:firefox|fxios)\/(\d+)/);return null!==e&&c(e[1],t)},t.firefox.api=["not"],t.ie=function(t){var e=x.match(/(?:msie |trident.+?; rv:)(\d+)/);return null!==e&&c(e[1],t)},t.ie.api=["not"],t.ios=function(){return t.iphone()||t.ipad()||t.ipod()},t.ios.api=["not"],t.ipad=function(t){var e=x.match(/ipad.+?os (\d+)/);return null!==e&&c(e[1],t)},t.ipad.api=["not"],t.iphone=function(t){var e=x.match(/iphone(?:.+?os (\d+))?/);return null!==e&&c(e[1]||1,t)},t.iphone.api=["not"],t.ipod=function(t){var e=x.match(/ipod.+?os (\d+)/);return null!==e&&c(e[1],t)},t.ipod.api=["not"],t.linux=function(){return/linux/.test(S)},t.linux.api=["not"],t.mac=function(){return/mac/.test(S)},t.mac.api=["not"],t.mobile=function(){return t.iphone()||t.ipod()||t.androidPhone()||t.blackberry()||t.windowsPhone()},t.mobile.api=["not"],t.offline=i(t.online),t.offline.api=["not"],t.online=function(){return!k||!0===k.onLine},t.online.api=["not"],t.opera=function(t){var e=x.match(/(?:^opera.+?version|opr)\/(\d+)/);return null!==e&&c(e[1],t)},t.opera.api=["not"],t.phantom=function(t){var e=x.match(/phantomjs\/(\d+)/);return null!==e&&c(e[1],t)},t.phantom.api=["not"],t.safari=function(t){var e=x.match(/version\/(\d+).+?safari/);return null!==e&&c(e[1],t)},t.safari.api=["not"],t.tablet=function(){return t.ipad()||t.androidTablet()||t.windowsTablet()},t.tablet.api=["not"],t.touchDevice=function(){return!!_&&("ontouchstart"in g||"DocumentTouch"in g&&_ instanceof DocumentTouch)},t.touchDevice.api=["not"],t.windows=function(){return/win/.test(S)},t.windows.api=["not"],t.windowsPhone=function(){return t.windows()&&/phone/.test(x)},t.windowsPhone.api=["not"],t.windowsTablet=function(){return t.windows()&&t.not.windowsPhone()&&/touch/.test(x)},t.windowsTablet.api=["not"],t.propertyCount=function(e,r){if(t.not.object(e)||t.not.number(r))return!1;var n=0;for(var i in e)if(o.call(e,i)&&++n>r)return!1;return n===r},t.propertyCount.api=["not"],t.propertyDefined=function(e,r){return t.object(e)&&t.string(r)&&r in e},t.propertyDefined.api=["not"],t.inArray=function(e,r){if(t.not.array(r))return!1;for(var n=0;n<r.length;n++)if(r[n]===e)return!0;return!1},t.inArray.api=["not"],t.sorted=function(e,r){if(t.not.array(e))return!1;for(var n=u[r]||u[">="],o=1;o<e.length;o++)if(!n(e[o],e[o-1]))return!1;return!0},function(){var e=t;for(var r in e)if(o.call(e,r)&&t.function(e[r]))for(var n=e[r].api||["not","all","any"],u=0;u<n.length;u++)"not"===n[u]&&(t.not[r]=i(t[r])),"all"===n[u]&&(t.all[r]=s(t[r])),"any"===n[u]&&(t.any[r]=a(t[r]))}(),t.setNamespace=function(){return b.is=w,this},t.setRegexp=function(t,e){for(var r in f)o.call(f,r)&&e===r&&(f[r]=t)},t}()}.call(e,r,e,t))||(t.exports=o)}).call(this,r(10))},function(t,e,r){var n;"undefined"!=typeof window?n=window:"undefined"!=typeof self?n=self:(console.warn("Using browser-only version of superagent in non-browser environment"),n=this);var o=r(130),i=r(131),s=r(58),a=r(132),u=r(134);function c(){}var l=e=t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1==arguments.length?new e.Request("GET",t):new e.Request(t,r)};e.Request=g,l.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only version of superagent could not find XHR")};var f="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function h(t){if(!s(t))return t;var e=[];for(var r in t)p(e,r,t[r]);return e.join("&")}function p(t,e,r){if(null!=r)if(Array.isArray(r))r.forEach((function(r){p(t,e,r)}));else if(s(r))for(var n in r)p(t,e+"["+n+"]",r[n]);else t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));else null===r&&t.push(encodeURIComponent(e))}function d(t){for(var e,r,n={},o=t.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(e=o[i]).indexOf("="))?n[decodeURIComponent(e)]="":n[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return n}function m(t){return/[\/+]json($|[^-\w])/.test(t)}function y(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.header=this.headers=function(t){for(var e,r,n,o,i=t.split(/\r?\n/),s={},a=0,u=i.length;a<u;++a)-1!==(e=(r=i[a]).indexOf(":"))&&(n=r.slice(0,e).toLowerCase(),o=f(r.slice(e+1)),s[n]=o);return s}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function g(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",(function(){var t,e=null,n=null;try{n=new y(r)}catch(t){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",n);try{r._isResponseOK(n)||(t=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=e,t.response=n,t.status=n.status,r.callback(t,n)):r.callback(null,n)}))}function v(t,e,r){var n=l("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}l.serializeObject=h,l.parseString=d,l.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":h,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":d,"application/json":JSON.parse},a(y.prototype),y.prototype._parseBody=function(t){var e=l.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&m(this.type)&&(e=l.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null)},y.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},l.Response=y,o(g.prototype),i(g.prototype),g.prototype.type=function(t){return this.set("Content-Type",l.types[t]||t),this},g.prototype.accept=function(t){return this.set("Accept",l.types[t]||t),this},g.prototype.auth=function(t,e,r){1===arguments.length&&(e=""),"object"==typeof e&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var n=function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(t,e,r,n)},g.prototype.query=function(t){return"string"!=typeof t&&(t=h(t)),t&&this._query.push(t),this},g.prototype.attach=function(t,e,r){if(e){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},g.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},g.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},g.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},g.prototype.buffer=g.prototype.ca=g.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},g.prototype.pipe=g.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},g.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},g.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||c,this._finalizeQueryString(),this._end()},g.prototype._end=function(){var t=this,e=this.xhr=l.getXHR(),r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||l.serialize[o?o.split(";")[0]:""];!i&&m(o)&&(i=l.serialize["application/json"]),i&&(r=i(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},l.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new l.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}})),u.prototype.del=u.prototype.delete,l.get=function(t,e,r){var n=l("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},l.head=function(t,e,r){var n=l("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},l.options=function(t,e,r){var n=l("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.del=v,l.delete=v,l.patch=function(t,e,r){var n=l("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.post=function(t,e,r){var n=l("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.put=function(t,e,r){var n=l("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},function(t,e,r){"use strict";(function(t){
|
|
5
|
+
*/i=this,void 0===(o=function(){return i.is=function(){var e={VERSION:"0.8.0",not:{},all:{},any:{}},t=Object.prototype.toString,r=Array.prototype.slice,o=Object.prototype.hasOwnProperty;function i(e){return function(){return!e.apply(null,r.call(arguments))}}function s(e){return function(){for(var t=l(arguments),r=t.length,n=0;n<r;n++)if(!e.call(null,t[n]))return!1;return!0}}function a(e){return function(){for(var t=l(arguments),r=t.length,n=0;n<r;n++)if(e.call(null,t[n]))return!0;return!1}}var u={"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t}};function c(e,t){var r=t+"",n=+(r.match(/\d+/)||NaN),o=r.match(/^[<>]=?|/)[0];return u[o]?u[o](e,n):e==n||n!=n}function l(t){var n=r.call(t);return 1===n.length&&e.array(n[0])&&(n=n[0]),n}e.arguments=function(e){return"[object Arguments]"===t.call(e)||null!=e&&"object"==typeof e&&"callee"in e},e.array=Array.isArray||function(e){return"[object Array]"===t.call(e)},e.boolean=function(e){return!0===e||!1===e||"[object Boolean]"===t.call(e)},e.char=function(t){return e.string(t)&&1===t.length},e.date=function(e){return"[object Date]"===t.call(e)},e.domNode=function(t){return e.object(t)&&t.nodeType>0},e.error=function(e){return"[object Error]"===t.call(e)},e.function=function(e){return"[object Function]"===t.call(e)||"function"==typeof e},e.json=function(e){return"[object Object]"===t.call(e)},e.nan=function(e){return e!=e},e.null=function(e){return null===e},e.number=function(r){return e.not.nan(r)&&"[object Number]"===t.call(r)},e.object=function(e){return Object(e)===e},e.regexp=function(e){return"[object RegExp]"===t.call(e)},e.sameType=function(r,n){var o=t.call(r);return o===t.call(n)&&("[object Number]"!==o||!e.any.nan(r,n)||e.all.nan(r,n))},e.sameType.api=["not"],e.string=function(e){return"[object String]"===t.call(e)},e.undefined=function(e){return void 0===e},e.windowObject=function(e){return null!=e&&"object"==typeof e&&"setInterval"in e},e.empty=function(t){if(e.object(t)){var r=Object.getOwnPropertyNames(t).length;return!!(0===r||1===r&&e.array(t)||2===r&&e.arguments(t))}return""===t},e.existy=function(e){return null!=e},e.falsy=function(e){return!e},e.truthy=i(e.falsy),e.above=function(t,r){return e.all.number(t,r)&&t>r},e.above.api=["not"],e.decimal=function(t){return e.number(t)&&t%1!=0},e.equal=function(t,r){return e.all.number(t,r)?t===r&&1/t==1/r:e.all.string(t,r)||e.all.regexp(t,r)?""+t==""+r:!!e.all.boolean(t,r)&&t===r},e.equal.api=["not"],e.even=function(t){return e.number(t)&&t%2==0},e.finite=isFinite||function(t){return e.not.infinite(t)&&e.not.nan(t)},e.infinite=function(e){return e===1/0||e===-1/0},e.integer=function(t){return e.number(t)&&t%1==0},e.negative=function(t){return e.number(t)&&t<0},e.odd=function(t){return e.number(t)&&t%2==1},e.positive=function(t){return e.number(t)&&t>0},e.under=function(t,r){return e.all.number(t,r)&&t<r},e.under.api=["not"],e.within=function(t,r,n){return e.all.number(t,r,n)&&t>r&&t<n},e.within.api=["not"];var f={affirmative:/^(?:1|t(?:rue)?|y(?:es)?|ok(?:ay)?)$/,alphaNumeric:/^[A-Za-z0-9]+$/,caPostalCode:/^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]\s?[0-9][A-Z][0-9]$/,creditCard:/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/,dateString:/^(1[0-2]|0?[1-9])([\/-])(3[01]|[12][0-9]|0?[1-9])(?:\2)(?:[0-9]{2})?[0-9]{2}$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,eppPhone:/^\+[0-9]{1,3}\.[0-9]{4,14}(?:x.+)?$/,hexadecimal:/^(?:0x)?[0-9a-fA-F]+$/,hexColor:/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ipv4:/^(?:(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/,ipv6:/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,nanpPhone:/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/,socialSecurityNumber:/^(?!000|666)[0-8][0-9]{2}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4}$/,timeString:/^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/,ukPostCode:/^[A-Z]{1,2}[0-9RCHNQ][0-9A-Z]?\s?[0-9][ABD-HJLNP-UW-Z]{2}$|^[A-Z]{2}-?[0-9]{4}$/,url:/^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/i,usZipCode:/^[0-9]{5}(?:-[0-9]{4})?$/};function p(t,r){e[t]=function(e){return r[t].test(e)}}for(var h in f)f.hasOwnProperty(h)&&p(h,f);e.ip=function(t){return e.ipv4(t)||e.ipv6(t)},e.capitalized=function(t){if(e.not.string(t))return!1;for(var r=t.split(" "),n=0;n<r.length;n++){var o=r[n];if(o.length){var i=o.charAt(0);if(i!==i.toUpperCase())return!1}}return!0},e.endWith=function(t,r){if(e.not.string(t))return!1;r+="";var n=t.length-r.length;return n>=0&&t.indexOf(r,n)===n},e.endWith.api=["not"],e.include=function(e,t){return e.indexOf(t)>-1},e.include.api=["not"],e.lowerCase=function(t){return e.string(t)&&t===t.toLowerCase()},e.palindrome=function(t){if(e.not.string(t))return!1;for(var r=(t=t.replace(/[^a-zA-Z0-9]+/g,"").toLowerCase()).length-1,n=0,o=Math.floor(r/2);n<=o;n++)if(t.charAt(n)!==t.charAt(r-n))return!1;return!0},e.space=function(t){if(e.not.char(t))return!1;var r=t.charCodeAt(0);return r>8&&r<14||32===r},e.startWith=function(t,r){return e.string(t)&&0===t.indexOf(r)},e.startWith.api=["not"],e.upperCase=function(t){return e.string(t)&&t===t.toUpperCase()};var d=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],m=["january","february","march","april","may","june","july","august","september","october","november","december"];e.day=function(t,r){return e.date(t)&&r.toLowerCase()===d[t.getDay()]},e.day.api=["not"],e.dayLightSavingTime=function(e){var t=new Date(e.getFullYear(),0,1),r=new Date(e.getFullYear(),6,1),n=Math.max(t.getTimezoneOffset(),r.getTimezoneOffset());return e.getTimezoneOffset()<n},e.future=function(t){var r=new Date;return e.date(t)&&t.getTime()>r.getTime()},e.inDateRange=function(t,r,n){if(e.not.date(t)||e.not.date(r)||e.not.date(n))return!1;var o=t.getTime();return o>r.getTime()&&o<n.getTime()},e.inDateRange.api=["not"],e.inLastMonth=function(t){return e.inDateRange(t,new Date((new Date).setMonth((new Date).getMonth()-1)),new Date)},e.inLastWeek=function(t){return e.inDateRange(t,new Date((new Date).setDate((new Date).getDate()-7)),new Date)},e.inLastYear=function(t){return e.inDateRange(t,new Date((new Date).setFullYear((new Date).getFullYear()-1)),new Date)},e.inNextMonth=function(t){return e.inDateRange(t,new Date,new Date((new Date).setMonth((new Date).getMonth()+1)))},e.inNextWeek=function(t){return e.inDateRange(t,new Date,new Date((new Date).setDate((new Date).getDate()+7)))},e.inNextYear=function(t){return e.inDateRange(t,new Date,new Date((new Date).setFullYear((new Date).getFullYear()+1)))},e.leapYear=function(t){return e.number(t)&&(t%4==0&&t%100!=0||t%400==0)},e.month=function(t,r){return e.date(t)&&r.toLowerCase()===m[t.getMonth()]},e.month.api=["not"],e.past=function(t){var r=new Date;return e.date(t)&&t.getTime()<r.getTime()},e.quarterOfYear=function(t,r){return e.date(t)&&e.number(r)&&r===Math.floor((t.getMonth()+3)/3)},e.quarterOfYear.api=["not"],e.today=function(t){var r=(new Date).toDateString();return e.date(t)&&t.toDateString()===r},e.tomorrow=function(t){var r=new Date,n=new Date(r.setDate(r.getDate()+1)).toDateString();return e.date(t)&&t.toDateString()===n},e.weekend=function(t){return e.date(t)&&(6===t.getDay()||0===t.getDay())},e.weekday=i(e.weekend),e.year=function(t,r){return e.date(t)&&e.number(r)&&r===t.getFullYear()},e.year.api=["not"],e.yesterday=function(t){var r=new Date,n=new Date(r.setDate(r.getDate()-1)).toDateString();return e.date(t)&&t.toDateString()===n};var y=e.windowObject("object"==typeof n&&n)&&n,g=e.windowObject("object"==typeof self&&self)&&self,v=e.windowObject("object"==typeof this&&this)&&this,b=y||g||v||Function("return this")(),_=g&&g.document,w=b.is,k=g&&g.navigator,S=(k&&k.appVersion||"").toLowerCase(),x=(k&&k.userAgent||"").toLowerCase(),E=(k&&k.vendor||"").toLowerCase();return e.android=function(){return/android/.test(x)},e.android.api=["not"],e.androidPhone=function(){return/android/.test(x)&&/mobile/.test(x)},e.androidPhone.api=["not"],e.androidTablet=function(){return/android/.test(x)&&!/mobile/.test(x)},e.androidTablet.api=["not"],e.blackberry=function(){return/blackberry/.test(x)||/bb10/.test(x)},e.blackberry.api=["not"],e.chrome=function(e){var t=/google inc/.test(E)?x.match(/(?:chrome|crios)\/(\d+)/):null;return null!==t&&c(t[1],e)},e.chrome.api=["not"],e.desktop=function(){return e.not.mobile()&&e.not.tablet()},e.desktop.api=["not"],e.edge=function(e){var t=x.match(/edge\/(\d+)/);return null!==t&&c(t[1],e)},e.edge.api=["not"],e.firefox=function(e){var t=x.match(/(?:firefox|fxios)\/(\d+)/);return null!==t&&c(t[1],e)},e.firefox.api=["not"],e.ie=function(e){var t=x.match(/(?:msie |trident.+?; rv:)(\d+)/);return null!==t&&c(t[1],e)},e.ie.api=["not"],e.ios=function(){return e.iphone()||e.ipad()||e.ipod()},e.ios.api=["not"],e.ipad=function(e){var t=x.match(/ipad.+?os (\d+)/);return null!==t&&c(t[1],e)},e.ipad.api=["not"],e.iphone=function(e){var t=x.match(/iphone(?:.+?os (\d+))?/);return null!==t&&c(t[1]||1,e)},e.iphone.api=["not"],e.ipod=function(e){var t=x.match(/ipod.+?os (\d+)/);return null!==t&&c(t[1],e)},e.ipod.api=["not"],e.linux=function(){return/linux/.test(S)},e.linux.api=["not"],e.mac=function(){return/mac/.test(S)},e.mac.api=["not"],e.mobile=function(){return e.iphone()||e.ipod()||e.androidPhone()||e.blackberry()||e.windowsPhone()},e.mobile.api=["not"],e.offline=i(e.online),e.offline.api=["not"],e.online=function(){return!k||!0===k.onLine},e.online.api=["not"],e.opera=function(e){var t=x.match(/(?:^opera.+?version|opr)\/(\d+)/);return null!==t&&c(t[1],e)},e.opera.api=["not"],e.phantom=function(e){var t=x.match(/phantomjs\/(\d+)/);return null!==t&&c(t[1],e)},e.phantom.api=["not"],e.safari=function(e){var t=x.match(/version\/(\d+).+?safari/);return null!==t&&c(t[1],e)},e.safari.api=["not"],e.tablet=function(){return e.ipad()||e.androidTablet()||e.windowsTablet()},e.tablet.api=["not"],e.touchDevice=function(){return!!_&&("ontouchstart"in g||"DocumentTouch"in g&&_ instanceof DocumentTouch)},e.touchDevice.api=["not"],e.windows=function(){return/win/.test(S)},e.windows.api=["not"],e.windowsPhone=function(){return e.windows()&&/phone/.test(x)},e.windowsPhone.api=["not"],e.windowsTablet=function(){return e.windows()&&e.not.windowsPhone()&&/touch/.test(x)},e.windowsTablet.api=["not"],e.propertyCount=function(t,r){if(e.not.object(t)||e.not.number(r))return!1;var n=0;for(var i in t)if(o.call(t,i)&&++n>r)return!1;return n===r},e.propertyCount.api=["not"],e.propertyDefined=function(t,r){return e.object(t)&&e.string(r)&&r in t},e.propertyDefined.api=["not"],e.inArray=function(t,r){if(e.not.array(r))return!1;for(var n=0;n<r.length;n++)if(r[n]===t)return!0;return!1},e.inArray.api=["not"],e.sorted=function(t,r){if(e.not.array(t))return!1;for(var n=u[r]||u[">="],o=1;o<t.length;o++)if(!n(t[o],t[o-1]))return!1;return!0},function(){var t=e;for(var r in t)if(o.call(t,r)&&e.function(t[r]))for(var n=t[r].api||["not","all","any"],u=0;u<n.length;u++)"not"===n[u]&&(e.not[r]=i(e[r])),"all"===n[u]&&(e.all[r]=s(e[r])),"any"===n[u]&&(e.any[r]=a(e[r]))}(),e.setNamespace=function(){return b.is=w,this},e.setRegexp=function(e,t){for(var r in f)o.call(f,r)&&t===r&&(f[r]=e)},e}()}.call(t,r,t,e))||(e.exports=o)}).call(this,r(10))},function(e,t,r){var n;"undefined"!=typeof window?n=window:"undefined"!=typeof self?n=self:(console.warn("Using browser-only version of superagent in non-browser environment"),n=this);var o=r(129),i=r(130),s=r(58),a=r(131),u=r(133);function c(){}var l=t=e.exports=function(e,r){return"function"==typeof r?new t.Request("GET",e).end(r):1==arguments.length?new t.Request("GET",e):new t.Request(e,r)};t.Request=g,l.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw Error("Browser-only version of superagent could not find XHR")};var f="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};function p(e){if(!s(e))return e;var t=[];for(var r in e)h(t,r,e[r]);return t.join("&")}function h(e,t,r){if(null!=r)if(Array.isArray(r))r.forEach((function(r){h(e,t,r)}));else if(s(r))for(var n in r)h(e,t+"["+n+"]",r[n]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));else null===r&&e.push(encodeURIComponent(t))}function d(e){for(var t,r,n={},o=e.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(t=o[i]).indexOf("="))?n[decodeURIComponent(t)]="":n[decodeURIComponent(t.slice(0,r))]=decodeURIComponent(t.slice(r+1));return n}function m(e){return/[\/+]json($|[^-\w])/.test(e)}function y(e){this.req=e,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.header=this.headers=function(e){for(var t,r,n,o,i=e.split(/\r?\n/),s={},a=0,u=i.length;a<u;++a)-1!==(t=(r=i[a]).indexOf(":"))&&(n=r.slice(0,t).toLowerCase(),o=f(r.slice(t+1)),s[n]=o);return s}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&e._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function g(e,t){var r=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",(function(){var e,t=null,n=null;try{n=new y(r)}catch(e){return(t=new Error("Parser is unable to parse the response")).parse=!0,t.original=e,r.xhr?(t.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,t.status=r.xhr.status?r.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),r.callback(t)}r.emit("response",n);try{r._isResponseOK(n)||(e=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=n,e.status=n.status,r.callback(e,n)):r.callback(null,n)}))}function v(e,t,r){var n=l("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}l.serializeObject=p,l.parseString=d,l.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":p,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":d,"application/json":JSON.parse},a(y.prototype),y.prototype._parseBody=function(e){var t=l.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&m(this.type)&&(t=l.parse["application/json"]),t&&e&&(e.length||e instanceof Object)?t(e):null)},y.prototype.toError=function(){var e=this.req,t=e.method,r=e.url,n="cannot "+t+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=t,o.url=r,o},l.Response=y,o(g.prototype),i(g.prototype),g.prototype.type=function(e){return this.set("Content-Type",l.types[e]||e),this},g.prototype.accept=function(e){return this.set("Accept",l.types[e]||e),this},g.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var n=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,n)},g.prototype.query=function(e){return"string"!=typeof e&&(e=p(e)),e&&this._query.push(e),this},g.prototype.attach=function(e,t,r){if(t){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},g.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},g.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var r=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),r(e,t)},g.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},g.prototype.buffer=g.prototype.ca=g.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},g.prototype.pipe=g.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},g.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},g.prototype.end=function(e){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||c,this._finalizeQueryString(),this._end()},g.prototype._end=function(){var e=this,t=this.xhr=l.getXHR(),r=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var r=t.readyState;if(r>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||l.serialize[o?o.split(";")[0]:""];!i&&m(o)&&(i=l.serialize["application/json"]),i&&(r=i(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&t.setRequestHeader(s,this.header[s]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},l.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){u.prototype[e.toLowerCase()]=function(t,r){var n=new l.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}})),u.prototype.del=u.prototype.delete,l.get=function(e,t,r){var n=l("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},l.head=function(e,t,r){var n=l("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},l.options=function(e,t,r){var n=l("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.del=v,l.delete=v,l.patch=function(e,t,r){var n=l("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.post=function(e,t,r){var n=l("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},l.put=function(e,t,r){var n=l("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},function(e,t,r){"use strict";(function(e){
|
|
6
6
|
/*!
|
|
7
7
|
* The buffer module from node.js, for the browser.
|
|
8
8
|
*
|
|
9
9
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
10
10
|
* @license MIT
|
|
11
11
|
*/
|
|
12
|
-
var n=r(239),o=r(240),i=r(241);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,r)}function c(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=h(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):h(t,e);if("Buffer"===e.type&&i(e.data))return h(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(l(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function h(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(n)return U(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var l=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){f=!1;break}if(f)return i}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function _(t,e,r,n){return H(U(e,t.length-r),t,r,n)}function w(t,e,r,n){return H(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function k(t,e,r,n){return w(t,e,r,n)}function S(t,e,r,n){return H(q(e),t,r,n)}function x(t,e,r,n){return H(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,c=t[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return c(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return l(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):m.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),c=this.slice(n,o),l=t.slice(e,r),f=0;f<a;++f)if(c[f]!==l[f]){i=c[f],s=l[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return k(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function P(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function I(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=F(t[i]);return o}function O(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function M(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function R(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function D(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):D(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):D(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):D(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:U(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function U(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(10))},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var t=a(h);l=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;)u&&u[f].run();f=-1,e=c.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function m(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new d(t,e)),1!==c.length||l||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){(function(n){e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(n++,"%c"===t&&(o=n))}),e.splice(o,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(t){}!t&&void 0!==n&&"env"in n&&(t=n.env.DEBUG);return t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.log=console.debug||console.log||(()=>{}),t.exports=r(258)(e);const{formatters:o}=t.exports;o.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,r(9))},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(28);t.exports=function(t){return n(t,{weekStartsOn:1})}},function(t,e,r){var n=r(0),o=r(14);t.exports=function(t){var e=n(t),r=e.getFullYear(),i=new Date(0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);var s=o(i),a=new Date(0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);var u=o(a);return e.getTime()>=s.getTime()?r+1:e.getTime()>=u.getTime()?r:r-1}},function(t,e,r){(e=t.exports=r(95)).Stream=e,e.Readable=e,e.Writable=r(99),e.Duplex=r(18),e.Transform=r(101),e.PassThrough=r(249),e.finished=r(44),e.pipeline=r(250)},function(t,e,r){"use strict";var n={};function o(t,e,r){r||(r=Error);var o=function(t){var r,n;function o(r,n,o){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,o))||this}return n=t,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,o}(r);o.prototype.name=r.name,o.prototype.code=t,n[t]=o}function i(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}o("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),o("ERR_INVALID_ARG_TYPE",(function(t,e,r){var n,o,s,a;if("string"==typeof e&&(o="not ",e.substr(!s||s<0?0:+s,o.length)===o)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(i(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(i(e,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},function(t,e,r){"use strict";(function(e){var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=c;var o=r(95),i=r(99);r(12)(c,o);for(var s=n(i.prototype),a=0;a<s.length;a++){var u=s[a];c.prototype[u]||(c.prototype[u]=i.prototype[u])}function c(t){if(!(this instanceof c))return new c(t);o.call(this,t),i.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||e.nextTick(f,this)}function f(t){t.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})}).call(this,r(9))},function(t,e,r){"use strict";t.exports=TypeError},function(t,e,r){var n=r(125),o=r(126),i=r(56),s=r(127);t.exports=function(t){return n(t)||o(t)||i(t)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(15),o=r(14);t.exports=function(t){var e=n(t),r=new Date(0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),o(r)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t).getTime(),o=n(e).getTime();return r<o?-1:r>o?1:0}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setDate(r.getDate()+o),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t).getTime(),o=Number(e);return new Date(r+o)}},function(t,e,r){"use strict";var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}g(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&g(t,"error",e,r)}(t,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var o,i,s,a;if(c(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=l(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=h.bind(n);return o.listener=r,n.wrapFn=o,o}function d(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):y(o,o.length)}function m(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function g(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");u=t}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return l(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)i(u,this,e);else{var c=u.length,l=y(u,c);for(r=0;r<c;++r)i(l[r],this,e)}return!0},a.prototype.addListener=function(t,e){return f(this,t,e,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(t,e){return f(this,t,e,!0)},a.prototype.once=function(t,e){return c(e),this.on(t,p(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,p(this,t,e)),this},a.prototype.removeListener=function(t,e){var r,n,o,i,s;if(c(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return d(this,t,!0)},a.prototype.rawListeners=function(t){return d(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e){function r(e){return t.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,r(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(13);t.exports=function(t,e){var r=n(t),o=n(e),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/864e5)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=e&&Number(e.weekStartsOn)||0,o=n(t),i=o.getDay(),s=(i<r?7:0)+i-r;return o.setDate(o.getDate()-s),o.setHours(0,0,0,0),o}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()-o.getTime()}},function(t,e,r){var n=r(0),o=r(39);t.exports=function(t,e){var r=n(t),i=Number(e),s=r.getMonth()+i,a=new Date(0);a.setFullYear(r.getFullYear(),s,1),a.setHours(0,0,0,0);var u=o(a);return r.setMonth(s,Math.min(u,r.getDate())),r}},function(t,e,r){(function(e){var n="function"==typeof Map&&Map.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,i=n&&o&&"function"==typeof o.get?o.get:null,s=n&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,u=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=a&&u&&"function"==typeof u.get?u.get:null,l=a&&Set.prototype.forEach,f="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,h="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,p="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,d=Boolean.prototype.valueOf,m=Object.prototype.toString,y=Function.prototype.toString,g=String.prototype.match,v=String.prototype.slice,b=String.prototype.replace,_=String.prototype.toUpperCase,w=String.prototype.toLowerCase,k=RegExp.prototype.test,S=Array.prototype.concat,x=Array.prototype.join,E=Array.prototype.slice,A=Math.floor,T="function"==typeof BigInt?BigInt.prototype.valueOf:null,P=Object.getOwnPropertySymbols,I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,O="function"==typeof Symbol&&"object"==typeof Symbol.iterator,M="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===O||"symbol")?Symbol.toStringTag:null,C=Object.prototype.propertyIsEnumerable,R=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function D(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||k.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var n=t<0?-A(-t):A(t);if(n!==t){var o=String(n),i=v.call(e,o.length+1);return b.call(o,r,"$&_")+"."+b.call(b.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(e,r,"$&_")}var j=r(279),L=j.custom,N=Y(L)?L:null,B={__proto__:null,double:'"',single:"'"},F={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function U(t,e,r){var n=r.quoteStyle||e,o=B[n];return o+t+o}function q(t){return b.call(String(t),/"/g,""")}function H(t){return!M||!("object"==typeof t&&(M in t||void 0!==t[M]))}function W(t){return"[object Array]"===V(t)&&H(t)}function K(t){return"[object RegExp]"===V(t)&&H(t)}function Y(t){if(O)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!I)return!1;try{return I.call(t),!0}catch(t){}return!1}t.exports=function t(r,n,o,a){var u=n||{};if($(u,"quoteStyle")&&!$(B,u.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if($(u,"maxStringLength")&&("number"==typeof u.maxStringLength?u.maxStringLength<0&&u.maxStringLength!==1/0:null!==u.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var m=!$(u,"customInspect")||u.customInspect;if("boolean"!=typeof m&&"symbol"!==m)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if($(u,"indent")&&null!==u.indent&&"\t"!==u.indent&&!(parseInt(u.indent,10)===u.indent&&u.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if($(u,"numericSeparator")&&"boolean"!=typeof u.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var _=u.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function t(e,r){if(e.length>r.maxStringLength){var n=e.length-r.maxStringLength,o="... "+n+" more character"+(n>1?"s":"");return t(v.call(e,0,r.maxStringLength),r)+o}var i=F[r.quoteStyle||"single"];return i.lastIndex=0,U(b.call(b.call(e,i,"\\$1"),/[\x00-\x1f]/g,Q),"single",r)}(r,u);if("number"==typeof r){if(0===r)return 1/0/r>0?"0":"-0";var k=String(r);return _?D(r,k):k}if("bigint"==typeof r){var A=String(r)+"n";return _?D(r,A):A}var P=void 0===u.depth?5:u.depth;if(void 0===o&&(o=0),o>=P&&P>0&&"object"==typeof r)return W(r)?"[Array]":"[Object]";var L=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=x.call(Array(t.indent+1)," ")}return{base:r,prev:x.call(Array(e+1),r)}}(u,o);if(void 0===a)a=[];else if(G(a,r)>=0)return"[Circular]";function z(e,r,n){if(r&&(a=E.call(a)).push(r),n){var i={depth:u.depth};return $(u,"quoteStyle")&&(i.quoteStyle=u.quoteStyle),t(e,i,o+1,a)}return t(e,u,o+1,a)}if("function"==typeof r&&!K(r)){var rt=function(t){if(t.name)return t.name;var e=g.call(y.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(r),nt=et(r,z);return"[Function"+(rt?": "+rt:" (anonymous)")+"]"+(nt.length>0?" { "+x.call(nt,", ")+" }":"")}if(Y(r)){var ot=O?b.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):I.call(r);return"object"!=typeof r||O?ot:J(ot)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(r)){for(var it="<"+w.call(String(r.nodeName)),st=r.attributes||[],at=0;at<st.length;at++)it+=" "+st[at].name+"="+U(q(st[at].value),"double",u);return it+=">",r.childNodes&&r.childNodes.length&&(it+="..."),it+="</"+w.call(String(r.nodeName))+">"}if(W(r)){if(0===r.length)return"[]";var ut=et(r,z);return L&&!function(t){for(var e=0;e<t.length;e++)if(G(t[e],"\n")>=0)return!1;return!0}(ut)?"["+tt(ut,L)+"]":"[ "+x.call(ut,", ")+" ]"}if(function(t){return"[object Error]"===V(t)&&H(t)}(r)){var ct=et(r,z);return"cause"in Error.prototype||!("cause"in r)||C.call(r,"cause")?0===ct.length?"["+String(r)+"]":"{ ["+String(r)+"] "+x.call(ct,", ")+" }":"{ ["+String(r)+"] "+x.call(S.call("[cause]: "+z(r.cause),ct),", ")+" }"}if("object"==typeof r&&m){if(N&&"function"==typeof r[N]&&j)return j(r,{depth:P-o});if("symbol"!==m&&"function"==typeof r.inspect)return r.inspect()}if(function(t){if(!i||!t||"object"!=typeof t)return!1;try{i.call(t);try{c.call(t)}catch(t){return!0}return t instanceof Map}catch(t){}return!1}(r)){var lt=[];return s&&s.call(r,(function(t,e){lt.push(z(e,r,!0)+" => "+z(t,r))})),Z("Map",i.call(r),lt,L)}if(function(t){if(!c||!t||"object"!=typeof t)return!1;try{c.call(t);try{i.call(t)}catch(t){return!0}return t instanceof Set}catch(t){}return!1}(r)){var ft=[];return l&&l.call(r,(function(t){ft.push(z(t,r))})),Z("Set",c.call(r),ft,L)}if(function(t){if(!f||!t||"object"!=typeof t)return!1;try{f.call(t,f);try{h.call(t,h)}catch(t){return!0}return t instanceof WeakMap}catch(t){}return!1}(r))return X("WeakMap");if(function(t){if(!h||!t||"object"!=typeof t)return!1;try{h.call(t,h);try{f.call(t,f)}catch(t){return!0}return t instanceof WeakSet}catch(t){}return!1}(r))return X("WeakSet");if(function(t){if(!p||!t||"object"!=typeof t)return!1;try{return p.call(t),!0}catch(t){}return!1}(r))return X("WeakRef");if(function(t){return"[object Number]"===V(t)&&H(t)}(r))return J(z(Number(r)));if(function(t){if(!t||"object"!=typeof t||!T)return!1;try{return T.call(t),!0}catch(t){}return!1}(r))return J(z(T.call(r)));if(function(t){return"[object Boolean]"===V(t)&&H(t)}(r))return J(d.call(r));if(function(t){return"[object String]"===V(t)&&H(t)}(r))return J(z(String(r)));if("undefined"!=typeof window&&r===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&r===globalThis||void 0!==e&&r===e)return"{ [object globalThis] }";if(!function(t){return"[object Date]"===V(t)&&H(t)}(r)&&!K(r)){var ht=et(r,z),pt=R?R(r)===Object.prototype:r instanceof Object||r.constructor===Object,dt=r instanceof Object?"":"null prototype",mt=!pt&&M&&Object(r)===r&&M in r?v.call(V(r),8,-1):dt?"Object":"",yt=(pt||"function"!=typeof r.constructor?"":r.constructor.name?r.constructor.name+" ":"")+(mt||dt?"["+x.call(S.call([],mt||[],dt||[]),": ")+"] ":"");return 0===ht.length?yt+"{}":L?yt+"{"+tt(ht,L)+"}":yt+"{ "+x.call(ht,", ")+" }"}return String(r)};var z=Object.prototype.hasOwnProperty||function(t){return t in this};function $(t,e){return z.call(t,e)}function V(t){return m.call(t)}function G(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}function Q(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+_.call(e.toString(16))}function J(t){return"Object("+t+")"}function X(t){return t+" { ? }"}function Z(t,e,r,n){return t+" ("+e+") {"+(n?tt(r,n):x.call(r,", "))+"}"}function tt(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+x.call(t,","+r)+"\n"+e.prev}function et(t,e){var r=W(t),n=[];if(r){n.length=t.length;for(var o=0;o<t.length;o++)n[o]=$(t,o)?e(t[o],t):""}var i,s="function"==typeof P?P(t):[];if(O){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var u in t)$(t,u)&&(r&&String(Number(u))===u&&u<t.length||O&&i["$"+u]instanceof Symbol||(k.call(/[^\w$]/,u)?n.push(e(u,t)+": "+e(t[u],t)):n.push(u+": "+e(t[u],t))));if("function"==typeof P)for(var c=0;c<s.length;c++)C.call(t,s[c])&&n.push("["+e(s[c])+"]: "+e(t[s[c]],t));return n}}).call(this,r(10))},function(t,e,r){"use strict";var n=r(301);t.exports=Function.prototype.bind||n},function(t,e){t.exports=function(t){return t instanceof Date}},function(t,e,r){var n=r(0),o=r(14),i=r(21);t.exports=function(t){var e=n(t),r=o(e).getTime()-i(e).getTime();return Math.round(r/6048e5)+1}},function(t,e,r){var n=r(136),o=r(137);t.exports={distanceInWords:n(),format:o()}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t).getTime(),o=n(e).getTime();return r>o?-1:r<o?1:0}},function(t,e,r){var n=r(29);t.exports=function(t,e){var r=n(t,e)/1e3;return r>0?Math.floor(r):Math.ceil(r)}},function(t,e,r){var n=r(0),o=r(63),i=r(22);t.exports=function(t,e){var r=n(t),s=n(e),a=i(r,s),u=Math.abs(o(r,s));return r.setMonth(r.getMonth()-a*u),a*(u-(i(r,s)===-a))}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getFullYear(),o=e.getMonth(),i=new Date(0);return i.setFullYear(r,o+1,0),i.setHours(0,0,0,0),i.getDate()}},function(t,e,r){var n=r(23);t.exports=function(t,e){var r=Number(e);return n(t,7*r)}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setHours(23,59,59,999),e}},function(t,e,r){var n=r(28);t.exports=function(t,e,r){var o=n(t,r),i=n(e,r);return o.getTime()===i.getTime()}},function(t,e){t.exports=function(){for(var t={},e=0;e<arguments.length;e++){var n=arguments[e];for(var o in n)r.call(n,o)&&(t[o]=n[o])}return t};var r=Object.prototype.hasOwnProperty},function(t,e,r){"use strict";var n=r(17).codes.ERR_STREAM_PREMATURE_CLOSE;function o(){}t.exports=function t(e,r,i){if("function"==typeof r)return t(e,null,r);r||(r={}),i=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];t.apply(this,n)}}}(i||o);var s=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},c=e._writableState&&e._writableState.finished,l=function(){a=!1,c=!0,s||i.call(e)},f=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,f=!0,a||i.call(e)},p=function(t){i.call(e,t)},d=function(){var t;return s&&!f?(e._readableState&&e._readableState.ended||(t=new n),i.call(e,t)):a&&!c?(e._writableState&&e._writableState.ended||(t=new n),i.call(e,t)):void 0},m=function(){e.req.on("finish",l)};return!function(t){return t.setHeader&&"function"==typeof t.abort}(e)?a&&!e._writableState&&(e.on("end",u),e.on("close",u)):(e.on("complete",l),e.on("abort",d),e.req?m():e.on("request",m)),e.on("end",h),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",m),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},function(t,e,r){"use strict";var n=r(105),o=r(281),i=r(282),s=r(283),a=r(284),u=r(285),c=r(19),l=r(286),f=r(287),h=r(288),p=r(289),d=r(290),m=r(291),y=r(292),g=r(293),v=Function,b=function(t){try{return v('"use strict"; return ('+t+").constructor;")()}catch(t){}},_=r(106),w=r(296),k=function(){throw new c},S=_?function(){try{return k}catch(t){try{return _(arguments,"callee").get}catch(t){return k}}}():k,x=r(297)(),E=r(299),A=r(108),T=r(107),P=r(110),I=r(46),O={},M="undefined"!=typeof Uint8Array&&E?E(Uint8Array):void 0,C={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":x&&E?E([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":O,"%AsyncGenerator%":O,"%AsyncGeneratorFunction%":O,"%AsyncIteratorPrototype%":O,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":i,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":O,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":x&&E?E(E([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&x&&E?E((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":n,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&x&&E?E((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":x&&E?E(""[Symbol.iterator]()):void 0,"%Symbol%":x?Symbol:void 0,"%SyntaxError%":u,"%ThrowTypeError%":S,"%TypedArray%":M,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":I,"%Function.prototype.apply%":P,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":A,"%Math.abs%":f,"%Math.floor%":h,"%Math.max%":p,"%Math.min%":d,"%Math.pow%":m,"%Math.round%":y,"%Math.sign%":g,"%Reflect.getPrototypeOf%":T};if(E)try{null.error}catch(t){var R=E(E(t));C["%Error.prototype%"]=R}var D={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},j=r(32),L=r(304),N=j.call(I,Array.prototype.concat),B=j.call(P,Array.prototype.splice),F=j.call(I,String.prototype.replace),U=j.call(I,String.prototype.slice),q=j.call(I,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,W=/\\(\\)?/g,K=function(t){var e=U(t,0,1),r=U(t,-1);if("%"===e&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return F(t,H,(function(t,e,r,o){n[n.length]=r?F(o,W,"$1"):e||t})),n},Y=function(t,e){var r,n=t;if(L(D,n)&&(n="%"+(r=D[n])[0]+"%"),L(C,n)){var o=C[n];if(o===O&&(o=function t(e){var r;if("%AsyncFunction%"===e)r=b("async function () {}");else if("%GeneratorFunction%"===e)r=b("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=b("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var o=t("%AsyncGenerator%");o&&E&&(r=E(o.prototype))}return C[e]=r,r}(n)),void 0===o&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new u("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===q(/^%?[^%]*%?$/,t))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=K(t),n=r.length>0?r[0]:"",o=Y("%"+n+"%",e),i=o.name,s=o.value,a=!1,l=o.alias;l&&(n=l[0],B(r,N([0,1],l)));for(var f=1,h=!0;f<r.length;f+=1){var p=r[f],d=U(p,0,1),m=U(p,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new u("property names with quotes must have matching quotes");if("constructor"!==p&&h||(a=!0),L(C,i="%"+(n+="."+p)+"%"))s=C[i];else if(null!=s){if(!(p in s)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(_&&f+1>=r.length){var y=_(s,p);s=(h=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:s[p]}else h=L(s,p),s=s[p];h&&!a&&(C[i]=s)}}return s}},function(t,e,r){"use strict";t.exports=Function.prototype.call},function(t,e,r){"use strict";var n=String.prototype.replace,o=/%20/g,i="RFC1738",s="RFC3986";t.exports={default:s,formatters:{RFC1738:function(t){return n.call(t,o,"+")},RFC3986:function(t){return String(t)}},RFC1738:i,RFC3986:s}},function(t,e,r){"use strict";const n=r(307),o=r(114),i=r(11)("mqttjs:tls");t.exports=function(t,e){e.port=e.port||8883,e.host=e.hostname||e.host||"localhost",0===o.isIP(e.host)&&(e.servername=e.host),e.rejectUnauthorized=!1!==e.rejectUnauthorized,delete e.path,i("port %d host %s rejectUnauthorized %b",e.port,e.host,e.rejectUnauthorized);const r=n.connect(e);function s(n){e.rejectUnauthorized&&t.emit("error",n),r.end()}return r.on("secureConnect",(function(){e.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s)})),r.on("error",s),r}},function(t,e,r){(function(e,n){var o=r(16),i=r(308),s=r(12),a=r(311),u=e.from&&e.from!==Uint8Array.from?e.from([0]):new e([0]),c=function(t,e){t._corked?t.once("uncork",e):e()},l=function(t,e){return function(r){r?function(t,e){t._autoDestroy&&t.destroy(e)}(t,"premature close"===r.message?null:r):e&&!t._ended&&t.end()}},f=function(){},h=function(t,e,r){if(!(this instanceof h))return new h(t,e,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,t&&this.setWritable(t),e&&this.setReadable(e)};s(h,o.Duplex),h.obj=function(t,e,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new h(t,e,r)},h.prototype.cork=function(){1==++this._corked&&this.emit("cork")},h.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},h.prototype.setWritable=function(t){if(this._unwrite&&this._unwrite(),this.destroyed)t&&t.destroy&&t.destroy();else if(null!==t&&!1!==t){var e=this,r=i(t,{writable:!0,readable:!1},l(this,this._forwardEnd)),o=function(){var t=e._ondrain;e._ondrain=null,t&&t()};this._unwrite&&n.nextTick(o),this._writable=t,this._writable.on("drain",o),this._unwrite=function(){e._writable.removeListener("drain",o),r()},this.uncork()}else this.end()},h.prototype.setReadable=function(t){if(this._unread&&this._unread(),this.destroyed)t&&t.destroy&&t.destroy();else{if(null===t||!1===t)return this.push(null),void this.resume();var e,r=this,n=i(t,{writable:!1,readable:!0},l(this)),s=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=t,this._readable2=t._readableState?t:(e=t,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)),this._readable2.on("readable",s),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",s),r._readable2.removeListener("end",a),n()},this._forward()}},h.prototype._read=function(){this._drained=!0,this._forward()},h.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var t;for(this._forwarding=!0;this._drained&&null!==(t=a(this._readable2));)this.destroyed||(this._drained=this.push(t));this._forwarding=!1}},h.prototype.destroy=function(t,e){if(e||(e=f),this.destroyed)return e(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(t),e(null)}))},h.prototype._destroy=function(t){if(t){var e=this._ondrain;this._ondrain=null,e?e(t):this.emit("error",t)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},h.prototype._write=function(t,e,r){if(!this.destroyed)return this._corked?c(this,this._write.bind(this,t,e,r)):t===u?this._finish(r):this._writable?void(!1===this._writable.write(t)?this._ondrain=r:this.destroyed||r()):r()},h.prototype._finish=function(t){var e=this;this.emit("preend"),c(this,(function(){var r,n;r=e._forwardEnd&&e._writable,n=function(){!1===e._writableState.prefinished&&(e._writableState.prefinished=!0),e.emit("prefinish"),c(e,t)},r?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n()}))},h.prototype.end=function(t,e,r){return"function"==typeof t?this.end(null,null,t):"function"==typeof e?this.end(t,null,e):(this._ended=!0,t&&this.write(t),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},t.exports=h}).call(this,r(8).Buffer,r(9))},function(t,e,r){var n=r(59),o=r(34),i=r(15),s=r(0),a=r(61),u=r(35);var c={M:function(t){return t.getMonth()+1},MM:function(t){return h(t.getMonth()+1,2)},Q:function(t){return Math.ceil((t.getMonth()+1)/3)},D:function(t){return t.getDate()},DD:function(t){return h(t.getDate(),2)},DDD:function(t){return n(t)},DDDD:function(t){return h(n(t),3)},d:function(t){return t.getDay()},E:function(t){return t.getDay()||7},W:function(t){return o(t)},WW:function(t){return h(o(t),2)},YY:function(t){return h(t.getFullYear(),4).substr(2)},YYYY:function(t){return h(t.getFullYear(),4)},GG:function(t){return String(i(t)).substr(2)},GGGG:function(t){return i(t)},H:function(t){return t.getHours()},HH:function(t){return h(t.getHours(),2)},h:function(t){var e=t.getHours();return 0===e?12:e>12?e%12:e},hh:function(t){return h(c.h(t),2)},m:function(t){return t.getMinutes()},mm:function(t){return h(t.getMinutes(),2)},s:function(t){return t.getSeconds()},ss:function(t){return h(t.getSeconds(),2)},S:function(t){return Math.floor(t.getMilliseconds()/100)},SS:function(t){return h(Math.floor(t.getMilliseconds()/10),2)},SSS:function(t){return h(t.getMilliseconds(),3)},Z:function(t){return f(t.getTimezoneOffset(),":")},ZZ:function(t){return f(t.getTimezoneOffset())},X:function(t){return Math.floor(t.getTime()/1e3)},x:function(t){return t.getTime()}};function l(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|]$/g,""):t.replace(/\\/g,"")}function f(t,e){e=e||"";var r=t>0?"-":"+",n=Math.abs(t),o=n%60;return r+h(Math.floor(n/60),2)+e+h(o,2)}function h(t,e){for(var r=Math.abs(t).toString();r.length<e;)r="0"+r;return r}t.exports=function(t,e,r){var n=e?String(e):"YYYY-MM-DDTHH:mm:ss.SSSZ",o=(r||{}).locale,i=u.format.formatters,f=u.format.formattingTokensRegExp;o&&o.format&&o.format.formatters&&(i=o.format.formatters,o.format.formattingTokensRegExp&&(f=o.format.formattingTokensRegExp));var h=s(t);return a(h)?function(t,e,r){var n,o,i=t.match(r),s=i.length;for(n=0;n<s;n++)o=e[i[n]]||c[i[n]],i[n]=o||l(i[n]);return function(t){for(var e="",r=0;r<s;r++)i[r]instanceof Function?e+=i[r](t,c):e+=i[r];return e}}(n,i,f)(h):"Invalid Date"}},function(t,e,r){var n=r(62);t.exports=function(t,e){return n(Date.now(),t,e)}},function(t,e,r){t.exports={addDays:r(23),addHours:r(64),addISOYears:r(65),addMilliseconds:r(24),addMinutes:r(67),addMonths:r(30),addQuarters:r(68),addSeconds:r(69),addWeeks:r(40),addYears:r(70),areRangesOverlapping:r(139),closestIndexTo:r(140),closestTo:r(141),compareAsc:r(22),compareDesc:r(36),differenceInCalendarDays:r(27),differenceInCalendarISOWeeks:r(142),differenceInCalendarISOYears:r(71),differenceInCalendarMonths:r(63),differenceInCalendarQuarters:r(143),differenceInCalendarWeeks:r(144),differenceInCalendarYears:r(73),differenceInDays:r(74),differenceInHours:r(145),differenceInISOYears:r(146),differenceInMilliseconds:r(29),differenceInMinutes:r(147),differenceInMonths:r(38),differenceInQuarters:r(148),differenceInSeconds:r(37),differenceInWeeks:r(149),differenceInYears:r(150),distanceInWords:r(62),distanceInWordsStrict:r(151),distanceInWordsToNow:r(51),eachDay:r(152),endOfDay:r(41),endOfHour:r(153),endOfISOWeek:r(154),endOfISOYear:r(155),endOfMinute:r(156),endOfMonth:r(77),endOfQuarter:r(157),endOfSecond:r(158),endOfToday:r(159),endOfTomorrow:r(160),endOfWeek:r(76),endOfYear:r(161),endOfYesterday:r(162),format:r(50),getDate:r(163),getDay:r(164),getDayOfYear:r(59),getDaysInMonth:r(39),getDaysInYear:r(165),getHours:r(166),getISODay:r(79),getISOWeek:r(34),getISOWeeksInYear:r(167),getISOYear:r(15),getMilliseconds:r(168),getMinutes:r(169),getMonth:r(170),getOverlappingDaysInRanges:r(171),getQuarter:r(72),getSeconds:r(172),getTime:r(173),getYear:r(174),isAfter:r(175),isBefore:r(176),isDate:r(33),isEqual:r(177),isFirstDayOfMonth:r(178),isFriday:r(179),isFuture:r(180),isLastDayOfMonth:r(181),isLeapYear:r(78),isMonday:r(182),isPast:r(183),isSameDay:r(184),isSameHour:r(80),isSameISOWeek:r(82),isSameISOYear:r(83),isSameMinute:r(84),isSameMonth:r(86),isSameQuarter:r(87),isSameSecond:r(89),isSameWeek:r(42),isSameYear:r(91),isSaturday:r(185),isSunday:r(186),isThisHour:r(187),isThisISOWeek:r(188),isThisISOYear:r(189),isThisMinute:r(190),isThisMonth:r(191),isThisQuarter:r(192),isThisSecond:r(193),isThisWeek:r(194),isThisYear:r(195),isThursday:r(196),isToday:r(197),isTomorrow:r(198),isTuesday:r(199),isValid:r(61),isWednesday:r(200),isWeekend:r(201),isWithinRange:r(202),isYesterday:r(203),lastDayOfISOWeek:r(204),lastDayOfISOYear:r(205),lastDayOfMonth:r(206),lastDayOfQuarter:r(207),lastDayOfWeek:r(92),lastDayOfYear:r(208),max:r(209),min:r(210),parse:r(0),setDate:r(211),setDay:r(212),setDayOfYear:r(213),setHours:r(214),setISODay:r(215),setISOWeek:r(216),setISOYear:r(66),setMilliseconds:r(217),setMinutes:r(218),setMonth:r(93),setQuarter:r(219),setSeconds:r(220),setYear:r(221),startOfDay:r(13),startOfHour:r(81),startOfISOWeek:r(14),startOfISOYear:r(21),startOfMinute:r(85),startOfMonth:r(222),startOfQuarter:r(88),startOfSecond:r(90),startOfToday:r(223),startOfTomorrow:r(224),startOfWeek:r(28),startOfYear:r(60),startOfYesterday:r(225),subDays:r(226),subHours:r(227),subISOYears:r(75),subMilliseconds:r(228),subMinutes:r(229),subMonths:r(230),subQuarters:r(231),subSeconds:r(232),subWeeks:r(233),subYears:r(234)}},function(t,e,r){var n=r(118);t.exports=function(t){return new n(t,0)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(118);function o(t){var e,r;function o(e,r){try{var s=t[e](r),a=s.value,u=a instanceof n;Promise.resolve(u?a.v:a).then((function(r){if(u){var n="return"===e?"return":"next";if(!a.k||r.done)return o(n,r);r=t[n](r).value}i(s.done?"return":"normal",r)}),(function(t){o("throw",t)}))}catch(t){i("throw",t)}}function i(t,n){switch(t){case"return":e.resolve({value:n,done:!0});break;case"throw":e.reject(n);break;default:e.resolve({value:n,done:!1})}(e=e.next)?o(e.key,e.arg):r=null}this._invoke=function(t,n){return new Promise((function(i,s){var a={key:t,arg:n,resolve:i,reject:s,next:null};r?r=r.next=a:(e=r=a,o(t,n))}))},"function"!=typeof t.return&&(this.return=void 0)}o.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},o.prototype.next=function(t){return this._invoke("next",t)},o.prototype.throw=function(t){return this._invoke("throw",t)},o.prototype.return=function(t){return this._invoke("return",t)},t.exports=function(t){return function(){return new o(t.apply(this,arguments))}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(55);t.exports=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(26).default,o=r(128);t.exports=function(t){var e=o(t,"string");return"symbol"==n(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){"use strict";t.exports=function(t){return null!==t&&"object"==typeof t}},function(t,e,r){var n=r(0),o=r(60),i=r(27);t.exports=function(t){var e=n(t);return i(e,o(e))+1}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=new Date(0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}},function(t,e,r){var n=r(33);t.exports=function(t){if(n(t))return!isNaN(t);throw new TypeError(toString.call(t)+" is not an instance of Date")}},function(t,e,r){var n=r(36),o=r(0),i=r(37),s=r(38),a=r(35);t.exports=function(t,e,r){var u=r||{},c=n(t,e),l=u.locale,f=a.distanceInWords.localize;l&&l.distanceInWords&&l.distanceInWords.localize&&(f=l.distanceInWords.localize);var h,p,d={addSuffix:Boolean(u.addSuffix),comparison:c};c>0?(h=o(t),p=o(e)):(h=o(e),p=o(t));var m,y=i(p,h),g=p.getTimezoneOffset()-h.getTimezoneOffset(),v=Math.round(y/60)-g;if(v<2)return u.includeSeconds?y<5?f("lessThanXSeconds",5,d):y<10?f("lessThanXSeconds",10,d):y<20?f("lessThanXSeconds",20,d):y<40?f("halfAMinute",null,d):f(y<60?"lessThanXMinutes":"xMinutes",1,d):0===v?f("lessThanXMinutes",1,d):f("xMinutes",v,d);if(v<45)return f("xMinutes",v,d);if(v<90)return f("aboutXHours",1,d);if(v<1440)return f("aboutXHours",Math.round(v/60),d);if(v<2520)return f("xDays",1,d);if(v<43200)return f("xDays",Math.round(v/1440),d);if(v<86400)return f("aboutXMonths",m=Math.round(v/43200),d);if((m=s(p,h))<12)return f("xMonths",Math.round(v/43200),d);var b=m%12,_=Math.floor(m/12);return b<3?f("aboutXYears",_,d):b<9?f("overXYears",_,d):f("almostXYears",_+1,d)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return 12*(r.getFullYear()-o.getFullYear())+(r.getMonth()-o.getMonth())}},function(t,e,r){var n=r(24);t.exports=function(t,e){var r=Number(e);return n(t,36e5*r)}},function(t,e,r){var n=r(15),o=r(66);t.exports=function(t,e){var r=Number(e);return o(t,n(t)+r)}},function(t,e,r){var n=r(0),o=r(21),i=r(27);t.exports=function(t,e){var r=n(t),s=Number(e),a=i(r,o(r)),u=new Date(0);return u.setFullYear(s,0,4),u.setHours(0,0,0,0),(r=o(u)).setDate(r.getDate()+a),r}},function(t,e,r){var n=r(24);t.exports=function(t,e){var r=Number(e);return n(t,6e4*r)}},function(t,e,r){var n=r(30);t.exports=function(t,e){var r=Number(e);return n(t,3*r)}},function(t,e,r){var n=r(24);t.exports=function(t,e){var r=Number(e);return n(t,1e3*r)}},function(t,e,r){var n=r(30);t.exports=function(t,e){var r=Number(e);return n(t,12*r)}},function(t,e,r){var n=r(15);t.exports=function(t,e){return n(t)-n(e)}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return Math.floor(e.getMonth()/3)+1}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getFullYear()-o.getFullYear()}},function(t,e,r){var n=r(0),o=r(27),i=r(22);t.exports=function(t,e){var r=n(t),s=n(e),a=i(r,s),u=Math.abs(o(r,s));return r.setDate(r.getDate()-a*u),a*(u-(i(r,s)===-a))}},function(t,e,r){var n=r(65);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=e&&Number(e.weekStartsOn)||0,o=n(t),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setDate(o.getDate()+s),o.setHours(23,59,59,999),o}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t).getFullYear();return e%400==0||e%4==0&&e%100!=0}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t).getDay();return 0===e&&(e=7),e}},function(t,e,r){var n=r(81);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setMinutes(0,0,0),e}},function(t,e,r){var n=r(42);t.exports=function(t,e){return n(t,e,{weekStartsOn:1})}},function(t,e,r){var n=r(21);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(85);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setSeconds(0,0),e}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}},function(t,e,r){var n=r(88);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getMonth(),o=r-r%3;return e.setMonth(o,1),e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(90);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setMilliseconds(0),e}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getFullYear()===o.getFullYear()}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=e&&Number(e.weekStartsOn)||0,o=n(t),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setHours(0,0,0,0),o.setDate(o.getDate()+s),o}},function(t,e,r){var n=r(0),o=r(39);t.exports=function(t,e){var r=n(t),i=Number(e),s=r.getFullYear(),a=r.getDate(),u=new Date(0);u.setFullYear(s,i,15),u.setHours(0,0,0,0);var c=o(u);return r.setMonth(i,Math.min(a,c)),r}},function(t,e,r){"use strict";const n=r(43),o=r(16).Readable,i={objectMode:!0},s={clean:!0};function a(t){if(!(this instanceof a))return new a(t);this.options=t||{},this.options=n(s,t),this._inflights=new Map}a.prototype.put=function(t,e){return this._inflights.set(t.messageId,t),e&&e(),this},a.prototype.createStream=function(){const t=new o(i),e=[];let r=!1,n=0;return this._inflights.forEach((function(t,r){e.push(t)})),t._read=function(){!r&&n<e.length?this.push(e[n++]):this.push(null)},t.destroy=function(){if(r)return;const t=this;r=!0,setTimeout((function(){t.emit("close")}),0)},t},a.prototype.del=function(t,e){return(t=this._inflights.get(t.messageId))?(this._inflights.delete(t.messageId),e(null,t)):e&&e(new Error("missing packet")),this},a.prototype.get=function(t,e){return(t=this._inflights.get(t.messageId))?e(null,t):e&&e(new Error("missing packet")),this},a.prototype.close=function(t){this.options.clean&&(this._inflights=null),t&&t()},t.exports=a},function(t,e,r){"use strict";(function(e,n){var o;t.exports=E,E.ReadableState=x;r(25).EventEmitter;var i=function(t,e){return t.listeners(e).length},s=r(96),a=r(8).Buffer,u=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=r(242);c=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(243),m=r(97),y=r(98).getHighWaterMark,g=r(17).codes,v=g.ERR_INVALID_ARG_TYPE,b=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,w=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(12)(E,s);var k=m.errorOrDestroy,S=["error","close","destroy","pause","resume"];function x(t,e,n){o=o||r(18),t=t||{},"boolean"!=typeof n&&(n=e instanceof o),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(100).StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function E(t){if(o=o||r(18),!(this instanceof E))return new E(t);var e=this instanceof o;this._readableState=new x(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function A(t,e,r,n,o){c("readableAddChunk",e);var i,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(c("onEofChunk"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,O(t)))}(t,s);else if(o||(i=function(t,e){var r;n=e,a.isBuffer(n)||n instanceof u||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e));var n;return r}(s,e)),i)k(t,i);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),n)s.endEmitted?k(t,new w):T(t,s,e,!0);else if(s.ended)k(t,new b);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?T(t,s,e,!1):M(t,s)):T(t,s,e,!1)}else n||(s.reading=!1,M(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function T(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&I(t)),M(t,e)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),E.prototype.destroy=m.destroy,E.prototype._undestroy=m.undestroy,E.prototype._destroy=function(t,e){e(t)},E.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=a.from(t,e),e=""),r=!0),A(this,t,e,!1,r)},E.prototype.unshift=function(t){return A(this,t,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(t){f||(f=r(100).StringDecoder);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,o="";null!==n;)o+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};function P(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,n.nextTick(O,t))}function O(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,L(t)}function M(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(c("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function R(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function D(t){c("readable nexttick read 0"),t.read(0)}function j(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),L(t),e.flowing&&!e.reading&&t.read(0)}function L(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function B(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,n.nextTick(F,e,t))}function F(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function U(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}E.prototype.read=function(t){c("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?B(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&B(this),null;var n,o=e.needReadable;return c("need readable",o),(0===e.length||e.length-t<e.highWaterMark)&&c("length less than watermark",o=!0),e.ended||e.reading?c("reading or ended",o=!1):o&&(c("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=P(r,e))),null===(n=t>0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&B(this)),null!==n&&this.emit("data",n),n},E.prototype._read=function(t){k(this,new _("_read()"))},E.prototype.pipe=function(t,e){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,c("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?u:y;function a(e,n){c("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",m),t.removeListener("drain",l),t.removeListener("error",p),t.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",h),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function u(){c("onend"),t.end()}o.endEmitted?n.nextTick(s):r.once("end",s),t.on("unpipe",a);var l=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,"data")&&(e.flowing=!0,L(t))}}(r);t.on("drain",l);var f=!1;function h(e){c("ondata");var n=t.write(e);c("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==U(o.pipes,t))&&!f&&(c("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function p(e){c("onerror",e),y(),t.removeListener("error",p),0===i(t,"error")&&k(t,e)}function d(){t.removeListener("finish",m),y()}function m(){c("onfinish"),t.removeListener("close",d),y()}function y(){c("unpipe"),r.unpipe(t)}return r.on("data",h),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",p),t.once("close",d),t.once("finish",m),t.emit("pipe",r),o.flowing||(c("pipe resume"),r.resume()),t},E.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,o=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<o;i++)n[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=U(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},E.prototype.on=function(t,e){var r=s.prototype.on.call(this,t,e),o=this._readableState;return"data"===t?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===t&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,c("on readable",o.length,o.reading),o.length?I(this):o.reading||n.nextTick(D,this))),r},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&n.nextTick(R,this),r},E.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||n.nextTick(R,this),e},E.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(j,t,e))}(this,t)),t.paused=!1,this},E.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var o in t.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(o){(c("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o)||(r.objectMode||o&&o.length)&&(e.push(o)||(n=!0,t.pause()))})),t)void 0===this[o]&&"function"==typeof t[o]&&(this[o]=function(e){return function(){return t[e].apply(t,arguments)}}(o));for(var i=0;i<S.length;i++)t.on(S[i],this.emit.bind(this,S[i]));return this._read=function(e){c("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(247)),h(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),E._fromList=N,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(t,e){return void 0===p&&(p=r(248)),p(E,t,e)})}).call(this,r(10),r(9))},function(t,e,r){t.exports=r(25).EventEmitter},function(t,e,r){"use strict";(function(e){function r(t,e){o(t,e),n(t)}function n(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(t,e){t.emit("error",e)}t.exports={destroy:function(t,i){var s=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(o,this,t)):e.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?s._writableState?s._writableState.errorEmitted?e.nextTick(n,s):(s._writableState.errorEmitted=!0,e.nextTick(r,s,t)):e.nextTick(r,s,t):i?(e.nextTick(n,s),i(t)):e.nextTick(n,s)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}}).call(this,r(9))},function(t,e,r){"use strict";var n=r(17).codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,o){var i=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,o,r);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new n(o?r:"highWaterMark",i);return Math.floor(i)}return t.objectMode?16:16384}}},function(t,e,r){"use strict";(function(e,n){function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var o=n.callback;e.pendingcb--,o(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=E,E.WritableState=x;var s={deprecate:r(245)},a=r(96),u=r(8).Buffer,c=(void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l,f=r(97),h=r(98).getHighWaterMark,p=r(17).codes,d=p.ERR_INVALID_ARG_TYPE,m=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,b=p.ERR_STREAM_NULL_VALUES,_=p.ERR_STREAM_WRITE_AFTER_END,w=p.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function S(){}function x(t,e,s){i=i||r(18),t=t||{},"boolean"!=typeof s&&(s=e instanceof i),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,o,i){--e.pendingcb,r?(n.nextTick(i,o),n.nextTick(M,t,e),t._writableState.errorEmitted=!0,k(t,o)):(i(o),t._writableState.errorEmitted=!0,k(t,o),M(t,e))}(t,r,o,e,i);else{var s=I(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||P(t,r),o?n.nextTick(T,t,r,s,i):T(t,r,s,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function E(t){var e=this instanceof(i=i||r(18));if(!e&&!l.call(E,this))return new E(t);this._writableState=new x(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function A(t,e,r,n,o,i,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new v("write")):r?t._writev(o,e.onwrite):t._write(o,i,e.onwrite),e.sync=!1}function T(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),M(t,e)}function P(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,A(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(A(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function I(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function O(t,e){t._final((function(r){e.pendingcb--,r&&k(t,r),e.prefinished=!0,t.emit("prefinish"),M(t,e)}))}function M(t,e){var r=I(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,n.nextTick(O,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var o=t._readableState;(!o||o.autoDestroy&&o.endEmitted)&&t.destroy()}return r}r(12)(E,a),x.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(x.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(l=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(t){return!!l.call(this,t)||this===E&&(t&&t._writableState instanceof x)}})):l=function(t){return t instanceof this},E.prototype.pipe=function(){k(this,new g)},E.prototype.write=function(t,e,r){var o,i=this._writableState,s=!1,a=!i.objectMode&&(o=t,u.isBuffer(o)||o instanceof c);return a&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=S),i.ending?function(t,e){var r=new _;k(t,r),n.nextTick(e,r)}(this,r):(a||function(t,e,r,o){var i;return null===r?i=new b:"string"==typeof r||e.objectMode||(i=new d("chunk",["string","Buffer"],r)),!i||(k(t,i),n.nextTick(o,i),!1)}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,o,i){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,r));return e}(e,n,o);n!==s&&(r=!0,o="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var c=e.length<e.highWaterMark;c||(e.needDrain=!0);if(e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:o,isBuf:r,callback:i,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else A(t,e,!1,a,n,o,i);return c}(this,i,a,t,e,r)),s},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||P(this,t))},E.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,r){r(new m("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,e,r){var o=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),o.corked&&(o.corked=1,this.uncork()),o.ending||function(t,e,r){e.ending=!0,M(t,e),r&&(e.finished?n.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,o,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=f.destroy,E.prototype._undestroy=f.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this,r(10),r(9))},function(t,e,r){"use strict";var n=r(246).Buffer,o=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===o||!o(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},i.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},i.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var o=s(e[n]);if(o>=0)return o>0&&(t.lastNeed=o-1),o;if(--n<r||-2===o)return 0;if((o=s(e[n]))>=0)return o>0&&(t.lastNeed=o-2),o;if(--n<r||-2===o)return 0;if((o=s(e[n]))>=0)return o>0&&(2===o?o=0:t.lastNeed=o-3),o;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},function(t,e,r){"use strict";t.exports=l;var n=r(17).codes,o=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(18);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new i);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}r(12)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new o("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var o=this._readableState;(n.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},function(t,e,r){(function(e){const r=t.exports;r.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},r.codes={};for(const t in r.types){const e=r.types[t];r.codes[e]=t}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=e.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=e.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=e.from([r.codes.connect<<r.CMD_SHIFT]),r.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},r.propertiesCodes={};for(const t in r.properties){const e=r.properties[t];r.propertiesCodes[e]=t}function n(t){return[0,1,2].map(n=>[0,1].map(o=>[0,1].map(i=>{const s=e.alloc(1);return s.writeUInt8(r.codes[t]<<r.CMD_SHIFT|(o?r.DUP_MASK:0)|n<<r.QOS_SHIFT|i,0,!0),s})))}r.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},r.PUBLISH_HEADER=n("publish"),r.SUBSCRIBE_HEADER=n("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=n("unsubscribe"),r.ACKS={unsuback:n("unsuback"),puback:n("puback"),pubcomp:n("pubcomp"),pubrel:n("pubrel"),pubrec:n("pubrec")},r.SUBACK_HEADER=e.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=e.from([3]),r.VERSION4=e.from([4]),r.VERSION5=e.from([5]),r.VERSION131=e.from([131]),r.VERSION132=e.from([132]),r.QOS=[0,1,2].map(t=>e.from([t])),r.EMPTY={pingreq:e.from([r.codes.pingreq<<4,0]),pingresp:e.from([r.codes.pingresp<<4,0]),disconnect:e.from([r.codes.disconnect<<4,0])}}).call(this,r(8).Buffer)},function(t,e,r){(function(e){const n=r(102),o=e.allocUnsafe(0),i=e.from([0]),s=r(266),a=r(267).nextTick,u=r(11)("mqtt-packet:writeToStream"),c=s.cache,l=s.generateNumber,f=s.generateCache,h=s.genBufVariableByteInt,p=s.generate4ByteBuffer;let d=k,m=!0;function y(t,r,s){switch(u("generate called"),r.cork&&(r.cork(),a(g,r)),m&&(m=!1,f()),u("generate: packet.cmd: %s",t.cmd),t.cmd){case"connect":return function(t,r,o){const i=t||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const u=i.will;let c=i.clean;const l=i.keepalive||0,f=i.clientId||"",h=i.username,p=i.password,m=i.properties;void 0===c&&(c=!0);let y=0;if(!s||"string"!=typeof s&&!e.isBuffer(s))return r.emit("error",new Error("Invalid protocolId")),!1;y+=s.length+2;if(3!==a&&4!==a&&5!==a)return r.emit("error",new Error("Invalid protocol version")),!1;y+=1;if(("string"==typeof f||e.isBuffer(f))&&(f||a>=4)&&(f||c))y+=e.byteLength(f)+2;else{if(a<4)return r.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return r.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return r.emit("error",new Error("Invalid keepalive")),!1;y+=2;if(y+=1,5===a){var g=E(r,m);if(!g)return!1;y+=g.length}if(u){if("object"!=typeof u)return r.emit("error",new Error("Invalid will")),!1;if(!u.topic||"string"!=typeof u.topic)return r.emit("error",new Error("Invalid will topic")),!1;if(y+=e.byteLength(u.topic)+2,y+=2,u.payload){if(!(u.payload.length>=0))return r.emit("error",new Error("Invalid will payload")),!1;"string"==typeof u.payload?y+=e.byteLength(u.payload):y+=u.payload.length}var v={};if(5===a){if(!(v=E(r,u.properties)))return!1;y+=v.length}}let w=!1;if(null!=h){if(!O(h))return r.emit("error",new Error("Invalid username")),!1;w=!0,y+=e.byteLength(h)+2}if(null!=p){if(!w)return r.emit("error",new Error("Username is required to use password")),!1;if(!O(p))return r.emit("error",new Error("Invalid password")),!1;y+=I(p)+2}r.write(n.CONNECT_HEADER),b(r,y),x(r,s),i.bridgeMode&&(a+=128);r.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let k=0;k|=null!=h?n.USERNAME_MASK:0,k|=null!=p?n.PASSWORD_MASK:0,k|=u&&u.retain?n.WILL_RETAIN_MASK:0,k|=u&&u.qos?u.qos<<n.WILL_QOS_SHIFT:0,k|=u?n.WILL_FLAG_MASK:0,k|=c?n.CLEAN_SESSION_MASK:0,r.write(e.from([k])),d(r,l),5===a&&g.write();x(r,f),u&&(5===a&&v.write(),_(r,u.topic),x(r,u.payload));null!=h&&x(r,h);null!=p&&x(r,p);return!0}(t,r);case"connack":return function(t,r,o){const s=o?o.protocolVersion:4,a=t||{},u=5===s?a.reasonCode:a.returnCode,c=a.properties;let l=2;if("number"!=typeof u)return r.emit("error",new Error("Invalid return code")),!1;let f=null;if(5===s){if(f=E(r,c),!f)return!1;l+=f.length}r.write(n.CONNACK_HEADER),b(r,l),r.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:i),r.write(e.from([u])),null!=f&&f.write();return!0}(t,r,s);case"publish":return function(t,r,i){u("publish: packet: %o",t);const s=i?i.protocolVersion:4,a=t||{},c=a.qos||0,l=a.retain?n.RETAIN_MASK:0,f=a.topic,h=a.payload||o,p=a.messageId,m=a.properties;let y=0;if("string"==typeof f)y+=e.byteLength(f)+2;else{if(!e.isBuffer(f))return r.emit("error",new Error("Invalid topic")),!1;y+=f.length+2}e.isBuffer(h)?y+=h.length:y+=e.byteLength(h);if(c&&"number"!=typeof p)return r.emit("error",new Error("Invalid messageId")),!1;c&&(y+=2);let g=null;if(5===s){if(g=E(r,m),!g)return!1;y+=g.length}r.write(n.PUBLISH_HEADER[c][a.dup?1:0][l?1:0]),b(r,y),d(r,I(f)),r.write(f),c>0&&d(r,p);null!=g&&g.write();return u("publish: payload: %o",h),r.write(h)}(t,r,s);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.cmd||"puback",u=s.messageId,c=s.dup&&"pubrel"===a?n.DUP_MASK:0;let l=0;const f=s.reasonCode,h=s.properties;let p=5===i?3:2;"pubrel"===a&&(l=1);if("number"!=typeof u)return r.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof h){if(m=A(r,h,o,p),!m)return!1;p+=m.length}r.write(n.ACKS[a][l][c][0]),b(r,p),d(r,u),5===i&&r.write(e.from([f]));null!==m&&m.write();return!0}(t,r,s);case"subscribe":return function(t,r,o){u("subscribe: packet: ");const i=o?o.protocolVersion:4,s=t||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,l=s.subscriptions,f=s.properties;let h=0;if("number"!=typeof c)return r.emit("error",new Error("Invalid messageId")),!1;h+=2;let p=null;if(5===i){if(p=E(r,f),!p)return!1;h+=p.length}if("object"!=typeof l||!l.length)return r.emit("error",new Error("Invalid subscriptions")),!1;for(let t=0;t<l.length;t+=1){const n=l[t].topic,o=l[t].qos;if("string"!=typeof n)return r.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return r.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(l[t].nl||!1))return r.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[t].rap||!1))return r.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const e=l[t].rh||0;if("number"!=typeof e||e>2)return r.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}h+=e.byteLength(n)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),r.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),b(r,h),d(r,c),null!==p&&p.write();let m=!0;for(const t of l){const o=t.topic,s=t.qos,a=+t.nl,u=+t.rap,c=t.rh;let l;_(r,o),l=n.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(l|=a?n.SUBSCRIBE_OPTIONS_NL:0,l|=u?n.SUBSCRIBE_OPTIONS_RAP:0,l|=c?n.SUBSCRIBE_OPTIONS_RH[c]:0),m=r.write(e.from([l]))}return m}(t,r,s);case"suback":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.messageId,u=s.granted,c=s.properties;let l=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof u||!u.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let t=0;t<u.length;t+=1){if("number"!=typeof u[t])return r.emit("error",new Error("Invalid qos vector")),!1;l+=1}let f=null;if(5===i){if(f=A(r,c,o,l),!f)return!1;l+=f.length}r.write(n.SUBACK_HEADER),b(r,l),d(r,a),null!==f&&f.write();return r.write(e.from(u))}(t,r,s);case"unsubscribe":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.unsubscriptions,l=s.properties;let f=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;f+=2;if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid unsubscriptions")),!1;for(let t=0;t<c.length;t+=1){if("string"!=typeof c[t])return r.emit("error",new Error("Invalid unsubscriptions")),!1;f+=e.byteLength(c[t])+2}let h=null;if(5===i){if(h=E(r,l),!h)return!1;f+=h.length}r.write(n.UNSUBSCRIBE_HEADER[1][u?1:0][0]),b(r,f),d(r,a),null!==h&&h.write();let p=!0;for(let t=0;t<c.length;t++)p=_(r,c[t]);return p}(t,r,s);case"unsuback":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.granted,l=s.properties,f=s.cmd;let h=2;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let t=0;t<c.length;t+=1){if("number"!=typeof c[t])return r.emit("error",new Error("Invalid qos vector")),!1;h+=1}}let p=null;if(5===i){if(p=A(r,l,o,h),!p)return!1;h+=p.length}r.write(n.ACKS[f][0][u][0]),b(r,h),d(r,a),null!==p&&p.write();5===i&&r.write(e.from(c));return!0}(t,r,s);case"pingreq":case"pingresp":return function(t,e,r){return e.write(n.EMPTY[t.cmd])}(t,r);case"disconnect":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0,l=null;if(5===i){if(l=A(r,u,o,c),!l)return!1;c+=l.length}r.write(e.from([n.codes.disconnect<<4])),b(r,c),5===i&&r.write(e.from([a]));null!==l&&l.write();return!0}(t,r,s);case"auth":return function(t,r,o){const i=o?o.protocolVersion:4,s=t||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0;5!==i&&r.emit("error",new Error("Invalid mqtt version for auth packet"));const l=A(r,u,o,c);if(!l)return!1;c+=l.length,r.write(e.from([n.codes.auth<<4])),b(r,c),r.write(e.from([a])),null!==l&&l.write();return!0}(t,r,s);default:return r.emit("error",new Error("Unknown command")),!1}}function g(t){t.uncork()}Object.defineProperty(y,"cacheNumbers",{get:()=>d===k,set(t){t?(c&&0!==Object.keys(c).length||(m=!0),d=k):(m=!1,d=S)}});const v={};function b(t,e){if(e>n.VARBYTEINT_MAX)return t.emit("error",new Error("Invalid variable byte integer: "+e)),!1;let r=v[e];return r||(r=h(e),e<16384&&(v[e]=r)),u("writeVarByteInt: writing to stream: %o",r),t.write(r)}function _(t,r){const n=e.byteLength(r);return d(t,n),u("writeString: %s",r),t.write(r,"utf8")}function w(t,e,r){_(t,e),_(t,r)}function k(t,e){return u("writeNumberCached: number: %d",e),u("writeNumberCached: %o",c[e]),t.write(c[e])}function S(t,e){const r=l(e);return u("writeNumberGenerated: %o",r),t.write(r)}function x(t,e){"string"==typeof e?_(t,e):e?(d(t,e.length),t.write(e)):d(t,0)}function E(t,r){if("object"!=typeof r||null!=r.length)return{length:1,write(){P(t,{},0)}};let o=0;function i(r,o){let i=0;switch(n.propertiesTypes[r]){case"byte":if("boolean"!=typeof o)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+e.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+e.byteLength(h(o));break;case"string":if("string"!=typeof o)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3+e.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return t.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce((t,r)=>{const n=o[r];return Array.isArray(n)?t+=n.reduce((t,n)=>t+=3+e.byteLength(r.toString())+2+e.byteLength(n.toString()),0):t+=3+e.byteLength(r.toString())+2+e.byteLength(o[r].toString()),t},0);break;default:return t.emit("error",new Error(`Invalid property ${r}: ${o}`)),!1}return i}if(r)for(const t in r){let e=0,n=0;const s=r[t];if(Array.isArray(s))for(let r=0;r<s.length;r++){if(n=i(t,s[r]),!n)return!1;e+=n}else{if(n=i(t,s),!n)return!1;e=n}if(!e)return!1;o+=e}return{length:e.byteLength(h(o))+o,write(){P(t,r,o)}}}function A(t,e,r,n){const o=["reasonString","userProperties"],i=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=E(t,e);if(i)for(;n+s.length>i;){const r=o.shift();if(!r||!e[r])return!1;delete e[r],s=E(t,e)}return s}function T(t,r,o){switch(n.propertiesTypes[r]){case"byte":t.write(e.from([n.properties[r]])),t.write(e.from([+o]));break;case"int8":t.write(e.from([n.properties[r]])),t.write(e.from([o]));break;case"binary":t.write(e.from([n.properties[r]])),x(t,o);break;case"int16":t.write(e.from([n.properties[r]])),d(t,o);break;case"int32":t.write(e.from([n.properties[r]])),function(t,e){const r=p(e);u("write4ByteNumber: %o",r),t.write(r)}(t,o);break;case"var":t.write(e.from([n.properties[r]])),b(t,o);break;case"string":t.write(e.from([n.properties[r]])),_(t,o);break;case"pair":Object.getOwnPropertyNames(o).forEach(i=>{const s=o[i];Array.isArray(s)?s.forEach(o=>{t.write(e.from([n.properties[r]])),w(t,i.toString(),o.toString())}):(t.write(e.from([n.properties[r]])),w(t,i.toString(),s.toString()))});break;default:return t.emit("error",new Error(`Invalid property ${r} value: ${o}`)),!1}}function P(t,e,r){b(t,r);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&null!==e[r]){const n=e[r];if(Array.isArray(n))for(let e=0;e<n.length;e++)T(t,r,n[e]);else T(t,r,n)}}function I(t){return t?t instanceof e?t.length:e.byteLength(t):0}function O(t){return"string"==typeof t||t instanceof e}t.exports=y}).call(this,r(8).Buffer)},function(t,e,r){"use strict";var n=r(45),o=r(111),i=r(31),s=r(19),a=n("%Map%",!0),u=o("Map.prototype.get",!0),c=o("Map.prototype.set",!0),l=o("Map.prototype.has",!0),f=o("Map.prototype.delete",!0),h=o("Map.prototype.size",!0);t.exports=!!a&&function(){var t,e={assert:function(t){if(!e.has(t))throw new s("Side channel does not contain "+i(t))},delete:function(e){if(t){var r=f(t,e);return 0===h(t)&&(t=void 0),r}return!1},get:function(e){if(t)return u(t,e)},has:function(e){return!!t&&l(t,e)},set:function(e,r){t||(t=new a),c(t,e,r)}};return e}},function(t,e,r){"use strict";t.exports=Object},function(t,e,r){"use strict";var n=r(295);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(t,e,r){"use strict";var n=r(105);t.exports=n.getPrototypeOf||null},function(t,e,r){"use strict";var n=r(32),o=r(19),i=r(46),s=r(302);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new o("a function is required");return s(n,i,t)}},function(t,e,r){"use strict";t.exports=Function.prototype.apply},function(t,e,r){"use strict";var n=r(45),o=r(109),i=o([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&i(t,".prototype.")>-1?o([r]):r}},function(t,e,r){"use strict";var n=r(47),o=Object.prototype.hasOwnProperty,i=Array.isArray,s=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),a=function(t,e){for(var r=e&&e.plainObjects?{__proto__:null}:{},n=0;n<t.length;++n)void 0!==t[n]&&(r[n]=t[n]);return r};t.exports={arrayToObject:a,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],n=0;n<e.length;++n)for(var o=e[n],s=o.obj[o.prop],a=Object.keys(s),u=0;u<a.length;++u){var c=a[u],l=s[c];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(e.push({obj:s,prop:c}),r.push(l))}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(i(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);e.obj[e.prop]=n}}}(e),t},decode:function(t,e,r){var n=t.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(t){return n}},encode:function(t,e,r,o,i){if(0===t.length)return t;var a=t;if("symbol"==typeof t?a=Symbol.prototype.toString.call(t):"string"!=typeof t&&(a=String(t)),"iso-8859-1"===r)return escape(a).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var u="",c=0;c<a.length;c+=1024){for(var l=a.length>=1024?a.slice(c,c+1024):a,f=[],h=0;h<l.length;++h){var p=l.charCodeAt(h);45===p||46===p||95===p||126===p||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||i===n.RFC1738&&(40===p||41===p)?f[f.length]=l.charAt(h):p<128?f[f.length]=s[p]:p<2048?f[f.length]=s[192|p>>6]+s[128|63&p]:p<55296||p>=57344?f[f.length]=s[224|p>>12]+s[128|p>>6&63]+s[128|63&p]:(h+=1,p=65536+((1023&p)<<10|1023&l.charCodeAt(h)),f[f.length]=s[240|p>>18]+s[128|p>>12&63]+s[128|p>>6&63]+s[128|63&p])}u+=f.join("")}return u},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(i(t)){for(var r=[],n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)},merge:function t(e,r,n){if(!r)return e;if("object"!=typeof r&&"function"!=typeof r){if(i(e))e.push(r);else{if(!e||"object"!=typeof e)return[e,r];(n&&(n.plainObjects||n.allowPrototypes)||!o.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(r);var s=e;return i(e)&&!i(r)&&(s=a(e,n)),i(e)&&i(r)?(r.forEach((function(r,i){if(o.call(e,i)){var s=e[i];s&&"object"==typeof s&&r&&"object"==typeof r?e[i]=t(s,r,n):e.push(r)}else e[i]=r})),e):Object.keys(r).reduce((function(e,i){var s=r[i];return o.call(e,i)?e[i]=t(e[i],s,n):e[i]=s,e}),s)}}},function(t,e,r){"use strict";const n=r(114),o=r(11)("mqttjs:tcp");t.exports=function(t,e){e.port=e.port||1883,e.hostname=e.hostname||e.host||"localhost";const r=e.port,i=e.hostname;return o("port %d and host %s",r,i),n.createConnection(r,i)}},function(t,e){},function(t,e,r){"use strict";const{Buffer:n}=r(8),o=r(16).Transform,i=r(49);let s,a,u;t.exports=function(t,e){if(e.hostname=e.hostname||e.host,!e.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===e.protocolId&&3===e.protocolVersion?"mqttv3.1":"mqtt";!function(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}(e);const c=function(t,e){const r="wxs"===t.protocol?"wss":"ws";let n=r+"://"+t.hostname+t.path;return t.port&&80!==t.port&&443!==t.port&&(n=r+"://"+t.hostname+":"+t.port+t.path),"function"==typeof t.transformWsUrl&&(n=t.transformWsUrl(n,t,e)),n}(e,t);s=wx.connectSocket({url:c,protocols:[r]}),a=function(){const t=new o;return t._write=function(t,e,r){s.send({data:t.buffer,success:function(){r()},fail:function(t){r(new Error(t))}})},t._flush=function(t){s.close({success:function(){t()}})},t}(),u=i.obj(),u._destroy=function(t,e){s.close({success:function(){e&&e(t)}})};const l=u.destroy;return u.destroy=function(){u.destroy=l;const t=this;setTimeout((function(){s.close({fail:function(){t._destroy(new Error)}})}),0)}.bind(u),s.onOpen((function(){u.setReadable(a),u.setWritable(a),u.emit("connect")})),s.onMessage((function(t){let e=t.data;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),a.push(e)})),s.onClose((function(){u.end(),u.destroy()})),s.onError((function(t){u.destroy(new Error(t.errMsg))})),u}},function(t,e,r){"use strict";const{Buffer:n}=r(8),o=r(16).Transform,i=r(49);let s,a,u,c=!1;t.exports=function(t,e){if(e.hostname=e.hostname||e.host,!e.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===e.protocolId&&3===e.protocolVersion?"mqttv3.1":"mqtt";!function(t){t.hostname||(t.hostname="localhost"),t.path||(t.path="/"),t.wsOptions||(t.wsOptions={})}(e);const l=function(t,e){const r="alis"===t.protocol?"wss":"ws";let n=r+"://"+t.hostname+t.path;return t.port&&80!==t.port&&443!==t.port&&(n=r+"://"+t.hostname+":"+t.port+t.path),"function"==typeof t.transformWsUrl&&(n=t.transformWsUrl(n,t,e)),n}(e,t);return s=e.my,s.connectSocket({url:l,protocols:r}),a=function(){const t=new o;return t._write=function(t,e,r){s.sendSocketMessage({data:t.buffer,success:function(){r()},fail:function(){r(new Error)}})},t._flush=function(t){s.closeSocket({success:function(){t()}})},t}(),u=i.obj(),c||(c=!0,s.onSocketOpen((function(){u.setReadable(a),u.setWritable(a),u.emit("connect")})),s.onSocketMessage((function(t){if("string"==typeof t.data){const e=n.from(t.data,"base64");a.push(e)}else{const e=new FileReader;e.addEventListener("load",(function(){let t=e.result;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),a.push(t)})),e.readAsArrayBuffer(t.data)}})),s.onSocketClose((function(){u.end(),u.destroy()})),s.onSocketError((function(t){u.destroy(t)}))),u}},function(t,e,r){"use strict";(function(e){const{Buffer:n}=r(8),o=r(312),i=r(11)("mqttjs:ws"),s=r(49),a=r(16).Transform,u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],c=void 0!==e&&"browser"===e.title||"function"==typeof r;function l(t,e){let r=t.protocol+"://"+t.hostname+":"+t.port+t.path;return"function"==typeof t.transformWsUrl&&(r=t.transformWsUrl(r,t,e)),r}function f(t){const e=t;return t.hostname||(e.hostname="localhost"),t.port||("wss"===t.protocol?e.port=443:e.port=80),t.path||(e.path="/"),t.wsOptions||(e.wsOptions={}),c||"wss"!==t.protocol||u.forEach((function(r){Object.prototype.hasOwnProperty.call(t,r)&&!Object.prototype.hasOwnProperty.call(t.wsOptions,r)&&(e.wsOptions[r]=t[r])})),e}t.exports=c?function(t,e){let r;i("browserStreamBuilder");const o=function(t){const e=f(t);if(e.hostname||(e.hostname=e.host),!e.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const t=new URL(document.URL);e.hostname=t.hostname,e.port||(e.port=t.port)}return void 0===e.objectMode&&(e.objectMode=!(!0===e.binary||void 0===e.binary)),e}(e).browserBufferSize||524288,u=e.browserBufferTimeout||1e3,c=!e.objectMode,h=function(t,e){const r="MQIsdp"===e.protocolId&&3===e.protocolVersion?"mqttv3.1":"mqtt",n=l(e,t),o=new WebSocket(n,[r]);return o.binaryType="arraybuffer",o}(t,e),p=function(t,e,r){const n=new a({objectModeMode:t.objectMode});return n._write=e,n._flush=r,n}(e,(function t(e,r,i){h.bufferedAmount>o&&setTimeout(t,u,e,r,i);c&&"string"==typeof e&&(e=n.from(e,"utf8"));try{h.send(e)}catch(t){return i(t)}i()}),(function(t){h.close(),t()}));e.objectMode||(p._writev=b),p.on("close",()=>{h.close()});const d=void 0!==h.addEventListener;function m(){r.setReadable(p),r.setWritable(p),r.emit("connect")}function y(){r.end(),r.destroy()}function g(t){r.destroy(t)}function v(t){let e=t.data;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),p.push(e)}function b(t,e){const r=new Array(t.length);for(let e=0;e<t.length;e++)"string"==typeof t[e].chunk?r[e]=n.from(t[e],"utf8"):r[e]=t[e].chunk;this._write(n.concat(r),"binary",e)}return h.readyState===h.OPEN?r=p:(r=r=s(void 0,void 0,e),e.objectMode||(r._writev=b),d?h.addEventListener("open",m):h.onopen=m),r.socket=h,d?(h.addEventListener("close",y),h.addEventListener("error",g),h.addEventListener("message",v)):(h.onclose=y,h.onerror=g,h.onmessage=v),r}:function(t,e){i("streamBuilder");const r=f(e),n=l(r,t),s=function(t,e,r){i("createWebSocket"),i("protocol: "+r.protocolId+" "+r.protocolVersion);const n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+e+" and protocol: "+n),new o(e,[n],r.wsOptions)}(0,n,r),a=o.createWebSocketStream(s,r.wsOptions);return a.url=n,s.on("close",()=>{a.destroy()}),a}}).call(this,r(9))},function(t,e){t.exports=function(t,e){this.v=t,this.k=e},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){(function(e){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,h=Math.min,p=function(){return c.Date.now()};function d(t,e,r){var n,o,i,s,a,u,c=0,l=!1,d=!1,g=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function v(e){var r=n,i=o;return n=o=void 0,c=e,s=t.apply(i,r)}function b(t){return c=t,a=setTimeout(w,e),l?v(t):s}function _(t){var r=t-u;return void 0===u||r>=e||r<0||d&&t-c>=i}function w(){var t=p();if(_(t))return k(t);a=setTimeout(w,function(t){var r=e-(t-u);return d?h(r,i-(t-c)):r}(t))}function k(t){return a=void 0,g&&n?v(t):(n=o=void 0,s)}function S(){var t=p(),r=_(t);if(n=arguments,o=this,u=t,r){if(void 0===a)return b(u);if(d)return a=setTimeout(w,e),v(u)}return void 0===a&&(a=setTimeout(w,e)),s}return e=y(e)||0,m(r)&&(l=!!r.leading,i=(d="maxWait"in r)?f(y(r.maxWait)||0,e):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(p())},S}function m(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function y(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==l.call(t)}(t))return NaN;if(m(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=m(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(r,"");var a=o.test(t);return a||i.test(t)?s(t.slice(2),a?2:8):n.test(t)?NaN:+t}t.exports=function(t,e,r){var n=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return m(r)&&(n="leading"in r?!!r.leading:n,o="trailing"in r?!!r.trailing:o),d(t,e,{leading:n,maxWait:e,trailing:o})}}).call(this,r(10))},function(t,e,r){var n=r(235),o=r(236),i=r(56),s=r(237);t.exports=function(t,e){return n(t)||o(t,e)||i(t,e)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){"use strict";(function(e){const n=r(238),o=r(94),i=r(273),s=r(43),a=r(11)("mqttjs"),u={};function c(t,e){if(a("connecting to an MQTT broker..."),"object"!=typeof t||e||(e=t,t=null),e=e||{},t){const r=i.parse(t,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(e=s(r,e)).protocol)throw new Error("Missing protocol");e.protocol=e.protocol.replace(/:$/,"")}if(function(t){let e;t.auth&&(e=t.auth.match(/^(.+):(.+)$/),e?(t.username=e[1],t.password=e[2]):t.username=t.auth)}(e),e.query&&"string"==typeof e.query.clientId&&(e.clientId=e.query.clientId),e.cert&&e.key){if(!e.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(e.protocol))switch(e.protocol){case"mqtt":e.protocol="mqtts";break;case"ws":e.protocol="wss";break;case"wx":e.protocol="wxs";break;case"ali":e.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+e.protocol+'"!')}}if(!u[e.protocol]){const t=-1!==["mqtts","wss"].indexOf(e.protocol);e.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,r){return(!t||r%2!=0)&&"function"==typeof u[e]}))[0]}if(!1===e.clean&&!e.clientId)throw new Error("Missing clientId for unclean clients");e.protocol&&(e.defaultProtocol=e.protocol);const r=new n((function(t){return e.servers&&(t._reconnectCount&&t._reconnectCount!==e.servers.length||(t._reconnectCount=0),e.host=e.servers[t._reconnectCount].host,e.port=e.servers[t._reconnectCount].port,e.protocol=e.servers[t._reconnectCount].protocol?e.servers[t._reconnectCount].protocol:e.defaultProtocol,e.hostname=e.host,t._reconnectCount++),a("calling streambuilder for",e.protocol),u[e.protocol](t,e)}),e);return r.on("error",(function(){})),r}void 0!==e&&"browser"!==e.title||"function"!=typeof r?(u.mqtt=r(113),u.tcp=r(113),u.ssl=r(48),u.tls=r(48),u.mqtts=r(48)):(u.wx=r(115),u.wxs=r(115),u.ali=r(116),u.alis=r(116)),u.ws=r(117),u.wss=r(117),t.exports=c,t.exports.connect=c,t.exports.MqttClient=n,t.exports.Store=o}).call(this,r(9))},function(t,e,r){(function(e){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,h=Math.min,p=function(){return c.Date.now()};function d(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function m(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==l.call(t)}(t))return NaN;if(d(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=d(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(r,"");var a=o.test(t);return a||i.test(t)?s(t.slice(2),a?2:8):n.test(t)?NaN:+t}t.exports=function(t,e,r){var n,o,i,s,a,u,c=0,l=!1,y=!1,g=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function v(e){var r=n,i=o;return n=o=void 0,c=e,s=t.apply(i,r)}function b(t){return c=t,a=setTimeout(w,e),l?v(t):s}function _(t){var r=t-u;return void 0===u||r>=e||r<0||y&&t-c>=i}function w(){var t=p();if(_(t))return k(t);a=setTimeout(w,function(t){var r=e-(t-u);return y?h(r,i-(t-c)):r}(t))}function k(t){return a=void 0,g&&n?v(t):(n=o=void 0,s)}function S(){var t=p(),r=_(t);if(n=arguments,o=this,u=t,r){if(void 0===a)return b(u);if(y)return a=setTimeout(w,e),v(u)}return void 0===a&&(a=setTimeout(w,e)),s}return e=m(e)||0,d(r)&&(l=!!r.leading,i=(y="maxWait"in r)?f(m(r.maxWait)||0,e):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(p())},S}}).call(this,r(10))},function(t){t.exports=JSON.parse('{"name":"qiscus-sdk-core","version":"2.12.6","description":"Qiscus Web SDK Core","license":"MIT","main":"lib/index.js","browser":"dist/qiscus-sdk-core.min.js","unpkg":"dist/qiscus-sdk-core.min.js","files":["lib","dist"],"scripts":{"build":"npm-run-all --parallel build:node build:web","build:dev":"npm-run-all --parallel build:node build:web:dev","build:dev:watch":"npm-run-all --parallel build:web:watch serve","build:node":"babel -d lib src","build:node:watch":"babel -w -d lib src","build:web":"webpack --env.production --env.target=web","build:web:dev":"webpack --env.development --env.target=web","build:web:watch":"webpack --env.development --env.target=web --watch","dev":"webpack --env.development --progress --colors --watch","watch":"npm-run-all build:web:watch build:node:watch","test":"mocha --require @babel/register --colors \'test/**/*test.js\'","test:watch":"npm run test -- -w","clean":"rimraf dist lib","preversion":"npm-run-all clean build","prepublishOnly":"npm-run-all clean build","serve":"http-server -p 1234 -c-1 dist","dev:serve":"run-p serve watch","release:patch":"np patch --any-branch --yolo"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/plugin-proposal-class-properties":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.0","@babel/polyfill":"^7.10.4","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@commitlint/cli":"^8.3.5","@commitlint/config-conventional":"^8.3.4","babel-eslint":"^8.2.6","babel-loader":"^8.0.6","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-date-fns":"^0.1.0","chai":"^4.2.0","chai-spies":"^1.0.0","eslint":"5.0.0","eslint-config-standard":"^12.0.0","eslint-loader":"^2.2.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","http-server":"^0.12.3","mocha":"^5.2.0","np":"^8.0.4","npm-run-all":"^4.1.5","rimraf":"^2.7.1","serve":"^12.0.0","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"dependencies":{"@babel/runtime":"^7.11.2","date-fns":"^1.30.1","is_js":"^0.9.0","lodash.debounce":"^4.0.8","lodash.throttle":"^4.1.1","mitt":"^1.2.0","mqtt":"^4.2.6","superagent":"^3.8.3"},"babel":{"presets":[["@babel/preset-env",{"modules":"auto"}]],"plugins":["@babel/plugin-transform-runtime","@babel/plugin-proposal-class-properties","babel-plugin-add-module-exports"]},"prettier":{"semi":false,"singleQuote":true,"trailingComma":"es5"},"engines":{"node":"16.15.1"},"packageManager":"pnpm@8.15.9"}')},function(t,e,r){t.exports=r(314)},function(t,e,r){var n=r(55);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(26).default;t.exports=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(26).default;function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,s=i.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",f=u.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(e){h=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,i=Object.create(o.prototype),s=new C(n||[]);return a(i,"_invoke",{value:P(t,r,s)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var m="suspendedStart",y="executing",g="completed",v={};function b(){}function _(){}function w(){}var k={};h(k,c,(function(){return this}));var S=Object.getPrototypeOf,x=S&&S(S(R([])));x&&x!==i&&s.call(x,c)&&(k=x);var E=w.prototype=b.prototype=Object.create(k);function A(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(o,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&s.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function P(t,r,n){var o=m;return function(i,s){if(o===y)throw Error("Generator is already running");if(o===g){if("throw"===i)throw s;return{value:e,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=I(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var c=d(t,r,n);if("normal"===c.type){if(o=n.done?g:"suspendedYield",c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=g,n.method="throw",n.arg=c.arg)}}}function I(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,I(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=d(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var s=i.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function R(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(s.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+" is not iterable")}return _.prototype=w,a(E,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:_,configurable:!0}),_.displayName=h(w,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,f,"GeneratorFunction")),t.prototype=Object.create(E),t},r.awrap=function(t){return{__await:t}},A(T.prototype),h(T.prototype,l,(function(){return this})),r.AsyncIterator=T,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var s=new T(p(t,e,n,o),i);return r.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},A(E),h(E,f,"Generator"),h(E,c,(function(){return this})),h(E,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=R,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!t)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return a.type="throw",a.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=s.call(i,"catchLoc"),c=s.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;M(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,r){"use strict";var n=r(58);function o(t){if(t)return function(t){for(var e in o.prototype)t[e]=o.prototype[e];return t}(t)}t.exports=o,o.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},o.prototype.parse=function(t){return this._parser=t,this},o.prototype.responseType=function(t){return this._responseType=t,this},o.prototype.serialize=function(t){return this._serializer=t,this},o.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},o.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];o.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~i.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},o.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},o.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(t,e){r.end((function(r,n){r?e(r):t(n)}))}))}return this._fullfilledPromise.then(t,e)},o.prototype.catch=function(t){return this.then(void 0,t)},o.prototype.use=function(t){return t(this),this},o.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},o.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},o.prototype.get=function(t){return this._header[t.toLowerCase()]},o.prototype.getHeader=o.prototype.get,o.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},o.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},o.prototype.field=function(t,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var o in e)this.field(t,e[o]);return this}if(null==e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},o.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},o.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},o.prototype.withCredentials=function(t){return null==t&&(t=!0),this._withCredentials=t,this},o.prototype.redirects=function(t){return this._maxRedirects=t,this},o.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},o.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},o.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)||r||this.type("json"),this},o.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},o.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},o.prototype._appendQueryString=function(){console.trace("Unsupported")},o.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},o.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))}},function(t,e,r){"use strict";var n=r(133);function o(t){if(t)return function(t){for(var e in o.prototype)t[e]=o.prototype[e];return t}(t)}t.exports=o,o.prototype.get=function(t){return this.header[t.toLowerCase()]},o.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var o in r)this[o]=r[o];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},o.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},function(t,e,r){"use strict";e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce((function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t}),{})},e.parseLinks=function(t){return t.split(/ *, */).reduce((function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t}),{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},function(t,e){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach((function(t){r.prototype[t]=function(){return this._defaults.push({fn:t,arguments:arguments}),this}})),r.prototype._setDefaults=function(t){this._defaults.forEach((function(e){t[e.fn].apply(t,e.arguments)}))},t.exports=r},function(t,e){t.exports=function(t){var e=new Date(t.getTime()),r=e.getTimezoneOffset();return e.setSeconds(0,0),6e4*r+e.getTime()%6e4}},function(t,e){t.exports=function(){var t={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};return{localize:function(e,r,n){var o;return n=n||{},o="string"==typeof t[e]?t[e]:1===r?t[e].one:t[e].other.replace("{{count}}",r),n.addSuffix?n.comparison>0?"in "+o:o+" ago":o}}}},function(t,e,r){var n=r(138);t.exports=function(){var t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],e=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Su","Mo","Tu","We","Th","Fr","Sa"],o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["AM","PM"],a=["am","pm"],u=["a.m.","p.m."],c={MMM:function(e){return t[e.getMonth()]},MMMM:function(t){return e[t.getMonth()]},dd:function(t){return r[t.getDay()]},ddd:function(t){return o[t.getDay()]},dddd:function(t){return i[t.getDay()]},A:function(t){return t.getHours()/12>=1?s[1]:s[0]},a:function(t){return t.getHours()/12>=1?a[1]:a[0]},aa:function(t){return t.getHours()/12>=1?u[1]:u[0]}};return["M","D","DDD","d","Q","W"].forEach((function(t){c[t+"o"]=function(e,r){return function(t){var e=t%100;if(e>20||e<10)switch(e%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"}(r[t](e))}})),{formatters:c,formattingTokensRegExp:n(c)}}},function(t,e){var r=["M","MM","Q","D","DD","DDD","DDDD","d","E","W","WW","YY","YYYY","GG","GGGG","H","HH","h","hh","m","mm","s","ss","S","SS","SSS","Z","ZZ","X","x"];t.exports=function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);var o=r.concat(e).sort().reverse();return new RegExp("(\\[[^\\[]*\\])|(\\\\)?("+o.join("|")+"|.)","g")}},function(t,e,r){var n=r(0);t.exports=function(t,e,r,o){var i=n(t).getTime(),s=n(e).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");return i<u&&a<s}},function(t,e,r){var n=r(0);t.exports=function(t,e){if(!(e instanceof Array))throw new TypeError(toString.call(e)+" is not an instance of Array");var r,o,i=n(t).getTime();return e.forEach((function(t,e){var s=n(t),a=Math.abs(i-s.getTime());(void 0===r||a<o)&&(r=e,o=a)})),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){if(!(e instanceof Array))throw new TypeError(toString.call(e)+" is not an instance of Array");var r,o,i=n(t).getTime();return e.forEach((function(t){var e=n(t),s=Math.abs(i-e.getTime());(void 0===r||s<o)&&(r=e,o=s)})),r}},function(t,e,r){var n=r(14);t.exports=function(t,e){var r=n(t),o=n(e),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/6048e5)}},function(t,e,r){var n=r(72),o=r(0);t.exports=function(t,e){var r=o(t),i=o(e);return 4*(r.getFullYear()-i.getFullYear())+(n(r)-n(i))}},function(t,e,r){var n=r(28);t.exports=function(t,e,r){var o=n(t,r),i=n(e,r),s=o.getTime()-6e4*o.getTimezoneOffset(),a=i.getTime()-6e4*i.getTimezoneOffset();return Math.round((s-a)/6048e5)}},function(t,e,r){var n=r(29);t.exports=function(t,e){var r=n(t,e)/36e5;return r>0?Math.floor(r):Math.ceil(r)}},function(t,e,r){var n=r(0),o=r(71),i=r(22),s=r(75);t.exports=function(t,e){var r=n(t),a=n(e),u=i(r,a),c=Math.abs(o(r,a));return r=s(r,u*c),u*(c-(i(r,a)===-u))}},function(t,e,r){var n=r(29);t.exports=function(t,e){var r=n(t,e)/6e4;return r>0?Math.floor(r):Math.ceil(r)}},function(t,e,r){var n=r(38);t.exports=function(t,e){var r=n(t,e)/3;return r>0?Math.floor(r):Math.ceil(r)}},function(t,e,r){var n=r(74);t.exports=function(t,e){var r=n(t,e)/7;return r>0?Math.floor(r):Math.ceil(r)}},function(t,e,r){var n=r(0),o=r(73),i=r(22);t.exports=function(t,e){var r=n(t),s=n(e),a=i(r,s),u=Math.abs(o(r,s));return r.setFullYear(r.getFullYear()-a*u),a*(u-(i(r,s)===-a))}},function(t,e,r){var n=r(36),o=r(0),i=r(37),s=r(35);t.exports=function(t,e,r){var a=r||{},u=n(t,e),c=a.locale,l=s.distanceInWords.localize;c&&c.distanceInWords&&c.distanceInWords.localize&&(l=c.distanceInWords.localize);var f,h,p,d={addSuffix:Boolean(a.addSuffix),comparison:u};u>0?(f=o(t),h=o(e)):(f=o(e),h=o(t));var m=Math[a.partialMethod?String(a.partialMethod):"floor"],y=i(h,f),g=h.getTimezoneOffset()-f.getTimezoneOffset(),v=m(y/60)-g;if("s"===(p=a.unit?String(a.unit):v<1?"s":v<60?"m":v<1440?"h":v<43200?"d":v<525600?"M":"Y"))return l("xSeconds",y,d);if("m"===p)return l("xMinutes",v,d);if("h"===p)return l("xHours",m(v/60),d);if("d"===p)return l("xDays",m(v/1440),d);if("M"===p)return l("xMonths",m(v/43200),d);if("Y"===p)return l("xYears",m(v/525600),d);throw new Error("Unknown unit: "+p)}},function(t,e,r){var n=r(0);t.exports=function(t,e,r){var o=n(t),i=void 0!==r?r:1,s=n(e).getTime();if(o.getTime()>s)throw new Error("The first date cannot be after the second date");var a=[],u=o;for(u.setHours(0,0,0,0);u.getTime()<=s;)a.push(n(u)),u.setDate(u.getDate()+i);return a}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setMinutes(59,59,999),e}},function(t,e,r){var n=r(76);t.exports=function(t){return n(t,{weekStartsOn:1})}},function(t,e,r){var n=r(15),o=r(14);t.exports=function(t){var e=n(t),r=new Date(0);r.setFullYear(e+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setMilliseconds(i.getMilliseconds()-1),i}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setSeconds(59,999),e}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getMonth(),o=r-r%3+3;return e.setMonth(o,0),e.setHours(23,59,59,999),e}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setMilliseconds(999),e}},function(t,e,r){var n=r(41);t.exports=function(){return n(new Date)}},function(t,e){t.exports=function(){var t=new Date,e=t.getFullYear(),r=t.getMonth(),n=t.getDate(),o=new Date(0);return o.setFullYear(e,r,n+1),o.setHours(23,59,59,999),o}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getFullYear();return e.setFullYear(r+1,0,0),e.setHours(23,59,59,999),e}},function(t,e){t.exports=function(){var t=new Date,e=t.getFullYear(),r=t.getMonth(),n=t.getDate(),o=new Date(0);return o.setFullYear(e,r,n-1),o.setHours(23,59,59,999),o}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getDate()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getDay()}},function(t,e,r){var n=r(78);t.exports=function(t){return n(t)?366:365}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getHours()}},function(t,e,r){var n=r(21),o=r(40);t.exports=function(t){var e=n(t),r=n(o(e,60)).valueOf()-e.valueOf();return Math.round(r/6048e5)}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getMilliseconds()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getMinutes()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getMonth()}},function(t,e,r){var n=r(0);t.exports=function(t,e,r,o){var i=n(t).getTime(),s=n(e).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");if(!(i<u&&a<s))return 0;var c=(u>s?s:u)-(a<i?i:a);return Math.ceil(c/864e5)}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getSeconds()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getFullYear()}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()>o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()<o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){return 1===n(t).getDate()}},function(t,e,r){var n=r(0);t.exports=function(t){return 5===n(t).getDay()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getTime()>(new Date).getTime()}},function(t,e,r){var n=r(0),o=r(41),i=r(77);t.exports=function(t){var e=n(t);return o(e).getTime()===i(e).getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){return 1===n(t).getDay()}},function(t,e,r){var n=r(0);t.exports=function(t){return n(t).getTime()<(new Date).getTime()}},function(t,e,r){var n=r(13);t.exports=function(t,e){var r=n(t),o=n(e);return r.getTime()===o.getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){return 6===n(t).getDay()}},function(t,e,r){var n=r(0);t.exports=function(t){return 0===n(t).getDay()}},function(t,e,r){var n=r(80);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(82);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(83);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(84);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(86);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(87);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(89);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(42);t.exports=function(t,e){return n(new Date,t,e)}},function(t,e,r){var n=r(91);t.exports=function(t){return n(new Date,t)}},function(t,e,r){var n=r(0);t.exports=function(t){return 4===n(t).getDay()}},function(t,e,r){var n=r(13);t.exports=function(t){return n(t).getTime()===n(new Date).getTime()}},function(t,e,r){var n=r(13);t.exports=function(t){var e=new Date;return e.setDate(e.getDate()+1),n(t).getTime()===n(e).getTime()}},function(t,e,r){var n=r(0);t.exports=function(t){return 2===n(t).getDay()}},function(t,e,r){var n=r(0);t.exports=function(t){return 3===n(t).getDay()}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t).getDay();return 0===e||6===e}},function(t,e,r){var n=r(0);t.exports=function(t,e,r){var o=n(t).getTime(),i=n(e).getTime(),s=n(r).getTime();if(i>s)throw new Error("The start of the range cannot be after the end of the range");return o>=i&&o<=s}},function(t,e,r){var n=r(13);t.exports=function(t){var e=new Date;return e.setDate(e.getDate()-1),n(t).getTime()===n(e).getTime()}},function(t,e,r){var n=r(92);t.exports=function(t){return n(t,{weekStartsOn:1})}},function(t,e,r){var n=r(15),o=r(14);t.exports=function(t){var e=n(t),r=new Date(0);r.setFullYear(e+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setDate(i.getDate()-1),i}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getMonth(),o=r-r%3+3;return e.setMonth(o,0),e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t),r=e.getFullYear();return e.setFullYear(r+1,0,0),e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(0);t.exports=function(){var t=Array.prototype.slice.call(arguments),e=t.map((function(t){return n(t)})),r=Math.max.apply(null,e);return new Date(r)}},function(t,e,r){var n=r(0);t.exports=function(){var t=Array.prototype.slice.call(arguments),e=t.map((function(t){return n(t)})),r=Math.min.apply(null,e);return new Date(r)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setDate(o),r}},function(t,e,r){var n=r(0),o=r(23);t.exports=function(t,e,r){var i=r&&Number(r.weekStartsOn)||0,s=n(t),a=Number(e),u=s.getDay();return o(s,((a%7+7)%7<i?7:0)+a-u)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setMonth(0),r.setDate(o),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setHours(o),r}},function(t,e,r){var n=r(0),o=r(23),i=r(79);t.exports=function(t,e){var r=n(t),s=Number(e),a=i(r);return o(r,s-a)}},function(t,e,r){var n=r(0),o=r(34);t.exports=function(t,e){var r=n(t),i=Number(e),s=o(r)-i;return r.setDate(r.getDate()-7*s),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setMilliseconds(o),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setMinutes(o),r}},function(t,e,r){var n=r(0),o=r(93);t.exports=function(t,e){var r=n(t),i=Number(e)-(Math.floor(r.getMonth()/3)+1);return o(r,r.getMonth()+3*i)}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setSeconds(o),r}},function(t,e,r){var n=r(0);t.exports=function(t,e){var r=n(t),o=Number(e);return r.setFullYear(o),r}},function(t,e,r){var n=r(0);t.exports=function(t){var e=n(t);return e.setDate(1),e.setHours(0,0,0,0),e}},function(t,e,r){var n=r(13);t.exports=function(){return n(new Date)}},function(t,e){t.exports=function(){var t=new Date,e=t.getFullYear(),r=t.getMonth(),n=t.getDate(),o=new Date(0);return o.setFullYear(e,r,n+1),o.setHours(0,0,0,0),o}},function(t,e){t.exports=function(){var t=new Date,e=t.getFullYear(),r=t.getMonth(),n=t.getDate(),o=new Date(0);return o.setFullYear(e,r,n-1),o.setHours(0,0,0,0),o}},function(t,e,r){var n=r(23);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(64);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(24);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(67);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(30);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(68);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(69);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(40);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e,r){var n=r(70);t.exports=function(t,e){var r=Number(e);return n(t,-r)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){"use strict";(function(e,n){const o=r(25).EventEmitter,i=r(94),s=r(251),a=r(252),u=r(260),c=r(268),l=r(16).Writable,f=r(12),h=r(269),p=r(270),d=r(272),m=r(43),y=r(11)("mqttjs:client"),g=e?e.nextTick:function(t){setTimeout(t,0)},v=n.setImmediate||function(t){g(t)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},_={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function w(t,e){let r;e.properties&&(r=e.properties.topicAlias);let n=e.topic.toString();if(0===n.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(n=t.topicAliasSend.getTopicByAlias(r),void 0===n)return new Error("Unregistered Topic Alias");e.topic=n}r&&delete e.properties.topicAlias}function k(t,e,r){y("sendPacket :: packet: %O",e),y("sendPacket :: emitting `packetsend`"),t.emit("packetsend",e),y("sendPacket :: writing to stream");const n=u.writeToStream(e,t.stream,t.options);y("sendPacket :: writeToStream result %s",n),!n&&r&&r!==E?(y("sendPacket :: handle events on `drain` once through callback."),t.stream.once("drain",r)):r&&(y("sendPacket :: invoking cb"),r())}function S(t){t&&(y("flush: queue exists? %b",!!t),Object.keys(t).forEach((function(e){"function"==typeof t[e].cb&&(t[e].cb(new Error("Connection closed")),delete t[e])})))}function x(t,e,r,n){y("storeAndSend :: store packet with cmd %s to outgoingStore",e.cmd);let o,i=e;if("publish"===i.cmd&&(i=p(e),o=w(t,i),o))return r&&r(o);t.outgoingStore.put(i,(function(o){if(o)return r&&r(o);n(),k(t,e,r)}))}function E(t){y("nop ::",t)}function A(t,e){let r;const n=this;if(!(this instanceof A))return new A(t,e);for(r in this.options=e||{},b)void 0===this.options[r]?this.options[r]=b[r]:this.options[r]=e[r];y("MqttClient :: options.protocol",e.protocol),y("MqttClient :: options.protocolVersion",e.protocolVersion),y("MqttClient :: options.username",e.username),y("MqttClient :: options.keepalive",e.keepalive),y("MqttClient :: options.reconnectPeriod",e.reconnectPeriod),y("MqttClient :: options.rejectUnauthorized",e.rejectUnauthorized),y("MqttClient :: options.topicAliasMaximum",e.topicAliasMaximum),this.options.clientId="string"==typeof e.clientId?e.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),y("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===e.protocolVersion&&e.customHandleAcks?e.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=t,this.messageIdProvider=void 0===this.options.messageIdProvider?new c:this.options.messageIdProvider,this.outgoingStore=e.outgoingStore||new i,this.incomingStore=e.incomingStore||new i,this.queueQoSZero=void 0===e.queueQoSZero||e.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,e.topicAliasMaximum>0&&(e.topicAliasMaximum>65535?y("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(e.topicAliasMaximum)),this.on("connect",(function(){const t=this.queue;y("connect :: sending queued packets"),function e(){const r=t.shift();y("deliver :: entry %o",r);let o=null;if(!r)return void n._resubscribe();o=r.packet,y("deliver :: call _sendPacket for %o",o);let i=!0;o.messageId&&0!==o.messageId&&(n.messageIdProvider.register(o.messageId)||(i=!1)),i?n._sendPacket(o,(function(t){r.cb&&r.cb(t),e()})):(y("messageId: %d has already used. The message is skipped and removed.",o.messageId),e())}()})),this.on("close",(function(){y("close :: connected set to `false`"),this.connected=!1,y("close :: clearing connackTimer"),clearTimeout(this.connackTimer),y("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),y("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),y("MqttClient :: setting up stream"),this._setupStream()}f(A,o),A.prototype._setupStream=function(){const t=this,e=new l,r=u.parser(this.options);let n=null;const o=[];function i(){if(o.length)g(s);else{const t=n;n=null,t()}}function s(){y("work :: getting next packet in queue");const e=o.shift();if(e)y("work :: packet pulled from queue"),t._handlePacket(e,i);else{y("work :: no packets in queue");const t=n;n=null,y("work :: done flag is %s",!!t),t&&t()}}y("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),y("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(t){y("parser :: on packet push to packets array."),o.push(t)})),e._write=function(t,e,o){n=o,y("writable stream :: parsing buffer"),r.parse(t),s()},y("_setupStream :: pipe stream to writable stream"),this.stream.pipe(e),this.stream.on("error",(function(e){y("streamErrorHandler :: error",e.message),e.code?(y("streamErrorHandler :: emitting error"),t.emit("error",e)):E(e)})),this.stream.on("close",(function(){var e;y("(%s)stream :: on close",t.options.clientId),(e=t.outgoing)&&(y("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])}))),y("stream: emit close to MqttClient"),t.emit("close")})),y("_setupStream: sending packet `connect`");const a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),k(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket){k(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){y("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},A.prototype._handlePacket=function(t,e){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<t.length)return this.emit("error",new Error("exceeding packets size "+t.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(y("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",t),t.cmd){case"publish":this._handlePublish(t,e);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(t),e();break;case"pubrel":this._handlePubrel(t,e);break;case"connack":this._handleConnack(t),e();break;case"auth":this._handleAuth(t),e();break;case"pingresp":this._handlePingresp(t),e();break;case"disconnect":this._handleDisconnect(t),e()}},A.prototype._checkDisconnecting=function(t){return this.disconnecting&&(t&&t!==E?t(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},A.prototype.publish=function(t,e,r,n){y("publish :: message `%s` to topic `%s`",e,t);const o=this.options;"function"==typeof r&&(n=r,r=null);if(r=m({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(n))return this;const i=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=i._nextId(),null===s))return y("No messageId left"),!1;const a={cmd:"publish",topic:t,payload:e,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===o.protocolVersion&&(a.properties=r.properties),y("publish :: qos",r.qos),r.qos){case 1:case 2:i.outgoing[a.messageId]={volatile:!1,cb:n||E},y("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,void 0,r.cbStorePut);break;default:y("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,n,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:n}),this},A.prototype.subscribe=function(){const t=this,e=new Array(arguments.length);for(let t=0;t<arguments.length;t++)e[t]=arguments[t];const r=[];let n=e.shift();const o=n.resubscribe;let i=e.pop()||E,s=e.pop();const a=this.options.protocolVersion;delete n.resubscribe,"string"==typeof n&&(n=[n]),"function"!=typeof i&&(s=i,i=E);const u=d.validateTopics(n);if(null!==u)return v(i,new Error("Invalid topic "+u)),this;if(this._checkDisconnecting(i))return y("subscribe: discconecting true"),this;const c={qos:0};if(5===a&&(c.nl=!1,c.rap=!1,c.rh=0),s=m(c,s),Array.isArray(n)?n.forEach((function(e){if(y("subscribe: array topic %s",e),!Object.prototype.hasOwnProperty.call(t._resubscribeTopics,e)||t._resubscribeTopics[e].qos<s.qos||o){const t={topic:e,qos:s.qos};5===a&&(t.nl=s.nl,t.rap=s.rap,t.rh=s.rh,t.properties=s.properties),y("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),r.push(t)}})):Object.keys(n).forEach((function(e){if(y("subscribe: object topic %s",e),!Object.prototype.hasOwnProperty.call(t._resubscribeTopics,e)||t._resubscribeTopics[e].qos<n[e].qos||o){const t={topic:e,qos:n[e].qos};5===a&&(t.nl=n[e].nl,t.rap=n[e].rap,t.rh=n[e].rh,t.properties=s.properties),y("subscribe: pushing `%s` to subs list",t),r.push(t)}})),!r.length)return i(null,[]),this;const l=function(){const e=t._nextId();if(null===e)return y("No messageId left"),!1;const n={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:e};if(s.properties&&(n.properties=s.properties),t.options.resubscribe){y("subscribe :: resubscribe true");const e=[];r.forEach((function(r){if(t.options.reconnectPeriod>0){const n={qos:r.qos};5===a&&(n.nl=r.nl||!1,n.rap=r.rap||!1,n.rh=r.rh||0,n.properties=r.properties),t._resubscribeTopics[r.topic]=n,e.push(r.topic)}})),t.messageIdToTopic[n.messageId]=e}return t.outgoing[n.messageId]={volatile:!0,cb:function(t,e){if(!t){const t=e.granted;for(let e=0;e<t.length;e+=1)r[e].qos=t[e]}i(t,r)}},y("subscribe :: call _sendPacket"),t._sendPacket(n),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!l())&&this._storeProcessingQueue.push({invoke:l,callback:i}),this},A.prototype.unsubscribe=function(){const t=this,e=new Array(arguments.length);for(let t=0;t<arguments.length;t++)e[t]=arguments[t];let r=e.shift(),n=e.pop()||E,o=e.pop();"string"==typeof r&&(r=[r]),"function"!=typeof n&&(o=n,n=E);const i=d.validateTopics(r);if(null!==i)return v(n,new Error("Invalid topic "+i)),this;if(t._checkDisconnecting(n))return this;const s=function(){const e=t._nextId();if(null===e)return y("No messageId left"),!1;const i={cmd:"unsubscribe",qos:1,messageId:e};return"string"==typeof r?i.unsubscriptions=[r]:Array.isArray(r)&&(i.unsubscriptions=r),t.options.resubscribe&&i.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof o&&o.properties&&(i.properties=o.properties),t.outgoing[i.messageId]={volatile:!0,cb:n},y("unsubscribe: call _sendPacket"),t._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:n}),this},A.prototype.end=function(t,e,r){const n=this;function o(){y("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=!0,n.incomingStore.close((function(t){n.outgoingStore.close((function(e){if(y("end :: closeStores: emitting end"),n.emit("end"),r){const n=t||e;y("end :: closeStores: invoking callback with args"),r(n)}}))})),n._deferredReconnect&&n._deferredReconnect()}function i(){y("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,t),n._cleanUp(t,()=>{y("end :: finish :: calling process.nextTick on closeStores"),g(o.bind(n))},e)}return y("end :: (%s)",this.options.clientId),null!=t&&"boolean"==typeof t||(r=e||E,e=t,t=!1,"object"!=typeof e&&(r=e,e=null,"function"!=typeof r&&(r=E))),"object"!=typeof e&&(r=e,e=null),y("end :: cb? %s",!!r),r=r||E,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!t&&Object.keys(this.outgoing).length>0?(y("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(y("end :: (%s) :: immediately calling finish",n.options.clientId),i()),this)},A.prototype.removeOutgoingMessage=function(t){const e=this.outgoing[t]?this.outgoing[t].cb:null;return delete this.outgoing[t],this.outgoingStore.del({messageId:t},(function(){e(new Error("Message removed"))})),this},A.prototype.reconnect=function(t){y("client reconnect");const e=this,r=function(){t?(e.options.incomingStore=t.incomingStore,e.options.outgoingStore=t.outgoingStore):(e.options.incomingStore=null,e.options.outgoingStore=null),e.incomingStore=e.options.incomingStore||new i,e.outgoingStore=e.options.outgoingStore||new i,e.disconnecting=!1,e.disconnected=!1,e._deferredReconnect=null,e._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},A.prototype._reconnect=function(){y("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),y("client already connected. disconnecting first.")):(y("_reconnect: calling _setupStream"),this._setupStream())},A.prototype._setupReconnect=function(){const t=this;!t.disconnecting&&!t.reconnectTimer&&t.options.reconnectPeriod>0?(this.reconnecting||(y("_setupReconnect :: emit `offline` state"),this.emit("offline"),y("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),y("_setupReconnect :: setting reconnectTimer for %d ms",t.options.reconnectPeriod),t.reconnectTimer=setInterval((function(){y("reconnectTimer :: reconnect triggered!"),t._reconnect()}),t.options.reconnectPeriod)):y("_setupReconnect :: doing nothing...")},A.prototype._clearReconnect=function(){y("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},A.prototype._cleanUp=function(t,e){const r=arguments[2];if(e&&(y("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",e)),y("_cleanUp :: forced? %s",t),t)0===this.options.reconnectPeriod&&this.options.clean&&S(this.outgoing),y("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const t=m({cmd:"disconnect"},r);y("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(t,v.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(y("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(y("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),e&&!this.connected&&(y("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",e),e())},A.prototype._sendPacket=function(t,e,r){y("_sendPacket :: (%s) :: start",this.options.clientId),r=r||E,e=e||E;const n=function(t,e){if(5===t.options.protocolVersion&&"publish"===e.cmd){let r;e.properties&&(r=e.properties.topicAlias);const n=e.topic.toString();if(t.topicAliasSend)if(r){if(0!==n.length&&(y("applyTopicAlias :: register topic: %s - alias: %d",n,r),!t.topicAliasSend.put(n,r)))return y("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}else 0!==n.length&&(t.options.autoAssignTopicAlias?(r=t.topicAliasSend.getAliasByTopic(n),r?(e.topic="",e.properties={...e.properties,topicAlias:r},y("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",n,r)):(r=t.topicAliasSend.getLruAlias(),t.topicAliasSend.put(n,r),e.properties={...e.properties,topicAlias:r},y("applyTopicAlias :: auto assign topic: %s - alias: %d",n,r))):t.options.autoUseTopicAlias&&(r=t.topicAliasSend.getAliasByTopic(n),r&&(e.topic="",e.properties={...e.properties,topicAlias:r},y("applyTopicAlias :: auto use topic: %s - alias: %d",n,r))));else if(r)return y("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}}(this,t);if(n)e(n);else{if(!this.connected)return"auth"===t.cmd?(this._shiftPingInterval(),void k(this,t,e)):(y("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(t,e,r));switch(this._shiftPingInterval(),t.cmd){case"publish":break;case"pubrel":return void x(this,t,e,r);default:return void k(this,t,e)}switch(t.qos){case 2:case 1:x(this,t,e,r);break;case 0:default:k(this,t,e)}y("_sendPacket :: (%s) :: end",this.options.clientId)}},A.prototype._storePacket=function(t,e,r){y("_storePacket :: packet: %o",t),y("_storePacket :: cb? %s",!!e),r=r||E;let n=t;if("publish"===n.cmd){n=p(t);const r=w(this,n);if(r)return e&&e(r)}0===(n.qos||0)&&this.queueQoSZero||"publish"!==n.cmd?this.queue.push({packet:n,cb:e}):n.qos>0?(e=this.outgoing[n.messageId]?this.outgoing[n.messageId].cb:null,this.outgoingStore.put(n,(function(t){if(t)return e&&e(t);r()}))):e&&e(new Error("No connection to broker"))},A.prototype._setupPingTimer=function(){y("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const t=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=h((function(){t._checkPing()}),1e3*this.options.keepalive))},A.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},A.prototype._checkPing=function(){y("_checkPing :: checking ping..."),this.pingResp?(y("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(y("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},A.prototype._handlePingresp=function(){this.pingResp=!0},A.prototype._handleConnack=function(t){y("_handleConnack");const e=this.options,r=5===e.protocolVersion?t.reasonCode:t.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,t.properties){if(t.properties.topicAliasMaximum){if(t.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));t.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(t.properties.topicAliasMaximum))}t.properties.serverKeepAlive&&e.keepalive&&(e.keepalive=t.properties.serverKeepAlive,this._shiftPingInterval()),t.properties.maximumPacketSize&&(e.properties||(e.properties={}),e.properties.maximumPacketSize=t.properties.maximumPacketSize)}if(0===r)this.reconnecting=!1,this._onConnect(t);else if(r>0){const t=new Error("Connection refused: "+_[r]);t.code=r,this.emit("error",t)}},A.prototype._handleAuth=function(t){const e=this.options.protocolVersion,r=5===e?t.reasonCode:t.returnCode;if(5!==e){const t=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+e);return t.code=r,void this.emit("error",t)}const n=this;this.handleAuth(t,(function(t,e){if(t)n.emit("error",t);else if(24===r)n.reconnecting=!1,n._sendPacket(e);else{const e=new Error("Connection refused: "+_[r]);t.code=r,n.emit("error",e)}}))},A.prototype.handleAuth=function(t,e){e()},A.prototype._handlePublish=function(t,e){y("_handlePublish: packet %o",t),e=void 0!==e?e:E;let r=t.topic.toString();const n=t.payload,o=t.qos,i=t.messageId,s=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let e;if(t.properties&&(e=t.properties.topicAlias),void 0!==e)if(0===r.length){if(!(e>0&&e<=65535))return y("_handlePublish :: topic alias out of range. alias: %d",e),void this.emit("error",new Error("Received Topic Alias is out of range"));{const t=this.topicAliasRecv.getTopicByAlias(e);if(!t)return y("_handlePublish :: unregistered topic alias. alias: %d",e),void this.emit("error",new Error("Received unregistered Topic Alias"));r=t,y("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,e)}}else{if(!this.topicAliasRecv.put(r,e))return y("_handlePublish :: topic alias out of range. alias: %d",e),void this.emit("error",new Error("Received Topic Alias is out of range"));y("_handlePublish :: registered topic: %s - alias: %d",r,e)}}switch(y("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(r,n,t,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===u.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:n},e):s.incomingStore.put(t,(function(){s._sendPacket({cmd:"pubrec",messageId:i},e)})))}));break;case 1:a.customHandleAcks(r,n,t,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===u.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,t),void s.handleMessage(t,(function(t){if(t)return e&&e(t);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},e)})))}));break;case 0:this.emit("message",r,n,t),this.handleMessage(t,e);break;default:y("_handlePublish: unknown QoS. Doing nothing.")}},A.prototype.handleMessage=function(t,e){e()},A.prototype._handleAck=function(t){const e=t.messageId,r=t.cmd;let n=null;const o=this.outgoing[e]?this.outgoing[e].cb:null,i=this;let s;if(o){switch(y("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=t.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+_[r]),s.code=r,o(s,t)),delete this.outgoing[e],this.outgoingStore.del(t,o),this.messageIdProvider.deallocate(e),this._invokeStoreProcessingQueue();break}case"pubrec":{n={cmd:"pubrel",qos:2,messageId:e};const r=t.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+_[r]),s.code=r,o(s,t)):this._sendPacket(n);break}case"suback":delete this.outgoing[e],this.messageIdProvider.deallocate(e);for(let r=0;r<t.granted.length;r++)if(0!=(128&t.granted[r])){const t=this.messageIdToTopic[e];t&&t.forEach((function(t){delete i._resubscribeTopics[t]}))}this._invokeStoreProcessingQueue(),o(null,t);break;case"unsuback":delete this.outgoing[e],this.messageIdProvider.deallocate(e),this._invokeStoreProcessingQueue(),o(null);break;default:i.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else y("_handleAck :: Server sent an ack in error. Ignoring.")},A.prototype._handlePubrel=function(t,e){y("handling pubrel packet"),e=void 0!==e?e:E;const r=t.messageId,n=this,o={cmd:"pubcomp",messageId:r};n.incomingStore.get(t,(function(t,r){t?n._sendPacket(o,e):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,(function(t){if(t)return e(t);n.incomingStore.del(r,E),n._sendPacket(o,e)})))}))},A.prototype._handleDisconnect=function(t){this.emit("disconnect",t)},A.prototype._nextId=function(){return this.messageIdProvider.allocate()},A.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},A.prototype._resubscribe=function(){y("_resubscribe");const t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){y("_resubscribe: protocolVersion 5");for(let e=0;e<t.length;e++){const r={};r[t[e]]=this._resubscribeTopics[t[e]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[e]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},A.prototype._onConnect=function(t){if(this.disconnected)return void this.emit("connect",t);const e=this;this.connackPacket=t,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function r(){let n=e.outgoingStore.createStream();function o(){e._storeProcessing=!1,e._packetIdsDuringStoreProcessing={}}function i(){n.destroy(),n=null,e._flushStoreProcessingQueue(),o()}e.once("close",i),n.on("error",(function(t){o(),e._flushStoreProcessingQueue(),e.removeListener("close",i),e.emit("error",t)})),n.on("end",(function(){let n=!0;for(const t in e._packetIdsDuringStoreProcessing)if(!e._packetIdsDuringStoreProcessing[t]){n=!1;break}n?(o(),e.removeListener("close",i),e._invokeAllStoreProcessingQueue(),e.emit("connect",t)):r()})),function t(){if(!n)return;e._storeProcessing=!0;const r=n.read(1);let o;r?e._packetIdsDuringStoreProcessing[r.messageId]?t():e.disconnecting||e.reconnectTimer?n.destroy&&n.destroy():(o=e.outgoing[r.messageId]?e.outgoing[r.messageId].cb:null,e.outgoing[r.messageId]={volatile:!1,cb:function(e,r){o&&o(e,r),t()}},e._packetIdsDuringStoreProcessing[r.messageId]=!0,e.messageIdProvider.register(r.messageId)?e._sendPacket(r):y("messageId: %d has already used.",r.messageId)):n.once("readable",t)}()}()},A.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const t=this._storeProcessingQueue[0];if(t&&t.invoke())return this._storeProcessingQueue.shift(),!0}return!1},A.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},A.prototype._flushStoreProcessingQueue=function(){for(const t of this._storeProcessingQueue)t.cbStorePut&&t.cbStorePut(new Error("Connection closed")),t.callback&&t.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=A}).call(this,r(9),r(10))},function(t,e,r){"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),l=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(l(t,s,s+16383>a?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function l(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){
|
|
12
|
+
var n=r(238),o=r(239),i=r(240);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return f(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=p(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,r),o=(e=a(e,n)).write(t,r);o!==n&&(e=e.slice(0,o));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|h(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):p(e,t);if("Buffer"===t.type&&i(t.data))return p(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 f(e,t){if(l(t),e=a(e,t<0?0:0|h(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function p(e,t){var r=t.length<0?0:0|h(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function h(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return B(e).length;default:if(n)return q(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,o);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){var i,s=1,a=e.length,u=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;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=r;i<a;i++)if(c(e,i)===c(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,p=0;p<u;p++)if(c(e,i+p)!==c(t,p)){f=!1;break}if(f)return i}return-1}function b(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function _(e,t,r,n){return H(q(t,e.length-r),e,r,n)}function w(e,t,r,n){return H(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function k(e,t,r,n){return w(e,t,r,n)}function S(e,t,r,n){return H(B(t),e,r,n)}function x(e,t,r,n){return H(function(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,u,c=e[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.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=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return f(null,e)},u.allocUnsafeSlow=function(e){return f(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):m.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,o){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(n,o),l=e.slice(t,r),f=0;f<a;++f)if(c[f]!==l[f]){i=c[f],s=l[f];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return k(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function I(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function C(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=N(e[i]);return o}function P(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function O(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,r,n,o,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function M(e,t,r,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-r,2);o<i;++o)e[r+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function D(e,t,r,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-r,4);o<i;++o)e[r+o]=t>>>8*(n?o:3-o)&255}function j(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,i){return i||j(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,i){return i||j(e,0,r,8),o.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var o=t-e;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},u.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},u.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]},u.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])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.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},u.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]},u.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),o.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||R(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||R(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);R(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*r-1);R(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o,i=n-r;if(this===e&&r<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t);return i},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=u.isBuffer(e)?e:q(new u(e,n).toString()),a=s.length;for(i=0;i<r-t;++i)this[i+t]=s[i%a]}return this};var F=/[^+\/0-9A-Za-z-_]/g;function N(e){return e<16?"0"+e.toString(16):e.toString(16)}function q(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function B(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}}).call(this,r(10))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],l=!1,f=-1;function p(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&h())}function h(){if(!l){var e=a(p);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new d(e,t)),1!==c.length||l||a(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(28);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(0),o=r(13);e.exports=function(e){var t=n(e),r=t.getFullYear(),i=new Date(0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);var s=o(i),a=new Date(0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);var u=o(a);return t.getTime()>=s.getTime()?r+1:t.getTime()>=u.getTime()?r:r-1}},function(e,t,r){(t=e.exports=r(95)).Stream=t,t.Readable=t,t.Writable=r(99),t.Duplex=r(18),t.Transform=r(101),t.PassThrough=r(248),t.finished=r(44),t.pipeline=r(249)},function(e,t,r){(function(n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))}),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(255)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){"use strict";var n={};function o(e,t,r){r||(r=Error);var o=function(e){var r,n;function o(r,n,o){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,o))||this}return n=e,(r=o).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,o}(r);o.prototype.name=r.name,o.prototype.code=e,n[e]=o}function i(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}o("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),o("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,o,s,a;if("string"==typeof t&&(o="not ",t.substr(!s||s<0?0:+s,o.length)===o)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(n," ").concat(i(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(i(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=c;var o=r(95),i=r(99);r(11)(c,o);for(var s=n(i.prototype),a=0;a<s.length;a++){var u=s[a];c.prototype[u]||(c.prototype[u]=i.prototype[u])}function c(e){if(!(this instanceof c))return new c(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||t.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,r(9))},function(e,t,r){"use strict";e.exports=TypeError},function(e,t,r){var n=r(124),o=r(125),i=r(56),s=r(126);e.exports=function(e){return n(e)||o(e)||i(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(14),o=r(13);e.exports=function(e){var t=n(e),r=new Date(0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),o(r)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e).getTime(),o=n(t).getTime();return r<o?-1:r>o?1:0}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setDate(r.getDate()+o),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e).getTime(),o=Number(t);return new Date(r+o)}},function(e,t,r){"use strict";var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}g(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,o,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var o,i,s,a;if(c(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return e}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=p.bind(n);return o.listener=r,n.wrapFn=o,o}function d(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):y(o,o.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function g(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){n.once&&e.removeEventListener(t,o),r(i)}))}}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},a.prototype.getMaxListeners=function(){return l(this)},a.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)i(u,this,t);else{var c=u.length,l=y(u,c);for(r=0;r<c;++r)i(l[r],this,t)}return!0},a.prototype.addListener=function(e,t){return f(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return f(this,e,t,!0)},a.prototype.once=function(e,t){return c(t),this.on(e,h(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return c(t),this.prependListener(e,h(this,e,t)),this},a.prototype.removeListener=function(e,t){var r,n,o,i,s;if(c(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return d(this,e,!0)},a.prototype.rawListeners=function(e){return d(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(12);e.exports=function(e,t){var r=n(e),o=n(t),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/864e5)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=(i<r?7:0)+i-r;return o.setDate(o.getDate()-s),o.setHours(0,0,0,0),o}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()-o.getTime()}},function(e,t,r){var n=r(0),o=r(39);e.exports=function(e,t){var r=n(e),i=Number(t),s=r.getMonth()+i,a=new Date(0);a.setFullYear(r.getFullYear(),s,1),a.setHours(0,0,0,0);var u=o(a);return r.setMonth(s,Math.min(u,r.getDate())),r}},function(e,t,r){(function(t){var n="function"==typeof Map&&Map.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,i=n&&o&&"function"==typeof o.get?o.get:null,s=n&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,u=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=a&&u&&"function"==typeof u.get?u.get:null,l=a&&Set.prototype.forEach,f="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,p="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,h="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,d=Boolean.prototype.valueOf,m=Object.prototype.toString,y=Function.prototype.toString,g=String.prototype.match,v=String.prototype.slice,b=String.prototype.replace,_=String.prototype.toUpperCase,w=String.prototype.toLowerCase,k=RegExp.prototype.test,S=Array.prototype.concat,x=Array.prototype.join,E=Array.prototype.slice,T=Math.floor,A="function"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,P="function"==typeof Symbol&&"object"==typeof Symbol.iterator,O="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===P||"symbol")?Symbol.toStringTag:null,R=Object.prototype.propertyIsEnumerable,M=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function D(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||k.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-T(-e):T(e);if(n!==e){var o=String(n),i=v.call(t,o.length+1);return b.call(o,r,"$&_")+"."+b.call(b.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(t,r,"$&_")}var j=r(268),L=j.custom,U=z(L)?L:null,F={__proto__:null,double:'"',single:"'"},N={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function q(e,t,r){var n=r.quoteStyle||t,o=F[n];return o+e+o}function B(e){return b.call(String(e),/"/g,""")}function H(e){return!O||!("object"==typeof e&&(O in e||void 0!==e[O]))}function Y(e){return"[object Array]"===K(e)&&H(e)}function W(e){return"[object RegExp]"===K(e)&&H(e)}function z(e){if(P)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!C)return!1;try{return C.call(e),!0}catch(e){}return!1}e.exports=function e(r,n,o,a){var u=n||{};if(V(u,"quoteStyle")&&!V(F,u.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(V(u,"maxStringLength")&&("number"==typeof u.maxStringLength?u.maxStringLength<0&&u.maxStringLength!==1/0:null!==u.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var m=!V(u,"customInspect")||u.customInspect;if("boolean"!=typeof m&&"symbol"!==m)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(V(u,"indent")&&null!==u.indent&&"\t"!==u.indent&&!(parseInt(u.indent,10)===u.indent&&u.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(V(u,"numericSeparator")&&"boolean"!=typeof u.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var _=u.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function e(t,r){if(t.length>r.maxStringLength){var n=t.length-r.maxStringLength,o="... "+n+" more character"+(n>1?"s":"");return e(v.call(t,0,r.maxStringLength),r)+o}var i=N[r.quoteStyle||"single"];return i.lastIndex=0,q(b.call(b.call(t,i,"\\$1"),/[\x00-\x1f]/g,G),"single",r)}(r,u);if("number"==typeof r){if(0===r)return 1/0/r>0?"0":"-0";var k=String(r);return _?D(r,k):k}if("bigint"==typeof r){var T=String(r)+"n";return _?D(r,T):T}var I=void 0===u.depth?5:u.depth;if(void 0===o&&(o=0),o>=I&&I>0&&"object"==typeof r)return Y(r)?"[Array]":"[Object]";var L=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=x.call(Array(e.indent+1)," ")}return{base:r,prev:x.call(Array(t+1),r)}}(u,o);if(void 0===a)a=[];else if(Q(a,r)>=0)return"[Circular]";function $(t,r,n){if(r&&(a=E.call(a)).push(r),n){var i={depth:u.depth};return V(u,"quoteStyle")&&(i.quoteStyle=u.quoteStyle),e(t,i,o+1,a)}return e(t,u,o+1,a)}if("function"==typeof r&&!W(r)){var re=function(e){if(e.name)return e.name;var t=g.call(y.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(r),ne=te(r,$);return"[Function"+(re?": "+re:" (anonymous)")+"]"+(ne.length>0?" { "+x.call(ne,", ")+" }":"")}if(z(r)){var oe=P?b.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):C.call(r);return"object"!=typeof r||P?oe:J(oe)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(r)){for(var ie="<"+w.call(String(r.nodeName)),se=r.attributes||[],ae=0;ae<se.length;ae++)ie+=" "+se[ae].name+"="+q(B(se[ae].value),"double",u);return ie+=">",r.childNodes&&r.childNodes.length&&(ie+="..."),ie+="</"+w.call(String(r.nodeName))+">"}if(Y(r)){if(0===r.length)return"[]";var ue=te(r,$);return L&&!function(e){for(var t=0;t<e.length;t++)if(Q(e[t],"\n")>=0)return!1;return!0}(ue)?"["+ee(ue,L)+"]":"[ "+x.call(ue,", ")+" ]"}if(function(e){return"[object Error]"===K(e)&&H(e)}(r)){var ce=te(r,$);return"cause"in Error.prototype||!("cause"in r)||R.call(r,"cause")?0===ce.length?"["+String(r)+"]":"{ ["+String(r)+"] "+x.call(ce,", ")+" }":"{ ["+String(r)+"] "+x.call(S.call("[cause]: "+$(r.cause),ce),", ")+" }"}if("object"==typeof r&&m){if(U&&"function"==typeof r[U]&&j)return j(r,{depth:I-o});if("symbol"!==m&&"function"==typeof r.inspect)return r.inspect()}if(function(e){if(!i||!e||"object"!=typeof e)return!1;try{i.call(e);try{c.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(r)){var le=[];return s&&s.call(r,(function(e,t){le.push($(t,r,!0)+" => "+$(e,r))})),Z("Map",i.call(r),le,L)}if(function(e){if(!c||!e||"object"!=typeof e)return!1;try{c.call(e);try{i.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(r)){var fe=[];return l&&l.call(r,(function(e){fe.push($(e,r))})),Z("Set",c.call(r),fe,L)}if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{f.call(e,f);try{p.call(e,p)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(r))return X("WeakMap");if(function(e){if(!p||!e||"object"!=typeof e)return!1;try{p.call(e,p);try{f.call(e,f)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(r))return X("WeakSet");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{return h.call(e),!0}catch(e){}return!1}(r))return X("WeakRef");if(function(e){return"[object Number]"===K(e)&&H(e)}(r))return J($(Number(r)));if(function(e){if(!e||"object"!=typeof e||!A)return!1;try{return A.call(e),!0}catch(e){}return!1}(r))return J($(A.call(r)));if(function(e){return"[object Boolean]"===K(e)&&H(e)}(r))return J(d.call(r));if(function(e){return"[object String]"===K(e)&&H(e)}(r))return J($(String(r)));if("undefined"!=typeof window&&r===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&r===globalThis||void 0!==t&&r===t)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===K(e)&&H(e)}(r)&&!W(r)){var pe=te(r,$),he=M?M(r)===Object.prototype:r instanceof Object||r.constructor===Object,de=r instanceof Object?"":"null prototype",me=!he&&O&&Object(r)===r&&O in r?v.call(K(r),8,-1):de?"Object":"",ye=(he||"function"!=typeof r.constructor?"":r.constructor.name?r.constructor.name+" ":"")+(me||de?"["+x.call(S.call([],me||[],de||[]),": ")+"] ":"");return 0===pe.length?ye+"{}":L?ye+"{"+ee(pe,L)+"}":ye+"{ "+x.call(pe,", ")+" }"}return String(r)};var $=Object.prototype.hasOwnProperty||function(e){return e in this};function V(e,t){return $.call(e,t)}function K(e){return m.call(e)}function Q(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function G(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+_.call(t.toString(16))}function J(e){return"Object("+e+")"}function X(e){return e+" { ? }"}function Z(e,t,r,n){return e+" ("+t+") {"+(n?ee(r,n):x.call(r,", "))+"}"}function ee(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+x.call(e,","+r)+"\n"+t.prev}function te(e,t){var r=Y(e),n=[];if(r){n.length=e.length;for(var o=0;o<e.length;o++)n[o]=V(e,o)?t(e[o],e):""}var i,s="function"==typeof I?I(e):[];if(P){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var u in e)V(e,u)&&(r&&String(Number(u))===u&&u<e.length||P&&i["$"+u]instanceof Symbol||(k.call(/[^\w$]/,u)?n.push(t(u,e)+": "+t(e[u],e)):n.push(u+": "+t(e[u],e))));if("function"==typeof I)for(var c=0;c<s.length;c++)R.call(e,s[c])&&n.push("["+t(s[c])+"]: "+t(e[s[c]],e));return n}}).call(this,r(10))},function(e,t,r){"use strict";var n=r(290);e.exports=Function.prototype.bind||n},function(e,t){e.exports=function(e){return e instanceof Date}},function(e,t,r){var n=r(0),o=r(13),i=r(21);e.exports=function(e){var t=n(e),r=o(t).getTime()-i(t).getTime();return Math.round(r/6048e5)+1}},function(e,t,r){var n=r(135),o=r(136);e.exports={distanceInWords:n(),format:o()}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e).getTime(),o=n(t).getTime();return r>o?-1:r<o?1:0}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/1e3;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(0),o=r(63),i=r(22);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setMonth(r.getMonth()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getFullYear(),o=t.getMonth(),i=new Date(0);return i.setFullYear(r,o+1,0),i.setHours(0,0,0,0),i.getDate()}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,7*r)}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(28);e.exports=function(e,t,r){var o=n(e,r),i=n(t,r);return o.getTime()===i.getTime()}},function(e,t){e.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e};var r=Object.prototype.hasOwnProperty},function(e,t,r){"use strict";var n=r(17).codes.ERR_STREAM_PREMATURE_CLOSE;function o(){}e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);r||(r={}),i=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];e.apply(this,n)}}}(i||o);var s=r.readable||!1!==r.readable&&t.readable,a=r.writable||!1!==r.writable&&t.writable,u=function(){t.writable||l()},c=t._writableState&&t._writableState.finished,l=function(){a=!1,c=!0,s||i.call(t)},f=t._readableState&&t._readableState.endEmitted,p=function(){s=!1,f=!0,a||i.call(t)},h=function(e){i.call(t,e)},d=function(){var e;return s&&!f?(t._readableState&&t._readableState.ended||(e=new n),i.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new n),i.call(t,e)):void 0},m=function(){t.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?a&&!t._writableState&&(t.on("end",u),t.on("close",u)):(t.on("complete",l),t.on("abort",d),t.req?m():t.on("request",m)),t.on("end",p),t.on("finish",l),!1!==r.error&&t.on("error",h),t.on("close",d),function(){t.removeListener("complete",l),t.removeListener("abort",d),t.removeListener("request",m),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("end",p),t.removeListener("error",h),t.removeListener("close",d)}}},function(e,t,r){"use strict";var n=r(105),o=r(270),i=r(271),s=r(272),a=r(273),u=r(274),c=r(19),l=r(275),f=r(276),p=r(277),h=r(278),d=r(279),m=r(280),y=r(281),g=r(282),v=Function,b=function(e){try{return v('"use strict"; return ('+e+").constructor;")()}catch(e){}},_=r(106),w=r(285),k=function(){throw new c},S=_?function(){try{return k}catch(e){try{return _(arguments,"callee").get}catch(e){return k}}}():k,x=r(286)(),E=r(288),T=r(108),A=r(107),I=r(110),C=r(46),P={},O="undefined"!=typeof Uint8Array&&E?E(Uint8Array):void 0,R={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":x&&E?E([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":P,"%AsyncGenerator%":P,"%AsyncGeneratorFunction%":P,"%AsyncIteratorPrototype%":P,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":i,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":P,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":x&&E?E(E([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&x&&E?E((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":n,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&x&&E?E((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":x&&E?E(""[Symbol.iterator]()):void 0,"%Symbol%":x?Symbol:void 0,"%SyntaxError%":u,"%ThrowTypeError%":S,"%TypedArray%":O,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":l,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":C,"%Function.prototype.apply%":I,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":T,"%Math.abs%":f,"%Math.floor%":p,"%Math.max%":h,"%Math.min%":d,"%Math.pow%":m,"%Math.round%":y,"%Math.sign%":g,"%Reflect.getPrototypeOf%":A};if(E)try{null.error}catch(e){var M=E(E(e));R["%Error.prototype%"]=M}var D={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},j=r(32),L=r(293),U=j.call(C,Array.prototype.concat),F=j.call(I,Array.prototype.splice),N=j.call(C,String.prototype.replace),q=j.call(C,String.prototype.slice),B=j.call(C,RegExp.prototype.exec),H=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Y=/\\(\\)?/g,W=function(e){var t=q(e,0,1),r=q(e,-1);if("%"===t&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return N(e,H,(function(e,t,r,o){n[n.length]=r?N(o,Y,"$1"):t||e})),n},z=function(e,t){var r,n=e;if(L(D,n)&&(n="%"+(r=D[n])[0]+"%"),L(R,n)){var o=R[n];if(o===P&&(o=function e(t){var r;if("%AsyncFunction%"===t)r=b("async function () {}");else if("%GeneratorFunction%"===t)r=b("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=b("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&E&&(r=E(o.prototype))}return R[t]=r,r}(n)),void 0===o&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new u("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===B(/^%?[^%]*%?$/,e))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=W(e),n=r.length>0?r[0]:"",o=z("%"+n+"%",t),i=o.name,s=o.value,a=!1,l=o.alias;l&&(n=l[0],F(r,U([0,1],l)));for(var f=1,p=!0;f<r.length;f+=1){var h=r[f],d=q(h,0,1),m=q(h,-1);if(('"'===d||"'"===d||"`"===d||'"'===m||"'"===m||"`"===m)&&d!==m)throw new u("property names with quotes must have matching quotes");if("constructor"!==h&&p||(a=!0),L(R,i="%"+(n+="."+h)+"%"))s=R[i];else if(null!=s){if(!(h in s)){if(!t)throw new c("base intrinsic for "+e+" exists, but the property is not available.");return}if(_&&f+1>=r.length){var y=_(s,h);s=(p=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:s[h]}else p=L(s,h),s=s[h];p&&!a&&(R[i]=s)}}return s}},function(e,t,r){"use strict";e.exports=Function.prototype.call},function(e,t,r){"use strict";var n=String.prototype.replace,o=/%20/g,i="RFC1738",s="RFC3986";e.exports={default:s,formatters:{RFC1738:function(e){return n.call(e,o,"+")},RFC3986:function(e){return String(e)}},RFC1738:i,RFC3986:s}},function(e,t,r){"use strict";var n=r(297),o=r(16)("mqttjs:tls");e.exports=function(e,t){var r;function i(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),(r=n.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",i)})),r.on("error",i),r}},function(e,t,r){(function(t,n){var o=r(15),i=r(298),s=r(11),a=r(301),u=t.from&&t.from!==Uint8Array.from?t.from([0]):new t([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(){},p=function(e,t,r){if(!(this instanceof p))return new p(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(p,o.Duplex),p.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new p(e,t,r)},p.prototype.cork=function(){1==++this._corked&&this.emit("cork")},p.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},p.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=i(e,{writable:!0,readable:!1},l(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=function(){t._writable.removeListener("drain",o),r()},this.uncork()}else this.end()},p.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,n=i(e,{writable:!1,readable:!0},l(this)),s=function(){r._forward()},a=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new o.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",s),this._readable2.on("end",a),this._unread=function(){r._readable2.removeListener("readable",s),r._readable2.removeListener("end",a),n()},this._forward()}},p.prototype._read=function(){this._drained=!0,this._forward()},p.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},p.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},p.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},p.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?c(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},p.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,(function(){var r,n;r=t._forwardEnd&&t._writable,n=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},r?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n()}))},p.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(u),o.Writable.prototype.end.call(this,r))},e.exports=p}).call(this,r(8).Buffer,r(9))},function(e,t,r){var n=r(59),o=r(34),i=r(14),s=r(0),a=r(61),u=r(35);var c={M:function(e){return e.getMonth()+1},MM:function(e){return p(e.getMonth()+1,2)},Q:function(e){return Math.ceil((e.getMonth()+1)/3)},D:function(e){return e.getDate()},DD:function(e){return p(e.getDate(),2)},DDD:function(e){return n(e)},DDDD:function(e){return p(n(e),3)},d:function(e){return e.getDay()},E:function(e){return e.getDay()||7},W:function(e){return o(e)},WW:function(e){return p(o(e),2)},YY:function(e){return p(e.getFullYear(),4).substr(2)},YYYY:function(e){return p(e.getFullYear(),4)},GG:function(e){return String(i(e)).substr(2)},GGGG:function(e){return i(e)},H:function(e){return e.getHours()},HH:function(e){return p(e.getHours(),2)},h:function(e){var t=e.getHours();return 0===t?12:t>12?t%12:t},hh:function(e){return p(c.h(e),2)},m:function(e){return e.getMinutes()},mm:function(e){return p(e.getMinutes(),2)},s:function(e){return e.getSeconds()},ss:function(e){return p(e.getSeconds(),2)},S:function(e){return Math.floor(e.getMilliseconds()/100)},SS:function(e){return p(Math.floor(e.getMilliseconds()/10),2)},SSS:function(e){return p(e.getMilliseconds(),3)},Z:function(e){return f(e.getTimezoneOffset(),":")},ZZ:function(e){return f(e.getTimezoneOffset())},X:function(e){return Math.floor(e.getTime()/1e3)},x:function(e){return e.getTime()}};function l(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|]$/g,""):e.replace(/\\/g,"")}function f(e,t){t=t||"";var r=e>0?"-":"+",n=Math.abs(e),o=n%60;return r+p(Math.floor(n/60),2)+t+p(o,2)}function p(e,t){for(var r=Math.abs(e).toString();r.length<t;)r="0"+r;return r}e.exports=function(e,t,r){var n=t?String(t):"YYYY-MM-DDTHH:mm:ss.SSSZ",o=(r||{}).locale,i=u.format.formatters,f=u.format.formattingTokensRegExp;o&&o.format&&o.format.formatters&&(i=o.format.formatters,o.format.formattingTokensRegExp&&(f=o.format.formattingTokensRegExp));var p=s(e);return a(p)?function(e,t,r){var n,o,i=e.match(r),s=i.length;for(n=0;n<s;n++)o=t[i[n]]||c[i[n]],i[n]=o||l(i[n]);return function(e){for(var t="",r=0;r<s;r++)i[r]instanceof Function?t+=i[r](e,c):t+=i[r];return t}}(n,i,f)(p):"Invalid Date"}},function(e,t,r){var n=r(62);e.exports=function(e,t){return n(Date.now(),e,t)}},function(e,t,r){e.exports={addDays:r(23),addHours:r(64),addISOYears:r(65),addMilliseconds:r(24),addMinutes:r(67),addMonths:r(30),addQuarters:r(68),addSeconds:r(69),addWeeks:r(40),addYears:r(70),areRangesOverlapping:r(138),closestIndexTo:r(139),closestTo:r(140),compareAsc:r(22),compareDesc:r(36),differenceInCalendarDays:r(27),differenceInCalendarISOWeeks:r(141),differenceInCalendarISOYears:r(71),differenceInCalendarMonths:r(63),differenceInCalendarQuarters:r(142),differenceInCalendarWeeks:r(143),differenceInCalendarYears:r(73),differenceInDays:r(74),differenceInHours:r(144),differenceInISOYears:r(145),differenceInMilliseconds:r(29),differenceInMinutes:r(146),differenceInMonths:r(38),differenceInQuarters:r(147),differenceInSeconds:r(37),differenceInWeeks:r(148),differenceInYears:r(149),distanceInWords:r(62),distanceInWordsStrict:r(150),distanceInWordsToNow:r(51),eachDay:r(151),endOfDay:r(41),endOfHour:r(152),endOfISOWeek:r(153),endOfISOYear:r(154),endOfMinute:r(155),endOfMonth:r(77),endOfQuarter:r(156),endOfSecond:r(157),endOfToday:r(158),endOfTomorrow:r(159),endOfWeek:r(76),endOfYear:r(160),endOfYesterday:r(161),format:r(50),getDate:r(162),getDay:r(163),getDayOfYear:r(59),getDaysInMonth:r(39),getDaysInYear:r(164),getHours:r(165),getISODay:r(79),getISOWeek:r(34),getISOWeeksInYear:r(166),getISOYear:r(14),getMilliseconds:r(167),getMinutes:r(168),getMonth:r(169),getOverlappingDaysInRanges:r(170),getQuarter:r(72),getSeconds:r(171),getTime:r(172),getYear:r(173),isAfter:r(174),isBefore:r(175),isDate:r(33),isEqual:r(176),isFirstDayOfMonth:r(177),isFriday:r(178),isFuture:r(179),isLastDayOfMonth:r(180),isLeapYear:r(78),isMonday:r(181),isPast:r(182),isSameDay:r(183),isSameHour:r(80),isSameISOWeek:r(82),isSameISOYear:r(83),isSameMinute:r(84),isSameMonth:r(86),isSameQuarter:r(87),isSameSecond:r(89),isSameWeek:r(42),isSameYear:r(91),isSaturday:r(184),isSunday:r(185),isThisHour:r(186),isThisISOWeek:r(187),isThisISOYear:r(188),isThisMinute:r(189),isThisMonth:r(190),isThisQuarter:r(191),isThisSecond:r(192),isThisWeek:r(193),isThisYear:r(194),isThursday:r(195),isToday:r(196),isTomorrow:r(197),isTuesday:r(198),isValid:r(61),isWednesday:r(199),isWeekend:r(200),isWithinRange:r(201),isYesterday:r(202),lastDayOfISOWeek:r(203),lastDayOfISOYear:r(204),lastDayOfMonth:r(205),lastDayOfQuarter:r(206),lastDayOfWeek:r(92),lastDayOfYear:r(207),max:r(208),min:r(209),parse:r(0),setDate:r(210),setDay:r(211),setDayOfYear:r(212),setHours:r(213),setISODay:r(214),setISOWeek:r(215),setISOYear:r(66),setMilliseconds:r(216),setMinutes:r(217),setMonth:r(93),setQuarter:r(218),setSeconds:r(219),setYear:r(220),startOfDay:r(12),startOfHour:r(81),startOfISOWeek:r(13),startOfISOYear:r(21),startOfMinute:r(85),startOfMonth:r(221),startOfQuarter:r(88),startOfSecond:r(90),startOfToday:r(222),startOfTomorrow:r(223),startOfWeek:r(28),startOfYear:r(60),startOfYesterday:r(224),subDays:r(225),subHours:r(226),subISOYears:r(75),subMilliseconds:r(227),subMinutes:r(228),subMonths:r(229),subQuarters:r(230),subSeconds:r(231),subWeeks:r(232),subYears:r(233)}},function(e,t,r){var n=r(117);e.exports=function(e){return new n(e,0)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(117);function o(e){var t,r;function o(t,r){try{var s=e[t](r),a=s.value,u=a instanceof n;Promise.resolve(u?a.v:a).then((function(r){if(u){var n="return"===t?"return":"next";if(!a.k||r.done)return o(n,r);r=e[n](r).value}i(s.done?"return":"normal",r)}),(function(e){o("throw",e)}))}catch(e){i("throw",e)}}function i(e,n){switch(e){case"return":t.resolve({value:n,done:!0});break;case"throw":t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?o(t.key,t.arg):r=null}this._invoke=function(e,n){return new Promise((function(i,s){var a={key:e,arg:n,resolve:i,reject:s,next:null};r?r=r.next=a:(t=r=a,o(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}o.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},o.prototype.next=function(e){return this._invoke("next",e)},o.prototype.throw=function(e){return this._invoke("throw",e)},o.prototype.return=function(e){return this._invoke("return",e)},e.exports=function(e){return function(){return new o(e.apply(this,arguments))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(55);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26).default,o=r(127);e.exports=function(e){var t=o(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";e.exports=function(e){return null!==e&&"object"==typeof e}},function(e,t,r){var n=r(0),o=r(60),i=r(27);e.exports=function(e){var t=n(e);return i(t,o(t))+1}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=new Date(0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}},function(e,t,r){var n=r(33);e.exports=function(e){if(n(e))return!isNaN(e);throw new TypeError(toString.call(e)+" is not an instance of Date")}},function(e,t,r){var n=r(36),o=r(0),i=r(37),s=r(38),a=r(35);e.exports=function(e,t,r){var u=r||{},c=n(e,t),l=u.locale,f=a.distanceInWords.localize;l&&l.distanceInWords&&l.distanceInWords.localize&&(f=l.distanceInWords.localize);var p,h,d={addSuffix:Boolean(u.addSuffix),comparison:c};c>0?(p=o(e),h=o(t)):(p=o(t),h=o(e));var m,y=i(h,p),g=h.getTimezoneOffset()-p.getTimezoneOffset(),v=Math.round(y/60)-g;if(v<2)return u.includeSeconds?y<5?f("lessThanXSeconds",5,d):y<10?f("lessThanXSeconds",10,d):y<20?f("lessThanXSeconds",20,d):y<40?f("halfAMinute",null,d):f(y<60?"lessThanXMinutes":"xMinutes",1,d):0===v?f("lessThanXMinutes",1,d):f("xMinutes",v,d);if(v<45)return f("xMinutes",v,d);if(v<90)return f("aboutXHours",1,d);if(v<1440)return f("aboutXHours",Math.round(v/60),d);if(v<2520)return f("xDays",1,d);if(v<43200)return f("xDays",Math.round(v/1440),d);if(v<86400)return f("aboutXMonths",m=Math.round(v/43200),d);if((m=s(h,p))<12)return f("xMonths",Math.round(v/43200),d);var b=m%12,_=Math.floor(m/12);return b<3?f("aboutXYears",_,d):b<9?f("overXYears",_,d):f("almostXYears",_+1,d)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return 12*(r.getFullYear()-o.getFullYear())+(r.getMonth()-o.getMonth())}},function(e,t,r){var n=r(24);e.exports=function(e,t){var r=Number(t);return n(e,36e5*r)}},function(e,t,r){var n=r(14),o=r(66);e.exports=function(e,t){var r=Number(t);return o(e,n(e)+r)}},function(e,t,r){var n=r(0),o=r(21),i=r(27);e.exports=function(e,t){var r=n(e),s=Number(t),a=i(r,o(r)),u=new Date(0);return u.setFullYear(s,0,4),u.setHours(0,0,0,0),(r=o(u)).setDate(r.getDate()+a),r}},function(e,t,r){var n=r(24);e.exports=function(e,t){var r=Number(t);return n(e,6e4*r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,3*r)}},function(e,t,r){var n=r(24);e.exports=function(e,t){var r=Number(t);return n(e,1e3*r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,12*r)}},function(e,t,r){var n=r(14);e.exports=function(e,t){return n(e)-n(t)}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return Math.floor(t.getMonth()/3)+1}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()-o.getFullYear()}},function(e,t,r){var n=r(0),o=r(27),i=r(22);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setDate(r.getDate()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(65);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setDate(o.getDate()+s),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e).getFullYear();return t%400==0||t%4==0&&t%100!=0}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e).getDay();return 0===t&&(t=7),t}},function(e,t,r){var n=r(81);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setMinutes(0,0,0),t}},function(e,t,r){var n=r(42);e.exports=function(e,t){return n(e,t,{weekStartsOn:1})}},function(e,t,r){var n=r(21);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(85);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setSeconds(0,0),t}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}},function(e,t,r){var n=r(88);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3;return t.setMonth(o,1),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(90);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setMilliseconds(0),t}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getFullYear()===o.getFullYear()}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=t&&Number(t.weekStartsOn)||0,o=n(e),i=o.getDay(),s=6+(i<r?-7:0)-(i-r);return o.setHours(0,0,0,0),o.setDate(o.getDate()+s),o}},function(e,t,r){var n=r(0),o=r(39);e.exports=function(e,t){var r=n(e),i=Number(t),s=r.getFullYear(),a=r.getDate(),u=new Date(0);u.setFullYear(s,i,15),u.setHours(0,0,0,0);var c=o(u);return r.setMonth(i,Math.min(a,c)),r}},function(e,t,r){"use strict";var n=r(43),o=r(15).Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=n(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){var e=new o(i),t=!1,r=[],n=0;return this._inflights.forEach((function(e,t){r.push(e)})),e._read=function(){!t&&n<r.length?this.push(r[n++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!0,setTimeout((function(){e.emit("close")}),0)}},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},e.exports=a},function(e,t,r){"use strict";(function(t,n){var o;e.exports=E,E.ReadableState=x;r(25).EventEmitter;var i=function(e,t){return e.listeners(t).length},s=r(96),a=r(8).Buffer,u=(void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var c,l=r(241);c=l&&l.debuglog?l.debuglog("stream"):function(){};var f,p,h,d=r(242),m=r(97),y=r(98).getHighWaterMark,g=r(17).codes,v=g.ERR_INVALID_ARG_TYPE,b=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,w=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(11)(E,s);var k=m.errorOrDestroy,S=["error","close","destroy","pause","resume"];function x(e,t,n){o=o||r(18),e=e||{},"boolean"!=typeof n&&(n=t instanceof o),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=r(100).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function E(e){if(o=o||r(18),!(this instanceof E))return new E(e);var t=this instanceof o;this._readableState=new x(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function T(e,t,r,n,o){c("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(c("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?C(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,P(e)))}(e,s);else if(o||(i=function(e,t){var r;n=t,a.isBuffer(n)||n instanceof u||"string"==typeof t||void 0===t||e.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(s,t)),i)k(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)s.endEmitted?k(e,new w):A(e,s,t,!0);else if(s.ended)k(e,new b);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?A(e,s,t,!1):O(e,s)):A(e,s,t,!1)}else n||(s.reading=!1,O(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&C(e)),O(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=m.destroy,E.prototype._undestroy=m.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=a.from(e,t),t=""),r=!0),T(this,e,t,!1,r)},E.prototype.unshift=function(e){return T(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){f||(f=r(100).StringDecoder);var t=new f(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,o="";null!==n;)o+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function C(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(P,e))}function P(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,L(e)}function O(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(c("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function M(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function D(e){c("readable nexttick read 0"),e.read(0)}function j(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),L(e),t.flowing&&!t.reading&&e.read(0)}function L(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function U(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function F(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(N,t,e))}function N(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function q(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}E.prototype.read=function(e){c("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?F(this):C(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&F(this),null;var n,o=t.needReadable;return c("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&c("length less than watermark",o=!0),t.ended||t.reading?c("reading or ended",o=!1):o&&(c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(r,t))),null===(n=e>0?U(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&F(this)),null!==n&&this.emit("data",n),n},E.prototype._read=function(e){k(this,new _("_read()"))},E.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,c("pipe count=%d opts=%j",o.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:y;function a(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("drain",l),e.removeListener("error",h),e.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",p),f=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function u(){c("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,L(e))}}(r);e.on("drain",l);var f=!1;function p(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==q(o.pipes,e))&&!f&&(c("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function h(t){c("onerror",t),y(),e.removeListener("error",h),0===i(e,"error")&&k(e,t)}function d(){e.removeListener("finish",m),y()}function m(){c("onfinish"),e.removeListener("close",d),y()}function y(){c("unpipe"),r.unpipe(e)}return r.on("data",p),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",d),e.once("finish",m),e.emit("pipe",r),o.flowing||(c("pipe resume"),r.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)n[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=q(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},E.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,c("on readable",o.length,o.reading),o.length?C(this):o.reading||n.nextTick(D,this))),r},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(M,this),r},E.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(M,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(j,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var o in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){(c("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o)||(r.objectMode||o&&o.length)&&(t.push(o)||(n=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<S.length;i++)e.on(S[i],this.emit.bind(this,S[i]));return this._read=function(t){c("wrapped _read",t),n&&(n=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=r(246)),p(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=U,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===h&&(h=r(247)),h(E,e,t)})}).call(this,r(10),r(9))},function(e,t,r){e.exports=r(25).EventEmitter},function(e,t,r){"use strict";(function(t){function r(e,t){o(e,t),n(e)}function n(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function o(e,t){e.emit("error",t)}e.exports={destroy:function(e,i){var s=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(i?i(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t.nextTick(o,this,e)):t.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!i&&e?s._writableState?s._writableState.errorEmitted?t.nextTick(n,s):(s._writableState.errorEmitted=!0,t.nextTick(r,s,e)):t.nextTick(r,s,e):i?(t.nextTick(n,s),i(e)):t.nextTick(n,s)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}}}).call(this,r(9))},function(e,t,r){"use strict";var n=r(17).codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,o){var i=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,o,r);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new n(o?r:"highWaterMark",i);return Math.floor(i)}return e.objectMode?16:16384}}},function(e,t,r){"use strict";(function(t,n){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var o=n.callback;t.pendingcb--,o(r),n=n.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=E,E.WritableState=x;var s={deprecate:r(244)},a=r(96),u=r(8).Buffer,c=(void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var l,f=r(97),p=r(98).getHighWaterMark,h=r(17).codes,d=h.ERR_INVALID_ARG_TYPE,m=h.ERR_METHOD_NOT_IMPLEMENTED,y=h.ERR_MULTIPLE_CALLBACK,g=h.ERR_STREAM_CANNOT_PIPE,v=h.ERR_STREAM_DESTROYED,b=h.ERR_STREAM_NULL_VALUES,_=h.ERR_STREAM_WRITE_AFTER_END,w=h.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function S(){}function x(e,t,s){i=i||r(18),e=e||{},"boolean"!=typeof s&&(s=t instanceof i),this.objectMode=!!e.objectMode,s&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=p(this,e,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===e.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new y;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(O,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),O(e,t))}(e,r,o,t,i);else{var s=C(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(e,r),o?n.nextTick(A,e,r,s,i):A(e,r,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function E(e){var t=this instanceof(i=i||r(18));if(!t&&!l.call(E,this))return new E(e);this._writableState=new x(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function T(e,t,r,n,o,i,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new v("write")):r?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function A(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),O(e,t)}function I(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(e,t,!1,t.objectMode?1:c.length,c,l,f),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function P(e,t){e._final((function(r){t.pendingcb--,r&&k(e,r),t.prefinished=!0,e.emit("prefinish"),O(e,t)}))}function O(e,t){var r=C(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(P,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var o=e._readableState;(!o||o.autoDestroy&&o.endEmitted)&&e.destroy()}return r}r(11)(E,a),x.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(x.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(l=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!l.call(this,e)||this===E&&(e&&e._writableState instanceof x)}})):l=function(e){return e instanceof this},E.prototype.pipe=function(){k(this,new g)},E.prototype.write=function(e,t,r){var o,i=this._writableState,s=!1,a=!i.objectMode&&(o=e,u.isBuffer(o)||o instanceof c);return a&&!u.isBuffer(e)&&(e=function(e){return u.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=S),i.ending?function(e,t){var r=new _;k(e,r),n.nextTick(t,r)}(this,r):(a||function(e,t,r,o){var i;return null===r?i=new b:"string"==typeof r||t.objectMode||(i=new d("chunk",["string","Buffer"],r)),!i||(k(e,i),n.nextTick(o,i),!1)}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,o,i){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=u.from(t,r));return t}(t,n,o);n!==s&&(r=!0,o="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;c||(t.needDrain=!0);if(t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:o,isBuf:r,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else T(e,t,!1,a,n,o,i);return c}(this,i,a,e,t,r)),s},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||I(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,r){r(new m("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,r){var o=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||function(e,t,r){t.ending=!0,O(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,o,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=f.destroy,E.prototype._undestroy=f.undestroy,E.prototype._destroy=function(e,t){t(e)}}).call(this,r(10),r(9))},function(e,t,r){"use strict";var n=r(245).Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=f,t=3;break;default:return this.write=p,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},i.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var o=s(t[n]);if(o>=0)return o>0&&(e.lastNeed=o-1),o;if(--n<r||-2===o)return 0;if((o=s(t[n]))>=0)return o>0&&(e.lastNeed=o-2),o;if(--n<r||-2===o)return 0;if((o=s(t[n]))>=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";e.exports=l;var n=r(17).codes,o=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(18);function c(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new i);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);u.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",f)}function f(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,r){p(e,t,r)}))}function p(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(11)(l,u),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,r){r(new o("_transform()"))},l.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var o=this._readableState;(n.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,(function(e){t(e)}))}},function(e,t,r){(function(t){const r=e.exports;r.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},r.codes={};for(const e in r.types){const t=r.types[e];r.codes[t]=e}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=t.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=t.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=t.from([r.codes.connect<<r.CMD_SHIFT]),r.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},r.propertiesCodes={};for(const e in r.properties){const t=r.properties[e];r.propertiesCodes[t]=e}function n(e){return[0,1,2].map(n=>[0,1].map(o=>[0,1].map(i=>{const s=t.alloc(1);return s.writeUInt8(r.codes[e]<<r.CMD_SHIFT|(o?r.DUP_MASK:0)|n<<r.QOS_SHIFT|i,0,!0),s})))}r.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},r.PUBLISH_HEADER=n("publish"),r.SUBSCRIBE_HEADER=n("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=n("unsubscribe"),r.ACKS={unsuback:n("unsuback"),puback:n("puback"),pubcomp:n("pubcomp"),pubrel:n("pubrel"),pubrec:n("pubrec")},r.SUBACK_HEADER=t.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=t.from([3]),r.VERSION4=t.from([4]),r.VERSION5=t.from([5]),r.VERSION131=t.from([131]),r.VERSION132=t.from([132]),r.QOS=[0,1,2].map(e=>t.from([e])),r.EMPTY={pingreq:t.from([r.codes.pingreq<<4,0]),pingresp:t.from([r.codes.pingresp<<4,0]),disconnect:t.from([r.codes.disconnect<<4,0])}}).call(this,r(8).Buffer)},function(e,t,r){(function(t){const n=r(102),o=t.allocUnsafe(0),i=t.from([0]),s=r(258),a=r(259).nextTick,u=r(16)("mqtt-packet:writeToStream"),c=s.cache,l=s.generateNumber,f=s.generateCache,p=s.genBufVariableByteInt,h=s.generate4ByteBuffer;let d=k,m=!0;function y(e,r,s){switch(u("generate called"),r.cork&&(r.cork(),a(g,r)),m&&(m=!1,f()),u("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,r,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const u=i.will;let c=i.clean;const l=i.keepalive||0,f=i.clientId||"",p=i.username,h=i.password,m=i.properties;void 0===c&&(c=!0);let y=0;if(!s||"string"!=typeof s&&!t.isBuffer(s))return r.emit("error",new Error("Invalid protocolId")),!1;y+=s.length+2;if(3!==a&&4!==a&&5!==a)return r.emit("error",new Error("Invalid protocol version")),!1;y+=1;if(("string"==typeof f||t.isBuffer(f))&&(f||a>=4)&&(f||c))y+=t.byteLength(f)+2;else{if(a<4)return r.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return r.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return r.emit("error",new Error("Invalid keepalive")),!1;y+=2;if(y+=1,5===a){var g=E(r,m);if(!g)return!1;y+=g.length}if(u){if("object"!=typeof u)return r.emit("error",new Error("Invalid will")),!1;if(!u.topic||"string"!=typeof u.topic)return r.emit("error",new Error("Invalid will topic")),!1;if(y+=t.byteLength(u.topic)+2,y+=2,u.payload){if(!(u.payload.length>=0))return r.emit("error",new Error("Invalid will payload")),!1;"string"==typeof u.payload?y+=t.byteLength(u.payload):y+=u.payload.length}var v={};if(5===a){if(!(v=E(r,u.properties)))return!1;y+=v.length}}let w=!1;if(null!=p){if(!P(p))return r.emit("error",new Error("Invalid username")),!1;w=!0,y+=t.byteLength(p)+2}if(null!=h){if(!w)return r.emit("error",new Error("Username is required to use password")),!1;if(!P(h))return r.emit("error",new Error("Invalid password")),!1;y+=C(h)+2}r.write(n.CONNECT_HEADER),b(r,y),x(r,s),i.bridgeMode&&(a+=128);r.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let k=0;k|=null!=p?n.USERNAME_MASK:0,k|=null!=h?n.PASSWORD_MASK:0,k|=u&&u.retain?n.WILL_RETAIN_MASK:0,k|=u&&u.qos?u.qos<<n.WILL_QOS_SHIFT:0,k|=u?n.WILL_FLAG_MASK:0,k|=c?n.CLEAN_SESSION_MASK:0,r.write(t.from([k])),d(r,l),5===a&&g.write();x(r,f),u&&(5===a&&v.write(),_(r,u.topic),x(r,u.payload));null!=p&&x(r,p);null!=h&&x(r,h);return!0}(e,r);case"connack":return function(e,r,o){const s=o?o.protocolVersion:4,a=e||{},u=5===s?a.reasonCode:a.returnCode,c=a.properties;let l=2;if("number"!=typeof u)return r.emit("error",new Error("Invalid return code")),!1;let f=null;if(5===s){if(f=E(r,c),!f)return!1;l+=f.length}r.write(n.CONNACK_HEADER),b(r,l),r.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:i),r.write(t.from([u])),null!=f&&f.write();return!0}(e,r,s);case"publish":return function(e,r,i){u("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},c=a.qos||0,l=a.retain?n.RETAIN_MASK:0,f=a.topic,p=a.payload||o,h=a.messageId,m=a.properties;let y=0;if("string"==typeof f)y+=t.byteLength(f)+2;else{if(!t.isBuffer(f))return r.emit("error",new Error("Invalid topic")),!1;y+=f.length+2}t.isBuffer(p)?y+=p.length:y+=t.byteLength(p);if(c&&"number"!=typeof h)return r.emit("error",new Error("Invalid messageId")),!1;c&&(y+=2);let g=null;if(5===s){if(g=E(r,m),!g)return!1;y+=g.length}r.write(n.PUBLISH_HEADER[c][a.dup?1:0][l?1:0]),b(r,y),d(r,C(f)),r.write(f),c>0&&d(r,h);null!=g&&g.write();return u("publish: payload: %o",p),r.write(p)}(e,r,s);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",u=s.messageId,c=s.dup&&"pubrel"===a?n.DUP_MASK:0;let l=0;const f=s.reasonCode,p=s.properties;let h=5===i?3:2;"pubrel"===a&&(l=1);if("number"!=typeof u)return r.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=T(r,p,o,h),!m)return!1;h+=m.length}r.write(n.ACKS[a][l][c][0]),b(r,h),d(r,u),5===i&&r.write(t.from([f]));null!==m&&m.write();return!0}(e,r,s);case"subscribe":return function(e,r,o){u("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,c=s.messageId,l=s.subscriptions,f=s.properties;let p=0;if("number"!=typeof c)return r.emit("error",new Error("Invalid messageId")),!1;p+=2;let h=null;if(5===i){if(h=E(r,f),!h)return!1;p+=h.length}if("object"!=typeof l||!l.length)return r.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const n=l[e].topic,o=l[e].qos;if("string"!=typeof n)return r.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return r.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(l[e].nl||!1))return r.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return r.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const t=l[e].rh||0;if("number"!=typeof t||t>2)return r.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=t.byteLength(n)+2+1}u("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),r.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),b(r,p),d(r,c),null!==h&&h.write();let m=!0;for(const e of l){const o=e.topic,s=e.qos,a=+e.nl,u=+e.rap,c=e.rh;let l;_(r,o),l=n.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(l|=a?n.SUBSCRIBE_OPTIONS_NL:0,l|=u?n.SUBSCRIBE_OPTIONS_RAP:0,l|=c?n.SUBSCRIBE_OPTIONS_RH[c]:0),m=r.write(t.from([l]))}return m}(e,r,s);case"suback":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.granted,c=s.properties;let l=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof u||!u.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return r.emit("error",new Error("Invalid qos vector")),!1;l+=1}let f=null;if(5===i){if(f=T(r,c,o,l),!f)return!1;l+=f.length}r.write(n.SUBACK_HEADER),b(r,l),d(r,a),null!==f&&f.write();return r.write(t.from(u))}(e,r,s);case"unsubscribe":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.unsubscriptions,l=s.properties;let f=0;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;f+=2;if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<c.length;e+=1){if("string"!=typeof c[e])return r.emit("error",new Error("Invalid unsubscriptions")),!1;f+=t.byteLength(c[e])+2}let p=null;if(5===i){if(p=E(r,l),!p)return!1;f+=p.length}r.write(n.UNSUBSCRIBE_HEADER[1][u?1:0][0]),b(r,f),d(r,a),null!==p&&p.write();let h=!0;for(let e=0;e<c.length;e++)h=_(r,c[e]);return h}(e,r,s);case"unsuback":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,u=s.dup?n.DUP_MASK:0,c=s.granted,l=s.properties,f=s.cmd;let p=2;if("number"!=typeof a)return r.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof c||!c.length)return r.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return r.emit("error",new Error("Invalid qos vector")),!1;p+=1}}let h=null;if(5===i){if(h=T(r,l,o,p),!h)return!1;p+=h.length}r.write(n.ACKS[f][0][u][0]),b(r,p),d(r,a),null!==h&&h.write();5===i&&r.write(t.from(c));return!0}(e,r,s);case"pingreq":case"pingresp":return function(e,t,r){return t.write(n.EMPTY[e.cmd])}(e,r);case"disconnect":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0,l=null;if(5===i){if(l=T(r,u,o,c),!l)return!1;c+=l.length}r.write(t.from([n.codes.disconnect<<4])),b(r,c),5===i&&r.write(t.from([a]));null!==l&&l.write();return!0}(e,r,s);case"auth":return function(e,r,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,u=s.properties;let c=5===i?1:0;5!==i&&r.emit("error",new Error("Invalid mqtt version for auth packet"));const l=T(r,u,o,c);if(!l)return!1;c+=l.length,r.write(t.from([n.codes.auth<<4])),b(r,c),r.write(t.from([a])),null!==l&&l.write();return!0}(e,r,s);default:return r.emit("error",new Error("Unknown command")),!1}}function g(e){e.uncork()}Object.defineProperty(y,"cacheNumbers",{get:()=>d===k,set(e){e?(c&&0!==Object.keys(c).length||(m=!0),d=k):(m=!1,d=S)}});const v={};function b(e,t){if(t>n.VARBYTEINT_MAX)return e.emit("error",new Error("Invalid variable byte integer: "+t)),!1;let r=v[t];return r||(r=p(t),t<16384&&(v[t]=r)),u("writeVarByteInt: writing to stream: %o",r),e.write(r)}function _(e,r){const n=t.byteLength(r);return d(e,n),u("writeString: %s",r),e.write(r,"utf8")}function w(e,t,r){_(e,t),_(e,r)}function k(e,t){return u("writeNumberCached: number: %d",t),u("writeNumberCached: %o",c[t]),e.write(c[t])}function S(e,t){const r=l(t);return u("writeNumberGenerated: %o",r),e.write(r)}function x(e,t){"string"==typeof t?_(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function E(e,r){if("object"!=typeof r||null!=r.length)return{length:1,write(){I(e,{},0)}};let o=0;function i(r,o){let i=0;switch(n.propertiesTypes[r]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+t.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=1+t.byteLength(p(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=3+t.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${r}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce((e,r)=>{const n=o[r];return Array.isArray(n)?e+=n.reduce((e,n)=>e+=3+t.byteLength(r.toString())+2+t.byteLength(n.toString()),0):e+=3+t.byteLength(r.toString())+2+t.byteLength(o[r].toString()),e},0);break;default:return e.emit("error",new Error(`Invalid property ${r}: ${o}`)),!1}return i}if(r)for(const e in r){let t=0,n=0;const s=r[e];if(Array.isArray(s))for(let r=0;r<s.length;r++){if(n=i(e,s[r]),!n)return!1;t+=n}else{if(n=i(e,s),!n)return!1;t=n}if(!t)return!1;o+=t}return{length:t.byteLength(p(o))+o,write(){I(e,r,o)}}}function T(e,t,r,n){const o=["reasonString","userProperties"],i=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=E(e,t);if(i)for(;n+s.length>i;){const r=o.shift();if(!r||!t[r])return!1;delete t[r],s=E(e,t)}return s}function A(e,r,o){switch(n.propertiesTypes[r]){case"byte":e.write(t.from([n.properties[r]])),e.write(t.from([+o]));break;case"int8":e.write(t.from([n.properties[r]])),e.write(t.from([o]));break;case"binary":e.write(t.from([n.properties[r]])),x(e,o);break;case"int16":e.write(t.from([n.properties[r]])),d(e,o);break;case"int32":e.write(t.from([n.properties[r]])),function(e,t){const r=h(t);u("write4ByteNumber: %o",r),e.write(r)}(e,o);break;case"var":e.write(t.from([n.properties[r]])),b(e,o);break;case"string":e.write(t.from([n.properties[r]])),_(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach(i=>{const s=o[i];Array.isArray(s)?s.forEach(o=>{e.write(t.from([n.properties[r]])),w(e,i.toString(),o.toString())}):(e.write(t.from([n.properties[r]])),w(e,i.toString(),s.toString()))});break;default:return e.emit("error",new Error(`Invalid property ${r} value: ${o}`)),!1}}function I(e,t,r){b(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const n=t[r];if(Array.isArray(n))for(let t=0;t<n.length;t++)A(e,r,n[t]);else A(e,r,n)}}function C(e){return e?e instanceof t?e.length:t.byteLength(e):0}function P(e){return"string"==typeof e||e instanceof t}e.exports=y}).call(this,r(8).Buffer)},function(e,t,r){"use strict";var n=r(45),o=r(111),i=r(31),s=r(19),a=n("%Map%",!0),u=o("Map.prototype.get",!0),c=o("Map.prototype.set",!0),l=o("Map.prototype.has",!0),f=o("Map.prototype.delete",!0),p=o("Map.prototype.size",!0);e.exports=!!a&&function(){var e,t={assert:function(e){if(!t.has(e))throw new s("Side channel does not contain "+i(e))},delete:function(t){if(e){var r=f(e,t);return 0===p(e)&&(e=void 0),r}return!1},get:function(t){if(e)return u(e,t)},has:function(t){return!!e&&l(e,t)},set:function(t,r){e||(e=new a),c(e,t,r)}};return t}},function(e,t,r){"use strict";e.exports=Object},function(e,t,r){"use strict";var n=r(284);if(n)try{n([],"length")}catch(e){n=null}e.exports=n},function(e,t,r){"use strict";e.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(e,t,r){"use strict";var n=r(105);e.exports=n.getPrototypeOf||null},function(e,t,r){"use strict";var n=r(32),o=r(19),i=r(46),s=r(291);e.exports=function(e){if(e.length<1||"function"!=typeof e[0])throw new o("a function is required");return s(n,i,e)}},function(e,t,r){"use strict";e.exports=Function.prototype.apply},function(e,t,r){"use strict";var n=r(45),o=r(109),i=o([n("%String.prototype.indexOf%")]);e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&i(e,".prototype.")>-1?o([r]):r}},function(e,t,r){"use strict";var n=r(47),o=Object.prototype.hasOwnProperty,i=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var r=t&&t.plainObjects?{__proto__:null}:{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var o=t[n],s=o.obj[o.prop],a=Object.keys(s),u=0;u<a.length;++u){var c=a[u],l=s[c];"object"==typeof l&&null!==l&&-1===r.indexOf(l)&&(t.push({obj:s,prop:c}),r.push(l))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(i(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,o,i){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===r)return escape(a).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var u="",c=0;c<a.length;c+=1024){for(var l=a.length>=1024?a.slice(c,c+1024):a,f=[],p=0;p<l.length;++p){var h=l.charCodeAt(p);45===h||46===h||95===h||126===h||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||i===n.RFC1738&&(40===h||41===h)?f[f.length]=l.charAt(p):h<128?f[f.length]=s[h]:h<2048?f[f.length]=s[192|h>>6]+s[128|63&h]:h<55296||h>=57344?f[f.length]=s[224|h>>12]+s[128|h>>6&63]+s[128|63&h]:(p+=1,h=65536+((1023&h)<<10|1023&l.charCodeAt(p)),f[f.length]=s[240|h>>18]+s[128|h>>12&63]+s[128|h>>6&63]+s[128|63&h])}u+=f.join("")}return u},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(i(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r&&"function"!=typeof r){if(i(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!o.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var s=t;return i(t)&&!i(r)&&(s=a(t,n)),i(t)&&i(r)?(r.forEach((function(r,i){if(o.call(t,i)){var s=t[i];s&&"object"==typeof s&&r&&"object"==typeof r?t[i]=e(s,r,n):t.push(r)}else t[i]=r})),t):Object.keys(r).reduce((function(t,i){var s=r[i];return o.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),s)}}},function(e,t,r){"use strict";var n=r(296),o=r(16)("mqttjs:tcp");e.exports=function(e,t){var r,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",r=t.port,i=t.hostname,o("port %d and host %s",r,i),n.createConnection(r,i)}},function(e,t,r){"use strict";(function(t){var n,o,i,s=r(15).Transform,a=r(49);e.exports=function(e,r){if(r.hostname=r.hostname||r.host,!r.hostname)throw new Error("Could not determine host. Specify host manually.");var u="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(r);var c=function(e,t){var r="wxs"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(r,e);n=wx.connectSocket({url:c,protocols:[u]}),o=function(){var e=new s;return e._write=function(e,t,r){n.send({data:e.buffer,success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){n.close({success:function(){e()}})},e}(),(i=a.obj())._destroy=function(e,t){n.close({success:function(){t&&t(e)}})};var l=i.destroy;return i.destroy=function(){i.destroy=l;var e=this;setTimeout((function(){n.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),n.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),n.onMessage((function(e){var r=e.data;r=r instanceof ArrayBuffer?t.from(r):t.from(r,"utf8"),o.push(r)})),n.onClose((function(){i.end(),i.destroy()})),n.onError((function(e){i.destroy(new Error(e.errMsg))})),i}}).call(this,r(8).Buffer)},function(e,t,r){"use strict";(function(t){var n,o,i,s=r(15).Transform,a=r(49),u=!1;e.exports=function(e,r){if(r.hostname=r.hostname||r.host,!r.hostname)throw new Error("Could not determine host. Specify host manually.");var c="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(r);var l=function(e,t){var r="alis"===e.protocol?"wss":"ws",n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}(r,e);return(n=r.my).connectSocket({url:l,protocols:c}),o=function(){var e=new s;return e._write=function(e,t,r){n.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){n.closeSocket({success:function(){e()}})},e}(),i=a.obj(),u||(u=!0,n.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),n.onSocketMessage((function(e){if("string"==typeof e.data){var r=t.from(e.data,"base64");o.push(r)}else{var n=new FileReader;n.addEventListener("load",(function(){var e=n.result;e=e instanceof ArrayBuffer?t.from(e):t.from(e,"utf8"),o.push(e)})),n.readAsArrayBuffer(e.data)}})),n.onSocketClose((function(){i.end(),i.destroy()})),n.onSocketError((function(e){i.destroy(e)}))),i}}).call(this,r(8).Buffer)},function(e,t,r){"use strict";(function(t,n){const o=r(302),i=r(16)("mqttjs:ws"),s=r(49),a=r(15).Transform;let u=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const c=void 0!==t&&"browser"===t.title||"function"==typeof r;function l(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(e){let t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),c||"wss"!==e.protocol||u.forEach((function(r){e.hasOwnProperty(r)&&!e.wsOptions.hasOwnProperty(r)&&(t.wsOptions[r]=e[r])})),t}e.exports=c?function(e,t){let r;i("browserStreamBuilder");const o=function(e){let t=f(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t).browserBufferSize||524288,u=t.browserBufferTimeout||1e3,c=!t.objectMode;let p=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let n=l(t,e),o=new WebSocket(n,[r]);return o.binaryType="arraybuffer",o}(e,t),h=function(e,t,r){let n=new a({objectModeMode:e.objectMode});return n._write=t,n._flush=r,n}(t,(function e(t,r,i){p.bufferedAmount>o&&setTimeout(e,u,t,r,i);c&&"string"==typeof t&&(t=n.from(t,"utf8"));try{p.send(t)}catch(e){return i(e)}i()}),(function(e){p.close(),e()}));t.objectMode||(h._writev=b),h.on("close",()=>{p.close()});const d=void 0!==p.addEventListener;function m(){r.setReadable(h),r.setWritable(h),r.emit("connect")}function y(){r.end(),r.destroy()}function g(e){r.destroy(e)}function v(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),h.push(t)}function b(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}return p.readyState===p.OPEN?r=h:(r=r=s(void 0,void 0,t),t.objectMode||(r._writev=b),d?p.addEventListener("open",m):p.onopen=m),r.socket=p,d?(p.addEventListener("close",y),p.addEventListener("error",g),p.addEventListener("message",v)):(p.onclose=y,p.onerror=g,p.onmessage=v),r}:function(e,t){i("streamBuilder");let r=f(t);const n=l(r,e);let s=function(e,t,r){i("createWebSocket"),i("protocol: "+r.protocolId+" "+r.protocolVersion);const n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+n),new o(t,[n],r.wsOptions)}(0,n,r),a=o.createWebSocketStream(s,r.wsOptions);return a.url=n,s.on("close",()=>{a.destroy()}),a}}).call(this,r(9),r(8).Buffer)},function(e,t){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){(function(t){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,p=Math.min,h=function(){return c.Date.now()};function d(e,t,r){var n,o,i,s,a,u,c=0,l=!1,d=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var r=n,i=o;return n=o=void 0,c=t,s=e.apply(i,r)}function b(e){return c=e,a=setTimeout(w,t),l?v(e):s}function _(e){var r=e-u;return void 0===u||r>=t||r<0||d&&e-c>=i}function w(){var e=h();if(_(e))return k(e);a=setTimeout(w,function(e){var r=t-(e-u);return d?p(r,i-(e-c)):r}(e))}function k(e){return a=void 0,g&&n?v(e):(n=o=void 0,s)}function S(){var e=h(),r=_(e);if(n=arguments,o=this,u=e,r){if(void 0===a)return b(u);if(d)return a=setTimeout(w,t),v(u)}return void 0===a&&(a=setTimeout(w,t)),s}return t=y(t)||0,m(r)&&(l=!!r.leading,i=(d="maxWait"in r)?f(y(r.maxWait)||0,t):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(h())},S}function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(e))return NaN;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var a=o.test(e);return a||i.test(e)?s(e.slice(2),a?2:8):n.test(e)?NaN:+e}e.exports=function(e,t,r){var n=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return m(r)&&(n="leading"in r?!!r.leading:n,o="trailing"in r?!!r.trailing:o),d(e,t,{leading:n,maxWait:t,trailing:o})}}).call(this,r(10))},function(e,t,r){var n=r(234),o=r(235),i=r(56),s=r(236);e.exports=function(e,t){return n(e)||o(e,t)||i(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";(function(t){var n=r(237),o=r(94),i=r(262),s=r(43),a=r(16)("mqttjs"),u={};function c(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var r=i.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=s(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!u[t.protocol]){var o=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,t){return(!o||t%2!=0)&&"function"==typeof u[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);var c=new n((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),u[t.protocol](e,t)}),t);return c.on("error",(function(){})),c}void 0!==t&&"browser"!==t.title||"function"!=typeof r?(u.mqtt=r(113),u.tcp=r(113),u.ssl=r(48),u.tls=r(48),u.mqtts=r(48)):(u.wx=r(114),u.wxs=r(114),u.ali=r(115),u.alis=r(115)),u.ws=r(116),u.wss=r(116),e.exports=c,e.exports.connect=c,e.exports.MqttClient=n,e.exports.Store=o}).call(this,r(9))},function(e,t,r){(function(t){var r=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),l=Object.prototype.toString,f=Math.max,p=Math.min,h=function(){return c.Date.now()};function d(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(e))return NaN;if(d(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=d(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var a=o.test(e);return a||i.test(e)?s(e.slice(2),a?2:8):n.test(e)?NaN:+e}e.exports=function(e,t,r){var n,o,i,s,a,u,c=0,l=!1,y=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var r=n,i=o;return n=o=void 0,c=t,s=e.apply(i,r)}function b(e){return c=e,a=setTimeout(w,t),l?v(e):s}function _(e){var r=e-u;return void 0===u||r>=t||r<0||y&&e-c>=i}function w(){var e=h();if(_(e))return k(e);a=setTimeout(w,function(e){var r=t-(e-u);return y?p(r,i-(e-c)):r}(e))}function k(e){return a=void 0,g&&n?v(e):(n=o=void 0,s)}function S(){var e=h(),r=_(e);if(n=arguments,o=this,u=e,r){if(void 0===a)return b(u);if(y)return a=setTimeout(w,t),v(u)}return void 0===a&&(a=setTimeout(w,t)),s}return t=m(t)||0,d(r)&&(l=!!r.leading,i=(y="maxWait"in r)?f(m(r.maxWait)||0,t):i,g="trailing"in r?!!r.trailing:g),S.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=u=o=a=void 0},S.flush=function(){return void 0===a?s:k(h())},S}}).call(this,r(10))},function(e){e.exports=JSON.parse('{"name":"qiscus-sdk-core","version":"2.13.1","description":"Qiscus Web SDK Core","license":"MIT","main":"lib/index.js","browser":"dist/qiscus-sdk-core.min.js","unpkg":"dist/qiscus-sdk-core.min.js","files":["lib","dist"],"scripts":{"build":"npm-run-all --parallel build:node build:web build:web:dev","build:dev":"npm-run-all --parallel build:node build:web:dev","build:dev:watch":"npm-run-all --parallel build:web:watch serve","build:node":"babel -d lib src","build:node:watch":"babel -w -d lib src","build:web":"webpack --env.production --env.target=web","build:web:dev":"webpack --env.development --env.target=web","build:web:watch":"webpack --env.development --env.target=web --watch","dev":"webpack --env.development --progress --colors --watch","watch":"npm-run-all build:web:watch build:node:watch","test":"mocha --require @babel/register --colors \'test/**/*test.js\'","test:watch":"npm run test -- -w","clean":"rimraf dist lib","preversion":"npm-run-all clean build","prepublishOnly":"npm-run-all clean build","serve":"http-server -p 1234 -c-1 dist","dev:serve":"run-p serve watch","release:patch":"np patch --any-branch --yolo"},"devDependencies":{"@babel/cli":"^7.10.5","@babel/core":"^7.11.4","@babel/plugin-proposal-class-properties":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.0","@babel/polyfill":"^7.10.4","@babel/preset-env":"^7.11.0","@babel/register":"^7.10.5","@commitlint/cli":"^8.3.5","@commitlint/config-conventional":"^8.3.4","babel-eslint":"^8.2.6","babel-loader":"^8.0.6","babel-plugin-add-module-exports":"^1.0.2","babel-plugin-date-fns":"^0.1.0","chai":"^4.2.0","chai-spies":"^1.0.0","eslint":"5.0.0","eslint-config-standard":"^12.0.0","eslint-loader":"^2.2.1","eslint-plugin-import":"^2.22.0","eslint-plugin-node":"^8.0.1","eslint-plugin-promise":"^4.2.1","eslint-plugin-standard":"^4.0.1","http-server":"^0.12.3","mocha":"^5.2.0","np":"^8.0.4","npm-run-all":"^4.1.5","rimraf":"^2.7.1","serve":"^12.0.0","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"dependencies":{"@babel/runtime":"^7.11.2","date-fns":"^1.30.1","is_js":"^0.9.0","lodash.debounce":"^4.0.8","lodash.throttle":"^4.1.1","mitt":"^1.2.0","mqtt":"~4.2.6","superagent":"^3.8.3"},"babel":{"presets":[["@babel/preset-env",{"modules":"auto"}]],"plugins":["@babel/plugin-transform-runtime","@babel/plugin-proposal-class-properties","babel-plugin-add-module-exports"]},"prettier":{"semi":false,"singleQuote":true,"trailingComma":"es5"},"engines":{"node":"16.15.1"},"packageManager":"pnpm@8.15.9"}')},function(e,t,r){e.exports=r(303)},function(e,t,r){var n=r(55);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(26).default;function o(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e.exports=o=function(){return r},e.exports.__esModule=!0,e.exports.default=e.exports;var t,r={},i=Object.prototype,s=i.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",f=u.toStringTag||"@@toStringTag";function p(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,i=Object.create(o.prototype),s=new R(n||[]);return a(i,"_invoke",{value:I(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=h;var m="suspendedStart",y="executing",g="completed",v={};function b(){}function _(){}function w(){}var k={};p(k,c,(function(){return this}));var S=Object.getPrototypeOf,x=S&&S(S(M([])));x&&x!==i&&s.call(x,c)&&(k=x);var E=w.prototype=b.prototype=Object.create(k);function T(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(o,i,a,u){var c=d(e[o],e,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&s.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}})}function I(e,r,n){var o=m;return function(i,s){if(o===y)throw Error("Generator is already running");if(o===g){if("throw"===i)throw s;return{value:t,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=C(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===m)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var c=d(e,r,n);if("normal"===c.type){if(o=n.done?g:"suspendedYield",c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=g,n.method="throw",n.arg=c.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var s=i.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(s.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(n(e)+" is not iterable")}return _.prototype=w,a(E,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:_,configurable:!0}),_.displayName=p(w,f,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,p(e,f,"GeneratorFunction")),e.prototype=Object.create(E),e},r.awrap=function(e){return{__await:e}},T(A.prototype),p(A.prototype,l,(function(){return this})),r.AsyncIterator=A,r.async=function(e,t,n,o,i){void 0===i&&(i=Promise);var s=new A(h(e,t,n,o),i);return r.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},T(E),p(E,f,"Generator"),p(E,c,(function(){return this})),p(E,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=M,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&s.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=s.call(i,"catchLoc"),c=s.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},r}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}},function(e,t,r){"use strict";var n=r(58);function o(e){if(e)return function(e){for(var t in o.prototype)e[t]=o.prototype[t];return e}(e)}e.exports=o,o.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},o.prototype.parse=function(e){return this._parser=e,this},o.prototype.responseType=function(e){return this._responseType=e,this},o.prototype.serialize=function(e){return this._serializer=e,this},o.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},o.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];o.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~i.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},o.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},o.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.end((function(r,n){r?t(r):e(n)}))}))}return this._fullfilledPromise.then(e,t)},o.prototype.catch=function(e){return this.then(void 0,e)},o.prototype.use=function(e){return e(this),this},o.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},o.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},o.prototype.get=function(e){return this._header[e.toLowerCase()]},o.prototype.getHeader=o.prototype.get,o.prototype.set=function(e,t){if(n(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},o.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},o.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var o in t)this.field(e,t[o]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},o.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},o.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},o.prototype.withCredentials=function(e){return null==e&&(e=!0),this._withCredentials=e,this},o.prototype.redirects=function(e){return this._maxRedirects=e,this},o.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},o.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},o.prototype.send=function(e){var t=n(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&n(this._data))for(var o in e)this._data[o]=e[o];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||r||this.type("json"),this},o.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},o.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},o.prototype._appendQueryString=function(){console.trace("Unsupported")},o.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},o.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))}},function(e,t,r){"use strict";var n=r(132);function o(e){if(e)return function(e){for(var t in o.prototype)e[t]=o.prototype[t];return e}(e)}e.exports=o,o.prototype.get=function(e){return this.header[e.toLowerCase()]},o.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=n.type(t);var r=n.params(t);for(var o in r)this[o]=r[o];this.links={};try{e.link&&(this.links=n.parseLinks(e.link))}catch(e){}},o.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},function(e,t,r){"use strict";t.type=function(e){return e.split(/ *; */).shift()},t.params=function(e){return e.split(/ *; */).reduce((function(e,t){var r=t.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(e[n]=o),e}),{})},t.parseLinks=function(e){return e.split(/ *, */).reduce((function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e}),{})},t.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},function(e,t){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach((function(e){r.prototype[e]=function(){return this._defaults.push({fn:e,arguments:arguments}),this}})),r.prototype._setDefaults=function(e){this._defaults.forEach((function(t){e[t.fn].apply(e,t.arguments)}))},e.exports=r},function(e,t){e.exports=function(e){var t=new Date(e.getTime()),r=t.getTimezoneOffset();return t.setSeconds(0,0),6e4*r+t.getTime()%6e4}},function(e,t){e.exports=function(){var e={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};return{localize:function(t,r,n){var o;return n=n||{},o="string"==typeof e[t]?e[t]:1===r?e[t].one:e[t].other.replace("{{count}}",r),n.addSuffix?n.comparison>0?"in "+o:o+" ago":o}}}},function(e,t,r){var n=r(137);e.exports=function(){var e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],t=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Su","Mo","Tu","We","Th","Fr","Sa"],o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=["AM","PM"],a=["am","pm"],u=["a.m.","p.m."],c={MMM:function(t){return e[t.getMonth()]},MMMM:function(e){return t[e.getMonth()]},dd:function(e){return r[e.getDay()]},ddd:function(e){return o[e.getDay()]},dddd:function(e){return i[e.getDay()]},A:function(e){return e.getHours()/12>=1?s[1]:s[0]},a:function(e){return e.getHours()/12>=1?a[1]:a[0]},aa:function(e){return e.getHours()/12>=1?u[1]:u[0]}};return["M","D","DDD","d","Q","W"].forEach((function(e){c[e+"o"]=function(t,r){return function(e){var t=e%100;if(t>20||t<10)switch(t%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"}(r[e](t))}})),{formatters:c,formattingTokensRegExp:n(c)}}},function(e,t){var r=["M","MM","Q","D","DD","DDD","DDDD","d","E","W","WW","YY","YYYY","GG","GGGG","H","HH","h","hh","m","mm","s","ss","S","SS","SSS","Z","ZZ","X","x"];e.exports=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);var o=r.concat(t).sort().reverse();return new RegExp("(\\[[^\\[]*\\])|(\\\\)?("+o.join("|")+"|.)","g")}},function(e,t,r){var n=r(0);e.exports=function(e,t,r,o){var i=n(e).getTime(),s=n(t).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");return i<u&&a<s}},function(e,t,r){var n=r(0);e.exports=function(e,t){if(!(t instanceof Array))throw new TypeError(toString.call(t)+" is not an instance of Array");var r,o,i=n(e).getTime();return t.forEach((function(e,t){var s=n(e),a=Math.abs(i-s.getTime());(void 0===r||a<o)&&(r=t,o=a)})),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){if(!(t instanceof Array))throw new TypeError(toString.call(t)+" is not an instance of Array");var r,o,i=n(e).getTime();return t.forEach((function(e){var t=n(e),s=Math.abs(i-t.getTime());(void 0===r||s<o)&&(r=t,o=s)})),r}},function(e,t,r){var n=r(13);e.exports=function(e,t){var r=n(e),o=n(t),i=r.getTime()-6e4*r.getTimezoneOffset(),s=o.getTime()-6e4*o.getTimezoneOffset();return Math.round((i-s)/6048e5)}},function(e,t,r){var n=r(72),o=r(0);e.exports=function(e,t){var r=o(e),i=o(t);return 4*(r.getFullYear()-i.getFullYear())+(n(r)-n(i))}},function(e,t,r){var n=r(28);e.exports=function(e,t,r){var o=n(e,r),i=n(t,r),s=o.getTime()-6e4*o.getTimezoneOffset(),a=i.getTime()-6e4*i.getTimezoneOffset();return Math.round((s-a)/6048e5)}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/36e5;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(0),o=r(71),i=r(22),s=r(75);e.exports=function(e,t){var r=n(e),a=n(t),u=i(r,a),c=Math.abs(o(r,a));return r=s(r,u*c),u*(c-(i(r,a)===-u))}},function(e,t,r){var n=r(29);e.exports=function(e,t){var r=n(e,t)/6e4;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(38);e.exports=function(e,t){var r=n(e,t)/3;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(74);e.exports=function(e,t){var r=n(e,t)/7;return r>0?Math.floor(r):Math.ceil(r)}},function(e,t,r){var n=r(0),o=r(73),i=r(22);e.exports=function(e,t){var r=n(e),s=n(t),a=i(r,s),u=Math.abs(o(r,s));return r.setFullYear(r.getFullYear()-a*u),a*(u-(i(r,s)===-a))}},function(e,t,r){var n=r(36),o=r(0),i=r(37),s=r(35);e.exports=function(e,t,r){var a=r||{},u=n(e,t),c=a.locale,l=s.distanceInWords.localize;c&&c.distanceInWords&&c.distanceInWords.localize&&(l=c.distanceInWords.localize);var f,p,h,d={addSuffix:Boolean(a.addSuffix),comparison:u};u>0?(f=o(e),p=o(t)):(f=o(t),p=o(e));var m=Math[a.partialMethod?String(a.partialMethod):"floor"],y=i(p,f),g=p.getTimezoneOffset()-f.getTimezoneOffset(),v=m(y/60)-g;if("s"===(h=a.unit?String(a.unit):v<1?"s":v<60?"m":v<1440?"h":v<43200?"d":v<525600?"M":"Y"))return l("xSeconds",y,d);if("m"===h)return l("xMinutes",v,d);if("h"===h)return l("xHours",m(v/60),d);if("d"===h)return l("xDays",m(v/1440),d);if("M"===h)return l("xMonths",m(v/43200),d);if("Y"===h)return l("xYears",m(v/525600),d);throw new Error("Unknown unit: "+h)}},function(e,t,r){var n=r(0);e.exports=function(e,t,r){var o=n(e),i=void 0!==r?r:1,s=n(t).getTime();if(o.getTime()>s)throw new Error("The first date cannot be after the second date");var a=[],u=o;for(u.setHours(0,0,0,0);u.getTime()<=s;)a.push(n(u)),u.setDate(u.getDate()+i);return a}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setMinutes(59,59,999),t}},function(e,t,r){var n=r(76);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(14),o=r(13);e.exports=function(e){var t=n(e),r=new Date(0);r.setFullYear(t+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setMilliseconds(i.getMilliseconds()-1),i}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setSeconds(59,999),t}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3+3;return t.setMonth(o,0),t.setHours(23,59,59,999),t}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setMilliseconds(999),t}},function(e,t,r){var n=r(41);e.exports=function(){return n(new Date)}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getFullYear();return t.setFullYear(r+1,0,0),t.setHours(23,59,59,999),t}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(23,59,59,999),o}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getDate()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getDay()}},function(e,t,r){var n=r(78);e.exports=function(e){return n(e)?366:365}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getHours()}},function(e,t,r){var n=r(21),o=r(40);e.exports=function(e){var t=n(e),r=n(o(t,60)).valueOf()-t.valueOf();return Math.round(r/6048e5)}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getMilliseconds()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getMinutes()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getMonth()}},function(e,t,r){var n=r(0);e.exports=function(e,t,r,o){var i=n(e).getTime(),s=n(t).getTime(),a=n(r).getTime(),u=n(o).getTime();if(i>s||a>u)throw new Error("The start of the range cannot be after the end of the range");if(!(i<u&&a<s))return 0;var c=(u>s?s:u)-(a<i?i:a);return Math.ceil(c/864e5)}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getSeconds()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getFullYear()}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()>o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()<o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){return 1===n(e).getDate()}},function(e,t,r){var n=r(0);e.exports=function(e){return 5===n(e).getDay()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getTime()>(new Date).getTime()}},function(e,t,r){var n=r(0),o=r(41),i=r(77);e.exports=function(e){var t=n(e);return o(t).getTime()===i(t).getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){return 1===n(e).getDay()}},function(e,t,r){var n=r(0);e.exports=function(e){return n(e).getTime()<(new Date).getTime()}},function(e,t,r){var n=r(12);e.exports=function(e,t){var r=n(e),o=n(t);return r.getTime()===o.getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){return 6===n(e).getDay()}},function(e,t,r){var n=r(0);e.exports=function(e){return 0===n(e).getDay()}},function(e,t,r){var n=r(80);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(82);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(83);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(84);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(86);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(87);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(89);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(42);e.exports=function(e,t){return n(new Date,e,t)}},function(e,t,r){var n=r(91);e.exports=function(e){return n(new Date,e)}},function(e,t,r){var n=r(0);e.exports=function(e){return 4===n(e).getDay()}},function(e,t,r){var n=r(12);e.exports=function(e){return n(e).getTime()===n(new Date).getTime()}},function(e,t,r){var n=r(12);e.exports=function(e){var t=new Date;return t.setDate(t.getDate()+1),n(e).getTime()===n(t).getTime()}},function(e,t,r){var n=r(0);e.exports=function(e){return 2===n(e).getDay()}},function(e,t,r){var n=r(0);e.exports=function(e){return 3===n(e).getDay()}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e).getDay();return 0===t||6===t}},function(e,t,r){var n=r(0);e.exports=function(e,t,r){var o=n(e).getTime(),i=n(t).getTime(),s=n(r).getTime();if(i>s)throw new Error("The start of the range cannot be after the end of the range");return o>=i&&o<=s}},function(e,t,r){var n=r(12);e.exports=function(e){var t=new Date;return t.setDate(t.getDate()-1),n(e).getTime()===n(t).getTime()}},function(e,t,r){var n=r(92);e.exports=function(e){return n(e,{weekStartsOn:1})}},function(e,t,r){var n=r(14),o=r(13);e.exports=function(e){var t=n(e),r=new Date(0);r.setFullYear(t+1,0,4),r.setHours(0,0,0,0);var i=o(r);return i.setDate(i.getDate()-1),i}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getMonth(),o=r-r%3+3;return t.setMonth(o,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e),r=t.getFullYear();return t.setFullYear(r+1,0,0),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(0);e.exports=function(){var e=Array.prototype.slice.call(arguments),t=e.map((function(e){return n(e)})),r=Math.max.apply(null,t);return new Date(r)}},function(e,t,r){var n=r(0);e.exports=function(){var e=Array.prototype.slice.call(arguments),t=e.map((function(e){return n(e)})),r=Math.min.apply(null,t);return new Date(r)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setDate(o),r}},function(e,t,r){var n=r(0),o=r(23);e.exports=function(e,t,r){var i=r&&Number(r.weekStartsOn)||0,s=n(e),a=Number(t),u=s.getDay();return o(s,((a%7+7)%7<i?7:0)+a-u)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMonth(0),r.setDate(o),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setHours(o),r}},function(e,t,r){var n=r(0),o=r(23),i=r(79);e.exports=function(e,t){var r=n(e),s=Number(t),a=i(r);return o(r,s-a)}},function(e,t,r){var n=r(0),o=r(34);e.exports=function(e,t){var r=n(e),i=Number(t),s=o(r)-i;return r.setDate(r.getDate()-7*s),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMilliseconds(o),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setMinutes(o),r}},function(e,t,r){var n=r(0),o=r(93);e.exports=function(e,t){var r=n(e),i=Number(t)-(Math.floor(r.getMonth()/3)+1);return o(r,r.getMonth()+3*i)}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setSeconds(o),r}},function(e,t,r){var n=r(0);e.exports=function(e,t){var r=n(e),o=Number(t);return r.setFullYear(o),r}},function(e,t,r){var n=r(0);e.exports=function(e){var t=n(e);return t.setDate(1),t.setHours(0,0,0,0),t}},function(e,t,r){var n=r(12);e.exports=function(){return n(new Date)}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n+1),o.setHours(0,0,0,0),o}},function(e,t){e.exports=function(){var e=new Date,t=e.getFullYear(),r=e.getMonth(),n=e.getDate(),o=new Date(0);return o.setFullYear(t,r,n-1),o.setHours(0,0,0,0),o}},function(e,t,r){var n=r(23);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(64);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(24);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(67);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(30);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(68);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(69);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(40);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t,r){var n=r(70);e.exports=function(e,t){var r=Number(t);return n(e,-r)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,s,a=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";(function(t,n){var o=r(25).EventEmitter,i=r(94),s=r(250),a=r(15).Writable,u=r(11),c=r(260),l=r(261),f=r(43),p=r(16)("mqttjs:client"),h=t?t.nextTick:function(e){setTimeout(e,0)},d=n.setImmediate||function(e){h(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},y=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],g={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function v(e,t,r){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var n=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",n),!n&&r?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(p("sendPacket :: invoking cb"),r())}function b(e){e&&(p("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function _(e,t,r,n){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return r&&r(o);n(),v(e,t,r)}))}function w(e){p("nop ::",e)}function k(e,t){var r,n=this;if(!(this instanceof k))return new k(e,t);for(r in this.options=t||{},m)void 0===this.options[r]?this.options[r]=m[r]:this.options[r]=t[r];p("MqttClient :: options.protocol",t.protocol),p("MqttClient :: options.protocolVersion",t.protocolVersion),p("MqttClient :: options.username",t.username),p("MqttClient :: options.keepalive",t.keepalive),p("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),p("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),p("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("connect",(function(){var e=this.queue;p("connect :: sending queued packets"),function t(){var r,o=e.shift();p("deliver :: entry %o",o),o&&(r=o.packet,p("deliver :: call _sendPacket for %o",r),n._sendPacket(r,(function(e){o.cb&&o.cb(e),t()})))}()})),this.on("close",(function(){p("close :: connected set to `false`"),this.connected=!1,p("close :: clearing connackTimer"),clearTimeout(this.connackTimer),p("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}u(k,o),k.prototype._setupStream=function(){var e,t=this,r=new a,n=s.parser(this.options),o=null,i=[];function u(){if(i.length)h(c);else{var e=o;o=null,e()}}function c(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,u);else{p("work :: no packets in queue");var r=o;o=null,p("work :: done flag is %s",!!r),r&&r()}}if(p("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),p("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),n.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),r._write=function(e,t,r){o=r,p("writable stream :: parsing buffer"),n.parse(e),c()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(r),this.stream.on("error",(function(e){p("streamErrorHandler :: error",e.message),y.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):w(e)})),this.stream.on("close",(function(){var e;p("(%s)stream :: on close",t.options.clientId),(e=t.outgoing)&&(p("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])}))),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",v(this,e),n.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end(()=>this.emit("error",new Error("Packet has no Authentication Method"))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket)v(this,f({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},k.prototype._handlePacket=function(e,t){var r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(p("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},k.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},k.prototype.publish=function(e,t,r,n){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;"function"==typeof r&&(n=r,r=null);if(r=f({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(n))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:this._nextId(),dup:r.dup},5===i.protocolVersion&&(o.properties=r.properties,(!i.properties&&o.properties&&o.properties.topicAlias||r.properties&&i.properties&&(r.properties.topicAlias&&i.properties.topicAliasMaximum&&r.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&r.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",r.qos),r.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:n||w},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,r.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,n,r.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,n,r.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),r=0;r<arguments.length;r++)t[r]=arguments[r];var n,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||w,u=t.pop(),c=this,h=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(u=a,a=w),null!==(n=l.validateTopics(i)))return d(a,new Error("Invalid topic "+n)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===h&&(m.nl=!1,m.rap=!1,m.rh=0),u=f(m,u),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!c._resubscribeTopics.hasOwnProperty(e)||c._resubscribeTopics[e].qos<u.qos||s){var t={topic:e,qos:u.qos};5===h&&(t.nl=u.nl,t.rap=u.rap,t.rh=u.rh,t.properties=u.properties),p("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),o.push(t)}})):Object.keys(i).forEach((function(e){if(p("subscribe: object topic %s",e),!c._resubscribeTopics.hasOwnProperty(e)||c._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===h&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=u.properties),p("subscribe: pushing `%s` to subs list",t),o.push(t)}})),e={cmd:"subscribe",subscriptions:o,qos:1,retain:!1,dup:!1,messageId:this._nextId()},u.properties&&(e.properties=u.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var y=[];o.forEach((function(e){if(c.options.reconnectPeriod>0){var t={qos:e.qos};5===h&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),c._resubscribeTopics[e.topic]=t,y.push(e.topic)}})),c.messageIdToTopic[e.messageId]=y}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var r=t.granted,n=0;n<r.length;n+=1)o[n].qos=r[n];a(e,o)}},p("subscribe :: call _sendPacket"),this._sendPacket(e),this}a(null,[])},k.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,r=new Array(arguments.length),n=0;n<arguments.length;n++)r[n]=arguments[n];var o=r.shift(),i=r.pop()||w,s=r.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=w),this._checkDisconnecting(i)||("string"==typeof o?e.unsubscriptions=[o]:Array.isArray(o)&&(e.unsubscriptions=o),this.options.resubscribe&&e.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof s&&s.properties&&(e.properties=s.properties),this.outgoing[e.messageId]={volatile:!0,cb:i},p("unsubscribe: call _sendPacket"),this._sendPacket(e)),this},k.prototype.end=function(e,t,r){var n=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=!0,n.incomingStore.close((function(e){n.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),n.emit("end"),r){let n=e||t;p("end :: closeStores: invoking callback with args"),r(n)}}))})),n._deferredReconnect&&n._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,e),n._cleanUp(e,()=>{p("end :: finish :: calling process.nextTick on closeStores"),h(o.bind(n))},t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||w,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=w))),"object"!=typeof t&&(r=t,t=null),p("end :: cb? %s",!!r),r=r||w,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",n.options.clientId),i()),this)},k.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},k.prototype.reconnect=function(e){p("client reconnect");var t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},k.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end(()=>{this._setupStream()}),p("client already connected. disconnecting first.")):(p("_reconnect: calling _setupStream"),this._setupStream())},k.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){p("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")},k.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},k.prototype._cleanUp=function(e,t){var r=arguments[2];if(t&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),p("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&b(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var n=f({cmd:"disconnect"},r);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(n,d.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},k.prototype._sendPacket=function(e,t,r){if(p("_sendPacket :: (%s) :: start",this.options.clientId),r=r||w,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void _(this,e,t,r);default:return void v(this,e,t)}switch(e.qos){case 2:case 1:_(this,e,t,r);break;case 0:default:v(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,r){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),r=r||w,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},k.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=c((function(){e._checkPing()}),1e3*this.options.keepalive))},k.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},k.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},k.prototype._handlePingresp=function(){this.pingResp=!0},k.prototype._handleConnack=function(e){p("_handleConnack");var t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){var n=new Error("Connection refused: "+g[r]);n.code=r,this.emit("error",n)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:w;var r=e.topic.toString(),n=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,u=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(r,n,e,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===u.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:n},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(r,n,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===u.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t);break;default:p("_handlePublish: unknown QoS. Doing nothing.")}},k.prototype.handleMessage=function(e,t){t()},k.prototype._handleAck=function(e){var t,r=e.messageId,n=e.cmd,o=null,i=this.outgoing[r]?this.outgoing[r].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",n),n){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+g[a])).code=a,i(t,e)),delete this.outgoing[r],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:r};var u=e.reasonCode;u&&u>0&&16!==u?((t=new Error("Publish error: "+g[u])).code=u,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[r];for(var c=0;c<e.granted.length;c++)if(0!=(128&e.granted[c])){var l=this.messageIdToTopic[r];l&&l.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[r],i(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else p("_handleAck :: Server sent an ack in error. Ignoring.")},k.prototype._handlePubrel=function(e,t){p("handling pubrel packet"),t=void 0!==t?t:w;var r=e.messageId,n=this,o={cmd:"pubcomp",messageId:r};n.incomingStore.get(e,(function(e,r){e?n._sendPacket(o,t):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,(function(e){if(e)return t(e);n.incomingStore.del(r,w),n._sendPacket(o,t)})))}))},k.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},k.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},k.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},k.prototype._resubscribe=function(e){p("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){p("_resubscribe: protocolVersion 5");for(var r=0;r<t.length;r++){var n={};n[t[r]]=this._resubscribeTopics[t[r]],n.resubscribe=!0,this.subscribe(n,{properties:n[t[r]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},k.prototype._onConnect=function(e){if(this.disconnected)this.emit("connect",e);else{var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0,function r(){var n=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){n.destroy(),n=null,o()}t.once("close",i),n.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),n.on("end",(function(){var n=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){n=!1;break}n?(o(),t.removeListener("close",i),t.emit("connect",e)):r()})),function e(){if(n){t._storeProcessing=!0;var r,o=n.read(1);o?t._packetIdsDuringStoreProcessing[o.messageId]?e():t.disconnecting||t.reconnectTimer?n.destroy&&n.destroy():(r=t.outgoing[o.messageId]?t.outgoing[o.messageId].cb:null,t.outgoing[o.messageId]={volatile:!1,cb:function(t,n){r&&r(t,n),e()}},t._packetIdsDuringStoreProcessing[o.messageId]=!0,t._sendPacket(o)):n.once("readable",e)}}()}()}},e.exports=k}).call(this,r(9),r(10))},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),l=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(l(e,s,s+16383>a?a:s+16383));1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var o,i,s=[],a=t;a<r;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(e,t){
|
|
13
13
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
14
|
-
|
|
14
|
+
t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?o-1:0,p=r?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=p,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=c}return(h?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,o),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;e[r+h]=255&a,h+=d,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[r+h]=255&s,h+=d,s/=256,c-=8);e[r+h-d]|=128*m}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var u=r(8).Buffer,c=r(243).inspect,l=c&&c.custom||"inspect";e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,r,n;return t=e,(r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t,r,n,o=u.allocUnsafe(e>>>0),i=this.head,s=0;i;)t=i.data,r=o,n=s,u.prototype.copy.call(t,r,n),s+=i.data.length,i=i.next;return o}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?n+=o:n+=o.slice(0,e),0==(e-=i)){i===o.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(i));break}++n}return this.length-=n,t}},{key:l,value:function(e,t){return c(this,o(o({},t),{},{depth:0,customInspect:!1}))}}])&&s(t.prototype,r),n&&s(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()},function(e,t){},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(10))},function(e,t,r){
|
|
15
15
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
16
|
-
var n=r(8),o=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return o(t,e,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return o(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=o(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return o(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},function(t,e,r){"use strict";(function(e){var n;function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i=r(44),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),h=Symbol("stream");function p(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[h].read();null!==r&&(t[l]=null,t[s]=null,t[a]=null,e(p(r,!1)))}}function m(t){e.nextTick(d,t)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((o(n={get stream(){return this[h]},next:function(){var t=this,r=this[u];if(null!==r)return Promise.reject(r);if(this[c])return Promise.resolve(p(void 0,!0));if(this[h].destroyed)return new Promise((function(r,n){e.nextTick((function(){t[u]?n(t[u]):r(p(void 0,!0))}))}));var n,o=this[l];if(o)n=new Promise(function(t,e){return function(r,n){t.then((function(){e[c]?r(p(void 0,!0)):e[f](r,n)}),n)}}(o,this));else{var i=this[h].read();if(null!==i)return Promise.resolve(p(i,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[h].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),y);t.exports=function(t){var e,r=Object.create(g,(o(e={},h,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:t._readableState.endEmitted,writable:!0}),o(e,f,{value:function(t,e){var n=r[h].read();n?(r[l]=null,r[s]=null,r[a]=null,t(p(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[l]=null,i(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[a];return null!==e&&(r[l]=null,r[s]=null,r[a]=null,e(t)),void(r[u]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[a]=null,n(p(void 0,!0))),r[c]=!0})),t.on("readable",m.bind(null,r)),r}}).call(this,r(9))},function(t,e){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(t,e,r){"use strict";t.exports=o;var n=r(101);function o(t){if(!(this instanceof o))return new o(t);n.call(this,t)}r(12)(o,n),o.prototype._transform=function(t,e,r){r(null,t)}},function(t,e,r){"use strict";var n;var o=r(17).codes,i=o.ERR_MISSING_ARGS,s=o.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t,e,o,i){i=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(i);var a=!1;t.on("close",(function(){a=!0})),void 0===n&&(n=r(44)),n(t,{readable:e,writable:o},(function(t){if(t)return i(t);a=!0,i()}));var u=!1;return function(e){if(!a&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void i(e||new s("pipe"))}}function c(t){t()}function l(t,e){return t.pipe(e)}function f(t){return t.length?"function"!=typeof t[t.length-1]?a:t.pop():a}t.exports=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n,o=f(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new i("streams");var s=e.map((function(t,r){var i=r<e.length-1;return u(t,i,r>0,(function(t){n||(n=t),t&&s.forEach(c),i||(s.forEach(c),o(n))}))}));return e.reduce(l)}},function(t,e,r){"use strict";function n(t){if(!(this instanceof n))return new n(t);this.aliasToTopic={},this.max=t}n.prototype.put=function(t,e){return!(0===e||e>this.max)&&(this.aliasToTopic[e]=t,this.length=Object.keys(this.aliasToTopic).length,!0)},n.prototype.getTopicByAlias=function(t){return this.aliasToTopic[t]},n.prototype.clear=function(){this.aliasToTopic={}},t.exports=n},function(t,e,r){"use strict";const n=r(253),o=r(256).NumberAllocator;function i(t){if(!(this instanceof i))return new i(t);t>0&&(this.aliasToTopic=new n({max:t}),this.topicToAlias={},this.numberAllocator=new o(1,t),this.max=t,this.length=0)}i.prototype.put=function(t,e){if(0===e||e>this.max)return!1;const r=this.aliasToTopic.get(e);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(e,t),this.topicToAlias[t]=e,this.numberAllocator.use(e),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(t){return this.aliasToTopic.get(t)},i.prototype.getAliasByTopic=function(t){const e=this.topicToAlias[t];return void 0!==e&&this.aliasToTopic.get(e),e},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){const t=this.numberAllocator.firstVacant();return t||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i},function(t,e,r){"use strict";const n=r(254),o=Symbol("max"),i=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),u=Symbol("maxAge"),c=Symbol("dispose"),l=Symbol("noDisposeOnSet"),f=Symbol("lruList"),h=Symbol("cache"),p=Symbol("updateAgeOnGet"),d=()=>1;const m=(t,e,r)=>{const n=t[h].get(e);if(n){const e=n.value;if(y(t,e)){if(v(t,n),!t[a])return}else r&&(t[p]&&(n.value.now=Date.now()),t[f].unshiftNode(n));return e.value}},y=(t,e)=>{if(!e||!e.maxAge&&!t[u])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[u]&&r>t[u]},g=t=>{if(t[i]>t[o])for(let e=t[f].tail;t[i]>t[o]&&null!==e;){const r=e.prev;v(t,e),e=r}},v=(t,e)=>{if(e){const r=e.value;t[c]&&t[c](r.key,r.value),t[i]-=r.length,t[h].delete(r.key),t[f].removeNode(e)}};class b{constructor(t,e,r,n,o){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=o||0}}const _=(t,e,r,n)=>{let o=r.value;y(t,o)&&(v(t,r),t[a]||(o=void 0)),o&&e.call(n,o.value,o.key,t)};t.exports=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[o]=t.max||1/0;const e=t.length||d;if(this[s]="function"!=typeof e?d:e,this[a]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[u]=t.maxAge||0,this[c]=t.dispose,this[l]=t.noDisposeOnSet||!1,this[p]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[o]=t||1/0,g(this)}get max(){return this[o]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[u]=t,g(this)}get maxAge(){return this[u]}set lengthCalculator(t){"function"!=typeof t&&(t=d),t!==this[s]&&(this[s]=t,this[i]=0,this[f].forEach(t=>{t.length=this[s](t.value,t.key),this[i]+=t.length})),g(this)}get lengthCalculator(){return this[s]}get length(){return this[i]}get itemCount(){return this[f].length}rforEach(t,e){e=e||this;for(let r=this[f].tail;null!==r;){const n=r.prev;_(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[f].head;null!==r;){const n=r.next;_(this,t,r,e),r=n}}keys(){return this[f].toArray().map(t=>t.key)}values(){return this[f].toArray().map(t=>t.value)}reset(){this[c]&&this[f]&&this[f].length&&this[f].forEach(t=>this[c](t.key,t.value)),this[h]=new Map,this[f]=new n,this[i]=0}dump(){return this[f].map(t=>!y(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)}).toArray().filter(t=>t)}dumpLru(){return this[f]}set(t,e,r){if((r=r||this[u])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,a=this[s](e,t);if(this[h].has(t)){if(a>this[o])return v(this,this[h].get(t)),!1;const s=this[h].get(t).value;return this[c]&&(this[l]||this[c](t,s.value)),s.now=n,s.maxAge=r,s.value=e,this[i]+=a-s.length,s.length=a,this.get(t),g(this),!0}const p=new b(t,e,a,n,r);return p.length>this[o]?(this[c]&&this[c](t,e),!1):(this[i]+=p.length,this[f].unshift(p),this[h].set(t,this[f].head),g(this),!0)}has(t){if(!this[h].has(t))return!1;const e=this[h].get(t).value;return!y(this,e)}get(t){return m(this,t,!0)}peek(t){return m(this,t,!1)}pop(){const t=this[f].tail;return t?(v(this,t),t.value):null}del(t){v(this,this[h].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],o=n.e||0;if(0===o)this.set(n.k,n.v);else{const t=o-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[h].forEach((t,e)=>m(this,e,!1))}}},function(t,e,r){"use strict";function n(t){var e=this;if(e instanceof n||(e=new n),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,o=arguments.length;r<o;r++)e.push(arguments[r]);return e}function o(t,e,r){var n=e===t.head?new a(r,null,e,t):new a(r,e,e.next,t);return null===n.next&&(t.tail=n),null===n.prev&&(t.head=n),t.length++,n}function i(t,e){t.tail=new a(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function s(t,e){t.head=new a(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function a(t,e,r,n){if(!(this instanceof a))return new a(t,e,r,n);this.list=n,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}t.exports=n,n.Node=a,n.create=n,n.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e},n.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},n.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},n.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)i(this,arguments[t]);return this.length},n.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)s(this,arguments[t]);return this.length},n.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},n.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},n.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,n=0;null!==r;n++)t.call(e,r.value,n,this),r=r.next},n.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,n=this.length-1;null!==r;n--)t.call(e,r.value,n,this),r=r.prev},n.prototype.get=function(t){for(var e=0,r=this.head;null!==r&&e<t;e++)r=r.next;if(e===t&&null!==r)return r.value},n.prototype.getReverse=function(t){for(var e=0,r=this.tail;null!==r&&e<t;e++)r=r.prev;if(e===t&&null!==r)return r.value},n.prototype.map=function(t,e){e=e||this;for(var r=new n,o=this.head;null!==o;)r.push(t.call(e,o.value,this)),o=o.next;return r},n.prototype.mapReverse=function(t,e){e=e||this;for(var r=new n,o=this.tail;null!==o;)r.push(t.call(e,o.value,this)),o=o.prev;return r},n.prototype.reduce=function(t,e){var r,n=this.head;if(arguments.length>1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var o=0;null!==n;o++)r=t(r,n.value,o),n=n.next;return r},n.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var o=this.length-1;null!==n;o--)r=t(r,n.value,o),n=n.prev;return r},n.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},n.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},n.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var o=0,i=this.head;null!==i&&o<t;o++)i=i.next;for(;null!==i&&o<e;o++,i=i.next)r.push(i.value);return r},n.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var o=this.length,i=this.tail;null!==i&&o>e;o--)i=i.prev;for(;null!==i&&o>t;o--,i=i.prev)r.push(i.value);return r},n.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,i=this.head;null!==i&&n<t;n++)i=i.next;var s=[];for(n=0;i&&n<e;n++)s.push(i.value),i=this.removeNode(i);null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev);for(n=0;n<r.length;n++)i=o(this,i,r[n]);return s},n.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=e,this.tail=t,this};try{r(255)(n)}catch(t){}},function(t,e,r){"use strict";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},function(t,e,r){const n=r(257);t.exports.NumberAllocator=n},function(t,e,r){"use strict";const n=r(313).OrderedSet,o=r(11)("number-allocator:trace"),i=r(11)("number-allocator:error");function s(t,e){this.low=t,this.high=e}function a(t,e){if(!(this instanceof a))return new a(t,e);this.min=t,this.max=e,this.ss=new n([],(t,e)=>t.compare(e)),o("Create"),this.clear()}s.prototype.equals=function(t){return this.low===t.low&&this.high===t.high},s.prototype.compare=function(t){return this.low<t.low&&this.high<t.low?-1:t.low<this.low&&t.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return o("alloc():empty"),null;const t=this.ss.begin(),e=t.pointer.low,r=t.pointer.high,n=e;return n+1<=r?this.ss.updateKeyByIterator(t,new s(e+1,r)):this.ss.eraseElementByPos(0),o("alloc():"+n),n},a.prototype.use=function(t){const e=new s(t,t),r=this.ss.lowerBound(e);if(!r.equals(this.ss.end())){const n=r.pointer.low,i=r.pointer.high;return r.pointer.equals(e)?(this.ss.eraseElementByIterator(r),o("use():"+t),!0):!(n>t)&&(n===t?(this.ss.updateKeyByIterator(r,new s(n+1,i)),o("use():"+t),!0):i===t?(this.ss.updateKeyByIterator(r,new s(n,i-1)),o("use():"+t),!0):(this.ss.updateKeyByIterator(r,new s(t+1,i)),this.ss.insert(new s(n,t-1)),o("use():"+t),!0))}return o("use():failed"),!1},a.prototype.free=function(t){if(t<this.min||t>this.max)return void i("free():"+t+" is out of range");const e=new s(t,t),r=this.ss.upperBound(e);if(r.equals(this.ss.end())){if(r.equals(this.ss.begin()))return void this.ss.insert(e);r.pre();const n=r.pointer.high;r.pointer.high+1===t?this.ss.updateKeyByIterator(r,new s(n,t)):this.ss.insert(e)}else if(r.equals(this.ss.begin()))if(t+1===r.pointer.low){const e=r.pointer.high;this.ss.updateKeyByIterator(r,new s(t,e))}else this.ss.insert(e);else{const n=r.pointer.low,o=r.pointer.high;r.pre();const i=r.pointer.low;r.pointer.high+1===t?t+1===n?(this.ss.eraseElementByIterator(r),this.ss.updateKeyByIterator(r,new s(i,o))):this.ss.updateKeyByIterator(r,new s(i,t)):t+1===n?(this.ss.eraseElementByIterator(r.next()),this.ss.insert(new s(t,o))):this.ss.insert(e)}o("free():"+t)},a.prototype.clear=function(){o("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const t of this.ss)console.log(t)},t.exports=a},function(t,e,r){t.exports=function(t){function e(t){let r,o,i,s=null;function a(...t){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";s++;const i=e.formatters[o];if("function"==typeof i){const e=t[s];r=i.call(n,e),t.splice(s,1),s--}return r}),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==e.namespaces&&(o=e.namespaces,i=e.enabled(t)),i),set:t=>{s=t}}),"function"==typeof e.init&&e.init(a),a}function n(t,r){const n=e(this.namespace+(void 0===r?":":r)+t);return n.log=this.log,n}function o(t,e){let r=0,n=0,o=-1,i=0;for(;r<t.length;)if(n<e.length&&(e[n]===t[r]||"*"===e[n]))"*"===e[n]?(o=n,i=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,i++,r=i}for(;n<e.length&&"*"===e[n];)n++;return n===e.length}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names,...e.skips.map(t=>"-"+t)].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];const r=("string"==typeof t?t:"").trim().replace(" ",",").split(",").filter(Boolean);for(const t of r)"-"===t[0]?e.skips.push(t.slice(1)):e.names.push(t)},e.enabled=function(t){for(const r of e.skips)if(o(t,r))return!1;for(const r of e.names)if(o(t,r))return!0;return!1},e.humanize=r(259),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(r=>{e[r]=t[r]}),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return e.colors[Math.abs(r)%e.colors.length]},e.enable(e.load()),e}},function(t,e){var r=1e3,n=6e4,o=60*n,i=24*o;function s(t,e,r,n){var o=e>=1.5*r;return Math.round(t/r)+" "+n+(o?"s":"")}t.exports=function(t,e){e=e||{};var a=typeof t;if("string"===a&&t.length>0)return function(t){if((t=String(t)).length>100)return;var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return;var s=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(t);if("number"===a&&isFinite(t))return e.long?function(t){var e=Math.abs(t);if(e>=i)return s(t,e,i,"day");if(e>=o)return s(t,e,o,"hour");if(e>=n)return s(t,e,n,"minute");if(e>=r)return s(t,e,r,"second");return t+" ms"}(t):function(t){var e=Math.abs(t);if(e>=i)return Math.round(t/i)+"d";if(e>=o)return Math.round(t/o)+"h";if(e>=n)return Math.round(t/n)+"m";if(e>=r)return Math.round(t/r)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},function(t,e,r){e.parser=r(261).parser,e.generate=r(265),e.writeToStream=r(103)},function(t,e,r){const n=r(262),o=r(25),i=r(264),s=r(102),a=r(11)("mqtt-packet:parser");class u extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(t){return this instanceof u?(this.settings=t||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new u).parser(t)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=n(),this._stateCounter=0}parse(t){for(this.error&&this._resetState(),this._list.append(t),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const t=this._list.readUInt8(0);return this.packet.cmd=s.types[t>>s.CMD_SHIFT],this.packet.retain=0!=(t&s.RETAIN_MASK),this.packet.qos=t>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(t&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const t=this._parseVarByteNum(!0);return t&&(this.packet.length=t.value,this._list.consume(t.bytes)),a("_parseLength %d",t.value),!!t}_parsePayload(){a("_parsePayload: payload %O",this._list);let t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}t=!0}return a("_parsePayload complete result: %s",t),t}_parseConnect(){let t,e,r,n;a("_parseConnect");const o={},i=this.packet,u=this._parseString();if(null===u)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==u&&"MQIsdp"!==u)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=u,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(i.properties=t)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(i.clientId=c,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(i.will.properties=t)}if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=t,a("_parseConnect: packet.will.topic: %s",i.will.topic),e=this._parseBuffer(),null===e)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=e,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));i.username=n,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));i.password=r}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const t=this.packet;if(this._list.length<1)return null;if(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?t.reasonCode=this._list.readUInt8(this._pos++):t.reasonCode=0;else{if(this._list.length<2)return null;t.returnCode=this._list.readUInt8(this._pos++)}if(-1===t.returnCode||-1===t.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));if(!(t.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}t.payload=this._list.slice(this._pos,t.length),a("_parsePublish: payload from buffer list: %o",t.payload)}}_parseSubscribe(){a("_parseSubscribe");const t=this.packet;let e,r,n,o,i,u,c;if(1!==t.qos)return this._emitError(new Error("Wrong subscribe header"));if(t.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<t.length;){if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=t.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,u=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:e,qos:n},5===this.settings.protocolVersion?(c.nl=u,c.rap=i,c.rh=o):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",c),t.subscriptions.push(c)}}}_parseSuback(){a("_parseSuback");const t=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const t=this.packet;if(t.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<t.length;){const e=this._parseString();if(null===e)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",e),t.unsubscriptions.push(e)}}}_parseUnsuback(){a("_parseUnsuback");const t=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const e=this._parseProperties();for(Object.getOwnPropertyNames(e).length&&(t.properties=e),t.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const t=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(t.length>2?(t.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",t.reasonCode)):t.reasonCode=0,t.length>3)){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}return!0}_parseDisconnect(){const t=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?t.reasonCode=this._parseByte():t.reasonCode=0;const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const t=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));t.reasonCode=this._parseByte();const e=this._parseProperties();return Object.getOwnPropertyNames(e).length&&(t.properties=e),a("_parseAuth: result: true"),!0}_parseMessageId(){const t=this.packet;return t.messageId=this._parseNum(),null===t.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",t.messageId),!0)}_parseString(t){const e=this._parseNum(),r=e+this._pos;if(-1===e||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=e,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const t=this._parseNum(),e=t+this._pos;if(-1===t||e>this._list.length||e>this.packet.length)return null;const r=this._list.slice(this._pos,e);return this._pos+=t,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const t=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",t),t}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const t=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",t),t}_parseVarByteNum(t){a("_parseVarByteNum");let e,r=0,n=1,o=0,i=!1;const u=this._pos?this._pos:0;for(;r<4&&u+r<this._list.length;){if(e=this._list.readUInt8(u+r++),o+=n*(e&s.VARBYTEINT_MASK),n*=128,0==(e&s.VARBYTEINT_FIN_MASK)){i=!0;break}if(this._list.length<=r)break}return!i&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=r),i=!!i&&(t?{bytes:r,value:o}:o),a("_parseVarByteNum: result: %o",i),i}_parseByte(){let t;return this._pos<this._list.length&&(t=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",t),t}_parseByType(t){switch(a("_parseByType: type: %s",t),t){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const t=this._parseVarByteNum(),e=this._pos+t,r={};for(;this._pos<e;){const t=this._parseByte();if(!t)return this._emitError(new Error("Cannot parse property code type")),!1;const e=s.propertiesCodes[t];if(!e)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==e)r[e]?(Array.isArray(r[e])||(r[e]=[r[e]]),r[e].push(this._parseByType(s.propertiesTypes[e]))):r[e]=this._parseByType(s.propertiesTypes[e]);else{r[e]||(r[e]=Object.create(null));const t=this._parseByType(s.propertiesTypes[e]);if(r[e][t.name])if(Array.isArray(r[e][t.name]))r[e][t.name].push(t.value);else{const n=r[e][t.name];r[e][t.name]=[n],r[e][t.name].push(t.value)}else r[e][t.name]=t.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(t){a("_emitError"),this.error=t,this.emit("error",t)}}t.exports=u},function(t,e,r){"use strict";const n=r(16).Duplex,o=r(12),i=r(263);function s(t){if(!(this instanceof s))return new s(t);if("function"==typeof t){this._callback=t;const e=function(t){this._callback&&(this._callback(t),this._callback=null)}.bind(this);this.on("pipe",(function(t){t.on("error",e)})),this.on("unpipe",(function(t){t.removeListener("error",e)})),t=null}i._init.call(this,t),n.call(this)}o(s,n),Object.assign(s.prototype,i.prototype),s.prototype._new=function(t){return new s(t)},s.prototype._write=function(t,e,r){this._appendBuffer(t),"function"==typeof r&&r()},s.prototype._read=function(t){if(!this.length)return this.push(null);t=Math.min(t,this.length),this.push(this.slice(0,t)),this.consume(t)},s.prototype.end=function(t){n.prototype.end.call(this,t),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(t,e){this._bufs.length=0,this.length=0,e(t)},s.prototype._isBufferList=function(t){return t instanceof s||t instanceof i||s.isBufferList(t)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},function(t,e,r){"use strict";const{Buffer:n}=r(8),o=Symbol.for("BufferList");function i(t){if(!(this instanceof i))return new i(t);i._init.call(this,t)}i._init=function(t){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,t&&this.append(t)},i.prototype._new=function(t){return new i(t)},i.prototype._offset=function(t){if(0===t)return[0,0];let e=0;for(let r=0;r<this._bufs.length;r++){const n=e+this._bufs[r].length;if(t<n||r===this._bufs.length-1)return[r,t-e];e=n}},i.prototype._reverseOffset=function(t){const e=t[0];let r=t[1];for(let t=0;t<e;t++)r+=this._bufs[t].length;return r},i.prototype.get=function(t){if(t>this.length||t<0)return;const e=this._offset(t);return this._bufs[e[0]][e[1]]},i.prototype.slice=function(t,e){return"number"==typeof t&&t<0&&(t+=this.length),"number"==typeof e&&e<0&&(e+=this.length),this.copy(null,0,t,e)},i.prototype.copy=function(t,e,r,o){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof o||o>this.length)&&(o=this.length),r>=this.length)return t||n.alloc(0);if(o<=0)return t||n.alloc(0);const i=!!t,s=this._offset(r),a=o-r;let u=a,c=i&&e||0,l=s[1];if(0===r&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let e=0;e<this._bufs.length;e++)this._bufs[e].copy(t,c),c+=this._bufs[e].length;return t}if(u<=this._bufs[s[0]].length-l)return i?this._bufs[s[0]].copy(t,e,l,l+u):this._bufs[s[0]].slice(l,l+u);i||(t=n.allocUnsafe(a));for(let e=s[0];e<this._bufs.length;e++){const r=this._bufs[e].length-l;if(!(u>r)){this._bufs[e].copy(t,c,l,l+u),c+=r;break}this._bufs[e].copy(t,c,l),c+=r,u-=r,l&&(l=0)}return t.length>c?t.slice(0,c):t},i.prototype.shallowSlice=function(t,e){if(t=t||0,e="number"!=typeof e?this.length:e,t<0&&(t+=this.length),e<0&&(e+=this.length),t===e)return this._new();const r=this._offset(t),n=this._offset(e),o=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,n[1]),0!==r[1]&&(o[0]=o[0].slice(r[1])),this._new(o)},i.prototype.toString=function(t,e,r){return this.slice(e,r).toString(t)},i.prototype.consume=function(t){if(t=Math.trunc(t),Number.isNaN(t)||t<=0)return this;for(;this._bufs.length;){if(!(t>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(t),this.length-=t;break}t-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const t=this._new();for(let e=0;e<this._bufs.length;e++)t.append(this._bufs[e]);return t},i.prototype.append=function(t){if(null==t)return this;if(t.buffer)this._appendBuffer(n.from(t.buffer,t.byteOffset,t.byteLength));else if(Array.isArray(t))for(let e=0;e<t.length;e++)this.append(t[e]);else if(this._isBufferList(t))for(let e=0;e<t._bufs.length;e++)this.append(t._bufs[e]);else"number"==typeof t&&(t=t.toString()),this._appendBuffer(n.from(t));return this},i.prototype._appendBuffer=function(t){this._bufs.push(t),this.length+=t.length},i.prototype.indexOf=function(t,e,r){if(void 0===r&&"string"==typeof e&&(r=e,e=void 0),"function"==typeof t||Array.isArray(t))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof t?t=n.from([t]):"string"==typeof t?t=n.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=n.from(t.buffer,t.byteOffset,t.byteLength):n.isBuffer(t)||(t=n.from(t)),e=Number(e||0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),0===t.length)return e>this.length?this.length:e;const o=this._offset(e);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const e=this._bufs[i];for(;s<e.length;){if(e.length-s>=t.length){const r=e.indexOf(t,s);if(-1!==r)return this._reverseOffset([i,r]);s=e.length-t.length+1}else{const e=this._reverseOffset([i,s]);if(this._match(e,t))return e;s++}}s=0}return-1},i.prototype._match=function(t,e){if(this.length-t<e.length)return!1;for(let r=0;r<e.length;r++)if(this.get(t+r)!==e[r])return!1;return!0},function(){const t={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const e in t)!function(e){i.prototype[e]=null===t[e]?function(t,r){return this.slice(t,t+r)[e](0,r)}:function(r=0){return this.slice(r,r+t[e])[e](0)}}(e)}(),i.prototype._isBufferList=function(t){return t instanceof i||i.isBufferList(t)},i.isBufferList=function(t){return null!=t&&t[o]},t.exports=i},function(t,e){t.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},function(t,e,r){(function(e){const n=r(103),o=r(25);class i extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(t){return this._array[this._i++]=t,!0}concat(){let t=0;const r=new Array(this._array.length),n=this._array;let o,i=0;for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?r[o]=n[o].length:r[o]=e.byteLength(n[o]),t+=r[o];const s=e.allocUnsafe(t);for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?(n[o].copy(s,i),i+=r[o]):(s.write(n[o],i),i+=r[o]);return s}}t.exports=function(t,e){const r=new i;return n(t,r,e),r.concat()}}).call(this,r(8).Buffer)},function(t,e,r){(function(e){const r={},n=e.isBuffer(e.from([1,2]).subarray(0,1));function o(t){const r=e.allocUnsafe(2);return r.writeUInt8(t>>8,0),r.writeUInt8(255&t,1),r}t.exports={cache:r,generateCache:function(){for(let t=0;t<65536;t++)r[t]=o(t)},generateNumber:o,genBufVariableByteInt:function(t){let r=0,o=0;const i=e.allocUnsafe(4);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),i.writeUInt8(r,o++)}while(t>0&&o<4);return t>0&&(o=0),n?i.subarray(0,o):i.slice(0,o)},generate4ByteBuffer:function(t){const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}}).call(this,r(8).Buffer)},function(t,e,r){"use strict";(function(e){void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,n,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,n)}));case 4:return e.nextTick((function(){t.call(null,r,n,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}}:t.exports=e}).call(this,r(9))},function(t,e,r){"use strict";function n(){if(!(this instanceof n))return new n;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}n.prototype.allocate=function(){const t=this.nextId++;return 65536===this.nextId&&(this.nextId=1),t},n.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},n.prototype.register=function(t){return!0},n.prototype.deallocate=function(t){},n.prototype.clear=function(){},t.exports=n},function(t,e,r){"use strict";function n(t,e,r){var n=this;this._callback=t,this._args=r,this._interval=setInterval(t,e,this._args),this.reschedule=function(t){t||(t=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,t,n._args)},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0)},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0}}t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;e<t.length;e++)t[e]=arguments[e+2]}return new n(arguments[0],arguments[1],t)}},function(t,e,r){"use strict";t.exports=r(271)()},function(t,e,r){"use strict";(function(e){function r(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}t.exports=function(t){if((t=t||{}).circles)return function(t){const e=[],n=[],o=new Map;if(o.set(Date,t=>new Date(t)),o.set(Map,(t,e)=>new Map(s(Array.from(t),e))),o.set(Set,(t,e)=>new Set(s(Array.from(t),e))),t.constructorHandlers)for(const e of t.constructorHandlers)o.set(e[0],e[1]);let i=null;return t.proto?function t(a){if("object"!=typeof a||null===a)return a;if(Array.isArray(a))return s(a,t);if(a.constructor!==Object&&(i=o.get(a.constructor)))return i(a,t);const u={};e.push(a),n.push(u);for(const s in a){const c=a[s];if("object"!=typeof c||null===c)u[s]=c;else if(c.constructor!==Object&&(i=o.get(c.constructor)))u[s]=i(c,t);else if(ArrayBuffer.isView(c))u[s]=r(c);else{const r=e.indexOf(c);u[s]=-1!==r?n[r]:t(c)}}return e.pop(),n.pop(),u}:function t(a){if("object"!=typeof a||null===a)return a;if(Array.isArray(a))return s(a,t);if(a.constructor!==Object&&(i=o.get(a.constructor)))return i(a,t);const u={};e.push(a),n.push(u);for(const s in a){if(!1===Object.hasOwnProperty.call(a,s))continue;const c=a[s];if("object"!=typeof c||null===c)u[s]=c;else if(c.constructor!==Object&&(i=o.get(c.constructor)))u[s]=i(c,t);else if(ArrayBuffer.isView(c))u[s]=r(c);else{const r=e.indexOf(c);u[s]=-1!==r?n[r]:t(c)}}return e.pop(),n.pop(),u};function s(t,s){const a=Object.keys(t),u=new Array(a.length);for(let c=0;c<a.length;c++){const l=a[c],f=t[l];if("object"!=typeof f||null===f)u[l]=f;else if(f.constructor!==Object&&(i=o.get(f.constructor)))u[l]=i(f,s);else if(ArrayBuffer.isView(f))u[l]=r(f);else{const t=e.indexOf(f);u[l]=-1!==t?n[t]:s(f)}}return u}}(t);const e=new Map;if(e.set(Date,t=>new Date(t)),e.set(Map,(t,e)=>new Map(o(Array.from(t),e))),e.set(Set,(t,e)=>new Set(o(Array.from(t),e))),t.constructorHandlers)for(const r of t.constructorHandlers)e.set(r[0],r[1]);let n=null;return t.proto?function t(i){if("object"!=typeof i||null===i)return i;if(Array.isArray(i))return o(i,t);if(i.constructor!==Object&&(n=e.get(i.constructor)))return n(i,t);const s={};for(const o in i){const a=i[o];"object"!=typeof a||null===a?s[o]=a:a.constructor!==Object&&(n=e.get(a.constructor))?s[o]=n(a,t):ArrayBuffer.isView(a)?s[o]=r(a):s[o]=t(a)}return s}:function t(i){if("object"!=typeof i||null===i)return i;if(Array.isArray(i))return o(i,t);if(i.constructor!==Object&&(n=e.get(i.constructor)))return n(i,t);const s={};for(const o in i){if(!1===Object.hasOwnProperty.call(i,o))continue;const a=i[o];"object"!=typeof a||null===a?s[o]=a:a.constructor!==Object&&(n=e.get(a.constructor))?s[o]=n(a,t):ArrayBuffer.isView(a)?s[o]=r(a):s[o]=t(a)}return s};function o(t,o){const i=Object.keys(t),s=new Array(i.length);for(let a=0;a<i.length;a++){const u=i[a],c=t[u];"object"!=typeof c||null===c?s[u]=c:c.constructor!==Object&&(n=e.get(c.constructor))?s[u]=n(c,o):ArrayBuffer.isView(c)?s[u]=r(c):s[u]=o(c)}return s}}}).call(this,r(8).Buffer)},function(t,e,r){"use strict";function n(t){const e=t.split("/");for(let t=0;t<e.length;t++)if("+"!==e[t]){if("#"===e[t])return t===e.length-1;if(-1!==e[t].indexOf("+")||-1!==e[t].indexOf("#"))return!1}return!0}t.exports={validateTopics:function(t){if(0===t.length)return"empty_topic_list";for(let e=0;e<t.length;e++)if(!n(t[e]))return t[e];return null}}},function(t,e,r){"use strict";var n=r(274);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var i=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(u),l=["%","/","?",";","#"].concat(c),f=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(276);function v(t,e,r){if(t&&"object"==typeof t&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),s=-1!==o&&o<t.indexOf("#")?"?":"#",u=t.split(s);u[0]=u[0].replace(/\\/g,"/");var v=t=u.join(s);if(v=v.trim(),!r&&1===t.split("#").length){var b=a.exec(v);if(b)return this.path=v,this.href=v,this.pathname=b[1],b[2]?(this.search=b[2],this.query=e?g.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var _=i.exec(v);if(_){var w=(_=_[0]).toLowerCase();this.protocol=w,v=v.substr(_.length)}if(r||_||v.match(/^\/\/[^@/]+@[^@/]+/)){var k="//"===v.substr(0,2);!k||_&&m[_]||(v=v.substr(2),this.slashes=!0)}if(!m[_]&&(k||_&&!y[_])){for(var S,x,E=-1,A=0;A<f.length;A++){-1!==(T=v.indexOf(f[A]))&&(-1===E||T<E)&&(E=T)}-1!==(x=-1===E?v.lastIndexOf("@"):v.lastIndexOf("@",E))&&(S=v.slice(0,x),v=v.slice(x+1),this.auth=decodeURIComponent(S)),E=-1;for(A=0;A<l.length;A++){var T;-1!==(T=v.indexOf(l[A]))&&(-1===E||T<E)&&(E=T)}-1===E&&(E=v.length),this.host=v.slice(0,E),v=v.slice(E),this.parseHost(),this.hostname=this.hostname||"";var P="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!P)for(var I=this.hostname.split(/\./),O=(A=0,I.length);A<O;A++){var M=I[A];if(M&&!M.match(h)){for(var C="",R=0,D=M.length;R<D;R++)M.charCodeAt(R)>127?C+="x":C+=M[R];if(!C.match(h)){var j=I.slice(0,A),L=I.slice(A+1),N=M.match(p);N&&(j.push(N[1]),L.unshift(N[2])),L.length&&(v="/"+L.join(".")+v),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),P||(this.hostname=n.toASCII(this.hostname));var B=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+B,this.href+=this.host,P&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!d[w])for(A=0,O=c.length;A<O;A++){var U=c[A];if(-1!==v.indexOf(U)){var q=encodeURIComponent(U);q===U&&(q=escape(U)),v=v.split(U).join(q)}}var H=v.indexOf("#");-1!==H&&(this.hash=v.substr(H),v=v.slice(0,H));var W=v.indexOf("?");if(-1!==W?(this.search=v.substr(W),this.query=v.substr(W+1),e&&(this.query=g.parse(this.query)),v=v.slice(0,W)):e&&(this.search="",this.query={}),v&&(this.pathname=v),y[w]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){B=this.pathname||"";var K=this.search||"";this.path=B+K}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,i="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(i=g.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||y[e])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),e+o+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(s=s.replace("#","%23"))+n},o.prototype.resolve=function(t){return this.resolveObject(v(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if("string"==typeof t){var e=new o;e.parse(t,!1,!0),t=e}for(var r=new o,n=Object.keys(this),i=0;i<n.length;i++){var s=n[i];r[s]=this[s]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),u=0;u<a.length;u++){var c=a[u];"protocol"!==c&&(r[c]=t[c])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!y[t.protocol]){for(var l=Object.keys(t),f=0;f<l.length;f++){var h=l[f];r[h]=t[h]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||m[t.protocol])r.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var d=r.pathname||"",g=r.search||"";r.path=d+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),b=t.host||t.pathname&&"/"===t.pathname.charAt(0),_=b||v||r.host&&t.pathname,w=_,k=r.pathname&&r.pathname.split("/")||[],S=(p=t.pathname&&t.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(S&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),_=_&&(""===p[0]||""===k[0])),b)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),r.search=t.search,r.query=t.query;else if(null!=t.search){if(S)r.host=k.shift(),r.hostname=r.host,(P=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=P.shift(),r.hostname=P.shift(),r.host=r.hostname);return r.search=t.search,r.query=t.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=k.slice(-1)[0],E=(r.host||t.host||k.length>1)&&("."===x||".."===x)||""===x,A=0,T=k.length;T>=0;T--)"."===(x=k[T])?k.splice(T,1):".."===x?(k.splice(T,1),A++):A&&(k.splice(T,1),A--);if(!_&&!w)for(;A--;A)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var P,I=""===k[0]||k[0]&&"/"===k[0].charAt(0);S&&(r.hostname=I?"":k.length?k.shift():"",r.host=r.hostname,(P=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=P.shift(),r.hostname=P.shift(),r.host=r.hostname));return(_=_||r.host&&k.length)&&!I&&k.unshift(""),k.length>0?r.pathname=k.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=s.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},e.parse=v,e.resolve=function(t,e){return v(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?v(t,!1,!0).resolveObject(e):e},e.format=function(t){return"string"==typeof t&&(t=v(t)),t instanceof o?t.format():o.prototype.format.call(t)},e.Url=o},function(t,e,r){(function(t,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,u=2147483647,c=/^xn--/,l=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,d=String.fromCharCode;function m(t){throw new RangeError(h[t])}function y(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function g(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+y((t=t.replace(f,".")).split("."),e).join(".")}function v(t){for(var e,r,n=[],o=0,i=t.length;o<i;)(e=t.charCodeAt(o++))>=55296&&e<=56319&&o<i?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function b(t){return y(t,(function(t){var e="";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=d(t)})).join("")}function _(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function w(t,e,r){var n=0;for(t=r?p(t/700):t>>1,t+=p(t/e);t>455;n+=36)t=p(t/35);return p(n+36*t/(t+38))}function k(t){var e,r,n,o,i,s,a,c,l,f,h,d=[],y=t.length,g=0,v=128,_=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&m("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;o<y;){for(i=g,s=1,a=36;o>=y&&m("invalid-input"),((c=(h=t.charCodeAt(o++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((u-g)/s))&&m("overflow"),g+=c*s,!(c<(l=a<=_?1:a>=_+26?26:a-_));a+=36)s>p(u/(f=36-l))&&m("overflow"),s*=f;_=w(g-i,e=d.length+1,0==i),p(g/e)>u-v&&m("overflow"),v+=p(g/e),g%=e,d.splice(g++,0,v)}return b(d)}function S(t){var e,r,n,o,i,s,a,c,l,f,h,y,g,b,k,S=[];for(y=(t=v(t)).length,e=128,r=0,i=72,s=0;s<y;++s)(h=t[s])<128&&S.push(d(h));for(n=o=S.length,o&&S.push("-");n<y;){for(a=u,s=0;s<y;++s)(h=t[s])>=e&&h<a&&(a=h);for(a-e>p((u-r)/(g=n+1))&&m("overflow"),r+=(a-e)*g,e=a,s=0;s<y;++s)if((h=t[s])<e&&++r>u&&m("overflow"),h==e){for(c=r,l=36;!(c<(f=l<=i?1:l>=i+26?26:l-i));l+=36)k=c-f,b=36-f,S.push(d(_(f+k%b,0))),c=p(k/b);S.push(d(_(c,0))),i=w(r,g,n==o),r=0,++n}++r,++e}return S.join("")}a={version:"1.4.1",ucs2:{decode:v,encode:b},decode:k,encode:S,toASCII:function(t){return g(t,(function(t){return l.test(t)?"xn--"+S(t):t}))},toUnicode:function(t){return g(t,(function(t){return c.test(t)?k(t.slice(4).toLowerCase()):t}))}},void 0===(o=function(){return a}.call(e,r,e,t))||(t.exports=o)}()}).call(this,r(275)(t),r(10))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";var n=r(277),o=r(306),i=r(47);t.exports={formats:i,parse:o,stringify:n}},function(t,e,r){"use strict";var n=r(278),o=r(112),i=r(47),s=Object.prototype.hasOwnProperty,a={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},u=Array.isArray,c=Array.prototype.push,l=function(t,e){c.apply(t,u(e)?e:[e])},f=Date.prototype.toISOString,h=i.default,p={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:o.encode,encodeValuesOnly:!1,filter:void 0,format:h,formatter:i.formatters[h],indices:!1,serializeDate:function(t){return f.call(t)},skipNulls:!1,strictNullHandling:!1},d={},m=function t(e,r,i,s,a,c,f,h,m,y,g,v,b,_,w,k,S,x){for(var E,A=e,T=x,P=0,I=!1;void 0!==(T=T.get(d))&&!I;){var O=T.get(e);if(P+=1,void 0!==O){if(O===P)throw new RangeError("Cyclic object value");I=!0}void 0===T.get(d)&&(P=0)}if("function"==typeof y?A=y(r,A):A instanceof Date?A=b(A):"comma"===i&&u(A)&&(A=o.maybeMap(A,(function(t){return t instanceof Date?b(t):t}))),null===A){if(c)return m&&!k?m(r,p.encoder,S,"key",_):r;A=""}if("string"==typeof(E=A)||"number"==typeof E||"boolean"==typeof E||"symbol"==typeof E||"bigint"==typeof E||o.isBuffer(A))return m?[w(k?r:m(r,p.encoder,S,"key",_))+"="+w(m(A,p.encoder,S,"value",_))]:[w(r)+"="+w(String(A))];var M,C=[];if(void 0===A)return C;if("comma"===i&&u(A))k&&m&&(A=o.maybeMap(A,m)),M=[{value:A.length>0?A.join(",")||null:void 0}];else if(u(y))M=y;else{var R=Object.keys(A);M=g?R.sort(g):R}var D=h?String(r).replace(/\./g,"%2E"):String(r),j=s&&u(A)&&1===A.length?D+"[]":D;if(a&&u(A)&&0===A.length)return j+"[]";for(var L=0;L<M.length;++L){var N=M[L],B="object"==typeof N&&N&&void 0!==N.value?N.value:A[N];if(!f||null!==B){var F=v&&h?String(N).replace(/\./g,"%2E"):String(N),U=u(A)?"function"==typeof i?i(j,F):j:j+(v?"."+F:"["+F+"]");x.set(e,P);var q=n();q.set(d,x),l(C,t(B,U,i,s,a,c,f,h,"comma"===i&&k&&u(A)?null:m,y,g,v,b,_,w,k,S,q))}}return C};t.exports=function(t,e){var r,o=t,c=function(t){if(!t)return p;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||p.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=i.default;if(void 0!==t.format){if(!s.call(i.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n,o=i.formatters[r],c=p.filter;if(("function"==typeof t.filter||u(t.filter))&&(c=t.filter),n=t.arrayFormat in a?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":p.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===t.allowDots?!0===t.encodeDotInKeys||p.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:p.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:p.allowEmptyArrays,arrayFormat:n,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:p.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:void 0===t.delimiter?p.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:p.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:p.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:p.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:p.encodeValuesOnly,filter:c,format:r,formatter:o,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:p.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:p.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:p.strictNullHandling}}(e);"function"==typeof c.filter?o=(0,c.filter)("",o):u(c.filter)&&(r=c.filter);var f=[];if("object"!=typeof o||null===o)return"";var h=a[c.arrayFormat],d="comma"===h&&c.commaRoundTrip;r||(r=Object.keys(o)),c.sort&&r.sort(c.sort);for(var y=n(),g=0;g<r.length;++g){var v=r[g],b=o[v];c.skipNulls&&null===b||l(f,m(b,v,h,d,c.allowEmptyArrays,c.strictNullHandling,c.skipNulls,c.encodeDotInKeys,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,y))}var _=f.join(c.delimiter),w=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),_.length>0?w+_:""}},function(t,e,r){"use strict";var n=r(19),o=r(31),i=r(280),s=r(104),a=r(305)||s||i;t.exports=function(){var t,e={assert:function(t){if(!e.has(t))throw new n("Side channel does not contain "+o(t))},delete:function(e){return!!t&&t.delete(e)},get:function(e){return t&&t.get(e)},has:function(e){return!!t&&t.has(e)},set:function(e,r){t||(t=a()),t.set(e,r)}};return e}},function(t,e){},function(t,e,r){"use strict";var n=r(31),o=r(19),i=function(t,e,r){for(var n,o=t;null!=(n=o.next);o=n)if(n.key===e)return o.next=n.next,r||(n.next=t.next,t.next=n),n};t.exports=function(){var t,e={assert:function(t){if(!e.has(t))throw new o("Side channel does not contain "+n(t))},delete:function(e){var r=t&&t.next,n=function(t,e){if(t)return i(t,e,!0)}(t,e);return n&&r&&r===n&&(t=void 0),!!n},get:function(e){return function(t,e){if(t){var r=i(t,e);return r&&r.value}}(t,e)},has:function(e){return function(t,e){return!!t&&!!i(t,e)}(t,e)},set:function(e,r){t||(t={next:void 0}),function(t,e,r){var n=i(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}}(t,e,r)}};return e}},function(t,e,r){"use strict";t.exports=Error},function(t,e,r){"use strict";t.exports=EvalError},function(t,e,r){"use strict";t.exports=RangeError},function(t,e,r){"use strict";t.exports=ReferenceError},function(t,e,r){"use strict";t.exports=SyntaxError},function(t,e,r){"use strict";t.exports=URIError},function(t,e,r){"use strict";t.exports=Math.abs},function(t,e,r){"use strict";t.exports=Math.floor},function(t,e,r){"use strict";t.exports=Math.max},function(t,e,r){"use strict";t.exports=Math.min},function(t,e,r){"use strict";t.exports=Math.pow},function(t,e,r){"use strict";t.exports=Math.round},function(t,e,r){"use strict";var n=r(294);t.exports=function(t){return n(t)||0===t?t:t<0?-1:1}},function(t,e,r){"use strict";t.exports=Number.isNaN||function(t){return t!=t}},function(t,e,r){"use strict";t.exports=Object.getOwnPropertyDescriptor},function(t,e,r){"use strict";var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(t){n=!1}t.exports=n},function(t,e,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,o=r(298);t.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&o())))}},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(t,e,r){"use strict";var n=r(107),o=r(108),i=r(300);t.exports=n?function(t){return n(t)}:o?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return o(t)}:i?function(t){return i(t)}:null},function(t,e,r){"use strict";var n,o=r(109),i=r(106);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var s=!!n&&i&&i(Object.prototype,"__proto__"),a=Object,u=a.getPrototypeOf;t.exports=s&&"function"==typeof s.get?o([s.get]):"function"==typeof u&&function(t){return u(null==t?t:a(t))}},function(t,e,r){"use strict";var n="Function.prototype.bind called on incompatible ",o=Object.prototype.toString,i=Math.max,s=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var o=0;o<e.length;o+=1)r[o+t.length]=e[o];return r},a=function(t,e){for(var r=[],n=e||0,o=0;n<t.length;n+=1,o+=1)r[o]=t[n];return r},u=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};t.exports=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==o.apply(e))throw new TypeError(n+e);for(var r,c=a(arguments,1),l=function(){if(this instanceof r){var n=e.apply(this,s(c,arguments));return Object(n)===n?n:this}return e.apply(t,s(c,arguments))},f=i(0,e.length-c.length),h=[],p=0;p<f;p++)h[p]="$"+p;if(r=Function("binder","return function ("+u(h,",")+"){ return binder.apply(this,arguments); }")(l),e.prototype){var d=function(){};d.prototype=e.prototype,r.prototype=new d,d.prototype=null}return r}},function(t,e,r){"use strict";var n=r(32),o=r(110),i=r(46),s=r(303);t.exports=s||n.call(i,o)},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(t,e,r){"use strict";var n=Function.prototype.call,o=Object.prototype.hasOwnProperty,i=r(32);t.exports=i.call(n,o)},function(t,e,r){"use strict";var n=r(45),o=r(111),i=r(31),s=r(104),a=r(19),u=n("%WeakMap%",!0),c=o("WeakMap.prototype.get",!0),l=o("WeakMap.prototype.set",!0),f=o("WeakMap.prototype.has",!0),h=o("WeakMap.prototype.delete",!0);t.exports=u?function(){var t,e,r={assert:function(t){if(!r.has(t))throw new a("Side channel does not contain "+i(t))},delete:function(r){if(u&&r&&("object"==typeof r||"function"==typeof r)){if(t)return h(t,r)}else if(s&&e)return e.delete(r);return!1},get:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&t?c(t,r):e&&e.get(r)},has:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&t?f(t,r):!!e&&e.has(r)},set:function(r,n){u&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new u),l(t,r,n)):s&&(e||(e=s()),e.set(r,n))}};return r}:s},function(t,e,r){"use strict";var n=r(112),o=Object.prototype.hasOwnProperty,i=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},a=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},u=function(t,e,r){if(t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1)return t.split(",");if(e.throwOnLimitExceeded&&r>=e.arrayLimit)throw new RangeError("Array limit exceeded. Only "+e.arrayLimit+" element"+(1===e.arrayLimit?"":"s")+" allowed in an array.");return t},c=function(t,e,r,i){if(t){var s=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/g,c=r.depth>0&&/(\[[^[\]]*])/.exec(s),l=c?s.slice(0,c.index):s,f=[];if(l){if(!r.plainObjects&&o.call(Object.prototype,l)&&!r.allowPrototypes)return;f.push(l)}for(var h=0;r.depth>0&&null!==(c=a.exec(s))&&h<r.depth;){if(h+=1,!r.plainObjects&&o.call(Object.prototype,c[1].slice(1,-1))&&!r.allowPrototypes)return;f.push(c[1])}if(c){if(!0===r.strictDepth)throw new RangeError("Input depth exceeded depth option of "+r.depth+" and strictDepth is true");f.push("["+s.slice(c.index)+"]")}return function(t,e,r,o){var i=0;if(t.length>0&&"[]"===t[t.length-1]){var s=t.slice(0,-1).join("");i=Array.isArray(e)&&e[s]?e[s].length:0}for(var a=o?e:u(e,r,i),c=t.length-1;c>=0;--c){var l,f=t[c];if("[]"===f&&r.parseArrays)l=r.allowEmptyArrays&&(""===a||r.strictNullHandling&&null===a)?[]:n.combine([],a);else{l=r.plainObjects?{__proto__:null}:{};var h="["===f.charAt(0)&&"]"===f.charAt(f.length-1)?f.slice(1,-1):f,p=r.decodeDotInKeys?h.replace(/%2E/g,"."):h,d=parseInt(p,10);r.parseArrays||""!==p?!isNaN(d)&&f!==p&&String(d)===p&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(l=[])[d]=a:"__proto__"!==p&&(l[p]=a):l={0:a}}a=l}return a}(f,e,r,i)}};t.exports=function(t,e){var r=function(t){if(!t)return s;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.decodeDotInKeys&&"boolean"!=typeof t.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==t.throwOnLimitExceeded&&"boolean"!=typeof t.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var e=void 0===t.charset?s.charset:t.charset,r=void 0===t.duplicates?s.duplicates:t.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||s.allowDots:!!t.allowDots,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof t.allowSparse?t.allowSparse:s.allowSparse,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:s.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:s.comma,decodeDotInKeys:"boolean"==typeof t.decodeDotInKeys?t.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof t.decoder?t.decoder:s.decoder,delimiter:"string"==typeof t.delimiter||n.isRegExp(t.delimiter)?t.delimiter:s.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:s.depth,duplicates:r,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:s.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof t.strictDepth?!!t.strictDepth:s.strictDepth,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:s.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof t.throwOnLimitExceeded&&t.throwOnLimitExceeded}}(e);if(""===t||null==t)return r.plainObjects?{__proto__:null}:{};for(var l="string"==typeof t?function(t,e){var r={__proto__:null},c=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;c=c.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l=e.parameterLimit===1/0?void 0:e.parameterLimit,f=c.split(e.delimiter,e.throwOnLimitExceeded?l+1:l);if(e.throwOnLimitExceeded&&f.length>l)throw new RangeError("Parameter limit exceeded. Only "+l+" parameter"+(1===l?"":"s")+" allowed.");var h,p=-1,d=e.charset;if(e.charsetSentinel)for(h=0;h<f.length;++h)0===f[h].indexOf("utf8=")&&("utf8=%E2%9C%93"===f[h]?d="utf-8":"utf8=%26%2310003%3B"===f[h]&&(d="iso-8859-1"),p=h,h=f.length);for(h=0;h<f.length;++h)if(h!==p){var m,y,g=f[h],v=g.indexOf("]="),b=-1===v?g.indexOf("="):v+1;-1===b?(m=e.decoder(g,s.decoder,d,"key"),y=e.strictNullHandling?null:""):(m=e.decoder(g.slice(0,b),s.decoder,d,"key"),y=n.maybeMap(u(g.slice(b+1),e,i(r[m])?r[m].length:0),(function(t){return e.decoder(t,s.decoder,d,"value")}))),y&&e.interpretNumericEntities&&"iso-8859-1"===d&&(y=a(String(y))),g.indexOf("[]=")>-1&&(y=i(y)?[y]:y);var _=o.call(r,m);_&&"combine"===e.duplicates?r[m]=n.combine(r[m],y):_&&"last"!==e.duplicates||(r[m]=y)}return r}(t,r):t,f=r.plainObjects?{__proto__:null}:{},h=Object.keys(l),p=0;p<h.length;++p){var d=h[p],m=c(d,l[d],r,"string"==typeof t);f=n.merge(f,m,r)}return!0===r.allowSparse?f:n.compact(f)}},function(t,e){},function(t,e,r){(function(e){var n=r(309),o=function(){},i=function(t,r,s){if("function"==typeof r)return i(t,null,r);r||(r={}),s=n(s||o);var a=t._writableState,u=t._readableState,c=r.readable||!1!==r.readable&&t.readable,l=r.writable||!1!==r.writable&&t.writable,f=!1,h=function(){t.writable||p()},p=function(){l=!1,c||s.call(t)},d=function(){c=!1,l||s.call(t)},m=function(e){s.call(t,e?new Error("exited with error code: "+e):null)},y=function(e){s.call(t,e)},g=function(){e.nextTick(v)},v=function(){if(!f)return(!c||u&&u.ended&&!u.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:s.call(t,new Error("premature close"))},b=function(){t.req.on("finish",p)};return!function(t){return t.setHeader&&"function"==typeof t.abort}(t)?l&&!a&&(t.on("end",h),t.on("close",h)):(t.on("complete",p),t.on("abort",g),t.req?b():t.on("request",b)),function(t){return t.stdio&&Array.isArray(t.stdio)&&3===t.stdio.length}(t)&&t.on("exit",m),t.on("end",d),t.on("finish",p),!1!==r.error&&t.on("error",y),t.on("close",g),function(){f=!0,t.removeListener("complete",p),t.removeListener("abort",g),t.removeListener("request",b),t.req&&t.req.removeListener("finish",p),t.removeListener("end",h),t.removeListener("close",h),t.removeListener("finish",p),t.removeListener("exit",m),t.removeListener("end",d),t.removeListener("error",y),t.removeListener("close",g)}};t.exports=i}).call(this,r(9))},function(t,e,r){var n=r(310);function o(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function i(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}t.exports=n(o),t.exports.strict=n(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},function(t,e){t.exports=function t(e,r){if(e&&r)return t(e)(r);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),r=0;r<t.length;r++)t[r]=arguments[r];var n=e.apply(this,t),o=t[t.length-1];return"function"==typeof n&&n!==o&&Object.keys(o).forEach((function(t){n[t]=o[t]})),n}}},function(t,e){t.exports=function(t){var e=t._readableState;return e?e.objectMode||"number"==typeof t._duplexState?t.read():t.read(function(t){if(t.buffer.length){var e=t.bufferIndex||0;if(t.buffer.head)return t.buffer.head.data.length;if(t.buffer.length-e>0&&t.buffer[e])return t.buffer[e].length}return t.length}(e)):null}},function(t,e,r){"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(t,e,r){"use strict";r.r(e),r.d(e,"Stack",(function(){return c})),r.d(e,"Queue",(function(){return f})),r.d(e,"PriorityQueue",(function(){return m})),r.d(e,"Vector",(function(){return T})),r.d(e,"LinkList",(function(){return M})),r.d(e,"Deque",(function(){return N})),r.d(e,"OrderedSet",(function(){return J})),r.d(e,"OrderedMap",(function(){return rt})),r.d(e,"HashSet",(function(){return lt})),r.d(e,"HashMap",(function(){return dt}));var n,o=(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=function(){function t(t){void 0===t&&(t=0),this.iteratorType=t}return t.prototype.equals=function(t){return this.o===t.o},t}(),s=function(){function t(){this.M=0}return Object.defineProperty(t.prototype,"length",{get:function(){return this.M},enumerable:!1,configurable:!0}),t.prototype.size=function(){return this.M},t.prototype.empty=function(){return 0===this.M},t}(),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e}(s),u=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),c=function(t){function e(e){void 0===e&&(e=[]);var r=t.call(this)||this;r.nt=[];var n=r;return e.forEach((function(t){n.push(t)})),r}return u(e,t),e.prototype.clear=function(){this.M=0,this.nt=[]},e.prototype.push=function(t){return this.nt.push(t),this.M+=1,this.M},e.prototype.pop=function(){if(0!==this.M)return this.M-=1,this.nt.pop()},e.prototype.top=function(){return this.nt[this.M-1]},e}(s),l=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),f=function(t){function e(e){void 0===e&&(e=[]);var r=t.call(this)||this;r.A=0,r.tt=[];var n=r;return e.forEach((function(t){n.push(t)})),r}return l(e,t),e.prototype.clear=function(){this.tt=[],this.M=this.A=0},e.prototype.push=function(t){var e=this.tt.length;if(this.A/e>.5&&this.A+this.M>=e&&e>4096){for(var r=this.M,n=0;n<r;++n)this.tt[n]=this.tt[this.A+n];this.A=0,this.tt[this.M]=t}else this.tt[this.A+this.M]=t;return++this.M},e.prototype.pop=function(){if(0!==this.M){var t=this.tt[this.A++];return this.M-=1,t}},e.prototype.front=function(){if(0!==this.M)return this.tt[this.A]},e}(s),h=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},d=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},m=function(t){function e(e,r,n){void 0===e&&(e=[]),void 0===r&&(r=function(t,e){return t>e?-1:t<e?1:0}),void 0===n&&(n=!0);var o=t.call(this)||this;if(o.$=r,Array.isArray(e))o.ii=n?d([],p(e),!1):e;else{o.ii=[];var i=o;e.forEach((function(t){i.ii.push(t)}))}o.M=o.ii.length;for(var s=o.M>>1,a=o.M-1>>1;a>=0;--a)o.ri(a,s);return o}return h(e,t),e.prototype.ti=function(t){for(var e=this.ii[t];t>0;){var r=t-1>>1,n=this.ii[r];if(this.$(n,e)<=0)break;this.ii[t]=n,t=r}this.ii[t]=e},e.prototype.ri=function(t,e){for(var r=this.ii[t];t<e;){var n=t<<1|1,o=n+1,i=this.ii[n];if(o<this.M&&this.$(i,this.ii[o])>0&&(n=o,i=this.ii[o]),this.$(i,r)>=0)break;this.ii[t]=i,t=n}this.ii[t]=r},e.prototype.clear=function(){this.M=0,this.ii.length=0},e.prototype.push=function(t){this.ii.push(t),this.ti(this.M),this.M+=1},e.prototype.pop=function(){if(0!==this.M){var t=this.ii[0],e=this.ii.pop();return this.M-=1,this.M&&(this.ii[0]=e,this.ri(0,this.M>>1)),t}},e.prototype.top=function(){return this.ii[0]},e.prototype.find=function(t){return this.ii.indexOf(t)>=0},e.prototype.remove=function(t){var e=this.ii.indexOf(t);return!(e<0)&&(0===e?this.pop():e===this.M-1?(this.ii.pop(),this.M-=1):(this.ii.splice(e,1,this.ii.pop()),this.M-=1,this.ti(e),this.ri(e,this.M>>1)),!0)},e.prototype.updateItem=function(t){var e=this.ii.indexOf(t);return!(e<0)&&(this.ti(e),this.ri(e,this.M>>1),!0)},e.prototype.toArray=function(){return d([],p(this.ii),!1)},e}(s),y=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),g=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return y(e,t),e}(a);function v(){throw new RangeError("Iterator access denied!")}var b=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),_=function(t){function e(e,r){var n=t.call(this,r)||this;return n.o=e,0===n.iteratorType?(n.pre=function(){return 0===this.o&&v(),this.o-=1,this},n.next=function(){return this.o===this.container.size()&&v(),this.o+=1,this}):(n.pre=function(){return this.o===this.container.size()-1&&v(),this.o+=1,this},n.next=function(){return-1===this.o&&v(),this.o-=1,this}),n}return b(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){return this.container.getElementByPos(this.o)},set:function(t){this.container.setElementByPos(this.o,t)},enumerable:!1,configurable:!0}),e}(i),w=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),k=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},S=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},x=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},E=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},A=function(t){function e(e,r,n){var o=t.call(this,e,n)||this;return o.container=r,o}return w(e,t),e.prototype.copy=function(){return new e(this.o,this.container,this.iteratorType)},e}(_),T=function(t){function e(e,r){void 0===e&&(e=[]),void 0===r&&(r=!0);var n=t.call(this)||this;if(Array.isArray(e))n.J=r?x([],S(e),!1):e,n.M=e.length;else{n.J=[];var o=n;e.forEach((function(t){o.pushBack(t)}))}return n}return w(e,t),e.prototype.clear=function(){this.M=0,this.J.length=0},e.prototype.begin=function(){return new A(0,this)},e.prototype.end=function(){return new A(this.M,this)},e.prototype.rBegin=function(){return new A(this.M-1,this,1)},e.prototype.rEnd=function(){return new A(-1,this,1)},e.prototype.front=function(){return this.J[0]},e.prototype.back=function(){return this.J[this.M-1]},e.prototype.getElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;return this.J[t]},e.prototype.eraseElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;return this.J.splice(t,1),this.M-=1,this.M},e.prototype.eraseElementByValue=function(t){for(var e=0,r=0;r<this.M;++r)this.J[r]!==t&&(this.J[e++]=this.J[r]);return this.M=this.J.length=e,this.M},e.prototype.eraseElementByIterator=function(t){var e=t.o;return t=t.next(),this.eraseElementByPos(e),t},e.prototype.pushBack=function(t){return this.J.push(t),this.M+=1,this.M},e.prototype.popBack=function(){if(0!==this.M)return this.M-=1,this.J.pop()},e.prototype.setElementByPos=function(t,e){if(t<0||t>this.M-1)throw new RangeError;this.J[t]=e},e.prototype.insert=function(t,e,r){var n;if(void 0===r&&(r=1),t<0||t>this.M)throw new RangeError;return(n=this.J).splice.apply(n,x([t,0],S(new Array(r).fill(e)),!1)),this.M+=r,this.M},e.prototype.find=function(t){for(var e=0;e<this.M;++e)if(this.J[e]===t)return new A(e,this);return this.end()},e.prototype.reverse=function(){this.J.reverse()},e.prototype.unique=function(){for(var t=1,e=1;e<this.M;++e)this.J[e]!==this.J[e-1]&&(this.J[t++]=this.J[e]);return this.M=this.J.length=t,this.M},e.prototype.sort=function(t){this.J.sort(t)},e.prototype.forEach=function(t){for(var e=0;e<this.M;++e)t(this.J[e],e,this)},e.prototype[Symbol.iterator]=function(){return function(){return k(this,(function(t){switch(t.label){case 0:return[5,E(this.J)];case 1:return t.sent(),[2]}}))}.bind(this)()},e}(g),P=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),I=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},O=function(t){function e(e,r,n,o){var i=t.call(this,o)||this;return i.o=e,i.h=r,i.container=n,0===i.iteratorType?(i.pre=function(){return this.o.L===this.h&&v(),this.o=this.o.L,this},i.next=function(){return this.o===this.h&&v(),this.o=this.o.m,this}):(i.pre=function(){return this.o.m===this.h&&v(),this.o=this.o.m,this},i.next=function(){return this.o===this.h&&v(),this.o=this.o.L,this}),i}return P(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){return this.o===this.h&&v(),this.o.p},set:function(t){this.o===this.h&&v(),this.o.p=t},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.o,this.h,this.container,this.iteratorType)},e}(i),M=function(t){function e(e){void 0===e&&(e=[]);var r=t.call(this)||this;r.h={},r.H=r.l=r.h.L=r.h.m=r.h;var n=r;return e.forEach((function(t){n.pushBack(t)})),r}return P(e,t),e.prototype.G=function(t){var e=t.L,r=t.m;e.m=r,r.L=e,t===this.H&&(this.H=r),t===this.l&&(this.l=e),this.M-=1},e.prototype.F=function(t,e){var r=e.m,n={p:t,L:e,m:r};e.m=n,r.L=n,e===this.h&&(this.H=n),r===this.h&&(this.l=n),this.M+=1},e.prototype.clear=function(){this.M=0,this.H=this.l=this.h.L=this.h.m=this.h},e.prototype.begin=function(){return new O(this.H,this.h,this)},e.prototype.end=function(){return new O(this.h,this.h,this)},e.prototype.rBegin=function(){return new O(this.l,this.h,this,1)},e.prototype.rEnd=function(){return new O(this.h,this.h,this,1)},e.prototype.front=function(){return this.H.p},e.prototype.back=function(){return this.l.p},e.prototype.getElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;for(var e=this.H;t--;)e=e.m;return e.p},e.prototype.eraseElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;for(var e=this.H;t--;)e=e.m;return this.G(e),this.M},e.prototype.eraseElementByValue=function(t){for(var e=this.H;e!==this.h;)e.p===t&&this.G(e),e=e.m;return this.M},e.prototype.eraseElementByIterator=function(t){var e=t.o;return e===this.h&&v(),t=t.next(),this.G(e),t},e.prototype.pushBack=function(t){return this.F(t,this.l),this.M},e.prototype.popBack=function(){if(0!==this.M){var t=this.l.p;return this.G(this.l),t}},e.prototype.pushFront=function(t){return this.F(t,this.h),this.M},e.prototype.popFront=function(){if(0!==this.M){var t=this.H.p;return this.G(this.H),t}},e.prototype.setElementByPos=function(t,e){if(t<0||t>this.M-1)throw new RangeError;for(var r=this.H;t--;)r=r.m;r.p=e},e.prototype.insert=function(t,e,r){if(void 0===r&&(r=1),t<0||t>this.M)throw new RangeError;if(r<=0)return this.M;if(0===t)for(;r--;)this.pushFront(e);else if(t===this.M)for(;r--;)this.pushBack(e);else{for(var n=this.H,o=1;o<t;++o)n=n.m;var i=n.m;for(this.M+=r;r--;)n.m={p:e,L:n},n.m.L=n,n=n.m;n.m=i,i.L=n}return this.M},e.prototype.find=function(t){for(var e=this.H;e!==this.h;){if(e.p===t)return new O(e,this.h,this);e=e.m}return this.end()},e.prototype.reverse=function(){if(!(this.M<=1))for(var t=this.H,e=this.l,r=0;r<<1<this.M;){var n=t.p;t.p=e.p,e.p=n,t=t.m,e=e.L,r+=1}},e.prototype.unique=function(){if(this.M<=1)return this.M;for(var t=this.H;t!==this.h;){for(var e=t;e.m!==this.h&&e.p===e.m.p;)e=e.m,this.M-=1;t.m=e.m,t.m.L=t,t=t.m}return this.M},e.prototype.sort=function(t){if(!(this.M<=1)){var e=[];this.forEach((function(t){e.push(t)})),e.sort(t);var r=this.H;e.forEach((function(t){r.p=t,r=r.m}))}},e.prototype.merge=function(t){var e=this;if(0===this.M)t.forEach((function(t){e.pushBack(t)}));else{var r=this.H;t.forEach((function(t){for(;r!==e.h&&r.p<=t;)r=r.m;e.F(t,r.L)}))}return this.M},e.prototype.forEach=function(t){for(var e=this.H,r=0;e!==this.h;)t(e.p,r++,this),e=e.m},e.prototype[Symbol.iterator]=function(){return function(){var t;return I(this,(function(e){switch(e.label){case 0:if(0===this.M)return[2];t=this.H,e.label=1;case 1:return t===this.h?[3,3]:[4,t.p];case 2:return e.sent(),t=t.m,[3,1];case 3:return[2]}}))}.bind(this)()},e}(g),C=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),R=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},D=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},j=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},L=function(t){function e(e,r,n){var o=t.call(this,e,n)||this;return o.container=r,o}return C(e,t),e.prototype.copy=function(){return new e(this.o,this.container,this.iteratorType)},e}(_),N=function(t){function e(e,r){void 0===e&&(e=[]),void 0===r&&(r=4096);var n=t.call(this)||this;n.A=0,n.S=0,n.R=0,n.k=0,n.C=0,n.j=[];var o=function(){if("number"==typeof e.length)return e.length;if("number"==typeof e.size)return e.size;if("function"==typeof e.size)return e.size();throw new TypeError("Cannot get the length or size of the container")}();n.B=r,n.C=Math.max(Math.ceil(o/n.B),1);for(var i=0;i<n.C;++i)n.j.push(new Array(n.B));var s=Math.ceil(o/n.B);n.A=n.R=(n.C>>1)-(s>>1),n.S=n.k=n.B-o%n.B>>1;var a=n;return e.forEach((function(t){a.pushBack(t)})),n}return C(e,t),e.prototype.O=function(){for(var t=[],e=Math.max(this.C>>1,1),r=0;r<e;++r)t[r]=new Array(this.B);for(r=this.A;r<this.C;++r)t[t.length]=this.j[r];for(r=0;r<this.R;++r)t[t.length]=this.j[r];t[t.length]=j([],D(this.j[this.R]),!1),this.A=e,this.R=t.length-1;for(r=0;r<e;++r)t[t.length]=new Array(this.B);this.j=t,this.C=t.length},e.prototype.T=function(t){var e=this.S+t+1,r=e%this.B,n=r-1,o=this.A+(e-r)/this.B;return 0===r&&(o-=1),o%=this.C,n<0&&(n+=this.B),{curNodeBucketIndex:o,curNodePointerIndex:n}},e.prototype.clear=function(){this.j=[new Array(this.B)],this.C=1,this.A=this.R=this.M=0,this.S=this.k=this.B>>1},e.prototype.begin=function(){return new L(0,this)},e.prototype.end=function(){return new L(this.M,this)},e.prototype.rBegin=function(){return new L(this.M-1,this,1)},e.prototype.rEnd=function(){return new L(-1,this,1)},e.prototype.front=function(){if(0!==this.M)return this.j[this.A][this.S]},e.prototype.back=function(){if(0!==this.M)return this.j[this.R][this.k]},e.prototype.pushBack=function(t){return this.M&&(this.k<this.B-1?this.k+=1:this.R<this.C-1?(this.R+=1,this.k=0):(this.R=0,this.k=0),this.R===this.A&&this.k===this.S&&this.O()),this.M+=1,this.j[this.R][this.k]=t,this.M},e.prototype.popBack=function(){if(0!==this.M){var t=this.j[this.R][this.k];return 1!==this.M&&(this.k>0?this.k-=1:this.R>0?(this.R-=1,this.k=this.B-1):(this.R=this.C-1,this.k=this.B-1)),this.M-=1,t}},e.prototype.pushFront=function(t){return this.M&&(this.S>0?this.S-=1:this.A>0?(this.A-=1,this.S=this.B-1):(this.A=this.C-1,this.S=this.B-1),this.A===this.R&&this.S===this.k&&this.O()),this.M+=1,this.j[this.A][this.S]=t,this.M},e.prototype.popFront=function(){if(0!==this.M){var t=this.j[this.A][this.S];return 1!==this.M&&(this.S<this.B-1?this.S+=1:this.A<this.C-1?(this.A+=1,this.S=0):(this.A=0,this.S=0)),this.M-=1,t}},e.prototype.getElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;var e=this.T(t),r=e.curNodeBucketIndex,n=e.curNodePointerIndex;return this.j[r][n]},e.prototype.setElementByPos=function(t,e){if(t<0||t>this.M-1)throw new RangeError;var r=this.T(t),n=r.curNodeBucketIndex,o=r.curNodePointerIndex;this.j[n][o]=e},e.prototype.insert=function(t,e,r){if(void 0===r&&(r=1),t<0||t>this.M)throw new RangeError;if(0===t)for(;r--;)this.pushFront(e);else if(t===this.M)for(;r--;)this.pushBack(e);else{for(var n=[],o=t;o<this.M;++o)n.push(this.getElementByPos(o));this.cut(t-1);for(o=0;o<r;++o)this.pushBack(e);for(o=0;o<n.length;++o)this.pushBack(n[o])}return this.M},e.prototype.cut=function(t){if(t<0)return this.clear(),0;var e=this.T(t),r=e.curNodeBucketIndex,n=e.curNodePointerIndex;return this.R=r,this.k=n,this.M=t+1,this.M},e.prototype.eraseElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;if(0===t)this.popFront();else if(t===this.M-1)this.popBack();else{for(var e=[],r=t+1;r<this.M;++r)e.push(this.getElementByPos(r));this.cut(t),this.popBack();var n=this;e.forEach((function(t){n.pushBack(t)}))}return this.M},e.prototype.eraseElementByValue=function(t){if(0===this.M)return 0;for(var e=[],r=0;r<this.M;++r){var n=this.getElementByPos(r);n!==t&&e.push(n)}var o=e.length;for(r=0;r<o;++r)this.setElementByPos(r,e[r]);return this.cut(o-1)},e.prototype.eraseElementByIterator=function(t){var e=t.o;return this.eraseElementByPos(e),t=t.next()},e.prototype.find=function(t){for(var e=0;e<this.M;++e)if(this.getElementByPos(e)===t)return new L(e,this);return this.end()},e.prototype.reverse=function(){for(var t=0,e=this.M-1;t<e;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(e)),this.setElementByPos(e,r),t+=1,e-=1}},e.prototype.unique=function(){if(this.M<=1)return this.M;for(var t=1,e=this.getElementByPos(0),r=1;r<this.M;++r){var n=this.getElementByPos(r);n!==e&&(e=n,this.setElementByPos(t++,n))}for(;this.M>t;)this.popBack();return this.M},e.prototype.sort=function(t){for(var e=[],r=0;r<this.M;++r)e.push(this.getElementByPos(r));e.sort(t);for(r=0;r<this.M;++r)this.setElementByPos(r,e[r])},e.prototype.shrinkToFit=function(){if(0!==this.M){var t=[];this.forEach((function(e){t.push(e)})),this.C=Math.max(Math.ceil(this.M/this.B),1),this.M=this.A=this.R=this.S=this.k=0,this.j=[];for(var e=0;e<this.C;++e)this.j.push(new Array(this.B));for(e=0;e<t.length;++e)this.pushBack(t[e])}},e.prototype.forEach=function(t){for(var e=0;e<this.M;++e)t(this.getElementByPos(e),e,this)},e.prototype[Symbol.iterator]=function(){return function(){var t;return R(this,(function(e){switch(e.label){case 0:t=0,e.label=1;case 1:return t<this.M?[4,this.getElementByPos(t)]:[3,4];case 2:e.sent(),e.label=3;case 3:return++t,[3,1];case 4:return[2]}}))}.bind(this)()},e}(g),B=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),F=function(){function t(t,e){this.ee=1,this.u=void 0,this.p=void 0,this.K=void 0,this.N=void 0,this.rr=void 0,this.u=t,this.p=e}return t.prototype.L=function(){var t=this;if(1===t.ee&&t.rr.rr===t)t=t.N;else if(t.K)for(t=t.K;t.N;)t=t.N;else{for(var e=t.rr;e.K===t;)e=(t=e).rr;t=e}return t},t.prototype.m=function(){var t=this;if(t.N){for(t=t.N;t.K;)t=t.K;return t}for(var e=t.rr;e.N===t;)e=(t=e).rr;return t.N!==e?e:t},t.prototype.ne=function(){var t=this.rr,e=this.N,r=e.K;return t.rr===this?t.rr=e:t.K===this?t.K=e:t.N=e,e.rr=t,e.K=this,this.rr=e,this.N=r,r&&(r.rr=this),e},t.prototype.te=function(){var t=this.rr,e=this.K,r=e.N;return t.rr===this?t.rr=e:t.K===this?t.K=e:t.N=e,e.rr=t,e.N=this,this.rr=e,this.K=r,r&&(r.rr=this),e},t}(),U=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.tr=1,e}return B(e,t),e.prototype.ne=function(){var e=t.prototype.ne.call(this);return this.ie(),e.ie(),e},e.prototype.te=function(){var e=t.prototype.te.call(this);return this.ie(),e.ie(),e},e.prototype.ie=function(){this.tr=1,this.K&&(this.tr+=this.K.tr),this.N&&(this.tr+=this.N.tr)},e}(F),q=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),H=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},W=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(t){function e(e,r){void 0===e&&(e=function(t,e){return t<e?-1:t>e?1:0}),void 0===r&&(r=!1);var n=t.call(this)||this;return n.W=void 0,n.$=e,r?(n.re=U,n.v=function(t,e,r){var n=this.se(t,e,r);if(n){for(var o=n.rr;o!==this.h;)o.tr+=1,o=o.rr;var i=this.fe(n);if(i){var s=i,a=s.parentNode,u=s.grandParent,c=s.curNode;a.ie(),u.ie(),c.ie()}}return this.M},n.G=function(t){for(var e=this.he(t);e!==this.h;)e.tr-=1,e=e.rr}):(n.re=F,n.v=function(t,e,r){var n=this.se(t,e,r);return n&&this.fe(n),this.M},n.G=n.he),n.h=new n.re,n}return q(e,t),e.prototype.U=function(t,e){for(var r=this.h;t;){var n=this.$(t.u,e);if(n<0)t=t.N;else{if(!(n>0))return t;r=t,t=t.K}}return r},e.prototype.X=function(t,e){for(var r=this.h;t;){this.$(t.u,e)<=0?t=t.N:(r=t,t=t.K)}return r},e.prototype.Y=function(t,e){for(var r=this.h;t;){var n=this.$(t.u,e);if(n<0)r=t,t=t.N;else{if(!(n>0))return t;t=t.K}}return r},e.prototype.Z=function(t,e){for(var r=this.h;t;){this.$(t.u,e)<0?(r=t,t=t.N):t=t.K}return r},e.prototype.ue=function(t){for(;;){var e,r=t.rr;if(r===this.h)return;if(1===t.ee)return void(t.ee=0);if(t===r.K)if(1===(e=r.N).ee)e.ee=0,r.ee=1,r===this.W?this.W=r.ne():r.ne();else{if(e.N&&1===e.N.ee)return e.ee=r.ee,r.ee=0,e.N.ee=0,void(r===this.W?this.W=r.ne():r.ne());e.K&&1===e.K.ee?(e.ee=1,e.K.ee=0,e.te()):(e.ee=1,t=r)}else if(1===(e=r.K).ee)e.ee=0,r.ee=1,r===this.W?this.W=r.te():r.te();else{if(e.K&&1===e.K.ee)return e.ee=r.ee,r.ee=0,e.K.ee=0,void(r===this.W?this.W=r.te():r.te());e.N&&1===e.N.ee?(e.ee=1,e.N.ee=0,e.ne()):(e.ee=1,t=r)}}},e.prototype.he=function(t){var e,r;if(1===this.M)return this.clear(),this.h;for(var n=t;n.K||n.N;){if(n.N)for(n=n.N;n.K;)n=n.K;else n=n.K;e=H([n.u,t.u],2),t.u=e[0],n.u=e[1],r=H([n.p,t.p],2),t.p=r[0],n.p=r[1],t=n}this.h.K===n?this.h.K=n.rr:this.h.N===n&&(this.h.N=n.rr),this.ue(n);var o=n.rr;return n===o.K?o.K=void 0:o.N=void 0,this.M-=1,this.W.ee=0,o},e.prototype.ae=function(t,e){return void 0!==t&&(!!this.ae(t.K,e)||(!!e(t)||this.ae(t.N,e)))},e.prototype.fe=function(t){for(;;){var e=t.rr;if(0===e.ee)return;var r=e.rr;if(e===r.K){if((n=r.N)&&1===n.ee){if(n.ee=e.ee=0,r===this.W)return;r.ee=1,t=r;continue}if(t===e.N){if(t.ee=0,t.K&&(t.K.rr=e),t.N&&(t.N.rr=r),e.N=t.K,r.K=t.N,t.K=e,t.N=r,r===this.W)this.W=t,this.h.rr=t;else(o=r.rr).K===r?o.K=t:o.N=t;return t.rr=r.rr,e.rr=t,r.rr=t,r.ee=1,{parentNode:e,grandParent:r,curNode:t}}e.ee=0,r===this.W?this.W=r.te():r.te(),r.ee=1}else{var n;if((n=r.K)&&1===n.ee){if(n.ee=e.ee=0,r===this.W)return;r.ee=1,t=r;continue}if(t===e.K){var o;if(t.ee=0,t.K&&(t.K.rr=r),t.N&&(t.N.rr=e),r.N=t.K,e.K=t.N,t.K=r,t.N=e,r===this.W)this.W=t,this.h.rr=t;else(o=r.rr).K===r?o.K=t:o.N=t;return t.rr=r.rr,e.rr=t,r.rr=t,r.ee=1,{parentNode:e,grandParent:r,curNode:t}}e.ee=0,r===this.W?this.W=r.ne():r.ne(),r.ee=1}return}},e.prototype.se=function(t,e,r){if(void 0===this.W)return this.M+=1,this.W=new this.re(t,e),this.W.ee=0,this.W.rr=this.h,this.h.rr=this.W,this.h.K=this.W,void(this.h.N=this.W);var n,o=this.h.K,i=this.$(o.u,t);if(0!==i){if(i>0)o.K=new this.re(t,e),o.K.rr=o,n=o.K,this.h.K=n;else{var s=this.h.N,a=this.$(s.u,t);if(0===a)return void(s.p=e);if(a<0)s.N=new this.re(t,e),s.N.rr=s,n=s.N,this.h.N=n;else{if(void 0!==r){var u=r.o;if(u!==this.h){var c=this.$(u.u,t);if(0===c)return void(u.p=e);if(c>0){var l=u.L(),f=this.$(l.u,t);if(0===f)return void(l.p=e);f<0&&(n=new this.re(t,e),void 0===l.N?(l.N=n,n.rr=l):(u.K=n,n.rr=u))}}}if(void 0===n)for(n=this.W;;){var h=this.$(n.u,t);if(h>0){if(void 0===n.K){n.K=new this.re(t,e),n.K.rr=n,n=n.K;break}n=n.K}else{if(!(h<0))return void(n.p=e);if(void 0===n.N){n.N=new this.re(t,e),n.N.rr=n,n=n.N;break}n=n.N}}}}return this.M+=1,n}o.p=e},e.prototype.g=function(t,e){for(;t;){var r=this.$(t.u,e);if(r<0)t=t.N;else{if(!(r>0))return t;t=t.K}}return t||this.h},e.prototype.clear=function(){this.M=0,this.W=void 0,this.h.rr=void 0,this.h.K=this.h.N=void 0},e.prototype.updateKeyByIterator=function(t,e){var r=t.o;if(r===this.h&&v(),1===this.M)return r.u=e,!0;if(r===this.h.K)return this.$(r.m().u,e)>0&&(r.u=e,!0);if(r===this.h.N)return this.$(r.L().u,e)<0&&(r.u=e,!0);var n=r.L().u;if(this.$(n,e)>=0)return!1;var o=r.m().u;return!(this.$(o,e)<=0)&&(r.u=e,!0)},e.prototype.eraseElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;var e=0,r=this;return this.ae(this.W,(function(n){return t===e?(r.G(n),!0):(e+=1,!1)})),this.M},e.prototype.eraseElementByKey=function(t){if(0===this.M)return!1;var e=this.g(this.W,t);return e!==this.h&&(this.G(e),!0)},e.prototype.eraseElementByIterator=function(t){var e=t.o;e===this.h&&v();var r=void 0===e.N;return 0===t.iteratorType?r&&t.next():r&&void 0!==e.K||t.next(),this.G(e),t},e.prototype.forEach=function(t){var e,r,n=0;try{for(var o=W(this),i=o.next();!i.done;i=o.next()){t(i.value,n++,this)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},e.prototype.getElementByPos=function(t){var e,r,n;if(t<0||t>this.M-1)throw new RangeError;var o=0;try{for(var i=W(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(o===t){n=a;break}o+=1}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n},e.prototype.getHeight=function(){if(0===this.M)return 0;var t=function(e){return e?Math.max(t(e.K),t(e.N))+1:0};return t(this.W)},e}(a),Y=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),z=function(t){function e(e,r,n){var o=t.call(this,n)||this;return o.o=e,o.h=r,0===o.iteratorType?(o.pre=function(){return this.o===this.h.K&&v(),this.o=this.o.L(),this},o.next=function(){return this.o===this.h&&v(),this.o=this.o.m(),this}):(o.pre=function(){return this.o===this.h.N&&v(),this.o=this.o.m(),this},o.next=function(){return this.o===this.h&&v(),this.o=this.o.L(),this}),o}return Y(e,t),Object.defineProperty(e.prototype,"index",{get:function(){var t=this.o,e=this.h.rr;if(t===this.h)return e?e.tr-1:0;var r=0;for(t.K&&(r+=t.K.tr);t!==e;){var n=t.rr;t===n.N&&(r+=1,n.K&&(r+=n.K.tr)),t=n}return r},enumerable:!1,configurable:!0}),e}(i),$=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),V=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},G=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(t){function e(e,r,n,o){var i=t.call(this,e,r,o)||this;return i.container=n,i}return $(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){return this.o===this.h&&v(),this.o.u},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.o,this.h,this.container,this.iteratorType)},e}(z),J=function(t){function e(e,r,n){void 0===e&&(e=[]);var o=t.call(this,r,n)||this,i=o;return e.forEach((function(t){i.insert(t)})),o}return $(e,t),e.prototype.P=function(t){return V(this,(function(e){switch(e.label){case 0:return void 0===t?[2]:[5,G(this.P(t.K))];case 1:return e.sent(),[4,t.u];case 2:return e.sent(),[5,G(this.P(t.N))];case 3:return e.sent(),[2]}}))},e.prototype.begin=function(){return new Q(this.h.K||this.h,this.h,this)},e.prototype.end=function(){return new Q(this.h,this.h,this)},e.prototype.rBegin=function(){return new Q(this.h.N||this.h,this.h,this,1)},e.prototype.rEnd=function(){return new Q(this.h,this.h,this,1)},e.prototype.front=function(){return this.h.K?this.h.K.u:void 0},e.prototype.back=function(){return this.h.N?this.h.N.u:void 0},e.prototype.insert=function(t,e){return this.v(t,void 0,e)},e.prototype.find=function(t){var e=this.g(this.W,t);return new Q(e,this.h,this)},e.prototype.lowerBound=function(t){var e=this.U(this.W,t);return new Q(e,this.h,this)},e.prototype.upperBound=function(t){var e=this.X(this.W,t);return new Q(e,this.h,this)},e.prototype.reverseLowerBound=function(t){var e=this.Y(this.W,t);return new Q(e,this.h,this)},e.prototype.reverseUpperBound=function(t){var e=this.Z(this.W,t);return new Q(e,this.h,this)},e.prototype.union=function(t){var e=this;return t.forEach((function(t){e.insert(t)})),this.M},e.prototype[Symbol.iterator]=function(){return this.P(this.W)},e}(K),X=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Z=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},tt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},et=function(t){function e(e,r,n,o){var i=t.call(this,e,r,o)||this;return i.container=n,i}return X(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){this.o===this.h&&v();var t=this;return new Proxy([],{get:function(e,r){return"0"===r?t.o.u:"1"===r?t.o.p:void 0},set:function(e,r,n){if("1"!==r)throw new TypeError("props must be 1");return t.o.p=n,!0}})},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.o,this.h,this.container,this.iteratorType)},e}(z),rt=function(t){function e(e,r,n){void 0===e&&(e=[]);var o=t.call(this,r,n)||this,i=o;return e.forEach((function(t){i.setElement(t[0],t[1])})),o}return X(e,t),e.prototype.P=function(t){return Z(this,(function(e){switch(e.label){case 0:return void 0===t?[2]:[5,tt(this.P(t.K))];case 1:return e.sent(),[4,[t.u,t.p]];case 2:return e.sent(),[5,tt(this.P(t.N))];case 3:return e.sent(),[2]}}))},e.prototype.begin=function(){return new et(this.h.K||this.h,this.h,this)},e.prototype.end=function(){return new et(this.h,this.h,this)},e.prototype.rBegin=function(){return new et(this.h.N||this.h,this.h,this,1)},e.prototype.rEnd=function(){return new et(this.h,this.h,this,1)},e.prototype.front=function(){if(0!==this.M){var t=this.h.K;return[t.u,t.p]}},e.prototype.back=function(){if(0!==this.M){var t=this.h.N;return[t.u,t.p]}},e.prototype.lowerBound=function(t){var e=this.U(this.W,t);return new et(e,this.h,this)},e.prototype.upperBound=function(t){var e=this.X(this.W,t);return new et(e,this.h,this)},e.prototype.reverseLowerBound=function(t){var e=this.Y(this.W,t);return new et(e,this.h,this)},e.prototype.reverseUpperBound=function(t){var e=this.Z(this.W,t);return new et(e,this.h,this)},e.prototype.setElement=function(t,e,r){return this.v(t,e,r)},e.prototype.find=function(t){var e=this.g(this.W,t);return new et(e,this.h,this)},e.prototype.getElementByKey=function(t){return this.g(this.W,t).p},e.prototype.union=function(t){var e=this;return t.forEach((function(t){e.setElement(t[0],t[1])})),this.M},e.prototype[Symbol.iterator]=function(){return this.P(this.W)},e}(K);function nt(t){var e=typeof t;return"object"===e&&null!==t||"function"===e}var ot=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),it=function(t){function e(e,r,n){var o=t.call(this,n)||this;return o.o=e,o.h=r,0===o.iteratorType?(o.pre=function(){return this.o.L===this.h&&v(),this.o=this.o.L,this},o.next=function(){return this.o===this.h&&v(),this.o=this.o.m,this}):(o.pre=function(){return this.o.m===this.h&&v(),this.o=this.o.m,this},o.next=function(){return this.o===this.h&&v(),this.o=this.o.L,this}),o}return ot(e,t),e}(i),st=function(t){function e(){var e=t.call(this)||this;return e._=[],e.I={},e.HASH_TAG=Symbol("@@HASH_TAG"),Object.setPrototypeOf(e.I,null),e.h={},e.h.L=e.h.m=e.H=e.l=e.h,e}return ot(e,t),e.prototype.G=function(t){var e=t.L,r=t.m;e.m=r,r.L=e,t===this.H&&(this.H=r),t===this.l&&(this.l=e),this.M-=1},e.prototype.v=function(t,e,r){var n;if(void 0===r&&(r=nt(t)),r){var o=t[this.HASH_TAG];if(void 0!==o)return this._[o].p=e,this.M;Object.defineProperty(t,this.HASH_TAG,{value:this._.length,configurable:!0}),n={u:t,p:e,L:this.l,m:this.h},this._.push(n)}else{var i=this.I[t];if(i)return i.p=e,this.M;n={u:t,p:e,L:this.l,m:this.h},this.I[t]=n}return 0===this.M?(this.H=n,this.h.m=n):this.l.m=n,this.l=n,this.h.L=n,++this.M},e.prototype.g=function(t,e){if(void 0===e&&(e=nt(t)),e){var r=t[this.HASH_TAG];return void 0===r?this.h:this._[r]}return this.I[t]||this.h},e.prototype.clear=function(){var t=this.HASH_TAG;this._.forEach((function(e){delete e.u[t]})),this._=[],this.I={},Object.setPrototypeOf(this.I,null),this.M=0,this.H=this.l=this.h.L=this.h.m=this.h},e.prototype.eraseElementByKey=function(t,e){var r;if(void 0===e&&(e=nt(t)),e){var n=t[this.HASH_TAG];if(void 0===n)return!1;delete t[this.HASH_TAG],r=this._[n],delete this._[n]}else{if(void 0===(r=this.I[t]))return!1;delete this.I[t]}return this.G(r),!0},e.prototype.eraseElementByIterator=function(t){var e=t.o;return e===this.h&&v(),this.G(e),t.next()},e.prototype.eraseElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;for(var e=this.H;t--;)e=e.m;return this.G(e),this.M},e}(a),at=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ut=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},ct=function(t){function e(e,r,n,o){var i=t.call(this,e,r,o)||this;return i.container=n,i}return at(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){return this.o===this.h&&v(),this.o.u},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.o,this.h,this.container,this.iteratorType)},e}(it),lt=function(t){function e(e){void 0===e&&(e=[]);var r=t.call(this)||this,n=r;return e.forEach((function(t){n.insert(t)})),r}return at(e,t),e.prototype.begin=function(){return new ct(this.H,this.h,this)},e.prototype.end=function(){return new ct(this.h,this.h,this)},e.prototype.rBegin=function(){return new ct(this.l,this.h,this,1)},e.prototype.rEnd=function(){return new ct(this.h,this.h,this,1)},e.prototype.front=function(){return this.H.u},e.prototype.back=function(){return this.l.u},e.prototype.insert=function(t,e){return this.v(t,void 0,e)},e.prototype.getElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;for(var e=this.H;t--;)e=e.m;return e.u},e.prototype.find=function(t,e){var r=this.g(t,e);return new ct(r,this.h,this)},e.prototype.forEach=function(t){for(var e=0,r=this.H;r!==this.h;)t(r.u,e++,this),r=r.m},e.prototype[Symbol.iterator]=function(){return function(){var t;return ut(this,(function(e){switch(e.label){case 0:t=this.H,e.label=1;case 1:return t===this.h?[3,3]:[4,t.u];case 2:return e.sent(),t=t.m,[3,1];case 3:return[2]}}))}.bind(this)()},e}(st),ft=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ht=function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(t){return function(e){return u([t,e])}}function u(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},pt=function(t){function e(e,r,n,o){var i=t.call(this,e,r,o)||this;return i.container=n,i}return ft(e,t),Object.defineProperty(e.prototype,"pointer",{get:function(){this.o===this.h&&v();var t=this;return new Proxy([],{get:function(e,r){return"0"===r?t.o.u:"1"===r?t.o.p:void 0},set:function(e,r,n){if("1"!==r)throw new TypeError("props must be 1");return t.o.p=n,!0}})},enumerable:!1,configurable:!0}),e.prototype.copy=function(){return new e(this.o,this.h,this.container,this.iteratorType)},e}(it),dt=function(t){function e(e){void 0===e&&(e=[]);var r=t.call(this)||this,n=r;return e.forEach((function(t){n.setElement(t[0],t[1])})),r}return ft(e,t),e.prototype.begin=function(){return new pt(this.H,this.h,this)},e.prototype.end=function(){return new pt(this.h,this.h,this)},e.prototype.rBegin=function(){return new pt(this.l,this.h,this,1)},e.prototype.rEnd=function(){return new pt(this.h,this.h,this,1)},e.prototype.front=function(){if(0!==this.M)return[this.H.u,this.H.p]},e.prototype.back=function(){if(0!==this.M)return[this.l.u,this.l.p]},e.prototype.setElement=function(t,e,r){return this.v(t,e,r)},e.prototype.getElementByKey=function(t,e){if(void 0===e&&(e=nt(t)),e){var r=t[this.HASH_TAG];return void 0!==r?this._[r].p:void 0}var n=this.I[t];return n?n.p:void 0},e.prototype.getElementByPos=function(t){if(t<0||t>this.M-1)throw new RangeError;for(var e=this.H;t--;)e=e.m;return[e.u,e.p]},e.prototype.find=function(t,e){var r=this.g(t,e);return new pt(r,this.h,this)},e.prototype.forEach=function(t){for(var e=0,r=this.H;r!==this.h;)t([r.u,r.p],e++,this),r=r.m},e.prototype[Symbol.iterator]=function(){return function(){var t;return ht(this,(function(e){switch(e.label){case 0:t=this.H,e.label=1;case 1:return t===this.h?[3,3]:[4,[t.u,t.p]];case 2:return e.sent(),t=t.m,[3,1];case 3:return[2]}}))}.bind(this)()},e}(st)},function(t,e,r){"use strict";r.r(e);var n=r(20),o=r.n(n),i=r(3),s=r.n(i),a=r(4),u=r.n(a),c=r(5),l=r.n(c),f=r(2),h=r.n(f),p=r(1),d=r.n(p),m=r(7),y=r.n(m);var g=function(t){return t=t||Object.create(null),{on:function(e,r){(t[e]||(t[e]=[])).push(r)},off:function(e,r){t[e]&&t[e].splice(t[e].indexOf(r)>>>0,1)},emit:function(e,r){(t[e]||[]).slice().map((function(t){t(r)})),(t["*"]||[]).slice().map((function(t){t(e,r)}))}}},v=r(6),b=r.n(v),_=r(50),w=r.n(_),k=r(51),S=r.n(k),x=r(52);function E(t){return t.replace(/<[^>]*\/?>([\s\S]*)?<\/.*?>/gi,(function(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}))}var A=function(){return l()((function t(e){u()(this,t),this.roomAdapter=e,this.name=null,this.emails=[],this.options={}}),[{key:"withName",value:function(t){return this.name=t,this}},{key:"withOptions",value:function(t){return this.options=t,this}},{key:"addParticipants",value:function(){for(var t,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return this.emails=(t=this.emails.filter((function(t){return-1===r.indexOf(t)}))).concat.apply(t,r),this}},{key:"create",value:function(){var t=this.name,e=this.emails,r=this.options;return this.roomAdapter.createRoom(t,e,{avatarURL:r.avatarURL},r)}}])}();var T=function(){return l()((function t(e){u()(this,t),this.id=e.id,this.before_id=e.comment_before_id,this.message=E(e.message),this.username_as=e.username_as||e.username,this.username_real=e.username_real||e.email,this.email=this.username_real,this.user_extras=e.user_extras,this.date=Object(x.format)(e.timestamp,"YYYY-MM-DD"),this.time=Object(x.format)(e.timestamp,"HH:mm"),this.timestamp=e.timestamp,this.unique_id=e.unique_temp_id||e.unique_id,this.unique_temp_id=e.unique_temp_id||e.unique_id,this.avatar=e.user_avatar_url,this.room_id=e.room_id,this.isChannel=e.is_public_channel,this.unix_timestamp=e.unix_timestamp,this.unix_nano_timestamp=e.unix_nano_timestamp,this.extras=e.extras,this.is_deleted=e.is_deleted,this.isPending=!1,this.isFailed=!1,this.isDelivered=!1,this.isRead=!1,this.isSent=!1,this.attachment=null,this.payload=e.payload,this.status=e.status,"reply"===e.type&&(e.payload.replied_comment_message=E(e.payload.replied_comment_message),e.payload.text=E(e.payload.text)),this.type=e.type,this.subtype="custom"===e.type?e.payload.type:null,"sent"===e.status?this.markAsSent():"delivered"===e.status?this.markAsDelivered():"read"===e.status&&this.markAsRead()}),[{key:"isAttachment",value:function(t){return"[file]"===t.substring(0,"[file]".length)}},{key:"isImageAttachment",value:function(t){return this.isAttachment(t)&&null!=t.match(/\.(jpg|jpeg|gif|png)/i)}},{key:"attachUniqueId",value:function(t){this.unique_id=t}},{key:"getAttachmentURI",value:function(t){if(this.isAttachment(t)){var e=t.length,r="[file]".length,n=e-"[/file]".length;return t.substring(r,n).trim()}}},{key:"setAttachment",value:function(t){this.attachment=t}},{key:"markAsPending",value:function(){this.isPending=!0,this.isDelivered=!1,this.status="pending"}},{key:"markAsSent",value:function(){this.isSent=!0,this.isPending=!1,this.isFailed=!1,this.status="sent"}},{key:"markAsDelivered",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.actor,r=t.activeActorId;e!==r&&(this.isRead||"read"===this.status||(this.isSent=!0,this.isRead=!1,this.isDelivered=!0,this.status="delivered"))}},{key:"markAsRead",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.actor,r=t.activeActorId;e!==r&&(this.isPending=!1,this.isSent=!0,this.isDelivered=!0,this.isRead=!0,this.status="read")}},{key:"markAsFailed",value:function(){this.isFailed=!0,this.isPending=!1,this.isStatus="failed"}},{key:"update",value:function(t){this.id=t.id,this.before_id=t.comment_before_id,this.message=E(t.message),t.payload&&(this.payload=t.payload),t.status&&(this.status=t.status),"reply"===t.type&&(this.payload.replied_comment_message=E(t.payload.replied_comment_message),this.payload.text=E(t.payload.text)),"sent"===t.status?this.markAsSent():"delivered"===t.status?this.markAsDelivered():"read"===t.status&&this.markAsRead()}}])}(),P=function(){return l()((function t(e){u()(this,t),this.id=e.id,this.last_comment_id=e.last_comment_id,this.last_comment_message=e.last_comment_message,this.last_comment_message_created_at=e.last_comment_message_created_at,this.last_comment_topic_title=e.last_comment_topic_title,this.avatar=e.room_avatar||e.avatarURL||e.avatar_url,this.name=e.room_name,this.room_type=e.room_type||e.chat_type,this.secret_code=e.secret_code,this.participants=e.participants,this.options=e.options,this.topics=[],this.last_comment=e.last_comment,this.comments=[],this.count_notif=e.unread_count,this.isLoaded=!1,this.custom_title=null,this.custom_subtitle=null,this.options=e.options,this.unique_id=e.unique_id,this.isChannel=e.is_public_channel,this.participantNumber=e.room_total_participants,e.comments&&this.receiveComments(e.comments)}),[{key:"isCurrentlySelected",value:function(t){return this.id===t.id}},{key:"getParticipantCount",value:function(){return null==this.participants?this.participantNumber:this.participants.length}},{key:"setTitle",value:function(t){this.custom_title=t}},{key:"setSubTitle",value:function(t){this.custom_subtitle=t}},{key:"receiveComment",value:function(t){if(t.room_id===this.id){var e=this.comments.find((function(e){return e.unique_id===t.unique_id}));e?(e.id=t.id,e.message=t.message,e.date=t.date,e.time=t.time,e.unix_timestamp=t.unix_timestamp):this.comments=[].concat(o()(this.comments),[t])}}},{key:"receiveComments",value:function(t){var e=this;t.forEach((function(t){e.receiveComment(new T(t))}))}},{key:"getParticipant",value:function(t){return this.participants.find((function(e){return e.email===t}))||null}},{key:"addParticipant",value:function(t){this.getParticipant(t.email)||this.participants.push(t)}}])}(),I=function(){return l()((function t(e){var r=e.baseURL,n=e.AppId,o=e.userId,i=e.version,s=e.getCustomHeader;u()(this,t),this.baseURL=r,this.token=null,this.userId=o,this.AppId=n,this.version=i,this.getCustomHeader=s}),[{key:"setToken",value:function(t){this.token=t}},{key:"get",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(o,i){var s=y.a.get("".concat(e.baseURL,"/").concat(t));n&&n.baseURL&&(s=y.a.get("".concat(n.baseURL,"/").concat(t))),(s=e.setupHeaders(s,r)).end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"get_request",value:function(t){var e=y.a.get("".concat(this.baseURL,"/").concat(t));return e=this.setupHeaders(e,{})}},{key:"post",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.post("".concat(e.baseURL,"/").concat(t));(s=e.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"post_json",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.post("".concat(e.baseURL,"/").concat(t));(s=e.setupHeaders(s,n)).send(r).set("Content-Type","application/json").end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"put",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.put("".concat(e.baseURL,"/").concat(t));(s=e.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"patch",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.patch("".concat(e.baseURL,"/").concat(t));(s=e.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"del",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.del("".concat(e.baseURL,"/").concat(t));(s=e.setupHeaders(s,n)).send(r).set("Content-Type","application/json").end((function(t,r){return t?(e._rethrowIfExpiredToken(t),i(t)):o(r)}))}))}},{key:"setupHeaders",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.AppId&&t.set("QISCUS-SDK-APP-ID","".concat(this.AppId)),null!=this.userId&&t.set("QISCUS-SDK-USER-ID","".concat(this.userId)),null!=this.token&&t.set("QISCUS-SDK-TOKEN","".concat(this.token)),null!=this.version&&t.set("QISCUS-SDK-VERSION","".concat(this.version)),null!=this.getCustomHeader){var r=this.getCustomHeader();Object.keys(r).filter((function(t){return null!=r[t]})).forEach((function(e){t.set(e,r[e])}))}if(Object.keys(e).length<1)return t;for(var n in e)e.hasOwnProperty(n)&&t.set(n,e[n]);return t}},{key:"_rethrowIfExpiredToken",value:function(t){var e,r,n,o=null===(e=t.response)||void 0===e?void 0:e.status,i=null===(r=t.response)||void 0===r?void 0:r.body;if(403===o&&"unauthorized. token is expired"===(null===(n=i.error)||void 0===n||null===(n=n.message)||void 0===n?void 0:n.toLowerCase()))throw new Error("Token expired")}}])}(),O=function(){return l()((function t(e){u()(this,t),this.HTTPAdapter=e,this.refreshToken=null,this.userId=null,this.autoRefreshToken=!1}),[{key:"getNonce",value:function(){return this.HTTPAdapter.post("api/v2/sdk/auth/nonce").then((function(t){return t.body.results}))}},{key:"loginOrRegister",value:function(t){var e=this;return this.HTTPAdapter.post("api/v2/sdk/login_or_register",t).then((function(t){if(200!==t.body.status)return Promise.reject(t);var r=t.body.results;return e.userId=r.user.email,e.refreshToken=r.user.refresh_token,r}))}},{key:"verifyIdentityToken",value:function(t){var e=this;return this.HTTPAdapter.post("api/v2/sdk/auth/verify_identity_token",{identity_token:t}).then((function(t){var r=t.body.results;return e.userId=r.user.email,e.refreshToken=r.user.refresh_token,r}))}},{key:"refreshAuthToken",value:function(){var t=this;return this.HTTPAdapter.post("api/v2/sdk/refresh_user_token",{user_id:this.userId,refresh_token:this.refreshToken}).then((function(e){var r=e.body.results;return t.refreshToken=r.refresh_token,t.HTTPAdapter.token=r.token,r}))}},{key:"expiredAuthToken",value:function(){return this.HTTPAdapter.post("api/v2/sdk/expire_user_token",{user_id:this.userId}).then((function(t){return t.body.results}))}}])}(),M=r(119),C=r.n(M);function R(t){var e={},r=function(t,e){return"".concat(t,"=").concat(e)};return{param:function(t,r){return e[t]=r,this},build:function(){var n=Object.keys(e).filter((function(t){return null!=e[t]})).map((function(t){return Array.isArray(e[t])?e[t].map((function(e){return r("".concat(t,"[]"),e)})).join("&"):r(t,e[t])})).join("&");return[t].concat(n).join("?")}}}var D=function(){return l()((function t(e){var r=this;u()(this,t),h()(this,"updateCommentStatus",C()((function(t,e,n){var o={room_id:t};return e&&(o.last_comment_read_id=e),n&&(o.last_comment_received_id=n),r.HTTPAdapter.post("api/v2/sdk/update_comment_status",o)}),500)),this.HTTPAdapter=e,this.token=e.token}),[{key:"postComment",value:function(t,e,r,n,o,i){return this.HTTPAdapter.post_json("api/v2/sdk/post_comment",{comment:e,topic_id:t,unique_temp_id:r,type:n,payload:o,extras:i}).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.comment)}))}},{key:"loadRoomList",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=R("api/v2/sdk/user_rooms").param("page",e.page).param("show_participants",e.show_participants||!0).param("limit",e.limit).param("show_empty",e.show_empty).param("room_type",null!==(t=e.room_type)&&void 0!==t?t:"default").build();return this.HTTPAdapter.get(r).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.rooms_info)}))}},{key:"searchMessages",value:function(t){var e={query:t.query||null,room_id:t.room_id||null,last_comment_id:t.last_comment_id||null};return this.HTTPAdapter.post("api/v2/sdk/search_messages",e).then((function(t){return t.body.results.comments}))}},{key:"updateProfile",value:function(t){var e={name:t.name||null,avatar_url:t.avatar_url||null,extras:t.extras?JSON.stringify(t.extras):null};return this.HTTPAdapter.patch("api/v2/sdk/my_profile",e).then((function(t){return t.body.results.user}))}},{key:"uploadFile",value:function(t){var e={file:t};return this.HTTPAdapter.post("api/v2/sdk/upload",e).then((function(t){return t.body}))}},{key:"getRoomsInfo",value:function(t){var e={show_participants:!0,show_removed:!1};return t.room_ids&&(e.room_id=t.room_ids),t.room_unique_ids&&(e.room_unique_id=t.room_unique_ids),t.show_participants&&(e.show_participants=t.show_participants),t.show_removed&&(e.show_removed=t.show_removed),this.HTTPAdapter.post_json("api/v2/sdk/rooms_info",e).then((function(t){return t.body}))}},{key:"loadComments",value:function(t,e){var r=R("api/v2/sdk/load_comments").param("topic_id",t).param("last_comment_id",e.last_comment_id).param("timestamp",e.timestamp).param("after",e.after).param("limit",e.limit).build();return this.HTTPAdapter.get(r).then((function(t){return 200!==t.status?Promise.reject(t):Promise.resolve(t.body.results.comments)}))}},{key:"deleteComment",value:function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!1===r&&console.warn("Deprecated: delete comment for me will be removed on next release"),!1===n&&console.warn("Deprecated: soft delete will be removed on next release");var o={unique_ids:e,is_delete_for_everyone:r,is_hard_delete:n};return this.HTTPAdapter.del("api/v2/sdk/delete_messages",o).then((function(t){return t.body}))}},{key:"clearRoomMessages",value:function(t){var e={room_channel_ids:t};return this.HTTPAdapter.del("api/v2/sdk/clear_room_messages",e).then((function(t){return t.body}))}},{key:"getCommentReceiptStatus",value:function(t){return this.HTTPAdapter.get("api/v2/sdk/comment_receipt?comment_id=".concat(t)).then((function(t){return t.body}))}},{key:"getBlockedUser",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r="api/v2/sdk/get_blocked_users?page=".concat(t,"&limit=").concat(e);return this.HTTPAdapter.get(r).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.blocked_users)}))}},{key:"blockUser",value:function(t){if(!t)throw new Error("email is required");var e={user_email:t};return this.HTTPAdapter.post("api/v2/sdk/block_user",e).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.user)}))}},{key:"unblockUser",value:function(t){if(!t)throw new Error("email is required");var e={user_email:t};return this.HTTPAdapter.post("api/v2/sdk/unblock_user",e).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.user)}))}},{key:"getProfile",value:function(){return this.HTTPAdapter.get("api/v2/sdk/my_profile").then((function(t){return t.body.results.user}))}},{key:"getUserPresences",value:function(t){var e={user_ids:t};return this.HTTPAdapter.post_json("api/v2/sdk/users/status",e).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.user_status)}))}},{key:"updateMessage",value:function(t){var e={token:this.token,comment:t.message,unique_id:t.unique_id||t.unique_temp_id};return null!=t.extras&&(e.extras=t.extras),null!=t.payload&&(e.payload=t.payload),this.HTTPAdapter.post_json("api/v2/sdk/update_message",e).then((function(t){return t.body.results.comment}))}}])}(),j=function(){return l()((function t(e){u()(this,t),this.HTTPAdapter=e,this.token=e.token}),[{key:"getOrCreateRoom",value:function(t,e,r){var n={emails:t};return r&&(n[r]=r),e&&(n.options=JSON.stringify(e)),this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_target",n).then((function(e){if(200!==e.body.status)return Promise.reject(e);var r=e.body.results.room;r.avatar=r.avatar_url,r.comments=e.body.results.comments.reverse();var n=r.participants.find((function(e){return e.email===t}));return r.name=n?n.username:"Room name",Promise.resolve(r)}))}},{key:"getRoomById",value:function(t){return this.HTTPAdapter.get("api/v2/sdk/get_room_by_id?id=".concat(t)).then((function(t){return t.body}))}},{key:"getOrCreateRoomByUniqueId",value:function(t,e,r){var n={unique_id:t,name:e,avatar_url:r};return this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_unique_id",n).then((function(t){if(200!==t.body.status)return Promise.reject(t);var e=t.body.results.room;return e.avatar=e.avatar_url,e.comments=t.body.results.comments.reverse(),e.name=e.room_name,Promise.resolve(e)}))}},{key:"createRoom",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=Object.keys(n).length<=0?null:JSON.stringify(n),i={name:t,"participants[]":e,avatar_url:r.avatarURL,options:o};return this.HTTPAdapter.post("api/v2/sdk/create_room",i).then((function(t){if(200!==t.body.status)return Promise.reject(t);var e=t.body.results.room;return e.comments=t.body.results.comments,Promise.resolve({id:e.id,name:e.room_name,lastCommentId:e.last_comment_id,lastCommentMessage:e.last_comment_message,lastTopicId:e.last_topic_id,avatarURL:e.avatar_url,options:e.options,participants:e.participants.map((function(t){return{id:t.id,email:t.email,username:t.username,avatarURL:t.avatar_url}}))})}))}},{key:"updateRoom",value:function(t){if(!t.id)throw new Error("id is required");var e={id:t.id};return t.room_name&&(e.room_name=t.room_name),t.avatar_url&&(e.avatar_url=t.avatar_url),t.options&&(e.options=JSON.stringify(t.options)),this.HTTPAdapter.post("api/v2/sdk/update_room",e).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.room)}))}},{key:"getTotalUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/total_unread_count").then((function(t){return t.body.results.total_unread_count}))}},{key:"getRoomUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/get_room_unread_count").then((function(t){return t.body.results.total_unread_count}))}},{key:"addParticipantsToGroup",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t||!e)throw new Error("room_id and emails is required");var r={room_id:t,"emails[]":e};return this.HTTPAdapter.post("api/v2/sdk/add_room_participants",r).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.participants_added)}))}},{key:"removeParticipantsFromGroup",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t||!e)throw new Error("room_id and emails is required");var r={room_id:t,"emails[]":e};return this.HTTPAdapter.post("api/v2/sdk/remove_room_participants",r).then((function(t){return 200!==t.body.status?Promise.reject(t):Promise.resolve(t.body.results.participants_removed)}))}}])}(),L=r(120),N=r.n(L),B=r(26),F=r.n(B),U=String("match.pattern.catchAll"),q=String("match.pattern.OR"),H=q.toString(),W=String("match.pattern.AND"),K=W.toString(),Y=String("match.pattern.RANGE"),z=Y.toString(),$=String("match.pattern.REGEXP"),V=$.toString(),G=/\/(.*)\/(.*)/;function Q(){Error.call(this,"Missing when() catch-all pattern as last match argument, add [when()]: void 0"),"stack"in this||(this.stack=(new Error).stack)}function J(t){return void 0===t?U:t instanceof RegExp?X([$.toString(),t.toString()]):X(t)}function X(t){return JSON.stringify([J.__uid++,t])}function Z(){return!0}function tt(t){if(Array.isArray(t)){if(t[0]===H)return t.shift(),function(e){return t[0].some((function(t){return r(t,e)}))};if(t[0]===K)return t.shift(),function(e){return t[0].every((function(t){return r(t,e)}))};if(t[0]===z)return t.shift(),function(e){return t[0]<=e&&e<=t[1]};if(t[0]===V){var e=G.exec(t[1]);return r.bind(null,new RegExp(e[1],e[2]))}}function r(t,e){if(Array.isArray(e))return JSON.stringify(t)===JSON.stringify(e);if(t instanceof RegExp)return t.test(e);if("object"===F()(e)){for(var r in t)if(e[r]!==t[r])return!1;return!0}return t===e}return function(e){return r(t,e)}}Q.prototype=Object.create(Error.prototype),J.__uid=0,J.or=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return X([q.toString(),e])},J.and=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return X([W.toString(),e])},J.range=function(t,e){return X([Y.toString(),t,e])},J.unserialize=function(t,e){if(t===U)return{match:Z,result:e,position:1/0};var r,n=(r=t,JSON.parse(r)),o=n[1],i=n[0];return{match:tt(o),result:e,position:i}};var et=r(121),rt=r.n(et),nt=r(122),ot=r.n(nt),it=function(t,e,r,n){try{var o=t();return null!=n&&n(o),o}catch(t){return null!=r&&r(t),e}},st=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(e){return setTimeout(e,t)}))},at=function(){return l()((function t(e,r,n,o){var i=this,a=o.shouldConnect,c=void 0===a||a,l=o.brokerLbUrl,f=o.enableLb,p=o.getClientId;u()(this,t),h()(this,"_getClientId",(function(){return null==i.getClientId?"".concat(i.core.AppId,"_").concat(i.core.user_id,"_").concat(Date.now()):i.getClientId()})),h()(this,"__mqtt_connected_handler",(function(){i.emitter.emit("connected")})),h()(this,"__mqtt_reconnect_handler",(function(){i.emitter.emit("reconnect")})),h()(this,"__mqtt_closed_handler",(function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];i.emitter.emit("close",e)})),h()(this,"__mqtt_message_handler",(function(t,e){var r=e.toString(),n=i.matcher(t);i.logger("message",t,e),null!=n&&n(r)})),h()(this,"__mqtt_error_handler",(function(t){t&&"client disconnecting"===t.message||(i.emitter.emit("error",t.message),i.logger("error",t.message))})),h()(this,"__mqtt_conneck",(function(t){var e=[],r={will:{topic:"u/".concat(i.core.user_id,"/s"),payload:0,retain:!0},clientId:i._getClientId()};if(null==t&&(t=i.cacheRealtimeURL),null!=i.mqtt){var n=Object.keys(i.mqtt._resubscribeTopics);e.push.apply(e,n),i.mqtt.removeAllListeners(),i.mqtt.end(!0),delete i.mqtt,i.mqtt=null}var o=rt()(t,r);return o.addListener("connect",i.__mqtt_connected_handler),o.addListener("reconnect",i.__mqtt_reconnect_handler),o.addListener("close",i.__mqtt_closed_handler),o.addListener("error",i.__mqtt_error_handler),o.addListener("message",i.__mqtt_message_handler),i.logger("resubscribe to old topics ".concat(e)),e.forEach((function(t){return o.subscribe(t)})),o})),h()(this,"_on_close_handler",ot()(s()(d.a.mark((function t(){var e,r,n,o;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=!0===i.enableLb&&!0===i.core.isLogin&&!0===i.shouldConnect&&!i.willConnectToRealtime,i.logEnabled&&(console.group("@mqtt.closed"),console.log("this.enableLb(".concat(i.enableLb,")")),console.log("this.core.isLogin(".concat(i.core.isLogin,")")),console.log("this.shouldConnect(".concat(i.shouldConnect,")")),console.log("this.willConnectToRealtime(".concat(i.willConnectToRealtime,")")),console.log("shouldReconnect(".concat(e,")")),console.groupEnd()),e){t.next=4;break}return t.abrupt("return");case 4:return i.willConnectToRealtime=!0,t.next=7,i.getMqttNode().then((function(t){return[t,null]})).catch((function(t){return[null,t]}));case 7:r=t.sent,n=N()(r,2),o=n[0],n[1]?(i.logger("cannot get new brokerURL, using old url instead (".concat(i.cacheRealtimeURL,")")),i.mqtt=i.__mqtt_conneck(i.cacheRealtimeURL)):(i.cacheRealtimeURL=o,i.logger("trying to reconnect to",o),i.mqtt=i.__mqtt_conneck(o)),i.willConnectToRealtime=!1;case 13:case"end":return t.stop()}}),t)}))),1e3)),h()(this,"subscribtionBuffer",[]),h()(this,"unsubscribtionBuffer",[]),h()(this,"publishBuffer",[]),this.emitter=g(),this.core=r,this.mqtt=null,this.brokerLbUrl=l,this.getClientId=p,this.enableLb=f,this.shouldConnect=c,this.matcher=function(){var t,e=(t=arguments.length-1)<0||arguments.length<=t?void 0:arguments[t],r=[];for(var n in e)r.push(J.unserialize(n,e[n]));r.sort((function(t,e){return t.position<e.position?-1:1})),-1!==Object.getOwnPropertySymbols(e).indexOf(U)&&r.push(J.unserialize(U,e[U]));var o=function(t){var e=r.find((function(e){return e.match(t)}));if(!e)throw new Q;return"function"==typeof e.result?e.result(t):e.result};return 2===arguments.length?o(arguments.length<=0?void 0:arguments[0]):o}(h()(h()(h()(h()(h()(h()(h()(h()(h()({},J(this.reNewMessage),(function(t){return i.newMessageHandler.bind(i,t)})),J(this.reNotification),(function(t){return i.notificationHandler.bind(i,t)})),J(this.reTyping),(function(t){return i.typingHandler.bind(i,t)})),J(this.reDelivery),(function(t){return i.deliveryReceiptHandler.bind(i,t)})),J(this.reRead),(function(t){return i.readReceiptHandler.bind(i,t)})),J(this.reOnlineStatus),(function(t){return i.onlinePresenceHandler.bind(i,t)})),J(this.reChannelMessage),(function(t){return i.channelMessageHandler.bind(i,t)})),J(this.reMessageUpdated),(function(t){return i.messageUpdatedHandler.bind(i,t)})),J(),(function(t){return i.logger("topic not handled",t)})));var m=this.__mqtt_conneck(e);this.mqtt=m,c||m.end(!0),this.willConnectToRealtime=!1,this.emitter.on("close",this._on_close_handler)}),[{key:"cacheRealtimeURL",get:function(){return this.core.mqttURL},set:function(t){this.core.mqttURL=t}},{key:"connect",value:function(){this.mqtt=this.__mqtt_conneck()}},{key:"openConnection",value:(r=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.shouldConnect=!0,this.__mqtt_conneck();case 2:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"closeConnection",value:(e=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.shouldConnect=!1,this.mqtt.end(!0);case 2:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"getMqttNode",value:(t=s()(d.a.mark((function t(){var e,r,n;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y.a.get(this.brokerLbUrl);case 2:return e=t.sent,r=e.body.data.url,n=e.body.data.wss_port,t.abrupt("return","wss://".concat(r,":").concat(n,"/mqtt"));case 6:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"connected",get:function(){return null!=this.mqtt&&this.mqtt.connected}},{key:"subscribe",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(this.logger("subscribe to",e),this.subscribtionBuffer.push(e),null!=this.mqtt)do{var n,o=this.subscribtionBuffer.shift();null!=o&&(n=this.mqtt).subscribe.apply(n,e)}while(this.subscribtionBuffer.length>0)}},{key:"unsubscribe",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];if(this.logger("unsubscribe from",e),this.unsubscribtionBuffer.push(e),null!=this.mqtt)do{var n,i=this.unsubscribtionBuffer.shift();if(null!=i)(n=this.mqtt).unsubscribe.apply(n,o()(i))}while(this.unsubscribtionBuffer.length>0)}},{key:"publish",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.publishBuffer.push({topic:t,payload:e,options:r});do{var n=this.publishBuffer.shift();if(null!=n)return this.mqtt.publish(n.topic,n.payload.toString(),n.options)}while(this.publishBuffer.length>0)}},{key:"emit",value:function(){var t;(t=this.emitter).emit.apply(t,arguments)}},{key:"on",value:function(){var t;(t=this.emitter).on.apply(t,arguments)}},{key:"off",value:function(){var t;(t=this.emitter).off.apply(t,arguments)}},{key:"logEnabled",get:function(){return this.core.debugMQTTMode}},{key:"logger",get:function(){return this.core.debugMQTTMode?console.log.bind(console,"QRealtime ->"):this.noop}},{key:"reNewMessage",get:function(){return/^(.+)\/c$/i}},{key:"reNotification",get:function(){return/^(.+)\/n$/i}},{key:"reTyping",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/t$/i}},{key:"reDelivery",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/d$/i}},{key:"reRead",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/r$/i}},{key:"reOnlineStatus",get:function(){return/^u\/(.+)\/s$/i}},{key:"reChannelMessage",get:function(){return/^(.+)\/(.+)\/c$/i}},{key:"reMessageUpdated",get:function(){return/^(.+)\/update$/i}},{key:"noop",value:function(){}},{key:"newMessageHandler",value:function(t,e){e=JSON.parse(e),this.logger("on:new-message",e),this.emit("new-message",e)}},{key:"notificationHandler",value:function(t,e){var r=this;this.logger("on:notification",e);var n=(e=JSON.parse(e)).payload.data;"deleted_messages"in n&&n.deleted_messages.forEach((function(t){r.emit("comment-deleted",{roomId:t.room_id,commentUniqueIds:t.message_unique_ids,isForEveryone:!0,isHard:!0})})),"deleted_rooms"in n&&n.deleted_rooms.forEach((function(t){r.emit("room-cleared",t)}))}},{key:"typingHandler",value:function(t,e){this.logger("on:typing",t);var r=t.match(this.reTyping);if(r[3]!==this.core.user_id){var n=r[3],o=r[1];if(this.emit("typing",{message:e,userId:n,roomId:o}),null!=this.core.selected)if("1"===e&&o===this.core.selected.id){var i=this.core.selected.participants.find((function(t){return t.email===n}));if(null==i)return;var s=i.username;this.core.isTypingStatus="".concat(s," is typing ...")}else this.core.isTypingStatus=null}}},{key:"deliveryReceiptHandler",value:function(t,e){this.logger("on:delivered",t,e);var r=t.match(this.reDelivery),n=e.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-delivered",{commentId:o,commentUniqueId:i,userId:s})}},{key:"readReceiptHandler",value:function(t,e){this.logger("on:read",t,e);var r=t.match(this.reRead),n=e.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-read",{commentId:o,commentUniqueId:i,userId:s})}},{key:"onlinePresenceHandler",value:function(t,e){this.logger("on:online-presence",t,e);var r=this.reOnlineStatus.exec(t)[1];this.emit("presence",{message:e,userId:r})}},{key:"channelMessageHandler",value:function(t,e){this.logger("on:channel-message",t,e),this.emit("new-message",JSON.parse(e))}},{key:"messageUpdatedHandler",value:function(t,e){e=JSON.parse(e),this.logger("on:message-updated",t,e),this.emit("message:updated",e)}},{key:"subscribeChannel",value:function(t,e){this.subscribe("".concat(t,"/").concat(e,"/c"))}},{key:"subscribeRoom",value:function(t){null!=this.core.selected&&(t=t||this.core.selected.id,this.subscribe("r/".concat(t,"/").concat(t,"/+/t")),this.subscribe("r/".concat(t,"/").concat(t,"/+/d")),this.subscribe("r/".concat(t,"/").concat(t,"/+/r")))}},{key:"unsubscribeRoom",value:function(t){null!=this.core.selected&&(t=t||this.core.selected.id,this.unsubscribe("r/".concat(t,"/").concat(t,"/+/t")),this.unsubscribe("r/".concat(t,"/").concat(t,"/+/d")),this.unsubscribe("r/".concat(t,"/").concat(t,"/+/r")))}},{key:"subscribeTyping",get:function(){return this.subscribeRoom.bind(this)}},{key:"unsubscribeTyping",get:function(){return this.unsubscribeRoom.bind(this)}},{key:"subscribeUserChannel",value:function(){this.subscribe("".concat(this.core.userData.token,"/c")),this.subscribe("".concat(this.core.userData.token,"/n")),this.subscribe("".concat(this.core.userData.token,"/update"))}},{key:"publishPresence",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e?this.publish("u/".concat(t,"/s"),1,{retain:!0}):this.publish("u/".concat(t,"/s"),0,{retain:!0})}},{key:"disconnect",value:function(){this.publishPresence(this.core.userData.email,!1),this.unsubscribe(Object.keys(this.mqtt._resubscribeTopics))}},{key:"subscribeUserPresence",value:function(t){this.subscribe("u/".concat(t,"/s"))}},{key:"unsubscribeUserPresence",value:function(t){this.unsubscribe("u/".concat(t,"/s"))}},{key:"subscribeRoomPresence",get:function(){return this.subscribeUserPresence.bind(this)}},{key:"unsubscribeRoomPresence",get:function(){return this.unsubscribeUserPresence.bind(this)}},{key:"publishTyping",value:function(t){if(null!=this.core.selected){var e=this.core.selected.id,r=this.core.user_id;this.publish("r/".concat(e,"/").concat(e,"/").concat(r,"/t"),t)}}}]);var t,e,r}();function ut(t,e){var r=g(),n={},o=/^r\/[\w]+\/[\w]+\/e$/i;t.mqtt.on("message",(function(t,e){o.test(t)&&r.emit(t,e)}));var i=function(t){return"r/".concat(t,"/").concat(t,"/e")};return{publishEvent:function(r,n){if(b.a.undefined(r))throw new Error("`roomId` required");if(b.a.not.string(r))throw new TypeError("`roomId` must have type of string");if(b.a.undefined(n))throw new Error("`payload` required");if(b.a.not.object(n))throw new TypeError("`payload` must have type of object");var o=JSON.stringify({sender:e,data:n});t.mqtt.publish(i(r),o)},subscribeEvent:function(e,o){if(b.a.undefined(e))throw new Error("`roomId` required");if(b.a.not.string(e))throw new TypeError("`roomId` must have type of string");if(b.a.undefined(o))throw new Error("`callback` required");if(b.a.not.function(o))throw new TypeError("`callback` must have type of function");var s=i(e);if(!n[s]){t.mqtt.subscribe(s);var a=function(t){var e=JSON.parse(t);o(e)};r.on(s,a),n[s]=a}},unsubscribeEvent:function(e){if(b.a.undefined(e))throw new Error("`roomId` required");if(b.a.not.string(e))throw new TypeError("`roomId` must have type of string");var o=i(e);n[o]&&(t.mqtt.unsubscribe(o),r.off(o,n[o]),n[o]=null,delete n[o])}}}var ct=r(53),lt=r.n(ct),ft=r(54),ht=r.n(ft);function pt(t){var e,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(e=t[r]))return e.call(t);if(n&&null!=(e=t[n]))return new dt(e.call(t));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function dt(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return(dt=function(t){this.s=t,this.n=t.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new dt(t)}var mt=function(){},yt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};function gt(t,e){var r=e.isDebug,n=void 0!==r&&r,o=e.syncInterval,i=e.getShouldSync,a=e.syncOnConnect,u=e.lastCommentId,c=e.statusLogin,l=e.enableSync,f=e.enableSyncEvent,h=g(),p=function(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return n?(t=console).log.apply(t,["QSync:"].concat(r)):{}},m=0,y=function(){return c()?i()?o():a():0},v=function(t,e,r,n,o){var i=g(),a=function(r){var n=R("api/v2/sdk/sync").param("last_received_comment_id",r).build();return t().get(n).then((function(t){var r=t.body.results,n=r.comments,o=r.meta.last_received_comment_id;return n.sort((function(t,e){return t.id-e.id})),Promise.resolve({lastMessageId:o,messages:n,interval:e()})})).catch(mt)};function u(){return c.apply(this,arguments)}function c(){return(c=ht()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=t()&&r()};case 3:if(!((i+=s)>=e()&&u())){o.next=9;break}return i=0,o.next=9,a(n());case 9:return o.next=11,lt()(yt(s));case 11:o.next=3;break;case 13:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function t(){var e,r,s,a,c,l,f,h;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!1,r=!1,t.prev=2,a=pt(u());case 4:return t.next=6,a.next();case 6:if(!(e=!(c=t.sent).done)){t.next=12;break}l=c.value;try{f=l.lastMessageId,h=l.messages,f>n()&&(h.forEach((function(t){return i.emit("message.new",t)})),i.emit("last-message-id.new",f))}catch(t){o("error when sync",t.message)}case 9:e=!1,t.next=4;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(2),r=!0,s=t.t0;case 18:if(t.prev=18,t.prev=19,!e||null==a.return){t.next=23;break}return t.next=23,a.return();case 23:if(t.prev=23,!r){t.next=26;break}throw s;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})))()}}}(t,y,(function(){return i()&&l()}),u,p);v.on("last-message-id.new",(function(t){return t})),v.on("message.new",(function(t){return h.emit("message.new",t)})),v.run().catch((function(t){return p("got error when sync",t)}));var b=function(t,e,r,n,o){var i=g(),a=function(r){var n=R("api/v2/sdk/sync_event").param("start_event_id",r).build();return t().get(n).then((function(t){var r=t.body.events,n=r.map((function(t){return t.id})).sort((function(t,e){return t-e})).pop(),o=r.filter((function(t){return"delivered"===t.action_topic})).map((function(t){return t.payload.data})),i=r.filter((function(t){return"read"===t.action_topic})).map((function(t){return t.payload.data})),s=r.filter((function(t){return"delete_message"===t.action_topic})).map((function(t){return t.payload.data})),a=r.filter((function(t){return"clear_room"===t.action_topic})).map((function(t){return t.payload.data}));return Promise.resolve({lastId:n,messageDelivered:o,messageRead:i,messageDeleted:s,roomCleared:a,interval:e()})})).catch(mt)};function u(){return c.apply(this,arguments)}function c(){return(c=ht()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=t()&&r()};case 3:if(!((i+=s)>=e()&&u())){o.next=9;break}return i=0,o.next=9,a(n());case 9:return o.next=11,lt()(yt(s));case 11:o.next=3;break;case 13:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function t(){var e,r,s,a,c,l,f;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=!1,r=!1,t.prev=2,a=pt(u());case 4:return t.next=6,a.next();case 6:if(!(e=!(c=t.sent).done)){t.next=12;break}l=c.value;try{(f=l.lastId)>n()&&(i.emit("last-event-id.new",f),l.messageDelivered.forEach((function(t){return i.emit("message.delivered",t)})),l.messageDeleted.forEach((function(t){return i.emit("message.deleted",t)})),l.messageRead.forEach((function(t){return i.emit("message.read",t)})),l.roomCleared.forEach((function(t){return i.emit("room.cleared",t)})))}catch(t){o("error when sync event",t.message)}case 9:e=!1,t.next=4;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(2),r=!0,s=t.t0;case 18:if(t.prev=18,t.prev=19,!e||null==a.return){t.next=23;break}return t.next=23,a.return();case 23:if(t.prev=23,!r){t.next=26;break}throw s;case 26:return t.finish(23);case 27:return t.finish(18);case 28:case"end":return t.stop()}}),t,null,[[2,14,18,28],[19,,23,27]])})))()}}}(t,y,(function(){return i()&&f()}),(function(){return m}),p);return b.on("last-event-id.new",(function(t){m=t})),b.on("message.read",(function(t){h.emit("message.read",t)})),b.on("message.delivered",(function(t){return h.emit("message.delivered",t)})),b.on("message.deleted",(function(t){return h.emit("message.deleted",t)})),b.on("room.cleared",(function(t){return h.emit("room.cleared",t)})),b.run().catch((function(t){return p("got error when sync event",t)})),{get on(){return h.on},get off(){return h.off},synchronize:function(){v.synchronize()},synchronizeEvent:function(){b.synchronize()}}}var vt=r(123),bt={MESSAGE_BEFORE_SENT:"message::before-sent",MESSAGE_BEFORE_RECEIVED:"message::before-received"};var _t,wt=function(){return l()((function t(e){var r=e.httpAdapter,n=e.refreshToken,o=e.expiredAt,i=e.userId,s=e.onTokenRefreshed,a=e.getAuthenticationStatus;u()(this,t),h()(this,"_isExpiredTokenEnabled",!1),h()(this,"_refreshToken",null),h()(this,"_expiredAt",null),h()(this,"_http",void 0),h()(this,"_onTokenRefreshed",void 0),h()(this,"_timerId",void 0),h()(this,"_getAuthenticationStatus",void 0),this._http=r,this._refreshToken=n,this._userId=i,this._onTokenRefreshed=s,this._getAuthenticationStatus=a,null!=this._refreshToken&&""===this._refreshToken&&(this._refreshToken=null),null!=o&&""!==o&&(this._expiredAt=new Date(o)),this._isExpiredTokenEnabled=null!=this._refreshToken&&null!=this._expiredAt,this._checkToken()}),[{key:"_checkToken",value:(r=s()(d.a.mark((function t(){var e,r;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=5e3,0!=this._getAuthenticationStatus()&&null!=this._refreshToken){t.next=3;break}return t.abrupt("return");case 3:if(null==this._expiredAt||!this._isExpiredTokenEnabled){t.next=9;break}if(r=Date.now(),!(Math.floor((this._expiredAt-r)/1e3)<e/1e3)){t.next=9;break}return t.next=9,this.refreshAuthToken();case 9:return t.next=11,st(e);case 11:this._checkToken();case 12:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"refreshAuthToken",value:(e=s()(d.a.mark((function t(){var e=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._http.post("api/v2/sdk/refresh_user_token",{user_id:this._userId,refresh_token:this._refreshToken}).then((function(t){var r,n=t.body.results,o=n.token;return e._refreshToken=n.refresh_token,e._http.setToken(n.token),null!=n.token_expires_at&&(e._expiredAt=new Date(n.token_expires_at)),null===(r=e._onTokenRefreshed)||void 0===r||r.call(e,o,e._refreshToken,e._expiredAt),n})));case 1:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"logout",value:(t=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._http.post("api/v2/sdk/logout",{user_id:this._userId,token:this._http.token}));case 1:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,e,r}();function kt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function St(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?kt(Object(r),!0).forEach((function(e){h()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):kt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function xt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Et(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Et(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var At=Object.freeze({disabled:"UpdateCommentStatusMode.disabled",throttled:"UpdateCommentStatusMode.throttled",enabled:"UpdateCommentStatusMode.enabled"}),Tt=function(){function t(){var e,r,n=this;u()(this,t),h()(this,"_readComment",(function(t,e){return n._updateStatus(t,e)})),h()(this,"_readCommentT",this._throttle((function(t,e){n._updateStatus(t,e)}),(function(){return n._throttleDelay}))),h()(this,"_deliverComment",(function(t,e){return n._updateStatus(t,void 0,e)})),h()(this,"_deliverCommentT",this._throttle((function(t,e){n._updateStatus(t,void 0,e)}),(function(){return n._throttleDelay}))),this.events=g(),this.rooms=[],this.selected=null,this.room_name_id_map={},this.pendingCommentId=0,this.uploadedFiles=[],this.chatmateStatus=null,this.version="WEB_".concat(vt.version),this.userData={},this.AppId=null,this.baseURL="https://api.qiscus.com",this.mqttURL="wss://realtime-jogja.qiscus.com:1886/mqtt",this.brokerLbUrl="https://realtime-lb.qiscus.com",this.syncOnConnect=1e4,this.enableEventReport=!1,this.enableRealtime=!0,this.enableRealtimeCheck=!0,this.enableSync=!0,this.enableSyncEvent=!1,this.HTTPAdapter=null,this.expiredTokenAdapter=null,this.realtimeAdapter=null,this.customEventAdapter=null,this.isInit=!1,this.isSynced=!1,this.syncInterval=5e3,this.sync="socket",this.enableLb=!0,this.httpsync=null,this.eventsync=null,this.extras=null,this.last_received_comment_id=0,this.googleMapKey="",this.options={avatar:!0},this.isConfigLoaded=!1,this.updateCommentStatusMode=t.UpdateCommentStatusMode.enabled,this.updateCommentStatusThrottleDelay=300,this.UI={},this.mode="widget",this.avatar=!0,this.plugins=[],this.isLogin=!1,this.isLoading=!1,this.isInit=!1,this.emoji=!1,this.isTypingStatus="",this.customTemplate=!1,this.templateFunction=null,this.debugMode=!1,this.debugMQTTMode=!1,this._customHeader={},this._forceEnableSync=!0,this.lastReceiveMessages=[],this._hookAdapter=(e={},r=function(t){return Array.isArray(e[t])||(e[t]=[]),e[t]},{trigger:function(t,e){return r(t).reduce((function(t,e){return Promise.resolve(t).then(e)}),Promise.resolve(e))},intercept:function(t,e){r(t).push(e);var n=r(t).length;return function(){return r(t).splice(n,1)}}}),this._uploadURL=null,this._autoRefreshToken=!1}return l()(t,[{key:"uploadURL",get:function(){return this._uploadURL||"".concat(this.baseURL,"/api/v2/sdk/upload")},set:function(t){this._uploadURL=t}},{key:"init",value:(E=s()(d.a.mark((function t(e){var r,n,o,i,a,u,c=this;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.AppId){t.next=2;break}throw new Error("Please provide valid AppId");case 2:if(this.AppId=e.AppId,n=null!=e.baseURL&&this.baseURL!==e.baseURL,o=null!=e.mqttURL&&this.mqttURL!==e.mqttURL,i=null!=e.brokerLbURL&&this.brokerLbUrl!==e.brokerLbURL,!n&&!o||i?null!=e.enableRealtimeLB&&(this.enableLb=e.enableRealtimeLB):(this.logger("force disable load balancing for realtime server, because `baseURL` or `mqttURL` get changed but did not provide `brokerLbURL`"),this.enableLb=!1),null!=e.updateCommentStatusMode&&(this.updateCommentStatusMode=e.updateCommentStatusMode),null!=e.updateCommentStatusThrottleDelay&&(this.updateCommentStatusThrottleDelay=e.updateCommentStatusThrottleDelay),e.baseURL&&(this.baseURL=e.baseURL),e.mqttURL&&(this.mqttURL=e.brokerUrl||e.mqttURL),e.mqttURL&&(this.brokerUrl=e.brokerUrl||e.mqttURL),e.brokerLbURL&&(this.brokerLbUrl=e.brokerLbURL),e.uploadURL&&(this.uploadURL=e.uploadURL),e.sync&&(this.sync=e.sync),e.mode&&(this.mode=e.mode),e.syncInterval&&(this.syncInterval=e.syncInterval||5e3),e.googleMapKey&&(this.googleMapKey=e.googleMapKey),e.allowedFileTypes&&(this.allowedFileTypes=e.allowedFileTypes),e.options&&(this.options=Object.assign({},this.options,e.options)),e.customTemplate&&(this.customTemplate=e.customTemplate),e.templateFunction&&(this.templateFunction=e.templateFunction),null!=e.syncInterval&&(this.syncInterval=e.syncInterval),this.HTTPAdapter=new I({baseURL:this.baseURL,AppId:this.AppId,userId:this.user_id,version:this.version,getCustomHeader:function(){return c._customHeader}}),a=function(t,e,r){if(""===e&&null!=t){if("string"!=typeof t)return t;if(t.length>0)return t}if(null!=e){if(e.length>0)return e;if("string"!=typeof e)return e}return r},u=function(t){return t.includes("wss://")?t:"wss://".concat(t,":1886/mqtt")},this.withConfig=null===(r=e.withConfig)||void 0===r||r,!0!==this.withConfig){t.next=32;break}return t.next=30,this.HTTPAdapter.get_request("api/v2/sdk/config").then((function(t){return 200==t.status?c.isConfigLoaded=!0:c.isConfigLoaded=!1,t.body.results})).then((function(t){var r=c.baseURL,n=c.brokerLbUrl,o=c.mqttURL,i=c.enableRealtime,s=c.enableRealtimeCheck,l=c.syncInterval,f=c.syncOnConnect,h=c.enableEventReport;c.baseURL=a(e.baseURL,t.base_url,r),c.brokerLbUrl=a(e.brokerLbURL,t.broker_lb_url,n),c.mqttURL=u(a(e.mqttURL,t.broker_url,o)),c.enableRealtime=a(e.enableRealtime,t.enable_realtime,i),c.syncInterval=a(e.syncInterval,t.sync_interval,l),c.syncOnConnect=a(e.syncOnConnect,t.sync_on_connect,f),c.enableRealtimeCheck=a(null,t.enable_realtime_check,s),c.enableEventReport=a(null,t.enable_event_report,h),c.extras=a(null,t.extras,{}),c.enableSync=a(null,t.enable_sync,c.enableSync),c.enableSyncEvent=a(null,t.enable_sync_event,c.enableSyncEvent),c._autoRefreshToken=a(null,t.auto_refresh_token,!1)})).catch((function(t){c.logger("got error when trying to get app config",t),c.isConfigLoaded=!0}));case 30:t.next=33;break;case 32:this.isConfigLoaded=!0;case 33:this._getMqttClientId=function(){return"".concat(c.AppId,"_").concat(c.user_id,"_").concat(Date.now())},this.realtimeAdapter=new at(this.mqttURL,this,this.isLogin,{brokerLbUrl:this.brokerLbUrl,enableLb:this.enableLb,shouldConnect:this.enableRealtime,getClientId:this._getMqttClientId}),this.realtimeAdapter.on("connected",(function(){!c.isLogin&&c.realtimeAdapter.connected||(c.last_received_comment_id=c.userData.last_comment_id,c.updateLastReceivedComment(c.last_received_comment_id))})),this.realtimeAdapter.on("close",(function(){})),this.realtimeAdapter.on("reconnect",(function(){var t,e;null===(t=(e=c.options).onReconnectCallback)||void 0===t||t.call(e)})),this.realtimeAdapter.on("message-delivered",(function(t){var e=t.commentId,r=t.commentUniqueId,n=t.userId;return c._setDelivered(e,r,n)})),this.realtimeAdapter.on("message-read",(function(t){var e=t.commentId,r=t.commentUniqueId,n=t.userId;return c._setRead(e,r,n)})),this.realtimeAdapter.on("new-message",function(){var t=s()(d.a.mark((function t(e){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,e);case 2:e=t.sent,c.events.emit("newmessages",[e]);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.realtimeAdapter.on("presence",(function(t){return c.events.emit("presence",t)})),this.realtimeAdapter.on("comment-deleted",(function(t){return c.events.emit("comment-deleted",t)})),this.realtimeAdapter.on("room-cleared",(function(t){return c.events.emit("room-cleared",t)})),this.realtimeAdapter.on("typing",(function(t){return c.events.emit("typing",{message:t.message,username:t.userId,room_id:t.roomId})})),this.realtimeAdapter.on("message:updated",(function(t){null!=c.options.messageUpdatedCallback&&c.options.messageUpdatedCallback(t)})),this.syncAdapter=gt((function(){return c.HTTPAdapter}),{getToken:function(){return c.userData.token},syncInterval:function(){return c.syncInterval},getShouldSync:function(){return c._forceEnableSync&&c.isLogin&&!c.realtimeAdapter.connected},syncOnConnect:function(){return c.syncOnConnect},lastCommentId:function(){return c.last_received_comment_id},statusLogin:function(){return c.isLogin},enableSync:function(){return c.enableSync},enableSyncEvent:function(){return c.enableSyncEvent}}),this.syncAdapter.on("message.new",function(){var t=s()(d.a.mark((function t(e){var r;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,e);case 2:e=t.sent,null!=c.selected?-1===c.selected.comments.findIndex((function(t){return t.id===e.id||t.unique_id===e.unique_temp_id}))&&((r=new T(e)).room_id===c.selected.id&&(c.selected.comments.push(r),c.sortComments()),c.events.emit("newmessages",[e])):c.events.emit("newmessages",[e]);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),this.syncAdapter.on("message.delivered",(function(t){c._setDelivered(t.comment_id,t.comment_unique_id,t.email)})),this.syncAdapter.on("message.read",(function(t){c._setRead(t.comment_id,t.comment_unique_id,t.email)})),this.syncAdapter.on("message.deleted",(function(t){t.deleted_messages.forEach((function(t){c.events.emit("comment-deleted",{roomId:t.room_id,commentUniqueIds:t.message_unique_ids,isForEveryone:!0,isHard:!0})}))})),this.syncAdapter.on("room.cleared",(function(t){t.deleted_rooms.forEach((function(t){c.events.emit("room-cleared",t)}))})),this.customEventAdapter=ut(this.realtimeAdapter,this.user_id),this.setEventListeners();case 54:case"end":return t.stop()}}),t,this)}))),function(t){return E.apply(this,arguments)})},{key:"_setRead",value:function(t,e,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===t||r.unique_id===e}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:t,activeActorId:this.user_id};n.comments.forEach((function(t){t.id<=o.id&&t.markAsRead(i)})),o.isRead&&this.events.emit("comment-read",{comment:o,userId:r})}}}},{key:"_setDelivered",value:function(t,e,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===t||r.unique_id===e}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:t,activeActorId:this.user_id};n.comments.forEach((function(t){t.id<=o.id&&t.markAsDelivered(i)})),o.isDelivered&&this.events.emit("comment-delivered",{comment:o,userId:r})}}}},{key:"setEventListeners",value:function(){var t=this,e=this;this.authAdapter=new O(e.HTTPAdapter),null!=this.userData.email&&(this.authAdapter.userId=this.userData.email),e.events.on("start-init",(function(){e.HTTPAdapter=new I({baseURL:e.baseURL,AppId:e.AppId,userId:e.user_id,version:e.version,getCustomHeader:function(){return t._customHeader}}),e.HTTPAdapter.setToken(e.userData.token)})),e.events.on("room-changed",(function(r){t.logging("room changed",r),e.options.roomChangedCallback&&e.options.roomChangedCallback(r)})),e.events.on("file-uploaded",(function(t){e.options.fileUploadedCallback&&e.options.fileUploadedCallback(t)})),e.events.on("profile-updated",(function(t){e.username=t.name,e.avatar_url=t.avatar_url,e.options.updateProfileCallback&&e.options.updateProfileCallback(t)})),e.events.on("newmessages",(function(r){t.logging("newmessages",r),t.lastReceiveMessages.length>0&&t.lastReceiveMessages[0].unique_temp_id===r[0].unique_temp_id?t.logging("lastReceiveMessages double",r):(t.lastReceiveMessages=r,e._callNewMessagesCallback(r),r.forEach((function(r){e.receiveComment(r.room_id,r.id);var n=!!e.selected&&r.room_id===e.selected.id,o=r.id<=e.last_received_comment_id;if(n){var i=e.selected,s=e.selected.comments[e.selected.comments.length-1];s.isPending||o||e.user_id===r.email||e.readComment(r.room_id,r.id);var a=s.id,u=e.selected.comments.find((function(t){return t.id===s.comment_before_id}));s.isPending||u||(t.logging("comment before id not found! ",r.comment_before_id),e.synchronize(a));var c=new T(r);i.receiveComment(c),i.last_comment_id=c.id,i.last_comment_message=c.message}e.updateLastReceivedComment(r.id),t.sortComments()})))})),this.events.on("login-success",(function(e){t.isLogin=!0,t.userData=e.user,t.last_received_comment_id=t.userData.last_comment_id,t.realtimeAdapter.connected||t.updateLastReceivedComment(t.last_received_comment_id),t.HTTPAdapter=new I({baseURL:t.baseURL,AppId:t.AppId,userId:t.user_id,version:t.version,getCustomHeader:function(){return t._customHeader}}),t.HTTPAdapter.setToken(t.userData.token);var r=e.user;t.expiredTokenAdapter=new wt({httpAdapter:t.HTTPAdapter,refreshToken:r.refresh_token,expiredAt:r.token_expires_at,userId:t.user_id,onTokenRefreshed:function(e,r,n){t.userData.token=e,t.userData.refresh_token=r,t.userData.token_expires_at=null==n?void 0:n.toJSON(),t.events.emit("token-refreshed",{token:e,refreshToken:r,expiredAt:n})},getAuthenticationStatus:function(){return null!=t.user_id&&t.isLogin}}),t.userAdapter=new D(t.HTTPAdapter),t.roomAdapter=new j(t.HTTPAdapter),t.realtimeAdapter.subscribeUserChannel(),null!=t.presensePublisherId&&-1!==t.presensePublisherId&&clearInterval(t.presensePublisherId),t.presensePublisherId=setInterval((function(){t.realtimeAdapter.publishPresence(t.user_id,!0)}),3500),t.options.loginSuccessCallback&&t.options.loginSuccessCallback(e),t.authAdapter.userId=t.userData.email,t.authAdapter.refreshToken=t.userData.refresh_token,t.authAdapter.autoRefreshToken=t._autoRefreshToken})),e.events.on("login-error",(function(t){e.options.loginErrorCallback&&e.options.loginErrorCallback(t)})),e.events.on("token-refreshed",(function(e){var r,n;null===(r=(n=t.options).authTokenRefreshedCallback)||void 0===r||r.call(n,e)})),e.events.on("room-cleared",(function(t){if(e.selected){var r=e.selected;e.selected.unique_id===t.unique_id&&(e.selected=null,e.selected=r)}e.options.roomClearedCallback&&e.options.roomClearedCallback(t)})),e.events.on("comment-deleted",(function(t){var r=t.roomId,n=t.commentUniqueIds,o=(t.isForEveryone,t.isHard);e.selected&&e.selected.id==r&&n.map((function(t){var r=e.selected.comments.findIndex((function(e){return e.unique_id===t}));r>-1&&(o?e.selected.comments.splice(r,1):e.selected.comments[r].message="this message has been deleted")})),e.options.commentDeletedCallback&&e.options.commentDeletedCallback(t)})),e.events.on("comment-delivered",(function(t){return e.logging("comment-delivered",t),!!t&&(e.options.commentDeliveredCallback?e.options.commentDeliveredCallback(t):void 0)})),e.events.on("chat-room-created",(function(t){e.isLoading=!1,e.options.chatRoomCreatedCallback&&e.options.chatRoomCreatedCallback(t)})),e.events.on("group-room-created",(function(t){e.isLoading=!1,e.options.groupRoomCreatedCallback&&e.options.groupRoomCreatedCallback(t)})),e.events.on("header-clicked",(function(t){e.options.headerClickedCallback&&e.options.headerClickedCallback(t)})),e.events.on("comment-read",(function(t){e.logging("comment-read",t),e.options.commentReadCallback&&e.options.commentReadCallback(t)})),e.events.on("presence",(function(r){var n=r.message,o=r.userId,i=n.split(":");t.chatmateStatus!==i[0]&&(t.chatmateStatus=1===i[0]?"Online":"Last seen ".concat(S()(Number(i[1].substring(0,13))))),e.options.presenceCallback&&e.options.presenceCallback(n,o)})),e.events.on("typing",(function(t){e.options.typingCallback&&e.options.typingCallback(t)})),e.events.on("message-info",(function(t){e.options.messageInfoCallback&&e.options.messageInfoCallback(t)})),e.events.on("participants-added",(function(e){var r;null!=e&&null!=t.selected&&(r=t.selected.participants).push.apply(r,o()(e))})),e.events.on("participants-removed",(function(e){if(null!=e&&null!=t.selected){var r=t.selected.participants.filter((function(t){return e.indexOf(t.email)<=-1}));t.selected.participants=r}})),e.events.on("block-user",(function(t){e.options.blockUserCallback&&e.options.blockUserCallback(t)})),e.events.on("unblock-user",(function(t){e.options.unblockUserCallback&&e.options.unblockUserCallback(t)}))}},{key:"onReconnectMqtt",value:function(){this.options.onReconnectCallback&&this.options.onReconnectedCallback(),this.selected&&this.loadComments(this.selected.id)}},{key:"_callNewMessagesCallback",value:function(t){this.options.newMessagesCallback&&this.options.newMessagesCallback(t)}},{key:"updateLastReceivedComment",value:function(t){this.last_received_comment_id<t&&(this.last_received_comment_id=t)}},{key:"setUser",value:function(t,e,r,n,o){var i=this,s=this;s.user_id=t,s.key=e,s.username=r,s.avatar_url=n;var a={email:this.user_id,password:this.key,username:this.username,extras:o?JSON.stringify(o):null};return this.avatar_url&&(a.avatar_url=this.avatar_url),new Promise((function(t,e){var r=setInterval((function(){if(i.isConfigLoaded)return clearInterval(r),i.logger("Config Success!"),s.events.emit("start-init"),s.authAdapter.loginOrRegister(a).then((function(e){s.isInit=!0,s.refresh_token=e.user.refresh_token,s.events.emit("login-success",e),i.realtimeAdapter.connect(),t(e)}),(function(t){s.events.emit("login-error",t),e(t)}));i.debugMode&&i.logger("Waiting for init config...")}),300)}))}},{key:"setUserWithIdentityToken",value:function(t){var e=this;if(!t||!("user"in t))return this.events.emit("login-error",t);this.email=t.user.email,this.user_id=t.user.email,this.key=t.identity_token,this.username=t.user.username,this.avatar_url=t.user.avatar_url,this.isInit=!0;var r=setInterval((function(){e.isConfigLoaded?(clearInterval(r),e.logger("Config Success!"),e.events.emit("login-success",t)):e.debugMode&&e.logger("Waiting for init config...")}),300)}},{key:"refreshAuthToken",value:function(){return this.expiredTokenAdapter.refreshAuthToken()}},{key:"publishOnlinePresence",value:function(t){var e=this;!0===t?_t=setInterval((function(){e.realtimeAdapter.publishPresence(e.user_id,!0)}),3500):(clearInterval(this.presensePublisherId),clearInterval(_t),setTimeout((function(){e.realtimeAdapter.publishPresence(e.user_id,!1)}),3500))}},{key:"subscribeUserPresence",value:function(t){this.realtimeAdapter.subscribeUserPresence(t)}},{key:"unsubscribeUserPresence",value:function(t){this.realtimeAdapter.unsubscribeUserPresence(t)}},{key:"logout",value:(x=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.expiredTokenAdapter.logout();case 2:clearInterval(this.presensePublisherId),this.publishOnlinePresence(!1),this.selected=null,this.isInit=!1,this.isLogin=!1,this.realtimeAdapter.disconnect(),this.userData={};case 9:case"end":return t.stop()}}),t,this)}))),function(){return x.apply(this,arguments)})},{key:"synchronize",get:function(){return this.syncAdapter.synchronize}},{key:"synchronizeEvent",get:function(){return this.syncAdapter.synchronizeEvent}},{key:"disconnect",value:function(){this.logout()}},{key:"setActiveRoom",value:function(t){var e=this;if(this.selected&&(this.realtimeAdapter.unsubscribeTyping(),"single"===this.selected.room_type)){var r=this.selected.participants.filter((function(t){return t.email!==e.user_id}));r.length>0&&this.realtimeAdapter.unsubscribeRoomPresence(r[0].email)}null==t.participants&&(t.participants=[]);var n=t.participants.find((function(t){return t.email!==e.user_id}));this.chatmateStatus=null,this.isTypingStatus=null,this.selected=t;var o=setInterval((function(){e.debugMode&&e.logger("Trying Initial Subscribe"),null!=e.realtimeAdapter?(e.debugMode&&e.logger("MQTT Connected"),clearInterval(o),"single"===t.room_type&&null!=n&&e.realtimeAdapter.subscribeRoomPresence(n.email),null==e.selected||e.selected.isChannel||(e.realtimeAdapter.subscribeTyping(t.id),e.events.emit("room-changed",e.selected)),e.debugMode&&null==e.realtimeAdapter&&e.logger("Retry")):e.debugMode&&e.logger("MQTT Not Connected, yet")}),3e3)}},{key:"chatTarget",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.userData.length)return!1;var n=r?r.message:null,o=r.distinctId;return this.isLoading=!0,this.isTypingStatus="",this.roomAdapter.getOrCreateRoom(t,r,o).then(function(){var t=s()(d.a.mark((function t(r){var o,i,a,u;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=new P(r),e.updateLastReceivedComment(o.last_comment_id),e.isLoading=!1,i=function(){var t=s()(d.a.mark((function t(r){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.next=6,Promise.all(o.comments.map((function(t){return i(t)})));case 6:if(o.comments=t.sent,e.setActiveRoom(o),(a=o.comments[o.comments.length-1])&&e.readComment(o.id,a.id),e.events.emit("chat-room-created",{room:o}),n){t.next=13;break}return t.abrupt("return",o);case 13:return u=o.id,t.abrupt("return",e.sendComment(u,n).then((function(){return Promise.resolve(o)})).catch((function(t){console.error("Error when submit comment",t)})));case 15:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){return console.error("Error when creating room",t),e.isLoading=!1,Promise.reject(t)}))}},{key:"chatGroup",value:function(t){if(this.isInit)return this.getRoomById(t).then((function(t){return Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"getRoomById",value:function(t){var e=this;if(this.isInit){var r=this;return r.isLoading=!0,r.isTypingStatus="",r.roomAdapter.getRoomById(t).then(function(){var t=s()(d.a.mark((function t(n){var o,i,s,a,u,c,l,f;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=n.results.room,i=[],s=xt(n.results.comments.reverse()),t.prev=3,s.s();case 5:if((a=s.n()).done){t.next=13;break}return u=a.value,t.next=9,e._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,u);case 9:c=t.sent,i.push(c);case 11:t.next=5;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(3),s.e(t.t0);case 18:return t.prev=18,s.f(),t.finish(18);case 21:return l=new P(St(St({},o),{},{comments:i,name:o.room_name})),r.updateLastReceivedComment(l.last_comment_id),r.setActiveRoom(l),r.isLoading=!1,(f=l.comments[l.comments.length-1])&&r.readComment(l.id,f.id),l.isChannel&&e.realtimeAdapter.subscribeChannel(e.AppId,l.unique_id),t.abrupt("return",l);case 29:case"end":return t.stop()}}),t,null,[[3,15,18,21]])})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){return console.error("Error getting room by id",t),Promise.reject(t)}))}}},{key:"getOrCreateRoomByUniqueId",value:function(t,e,r){var n=this,o=this;return o.isLoading=!0,o.isTypingStatus="",o.roomAdapter.getOrCreateRoomByUniqueId(t,e,r).then(function(){var t=s()(d.a.mark((function t(e){var r,i,a;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new P(e),o.updateLastReceivedComment(r.last_comment_id),i=function(){var t=s()(d.a.mark((function t(e){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.next=5,Promise.all(r.comments.map((function(t){return i(t)})));case 5:return r.comments=t.sent,o.setActiveRoom(r),o.isLoading=!1,(a=r.comments[r.comments.length-1])&&o.readComment(r.id,a.id),n.realtimeAdapter.subscribeChannel(n.AppId,r.unique_id),t.abrupt("return",Promise.resolve(r));case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){return Promise.reject(t)}))}},{key:"getOrCreateRoomByChannel",value:function(t,e,r){return this.getOrCreateRoomByUniqueId(t,e,r)}},{key:"sortComments",value:function(){this.selected&&this.selected.comments.sort((function(t,e){return t.unix_timestamp-e.unix_timestamp}))}},{key:"loadRoomList",value:(k=s()(d.a.mark((function t(){var e,r,n=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.userAdapter.loadRoomList(e);case 3:return r=t.sent,t.abrupt("return",r.map((function(t){return t.last_comment_id=t.last_comment.id,t.last_comment_message=t.last_comment.message,t.last_comment_message_created_at=t.last_comment.timestamp,t.room_type=t.chat_type,t.comments=[],new P(t)})));case 5:case"end":return t.stop()}}),t,this)}))),function(){return k.apply(this,arguments)})},{key:"loadComments",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.userAdapter.loadComments(t,r).then(function(){var t=s()(d.a.mark((function t(r){var n,o,i,s;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=[],o=xt(r),t.prev=2,o.s();case 4:if((i=o.n()).done){t.next=13;break}return s=i.value,t.t0=n,t.next=9,e._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,s);case 9:t.t1=t.sent,t.t0.push.call(t.t0,t.t1);case 11:t.next=4;break;case 13:t.next=18;break;case 15:t.prev=15,t.t2=t.catch(2),o.e(t.t2);case 18:return t.prev=18,o.f(),t.finish(18);case 21:return null!=e.selected&&(e.selected.receiveComments(n.reverse()),e.sortComments()),t.abrupt("return",n);case 23:case"end":return t.stop()}}),t,null,[[2,15,18,21]])})));return function(e){return t.apply(this,arguments)}}())}},{key:"loadMore",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.selected)return e.last_comment_id=t,e.after=!1,this.loadComments(this.selected.id,e)}},{key:"registerDeviceToken",value:(_=s()(d.a.mark((function t(e){var r,n,o=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],t.next=3,this.HTTPAdapter.post("api/v2/sdk/set_user_device_token",{device_token:e,device_platform:"rn",is_development:r});case 3:return n=t.sent,t.abrupt("return",n.body.results);case 5:case"end":return t.stop()}}),t,this)}))),function(t){return _.apply(this,arguments)})},{key:"removeDeviceToken",value:(v=s()(d.a.mark((function t(e){var r,n,o=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],t.next=3,this.HTTPAdapter.post("api/v2/sdk/remove_user_device_token",{device_token:e,device_platform:"rn",is_development:r});case 3:return n=t.sent,t.abrupt("return",n.body.results);case 5:case"end":return t.stop()}}),t,this)}))),function(t){return v.apply(this,arguments)})},{key:"searchMessages",value:(m=s()(d.a.mark((function t(){var e,r,n=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},console.warn("Deprecated: search message will be removed on next release"),t.next=4,this.userAdapter.searchMessages(e);case 4:return r=t.sent,t.abrupt("return",r.map((function(t){return new T(t)})));case 6:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)})},{key:"updateProfile",value:function(t){var e=this;return this.userAdapter.updateProfile(t).then((function(r){return e.events.emit("profile-updated",t),e.userData=r,Promise.resolve(r)}),(function(t){return e.logger(t)}))}},{key:"getNonce",value:function(){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/nonce")).send().set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(t){return Promise.resolve(t.body.results)}),(function(t){return Promise.reject(t)}))}},{key:"verifyIdentityToken",value:function(t){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/verify_identity_token")).send({identity_token:t}).set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(t){return Promise.resolve(t.body.results)}),(function(t){return Promise.reject(t)}))}},{key:"sendComment",value:(p=s()(d.a.mark((function t(e,r,n){var o,i,a,u,c,l,f,h,p,m,y=this,g=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=g.length>3&&void 0!==g[3]?g[3]:"text",i=g.length>4?g[4]:void 0,a=g.length>5?g[5]:void 0,(u=this).options.prePostCommentCallback&&u.options.prePostCommentCallback(r),u.options.commentFormaterCallback&&(r=u.options.commentFormaterCallback(r)),u.pendingCommentId--,c={message:r,username_as:this.username,username_real:this.user_id,user_avatar_url:this.userData.avatar_url,user_extras:this.userData.user_extras,id:Math.round(1e6*Date.now()+Date.now()),type:o||"text",timestamp:w()(new Date),unique_id:n?String(n):null,payload:it((function(){return JSON.parse(i)}),i,(function(t){return y.logger("Error when parsing payload",t.message)}))},l=u.prepareCommentToBeSubmitted(c),"reply"===o&&(f=JSON.parse(i),h=u.selected.comments.find((function(t){return t.id===f.replied_comment_id})),f.replied_comment_message="reply"===h.type?h.payload.text:h.message,f.replied_comment_sender_username=h.username_as,l.payload=f),p=a||u.extras,t.next=13,this._hookAdapter.trigger(bt.MESSAGE_BEFORE_SENT,St(St({},l),{},{extras:p}));case 13:return m=t.sent,m=u.prepareCommentToBeSubmitted(m),u.selected&&u.selected.comments.push(m),t.abrupt("return",this.userAdapter.postComment(""+e,m.message,m.unique_id,m.type,m.payload,m.extras).then(function(){var t=s()(d.a.mark((function t(e){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,y._hookAdapter.trigger(bt.MESSAGE_BEFORE_RECEIVED,e);case 2:if(e=t.sent,Object.assign(m,e),u.selected){t.next=6;break}return t.abrupt("return",Promise.resolve(m));case 6:return m.markAsSent(),m.id=e.id,m.before_id=e.comment_before_id,m.unix_timestamp=e.unix_timestamp,u.sortComments(),t.abrupt("return",m);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){return m.markAsFailed(),Promise.reject(t)})));case 17:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return p.apply(this,arguments)})},{key:"getUsers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/get_user_list").query({query:t,page:e,limit:r}).then((function(t){return Promise.resolve(t.body.results)}))}},{key:"getParticipants",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:t,page:e,limit:r}).then((function(t){return t.body.results}))}},{key:"getRoomParticipants",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return console.warn("`getRoomParticipants` are deprecated, use `getParticipants` instead."),this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:t,offset:e}).then((function(t){return Promise.resolve(t.body.results)}))}},{key:"resendComment",value:function(t){if(null!=this.selected){var e=this,r=e.selected,n=r.comments.find((function(e){return e.id===t.id})),o=e.extras;return this.userAdapter.postComment(""+r.id,n.message,n.unique_id,t.type,t.payload,o).then((function(t){return n.markAsSent(),n.id=t.id,n.before_id=t.comment_before_id,new Promise((function(t,r){return t(e.selected)}))}),(function(t){return n.markAsFailed(),new Promise((function(e,r){return r(t)}))}))}}},{key:"prepareCommentToBeSubmitted",value:function(t){var e,r;return e=new T(t),r="bq"+Date.now(),t.unique_id&&(r=t.unique_id),e.attachUniqueId(r),e.markAsPending(),e.isDelivered=!1,e.isSent=!1,e.isRead=!1,e.unix_timestamp=Math.round((new Date).getTime()/1e3),e}},{key:"updateRoom",value:function(t){return this.roomAdapter.updateRoom(t)}},{key:"removeSelectedRoomParticipants",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id";if(b.a.not.array(t))return Promise.reject(new Error("`values` must have type of array"));var r=this.selected.participants;if(!r)return Promise.reject(new Error("Nothing selected room chat."));var n=r;return"id"===e&&(n=r.filter((function(e){return t.indexOf(e.id)<=-1}))),"email"===e&&(n=r.filter((function(e){return t.indexOf(e.email)<=-1}))),"username"===e&&(n=r.filter((function(e){return t.indexOf(e.username)<=-1}))),this.selected.participants=n,Promise.resolve(r)}},{key:"createGroupRoom",value:function(t,e,r){var n=this;if(!this.isLogin)throw new Error("Please initiate qiscus SDK first");return new A(this.roomAdapter).withName(t).withOptions(r).addParticipants(e).create().then((function(t){return n.events.emit("group-room-created",t),Promise.resolve(t)}))}},{key:"addParticipantsToGroup",value:function(t,e){var r=this;if(!Array.isArray(e))throw new Error("emails' must be type of Array");return r.roomAdapter.addParticipantsToGroup(t,e).then((function(t){return r.events.emit("participants-added",t),Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"removeParticipantsFromGroup",value:function(t,e){var r=this;return b.a.not.array(e)?Promise.reject(new Error("`emails` must have type of array")):this.roomAdapter.removeParticipantsFromGroup(t,e).then((function(t){return r.events.emit("participants-removed",e),Promise.resolve(t)}))}},{key:"getBlockedUser",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=this;return r.userAdapter.getBlockedUser(t,e).then((function(t){return Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"blockUser",value:function(t){var e=this;return e.userAdapter.blockUser(t).then((function(t){return e.events.emit("block-user",t),Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"unblockUser",value:function(t){var e=this;return e.userAdapter.unblockUser(t).then((function(t){return e.events.emit("unblock-user",t),Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"getUserPresences",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(b.a.not.array(t))return Promise.reject(new Error("`email` must have type of array"));var e=this;return e.userAdapter.getUserPresences(t).then((function(t){return e.events.emit("user-status",t),Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"upload",value:function(t,e){var r=y.a.post(this.uploadURL);return(r=this.HTTPAdapter.setupHeaders(r)).attach("file",t).on("progress",(function(t){"upload"===t.direction&&e(null,t)})).then((function(t){var r=t.body.results.file.url;return e(null,null,t.body.results.file.url),Promise.resolve(r)})).catch((function(t){return e(t),Promise.reject(t)}))}},{key:"uploadFile",value:function(t,e){var r=this,n=new FormData;n.append("file",e);var o=new XMLHttpRequest;o.open("POST","".concat(r.baseURL,"/api/v2/sdk/upload"),!0),o.setRequestHeader("qiscus_sdk_app_id","".concat(r.AppId)),o.setRequestHeader("qiscus_sdk_user_id","".concat(r.user_id)),o.setRequestHeader("qiscus_sdk_token","".concat(r.userData.token)),o.onload=function(){if(200===o.status){var e=JSON.parse(o.response).results.file.url;return r.events.emit("fileupload",e),r.sendComment(t,"[file] ".concat(e," [/file]"))}return Promise.reject(o)},o.send(n)}},{key:"addUploadedFile",value:function(t,e){this.uploadedFiles.push(new Pt(t,e))}},{key:"removeUploadedFile",value:function(t,e){var r=this.uploadedFiles.findIndex((function(r){return r.name===t&&r.roomId===e}));this.uploadedFiles.splice(r,1)}},{key:"publishTyping",value:function(t){this.realtimeAdapter.publishTyping(t)}},{key:"getRoomsInfo",value:function(t){return this.userAdapter.getRoomsInfo(t)}},{key:"deleteComment",value:function(t,e,r,n){var o=this;if(!Array.isArray(e))throw new Error("unique ids' must be type of Array");return this.userAdapter.deleteComment(t,e,r,n).then((function(i){return o.events.emit("comment-deleted",{roomId:t,commentUniqueIds:e,isForEveryone:r,isHard:n}),Promise.resolve(i)}),(function(t){return Promise.reject(t)}))}},{key:"clearRoomsCache",value:function(){var t=this;if(this.selected){this.room_name_id_map=h()({},this.selected.name,this.selected.id);var e=this.rooms.length,r=this.rooms.findIndex((function(e){return e.id===t.selected.id}));r+1!==e&&this.rooms.splice(r+1,e-(r+1)),(r=this.rooms.findIndex((function(e){return e.id===t.selected.id})))>0&&this.rooms.length>1&&this.rooms.splice(1,this.rooms.length-1)}}},{key:"exitChatRoom",value:function(){var t=this;this.realtimeAdapter.unsubscribeTyping(),it((function(){return t.selected.participants.filter((function(e){return e.email!==t.user_id})).map((function(t){return t.email}))}),null,this.noop,(function(e){return e.forEach((function(e){return t.realtimeAdapter.unsubscribeRoomPresence(e)}))})),this.selected=null}},{key:"clearRoomMessages",value:function(t){if(!Array.isArray(t))throw new Error("room_ids must be type of array");return this.userAdapter.clearRoomMessages(t)}},{key:"logging",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.debugMode&&console.log(t,e)}},{key:"getTotalUnreadCount",value:function(){return this.roomAdapter.getTotalUnreadCount().then((function(t){return Promise.resolve(t)}),(function(t){return Promise.reject(t)}))}},{key:"getRoomUnreadCount",value:function(){return this.roomAdapter.getRoomUnreadCount()}},{key:"publishEvent",value:function(){var t;(t=this.customEventAdapter).publishEvent.apply(t,arguments)}},{key:"subscribeEvent",value:function(){var t;(t=this.customEventAdapter).subscribeEvent.apply(t,arguments)}},{key:"unsubscribeEvent",value:function(){var t;(t=this.customEventAdapter).unsubscribeEvent.apply(t,arguments)}},{key:"setCustomHeader",value:function(t){if(b.a.not.json(t))throw new TypeError("`headers` must have type of object");this._customHeader=t}},{key:"getUserProfile",value:function(){return this.userAdapter.getProfile()}},{key:"Interceptor",get:function(){return bt}},{key:"intercept",value:function(t,e){return this._hookAdapter.intercept(t,e)}},{key:"getThumbnailURL",value:function(t){return t.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(t,e,r){return t.replace(e,"/upload/w_320,h_320,c_limit/").replace(r,".png")}))}},{key:"getBlurryThumbnailURL",value:function(t){return t.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(t,e,r){return t.replace(e,"/upload/w_320,h_320,c_limit,e_blur:300/").replace(r,".png")}))}},{key:"logger",get:function(){return this.debugMode?console.log.bind(console,"Qiscus ->"):this.noop}},{key:"noop",value:function(){}},{key:"_throttleDelay",get:function(){return this.updateCommentStatusMode===t.UpdateCommentStatusMode.enabled?0:this.updateCommentStatusThrottleDelay||300}},{key:"_updateStatusEnabled",get:function(){return this.updateCommentStatusMode!==t.UpdateCommentStatusMode.disabled}},{key:"_updateStatus",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null!=r,o=null!=e,i=(null!=this.selected&&this.selected.id,null!=this.selected&&this.selected.isChannel||!1),s=!this._updateStatusEnabled,a=o?"read":n?"receive":void 0,u=!(i||n&&s);if(this.debugMode&&(console.group("update-command-status"),console.log("run:",a,"on: roomId(".concat(t,") commentId(").concat(e||r,")")),console.log("is able to run command?",u),console.groupEnd()),!u)return!1;this.userAdapter.updateCommentStatus(t,e,r).catch((function(t){}))}},{key:"readComment",value:function(e,r){return this.updateCommentStatusMode===t.UpdateCommentStatusMode.enabled?this._readComment(e,r):this._readCommentT(e,r)}},{key:"receiveComment",value:function(e,r){return this.updateCommentStatusMode===t.UpdateCommentStatusMode.enabled?this._deliverComment(e,r):this._deliverCommentT(e,r)}},{key:"_throttle",value:function(t,e){var r=!1;return function(){var n=e();r||(t.apply(void 0,arguments),r=!0,setTimeout((function(){return r=!1}),n))}}},{key:"searchMessage",value:(f=s()(d.a.mark((function t(){var e,r,n,o,i,s,a,u,c,l,f,h,p=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=p.length>0&&void 0!==p[0]?p[0]:{},r=e.query,n=e.roomIds,o=void 0===n?[]:n,i=e.userId,s=e.type,a=e.roomType,u=e.page,c=e.limit,l="api/v2/sdk/search",f=["group","single","channel"].some((function(t){return t===a})),null==a||f){t.next=5;break}return t.abrupt("return",Promise.reject("Invalid room type, valid room type are: `group`, `single`, and `channel`"));case 5:return h=function(t){return{type:null==t?void 0:"single"===t?"single":"group",isPublic:null==t?void 0:"channel"===t}}(a),t.abrupt("return",this.HTTPAdapter.post_json(l,{token:this.token,query:r,sender:i,type:s,room_ids:o.map((function(t){return String(t)})),room_type:h.type||void 0,is_public:h.isPublic||void 0,page:u,limit:c}).then((function(t){return t.body})));case 7:case"end":return t.stop()}}),t,this)}))),function(){return f.apply(this,arguments)})},{key:"getFileList",value:(c=s()(d.a.mark((function t(){var e,r,n,o,i,s,a,u,c,l,f,h,p=arguments;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=p.length>0&&void 0!==p[0]?p[0]:{},r=e.roomIds,n=void 0===r?[]:r,o=e.fileType,i=e.page,s=e.limit,a=e.sender,u=e.userId,c=e.includeExtensions,l=e.excludeExtensions,f="api/v2/sdk/file_list",this.isLogin){t.next=4;break}return t.abrupt("return",Promise.reject("You need to login to use this method"));case 4:return void 0===a&&(a=this.user_id),void 0===u&&(a=u=this.user_id),h={room_ids:n.map((function(t){return String(t)})),file_type:o,page:i,limit:s,include_extensions:c,exclude_extensions:l},null!=a&&(h.sender=a),t.abrupt("return",this.HTTPAdapter.post_json(f,h).then((function(t){return t.body})));case 9:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"_generateUniqueId",value:function(){return"javascript-".concat(Date.now())}},{key:"generateMessage",value:function(t){var e=t.roomId,r=t.text,n=t.extras,o=Date.now();return new T({id:o,message:r,room_id:e,extras:n,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"text"})}},{key:"generateFileAttachmentMessage",value:function(t){var e=t.roomId,r=t.caption,n=t.url,o=t.text,i=void 0===o?"File attachment":o,s=t.extras,a=t.filename,u=t.size,c=Date.now();return new T({id:c,message:i,room_id:e,extras:s,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"file_attachment",payload:{url:n,file_name:a,size:u,caption:r}})}},{key:"generateCustomMessage",value:function(t){var e=t.roomId,r=t.text,n=t.type,o=t.payload,i=t.extras,s=Date.now();return new T({id:s,message:r,room_id:e,extras:i,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"custom",payload:{type:n,content:o}})}},{key:"generateReplyMessage",value:function(t){var e=t.roomId,r=t.text,n=t.repliedMessage,o=t.extras,i=Date.now();return new T({id:i,message:r,room_id:e,extras:o,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"reply",payload:{text:r,replied_comment_id:n.id,replied_comment_message:n.message,replied_comment_type:n.type,replied_comment_payload:n.payload,replied_comment_sender_username:n.username_as,replied_comment_sender_email:n.username_real}})}},{key:"updateMessage",value:(a=s()(d.a.mark((function t(e){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.userAdapter.updateMessage(e));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"onMessageUpdated",value:function(t){var e=this;return this.realtimeAdapter.on("message:updated",t),function(){return e.realtimeAdapter.off("message:updated",t)}}},{key:"closeRealtimeConnection",value:(i=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.realtimeAdapter.closeConnection());case 1:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"openRealtimeConnection",value:(n=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.realtimeAdapter.openConnection());case 1:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"startSync",value:(r=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._forceEnableSync=!0;case 1:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"stopSync",value:(e=s()(d.a.mark((function t(){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._forceEnableSync=!1;case 1:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})}]);var e,r,n,i,a,c,f,p,m,v,_,k,x,E}();h()(Tt,"UpdateCommentStatusMode",At),h()(Tt,"Interceptor",bt);var Pt=l()((function t(e,r){u()(this,t),this.name=e,this.roomId=r,this.progress=0}));e.default=Tt}]).default}));
|
|
16
|
+
var n=r(8),o=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t){var n;function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=r(44),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),p=Symbol("stream");function h(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var r=e[p].read();null!==r&&(e[l]=null,e[s]=null,e[a]=null,t(h(r,!1)))}}function m(e){t.nextTick(d,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var e=this,r=this[u];if(null!==r)return Promise.reject(r);if(this[c])return Promise.resolve(h(void 0,!0));if(this[p].destroyed)return new Promise((function(r,n){t.nextTick((function(){e[u]?n(e[u]):r(h(void 0,!0))}))}));var n,o=this[l];if(o)n=new Promise(function(e,t){return function(r,n){e.then((function(){t[c]?r(h(void 0,!0)):t[f](r,n)}),n)}}(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(h(i,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var e=this;return new Promise((function(t,r){e[p].destroy(null,(function(e){e?r(e):t(h(void 0,!0))}))}))})),n),y);e.exports=function(e){var t,r=Object.create(g,(o(t={},p,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,u,{value:null,writable:!0}),o(t,c,{value:e._readableState.endEmitted,writable:!0}),o(t,f,{value:function(e,t){var n=r[p].read();n?(r[l]=null,r[s]=null,r[a]=null,e(h(n,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[l]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];return null!==t&&(r[l]=null,r[s]=null,r[a]=null,t(e)),void(r[u]=e)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[a]=null,n(h(void 0,!0))),r[c]=!0})),e.on("readable",m.bind(null,r)),r}}).call(this,r(9))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,r){"use strict";e.exports=o;var n=r(101);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}r(11)(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";var n;var o=r(17).codes,i=o.ERR_MISSING_ARGS,s=o.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function u(e,t,o,i){i=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(i);var a=!1;e.on("close",(function(){a=!0})),void 0===n&&(n=r(44)),n(e,{readable:t,writable:o},(function(e){if(e)return i(e);a=!0,i()}));var u=!1;return function(t){if(!a&&!u)return u=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void i(t||new s("pipe"))}}function c(e){e()}function l(e,t){return e.pipe(t)}function f(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}e.exports=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new i("streams");var s=t.map((function(e,r){var i=r<t.length-1;return u(e,i,r>0,(function(e){n||(n=e),e&&s.forEach(c),i||(s.forEach(c),o(n))}))}));return t.reduce(l)}},function(e,t,r){t.parser=r(251).parser,t.generate=r(257),t.writeToStream=r(103)},function(e,t,r){const n=r(252),o=r(25),i=r(254),s=r(102),a=r(16)("mqtt-packet:parser");class u extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof u?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new u).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");const o={},i=this.packet,u=this._parseString();if(null===u)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==u&&"MQIsdp"!==u)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=u,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(i.clientId=c,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));i.username=n,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));i.password=r}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,n,o,i,u,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,u=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:n},5===this.settings.protocolVersion?(c.nl=u,c.rap=i,c.rh=o):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,n=1,o=0,i=!1;const u=this._pos?this._pos:0;for(;r<4&&u+r<this._list.length;){if(t=this._list.readUInt8(u+r++),o+=n*(t&s.VARBYTEINT_MASK),n*=128,0==(t&s.VARBYTEINT_FIN_MASK)){i=!0;break}if(this._list.length<=r)break}return!i&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=r),i=!!i&&(e?{bytes:r,value:o}:o),a("_parseVarByteNum: result: %o",i),i}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const n=r[t][e.name];r[t][e.name]=[n],r[t][e.name].push(e.value)}else r[t][e.name]=e.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}e.exports=u},function(e,t,r){"use strict";const n=r(15).Duplex,o=r(11),i=r(253);function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),n.call(this)}o(s,n),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,e.exports=s,e.exports.BufferListStream=s,e.exports.BufferList=i},function(e,t,r){"use strict";const{Buffer:n}=r(8),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return[r,e-t];t=n}},i.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,r,o){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof o||o>this.length)&&(o=this.length),r>=this.length)return e||n.alloc(0);if(o<=0)return e||n.alloc(0);const i=!!e,s=this._offset(r),a=o-r;let u=a,c=i&&t||0,l=s[1];if(0===r&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(u<=this._bufs[s[0]].length-l)return i?this._bufs[s[0]].copy(e,t,l,l+u):this._bufs[s[0]].slice(l,l+u);i||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-l;if(!(u>r)){this._bufs[t].copy(e,c,l,l+u),c+=r;break}this._bufs[t].copy(e,c,l),c+=r,u-=r,l&&(l=0)}return e.length>c?e.slice(0,c):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),o=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,n[1]),0!==r[1]&&(o[0]=o[0].slice(r[1])),this._new(o)},i.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;){if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([i,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){i.prototype[t]=null===e[t]?function(e,r){return this.slice(e,e+r)[t](0,r)}:function(r=0){return this.slice(r,r+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},e.exports=i},function(e,t){e.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},function(e,t,r){e.exports=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function o(e,t){let r=0,n=0,o=-1,i=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(o=n,i=r,n++):(r++,n++);else{if(-1===o)return!1;n=o+1,i++,r=i}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(o(e,r))return!1;for(const r of t.names)if(o(e,r))return!0;return!1},t.humanize=r(256),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(r=>{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},function(e,t){var r=1e3,n=6e4,o=60*n,i=24*o;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}e.exports=function(e,t){t=t||{};var a=typeof e;if("string"===a&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===a&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=i)return s(e,t,i,"day");if(t>=o)return s(e,t,o,"hour");if(t>=n)return s(e,t,n,"minute");if(t>=r)return s(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=i)return Math.round(e/i)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){(function(t){const n=r(103),o=r(25);class i extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const r=new Array(this._array.length),n=this._array;let o,i=0;for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?r[o]=n[o].length:r[o]=t.byteLength(n[o]),e+=r[o];const s=t.allocUnsafe(e);for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?(n[o].copy(s,i),i+=r[o]):(s.write(n[o],i),i+=r[o]);return s}}e.exports=function(e,t){const r=new i;return n(e,r,t),r.concat()}}).call(this,r(8).Buffer)},function(e,t,r){(function(t){const r={},n=t.isBuffer(t.from([1,2]).subarray(0,1));function o(e){const r=t.allocUnsafe(2);return r.writeUInt8(e>>8,0),r.writeUInt8(255&e,1),r}e.exports={cache:r,generateCache:function(){for(let e=0;e<65536;e++)r[e]=o(e)},generateNumber:o,genBufVariableByteInt:function(e){let r=0,o=0;const i=t.allocUnsafe(4);do{r=e%128|0,(e=e/128|0)>0&&(r|=128),i.writeUInt8(r,o++)}while(e>0&&o<4);return e>0&&(o=0),n?i.subarray(0,o):i.slice(0,o)},generate4ByteBuffer:function(e){const r=t.allocUnsafe(4);return r.writeUInt32BE(e,0),r}}}).call(this,r(8).Buffer)},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,o){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,n)}));case 4:return t.nextTick((function(){e.call(null,r,n,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return t.nextTick((function(){e.apply(null,i)}))}}}:e.exports=t}).call(this,r(9))},function(e,t,r){"use strict";function n(e,t,r){var n=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,e,n._args)},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0)},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0}}e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new n(arguments[0],arguments[1],e)}},function(e,t,r){"use strict";function n(e){for(var t=e.split("/"),r=0;r<t.length;r++)if("+"!==t[r]){if("#"===t[r])return r===t.length-1;if(-1!==t[r].indexOf("+")||-1!==t[r].indexOf("#"))return!1}return!0}e.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!n(e[t]))return e[t];return null}}},function(e,t,r){"use strict";var n=r(263);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var i=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(u),l=["%","/","?",";","#"].concat(c),f=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=r(265);function v(e,t,r){if(e&&"object"==typeof e&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if("string"!=typeof e)throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o<e.indexOf("#")?"?":"#",u=e.split(s);u[0]=u[0].replace(/\\/g,"/");var v=e=u.join(s);if(v=v.trim(),!r&&1===e.split("#").length){var b=a.exec(v);if(b)return this.path=v,this.href=v,this.pathname=b[1],b[2]?(this.search=b[2],this.query=t?g.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var _=i.exec(v);if(_){var w=(_=_[0]).toLowerCase();this.protocol=w,v=v.substr(_.length)}if(r||_||v.match(/^\/\/[^@/]+@[^@/]+/)){var k="//"===v.substr(0,2);!k||_&&m[_]||(v=v.substr(2),this.slashes=!0)}if(!m[_]&&(k||_&&!y[_])){for(var S,x,E=-1,T=0;T<f.length;T++){-1!==(A=v.indexOf(f[T]))&&(-1===E||A<E)&&(E=A)}-1!==(x=-1===E?v.lastIndexOf("@"):v.lastIndexOf("@",E))&&(S=v.slice(0,x),v=v.slice(x+1),this.auth=decodeURIComponent(S)),E=-1;for(T=0;T<l.length;T++){var A;-1!==(A=v.indexOf(l[T]))&&(-1===E||A<E)&&(E=A)}-1===E&&(E=v.length),this.host=v.slice(0,E),v=v.slice(E),this.parseHost(),this.hostname=this.hostname||"";var I="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!I)for(var C=this.hostname.split(/\./),P=(T=0,C.length);T<P;T++){var O=C[T];if(O&&!O.match(p)){for(var R="",M=0,D=O.length;M<D;M++)O.charCodeAt(M)>127?R+="x":R+=O[M];if(!R.match(p)){var j=C.slice(0,T),L=C.slice(T+1),U=O.match(h);U&&(j.push(U[1]),L.unshift(U[2])),L.length&&(v="/"+L.join(".")+v),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var F=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+F,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!d[w])for(T=0,P=c.length;T<P;T++){var q=c[T];if(-1!==v.indexOf(q)){var B=encodeURIComponent(q);B===q&&(B=escape(q)),v=v.split(q).join(B)}}var H=v.indexOf("#");-1!==H&&(this.hash=v.substr(H),v=v.slice(0,H));var Y=v.indexOf("?");if(-1!==Y?(this.search=v.substr(Y),this.query=v.substr(Y+1),t&&(this.query=g.parse(this.query)),v=v.slice(0,Y)):t&&(this.search="",this.query={}),v&&(this.pathname=v),y[w]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var W=this.search||"";this.path=F+W}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,i="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(i=g.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||i&&"?"+i||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||y[t])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),t+o+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(s=s.replace("#","%23"))+n},o.prototype.resolve=function(e){return this.resolveObject(v(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if("string"==typeof e){var t=new o;t.parse(e,!1,!0),e=t}for(var r=new o,n=Object.keys(this),i=0;i<n.length;i++){var s=n[i];r[s]=this[s]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var a=Object.keys(e),u=0;u<a.length;u++){var c=a[u];"protocol"!==c&&(r[c]=e[c])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!y[e.protocol]){for(var l=Object.keys(e),f=0;f<l.length;f++){var p=l[f];r[p]=e[p]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||m[e.protocol])r.pathname=e.pathname;else{for(var h=(e.pathname||"").split("/");h.length&&!(e.host=h.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==h[0]&&h.unshift(""),h.length<2&&h.unshift(""),r.pathname=h.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var d=r.pathname||"",g=r.search||"";r.path=d+g}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),b=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=b||v||r.host&&e.pathname,w=_,k=r.pathname&&r.pathname.split("/")||[],S=(h=e.pathname&&e.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(S&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===h[0]?h[0]=e.host:h.unshift(e.host)),e.host=null),_=_&&(""===h[0]||""===k[0])),b)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,k=h;else if(h.length)k||(k=[]),k.pop(),k=k.concat(h),r.search=e.search,r.query=e.query;else if(null!=e.search){if(S)r.host=k.shift(),r.hostname=r.host,(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname);return r.search=e.search,r.query=e.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=k.slice(-1)[0],E=(r.host||e.host||k.length>1)&&("."===x||".."===x)||""===x,T=0,A=k.length;A>=0;A--)"."===(x=k[A])?k.splice(A,1):".."===x?(k.splice(A,1),T++):T&&(k.splice(A,1),T--);if(!_&&!w)for(;T--;T)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var I,C=""===k[0]||k[0]&&"/"===k[0].charAt(0);S&&(r.hostname=C?"":k.length?k.shift():"",r.host=r.hostname,(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.hostname=I.shift(),r.host=r.hostname));return(_=_||r.host&&k.length)&&!C&&k.unshift(""),k.length>0?r.pathname=k.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},t.parse=v,t.resolve=function(e,t){return v(e,!1,!0).resolve(t)},t.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},t.format=function(e){return"string"==typeof e&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},t.Url=o},function(e,t,r){(function(e,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){t&&t.nodeType,e&&e.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,u=2147483647,c=/^xn--/,l=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=Math.floor,d=String.fromCharCode;function m(e){throw new RangeError(p[e])}function y(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function g(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+y((e=e.replace(f,".")).split("."),t).join(".")}function v(e){for(var t,r,n=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=d((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=d(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,r){var n=0;for(e=r?h(e/700):e>>1,e+=h(e/t);e>455;n+=36)e=h(e/35);return h(n+36*e/(e+38))}function k(e){var t,r,n,o,i,s,a,c,l,f,p,d=[],y=e.length,g=0,v=128,_=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)e.charCodeAt(n)>=128&&m("not-basic"),d.push(e.charCodeAt(n));for(o=r>0?r+1:0;o<y;){for(i=g,s=1,a=36;o>=y&&m("invalid-input"),((c=(p=e.charCodeAt(o++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||c>h((u-g)/s))&&m("overflow"),g+=c*s,!(c<(l=a<=_?1:a>=_+26?26:a-_));a+=36)s>h(u/(f=36-l))&&m("overflow"),s*=f;_=w(g-i,t=d.length+1,0==i),h(g/t)>u-v&&m("overflow"),v+=h(g/t),g%=t,d.splice(g++,0,v)}return b(d)}function S(e){var t,r,n,o,i,s,a,c,l,f,p,y,g,b,k,S=[];for(y=(e=v(e)).length,t=128,r=0,i=72,s=0;s<y;++s)(p=e[s])<128&&S.push(d(p));for(n=o=S.length,o&&S.push("-");n<y;){for(a=u,s=0;s<y;++s)(p=e[s])>=t&&p<a&&(a=p);for(a-t>h((u-r)/(g=n+1))&&m("overflow"),r+=(a-t)*g,t=a,s=0;s<y;++s)if((p=e[s])<t&&++r>u&&m("overflow"),p==t){for(c=r,l=36;!(c<(f=l<=i?1:l>=i+26?26:l-i));l+=36)k=c-f,b=36-f,S.push(d(_(f+k%b,0))),c=h(k/b);S.push(d(_(c,0))),i=w(r,g,n==o),r=0,++n}++r,++t}return S.join("")}a={version:"1.4.1",ucs2:{decode:v,encode:b},decode:k,encode:S,toASCII:function(e){return g(e,(function(e){return l.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?k(e.slice(4).toLowerCase()):e}))}},void 0===(o=function(){return a}.call(t,r,t,e))||(e.exports=o)}()}).call(this,r(264)(e),r(10))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";var n=r(266),o=r(295),i=r(47);e.exports={formats:i,parse:o,stringify:n}},function(e,t,r){"use strict";var n=r(267),o=r(112),i=r(47),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},u=Array.isArray,c=Array.prototype.push,l=function(e,t){c.apply(e,u(t)?t:[t])},f=Date.prototype.toISOString,p=i.default,h={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:o.encode,encodeValuesOnly:!1,filter:void 0,format:p,formatter:i.formatters[p],indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},d={},m=function e(t,r,i,s,a,c,f,p,m,y,g,v,b,_,w,k,S,x){for(var E,T=t,A=x,I=0,C=!1;void 0!==(A=A.get(d))&&!C;){var P=A.get(t);if(I+=1,void 0!==P){if(P===I)throw new RangeError("Cyclic object value");C=!0}void 0===A.get(d)&&(I=0)}if("function"==typeof y?T=y(r,T):T instanceof Date?T=b(T):"comma"===i&&u(T)&&(T=o.maybeMap(T,(function(e){return e instanceof Date?b(e):e}))),null===T){if(c)return m&&!k?m(r,h.encoder,S,"key",_):r;T=""}if("string"==typeof(E=T)||"number"==typeof E||"boolean"==typeof E||"symbol"==typeof E||"bigint"==typeof E||o.isBuffer(T))return m?[w(k?r:m(r,h.encoder,S,"key",_))+"="+w(m(T,h.encoder,S,"value",_))]:[w(r)+"="+w(String(T))];var O,R=[];if(void 0===T)return R;if("comma"===i&&u(T))k&&m&&(T=o.maybeMap(T,m)),O=[{value:T.length>0?T.join(",")||null:void 0}];else if(u(y))O=y;else{var M=Object.keys(T);O=g?M.sort(g):M}var D=p?String(r).replace(/\./g,"%2E"):String(r),j=s&&u(T)&&1===T.length?D+"[]":D;if(a&&u(T)&&0===T.length)return j+"[]";for(var L=0;L<O.length;++L){var U=O[L],F="object"==typeof U&&U&&void 0!==U.value?U.value:T[U];if(!f||null!==F){var N=v&&p?String(U).replace(/\./g,"%2E"):String(U),q=u(T)?"function"==typeof i?i(j,N):j:j+(v?"."+N:"["+N+"]");x.set(t,I);var B=n();B.set(d,x),l(R,e(F,q,i,s,a,c,f,p,"comma"===i&&k&&u(T)?null:m,y,g,v,b,_,w,k,S,B))}}return R};e.exports=function(e,t){var r,o=e,c=function(e){if(!e)return h;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||h.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=i.default;if(void 0!==e.format){if(!s.call(i.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n,o=i.formatters[r],c=h.filter;if(("function"==typeof e.filter||u(e.filter))&&(c=e.filter),n=e.arrayFormat in a?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":h.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===e.allowDots?!0===e.encodeDotInKeys||h.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:h.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:h.allowEmptyArrays,arrayFormat:n,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:h.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?h.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:h.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:h.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:h.encodeValuesOnly,filter:c,format:r,formatter:o,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:h.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:h.strictNullHandling}}(t);"function"==typeof c.filter?o=(0,c.filter)("",o):u(c.filter)&&(r=c.filter);var f=[];if("object"!=typeof o||null===o)return"";var p=a[c.arrayFormat],d="comma"===p&&c.commaRoundTrip;r||(r=Object.keys(o)),c.sort&&r.sort(c.sort);for(var y=n(),g=0;g<r.length;++g){var v=r[g],b=o[v];c.skipNulls&&null===b||l(f,m(b,v,p,d,c.allowEmptyArrays,c.strictNullHandling,c.skipNulls,c.encodeDotInKeys,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,y))}var _=f.join(c.delimiter),w=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?w+="utf8=%26%2310003%3B&":w+="utf8=%E2%9C%93&"),_.length>0?w+_:""}},function(e,t,r){"use strict";var n=r(19),o=r(31),i=r(269),s=r(104),a=r(294)||s||i;e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n("Side channel does not contain "+o(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,r){e||(e=a()),e.set(t,r)}};return t}},function(e,t){},function(e,t,r){"use strict";var n=r(31),o=r(19),i=function(e,t,r){for(var n,o=e;null!=(n=o.next);o=n)if(n.key===t)return o.next=n.next,r||(n.next=e.next,e.next=n),n};e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new o("Side channel does not contain "+n(e))},delete:function(t){var r=e&&e.next,n=function(e,t){if(e)return i(e,t,!0)}(e,t);return n&&r&&r===n&&(e=void 0),!!n},get:function(t){return function(e,t){if(e){var r=i(e,t);return r&&r.value}}(e,t)},has:function(t){return function(e,t){return!!e&&!!i(e,t)}(e,t)},set:function(t,r){e||(e={next:void 0}),function(e,t,r){var n=i(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(e,t,r)}};return t}},function(e,t,r){"use strict";e.exports=Error},function(e,t,r){"use strict";e.exports=EvalError},function(e,t,r){"use strict";e.exports=RangeError},function(e,t,r){"use strict";e.exports=ReferenceError},function(e,t,r){"use strict";e.exports=SyntaxError},function(e,t,r){"use strict";e.exports=URIError},function(e,t,r){"use strict";e.exports=Math.abs},function(e,t,r){"use strict";e.exports=Math.floor},function(e,t,r){"use strict";e.exports=Math.max},function(e,t,r){"use strict";e.exports=Math.min},function(e,t,r){"use strict";e.exports=Math.pow},function(e,t,r){"use strict";e.exports=Math.round},function(e,t,r){"use strict";var n=r(283);e.exports=function(e){return n(e)||0===e?e:e<0?-1:1}},function(e,t,r){"use strict";e.exports=Number.isNaN||function(e){return e!=e}},function(e,t,r){"use strict";e.exports=Object.getOwnPropertyDescriptor},function(e,t,r){"use strict";var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(e){n=!1}e.exports=n},function(e,t,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,o=r(287);e.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&o())))}},function(e,t,r){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var o=Object.getOwnPropertySymbols(e);if(1!==o.length||o[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(e,t,r){"use strict";var n=r(107),o=r(108),i=r(289);e.exports=n?function(e){return n(e)}:o?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return o(e)}:i?function(e){return i(e)}:null},function(e,t,r){"use strict";var n,o=r(109),i=r(106);try{n=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var s=!!n&&i&&i(Object.prototype,"__proto__"),a=Object,u=a.getPrototypeOf;e.exports=s&&"function"==typeof s.get?o([s.get]):"function"==typeof u&&function(e){return u(null==e?e:a(e))}},function(e,t,r){"use strict";var n="Function.prototype.bind called on incompatible ",o=Object.prototype.toString,i=Math.max,s=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},a=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r},u=function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r};e.exports=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==o.apply(t))throw new TypeError(n+t);for(var r,c=a(arguments,1),l=function(){if(this instanceof r){var n=t.apply(this,s(c,arguments));return Object(n)===n?n:this}return t.apply(e,s(c,arguments))},f=i(0,t.length-c.length),p=[],h=0;h<f;h++)p[h]="$"+h;if(r=Function("binder","return function ("+u(p,",")+"){ return binder.apply(this,arguments); }")(l),t.prototype){var d=function(){};d.prototype=t.prototype,r.prototype=new d,d.prototype=null}return r}},function(e,t,r){"use strict";var n=r(32),o=r(110),i=r(46),s=r(292);e.exports=s||n.call(i,o)},function(e,t,r){"use strict";e.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(e,t,r){"use strict";var n=Function.prototype.call,o=Object.prototype.hasOwnProperty,i=r(32);e.exports=i.call(n,o)},function(e,t,r){"use strict";var n=r(45),o=r(111),i=r(31),s=r(104),a=r(19),u=n("%WeakMap%",!0),c=o("WeakMap.prototype.get",!0),l=o("WeakMap.prototype.set",!0),f=o("WeakMap.prototype.has",!0),p=o("WeakMap.prototype.delete",!0);e.exports=u?function(){var e,t,r={assert:function(e){if(!r.has(e))throw new a("Side channel does not contain "+i(e))},delete:function(r){if(u&&r&&("object"==typeof r||"function"==typeof r)){if(e)return p(e,r)}else if(s&&t)return t.delete(r);return!1},get:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&e?c(e,r):t&&t.get(r)},has:function(r){return u&&r&&("object"==typeof r||"function"==typeof r)&&e?f(e,r):!!t&&t.has(r)},set:function(r,n){u&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new u),l(e,r,n)):s&&(t||(t=s()),t.set(r,n))}};return r}:s},function(e,t,r){"use strict";var n=r(112),o=Object.prototype.hasOwnProperty,i=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},u=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1)return e.split(",");if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},c=function(e,t,r,i){if(e){var s=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,c=r.depth>0&&/(\[[^[\]]*])/.exec(s),l=c?s.slice(0,c.index):s,f=[];if(l){if(!r.plainObjects&&o.call(Object.prototype,l)&&!r.allowPrototypes)return;f.push(l)}for(var p=0;r.depth>0&&null!==(c=a.exec(s))&&p<r.depth;){if(p+=1,!r.plainObjects&&o.call(Object.prototype,c[1].slice(1,-1))&&!r.allowPrototypes)return;f.push(c[1])}if(c){if(!0===r.strictDepth)throw new RangeError("Input depth exceeded depth option of "+r.depth+" and strictDepth is true");f.push("["+s.slice(c.index)+"]")}return function(e,t,r,o){var i=0;if(e.length>0&&"[]"===e[e.length-1]){var s=e.slice(0,-1).join("");i=Array.isArray(t)&&t[s]?t[s].length:0}for(var a=o?t:u(t,r,i),c=e.length-1;c>=0;--c){var l,f=e[c];if("[]"===f&&r.parseArrays)l=r.allowEmptyArrays&&(""===a||r.strictNullHandling&&null===a)?[]:n.combine([],a);else{l=r.plainObjects?{__proto__:null}:{};var p="["===f.charAt(0)&&"]"===f.charAt(f.length-1)?f.slice(1,-1):f,h=r.decodeDotInKeys?p.replace(/%2E/g,"."):p,d=parseInt(h,10);r.parseArrays||""!==h?!isNaN(d)&&f!==h&&String(d)===h&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(l=[])[d]=a:"__proto__"!==h&&(l[h]=a):l={0:a}}a=l}return a}(f,t,r,i)}};e.exports=function(e,t){var r=function(e){if(!e)return s;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var t=void 0===e.charset?s.charset:e.charset,r=void 0===e.duplicates?s.duplicates:e.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||s.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:s.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:s.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:s.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:s.decoder,delimiter:"string"==typeof e.delimiter||n.isRegExp(e.delimiter)?e.delimiter:s.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:s.depth,duplicates:r,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:s.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:s.strictDepth,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}}(t);if(""===e||null==e)return r.plainObjects?{__proto__:null}:{};for(var l="string"==typeof e?function(e,t){var r={__proto__:null},c=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;c=c.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l=t.parameterLimit===1/0?void 0:t.parameterLimit,f=c.split(t.delimiter,t.throwOnLimitExceeded?l+1:l);if(t.throwOnLimitExceeded&&f.length>l)throw new RangeError("Parameter limit exceeded. Only "+l+" parameter"+(1===l?"":"s")+" allowed.");var p,h=-1,d=t.charset;if(t.charsetSentinel)for(p=0;p<f.length;++p)0===f[p].indexOf("utf8=")&&("utf8=%E2%9C%93"===f[p]?d="utf-8":"utf8=%26%2310003%3B"===f[p]&&(d="iso-8859-1"),h=p,p=f.length);for(p=0;p<f.length;++p)if(p!==h){var m,y,g=f[p],v=g.indexOf("]="),b=-1===v?g.indexOf("="):v+1;-1===b?(m=t.decoder(g,s.decoder,d,"key"),y=t.strictNullHandling?null:""):(m=t.decoder(g.slice(0,b),s.decoder,d,"key"),y=n.maybeMap(u(g.slice(b+1),t,i(r[m])?r[m].length:0),(function(e){return t.decoder(e,s.decoder,d,"value")}))),y&&t.interpretNumericEntities&&"iso-8859-1"===d&&(y=a(String(y))),g.indexOf("[]=")>-1&&(y=i(y)?[y]:y);var _=o.call(r,m);_&&"combine"===t.duplicates?r[m]=n.combine(r[m],y):_&&"last"!==t.duplicates||(r[m]=y)}return r}(e,r):e,f=r.plainObjects?{__proto__:null}:{},p=Object.keys(l),h=0;h<p.length;++h){var d=p[h],m=c(d,l[d],r,"string"==typeof e);f=n.merge(f,m,r)}return!0===r.allowSparse?f:n.compact(f)}},function(e,t){},function(e,t){},function(e,t,r){(function(t){var n=r(299),o=function(){},i=function(e,r,s){if("function"==typeof r)return i(e,null,r);r||(r={}),s=n(s||o);var a=e._writableState,u=e._readableState,c=r.readable||!1!==r.readable&&e.readable,l=r.writable||!1!==r.writable&&e.writable,f=!1,p=function(){e.writable||h()},h=function(){l=!1,c||s.call(e)},d=function(){c=!1,l||s.call(e)},m=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){s.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!f)return(!c||u&&u.ended&&!u.destroyed)&&(!l||a&&a.ended&&!a.destroyed)?void 0:s.call(e,new Error("premature close"))},b=function(){e.req.on("finish",h)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?l&&!a&&(e.on("end",p),e.on("close",p)):(e.on("complete",h),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",d),e.on("finish",h),!1!==r.error&&e.on("error",y),e.on("close",g),function(){f=!0,e.removeListener("complete",h),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",h),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",h),e.removeListener("exit",m),e.removeListener("end",d),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=i}).call(this,r(9))},function(e,t,r){var n=r(300);function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=n(o),e.exports.strict=n(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){n[e]=t[e]})),n;function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),o=e[e.length-1];return"function"==typeof n&&n!==o&&Object.keys(o).forEach((function(e){n[e]=o[e]})),n}}},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}(t)):null}},function(e,t,r){"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},function(e,t,r){"use strict";r.r(t);var n=r(20),o=r.n(n),i=r(3),s=r.n(i),a=r(4),u=r.n(a),c=r(5),l=r.n(c),f=r(2),p=r.n(f),h=r(1),d=r.n(h),m=r(7),y=r.n(m);var g=function(e){return e=e||Object.create(null),{on:function(t,r){(e[t]||(e[t]=[])).push(r)},off:function(t,r){e[t]&&e[t].splice(e[t].indexOf(r)>>>0,1)},emit:function(t,r){(e[t]||[]).slice().map((function(e){e(r)})),(e["*"]||[]).slice().map((function(e){e(t,r)}))}}},v=r(6),b=r.n(v),_=r(50),w=r.n(_),k=r(51),S=r.n(k),x=r(52);function E(e){return e.replace(/<[^>]*\/?>([\s\S]*)?<\/.*?>/gi,(function(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}))}var T=function(){return l()((function e(t){u()(this,e),this.roomAdapter=t,this.name=null,this.emails=[],this.options={}}),[{key:"withName",value:function(e){return this.name=e,this}},{key:"withOptions",value:function(e){return this.options=e,this}},{key:"addParticipants",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return this.emails=(e=this.emails.filter((function(e){return-1===r.indexOf(e)}))).concat.apply(e,r),this}},{key:"create",value:function(){var e=this.name,t=this.emails,r=this.options;return this.roomAdapter.createRoom(e,t,{avatarURL:r.avatarURL},r)}}])}();var A=function(){return l()((function e(t){u()(this,e),this.id=t.id,this.before_id=t.comment_before_id,this.message=E(t.message),this.username_as=t.username_as||t.username,this.username_real=t.username_real||t.email,this.email=this.username_real,this.user_extras=t.user_extras,this.date=Object(x.format)(t.timestamp,"YYYY-MM-DD"),this.time=Object(x.format)(t.timestamp,"HH:mm"),this.timestamp=t.timestamp,this.unique_id=t.unique_temp_id||t.unique_id,this.unique_temp_id=t.unique_temp_id||t.unique_id,this.avatar=t.user_avatar_url,this.room_id=t.room_id,this.isChannel=t.is_public_channel,this.unix_timestamp=t.unix_timestamp,this.unix_nano_timestamp=t.unix_nano_timestamp,this.extras=t.extras,this.is_deleted=t.is_deleted,this.isPending=!1,this.isFailed=!1,this.isDelivered=!1,this.isRead=!1,this.isSent=!1,this.attachment=null,this.payload=t.payload,this.status=t.status,"reply"===t.type&&(t.payload.replied_comment_message=E(t.payload.replied_comment_message),t.payload.text=E(t.payload.text)),this.type=t.type,this.subtype="custom"===t.type?t.payload.type:null,"sent"===t.status?this.markAsSent():"delivered"===t.status?this.markAsDelivered():"read"===t.status&&this.markAsRead()}),[{key:"isAttachment",value:function(e){return"[file]"===e.substring(0,"[file]".length)}},{key:"isImageAttachment",value:function(e){return this.isAttachment(e)&&null!=e.match(/\.(jpg|jpeg|gif|png)/i)}},{key:"attachUniqueId",value:function(e){this.unique_id=e}},{key:"getAttachmentURI",value:function(e){if(this.isAttachment(e)){var t=e.length,r="[file]".length,n=t-"[/file]".length;return e.substring(r,n).trim()}}},{key:"setAttachment",value:function(e){this.attachment=e}},{key:"markAsPending",value:function(){this.isPending=!0,this.isDelivered=!1,this.status="pending"}},{key:"markAsSent",value:function(){this.isSent=!0,this.isPending=!1,this.isFailed=!1,this.status="sent"}},{key:"markAsDelivered",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.actor,r=e.activeActorId;t!==r&&(this.isRead||"read"===this.status||(this.isSent=!0,this.isRead=!1,this.isDelivered=!0,this.status="delivered"))}},{key:"markAsRead",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.actor,r=e.activeActorId;t!==r&&(this.isPending=!1,this.isSent=!0,this.isDelivered=!0,this.isRead=!0,this.status="read")}},{key:"markAsFailed",value:function(){this.isFailed=!0,this.isPending=!1,this.isStatus="failed"}},{key:"update",value:function(e){this.id=e.id,this.before_id=e.comment_before_id,this.message=E(e.message),e.payload&&(this.payload=e.payload),e.status&&(this.status=e.status),"reply"===e.type&&(this.payload.replied_comment_message=E(e.payload.replied_comment_message),this.payload.text=E(e.payload.text)),"sent"===e.status?this.markAsSent():"delivered"===e.status?this.markAsDelivered():"read"===e.status&&this.markAsRead()}}])}(),I=function(){return l()((function e(t){u()(this,e),this.id=t.id,this.last_comment_id=t.last_comment_id,this.last_comment_message=t.last_comment_message,this.last_comment_message_created_at=t.last_comment_message_created_at,this.last_comment_topic_title=t.last_comment_topic_title,this.avatar=t.room_avatar||t.avatarURL||t.avatar_url,this.name=t.room_name,this.room_type=t.room_type||t.chat_type,this.secret_code=t.secret_code,this.participants=t.participants,this.options=t.options,this.topics=[],this.last_comment=t.last_comment,this.comments=[],this.count_notif=t.unread_count,this.isLoaded=!1,this.custom_title=null,this.custom_subtitle=null,this.options=t.options,this.unique_id=t.unique_id,this.isChannel=t.is_public_channel,this.participantNumber=t.room_total_participants,t.comments&&this.receiveComments(t.comments)}),[{key:"isCurrentlySelected",value:function(e){return this.id===e.id}},{key:"getParticipantCount",value:function(){return null==this.participants?this.participantNumber:this.participants.length}},{key:"setTitle",value:function(e){this.custom_title=e}},{key:"setSubTitle",value:function(e){this.custom_subtitle=e}},{key:"receiveComment",value:function(e){if(e.room_id===this.id){var t=this.comments.find((function(t){return t.unique_id===e.unique_id}));t?(t.id=e.id,t.message=e.message,t.date=e.date,t.time=e.time,t.unix_timestamp=e.unix_timestamp):this.comments=[].concat(o()(this.comments),[e])}}},{key:"receiveComments",value:function(e){var t=this;e.forEach((function(e){t.receiveComment(new A(e))}))}},{key:"getParticipant",value:function(e){return this.participants.find((function(t){return t.email===e}))||null}},{key:"addParticipant",value:function(e){this.getParticipant(e.email)||this.participants.push(e)}}])}(),C=function(){return l()((function e(t){var r=t.baseURL,n=t.AppId,o=t.userId,i=t.version,s=t.getCustomHeader;u()(this,e),this.baseURL=r,this.token=null,this.userId=o,this.AppId=n,this.version=i,this.getCustomHeader=s}),[{key:"setToken",value:function(e){this.token=e}},{key:"get",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(o,i){var s=y.a.get("".concat(t.baseURL,"/").concat(e));n&&n.baseURL&&(s=y.a.get("".concat(n.baseURL,"/").concat(e))),(s=t.setupHeaders(s,r)).end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"get_request",value:function(e){var t=y.a.get("".concat(this.baseURL,"/").concat(e));return t=this.setupHeaders(t,{})}},{key:"post",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.post("".concat(t.baseURL,"/").concat(e));(s=t.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"post_json",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.post("".concat(t.baseURL,"/").concat(e));(s=t.setupHeaders(s,n)).send(r).set("Content-Type","application/json").end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"put",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.put("".concat(t.baseURL,"/").concat(e));(s=t.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"patch",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.patch("".concat(t.baseURL,"/").concat(e));(s=t.setupHeaders(s,n)).send(r).set("Content-Type","application/x-www-form-urlencoded").end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"del",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise((function(o,i){var s=y.a.del("".concat(t.baseURL,"/").concat(e));(s=t.setupHeaders(s,n)).send(r).set("Content-Type","application/json").end((function(e,r){return e?(t._rethrowIfExpiredToken(e),i(e)):o(r)}))}))}},{key:"setupHeaders",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.AppId&&e.set("QISCUS-SDK-APP-ID","".concat(this.AppId)),null!=this.userId&&e.set("QISCUS-SDK-USER-ID","".concat(this.userId)),null!=this.token&&e.set("QISCUS-SDK-TOKEN","".concat(this.token)),null!=this.version&&e.set("QISCUS-SDK-VERSION","".concat(this.version)),null!=this.getCustomHeader){var r=this.getCustomHeader();Object.keys(r).filter((function(e){return null!=r[e]})).forEach((function(t){e.set(t,r[t])}))}if(Object.keys(t).length<1)return e;for(var n in t)t.hasOwnProperty(n)&&e.set(n,t[n]);return e}},{key:"_rethrowIfExpiredToken",value:function(e){var t,r,n,o=null===(t=e.response)||void 0===t?void 0:t.status,i=null===(r=e.response)||void 0===r?void 0:r.body;if(403===o&&"unauthorized. token is expired"===(null===(n=i.error)||void 0===n||null===(n=n.message)||void 0===n?void 0:n.toLowerCase()))throw new Error("Token expired")}}])}(),P=function(){return l()((function e(t){u()(this,e),this.HTTPAdapter=t,this.refreshToken=null,this.userId=null,this.autoRefreshToken=!1}),[{key:"getNonce",value:function(){return this.HTTPAdapter.post("api/v2/sdk/auth/nonce").then((function(e){return e.body.results}))}},{key:"loginOrRegister",value:function(e){var t=this;return this.HTTPAdapter.post("api/v2/sdk/login_or_register",e).then((function(e){if(200!==e.body.status)return Promise.reject(e);var r=e.body.results;return t.userId=r.user.email,t.refreshToken=r.user.refresh_token,r}))}},{key:"verifyIdentityToken",value:function(e){var t=this;return this.HTTPAdapter.post("api/v2/sdk/auth/verify_identity_token",{identity_token:e}).then((function(e){var r=e.body.results;return t.userId=r.user.email,t.refreshToken=r.user.refresh_token,r}))}},{key:"refreshAuthToken",value:function(){var e=this;return this.HTTPAdapter.post("api/v2/sdk/refresh_user_token",{user_id:this.userId,refresh_token:this.refreshToken}).then((function(t){var r=t.body.results;return e.refreshToken=r.refresh_token,e.HTTPAdapter.token=r.token,r}))}},{key:"expiredAuthToken",value:function(){return this.HTTPAdapter.post("api/v2/sdk/expire_user_token",{user_id:this.userId}).then((function(e){return e.body.results}))}}])}(),O=r(118),R=r.n(O);function M(e){var t={},r=function(e,t){return"".concat(e,"=").concat(t)};return{param:function(e,r){return t[e]=r,this},build:function(){var n=Object.keys(t).filter((function(e){return null!=t[e]})).map((function(e){return Array.isArray(t[e])?t[e].map((function(t){return r("".concat(e,"[]"),t)})).join("&"):r(e,t[e])})).join("&");return[e].concat(n).join("?")}}}var D=function(){return l()((function e(t){var r=this;u()(this,e),p()(this,"updateCommentStatus",R()((function(e,t,n){var o={room_id:e};return t&&(o.last_comment_read_id=t),n&&(o.last_comment_received_id=n),r.HTTPAdapter.post("api/v2/sdk/update_comment_status",o)}),500)),this.HTTPAdapter=t,this.token=t.token}),[{key:"postComment",value:function(e,t,r,n,o,i){return this.HTTPAdapter.post_json("api/v2/sdk/post_comment",{comment:t,topic_id:e,unique_temp_id:r,type:n,payload:o,extras:i}).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.comment)}))}},{key:"loadRoomList",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=M("api/v2/sdk/user_rooms").param("page",t.page).param("show_participants",t.show_participants||!0).param("limit",t.limit).param("show_empty",t.show_empty).param("room_type",null!==(e=t.room_type)&&void 0!==e?e:"default").build();return this.HTTPAdapter.get(r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.rooms_info)}))}},{key:"searchMessages",value:function(e){var t={query:e.query||null,room_id:e.room_id||null,last_comment_id:e.last_comment_id||null};return this.HTTPAdapter.post("api/v2/sdk/search_messages",t).then((function(e){return e.body.results.comments}))}},{key:"updateProfile",value:function(e){var t={name:e.name||null,avatar_url:e.avatar_url||null,extras:e.extras?JSON.stringify(e.extras):null};return this.HTTPAdapter.patch("api/v2/sdk/my_profile",t).then((function(e){return e.body.results.user}))}},{key:"uploadFile",value:function(e){var t={file:e};return this.HTTPAdapter.post("api/v2/sdk/upload",t).then((function(e){return e.body}))}},{key:"getRoomsInfo",value:function(e){var t={show_participants:!0,show_removed:!1};return e.room_ids&&(t.room_id=e.room_ids),e.room_unique_ids&&(t.room_unique_id=e.room_unique_ids),e.show_participants&&(t.show_participants=e.show_participants),e.show_removed&&(t.show_removed=e.show_removed),this.HTTPAdapter.post_json("api/v2/sdk/rooms_info",t).then((function(e){return e.body}))}},{key:"loadComments",value:function(e,t){var r=M("api/v2/sdk/load_comments").param("topic_id",e).param("last_comment_id",t.last_comment_id).param("timestamp",t.timestamp).param("after",t.after).param("limit",t.limit).build();return this.HTTPAdapter.get(r).then((function(e){return 200!==e.status?Promise.reject(e):Promise.resolve(e.body.results.comments)}))}},{key:"deleteComment",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!1===r&&console.warn("Deprecated: delete comment for me will be removed on next release"),!1===n&&console.warn("Deprecated: soft delete will be removed on next release");var o={unique_ids:t,is_delete_for_everyone:r,is_hard_delete:n};return this.HTTPAdapter.del("api/v2/sdk/delete_messages",o).then((function(e){return e.body}))}},{key:"clearRoomMessages",value:function(e){var t={room_channel_ids:e};return this.HTTPAdapter.del("api/v2/sdk/clear_room_messages",t).then((function(e){return e.body}))}},{key:"getCommentReceiptStatus",value:function(e){return this.HTTPAdapter.get("api/v2/sdk/comment_receipt?comment_id=".concat(e)).then((function(e){return e.body}))}},{key:"getBlockedUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r="api/v2/sdk/get_blocked_users?page=".concat(e,"&limit=").concat(t);return this.HTTPAdapter.get(r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.blocked_users)}))}},{key:"blockUser",value:function(e){if(!e)throw new Error("email is required");var t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/block_user",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user)}))}},{key:"unblockUser",value:function(e){if(!e)throw new Error("email is required");var t={user_email:e};return this.HTTPAdapter.post("api/v2/sdk/unblock_user",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user)}))}},{key:"getProfile",value:function(){return this.HTTPAdapter.get("api/v2/sdk/my_profile").then((function(e){return e.body.results.user}))}},{key:"getUserPresences",value:function(e){var t={user_ids:e};return this.HTTPAdapter.post_json("api/v2/sdk/users/status",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.user_status)}))}},{key:"updateMessage",value:function(e){var t={token:this.token,comment:e.message,unique_id:e.unique_id||e.unique_temp_id};return null!=e.extras&&(t.extras=e.extras),null!=e.payload&&(t.payload=e.payload),this.HTTPAdapter.post_json("api/v2/sdk/update_message",t).then((function(e){return e.body.results.comment}))}}])}(),j=function(){return l()((function e(t){u()(this,e),this.HTTPAdapter=t,this.token=t.token}),[{key:"getOrCreateRoom",value:function(e,t,r){var n={emails:e};return r&&(n[r]=r),t&&(n.options=JSON.stringify(t)),this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_target",n).then((function(t){if(200!==t.body.status)return Promise.reject(t);var r=t.body.results.room;r.avatar=r.avatar_url,r.comments=t.body.results.comments.reverse();var n=r.participants.find((function(t){return t.email===e}));return r.name=n?n.username:"Room name",Promise.resolve(r)}))}},{key:"getRoomById",value:function(e){return this.HTTPAdapter.get("api/v2/sdk/get_room_by_id?id=".concat(e)).then((function(e){return e.body}))}},{key:"getOrCreateRoomByUniqueId",value:function(e,t,r){var n={unique_id:e,name:t,avatar_url:r};return this.HTTPAdapter.post("api/v2/sdk/get_or_create_room_with_unique_id",n).then((function(e){if(200!==e.body.status)return Promise.reject(e);var t=e.body.results.room;return t.avatar=t.avatar_url,t.comments=e.body.results.comments.reverse(),t.name=t.room_name,Promise.resolve(t)}))}},{key:"createRoom",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=Object.keys(n).length<=0?null:JSON.stringify(n),i={name:e,"participants[]":t,avatar_url:r.avatarURL,options:o};return this.HTTPAdapter.post("api/v2/sdk/create_room",i).then((function(e){if(200!==e.body.status)return Promise.reject(e);var t=e.body.results.room;return t.comments=e.body.results.comments,Promise.resolve({id:t.id,name:t.room_name,lastCommentId:t.last_comment_id,lastCommentMessage:t.last_comment_message,lastTopicId:t.last_topic_id,avatarURL:t.avatar_url,options:t.options,participants:t.participants.map((function(e){return{id:e.id,email:e.email,username:e.username,avatarURL:e.avatar_url}}))})}))}},{key:"updateRoom",value:function(e){if(!e.id)throw new Error("id is required");var t={id:e.id};return e.room_name&&(t.room_name=e.room_name),e.avatar_url&&(t.avatar_url=e.avatar_url),e.options&&(t.options=JSON.stringify(e.options)),this.HTTPAdapter.post("api/v2/sdk/update_room",t).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.room)}))}},{key:"getTotalUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/total_unread_count").then((function(e){return e.body.results.total_unread_count}))}},{key:"getRoomUnreadCount",value:function(){return this.HTTPAdapter.get("api/v2/sdk/get_room_unread_count").then((function(e){return e.body.results.total_unread_count}))}},{key:"addParticipantsToGroup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e||!t)throw new Error("room_id and emails is required");var r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/add_room_participants",r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.participants_added)}))}},{key:"removeParticipantsFromGroup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e||!t)throw new Error("room_id and emails is required");var r={room_id:e,"emails[]":t};return this.HTTPAdapter.post("api/v2/sdk/remove_room_participants",r).then((function(e){return 200!==e.body.status?Promise.reject(e):Promise.resolve(e.body.results.participants_removed)}))}}])}(),L=r(119),U=r.n(L),F=r(26),N=r.n(F),q=String("match.pattern.catchAll"),B=String("match.pattern.OR"),H=B.toString(),Y=String("match.pattern.AND"),W=Y.toString(),z=String("match.pattern.RANGE"),$=z.toString(),V=String("match.pattern.REGEXP"),K=V.toString(),Q=/\/(.*)\/(.*)/;function G(){Error.call(this,"Missing when() catch-all pattern as last match argument, add [when()]: void 0"),"stack"in this||(this.stack=(new Error).stack)}function J(e){return void 0===e?q:e instanceof RegExp?X([V.toString(),e.toString()]):X(e)}function X(e){return JSON.stringify([J.__uid++,e])}function Z(){return!0}function ee(e){if(Array.isArray(e)){if(e[0]===H)return e.shift(),function(t){return e[0].some((function(e){return r(e,t)}))};if(e[0]===W)return e.shift(),function(t){return e[0].every((function(e){return r(e,t)}))};if(e[0]===$)return e.shift(),function(t){return e[0]<=t&&t<=e[1]};if(e[0]===K){var t=Q.exec(e[1]);return r.bind(null,new RegExp(t[1],t[2]))}}function r(e,t){if(Array.isArray(t))return JSON.stringify(e)===JSON.stringify(t);if(e instanceof RegExp)return e.test(t);if("object"===N()(t)){for(var r in e)if(t[r]!==e[r])return!1;return!0}return e===t}return function(t){return r(e,t)}}G.prototype=Object.create(Error.prototype),J.__uid=0,J.or=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return X([B.toString(),t])},J.and=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return X([Y.toString(),t])},J.range=function(e,t){return X([z.toString(),e,t])},J.unserialize=function(e,t){if(e===q)return{match:Z,result:t,position:1/0};var r,n=(r=e,JSON.parse(r)),o=n[1],i=n[0];return{match:ee(o),result:t,position:i}};var te=r(120),re=r.n(te),ne=r(121),oe=r.n(ne),ie=function(e,t,r,n){try{var o=e();return null!=n&&n(o),o}catch(e){return null!=r&&r(e),t}},se=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return new Promise((function(t){return setTimeout(t,e)}))};function ae(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ue(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(r),!0).forEach((function(t){p()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ce=function(){return l()((function e(t,r,n,o){var i=this,a=o.shouldConnect,c=void 0===a||a,l=o.brokerLbUrl,f=o.enableLb,h=o.getClientId;u()(this,e),p()(this,"_getClientId",(function(){return null==i.getClientId?"".concat(i.core.AppId,"_").concat(i.core.user_id,"_").concat(Date.now()):i.getClientId()})),p()(this,"__mqtt_connected_handler",(function(){i.emitter.emit("connected")})),p()(this,"__mqtt_reconnect_handler",(function(){i.emitter.emit("reconnect")})),p()(this,"__mqtt_closed_handler",(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i.emitter.emit("close",t)})),p()(this,"__mqtt_message_handler",(function(e,t){var r=t.toString(),n=i.matcher(e);i.logger("message",e,t),null!=n&&n(r)})),p()(this,"__mqtt_error_handler",(function(e){e&&"client disconnecting"===e.message||(i.emitter.emit("error",e.message),i.logger("error",e.message))})),p()(this,"__mqtt_conneck",(function(e){var t=[],r={will:{topic:"u/".concat(i.core.user_id,"/s"),payload:0,retain:!0},clientId:i._getClientId()};if(null==e&&(e=i.cacheRealtimeURL),null!=i.mqtt){var n=Object.keys(i.mqtt._resubscribeTopics);t.push.apply(t,n),i.mqtt.removeAllListeners(),i.mqtt.end(!0),delete i.mqtt,i.mqtt=null}var o=re()(e,r);return o.addListener("connect",i.__mqtt_connected_handler),o.addListener("reconnect",i.__mqtt_reconnect_handler),o.addListener("close",i.__mqtt_closed_handler),o.addListener("error",i.__mqtt_error_handler),o.addListener("message",i.__mqtt_message_handler),i.logger("resubscribe to old topics ".concat(t)),t.forEach((function(e){return o.subscribe(e)})),o})),p()(this,"_on_close_handler",oe()(s()(d.a.mark((function e(){var t,r,n,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=!0===i.enableLb&&!0===i.core.isLogin&&!0===i.shouldConnect&&!i.willConnectToRealtime,i.logEnabled&&(console.group("@mqtt.closed"),console.log("this.enableLb(".concat(i.enableLb,")")),console.log("this.core.isLogin(".concat(i.core.isLogin,")")),console.log("this.shouldConnect(".concat(i.shouldConnect,")")),console.log("this.willConnectToRealtime(".concat(i.willConnectToRealtime,")")),console.log("shouldReconnect(".concat(t,")")),console.groupEnd()),t){e.next=4;break}return e.abrupt("return");case 4:return i.willConnectToRealtime=!0,e.next=7,i.getMqttNode().then((function(e){return[e,null]})).catch((function(e){return[null,e]}));case 7:r=e.sent,n=U()(r,2),o=n[0],n[1]?(i.logger("cannot get new brokerURL, using old url instead (".concat(i.cacheRealtimeURL,")")),i.mqtt=i.__mqtt_conneck(i.cacheRealtimeURL)):(i.cacheRealtimeURL=o,i.logger("trying to reconnect to",o),i.mqtt=i.__mqtt_conneck(o)),i.willConnectToRealtime=!1;case 13:case"end":return e.stop()}}),e)}))),1e3)),p()(this,"subscribtionBuffer",[]),p()(this,"unsubscribtionBuffer",[]),p()(this,"publishBuffer",[]),this.emitter=g(),this.core=r,this.mqtt=null,this.brokerLbUrl=l,this.getClientId=h,this.enableLb=f,this.shouldConnect=c,this.matcher=function(){var e,t=(e=arguments.length-1)<0||arguments.length<=e?void 0:arguments[e],r=[];for(var n in t)r.push(J.unserialize(n,t[n]));r.sort((function(e,t){return e.position<t.position?-1:1})),-1!==Object.getOwnPropertySymbols(t).indexOf(q)&&r.push(J.unserialize(q,t[q]));var o=function(e){var t=r.find((function(t){return t.match(e)}));if(!t)throw new G;return"function"==typeof t.result?t.result(e):t.result};return 2===arguments.length?o(arguments.length<=0?void 0:arguments[0]):o}(p()(p()(p()(p()(p()(p()(p()(p()(p()(p()({},J(this.reNewMessage),(function(e){return i.newMessageHandler.bind(i,e)})),J(this.reNotification),(function(e){return i.notificationHandler.bind(i,e)})),J(this.reTyping),(function(e){return i.typingHandler.bind(i,e)})),J(this.reRoomTyping),(function(e){return i.roomTypingHandler.bind(i,e)})),J(this.reDelivery),(function(e){return i.deliveryReceiptHandler.bind(i,e)})),J(this.reRead),(function(e){return i.readReceiptHandler.bind(i,e)})),J(this.reOnlineStatus),(function(e){return i.onlinePresenceHandler.bind(i,e)})),J(this.reChannelMessage),(function(e){return i.channelMessageHandler.bind(i,e)})),J(this.reMessageUpdated),(function(e){return i.messageUpdatedHandler.bind(i,e)})),J(),(function(e){return i.logger("topic not handled",e)})));var m=this.__mqtt_conneck(t);this.mqtt=m,c||m.end(!0),this.willConnectToRealtime=!1,this.emitter.on("close",this._on_close_handler)}),[{key:"cacheRealtimeURL",get:function(){return this.core.mqttURL},set:function(e){this.core.mqttURL=e}},{key:"connect",value:function(){this.mqtt=this.__mqtt_conneck()}},{key:"openConnection",value:(r=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.shouldConnect=!0,this.__mqtt_conneck();case 2:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"closeConnection",value:(t=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.shouldConnect=!1,this.mqtt.end(!0);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getMqttNode",value:(e=s()(d.a.mark((function e(){var t,r,n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y.a.get(this.brokerLbUrl);case 2:return t=e.sent,r=t.body.data.url,n=t.body.data.wss_port,e.abrupt("return","wss://".concat(r,":").concat(n,"/mqtt"));case 6:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"connected",get:function(){return null!=this.mqtt&&this.mqtt.connected}},{key:"subscribe",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(this.logger("subscribe to",t),this.subscribtionBuffer.push(t),null!=this.mqtt)do{var n,o=this.subscribtionBuffer.shift();null!=o&&(n=this.mqtt).subscribe.apply(n,t)}while(this.subscribtionBuffer.length>0)}},{key:"unsubscribe",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(this.logger("unsubscribe from",t),this.unsubscribtionBuffer.push(t),null!=this.mqtt)do{var n,i=this.unsubscribtionBuffer.shift();if(null!=i)(n=this.mqtt).unsubscribe.apply(n,o()(i))}while(this.unsubscribtionBuffer.length>0)}},{key:"publish",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.publishBuffer.push({topic:e,payload:t,options:r});do{var n=this.publishBuffer.shift();if(null!=n)return this.mqtt.publish(n.topic,n.payload.toString(),n.options)}while(this.publishBuffer.length>0)}},{key:"emit",value:function(){var e;(e=this.emitter).emit.apply(e,arguments)}},{key:"on",value:function(){var e;(e=this.emitter).on.apply(e,arguments)}},{key:"off",value:function(){var e;(e=this.emitter).off.apply(e,arguments)}},{key:"logEnabled",get:function(){return this.core.debugMQTTMode}},{key:"logger",get:function(){return this.core.debugMQTTMode?console.log.bind(console,"QRealtime ->"):this.noop}},{key:"reNewMessage",get:function(){return/^(.+)\/c$/i}},{key:"reNotification",get:function(){return/^(.+)\/n$/i}},{key:"reTyping",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/t$/i}},{key:"reRoomTyping",get:function(){return/^r\/(.+)\/typing$/i}},{key:"reDelivery",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/d$/i}},{key:"reRead",get:function(){return/^r\/([\d]+)\/([\d]+)\/(.+)\/r$/i}},{key:"reOnlineStatus",get:function(){return/^u\/(.+)\/s$/i}},{key:"reChannelMessage",get:function(){return/^(.+)\/(.+)\/c$/i}},{key:"reMessageUpdated",get:function(){return/^(.+)\/update$/i}},{key:"noop",value:function(){}},{key:"newMessageHandler",value:function(e,t){t=JSON.parse(t),this.logger("on:new-message",t),this.emit("new-message",t)}},{key:"notificationHandler",value:function(e,t){var r=this;this.logger("on:notification",t);var n=(t=JSON.parse(t)).payload.data;"deleted_messages"in n&&n.deleted_messages.forEach((function(e){r.emit("comment-deleted",{roomId:e.room_id,commentUniqueIds:e.message_unique_ids,isForEveryone:!0,isHard:!0})})),"deleted_rooms"in n&&n.deleted_rooms.forEach((function(e){r.emit("room-cleared",e)}))}},{key:"roomTypingHandler",value:function(e,t){var r;this.logger("on:room-typing",e);var n=null===(r=e.match(this.reRoomTyping))||void 0===r?void 0:r[1],o=JSON.parse(t);this.emit("room-typing",ue(ue({},o),{},{room_id:n}))}},{key:"typingHandler",value:function(e,t){this.logger("on:typing",e);var r=e.match(this.reTyping);if(r[3]!==this.core.user_id){var n=r[3],o=r[1];if(this.emit("typing",{message:t,userId:n,roomId:o}),null!=this.core.selected)if("1"===t&&o===this.core.selected.id){var i=this.core.selected.participants.find((function(e){return e.email===n}));if(null==i)return;var s=i.username;this.core.isTypingStatus="".concat(s," is typing ...")}else this.core.isTypingStatus=null}}},{key:"deliveryReceiptHandler",value:function(e,t){this.logger("on:delivered",e,t);var r=e.match(this.reDelivery),n=t.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-delivered",{commentId:o,commentUniqueId:i,userId:s})}},{key:"readReceiptHandler",value:function(e,t){this.logger("on:read",e,t);var r=e.match(this.reRead),n=t.split(":"),o=Number(n[0]),i=n[1],s=r[3];this.emit("message-read",{commentId:o,commentUniqueId:i,userId:s})}},{key:"onlinePresenceHandler",value:function(e,t){this.logger("on:online-presence",e,t);var r=this.reOnlineStatus.exec(e)[1];this.emit("presence",{message:t,userId:r})}},{key:"channelMessageHandler",value:function(e,t){this.logger("on:channel-message",e,t),this.emit("new-message",JSON.parse(t))}},{key:"messageUpdatedHandler",value:function(e,t){t=JSON.parse(t),this.logger("on:message-updated",e,t),this.emit("message:updated",t)}},{key:"subscribeChannel",value:function(e,t){this.subscribe("".concat(e,"/").concat(t,"/c"))}},{key:"subscribeRoom",value:function(e){null!=this.core.selected&&(e=e||this.core.selected.id,this.subscribe("r/".concat(e,"/typing")),this.subscribe("r/".concat(e,"/").concat(e,"/+/t")),this.subscribe("r/".concat(e,"/").concat(e,"/+/d")),this.subscribe("r/".concat(e,"/").concat(e,"/+/r")))}},{key:"unsubscribeRoom",value:function(e){null!=this.core.selected&&(e=e||this.core.selected.id,this.unsubscribe("r/".concat(e,"/typing")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/t")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/d")),this.unsubscribe("r/".concat(e,"/").concat(e,"/+/r")))}},{key:"subscribeTyping",get:function(){return this.subscribeRoom.bind(this)}},{key:"unsubscribeTyping",get:function(){return this.unsubscribeRoom.bind(this)}},{key:"subscribeUserChannel",value:function(){this.subscribe("".concat(this.core.userData.token,"/c")),this.subscribe("".concat(this.core.userData.token,"/n")),this.subscribe("".concat(this.core.userData.token,"/update"))}},{key:"publishPresence",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];t?this.publish("u/".concat(e,"/s"),1,{retain:!0}):this.publish("u/".concat(e,"/s"),0,{retain:!0})}},{key:"disconnect",value:function(){this.publishPresence(this.core.userData.email,!1),this.unsubscribe(Object.keys(this.mqtt._resubscribeTopics))}},{key:"subscribeUserPresence",value:function(e){this.subscribe("u/".concat(e,"/s"))}},{key:"unsubscribeUserPresence",value:function(e){this.unsubscribe("u/".concat(e,"/s"))}},{key:"subscribeRoomPresence",get:function(){return this.subscribeUserPresence.bind(this)}},{key:"unsubscribeRoomPresence",get:function(){return this.unsubscribeUserPresence.bind(this)}},{key:"publishTyping",value:function(e){if(null!=this.core.selected){var t=this.core.selected.id,r=this.core.user_id;this.publish("r/".concat(t,"/").concat(t,"/").concat(r,"/t"),e)}}}]);var e,t,r}();function le(e,t){var r=g(),n={},o=/^r\/[\w]+\/[\w]+\/e$/i;e.mqtt.on("message",(function(e,t){o.test(e)&&r.emit(e,t)}));var i=function(e){return"r/".concat(e,"/").concat(e,"/e")};return{publishEvent:function(r,n){if(b.a.undefined(r))throw new Error("`roomId` required");if(b.a.not.string(r))throw new TypeError("`roomId` must have type of string");if(b.a.undefined(n))throw new Error("`payload` required");if(b.a.not.object(n))throw new TypeError("`payload` must have type of object");var o=JSON.stringify({sender:t,data:n});e.mqtt.publish(i(r),o)},subscribeEvent:function(t,o){if(b.a.undefined(t))throw new Error("`roomId` required");if(b.a.not.string(t))throw new TypeError("`roomId` must have type of string");if(b.a.undefined(o))throw new Error("`callback` required");if(b.a.not.function(o))throw new TypeError("`callback` must have type of function");var s=i(t);if(!n[s]){e.mqtt.subscribe(s);var a=function(e){var t=JSON.parse(e);o(t)};r.on(s,a),n[s]=a}},unsubscribeEvent:function(t){if(b.a.undefined(t))throw new Error("`roomId` required");if(b.a.not.string(t))throw new TypeError("`roomId` must have type of string");var o=i(t);n[o]&&(e.mqtt.unsubscribe(o),r.off(o,n[o]),n[o]=null,delete n[o])}}}var fe=r(53),pe=r.n(fe),he=r(54),de=r.n(he);function me(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new ye(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function ye(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(ye=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new ye(e)}var ge=function(){},ve=function(e){return new Promise((function(t){return setTimeout(t,e)}))};function be(e,t){var r=t.isDebug,n=void 0!==r&&r,o=t.syncInterval,i=t.getShouldSync,a=t.syncOnConnect,u=t.lastCommentId,c=t.statusLogin,l=t.enableSync,f=t.enableSyncEvent,p=g(),h=function(){for(var e,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return n?(e=console).log.apply(e,["QSync:"].concat(r)):{}},m=0,y=function(){return c()?i()?o():a():0},v=function(e,t,r,n,o){var i=g(),a=function(r){var n=M("api/v2/sdk/sync").param("last_received_comment_id",r).build();return e().get(n).then((function(e){var r=e.body.results,n=r.comments,o=r.meta.last_received_comment_id;return n.sort((function(e,t){return e.id-t.id})),Promise.resolve({lastMessageId:o,messages:n,interval:t()})})).catch(ge)};function u(){return c.apply(this,arguments)}function c(){return(c=de()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=e()&&r()};case 3:if(!((i+=s)>=t()&&u())){o.next=9;break}return i=0,o.next=9,a(n());case 9:return o.next=11,pe()(ve(s));case 11:o.next=3;break;case 13:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function e(){var t,r,s,a,c,l,f,p;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!1,r=!1,e.prev=2,a=me(u());case 4:return e.next=6,a.next();case 6:if(!(t=!(c=e.sent).done)){e.next=12;break}l=c.value;try{f=l.lastMessageId,p=l.messages,f>n()&&(p.forEach((function(e){return i.emit("message.new",e)})),i.emit("last-message-id.new",f))}catch(e){o("error when sync",e.message)}case 9:t=!1,e.next=4;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(2),r=!0,s=e.t0;case 18:if(e.prev=18,e.prev=19,!t||null==a.return){e.next=23;break}return e.next=23,a.return();case 23:if(e.prev=23,!r){e.next=26;break}throw s;case 26:return e.finish(23);case 27:return e.finish(18);case 28:case"end":return e.stop()}}),e,null,[[2,14,18,28],[19,,23,27]])})))()}}}(e,y,(function(){return i()&&l()}),u,h);v.on("last-message-id.new",(function(e){return e})),v.on("message.new",(function(e){return p.emit("message.new",e)})),v.run().catch((function(e){return h("got error when sync",e)}));var b=function(e,t,r,n,o){var i=g(),a=function(r){var n=M("api/v2/sdk/sync_event").param("start_event_id",r).build();return e().get(n).then((function(e){var r=e.body.events,n=r.map((function(e){return e.id})).sort((function(e,t){return e-t})).pop(),o=r.filter((function(e){return"delivered"===e.action_topic})).map((function(e){return e.payload.data})),i=r.filter((function(e){return"read"===e.action_topic})).map((function(e){return e.payload.data})),s=r.filter((function(e){return"delete_message"===e.action_topic})).map((function(e){return e.payload.data})),a=r.filter((function(e){return"clear_room"===e.action_topic})).map((function(e){return e.payload.data}));return Promise.resolve({lastId:n,messageDelivered:o,messageRead:i,messageDeleted:s,roomCleared:a,interval:t()})})).catch(ge)};function u(){return c.apply(this,arguments)}function c(){return(c=de()(d.a.mark((function o(){var i,s,u;return d.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:i=0,s=100,u=function(){return null!=e()&&r()};case 3:if(!((i+=s)>=t()&&u())){o.next=9;break}return i=0,o.next=9,a(n());case 9:return o.next=11,pe()(ve(s));case 11:o.next=3;break;case 13:case"end":return o.stop()}}),o)})))).apply(this,arguments)}return{get synchronize(){return a},get on(){return i.on},get off(){return i.off},run:function(){return s()(d.a.mark((function e(){var t,r,s,a,c,l,f;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=!1,r=!1,e.prev=2,a=me(u());case 4:return e.next=6,a.next();case 6:if(!(t=!(c=e.sent).done)){e.next=12;break}l=c.value;try{(f=l.lastId)>n()&&(i.emit("last-event-id.new",f),l.messageDelivered.forEach((function(e){return i.emit("message.delivered",e)})),l.messageDeleted.forEach((function(e){return i.emit("message.deleted",e)})),l.messageRead.forEach((function(e){return i.emit("message.read",e)})),l.roomCleared.forEach((function(e){return i.emit("room.cleared",e)})))}catch(e){o("error when sync event",e.message)}case 9:t=!1,e.next=4;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(2),r=!0,s=e.t0;case 18:if(e.prev=18,e.prev=19,!t||null==a.return){e.next=23;break}return e.next=23,a.return();case 23:if(e.prev=23,!r){e.next=26;break}throw s;case 26:return e.finish(23);case 27:return e.finish(18);case 28:case"end":return e.stop()}}),e,null,[[2,14,18,28],[19,,23,27]])})))()}}}(e,y,(function(){return i()&&f()}),(function(){return m}),h);return b.on("last-event-id.new",(function(e){m=e})),b.on("message.read",(function(e){p.emit("message.read",e)})),b.on("message.delivered",(function(e){return p.emit("message.delivered",e)})),b.on("message.deleted",(function(e){return p.emit("message.deleted",e)})),b.on("room.cleared",(function(e){return p.emit("room.cleared",e)})),b.run().catch((function(e){return h("got error when sync event",e)})),{get on(){return p.on},get off(){return p.off},synchronize:function(){v.synchronize()},synchronizeEvent:function(){b.synchronize()}}}var _e=r(122),we={MESSAGE_BEFORE_SENT:"message::before-sent",MESSAGE_BEFORE_RECEIVED:"message::before-received"};var ke,Se=function(){return l()((function e(t){var r=t.httpAdapter,n=t.refreshToken,o=t.expiredAt,i=t.userId,s=t.onTokenRefreshed,a=t.getAuthenticationStatus;u()(this,e),p()(this,"_isExpiredTokenEnabled",!1),p()(this,"_refreshToken",null),p()(this,"_expiredAt",null),p()(this,"_http",void 0),p()(this,"_onTokenRefreshed",void 0),p()(this,"_timerId",void 0),p()(this,"_getAuthenticationStatus",void 0),this._http=r,this._refreshToken=n,this._userId=i,this._onTokenRefreshed=s,this._getAuthenticationStatus=a,null!=this._refreshToken&&""===this._refreshToken&&(this._refreshToken=null),null!=o&&""!==o&&(this._expiredAt=new Date(o)),this._isExpiredTokenEnabled=null!=this._refreshToken&&null!=this._expiredAt,this._checkToken()}),[{key:"_checkToken",value:(r=s()(d.a.mark((function e(){var t,r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=5e3,0!=this._getAuthenticationStatus()&&null!=this._refreshToken){e.next=3;break}return e.abrupt("return");case 3:if(null==this._expiredAt||!this._isExpiredTokenEnabled){e.next=9;break}if(r=Date.now(),!(Math.floor((this._expiredAt-r)/1e3)<t/1e3)){e.next=9;break}return e.next=9,this.refreshAuthToken();case 9:return e.next=11,se(t);case 11:this._checkToken();case 12:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"refreshAuthToken",value:(t=s()(d.a.mark((function e(){var t=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._http.post("api/v2/sdk/refresh_user_token",{user_id:this._userId,refresh_token:this._refreshToken}).then((function(e){var r,n=e.body.results,o=n.token;return t._refreshToken=n.refresh_token,t._http.setToken(n.token),null!=n.token_expires_at&&(t._expiredAt=new Date(n.token_expires_at)),null===(r=t._onTokenRefreshed)||void 0===r||r.call(t,o,t._refreshToken,t._expiredAt),n})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"logout",value:(e=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._http.post("api/v2/sdk/logout",{user_id:this._userId,token:this._http.token}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t,r}();function xe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ee(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(r),!0).forEach((function(t){p()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Te(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Ae(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ae(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw i}}}}function Ae(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Ie=Object.freeze({disabled:"UpdateCommentStatusMode.disabled",throttled:"UpdateCommentStatusMode.throttled",enabled:"UpdateCommentStatusMode.enabled"}),Ce=function(){function e(){var t,r,n=this;u()(this,e),p()(this,"_readComment",(function(e,t){return n._updateStatus(e,t)})),p()(this,"_readCommentT",this._throttle((function(e,t){n._updateStatus(e,t)}),(function(){return n._throttleDelay}))),p()(this,"_deliverComment",(function(e,t){return n._updateStatus(e,void 0,t)})),p()(this,"_deliverCommentT",this._throttle((function(e,t){n._updateStatus(e,void 0,t)}),(function(){return n._throttleDelay}))),this.events=g(),this.rooms=[],this.selected=null,this.room_name_id_map={},this.pendingCommentId=0,this.uploadedFiles=[],this.chatmateStatus=null,this.version="WEB_".concat(_e.version),this.userData={},this.AppId=null,this.baseURL="https://api.qiscus.com",this.mqttURL="wss://realtime-jogja.qiscus.com:1886/mqtt",this.brokerLbUrl="https://realtime-lb.qiscus.com",this.syncOnConnect=1e4,this.enableEventReport=!1,this.enableRealtime=!0,this.enableRealtimeCheck=!0,this.enableSync=!0,this.enableSyncEvent=!1,this.HTTPAdapter=null,this.expiredTokenAdapter=null,this.realtimeAdapter=null,this.customEventAdapter=null,this.isInit=!1,this.isSynced=!1,this.syncInterval=5e3,this.sync="socket",this.enableLb=!0,this.httpsync=null,this.eventsync=null,this.extras=null,this.last_received_comment_id=0,this.googleMapKey="",this.options={avatar:!0},this.isConfigLoaded=!1,this.updateCommentStatusMode=e.UpdateCommentStatusMode.enabled,this.updateCommentStatusThrottleDelay=300,this.UI={},this.mode="widget",this.avatar=!0,this.plugins=[],this.isLogin=!1,this.isLoading=!1,this.isInit=!1,this.emoji=!1,this.isTypingStatus="",this.customTemplate=!1,this.templateFunction=null,this.debugMode=!1,this.debugMQTTMode=!1,this._customHeader={},this._forceEnableSync=!0,this.lastReceiveMessages=[],this._hookAdapter=(t={},r=function(e){return Array.isArray(t[e])||(t[e]=[]),t[e]},{trigger:function(e,t){return r(e).reduce((function(e,t){return Promise.resolve(e).then(t)}),Promise.resolve(t))},intercept:function(e,t){r(e).push(t);var n=r(e).length;return function(){return r(e).splice(n,1)}}}),this._uploadURL=null,this._autoRefreshToken=!1}return l()(e,[{key:"uploadURL",get:function(){return this._uploadURL||"".concat(this.baseURL,"/api/v2/sdk/upload")},set:function(e){this._uploadURL=e}},{key:"init",value:(E=s()(d.a.mark((function e(t){var r,n,o,i,a,u,c=this;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.AppId){e.next=2;break}throw new Error("Please provide valid AppId");case 2:if(this.AppId=t.AppId,n=null!=t.baseURL&&this.baseURL!==t.baseURL,o=null!=t.mqttURL&&this.mqttURL!==t.mqttURL,i=null!=t.brokerLbURL&&this.brokerLbUrl!==t.brokerLbURL,!n&&!o||i?null!=t.enableRealtimeLB&&(this.enableLb=t.enableRealtimeLB):(this.logger("force disable load balancing for realtime server, because `baseURL` or `mqttURL` get changed but did not provide `brokerLbURL`"),this.enableLb=!1),null!=t.updateCommentStatusMode&&(this.updateCommentStatusMode=t.updateCommentStatusMode),null!=t.updateCommentStatusThrottleDelay&&(this.updateCommentStatusThrottleDelay=t.updateCommentStatusThrottleDelay),t.baseURL&&(this.baseURL=t.baseURL),t.mqttURL&&(this.mqttURL=t.brokerUrl||t.mqttURL),t.mqttURL&&(this.brokerUrl=t.brokerUrl||t.mqttURL),t.brokerLbURL&&(this.brokerLbUrl=t.brokerLbURL),t.uploadURL&&(this.uploadURL=t.uploadURL),t.sync&&(this.sync=t.sync),t.mode&&(this.mode=t.mode),t.syncInterval&&(this.syncInterval=t.syncInterval||5e3),t.googleMapKey&&(this.googleMapKey=t.googleMapKey),t.allowedFileTypes&&(this.allowedFileTypes=t.allowedFileTypes),t.options&&(this.options=Object.assign({},this.options,t.options)),t.customTemplate&&(this.customTemplate=t.customTemplate),t.templateFunction&&(this.templateFunction=t.templateFunction),null!=t.syncInterval&&(this.syncInterval=t.syncInterval),this.HTTPAdapter=new C({baseURL:this.baseURL,AppId:this.AppId,userId:this.user_id,version:this.version,getCustomHeader:function(){return c._customHeader}}),a=function(e,t,r){if(""===t&&null!=e){if("string"!=typeof e)return e;if(e.length>0)return e}if(null!=t){if(t.length>0)return t;if("string"!=typeof t)return t}return r},u=function(e){return e.includes("wss://")?e:"wss://".concat(e,":1886/mqtt")},this.withConfig=null===(r=t.withConfig)||void 0===r||r,!0!==this.withConfig){e.next=32;break}return e.next=30,this.HTTPAdapter.get_request("api/v2/sdk/config").then((function(e){return 200==e.status?c.isConfigLoaded=!0:c.isConfigLoaded=!1,e.body.results})).then((function(e){var r=c.baseURL,n=c.brokerLbUrl,o=c.mqttURL,i=c.enableRealtime,s=c.enableRealtimeCheck,l=c.syncInterval,f=c.syncOnConnect,p=c.enableEventReport;c.baseURL=a(t.baseURL,e.base_url,r),c.brokerLbUrl=a(t.brokerLbURL,e.broker_lb_url,n),c.mqttURL=u(a(t.mqttURL,e.broker_url,o)),c.enableRealtime=a(t.enableRealtime,e.enable_realtime,i),c.syncInterval=a(t.syncInterval,e.sync_interval,l),c.syncOnConnect=a(t.syncOnConnect,e.sync_on_connect,f),c.enableRealtimeCheck=a(null,e.enable_realtime_check,s),c.enableEventReport=a(null,e.enable_event_report,p),c.extras=a(null,e.extras,{}),c.enableSync=a(null,e.enable_sync,c.enableSync),c.enableSyncEvent=a(null,e.enable_sync_event,c.enableSyncEvent),c._autoRefreshToken=a(null,e.auto_refresh_token,!1)})).catch((function(e){c.logger("got error when trying to get app config",e),c.isConfigLoaded=!0}));case 30:e.next=33;break;case 32:this.isConfigLoaded=!0;case 33:this._getMqttClientId=function(){return"".concat(c.AppId,"_").concat(c.user_id,"_").concat(Date.now())},this.realtimeAdapter=new ce(this.mqttURL,this,this.isLogin,{brokerLbUrl:this.brokerLbUrl,enableLb:this.enableLb,shouldConnect:this.enableRealtime,getClientId:this._getMqttClientId}),this.realtimeAdapter.on("connected",(function(){!c.isLogin&&c.realtimeAdapter.connected||(c.last_received_comment_id=c.userData.last_comment_id,c.updateLastReceivedComment(c.last_received_comment_id))})),this.realtimeAdapter.on("close",(function(){})),this.realtimeAdapter.on("reconnect",(function(){var e,t;null===(e=(t=c.options).onReconnectCallback)||void 0===e||e.call(t)})),this.realtimeAdapter.on("message-delivered",(function(e){var t=e.commentId,r=e.commentUniqueId,n=e.userId;return c._setDelivered(t,r,n)})),this.realtimeAdapter.on("message-read",(function(e){var t=e.commentId,r=e.commentUniqueId,n=e.userId;return c._setRead(t,r,n)})),this.realtimeAdapter.on("new-message",function(){var e=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,t);case 2:t=e.sent,c.events.emit("newmessages",[t]);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this.realtimeAdapter.on("presence",(function(e){return c.events.emit("presence",e)})),this.realtimeAdapter.on("comment-deleted",(function(e){return c.events.emit("comment-deleted",e)})),this.realtimeAdapter.on("room-cleared",(function(e){return c.events.emit("room-cleared",e)})),this.realtimeAdapter.on("typing",(function(e){return c.events.emit("typing",{message:e.message,username:e.userId,room_id:e.roomId})})),this.realtimeAdapter.on("message:updated",(function(e){null!=c.options.messageUpdatedCallback&&c.options.messageUpdatedCallback(e)})),this.realtimeAdapter.on("room-typing",(function(e){c.events.emit("typing",{message:e.text,username:e.sender_name,email:e.sender_id,room_id:e.room_id}),null!=c.options.onRoomTypingCallback&&(c.events.emit("room-typing",e),c.options.onRoomTypingCallback(e))})),this.syncAdapter=be((function(){return c.HTTPAdapter}),{getToken:function(){return c.userData.token},syncInterval:function(){return c.syncInterval},getShouldSync:function(){return c._forceEnableSync&&c.isLogin&&!c.realtimeAdapter.connected},syncOnConnect:function(){return c.syncOnConnect},lastCommentId:function(){return c.last_received_comment_id},statusLogin:function(){return c.isLogin},enableSync:function(){return c.enableSync},enableSyncEvent:function(){return c.enableSyncEvent}}),this.syncAdapter.on("message.new",function(){var e=s()(d.a.mark((function e(t){var r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,t);case 2:t=e.sent,null!=c.selected?-1===c.selected.comments.findIndex((function(e){return e.id===t.id||e.unique_id===t.unique_temp_id}))&&((r=new A(t)).room_id===c.selected.id&&(c.selected.comments.push(r),c.sortComments()),c.events.emit("newmessages",[t])):c.events.emit("newmessages",[t]);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),this.syncAdapter.on("message.delivered",(function(e){c._setDelivered(e.comment_id,e.comment_unique_id,e.email)})),this.syncAdapter.on("message.read",(function(e){c._setRead(e.comment_id,e.comment_unique_id,e.email)})),this.syncAdapter.on("message.deleted",(function(e){e.deleted_messages.forEach((function(e){c.events.emit("comment-deleted",{roomId:e.room_id,commentUniqueIds:e.message_unique_ids,isForEveryone:!0,isHard:!0})}))})),this.syncAdapter.on("room.cleared",(function(e){e.deleted_rooms.forEach((function(e){c.events.emit("room-cleared",e)}))})),this.customEventAdapter=le(this.realtimeAdapter,this.user_id),this.setEventListeners();case 55:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_setRead",value:function(e,t,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===e||r.unique_id===t}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach((function(e){e.id<=o.id&&e.markAsRead(i)})),o.isRead&&this.events.emit("comment-read",{comment:o,userId:r})}}}},{key:"_setDelivered",value:function(e,t,r){if(null!=this.selected){var n=this.selected,o=n.comments.find((function(r){return r.id===e||r.unique_id===t}));if(null!=o&&"read"!==o.status){var i={participants:n.participants,actor:r,comment_id:e,activeActorId:this.user_id};n.comments.forEach((function(e){e.id<=o.id&&e.markAsDelivered(i)})),o.isDelivered&&this.events.emit("comment-delivered",{comment:o,userId:r})}}}},{key:"setEventListeners",value:function(){var e=this,t=this;this.authAdapter=new P(t.HTTPAdapter),null!=this.userData.email&&(this.authAdapter.userId=this.userData.email),t.events.on("start-init",(function(){t.HTTPAdapter=new C({baseURL:t.baseURL,AppId:t.AppId,userId:t.user_id,version:t.version,getCustomHeader:function(){return e._customHeader}}),t.HTTPAdapter.setToken(t.userData.token)})),t.events.on("room-changed",(function(r){e.logging("room changed",r),t.options.roomChangedCallback&&t.options.roomChangedCallback(r)})),t.events.on("file-uploaded",(function(e){t.options.fileUploadedCallback&&t.options.fileUploadedCallback(e)})),t.events.on("profile-updated",(function(e){t.username=e.name,t.avatar_url=e.avatar_url,t.options.updateProfileCallback&&t.options.updateProfileCallback(e)})),t.events.on("newmessages",(function(r){e.logging("newmessages",r),e.lastReceiveMessages.length>0&&e.lastReceiveMessages[0].unique_temp_id===r[0].unique_temp_id?e.logging("lastReceiveMessages double",r):(e.lastReceiveMessages=r,t._callNewMessagesCallback(r),r.forEach((function(r){t.receiveComment(r.room_id,r.id);var n=!!t.selected&&r.room_id===t.selected.id,o=r.id<=t.last_received_comment_id;if(n){var i=t.selected,s=t.selected.comments[t.selected.comments.length-1];s.isPending||o||t.user_id===r.email||t.readComment(r.room_id,r.id);var a=s.id,u=t.selected.comments.find((function(e){return e.id===s.comment_before_id}));s.isPending||u||(e.logging("comment before id not found! ",r.comment_before_id),t.synchronize(a));var c=new A(r);i.receiveComment(c),i.last_comment_id=c.id,i.last_comment_message=c.message}t.updateLastReceivedComment(r.id),e.sortComments()})))})),this.events.on("login-success",(function(t){e.isLogin=!0,e.userData=t.user,e.last_received_comment_id=e.userData.last_comment_id,e.realtimeAdapter.connected||e.updateLastReceivedComment(e.last_received_comment_id),e.HTTPAdapter=new C({baseURL:e.baseURL,AppId:e.AppId,userId:e.user_id,version:e.version,getCustomHeader:function(){return e._customHeader}}),e.HTTPAdapter.setToken(e.userData.token);var r=t.user;e.expiredTokenAdapter=new Se({httpAdapter:e.HTTPAdapter,refreshToken:r.refresh_token,expiredAt:r.token_expires_at,userId:e.user_id,onTokenRefreshed:function(t,r,n){e.userData.token=t,e.userData.refresh_token=r,e.userData.token_expires_at=null==n?void 0:n.toJSON(),e.events.emit("token-refreshed",{token:t,refreshToken:r,expiredAt:n})},getAuthenticationStatus:function(){return null!=e.user_id&&e.isLogin}}),e.userAdapter=new D(e.HTTPAdapter),e.roomAdapter=new j(e.HTTPAdapter),e.realtimeAdapter.subscribeUserChannel(),null!=e.presensePublisherId&&-1!==e.presensePublisherId&&clearInterval(e.presensePublisherId),e.presensePublisherId=setInterval((function(){e.realtimeAdapter.publishPresence(e.user_id,!0)}),3500),e.options.loginSuccessCallback&&e.options.loginSuccessCallback(t),e.authAdapter.userId=e.userData.email,e.authAdapter.refreshToken=e.userData.refresh_token,e.authAdapter.autoRefreshToken=e._autoRefreshToken})),t.events.on("login-error",(function(e){t.options.loginErrorCallback&&t.options.loginErrorCallback(e)})),t.events.on("token-refreshed",(function(t){var r,n;null===(r=(n=e.options).authTokenRefreshedCallback)||void 0===r||r.call(n,t)})),t.events.on("room-cleared",(function(e){if(t.selected){var r=t.selected;t.selected.unique_id===e.unique_id&&(t.selected=null,t.selected=r)}t.options.roomClearedCallback&&t.options.roomClearedCallback(e)})),t.events.on("comment-deleted",(function(e){var r=e.roomId,n=e.commentUniqueIds,o=(e.isForEveryone,e.isHard);t.selected&&t.selected.id==r&&n.map((function(e){var r=t.selected.comments.findIndex((function(t){return t.unique_id===e}));r>-1&&(o?t.selected.comments.splice(r,1):t.selected.comments[r].message="this message has been deleted")})),t.options.commentDeletedCallback&&t.options.commentDeletedCallback(e)})),t.events.on("comment-delivered",(function(e){return t.logging("comment-delivered",e),!!e&&(t.options.commentDeliveredCallback?t.options.commentDeliveredCallback(e):void 0)})),t.events.on("chat-room-created",(function(e){t.isLoading=!1,t.options.chatRoomCreatedCallback&&t.options.chatRoomCreatedCallback(e)})),t.events.on("group-room-created",(function(e){t.isLoading=!1,t.options.groupRoomCreatedCallback&&t.options.groupRoomCreatedCallback(e)})),t.events.on("header-clicked",(function(e){t.options.headerClickedCallback&&t.options.headerClickedCallback(e)})),t.events.on("comment-read",(function(e){t.logging("comment-read",e),t.options.commentReadCallback&&t.options.commentReadCallback(e)})),t.events.on("presence",(function(r){var n=r.message,o=r.userId,i=n.split(":");e.chatmateStatus!==i[0]&&(e.chatmateStatus=1===i[0]?"Online":"Last seen ".concat(S()(Number(i[1].substring(0,13))))),t.options.presenceCallback&&t.options.presenceCallback(n,o)})),t.events.on("typing",(function(e){t.options.typingCallback&&t.options.typingCallback(e)})),t.events.on("message-info",(function(e){t.options.messageInfoCallback&&t.options.messageInfoCallback(e)})),t.events.on("participants-added",(function(t){var r;null!=t&&null!=e.selected&&(r=e.selected.participants).push.apply(r,o()(t))})),t.events.on("participants-removed",(function(t){if(null!=t&&null!=e.selected){var r=e.selected.participants.filter((function(e){return t.indexOf(e.email)<=-1}));e.selected.participants=r}})),t.events.on("block-user",(function(e){t.options.blockUserCallback&&t.options.blockUserCallback(e)})),t.events.on("unblock-user",(function(e){t.options.unblockUserCallback&&t.options.unblockUserCallback(e)}))}},{key:"onReconnectMqtt",value:function(){this.options.onReconnectCallback&&this.options.onReconnectedCallback(),this.selected&&this.loadComments(this.selected.id)}},{key:"_callNewMessagesCallback",value:function(e){this.options.newMessagesCallback&&this.options.newMessagesCallback(e)}},{key:"updateLastReceivedComment",value:function(e){this.last_received_comment_id<e&&(this.last_received_comment_id=e)}},{key:"setUser",value:function(e,t,r,n,o){var i=this,s=this;s.user_id=e,s.key=t,s.username=r,s.avatar_url=n;var a={email:this.user_id,password:this.key,username:this.username,extras:o?JSON.stringify(o):null};return this.avatar_url&&(a.avatar_url=this.avatar_url),new Promise((function(e,t){var r=setInterval((function(){if(i.isConfigLoaded)return clearInterval(r),i.logger("Config Success!"),s.events.emit("start-init"),s.authAdapter.loginOrRegister(a).then((function(t){s.isInit=!0,s.refresh_token=t.user.refresh_token,s.events.emit("login-success",t),i.realtimeAdapter.connect(),e(t)}),(function(e){s.events.emit("login-error",e),t(e)}));i.debugMode&&i.logger("Waiting for init config...")}),300)}))}},{key:"setUserWithIdentityToken",value:function(e){var t=this;if(!e||!("user"in e))return this.events.emit("login-error",e);this.email=e.user.email,this.user_id=e.user.email,this.key=e.identity_token,this.username=e.user.username,this.avatar_url=e.user.avatar_url,this.isInit=!0;var r=setInterval((function(){t.isConfigLoaded?(clearInterval(r),t.logger("Config Success!"),t.events.emit("login-success",e)):t.debugMode&&t.logger("Waiting for init config...")}),300)}},{key:"refreshAuthToken",value:function(){return this.expiredTokenAdapter.refreshAuthToken()}},{key:"publishOnlinePresence",value:function(e){var t=this;!0===e?ke=setInterval((function(){t.realtimeAdapter.publishPresence(t.user_id,!0)}),3500):(clearInterval(this.presensePublisherId),clearInterval(ke),setTimeout((function(){t.realtimeAdapter.publishPresence(t.user_id,!1)}),3500))}},{key:"subscribeUserPresence",value:function(e){this.realtimeAdapter.subscribeUserPresence(e)}},{key:"unsubscribeUserPresence",value:function(e){this.realtimeAdapter.unsubscribeUserPresence(e)}},{key:"logout",value:(x=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.expiredTokenAdapter.logout();case 2:clearInterval(this.presensePublisherId),this.publishOnlinePresence(!1),this.selected=null,this.isInit=!1,this.isLogin=!1,this.realtimeAdapter.disconnect(),this.userData={};case 9:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"synchronize",get:function(){return this.syncAdapter.synchronize}},{key:"synchronizeEvent",get:function(){return this.syncAdapter.synchronizeEvent}},{key:"disconnect",value:function(){this.logout()}},{key:"setActiveRoom",value:function(e){var t=this;if(this.selected&&(this.realtimeAdapter.unsubscribeTyping(),"single"===this.selected.room_type)){var r=this.selected.participants.filter((function(e){return e.email!==t.user_id}));r.length>0&&this.realtimeAdapter.unsubscribeRoomPresence(r[0].email)}null==e.participants&&(e.participants=[]);var n=e.participants.find((function(e){return e.email!==t.user_id}));this.chatmateStatus=null,this.isTypingStatus=null,this.selected=e;var o=setInterval((function(){t.debugMode&&t.logger("Trying Initial Subscribe"),null!=t.realtimeAdapter?(t.debugMode&&t.logger("MQTT Connected"),clearInterval(o),"single"===e.room_type&&null!=n&&t.realtimeAdapter.subscribeRoomPresence(n.email),null==t.selected||t.selected.isChannel||(t.realtimeAdapter.subscribeTyping(e.id),t.events.emit("room-changed",t.selected)),t.debugMode&&null==t.realtimeAdapter&&t.logger("Retry")):t.debugMode&&t.logger("MQTT Not Connected, yet")}),3e3)}},{key:"chatTarget",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.userData.length)return!1;var n=r?r.message:null,o=r.distinctId;return this.isLoading=!0,this.isTypingStatus="",this.roomAdapter.getOrCreateRoom(e,r,o).then(function(){var e=s()(d.a.mark((function e(r){var o,i,a,u;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=new I(r),t.updateLastReceivedComment(o.last_comment_id),t.isLoading=!1,i=function(){var e=s()(d.a.mark((function e(r){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=6,Promise.all(o.comments.map((function(e){return i(e)})));case 6:if(o.comments=e.sent,t.setActiveRoom(o),(a=o.comments[o.comments.length-1])&&t.readComment(o.id,a.id),t.events.emit("chat-room-created",{room:o}),n){e.next=13;break}return e.abrupt("return",o);case 13:return u=o.id,e.abrupt("return",t.sendComment(u,n).then((function(){return Promise.resolve(o)})).catch((function(e){console.error("Error when submit comment",e)})));case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return console.error("Error when creating room",e),t.isLoading=!1,Promise.reject(e)}))}},{key:"chatGroup",value:function(e){if(this.isInit)return this.getRoomById(e).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getRoomById",value:function(e){var t=this;if(this.isInit){var r=this;return r.isLoading=!0,r.isTypingStatus="",r.roomAdapter.getRoomById(e).then(function(){var e=s()(d.a.mark((function e(n){var o,i,s,a,u,c,l,f;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=n.results.room,i=[],s=Te(n.results.comments.reverse()),e.prev=3,s.s();case 5:if((a=s.n()).done){e.next=13;break}return u=a.value,e.next=9,t._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,u);case 9:c=e.sent,i.push(c);case 11:e.next=5;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),s.e(e.t0);case 18:return e.prev=18,s.f(),e.finish(18);case 21:return l=new I(Ee(Ee({},o),{},{comments:i,name:o.room_name})),r.updateLastReceivedComment(l.last_comment_id),r.setActiveRoom(l),r.isLoading=!1,(f=l.comments[l.comments.length-1])&&r.readComment(l.id,f.id),l.isChannel&&t.realtimeAdapter.subscribeChannel(t.AppId,l.unique_id),e.abrupt("return",l);case 29:case"end":return e.stop()}}),e,null,[[3,15,18,21]])})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return console.error("Error getting room by id",e),Promise.reject(e)}))}}},{key:"getOrCreateRoomByUniqueId",value:function(e,t,r){var n=this,o=this;return o.isLoading=!0,o.isTypingStatus="",o.roomAdapter.getOrCreateRoomByUniqueId(e,t,r).then(function(){var e=s()(d.a.mark((function e(t){var r,i,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new I(t),o.updateLastReceivedComment(r.last_comment_id),i=function(){var e=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=5,Promise.all(r.comments.map((function(e){return i(e)})));case 5:return r.comments=e.sent,o.setActiveRoom(r),o.isLoading=!1,(a=r.comments[r.comments.length-1])&&o.readComment(r.id,a.id),n.realtimeAdapter.subscribeChannel(n.AppId,r.unique_id),e.abrupt("return",Promise.resolve(r));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return Promise.reject(e)}))}},{key:"getOrCreateRoomByChannel",value:function(e,t,r){return this.getOrCreateRoomByUniqueId(e,t,r)}},{key:"sortComments",value:function(){this.selected&&this.selected.comments.sort((function(e,t){return e.unix_timestamp-t.unix_timestamp}))}},{key:"loadRoomList",value:(k=s()(d.a.mark((function e(){var t,r,n=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},e.next=3,this.userAdapter.loadRoomList(t);case 3:return r=e.sent,e.abrupt("return",r.map((function(e){return e.last_comment_id=e.last_comment.id,e.last_comment_message=e.last_comment.message,e.last_comment_message_created_at=e.last_comment.timestamp,e.room_type=e.chat_type,e.comments=[],new I(e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"loadComments",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.userAdapter.loadComments(e,r).then(function(){var e=s()(d.a.mark((function e(r){var n,o,i,s;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],o=Te(r),e.prev=2,o.s();case 4:if((i=o.n()).done){e.next=13;break}return s=i.value,e.t0=n,e.next=9,t._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,s);case 9:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 11:e.next=4;break;case 13:e.next=18;break;case 15:e.prev=15,e.t2=e.catch(2),o.e(e.t2);case 18:return e.prev=18,o.f(),e.finish(18);case 21:return null!=t.selected&&(t.selected.receiveComments(n.reverse()),t.sortComments()),e.abrupt("return",n);case 23:case"end":return e.stop()}}),e,null,[[2,15,18,21]])})));return function(t){return e.apply(this,arguments)}}())}},{key:"loadMore",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=this.selected)return t.last_comment_id=e,t.after=!1,this.loadComments(this.selected.id,t)}},{key:"registerDeviceToken",value:(_=s()(d.a.mark((function e(t){var r,n,o=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],e.next=3,this.HTTPAdapter.post("api/v2/sdk/set_user_device_token",{device_token:t,device_platform:"rn",is_development:r});case 3:return n=e.sent,e.abrupt("return",n.body.results);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"removeDeviceToken",value:(v=s()(d.a.mark((function e(t){var r,n,o=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],e.next=3,this.HTTPAdapter.post("api/v2/sdk/remove_user_device_token",{device_token:t,device_platform:"rn",is_development:r});case 3:return n=e.sent,e.abrupt("return",n.body.results);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"searchMessages",value:(m=s()(d.a.mark((function e(){var t,r,n=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},console.warn("Deprecated: search message will be removed on next release"),e.next=4,this.userAdapter.searchMessages(t);case 4:return r=e.sent,e.abrupt("return",r.map((function(e){return new A(e)})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"updateProfile",value:function(e){var t=this;return this.userAdapter.updateProfile(e).then((function(r){return t.events.emit("profile-updated",e),t.userData=r,Promise.resolve(r)}),(function(e){return t.logger(e)}))}},{key:"getNonce",value:function(){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/nonce")).send().set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(e){return Promise.resolve(e.body.results)}),(function(e){return Promise.reject(e)}))}},{key:"verifyIdentityToken",value:function(e){return y.a.post("".concat(this.baseURL,"/api/v2/sdk/auth/verify_identity_token")).send({identity_token:e}).set("qiscus_sdk_app_id","".concat(this.AppId)).set("qiscus_sdk_version","".concat(this.version)).then((function(e){return Promise.resolve(e.body.results)}),(function(e){return Promise.reject(e)}))}},{key:"sendComment",value:(h=s()(d.a.mark((function e(t,r,n){var o,i,a,u,c,l,f,p,h,m,y=this,g=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=g.length>3&&void 0!==g[3]?g[3]:"text",i=g.length>4?g[4]:void 0,a=g.length>5?g[5]:void 0,(u=this).options.prePostCommentCallback&&u.options.prePostCommentCallback(r),u.options.commentFormaterCallback&&(r=u.options.commentFormaterCallback(r)),u.pendingCommentId--,c={message:r,username_as:this.username,username_real:this.user_id,user_avatar_url:this.userData.avatar_url,user_extras:this.userData.user_extras,id:Math.round(1e6*Date.now()+Date.now()),type:o||"text",timestamp:w()(new Date),unique_id:n?String(n):null,payload:ie((function(){return JSON.parse(i)}),i,(function(e){return y.logger("Error when parsing payload",e.message)}))},l=u.prepareCommentToBeSubmitted(c),"reply"===o&&(f=JSON.parse(i),p=u.selected.comments.find((function(e){return e.id===f.replied_comment_id})),f.replied_comment_message="reply"===p.type?p.payload.text:p.message,f.replied_comment_sender_username=p.username_as,l.payload=f),h=a||u.extras,e.next=13,this._hookAdapter.trigger(we.MESSAGE_BEFORE_SENT,Ee(Ee({},l),{},{extras:h}));case 13:return m=e.sent,m=u.prepareCommentToBeSubmitted(m),u.selected&&u.selected.comments.push(m),e.abrupt("return",this.userAdapter.postComment(""+t,m.message,m.unique_id,m.type,m.payload,m.extras).then(function(){var e=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,y._hookAdapter.trigger(we.MESSAGE_BEFORE_RECEIVED,t);case 2:if(t=e.sent,Object.assign(m,t),u.selected){e.next=6;break}return e.abrupt("return",Promise.resolve(m));case 6:return m.markAsSent(),m.id=t.id,m.before_id=t.comment_before_id,m.unix_timestamp=t.unix_timestamp,u.sortComments(),e.abrupt("return",m);case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return m.markAsFailed(),Promise.reject(e)})));case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return h.apply(this,arguments)})},{key:"getUsers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/get_user_list").query({query:e,page:t,limit:r}).then((function(e){return Promise.resolve(e.body.results)}))}},{key:"getParticipants",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,page:t,limit:r}).then((function(e){return e.body.results}))}},{key:"getRoomParticipants",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return console.warn("`getRoomParticipants` are deprecated, use `getParticipants` instead."),this.HTTPAdapter.get_request("api/v2/sdk/room_participants").query({room_unique_id:e,offset:t}).then((function(e){return Promise.resolve(e.body.results)}))}},{key:"resendComment",value:function(e){if(null!=this.selected){var t=this,r=t.selected,n=r.comments.find((function(t){return t.id===e.id})),o=t.extras;return this.userAdapter.postComment(""+r.id,n.message,n.unique_id,e.type,e.payload,o).then((function(e){return n.markAsSent(),n.id=e.id,n.before_id=e.comment_before_id,new Promise((function(e,r){return e(t.selected)}))}),(function(e){return n.markAsFailed(),new Promise((function(t,r){return r(e)}))}))}}},{key:"prepareCommentToBeSubmitted",value:function(e){var t,r;return t=new A(e),r="bq"+Date.now(),e.unique_id&&(r=e.unique_id),t.attachUniqueId(r),t.markAsPending(),t.isDelivered=!1,t.isSent=!1,t.isRead=!1,t.unix_timestamp=Math.round((new Date).getTime()/1e3),t}},{key:"updateRoom",value:function(e){return this.roomAdapter.updateRoom(e)}},{key:"removeSelectedRoomParticipants",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id";if(b.a.not.array(e))return Promise.reject(new Error("`values` must have type of array"));var r=this.selected.participants;if(!r)return Promise.reject(new Error("Nothing selected room chat."));var n=r;return"id"===t&&(n=r.filter((function(t){return e.indexOf(t.id)<=-1}))),"email"===t&&(n=r.filter((function(t){return e.indexOf(t.email)<=-1}))),"username"===t&&(n=r.filter((function(t){return e.indexOf(t.username)<=-1}))),this.selected.participants=n,Promise.resolve(r)}},{key:"createGroupRoom",value:function(e,t,r){var n=this;if(!this.isLogin)throw new Error("Please initiate qiscus SDK first");return new T(this.roomAdapter).withName(e).withOptions(r).addParticipants(t).create().then((function(e){return n.events.emit("group-room-created",e),Promise.resolve(e)}))}},{key:"addParticipantsToGroup",value:function(e,t){var r=this;if(!Array.isArray(t))throw new Error("emails' must be type of Array");return r.roomAdapter.addParticipantsToGroup(e,t).then((function(e){return r.events.emit("participants-added",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"removeParticipantsFromGroup",value:function(e,t){var r=this;return b.a.not.array(t)?Promise.reject(new Error("`emails` must have type of array")):this.roomAdapter.removeParticipantsFromGroup(e,t).then((function(e){return r.events.emit("participants-removed",t),Promise.resolve(e)}))}},{key:"getBlockedUser",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=this;return r.userAdapter.getBlockedUser(e,t).then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"blockUser",value:function(e){var t=this;return t.userAdapter.blockUser(e).then((function(e){return t.events.emit("block-user",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"unblockUser",value:function(e){var t=this;return t.userAdapter.unblockUser(e).then((function(e){return t.events.emit("unblock-user",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getUserPresences",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(b.a.not.array(e))return Promise.reject(new Error("`email` must have type of array"));var t=this;return t.userAdapter.getUserPresences(e).then((function(e){return t.events.emit("user-status",e),Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"upload",value:function(e,t){var r=y.a.post(this.uploadURL);return(r=this.HTTPAdapter.setupHeaders(r)).attach("file",e).on("progress",(function(e){"upload"===e.direction&&t(null,e)})).then((function(e){var r=e.body.results.file.url;return t(null,null,e.body.results.file.url),Promise.resolve(r)})).catch((function(e){return t(e),Promise.reject(e)}))}},{key:"uploadFile",value:function(e,t){var r=this,n=new FormData;n.append("file",t);var o=new XMLHttpRequest;o.open("POST","".concat(r.baseURL,"/api/v2/sdk/upload"),!0),o.setRequestHeader("qiscus_sdk_app_id","".concat(r.AppId)),o.setRequestHeader("qiscus_sdk_user_id","".concat(r.user_id)),o.setRequestHeader("qiscus_sdk_token","".concat(r.userData.token)),o.onload=function(){if(200===o.status){var t=JSON.parse(o.response).results.file.url;return r.events.emit("fileupload",t),r.sendComment(e,"[file] ".concat(t," [/file]"))}return Promise.reject(o)},o.send(n)}},{key:"addUploadedFile",value:function(e,t){this.uploadedFiles.push(new Pe(e,t))}},{key:"removeUploadedFile",value:function(e,t){var r=this.uploadedFiles.findIndex((function(r){return r.name===e&&r.roomId===t}));this.uploadedFiles.splice(r,1)}},{key:"publishTyping",value:function(e){this.realtimeAdapter.publishTyping(e)}},{key:"getRoomsInfo",value:function(e){return this.userAdapter.getRoomsInfo(e)}},{key:"deleteComment",value:function(e,t,r,n){var o=this;if(!Array.isArray(t))throw new Error("unique ids' must be type of Array");return this.userAdapter.deleteComment(e,t,r,n).then((function(i){return o.events.emit("comment-deleted",{roomId:e,commentUniqueIds:t,isForEveryone:r,isHard:n}),Promise.resolve(i)}),(function(e){return Promise.reject(e)}))}},{key:"clearRoomsCache",value:function(){var e=this;if(this.selected){this.room_name_id_map=p()({},this.selected.name,this.selected.id);var t=this.rooms.length,r=this.rooms.findIndex((function(t){return t.id===e.selected.id}));r+1!==t&&this.rooms.splice(r+1,t-(r+1)),(r=this.rooms.findIndex((function(t){return t.id===e.selected.id})))>0&&this.rooms.length>1&&this.rooms.splice(1,this.rooms.length-1)}}},{key:"exitChatRoom",value:function(){var e=this;this.realtimeAdapter.unsubscribeTyping(),ie((function(){return e.selected.participants.filter((function(t){return t.email!==e.user_id})).map((function(e){return e.email}))}),null,this.noop,(function(t){return t.forEach((function(t){return e.realtimeAdapter.unsubscribeRoomPresence(t)}))})),this.selected=null}},{key:"clearRoomMessages",value:function(e){if(!Array.isArray(e))throw new Error("room_ids must be type of array");return this.userAdapter.clearRoomMessages(e)}},{key:"logging",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.debugMode&&console.log(e,t)}},{key:"getTotalUnreadCount",value:function(){return this.roomAdapter.getTotalUnreadCount().then((function(e){return Promise.resolve(e)}),(function(e){return Promise.reject(e)}))}},{key:"getRoomUnreadCount",value:function(){return this.roomAdapter.getRoomUnreadCount()}},{key:"publishEvent",value:function(){var e;(e=this.customEventAdapter).publishEvent.apply(e,arguments)}},{key:"subscribeEvent",value:function(){var e;(e=this.customEventAdapter).subscribeEvent.apply(e,arguments)}},{key:"unsubscribeEvent",value:function(){var e;(e=this.customEventAdapter).unsubscribeEvent.apply(e,arguments)}},{key:"setCustomHeader",value:function(e){if(b.a.not.json(e))throw new TypeError("`headers` must have type of object");this._customHeader=e}},{key:"getUserProfile",value:function(){return this.userAdapter.getProfile()}},{key:"Interceptor",get:function(){return we}},{key:"intercept",value:function(e,t){return this._hookAdapter.intercept(e,t)}},{key:"getThumbnailURL",value:function(e){return e.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(e,t,r){return e.replace(t,"/upload/w_320,h_320,c_limit/").replace(r,".png")}))}},{key:"getBlurryThumbnailURL",value:function(e){return e.replace(/^https?:\/\/\S+(\/upload\/)\S+(\.\w+)$/i,(function(e,t,r){return e.replace(t,"/upload/w_320,h_320,c_limit,e_blur:300/").replace(r,".png")}))}},{key:"logger",get:function(){return this.debugMode?console.log.bind(console,"Qiscus ->"):this.noop}},{key:"noop",value:function(){}},{key:"_throttleDelay",get:function(){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?0:this.updateCommentStatusThrottleDelay||300}},{key:"_updateStatusEnabled",get:function(){return this.updateCommentStatusMode!==e.UpdateCommentStatusMode.disabled}},{key:"_updateStatus",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null!=r,o=null!=t,i=(null!=this.selected&&this.selected.id,null!=this.selected&&this.selected.isChannel||!1),s=!this._updateStatusEnabled,a=o?"read":n?"receive":void 0,u=!(i||n&&s);if(this.debugMode&&(console.group("update-command-status"),console.log("run:",a,"on: roomId(".concat(e,") commentId(").concat(t||r,")")),console.log("is able to run command?",u),console.groupEnd()),!u)return!1;this.userAdapter.updateCommentStatus(e,t,r).catch((function(e){}))}},{key:"readComment",value:function(t,r){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?this._readComment(t,r):this._readCommentT(t,r)}},{key:"receiveComment",value:function(t,r){return this.updateCommentStatusMode===e.UpdateCommentStatusMode.enabled?this._deliverComment(t,r):this._deliverCommentT(t,r)}},{key:"_throttle",value:function(e,t){var r=!1;return function(){var n=t();r||(e.apply(void 0,arguments),r=!0,setTimeout((function(){return r=!1}),n))}}},{key:"searchMessage",value:(f=s()(d.a.mark((function e(){var t,r,n,o,i,s,a,u,c,l,f,p,h=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=h.length>0&&void 0!==h[0]?h[0]:{},r=t.query,n=t.roomIds,o=void 0===n?[]:n,i=t.userId,s=t.type,a=t.roomType,u=t.page,c=t.limit,l="api/v2/sdk/search",f=["group","single","channel"].some((function(e){return e===a})),null==a||f){e.next=5;break}return e.abrupt("return",Promise.reject("Invalid room type, valid room type are: `group`, `single`, and `channel`"));case 5:return p=function(e){return{type:null==e?void 0:"single"===e?"single":"group",isPublic:null==e?void 0:"channel"===e}}(a),e.abrupt("return",this.HTTPAdapter.post_json(l,{token:this.token,query:r,sender:i,type:s,room_ids:o.map((function(e){return String(e)})),room_type:p.type||void 0,is_public:p.isPublic||void 0,page:u,limit:c}).then((function(e){return e.body})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getFileList",value:(c=s()(d.a.mark((function e(){var t,r,n,o,i,s,a,u,c,l,f,p,h=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=h.length>0&&void 0!==h[0]?h[0]:{},r=t.roomIds,n=void 0===r?[]:r,o=t.fileType,i=t.page,s=t.limit,a=t.sender,u=t.userId,c=t.includeExtensions,l=t.excludeExtensions,f="api/v2/sdk/file_list",this.isLogin){e.next=4;break}return e.abrupt("return",Promise.reject("You need to login to use this method"));case 4:return void 0===a&&(a=this.user_id),void 0===u&&(a=u=this.user_id),p={room_ids:n.map((function(e){return String(e)})),file_type:o,page:i,limit:s,include_extensions:c,exclude_extensions:l},null!=a&&(p.sender=a),e.abrupt("return",this.HTTPAdapter.post_json(f,p).then((function(e){return e.body})));case 9:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"_generateUniqueId",value:function(){return"javascript-".concat(Date.now())}},{key:"generateMessage",value:function(e){var t=e.roomId,r=e.text,n=e.extras,o=Date.now();return new A({id:o,message:r,room_id:t,extras:n,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"text"})}},{key:"generateFileAttachmentMessage",value:function(e){var t=e.roomId,r=e.caption,n=e.url,o=e.text,i=void 0===o?"File attachment":o,s=e.extras,a=e.filename,u=e.size,c=Date.now();return new A({id:c,message:i,room_id:t,extras:s,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"file_attachment",payload:{url:n,file_name:a,size:u,caption:r}})}},{key:"generateCustomMessage",value:function(e){var t=e.roomId,r=e.text,n=e.type,o=e.payload,i=e.extras,s=Date.now();return new A({id:s,message:r,room_id:t,extras:i,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"custom",payload:{type:n,content:o}})}},{key:"generateReplyMessage",value:function(e){var t=e.roomId,r=e.text,n=e.repliedMessage,o=e.extras,i=Date.now();return new A({id:i,message:r,room_id:t,extras:o,timestamp:new Date,unique_id:this._generateUniqueId(),before_id:0,username:this.userData.username,email:this.userData.email,status:"pending",type:"reply",payload:{text:r,replied_comment_id:n.id,replied_comment_message:n.message,replied_comment_type:n.type,replied_comment_payload:n.payload,replied_comment_sender_username:n.username_as,replied_comment_sender_email:n.username_real}})}},{key:"updateMessage",value:(a=s()(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.userAdapter.updateMessage(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onMessageUpdated",value:function(e){var t=this;return this.realtimeAdapter.on("message:updated",e),function(){return t.realtimeAdapter.off("message:updated",e)}}},{key:"closeRealtimeConnection",value:(i=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.realtimeAdapter.closeConnection());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"openRealtimeConnection",value:(n=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.realtimeAdapter.openConnection());case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startSync",value:(r=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._forceEnableSync=!0;case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"stopSync",value:(t=s()(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._forceEnableSync=!1;case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]);var t,r,n,i,a,c,f,h,m,v,_,k,x,E}();p()(Ce,"UpdateCommentStatusMode",Ie),p()(Ce,"Interceptor",we);var Pe=l()((function e(t,r){u()(this,e),this.name=t,this.roomId=r,this.progress=0}));t.default=Ce}]).default}));
|
|
17
17
|
//# sourceMappingURL=qiscus-sdk-core.min.js.map
|