quickblox 2.22.0 → 2.23.0

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/quickblox.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).QB=e()}}(function(){return function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){return i(t[s][1][e]||e)},u,u.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}}()({1:[function(e,t,n){"use strict";function r(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var i=r({HTML:"text/html",isHTML:function(e){return e===i.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),o=r({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===o.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});n.assign=function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.find=function(e,t,n){if(void 0===n&&(n=Array.prototype),e&&"function"==typeof n.find)return n.find.call(e,t);for(var r=0;r<e.length;r++)if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];if(t.call(void 0,i,r,e))return i}},n.freeze=r,n.MIME_TYPE=i,n.NAMESPACE=o},{}],2:[function(e,t,n){var r=e("./conventions"),i=e("./dom"),o=e("./entities"),s=e("./sax"),a=i.DOMImplementation,c=r.NAMESPACE,l=s.ParseError,u=s.XMLReader;function d(e){return e.replace(/\r[\n\u0085]/g,"\n").replace(/[\r\u0085\u2028]/g,"\n")}function h(e){this.options=e||{locator:{}}}function p(){this.cdata=!1}function f(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function m(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function g(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function v(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}h.prototype.parseFromString=function(e,t){var n=this.options,r=new u,i=n.domBuilder||new p,s=n.errorHandler,a=n.locator,l=n.xmlns||{},h=/\/x?html?$/.test(t),f=h?o.HTML_ENTITIES:o.XML_ENTITIES;a&&i.setDocumentLocator(a),r.errorHandler=function(e,t,n){if(!e){if(t instanceof p)return t;e=t}var r={},i=e instanceof Function;function o(t){var o=e[t];!o&&i&&(o=2==e.length?function(n){e(t,n)}:e),r[t]=o&&function(e){o("[xmldom "+t+"]\t"+e+m(n))}||function(){}}return n=n||{},o("warning"),o("error"),o("fatalError"),r}(s,i,a),r.domBuilder=n.domBuilder||i,h&&(l[""]=c.HTML),l.xml=l.xml||c.XML;var g=n.normalizeLineEndings||d;return e&&"string"==typeof e?r.parse(g(e),l,f):r.errorHandler.error("invalid doc source"),i.doc},p.prototype={startDocument:function(){this.doc=(new a).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.doc,o=i.createElementNS(e,n||t),s=r.length;v(this,o),this.currentElement=o,this.locator&&f(this.locator,o);for(var a=0;a<s;a++){e=r.getURI(a);var c=r.getValue(a),l=(n=r.getQName(a),i.createAttributeNS(e,n));this.locator&&f(r.getLocator(a),l),l.value=l.nodeValue=c,o.setAttributeNode(l)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&f(this.locator,n),v(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=g.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&f(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=g.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&f(this.locator,r),v(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var i=r.createDocumentType(e,t,n);this.locator&&f(this.locator,i),v(this,i),this.doc.doctype=i}},warning:function(e){console.warn("[xmldom warning]\t"+e,m(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,m(this.locator))},fatalError:function(e){throw new l(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){p.prototype[e]=function(){return null}}),n.__DOMHandler=p,n.normalizeLineEndings=d,n.DOMParser=h},{"./conventions":1,"./dom":3,"./entities":4,"./sax":6}],3:[function(e,t,n){var r=e("./conventions"),i=r.find,o=r.NAMESPACE;function s(e){return""!==e}function a(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function c(e){if(!e)return[];var t=function(e){return e?e.split(/[\t\n\f\r ]+/).filter(s):[]}(e);return Object.keys(t.reduce(a,{}))}function l(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}function u(e,t){var n=e.prototype;if(!(n instanceof t)){function r(){}r.prototype=t.prototype,l(n,r=new r),e.prototype=n=r}n.constructor!=e&&("function"!=typeof e&&console.error("unknown Class:"+e),n.constructor=e)}var d={},h=d.ELEMENT_NODE=1,p=d.ATTRIBUTE_NODE=2,f=d.TEXT_NODE=3,m=d.CDATA_SECTION_NODE=4,g=d.ENTITY_REFERENCE_NODE=5,v=d.ENTITY_NODE=6,y=d.PROCESSING_INSTRUCTION_NODE=7,b=d.COMMENT_NODE=8,S=d.DOCUMENT_NODE=9,C=d.DOCUMENT_TYPE_NODE=10,_=d.DOCUMENT_FRAGMENT_NODE=11,w=d.NOTATION_NODE=12,T={},E={},x=(T.INDEX_SIZE_ERR=(E[1]="Index size error",1),T.DOMSTRING_SIZE_ERR=(E[2]="DOMString size error",2),T.HIERARCHY_REQUEST_ERR=(E[3]="Hierarchy request error",3)),R=(T.WRONG_DOCUMENT_ERR=(E[4]="Wrong document",4),T.INVALID_CHARACTER_ERR=(E[5]="Invalid character",5),T.NO_DATA_ALLOWED_ERR=(E[6]="No data allowed",6),T.NO_MODIFICATION_ALLOWED_ERR=(E[7]="No modification allowed",7),T.NOT_FOUND_ERR=(E[8]="Not found",8)),k=(T.NOT_SUPPORTED_ERR=(E[9]="Not supported",9),T.INUSE_ATTRIBUTE_ERR=(E[10]="Attribute in use",10));T.INVALID_STATE_ERR=(E[11]="Invalid state",11),T.SYNTAX_ERR=(E[12]="Syntax error",12),T.INVALID_MODIFICATION_ERR=(E[13]="Invalid modification",13),T.NAMESPACE_ERR=(E[14]="Invalid namespace",14),T.INVALID_ACCESS_ERR=(E[15]="Invalid access",15);function I(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,E[e]),this.message=E[e],Error.captureStackTrace&&Error.captureStackTrace(this,I);return n.code=e,t&&(this.message=this.message+": "+t),n}function N(){}function D(e,t){this._node=e,this._refresh=t,A(this)}function A(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);ge(e,"length",n.length),l(n,e),e._inc=t}}function O(){}function L(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function P(e,t,n,r){if(r?t[L(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&H(i,e,r),function(e,t,n){e&&e._inc++,n.namespaceURI===o.XMLNS&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function M(e,t,n){var r=L(t,n);if(!(r>=0))throw new I(R,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var o=e.ownerDocument;o&&(H(o,e,n),n.ownerElement=null)}}function j(){}function q(){}function B(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function U(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(U(e,t))return!0}while(e=e.nextSibling)}function F(){this.ownerDocument=this}function H(e,t,n,r){e&&e._inc++,n.namespaceURI===o.XMLNS&&delete t._nsMap[n.prefix?n.localName:""]}function z(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,o=0;i;)r[o++]=i,i=i.nextSibling;r.length=o,delete r[r.length]}}}function Q(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,z(e.ownerDocument,e),t}function G(e){return e&&e.nodeType===q.DOCUMENT_TYPE_NODE}function J(e){return e&&e.nodeType===q.ELEMENT_NODE}function V(e){return e&&e.nodeType===q.TEXT_NODE}function W(e,t){var n=e.childNodes||[];if(i(n,J)||G(t))return!1;var r=i(n,G);return!(t&&r&&n.indexOf(r)>n.indexOf(t))}function X(e,t){var n=e.childNodes||[];if(i(n,function(e){return J(e)&&e!==t}))return!1;var r=i(n,G);return!(t&&r&&n.indexOf(r)>n.indexOf(t))}function $(e,t,n){if(!function(e){return e&&(e.nodeType===q.DOCUMENT_NODE||e.nodeType===q.DOCUMENT_FRAGMENT_NODE||e.nodeType===q.ELEMENT_NODE)}(e))throw new I(x,"Unexpected parent node type "+e.nodeType);if(n&&n.parentNode!==e)throw new I(R,"child not in parent");if(!function(e){return e&&(J(e)||V(e)||G(e)||e.nodeType===q.DOCUMENT_FRAGMENT_NODE||e.nodeType===q.COMMENT_NODE||e.nodeType===q.PROCESSING_INSTRUCTION_NODE)}(t)||G(t)&&e.nodeType!==q.DOCUMENT_NODE)throw new I(x,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function K(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=o.filter(J);if(s.length>1||i(o,V))throw new I(x,"More than one element or text in fragment");if(1===s.length&&!X(e,n))throw new I(x,"Element in fragment can not be inserted before doctype")}if(J(t)&&!X(e,n))throw new I(x,"Only one element can be added and only after doctype");if(G(t)){if(i(r,function(e){return G(e)&&e!==n}))throw new I(x,"Only one doctype is allowed");var a=i(r,J);if(n&&r.indexOf(a)<r.indexOf(n))throw new I(x,"Doctype can only be inserted before an element")}}function Y(e,t,n,r){$(e,t,n),e.nodeType===q.DOCUMENT_NODE&&(r||function(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=o.filter(J);if(s.length>1||i(o,V))throw new I(x,"More than one element or text in fragment");if(1===s.length&&!W(e,n))throw new I(x,"Element in fragment can not be inserted before doctype")}if(J(t)&&!W(e,n))throw new I(x,"Only one element can be added and only after doctype");if(G(t)){if(i(r,G))throw new I(x,"Only one doctype is allowed");var a=i(r,J);if(n&&r.indexOf(a)<r.indexOf(n))throw new I(x,"Doctype can only be inserted before an element");if(!n&&a)throw new I(x,"Doctype can not be appended since element is present")}})(e,t,n);var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===_){var s=t.firstChild;if(null==s)return t;var a=t.lastChild}else s=a=t;var c=n?n.previousSibling:e.lastChild;s.previousSibling=c,a.nextSibling=n,c?c.nextSibling=s:e.firstChild=s,null==n?e.lastChild=a:n.previousSibling=a;do{s.parentNode=e}while(s!==a&&(s=s.nextSibling));return z(e.ownerDocument||e,e),t.nodeType==_&&(t.firstChild=t.lastChild=null),t}function Z(){this._nsMap={}}function ee(){}function te(){}function ne(){}function re(){}function ie(){}function oe(){}function se(){}function ae(){}function ce(){}function le(){}function ue(){}function de(){}function he(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,i=r.prefix,o=r.namespaceURI;if(o&&null==i&&null==(i=r.lookupPrefix(o)))var s=[{namespace:o,prefix:null}];return me(this,n,e,t,s),n.join("")}function pe(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!i)return!1;if("xml"===r&&i===o.XML||i===o.XMLNS)return!1;for(var s=n.length;s--;){var a=n[s];if(a.prefix===r)return a.namespace!==i}return!0}function fe(e,t,n){e.push(" ",t,'="',n.replace(/[<>&"\t\n\r]/g,B),'"')}function me(e,t,n,r,i){if(i||(i=[]),r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case h:var s=e.attributes,a=s.length,c=e.firstChild,l=e.tagName,u=l;if(!(n=o.isHTML(e.namespaceURI)||n)&&!e.prefix&&e.namespaceURI){for(var d,v=0;v<s.length;v++)if("xmlns"===s.item(v).name){d=s.item(v).value;break}if(!d)for(var w=i.length-1;w>=0;w--){if(""===(T=i[w]).prefix&&T.namespace===e.namespaceURI){d=T.namespace;break}}if(d!==e.namespaceURI)for(w=i.length-1;w>=0;w--){var T;if((T=i[w]).namespace===e.namespaceURI){T.prefix&&(u=T.prefix+":"+l);break}}}t.push("<",u);for(var E=0;E<a;E++){"xmlns"==(x=s.item(E)).prefix?i.push({prefix:x.localName,namespace:x.value}):"xmlns"==x.nodeName&&i.push({prefix:"",namespace:x.value})}for(E=0;E<a;E++){var x,R,k;if(pe(x=s.item(E),0,i))fe(t,(R=x.prefix||"")?"xmlns:"+R:"xmlns",k=x.namespaceURI),i.push({prefix:R,namespace:k});me(x,t,n,r,i)}if(l===u&&pe(e,0,i))fe(t,(R=e.prefix||"")?"xmlns:"+R:"xmlns",k=e.namespaceURI),i.push({prefix:R,namespace:k});if(c||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(l)){if(t.push(">"),n&&/^script$/i.test(l))for(;c;)c.data?t.push(c.data):me(c,t,n,r,i.slice()),c=c.nextSibling;else for(;c;)me(c,t,n,r,i.slice()),c=c.nextSibling;t.push("</",u,">")}else t.push("/>");return;case S:case _:for(c=e.firstChild;c;)me(c,t,n,r,i.slice()),c=c.nextSibling;return;case p:return fe(t,e.name,e.value);case f:return t.push(e.data.replace(/[<&>]/g,B));case m:return t.push("<![CDATA[",e.data,"]]>");case b:return t.push("\x3c!--",e.data,"--\x3e");case C:var I=e.publicId,N=e.systemId;if(t.push("<!DOCTYPE ",e.name),I)t.push(" PUBLIC ",I),N&&"."!=N&&t.push(" ",N),t.push(">");else if(N&&"."!=N)t.push(" SYSTEM ",N,">");else{var D=e.internalSubset;D&&t.push(" [",D,"]"),t.push(">")}return;case y:return t.push("<?",e.target," ",e.data,"?>");case g:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ge(e,t,n){e[t]=n}I.prototype=Error.prototype,l(T,I),N.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)me(this[r],n,e,t);return n.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}},D.prototype.item=function(e){return A(this),this[e]},u(D,N),O.prototype={length:0,item:N.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new I(k);var n=this.getNamedItem(e.nodeName);return P(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new I(k);return t=this.getNamedItemNS(e.namespaceURI,e.localName),P(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return M(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return M(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},j.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,n){var r=new F;if(r.implementation=this,r.childNodes=new N,r.doctype=n||null,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new oe;return r.name=e,r.nodeName=e,r.publicId=t||"",r.systemId=n||"",r}},q.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return Y(this,e,t)},replaceChild:function(e,t){Y(this,e,t,K),t&&this.removeChild(t)},removeChild:function(e){return Q(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return function e(t,n,r){var i=new n.constructor;for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){var s=n[o];"object"!=typeof s&&s!=i[o]&&(i[o]=s)}n.childNodes&&(i.childNodes=new N);i.ownerDocument=t;switch(i.nodeType){case h:var a=n.attributes,c=i.attributes=new O,l=a.length;c._ownerElement=i;for(var u=0;u<l;u++)i.setAttributeNode(e(t,a.item(u),!0));break;case p:r=!0}if(r)for(var d=n.firstChild;d;)i.appendChild(e(t,d,r)),d=d.nextSibling;return i}(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==f&&e.nodeType==f?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&n[r]===e)return r;t=t.nodeType==p?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];t=t.nodeType==p?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},l(d,q),l(d,q.prototype),F.prototype={nodeName:"#document",nodeType:S,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==_){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return Y(this,e,t),e.ownerDocument=this,null===this.documentElement&&e.nodeType===h&&(this.documentElement=e),e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),Q(this,e)},replaceChild:function(e,t){Y(this,e,t,K),e.ownerDocument=this,t&&this.removeChild(t),J(e)&&(this.documentElement=e)},importNode:function(e,t){return function e(t,n,r){var i;switch(n.nodeType){case h:(i=n.cloneNode(!1)).ownerDocument=t;case _:break;case p:r=!0}i||(i=n.cloneNode(!1));i.ownerDocument=t;i.parentNode=null;if(r)for(var o=n.firstChild;o;)i.appendChild(e(t,o,r)),o=o.nextSibling;return i}(this,e,t)},getElementById:function(e){var t=null;return U(this.documentElement,function(n){if(n.nodeType==h&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=c(e);return new D(this,function(n){var r=[];return t.length>0&&U(n.documentElement,function(i){if(i!==n&&i.nodeType===h){var o=i.getAttribute("class");if(o){var s=e===o;if(!s){var a=c(o);s=t.every((l=a,function(e){return l&&-1!==l.indexOf(e)}))}s&&r.push(i)}}var l}),r})},createElement:function(e){var t=new Z;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new N,(t.attributes=new O)._ownerElement=t,t},createDocumentFragment:function(){var e=new le;return e.ownerDocument=this,e.childNodes=new N,e},createTextNode:function(e){var t=new ne;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new re;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new ie;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ue;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new ee;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new ce;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new Z,r=t.split(":"),i=n.attributes=new O;return n.childNodes=new N,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new ee,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},u(F,q),Z.prototype={nodeType:h,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===_?this.insertBefore(e,null):function(e,t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=e,t.previousSibling=e.lastChild,t.nextSibling=null,t.previousSibling?t.previousSibling.nextSibling=t:e.firstChild=t,e.lastChild=t,z(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new D(this,function(t){var n=[];return U(t,function(r){r===t||r.nodeType!=h||"*"!==e&&r.tagName!=e||n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new D(this,function(n){var r=[];return U(n,function(i){i===n||i.nodeType!==h||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||r.push(i)}),r})}},F.prototype.getElementsByTagName=Z.prototype.getElementsByTagName,F.prototype.getElementsByTagNameNS=Z.prototype.getElementsByTagNameNS,u(Z,q),ee.prototype.nodeType=p,u(ee,q),te.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(E[x])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},u(te,q),ne.prototype={nodeName:"#text",nodeType:f,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},u(ne,te),re.prototype={nodeName:"#comment",nodeType:b},u(re,te),ie.prototype={nodeName:"#cdata-section",nodeType:m},u(ie,te),oe.prototype.nodeType=C,u(oe,q),se.prototype.nodeType=w,u(se,q),ae.prototype.nodeType=v,u(ae,q),ce.prototype.nodeType=g,u(ce,q),le.prototype.nodeName="#document-fragment",le.prototype.nodeType=_,u(le,q),ue.prototype.nodeType=y,u(ue,q),de.prototype.serializeToString=function(e,t,n){return he.call(e,t,n)},q.prototype.toString=he;try{if(Object.defineProperty){Object.defineProperty(D.prototype,"length",{get:function(){return A(this),this.$$length}}),Object.defineProperty(q.prototype,"textContent",{get:function(){return function e(t){switch(t.nodeType){case h:case _:var n=[];for(t=t.firstChild;t;)7!==t.nodeType&&8!==t.nodeType&&n.push(e(t)),t=t.nextSibling;return n.join("");default:return t.nodeValue}}(this)},set:function(e){switch(this.nodeType){case h:case _:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ge=function(e,t,n){e["$$"+t]=n}}}catch(e){}n.DocumentType=oe,n.DOMException=I,n.DOMImplementation=j,n.Element=Z,n.Node=q,n.NodeList=N,n.XMLSerializer=de},{"./conventions":1}],4:[function(e,t,n){"use strict";var r=e("./conventions").freeze;n.XML_ENTITIES=r({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),n.HTML_ENTITIES=r({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"ℂ",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"⨯",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"∪",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"ⅅ",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:" ",emsp13:" ",emsp14:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"ℰ",escr:"ℯ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",ExponentialE:"ⅇ",exponentiale:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",Fscr:"ℱ",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"ℌ",hfr:"𝔥",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"ℍ",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"ℋ",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"⁣",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"ℑ",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"ℑ",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"⁣",InvisibleTimes:"⁢",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"ℐ",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",Lscr:"ℒ",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"ℳ",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",Or:"⩔",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",Popf:"ℙ",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"′",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"ℚ",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"∶",rationals:"ℚ",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"ℜ",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"ℜ",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"ℝ",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",Rscr:"ℛ",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:"  ",thinsp:" ",ThinSpace:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",Tilde:"∼",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"⋁",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"​",Zeta:"Ζ",zeta:"ζ",Zfr:"ℨ",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"ℤ",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"‍",zwnj:"‌"}),n.entityMap=n.HTML_ENTITIES},{"./conventions":1}],5:[function(e,t,n){var r=e("./dom");n.DOMImplementation=r.DOMImplementation,n.XMLSerializer=r.XMLSerializer,n.DOMParser=e("./dom-parser").DOMParser},{"./dom":3,"./dom-parser":2}],6:[function(e,t,n){var r=e("./conventions").NAMESPACE,i=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,o=new RegExp("[\\-\\.0-9"+i.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),s=new RegExp("^"+i.source+o.source+"*(?::"+i.source+o.source+"*)?$"),a=0,c=1,l=2,u=3,d=4,h=5,p=6,f=7;function m(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,m)}function g(){}function v(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function y(e,t,n,i,o,s){function m(e,t,r){n.attributeNames.hasOwnProperty(e)&&s.fatalError("Attribute "+e+" redefined"),n.addValue(e,t.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,o),r)}for(var g,v=++t,y=a;;){var b=e.charAt(v);switch(b){case"=":if(y===c)g=e.slice(t,v),y=u;else{if(y!==l)throw new Error("attribute equal must after attrName");y=u}break;case"'":case'"':if(y===u||y===c){if(y===c&&(s.warning('attribute value must after "="'),g=e.slice(t,v)),t=v+1,!((v=e.indexOf(b,t))>0))throw new Error("attribute value no end '"+b+"' match");m(g,S=e.slice(t,v),t-1),y=h}else{if(y!=d)throw new Error('attribute value must after "="');m(g,S=e.slice(t,v),t),s.warning('attribute "'+g+'" missed start quot('+b+")!!"),t=v+1,y=h}break;case"/":switch(y){case a:n.setTagName(e.slice(t,v));case h:case p:case f:y=f,n.closed=!0;case d:case c:break;case l:n.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),y==a&&n.setTagName(e.slice(t,v)),v;case">":switch(y){case a:n.setTagName(e.slice(t,v));case h:case p:case f:break;case d:case c:"/"===(S=e.slice(t,v)).slice(-1)&&(n.closed=!0,S=S.slice(0,-1));case l:y===l&&(S=g),y==d?(s.warning('attribute "'+S+'" missed quot(")!'),m(g,S,t)):(r.isHTML(i[""])&&S.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+S+'" missed value!! "'+S+'" instead!!'),m(S,S,t));break;case u:throw new Error("attribute value missed!!")}return v;case"€":b=" ";default:if(b<=" ")switch(y){case a:n.setTagName(e.slice(t,v)),y=p;break;case c:g=e.slice(t,v),y=l;break;case d:var S=e.slice(t,v);s.warning('attribute "'+S+'" missed quot(")!!'),m(g,S,t);case h:y=p}else switch(y){case l:n.tagName;r.isHTML(i[""])&&g.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+g+'" missed value!! "'+g+'" instead2!!'),m(g,g,t),t=v,y=c;break;case h:s.warning('attribute space is required"'+g+'"!!');case p:y=c,t=v;break;case u:y=d,t=v;break;case f:throw new Error("elements closed character '/' and '>' must be connected to")}}v++}}function b(e,t,n){for(var i=e.tagName,o=null,s=e.length;s--;){var a=e[s],c=a.qName,l=a.value;if((p=c.indexOf(":"))>0)var u=a.prefix=c.slice(0,p),d=c.slice(p+1),h="xmlns"===u&&d;else d=c,u=null,h="xmlns"===c&&"";a.localName=d,!1!==h&&(null==o&&(o={},_(n,n={})),n[h]=o[h]=l,a.uri=r.XMLNS,t.startPrefixMapping(h,l))}for(s=e.length;s--;){(u=(a=e[s]).prefix)&&("xml"===u&&(a.uri=r.XML),"xmlns"!==u&&(a.uri=n[u||""]))}var p;(p=i.indexOf(":"))>0?(u=e.prefix=i.slice(0,p),d=e.localName=i.slice(p+1)):(u=null,d=e.localName=i);var f=e.uri=n[u||""];if(t.startElement(f,d,i,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(f,d,i),o)for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&t.endPrefixMapping(u)}function S(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),s=e.substring(t+1,o);if(/[&<]/.test(s))return/^script$/i.test(n)?(i.characters(s,0,s.length),o):(s=s.replace(/&#?\w+;/g,r),i.characters(s,0,s.length),o)}return t+1}function C(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function _(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}function w(e,t,n,r){switch(e.charAt(t+2)){case"-":return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;default:if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var o=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),s=o.length;if(s>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],c=!1,l=!1;s>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],l=s>4&&o[4][0]):/^system$/i.test(o[2][0])&&(l=o[3][0]));var u=o[s-1];return n.startDTD(a,c,l),n.endDTD(),u.index+u[0].length}}return-1}function T(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){i[0].length;return n.processingInstruction(i[1],i[2]),r+2}return-1}return-1}function E(){this.attributeNames={}}m.prototype=new Error,m.prototype.name=m.name,g.prototype={parse:function(e,t,n){var i=this.domBuilder;i.startDocument(),_(t,t={}),function(e,t,n,i,o){function s(e){var t=e.slice(1,-1);return Object.hasOwnProperty.call(n,t)?n[t]:"#"===t.charAt(0)?function(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}(parseInt(t.substr(1).replace("x","0x"))):(o.error("entity not found:"+e),e)}function a(t){if(t>g){var n=e.substring(g,t).replace(/&#?\w+;/g,s);h&&c(g),i.characters(n,0,t-g),g=t}}function c(t,n){for(;t>=u&&(n=d.exec(e));)l=n.index,u=l+n[0].length,h.lineNumber++;h.columnNumber=t-l+1}var l=0,u=0,d=/.*(?:\r\n?|\n)|.*$/g,h=i.locator,p=[{currentNSMap:t}],f={},g=0;for(;;){try{var _=e.indexOf("<",g);if(_<0){if(!e.substr(g).match(/^\s*$/)){var x=i.doc,R=x.createTextNode(e.substr(g));x.appendChild(R),i.currentElement=R}return}switch(_>g&&a(_),e.charAt(_+1)){case"/":var k=e.indexOf(">",_+3),I=e.substring(_+2,k).replace(/[ \t\n\r]+$/g,""),N=p.pop();k<0?(I=e.substring(_+2).replace(/[\s<].*/,""),o.error("end tag name: "+I+" is not complete:"+N.tagName),k=_+1+I.length):I.match(/\s</)&&(I=I.replace(/[\s<].*/,""),o.error("end tag name: "+I+" maybe not complete"),k=_+1+I.length);var D=N.localNSMap,A=N.tagName==I,O=A||N.tagName&&N.tagName.toLowerCase()==I.toLowerCase();if(O){if(i.endElement(N.uri,N.localName,I),D)for(var L in D)Object.prototype.hasOwnProperty.call(D,L)&&i.endPrefixMapping(L);A||o.fatalError("end tag name: "+I+" is not match the current start tagName:"+N.tagName)}else p.push(N);k++;break;case"?":h&&c(_),k=T(e,_,i);break;case"!":h&&c(_),k=w(e,_,i,o);break;default:h&&c(_);var P=new E,M=p[p.length-1].currentNSMap,k=y(e,_,P,M,s,o),j=P.length;if(!P.closed&&C(e,k,P.tagName,f)&&(P.closed=!0,n.nbsp||o.warning("unclosed xml attribute")),h&&j){for(var q=v(h,{}),B=0;B<j;B++){var U=P[B];c(U.offset),U.locator=v(h,{})}i.locator=q,b(P,i,M)&&p.push(P),i.locator=h}else b(P,i,M)&&p.push(P);r.isHTML(P.uri)&&!P.closed?k=S(e,k,P.tagName,s,i):k++}}catch(e){if(e instanceof m)throw e;o.error("element parse error: "+e),k=-1}k>g?g=k:a(Math.max(_,g)+1)}}(e,t,n,i,this.errorHandler),i.endDocument()}},E.prototype={setTagName:function(e){if(!s.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!s.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},n.XMLReader=g,n.ParseError=m},{"./conventions":1}],7:[function(e,t,n){"use strict";var r=e("inherits"),i=e("events").EventEmitter,o=e("ltx/lib/parsers/ltx"),s=e("@xmpp/xml"),a=s.Stanza,c=s.Element;function l(e){i.call(this);var t=this,n=e&&e.Element||c,r=e&&e.Parser||o;this.maxStanzaSize=e&&e.maxStanzaSize,this.parser=new r,this.bytesParsed=0,this.bytesParsedOnStanzaBegin=0,this.parser.on("startElement",function(e,r){var i;(t.element||(t.emit("startElement",e,r),t.emit("start",new c(e,r))),t.element||"stream:stream"!==e)?t.element?(i=new n(e,r),t.element=t.element.cnode(i)):(i=new a(e,r),t.element=i,t.bytesParsedOnStanzaBegin=t.bytesParsed):t.emit("streamStart",r)}),this.parser.on("endElement",function(e){t.element||t.emit("endElement",e),t.element||"stream:stream"!==e?t.element&&e===t.element.name?t.element.parent?t.element=t.element.parent:(t.emit("element",t.element),t.emit("stanza",t.element),delete t.element,delete t.bytesParsedOnStanzaBegin):t.error("xml-not-well-formed","XML parse error"):t.end()}),this.parser.on("text",function(e){t.element&&t.element.t(e)}),this.parser.on("entityDecl",function(){t.error("xml-not-well-formed","No entity declarations allowed"),t.end()}),this.parser.on("error",this.emit.bind(this,"error"))}r(l,i),l.prototype.checkXMLHeader=function(e){var t=e.indexOf("<?xml");if(-1!==t){var n=e.indexOf("?>");if(t>=0&&n>=0&&t<n+2){var r=e.substring(t,n+2);e=e.replace(r,"")}}return e},l.prototype.write=function(e){if(this.parser){if(e=e.toString("utf8"),e=this.checkXMLHeader(e),this.bytesParsedOnStanzaBegin&&this.maxStanzaSize&&this.bytesParsed>this.bytesParsedOnStanzaBegin+this.maxStanzaSize)return void this.error("policy-violation","Maximum stanza size exceeded");this.bytesParsed+=e.length,this.parser.write(e)}},l.prototype.end=function(e){e&&this.write(e),delete this.parser,this.emit("end")},l.prototype.error=function(e,t){var n=new Error(t);n.condition=e,this.emit("error",n)},t.exports=l},{"@xmpp/xml":8,events:37,inherits:41,"ltx/lib/parsers/ltx":53}],8:[function(e,t,n){"use strict";var r=e("ltx"),i=e("./lib/tag");n=t.exports=function(){return i.apply(null,arguments)},Object.assign(n,r),n.IQ=e("./lib/IQ"),n.Message=e("./lib/Message"),n.Presence=e("./lib/Presence"),n.Stanza=e("./lib/Stanza"),n.createStanza=e("./lib/createStanza"),n.parse=e("./lib/parse"),n.Parser=e("./lib/Parser"),n.tag=e("./lib/tag"),n.ltx=r},{"./lib/IQ":9,"./lib/Message":10,"./lib/Parser":11,"./lib/Presence":12,"./lib/Stanza":13,"./lib/createStanza":14,"./lib/parse":15,"./lib/tag":16,ltx:44}],9:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"iq",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],10:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"message",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],11:[function(e,t,n){"use strict";var r=e("inherits"),i=e("./createStanza"),o=e("ltx").Parser;function s(e){o.call(this,e)}r(s,o),s.prototype.DefaultElement=i,t.exports=s},{"./createStanza":14,inherits:41,ltx:44}],12:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"presence",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],13:[function(e,t,n){"use strict";var r=e("inherits"),i=e("ltx").Element;function o(e,t){i.call(this,e,t)}r(o,i),Object.defineProperty(o.prototype,"from",{get:function(){return this.attrs.from},set:function(e){this.attrs.from=e}}),Object.defineProperty(o.prototype,"to",{get:function(){return this.attrs.to},set:function(e){this.attrs.to=e}}),Object.defineProperty(o.prototype,"id",{get:function(){return this.attrs.id},set:function(e){this.attrs.id=e}}),Object.defineProperty(o.prototype,"type",{get:function(){return this.attrs.type},set:function(e){this.attrs.type=e}}),t.exports=o},{inherits:41,ltx:44}],14:[function(e,t,n){"use strict";var r=e("./Stanza"),i=e("ltx").Element;t.exports=function(e,t){var n;switch(e){case"presence":case"message":case"iq":n=new r(e,t);break;default:n=new i(e,t)}return Array.prototype.slice.call(arguments,2).forEach(function(e){n.cnode(e)}),n}},{"./Stanza":13,ltx:44}],15:[function(e,t,n){"use strict";var r=e("./Parser"),i=e("ltx").parse;t.exports=function(e){return i(e,r)}},{"./Parser":11,ltx:44}],16:[function(e,t,n){"use strict";var r=e("ltx").tagString,i=e("./parse");t.exports=function(){return i(r.apply(null,arguments))}},{"./parse":15,ltx:44}],17:[function(e,t,n){var r=e("./lib/backoff"),i=e("./lib/strategy/exponential"),o=e("./lib/strategy/fibonacci"),s=e("./lib/function_call.js");t.exports.Backoff=r,t.exports.FunctionCall=s,t.exports.FibonacciStrategy=o,t.exports.ExponentialStrategy=i,t.exports.fibonacci=function(e){return new r(new o(e))},t.exports.exponential=function(e){return new r(new i(e))},t.exports.call=function(e,t,n){var r=Array.prototype.slice.call(arguments);return e=r[0],t=r.slice(1,r.length-1),n=r[r.length-1],new s(e,t,n)}},{"./lib/backoff":18,"./lib/function_call.js":19,"./lib/strategy/exponential":20,"./lib/strategy/fibonacci":21}],18:[function(e,t,n){var r=e("events");function i(e){r.EventEmitter.call(this),this.backoffStrategy_=e,this.maxNumberOfRetry_=-1,this.backoffNumber_=0,this.backoffDelay_=0,this.timeoutID_=-1,this.handlers={backoff:this.onBackoff_.bind(this)}}e("util").inherits(i,r.EventEmitter),i.prototype.failAfter=function(e){if(e<1)throw new Error("Maximum number of retry must be greater than 0. Actual: "+e);this.maxNumberOfRetry_=e},i.prototype.backoff=function(e){if(-1!==this.timeoutID_)throw new Error("Backoff in progress.");this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},i.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},i.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=i},{events:37,util:116}],19:[function(e,t,n){var r=e("events"),i=e("util"),o=e("./backoff"),s=e("./strategy/fibonacci");function a(e){return"function"==typeof e}function c(e,t,n){if(r.EventEmitter.call(this),!a(e))throw new Error("fn should be a function.Actual: "+typeof e);if(!a(n))throw new Error("callback should be a function.Actual: "+typeof e);this.function_=e,this.arguments_=t,this.callback_=n,this.results_=[],this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.state_=c.State_.PENDING}i.inherits(c,r.EventEmitter),c.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},c.prototype.isPending=function(){return this.state_==c.State_.PENDING},c.prototype.isRunning=function(){return this.state_==c.State_.RUNNING},c.prototype.isCompleted=function(){return this.state_==c.State_.COMPLETED},c.prototype.isAborted=function(){return this.state_==c.State_.ABORTED},c.prototype.setStrategy=function(e){if(!this.isPending())throw new Error("FunctionCall in progress.");return this.strategy_=e,this},c.prototype.getResults=function(){return this.results_.concat()},c.prototype.failAfter=function(e){if(!this.isPending())throw new Error("FunctionCall in progress.");return this.failAfter_=e,this},c.prototype.abort=function(){if(this.isCompleted())throw new Error("FunctionCall already completed.");this.isRunning()&&this.backoff_.reset(),this.state_=c.State_.ABORTED},c.prototype.start=function(e){if(this.isAborted())throw new Error("FunctionCall aborted.");if(!this.isPending())throw new Error("FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new o(t),this.backoff_.on("ready",this.doCall_.bind(this)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=c.State_.RUNNING,this.doCall_()},c.prototype.doCall_=function(){var e=["call"].concat(this.arguments_);r.EventEmitter.prototype.emit.apply(this,e);var t=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(t))},c.prototype.doCallback_=function(){var e=this.results_[this.results_.length-1];this.callback_.apply(null,e)},c.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.results_.push(e),r.EventEmitter.prototype.emit.apply(this,["callback"].concat(e)),e[0]?this.backoff_.backoff(e[0]):(this.state_=c.State_.COMPLETED,this.doCallback_())}},c.prototype.handleBackoff_=function(e,t,n){this.emit("backoff",e,t,n)},t.exports=c},{"./backoff":18,"./strategy/fibonacci":21,events:37,util:116}],20:[function(e,t,n){var r=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}r.inherits(o,i),o.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=2*this.backoffDelay_,this.backoffDelay_},o.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=o},{"./strategy":22,util:116}],21:[function(e,t,n){var r=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}r.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":22,util:116}],22:[function(e,t,n){e("events"),e("util");function r(e){return null!=e}function i(e){if(r((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(r(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(r(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:37,util:116}],23:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=l(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),u=0,d=a>0?s-4:s;for(n=0;n<d;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[u++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(u(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],24:[function(e,t,n){var r,i;r=this,i=function(){var e=XMLHttpRequest;if(!e)throw new Error("missing XMLHttpRequest");function t(o,s){if("function"!=typeof s)throw new Error("Bad callback given: "+s);if(!o)throw new Error("No options given");var a=o.onResponse;if((o="string"==typeof o?{uri:o}:JSON.parse(JSON.stringify(o))).onResponse=a,o.verbose&&(t.log=function(){var e,t,n={},o=["trace","debug","info","warn","error"];for(t=0;t<o.length;t++)n[e=o[t]]=r,"undefined"!=typeof console&&console&&console[e]&&(n[e]=i(console,e));return n}()),o.url&&(o.uri=o.url,delete o.url),!o.uri&&""!==o.uri)throw new Error("options.uri is a required argument");if("string"!=typeof o.uri)throw new Error("options.uri must be a string");for(var c=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],l=0;l<c.length;l++)if(o[c[l]])throw new Error("options."+c[l]+" is not supported");if(o.callback=s,o.method=o.method||"GET",o.headers=o.headers||{},o.body=o.body||null,o.timeout=o.timeout||t.DEFAULT_TIMEOUT,o.headers.host)throw new Error("Options.headers.host is not supported");o.json&&(o.headers.accept=o.headers.accept||"application/json","GET"!==o.method&&(o.headers["content-type"]="application/json"),"boolean"!=typeof o.json?o.body=JSON.stringify(o.json):"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)));var u=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(o.qs){var d="string"==typeof o.qs?o.qs:u(o.qs);-1!==o.uri.indexOf("?")?o.uri=o.uri+"&"+d:o.uri=o.uri+"?"+d}if(o.form){if("string"==typeof o.form)throw"form name unsupported";if("POST"===o.method){var h=(o.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(o.headers["content-type"]=h,h){case"application/x-www-form-urlencoded":o.body=u(o.form).replace(/%20/g,"+");break;case"multipart/form-data":var p=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+r+'"\n\n'+e[r]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t}(o.form);o.body=p.body,o.headers["content-type"]=p.type;break;default:throw new Error("unsupported encoding:"+h)}}}return o.onResponse=o.onResponse||r,!0===o.onResponse&&(o.onResponse=s,o.callback=r),!o.headers.authorization&&o.auth&&(o.headers.authorization="Basic "+function(e){var t,n,r,i,o,s,a,c,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,d=0,h="",p=[];if(!e)return e;do{t=e.charCodeAt(u++),n=e.charCodeAt(u++),r=e.charCodeAt(u++),i=(c=t<<16|n<<8|r)>>18&63,o=c>>12&63,s=c>>6&63,a=63&c,p[d++]=l.charAt(i)+l.charAt(o)+l.charAt(s)+l.charAt(a)}while(u<e.length);switch(h=p.join(""),e.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h}(o.auth.username+":"+o.auth.password)),function(r){var i=new e,o=!1,s=function(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(e){(t=document.createElement("a")).href="",t=t.href}var r=n.exec(t.toLowerCase())||[],i=n.exec(e.toLowerCase());return!(!i||i[1]==r[1]&&i[2]==r[2]&&(i[3]||("http:"===i[1]?80:443))==(r[3]||("http:"===r[1]?80:443)))}(r.uri),a="withCredentials"in i;if(n+=1,i.seq_id=n,i.id=n+": "+r.method+" "+r.uri,i._id=i.id,s&&!a){var c=new Error("Browser does not support cross-origin request: "+r.uri);return c.cors="unsupported",r.callback(c,i)}i.timeoutTimer=setTimeout(function(){o=!0;var e=new Error("ETIMEDOUT");return e.code="ETIMEDOUT",e.duration=r.timeout,t.log.error("Timeout",{id:i._id,milliseconds:r.timeout}),r.callback(e,i)},r.timeout);var l={response:!1,loading:!1,end:!1};i.onreadystatechange=function(n){if(o)return t.log.debug("Ignoring timed out state change",{state:i.readyState,id:i.id});if(t.log.debug("State change",{state:i.readyState,id:i.id,timed_out:o}),i.readyState===e.OPENED)for(var s in t.log.debug("Request started",{id:i.id}),r.headers)i.setRequestHeader(s,r.headers[s]);else i.readyState===e.HEADERS_RECEIVED?u():i.readyState===e.LOADING?(u(),d()):i.readyState===e.DONE&&(u(),d(),function(){if(!l.end){if(l.end=!0,t.log.debug("Request done",{id:i.id}),i.body=i.responseText,r.json)try{i.body=JSON.parse(i.responseText)}catch(e){return r.callback(e,i)}r.callback(null,i,i.body)}}())},i.open(r.method,r.uri,!0),s&&(i.withCredentials=!!r.withCredentials);return i.send(r.body),i;function u(){if(!l.response){if(l.response=!0,t.log.debug("Got response",{id:i.id,status:i.status}),clearTimeout(i.timeoutTimer),i.statusCode=i.status,s&&0==i.statusCode){var e=new Error("CORS request rejected: "+r.uri);return e.cors="rejected",l.loading=!0,l.end=!0,r.callback(e,i)}r.onResponse(null,i)}}function d(){l.loading||(l.loading=!0,t.log.debug("Response body loading",{id:i.id}))}}(o)}t.log={trace:r,debug:r,info:r,warn:r,error:r};var n=0;function r(){}function i(e,t){return function(n,r){"object"==typeof r&&(n+=" "+JSON.stringify(r));return e[t].call(e,n)}}return t.withCredentials=!1,t.DEFAULT_TIMEOUT=18e4,t.defaults=function(e,n){var r=function(t){return function(n,r){for(var i in n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n)),e)void 0===n[i]&&(n[i]=e[i]);return t(n,r)}},i=r(t);return i.get=r(t.get),i.post=r(t.post),i.put=r(t.put),i.head=r(t.head),i},["get","put","post","head"].forEach(function(e){var n=e.toUpperCase();t[e.toLowerCase()]=function(e){"string"==typeof e?e={method:n,uri:e}:(e=JSON.parse(JSON.stringify(e))).method=n;var r=[e].concat(Array.prototype.slice.apply(arguments,[1]));return t.apply(this,r)}}),t.couch=function(e,n){return"string"==typeof e&&(e={uri:e}),e.json=!0,e.body&&(e.json=e.body),delete e.body,n=n||r,t(e,function(e,t,r){if(e)return n(e,t,r);if((t.statusCode<200||t.statusCode>299)&&r.error){for(var i in e=new Error("CouchDB error: "+(r.error.reason||r.error.error)),r)e[i]=r[i];return n(e,t,r)}return n(e,t,r)})},t},"object"==typeof n?t.exports=i():r.returnExports=i()},{}],25:[function(e,t,n){},{}],26:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],27:[function(e,t,n){(function(t,r){(function(){"use strict";var r=e("base64-js"),i=e("ieee754"),o=e("isarray");function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return l(this,e,t,n)}function l(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function d(e,t){if(u(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(e).length;default:if(r)return U(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var u=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===c)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var d=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){d=!1;break}if(d)return o}return-1}function y(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return H(U(t,e.length-n),e,n,r)}function S(e,t,n,r){return H(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function C(e,t,n,r){return S(e,t,n,r)}function _(e,t,n,r){return H(F(t),e,n,r)}function w(e,t,n,r){return H(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function E(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],u=null,d=l>239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(u=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=x));return n}(r)}n.Buffer=c,n.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},n.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.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}}(),n.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return l(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return u(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?E(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return k(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(r,i),u=e.slice(t,n),d=0;d<a;++d)if(l[d]!==u[d]){o=l[d],s=u[d];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return y(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return S(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return _(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function R(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function k(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=B(e[o]);return i}function N(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function P(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(e,t,n,r,o){return o||P(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,o){return o||P(e,0,n,8),i.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return M(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return M(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:U(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function B(e){return e<16?"0"+e.toString(16):e.toString(16)}function U(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function F(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":23,buffer:27,ieee754:40,isarray:42}],28:[function(e,t,n){function r(e){return Object.prototype.toString.call(e)}n.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},n.isBoolean=function(e){return"boolean"==typeof e},n.isNull=function(e){return null===e},n.isNullOrUndefined=function(e){return null==e},n.isNumber=function(e){return"number"==typeof e},n.isString=function(e){return"string"==typeof e},n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=function(e){return void 0===e},n.isRegExp=function(e){return"[object RegExp]"===r(e)},n.isObject=function(e){return"object"==typeof e&&null!==e},n.isDate=function(e){return"[object Date]"===r(e)},n.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},n.isFunction=function(e){return"function"==typeof e},n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("buffer").Buffer.isBuffer},{buffer:27}],29:[function(e,t,n){(function(r){(function(){var i,o;i=this,o=function(){var t=t||function(t,n){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==r&&r.crypto&&(i=r.crypto),!i&&"function"==typeof e)try{i=e("crypto")}catch(e){}var o=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},c=a.lib={},l=c.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=l.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new u.init(t,e)}}),d=a.enc={},h=d.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},p=d.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},f=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},m=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var n,r=this._data,i=r.words,o=r.sigBytes,s=this.blockSize,a=o/(4*s),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,l=t.min(4*c,o);if(c){for(var d=0;d<c;d+=s)this._doProcessBlock(i,d);n=i.splice(0,c),r.sigBytes-=l}return new u.init(n,l)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(c.Hasher=m.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}}),a.algo={});return a}(Math);return t},"object"==typeof n?t.exports=n=o():i.CryptoJS=o()}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{crypto:25}],30:[function(e,t,n){var r,i;r=this,i=function(e){return e.HmacSHA1},"object"==typeof n?t.exports=n=i(e("./core"),e("./sha1"),e("./hmac")):i(r.CryptoJS)},{"./core":29,"./hmac":32,"./sha1":33}],31:[function(e,t,n){var r,i;r=this,i=function(e){return e.HmacSHA256},"object"==typeof n?t.exports=n=i(e("./core"),e("./sha256"),e("./hmac")):i(r.CryptoJS)},{"./core":29,"./hmac":32,"./sha256":34}],32:[function(e,t,n){var r,i;r=this,i=function(e){var t,n,r;n=(t=e).lib.Base,r=t.enc.Utf8,t.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,i=4*n;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,l=0;l<n;l++)a[l]^=1549556828,c[l]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],33:[function(e,t,n){var r,i;r=this,i=function(e){var t,n,r,i,o,s,a;return n=(t=e).lib,r=n.WordArray,i=n.Hasher,o=t.algo,s=[],a=o.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],c=n[4],l=0;l<80;l++){if(l<16)s[l]=0|e[t+l];else{var u=s[l-3]^s[l-8]^s[l-14]^s[l-16];s[l]=u<<1|u>>>31}var d=(r<<5|r>>>27)+c+s[l];d+=l<20?1518500249+(i&o|~i&a):l<40?1859775393+(i^o^a):l<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(a),t.HmacSHA1=i._createHmacHelper(a),e.SHA1},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],34:[function(e,t,n){var r,i;r=this,i=function(e){return function(t){var n=e,r=n.lib,i=r.WordArray,o=r.Hasher,s=n.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(a[i]=n(t.pow(r,.5))),c[i]=n(t.pow(r,1/3)),i++),r++}();var l=[],u=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],d=n[6],h=n[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var f=l[p-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=l[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=m+l[p-7]+v+l[p-16]}var y=r&i^r&o^i&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&d)+c[p]+l[p];h=d,d=u,u=a,a=s+S|0,s=o,o=i,i=r,r=S+(b+y)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+u|0,n[6]=n[6]+d|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=o._createHelper(u),n.HmacSHA256=o._createHmacHelper(u)}(Math),e.SHA256},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],35:[function(e,t,n){(function(r){(function(){function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(n=t.exports=e("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},n.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)},n.save=function(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}},n.load=i,n.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this)}).call(this,e("_process"))},{"./debug":36,_process:89}],36:[function(e,t,n){var r;function i(e){function t(){if(t.enabled){var e=t,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(t,r){if("%%"===t)return t;c++;var i=n.formatters[r];if("function"==typeof i){var o=s[c];t=i.call(e,o),s.splice(c,1),c--}return t}),n.formatArgs.call(e,s),(t.log||n.log||console.log.bind(console)).apply(e,s)}}return t.namespace=e,t.enabled=n.enabled(e),t.useColors=n.useColors(),t.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}(e),"function"==typeof n.init&&n.init(t),t}(n=t.exports=i.debug=i.default=i).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];for(var t=("string"==typeof e?e:"").split(/[\s,]+/),r=t.length,i=0;i<r;i++)t[i]&&("-"===(e=t[i].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={}},{ms:58}],37:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,a,c,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(s(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(o(n))for(a=Array.prototype.slice.call(arguments,1),r=(l=n.slice()).length,c=0;c<r;c++)l[c].apply(this,a);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],38:[function(e,t,n){"use strict";t.exports="object"==typeof self?self.FormData:window.FormData},{}],39:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=r.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)};var s="undefined"!=typeof Uint8Array,a="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(r.prototype instanceof Uint8Array||r.TYPED_ARRAY_SUPPORT);o.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=function(e,t){if(e instanceof r)return e;if("string"==typeof e)return r.from(e,t);if(a&&ArrayBuffer.isView(e)){if(0===e.byteLength)return r.alloc(0);var n=r.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}if(s&&e instanceof Uint8Array)return r.from(e);if(r.isBuffer(e)&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e))return r.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(e,t);for(var n=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)n[this._blockOffset++]=e[i++];for(var c=0,l=8*e.length;l>0;++c)this._length[c]+=l,(l=this._length[c]/4294967296|0)>0&&(this._length[c]-=4294967296*l);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:41,"safe-buffer":107,stream:109}],40:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?i-1:0,h=n?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+e[t+d],d+=h,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+d],d+=h,u-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=l}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,u=(1<<l)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?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=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(t*c-1)*Math.pow(2,i),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+p]=255&s,p+=f,s/=256,l-=8);e[n+p-f]|=128*m}},{}],41:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],42:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],43:[function(e,t,n){var r=9007199254740991,i="[object Arguments]",o="[object Function]",s="[object GeneratorFunction]",a=/^(?:0|[1-9]\d*)$/;var c,l,u=Object.prototype,d=u.hasOwnProperty,h=u.toString,p=u.propertyIsEnumerable,f=(c=Object.keys,l=Object,function(e){return c(l(e))}),m=Math.max,g=!p.call({valueOf:1},"valueOf");function v(e,t){var n=_(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&w(e)}(e)&&d.call(e,"callee")&&(!p.call(e,"callee")||h.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var s in e)!t&&!d.call(e,s)||o&&("length"==s||b(s,r))||n.push(s);return n}function y(e,t,n){var r=e[t];d.call(e,t)&&C(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function b(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||a.test(e))&&e>-1&&e%1==0&&e<t}function S(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||u)}function C(e,t){return e===t||e!=e&&t!=t}var _=Array.isArray;function w(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!function(e){var t=T(e)?h.call(e):"";return t==o||t==s}(e)}function T(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var E=function(e){return t=function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function(e,t,n){if(!T(n))return!1;var r=typeof t;return!!("number"==r?w(n)&&b(t,n.length):"string"==r&&t in n)&&C(n[t],e)}(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var a=n[r];a&&e(t,a,r,o)}return t},n=m(void 0===n?t.length-1:n,0),function(){for(var e=arguments,r=-1,i=m(e.length-n,0),o=Array(i);++r<i;)o[r]=e[n+r];r=-1;for(var s=Array(n+1);++r<n;)s[r]=e[r];return s[n]=o,function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(t,this,s)};var t,n}(function(e,t){if(g||S(t)||w(t))!function(e,t,n,r){n||(n={});for(var i=-1,o=t.length;++i<o;){var s=t[i],a=r?r(n[s],e[s],s,n,e):void 0;y(n,s,void 0===a?e[s]:a)}}(t,function(e){return w(e)?v(e):function(e){if(!S(e))return f(e);var t=[];for(var n in Object(e))d.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}(t),e);else for(var n in t)d.call(t,n)&&y(e,n,t[n])});t.exports=E},{}],44:[function(e,t,n){"use strict";var r=e("./lib/parse"),i=e("./lib/Parser"),o=e("./lib/escape"),s=e("./lib/Element"),a=e("./lib/equal"),c=e("./lib/createElement"),l=e("./lib/tag"),u=e("./lib/tagString"),d=e("./lib/is"),h=e("./lib/clone"),p=e("./lib/stringify");(n=t.exports=function(){return l.apply(null,arguments)}).Element=s,n.equal=a.equal,n.nameEqual=a.name,n.attrsEqual=a.attrs,n.childrenEqual=a.children,n.isNode=d.isNode,n.isElement=d.isElement,n.isText=d.isText,n.clone=h,n.createElement=c,n.escapeXML=o.escapeXML,n.unescapeXML=o.unescapeXML,n.escapeXMLText=o.escapeXMLText,n.unescapeXMLText=o.unescapeXMLText,n.Parser=i,n.parse=r,n.tag=l,n.tagString=u,n.stringify=p},{"./lib/Element":45,"./lib/Parser":46,"./lib/clone":47,"./lib/createElement":48,"./lib/equal":49,"./lib/escape":50,"./lib/is":51,"./lib/parse":52,"./lib/stringify":54,"./lib/tag":55,"./lib/tagString":56}],45:[function(e,t,n){"use strict";var r=e("./escape"),i=r.escapeXML,o=r.escapeXMLText,s=e("./equal"),a=s.equal,c=s.name,l=s.attrs,u=s.children,d=e("./clone");function h(e,t){this.name=e,this.parent=null,this.children=[],this.attrs={},this.setAttrs(t)}h.prototype.is=function(e,t){return this.getName()===e&&(!t||this.getNS()===t)},h.prototype.getName=function(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name},h.prototype.getNS=function(){if(this.name.indexOf(":")>=0){var e=this.name.substr(0,this.name.indexOf(":"));return this.findNS(e)}return this.findNS()},h.prototype.findNS=function(e){if(e){var t="xmlns:"+e;if(this.attrs[t])return this.attrs[t];if(this.parent)return this.parent.findNS(e)}else{if(this.attrs.xmlns)return this.attrs.xmlns;if(this.parent)return this.parent.findNS()}},h.prototype.getXmlns=function(){var e={};for(var t in this.parent&&(e=this.parent.getXmlns()),this.attrs){var n=t.match("xmlns:?(.*)");this.attrs.hasOwnProperty(t)&&n&&(e[this.attrs[t]]=n[1])}return e},h.prototype.setAttrs=function(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach(function(t){this.attrs[t]=e[t]},this)},h.prototype.getAttr=function(e,t){if(!t)return this.attrs[e];var n=this.getXmlns();return n[t]?this.attrs[[n[t],e].join(":")]:null},h.prototype.getChild=function(e,t){return this.getChildren(e,t)[0]},h.prototype.getChildren=function(e,t){for(var n=[],r=0;r<this.children.length;r++){var i=this.children[r];!i.getName||i.getName()!==e||t&&i.getNS()!==t||n.push(i)}return n},h.prototype.getChildByAttr=function(e,t,n,r){return this.getChildrenByAttr(e,t,n,r)[0]},h.prototype.getChildrenByAttr=function(e,t,n,r){for(var i=[],o=0;o<this.children.length;o++){var s=this.children[o];!s.attrs||s.attrs[e]!==t||n&&s.getNS()!==n||i.push(s),r&&s.getChildrenByAttr&&i.push(s.getChildrenByAttr(e,t,n,!0))}return r&&(i=[].concat.apply([],i)),i},h.prototype.getChildrenByFilter=function(e,t){for(var n=[],r=0;r<this.children.length;r++){var i=this.children[r];e(i)&&n.push(i),t&&i.getChildrenByFilter&&n.push(i.getChildrenByFilter(e,!0))}return t&&(n=[].concat.apply([],n)),n},h.prototype.getText=function(){for(var e="",t=0;t<this.children.length;t++){var n=this.children[t];"string"!=typeof n&&"number"!=typeof n||(e+=n)}return e},h.prototype.getChildText=function(e,t){var n=this.getChild(e,t);return n?n.getText():null},h.prototype.getChildElements=function(){return this.getChildrenByFilter(function(e){return e instanceof h})},h.prototype.root=function(){return this.parent?this.parent.root():this},h.prototype.tree=h.prototype.root,h.prototype.up=function(){return this.parent?this.parent:this},h.prototype.c=function(e,t){return this.cnode(new h(e,t))},h.prototype.cnode=function(e){return this.children.push(e),"object"==typeof e&&(e.parent=this),e},h.prototype.t=function(e){return this.children.push(e),this},h.prototype.remove=function(e,t){var n;return n="string"==typeof e?function(n){return!(n.is&&n.is(e,t))}:function(t){return t!==e},this.children=this.children.filter(n),this},h.prototype.clone=function(){return d(this)},h.prototype.text=function(e){return e&&1===this.children.length?(this.children[0]=e,this):this.getText()},h.prototype.attr=function(e,t){return void 0!==t||null===t?(this.attrs||(this.attrs={}),this.attrs[e]=t,this):this.attrs[e]},h.prototype.toString=function(){var e="";return this.write(function(t){e+=t}),e},h.prototype.toJSON=function(){return{name:this.name,attrs:this.attrs,children:this.children.map(function(e){return e&&e.toJSON?e.toJSON():e})}},h.prototype._addChildren=function(e){e(">");for(var t=0;t<this.children.length;t++){var n=this.children[t];(n||0===n)&&(n.write?n.write(e):"string"==typeof n?e(o(n)):n.toString&&e(o(n.toString(10))))}e("</"),e(this.name),e(">")},h.prototype.write=function(e){for(var t in e("<"),e(this.name),this.attrs){var n=this.attrs[t];null!=n&&(e(" "),e(t),e('="'),"string"!=typeof n&&(n=n.toString()),e(i(n)),e('"'))}0===this.children.length?e("/>"):this._addChildren(e)},h.prototype.nameEquals=function(e){return c(this,e)},h.prototype.attrsEquals=function(e){return l(this,e)},h.prototype.childrenEquals=function(e){return u(this,e)},h.prototype.equals=function(e){return a(this,e)},t.exports=h},{"./clone":47,"./equal":49,"./escape":50}],46:[function(e,t,n){"use strict";var r=e("events").EventEmitter,i=e("inherits"),o=e("./Element"),s=e("./parsers/ltx"),a=function(e){r.call(this);var t,n=this.Parser=e&&e.Parser||this.DefaultParser,i=this.Element=e&&e.Element||this.DefaultElement;this.parser=new n;var o=this;this.parser.on("startElement",function(e,n){var r=new i(e,n);t=t?t.cnode(r):r}),this.parser.on("endElement",function(e){t&&e===t.name&&(t.parent?t=t.parent:o.tree||(o.tree=t,t=void 0))}),this.parser.on("text",function(e){t&&t.t(e)}),this.parser.on("error",function(e){o.error=e,o.emit("error",e)})};i(a,r),a.prototype.DefaultParser=s,a.prototype.DefaultElement=o,a.prototype.write=function(e){this.parser.write(e)},a.prototype.end=function(e){this.parser.end(e),this.error||(this.tree?this.emit("tree",this.tree):this.emit("error",new Error("Incomplete document")))},t.exports=a},{"./Element":45,"./parsers/ltx":53,events:37,inherits:41}],47:[function(e,t,n){"use strict";t.exports=function(e){for(var t=new e.constructor(e.name,e.attrs),n=0;n<e.children.length;n++){var r=e.children[n];t.cnode(r.clone?r.clone():r)}return t}},{}],48:[function(e,t,n){"use strict";var r=e("./Element");t.exports=function(e,t){for(var n=new r(e,t),i=2;i<arguments.length;i++){var o=arguments[i];o&&n.cnode(o)}return n}},{"./Element":45}],49:[function(e,t,n){"use strict";function r(e,t){return e.name===t.name}function i(e,t){var n=e.attrs,r=Object.keys(n),i=r.length;if(i!==Object.keys(t.attrs).length)return!1;for(var o=0,s=i;o<s;o++){var a=r[o],c=n[a];if(null==c||null==t.attrs[a]){if(c!==t.attrs[a])return!1}else if(c.toString()!==t.attrs[a].toString())return!1}return!0}function o(e,t){var n=e.children,r=n.length;if(r!==t.children.length)return!1;for(var i=0,o=r;i<o;i++){var s=n[i];if("string"==typeof s){if(s!==t.children[i])return!1}else if(!s.equals(t.children[i]))return!1}return!0}t.exports.name=r,t.exports.attrs=i,t.exports.children=o,t.exports.equal=function(e,t){return!!r(e,t)&&!!i(e,t)&&!!o(e,t)}},{}],50:[function(e,t,n){"use strict";var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};function i(e){return r[e]}var o={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'"};function s(e){if("#"===e[1]){var t;if(9===(t="x"===e[2]?parseInt(e.slice(3),16):parseInt(e.slice(2),10))||10===t||13===t||t>=32&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111)return String.fromCodePoint(t);throw new Error("Illegal XML character 0x"+t.toString(16))}if(o[e])return o[e]||e;throw new Error("Illegal XML entity "+e)}n.escapeXML=function(e){return e.replace(/&|<|>|"|'/g,i)},n.unescapeXML=function(e){for(var t="",n=-1,r=-1,i=0;-1!==(n=e.indexOf("&",i))&&-1!==(r=e.indexOf(";",n+1));)t=t+e.substring(i,n)+s(e.substring(n,r+1)),i=r+1;return 0===i?e:t+=e.substring(i)},n.escapeXMLText=function(e){return e.replace(/&|<|>/g,i)},n.unescapeXMLText=function(e){return e.replace(/&(amp|#38|lt|#60|gt|#62);/g,s)}},{}],51:[function(e,t,n){"use strict";var r=e("./Element");t.exports.isNode=function(e){return e instanceof r||"string"==typeof e},t.exports.isElement=function(e){return e instanceof r},t.exports.isText=function(e){return"string"==typeof e}},{"./Element":45}],52:[function(e,t,n){"use strict";var r=e("./Parser");t.exports=function(e,t){var n;n="function"==typeof t?new t:new r(t);var i=null,o=null;if(n.on("tree",function(e){i=e}),n.on("error",function(e){o=e}),n.write(e),n.end(),o)throw o;return i}},{"./Parser":46}],53:[function(e,t,n){"use strict";var r=e("inherits"),i=e("events").EventEmitter,o=e("../escape").unescapeXML,s=t.exports=function(){i.call(this);var e,t,n,r,s,a,c,l,u=0,d=0;this._handleTagOpening=function(e,t,n){e?this.emit("endElement",t):(this.emit("startElement",t,n),s&&this.emit("endElement",t))},this.write=function(i){"string"!=typeof i&&(i=i.toString());var h=0;function p(){if("number"==typeof d){var e=i.substring(d,h);return d=void 0,e}}for(e&&(i=e+i,h+=e.length,e=null);h<i.length;h++){if(0===u){var f=i.indexOf("<",h);-1!==f&&h!==f&&(h=f)}else if(8===u){var m=i.indexOf(c,h);-1!==m&&(h=m)}else if(1===u){var g=i.indexOf("--\x3e",h);-1!==g&&(h=g+2)}else if(10===u){var v=i.indexOf("]]>",h);-1!==v&&(h=v+2)}var y=i.charCodeAt(h);switch(u){case 0:if(60===y){var b=p();b&&this.emit("text",o(b)),u=3,d=h+1,n={}}break;case 9:if(93===y&&"]>"===i.substr(h+1,2)){var S=p();S&&this.emit("text",S),u=0}break;case 3:47===y&&d===h?(d=h+1,r=!0):33===y?"[CDATA["===i.substr(h+1,7)?(d=h+8,u=9):(d=void 0,u=1):63===y?(d=void 0,u=2):(y<=32||47===y||62===y)&&(t=p(),h--,u=4);break;case 1:if(62===y){var C=i.charCodeAt(h-1),_=i.charCodeAt(h-2);(45===C&&45===_||93===C&&93===_)&&(u=0)}break;case 2:if(62===y)63===i.charCodeAt(h-1)&&(u=0);break;case 4:62===y?(this._handleTagOpening(r,t,n),t=void 0,n=void 0,r=void 0,s=void 0,u=0,d=h+1):47===y?s=!0:y>32&&(d=h,u=5);break;case 5:(y<=32||61===y)&&(l=p(),h--,u=6);break;case 6:61===y&&(u=7);break;case 7:34!==y&&39!==y||(a=y,c=34===y?'"':"'",u=8,d=h+1);break;case 8:if(y===a){var w=o(p());n[l]=w,l=void 0,u=4}}}"number"==typeof d&&d<=i.length&&(e=i.slice(d),d=0)}};r(s,i),s.prototype.end=function(e){e&&this.write(e),this.write=function(){}}},{"../escape":50,events:37,inherits:41}],54:[function(e,t,n){"use strict";t.exports=function e(t,n,r){"number"==typeof n&&(n=" ".repeat(n)),r||(r=1);var i="";return i+="<"+t.name,Object.keys(t.attrs).forEach(function(e){i+=" "+e+'="'+t.attrs[e]+'"'}),t.children.length?(i+=">",t.children.forEach(function(t,o){n&&(i+="\n"+n.repeat(r)),i+="string"==typeof t?t:e(t,n,r+1)}),n&&(i+="\n"+n.repeat(r-1)),i+="</"+t.name+">"):i+="/>",i}},{}],55:[function(e,t,n){"use strict";var r=e("./tagString"),i=e("./parse");t.exports=function(){return i(r.apply(null,arguments))}},{"./parse":52,"./tagString":56}],56:[function(e,t,n){"use strict";var r=e("./escape").escapeXML;t.exports=function(){for(var e=arguments[0],t="",n=1;n<arguments.length;n++)t+=e[n-1],t+=r(arguments[n]);return t+=e[e.length-1]}},{"./escape":50}],57:[function(e,t,n){"use strict";var r=e("inherits"),i=e("hash-base"),o=e("safe-buffer").Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<<t|e>>>32-t}function l(e,t,n,r,i,o,s){return c(e+(t&n|~t&r)+i+o|0,s)+t|0}function u(e,t,n,r,i,o,s){return c(e+(t&r|n&~r)+i+o|0,s)+t|0}function d(e,t,n,r,i,o,s){return c(e+(t^n^r)+i+o|0,s)+t|0}function h(e,t,n,r,i,o,s){return c(e+(n^(t|~r))+i+o|0,s)+t|0}r(a,i),a.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=l(n,r,i,o,e[0],3614090360,7),o=l(o,n,r,i,e[1],3905402710,12),i=l(i,o,n,r,e[2],606105819,17),r=l(r,i,o,n,e[3],3250441966,22),n=l(n,r,i,o,e[4],4118548399,7),o=l(o,n,r,i,e[5],1200080426,12),i=l(i,o,n,r,e[6],2821735955,17),r=l(r,i,o,n,e[7],4249261313,22),n=l(n,r,i,o,e[8],1770035416,7),o=l(o,n,r,i,e[9],2336552879,12),i=l(i,o,n,r,e[10],4294925233,17),r=l(r,i,o,n,e[11],2304563134,22),n=l(n,r,i,o,e[12],1804603682,7),o=l(o,n,r,i,e[13],4254626195,12),i=l(i,o,n,r,e[14],2792965006,17),n=u(n,r=l(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=u(o,n,r,i,e[6],3225465664,9),i=u(i,o,n,r,e[11],643717713,14),r=u(r,i,o,n,e[0],3921069994,20),n=u(n,r,i,o,e[5],3593408605,5),o=u(o,n,r,i,e[10],38016083,9),i=u(i,o,n,r,e[15],3634488961,14),r=u(r,i,o,n,e[4],3889429448,20),n=u(n,r,i,o,e[9],568446438,5),o=u(o,n,r,i,e[14],3275163606,9),i=u(i,o,n,r,e[3],4107603335,14),r=u(r,i,o,n,e[8],1163531501,20),n=u(n,r,i,o,e[13],2850285829,5),o=u(o,n,r,i,e[2],4243563512,9),i=u(i,o,n,r,e[7],1735328473,14),n=d(n,r=u(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=d(o,n,r,i,e[8],2272392833,11),i=d(i,o,n,r,e[11],1839030562,16),r=d(r,i,o,n,e[14],4259657740,23),n=d(n,r,i,o,e[1],2763975236,4),o=d(o,n,r,i,e[4],1272893353,11),i=d(i,o,n,r,e[7],4139469664,16),r=d(r,i,o,n,e[10],3200236656,23),n=d(n,r,i,o,e[13],681279174,4),o=d(o,n,r,i,e[0],3936430074,11),i=d(i,o,n,r,e[3],3572445317,16),r=d(r,i,o,n,e[6],76029189,23),n=d(n,r,i,o,e[9],3654602809,4),o=d(o,n,r,i,e[12],3873151461,11),i=d(i,o,n,r,e[15],530742520,16),n=h(n,r=d(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=h(o,n,r,i,e[7],1126891415,10),i=h(i,o,n,r,e[14],2878612391,15),r=h(r,i,o,n,e[5],4237533241,21),n=h(n,r,i,o,e[12],1700485571,6),o=h(o,n,r,i,e[3],2399980690,10),i=h(i,o,n,r,e[10],4293915773,15),r=h(r,i,o,n,e[1],2240044497,21),n=h(n,r,i,o,e[8],1873313359,6),o=h(o,n,r,i,e[15],4264355552,10),i=h(i,o,n,r,e[6],2734768916,15),r=h(r,i,o,n,e[13],1309151649,21),n=h(n,r,i,o,e[4],4149444226,6),o=h(o,n,r,i,e[11],3174756917,10),i=h(i,o,n,r,e[2],718787259,15),r=h(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a},{"hash-base":39,inherits:41,"safe-buffer":107}],58:[function(e,t,n){var r=1e3,i=60*r,o=60*i,s=24*o,a=365.25*s;function c(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){t=t||{};var n,l=typeof e;if("string"===l&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?c(n=e,s,"day")||c(n,o,"hour")||c(n,i,"minute")||c(n,r,"second")||n+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=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))}},{}],59:[function(e,t,n){(function(e){(function(){"use strict";var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=n=r.fetch,r.fetch&&(n.default=r.fetch.bind(r)),n.Headers=r.Headers,n.Request=r.Request,n.Response=r.Response}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],60:[function(e,t,n){"use strict";var r=e("./lib/Client"),i=e("./lib/sasl"),o=e("node-xmpp-core");t.exports=r,t.exports.Client=r,t.exports.SASL=i,o.exportCoreUtils(t.exports)},{"./lib/Client":61,"./lib/sasl":69,"node-xmpp-core":72}],61:[function(e,t,n){(function(n){(function(){"use strict";var r,i,o,s=e("./session"),a=e("node-xmpp-core"),c=a.JID,l=a.Stanza,u=a.Element,d=a.inherits,h=e("./sasl"),p=e("./authentication/anonymous"),f=e("./authentication/plain"),m=e("./authentication/digestmd5"),g=e("./authentication/xoauth2"),v=e("./authentication/external"),y=e("child_process").exec,b=e("debug")("xmpp:client"),S=e("path"),C="urn:ietf:params:xml:ns:xmpp-sasl",_="urn:ietf:params:xml:ns:xmpp-bind";if(void 0===w)var w=null,T=null;function E(e){this.options={},e&&(this.options=e),this.availableSaslMechanisms=[g,v,m,f,p],!1!==this.options.autostart&&this.connect()}"function"==typeof w?r=function(e){return T(e)}:(o=e("buffer").Buffer,r=function(e){return new o(e,"base64").toString("utf8")}),"function"==typeof T?i=function(e){return w(e)}:(o=e("buffer").Buffer,i=function(e){return new o(e,"utf8").toString("base64")}),d(E,s),E.NS_CLIENT="jabber:client",E.prototype.connect=function(){if(this.options.bosh&&this.options.bosh.prebind)return this._connectViaBosh();this._useStandardConnect()},E.prototype._useStandardConnect=function(){this.options.xmlns="jabber:client",delete this.did_bind,delete this.did_session,this.state=0,this.on("end",function(){this.state=0,delete this.did_bind,delete this.did_session}),s.call(this,this.options),this.options.jid=this.jid,this.connection.on("disconnect",function(e){this.state=0,this.connection.reconnect||(e&&this.emit("error",e),this.emit("offline")),delete this.did_bind,delete this.did_session}.bind(this)),this.options.preferred?this.preferredSaslMechanism=this.options.preferred:this.preferredSaslMechanism="DIGEST-MD5";var e=h.detectMechanisms(this.options,this.availableSaslMechanisms);this.availableSaslMechanisms=e},E.prototype._connectViaBosh=function(){b("load bosh prebind");var e=this.options.bosh.prebind;delete this.options.bosh.prebind;var t="node "+S.join(n,"prebind.js")+" "+encodeURI(JSON.stringify(this.options));y(t,function(t,n,r){if(t)e(t,null);else{var i=n.match(/rid:+[ 0-9]*/i),o=n.match(/sid:+[ a-z+'"-_A-Z+0-9]*/i);if(!i||!o)return e(r);if(i=i[0].split(":")[1].trim(),o=o[0].split(":")[1].replace("'","").replace("'","").trim(),i&&o)return e(null,{rid:i,sid:o});e(r)}})},E.prototype.onStanza=function(e){return"stream:error"===e.name?this._handleStreamError(e):5!==this.state&&e.is("features")?(this.streamFeatures=e,this.useFeatures()):void this._handleStanza(e)},E.prototype._handleStanza=function(e){switch(this.state){case 5:this.emit("stanza",e);break;case 0:this.emit("stanza:preauth",e);break;case 1:this._handleAuthState(e);break;case 3:e.is("iq")&&"bind"===e.attrs.id&&this._handleBindState(e);break;case 4:!0===e.is("iq")&&"sess"===e.attrs.id&&this._handleSessionState(e)}},E.prototype._handleStreamError=function(e){this.reconnect||this.emit("error",e)},E.prototype._handleSessionState=function(e){"result"===e.attrs.type?(this.state=2,this.did_session=!0,this.useFeatures()):this.emit("error","Cannot bind resource")},E.prototype._handleBindState=function(e){if("result"===e.attrs.type){this.state=2,this.did_bind=!0;var t=e.getChild("bind",_);t&&t.getChild("jid")&&(this.jid=new c(t.getChild("jid").getText())),this.useFeatures()}else this.emit("error","Cannot bind resource")},E.prototype._handleAuthState=function(e){if(e.is("challenge",C)){var t=r(e.getText()),n=i(this.mech.challenge(t)),o=new u("response",{xmlns:C}).t(n);this.send(o)}else e.is("success",C)?(this.mech=null,this.state=2,this.emit("auth")):this.emit("error","XMPP authentication failure")},E.prototype._handlePreAuthState=function(){this.state=1;var e=this.streamFeatures.getChild("mechanisms",C).getChildren("mechanism",C).map(function(e){return e.getText()});if(this.mech=h.selectMechanism(e,this.preferredSaslMechanism,this.availableSaslMechanisms),this.mech){this.mech.authzid=this.jid.bare().toString(),this.mech.authcid=this.jid.local,this.mech.password=this.password,this.mech.api_key=this.api_key,this.mech.access_token=this.access_token,this.mech.oauth2_token=this.oauth2_token,this.mech.oauth2_auth=this.oauth2_auth,this.mech.realm=this.jid.domain,this.actAs&&(this.mech.actAs=this.actAs.user),this.mech.digest_uri="xmpp/"+this.jid.domain;var t=i(this.mech.auth()),n=this.mech.authAttrs();n.xmlns=C,n.mechanism=this.mech.name,this.send(new u("auth",n).t(t))}else this.emit("error",new Error("No usable SASL mechanism"))},E.prototype.useFeatures=function(){if(0===this.state&&this.register)delete this.register,this.doRegister();else if(0===this.state&&this.streamFeatures.getChild("mechanisms",C))this._handlePreAuthState();else if(2===this.state&&!this.did_bind&&this.streamFeatures.getChild("bind",_)){this.state=3;var e=new l("iq",{type:"set",id:"bind"}).c("bind",{xmlns:_});this.jid.resource&&e.c("resource").t(this.jid.resource),this.send(e)}else if(2===this.state&&!this.did_session&&this.streamFeatures.getChild("session","urn:ietf:params:xml:ns:xmpp-session")){this.state=4;var t=new l("iq",{type:"set",to:this.jid.domain,id:"sess"}).c("session",{xmlns:"urn:ietf:params:xml:ns:xmpp-session"});this.send(t)}else 2===this.state&&(this.state=5,this.emit("online",{jid:this.jid}))},E.prototype.doRegister=function(){var e="register"+Math.ceil(99999*Math.random()),t=new l("iq",{type:"set",id:e,to:this.jid.domain}).c("query",{xmlns:"jabber:iq:register"}).c("username").t(this.jid.local).up().c("password").t(this.password);this.send(t);var n=this,r=function(t){t.is("iq")&&t.attrs.id===e&&(n.removeListener("stanza",r),"result"===t.attrs.type?n.useFeatures():n.emit("error",new Error("Registration error")))};this.on("stanza:preauth",r)},E.prototype.getSaslMechanisms=function(){return this.availableSaslMechanisms},E.prototype.clearSaslMechanism=function(){this.availableSaslMechanisms=[]},E.prototype.registerSaslMechanism=function(e){-1===this.availableSaslMechanisms.indexOf(e)&&this.availableSaslMechanisms.push(e)},E.prototype.unregisterSaslMechanism=function(e){var t=this.availableSaslMechanisms.indexOf(e);t>=0&&(this.availableSaslMechanisms=this.availableSaslMechanisms.splice(t,1))},t.exports=E}).call(this)}).call(this,"/node_modules/node-xmpp-client/lib")},{"./authentication/anonymous":62,"./authentication/digestmd5":63,"./authentication/external":64,"./authentication/plain":66,"./authentication/xoauth2":67,"./sasl":69,"./session":70,buffer:27,child_process:26,debug:35,"node-xmpp-core":72,path:25}],62:[function(e,t,n){"use strict";var r=e("./mechanism");function i(){}(0,e("node-xmpp-core").inherits)(i,r),i.prototype.name="ANONYMOUS",i.prototype.auth=function(){return this.authzid},i.prototype.match=function(){return!0},t.exports=i},{"./mechanism":65,"node-xmpp-core":72}],63:[function(e,t,n){"use strict";var r=e("node-xmpp-core").inherits,i=e("./mechanism"),o=e("crypto"),s=e("md5.js");function a(e,t){return(o.createHash?o.createHash("md5"):new s).update(e,"binary").digest(t||"binary")}function c(e){return a(e,"hex")}function l(e){for(var t={};e;){var n;(n=/^(.+?)=(.*?[^\\]),\s*(.*)/.exec(e))?(t[n[1]]=n[2].replace(/"/g,""),e=n[3]):(n=/^(.+?)=(.+?),\s*(.*)/.exec(e))?(t[n[1]]=n[2],e=n[3]):(n=/^(.+?)="(.*?[^\\])"$/.exec(e))?(t[n[1]]=n[2],e=n[3]):(n=/^(.+?)=(.+?)$/.exec(e))?(t[n[1]]=n[2],e=n[3]):e=null}return t}function u(e){var t="";for(var n in e){var r=e[n];r&&(t+=","+n+'="'+r+'"')}return t.substr(1)}function d(){for(var e="",t=0;t<8;t++)e+=String.fromCharCode(48+Math.ceil(10*Math.random()));return e}function h(){this.nonce_count=0,this.cnonce=d(),this.authcid=null,this.actAs=null,this.realm=null,this.password=null}r(h,i),h.prototype.name="DIGEST-MD5",h.prototype.auth=function(){return""},h.prototype.getNC=function(){return function(e,t,n){for(;e.length<t;)e=n+e;return e}(this.nonce_count.toString(),8,"0")},h.prototype.responseValue=function(e){var t,n=l(e);if(n.realm&&(this.realm=n.realm),n.nonce&&n.qop){this.nonce_count++;var r=a(this.authcid+":"+this.realm+":"+this.password)+":"+n.nonce+":"+this.cnonce;this.actAs&&(r+=":"+this.actAs);var i="AUTHENTICATE:"+this.digest_uri;"auth-int"!==n.qop&&"auth-conf"!==n.qop||(i+=":00000000000000000000000000000000"),t=c(c(r)+":"+n.nonce+":"+this.getNC()+":"+this.cnonce+":"+n.qop+":"+c(i))}return t},h.prototype.challenge=function(e){var t,n=l(e);if(n.realm&&(this.realm=n.realm),n.nonce&&n.qop){var r=this.responseValue(e);t={username:this.authcid,realm:this.realm,nonce:n.nonce,cnonce:this.cnonce,nc:this.getNC(),qop:n.qop,"digest-uri":this.digest_uri,response:r,charset:"utf-8"},this.actAs&&(t.authzid=this.actAs)}else if(n.rspauth)return"";return u(t)},h.prototype.serverChallenge=function(){var e={realm:""};return this.nonce=e.nonce=d(),e.qop="auth",this.charset=e.charset="utf-8",e.algorithm="md5-sess",u(e)},h.prototype.response=function(e){var t=l(e);return this.authcid=t.username,t.nonce===this.nonce&&(!!t.cnonce&&(this.cnonce=t.cnonce,this.charset===t.charset&&(this.response=t.response,!0)))},h.prototype.match=function(e){return!!e.password},t.exports=h},{"./mechanism":65,crypto:25,"md5.js":57,"node-xmpp-core":72}],64:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="EXTERNAL",r.prototype.auth=function(){return this.authzid},r.prototype.match=function(e){return!!e.credentials},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],65:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("events").EventEmitter),r.prototype.authAttrs=function(){return{}},t.exports=r},{events:37,"node-xmpp-core":72}],66:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="PLAIN",r.prototype.auth=function(){return this.authzid+"\0"+this.authcid+"\0"+this.password},r.prototype.match=function(e){return!!e.password},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],67:[function(e,t,n){"use strict";function r(){this.oauth2_auth=null,this.authzid=null}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="X-OAUTH2",r.prototype.NS_GOOGLE_AUTH="http://www.google.com/talk/protocol/auth",r.prototype.auth=function(){return"\0"+this.authzid+"\0"+this.oauth2_token},r.prototype.authAttrs=function(){return{"auth:service":"oauth2","xmlns:auth":this.oauth2_auth}},r.prototype.match=function(e){return e.oauth2_auth===r.prototype.NS_GOOGLE_AUTH},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],68:[function(e,t,n){(function(n){(function(){"use strict";var r=e("events").EventEmitter,i=e("node-xmpp-core"),o=i.inherits,s=i.ltx,a=e("request"),c=e("debug")("xmpp:client:bosh");function l(e){var t=this;if(r.call(this),this.boshURL=e.bosh.url,this.jid=e.jid,this.wait=e.bosh.wait||60,this.xmlnsAttrs={xmlns:"http://jabber.org/protocol/httpbind","xmlns:xmpp":"urn:xmpp:xbosh","xmlns:stream":"http://etherx.jabber.org/streams"},e.xmlns)for(var i in e.xmlns)i?this.xmlnsAttrs["xmlns:"+i]=e.xmlns[i]:this.xmlnsAttrs.xmlns=e.xmlns[i];this.currentRequests=0,this.queue=[],this.rid=Math.ceil(9999999999*Math.random()),this.request({to:this.jid.domain,ver:"1.6",wait:this.wait,hold:"1",content:this.contentType,"xmpp:version":"1.0"},[],function(e,r){e?t.emit("error",e):r&&r.attrs&&(t.sid=r.attrs.sid,t.maxRequests=parseInt(r.attrs.requests,10)||2,t.sid&&t.maxRequests>0?(t.emit("connect"),t.processResponse(r),n.nextTick(t.mayRequest.bind(t))):t.emit("error","Invalid parameters"))})}o(l,r),l.prototype.contentType="text/xml; charset=utf-8",l.prototype.send=function(e){this.queue.push(e.root()),n.nextTick(this.mayRequest.bind(this))},l.prototype.startStream=function(){var e=this;this.rid++,this.request({to:this.jid.domain,"xmpp:restart":"true"},[],function(t,r){t?(e.emit("error",t),e.emit("disconnect"),e.emit("end"),delete e.sid,e.emit("close")):(e.streamOpened=!0,r&&e.processResponse(r),n.nextTick(e.mayRequest.bind(e)))})},l.prototype.processResponse=function(e){if(c("process bosh server response "+e.toString()),e&&e.children)for(var t=0;t<e.children.length;t++){var n=e.children[t];n.name&&n.attrs&&n.children&&this.emit("stanza",n)}e&&"terminate"===e.attrs.type&&(this.shutdown&&!e.attrs.condition||this.emit("error",new Error(e.attrs.condition||"Session terminated")),this.emit("disconnect"),this.emit("end"),this.emit("close"))},l.prototype.mayRequest=function(){if(this.sid&&(0===this.currentRequests||this.queue.length>0&&this.currentRequests<this.maxRequests)){var e=this.queue;this.queue=[],this.rid++,this.request({},e,function(e,t){e?(this.emit("error",e),this.emit("disconnect"),this.emit("end"),delete this.sid,this.emit("close")):(t&&this.processResponse(t),n.nextTick(this.mayRequest.bind(this)))}.bind(this))}},l.prototype.end=function(e){typeof(e=e||[])!==Array&&(e=[e]),e=this.queue.concat(e),this.shutdown=!0,this.queue=[],this.rid++,this.request({type:"terminate"},e,function(e,t){e||t&&this.processResponse(t),this.emit("disconnect"),this.emit("end"),delete this.sid,this.emit("close")}.bind(this))},l.prototype.maxHTTPRetries=5,l.prototype.request=function(e,t,n,r){var i=this;for(var o in r=r||0,e.rid=this.rid.toString(),this.sid&&(e.sid=this.sid),this.xmlnsAttrs)e[o]=this.xmlnsAttrs[o];for(var l=new s.Element("body",e),u=0;u<t.length;u++)l.cnode(t[u]);c("send bosh request:"+l.toString()),a({uri:this.boshURL,method:"POST",headers:{"Content-Type":this.contentType},body:l.toString()},function(o,a,c){if(i.currentRequests--,o)return r<i.maxHTTPRetries?i.request(e,t,n,r+1):n(o);if(a.statusCode<200||a.statusCode>=400)return n(new Error("HTTP status "+a.statusCode));var l;try{l=s.parse(c)}catch(e){return n(e)}l&&"terminate"===l.attrs.type&&l.attrs.condition?n(new Error(l.attrs.condition)):l?n(null,l):n(new Error("no <body/>"))}),this.currentRequests++},t.exports=l}).call(this)}).call(this,e("_process"))},{_process:89,debug:35,events:37,"node-xmpp-core":72,request:24}],69:[function(e,t,n){"use strict";var r=e("./authentication/mechanism");n.selectMechanism=function(e,t,n){var r,i=[],o={};return Array.isArray(n)&&(i=i.concat(n)),i.forEach(function(e){o[e.prototype.name]=e}),o[t]&&e.indexOf(t)>=0&&(r=o[t]),i.forEach(function(t){!r&&e.indexOf(t.prototype.name)>=0&&(r=t)}),r?new r:null},n.detectMechanisms=function(e,t){var n=[];return(t||[]).forEach(function(t){(0,t.prototype.match)(e)&&n.push(t)}),n},n.AbstractMechanism=r},{"./authentication/mechanism":65}],70:[function(e,t,n){(function(n){(function(){"use strict";var r=e("tls"),i=e("events").EventEmitter,o=e("node-xmpp-core"),s=o.inherits,a=o.Connection,c=o.JID,l=o.SRV,u=e("./bosh"),d=e("./websockets"),h=e("debug")("xmpp:client:session");function p(e){i.call(this),this.setOptions(e),e.websocket&&e.websocket.url?(h("start websocket connection"),this._setupWebsocketConnection(e)):e.bosh&&e.bosh.url?(h("start bosh connection"),this._setupBoshConnection(e)):(h("start socket connection"),this._setupSocketConnection(e))}s(p,i),p.prototype._setupSocketConnection=function(e){var t={xmlns:{"":e.xmlns},streamAttrs:{version:"1.0",to:this.jid.domain},serialized:e.serialized};for(var n in e)n in t||(t[n]=e[n]);if(this.connection=new a(t),this._addConnectionListeners(),e.host||e.port)this._socketConnectionToHost(e);else{if(!l)throw new Error("Cannot load SRV");this._performSrvLookup(e)}},p.prototype._socketConnectionToHost=function(e){var t=this;e.legacySSL?(this.connection.allowTLS=!1,this.connection.connect({socket:function(){return r.connect(e.port||5223,e.host||"localhost",e.credentials||{},function(){this.socket.authorized?t.emit("connect",this.socket):t.emit("error","unauthorized")}.bind(this))}})):(e.credentials&&(this.connection.credentials=r.createSecureContext(e.credentials)),e.disallowTLS&&(this.connection.allowTLS=!1),this.connection.listen({socket:function(){n.nextTick(function(){this.socket.connect(e.port||5222,e.host)}.bind(this));var t=e.socket;return e.socket=null,t}}))},p.prototype._performSrvLookup=function(e){if(e.legacySSL)throw new Error("LegacySSL mode does not support DNS lookups");e.credentials&&(this.connection.credentials=r.createSecureContext(e.credentials)),e.disallowTLS&&(this.connection.allowTLS=!1),this.connection.listen({socket:l.connect({socket:e.socket,services:["_xmpp-client._tcp"],domain:this.jid.domain,defaultPort:5222})})},p.prototype._setupBoshConnection=function(e){this.connection=new u({jid:this.jid,bosh:e.bosh}),this._addConnectionListeners(),this.connection.on("connected",function(){this.connection.startStream&&this.connection.startStream()}.bind(this))},p.prototype._setupWebsocketConnection=function(e){this.connection=new d({jid:this.jid,websocket:e.websocket}),this._addConnectionListeners(),this.connection.on("connected",function(){this.connection.startStream&&this.connection.startStream()}.bind(this))},p.prototype.setOptions=function(e){this.jid="string"==typeof e.jid?new c(e.jid):e.jid,this.password=e.password,this.preferredSaslMechanism=e.preferredSaslMechanism,this.api_key=e.api_key,this.access_token=e.access_token,this.oauth2_token=e.oauth2_token,this.oauth2_auth=e.oauth2_auth,this.register=e.register,"string"==typeof e.actAs?this.actAs=new c(e.actAs):this.actAs=e.actAs},p.prototype._addConnectionListeners=function(e){(e=e||this.connection).on("stanza",this.onStanza.bind(this)),e.on("drain",this.emit.bind(this,"drain")),e.on("end",this.emit.bind(this,"end")),e.on("close",this.emit.bind(this,"close")),e.on("error",this.emit.bind(this,"error")),e.on("connect",this.emit.bind(this,"connect")),e.on("reconnect",this.emit.bind(this,"reconnect")),e.on("disconnect",this.emit.bind(this,"disconnect")),e.startStream&&(e.on("connect",function(){e.startStream()}),this.on("auth",function(){e.startStream()}))},p.prototype.pause=function(){this.connection&&this.connection.pause&&this.connection.pause()},p.prototype.resume=function(){this.connection&&this.connection.resume&&this.connection.resume()},p.prototype.send=function(e){return!!this.connection&&this.connection.send(e)},p.prototype.end=function(){this.connection&&this.connection.end()},p.prototype.onStanza=function(){},t.exports=p}).call(this)}).call(this,e("_process"))},{"./bosh":68,"./websockets":71,_process:89,debug:35,events:37,"node-xmpp-core":72,tls:26}],71:[function(e,t,n){"use strict";var r=e("events").EventEmitter,i=e("node-xmpp-core"),o=i.Element,s=i.StreamParser,a=i.Connection,c=i.inherits,l=e("ws"),u=l.Server?l:window.WebSocket,d=e("debug")("xmpp:client:websocket"),h="urn:ietf:params:xml:ns:xmpp-framing";function p(e){r.call(this),this.url=e.websocket.url,this.jid=e.jid,this.xmlns={"":h},this.websocket=new u(this.url,["xmpp"],e.websocket.options),this.websocket.onopen=this.onopen.bind(this),this.websocket.onmessage=this.onmessage.bind(this),this.websocket.onclose=this.onclose.bind(this),this.websocket.onerror=this.onerror.bind(this)}c(p,r),p.prototype.maxStanzaSize=65535,p.prototype.xmppVersion="1.0",p.prototype.onopen=function(){this.startParser(),this.emit("connected")},p.prototype.startParser=function(){var e=this;this.parser=new s(this.maxStanzaSize),this.parser.on("start",function(t){for(var n in e.streamAttrs=t,e.streamNsAttrs={},t)"xmlns"!==n&&"xmlns:"!==n.substr(0,6)||(e.streamNsAttrs[n]=t[n]);e.emit("streamStart",t)}),this.parser.on("stanza",function(t){e.onStanza(t)}),this.parser.on("error",this.onerror.bind(this)),this.parser.on("end",function(){e.stopParser(),e.end()})},p.prototype.stopParser=function(){this.parser&&delete this.parser},p.prototype.onmessage=function(e){d("ws msg <--",e.data),e&&e.data&&this.parser&&this.parser.write(e.data)},p.prototype.onStanza=function(e){e.is("error",a.NS_STREAM)?this.emit("error",e):this.emit("stanza",e)},p.prototype.startStream=function(){var e={};for(var t in this.xmlns)this.xmlns.hasOwnProperty(t)&&(t?e["xmlns:"+t]=this.xmlns[t]:e.xmlns=this.xmlns[t]);this.xmppVersion&&(e.version=this.xmppVersion),this.streamTo&&(e.to=this.streamTo),this.jid&&(e.to=this.jid.domain),this.send(new o("open",e)),this.streamOpened=!0},p.prototype.send=function(e){e.root&&(e=e.root()),!e.attrs.xmlns&&(e.is("iq")||e.is("presence")||e.is("message"))&&(e.attrs.xmlns="jabber:client"),e=e.toString(),d("ws send --\x3e",e),this.websocket.send(e)},p.prototype.onclose=function(){this.emit("disconnect"),this.emit("close")},p.prototype.end=function(){this.send(new o("close",{xmlns:h})),this.emit("disconnect"),this.emit("end"),this.websocket&&this.websocket.close()},p.prototype.onerror=function(e){this.emit("error",e)},t.exports=p},{debug:35,events:37,"node-xmpp-core":72,ws:25}],72:[function(e,t,n){"use strict";var r=e("./lib/Connection"),i=e("@xmpp/streamparser"),o=e("@xmpp/jid"),s=e("@xmpp/xml"),a=e("inherits");n.SRV=e("./lib/SRV"),n.exportCoreUtils=function(e){e.Connection=r,e.StreamParser=i,e.JID=o,e.inherits=a,e.stanza=s,e.Stanza=s.Stanza,e.createStanza=s.createStanza,e.IQ=s.IQ,e.Presence=s.Presence,e.Message=s.Message,e.Parser=s.Parser,e.parse=s.parse,e.ltx=s.ltx,e.createElement=s.createElement,e.Element=s.Element,e.escapeXML=s.escapeXML,e.escapeXMLText=s.escapeXMLText},n.exportCoreUtils(n)},{"./lib/Connection":73,"./lib/SRV":25,"@xmpp/jid":74,"@xmpp/streamparser":7,"@xmpp/xml":78,inherits:41}],73:[function(e,t,n){"use strict";var r=e("net"),i=e("events").EventEmitter,o=e("inherits"),s=e("@xmpp/xml").Element,a=e("reconnect-core"),c=e("@xmpp/streamparser"),l=e("node-xmpp-tls-connect"),u=e("debug")("xmpp:connection"),d=e("lodash.assign"),h="http://etherx.jabber.org/streams",p="urn:ietf:params:xml:ns:xmpp-streams",f=1e3,m=3e4,g="stream:stream",v="</stream:stream>";function y(e){i.call(this),this.streamAttrs=e&&e.streamAttrs||{},this.xmlns=e&&e.xmlns||{},this.xmlns.stream=h,this.streamOpen=e&&e.streamOpen||g,this.streamClose=e&&e.streamClose||v,this.rejectUnauthorized=!(!e||!e.rejectUnauthorized),this.serialized=!(!e||!e.serialized),this.requestCert=!(!e||!e.requestCert),this.servername=e&&e.servername,this.boundOnData=this.onData.bind(this),this.boundOnClose=this.onClose.bind(this),this.boundEmitData=this.emit.bind(this,"data"),this.boundEmitDrain=this.emit.bind(this,"drain"),this._setupSocket(function(e,t){var n=d({},t);return n.initialDelay=t&&(t.initialReconnectDelay||t.reconnectDelay)||f,n.maxDelay=t&&t.maxReconnectDelay||m,n.immediate=t&&t.socket&&"function"!=typeof t.socket,n.type=t&&t.delayType,n.emitter=e,n}(this,e)),this.once("reconnect",function(){this.reconnect=e&&e.reconnect})}o(y,i),y.prototype.NS_XMPP_TLS="urn:ietf:params:xml:ns:xmpp-tls",y.NS_STREAM=h,y.prototype.NS_XMPP_STREAMS=p,y.prototype.allowTLS=!0,y.prototype._setupSocket=function(e){u("setup socket");var t={},n=a(function(e){var i=this.socket;return"on"===e.preserve?(e.preserve=t,t=e):e=t=e.preserve?e.preserve:e||t,"function"==typeof e.socket?(u("use lazy socket"),this.socket=e.socket.call(this)):(u("use standard socket"),this.socket=e.socket,e.socket=null,this.socket&&this.once("connect",function(){n.options.immediate=!1})),this.socket=this.socket||new r.Socket,i!==this.socket&&this.setupStream(),this.socket}.bind(this));n(n.options=e);var i=this.end;this.end=this.disconnect=function(){this.closeStream(),i()},this.on("connection",function(){this.parser||this.startParser()}),this.on("end",function(){t={}})},y.prototype.setupStream=function(){u("setup stream"),this.socket.on("end",this.onEnd.bind(this)),this.socket.on("data",this.boundOnData),this.socket.on("close",this.boundOnClose),this.socket.on("data",this.boundEmitData),this.socket.on("drain",this.boundEmitDrain),this.socket.on("error",function(){}),this.socket.serializeStanza||(this.serialized?this.socket.serializeStanza=function(e,t){e.write(function(e){t(e)})}:this.socket.serializeStanza=function(e,t){t(e.toString())})},y.prototype.pause=function(){this.socket.pause&&this.socket.pause()},y.prototype.resume=function(){this.socket.resume&&this.socket.resume()},y.prototype.send=function(e){if(this.socket&&this.streamOpened){if(this.socket.writable){u("send: "+e.toString());var t=!0;if(e.root){var n=this.rmXmlns(e.root());this.socket.serializeStanza(n,function(e){t=this.write(e)}.bind(this.socket))}else t=this.socket.write(e);return t}this.socket.end()}},y.prototype.startParser=function(){var e=this;this.parser=new c(this.maxStanzaSize),this.parser.on("streamStart",function(t){for(var n in e.streamNsAttrs={},t)"xmlns"!==n&&"xmlns:"!==n.substr(0,6)||(e.streamNsAttrs[n]=t[n]);e.emit("streamStart",t)}),this.parser.on("stanza",function(t){e.onStanza(e.addStreamNs(t))}),this.parser.on("error",function(t){e.error(t.condition||"internal-server-error",t.message)}),this.parser.once("end",function(){e.stopParser(),e.reconnect?e.once("reconnect",e.startParser.bind(e)):e.end()})},y.prototype.stopParser=function(){if(this.parser){var e=this.parser;this.parser=null,e.end()}},y.prototype.openStream=function(){var e={};for(var t in this.xmlns)this.xmlns.hasOwnProperty(t)&&(t?e["xmlns:"+t]=this.xmlns[t]:e.xmlns=this.xmlns[t]);for(t in this.streamAttrs)this.streamAttrs.hasOwnProperty(t)&&(e[t]=this.streamAttrs[t]);this.streamTo&&(e.to=this.streamTo);var n,r=new s(this.streamOpen,e);if("stream:stream"===r.name){r.t(" ");var i=r.toString();n=i.substr(0,i.indexOf(" </stream:stream>"))}else n=r.toString();this.streamOpened=!0,this.send(n)},y.prototype.startStream=y.prototype.openStream,y.prototype.closeStream=function(){this.send(this.streamClose),this.streamOpened=!1},y.prototype.endStream=y.prototype.closeStream,y.prototype.onData=function(e){u("receive: "+e.toString("utf8")),this.parser&&this.parser.write(e)},y.prototype.setSecure=function(e,t,n){this.socket.removeListener("data",this.boundOnData),this.socket.removeListener("data",this.boundEmitData),this.socket.removeListener("drain",this.boundEmitDrain),this.socket.removeListener("close",this.boundOnClose),this.socket.clearTimer&&this.socket.clearTimer();var r=l({socket:this.socket,rejectUnauthorized:this.rejectUnauthorized,credentials:e||this.credentials,requestCert:this.requestCert,isServer:!!t,servername:t&&n},function(){this.isSecure=!0,this.once("disconnect",function(){this.isSecure=!1}),r.emit("connect",r)}.bind(this));r.on("clientError",this.emit.bind(this,"error")),this.reconnect||(this.reconnect=!0,this.once("reconnect",function(){this.reconnect=!1})),this.stopParser(),this.listen({socket:r,preserve:"on"})},y.prototype.onStanza=function(e){if(e.is("error",h)){var t=new Error(""+function e(t){return t.children?t.children.reduce(function(t,n){return t+e(n)},""):t}(e));t.stanza=e,this.socket.emit("error",t)}else e.is("features",this.NS_STREAM)&&this.allowTLS&&!this.isSecure&&e.getChild("starttls",this.NS_XMPP_TLS)?this.send(new s("starttls",{xmlns:this.NS_XMPP_TLS})):this.allowTLS&&e.is("proceed",this.NS_XMPP_TLS)?this.setSecure():this.emit("stanza",e)},y.prototype.addStreamNs=function(e){for(var t in this.streamNsAttrs)e.attrs[t]||"xmlns"===t&&this.streamNsAttrs[t]===this.xmlns[""]||(e.attrs[t]=this.streamNsAttrs[t]);return e},y.prototype.rmXmlns=function(e){for(var t in this.xmlns){var n=t?"xmlns:"+t:"xmlns";e.attrs[n]===this.xmlns[t]&&(e.attrs[n]=null)}return e},y.prototype.onEnd=function(){this.closeStream(),this.reconnect||this.emit("end")},y.prototype.onClose=function(){this.reconnect||this.emit("close")},y.prototype.error=function(e,t){if(this.emit("error",new Error(t)),this.socket&&this.socket.writable){this.streamOpened||this.openStream();var n=new s("stream:error");n.c(e,{xmlns:p}),t&&n.c("text",{xmlns:p,"xml:lang":"en"}).t(t),this.send(n),this.end()}},t.exports=y},{"@xmpp/streamparser":7,"@xmpp/xml":78,debug:35,events:37,inherits:41,"lodash.assign":43,net:26,"node-xmpp-tls-connect":25,"reconnect-core":105}],74:[function(e,t,n){"use strict";var r=e("./lib/JID"),i=e("./lib/tag");t.exports=function(e,t,n){return Array.isArray(e)?i.apply(null,arguments):new r(e,t,n)},t.exports.JID=r,t.exports.tag=i,t.exports.equal=function(e,t){return e.equals(t)},t.exports.is=function(e){return e instanceof r}},{"./lib/JID":75,"./lib/tag":77}],75:[function(e,t,n){"use strict";var r=e("./escaping");function i(e,t,n){if(this._local=null,this.user=null,this._domain=null,this._resource=null,!e||t||n){if(!t)throw new Error("Argument error");this.setLocal(e),this.setDomain(t),this.setResource(n)}else this.parseJID(e)}i.prototype.parseJID=function(e){var t=e.indexOf("/");-1!==t&&(this.setResource(e.substr(t+1)),e=e.substr(0,t));var n=e.indexOf("@");-1!==n&&(this.setLocal(e.substr(0,n)),e=e.substr(n+1)),this.setDomain(e)},i.prototype.toString=function(e){var t=this._domain;return this._local&&(t=this.getLocal(e)+"@"+t),this._resource&&(t=t+"/"+this._resource),t},i.prototype.bare=function(){return this._resource?new i(this._local,this._domain,null):this},i.prototype.equals=function(e){return this._local===e._local&&this._domain===e._domain&&this._resource===e._resource},i.prototype.setLocal=function(e,t){return(t=t||r.detect(e))&&(e=r.escape(e)),this._local=e&&e.toLowerCase(),this.user=this._local,this},i.prototype.setUser=function(){console.log("JID.setUser: Use JID.setLocal instead"),this.setLocal.apply(this,arguments)},i.prototype.getUser=function(){return console.log("JID.getUser: Use JID.getLocal instead"),this.getLocal.apply(this,arguments)},i.prototype.getLocal=function(e){return(e=e||!1)?r.unescape(this._local):this._local},Object.defineProperty(i.prototype,"local",{get:i.prototype.getLocal,set:i.prototype.setLocal}),i.prototype.setDomain=function(e){return this._domain=e.toLowerCase(),this},i.prototype.getDomain=function(){return this._domain},Object.defineProperty(i.prototype,"domain",{get:i.prototype.getDomain,set:i.prototype.setDomain}),i.prototype.setResource=function(e){return this._resource=e,this},i.prototype.getResource=function(){return this._resource},Object.defineProperty(i.prototype,"resource",{get:i.prototype.getResource,set:i.prototype.setResource}),i.prototype.detectEscape=r.detectEscape,i.prototype.escapeLocal=r.escape,i.prototype.unescapeLocal=r.unescape,t.exports=i},{"./escaping":76}],76:[function(e,t,n){"use strict";t.exports.detect=function(e){return!!e&&-1!==e.replace(/\\20/g,"").replace(/\\22/g,"").replace(/\\26/g,"").replace(/\\27/g,"").replace(/\\2f/g,"").replace(/\\3a/g,"").replace(/\\3c/g,"").replace(/\\3e/g,"").replace(/\\40/g,"").replace(/\\5c/g,"").search(/\\| |"|&|'|\/|:|<|>|@/g)},t.exports.escape=function(e){return null===e?null:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40").replace(/\3a/g,"c3a")},t.exports.unescape=function(e){return null===e?null:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")}},{}],77:[function(e,t,n){"use strict";var r=e("./JID");t.exports=function(){for(var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n="",i=0;i<t.length;i++)n+=e[i],n+=t[i];return n+=e[e.length-1],new r(n)}},{"./JID":75}],78:[function(e,t,n){arguments[4][8][0].apply(n,arguments)},{"./lib/IQ":79,"./lib/Message":80,"./lib/Parser":81,"./lib/Presence":82,"./lib/Stanza":83,"./lib/createStanza":84,"./lib/parse":85,"./lib/tag":86,dup:8,ltx:44}],79:[function(e,t,n){arguments[4][9][0].apply(n,arguments)},{"./Stanza":83,dup:9,inherits:41}],80:[function(e,t,n){arguments[4][10][0].apply(n,arguments)},{"./Stanza":83,dup:10,inherits:41}],81:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{"./createStanza":84,dup:11,inherits:41,ltx:44}],82:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./Stanza":83,dup:12,inherits:41}],83:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,inherits:41,ltx:44}],84:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{"./Stanza":83,dup:14,ltx:44}],85:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./Parser":81,dup:15,ltx:44}],86:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./parse":85,dup:16,ltx:44}],87:[function(e,t,n){n.endianness=function(){return"LE"},n.hostname=function(){return"undefined"!=typeof location?location.hostname:""},n.loadavg=function(){return[]},n.uptime=function(){return 0},n.freemem=function(){return Number.MAX_VALUE},n.totalmem=function(){return Number.MAX_VALUE},n.cpus=function(){return[]},n.type=function(){return"Browser"},n.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},n.networkInterfaces=n.getNetworkInterfaces=function(){return{}},n.arch=function(){return"javascript"},n.platform=function(){return"browser"},n.tmpdir=n.tmpDir=function(){return"/tmp"},n.EOL="\n"},{}],88:[function(e,t,n){(function(e){(function(){"use strict";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,n,r,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick(function(){t.apply(null,o)})}}}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:89}],89:[function(e,t,n){var r,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!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:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var l,u=[],d=!1,h=-1;function p(){d&&l&&(d=!1,l.length?u=l.concat(u):h=-1,u.length&&f())}function f(){if(!d){var e=c(p);d=!0;for(var t=u.length;t;){for(l=u,u=[];++h<t;)l&&l[h].run();h=-1,t=u.length}l=null,d=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new m(e,t)),1!==u.length||d||c(f)},m.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=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,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}},{}],90:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":91}],91:[function(e,t,n){"use strict";var r=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=d;var o=Object.create(e("core-util-is"));o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(d,s);for(var c=i(a.prototype),l=0;l<c.length;l++){var u=c[l];d.prototype[u]||(d.prototype[u]=a.prototype[u])}function d(e){if(!(this instanceof d))return new d(e);s.call(this,e),a.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",h)}function h(){this.allowHalfOpen||this._writableState.ended||r.nextTick(p,this)}function p(e){e.end()}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(d.prototype,"destroyed",{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)}}),d.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},{"./_stream_readable":93,"./_stream_writable":95,"core-util-is":28,inherits:41,"process-nextick-args":88}],92:[function(e,t,n){"use strict";t.exports=o;var r=e("./_stream_transform"),i=Object.create(e("core-util-is"));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=e("inherits"),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":94,"core-util-is":28,inherits:41}],93:[function(e,t,n){(function(n,r){(function(){"use strict";var i=e("process-nextick-args");t.exports=b;var o,s=e("isarray");b.ReadableState=y;e("events").EventEmitter;var a=function(e,t){return e.listeners(t).length},c=e("./internal/streams/stream"),l=e("safe-buffer").Buffer,u=(void 0!==r?r:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var d=Object.create(e("core-util-is"));d.inherits=e("inherits");var h=e("util"),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var f,m=e("./internal/streams/BufferList"),g=e("./internal/streams/destroy");d.inherits(b,c);var v=["error","close","destroy","pause","resume"];function y(t,n){t=t||{};var r=n instanceof(o=o||e("./_stream_duplex"));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,s=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,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.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||e("./_stream_duplex"),!(this instanceof b))return new b(t);this._readableState=new y(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),c.call(this)}function S(e,t,n,r,i){var o,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,T(e)}(e,s)):(i||(o=function(e,t){var n;r=t,l.isBuffer(r)||r instanceof u||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),r?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):C(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?C(e,s,t,!1):x(e,s)):C(e,s,t,!1))):r||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(s)}function C(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&T(e)),x(e,t)}Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(e,t){this.push(null),t(e)},b.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=l.from(e,t),t=""),n=!0),S(this,e,t,!1,n)},b.prototype.unshift=function(e){return S(this,e,null,!0,!1)},b.prototype.isPaused=function(){return!1===this._readableState.flowing},b.prototype.setEncoding=function(t){return f||(f=e("string_decoder/").StringDecoder),this._readableState.decoder=new f(t),this._readableState.encoding=t,this};var _=8388608;function w(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>=_?e=_:(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 T(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(E,e):E(e))}function E(e){p("emit readable"),e.emit("readable"),N(e)}function x(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(R,e,t))}function R(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(p("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function k(e){p("readable nexttick read 0"),e.read(0)}function I(e,t){t.reading||(p("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),N(e),t.flowing&&!t.reading&&e.read(0)}function N(e){var t=e._readableState;for(p("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=l.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),0===(e-=s)){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function A(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function L(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}b.prototype.read=function(e){p("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?A(this):T(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&A(this),null;var r,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&p("length less than watermark",i=!0),t.ended||t.reading?p("reading or ended",i=!1):i&&(p("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=w(n,t))),null===(r=e>0?D(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&A(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},b.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,p("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:b;function l(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",v),e.removeListener("finish",y),e.removeListener("drain",d),e.removeListener("error",g),e.removeListener("unpipe",l),r.removeListener("end",u),r.removeListener("end",b),r.removeListener("data",m),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||d())}function u(){p("onend"),e.end()}o.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",l);var d=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,N(e))}}(r);e.on("drain",d);var h=!1;var f=!1;function m(t){p("ondata"),f=!1,!1!==e.write(t)||f||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==L(o.pipes,e))&&!h&&(p("false write response, pause",o.awaitDrain),o.awaitDrain++,f=!0),r.pause())}function g(t){p("onerror",t),b(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",y),b()}function y(){p("onfinish"),e.removeListener("close",v),b()}function b(){p("unpipe"),r.unpipe(e)}return r.on("data",m),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",g),e.once("close",v),e.once("finish",y),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},b.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=L(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},b.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&T(this):i.nextTick(k,this))}return n},b.prototype.addListener=b.prototype.on,b.prototype.resume=function(){var e=this._readableState;return e.flowing||(p("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(I,e,t))}(this,e)),this},b.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},b.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(p("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<v.length;o++)e.on(v[o],this.emit.bind(this,v[o]));return this._read=function(t){p("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(b.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),b._fromList=D}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":91,"./internal/streams/BufferList":96,"./internal/streams/destroy":97,"./internal/streams/stream":98,_process:89,"core-util-is":28,events:37,inherits:41,isarray:42,"process-nextick-args":88,"safe-buffer":99,"string_decoder/":100,util:25}],94:[function(e,t,n){"use strict";t.exports=s;var r=e("./_stream_duplex"),i=Object.create(e("core-util-is"));function o(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function s(e){if(!(this instanceof s))return new s(e);r.call(this,e),this._transformState={afterTransform:o.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",a)}function a(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){c(e,t,n)}):c(this,null,null)}function c(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}i.inherits=e("inherits"),i.inherits(s,r),s.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},s.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},s.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},s.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},s.prototype._destroy=function(e,t){var n=this;r.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},{"./_stream_duplex":91,"core-util-is":28,inherits:41}],95:[function(e,t,n){(function(n,r,i){(function(){"use strict";var o=e("process-nextick-args");function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}t.exports=y;var a,c=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?i:o.nextTick;y.WritableState=v;var l=Object.create(e("core-util-is"));l.inherits=e("inherits");var u={deprecate:e("util-deprecate")},d=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,p=(void 0!==r?r:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,m=e("./internal/streams/destroy");function g(){}function v(t,n){a=a||e("./_stream_duplex"),t=t||{};var r=n instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,l=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(l||0===l)?l:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var d=!1===t.decodeStrings;this.decodeStrings=!d,this.defaultEncoding=t.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 n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),T(e,t))}(e,n,r,t,i);else{var s=_(n);s||n.corked||n.bufferProcessing||!n.bufferedRequest||C(e,n),r?c(S,e,n,s,i):S(e,n,s,i)}}(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function y(t){if(a=a||e("./_stream_duplex"),!(f.call(y,this)||this instanceof a))return new y(t);this._writableState=new v(t,this),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)),d.call(this)}function b(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function S(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),T(e,t)}function C(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,b(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback;if(b(e,t,!1,t.objectMode?1:l.length,l,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function w(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),T(e,t)})}function T(e,t){var n=_(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(w,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}l.inherits(y,d),v.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(v.prototype,"buffer",{get:u.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]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===y&&(e&&e._writableState instanceof v)}})):f=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,n){var r,i=this._writableState,s=!1,a=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof p);return a&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=g),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(a||function(e,t,n,r){var i=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(r,s),i=!1),i}(this,i,e,n))&&(i.pendingcb++,s=function(e,t,n,r,i,o){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=t.objectMode?1:r.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:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else b(e,t,!1,a,r,i,o);return c}(this,i,a,e,t,n)),s},y.prototype.cork=function(){this._writableState.corked++},y.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||C(this,e))},y.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 TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,T(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":91,"./internal/streams/destroy":97,"./internal/streams/stream":98,_process:89,"core-util-is":28,inherits:41,"process-nextick-args":88,"safe-buffer":99,timers:112,"util-deprecate":113}],96:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("util");t.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}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=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}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);for(var t,n,i,o=r.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,i=a,t.copy(n,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":99,util:25}],97:[function(e,t,n){"use strict";var r=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(i,this,e)):r.nextTick(i,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,r.nextTick(i,n,e)):r.nextTick(i,n,e):t&&t(e)}),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)}}},{"process-nextick-args":88}],98:[function(e,t,n){t.exports=e("events").EventEmitter},{events:37}],99:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:27}],100:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=r.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 o(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&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.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,n=function(e,t,n){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!==n?n: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 c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?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-n))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}n.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.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}},{"safe-buffer":99}],101:[function(e,t,n){t.exports=e("./readable").PassThrough},{"./readable":102}],102:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":91,"./lib/_stream_passthrough.js":92,"./lib/_stream_readable.js":93,"./lib/_stream_transform.js":94,"./lib/_stream_writable.js":95}],103:[function(e,t,n){t.exports=e("./readable").Transform},{"./readable":102}],104:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":95}],105:[function(e,t,n){var r=e("events").EventEmitter,i=e("backoff"),o=function(){};t.exports=function(e){return function(t,n){n="function"==typeof t?t:n,t="object"==typeof t?t:{initialDelay:1e3,maxDelay:3e4},n||(n=t.onConnect);var s=t.emitter||new r;s.connected=!1,s.reconnect=!0,n&&s.on("connect",n);var a,c=(i[t.type]||i.fibonacci)(t);c.on("backoff",function(e,t){s.emit("backoff",e,t)});var l=o;function u(r,i){if(s.reconnect){l(),s.emit("reconnect",r,i);var u=e.apply(null,a);u!==s._connection&&s.emit("connection",u),s._connection=u,l=d,u.on("error",h).on("close",h).on("end",h),t.immediate||"Request"==u.constructor.name?(s.connected=!0,s.emit("connect",u),u.once("data",function(){c.reset()})):u.on("connect",p)}function d(e){l=o,u.removeListener("connect",p),u.removeListener("error",h),u.removeListener("close",h),u.removeListener("end",h),"Request"==u.constructor.name&&u.on("error",o)}function h(e){if(s.connected=!1,d(),s.emit("disconnect",e),s.reconnect)try{c.backoff()}catch(e){}}function p(){c.reset(),s.connected=!0,n&&u.removeListener("connect",n),s.emit("connect",u)}}return c.on("ready",u),s.connect=s.listen=function(){return this.reconnect=!0,c.reset(),a=[].slice.call(arguments),u(0,0),s},s.end=s.disconnect=function(){return s.reconnect=!1,s._connection&&s._connection.end(),s.emit("disconnect"),s},s}}},{backoff:17,events:37}],106:[function(e,t,n){"use strict";var r=e("sdp");function i(e,t,n,i,o){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":o||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var c="msid:"+(i?i.id:"-")+" "+a+"\r\n";s+="a="+c,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),s=r(t.parameters.apt,i);return o&&s&&o.name.toLowerCase()===s.name.toLowerCase()};return e.codecs.forEach(function(r){for(var o=0;o<t.codecs.length;o++){var s=t.codecs[o];if(r.name.toLowerCase()===s.name.toLowerCase()&&r.clockRate===s.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&s.parameters.apt&&!i(r,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(r.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function s(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function a(e,t){var n=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return n||e.addRemoteCandidate(t),!n}function c(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}t.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function l(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout(function(){t._dispatchEvent("track",o)})}var u=function(n){var i=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){i[e]=o[e].bind(o)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var s=n.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(u.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(u.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),u.prototype.onicecandidate=null,u.prototype.onaddstream=null,u.prototype.ontrack=null,u.prototype.onremovestream=null,u.prototype.onsignalingstatechange=null,u.prototype.oniceconnectionstatechange=null,u.prototype.onconnectionstatechange=null,u.prototype.onicegatheringstatechange=null,u.prototype.onnegotiationneeded=null,u.prototype.ondatachannel=null,u.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},u.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},u.prototype.getConfiguration=function(){return this._config},u.prototype.getLocalStreams=function(){return this.localStreams},u.prototype.getRemoteStreams=function(){return this.remoteStreams},u.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},u.prototype.addTrack=function(t,n){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw c("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},u.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},u.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw c("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},u.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},u.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},u.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},u.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},u.prototype._gather=function(t,n){var i=this,o=this.transceivers[n].iceGatherer;if(!o.onlocalcandidate){var s=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,c=!a||0===Object.keys(a).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),a.component=1,a.ufrag=o.getLocalParameters().usernameFragment;var l=r.writeCandidate(a);s.candidate=Object.assign(s.candidate,r.parseCandidate(l)),s.candidate.candidate=l,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var u=r.getMediaSections(i._localDescription.sdp);u[s.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=r.getDescription(i._localDescription.sdp)+u.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",s),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){o.onlocalcandidate(e)})},0)}},u.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},u.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},u.prototype._transceive=function(e,n,i){var s=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(s.encodings=e.sendEncodingParameters,s.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(s.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(s)),i&&e.rtpReceiver&&s.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?s.encodings=e.recvEncodingParameters:s.encodings=[{}],s.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(s.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(s.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(s))},u.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!s("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=r.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n}),i.transceivers.forEach(function(e,t){i._gather(e.mid,t)});else if("answer"===e.type){t=r.splitSections(i._remoteDescription.sdp),n=t.shift();var a=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var s=i.transceivers[t],c=s.iceGatherer,l=s.iceTransport,u=s.dtlsTransport,d=s.localCapabilities,h=s.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var p=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);a&&(f.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===l.state&&l.start(c,p,a?"controlling":"controlled"),"new"===u.state&&u.start(f));var m=o(d,h);i._transceive(s,m.codecs.length>0,!1)}})}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},u.prototype.setRemoteDescription=function(i){var u=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!s("setRemoteDescription",i.type,u.signalingState)||u._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+u.signalingState));var d={};u.remoteStreams.forEach(function(e){d[e.id]=e});var h=[],p=r.splitSections(i.sdp),f=p.shift(),m=r.matchPrefix(f,"a=ice-lite").length>0,g=r.matchPrefix(f,"a=group:BUNDLE ").length>0;u.usingBundle=g;var v=r.matchPrefix(f,"a=ice-options:")[0];return u.canTrickleIceCandidates=!!v&&v.substr(14).split(" ").indexOf("trickle")>=0,p.forEach(function(s,c){var l=r.splitLines(s),p=r.getKind(s),v=r.isRejected(s)&&0===r.matchPrefix(s,"a=bundle-only").length,y=l[0].substr(2).split(" ")[2],b=r.getDirection(s,f),S=r.parseMsid(s),C=r.getMid(s)||r.generateIdentifier();if(v||"application"===p&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))u.transceivers[c]={mid:C,kind:p,protocol:y,rejected:!0};else{var _,w,T,E,x,R,k,I,N;!v&&u.transceivers[c]&&u.transceivers[c].rejected&&(u.transceivers[c]=u._createTransceiver(p,!0));var D,A,O=r.parseRtpParameters(s);v||(D=r.getIceParameters(s,f),(A=r.getDtlsParameters(s,f)).role="client"),k=r.parseRtpEncodingParameters(s);var L=r.parseRtcpParameters(s),P=r.matchPrefix(s,"a=end-of-candidates",f).length>0,M=r.matchPrefix(s,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!v&&g&&c>0&&u.transceivers[c]&&(u._disposeIceAndDtlsTransports(c),u.transceivers[c].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[c].iceTransport=u.transceivers[0].iceTransport,u.transceivers[c].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[c].rtpSender&&u.transceivers[c].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[c].rtpReceiver&&u.transceivers[c].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),"offer"!==i.type||v){if("answer"===i.type&&!v){w=(_=u.transceivers[c]).iceGatherer,T=_.iceTransport,E=_.dtlsTransport,x=_.rtpReceiver,R=_.sendEncodingParameters,I=_.localCapabilities,u.transceivers[c].recvEncodingParameters=k,u.transceivers[c].remoteCapabilities=O,u.transceivers[c].rtcpParameters=L,M.length&&"new"===T.state&&(!m&&!P||g&&0!==c?M.forEach(function(e){a(_.iceTransport,e)}):T.setRemoteCandidates(M)),g&&0!==c||("new"===T.state&&T.start(w,D,"controlling"),"new"===E.state&&E.start(A)),!o(_.localCapabilities,_.remoteCapabilities).codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&_.sendEncodingParameters[0].rtx&&delete _.sendEncodingParameters[0].rtx,u._transceive(_,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!x||"sendrecv"!==b&&"sendonly"!==b?delete _.rtpReceiver:(N=x.track,S?(d[S.stream]||(d[S.stream]=new e.MediaStream),n(N,d[S.stream]),h.push([N,x,d[S.stream]])):(d.default||(d.default=new e.MediaStream),n(N,d.default),h.push([N,x,d.default])))}}else{(_=u.transceivers[c]||u._createTransceiver(p)).mid=C,_.iceGatherer||(_.iceGatherer=u._createIceGatherer(c,g)),M.length&&"new"===_.iceTransport.state&&(!P||g&&0!==c?M.forEach(function(e){a(_.iceTransport,e)}):_.iceTransport.setRemoteCandidates(M)),I=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(I.codecs=I.codecs.filter(function(e){return"rtx"!==e.name})),R=_.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,q=!1;if("sendrecv"===b||"sendonly"===b){if(q=!_.rtpReceiver,x=_.rtpReceiver||new e.RTCRtpReceiver(_.dtlsTransport,p),q)N=x.track,S&&"-"===S.stream||(S?(d[S.stream]||(d[S.stream]=new e.MediaStream,Object.defineProperty(d[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(N,"id",{get:function(){return S.track}}),j=d[S.stream]):(d.default||(d.default=new e.MediaStream),j=d.default)),j&&(n(N,j),_.associatedRemoteMediaStreams.push(j)),h.push([N,x,j])}else _.rtpReceiver&&_.rtpReceiver.track&&(_.associatedRemoteMediaStreams.forEach(function(t){var n,r,i=t.getTracks().find(function(e){return e.id===_.rtpReceiver.track.id});i&&(n=i,(r=t).removeTrack(n),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:n})))}),_.associatedRemoteMediaStreams=[]);_.localCapabilities=I,_.remoteCapabilities=O,_.rtpReceiver=x,_.rtcpParameters=L,_.sendEncodingParameters=R,_.recvEncodingParameters=k,u._transceive(u.transceivers[c],!1,q)}}}),void 0===u._dtlsRole&&(u._dtlsRole="offer"===i.type?"active":"passive"),u._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?u._updateSignalingState("have-remote-offer"):u._updateSignalingState("stable"),Object.keys(d).forEach(function(t){var n=d[t];if(n.getTracks().length){if(-1===u.remoteStreams.indexOf(n)){u.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){u._dispatchEvent("addstream",r)})}h.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&l(u,t,r,[n])})}}),h.forEach(function(e){e[2]||l(u,e[0],e[1],[])}),e.setTimeout(function(){u&&u.transceivers&&u.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},u.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},u.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},u.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},u.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},u.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},u.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter(function(e){return"audio"===e.kind}).length,s=n.transceivers.filter(function(e){return"video"===e.kind}).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(o=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(s=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--s<0&&(e.wantReceive=!1)});o>0||s>0;)o>0&&(n._createTransceiver("audio"),o--),s>0&&(n._createTransceiver("video"),s--);var l=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(i,o){var s=i.track,a=i.kind,c=i.mid||r.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(o,n.usingBundle));var l=e.RTCRtpSender.getCapabilities(a);t<15019&&(l.codecs=l.codecs.filter(function(e){return"rtx"!==e.name})),l.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),l.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var u=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];s&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=l,i.sendEncodingParameters=u}),"max-compat"!==n._config.bundlePolicy&&(l+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),l+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){l+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),l+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,l+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(l+="a=end-of-candidates\r\n"))});var u=new e.RTCSessionDescription({type:"offer",sdp:l});return Promise.resolve(u)},u.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var s=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(s+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n";var a=r.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach(function(e,r){if(!(r+1>a)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?s+="m=application 0 DTLS/SCTP 5000\r\n":s+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?s+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(s+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(s+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var l=o(e.localCapabilities,e.remoteCapabilities);!l.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,s+=i(e,l,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(s+="a=rtcp-rsize\r\n")}});var l=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(l)},u.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,o){if(!n._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var l=0;l<n.transceivers.length;l++)if(n.transceivers[l].mid===e.sdpMid){s=l;break}var u=n.transceivers[s];if(!u)return o(c("OperationError","Can not add ICE candidate"));if(u.rejected)return i();var d=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===d.protocol&&(0===d.port||9===d.port))return i();if(d.component&&1!==d.component)return i();if((0===s||s>0&&u.iceTransport!==n.transceivers[0].iceTransport)&&!a(u.iceTransport,d))return o(c("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n._remoteDescription.sdp))[s]+="a="+(d.type?h:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),(t=r.getMediaSections(n._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);i()})},u.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)}),!n)throw c("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])}),t})}}});var d=["createOffer","createAnswer"];return d.forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(d=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),u}},{sdp:108}],107:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:27}],108:[function(e,t,n){"use strict";var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},r.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},r.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?r.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},r.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},r.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},r.getCryptoParameters=function(e,t){return r.matchPrefix(e+t,"a=crypto:").map(r.parseCryptoLine)},r.getIceParameters=function(e,t){var n=r.matchPrefix(e+t,"a=ice-ufrag:")[0],i=r.matchPrefix(e+t,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substr(12),password:i.substr(10)}:null},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],s=r.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var a=r.parseRtpMap(s),c=r.matchPrefix(e,"a=fmtp:"+o+" ");switch(a.parameters=c.length?r.parseFmtp(c[0]):{},a.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(r.parseRtcpFb),t.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(a.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=a.length>0&&a[0].ssrc,l=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});l.length>0&&l[0].length>1&&l[0][0]===c&&(t=l[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(r.rtx={ssrc:t}),n.push(r),o&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var u=r.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=u})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=r.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.parseSctpDescription=function(e){var t,n=r.parseMLine(e),i=r.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var o=r.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:n.fmt,maxMessageSize:t};if(r.matchPrefix(e,"a=sctpmap:").length>0){var s=r.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:t}}},r.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t,n){var i=void 0!==t?t:2;return"v=0\r\no="+(n||"thisisadapterortc")+" "+(e||r.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var o=r.writeRtpDescription(e.kind,t);if(o+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),o},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},r.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=r.splitLines(e),n=0;n<t.length;n++)if(t[n].length<2||"="!==t[n].charAt(1))return!1;return!0},"object"==typeof t&&(t.exports=r)},{}],109:[function(e,t,n){t.exports=i;var r=e("events").EventEmitter;function i(){r.call(this)}e("inherits")(i,r),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(n.on("end",a),n.on("close",c));var s=!1;function a(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){n.removeListener("data",i),e.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",c),n.removeListener("error",l),e.removeListener("error",l),n.removeListener("end",u),n.removeListener("close",u),e.removeListener("close",u)}return n.on("error",l),e.on("error",l),n.on("end",u),n.on("close",u),e.on("close",u),e.emit("pipe",n),e}},{events:37,inherits:41,"readable-stream/duplex.js":90,"readable-stream/passthrough.js":101,"readable-stream/readable.js":102,"readable-stream/transform.js":103,"readable-stream/writable.js":104}],110:[function(e,t,n){var r;r=this,function(t){"use strict";const n=function(){if(void 0===globalThis.WebSocket)try{return e("ws")}catch(e){throw new Error('You must install the "ws" package to use Strophe in nodejs.')}return globalThis.WebSocket}(),r=function(){let t=globalThis.DOMParser;if(void 0===t)try{t=e("@xmldom/xmldom").DOMParser}catch(e){throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.')}return t}();function i(){if("undefined"==typeof document)try{return(new(0,e("@xmldom/xmldom").DOMImplementation)).createDocument("jabber:client","strophe",null)}catch(e){throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.')}return document.implementation.createDocument("jabber:client","strophe",null)}const o={HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},s={tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"]},a={ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8,REDIRECT:9,CONNTIMEOUT:10,BINDREQUIRED:11,ATTACHFAIL:12,RECONNECTING:13},c={NORMAL:1,TEXT:3,CDATA:4,FRAGMENT:11};function l(e,t){return new p(e,t)}function u(e){return new p("message",e)}function d(e){return new p("iq",e)}function h(e){return new p("presence",e)}class p{constructor(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=o.CLIENT:t||(t={xmlns:o.CLIENT})),this.nodeTree=w(e,t),this.node=this.nodeTree}tree(){return this.nodeTree}toString(){return N(this.nodeTree)}up(){return this.node=this.node.parentElement,this}root(){return this.node=this.nodeTree,this}attrs(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null!=e[t]?this.node.setAttribute(t,e[t].toString()):this.node.removeAttribute(t));return this}c(e,t,n){const r=w(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this}cnode(e){let t;const n=C();try{t=void 0!==n.importNode}catch(e){t=!1}const r=t?n.importNode(e,!0):k(e);return this.node.appendChild(r),this.node=r,this}t(e){const t=_(e);return this.node.appendChild(t),this}h(e){const t=C().createElement("body");t.innerHTML=e;const n=R(t);for(;n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}}function f(e){let t="";const n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=0&&n<=127?t+=e.charAt(r):n>2047?(t+=String.fromCharCode(224|n>>12&15),t+=String.fromCharCode(128|n>>6&63),t+=String.fromCharCode(128|n>>0&63)):(t+=String.fromCharCode(192|n>>6&31),t+=String.fromCharCode(128|n>>0&63))}return t}function m(e,t){const n=new Uint8Array(e),r=new Uint8Array(t),i=new Uint8Array(e.byteLength);for(let t=0;t<e.byteLength;t++)i[t]=n[t]^r[t];return i.buffer}function g(e){let t="";const n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function v(e){var t;return null===(t=Uint8Array.from(atob(e),e=>e.charCodeAt(0)))||void 0===t?void 0:t.buffer}function y(e){return(new TextEncoder).encode(e).buffer}function b(e){"undefined"==typeof document&&V.log(V.LogLevel.ERROR,"addCookies: not adding any cookies, since there's no document object"),e=e||{};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n="",r="",i="";const o=e[t],s="object"==typeof o,a=escape(unescape(s?o.value:o));s&&(n=o.expires?";expires="+o.expires:"",r=o.domain?";domain="+o.domain:"",i=o.path?";path="+o.path:""),document.cookie=t+"="+a+n+r+i}}let S=null;function C(){return S||(S=i()),S}function _(e){return C().createTextNode(e)}function w(e,t,n){if(!e)return null;const r=C().createElement(e);if(!n||"string"!=typeof n&&"number"!=typeof n){if("string"==typeof t||"number"==typeof t)return r.appendChild(_(t.toString())),r;if(!t)return r}else r.appendChild(_(n.toString()));if(Array.isArray(t))for(const e of t)Array.isArray(e)&&null!=e[0]&&null!=e[1]&&r.setAttribute(e[0],e[1]);else if("object"==typeof t)for(const e of Object.keys(t))e&&null!=t[e]&&r.setAttribute(e,t[e].toString());return r}function T(e){for(let t=0;t<s.tags.length;t++)if(e===s.tags[t])return!0;return!1}function E(e,t){const n=s.attributes[e];if((null==n?void 0:n.length)>0)for(let e=0;e<n.length;e++)if(t===n[e])return!0;return!1}function x(e){for(let t=0;t<s.css.length;t++)if(e===s.css[t])return!0;return!1}function R(e){if(e.nodeType===c.NORMAL)return function(e){let t;const n=e.nodeName.toLowerCase();if(T(n))try{if(t=w(n),n in s.attributes){const i=s.attributes[n];for(let n=0;n<i.length;n++){const o=i[n];let s=e.getAttribute(o);var r;if(null!=s&&""!==s)if("style"===o&&"object"==typeof s&&(s=null!==(r=s.cssText)&&void 0!==r?r:s),"style"===o){const e=[],n=s.split(";");for(let t=0;t<n.length;t++){const r=n[t].split(":"),i=r[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase();if(x(i)){const t=r[1].replace(/^\s*/,"").replace(/\s*$/,"");e.push(i+": "+t)}}e.length>0&&(s=e.join("; "),t.setAttribute(o,s))}else t.setAttribute(o,s)}for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]))}}catch(e){t=_("")}else{t=C().createDocumentFragment();for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]))}return t}(e);if(e.nodeType===c.FRAGMENT){const t=C().createDocumentFragment();for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]));return t}return e.nodeType===c.TEXT?_(e.nodeValue):void 0}function k(e){let t;if(e.nodeType===c.NORMAL){const n=e;t=w(n.tagName);for(let e=0;e<n.attributes.length;e++)t.setAttribute(n.attributes[e].nodeName,n.attributes[e].value);for(let e=0;e<n.childNodes.length;e++)t.appendChild(k(n.childNodes[e]))}else e.nodeType===c.TEXT&&(t=C().createTextNode(e.nodeValue));return t}function I(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&amp;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;")).replace(/'/g,"&apos;")).replace(/"/g,"&quot;")}function N(e){if(!e)return null;const t=e instanceof p?e.tree():e,n=[...Array(t.attributes.length).keys()].map(e=>t.attributes[e].nodeName);n.sort();let r=n.reduce((e,n)=>`${e} ${n}="${I(t.attributes.getNamedItem(n).value)}"`,`<${t.nodeName}`);if(t.childNodes.length>0){r+=">";for(let e=0;e<t.childNodes.length;e++){const n=t.childNodes[e];switch(n.nodeType){case c.NORMAL:r+=N(n);break;case c.TEXT:r+=I(n.nodeValue);break;case c.CDATA:r+="<![CDATA["+n.nodeValue+"]]>"}}r+="</"+t.nodeName+">"}else r+="/>";return r}function D(e,t,n){for(let r=0;r<e.childNodes.length;r++){const i=e.childNodes[r];i.nodeType!==c.NORMAL||t&&!this.isTagEqual(i,t)||n(i)}}function A(e){var t;if(!e)return null;let n="";null!==(t=e.childNodes)&&void 0!==t&&t.length||e.nodeType!==c.TEXT||(n+=e.nodeValue);for(let t=0;null!==(r=t<(null===(i=e.childNodes)||void 0===i?void 0:i.length))&&void 0!==r&&r;t++){var r,i;e.childNodes[t].nodeType===c.TEXT&&(n+=e.childNodes[t].nodeValue)}return I(n)}function O(e){return e?e.split("/")[0]:null}const L={utf16to8:f,xorArrayBuffers:m,arrayBufToBase64:g,base64ToArrayBuf:v,stringToArrayBuf:y,addCookies:b};class P{constructor(e,t,n,r,i,o,s){this.handler=e,this.ns=t,this.name=n,this.type=r,this.id=i,this.options=s||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBareFromJid?this.from=o?O(o):null:this.from=o,this.user=!0}getNamespace(e){let t=e.getAttribute("xmlns");return t&&this.options.ignoreNamespaceFragment&&(t=t.split("#")[0]),t}namespaceMatch(e){let t=!1;return!this.ns||(D(e,null,e=>{this.getNamespace(e)===this.ns&&(t=!0)}),t||this.getNamespace(e)===this.ns)}isMatch(e){let t=e.getAttribute("from");this.options.matchBareFromJid&&(t=O(t));const n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!V.isTagEqual(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(n):n!==this.type)||this.id&&e.getAttribute("id")!==this.id||this.from&&t!==this.from)}run(e){let t=null;try{t=this.handler(e)}catch(e){throw V._handleError(e),e}return t}toString(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}}class M{constructor(e,t){this.period=e,this.handler=t,this.lastCalled=(new Date).getTime(),this.user=!0}run(){return this.lastCalled=(new Date).getTime(),this.handler()}reset(){this.lastCalled=(new Date).getTime()}toString(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}}const j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function q(e){const t=j.indexOf(e);return t<0?void 0:t}const B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function U(e){if(e>=0&&e<64)return B[e]}var F={atob:function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");if((e=(e=`${e}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;let t="",n=0,r=0;for(let i=0;i<e.length;i++)n<<=6,n|=q(e[i]),24===(r+=6)&&(t+=String.fromCharCode((16711680&n)>>16),t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n),n=r=0);return 12===r?(n>>=4,t+=String.fromCharCode(n)):18===r&&(n>>=2,t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n)),t},btoa:function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");let t;for(e=`${e}`,t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return null;let n="";for(t=0;t<e.length;t+=3){const r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(t)>>2,r[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(r[1]|=e.charCodeAt(t+1)>>4,r[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(r[2]|=e.charCodeAt(t+2)>>6,r[3]=63&e.charCodeAt(t+2));for(let e=0;e<r.length;e++)void 0===r[e]?n+="=":n+=U(r[e])}return n}};class H extends Error{constructor(e){super(e),this.name="StropheSessionError"}}class z{constructor(e,t,n){this.mechname=e,this.isClientFirst=t,this.priority=n}test(e){return!0}onStart(e){this._connection=e}onChallenge(e,t){throw new Error("You should implement challenge handling!")}clientChallenge(e){if(!this.isClientFirst)throw new Error("clientChallenge should not be called if isClientFirst is false!");return this.onChallenge(e)}onFailure(){this._connection=null}onSuccess(){this._connection=null}}const Q={async scramResponse(e,t,n,r){const i=e._sasl_data.cnonce,o=function(e){let t,n,r;const i=/([a-z]+)=([^,]+)(,|$)/;for(;e.match(i);){const o=e.match(i);switch(e=e.replace(o[0],""),o[1]){case"r":t=o[2];break;case"s":n=L.base64ToArrayBuf(o[2]);break;case"i":r=parseInt(o[2],10);break;case"m":return}}if(isNaN(r)||r<4096)V.warn("Failing SCRAM authentication because server supplied iteration count < 4096.");else{if(n)return{nonce:t,salt:n,iter:r};V.warn("Failing SCRAM authentication because server supplied incorrect salt.")}}(t);if(!o&&(null==o?void 0:o.nonce.slice(0,i.length))!==i)return V.warn("Failing SCRAM authentication because server supplied incorrect nonce."),e._sasl_data={},e._sasl_failure_cb();let s,a;const{pass:c}=e;if("string"==typeof e.pass||e.pass instanceof String){const e=await async function(e,t,n,r,i){const o=await crypto.subtle.deriveBits({name:"PBKDF2",salt:t,iterations:n,hash:{name:r}},await crypto.subtle.importKey("raw",L.stringToArrayBuf(e),"PBKDF2",!1,["deriveBits"]),i),s=await crypto.subtle.importKey("raw",o,{name:"HMAC",hash:r},!1,["sign"]);return{ck:await crypto.subtle.sign("HMAC",s,L.stringToArrayBuf("Client Key")),sk:await crypto.subtle.sign("HMAC",s,L.stringToArrayBuf("Server Key"))}}(c,o.salt,o.iter,n,r);s=e.ck,a=e.sk}else{if((null==c?void 0:c.name)!==n||(null==c?void 0:c.salt)!==L.arrayBufToBase64(o.salt)||(null==c?void 0:c.iter)!==o.iter)return e._sasl_failure_cb();{const{ck:e,sk:t}=c;s=L.base64ToArrayBuf(e),a=L.base64ToArrayBuf(t)}}const l=e._sasl_data["client-first-message-bare"],u=t,d=`c=biws,r=${o.nonce}`,h=`${l},${u},${d}`,p=await async function(e,t,n){const r=await crypto.subtle.importKey("raw",await crypto.subtle.digest(n,t),{name:"HMAC",hash:n},!1,["sign"]),i=await crypto.subtle.sign("HMAC",r,L.stringToArrayBuf(e));return L.xorArrayBuffers(t,i)}(h,s,n),f=await async function(e,t,n){const r=await crypto.subtle.importKey("raw",t,{name:"HMAC",hash:n},!1,["sign"]);return crypto.subtle.sign("HMAC",r,L.stringToArrayBuf(e))}(h,a,n);return e._sasl_data["server-signature"]=L.arrayBufToBase64(f),e._sasl_data.keys={name:n,iter:o.iter,salt:L.arrayBufToBase64(o.salt),ck:L.arrayBufToBase64(s),sk:L.arrayBufToBase64(a)},`${d},p=${L.arrayBufToBase64(p)}`},clientChallenge(e,t){const n=t||function(){const e=new Uint8Array(16);return L.arrayBufToBase64(crypto.getRandomValues(e).buffer)}(),r=`n=${e.authcid},r=${n}`;return e._sasl_data.cnonce=n,e._sasl_data["client-first-message-bare"]=r,`n,,${r}`}};class G{constructor(e){var t;this._conn=e,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this.inactivity=null,this.strip=null!==(t=G.prototype.strip)&&void 0!==t&&t,this.lastResponseHeaders=null,this._requests=[]}_buildBody(){const e=l("body",{rid:this.rid++,xmlns:V.NS.HTTPBIND});return null!==this.sid&&e.attrs({sid:this.sid}),this._conn.options.keepalive&&this._conn._sessionCachingSupported()&&this._cacheSession(),e}_reset(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_connect(e,t,n){this.wait=e||this.wait,this.hold=t||this.hold,this.errors=0;const r=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":V.NS.BOSH});n&&r.attrs({route:n});const i=this._conn._connect_cb;this._requests.push(new V.Request(r.tree(),this._onRequestStateChange.bind(this,i.bind(this._conn)),Number(r.tree().getAttribute("rid")))),this._throttledRequestHandler()}_attach(e,t,n,r,i,o,s){this._conn.jid=e,this.sid=t,this.rid=n,this._conn.connect_callback=r,this._conn.domain=V.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=i||this.wait,this.hold=o||this.hold,this.window=s||this.window,this._conn._changeConnectStatus(V.Status.ATTACHED,null)}_restore(e,t,n,r,i){const o=JSON.parse(sessionStorage.getItem("strophe-bosh-session"));if(!(null!=o&&o.rid&&o.sid&&o.jid&&(null==e||V.getBareJidFromJid(o.jid)===V.getBareJidFromJid(e)||null===V.getNodeFromJid(e)&&V.getDomainFromJid(o.jid)===e))){const e=new Error("_restore: no restoreable session.");throw e.name="StropheSessionError",e}this._conn.restored=!0,this._attach(o.jid,o.sid,o.rid,t,n,r,i)}_cacheSession(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):sessionStorage.removeItem("strophe-bosh-session")}_connect_cb(e){const t=e.getAttribute("type");if(null!==t&&"terminate"===t){let t=e.getAttribute("condition");V.error("BOSH-Connection failed: "+t);const n=e.getElementsByTagName("conflict");return null!==t?("remote-stream-error"===t&&n.length>0&&(t="conflict"),this._conn._changeConnectStatus(V.Status.CONNFAIL,t)):this._conn._changeConnectStatus(V.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(t),V.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));const n=e.getAttribute("requests");n&&(this.window=parseInt(n,10));const r=e.getAttribute("hold");r&&(this.hold=parseInt(r,10));const i=e.getAttribute("wait");i&&(this.wait=parseInt(i,10));const o=e.getAttribute("inactivity");o&&(this.inactivity=parseInt(o,10))}_disconnect(e){this._sendTerminate(e)}_doDisconnect(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_emptyQueue(){return 0===this._requests.length}_callProtocolErrorHandlers(e){const t=G._getRequestStatus(e),n=this._conn.protocolErrorHandlers.HTTP[t];n&&n.call(this,t)}_hitError(e){this.errors++,V.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()}_no_auth_received(e){V.warn("Server did not yet offer a supported authentication mechanism. Sending a blank poll request."),e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);const t=this._buildBody();this._requests.push(new V.Request(t.tree(),this._onRequestStateChange.bind(this,e),Number(t.tree().getAttribute("rid")))),this._throttledRequestHandler()}_onDisconnectTimeout(){this._abortAllRequests()}_abortAllRequests(){for(;this._requests.length>0;){const e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}}_onIdle(){const e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(V.debug("no requests during idle cycle, sending blank request"),e.push(null)),!this._conn.paused){if(this._requests.length<2&&e.length>0){const t=this._buildBody();for(let n=0;n<e.length;n++)null!==e[n]&&("restart"===e[n]?t.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":V.NS.BOSH}):t.cnode(e[n]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new V.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),Number(t.tree().getAttribute("rid")))),this._throttledRequestHandler()}if(this._requests.length>0){const e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(V.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(V.TIMEOUT*this.wait)&&(V.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(V.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}}static _getRequestStatus(e,t){let n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){V.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n}_onRequestStateChange(e,t){if(V.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)return void(t.abort=!1);if(4!==t.xhr.readyState)return;const n=G._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this._conn.disconnecting&&n>=400)return this._hitError(n),void this._callProtocolErrorHandlers(t);const r=this._requests[0]===t,i=this._requests[1]===t,o=n>0&&n<500,s=t.sends>this._conn.maxRetries;(o||s)&&(this._removeRequest(t),V.debug("request id "+t.id+" should now be removed")),200===n?((i||r&&this._requests.length>0&&this._requests[0].age()>Math.floor(V.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(t.rid+1),V.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0):0===n||n>=400&&n<600||n>=12e3?(V.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),n>=400&&n<500&&(this._conn._changeConnectStatus(V.Status.DISCONNECTING,null),this._conn._doDisconnect())):V.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),o||s?s&&!this._conn.connected&&this._conn._changeConnectStatus(V.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}_processRequest(e){let t=this._requests[e];const n=G._getRequestStatus(t,-1);if(t.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();const r=t.age(),i=!isNaN(r)&&r>Math.floor(V.TIMEOUT*this.wait),o=null!==t.dead&&t.timeDead()>Math.floor(V.SECONDARY_TIMEOUT*this.wait),s=4===t.xhr.readyState&&(n<1||n>=500);if((i||o||s)&&(o&&V.error(`Request ${this._requests[e].id} timed out (secondary), restarting`),t.abort=!0,t.xhr.abort(),t.xhr.onreadystatechange=function(){},this._requests[e]=new V.Request(t.xmlData,t.origFunc,t.rid,t.sends),t=this._requests[e]),0===t.xhr.readyState){var a,c;V.debug("request id "+t.id+"."+t.sends+" posting");try{const e=this._conn.options.contentType||"text/xml; charset=utf-8";t.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==t.xhr.setRequestHeader&&t.xhr.setRequestHeader("Content-Type",e),this._conn.options.withCredentials&&(t.xhr.withCredentials=!0)}catch(e){return V.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(V.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}const e=()=>{if(t.date=(new Date).valueOf(),this._conn.options.customHeaders){const e=this._conn.options.customHeaders;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.xhr.setRequestHeader(n,e[n])}t.xhr.send(t.data)};if(t.sends>1){const n=1e3*Math.min(Math.floor(V.TIMEOUT*this.wait),Math.pow(t.sends,3));setTimeout(function(){e()},n)}else e();var l,u,d,h;if(t.sends++,this.strip&&"body"===t.xmlData.nodeName&&t.xmlData.childNodes.length)null===(l=(u=this._conn).xmlOutput)||void 0===l||l.call(u,t.xmlData.children[0]);else null===(d=(h=this._conn).xmlOutput)||void 0===d||d.call(h,t.xmlData);null===(a=(c=this._conn).rawOutput)||void 0===a||a.call(c,t.data)}else V.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+t.xhr.readyState)}_removeRequest(e){V.debug("removing request");for(let t=this._requests.length-1;t>=0;t--)e===this._requests[t]&&this._requests.splice(t,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()}_restartRequest(e){const t=this._requests[e];null===t.dead&&(t.dead=new Date),this._processRequest(e)}_reqToData(e){try{return e.getResponse()}catch(e){if("parsererror"!==e.message)throw e;this._conn.disconnect("strophe-parsererror")}}_sendTerminate(e){V.debug("_sendTerminate was called");const t=this._buildBody().attrs({type:"terminate"}),n=e instanceof p?e.tree():e;e&&t.cnode(n);const r=new V.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),Number(t.tree().getAttribute("rid")));this._requests.push(r),this._throttledRequestHandler()}_send(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(()=>this._conn._onIdle(),100)}_sendRestart(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)}_throttledRequestHandler(){this._requests?V.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):V.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)<this.window&&this._processRequest(1))}}class J{constructor(e){this._conn=e,this.strip="wrapper";const t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){let n="";"ws"===e.options.protocol&&"https:"!==location.protocol?n+="ws":n+="wss",n+="://"+location.host,0!==t.indexOf("/")?n+=location.pathname+t:n+=t,e.service=n}}_buildStream(){return l("open",{xmlns:V.NS.FRAMING,to:this._conn.domain,version:"1.0"})}_checkStreamError(e,t){let n;if(0===(n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(V.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;const r=n[0];let i="",o="";for(let e=0;e<r.childNodes.length;e++){const t=r.children[e];if("urn:ietf:params:xml:ns:xmpp-streams"!==t.getAttribute("xmlns"))break;"text"===t.nodeName?o=t.textContent:i=t.nodeName}let s="WebSocket stream error: ";return s+=i||"unknown",o&&(s+=" - "+o),V.error(s),this._conn._changeConnectStatus(t,i),this._conn._doDisconnect(),!0}_reset(){}_connect(){this._closeSocket(),this.socket=new n(this._conn.service,"xmpp"),this.socket.onopen=(()=>this._onOpen()),this.socket.onerror=(e=>this._onError(e)),this.socket.onclose=(e=>this._onClose(e)),this.socket.onmessage=(e=>this._onInitialMessage(e))}_connect_cb(e){if(this._checkStreamError(e,V.Status.CONNFAIL))return V.Status.CONNFAIL}_handleStreamStart(e){let t=null;const n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in <open />":n!==V.NS.FRAMING&&(t="Wrong xmlns in <open />: "+n);const r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in <open />":"1.0"!==r&&(t="Wrong version in <open />: "+r),!t||(this._conn._changeConnectStatus(V.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)}_onInitialMessage(e){if(0===e.data.indexOf("<open ")||0===e.data.indexOf("<?xml")){const t=e.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===t)return;const n=(new r).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf("<close ")){const t=(new r).parseFromString(e.data,"text/xml").documentElement;this._conn.xmlInput(t),this._conn.rawInput(e.data);const n=t.getAttribute("see-other-uri");if(n){const e=this._conn.service;(e.indexOf("wss:")>=0&&n.indexOf("wss:")>=0||e.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus(V.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=n,this._connect())}else this._conn._changeConnectStatus(V.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{this._replaceMessageHandler();const t=this._streamWrap(e.data),n=(new r).parseFromString(t,"text/xml").documentElement;this._conn._connect_cb(n,null,e.data)}}_replaceMessageHandler(){this.socket.onmessage=(e=>this._onMessage(e))}_disconnect(e){if(this.socket&&this.socket.readyState!==n.CLOSED){e&&this._conn.send(e);const t=l("close",{xmlns:V.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=V.serialize(t);this._conn.rawOutput(n);try{this.socket.send(n)}catch(e){V.warn("Couldn't send <close /> tag.")}}setTimeout(()=>this._conn._doDisconnect(),0)}_doDisconnect(){V.debug("WebSockets _doDisconnect was called"),this._closeSocket()}_streamWrap(e){return"<wrapper>"+e+"</wrapper>"}_closeSocket(){if(this.socket)try{this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close()}catch(e){V.debug(e.message)}this.socket=null}_emptyQueue(){return!0}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(V.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(V.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(V.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):V.debug("Websocket closed")}_no_auth_received(e){V.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus(V.Status.CONNFAIL,V.ErrorCondition.NO_AUTH_MECH),null==e||e.call(this._conn),this._conn._doDisconnect()}_onDisconnectTimeout(){}_abortAllRequests(){}_onError(e){V.error("Websocket error "+JSON.stringify(e)),this._conn._changeConnectStatus(V.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()}_onIdle(){const e=this._conn._data;if(e.length>0&&!this._conn.paused){for(let t=0;t<e.length;t++)if(null!==e[t]){const n="restart"===e[t]?this._buildStream().tree():e[t];if("restart"===n)throw new Error("Wrong type for stanza");const r=V.serialize(n);this._conn.xmlOutput(n),this._conn.rawOutput(r),this.socket.send(r)}this._conn._data=[]}}_onMessage(e){let t;const n='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(e.data===n)return this._conn.rawInput(n),this._conn.xmlInput(e),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===e.data.search("<open ")){if(t=(new r).parseFromString(e.data,"text/xml").documentElement,!this._handleStreamStart(t))return}else{const n=this._streamWrap(e.data);t=(new r).parseFromString(n,"text/xml").documentElement}return this._checkStreamError(t,V.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===t.firstElementChild.nodeName&&"unavailable"===t.firstElementChild.getAttribute("type")?(this._conn.xmlInput(t),void this._conn.rawInput(V.serialize(t))):void this._conn._dataRecv(t,e.data)}_onOpen(){V.debug("Websocket open");const e=this._buildStream();this._conn.xmlOutput(e.tree());const t=V.serialize(e);this._conn.rawOutput(t),this.socket.send(t)}_send(){this._conn.flush()}_sendRestart(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}}const V={VERSION:"1.6.1",TIMEOUT:1.1,SECONDARY_TIMEOUT:.1,shims:Object.freeze({__proto__:null,WebSocket:n,DOMParser:r,getDummyXMLDOMDocument:i}),Request:class{constructor(e,t,n,r=0){this.id=++V._requestId,this.xmlData=e,this.data=V.serialize(e),this.origFunc=t,this.func=t,this.rid=n,this.date=NaN,this.sends=r,this.abort=!1,this.dead=null,this.age=(()=>this.date?((new Date).valueOf()-this.date.valueOf())/1e3:0),this.timeDead=(()=>this.dead?((new Date).valueOf()-this.dead.valueOf())/1e3:0),this.xhr=this._newXHR()}getResponse(){var e;let t=null===(e=this.xhr.responseXML)||void 0===e?void 0:e.documentElement;if(t){if("parsererror"===t.tagName)throw V.error("invalid response received"),V.error("responseText: "+this.xhr.responseText),V.error("responseXML: "+V.serialize(t)),new Error("parsererror")}else if(this.xhr.responseText){var n;V.debug("Got responseText but no responseXML; attempting to parse it with DOMParser...");const e=null===(n=t=(new r).parseFromString(this.xhr.responseText,"application/xml").documentElement)||void 0===n?void 0:n.querySelector("parsererror");if(!t||e){e&&(V.error("invalid response received: "+e.textContent),V.error("responseText: "+this.xhr.responseText));const t=new Error;throw t.name=V.ErrorCondition.BAD_FORMAT,t}}return t}_newXHR(){const e=new XMLHttpRequest;return e.overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8"),e.onreadystatechange=this.func.bind(null,this),e}},Bosh:G,Websocket:J,WorkerWebsocket:class extends J{constructor(e){super(e),this._conn=e,this.worker=new SharedWorker(this._conn.options.worker,"Strophe XMPP Connection"),this.worker.onerror=(e=>{var t;null===(t=console)||void 0===t||t.error(e),V.log(V.LogLevel.ERROR,`Shared Worker Error: ${e}`)})}_setSocket(){this.socket={send:e=>this.worker.port.postMessage(["send",e]),close:()=>this.worker.port.postMessage(["_closeSocket"]),onopen:()=>{},onerror:e=>this._onError(e),onclose:e=>this._onClose(e),onmessage:()=>{},readyState:null}}_connect(){this._setSocket(),this._messageHandler=(e=>this._onInitialMessage(e)),this.worker.port.start(),this.worker.port.onmessage=(e=>this._onWorkerMessage(e)),this.worker.port.postMessage(["_connect",this._conn.service,this._conn.jid])}_attach(e){this._setSocket(),this._messageHandler=(e=>this._onMessage(e)),this._conn.connect_callback=e,this.worker.port.start(),this.worker.port.onmessage=(e=>this._onWorkerMessage(e)),this.worker.port.postMessage(["_attach",this._conn.service])}_attachCallback(e,t){e===V.Status.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus(V.Status.ATTACHED)):e===V.Status.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus(V.Status.ATTACHFAIL))}_disconnect(e){e&&this._conn.send(e);const t=l("close",{xmlns:V.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=V.serialize(t);this._conn.rawOutput(n),this.worker.port.postMessage(["send",n]),this._conn._doDisconnect()}_closeSocket(){this.socket.close()}_replaceMessageHandler(){this._messageHandler=(e=>this._onMessage(e))}_onWorkerMessage(e){const t={};t.debug=V.LogLevel.DEBUG,t.info=V.LogLevel.INFO,t.warn=V.LogLevel.WARN,t.error=V.LogLevel.ERROR,t.fatal=V.LogLevel.FATAL;const{data:n}=e,r=n[0];if("_onMessage"===r)this._messageHandler(n[1]);else if(r in this)try{this[r].apply(this,e.data.slice(1))}catch(e){V.log(V.LogLevel.ERROR,e)}else if("log"===r){const e=n[1],r=n[2];V.log(t[e],r)}else V.log(V.LogLevel.ERROR,`Found unhandled service worker message: ${n}`)}},SASLAnonymous:class extends z{constructor(e="ANONYMOUS",t=!1,n=20){super(e,t,n)}test(e){return null===e.authcid}},SASLPlain:class extends z{constructor(e="PLAIN",t=!0,n=50){super(e,t,n)}test(e){return null!==e.authcid}onChallenge(e){const{authcid:t,authzid:n,domain:r,pass:i}=e;if(!r)throw new Error("SASLPlain onChallenge: domain is not defined!");let o=n!==`${t}@${r}`?n:"";return o+="\0",o+=t,o+="\0",o+=i,L.utf16to8(o)}},SASLSHA1:class extends z{constructor(e="SCRAM-SHA-1",t=!0,n=60){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-1",160)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA256:class extends z{constructor(e="SCRAM-SHA-256",t=!0,n=70){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-256",256)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA384:class extends z{constructor(e="SCRAM-SHA-384",t=!0,n=71){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-384",384)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA512:class extends z{constructor(e="SCRAM-SHA-512",t=!0,n=72){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-512",512)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLOAuthBearer:class extends z{constructor(e="OAUTHBEARER",t=!0,n=40){super(e,t,n)}test(e){return null!==e.pass}onChallenge(e){let t="n,";return null!==e.authcid&&(t=t+"a="+e.authzid),t+=",",t+="",t+="auth=Bearer ",t+=e.pass,t+="",t+="",L.utf16to8(t)}},SASLExternal:class extends z{constructor(e="EXTERNAL",t=!0,n=10){super(e,t,n)}onChallenge(e){return e.authcid===e.authzid?"":e.authzid}},SASLXOAuth2:class extends z{constructor(e="X-OAUTH2",t=!0,n=30){super(e,t,n)}test(e){return null!==e.pass}onChallenge(e){let t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,L.utf16to8(t)}},Builder:p,Connection:class{constructor(e,t={}){this.service=e,this.options=t,this.setProtocol(),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_bind=!1,this.do_session=!1,this.mechanisms={},this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.protocolErrorHandlers={HTTP:{},websocket:{}},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout(()=>this._onIdle(),100),b(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),this.iqFallbackHandler=new P(e=>this.send(d({type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("service-unavailable",{xmlns:V.NS.STANZAS})),null,"iq",["get","set"]);for(const e in V._connectionPlugins)if(Object.prototype.hasOwnProperty.call(V._connectionPlugins,e)){const t=function(){};t.prototype=V._connectionPlugins[e],this[e]=new t,this[e].init(this)}}setProtocol(){const e=this.options.protocol||"";this.options.worker?this._proto=new V.WorkerWebsocket(this):0===this.service.indexOf("ws:")||0===this.service.indexOf("wss:")||0===e.indexOf("ws")?this._proto=new V.Websocket(this):this._proto=new V.Bosh(this)}reset(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0}pause(){this.paused=!0}resume(){this.paused=!1}getUniqueId(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}addProtocolErrorHandler(e,t,n){this.protocolErrorHandlers[e][t]=n}connect(e,t,n,r,i,o,s,c=3e3){this.jid=e,this.authzid=V.getBareJidFromJid(this.jid),this.authcid=s||V.getNodeFromJid(this.jid),this.pass=t,this.scram_keys=null,this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.disconnection_timeout=c,this.domain=V.getDomainFromJid(this.jid),this._changeConnectStatus(a.CONNECTING,null),this._proto._connect(r,i,o)}attach(e,t,n,r,i,o,s){if(this._proto instanceof V.Bosh&&"string"==typeof e)return this._proto._attach(e,t,n,r,i,o,s);if(this._proto instanceof V.WorkerWebsocket&&"function"==typeof e){const t=e;return this._proto._attach(t)}throw new H('The "attach" method is not available for your connection protocol')}restore(e,t,n,r,i){if(!(this._proto instanceof V.Bosh&&this._sessionCachingSupported()))throw new H('The "restore" method can only be used with a BOSH connection.');this._sessionCachingSupported()&&this._proto._restore(e,t,n,r,i)}_sessionCachingSupported(){if(this._proto instanceof V.Bosh){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1}xmlInput(e){}xmlOutput(e){}rawInput(e){}rawOutput(e){}nextValidRid(e){}send(e){if(null!==e){if(Array.isArray(e))e.forEach(e=>this._queueData(e instanceof p?e.tree():e));else{const t=e instanceof p?e.tree():e;this._queueData(t)}this._proto._send()}}flush(){clearTimeout(this._idleTimeout),this._onIdle()}sendPresence(e,t,n,r){let i=null;const o=e instanceof p?e.tree():e;let s=o.getAttribute("id");if(s||(s=this.getUniqueId("sendPresence"),o.setAttribute("id",s)),"function"==typeof t||"function"==typeof n){const e=this.addHandler(e=>{i&&this.deleteTimedHandler(i),"error"===e.getAttribute("type")?null==n||n(e):t&&t(e)},null,"presence",null,s);r&&(i=this.addTimedHandler(r,()=>(this.deleteHandler(e),null==n||n(null),!1)))}return this.send(o),s}sendIQ(e,t,n,r){let i=null;const o=e instanceof p?e.tree():e;let s=o.getAttribute("id");if(s||(s=this.getUniqueId("sendIQ"),o.setAttribute("id",s)),"function"==typeof t||"function"==typeof n){const e=this.addHandler(e=>{i&&this.deleteTimedHandler(i);const r=e.getAttribute("type");if("result"===r)null==t||t(e);else{if("error"!==r){const e=new Error(`Got bad IQ type of ${r}`);throw e.name="StropheError",e}null==n||n(e)}},null,"iq",["error","result"],s);r&&(i=this.addTimedHandler(r,()=>(this.deleteHandler(e),null==n||n(null),!1)))}return this.send(o),s}_queueData(e){if(null===e||!e.tagName||!e.childNodes){const e=new Error("Cannot queue non-DOMElement.");throw e.name="StropheError",e}this._data.push(e)}_sendRestart(){this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout(()=>this._onIdle(),100)}addTimedHandler(e,t){const n=new V.TimedHandler(e,t);return this.addTimeds.push(n),n}deleteTimedHandler(e){this.removeTimeds.push(e)}addHandler(e,t,n,r,i,o,s){const a=new P(e,t,n,r,i,o,s);return this.addHandlers.push(a),a}deleteHandler(e){this.removeHandlers.push(e);const t=this.addHandlers.indexOf(e);t>=0&&this.addHandlers.splice(t,1)}registerSASLMechanisms(e){this.mechanisms={},(e||[V.SASLAnonymous,V.SASLExternal,V.SASLOAuthBearer,V.SASLXOAuth2,V.SASLPlain,V.SASLSHA1,V.SASLSHA256,V.SASLSHA384,V.SASLSHA512]).forEach(e=>this.registerSASLMechanism(e))}registerSASLMechanism(e){const t=new e;this.mechanisms[t.mechname]=t}disconnect(e){if(this._changeConnectStatus(a.DISCONNECTING,e),e?V.warn("Disconnect was called because: "+e):V.info("Disconnect was called"),this.connected){let e=null;this.disconnecting=!0,this.authenticated&&(e=h({xmlns:V.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(this.disconnection_timeout,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else V.warn("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()}_changeConnectStatus(e,t,n){for(const n in V._connectionPlugins)if(Object.prototype.hasOwnProperty.call(V._connectionPlugins,n)){const r=this[n];if(r.statusChanged)try{r.statusChanged(e,t)}catch(e){V.error(`${n} plugin caused an exception changing status: ${e}`)}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){V._handleError(e),V.error(`User connection callback caused an exception: ${e}`)}}_doDisconnect(e){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),V.debug("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(a.DISCONNECTED,e),this.connected=!1}_dataRecv(e,t){const n="_reqToData"in this._proto?this._proto._reqToData(e):e;if(null===n)return;for(this.xmlInput!==V.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==V.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(V.serialize(n)));this.removeHandlers.length>0;){const e=this.removeHandlers.pop(),t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();const r=n.getAttribute("type");if(null!==r&&"terminate"===r){if(this.disconnecting)return;let e=n.getAttribute("condition");const t=n.getElementsByTagName("conflict");return null!==e?("remote-stream-error"===e&&t.length>0&&(e="conflict"),this._changeConnectStatus(a.CONNFAIL,e)):this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.UNKNOWN_REASON),void this._doDisconnect(e)}V.forEachChild(n,null,e=>{const t=[];this.handlers=this.handlers.reduce((n,r)=>{try{!r.isMatch(e)||!this.authenticated&&r.user?n.push(r):(r.run(e)&&n.push(r),t.push(r))}catch(e){V.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}return n},[]),!t.length&&this.iqFallbackHandler.isMatch(e)&&this.iqFallbackHandler.run(e)})}_connect_cb(e,t,n){let r,i;V.debug("_connect_cb was called"),this.connected=!0;try{r="_reqToData"in this._proto?this._proto._reqToData(e):e}catch(e){if(e.name!==V.ErrorCondition.BAD_FORMAT)throw e;this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.BAD_FORMAT),this._doDisconnect(V.ErrorCondition.BAD_FORMAT)}if(!r)return;if(this.xmlInput!==V.Connection.prototype.xmlInput&&(r.nodeName===this._proto.strip&&r.childNodes.length?this.xmlInput(r.childNodes[0]):this.xmlInput(r)),this.rawInput!==V.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(V.serialize(r))),this._proto._connect_cb(r)===a.CONNFAIL)return;if(!(i=r.getElementsByTagNameNS?r.getElementsByTagNameNS(V.NS.STREAM,"features").length>0:r.getElementsByTagName("stream:features").length>0||r.getElementsByTagName("features").length>0))return void this._proto._no_auth_received(t);const o=Array.from(r.getElementsByTagName("mechanism")).map(e=>this.mechanisms[e.textContent]).filter(e=>e);0!==o.length||0!==r.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(o):this._proto._no_auth_received(t)}sortMechanismsByPriority(e){for(let t=0;t<e.length-1;++t){let n=t;for(let r=t+1;r<e.length;++r)e[r].priority>e[n].priority&&(n=r);if(n!==t){const r=e[t];e[t]=e[n],e[n]=r}}return e}authenticate(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}_attemptSASLAuth(e){e=this.sortMechanismsByPriority(e||[]);let t=!1;for(let n=0;n<e.length;++n){if(!e[n].test(this))continue;this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null),this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null),this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge_cb.bind(this),null,"challenge",null,null),this._sasl_mechanism=e[n],this._sasl_mechanism.onStart(this);const r=l("auth",{xmlns:V.NS.SASL,mechanism:this._sasl_mechanism.mechname});if(this._sasl_mechanism.isClientFirst){const e=this._sasl_mechanism.clientChallenge(this);r.t(F.btoa(e))}this.send(r.tree()),t=!0;break}return t}async _sasl_challenge_cb(e){const t=F.atob(A(e)),n=await this._sasl_mechanism.onChallenge(this,t),r=l("response",{xmlns:V.NS.SASL});return n&&r.t(F.btoa(n)),this.send(r.tree()),!0}_attemptLegacyAuth(){null===V.getNodeFromJid(this.jid)?(this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.MISSING_JID_NODE),this.disconnect(V.ErrorCondition.MISSING_JID_NODE)):(this._changeConnectStatus(a.AUTHENTICATING,null),this._addSysHandler(this._onLegacyAuthIQResult.bind(this),null,null,null,"_auth_1"),this.send(d({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:V.NS.AUTH}).c("username",{}).t(V.getNodeFromJid(this.jid)).tree()))}_onLegacyAuthIQResult(){const e="string"==typeof this.pass?this.pass:"",t=d({type:"set",id:"_auth_2"}).c("query",{xmlns:V.NS.AUTH}).c("username",{}).t(V.getNodeFromJid(this.jid)).up().c("password").t(e);return V.getResourceFromJid(this.jid)||(this.jid=V.getBareJidFromJid(this.jid)+"/strophe"),t.up().c("resource",{}).t(V.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(t.tree()),!1}_sasl_success_cb(e){if(this._sasl_data["server-signature"]){let t;const n=/([a-z]+)=([^,]+)(,|$)/,r=F.atob(A(e)).match(n);if("v"===r[1]&&(t=r[2]),t!==this._sasl_data["server-signature"])return this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_data={},this._sasl_failure_cb(null)}V.info("SASL authentication succeeded."),this._sasl_data.keys&&(this.scram_keys=this._sasl_data.keys),this._sasl_mechanism&&this._sasl_mechanism.onSuccess(),this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null);const t=[],n=(e,t)=>{for(;e.length;)this.deleteHandler(e.pop());return this._onStreamFeaturesAfterSASL(t),!1};return t.push(this._addSysHandler(e=>n(t,e),null,"stream:features",null,null)),t.push(this._addSysHandler(e=>n(t,e),V.NS.STREAM,"features",null,null)),this._sendRestart(),!1}_onStreamFeaturesAfterSASL(e){this.features=e;for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];"bind"===n.nodeName&&(this.do_bind=!0),"session"===n.nodeName&&(this.do_session=!0)}return this.do_bind?(this.options.explicitResourceBinding?this._changeConnectStatus(a.BINDREQUIRED,null):this.bind(),!1):(this._changeConnectStatus(a.AUTHFAIL,null),!1)}bind(){if(!this.do_bind)return void V.log(V.LogLevel.INFO,'Strophe.Connection.prototype.bind called but "do_bind" is false');this._addSysHandler(this._onResourceBindResultIQ.bind(this),null,null,null,"_bind_auth_2");const e=V.getResourceFromJid(this.jid);e?this.send(d({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:V.NS.BIND}).c("resource",{}).t(e).tree()):this.send(d({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:V.NS.BIND}).tree())}_onResourceBindResultIQ(e){if("error"===e.getAttribute("type")){let t;return V.warn("Resource binding failed."),e.getElementsByTagName("conflict").length>0&&(t=V.ErrorCondition.CONFLICT),this._changeConnectStatus(a.AUTHFAIL,t,e),!1}const t=e.getElementsByTagName("bind");if(!(t.length>0))return V.warn("Resource binding failed."),this._changeConnectStatus(a.AUTHFAIL,null,e),!1;{const e=t[0].getElementsByTagName("jid");e.length>0&&(this.authenticated=!0,this.jid=A(e[0]),this.do_session?this._establishSession():this._changeConnectStatus(a.CONNECTED,null))}}_establishSession(){if(!this.do_session)throw new Error("Strophe.Connection.prototype._establishSession "+`called but apparently ${V.NS.SESSION} wasn't advertised by the server`);this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(d({type:"set",id:"_session_auth_2"}).c("session",{xmlns:V.NS.SESSION}).tree())}_onSessionResultIQ(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(a.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,V.warn("Session creation failed."),this._changeConnectStatus(a.AUTHFAIL,null,e),!1;return!1}_sasl_failure_cb(e){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(a.AUTHFAIL,null,e),!1}_auth2_cb(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(a.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(a.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}_addSysTimedHandler(e,t){const n=new M(e,t);return n.user=!1,this.addTimeds.push(n),n}_addSysHandler(e,t,n,r,i){const o=new P(e,t,n,r,i);return o.user=!1,this.addHandlers.push(o),o}_onDisconnectTimeout(){return V.debug("_onDisconnectTimeout was called"),this._changeConnectStatus(a.CONNTIMEOUT,null),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1}_onIdle(){for(;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;){const e=this.removeTimeds.pop(),t=this.timedHandlers.indexOf(e);t>=0&&this.timedHandlers.splice(t,1)}const e=(new Date).getTime(),t=[];for(let n=0;n<this.timedHandlers.length;n++){const r=this.timedHandlers[n];!this.authenticated&&r.user||(r.lastCalled+r.period-e<=0?r.run()&&t.push(r):t.push(r))}this.timedHandlers=t,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(()=>this._onIdle(),100))}},ElementType:c,ErrorCondition:{BAD_FORMAT:"bad-format",CONFLICT:"conflict",MISSING_JID_NODE:"x-strophe-bad-non-anon-jid",NO_AUTH_MECH:"no-auth-mech",UNKNOWN_REASON:"unknown"},Handler:P,LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},NS:o,SASLMechanism:z,Status:a,TimedHandler:M,...Object.freeze({__proto__:null,utf16to8:f,xorArrayBuffers:m,arrayBufToBase64:g,base64ToArrayBuf:v,stringToArrayBuf:y,addCookies:b,xmlGenerator:C,xmlTextNode:_,xmlHtmlNode:function(e){return(new r).parseFromString(e,"text/xml")},xmlElement:w,validTag:T,validAttribute:E,validCSS:x,createHtml:R,copyElement:k,xmlescape:I,xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&amp;/g,"&")).replace(/&lt;/g,"<")).replace(/&gt;/g,">")).replace(/&apos;/g,"'")).replace(/&quot;/g,'"')},serialize:N,forEachChild:D,isTagEqual:function(e,t){return e.tagName===t},getText:A,escapeNode:function(e){return"string"!=typeof e?e:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){const t=O(e);if(t.indexOf("@")<0)return t;{const e=t.split("@");return e.splice(0,1),e.join("@")}},getResourceFromJid:function(e){if(!e)return null;const t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:O,default:L}),XHTML:{...s,validTag:T,validCSS:x,validAttribute:E},addNamespace(e,t){V.NS[e]=t},_handleError(e){void 0!==e.stack&&V.fatal(e.stack),V.fatal("error: "+e.message)},log(e,t){var n;e===this.LogLevel.FATAL&&(null===(n=console)||void 0===n||n.error(t))},debug(e){this.log(this.LogLevel.DEBUG,e)},info(e){this.log(this.LogLevel.INFO,e)},warn(e){this.log(this.LogLevel.WARN,e)},error(e){this.log(this.LogLevel.ERROR,e)},fatal(e){this.log(this.LogLevel.FATAL,e)},_requestId:0,_connectionPlugins:{},addConnectionPlugin(e,t){V._connectionPlugins[e]=t}},W="http://www.w3.org/1999/xhtml";function X(e,t){const n=V.xmlHtmlNode(e);if(n.getElementsByTagNameNS(W,"parsererror").length)throw new Error(`Parser Error: ${e}`);const r=n.firstElementChild;if(["message","iq","presence"].includes(r.nodeName.toLowerCase())&&"jabber:client"!==r.namespaceURI&&"jabber:server"!==r.namespaceURI){const e=`Invalid namespaceURI ${r.namespaceURI}`;if(t)throw new Error(e);V.log(V.LogLevel.ERROR,e)}return r}class ${constructor(e,t){this.strings=e,this.values=t}toString(){return this.string=this.string||this.strings.reduce((e,t)=>{const n=this.strings.indexOf(t);return e+t+(this.values.length>n?this.values[n].toString():"")},""),this.string}tree(){var e;return this.node=null!==(e=this.node)&&void 0!==e?e:X(this.toString(),!0),this.node}}globalThis.$build=l,globalThis.$iq=d,globalThis.$msg=u,globalThis.$pres=h,globalThis.Strophe=V,t.$build=l,t.$iq=d,t.$msg=u,t.$pres=h,t.Builder=p,t.Strophe=V,t.stx=function(e,...t){return new $(e,t)},t.toStanza=X,Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof n&&void 0!==t?n:(r="undefined"!=typeof globalThis?globalThis:r||self).strophe={})},{"@xmldom/xmldom":5,ws:111}],111:[function(e,t,n){"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],112:[function(e,t,n){(function(t,r){(function(){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function l(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new l(o.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new l(o.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete a[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":89,timers:112}],113:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],114:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],115:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],116:[function(e,t,n){(function(t,r){(function(){var i=/%[sdj%]/g;n.format=function(e){if(!v(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,s=String(e).replace(i,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),c=r[n];n<o;c=r[++n])m(c)||!S(c)?s+=" "+c:s+=" "+a(c);return s},n.deprecate=function(e,i){if(y(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(!0===t.noDeprecation)return e;var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var o,s={};function a(e,t){var r={seen:[],stylize:l};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),f(t)?r.showHidden=t:t&&n._extend(r,t),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),u(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return v(i)||(i=u(e,i,r)),i}var o=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(t))return e.stylize(""+t,"number");if(f(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),_(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(t);if(0===s.length){if(w(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(b(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(C(t))return e.stylize(Date.prototype.toString.call(t),"date");if(_(t))return d(t)}var l,S="",T=!1,E=["{","}"];(p(t)&&(T=!0,E=["[","]"]),w(t))&&(S=" [Function"+(t.name?": "+t.name:"")+"]");return b(t)&&(S=" "+RegExp.prototype.toString.call(t)),C(t)&&(S=" "+Date.prototype.toUTCString.call(t)),_(t)&&(S=" "+d(t)),0!==s.length||T&&0!=t.length?r<0?b(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=T?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)R(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}(e,t,r,a,s):s.map(function(n){return h(e,t,r,a,n,T)}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(l,S,E)):E[0]+S+E[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return void 0===e}function b(e){return S(e)&&"[object RegExp]"===T(e)}function S(e){return"object"==typeof e&&null!==e}function C(e){return S(e)&&"[object Date]"===T(e)}function _(e){return S(e)&&("[object Error]"===T(e)||e instanceof Error)}function w(e){return"function"==typeof e}function T(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(y(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=t.pid;s[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else s[e]=function(){};return s[e]},n.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=f,n.isNull=m,n.isNullOrUndefined=function(e){return null==e},n.isNumber=g,n.isString=v,n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=y,n.isRegExp=b,n.isObject=S,n.isDate=C,n.isError=_,n.isFunction=w,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":"),[e.getDate(),x[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":115,_process:89,inherits:114}],117:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=(0,e("./adapter_factory.js").adapterFactory)({window:"undefined"==typeof window?void 0:window});n.default=r},{"./adapter_factory.js":118}],118:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.adapterFactory=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},n=r.log,l=r.detectBrowser(e),u={browserDetails:l,commonShim:c,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(l.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),u;if(null===l.version)return n("Chrome shim can not determine version, not shimming."),u;n("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,l),i.shimGetUserMedia(e,l),i.shimMediaStream(e,l),i.shimPeerConnection(e,l),i.shimOnTrack(e,l),i.shimAddTrackRemoveTrack(e,l),i.shimGetSendersWithDtmf(e,l),i.shimGetStats(e,l),i.shimSenderReceiverGetStats(e,l),i.fixNegotiationNeeded(e,l),c.shimRTCIceCandidate(e,l),c.shimConnectionState(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l),c.removeExtmapAllowMixed(e,l);break;case"firefox":if(!s||!s.shimPeerConnection||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),u;n("adapter.js shimming firefox."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,l),s.shimGetUserMedia(e,l),s.shimPeerConnection(e,l),s.shimOnTrack(e,l),s.shimRemoveStream(e,l),s.shimSenderGetStats(e,l),s.shimReceiverGetStats(e,l),s.shimRTCDataChannel(e,l),s.shimAddTransceiver(e,l),s.shimGetParameters(e,l),s.shimCreateOffer(e,l),s.shimCreateAnswer(e,l),c.shimRTCIceCandidate(e,l),c.shimConnectionState(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l);break;case"edge":if(!o||!o.shimPeerConnection||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),u;n("adapter.js shimming edge."),u.browserShim=o,o.shimGetUserMedia(e,l),o.shimGetDisplayMedia(e,l),o.shimPeerConnection(e,l),o.shimReplaceTrack(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l);break;case"safari":if(!a||!t.shimSafari)return n("Safari shim is not included in this adapter release."),u;n("adapter.js shimming safari."),u.browserShim=a,c.shimAddIceCandidateNullOrEmpty(e,l),a.shimRTCIceServerUrls(e,l),a.shimCreateOfferLegacy(e,l),a.shimCallbacksAPI(e,l),a.shimLocalStreamsAPI(e,l),a.shimRemoteStreamsAPI(e,l),a.shimTrackEventTransceiver(e,l),a.shimGetUserMedia(e,l),a.shimAudioContext(e,l),c.shimRTCIceCandidate(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l),c.removeExtmapAllowMixed(e,l);break;default:n("Unsupported browser!")}return u};var r=l(e("./utils")),i=l(e("./chrome/chrome_shim")),o=l(e("./edge/edge_shim")),s=l(e("./firefox/firefox_shim")),a=l(e("./safari/safari_shim")),c=l(e("./common_shim"));function l(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}},{"./chrome/chrome_shim":119,"./common_shim":122,"./edge/edge_shim":123,"./firefox/firefox_shim":127,"./safari/safari_shim":130,"./utils":131}],119:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var 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},i=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var o=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}}),n.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},n.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)s.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)}),t.stream.getTracks().forEach(function(r){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},n.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],s.apply(this,[e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},n.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,n=Array.prototype.slice.call(arguments),r=n[0],i=n[1],o=n[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var s=function(e){var t={},n=e.result();return n.forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},a=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(a(s(e)))},r])}return new Promise(function(n,r){t.apply(e,[function(e){n(a(s(e)))},r])}).then(i,o)}},n.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),s.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],n=void 0,r=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(n?i=!0:n=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(r?i=!0:r=e),e.track===t}),i||n&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return o.apply(this,arguments)}},n.shimAddTrackRemoveTrackWithNative=c,n.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=n.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find(function(e){return e.track===t});if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var s=this._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);this._streams[n.id]=a,this._reverseStreams[a.id]=n,this.addStream(a)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=a({},t,function(){var e=this,t=arguments,r=arguments.length&&"function"==typeof arguments[0];return r?n.apply(this,[function(n){var r=o(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(this,arguments).then(function(t){return o(e,t)})});e.RTCPeerConnection.prototype[t]=r[t]});var s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],n=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})),s.apply(this,arguments)):s.apply(this,arguments);var e,t,n};var l=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=l.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");var n=e._pc===this;if(!n)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var r=void 0;Object.keys(this._streams).forEach(function(n){var i=t._streams[n].getTracks().find(function(t){return e.track===t});i&&(r=t._streams[n])}),r&&(1===r.getTracks().length?this.removeStream(this._reverseStreams[r.id]):r.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},n.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=a({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=r[t]})},n.fixNegotiationNeeded=function(e,t){s.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e})};var s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils.js"));function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var r=this.getSenders();n.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===r.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]}),i.apply(this,arguments)}}},{"../utils.js":131,"./getdisplaymedia":120,"./getusermedia":121}],120:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(function(t){var r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)})}}},{}],121:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimGetUserMedia=function(e,t){var n=e&&e.navigator;if(!n.mediaDevices)return;var o=function(e){if("object"!==(void 0===e?"undefined":r(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var i="object"===r(e[n])?e[n]:{ideal:e[n]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var s={};"number"==typeof i.ideal?(s[o("min",n)]=i.ideal,t.optional.push(s),(s={})[o("max",n)]=i.ideal,t.optional.push(s)):(s[o("",n)]=i.ideal,t.optional.push(s))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[o("",n)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[o(e,n)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},s=function(e,s){if(t.version>=61)return s(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===r(e.audio)){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),a(e.audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=o(e.audio)}if(e&&"object"===r(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":r(c))?c:{ideal:c});var l=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!n&&t.length&&u.includes("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=c.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=o(e.video),i("chrome: "+JSON.stringify(e)),s(e)})}e.video=o(e.video)}return i("chrome: "+JSON.stringify(e)),s(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){s(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(a(e))})})}.bind(n),n.mediaDevices.getUserMedia){var c=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return s(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(a(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":131}],122:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":r(e))&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=s.default.parseCandidate(e.candidate),o=Object.assign(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,a.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},n.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),r=e.sdpSemantics;"plan-b"===r&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=s.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=s.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),o=function(e){var n=65536;"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return n}(i),a=function(e,n){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var i=s.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637);return r}(arguments[0],i),c=void 0;c=0===o&&0===a?Number.POSITIVE_INFINITY:0===o||0===a?Math.max(o,a):Math.min(o,a);var l={};Object.defineProperty(l,"maxMessageSize",{get:function(){return c}}),this._sctp=l}return n.apply(this,arguments)}},n.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}var n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=n.apply(this,arguments);return t(e,this),e},a.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},n.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(e){var n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})},n.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return n.apply(this,arguments)}},n.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var n=e.RTCPeerConnection.prototype.addIceCandidate;if(!n||0===n.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,o=e("sdp"),s=(i=o)&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("./utils"))},{"./utils":131,sdp:108}],123:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var r=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return r.shimGetUserMedia}});var i=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return i.shimGetDisplayMedia}}),n.shimPeerConnection=function(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}});e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var r=(0,l.default)(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=(0,a.filterIceServers)(e.iceServers,t.version),s.log("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype},n.shimReplaceTrack=function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)};var o,s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils")),a=e("./filtericeservers"),c=e("rtcpeerconnection-shim"),l=(o=c)&&o.__esModule?o:{default:o}},{"../utils":131,"./filtericeservers":124,"./getdisplaymedia":125,"./getusermedia":126,"rtcpeerconnection-shim":106}],124:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.filterIceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&r.deprecated("RTCIceServer.url","RTCIceServer.urls");var i="string"==typeof t;return i&&(t=[t]),t=t.filter(function(e){if(0===e.indexOf("stun:"))return!1;var t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!n?(n=!0,!0):t&&!n}),delete e.url,e.urls=i?t[0]:t,!!t.length}})};var r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131}],125:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e){if(!("getDisplayMedia"in e.navigator))return;if(!e.navigator.mediaDevices)return;if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)}},{}],126:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetUserMedia=function(e){var t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))})}}},{}],127:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var 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},i=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var o=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}}),n.shimOnTrack=function(e){"object"===(void 0===e?"undefined":r(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},n.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=r[t]});var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),r=e[0],o=e[1],s=e[2];return i.apply(this,[r||null]).then(function(e){if(t.version<53&&!o)try{e.forEach(function(e){e.type=n[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(o,s)}},n.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e});e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}},n.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});s.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},n.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;s.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)})}},n.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},n.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var r=t.apply(this,arguments);if(n){var i=r.sender,o=i.getParameters();"encodings"in o&&(1!==o.encodings.length||0!==Object.keys(o.encodings[0]).length)||(o.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(o).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return r})},n.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},n.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,n=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,n)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},n.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,n=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,n)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131,"./getdisplaymedia":128,"./getusermedia":129}],128:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)}}},{}],129:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimGetUserMedia=function(e,t){var n=e&&e.navigator,o=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var s=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":r(e))&&"object"===r(e.audio)&&(e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","mozAutoGainControl"),s(e.audio,"noiseSuppression","mozNoiseSuppression")),a(e)},o&&o.prototype.getSettings){var c=o.prototype.getSettings;o.prototype.getSettings=function(){var e=c.apply(this,arguments);return s(e,"mozAutoGainControl","autoGainControl"),s(e,"mozNoiseSuppression","noiseSuppression"),e}}if(o&&o.prototype.applyConstraints){var l=o.prototype.applyConstraints;o.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":r(e))&&(e=JSON.parse(JSON.stringify(e)),s(e,"autoGainControl","mozAutoGainControl"),s(e,"noiseSuppression","mozNoiseSuppression")),l.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131}],130:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(r){return t.call(n,r,e)}),e.getVideoTracks().forEach(function(r){return t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=this,r=arguments.length,i=Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i&&i.forEach(function(e){n._localStreams?n._localStreams.includes(e)||n._localStreams.push(e):n._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var n=this._localStreams.indexOf(e);if(-1!==n){this._localStreams.splice(n,1);var r=e.getTracks();this.getSenders().forEach(function(e){r.includes(e.track)&&t.removeTrack(e)})}})},n.shimRemoteStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;"getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]});if(!("onaddstream"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}})})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}})}),t.apply(e,arguments)}}},n.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,n=t.createOffer,i=t.createAnswer,o=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r};var c=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=c,c=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=c,c=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=c},n.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=function(e){return r(o(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))},n.shimConstraints=o,n.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var r=[],o=0;o<e.iceServers.length;o++){var s=e.iceServers[o];!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")?(i.deprecated("RTCIceServer.url","RTCIceServer.urls"),(s=JSON.parse(JSON.stringify(s))).urls=s.url,delete s.url,r.push(s)):r.push(e.iceServers[o])}e.iceServers=r}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})},n.shimTrackEventTransceiver=function(e){"object"===(void 0===e?"undefined":r(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},n.shimCreateOfferLegacy=function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var n=this.getTransceivers().find(function(e){return"audio"===e.receiver.track.kind});!1===e.offerToReceiveAudio&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveAudio||n||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var r=this.getTransceivers().find(function(e){return"video"===e.receiver.track.kind});!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}},n.shimAudioContext=function(e){if("object"!==(void 0===e?"undefined":r(e))||e.AudioContext)return;e.AudioContext=e.webkitAudioContext};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"));function o(e){return e&&void 0!==e.video?Object.assign({},e,{video:i.compactObject(e.video)}):e}},{"../utils":131}],131:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.extractVersion=s,n.wrapPeerConnectionEvent=function(e,t,n){if(!e.RTCPeerConnection)return;var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};var o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);var r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})},n.disableLog=function(e){if("boolean"!=typeof e)return new Error("Argument type: "+(void 0===e?"undefined":r(e))+". Please use a boolean.");return i=e,e?"adapter.js logging disabled":"adapter.js logging enabled"},n.disableWarnings=function(e){if("boolean"!=typeof e)return new Error("Argument type: "+(void 0===e?"undefined":r(e))+". Please use a boolean.");return o=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled")},n.log=function(){if("object"===("undefined"==typeof window?"undefined":r(window))){if(i)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},n.deprecated=function(e,t){if(!o)return;console.warn(e+" is deprecated, please use "+t+" instead.")},n.detectBrowser=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var n=e.navigator;if(n.mozGetUserMedia)t.browser="firefox",t.version=s(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=s(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=s(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=s(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t},n.compactObject=function e(t){if(!a(t))return t;return Object.keys(t).reduce(function(n,r){var i=a(t[r]),o=i?e(t[r]):t[r],s=i&&!Object.keys(o).length;return void 0===o||s?n:Object.assign(n,function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n;return e}({},r,o))},{})},n.walkStats=c,n.filterStats=function(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(function(t){e.forEach(function(n){n.type===r&&n.trackId===t.id&&c(e,n,i)})}),i};var i=!0,o=!0;function s(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(function(r){r.endsWith("Id")?c(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach(function(t){c(e,e.get(t),n)})}))}},{}],132:[function(e,t,n){"use strict";var r,i=e("./qbChatHelpers"),o=e("../../qbConfig"),s=e("../../qbUtils"),a=e("../../plugins/streamManagement"),c="This function isn't supported outside of the browser (...yet)";if(s.getEnv().browser){var l=e("../../qbStrophe");Strophe.addNamespace("CARBONS",i.MARKERS.CARBONS),Strophe.addNamespace("CHAT_MARKERS",i.MARKERS.CHAT),Strophe.addNamespace("PRIVACY_LIST",i.MARKERS.PRIVACY),Strophe.addNamespace("CHAT_STATES",i.MARKERS.STATES)}else s.getEnv().nativescript?r=e("nativescript-xmpp-client"):s.getEnv().node&&(r=e("node-xmpp-client"));function u(e){var t,n=this;n.webrtcSignalingProcessor=null,s.getEnv().browser?(n.connection=l(n._OnLogListener.bind(this)),n.connection.XHandlerReferences=[],n.connection.XAddTrackedHandler=function(e,t,r,i,o,s,a){n.connection.XHandlerReferences.push(n.connection.addHandler(e,t,r,i,o,s,a))},n.connection.XDeleteHandlers=function(){for(;n.connection.XHandlerReferences.length;)n.connection.deleteHandler(n.connection.XHandlerReferences.pop())},t=n.connection.send,n.connection.send=function(e){if(!n.connection.connected)throw new i.ChatNotConnectedError("Chat is not connected");t.call(n.connection,e)}):(s.getEnv().nativescript?n.Client=new r.Client({websocket:{url:o.chatProtocol.websocket},autostart:!1}):s.getEnv().node&&(n.Client=new r({autostart:!1})),t=n.Client.send,n.Client.send=function(e){s.QBLog("[QBChat]","SENT:",e.toString()),t.call(n.Client,e)},n.nodeStanzasCallbacks={}),this.service=e,this.isConnected=!1,this._isConnecting=!1,this._isLogout=!1,this._checkConnectionTimer=void 0,this._checkConnectionPingTimer=void 0,this._chatPingFailedCounter=0,this._onlineStatus=!0,this._checkExpiredSessionTimer=void 0,this._sessionHasExpired=!1,this._pings={},this.helpers=new f;var c={service:e,helpers:n.helpers,stropheClient:n.connection,xmppClient:n.Client,nodeStanzasCallbacks:n.nodeStanzasCallbacks};this.roster=new d(c),this.privacylist=new p(c),this.muc=new h(c),this.chatUtils=i,o.streamManagement.enable&&(2===o.chatProtocol.active?(this.streamManagement=new a(o.streamManagement),n._sentMessageCallback=function(e,t){"function"==typeof n.onSentMessageCallback&&(t?n.onSentMessageCallback(null,t):n.onSentMessageCallback(e))}):s.QBLog("[QBChat] StreamManagement:",'BOSH protocol doesn\'t support stream management. Set WebSocket as the "chatProtocol" parameter to use this functionality. https://quickblox.com/developers/Javascript#Configuration')),this._onMessage=function(e){var t,r,o,a,c=i.getAttr(e,"from"),l=(i.getAttr(e,"to"),i.getAttr(e,"type")),u=i.getAttr(e,"id"),d=i.getElement(e,"markable"),h=i.getElement(e,"received"),p=i.getElement(e,"displayed"),f=i.getElement(e,"composing"),m=i.getElement(e,"paused"),g=i.getElement(e,"invite"),v=i.getElement(e,"delay"),y=i.getElement(e,"extraParams"),b=i.getElementText(e,"body"),S=i.getElement(e,"forwarded");if(s.getEnv().browser)o=e.querySelector("forwarded")?e.querySelector("forwarded").querySelector("message").getAttribute("to"):null,a=n.connection.jid;else{var C=S?i.getElement(S,"message"):null;o=C?i.getAttr(C,"to"):null,a=n.Client.options.jid.user}r=o?n.helpers.getIdFromNode(o):null;var _="groupchat"===l?n.helpers.getDialogIdFromNode(c):null,w="groupchat"===l?n.helpers.getIdFromResource(c):n.helpers.getIdFromNode(c),T=h||p||null;if(g)return!0;if(y&&(t=i.parseExtraParams(y)).dialogId&&(_=t.dialogId),f||m)return"function"!=typeof n.onMessageTypingListener||"chat"!==l&&"groupchat"!==l&&v||s.safeCallbackCall(n.onMessageTypingListener,!!f,w,_),!0;if(T)return h?"function"==typeof n.onDeliveredStatusListener&&"chat"===l&&s.safeCallbackCall(n.onDeliveredStatusListener,i.getAttr(h,"id"),_,w):"function"==typeof n.onReadStatusListener&&"chat"===l&&s.safeCallbackCall(n.onReadStatusListener,i.getAttr(p,"id"),_,w),!0;if(d&&w!=n.helpers.getIdFromNode(a)){var E={messageId:u,userId:w,dialogId:_};n.sendDeliveredStatus(E)}var x={id:u,dialog_id:_,recipient_id:r,type:l,body:b,extension:t?t.extension:null,delay:v};return d&&(x.markable=1),"function"!=typeof n.onMessageListener||"chat"!==l&&"groupchat"!==l||s.safeCallbackCall(n.onMessageListener,w,x),!0},this._onPresence=function(e){var t,o,a,c,l,u=i.getAttr(e,"from"),d=(i.getAttr(e,"to"),i.getAttr(e,"id")),h=i.getAttr(e,"type"),p=n.helpers.getIdFromNode(n.helpers.userCurrentJid(s.getEnv().browser?n.connection:n.Client)),f=i.getElement(e,"x");if(f&&(t=i.getAttr(f,"xmlns"),(o=i.getElement(f,"status"))&&(a=i.getAttr(o,"code"))),t&&"http://jabber.org/protocol/muc#user"==t){if(c=n.helpers.getDialogIdFromNode(u),l=n.helpers.getUserIdFromRoomJid(u),o&&"301"==a){if("function"==typeof n.onKickOccupant){var m=i.getElement(i.getElement(f,"item"),"actor"),g=i.getAttr(m,"jid");s.safeCallbackCall(n.onKickOccupant,c,n.helpers.getIdFromNode(g))}return delete n.muc.joinedRooms[n.helpers.getRoomJidFromRoomFullJid(u)],!0}if(!o&&l!=p)return h&&"unavailable"===h?("function"==typeof n.onLeaveOccupant&&s.safeCallbackCall(n.onLeaveOccupant,c,parseInt(l)),!0):("function"==typeof n.onJoinOccupant&&s.safeCallbackCall(n.onJoinOccupant,c,parseInt(l)),!0)}if(!s.getEnv().browser&&t)if("http://jabber.org/protocol/muc#user"==t){if(h&&"unavailable"===h)return o&&"110"==a&&"function"==typeof n.nodeStanzasCallbacks["muc:leave"]&&s.safeCallbackCall(n.nodeStanzasCallbacks["muc:leave"],null),!0;if(d.endsWith(":join")&&o&&"110"==a)return"function"==typeof n.nodeStanzasCallbacks[d]&&n.nodeStanzasCallbacks[d](e),!0}else if(h&&"error"===h&&"http://jabber.org/protocol/muc"==t)return d.endsWith(":join")&&"function"==typeof n.nodeStanzasCallbacks[d]&&n.nodeStanzasCallbacks[d](e),!0;if(l=n.helpers.getIdFromNode(u),h)switch(h){case"subscribe":n.roster.contacts[l]&&"to"===n.roster.contacts[l].subscription?(n.roster.contacts[l]={subscription:"both",ask:null},n.roster._sendSubscriptionPresence({jid:u,type:"subscribed"})):"function"==typeof n.onSubscribeListener&&s.safeCallbackCall(n.onSubscribeListener,l);break;case"subscribed":n.roster.contacts[l]&&"from"===n.roster.contacts[l].subscription?n.roster.contacts[l]={subscription:"both",ask:null}:(n.roster.contacts[l]={subscription:"to",ask:null},"function"==typeof n.onConfirmSubscribeListener&&s.safeCallbackCall(n.onConfirmSubscribeListener,l));break;case"unsubscribed":n.roster.contacts[l]={subscription:"none",ask:null},"function"==typeof n.onRejectSubscribeListener&&s.safeCallbackCall(n.onRejectSubscribeListener,l);break;case"unsubscribe":n.roster.contacts[l]={subscription:"to",ask:null};break;case"unavailable":"function"==typeof n.onContactListListener&&n.roster.contacts[l]&&"none"!==n.roster.contacts[l].subscription&&s.safeCallbackCall(n.onContactListListener,l,h),l===p&&(s.getEnv().browser?n.connection.send($pres()):n.Client.send(i.createStanza(r.Stanza,null,"presence")))}else"function"==typeof n.onContactListListener&&n.roster.contacts[l]&&"none"!==n.roster.contacts[l].subscription&&s.safeCallbackCall(n.onContactListListener,l);return!0},this._onIQ=function(e){var t=i.getAttr(e,"id"),o=t.indexOf("lastActivity")>-1,a=t.indexOf("ping")>-1,c=i.getElement(e,"ping"),l=i.getAttr(e,"type"),u=i.getAttr(e,"from"),d=u?n.helpers.getIdFromNode(u):null;if("function"==typeof n.onLastUserActivityListener&&o){var h=i.getElement(e,"query"),p=i.getElement(e,"error")?void 0:+i.getAttr(h,"seconds");s.safeCallbackCall(n.onLastUserActivityListener,d,p)}if((c||a)&&l)if("get"===l&&c&&n.isConnected){var f=s.getEnv().browser?$iq:r.Stanza,m={from:n.helpers.getUserCurrentJid(),id:t,to:u,type:"result"},g=i.createStanza(f,m,"iq");s.getEnv().browser?n.connection.send(g):n.Client.send(g)}else{var v=n._pings[t];v&&(v.callback&&v.callback(null),v.interval&&clearInterval(v.interval),n._pings[t]=void 0,delete n._pings[t])}return s.getEnv().browser||n.nodeStanzasCallbacks[t]&&(s.safeCallbackCall(n.nodeStanzasCallbacks[t],e),delete n.nodeStanzasCallbacks[t]),!0},this._onSystemMessageListener=function(e){var t,r=i.getAttr(e,"from"),o=(i.getAttr(e,"to"),i.getAttr(e,"id")),a=i.getElement(e,"extraParams"),c=n.helpers.getIdFromNode(r),l=i.getElement(e,"delay"),u=i.getElementText(a,"moduleIdentifier"),d=i.getElementText(e,"body"),h=i.parseExtraParams(a);return"SystemNotifications"===u&&"function"==typeof n.onSystemMessageListener?(t={id:o,userId:c,body:d,extension:h.extension},s.safeCallbackCall(n.onSystemMessageListener,t)):n.webrtcSignalingProcessor&&!l&&"WebRTCVideoChat"===u&&n.webrtcSignalingProcessor._onMessage(r,a,l,c,h.extension),!0},this._onMessageErrorListener=function(e){var t=i.getAttr(e,"id"),r=i.getErrorFromXMLNode(e);return"function"==typeof n.onMessageErrorListener&&s.safeCallbackCall(n.onMessageErrorListener,t,r),!0}}function d(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks,this.contacts={}}function h(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks,this.joinedRooms={}}function p(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks}function f(){this._userCurrentJid=""}u.prototype={_OnLogListener:function(e){"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,e)},connect:function(e,t){s.QBLog("[QBChat]","Connect with parameters "+JSON.stringify(e));var n,r=this,a=i.buildUserJid(e),c="function"==typeof t;return r._isConnecting?(n=s.getError(422,"Status.REJECT - The connection is still in the Status.CONNECTING state","QBChat"),void(c&&t(n,null))):r.isConnected?(s.QBLog("[QBChat]","Status.CONNECTED - You are already connected"),void(c&&t(null,r.roster.contacts))):(r._isConnecting=!0,r._isLogout=!1,s.getEnv().browser&&(s.QBLog("[QBChat]","!!---Browser env - connected--!!"),r.connection.connect(a,e.password,function(a,l,u){switch(s.QBLog("[QBChat]","self.connection.connect called with status "+a),s.QBLog("[QBChat]","self.connection.connect called with condition "+l),s.QBLog("[QBChat]","self.connection.connect called with elem "+u),a){case Strophe.Status.ERROR:s.QBLog("[QBChat]","Status.ERROR at "+i.getLocalTime()),s.QBLog("[QBChat]","ERROR CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ERROR at "+i.getLocalTime()+" ERROR CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(422,"Status.ERROR - An error has occurred","QBChat"),c&&t(n,null);break;case Strophe.Status.CONNFAIL:s.QBLog("[QBChat]","Status.CONNFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNFAIL at "+i.getLocalTime()+" CONNFAIL CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(422,"Status.CONNFAIL - The connection attempt failed","QBChat"),c&&t(n,null);break;case Strophe.Status.AUTHENTICATING:s.QBLog("[QBChat]","Status.AUTHENTICATING at "+i.getLocalTime()),s.QBLog("[QBChat]","AUTHENTICATING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.AUTHENTICATING at "+i.getLocalTime()+" AUTHENTICATING CONDITION: "+l);break;case Strophe.Status.AUTHFAIL:s.QBLog("[QBChat]","Status.AUTHFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","AUTHFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.AUTHFAIL at "+i.getLocalTime()+" AUTHFAIL CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(401,"Status.AUTHFAIL - The authentication attempt failed","QBChat"),c&&t(n,null),r.isConnected||"function"!=typeof r.onReconnectFailedListener||s.safeCallbackCall(r.onReconnectFailedListener,n);break;case Strophe.Status.CONNECTING:s.QBLog("[QBChat]","Status.CONNECTING","(Chat Protocol - "+(1===o.chatProtocol.active?"BOSH":"WebSocket)")),s.QBLog("[QBChat]","Status.CONNECTING at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNECTING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNECTING at (Chat Protocol - "+o.chatProtocol.active===1?"BOSH":"WebSocket)"+i.getLocalTime()+" CONNECTING CONDITION: "+l);break;case Strophe.Status.CONNECTED:s.QBLog("[QBChat]","Status.CONNECTED at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNECTED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNECTED at "+i.getLocalTime()+" CONNECTED CONDITION: "+l),r.connection.XDeleteHandlers(),r.connection.XAddTrackedHandler(r._onMessage,null,"message","chat"),r.connection.XAddTrackedHandler(r._onMessage,null,"message","groupchat"),r.connection.XAddTrackedHandler(r._onPresence,null,"presence"),r.connection.XAddTrackedHandler(r._onIQ,null,"iq"),r.connection.XAddTrackedHandler(r._onSystemMessageListener,null,"message","headline"),r.connection.XAddTrackedHandler(r._onMessageErrorListener,null,"message","error");var d=void 0===r._checkConnectionPingTimer;if((d=0!==o.pingLocalhostTimeInterval&&d)&&(s.QBLog("[QBChat]","Init ping to chat at ",s.getCurrentTime()),r._checkConnectionPingTimer=setInterval(function(){try{r.pingchat(function(t){t?(s.QBLog("[QBChat]","Chat Ping: ","failed, at ",s.getCurrentTime(),"_chatPingFailedCounter: ",r._chatPingFailedCounter," error: ",t),r._chatPingFailedCounter+=1,r._chatPingFailedCounter>=o.chatPingMissLimit&&(r.isConnected&&"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r._chatPingFailedCounter=0,r._establishConnection(e,"CONNECTED have SDK ping failed"))):(s.QBLog("[QBChat]","Chat Ping: ","ok, at ",s.getCurrentTime(),"_chatPingFailedCounter: ",r._chatPingFailedCounter),r._chatPingFailedCounter=0)})}catch(e){s.QBLog("[QBChat]","Chat Ping: ","Exception, at ",s.getCurrentTime(),", detail info: ",e)}},1e3*o.pingLocalhostTimeInterval)),"function"==typeof r.onSessionExpiredListener)void 0===r._checkExpiredSessionTimer&&(s.QBLog("[QBChat]","Init timer for check session expired at ",(new Date).toTimeString().split(" ")[0]),r._checkExpiredSessionTimer=setInterval(function(){var e=new Date;void 0!==o.qbTokenExpirationDate&&(Math.round((e.getTime()-o.qbTokenExpirationDate.getTime())/6e4)>=0&&(r._sessionHasExpired=!0,s.safeCallbackCall(r.onSessionExpiredListener,null)))},5e3));r._postConnectActions(function(e){t(null,e)},c);break;case Strophe.Status.DISCONNECTING:s.QBLog("[QBChat]","Status.DISCONNECTING at "+i.getLocalTime()),s.QBLog("[QBChat]","DISCONNECTING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.DISCONNECTING at "+i.getLocalTime()+" DISCONNECTING CONDITION: "+l);break;case Strophe.Status.DISCONNECTED:s.QBLog("[QBChat]","Status.DISCONNECTED at "+i.getLocalTime()),s.QBLog("[QBChat]","DISCONNECTED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.DISCONNECTED at "+i.getLocalTime()+" DISCONNECTED CONDITION: "+l),r.isConnected&&"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r.connection.reset(),r._establishConnection(e,"DISCONNECTED");break;case Strophe.Status.ATTACHED:s.QBLog("[QBChat]","Status.ATTACHED at "+i.getLocalTime()),s.QBLog("[QBChat]","ATTACHED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ATTACHED at "+i.getLocalTime()+" ATTACHED CONDITION: "+l);break;case Strophe.Status.REDIRECT:s.QBLog("[QBChat]","Status.REDIRECT at "+i.getLocalTime()),s.QBLog("[QBChat]","REDIRECT CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.REDIRECT at "+i.getLocalTime()+" REDIRECT CONDITION: "+l);break;case Strophe.Status.CONNTIMEOUT:s.QBLog("[QBChat]","Status.CONNTIMEOUT at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNTIMEOUT CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNTIMEOUT at "+i.getLocalTime()+" CONNTIMEOUT CONDITION: "+l);break;case Strophe.Status.BINDREQUIRED:s.QBLog("[QBChat]","Status.BINDREQUIRED at "+i.getLocalTime()),s.QBLog("[QBChat]","BINDREQUIRED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.BINDREQUIRED at "+i.getLocalTime()+" BINDREQUIRED CONDITION: "+l);break;case Strophe.Status.ATTACHFAIL:s.QBLog("[QBChat]","Status.ATTACHFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","ATTACHFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ATTACHFAIL at "+i.getLocalTime()+" ATTACHFAIL CONDITION: "+l);break;default:s.QBLog("[QBChat]","Status is unknown at "+i.getLocalTime()),s.QBLog("[QBChat]","unknown CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status is unknown at "+i.getLocalTime()+" unknown CONDITION: "+l)}})),void(s.getEnv().browser||(s.QBLog("[QBChat]","!!--call branch code connect for node--!!"),r.Client.removeAllListeners(),r.Client.on("connect",function(){s.QBLog("[QBChat]","Status.CONNECTING","(Chat Protocol - "+(1===o.chatProtocol.active?"BOSH":"WebSocket)"))}),r.Client.on("auth",function(){s.QBLog("[QBChat]","Status.AUTHENTICATING")}),r.Client.on("online",function(){r._postConnectActions(function(e){t(null,e)},c)}),r.Client.on("stanza",function(e){s.QBLog("[QBChat] RECV:",e.toString()),e.is("presence")?r._onPresence(e):e.is("iq")?r._onIQ(e):e.is("message")&&("headline"===e.attrs.type?r._onSystemMessageListener(e):"error"===e.attrs.type?r._onMessageErrorListener(e):r._onMessage(e))}),r.Client.on("disconnect",function(){s.QBLog("[QBChat]","Status.DISCONNECTED - "+i.getLocalTime()),"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r._establishConnection(e,"NODE:DISCONNECTED")}),r.Client.on("error",function(){s.QBLog("[QBChat]","Status.ERROR - "+i.getLocalTime()),n=s.getError(422,"Status.ERROR - An error has occurred","QBChat"),c&&t(n,null),r.isConnected=!1,r._isConnecting=!1}),r.Client.on("end",function(){r.Client.removeAllListeners()}),r.Client.options.jid=a,r.Client.options.password=e.password,r.Client.connect())))},_postConnectActions:function(e,t){s.QBLog("[QBChat]","Status.CONNECTED at "+i.getLocalTime());var n=this,a=s.getEnv().browser,c=a?n.connection:n.Client,l=a?$pres():i.createStanza(r.Stanza,null,"presence");if(o.streamManagement.enable&&2===o.chatProtocol.active&&(n.streamManagement.enable(n.connection,null),n.streamManagement.sentMessageCallback=n._sentMessageCallback),n.helpers.setUserCurrentJid(n.helpers.userCurrentJid(c)),n.isConnected=!0,n._isConnecting=!1,n._sessionHasExpired=!1,n._enableCarbons(),t)n.roster.get(function(t){c.send(l),n.roster.contacts=t,e(n.roster.contacts)});else{var u=Object.keys(n.muc.joinedRooms);c.send(l),s.QBLog("[QBChat]","Re-joining "+u.length+" rooms...");for(var d=0,h=u.length;d<h;d++)n.muc.join(u[d]);"function"==typeof n.onReconnectListener&&s.safeCallbackCall(n.onReconnectListener)}},_establishConnection:function(e,t){var n=this;if(s.QBLog("[QBChat]","_establishConnection called in "+t),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]_establishConnection called in "+t),n._isLogout||n._checkConnectionTimer)return s.QBLog("[QBChat]","_establishConnection return"),void("function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,(n._isLogout,n._isLogout)));var r=function(){s.QBLog("[QBChat]","call _connect() in _establishConnection in "+t),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat] call _connect() in _establishConnection in "+t),n.isConnected||n._isConnecting||n._sessionHasExpired?(s.QBLog("[QBChat]","stop timer in _establishConnection "),clearInterval(n._checkConnectionTimer),n._checkConnectionTimer=void 0,"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]stop timer in _establishConnection in "+t)):(s.QBLog("[QBChat]"," start EXECUTE connect() in _establishConnection "),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat] start EXECUTE connect() in _establishConnection in "+t+" self.isConnected: "+n.isConnected+" self._isConnecting: "+n._isConnecting+" self._sessionHasExpired: "+n._sessionHasExpired),n.connect(e),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]call _connect() in _establishConnection in "+t+" is executed"))};r(),n._checkConnectionTimer=setInterval(function(){s.QBLog("[QBChat]","self._checkConnectionTimer called with config.chatReconnectionTimeInterval = "+o.chatReconnectionTimeInterval),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]self._checkConnectionTimer called with config.chatReconnectionTimeInterval = "+o.chatReconnectionTimeInterval),r()},1e3*o.chatReconnectionTimeInterval)},reconnect:function(){s.QBLog("[QBChat]","Call reconnect "),"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,"[QBChat][SDK v"+o.version+"] Call reconnect "+i.getLocalTime()),clearInterval(this._checkConnectionTimer),this._checkConnectionTimer=void 0,this.muc.joinedRooms={},this.helpers.setUserCurrentJid(""),s.getEnv().browser?(this.connection.flush(),this.connection.disconnect("call Qb.chat.reconnect")):this.Client.end()},send:function(e,t){s.QBLog("[QBChat]","Call send "+JSON.stringify(t));var n=s.getEnv().browser?$msg:r.Stanza,a={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:t.type?t.type:"chat",id:t.id?t.id:s.getBsonObjectId()},c=i.createStanza(n,a);return t.body&&c.c("body",{xmlns:i.MARKERS.CLIENT}).t(t.body).up(),t.markable&&c.c("markable",{xmlns:i.MARKERS.CHAT}).up(),t.extension&&(c.c("extraParams",{xmlns:i.MARKERS.CLIENT}),c=i.filledExtraParams(c,t.extension)),s.getEnv().browser?o.streamManagement.enable?(t.id=a.id,t.jid_or_user_id=e,this.connection.send(c,t)):this.connection.send(c):o.streamManagement.enable?(t.id=a.id,t.jid_or_user_id=e,this.Client.send(c,t)):this.Client.send(c),a.id},sendSystemMessage:function(e,t){s.QBLog("[QBChat]","Call sendSystemMessage "+JSON.stringify(t));var n=s.getEnv().browser?$msg:r.Stanza,o={type:"headline",id:t.id?t.id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e)},a=i.createStanza(n,o);return t.body&&a.c("body",{xmlns:i.MARKERS.CLIENT}).t(t.body).up(),s.getEnv().browser?(t.extension&&(a.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("moduleIdentifier").t("SystemNotifications").up(),a=i.filledExtraParams(a,t.extension)),this.connection.send(a)):(t.extension&&(a.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("moduleIdentifier").t("SystemNotifications"),a=i.filledExtraParams(a,t.extension)),this.Client.send(a)),o.id},sendIsTypingStatus:function(e){s.QBLog("[QBChat]","Call sendIsTypingStatus ");var t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("composing",{xmlns:i.MARKERS.STATES}),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendIsStopTypingStatus:function(e){s.QBLog("[QBChat]","Call sendIsStopTypingStatus ");var t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("paused",{xmlns:i.MARKERS.STATES}),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendDeliveredStatus:function(e){s.QBLog("[QBChat]","Call sendDeliveredStatus ");var t={type:"chat",from:this.helpers.getUserCurrentJid(),id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e.userId)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("received",{xmlns:i.MARKERS.MARKERS,id:e.messageId}).up(),o.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("dialog_id").t(e.dialogId),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendReadStatus:function(e){s.QBLog("[QBChat]","Call sendReadStatus "+JSON.stringify(e));var t={type:"chat",from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.userId),id:s.getBsonObjectId()},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("displayed",{xmlns:i.MARKERS.MARKERS,id:e.messageId}).up(),o.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("dialog_id").t(e.dialogId),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},getLastUserActivity:function(e){var t,n,o;s.QBLog("[QBChat]","Call getLastUserActivity "),t={from:this.helpers.getUserCurrentJid(),id:this.helpers.getUniqueId("lastActivity"),to:this.helpers.jidOrUserId(e),type:"get"},n=s.getEnv().browser?$iq:r.Stanza,(o=i.createStanza(n,t,"iq")).c("query",{xmlns:i.MARKERS.LAST}),s.getEnv().browser?this.connection.sendIQ(o):this.Client.send(o)},pingchat:function(e){s.QBLog("[QBChat]","ping chat");var t,n,a,c=this,l=this.helpers.getUniqueId("ping"),u=s.getEnv().browser?$iq:r.Stanza;t=o.endpoints.chat?o.endpoints.chat:"chat.quickblox.com",n=e;var d={from:this.helpers.getUserCurrentJid(),id:l,to:t,type:"get"};(a=i.createStanza(u,d,"iq")).c("ping",{xmlns:"urn:xmpp:ping"});return s.getEnv().browser?this.connection.send(a):this.Client.send(a),this._pings[l]={callback:n,interval:setTimeout(function(){n("Chat ping No answer"),c._pings[l]=void 0,delete c._pings[l]},1e3*o.pingTimeout)},l},ping:function(e,t){s.QBLog("[QBChat]","Call ping ");var n,a,c,l=this,u=this.helpers.getUniqueId("ping"),d=s.getEnv().browser?$iq:r.Stanza;if("string"!=typeof e&&"number"!=typeof e||"function"!=typeof t){if("function"!=typeof e||t)throw new Error("Invalid arguments provided. Either userId/jid (number/string) and callback or only callback should be provided.");n=o.endpoints.chat,a=e}else n=this.helpers.jidOrUserId(e),a=t;var h={from:this.helpers.getUserCurrentJid(),id:u,to:n,type:"get"};(c=i.createStanza(d,h,"iq")).c("ping",{xmlns:"urn:xmpp:ping"});return s.getEnv().browser?this.connection.send(c):this.Client.send(c),this._pings[u]={callback:a,interval:setTimeout(function(){a("No answer"),l._pings[u]=void 0,delete l._pings[u]},1e3*o.pingTimeout)},u},disconnect:function(){s.QBLog("[QBChat]","Call disconnect "),"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,"[QBChat][SDK v"+o.version+"] Call disconnect "+i.getLocalTime()),clearInterval(this._checkConnectionTimer),clearInterval(this._checkExpiredSessionTimer),this._checkConnectionTimer=void 0,this._checkExpiredSessionTimer=void 0,this.muc.joinedRooms={},this._isLogout=!0,this.helpers.setUserCurrentJid(""),s.getEnv().browser?(this.connection.flush(),this.connection.disconnect("call QB.chat.disconnect"),void 0!==this._checkConnectionPingTimer&&(s.QBLog("[QBChat]","Stop ping"),clearInterval(this._checkConnectionPingTimer),this._checkConnectionPingTimer=void 0)):this.Client.end()},addListener:function(e,t){if(s.QBLog("[Deprecated!]","Avoid using it, this feature will be removed in future version."),!s.getEnv().browser)throw new Error(c);return this.connection.XAddTrackedHandler(function(){return t(),!1!==e.live},null,e.name||null,e.type||null,e.id||null,e.from||null)},deleteListener:function(e){if(s.QBLog("[Deprecated!]","Avoid using it, this feature will be removed in future version."),!s.getEnv().browser)throw new Error(c);this.connection.deleteHandler(e)},_enableCarbons:function(e){var t={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("enableCarbons")},n=s.getEnv().browser?$iq:r.Stanza,o=i.createStanza(n,t,"iq");o.c("enable",{xmlns:i.MARKERS.CARBONS}),s.getEnv().browser?this.connection.sendIQ(o):this.Client.send(o)}},d.prototype={get:function(e){var t=this,n={},o={type:"get",from:t.helpers.getUserCurrentJid(),id:i.getUniqueId("getRoster")},a=s.getEnv().browser?$iq:r.Stanza,c=i.createStanza(a,o,"iq");function l(r){for(var o=function(e){return s.getEnv().browser?e.getElementsByTagName("item"):e.getChild("query").children}(r),a=0,c=o.length;a<c;a++){var l=t.helpers.getIdFromNode(i.getAttr(o[a],"jid")),u=i.getAttr(o[a],"ask"),d=i.getAttr(o[a],"subscription");n[l]={subscription:d,ask:u||null}}e(n)}c.c("query",{xmlns:i.MARKERS.ROSTER}),s.getEnv().browser?t.connection.sendIQ(c,l):(t.nodeStanzasCallbacks[o.id]=l,t.Client.send(c))},add:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"none",ask:"subscribe"},this._sendSubscriptionPresence({jid:n,type:"subscribe"}),"function"==typeof t&&t()},confirm:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"from",ask:"subscribe"},this._sendSubscriptionPresence({jid:n,type:"subscribed"}),this._sendSubscriptionPresence({jid:n,type:"subscribe"}),"function"==typeof t&&t()},reject:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"none",ask:null},this._sendSubscriptionPresence({jid:n,type:"unsubscribed"}),"function"==typeof t&&t()},remove:function(e,t){var n=this,o=this.helpers.jidOrUserId(e),a=this.helpers.getIdFromNode(o),c={type:"set",from:n.connection?n.connection.jid:n.Client.jid.user,id:i.getUniqueId("getRoster")},l=s.getEnv().browser?$iq:r.Stanza,u=i.createStanza(l,c,"iq");function d(){delete n.contacts[a],"function"==typeof t&&t()}u.c("query",{xmlns:i.MARKERS.ROSTER}).c("item",{jid:o,subscription:"remove"}),s.getEnv().browser?n.connection.sendIQ(u,d):(n.nodeStanzasCallbacks[c.id]=d,n.Client.send(u))},_sendSubscriptionPresence:function(e){var t=s.getEnv().browser?$pres:r.Stanza,n={to:e.jid,type:e.type},o=i.createStanza(t,n,"presence");s.getEnv().browser?this.connection.send(o):this.Client.send(o)}},h.prototype={join:function(e,t){var n=this,o=i.getUniqueId("join"),a=this.helpers.getDialogJid(e),c={id:o,from:n.helpers.getUserCurrentJid(),to:n.helpers.getRoomJid(a)},l=s.getEnv().browser?$pres:r.Stanza,u=i.createStanza(l,c,"presence");function d(e){var r=i.getAttr(e,"id"),o=i.getAttr(e,"from"),a=n.helpers.getDialogIdFromNode(o),c=i.getElement(e,"x"),l=i.getAttr(c,"xmlns"),u=i.getElement(c,"status"),d=i.getAttr(u,"code");if(1==t.length)return s.safeCallbackCall(t,e),!0;if(u&&"110"==d)s.safeCallbackCall(t,null,{dialogId:a});else{var h=i.getAttr(e,"type");if(h&&"error"===h&&"http://jabber.org/protocol/muc"==l&&r.endsWith(":join")){var p=i.getElement(e,"error"),f=i.getAttr(p,"code"),m=i.getElementText(p,"text");s.safeCallbackCall(t,{code:f||500,message:m||"Unknown issue"},{dialogId:a})}}}u.c("x",{xmlns:i.MARKERS.MUC}).c("history",{maxstanzas:0}),this.joinedRooms[a]=!0,s.getEnv().browser?("function"==typeof t&&n.connection.XAddTrackedHandler(d,null,"presence",null,o),n.connection.send(u)):("function"==typeof t&&(n.nodeStanzasCallbacks[o]=d),n.Client.send(u))},leave:function(e,t){var n=this,o={type:"unavailable",from:n.helpers.getUserCurrentJid(),to:n.helpers.getRoomJid(e)},a=s.getEnv().browser?$pres:r.Stanza,c=i.createStanza(a,o,"presence");function l(e){var r=i.getAttr(e,"id"),o=i.getAttr(e,"from"),a=n.helpers.getDialogIdFromNode(o),c=i.getElement(e,"x"),l=i.getAttr(c,"xmlns"),u=i.getElement(c,"status"),d=i.getAttr(u,"code");if(u&&"110"==d)s.safeCallbackCall(t,null,{dialogId:a});else{var h=i.getAttr(e,"type");if(h&&"error"===h&&"http://jabber.org/protocol/muc"==l&&r.endsWith(":join")){var p=i.getElement(e,"error"),f=i.getAttr(p,"code"),m=i.getElementText(p,"text");s.safeCallbackCall(t,{code:f||500,message:m||"Unknown issue"},null)}}}if(delete this.joinedRooms[e],s.getEnv().browser){var u=n.helpers.getRoomJid(e);"function"==typeof t&&n.connection.XAddTrackedHandler(l,null,"presence",o.type,null,u),n.connection.send(c)}else"function"==typeof t&&(n.nodeStanzasCallbacks["muc:leave"]=l),n.Client.send(c)},listOnlineUsers:function(e,t){var n=this,o=[],a={type:"get",to:e,from:n.helpers.getUserCurrentJid(),id:i.getUniqueId("muc_disco_items")},c=s.getEnv().browser?$iq:r.Stanza,l=i.createStanza(c,a,"iq");l.c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),s.getEnv().browser?n.connection.sendIQ(l,function(e){for(var r,i=e.getElementsByTagName("item"),s=0,a=i.length;s<a;s++)r=n.helpers.getUserIdFromRoomJid(i[s].getAttribute("jid")),o.push(parseInt(r));t(o)}):(n.Client.send(l),n.nodeStanzasCallbacks[a.id]=function(e){var r=e.attrs.id;if(n.nodeStanzasCallbacks[r]){for(var i,o=[],s=e.getChild("query").getChildElements("item"),a=0,c=s.length;a<c;a++)i=n.helpers.getUserIdFromRoomJid(s[a].attrs.jid),o.push(parseInt(i));t(o)}})}},p.prototype={create:function(e,t){for(var n,o,a,c,l,u,d={},h=e.items.length-1;h>=0;h--){var p=e.items[h];d[p.user_id]={action:p.action,mutualBlock:!0===p.mutualBlock}}u=Object.keys(d);var f={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("edit")},m=s.getEnv().browser?$iq:r.Stanza,g=i.createStanza(m,f,"iq");function v(e,t){s.getEnv().browser?e.c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up():e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up();return e}function y(e,t){s.getEnv().browser?e.c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up():e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up();return e}g.c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e.name});for(var b=0,S=0,C=u.length;b<C;b++,S+=2)l=d[n=u[b]].mutualBlock,c=d[n].action,o=this.helpers.jidOrUserId(parseInt(n,10)),a=this.helpers.getUserNickWithMucDomain(n),l&&"deny"===c?(g=y(g,{order:S+1,jidOrMuc:o,userAction:c}),g=y(g,{order:S+2,jidOrMuc:a,userAction:c}).up().up()):(g=v(g,{order:S+1,jidOrMuc:o,userAction:c}),g=v(g,{order:S+2,jidOrMuc:a,userAction:c}));s.getEnv().browser?this.connection.sendIQ(g,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))}):(this.Client.send(g),this.nodeStanzasCallbacks[f.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)})},getList:function(e,t){var n,o,a,c=this,l=[],u={type:"get",from:c.helpers.getUserCurrentJid(),id:i.getUniqueId("getlist")},d=s.getEnv().browser?$iq:r.Stanza,h=i.createStanza(d,u,"iq");h.c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e}),s.getEnv().browser?c.connection.sendIQ(h,function(r){for(var i=0,s=(n=r.getElementsByTagName("item")).length;i<s;i+=2)o=n[i].getAttribute("value"),a=c.helpers.getIdFromNode(o),l.push({user_id:a,action:n[i].getAttribute("action")});t(null,{name:e,items:l})},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n,null)}else t(s.getError(408),null)}):(c.nodeStanzasCallbacks[u.id]=function(e){for(var n,r,i=e.getChild("query"),o=i?i.getChild("list"):null,s=o?o.getChildElements("item"):null,a=[],l=0,d=s.length;l<d;l+=2)n=s[l].attrs.value,r=c.helpers.getIdFromNode(n),a.push({user_id:r,action:s[l].attrs.action});o={name:o.attrs.name,items:a},t(null,o),delete c.nodeStanzasCallbacks[u.id]},c.Client.send(h))},update:function(e,t){var n=this;n.getList(e.name,function(r,i){if(r)t(r,null);else{var o={};o.items=s.MergeArrayOfObjects(i.items,e.items),o.name=e.name,n.create(o,function(e,n){r?t(e,null):t(null,n)})}})},getNames:function(e){var t,n={type:"get",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("getNames")};s.getEnv().browser?(t=$iq(n).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}),this.connection.sendIQ(t,function(t){for(var n=[],r=t.getElementsByTagName("default"),i=t.getElementsByTagName("active"),o=t.getElementsByTagName("list"),s=r&&r.length>0?r[0].getAttribute("name"):null,a=i&&i.length>0?i[0].getAttribute("name"):null,c=0,l=o.length;c<l;c++)n.push(o[c].getAttribute("name"));e(null,{default:s,active:a,names:n})},function(t){if(t){var n=i.getErrorFromXMLNode(t);e(n,null)}else e(s.getError(408),null)})):((t=new r.Stanza("iq",n)).c("query",{xmlns:i.MARKERS.PRIVACY}),this.nodeStanzasCallbacks[t.attrs.id]=function(t){if("error"!==t.attrs.type){for(var n=[],r=t.getChild("query"),i=r.getChild("default"),o=r.getChild("active"),a=r.getChildElements("list"),c=i?i.attrs.name:null,l=o?o.attrs.name:null,u=0,d=a.length;u<d;u++)n.push(a[u].attrs.name);e(null,{default:c,active:l,names:n})}else e(s.getError(408))},this.Client.send(t))},delete:function(e,t){var n,o={from:this.connection?this.connection.jid:this.Client.jid.user,type:"set",id:i.getUniqueId("remove")};s.getEnv().browser?(n=$iq(o).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:e||""}),this.connection.sendIQ(n,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((n=new r.Stanza("iq",o)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e||""}),this.nodeStanzasCallbacks[o.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)},this.Client.send(n))},setAsDefault:function(e,t){var n,o=this,a={from:this.connection?this.connection.jid:this.Client.jid.user,type:"set",id:i.getUniqueId("default")};function c(n){var o,a={from:n.connection?n.connection.jid:n.Client.jid.user,type:"set",id:i.getUniqueId("active1")};s.getEnv().browser?(o=$iq(a).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("active",e&&e.length>0?{name:e}:{}),n.connection.sendIQ(o,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((o=new r.Stanza("iq",a)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("active",e&&e.length>0?{name:e}:{}),n.nodeStanzasCallbacks[a.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)},n.Client.send(o))}s.getEnv().browser?(n=$iq(a).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("default",e&&e.length>0?{name:e}:{}),this.connection.sendIQ(n,function(e){c(o)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((n=new r.Stanza("iq",a)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("default",e&&e.length>0?{name:e}:{}),this.nodeStanzasCallbacks[a.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):c(o)},this.Client.send(n))}},f.prototype={getUniqueId:i.getUniqueId,jidOrUserId:function(e){var t;if("string"==typeof e)t=e;else{if("number"!=typeof e)throw new Error('The method "jidOrUserId" may take jid or id');t=e+"-"+o.creds.appId+"@"+o.endpoints.chat}return t},typeChat:function(e){var t;if("string"==typeof e)t=e.indexOf("muc")>-1?"groupchat":"chat";else{if("number"!=typeof e)throw new Error(c);t="chat"}return t},getRecipientId:function(e,t){var n=null;return e.forEach(function(e){e!=t&&(n=e)}),n},getUserJid:function(e,t){return t?e+"-"+t+"@"+o.endpoints.chat:e+"-"+o.creds.appId+"@"+o.endpoints.chat},getUserNickWithMucDomain:function(e){return o.endpoints.muc+"/"+e},getIdFromNode:function(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])},getDialogIdFromNode:function(e){return e.indexOf("@")<0?null:e.split("@")[0].split("_")[1]},getRoomJidFromDialogId:function(e){return o.creds.appId+"_"+e+"@"+o.endpoints.muc},getRoomJid:function(e){return e+"/"+this.getIdFromNode(this._userCurrentJid)},getIdFromResource:function(e){var t=e.split("/");return t.length<2?null:(t.splice(0,1),parseInt(t.join("/")))},getRoomJidFromRoomFullJid:function(e){var t=e.split("/");return t.length<2?null:t[0]},getBsonObjectId:function(){return s.getBsonObjectId()},getUserIdFromRoomJid:function(e){var t=e.toString().split("/");return 0===t.length?null:t[t.length-1]},userCurrentJid:function(e){try{return e instanceof Strophe.Connection?e.jid:e.jid.user+"@"+e.jid._domain+"/"+e.jid._resource}catch(t){return e.jid.user+"@"+e.jid._domain+"/"+e.jid._resource}},getUserCurrentJid:function(){return this._userCurrentJid},setUserCurrentJid:function(e){this._userCurrentJid=e},getDialogJid:function(e){return e.indexOf("@")>0?e:this.getRoomJidFromDialogId(e)}},t.exports=u},{"../../plugins/streamManagement":150,"../../qbConfig":151,"../../qbStrophe":154,"../../qbUtils":155,"./qbChatHelpers":133,"nativescript-xmpp-client":void 0,"node-xmpp-client":60}],133:[function(e,t,n){"use strict";var r=e("../../qbUtils"),i=e("../../qbConfig"),o="Unknown interface. SDK support browser / node env.";function s(e,t,n){var r=new Error(e,t,n);return r.name="ChatNotConnectedError",Object.setPrototypeOf(r,Object.getPrototypeOf(this)),Error.captureStackTrace&&Error.captureStackTrace(r,s),r}s.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(s,Error):s.__proto__=Error;var a={MARKERS:{CLIENT:"jabber:client",CHAT:"urn:xmpp:chat-markers:0",STATES:"http://jabber.org/protocol/chatstates",MARKERS:"urn:xmpp:chat-markers:0",CARBONS:"urn:xmpp:carbons:2",ROSTER:"jabber:iq:roster",MUC:"http://jabber.org/protocol/muc",PRIVACY:"jabber:iq:privacy",LAST:"jabber:iq:last"},ChatNotConnectedError:s,buildUserJid:function(e){var t;return"userId"in e?(t=e.userId+"-"+i.creds.appId+"@"+i.endpoints.chat,"resource"in e&&(t=t+"/"+e.resource)):"jid"in e&&(t=e.jid),t},createStanza:function(e,t,n){return r.getEnv().browser?e(t):new e(n||"message",t)},getAttr:function(e,t){var n;return e?("function"==typeof e.getAttribute?n=e.getAttribute(t):e.attrs&&(n=e.attrs[t]),n||null):null},getElement:function(e,t){var n;if("function"==typeof e.querySelector)n=e.querySelector(t);else{if("function"!=typeof e.getChild)throw o;n=e.getChild(t)||e.children.find(e=>"function"==typeof e.getChild&&this.getElement(e,t))}return n||null},getAllElements:function(e,t){var n;if("function"==typeof e.querySelectorAll)n=e.querySelectorAll(t);else{if("function"!=typeof e.getChild)throw o;n=e.getChild(t)}return n||null},getElementText:function(e,t){var n,r;if("function"==typeof e.querySelector)r=(n=e.querySelector(t))?n.textContent:null;else{if("function"!=typeof e.getChildText)throw o;r=e.getChildText(t)||e.children.find(e=>"function"==typeof e.getChildText&&this.getElementText(e,t))}return r||null},_JStoXML:function(e,t,n){var r=this;n.c(e),Object.keys(t).forEach(function(e){"object"==typeof t[e]?r._JStoXML(e,t[e],n):n.c(e).t(t[e]).up()}),n.up()},_XMLtoJS:function(e,t,n){e[t]={};for(var r=0,i=n.childNodes.length;r<i;r++)n.childNodes[r].childNodes.length>1?e[t]=this._XMLtoJS(e[t],n.childNodes[r].tagName,n.childNodes[r]):e[t][n.childNodes[r].tagName]=n.childNodes[r].textContent;return e},filledExtraParams:function(e,t){var n=this;return Object.keys(t).forEach(function(i){"attachments"===i?t[i].forEach(function(t){r.getEnv().browser?e.c("attachment",t).up():e.getChild("extraParams").c("attachment",t).up()}):"object"==typeof t[i]?n._JStoXML(i,t[i],e):r.getEnv().browser?e.c(i).t(t[i]).up():e.getChild("extraParams").c(i).t(t[i]).up()}),e.up(),e},parseExtraParams:function(e){if(!e)return null;var t,n,i,o={},s=[];if(r.getEnv().browser)for(var a=0,c=e.childNodes.length;a<c;a++)if("attachment"===e.childNodes[a].tagName){n={};for(var l=0,u=(i=e.childNodes[a].attributes).length;l<u;l++)"size"===i[l].name?n[i[l].name]=parseInt(i[l].value):n[i[l].name]=i[l].value;s.push(n)}else if("dialog_id"===e.childNodes[a].tagName)t=e.childNodes[a].textContent,o.dialog_id=t;else{if(e.childNodes[a].childNodes.length>1)if(e.childNodes[a].textContent.length>4096){for(var d="",h=0;h<e.childNodes[a].childNodes.length;++h)d+=e.childNodes[a].childNodes[h].textContent;o[e.childNodes[a].tagName]=d}else o=this._XMLtoJS(o,e.childNodes[a].tagName,e.childNodes[a]);else o[e.childNodes[a].tagName]=e.childNodes[a].textContent}else for(var p=0,f=e.children.length;p<f;p++){if("attachment"===e.children[p].name){n={},i=e.children[p].attrs;for(var m=Object.keys(i),g=0;g<m.length;g++)"size"===m[g]?n.size=parseInt(i.size):n[m[g]]=i[m[g]];s.push(n)}else"dialog_id"===e.children[p].name&&(t=e.getChildText("dialog_id"),o.dialog_id=t);if(1===e.children[p].children.length){var v=e.children[p];o[v.name]=v.children[0]}}return s.length>0&&(o.attachments=s),o.moduleIdentifier&&delete o.moduleIdentifier,{extension:o,dialogId:t}},getUniqueId:function(e){var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)});return"string"==typeof e||"number"==typeof e?t+":"+e:t+""},getErrorFromXMLNode:function(e){var t=this.getElement(e,"error"),n=parseInt(this.getAttr(t,"code")),i=this.getElementText(t,"text");return r.getError(n,i)},getLocalTime:function(){return(new Date).toTimeString().split(" ")[0]}};t.exports=a},{"../../qbConfig":151,"../../qbUtils":155}],134:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("../../qbUtils"),o=r.urls.chat+"/Dialog";function s(e){this.service=e}s.prototype={list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e={}),this.service.ajax({url:i.getUrl(o),data:e},t)},create:function(e,t){e&&e.occupants_ids&&i.isArray(e.occupants_ids)&&(e.occupants_ids=e.occupants_ids.join(", ")),this.service.ajax({url:i.getUrl(o),type:"POST",data:e},t)},update:function(e,t,n){this.service.ajax({url:i.getUrl(o,e),type:"PUT",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:t},n)},delete:function(e,t,n){var r={url:i.getUrl(o,e),type:"DELETE",dataType:"text"};2===arguments.length?this.service.ajax(r,t):3===arguments.length&&(r.data=t,this.service.ajax(r,n))}},t.exports=s},{"../../qbConfig":151,"../../qbUtils":155}],135:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("../../qbUtils"),o=r.urls.chat+"/Message";function s(e){this.service=e}s.prototype={list:function(e,t){this.service.ajax({url:i.getUrl(o),data:e},t)},create:function(e,t){this.service.ajax({url:i.getUrl(o),type:"POST",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:e},t)},update:function(e,t,n){var r={type:"PUT",dataType:"text",url:i.getUrl(o,e),data:t};this.service.ajax(r,n)},delete:function(e,t,n){var r={url:i.getUrl(o,e),type:"DELETE",dataType:"text"};2===arguments.length?this.service.ajax(r,t):3===arguments.length&&(r.data=t,this.service.ajax(r,n))},unreadCount:function(e,t){e&&e.chat_dialog_ids&&i.isArray(e.chat_dialog_ids)&&(e.chat_dialog_ids=e.chat_dialog_ids.join()),this.service.ajax({url:i.getUrl(o+"/unread"),data:e},t)}},t.exports=s},{"../../qbConfig":151,"../../qbUtils":155}],136:[function(e,t,n){"use strict";var r=e("../qbUtils"),i="ai/ai_extensions";function o(e){this.service=e}o.prototype={answerAssist:function(e,t,n,o){if(!o||"function"!=typeof o)throw new Error("Callback function is required and must be a function");if(function(e){var t="user",n="assistant";if(null!=e){if(!Array.isArray(e))throw new Error("History must be an array");for(var r=0;r<e.length;r++){var i=e[r];if("object"!=typeof i||null===i||Array.isArray(i))throw new Error("Each element of history must be an object");if(!("role"in i&&"message"in i))throw new Error("Each element of history must have an role and message fields");if(i.role!==t&&i.role!==n)throw new Error("Invalid role in history item");if("string"!=typeof i.message)throw new Error("Message of history item must be a string")}}return!0}(n)){var s=n?{smart_chat_assistant_id:e,message:t,history:n}:{smart_chat_assistant_id:e,message:t},a={type:"POST",url:r.formatUrl(i+"/ai_answer_assist"),data:s,contentType:"application/json; charset=utf-8",isNeedStringify:!0};this.service.ajax(a,o)}},translate:function(e,t,n,o){if(!o||"function"!=typeof o)throw new Error("Callback function is required and must be a function");var s={smart_chat_assistant_id:e,text:t,to_language:n||"en"},a={type:"POST",url:r.formatUrl(i+"/ai_translate"),data:s};this.service.ajax(a,o)},gateway:function(e,t,n,o){var s,a;if("function"==typeof n?(a=n,s={}):(s=n||{},a=o),!a||"function"!=typeof a)throw new Error("Callback function is required and must be a function");if(!e||"string"!=typeof e)throw new Error("smartChatAssistantId is required and must be a string");this._validateGatewayMessages(t);var c={smart_chat_assistant_id:e,messages:t},l={type:"POST",url:r.formatUrl(i+"/ai_gateway"),data:c,contentType:"application/json; charset=utf-8",isNeedStringify:!0};s.apiKey&&(l.headers={Authorization:"ApiKey "+s.apiKey}),this.service.ajax(l,a)},_validateGatewayMessages:function(e){var t=["user","assistant","developer"],n=["text","image_url"];if(!e||!Array.isArray(e))throw new Error("messages is required and must be an array");if(0===e.length)throw new Error("messages array cannot be empty");for(var r=0;r<e.length;r++){var i=e[r];if("object"!=typeof i||null===i||Array.isArray(i))throw new Error("Each message must be an object");if(!i.role||-1===t.indexOf(i.role))throw new Error("Each message must have a valid role (user, assistant, or developer)");if(void 0===i.content||null===i.content)throw new Error("Each message must have content (string or array)");if("string"!=typeof i.content){if(!Array.isArray(i.content))throw new Error("Message content must be a string or array");if(0===i.content.length)throw new Error("Content array cannot be empty");for(var o=0;o<i.content.length;o++){var s=i.content[o];if("object"!=typeof s||null===s)throw new Error("Each content item must be an object");if(!s.type||-1===n.indexOf(s.type))throw new Error("Each content item must have a valid type (text or image_url)");if("text"===s.type){if("string"!=typeof s.text)throw new Error("Text content item must have a text string")}else if("image_url"===s.type&&(!s.image_url||"string"!=typeof s.image_url.url))throw new Error("Image content item must have image_url.url string")}}else if(0===i.content.length)throw new Error("String content cannot be empty")}return!0},summarize:function(e,t,n){if(!n||"function"!=typeof n)throw new Error("Callback function is required and must be a function");if(!e||"string"!=typeof e)throw new Error("smartChatAssistantId is required and must be a string");if(!t||"string"!=typeof t)throw new Error("dialogId is required and must be a string");var o={smart_chat_assistant_id:e,dialog_id:t},s={type:"POST",url:r.formatUrl(i+"/ai_summarize"),data:o,contentType:"application/json; charset=utf-8",isNeedStringify:!0};this.service.ajax(s,n)}},t.exports=o},{"../qbUtils":155}],137:[function(e,t,n){"use strict";var r=e("../qbUtils"),i=e("../qbConfig");function o(e){this.service=e}function s(e){return!!(e&&e.constructor&&e.call&&e.apply)}o.prototype={uploadAddressBook:function(e,t,n){if(Array.isArray(e)){var o,a;s(t)?a=t:(o=t,a=n);var c={contacts:e};o&&(o.force&&(c.force=o.force),o.udid&&(c.udid=o.udid)),this.service.ajax({type:"POST",url:r.getUrl(i.urls.addressbook),data:c,contentType:"application/json; charset=utf-8",isNeedStringify:!0},function(e,t){e?a(e,null):a(null,t)})}else new Error("First parameter must be an Array.")},_isFakeErrorEmptyAddressBook:function(e){var t=e.detail?e.detail:e.message.errors;return 404===e.code&&"Empty address book"===t[0]},get:function(e,t){var n,o,a=this;if(s(e)?o=e:(n=e,o=t),!s(o))throw new Error("The QB.addressbook.get accept callback function is required.");var c={type:"GET",url:r.getUrl(i.urls.addressbook),contentType:"application/json; charset=utf-8",isNeedStringify:!0};n&&(c.data={udid:n}),this.service.ajax(c,function(e,t){e?a._isFakeErrorEmptyAddressBook(e)?o(null,[]):o(e,null):o(null,t)})},getRegisteredUsers:function(e,t){var n,o,a=this;if(s(e)?o=e:(n=e,o=t),!s(o))throw new Error("The QB.addressbook.get accept callback function is required.");var c={type:"GET",url:r.getUrl(i.urls.addressbookRegistered),contentType:"application/json; charset=utf-8"};n&&(c.data={compact:1}),this.service.ajax(c,function(e,t){e?a._isFakeErrorEmptyAddressBook(e)?o(null,[]):o(e,null):o(null,t)})}},t.exports=o},{"../qbConfig":151,"../qbUtils":155}],138:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o=e("crypto-js/hmac-sha1"),s=e("crypto-js/hmac-sha256");function a(e){this.service=e}a.prototype={getSession:function(e){this.service.ajax({url:i.getUrl(r.urls.session)},function(t,n){e(t,t?null:n)})},createSession:function(e,t){if(""===r.creds.appId||""===r.creds.authKey||""===r.creds.authSecret)throw new Error("Cannot create a new session without app credentials (app ID, auth key and auth secret)");var n,a=this;"function"==typeof e&&void 0===t&&(t=e,e={}),(n=function(e){var t={application_id:r.creds.appId,auth_key:r.creds.authKey,nonce:i.randomNonce(),timestamp:i.unixTime()};e.login&&e.password?t.user={login:e.login,password:e.password}:e.email&&e.password?t.user={email:e.email,password:e.password}:e.provider&&(t.provider=e.provider,e.scope&&(t.scope=e.scope),e.keys&&e.keys.token&&(t.keys={token:e.keys.token}),e.keys&&e.keys.secret&&(t.keys.secret=e.keys.secret));return t}(e)).signature=function(e,t){var n,i=Object.keys(e).map(function(t){return"object"==typeof e[t]?Object.keys(e[t]).map(function(n){return t+"["+n+"]="+e[t][n]}).sort().join("&"):t+"="+e[t]}).sort().join("&");if("sha1"===r.hash)n=o(i,t).toString();else{if("sha256"!==r.hash)throw new Error("Quickblox SDK: unknown crypto standards, available sha1 or sha256");n=s(i,t).toString()}return n}(n,r.creds.authSecret),this.service.ajax({url:i.getUrl(r.urls.session),type:"POST",data:n},function(e,n){e?t(e,null):(a.service.setSession(n.session),t(null,n.session))})},destroySession:function(e){var t=this;this.service.ajax({url:i.getUrl(r.urls.session),type:"DELETE",dataType:"text"},function(n,r){n?e(n,null):(t.service.setSession(null),e(null,r))})},login:function(e,t){var n={type:"POST",url:i.getUrl(r.urls.login),data:e};this.service.ajax(n,function(e,n){e?t(e,null):t(null,n.user)})},logout:function(e){this.service.ajax({url:i.getUrl(r.urls.login),type:"DELETE",dataType:"text"},e)}},t.exports=a},{"../qbConfig":151,"../qbUtils":155,"crypto-js/hmac-sha1":30,"crypto-js/hmac-sha256":31}],139:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils");function o(e){this.service=e}function s(e){for(var t=s.options,n=t.parser[t.strictMode?"strict":"loose"].exec(e),r={},i=14;i--;)r[t.key[i]]=n[i]||"";return r[t.q.name]={},r[t.key[12]].replace(t.q.parser,function(e,n,i){n&&(r[t.q.name][n]=i)}),r}o.prototype={list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e=null),this.service.ajax({url:i.getUrl(r.urls.blobs),data:e,type:"GET"},function(e,n){t(e,e?null:n)})},create:function(e,t){this.service.ajax({type:"POST",data:{blob:e},url:i.getUrl(r.urls.blobs)},function(e,n){t(e,e?null:n.blob)})},delete:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e),type:"DELETE",dataType:"text"},function(e,n){e?t(e,null):t(null,!0)})},createAndUpload:function(e,t){var n,r,i,o,a,c=this,l={};JSON.parse(JSON.stringify(e)).file.data="...",n=e.file,r=e.name||n.name,i=e.type||n.type,o=e.size||n.size,l.name=r,l.content_type=i,e.public&&(l.public=e.public),e.tag_list&&(l.tag_list=e.tag_list),this.create(l,function(e,i){if(e)t(e,null);else{var l=s(i.blob_object_access.params),u={url:l.protocol+"://"+l.authority+l.path},d={};a=i.id,i.size=o,Object.keys(l.queryKey).forEach(function(e){d[e]=decodeURIComponent(l.queryKey[e])}),d.file=n,d.name=r,u.data=d,c.upload(u,function(e,n){e?t(e,null):c.markUploaded({id:a,size:o},function(e,n){e?t(e,null):t(null,i)})})}})},upload:function(e,t){var n=Object.assign({},e.data),r={data:e.data.file,name:e.data.name||e.data.file.name};n.file=r;var i={type:"POST",dataType:"text",contentType:!1,url:e.url,data:n,fileToCustomObject:!0};this.service.ajax(i,function(e,n){e?t(e,null):t(null,{})})},markUploaded:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e.id+"/complete"),type:"PUT",data:{size:e.size},dataType:"text"},function(e,n){e?t(e,null):t(null,n)})},getInfo:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e)},function(e,n){e?t(e,null):t(null,n)})},getFile:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e)},function(e,n){e?t(e,null):t(null,n)})},update:function(e,t){var n={blob:{}};void 0!==e.name&&(n.blob.name=e.name),this.service.ajax({url:i.getUrl(r.urls.blobs,e.id),data:n},function(e,n){e?t(e,null):t(null,n)})},privateUrl:function(e){return"https://"+r.endpoints.api+"/blobs/"+e+"?token="+this.service.getSession().token},publicUrl:function(e){return"https://"+r.endpoints.api+"/blobs/"+e}},t.exports=o,s.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},{"../qbConfig":151,"../qbUtils":155}],140:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils");function o(e){this.service=e}o.prototype={create:function(e,t,n){var o={type:"POST",data:t,isNeedStringify:!0,contentType:"application/json; charset=utf-8",url:i.getUrl(r.urls.data,e)};this.service.ajax(o,function(e,t){n(e,e?null:t)})},list:function(e,t,n){void 0===n&&"function"==typeof t&&(n=t,t=null),this.service.ajax({url:i.getUrl(r.urls.data,e),data:t},function(e,t){n(e,e?null:t)})},update:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t._id),type:"PUT",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:t},function(e,t){n(e,e?null:t)})},delete:function(e,t,n){var o,s={id:1,ids:2,criteria:3},a={deleted:[],deletedCount:0},c={type:"DELETE",dataType:"text"};"string"==typeof t?o=s.id:i.isArray(t)?o=s.ids:i.isObject(t)&&(o=s.criteria),o===s.id?c.url=i.getUrl(r.urls.data,e+"/"+t):o===s.ids?c.url=i.getUrl(r.urls.data,e+"/"+t.toString()):o===s.criteria&&(c.url=i.getUrl(r.urls.data,e+"/by_criteria"),c.data=t),this.service.ajax(c,function(e,r){var i;e?n(e,null):(o===s.id?(a.deleted.push(t),a.deletedCount=a.deleted.length):o===s.ids?(i=JSON.parse(r),a.deleted=i.SuccessfullyDeleted.ids.slice(0),a.deletedCount=a.deleted.length):o===s.criteria&&(i=JSON.parse(r),a.deleted=null,a.deletedCount=i.total_deleted),n(e,a))})},uploadFile:function(e,t,n){var o={field_name:t.field_name,file:{data:t.file,name:t.name}};this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t.id+"/file"),type:"POST",fileToCustomObject:!0,contentType:!1,data:o},function(e,t){n(e,e?null:t)})},downloadFile:function(e,t,n){var o=i.getUrl(r.urls.data,e+"/"+t.id+"/file");n(null,o+="?field_name="+t.field_name+"&token="+this.service.getSession().token)},fileUrl:function(e,t){var n=i.getUrl(r.urls.data,e+"/"+t.id+"/file");return n+="?field_name="+t.field_name+"&token="+this.service.getSession().token},deleteFile:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t.id+"/file"),data:{field_name:t.field_name},dataType:"text",type:"DELETE"},function(e,t){n(e,!e||null)})}},t.exports=o},{"../qbConfig":151,"../qbUtils":155}],141:[function(e,t,n){(function(n){(function(){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o="undefined"!=typeof window;function s(e){this.service=e}function a(e){this.service=e}s.prototype={create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.subscriptions),type:"POST",data:e},t)},list:function(e){this.service.ajax({url:i.getUrl(r.urls.subscriptions)},e)},delete:function(e,t){var n={type:"DELETE",dataType:"text",url:i.getUrl(r.urls.subscriptions,e)};this.service.ajax(n,function(e,n){e?t(e,null):t(null,!0)})}},a.prototype={create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events),type:"POST",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:{event:e}},t)},list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e=null),this.service.ajax({url:i.getUrl(r.urls.events),data:e},t)},get:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e)},t)},delete:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e),dataType:"text",type:"DELETE"},t)},status:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e+"/status")},t)}},t.exports=function(e){this.service=e,this.subscriptions=new s(e),this.events=new a(e),this.base64Encode=function(e){return o?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})):new n(e).toString("base64")}}}).call(this)}).call(this,e("buffer").Buffer)},{"../qbConfig":151,"../qbUtils":155,buffer:27}],142:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o=["created_at","updated_at","last_request_at"],s=["id","external_user_id"],a=r.urls.users+"/password/reset";function c(e){this.service=e}function l(e){var t=e.field in o?"date":typeof e.value;return i.isArray(e.value)&&("object"===t&&(t=typeof e.value[0]),e.value=e.value.toString()),[t,e.field,e.param,e.value].join(" ")}c.prototype={listUsers:function(e,t){var n,a,c,u={},d=[];"function"==typeof e&&void 0===t&&(t=e,e={}),e&&e.filter&&(i.isArray(e.filter)?e.filter.forEach(function(e){n=l(e),d.push(n)}):(n=l(e.filter),d.push(n)),u.filter=d),e.order&&(u.order=(a=e.order,c=a.field in o?"date":a.field in s?"number":"string",[a.sort,c,a.field].join(" "))),e.page&&(u.page=e.page),e.per_page&&(u.per_page=e.per_page),this.service.ajax({url:i.getUrl(r.urls.users),data:u},t)},get:function(e,t){var n;"number"==typeof e?(n=e,e={}):e.login?n="by_login":e.full_name?n="by_full_name":e.facebook_id?n="by_facebook_id":e.twitter_id?n="by_twitter_id":e.phone?n="phone":e.email?n="by_email":e.tags?n="by_tags":e.external&&(n="external/"+e.external,e={}),this.service.ajax({url:i.getUrl(r.urls.users,n),data:e},function(e,n){e?t(e,null):t(null,n.user||n)})},create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.users),type:"POST",data:{user:e}},function(e,n){e?t(e,null):t(null,n.user)})},update:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.users,e),type:"PUT",data:{user:t}},function(e,t){e?n(e,null):n(null,t.user)})},delete:function(e,t){var n;"number"==typeof e?n=e:e.external&&(n="external/"+e.external),this.service.ajax({url:i.getUrl(r.urls.users,n),type:"DELETE",dataType:"text"},t)},resetPassword:function(e,t){this.service.ajax({url:i.getUrl(a),data:{email:e},dataType:"text"},t)}},t.exports=c},{"../qbConfig":151,"../qbUtils":155}],143:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("./qbWebRTCHelpers"),o=function(e){this._pc=new window.RTCPeerConnection(e),this.remoteStream=void 0,this.preferredCodec="VP8"};function s(e,t,n,r,i,o){if(void 0===o&&(o="asc"),"asc"===(o=o||"asc")){for(var s=-1!==n?n:e.length,a=t;a<s;++a)if(0===e[a].indexOf(r)&&(!i||-1!==e[a].toLowerCase().indexOf(i.toLowerCase())))return a}else for(var c=-1!==t?t:e.length-1;c>=0;--c)if(0===e[c].indexOf(r)&&(!i||-1!==e[c].toLowerCase().indexOf(i.toLowerCase())))return c;return null}function a(e,t){var n=e.split(" "),r=n.slice(0,3);r.push(t);for(var i=3;i<n.length;i++)n[i]!==t&&r.push(n[i]);return r.join(" ")}function c(e,t,n){if(!n)return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"");for(var r=e.split("\n"),o=-1,s=i.getVersionFirefox()?"TIAS":"AS",a=i.getVersionFirefox()?1024*n:n,c=0;c<r.length;c++)if(0===r[c].indexOf("m="+t)){o=c;break}if(-1===o)return e;for(o++;0===r[o].indexOf("i=")||0===r[o].indexOf("c=");)o++;if(0===r[o].indexOf("b"))return r[o]="b="+s+":"+a,r.join("\n");var l=r.slice(0,o);return l.push("b="+s+":"+a),(l=l.concat(r.slice(o,r.length))).join("\n")}o.State={NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},o.prototype._init=function(e,t,n,r){i.trace("RTCPeerConnection init.","userID: ",t,", sessionID: ",n,", polite: ",r),this.delegate=e,this.localIceCandidates=[],this.remoteIceCandidates=[],this.remoteSDP=void 0,this.sessionID=n,this.polite=r,this.userID=t,this._reconnecting=!1,this.state=o.State.NEW,this._pc.onicecandidate=this.onIceCandidateCallback.bind(this),this._pc.onsignalingstatechange=this.onSignalingStateCallback.bind(this),this._pc.oniceconnectionstatechange=this.onIceConnectionStateCallback.bind(this),this._pc.ontrack=this.onTrackCallback.bind(this),this.dialingTimer=null,this.answerTimeInterval=0,this.statsReportTimer=null},o.prototype.release=function(){this._clearDialingTimer(),this._clearStatsReportTimer(),this._pc.close(),this.state=o.State.CLOSED,this._pc.onicecandidate=null,this._pc.onsignalingstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.ontrack=null,navigator.userAgent.includes("Edge")&&(this.connectionState="closed",this.iceConnectionState="closed")},o.prototype.negotiate=function(){var e=this;return this.setLocalSessionDescription({type:"offer",options:{iceRestart:!0}},function(t){if(t)return i.traceError("Error in 'negotiate': "+t);var n=e._pc.localDescription.toJSON();e.delegate.update({reason:"reconnect",sessionDescription:{offerId:e.offerId,sdp:n.sdp,type:n.type}},e.userID)})},o.prototype.setRemoteSDP=function(e){if(!e)throw new Error("sdp string can't be empty.");this.remoteSDP=e},o.prototype.getRemoteSDP=function(){return this.remoteSDP},o.prototype.setLocalSessionDescription=function(e,t){var n=this;function r(e){var r=function(e){e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n"));return e}(e);r.sdp=function(e,t,n){if(!n)return e;var r=e.split("\r\n"),i=s(r,0,-1,"m=",t);if(null===i)return e;for(var o=null,c=r.length-1;c>=0;--c){var l=s(r,c,0,"a=rtpmap",n,"desc");if(null===l)break;c=l,u=r[l],d=void 0,h=void 0,d=new RegExp("a=rtpmap:(\\d+) [a-zA-Z0-9-]+\\/\\d+"),h=u.match(d),(o=h&&2===h.length?h[1]:null)&&(r[i]=a(r[i],o))}var u,d,h;return e=r.join("\r\n")}(r.sdp,"video",n.preferredCodec),n.delegate.bandwidth&&(r.sdp=c(r.sdp,"video",n.delegate.bandwidth)),n._pc.setLocalDescription(r).then(function(){t(null)}).catch(function(e){i.traceError("Error in 'setLocalSessionDescription': "+e),t(e)})}n.state=o.State.CONNECTING,window.RTCRtpTransceiver&&"setCodecPreferences"in window.RTCRtpTransceiver.prototype&&Boolean(i.getVersionSafari())&&n._pc.getTransceivers().forEach(function(e){var t=e.sender.track.kind,r=window.RTCRtpSender.getCapabilities(t).codecs,i=window.RTCRtpReceiver.getCapabilities(t).codecs;if("video"===t){var o=r.findIndex(function(e){return e.mimeType.toLowerCase().includes(n.preferredCodec.toLowerCase())});if(-1!==o){var s=r.splice(o,1);r.unshift(s[0])}var a=i.findIndex(function(e){return e.mimeType.toLowerCase().includes(n.preferredCodec.toLowerCase())});if(-1!==a){var c=i.splice(a,1);i.unshift(c[0])}var l=r.filter(function(e){return!e.mimeType.toLowerCase().includes("h264")}),u=i.filter(function(e){return!e.mimeType.toLowerCase().includes("h264")}),d=l.concat(u);e.setCodecPreferences(d)}}),"answer"===e.type?this._pc.createAnswer(e.options).then(r).catch(t):this._pc.createOffer(e.options).then(r).catch(t)},o.prototype.setRemoteSessionDescription=function(e,t){var n=this.delegate.bandwidth?{type:e.type,sdp:c(e.sdp,"video",this.delegate.bandwidth)}:e;this._pc.setRemoteDescription(n).then(function(){t()}).catch(function(e){i.traceError("Error in 'setRemoteSessionDescription': "+e),t(e)})},o.prototype.addLocalStream=function(e){if(!e)throw new Error("'qbRTCPeerConnection.addLocalStream' error: stream is not defined");var t=this;e.getTracks().forEach(function(n){t._pc.addTrack(n,e)})},o.prototype._addIceCandidate=function(e){return this._pc.addIceCandidate(e).catch(function(e){i.traceError("Error on 'addIceCandidate': "+e)})},o.prototype.addCandidates=function(e){var t=this;e.forEach(function(e){t.remoteIceCandidates.push(e)}),this._pc.remoteDescription&&t.remoteIceCandidates.forEach(function(e){t._addIceCandidate(e)})},o.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", state: "+this.state},o.prototype.onSignalingStateCallback=function(){if("stable"===this._pc.signalingState&&this.localIceCandidates.length>0)for(this.delegate.processIceCandidates(this,this.localIceCandidates);this.localIceCandidates.length;)this.localIceCandidates.pop()},o.prototype.onIceCandidateCallback=function(e){if(e.candidate){var t={candidate:e.candidate.candidate,sdpMid:e.candidate.sdpMid,sdpMLineIndex:e.candidate.sdpMLineIndex};"stable"===this._pc.signalingState?this.delegate.processIceCandidates(this,[t]):this.localIceCandidates.push(t)}},o.prototype.onTrackCallback=function(e){this.remoteStream=e.streams[0],"function"==typeof this.delegate._onRemoteStreamListener&&["connected","completed"].includes(this._pc.iceConnectionState)&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream),this._getStatsWrap()},o.prototype.onIceConnectionStateCallback=function(){i.trace("onIceConnectionStateCallback: "+this._pc.iceConnectionState);var e=null;switch(this._pc.iceConnectionState){case"checking":this.state=o.State.CHECKING,e=i.SessionConnectionState.CONNECTING;break;case"connected":this._reconnecting&&this.delegate._stopReconnectTimer(this.userID),this.state=o.State.CONNECTED,e=i.SessionConnectionState.CONNECTED;break;case"completed":this._reconnecting&&this.delegate._stopReconnectTimer(this.userID),this.state=o.State.COMPLETED,e=i.SessionConnectionState.COMPLETED;break;case"failed":this.delegate._startReconnectTimer(this.userID),this.state=o.State.FAILED,e=i.SessionConnectionState.FAILED;break;case"disconnected":this.delegate._startReconnectTimer(this.userID),this.state=o.State.DISCONNECTED,e=i.SessionConnectionState.DISCONNECTED;break;case"closed":this.delegate._stopReconnectTimer(this.userID),this.state=o.State.CLOSED,e=i.SessionConnectionState.CLOSED}"function"==typeof this.delegate._onSessionConnectionStateChangedListener&&e&&this.delegate._onSessionConnectionStateChangedListener(this.userID,e),"connected"===this._pc.iceConnectionState&&"function"==typeof this.delegate._onRemoteStreamListener&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream)},o.prototype._clearStatsReportTimer=function(){this.statsReportTimer&&(clearInterval(this.statsReportTimer),this.statsReportTimer=null)},o.prototype._getStatsWrap=function(){var e,t,n=this;if(r.webrtc&&r.webrtc.statsReportTimeInterval&&!n.statsReportTimer){if(isNaN(+r.webrtc.statsReportTimeInterval))return void i.traceError("statsReportTimeInterval ("+r.webrtc.statsReportTimeInterval+") must be integer.");e=1e3*r.webrtc.statsReportTimeInterval;i.trace("Stats tracker has been started."),n.statsReportTimer=setInterval(function(){!function(e,t,n,r){var o={local:{audio:{},video:{},candidate:{}},remote:{audio:{},video:{},candidate:{}}};if(i.getVersionFirefox()){var s=e.getLocalStreams().length?e.getLocalStreams()[0]:e.delegate.localStream,a=s.getVideoTracks().length?s.getVideoTracks()[0].getSettings():null;o.local.video.frameHeight=a&&a.height,o.local.video.frameWidth=a&&a.width}function c(e,t,n){var r,i=t&&t.get(e.id),o=i?(e.timestamp-i.timestamp)/1e3:5;return r=i?n?8*(e.bytesSent-i.bytesSent)/(1024*o):8*(e.bytesReceived-i.bytesReceived)/(1024*o):0,Math.round(r)}function l(e,t,n){var r,i=t&&t.get(e.id),o=i?(e.timestamp-i.timestamp)/1e3:5;return r=i?n?(e.framesSent-i.framesSent)/o:(e.framesReceived-i.framesReceived)/o:0,Math.round(10*r)/10}e.getStats(null).then(function(e){e.forEach(function(e){var n;e.bytesReceived&&"inbound-rtp"===e.type?((n=o.remote[e.mediaType]).bitrate=c(e,t,!1),n.bytesReceived=e.bytesReceived,n.packetsReceived=e.packetsReceived,n.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(n.framesPerSecond=Math.round(10*e.framerateMean)/10)):e.bytesSent&&"outbound-rtp"===e.type?((n=o.local[e.mediaType]).bitrate=c(e,t,!0),n.bytesSent=e.bytesSent,n.packetsSent=e.packetsSent,n.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(n.framesPerSecond=Math.round(10*e.framerateMean)/10)):"local-candidate"===e.type?(n=o.local.candidate,"host"===e.candidateType&&"udp"===e.mozLocalTransport&&"udp"===e.transport?(n.protocol=e.transport,n.ip=e.ipAddress,n.port=e.portNumber):i.getVersionFirefox()||(n.protocol=e.protocol,n.ip=e.ip,n.port=e.port)):"remote-candidate"===e.type?((n=o.remote.candidate).protocol=e.protocol||e.transport,n.ip=e.ip||e.ipAddress,n.port=e.port||e.portNumber):"track"!==e.type||"video"!==e.kind||i.getVersionFirefox()||(e.remoteSource?((n=o.remote.video).frameHeight=e.frameHeight,n.frameWidth=e.frameWidth,n.framesPerSecond=l(e,t,!1)):((n=o.local.video).frameHeight=e.frameHeight,n.frameWidth=e.frameWidth,n.framesPerSecond=l(e,t,!0)))}),n(o,e)},r)}(n._pc,t,function(e,r){t=r,n.delegate._onCallStatsReport(n.userID,e,null)},function(e){i.traceError("_getStats error. "+e.name+": "+e.message),n.delegate._onCallStatsReport(n.userID,null,e)})},e)}},o.prototype._clearDialingTimer=function(){this.dialingTimer&&(i.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},o.prototype._startDialingTimer=function(e){var t=this,n=1e3*r.webrtc.dialingTimeInterval;i.trace("_startDialingTimer, dialingTimeInterval: "+n);var o=function(e,o){o||(t.answerTimeInterval+=n),i.trace("_dialingCallback, answerTimeInterval: "+t.answerTimeInterval),t.answerTimeInterval>=1e3*r.webrtc.answerTimeInterval?(t._clearDialingTimer(),t.delegate.processOnNotAnswer(t)):t.delegate.processCall(t,e)};t.dialingTimer=setInterval(o,n,e,!1),o(e,!0)},t.exports=o},{"../../qbConfig":151,"./qbWebRTCHelpers":145}],144:[function(e,t,n){"use strict";var r=e("./qbWebRTCSession"),i=e("./qbWebRTCSignalingProcessor"),o=e("./qbWebRTCSignalingProvider"),s=e("./qbWebRTCHelpers"),a=e("./qbRTCPeerConnection"),c=e("./qbWebRTCSignalingConstants"),l=e("../../qbUtils"),u=e("../../qbConfig"),d=[r.State.NEW,r.State.CONNECTING,r.State.ACTIVE];function h(e,t){this.chat=t,this.signalingProcessor=new i(e,this),this.signalingProvider=new o(e,t),t.webrtcSignalingProcessor=this.signalingProcessor,this.SessionConnectionState=s.SessionConnectionState,this.CallType=s.CallType,this.PeerConnectionState=a.State,this.sessions={},navigator.mediaDevices&&"ondevicechange"in navigator.mediaDevices&&(navigator.mediaDevices.ondevicechange=this._onDevicesChangeListener.bind(this))}h.prototype.getMediaDevices=function(e){var t=[],n="Browser does not support output device selection.";return new Promise(function(r,i){navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices().then(function(n){e?(n.forEach(function(n,r){n.kind===e&&t.push(n)}),r(t)):r(n)}):(i(n),s.traceWarning(n))})},h.prototype.sessions={},h.prototype.createNewSession=function(e,t,n,i){var o=function(e){var t=[];Object.keys(e).length>0&&Object.keys(e).forEach(function(n,i,o){var s=e[n];s.state!==r.State.NEW&&s.state!==r.State.ACTIVE||t.push(s.opponentsIDs)});return t}(this.sessions),a=n||s.getIdFromNode(this.chat.connection.jid),c=i&&i.bandwidth&&!isNaN(i.bandwidth)?+i.bandwidth:0,l=t||2;if(!e)throw new Error("Can't create a session without the opponentsIDs.");if(!Array.isArray(e))throw new Error('"opponentsIDs" should be Array of numbers');if(e.forEach(function(e){var t=parseInt(e);if(isNaN(t))throw new Error('"opponentsIDs" should be Array of numbers');e=t}),function(e,t){var n=!1,r=t.sort();e.length&&e.forEach(function(e){var t=e.sort();n=t.length==r.length&&t.every(function(e,t){return e===r[t]})});return n}(o,e))throw new Error("Can't create a session with the same opponentsIDs. There is a session already in NEW or ACTIVE state.");return this._createAndStoreSession(null,a,e,l,c)},h.prototype._createAndStoreSession=function(e,t,n,i,o){var a=new r({sessionID:e,initiatorID:t,opIDs:n,callType:i,signalingProvider:this.signalingProvider,currentUserID:s.getIdFromNode(this.chat.connection.jid),bandwidth:o});return a.onUserNotAnswerListener=this.onUserNotAnswerListener,a.onReconnectListener=this.onReconnectListener,a.onRemoteStreamListener=this.onRemoteStreamListener,a.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,a.onSessionCloseListener=this.onSessionCloseListener,a.onCallStatsReport=this.onCallStatsReport,this.sessions[a.ID]=a,a},h.prototype.clearSession=function(e){delete h.sessions[e]},h.prototype.isExistLiveSessionExceptSessionID=function(e){var t=!1,n=this.sessions;return Object.keys(n).length>0&&(t=Object.keys(n).some(function(t){var r=n[t];return d.includes(r.state)&&r.ID!==e})),t},h.prototype.getNewSessionsCount=function(e){var t=this.sessions;return Object.keys(t).reduce(function(n,i){var o=t[i];return o.ID===e?n:o.state===r.State.NEW?n+1:n},0)},h.prototype._onCallListener=function(e,t,n){var r=n.userInfo||{},i=s.getIdFromNode(this.chat.connection.jid);if(e!==i||n.opponentsIDs.includes(i)){s.trace("onCall. UserID:"+e+". SessionID: "+t);var o=this.isExistLiveSessionExceptSessionID(t),a=this.getNewSessionsCount(t);if(o&&!this.sessions[t]&&a++,o&&(u.webrtc.autoReject||a>u.webrtc.incomingLimit))s.trace("User with id "+e+" is busy at the moment."),delete n.sessionDescription,delete n.platform,n.sessionID=t,this.signalingProvider.sendMessage(e,n,c.SignalingType.REJECT),"function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onCall",t,e,r);else{var d=this.sessions[t],h=+r.bandwidth||0;d||(d=this._createAndStoreSession(t,n.callerID,n.opponentsIDs,n.callType,h),"function"==typeof this.onCallListener&&l.safeCallbackCall(this.onCallListener,d,r)),d.processOnCall(e,n)}}else s.trace('Ignore "onCall" signal from current user. userID:'+e+", sessionID: "+t)},h.prototype._onAcceptListener=function(e,t,n){var i=this.sessions[t],o=n.userInfo||{};s.trace("onAccept. UserID:"+e+". SessionID: "+t),i?i.state===r.State.CONNECTING||i.state===r.State.ACTIVE?("function"==typeof this.onAcceptCallListener&&l.safeCallbackCall(this.onAcceptCallListener,i,e,o),i.processOnAccept(e,n)):("function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onAccept",i,e,o),s.traceWarning("Ignore 'onAccept', the session( "+t+" ) has invalid state.")):s.traceError("Ignore 'onAccept', there is no information about session "+t+" by some reason.")},h.prototype._onRejectListener=function(e,t,n){var r=this.sessions[t];if(s.trace("onReject. UserID:"+e+". SessionID: "+t),r){var i=n.userInfo||{};"function"==typeof this.onRejectCallListener&&l.safeCallbackCall(this.onRejectCallListener,r,e,i),r.processOnReject(e,n)}else s.traceError("Ignore 'onReject', there is no information about session "+t+" by some reason.")},h.prototype._onStopListener=function(e,t,n){s.trace("onStop. UserID:"+e+". SessionID: "+t);var r=this.sessions[t],i=n.userInfo||{};r&&d.includes(r.state)?("function"==typeof this.onStopCallListener&&l.safeCallbackCall(this.onStopCallListener,r,e,i),setTimeout(r.processOnStop.bind(r),10,e,n)):("function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onStop",r,e,i),s.traceError("Ignore 'onStop', there is no information about session "+t+" by some reason."))},h.prototype._onIceCandidatesListener=function(e,t,n){var i=this.sessions[t];s.trace("onIceCandidates. UserID:"+e+". SessionID: "+t+". ICE candidates count: "+n.iceCandidates.length),i?i.state===r.State.CONNECTING||i.state===r.State.ACTIVE?i.processOnIceCandidates(e,n):s.traceWarning("Ignore 'OnIceCandidates', the session ( "+t+" ) has invalid state."):s.traceError("Ignore 'OnIceCandidates', there is no information about session "+t+" by some reason.")},h.prototype._onUpdateListener=function(e,t,n){var r=this.sessions[t],i=n.userInfo||{};s.trace("onUpdate. UserID:"+e+". SessionID: "+t+". Extension: "+JSON.stringify(i)),r&&(n.reason&&r.processOnUpdate(e,n),"function"==typeof this.onUpdateCallListener&&l.safeCallbackCall(this.onUpdateCallListener,r,e,i))},h.prototype._onDevicesChangeListener=function(){"function"==typeof this.onDevicesChangeListener&&l.safeCallbackCall(this.onDevicesChangeListener)},t.exports=h},{"../../qbConfig":151,"../../qbUtils":155,"./qbRTCPeerConnection":143,"./qbWebRTCHelpers":145,"./qbWebRTCSession":146,"./qbWebRTCSignalingConstants":147,"./qbWebRTCSignalingProcessor":148,"./qbWebRTCSignalingProvider":149}],145:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i={getUserJid:function(e,t){return e+"-"+t+"@"+r.endpoints.chat},getIdFromNode:function(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])},trace:function(e){r.debug&&console.log("[QBWebRTC]:",e)},traceWarning:function(e){r.debug&&console.warn("[QBWebRTC]:",e)},traceError:function(e){r.debug&&console.error("[QBWebRTC]:",e)},getLocalTime:function(){return(new Date).toString().split(" ").slice(1,5).join("-")},isIOS:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent;return Boolean(e.match(/iP(ad|hone)/i))},isIOSSafari:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent,t=Boolean(e.match(/iP(ad|hone)/i)),n=Boolean(e.match(/WebKit/i)),r=Boolean(e.match(/CriOS/i));return t&&n&&!r},isIOSChrome:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent,t=Boolean(e.match(/iP(ad|hone)/i)),n=Boolean(e.match(/WebKit/i)),r=Boolean(e.match(/CriOS/i));return t&&!n&&r},getVersionFirefox:function(){var e,t=!!navigator&&navigator.userAgent;if(t){var n=t.match(/(?:firefox)[ \/](\d+)/i)||[];e=n[1]?+n[1]:null}return e},getVersionSafari:function(){var e,t=!!navigator&&navigator.userAgent;if(t)if((t.match(/(?:safari)[ \/](\d+)/i)||[]).length){var n=t.match(/(?:version)[ \/](\d+)/i)||[];e=n&&n[1]?+n[1]:null}else e=null;return e},delay:function(e){return e="number"==typeof e&&e>0?e:0,new Promise(function(t){setTimeout(t,e)})},SessionConnectionState:{UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},CallType:{VIDEO:1,AUDIO:2}};t.exports=i},{"../../qbConfig":151}],146:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("./qbRTCPeerConnection"),o=e("../../qbUtils"),s=e("./qbWebRTCHelpers"),a=e("./qbWebRTCSignalingConstants");d.State={NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5};var c="reconnecting",l="reconnected",u="failed";function d(e){this.ID=e.sessionID?e.sessionID:h(),this.state=d.State.NEW,this.initiatorID=parseInt(e.initiatorID),this.opponentsIDs=e.opIDs,this.callType=parseInt(e.callType),this.peerConnections={},this.mediaParams=null,this.iceConnectTimers={},this.reconnectTimers={},this.signalingProvider=e.signalingProvider,this.currentUserID=e.currentUserID,this.bandwidth=e.bandwidth,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0,this.localStream=void 0}function h(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)})}function p(e){var t={};try{if("[object Object]"!=={}.toString.call(e))throw new Error('Invalid type of "extension" object.');t.userInfo=e,t=JSON.parse(JSON.stringify(t).replace(/null/g,'""'))}catch(e){s.traceWarning(e.message)}return t}d.prototype.getUserMedia=function(e,t){if(!navigator.mediaDevices.getUserMedia)throw new Error("getUserMedia() is not supported in your browser");var n=this,r={audio:e.audio||!1,video:e.video||!1};navigator.mediaDevices.getUserMedia(r).then(function(r){n.localStream=r,n.mediaParams=Object.assign({},e),e.elemId&&n.attachMediaStream(e.elemId,r,e.options),t&&"function"==typeof t&&t(void 0,r)}).catch(t)},d.prototype.connectionStateForUser=function(e){var t=this.peerConnections[e];return t?t.state:void 0},d.prototype.attachMediaStream=function(e,t,n){var r=document.getElementById(e);if(!r)throw new Error('Unable to attach media stream, cannot find element by Id "'+e+'"');if(!(r instanceof HTMLMediaElement))throw new Error('Cannot attach media stream to element with id "'+e+'" because it is not of type HTMLMediaElement');"srcObject"in r?r.srcObject=t:r.src=window.URL.createObjectURL(t),n&&n.muted&&(r.muted=!0),n&&n.mirror&&(r.style.transform="scaleX(-1)"),r.autoplay||(r.onloadedmetadata=function(){r.play()})},d.prototype.detachMediaStream=function(e,t){var n=document.getElementById(e);n&&n instanceof HTMLMediaElement&&(n.pause(),t&&t.stopTracks&&n.srcObject&&"object"==typeof n.srcObject&&n.srcObject.getTracks().forEach(function(e){e.stop(),e.enabled=!1}),n.srcObject=null,n.removeAttribute("src"),n.removeAttribute("srcObject"))},d.prototype.switchMediaTracks=function(e,t){if(!navigator.mediaDevices.getUserMedia)throw new Error("getUserMedia() is not supported in your browser");var n=this;e&&e.audio&&(this.mediaParams.audio.deviceId=e.audio),e&&e.video&&(this.mediaParams.video.deviceId=e.video),this.localStream.getTracks().forEach(function(e){e.stop()}),navigator.mediaDevices.getUserMedia({audio:n.mediaParams.audio||!1,video:n.mediaParams.video||!1}).then(function(e){return n._replaceTracks(e).then(function(){t(null,e)})}).catch(function(e){t(e,null)})},d.prototype.replaceVideoTrack=function(e){var t=this.localStream,n=this.mediaParams.elemId,r=t.getVideoTracks()[0];if(r&&(r.stop(),t.removeTrack(r)),t.addTrack(e),n){var i=document.getElementById(n);i&&i instanceof HTMLMediaElement&&(i.srcObject=t)}return Promise.all(Object.values(this.peerConnections).map(function(e){return e._pc}).map(function(t){var n=t.getSenders().find(function(e){return e.track&&"video"===e.track.kind});return n?n.replaceTrack(e):Promise.resolve()}))},d.prototype._replaceTracks=function(e){var t=this.localStream,n=this.mediaParams.elemId,r=e.getTracks();if(r.forEach(function(e){var n=t.getTracks().find(function(t){return t.kind===e.kind});n&&(n.stop(),t.removeTrack(n)),t.addTrack(e)}),n){var i=document.getElementById(n);i&&i instanceof HTMLMediaElement&&(i.srcObject=t)}return Promise.all(Object.values(this.peerConnections).map(function(e){return e._pc}).map(function(e){return Promise.all(e.getSenders().filter(function(e){return null!==e.track}).map(function(e){var t=r.find(function(t){return t.kind===e.track.kind});return t?e.replaceTrack(t):Promise.resolve()}))}))},d.prototype.call=function(e,t){var n=this,r=p(e);s.trace("Call, extension: "+JSON.stringify(r.userInfo)),n.state=d.State.ACTIVE,n._reconnectToChat(function(){n.state===d.State.ACTIVE&&n.opponentsIDs.forEach(function(e){n._callInternal(e,r)})}),"function"==typeof t&&t(null)},d.prototype._callInternal=function(e,t){var n=this._createPeer(e,this.currentUserID<e);this.peerConnections[e]=n,n.addLocalStream(this.localStream),n.setLocalSessionDescription({type:"offer"},function(e){e?s.trace("setLocalSessionDescription error: "+e):(s.trace("setLocalSessionDescription success"),n._startDialingTimer(t))})},d.prototype.accept=function(e){var t=this,n=p(e);if(s.trace("Accept, extension: "+JSON.stringify(n.userInfo)),t.state!==d.State.ACTIVE){if(t.state===d.State.CLOSED)return s.traceError("Can't accept, the session is already closed, return."),void t.stop({});t.state=d.State.ACTIVE,t.acceptCallTime=new Date,t._clearAnswerTimer(),t._acceptInternal(t.initiatorID,n);var r=t._uniqueOpponentsIDsWithoutInitiator();if(r.length>0){var i=(t.acceptCallTime-t.startCallTime)/1e3;t._startWaitingOfferOrAnswerTimer(i),r.forEach(function(e,n,r){t.currentUserID>e&&t._callInternal(e,{},!0)})}}else s.traceError("Can't accept, the session is already active, return.")},d.prototype._acceptInternal=function(e,t){var n=this,r=this.peerConnections[e];if(r){var i=r.getRemoteSDP();r.addLocalStream(n.localStream),r.setRemoteSessionDescription(i,function(i){i?s.traceError("'setRemoteSessionDescription' error: "+i):(s.trace("'setRemoteSessionDescription' success"),r.setLocalSessionDescription({type:"answer"},function(i){i?s.trace("setLocalSessionDescription error: "+i):(s.trace("'setLocalSessionDescription' success"),t.sessionID=n.ID,t.callType=n.callType,t.callerID=n.initiatorID,t.opponentsIDs=n.opponentsIDs,r._pc.localDescription&&(t.sdp=r._pc.localDescription.toJSON().sdp),n.signalingProvider.sendMessage(e,t,a.SignalingType.ACCEPT))}))})}else s.traceError("Can't accept the call, peer connection for userID "+e+" was not found")},d.prototype.reject=function(e){var t=this,n=p(e);s.trace("Reject, extension: "+JSON.stringify(n.userInfo)),t.state=d.State.REJECTED,t._clearAnswerTimer(),n.sessionID=t.ID,n.callType=t.callType,n.callerID=t.initiatorID,n.opponentsIDs=t.opponentsIDs,Object.keys(t.peerConnections).forEach(function(e){var r=t.peerConnections[e];t.signalingProvider.sendMessage(r.userID,n,a.SignalingType.REJECT)}),t._close()},d.prototype.stop=function(e){var t=this,n=p(e);s.trace("Stop, extension: "+JSON.stringify(n.userInfo)),t.state=d.State.HUNGUP,t.answerTimer&&t._clearAnswerTimer(),n.sessionID=t.ID,n.callType=t.callType,n.callerID=t.initiatorID,n.opponentsIDs=t.opponentsIDs,Object.keys(t.peerConnections).forEach(function(e){var r=t.peerConnections[e];t.signalingProvider.sendMessage(r.userID,n,a.SignalingType.STOP)}),t._close()},d.prototype.closeConnection=function(e){var t=this.peerConnections[e];if(!t)return s.traceWarn("Not found connection with user ("+e+")"),!1;try{t.release()}catch(e){s.traceError(e)}finally{this._closeSessionIfAllConnectionsClosed()}},d.prototype.update=function(e,t){var n="object"==typeof e?e:{};if(s.trace("Update, extension: "+JSON.stringify(e)),null!==e)if(n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,t)this.signalingProvider.sendMessage(t,n,a.SignalingType.PARAMETERS_CHANGED);else for(var r in this.peerConnections){var i=this.peerConnections[r];this.signalingProvider.sendMessage(i.userID,n,a.SignalingType.PARAMETERS_CHANGED)}else s.trace("extension is null, no parameters to update")},d.prototype.mute=function(e){this._muteStream(0,e)},d.prototype.unmute=function(e){this._muteStream(1,e)},d.prototype.processOnCall=function(e,t){var n=this;n._uniqueOpponentsIDs().forEach(function(r){var i=n.peerConnections[r];i||(i=n._createPeer(r,n.currentUserID<r),n.peerConnections[r]=i,r==e&&n._startAnswerTimer()),r==e&&(i.setRemoteSDP(new window.RTCSessionDescription({sdp:t.sdp,type:"offer"})),e!=n.initiatorID&&n.state===d.State.ACTIVE&&n._acceptInternal(e,{}))})},d.prototype.processOnAccept=function(e,t){var n=this,r=this.peerConnections[e];if(r)if(r._clearDialingTimer(),"stable"!==r._pc.signalingState){var i=new window.RTCSessionDescription({sdp:t.sdp,type:"answer"});r.setRemoteSDP(i),r.setRemoteSessionDescription(i,function(e){e?s.traceError("'setRemoteSessionDescription' error: "+e):(s.trace("'setRemoteSessionDescription' success"),n.state!==d.State.ACTIVE&&(n.state=d.State.ACTIVE))})}else s.traceError("Ignore 'onAccept', PeerConnection is already in 'stable' state");else s.traceError("Ignore 'OnAccept': peer connection for user with Id "+e+" was not found")},d.prototype.processOnReject=function(e,t){var n=this.peerConnections[e];this._clearWaitingOfferOrAnswerTimer(),n?n.release():s.traceError("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnStop=function(e,t){this._clearAnswerTimer();var n=this.peerConnections[e];n?(n.release(),n._reconnecting&&(n._reconnecting=!1),this._stopReconnectTimer(e)):s.traceError("Ignore 'OnStop', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnIceCandidates=function(e,t){var n=this.peerConnections[e];n?n.addCandidates(t.iceCandidates):s.traceError("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")},d.prototype.processOnUpdate=function(e,t){var n=t.sessionDescription,r=t.reason;this.state===d.State.ACTIVE&&r&&"reconnect"===r&&(this.peerConnections[e]?n&&("offer"===n.type?this._processReconnectOffer(e,n):this._processReconnectAnswer(e,n)):s.traceError("Ignore 'OnUpdate': peer connection for user with Id "+e+" was not found"))},d.prototype._processReconnectOffer=function(e,t){var n=this;if(this.peerConnections[e].polite){this._reconnect(this.peerConnections[e]);var r=this.peerConnections[e],i=t.offerId,o=new window.RTCSessionDescription({sdp:t.sdp,type:t.type});r.setRemoteSDP(o),r.setRemoteSessionDescription(o,function(t){t?s.traceError('"setRemoteSessionDescription" error:'+t.message):r.setLocalSessionDescription({type:"answer"},function(){var t=r._pc.localDescription.toJSON(),o={reason:"reconnect",sessionDescription:{offerId:i,sdp:t.sdp,type:t.type}};n.update(o,e)})})}else this._reconnect(this.peerConnections[e],!0)},d.prototype._processReconnectAnswer=function(e,t){var n=this.peerConnections[e],r=t.offerId;if(n&&n.offerId&&r&&n.offerId===r){var i=new window.RTCSessionDescription({sdp:t.sdp,type:t.type});n.setRemoteSDP(i),n.setRemoteSessionDescription(i,function(e){e&&s.traceError('"setRemoteSessionDescription" error:'+e.message)})}},d.prototype.processCall=function(e,t){var n=t||{};e._pc.localDescription&&(n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,n.sdp=e._pc.localDescription.sdp,n.userInfo=t&&t.userInfo?t.userInfo:{},n.userInfo.bandwidth=this.bandwidth,this.signalingProvider.sendMessage(e.userID,n,a.SignalingType.CALL))},d.prototype.processIceCandidates=function(e,t){var n={};n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(e.userID,t,n)},d.prototype.processOnNotAnswer=function(e){s.trace("Answer timeout callback for session "+this.ID+" for user "+e.userID),this._clearWaitingOfferOrAnswerTimer(),e.release(),"function"==typeof this.onUserNotAnswerListener&&o.safeCallbackCall(this.onUserNotAnswerListener,this,e.userID),this._closeSessionIfAllConnectionsClosed()},d.prototype._onRemoteStreamListener=function(e,t){"function"==typeof this.onRemoteStreamListener&&o.safeCallbackCall(this.onRemoteStreamListener,this,e,t)},d.prototype._onCallStatsReport=function(e,t,n){"function"==typeof this.onCallStatsReport&&o.safeCallbackCall(this.onCallStatsReport,this,e,t,n)},d.prototype._onSessionConnectionStateChangedListener=function(e,t){var n=s.SessionConnectionState.CLOSED,r=this.peerConnections[e];"function"==typeof this.onSessionConnectionStateChangedListener&&o.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e,t),t===n&&r&&(r._pc.onicecandidate=null,r._pc.onsignalingstatechange=null,r._pc.ontrack=null,r._pc.oniceconnectionstatechange=null,delete this.peerConnections[e])},d.prototype._createPeer=function(e,t){if(!window.RTCPeerConnection)throw new Error("_createPeer error: RTCPeerConnection is not supported in your browser");this.startCallTime=new Date;const n={iceServers:r.webrtc.iceServers},o=void 0===r.webrtc.iceTransportPolicy?{}:{iceTransportPolicy:r.webrtc.iceTransportPolicy},a=Object.assign({},n,o);s.trace("_createPeer configuration: "+JSON.stringify(a));var c=new i(a);return c._init(this,e,this.ID,t),c},d.prototype._startReconnectTimer=function(e){var t=this,n=1e3*r.webrtc.disconnectTimeInterval,i=this.peerConnections[e];i._reconnecting=!0;var a=function(){s.trace("disconnectTimeInterval reached for userID "+e),t._stopReconnectTimer(e),t.peerConnections[e].release(),t._onSessionConnectionStateChangedListener(e,s.SessionConnectionState.CLOSED),t._closeSessionIfAllConnectionsClosed()};"function"==typeof this.onReconnectListener&&o.safeCallbackCall(this.onReconnectListener,this,e,c),s.trace("_startReconnectTimer for userID:"+e+", timeout: "+n);this.iceConnectTimers[e]||(this.iceConnectTimers[e]=setTimeout(function(){s.trace("iceConnectTimeout reached for user "+e),t.iceConnectTimers[e]&&(clearTimeout(t.iceConnectTimers[e]),t.iceConnectTimers[e]=void 0,t.reconnectTimers[e]||(t.reconnectTimers[e]=setTimeout(a,n-5e3),t._reconnectToChat(function(){t.state===d.State.ACTIVE&&t.reconnectTimers[e]&&t._reconnect(i,!0)})))},5e3))},d.prototype._stopReconnectTimer=function(e){var t=this.peerConnections[e];if(this.iceConnectTimers[e]&&(clearTimeout(this.iceConnectTimers[e]),this.iceConnectTimers[e]=void 0),this.reconnectTimers[e]&&(s.trace("_stopReconnectTimer for userID: "+e),clearTimeout(this.reconnectTimers[e]),this.reconnectTimers[e]=void 0),t&&t._reconnecting&&(t._reconnecting=!1,"function"==typeof this.onReconnectListener)){var n=t._pc.iceConnectionState;o.safeCallbackCall(this.onReconnectListener,this,e,"connected"===n?l:u)}},d.prototype._reconnectToChat=function(e){var t=this,n=this.signalingProvider,r=function(){var t=n.chat.onReconnectListener;n.chat.onReconnectListener=function(){"function"==typeof t&&t(),n.chat.onReconnectListener=t,e()},n.chat.reconnect()};if(n&&n.chat)try{n.chat.ping(function(n){t.state!==d.State.CLOSED&&(n?r():e())})}catch(e){t.state!==d.State.CLOSED&&r()}},d.prototype._reconnect=function(e,t){if(!e||!e.userID)return;var n=e.userID,o=e.polite,a=e._reconnecting;e.release();const c={iceServers:r.webrtc.iceServers},l=void 0===r.webrtc.iceTransportPolicy?{}:{iceTransportPolicy:r.webrtc.iceTransportPolicy},u=Object.assign({},c,l);s.trace("_reconnect peer configuration: "+JSON.stringify(u));var d=new i(u);this.peerConnections[n]=d,d._init(this,n,this.ID,o),d._reconnecting=a,d.addLocalStream(this.localStream),t&&(d.offerId=h(),d.negotiate())},d.prototype._close=function(){for(var e in s.trace("_close"),this.peerConnections){var t=this.peerConnections[e];this._stopReconnectTimer(t.userID);try{t.release()}catch(e){console.warn("Peer close error:",e)}}this._closeLocalMediaStream(),"function"==typeof this._detectSilentAudioTaskCleanup&&(this._detectSilentAudioTaskCleanup(),this._detectSilentAudioTaskCleanup=void 0),"function"==typeof this._detectSilentVideoTaskCleanup&&(this._detectSilentVideoTaskCleanup(),this._detectSilentVideoTaskCleanup=void 0),this.state=d.State.CLOSED,"function"==typeof this.onSessionCloseListener&&o.safeCallbackCall(this.onSessionCloseListener,this)},d.prototype._closeSessionIfAllConnectionsClosed=function(){var e=Object.values(this.peerConnections).every(function(e){return e.state===i.State.CLOSED});s.trace("All peer connections closed: "+e),e&&(this._closeLocalMediaStream(),"function"==typeof this.onSessionCloseListener&&this.onSessionCloseListener(this),this.state=d.State.CLOSED)},d.prototype._closeLocalMediaStream=function(){this.localStream&&(this.localStream.getTracks().forEach(function(e){e.stop(),e.enabled=!1}),this.localStream=null)},d.prototype._muteStream=function(e,t){"audio"===t&&this.localStream.getAudioTracks().length>0?this.localStream.getAudioTracks().forEach(function(t){t.enabled=!!e}):"video"===t&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach(function(t){t.enabled=!!e})},d.prototype._clearAnswerTimer=function(){this.answerTimer&&(s.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)},d.prototype._startAnswerTimer=function(){s.trace("_startAnswerTimer");var e=this,t=1e3*r.webrtc.answerTimeInterval;this.answerTimer=setTimeout(function(){s.trace("_answerTimeoutCallback"),"function"==typeof e.onSessionCloseListener&&e._close(),e.answerTimer=null},t)},d.prototype._clearWaitingOfferOrAnswerTimer=function(){this.waitingOfferOrAnswerTimer&&(s.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)},d.prototype._startWaitingOfferOrAnswerTimer=function(e){var t=this,n=r.webrtc.answerTimeInterval-e<0?1:r.webrtc.answerTimeInterval-e;s.trace("_startWaitingOfferOrAnswerTimer, timeout: "+n),this.waitingOfferOrAnswerTimer=setTimeout(function(){s.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(t.peerConnections).length>0&&Object.keys(t.peerConnections).forEach(function(e){var n=t.peerConnections[e];n.state!==i.State.CONNECTING&&n.state!==i.State.NEW||t.processOnNotAnswer(n)}),t.waitingOfferOrAnswerTimer=null},1e3*n)},d.prototype._uniqueOpponentsIDs=function(){var e=this,t=[];return this.initiatorID!==this.currentUserID&&t.push(this.initiatorID),this.opponentsIDs.forEach(function(n,r,i){n!=e.currentUserID&&t.push(parseInt(n))}),t},d.prototype._uniqueOpponentsIDsWithoutInitiator=function(){var e=this,t=[];return this.opponentsIDs.forEach(function(n,r,i){n!=e.currentUserID&&t.push(parseInt(n))}),t},d.prototype.toString=function(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType},t.exports=d},{"../../qbConfig":151,"../../qbUtils":155,"./qbRTCPeerConnection":143,"./qbWebRTCHelpers":145,"./qbWebRTCSignalingConstants":147}],147:[function(e,t,n){"use strict";function r(){}r.MODULE_ID="WebRTCVideoChat",r.SignalingType={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},t.exports=r},{}],148:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbWebRTCSignalingConstants");t.exports=function(e,t){var n=this;n.service=e,n.delegate=t,this._onMessage=function(e,t,r,i){var s=n._getExtension(t),a=s.sessionID,c=s.signalType;switch(delete s.moduleIdentifier,delete s.sessionID,delete s.signalType,c){case o.SignalingType.CALL:"function"==typeof n.delegate._onCallListener&&n.delegate._onCallListener(i,a,s);break;case o.SignalingType.ACCEPT:"function"==typeof n.delegate._onAcceptListener&&n.delegate._onAcceptListener(i,a,s);break;case o.SignalingType.REJECT:"function"==typeof n.delegate._onRejectListener&&n.delegate._onRejectListener(i,a,s);break;case o.SignalingType.STOP:"function"==typeof n.delegate._onStopListener&&n.delegate._onStopListener(i,a,s);break;case o.SignalingType.CANDIDATE:"function"==typeof n.delegate._onIceCandidatesListener&&n.delegate._onIceCandidatesListener(i,a,s);break;case o.SignalingType.PARAMETERS_CHANGED:"function"==typeof n.delegate._onUpdateListener&&n.delegate._onUpdateListener(i,a,s)}},this._getExtension=function(e){if(!e)return{};var t={},r=[],i=[];return e.childNodes.forEach(function(e){"iceCandidates"===e.nodeName?e.childNodes.forEach(function(e){var t={};e.childNodes.forEach(function(e){t[e.nodeName]=e.textContent}),r.push(t)}):"opponentsIDs"===e.nodeName?e.childNodes.forEach(function(e){var t=e.textContent;i.push(parseInt(t))}):e.childNodes.length>1?t=n._XMLtoJS(t,e.nodeName,e):"userInfo"===e.nodeName?t=n._XMLtoJS(t,e.nodeName,e):t[e.nodeName]=e.textContent}),r.length>0&&(t.iceCandidates=r),i.length>0&&(t.opponentsIDs=i),t},this._XMLtoJS=function(e,t,n){var r=this;return e[t]={},n.childNodes.forEach(function(n){n.childNodes.length>1?e[t]=r._XMLtoJS(e[t],n.nodeName,n):e[t][n.nodeName]=n.textContent}),e}}},{"./qbWebRTCSignalingConstants":147,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],149:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbWebRTCHelpers"),s=e("./qbWebRTCSignalingConstants"),a=e("../../qbUtils"),c=e("../../qbConfig");function l(e,t){this.service=e,this.chat=t}l.prototype.sendCandidate=function(e,t,n){var r=n||{};r.iceCandidates=t,this.sendMessage(e,r,s.SignalingType.CANDIDATE)},l.prototype.sendMessage=function(e,t,n){var r=t||{},l=this;r.moduleIdentifier=s.MODULE_ID,r.signalType=n,r.platform="web",r.userInfo&&!Object.keys(r.userInfo).length&&delete r.userInfo;var u={to:o.getUserJid(e,c.creds.appId),type:"headline",id:a.getBsonObjectId()},d=$msg(u).c("extraParams",{xmlns:i.NS.CLIENT});Object.keys(r).forEach(function(e){"iceCandidates"===e?(d.c("iceCandidates"),r[e].forEach(function(e){d.c("iceCandidate"),Object.keys(e).forEach(function(t){d.c(t).t(e[t]).up()}),d.up()}),d.up()):"opponentsIDs"===e?(d.c("opponentsIDs"),r[e].forEach(function(e){d.c("opponentID").t(e).up()}),d.up()):"object"==typeof r[e]?l._JStoXML(e,r[e],d):d.c(e).t(r[e]).up()}),this.chat.connection.send(d)},l.prototype._JStoXML=function(e,t,n){var r=this;n.c(e),Object.keys(t).forEach(function(e){"object"==typeof t[e]?r._JStoXML(e,t[e],n):n.c(e).t(t[e]).up()}),n.up()},t.exports=l},{"../../qbConfig":151,"../../qbUtils":155,"./qbWebRTCHelpers":145,"./qbWebRTCSignalingConstants":147,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],150:[function(e,t,n){"use strict";var r=e("../qbUtils"),i=e("../modules/chat/qbChatHelpers");function o(e){this._NS="urn:xmpp:sm:3",this._isStreamManagementEnabled=!1,this._clientProcessedStanzasCounter=null,this._clientSentStanzasCounter=null,this._intervalId=null,this._timeInterval=r.getTimeIntervalForCallBackMessage(),this.sentMessageCallback=null,r.getEnv().browser&&(this._parser=new DOMParser),this._c=null,this._nodeBuilder=null,this._originalSend=null,this._stanzasQueue=[]}o.prototype.enable=function(e,t){var n,o={xmlns:this._NS};this._isStreamManagementEnabled||(this._c=e,this._originalSend=this._c.send,this._c.send=this.send.bind(this)),r.getEnv().browser?(this._clientProcessedStanzasCounter=null,this._clientSentStanzasCounter=null,this._addEnableHandlers(),n=$build("enable",o)):(this._nodeBuilder=t.Stanza,this._addEnableHandlers(),n=i.createStanza(this._nodeBuilder,o,"enable")),this._c.send(n)},o.prototype._timeoutCallback=function(){var e=Date.now(),t=[];if(this._stanzasQueue.length){for(var n=0;n<this._stanzasQueue.length;n++)this._stanzasQueue[n]&&this._stanzasQueue[n].time<e?this.sentMessageCallback(this._stanzasQueue[n].message):t.push(this._stanzasQueue[n]);this._stanzasQueue=t}},o.prototype._addEnableHandlers=function(){var e=this;function t(t){var n=t.name||t.tagName||t.nodeTree.tagName;if("enabled"===n)return e._isStreamManagementEnabled=!0,!0;if(e._isStreamManagementEnabled&&"message"===n)return clearInterval(e._intervalId),e._intervalId=setInterval(e._timeoutCallback.bind(e),e._timeInterval),!0;if(i.getAttr(t,"xmlns")!==e._NS&&e._increaseReceivedStanzasCounter(),"r"===n){var o={xmlns:e._NS,h:e._clientProcessedStanzasCounter},s=r.getEnv().browser?$build("a",o):i.createStanza(e._nodeBuilder,o,"a");return e._originalSend.call(e._c,s),!0}if("a"===n){var a=parseInt(i.getAttr(t,"h"));e._checkCounterOnIncomeStanza(a)}return!0}r.getEnv().browser?e._c.XAddTrackedHandler(t.bind(e)):e._c.on("stanza",t.bind(e))},o.prototype.send=function(e,t){var n=e.nodeTree?this._parser.parseFromString(e.nodeTree.outerHTML,"application/xml").childNodes[0]:e,o=n.name||n.tagName||n.nodeTree.tagName,s=i.getAttr(n,"type"),a=i.getElementText(n,"body")||"",c=i.getAllElements(n,"attachment")||"";try{this._originalSend.call(this._c,e)}catch(e){r.QBLog("[QBChat]",e.message)}finally{"message"!==o||"chat"!==s&&"groupchat"!==s||!a&&!c.length||this._sendStanzasRequest({message:t,time:Date.now()+this._timeInterval,expect:this._clientSentStanzasCounter}),this._clientSentStanzasCounter++}},o.prototype._sendStanzasRequest=function(e){if(this._isStreamManagementEnabled){this._stanzasQueue.push(e);var t=r.getEnv().browser?$build("r",{xmlns:this._NS}):i.createStanza(this._nodeBuilder,{xmlns:this._NS},"r");this._c.connected?this._originalSend.call(this._c,t):this._checkCounterOnIncomeStanza()}},o.prototype.getClientSentStanzasCounter=function(){return this._clientSentStanzasCounter},o.prototype._checkCounterOnIncomeStanza=function(e){var t=[];if(this._stanzasQueue.length){for(var n=0;n<this._stanzasQueue.length;n++)this._stanzasQueue[n].expect==e?this.sentMessageCallback(null,this._stanzasQueue[n].message):t.push(this._stanzasQueue[n]);this._stanzasQueue=t}},o.prototype._increaseReceivedStanzasCounter=function(){this._clientProcessedStanzasCounter++},t.exports=o},{"../modules/chat/qbChatHelpers":133,"../qbUtils":155}],151:[function(e,t,n){"use strict";var r={version:"2.22.0",buildNumber:"1177",creds:{appId:0,authKey:"",authSecret:"",accountKey:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com"},hash:"sha1",streamManagement:{enable:!1},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},pingTimeout:1,pingDebug:!1,initBlockOnSettings:!1,initBlockDurationMs:3e3,pingLocalhostTimeInterval:5,chatReconnectionTimeInterval:3,chatPingMissLimit:3,webrtc:{answerTimeInterval:60,autoReject:!0,incomingLimit:1,dialingTimeInterval:5,disconnectTimeInterval:30,statsReportTimeInterval:!1,iceTransportPolicy:void 0,iceServers:[{urls:["turn:turn.quickblox.com","stun:turn.quickblox.com"],username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"}]},urls:{account:"account_settings",session:"session",login:"login",users:"users",chat:"chat",blobs:"blobs",geodata:"geodata",pushtokens:"push_tokens",subscriptions:"subscriptions",events:"events",data:"data",addressbook:"address_book",addressbookRegistered:"address_book/registered_users",type:".json"},on:{sessionExpired:null},timeout:null,debug:{mode:0,file:null},addISOTime:!1,qbTokenExpirationDate:null,liveSessionInterval:120,callBackInterval:30,set:function(e){"object"==typeof e.endpoints&&e.endpoints.chat&&(r.endpoints.muc="muc."+e.endpoints.chat,r.chatProtocol.bosh="https://"+e.endpoints.chat+":5281",r.chatProtocol.websocket="wss://"+e.endpoints.chat+":5291"),Object.keys(e).forEach(function(t){"set"!==t&&Object.prototype.hasOwnProperty.call(r,t)&&("object"!=typeof e[t]||null===e[t]?void 0!==e[t]&&(r[t]=e[t]):Object.keys(e[t]).forEach(function(n){Object.prototype.hasOwnProperty.call(r[t],n)&&void 0!==e[t][n]&&(r[t][n]=e[t][n])})),"iceServers"===t&&void 0!==e[t]&&(r.webrtc.iceServers=e[t]),"iceTransportPolicy"===t&&void 0!==e[t]&&(r.webrtc.iceTransportPolicy=e[t])})},updateSessionExpirationDate:function(e,t=!1){var n;if(t){var i=e.replaceAll("-","/");(n=new Date(i)).setMinutes(n.getMinutes()-1)}else(n=new Date(e)).setMinutes(n.getMinutes()-1),n.setMinutes(n.getMinutes()+r.liveSessionInterval);r.qbTokenExpirationDate=n}};t.exports=r},{}],152:[function(e,t,n){"use strict";var r=e("./qbConfig"),i=e("./qbUtils");function o(){}o.prototype={version:r.version,buildNumber:r.buildNumber,_getOS:i.getOS.bind(i),init:function(t,n,o,s,a){console.log("current platform: ",i.getEnv()),"string"==typeof s&&s.length?(a&&"object"==typeof a&&r.set(a),r.creds.accountKey=s):(console.warn('Parameter "accountKey" is missing. This will lead to error in next major release'),console.warn('NOTE: Account migration will not work without "accountKey"'),"object"==typeof s&&r.set(s));var c="api.quickblox.com",l=e("./qbProxy"),u=e("./modules/qbAuth"),d=e("./modules/qbUsers"),h=e("./modules/qbContent"),p=e("./modules/qbPushNotifications"),f=e("./modules/qbData"),m=e("./modules/qbAddressBook"),g=e("./modules/chat/qbChat"),v=e("./modules/chat/qbDialog"),y=e("./modules/chat/qbMessage"),b=e("./modules/qbAI");if(this.service=new l,this.auth=new u(this.service),this.users=new d(this.service),this.content=new h(this.service),this.pushnotifications=new p(this.service),this.data=new f(this.service),this.addressbook=new m(this.service),this.chat=new g(this.service),this.chat.dialog=new v(this.service),this.chat.message=new y(this.service),this.ai=new b(this.service),i.getEnv().browser)if(e("webrtc-adapter"),i.isWebRTCAvailble()){var S=e("./modules/webrtc/qbWebRTCClient");this.webrtc=new S(this.service,this.chat)}else this.webrtc=!1;else this.webrtc=!1;this._initReady=Promise.resolve();var C="boolean"!=typeof r.initBlockOnSettings||r.initBlockOnSettings,_="number"==typeof r.initBlockDurationMs?r.initBlockDurationMs:3e3;"string"!=typeof t||n&&"number"!=typeof n||o?(r.creds.appId=t,r.creds.authKey=n,r.creds.authSecret=o):("number"==typeof n&&(r.creds.appId=n),this.service.setSession({token:t}));var w=r.creds.accountKey&&(!r.endpoints.api||r.endpoints.api===c||!r.endpoints.chat||"chat.quickblox.com"===r.endpoints.chat);if(w){var T=["https://",c,"/",r.urls.account,r.urls.type].join(""),E=function(e){var t={};return e?(Object.keys(e).forEach(function(n){/^on[A-Z]/.test(n)&&"function"==typeof e[n]&&(t[n]=e[n])}),t):t},x=function(e,t){e&&t&&Object.keys(t).forEach(function(n){e[n]=t[n]})},R=this;this._initReady=new Promise(function(t){R.service.ajax({url:T},function(n,o){if(!n&&"object"==typeof o){var s={endpoints:{api:o.api_endpoint.replace(/^https?:\/\//,""),chat:o.chat_endpoint}};r.set(s);var a=E(R.chat),c=E(R.webrtc);if(R.pushnotifications=new p(R.service),R.chat=new g(R.service),R.chat.dialog=new v(R.service),R.chat.message=new y(R.service),i.getEnv().browser)if(e("webrtc-adapter"),i.isWebRTCAvailble()){var l=e("./modules/webrtc/qbWebRTCClient");R.webrtc=new l(R.service,R.chat)}else R.webrtc=!1;else R.webrtc=!1;x(R.chat,a),x(R.webrtc,c)}t()})})}if(w&&C)try{for(var k=Date.now()+_;Date.now()<k;);}catch(e){}},ready:function(){return this._initReady||Promise.resolve()},initWithAppId:function(e,t,n){if("number"!=typeof e)throw new Error("Type of appId must be a number");if(""===e||null==e||""===t||null==t)throw new Error("Cannot init QuickBlox without app credentials (app ID, auth key)");this.init("",e,null,t,n)},getSession:function(e){this.auth.getSession(e)},startSessionWithToken:function(e,t){if(void 0===e)throw new Error("Cannot start session with undefined token");if(""===e)throw new Error("Cannot start session with empty string token");if(null===e)throw new Error("Cannot start session with null value token");if("function"!=typeof t)throw new Error("Cannot start session without callback function");try{this.service.setSession({token:e})}catch(e){t(e,null)}if("function"==typeof t)try{this.auth.getSession(t)}catch(e){t(e,null)}},createSession:function(e,t){this.auth.createSession(e,t)},destroySession:function(e){this.auth.destroySession(e)},login:function(e,t){this.auth.login(e,t)},logout:function(e){this.auth.logout(e)}};var s=new o;s.QuickBlox=o,t.exports=s},{"./modules/chat/qbChat":132,"./modules/chat/qbDialog":134,"./modules/chat/qbMessage":135,"./modules/qbAI":136,"./modules/qbAddressBook":137,"./modules/qbAuth":138,"./modules/qbContent":139,"./modules/qbData":140,"./modules/qbPushNotifications":141,"./modules/qbUsers":142,"./modules/webrtc/qbWebRTCClient":144,"./qbConfig":151,"./qbProxy":153,"./qbUtils":155,"webrtc-adapter":117}],153:[function(e,t,n){"use strict";var r,i,o=e("./qbConfig"),s=e("./qbUtils");function a(){this.qbInst={config:o,session:null},this.reqCount=0}s.getEnv().node?(r=e("node-fetch"),i=e("form-data")):(r=fetch,i=FormData),a.prototype={_fetchingSettings:!1,_queue:[],setSession:function(e){this.qbInst.session=e},getSession:function(){return this.qbInst.session},handleResponse:function(e,t,n,r){if(e){const i=e.message?JSON.stringify(e.message).toLowerCase():"";"function"==typeof o.on.sessionExpired&&401===e.code&&i.indexOf("session does not exist")>-1?o.on.sessionExpired(function(){n(e,t)},r):n(e,null)}else o.addISOTime&&(t=s.injectISOTimes(t)),n(null,t)},startLogger:function(e){var t;++this.reqCount,e.data&&e.data.file?(t=JSON.parse(JSON.stringify(e.data))).file="...":t=s.getEnv().nativescript?JSON.stringify(e.data):e.data,s.QBLog("[Request]["+this.reqCount+"]",(e.type||"GET")+" "+e.url,t||"")},ajax:function(e,t){if(this._fetchingSettings)this._queue.push([e,t]);else{this.startLogger(e);var n,a,c=this,l=!e.type||"GET"===e.type||"HEAD"===e.type,u=c.qbInst&&c.qbInst.session&&c.qbInst.session.token,d=-1===e.url.indexOf("s3.amazonaws.com"),h=!1===e.contentType,p=e.dataType||"json",f=e.url,m={};m.method=e.type||"GET",e.data&&(n=function(){var t,n=e.data;h?(t=new i,Object.keys(n).forEach(function(r){e.fileToCustomObject&&"file"===r?t.append(r,n[r].data,n[r].name):t.append(r,e.data[r])})):t=e.isNeedStringify?JSON.stringify(n):Object.keys(n).map(function(e){return s.isObject(n[e])?Object.keys(n[e]).map(function(t){return g(e)+"["+(s.isArray(n[e])?"":t)+"]="+g(n[e][t])}).sort().join("&"):g(e)+(s.isArray(n[e])?"[]":"")+"="+g(n[e])}).sort().join("&");return t}(),l?f+="?"+n:m.body=n),h||(m.headers={"Content-Type":e.contentType||"application/x-www-form-urlencoded; charset=UTF-8"}),d&&(m.headers||(m.headers={}),m.headers["QB-OS"]=s.getOS(),m.headers["QB-SDK"]="JS "+o.version+" - Client",u&&(m.headers["QB-Token"]=u),e.url.indexOf(o.urls.account)>-1&&(m.headers["QB-Account-Key"]=o.creds.accountKey,this._fetchingSettings=!0)),e.headers&&Object.keys(e.headers).forEach(function(t){m.headers[t]=e.headers[t]}),o.timeout&&(m.timeout=o.timeout),r(f,m).then(function(e){if(a=e,"GET"===m.method||"POST"===m.method){var t=a.headers.get("qb-token-expirationdate"),n=!(null==t);t=n?t:new Date,c.qbInst.config.updateSessionExpirationDate(t,n),s.QBLog("[Request][ajax]","header has token:",n),s.QBLog("[Request][ajax]","updateSessionExpirationDate ... Set value: ",c.qbInst.config.qbTokenExpirationDate)}return"text"===p?e.text():e.json()},function(){return a={status:200}," "}).then(function(e){v(null,a,e)},function(e){v(e)}).catch(e=>{console.log("qbProxy fetch ... catch, error: ",e),v(e)})}function g(e){return encodeURIComponent(e).replace(/[#$&+,/:;=?@\[\]]/g,function(e){return"%"+e.charCodeAt(0).toString(16)})}function v(e,n,r){var i,o,a=n&&(n.status||n.statusCode);if(e||200!==a&&201!==a&&202!==a){var l;try{l={code:n&&a||e&&e.code,status:n&&n.headers&&n.headers.status||"error",message:r||e&&e.errno,detail:r&&r.errors||e&&e.syscall}}catch(t){l=e}o=r||e||r.errors,i=s.getEnv().nativescript?JSON.stringify(o):o,s.QBLog("[Response]["+c.reqCount+"]","error",a,i),c.handleResponse(l,null,t,y)}else o=r&&" "!==r?r:"empty body",i=s.getEnv().nativescript?JSON.stringify(o):o,s.QBLog("[Response]["+c.reqCount+"]",i),c.handleResponse(null,r,t,y);if(c._fetchingSettings){c._fetchingSettings=!1;var u="api.quickblox.com",d="chat.quickblox.com";u=u.replace(/^https?:\/\//i,"").replace(/\/+$/,""),d=d.replace(/^https?:\/\//i,"").replace(/\/+$/,"");for(var h=new RegExp("^https?://"+u.replace(/\./g,"\\.")+"(?=[:/]|$)","i"),p=new RegExp("^https?://"+d.replace(/\./g,"\\.")+"(?=[:/]|$)","i"),f="https://"+(c.qbInst.config.endpoints.api||"").replace(/^https?:\/\//i,"").replace(/\/+$/,""),m="https://"+(c.qbInst.config.endpoints.chat||"").replace(/^https?:\/\//i,"").replace(/\/+$/,"");c._queue.length;){var g=c._queue.shift(),v=g&&g[0];if(v&&"string"==typeof v.url){var b=v.url,S=!1;h.test(b)&&(b=b.replace(h,f),S=!0),p.test(b)&&(b=b.replace(p,m),S=!0),S&&(v.url=b)}c.ajax.apply(c,g)}}}function y(n){n&&(c.setSession(n),c.ajax(e,t))}}},t.exports=a},{"./qbConfig":151,"./qbUtils":155,"form-data":38,"node-fetch":59}],154:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbConfig"),s=o.chatProtocol,a=e("./qbUtils");t.exports=function(e){var t=1===s.active?s.bosh:s.websocket,n=new i.Connection(t),r=o.debug?e:null,c=function(t,n){if((r=o.debug?e:null)&&"function"==typeof r){var i=n&&n.id?n.id:"",s=n&&n.innerHTML?n.innerHTML:"",c=n&&n.outerHTML?n.outerHTML:"";a.safeCallbackCall(r,"[QBChat][QBStrophe]"+t+" id:"+i+" innerHTML: "+s+" outerHTML: "+c+JSON.stringify(n))}};return 1===s.active?(n.xmlInput=function(e){if(e.childNodes[0])for(var t=0,n=e.childNodes.length;t<n;t++)a.QBLog("[QBChat]","RECV:",e.childNodes[t]),c("RECV:",e.childNodes[t])},n.xmlOutput=function(e){if(e.childNodes[0])for(var t=0,n=e.childNodes.length;t<n;t++)a.QBLog("[QBChat]","SENT:",e.childNodes[t]),c("SENT",e.childNodes[t])}):(n.xmlInput=function(e){a.QBLog("[QBChat]","RECV:",e),c("RECV:",e);try{let t=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("error");if(t.length>0){let e=t[0].getElementsByTagName("condition");if(e.length>0){let t=e[0].textContent;console.log("Disconnect condition:",t),c("DISCONNECTED CONDITION:",t)}}}catch(e){console.error("Error parsing XML input:",e)}},n.xmlOutput=function(e){a.QBLog("[QBChat]","SENT:",e),c("SENT",e)}),n}},{"./qbConfig":151,"./qbUtils":155,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],155:[function(e,t,n){(function(r){(function(){"use strict";var i=e("./qbConfig"),o="object"==typeof r&&(r.hasOwnProperty("android")||r.hasOwnProperty("NSObject")),s="undefined"==typeof window&&"object"==typeof n&&!o,a="undefined"!=typeof window;if(s)var c=e("fs"),l=e("os");var u={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0},d={getEnv:function(){return{nativescript:o,browser:a,node:s}},_getOSInfoFromNodeJS:function(){return l.platform()},_getOSInfoFromBrowser:function(){return window.navigator.userAgent},_getOSInfoFromNativeScript:function(){return(r&&r.hasOwnProperty("android")?"Android":"iOS")+" - NativeScript"},getOS:function(){var e,t="An unknown OS";if(this.getEnv().browser)e=this._getOSInfoFromBrowser();else if(this.getEnv().node)e=this._getOSInfoFromNodeJS();else if(this.getEnv().nativescript)return this._getOSInfoFromNativeScript();return[{osName:"Windows",codeNames:["Windows","win32"]},{osName:"Linux",codeNames:["Linux","linux"]},{osName:"macOS",codeNames:["Mac OS","darwin"]}].forEach(function(n){n.codeNames.forEach(function(r){-1!==e.indexOf(r)&&(t=n.osName)})}),t},safeCallbackCall:function(){for(var e,t=arguments[0].toString().split("(")[0].split(" ")[1],n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);e=n.shift();try{e.apply(null,n)}catch(e){""===t?console.error("Error: "+e):console.error("Error in listener "+t+": "+e)}},randomNonce:function(){return Math.floor(1e4*Math.random())},unixTime:function(){return Math.floor(Date.now()/1e3)},getUrl:function(e,t){var n=t?"/"+t:"";return"https://"+i.endpoints.api+"/"+e+n+i.urls.type},formatUrl:function(e,t){var n=t?"/"+t:"";return"https://"+i.endpoints.api+"/"+e+n},isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},isObject:function(e){return"[object Object]"===Object.prototype.toString.call(e)},getBsonObjectId:function(){var e=this.unixTime().toString(16),t=(u.increment++).toString(16);return t>16777215&&(u.increment=0),"00000000".substr(0,8-e.length)+e+"000000".substr(0,6-u.machine.length)+u.machine+"0000".substr(0,4-u.pid.length)+u.pid+"000000".substr(0,6-t.length)+t},getCurrentTime:function(){return(new Date).toTimeString().split(" ")[0]},injectISOTimes:function(e){if(e.created_at)"number"==typeof e.created_at&&(e.iso_created_at=new Date(1e3*e.created_at).toISOString()),"number"==typeof e.updated_at&&(e.iso_updated_at=new Date(1e3*e.updated_at).toISOString());else if(e.items)for(var t=0,n=e.items.length;t<n;++t)"number"==typeof e.items[t].created_at&&(e.items[t].iso_created_at=new Date(1e3*e.items[t].created_at).toISOString()),"number"==typeof e.items[t].updated_at&&(e.items[t].iso_updated_at=new Date(1e3*e.items[t].updated_at).toISOString());return e},QBLog:function(){var e=Array.prototype.slice.call(arguments);let t=i&&!1===i.pingDebug,n=e.some(function(e){try{if(null==e)return!1;if("string"==typeof e)return-1!==e.toLowerCase().indexOf("ping");if("number"==typeof e||"boolean"==typeof e)return!1;if("object"==typeof e){if("string"==typeof e.outerHTML){var t=e.outerHTML.replace(/\s+/g," ").toLowerCase();if(-1!==t.indexOf("urn:xmpp:sm:3")&&(/^<\s*r\b/.test(t)||/^<\s*a\b/.test(t)))return!0}for(var n=[e.textContent,e.innerHTML,e.outerHTML,e.nodeName,e.tagName,e.id],r=0;r<n.length;r++){var i=n[r];if("string"==typeof i&&-1!==i.toLowerCase().indexOf("ping"))return!0}}}catch(e){}return!1}),r=t&&n;if(this.loggers)for(var o=0;o<this.loggers.length;++o)r||this.loggers[o](arguments);else{var s;this.loggers=[];var a=function(){return function(e){console.log.apply(console,Array.prototype.slice.call(e))}},l=function(){return function(e){if(!c)throw"This function isn't supported outside of the browser (...yet)";for(var t=[],n=0;n<e.length;n++)t.push(JSON.stringify(e[n]));t=t.join(" ");var r="\n"+new Date+". "+t;c.appendFile(i.debug.file,r,function(e){if(e)return console.error("Error while writing log to file. Error: "+e)})}};if("object"==typeof i.debug){if("number"==typeof i.debug.mode)1==i.debug.mode?(s=a(),this.loggers.push(s)):2==i.debug.mode&&(s=l(),this.loggers.push(s));else if("object"==typeof i.debug.mode){var u=this;i.debug.mode.forEach(function(e){1===e?(s=a(),u.loggers.push(s)):2===e&&(s=l(),u.loggers.push(s))})}}else"boolean"==typeof i.debug&&i.debug&&(s=a(),this.loggers.push(s));if(this.loggers)for(var d=0;d<this.loggers.length;++d)r||this.loggers[d](arguments)}},isWebRTCAvailble:function(){var e=window.RTCPeerConnection,t=window.RTCIceCandidate,n=window.RTCSessionDescription,r=window.navigator.mediaDevices;return Boolean(e)&&Boolean(t)&&Boolean(n)&&Boolean(r)},getError:function(e,t,n){var r={code:e,status:"error",detail:t};switch(e){case 401:r.message="Unauthorized";break;case 403:r.message="Forbidden";break;case 408:r.message="Request Timeout";break;case 422:r.message="Unprocessable Entity";break;case 502:r.message="Bad Gateway";break;default:r.message="Unknown error"}return this.QBLog("["+n+"]","Error:",t),r},MergeArrayOfObjects:function(e,t){var n=JSON.parse(JSON.stringify(e));e:for(var r=0;r<t.length;r++){for(var i=t[r],o=0;o<n.length;o++)if(i.user_id===n[o].user_id){n[o]=i;continue e}n.push(i)}return n},getTimeIntervalForCallBackMessage:function(){return 1e3*(void 0===i.callBackInterval?2:i.callBackInterval)}};t.exports=d}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./qbConfig":151,fs:26,os:87}]},{},[152])(152)});
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).QB=e()}}(function(){return function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){return i(t[s][1][e]||e)},u,u.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}}()({1:[function(e,t,n){"use strict";function r(e,t){return void 0===t&&(t=Object),t&&"function"==typeof t.freeze?t.freeze(e):e}var i=r({HTML:"text/html",isHTML:function(e){return e===i.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),o=r({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===o.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});n.assign=function(e,t){if(null===e||"object"!=typeof e)throw new TypeError("target is not an object");for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},n.find=function(e,t,n){if(void 0===n&&(n=Array.prototype),e&&"function"==typeof n.find)return n.find.call(e,t);for(var r=0;r<e.length;r++)if(Object.prototype.hasOwnProperty.call(e,r)){var i=e[r];if(t.call(void 0,i,r,e))return i}},n.freeze=r,n.MIME_TYPE=i,n.NAMESPACE=o},{}],2:[function(e,t,n){var r=e("./conventions"),i=e("./dom"),o=e("./entities"),s=e("./sax"),a=i.DOMImplementation,c=r.NAMESPACE,l=s.ParseError,u=s.XMLReader;function d(e){return e.replace(/\r[\n\u0085]/g,"\n").replace(/[\r\u0085\u2028]/g,"\n")}function h(e){this.options=e||{locator:{}}}function p(){this.cdata=!1}function f(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function m(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function g(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function v(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}h.prototype.parseFromString=function(e,t){var n=this.options,r=new u,i=n.domBuilder||new p,s=n.errorHandler,a=n.locator,l=n.xmlns||{},h=/\/x?html?$/.test(t),f=h?o.HTML_ENTITIES:o.XML_ENTITIES;a&&i.setDocumentLocator(a),r.errorHandler=function(e,t,n){if(!e){if(t instanceof p)return t;e=t}var r={},i=e instanceof Function;function o(t){var o=e[t];!o&&i&&(o=2==e.length?function(n){e(t,n)}:e),r[t]=o&&function(e){o("[xmldom "+t+"]\t"+e+m(n))}||function(){}}return n=n||{},o("warning"),o("error"),o("fatalError"),r}(s,i,a),r.domBuilder=n.domBuilder||i,h&&(l[""]=c.HTML),l.xml=l.xml||c.XML;var g=n.normalizeLineEndings||d;return e&&"string"==typeof e?r.parse(g(e),l,f):r.errorHandler.error("invalid doc source"),i.doc},p.prototype={startDocument:function(){this.doc=(new a).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var i=this.doc,o=i.createElementNS(e,n||t),s=r.length;v(this,o),this.currentElement=o,this.locator&&f(this.locator,o);for(var a=0;a<s;a++){e=r.getURI(a);var c=r.getValue(a),l=(n=r.getQName(a),i.createAttributeNS(e,n));this.locator&&f(r.getLocator(a),l),l.value=l.nodeValue=c,o.setAttributeNode(l)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&f(this.locator,n),v(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=g.apply(this,arguments)){if(this.cdata)var r=this.doc.createCDATASection(e);else r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&f(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=g.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&f(this.locator,r),v(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var r=this.doc.implementation;if(r&&r.createDocumentType){var i=r.createDocumentType(e,t,n);this.locator&&f(this.locator,i),v(this,i),this.doc.doctype=i}},warning:function(e){console.warn("[xmldom warning]\t"+e,m(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,m(this.locator))},fatalError:function(e){throw new l(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){p.prototype[e]=function(){return null}}),n.__DOMHandler=p,n.normalizeLineEndings=d,n.DOMParser=h},{"./conventions":1,"./dom":3,"./entities":4,"./sax":6}],3:[function(e,t,n){var r=e("./conventions"),i=r.find,o=r.NAMESPACE;function s(e){return""!==e}function a(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function c(e){if(!e)return[];var t=function(e){return e?e.split(/[\t\n\f\r ]+/).filter(s):[]}(e);return Object.keys(t.reduce(a,{}))}function l(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}function u(e,t){var n=e.prototype;if(!(n instanceof t)){function r(){}r.prototype=t.prototype,l(n,r=new r),e.prototype=n=r}n.constructor!=e&&("function"!=typeof e&&console.error("unknown Class:"+e),n.constructor=e)}var d={},h=d.ELEMENT_NODE=1,p=d.ATTRIBUTE_NODE=2,f=d.TEXT_NODE=3,m=d.CDATA_SECTION_NODE=4,g=d.ENTITY_REFERENCE_NODE=5,v=d.ENTITY_NODE=6,y=d.PROCESSING_INSTRUCTION_NODE=7,b=d.COMMENT_NODE=8,S=d.DOCUMENT_NODE=9,_=d.DOCUMENT_TYPE_NODE=10,C=d.DOCUMENT_FRAGMENT_NODE=11,w=d.NOTATION_NODE=12,T={},E={},x=(T.INDEX_SIZE_ERR=(E[1]="Index size error",1),T.DOMSTRING_SIZE_ERR=(E[2]="DOMString size error",2),T.HIERARCHY_REQUEST_ERR=(E[3]="Hierarchy request error",3)),R=(T.WRONG_DOCUMENT_ERR=(E[4]="Wrong document",4),T.INVALID_CHARACTER_ERR=(E[5]="Invalid character",5),T.NO_DATA_ALLOWED_ERR=(E[6]="No data allowed",6),T.NO_MODIFICATION_ALLOWED_ERR=(E[7]="No modification allowed",7),T.NOT_FOUND_ERR=(E[8]="Not found",8)),k=(T.NOT_SUPPORTED_ERR=(E[9]="Not supported",9),T.INUSE_ATTRIBUTE_ERR=(E[10]="Attribute in use",10));T.INVALID_STATE_ERR=(E[11]="Invalid state",11),T.SYNTAX_ERR=(E[12]="Syntax error",12),T.INVALID_MODIFICATION_ERR=(E[13]="Invalid modification",13),T.NAMESPACE_ERR=(E[14]="Invalid namespace",14),T.INVALID_ACCESS_ERR=(E[15]="Invalid access",15);function I(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,E[e]),this.message=E[e],Error.captureStackTrace&&Error.captureStackTrace(this,I);return n.code=e,t&&(this.message=this.message+": "+t),n}function N(){}function D(e,t){this._node=e,this._refresh=t,A(this)}function A(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!=t){var n=e._refresh(e._node);ge(e,"length",n.length),l(n,e),e._inc=t}}function O(){}function L(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function P(e,t,n,r){if(r?t[L(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&H(i,e,r),function(e,t,n){e&&e._inc++,n.namespaceURI===o.XMLNS&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function M(e,t,n){var r=L(t,n);if(!(r>=0))throw new I(R,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var o=e.ownerDocument;o&&(H(o,e,n),n.ownerElement=null)}}function j(){}function q(){}function B(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function U(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(U(e,t))return!0}while(e=e.nextSibling)}function F(){this.ownerDocument=this}function H(e,t,n,r){e&&e._inc++,n.namespaceURI===o.XMLNS&&delete t._nsMap[n.prefix?n.localName:""]}function z(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,o=0;i;)r[o++]=i,i=i.nextSibling;r.length=o,delete r[r.length]}}}function Q(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,t.parentNode=null,t.previousSibling=null,t.nextSibling=null,z(e.ownerDocument,e),t}function G(e){return e&&e.nodeType===q.DOCUMENT_TYPE_NODE}function J(e){return e&&e.nodeType===q.ELEMENT_NODE}function V(e){return e&&e.nodeType===q.TEXT_NODE}function W(e,t){var n=e.childNodes||[];if(i(n,J)||G(t))return!1;var r=i(n,G);return!(t&&r&&n.indexOf(r)>n.indexOf(t))}function X(e,t){var n=e.childNodes||[];if(i(n,function(e){return J(e)&&e!==t}))return!1;var r=i(n,G);return!(t&&r&&n.indexOf(r)>n.indexOf(t))}function $(e,t,n){if(!function(e){return e&&(e.nodeType===q.DOCUMENT_NODE||e.nodeType===q.DOCUMENT_FRAGMENT_NODE||e.nodeType===q.ELEMENT_NODE)}(e))throw new I(x,"Unexpected parent node type "+e.nodeType);if(n&&n.parentNode!==e)throw new I(R,"child not in parent");if(!function(e){return e&&(J(e)||V(e)||G(e)||e.nodeType===q.DOCUMENT_FRAGMENT_NODE||e.nodeType===q.COMMENT_NODE||e.nodeType===q.PROCESSING_INSTRUCTION_NODE)}(t)||G(t)&&e.nodeType!==q.DOCUMENT_NODE)throw new I(x,"Unexpected node type "+t.nodeType+" for parent node type "+e.nodeType)}function K(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=o.filter(J);if(s.length>1||i(o,V))throw new I(x,"More than one element or text in fragment");if(1===s.length&&!X(e,n))throw new I(x,"Element in fragment can not be inserted before doctype")}if(J(t)&&!X(e,n))throw new I(x,"Only one element can be added and only after doctype");if(G(t)){if(i(r,function(e){return G(e)&&e!==n}))throw new I(x,"Only one doctype is allowed");var a=i(r,J);if(n&&r.indexOf(a)<r.indexOf(n))throw new I(x,"Doctype can only be inserted before an element")}}function Y(e,t,n,r){$(e,t,n),e.nodeType===q.DOCUMENT_NODE&&(r||function(e,t,n){var r=e.childNodes||[],o=t.childNodes||[];if(t.nodeType===q.DOCUMENT_FRAGMENT_NODE){var s=o.filter(J);if(s.length>1||i(o,V))throw new I(x,"More than one element or text in fragment");if(1===s.length&&!W(e,n))throw new I(x,"Element in fragment can not be inserted before doctype")}if(J(t)&&!W(e,n))throw new I(x,"Only one element can be added and only after doctype");if(G(t)){if(i(r,G))throw new I(x,"Only one doctype is allowed");var a=i(r,J);if(n&&r.indexOf(a)<r.indexOf(n))throw new I(x,"Doctype can only be inserted before an element");if(!n&&a)throw new I(x,"Doctype can not be appended since element is present")}})(e,t,n);var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===C){var s=t.firstChild;if(null==s)return t;var a=t.lastChild}else s=a=t;var c=n?n.previousSibling:e.lastChild;s.previousSibling=c,a.nextSibling=n,c?c.nextSibling=s:e.firstChild=s,null==n?e.lastChild=a:n.previousSibling=a;do{s.parentNode=e}while(s!==a&&(s=s.nextSibling));return z(e.ownerDocument||e,e),t.nodeType==C&&(t.firstChild=t.lastChild=null),t}function Z(){this._nsMap={}}function ee(){}function te(){}function ne(){}function re(){}function ie(){}function oe(){}function se(){}function ae(){}function ce(){}function le(){}function ue(){}function de(){}function he(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,i=r.prefix,o=r.namespaceURI;if(o&&null==i&&null==(i=r.lookupPrefix(o)))var s=[{namespace:o,prefix:null}];return me(this,n,e,t,s),n.join("")}function pe(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!i)return!1;if("xml"===r&&i===o.XML||i===o.XMLNS)return!1;for(var s=n.length;s--;){var a=n[s];if(a.prefix===r)return a.namespace!==i}return!0}function fe(e,t,n){e.push(" ",t,'="',n.replace(/[<>&"\t\n\r]/g,B),'"')}function me(e,t,n,r,i){if(i||(i=[]),r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case h:var s=e.attributes,a=s.length,c=e.firstChild,l=e.tagName,u=l;if(!(n=o.isHTML(e.namespaceURI)||n)&&!e.prefix&&e.namespaceURI){for(var d,v=0;v<s.length;v++)if("xmlns"===s.item(v).name){d=s.item(v).value;break}if(!d)for(var w=i.length-1;w>=0;w--){if(""===(T=i[w]).prefix&&T.namespace===e.namespaceURI){d=T.namespace;break}}if(d!==e.namespaceURI)for(w=i.length-1;w>=0;w--){var T;if((T=i[w]).namespace===e.namespaceURI){T.prefix&&(u=T.prefix+":"+l);break}}}t.push("<",u);for(var E=0;E<a;E++){"xmlns"==(x=s.item(E)).prefix?i.push({prefix:x.localName,namespace:x.value}):"xmlns"==x.nodeName&&i.push({prefix:"",namespace:x.value})}for(E=0;E<a;E++){var x,R,k;if(pe(x=s.item(E),0,i))fe(t,(R=x.prefix||"")?"xmlns:"+R:"xmlns",k=x.namespaceURI),i.push({prefix:R,namespace:k});me(x,t,n,r,i)}if(l===u&&pe(e,0,i))fe(t,(R=e.prefix||"")?"xmlns:"+R:"xmlns",k=e.namespaceURI),i.push({prefix:R,namespace:k});if(c||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(l)){if(t.push(">"),n&&/^script$/i.test(l))for(;c;)c.data?t.push(c.data):me(c,t,n,r,i.slice()),c=c.nextSibling;else for(;c;)me(c,t,n,r,i.slice()),c=c.nextSibling;t.push("</",u,">")}else t.push("/>");return;case S:case C:for(c=e.firstChild;c;)me(c,t,n,r,i.slice()),c=c.nextSibling;return;case p:return fe(t,e.name,e.value);case f:return t.push(e.data.replace(/[<&>]/g,B));case m:return t.push("<![CDATA[",e.data,"]]>");case b:return t.push("\x3c!--",e.data,"--\x3e");case _:var I=e.publicId,N=e.systemId;if(t.push("<!DOCTYPE ",e.name),I)t.push(" PUBLIC ",I),N&&"."!=N&&t.push(" ",N),t.push(">");else if(N&&"."!=N)t.push(" SYSTEM ",N,">");else{var D=e.internalSubset;D&&t.push(" [",D,"]"),t.push(">")}return;case y:return t.push("<?",e.target," ",e.data,"?>");case g:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ge(e,t,n){e[t]=n}I.prototype=Error.prototype,l(T,I),N.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)me(this[r],n,e,t);return n.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}},D.prototype.item=function(e){return A(this),this[e]},u(D,N),O.prototype={length:0,item:N.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new I(k);var n=this.getNamedItem(e.nodeName);return P(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new I(k);return t=this.getNamedItemNS(e.namespaceURI,e.localName),P(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return M(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return M(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},j.prototype={hasFeature:function(e,t){return!0},createDocument:function(e,t,n){var r=new F;if(r.implementation=this,r.childNodes=new N,r.doctype=n||null,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new oe;return r.name=e,r.nodeName=e,r.publicId=t||"",r.systemId=n||"",r}},q.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return Y(this,e,t)},replaceChild:function(e,t){Y(this,e,t,K),t&&this.removeChild(t)},removeChild:function(e){return Q(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return function e(t,n,r){var i=new n.constructor;for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)){var s=n[o];"object"!=typeof s&&s!=i[o]&&(i[o]=s)}n.childNodes&&(i.childNodes=new N);i.ownerDocument=t;switch(i.nodeType){case h:var a=n.attributes,c=i.attributes=new O,l=a.length;c._ownerElement=i;for(var u=0;u<l;u++)i.setAttributeNode(e(t,a.item(u),!0));break;case p:r=!0}if(r)for(var d=n.firstChild;d;)i.appendChild(e(t,d,r)),d=d.nextSibling;return i}(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==f&&e.nodeType==f?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)&&n[r]===e)return r;t=t.nodeType==p?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&Object.prototype.hasOwnProperty.call(n,e))return n[e];t=t.nodeType==p?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},l(d,q),l(d,q.prototype),F.prototype={nodeName:"#document",nodeType:S,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==C){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return Y(this,e,t),e.ownerDocument=this,null===this.documentElement&&e.nodeType===h&&(this.documentElement=e),e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),Q(this,e)},replaceChild:function(e,t){Y(this,e,t,K),e.ownerDocument=this,t&&this.removeChild(t),J(e)&&(this.documentElement=e)},importNode:function(e,t){return function e(t,n,r){var i;switch(n.nodeType){case h:(i=n.cloneNode(!1)).ownerDocument=t;case C:break;case p:r=!0}i||(i=n.cloneNode(!1));i.ownerDocument=t;i.parentNode=null;if(r)for(var o=n.firstChild;o;)i.appendChild(e(t,o,r)),o=o.nextSibling;return i}(this,e,t)},getElementById:function(e){var t=null;return U(this.documentElement,function(n){if(n.nodeType==h&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=c(e);return new D(this,function(n){var r=[];return t.length>0&&U(n.documentElement,function(i){if(i!==n&&i.nodeType===h){var o=i.getAttribute("class");if(o){var s=e===o;if(!s){var a=c(o);s=t.every((l=a,function(e){return l&&-1!==l.indexOf(e)}))}s&&r.push(i)}}var l}),r})},createElement:function(e){var t=new Z;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.localName=e,t.childNodes=new N,(t.attributes=new O)._ownerElement=t,t},createDocumentFragment:function(){var e=new le;return e.ownerDocument=this,e.childNodes=new N,e},createTextNode:function(e){var t=new ne;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new re;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new ie;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new ue;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new ee;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new ce;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new Z,r=t.split(":"),i=n.attributes=new O;return n.childNodes=new N,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new ee,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},u(F,q),Z.prototype={nodeType:h,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===C?this.insertBefore(e,null):function(e,t){return t.parentNode&&t.parentNode.removeChild(t),t.parentNode=e,t.previousSibling=e.lastChild,t.nextSibling=null,t.previousSibling?t.previousSibling.nextSibling=t:e.firstChild=t,e.lastChild=t,z(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new D(this,function(t){var n=[];return U(t,function(r){r===t||r.nodeType!=h||"*"!==e&&r.tagName!=e||n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new D(this,function(n){var r=[];return U(n,function(i){i===n||i.nodeType!==h||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||r.push(i)}),r})}},F.prototype.getElementsByTagName=Z.prototype.getElementsByTagName,F.prototype.getElementsByTagNameNS=Z.prototype.getElementsByTagNameNS,u(Z,q),ee.prototype.nodeType=p,u(ee,q),te.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(E[x])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},u(te,q),ne.prototype={nodeName:"#text",nodeType:f,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},u(ne,te),re.prototype={nodeName:"#comment",nodeType:b},u(re,te),ie.prototype={nodeName:"#cdata-section",nodeType:m},u(ie,te),oe.prototype.nodeType=_,u(oe,q),se.prototype.nodeType=w,u(se,q),ae.prototype.nodeType=v,u(ae,q),ce.prototype.nodeType=g,u(ce,q),le.prototype.nodeName="#document-fragment",le.prototype.nodeType=C,u(le,q),ue.prototype.nodeType=y,u(ue,q),de.prototype.serializeToString=function(e,t,n){return he.call(e,t,n)},q.prototype.toString=he;try{if(Object.defineProperty){Object.defineProperty(D.prototype,"length",{get:function(){return A(this),this.$$length}}),Object.defineProperty(q.prototype,"textContent",{get:function(){return function e(t){switch(t.nodeType){case h:case C:var n=[];for(t=t.firstChild;t;)7!==t.nodeType&&8!==t.nodeType&&n.push(e(t)),t=t.nextSibling;return n.join("");default:return t.nodeValue}}(this)},set:function(e){switch(this.nodeType){case h:case C:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),ge=function(e,t,n){e["$$"+t]=n}}}catch(e){}n.DocumentType=oe,n.DOMException=I,n.DOMImplementation=j,n.Element=Z,n.Node=q,n.NodeList=N,n.XMLSerializer=de},{"./conventions":1}],4:[function(e,t,n){"use strict";var r=e("./conventions").freeze;n.XML_ENTITIES=r({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}),n.HTML_ENTITIES=r({Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"ℂ",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"⨯",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"∪",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"ⅅ",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:" ",emsp13:" ",emsp14:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"ℰ",escr:"ℯ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",ExponentialE:"ⅇ",exponentiale:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",Fscr:"ℱ",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",Gt:"≫",GT:">",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"ℌ",hfr:"𝔥",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"ℍ",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"ℋ",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"⁣",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"ℑ",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"ℑ",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"⁣",InvisibleTimes:"⁢",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"ℐ",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",Lscr:"ℒ",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",Lt:"≪",LT:"<",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"ℳ",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",Or:"⩔",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",Popf:"ℙ",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"′",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"ℚ",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"∶",rationals:"ℚ",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"ℜ",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"ℜ",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"ℝ",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",Rscr:"ℛ",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:"  ",thinsp:" ",ThinSpace:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",Tilde:"∼",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"⋁",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"​",Zeta:"Ζ",zeta:"ζ",Zfr:"ℨ",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"ℤ",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"‍",zwnj:"‌"}),n.entityMap=n.HTML_ENTITIES},{"./conventions":1}],5:[function(e,t,n){var r=e("./dom");n.DOMImplementation=r.DOMImplementation,n.XMLSerializer=r.XMLSerializer,n.DOMParser=e("./dom-parser").DOMParser},{"./dom":3,"./dom-parser":2}],6:[function(e,t,n){var r=e("./conventions").NAMESPACE,i=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,o=new RegExp("[\\-\\.0-9"+i.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),s=new RegExp("^"+i.source+o.source+"*(?::"+i.source+o.source+"*)?$"),a=0,c=1,l=2,u=3,d=4,h=5,p=6,f=7;function m(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,m)}function g(){}function v(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function y(e,t,n,i,o,s){function m(e,t,r){n.attributeNames.hasOwnProperty(e)&&s.fatalError("Attribute "+e+" redefined"),n.addValue(e,t.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,o),r)}for(var g,v=++t,y=a;;){var b=e.charAt(v);switch(b){case"=":if(y===c)g=e.slice(t,v),y=u;else{if(y!==l)throw new Error("attribute equal must after attrName");y=u}break;case"'":case'"':if(y===u||y===c){if(y===c&&(s.warning('attribute value must after "="'),g=e.slice(t,v)),t=v+1,!((v=e.indexOf(b,t))>0))throw new Error("attribute value no end '"+b+"' match");m(g,S=e.slice(t,v),t-1),y=h}else{if(y!=d)throw new Error('attribute value must after "="');m(g,S=e.slice(t,v),t),s.warning('attribute "'+g+'" missed start quot('+b+")!!"),t=v+1,y=h}break;case"/":switch(y){case a:n.setTagName(e.slice(t,v));case h:case p:case f:y=f,n.closed=!0;case d:case c:break;case l:n.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return s.error("unexpected end of input"),y==a&&n.setTagName(e.slice(t,v)),v;case">":switch(y){case a:n.setTagName(e.slice(t,v));case h:case p:case f:break;case d:case c:"/"===(S=e.slice(t,v)).slice(-1)&&(n.closed=!0,S=S.slice(0,-1));case l:y===l&&(S=g),y==d?(s.warning('attribute "'+S+'" missed quot(")!'),m(g,S,t)):(r.isHTML(i[""])&&S.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+S+'" missed value!! "'+S+'" instead!!'),m(S,S,t));break;case u:throw new Error("attribute value missed!!")}return v;case"€":b=" ";default:if(b<=" ")switch(y){case a:n.setTagName(e.slice(t,v)),y=p;break;case c:g=e.slice(t,v),y=l;break;case d:var S=e.slice(t,v);s.warning('attribute "'+S+'" missed quot(")!!'),m(g,S,t);case h:y=p}else switch(y){case l:n.tagName;r.isHTML(i[""])&&g.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+g+'" missed value!! "'+g+'" instead2!!'),m(g,g,t),t=v,y=c;break;case h:s.warning('attribute space is required"'+g+'"!!');case p:y=c,t=v;break;case u:y=d,t=v;break;case f:throw new Error("elements closed character '/' and '>' must be connected to")}}v++}}function b(e,t,n){for(var i=e.tagName,o=null,s=e.length;s--;){var a=e[s],c=a.qName,l=a.value;if((p=c.indexOf(":"))>0)var u=a.prefix=c.slice(0,p),d=c.slice(p+1),h="xmlns"===u&&d;else d=c,u=null,h="xmlns"===c&&"";a.localName=d,!1!==h&&(null==o&&(o={},C(n,n={})),n[h]=o[h]=l,a.uri=r.XMLNS,t.startPrefixMapping(h,l))}for(s=e.length;s--;){(u=(a=e[s]).prefix)&&("xml"===u&&(a.uri=r.XML),"xmlns"!==u&&(a.uri=n[u||""]))}var p;(p=i.indexOf(":"))>0?(u=e.prefix=i.slice(0,p),d=e.localName=i.slice(p+1)):(u=null,d=e.localName=i);var f=e.uri=n[u||""];if(t.startElement(f,d,i,e),!e.closed)return e.currentNSMap=n,e.localNSMap=o,!0;if(t.endElement(f,d,i),o)for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&t.endPrefixMapping(u)}function S(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),s=e.substring(t+1,o);if(/[&<]/.test(s))return/^script$/i.test(n)?(i.characters(s,0,s.length),o):(s=s.replace(/&#?\w+;/g,r),i.characters(s,0,s.length),o)}return t+1}function _(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function C(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}function w(e,t,n,r){switch(e.charAt(t+2)){case"-":return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;default:if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var o=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),s=o.length;if(s>1&&/!doctype/i.test(o[0][0])){var a=o[1][0],c=!1,l=!1;s>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],l=s>4&&o[4][0]):/^system$/i.test(o[2][0])&&(l=o[3][0]));var u=o[s-1];return n.startDTD(a,c,l),n.endDTD(),u.index+u[0].length}}return-1}function T(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(i){i[0].length;return n.processingInstruction(i[1],i[2]),r+2}return-1}return-1}function E(){this.attributeNames={}}m.prototype=new Error,m.prototype.name=m.name,g.prototype={parse:function(e,t,n){var i=this.domBuilder;i.startDocument(),C(t,t={}),function(e,t,n,i,o){function s(e){var t=e.slice(1,-1);return Object.hasOwnProperty.call(n,t)?n[t]:"#"===t.charAt(0)?function(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}(parseInt(t.substr(1).replace("x","0x"))):(o.error("entity not found:"+e),e)}function a(t){if(t>g){var n=e.substring(g,t).replace(/&#?\w+;/g,s);h&&c(g),i.characters(n,0,t-g),g=t}}function c(t,n){for(;t>=u&&(n=d.exec(e));)l=n.index,u=l+n[0].length,h.lineNumber++;h.columnNumber=t-l+1}var l=0,u=0,d=/.*(?:\r\n?|\n)|.*$/g,h=i.locator,p=[{currentNSMap:t}],f={},g=0;for(;;){try{var C=e.indexOf("<",g);if(C<0){if(!e.substr(g).match(/^\s*$/)){var x=i.doc,R=x.createTextNode(e.substr(g));x.appendChild(R),i.currentElement=R}return}switch(C>g&&a(C),e.charAt(C+1)){case"/":var k=e.indexOf(">",C+3),I=e.substring(C+2,k).replace(/[ \t\n\r]+$/g,""),N=p.pop();k<0?(I=e.substring(C+2).replace(/[\s<].*/,""),o.error("end tag name: "+I+" is not complete:"+N.tagName),k=C+1+I.length):I.match(/\s</)&&(I=I.replace(/[\s<].*/,""),o.error("end tag name: "+I+" maybe not complete"),k=C+1+I.length);var D=N.localNSMap,A=N.tagName==I,O=A||N.tagName&&N.tagName.toLowerCase()==I.toLowerCase();if(O){if(i.endElement(N.uri,N.localName,I),D)for(var L in D)Object.prototype.hasOwnProperty.call(D,L)&&i.endPrefixMapping(L);A||o.fatalError("end tag name: "+I+" is not match the current start tagName:"+N.tagName)}else p.push(N);k++;break;case"?":h&&c(C),k=T(e,C,i);break;case"!":h&&c(C),k=w(e,C,i,o);break;default:h&&c(C);var P=new E,M=p[p.length-1].currentNSMap,k=y(e,C,P,M,s,o),j=P.length;if(!P.closed&&_(e,k,P.tagName,f)&&(P.closed=!0,n.nbsp||o.warning("unclosed xml attribute")),h&&j){for(var q=v(h,{}),B=0;B<j;B++){var U=P[B];c(U.offset),U.locator=v(h,{})}i.locator=q,b(P,i,M)&&p.push(P),i.locator=h}else b(P,i,M)&&p.push(P);r.isHTML(P.uri)&&!P.closed?k=S(e,k,P.tagName,s,i):k++}}catch(e){if(e instanceof m)throw e;o.error("element parse error: "+e),k=-1}k>g?g=k:a(Math.max(C,g)+1)}}(e,t,n,i,this.errorHandler),i.endDocument()}},E.prototype={setTagName:function(e){if(!s.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,n){if(!s.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:n}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},n.XMLReader=g,n.ParseError=m},{"./conventions":1}],7:[function(e,t,n){"use strict";var r=e("inherits"),i=e("events").EventEmitter,o=e("ltx/lib/parsers/ltx"),s=e("@xmpp/xml"),a=s.Stanza,c=s.Element;function l(e){i.call(this);var t=this,n=e&&e.Element||c,r=e&&e.Parser||o;this.maxStanzaSize=e&&e.maxStanzaSize,this.parser=new r,this.bytesParsed=0,this.bytesParsedOnStanzaBegin=0,this.parser.on("startElement",function(e,r){var i;(t.element||(t.emit("startElement",e,r),t.emit("start",new c(e,r))),t.element||"stream:stream"!==e)?t.element?(i=new n(e,r),t.element=t.element.cnode(i)):(i=new a(e,r),t.element=i,t.bytesParsedOnStanzaBegin=t.bytesParsed):t.emit("streamStart",r)}),this.parser.on("endElement",function(e){t.element||t.emit("endElement",e),t.element||"stream:stream"!==e?t.element&&e===t.element.name?t.element.parent?t.element=t.element.parent:(t.emit("element",t.element),t.emit("stanza",t.element),delete t.element,delete t.bytesParsedOnStanzaBegin):t.error("xml-not-well-formed","XML parse error"):t.end()}),this.parser.on("text",function(e){t.element&&t.element.t(e)}),this.parser.on("entityDecl",function(){t.error("xml-not-well-formed","No entity declarations allowed"),t.end()}),this.parser.on("error",this.emit.bind(this,"error"))}r(l,i),l.prototype.checkXMLHeader=function(e){var t=e.indexOf("<?xml");if(-1!==t){var n=e.indexOf("?>");if(t>=0&&n>=0&&t<n+2){var r=e.substring(t,n+2);e=e.replace(r,"")}}return e},l.prototype.write=function(e){if(this.parser){if(e=e.toString("utf8"),e=this.checkXMLHeader(e),this.bytesParsedOnStanzaBegin&&this.maxStanzaSize&&this.bytesParsed>this.bytesParsedOnStanzaBegin+this.maxStanzaSize)return void this.error("policy-violation","Maximum stanza size exceeded");this.bytesParsed+=e.length,this.parser.write(e)}},l.prototype.end=function(e){e&&this.write(e),delete this.parser,this.emit("end")},l.prototype.error=function(e,t){var n=new Error(t);n.condition=e,this.emit("error",n)},t.exports=l},{"@xmpp/xml":8,events:37,inherits:41,"ltx/lib/parsers/ltx":53}],8:[function(e,t,n){"use strict";var r=e("ltx"),i=e("./lib/tag");n=t.exports=function(){return i.apply(null,arguments)},Object.assign(n,r),n.IQ=e("./lib/IQ"),n.Message=e("./lib/Message"),n.Presence=e("./lib/Presence"),n.Stanza=e("./lib/Stanza"),n.createStanza=e("./lib/createStanza"),n.parse=e("./lib/parse"),n.Parser=e("./lib/Parser"),n.tag=e("./lib/tag"),n.ltx=r},{"./lib/IQ":9,"./lib/Message":10,"./lib/Parser":11,"./lib/Presence":12,"./lib/Stanza":13,"./lib/createStanza":14,"./lib/parse":15,"./lib/tag":16,ltx:44}],9:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"iq",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],10:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"message",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],11:[function(e,t,n){"use strict";var r=e("inherits"),i=e("./createStanza"),o=e("ltx").Parser;function s(e){o.call(this,e)}r(s,o),s.prototype.DefaultElement=i,t.exports=s},{"./createStanza":14,inherits:41,ltx:44}],12:[function(e,t,n){"use strict";var r=e("./Stanza");function i(e){r.call(this,"presence",e)}e("inherits")(i,r),t.exports=i},{"./Stanza":13,inherits:41}],13:[function(e,t,n){"use strict";var r=e("inherits"),i=e("ltx").Element;function o(e,t){i.call(this,e,t)}r(o,i),Object.defineProperty(o.prototype,"from",{get:function(){return this.attrs.from},set:function(e){this.attrs.from=e}}),Object.defineProperty(o.prototype,"to",{get:function(){return this.attrs.to},set:function(e){this.attrs.to=e}}),Object.defineProperty(o.prototype,"id",{get:function(){return this.attrs.id},set:function(e){this.attrs.id=e}}),Object.defineProperty(o.prototype,"type",{get:function(){return this.attrs.type},set:function(e){this.attrs.type=e}}),t.exports=o},{inherits:41,ltx:44}],14:[function(e,t,n){"use strict";var r=e("./Stanza"),i=e("ltx").Element;t.exports=function(e,t){var n;switch(e){case"presence":case"message":case"iq":n=new r(e,t);break;default:n=new i(e,t)}return Array.prototype.slice.call(arguments,2).forEach(function(e){n.cnode(e)}),n}},{"./Stanza":13,ltx:44}],15:[function(e,t,n){"use strict";var r=e("./Parser"),i=e("ltx").parse;t.exports=function(e){return i(e,r)}},{"./Parser":11,ltx:44}],16:[function(e,t,n){"use strict";var r=e("ltx").tagString,i=e("./parse");t.exports=function(){return i(r.apply(null,arguments))}},{"./parse":15,ltx:44}],17:[function(e,t,n){var r=e("./lib/backoff"),i=e("./lib/strategy/exponential"),o=e("./lib/strategy/fibonacci"),s=e("./lib/function_call.js");t.exports.Backoff=r,t.exports.FunctionCall=s,t.exports.FibonacciStrategy=o,t.exports.ExponentialStrategy=i,t.exports.fibonacci=function(e){return new r(new o(e))},t.exports.exponential=function(e){return new r(new i(e))},t.exports.call=function(e,t,n){var r=Array.prototype.slice.call(arguments);return e=r[0],t=r.slice(1,r.length-1),n=r[r.length-1],new s(e,t,n)}},{"./lib/backoff":18,"./lib/function_call.js":19,"./lib/strategy/exponential":20,"./lib/strategy/fibonacci":21}],18:[function(e,t,n){var r=e("events");function i(e){r.EventEmitter.call(this),this.backoffStrategy_=e,this.maxNumberOfRetry_=-1,this.backoffNumber_=0,this.backoffDelay_=0,this.timeoutID_=-1,this.handlers={backoff:this.onBackoff_.bind(this)}}e("util").inherits(i,r.EventEmitter),i.prototype.failAfter=function(e){if(e<1)throw new Error("Maximum number of retry must be greater than 0. Actual: "+e);this.maxNumberOfRetry_=e},i.prototype.backoff=function(e){if(-1!==this.timeoutID_)throw new Error("Backoff in progress.");this.backoffNumber_===this.maxNumberOfRetry_?(this.emit("fail",e),this.reset()):(this.backoffDelay_=this.backoffStrategy_.next(),this.timeoutID_=setTimeout(this.handlers.backoff,this.backoffDelay_),this.emit("backoff",this.backoffNumber_,this.backoffDelay_,e))},i.prototype.onBackoff_=function(){this.timeoutID_=-1,this.emit("ready",this.backoffNumber_,this.backoffDelay_),this.backoffNumber_++},i.prototype.reset=function(){this.backoffNumber_=0,this.backoffStrategy_.reset(),clearTimeout(this.timeoutID_),this.timeoutID_=-1},t.exports=i},{events:37,util:116}],19:[function(e,t,n){var r=e("events"),i=e("util"),o=e("./backoff"),s=e("./strategy/fibonacci");function a(e){return"function"==typeof e}function c(e,t,n){if(r.EventEmitter.call(this),!a(e))throw new Error("fn should be a function.Actual: "+typeof e);if(!a(n))throw new Error("callback should be a function.Actual: "+typeof e);this.function_=e,this.arguments_=t,this.callback_=n,this.results_=[],this.backoff_=null,this.strategy_=null,this.failAfter_=-1,this.state_=c.State_.PENDING}i.inherits(c,r.EventEmitter),c.State_={PENDING:0,RUNNING:1,COMPLETED:2,ABORTED:3},c.prototype.isPending=function(){return this.state_==c.State_.PENDING},c.prototype.isRunning=function(){return this.state_==c.State_.RUNNING},c.prototype.isCompleted=function(){return this.state_==c.State_.COMPLETED},c.prototype.isAborted=function(){return this.state_==c.State_.ABORTED},c.prototype.setStrategy=function(e){if(!this.isPending())throw new Error("FunctionCall in progress.");return this.strategy_=e,this},c.prototype.getResults=function(){return this.results_.concat()},c.prototype.failAfter=function(e){if(!this.isPending())throw new Error("FunctionCall in progress.");return this.failAfter_=e,this},c.prototype.abort=function(){if(this.isCompleted())throw new Error("FunctionCall already completed.");this.isRunning()&&this.backoff_.reset(),this.state_=c.State_.ABORTED},c.prototype.start=function(e){if(this.isAborted())throw new Error("FunctionCall aborted.");if(!this.isPending())throw new Error("FunctionCall already started.");var t=this.strategy_||new s;this.backoff_=e?e(t):new o(t),this.backoff_.on("ready",this.doCall_.bind(this)),this.backoff_.on("fail",this.doCallback_.bind(this)),this.backoff_.on("backoff",this.handleBackoff_.bind(this)),this.failAfter_>0&&this.backoff_.failAfter(this.failAfter_),this.state_=c.State_.RUNNING,this.doCall_()},c.prototype.doCall_=function(){var e=["call"].concat(this.arguments_);r.EventEmitter.prototype.emit.apply(this,e);var t=this.handleFunctionCallback_.bind(this);this.function_.apply(null,this.arguments_.concat(t))},c.prototype.doCallback_=function(){var e=this.results_[this.results_.length-1];this.callback_.apply(null,e)},c.prototype.handleFunctionCallback_=function(){if(!this.isAborted()){var e=Array.prototype.slice.call(arguments);this.results_.push(e),r.EventEmitter.prototype.emit.apply(this,["callback"].concat(e)),e[0]?this.backoff_.backoff(e[0]):(this.state_=c.State_.COMPLETED,this.doCallback_())}},c.prototype.handleBackoff_=function(e,t,n){this.emit("backoff",e,t,n)},t.exports=c},{"./backoff":18,"./strategy/fibonacci":21,events:37,util:116}],20:[function(e,t,n){var r=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}r.inherits(o,i),o.prototype.next_=function(){return this.backoffDelay_=Math.min(this.nextBackoffDelay_,this.getMaxDelay()),this.nextBackoffDelay_=2*this.backoffDelay_,this.backoffDelay_},o.prototype.reset_=function(){this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()},t.exports=o},{"./strategy":22,util:116}],21:[function(e,t,n){var r=e("util"),i=e("./strategy");function o(e){i.call(this,e),this.backoffDelay_=0,this.nextBackoffDelay_=this.getInitialDelay()}r.inherits(o,i),o.prototype.next_=function(){var e=Math.min(this.nextBackoffDelay_,this.getMaxDelay());return this.nextBackoffDelay_+=this.backoffDelay_,this.backoffDelay_=e,e},o.prototype.reset_=function(){this.nextBackoffDelay_=this.getInitialDelay(),this.backoffDelay_=0},t.exports=o},{"./strategy":22,util:116}],22:[function(e,t,n){e("events"),e("util");function r(e){return null!=e}function i(e){if(r((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be greater than 0.");if(r(e.maxDelay)&&e.maxDelay<1)throw new Error("The maximal timeout must be greater than 0.");if(this.initialDelay_=e.initialDelay||100,this.maxDelay_=e.maxDelay||1e4,this.maxDelay_<=this.initialDelay_)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");if(r(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");this.randomisationFactor_=e.randomisationFactor||0}i.prototype.getMaxDelay=function(){return this.maxDelay_},i.prototype.getInitialDelay=function(){return this.initialDelay_},i.prototype.next=function(){var e=this.next_(),t=1+Math.random()*this.randomisationFactor_;return Math.round(e*t)},i.prototype.next_=function(){throw new Error("BackoffStrategy.next_() unimplemented.")},i.prototype.reset=function(){this.reset_()},i.prototype.reset_=function(){throw new Error("BackoffStrategy.reset_() unimplemented.")},t.exports=i},{events:37,util:116}],23:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=l(e),s=r[0],a=r[1],c=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),u=0,d=a>0?s-4:s;for(n=0;n<d;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,c[u++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,a=n-i;s<a;s+=16383)o.push(u(e,s,s+16383>a?a:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],i[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,n){for(var i,o,s=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],24:[function(e,t,n){var r,i;r=this,i=function(){var e=XMLHttpRequest;if(!e)throw new Error("missing XMLHttpRequest");function t(o,s){if("function"!=typeof s)throw new Error("Bad callback given: "+s);if(!o)throw new Error("No options given");var a=o.onResponse;if((o="string"==typeof o?{uri:o}:JSON.parse(JSON.stringify(o))).onResponse=a,o.verbose&&(t.log=function(){var e,t,n={},o=["trace","debug","info","warn","error"];for(t=0;t<o.length;t++)n[e=o[t]]=r,"undefined"!=typeof console&&console&&console[e]&&(n[e]=i(console,e));return n}()),o.url&&(o.uri=o.url,delete o.url),!o.uri&&""!==o.uri)throw new Error("options.uri is a required argument");if("string"!=typeof o.uri)throw new Error("options.uri must be a string");for(var c=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],l=0;l<c.length;l++)if(o[c[l]])throw new Error("options."+c[l]+" is not supported");if(o.callback=s,o.method=o.method||"GET",o.headers=o.headers||{},o.body=o.body||null,o.timeout=o.timeout||t.DEFAULT_TIMEOUT,o.headers.host)throw new Error("Options.headers.host is not supported");o.json&&(o.headers.accept=o.headers.accept||"application/json","GET"!==o.method&&(o.headers["content-type"]="application/json"),"boolean"!=typeof o.json?o.body=JSON.stringify(o.json):"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)));var u=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(o.qs){var d="string"==typeof o.qs?o.qs:u(o.qs);-1!==o.uri.indexOf("?")?o.uri=o.uri+"&"+d:o.uri=o.uri+"?"+d}if(o.form){if("string"==typeof o.form)throw"form name unsupported";if("POST"===o.method){var h=(o.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(o.headers["content-type"]=h,h){case"application/x-www-form-urlencoded":o.body=u(o.form).replace(/%20/g,"+");break;case"multipart/form-data":var p=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var r in e)e.hasOwnProperty(r)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+r+'"\n\n'+e[r]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t}(o.form);o.body=p.body,o.headers["content-type"]=p.type;break;default:throw new Error("unsupported encoding:"+h)}}}return o.onResponse=o.onResponse||r,!0===o.onResponse&&(o.onResponse=s,o.callback=r),!o.headers.authorization&&o.auth&&(o.headers.authorization="Basic "+function(e){var t,n,r,i,o,s,a,c,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,d=0,h="",p=[];if(!e)return e;do{t=e.charCodeAt(u++),n=e.charCodeAt(u++),r=e.charCodeAt(u++),i=(c=t<<16|n<<8|r)>>18&63,o=c>>12&63,s=c>>6&63,a=63&c,p[d++]=l.charAt(i)+l.charAt(o)+l.charAt(s)+l.charAt(a)}while(u<e.length);switch(h=p.join(""),e.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h}(o.auth.username+":"+o.auth.password)),function(r){var i=new e,o=!1,s=function(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(e){(t=document.createElement("a")).href="",t=t.href}var r=n.exec(t.toLowerCase())||[],i=n.exec(e.toLowerCase());return!(!i||i[1]==r[1]&&i[2]==r[2]&&(i[3]||("http:"===i[1]?80:443))==(r[3]||("http:"===r[1]?80:443)))}(r.uri),a="withCredentials"in i;if(n+=1,i.seq_id=n,i.id=n+": "+r.method+" "+r.uri,i._id=i.id,s&&!a){var c=new Error("Browser does not support cross-origin request: "+r.uri);return c.cors="unsupported",r.callback(c,i)}i.timeoutTimer=setTimeout(function(){o=!0;var e=new Error("ETIMEDOUT");return e.code="ETIMEDOUT",e.duration=r.timeout,t.log.error("Timeout",{id:i._id,milliseconds:r.timeout}),r.callback(e,i)},r.timeout);var l={response:!1,loading:!1,end:!1};i.onreadystatechange=function(n){if(o)return t.log.debug("Ignoring timed out state change",{state:i.readyState,id:i.id});if(t.log.debug("State change",{state:i.readyState,id:i.id,timed_out:o}),i.readyState===e.OPENED)for(var s in t.log.debug("Request started",{id:i.id}),r.headers)i.setRequestHeader(s,r.headers[s]);else i.readyState===e.HEADERS_RECEIVED?u():i.readyState===e.LOADING?(u(),d()):i.readyState===e.DONE&&(u(),d(),function(){if(!l.end){if(l.end=!0,t.log.debug("Request done",{id:i.id}),i.body=i.responseText,r.json)try{i.body=JSON.parse(i.responseText)}catch(e){return r.callback(e,i)}r.callback(null,i,i.body)}}())},i.open(r.method,r.uri,!0),s&&(i.withCredentials=!!r.withCredentials);return i.send(r.body),i;function u(){if(!l.response){if(l.response=!0,t.log.debug("Got response",{id:i.id,status:i.status}),clearTimeout(i.timeoutTimer),i.statusCode=i.status,s&&0==i.statusCode){var e=new Error("CORS request rejected: "+r.uri);return e.cors="rejected",l.loading=!0,l.end=!0,r.callback(e,i)}r.onResponse(null,i)}}function d(){l.loading||(l.loading=!0,t.log.debug("Response body loading",{id:i.id}))}}(o)}t.log={trace:r,debug:r,info:r,warn:r,error:r};var n=0;function r(){}function i(e,t){return function(n,r){"object"==typeof r&&(n+=" "+JSON.stringify(r));return e[t].call(e,n)}}return t.withCredentials=!1,t.DEFAULT_TIMEOUT=18e4,t.defaults=function(e,n){var r=function(t){return function(n,r){for(var i in n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n)),e)void 0===n[i]&&(n[i]=e[i]);return t(n,r)}},i=r(t);return i.get=r(t.get),i.post=r(t.post),i.put=r(t.put),i.head=r(t.head),i},["get","put","post","head"].forEach(function(e){var n=e.toUpperCase();t[e.toLowerCase()]=function(e){"string"==typeof e?e={method:n,uri:e}:(e=JSON.parse(JSON.stringify(e))).method=n;var r=[e].concat(Array.prototype.slice.apply(arguments,[1]));return t.apply(this,r)}}),t.couch=function(e,n){return"string"==typeof e&&(e={uri:e}),e.json=!0,e.body&&(e.json=e.body),delete e.body,n=n||r,t(e,function(e,t,r){if(e)return n(e,t,r);if((t.statusCode<200||t.statusCode>299)&&r.error){for(var i in e=new Error("CouchDB error: "+(r.error.reason||r.error.error)),r)e[i]=r[i];return n(e,t,r)}return n(e,t,r)})},t},"object"==typeof n?t.exports=i():r.returnExports=i()},{}],25:[function(e,t,n){},{}],26:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],27:[function(e,t,n){(function(t,r){(function(){"use strict";var r=e("base64-js"),i=e("ieee754"),o=e("isarray");function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return l(this,e,t,n)}function l(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|f(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(c.isBuffer(t)){var n=0|p(t.length);return 0===(e=a(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function d(e,t){if(u(t),e=a(e,t<0?0:0|p(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return F(e).length;default:if(r)return U(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var u=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===c)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var d=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){d=!1;break}if(d)return o}return-1}function y(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function b(e,t,n,r){return H(U(t,e.length-n),e,n,r)}function S(e,t,n,r){return H(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function _(e,t,n,r){return S(e,t,n,r)}function C(e,t,n,r){return H(F(t),e,n,r)}function w(e,t,n,r){return H(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function E(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],u=null,d=l>239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(u=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=x));return n}(r)}n.Buffer=c,n.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},n.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.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}}(),n.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return l(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return function(e,t,n,r){return u(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?E(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return R(this,t,n);case"latin1":case"binary":return k(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,n,r,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),l=this.slice(r,i),u=e.slice(t,n),d=0;d<a;++d)if(l[d]!==u[d]){o=l[d],s=u[d];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return y(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return S(this,e,t,n);case"latin1":case"binary":return _(this,e,t,n);case"base64":return C(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function R(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function k(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=B(e[o]);return i}function N(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function D(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function P(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(e,t,n,r,o){return o||P(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,o){return o||P(e,0,n,8),i.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;n=new c(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},c.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||D(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||A(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):L(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);A(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):L(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||A(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):L(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return M(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return M(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},c.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=c.isBuffer(e)?e:U(new c(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function B(e){return e<16?"0"+e.toString(16):e.toString(16)}function U(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function F(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"base64-js":23,buffer:27,ieee754:40,isarray:42}],28:[function(e,t,n){function r(e){return Object.prototype.toString.call(e)}n.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},n.isBoolean=function(e){return"boolean"==typeof e},n.isNull=function(e){return null===e},n.isNullOrUndefined=function(e){return null==e},n.isNumber=function(e){return"number"==typeof e},n.isString=function(e){return"string"==typeof e},n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=function(e){return void 0===e},n.isRegExp=function(e){return"[object RegExp]"===r(e)},n.isObject=function(e){return"object"==typeof e&&null!==e},n.isDate=function(e){return"[object Date]"===r(e)},n.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},n.isFunction=function(e){return"function"==typeof e},n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("buffer").Buffer.isBuffer},{buffer:27}],29:[function(e,t,n){(function(r){(function(){var i,o;i=this,o=function(){var t=t||function(t,n){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==r&&r.crypto&&(i=r.crypto),!i&&"function"==typeof e)try{i=e("crypto")}catch(e){}var o=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},c=a.lib={},l=c.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=c.WordArray=l.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||h).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new u.init(t,e)}}),d=a.enc={},h=d.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},p=d.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},f=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},m=c.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var n,r=this._data,i=r.words,o=r.sigBytes,s=this.blockSize,a=o/(4*s),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,l=t.min(4*c,o);if(c){for(var d=0;d<c;d+=s)this._doProcessBlock(i,d);n=i.splice(0,c),r.sigBytes-=l}return new u.init(n,l)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(c.Hasher=m.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}}),a.algo={});return a}(Math);return t},"object"==typeof n?t.exports=n=o():i.CryptoJS=o()}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{crypto:25}],30:[function(e,t,n){var r,i;r=this,i=function(e){return e.HmacSHA1},"object"==typeof n?t.exports=n=i(e("./core"),e("./sha1"),e("./hmac")):i(r.CryptoJS)},{"./core":29,"./hmac":32,"./sha1":33}],31:[function(e,t,n){var r,i;r=this,i=function(e){return e.HmacSHA256},"object"==typeof n?t.exports=n=i(e("./core"),e("./sha256"),e("./hmac")):i(r.CryptoJS)},{"./core":29,"./hmac":32,"./sha256":34}],32:[function(e,t,n){var r,i;r=this,i=function(e){var t,n,r;n=(t=e).lib.Base,r=t.enc.Utf8,t.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,i=4*n;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,l=0;l<n;l++)a[l]^=1549556828,c[l]^=909522486;o.sigBytes=s.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],33:[function(e,t,n){var r,i;r=this,i=function(e){var t,n,r,i,o,s,a;return n=(t=e).lib,r=n.WordArray,i=n.Hasher,o=t.algo,s=[],a=o.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],c=n[4],l=0;l<80;l++){if(l<16)s[l]=0|e[t+l];else{var u=s[l-3]^s[l-8]^s[l-14]^s[l-16];s[l]=u<<1|u>>>31}var d=(r<<5|r>>>27)+c+s[l];d+=l<20?1518500249+(i&o|~i&a):l<40?1859775393+(i^o^a):l<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(a),t.HmacSHA1=i._createHmacHelper(a),e.SHA1},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],34:[function(e,t,n){var r,i;r=this,i=function(e){return function(t){var n=e,r=n.lib,i=r.WordArray,o=r.Hasher,s=n.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(a[i]=n(t.pow(r,.5))),c[i]=n(t.pow(r,1/3)),i++),r++}();var l=[],u=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],d=n[6],h=n[7],p=0;p<64;p++){if(p<16)l[p]=0|e[t+p];else{var f=l[p-15],m=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,g=l[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[p]=m+l[p-7]+v+l[p-16]}var y=r&i^r&o^i&o,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&d)+c[p]+l[p];h=d,d=u,u=a,a=s+S|0,s=o,o=i,i=r,r=S+(b+y)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+u|0,n[6]=n[6]+d|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=o._createHelper(u),n.HmacSHA256=o._createHmacHelper(u)}(Math),e.SHA256},"object"==typeof n?t.exports=n=i(e("./core")):i(r.CryptoJS)},{"./core":29}],35:[function(e,t,n){(function(r){(function(){function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(n=t.exports=e("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},n.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)},n.save=function(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}},n.load=i,n.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this)}).call(this,e("_process"))},{"./debug":36,_process:89}],36:[function(e,t,n){var r;function i(e){function t(){if(t.enabled){var e=t,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(t,r){if("%%"===t)return t;c++;var i=n.formatters[r];if("function"==typeof i){var o=s[c];t=i.call(e,o),s.splice(c,1),c--}return t}),n.formatArgs.call(e,s),(t.log||n.log||console.log.bind(console)).apply(e,s)}}return t.namespace=e,t.enabled=n.enabled(e),t.useColors=n.useColors(),t.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return n.colors[Math.abs(r)%n.colors.length]}(e),"function"==typeof n.init&&n.init(t),t}(n=t.exports=i.debug=i.default=i).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];for(var t=("string"==typeof e?e:"").split(/[\s,]+/),r=t.length,i=0;i<r;i++)t[i]&&("-"===(e=t[i].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={}},{ms:58}],37:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,a,c,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(s(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(o(n))for(a=Array.prototype.slice.call(arguments,1),r=(l=n.slice()).length,c=0;c<r;c++)l[c].apply(this,a);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],38:[function(e,t,n){"use strict";t.exports="object"==typeof self?self.FormData:window.FormData},{}],39:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("stream").Transform;function o(e){i.call(this),this._block=r.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}e("inherits")(o,i),o.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)};var s="undefined"!=typeof Uint8Array,a="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(r.prototype instanceof Uint8Array||r.TYPED_ARRAY_SUPPORT);o.prototype.update=function(e,t){if(this._finalized)throw new Error("Digest already called");e=function(e,t){if(e instanceof r)return e;if("string"==typeof e)return r.from(e,t);if(a&&ArrayBuffer.isView(e)){if(0===e.byteLength)return r.alloc(0);var n=r.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}if(s&&e instanceof Uint8Array)return r.from(e);if(r.isBuffer(e)&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e))return r.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(e,t);for(var n=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)n[this._blockOffset++]=e[i++];for(var c=0,l=8*e.length;l>0;++c)this._length[c]+=l,(l=this._length[c]/4294967296|0)>0&&(this._length[c]-=4294967296*l);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},{inherits:41,"safe-buffer":107,stream:109}],40:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?i-1:0,h=n?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+e[t+d],d+=h,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+d],d+=h,u-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=l}return(p?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,u=(1<<l)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?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=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(t*c-1)*Math.pow(2,i),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+p]=255&s,p+=f,s/=256,l-=8);e[n+p-f]|=128*m}},{}],41:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],42:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],43:[function(e,t,n){var r=9007199254740991,i="[object Arguments]",o="[object Function]",s="[object GeneratorFunction]",a=/^(?:0|[1-9]\d*)$/;var c,l,u=Object.prototype,d=u.hasOwnProperty,h=u.toString,p=u.propertyIsEnumerable,f=(c=Object.keys,l=Object,function(e){return c(l(e))}),m=Math.max,g=!p.call({valueOf:1},"valueOf");function v(e,t){var n=C(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&w(e)}(e)&&d.call(e,"callee")&&(!p.call(e,"callee")||h.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var s in e)!t&&!d.call(e,s)||o&&("length"==s||b(s,r))||n.push(s);return n}function y(e,t,n){var r=e[t];d.call(e,t)&&_(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function b(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||a.test(e))&&e>-1&&e%1==0&&e<t}function S(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||u)}function _(e,t){return e===t||e!=e&&t!=t}var C=Array.isArray;function w(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!function(e){var t=T(e)?h.call(e):"";return t==o||t==s}(e)}function T(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var E=function(e){return t=function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function(e,t,n){if(!T(n))return!1;var r=typeof t;return!!("number"==r?w(n)&&b(t,n.length):"string"==r&&t in n)&&_(n[t],e)}(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var a=n[r];a&&e(t,a,r,o)}return t},n=m(void 0===n?t.length-1:n,0),function(){for(var e=arguments,r=-1,i=m(e.length-n,0),o=Array(i);++r<i;)o[r]=e[n+r];r=-1;for(var s=Array(n+1);++r<n;)s[r]=e[r];return s[n]=o,function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(t,this,s)};var t,n}(function(e,t){if(g||S(t)||w(t))!function(e,t,n,r){n||(n={});for(var i=-1,o=t.length;++i<o;){var s=t[i],a=r?r(n[s],e[s],s,n,e):void 0;y(n,s,void 0===a?e[s]:a)}}(t,function(e){return w(e)?v(e):function(e){if(!S(e))return f(e);var t=[];for(var n in Object(e))d.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}(t),e);else for(var n in t)d.call(t,n)&&y(e,n,t[n])});t.exports=E},{}],44:[function(e,t,n){"use strict";var r=e("./lib/parse"),i=e("./lib/Parser"),o=e("./lib/escape"),s=e("./lib/Element"),a=e("./lib/equal"),c=e("./lib/createElement"),l=e("./lib/tag"),u=e("./lib/tagString"),d=e("./lib/is"),h=e("./lib/clone"),p=e("./lib/stringify");(n=t.exports=function(){return l.apply(null,arguments)}).Element=s,n.equal=a.equal,n.nameEqual=a.name,n.attrsEqual=a.attrs,n.childrenEqual=a.children,n.isNode=d.isNode,n.isElement=d.isElement,n.isText=d.isText,n.clone=h,n.createElement=c,n.escapeXML=o.escapeXML,n.unescapeXML=o.unescapeXML,n.escapeXMLText=o.escapeXMLText,n.unescapeXMLText=o.unescapeXMLText,n.Parser=i,n.parse=r,n.tag=l,n.tagString=u,n.stringify=p},{"./lib/Element":45,"./lib/Parser":46,"./lib/clone":47,"./lib/createElement":48,"./lib/equal":49,"./lib/escape":50,"./lib/is":51,"./lib/parse":52,"./lib/stringify":54,"./lib/tag":55,"./lib/tagString":56}],45:[function(e,t,n){"use strict";var r=e("./escape"),i=r.escapeXML,o=r.escapeXMLText,s=e("./equal"),a=s.equal,c=s.name,l=s.attrs,u=s.children,d=e("./clone");function h(e,t){this.name=e,this.parent=null,this.children=[],this.attrs={},this.setAttrs(t)}h.prototype.is=function(e,t){return this.getName()===e&&(!t||this.getNS()===t)},h.prototype.getName=function(){return this.name.indexOf(":")>=0?this.name.substr(this.name.indexOf(":")+1):this.name},h.prototype.getNS=function(){if(this.name.indexOf(":")>=0){var e=this.name.substr(0,this.name.indexOf(":"));return this.findNS(e)}return this.findNS()},h.prototype.findNS=function(e){if(e){var t="xmlns:"+e;if(this.attrs[t])return this.attrs[t];if(this.parent)return this.parent.findNS(e)}else{if(this.attrs.xmlns)return this.attrs.xmlns;if(this.parent)return this.parent.findNS()}},h.prototype.getXmlns=function(){var e={};for(var t in this.parent&&(e=this.parent.getXmlns()),this.attrs){var n=t.match("xmlns:?(.*)");this.attrs.hasOwnProperty(t)&&n&&(e[this.attrs[t]]=n[1])}return e},h.prototype.setAttrs=function(e){"string"==typeof e?this.attrs.xmlns=e:e&&Object.keys(e).forEach(function(t){this.attrs[t]=e[t]},this)},h.prototype.getAttr=function(e,t){if(!t)return this.attrs[e];var n=this.getXmlns();return n[t]?this.attrs[[n[t],e].join(":")]:null},h.prototype.getChild=function(e,t){return this.getChildren(e,t)[0]},h.prototype.getChildren=function(e,t){for(var n=[],r=0;r<this.children.length;r++){var i=this.children[r];!i.getName||i.getName()!==e||t&&i.getNS()!==t||n.push(i)}return n},h.prototype.getChildByAttr=function(e,t,n,r){return this.getChildrenByAttr(e,t,n,r)[0]},h.prototype.getChildrenByAttr=function(e,t,n,r){for(var i=[],o=0;o<this.children.length;o++){var s=this.children[o];!s.attrs||s.attrs[e]!==t||n&&s.getNS()!==n||i.push(s),r&&s.getChildrenByAttr&&i.push(s.getChildrenByAttr(e,t,n,!0))}return r&&(i=[].concat.apply([],i)),i},h.prototype.getChildrenByFilter=function(e,t){for(var n=[],r=0;r<this.children.length;r++){var i=this.children[r];e(i)&&n.push(i),t&&i.getChildrenByFilter&&n.push(i.getChildrenByFilter(e,!0))}return t&&(n=[].concat.apply([],n)),n},h.prototype.getText=function(){for(var e="",t=0;t<this.children.length;t++){var n=this.children[t];"string"!=typeof n&&"number"!=typeof n||(e+=n)}return e},h.prototype.getChildText=function(e,t){var n=this.getChild(e,t);return n?n.getText():null},h.prototype.getChildElements=function(){return this.getChildrenByFilter(function(e){return e instanceof h})},h.prototype.root=function(){return this.parent?this.parent.root():this},h.prototype.tree=h.prototype.root,h.prototype.up=function(){return this.parent?this.parent:this},h.prototype.c=function(e,t){return this.cnode(new h(e,t))},h.prototype.cnode=function(e){return this.children.push(e),"object"==typeof e&&(e.parent=this),e},h.prototype.t=function(e){return this.children.push(e),this},h.prototype.remove=function(e,t){var n;return n="string"==typeof e?function(n){return!(n.is&&n.is(e,t))}:function(t){return t!==e},this.children=this.children.filter(n),this},h.prototype.clone=function(){return d(this)},h.prototype.text=function(e){return e&&1===this.children.length?(this.children[0]=e,this):this.getText()},h.prototype.attr=function(e,t){return void 0!==t||null===t?(this.attrs||(this.attrs={}),this.attrs[e]=t,this):this.attrs[e]},h.prototype.toString=function(){var e="";return this.write(function(t){e+=t}),e},h.prototype.toJSON=function(){return{name:this.name,attrs:this.attrs,children:this.children.map(function(e){return e&&e.toJSON?e.toJSON():e})}},h.prototype._addChildren=function(e){e(">");for(var t=0;t<this.children.length;t++){var n=this.children[t];(n||0===n)&&(n.write?n.write(e):"string"==typeof n?e(o(n)):n.toString&&e(o(n.toString(10))))}e("</"),e(this.name),e(">")},h.prototype.write=function(e){for(var t in e("<"),e(this.name),this.attrs){var n=this.attrs[t];null!=n&&(e(" "),e(t),e('="'),"string"!=typeof n&&(n=n.toString()),e(i(n)),e('"'))}0===this.children.length?e("/>"):this._addChildren(e)},h.prototype.nameEquals=function(e){return c(this,e)},h.prototype.attrsEquals=function(e){return l(this,e)},h.prototype.childrenEquals=function(e){return u(this,e)},h.prototype.equals=function(e){return a(this,e)},t.exports=h},{"./clone":47,"./equal":49,"./escape":50}],46:[function(e,t,n){"use strict";var r=e("events").EventEmitter,i=e("inherits"),o=e("./Element"),s=e("./parsers/ltx"),a=function(e){r.call(this);var t,n=this.Parser=e&&e.Parser||this.DefaultParser,i=this.Element=e&&e.Element||this.DefaultElement;this.parser=new n;var o=this;this.parser.on("startElement",function(e,n){var r=new i(e,n);t=t?t.cnode(r):r}),this.parser.on("endElement",function(e){t&&e===t.name&&(t.parent?t=t.parent:o.tree||(o.tree=t,t=void 0))}),this.parser.on("text",function(e){t&&t.t(e)}),this.parser.on("error",function(e){o.error=e,o.emit("error",e)})};i(a,r),a.prototype.DefaultParser=s,a.prototype.DefaultElement=o,a.prototype.write=function(e){this.parser.write(e)},a.prototype.end=function(e){this.parser.end(e),this.error||(this.tree?this.emit("tree",this.tree):this.emit("error",new Error("Incomplete document")))},t.exports=a},{"./Element":45,"./parsers/ltx":53,events:37,inherits:41}],47:[function(e,t,n){"use strict";t.exports=function(e){for(var t=new e.constructor(e.name,e.attrs),n=0;n<e.children.length;n++){var r=e.children[n];t.cnode(r.clone?r.clone():r)}return t}},{}],48:[function(e,t,n){"use strict";var r=e("./Element");t.exports=function(e,t){for(var n=new r(e,t),i=2;i<arguments.length;i++){var o=arguments[i];o&&n.cnode(o)}return n}},{"./Element":45}],49:[function(e,t,n){"use strict";function r(e,t){return e.name===t.name}function i(e,t){var n=e.attrs,r=Object.keys(n),i=r.length;if(i!==Object.keys(t.attrs).length)return!1;for(var o=0,s=i;o<s;o++){var a=r[o],c=n[a];if(null==c||null==t.attrs[a]){if(c!==t.attrs[a])return!1}else if(c.toString()!==t.attrs[a].toString())return!1}return!0}function o(e,t){var n=e.children,r=n.length;if(r!==t.children.length)return!1;for(var i=0,o=r;i<o;i++){var s=n[i];if("string"==typeof s){if(s!==t.children[i])return!1}else if(!s.equals(t.children[i]))return!1}return!0}t.exports.name=r,t.exports.attrs=i,t.exports.children=o,t.exports.equal=function(e,t){return!!r(e,t)&&!!i(e,t)&&!!o(e,t)}},{}],50:[function(e,t,n){"use strict";var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};function i(e){return r[e]}var o={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'"};function s(e){if("#"===e[1]){var t;if(9===(t="x"===e[2]?parseInt(e.slice(3),16):parseInt(e.slice(2),10))||10===t||13===t||t>=32&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111)return String.fromCodePoint(t);throw new Error("Illegal XML character 0x"+t.toString(16))}if(o[e])return o[e]||e;throw new Error("Illegal XML entity "+e)}n.escapeXML=function(e){return e.replace(/&|<|>|"|'/g,i)},n.unescapeXML=function(e){for(var t="",n=-1,r=-1,i=0;-1!==(n=e.indexOf("&",i))&&-1!==(r=e.indexOf(";",n+1));)t=t+e.substring(i,n)+s(e.substring(n,r+1)),i=r+1;return 0===i?e:t+=e.substring(i)},n.escapeXMLText=function(e){return e.replace(/&|<|>/g,i)},n.unescapeXMLText=function(e){return e.replace(/&(amp|#38|lt|#60|gt|#62);/g,s)}},{}],51:[function(e,t,n){"use strict";var r=e("./Element");t.exports.isNode=function(e){return e instanceof r||"string"==typeof e},t.exports.isElement=function(e){return e instanceof r},t.exports.isText=function(e){return"string"==typeof e}},{"./Element":45}],52:[function(e,t,n){"use strict";var r=e("./Parser");t.exports=function(e,t){var n;n="function"==typeof t?new t:new r(t);var i=null,o=null;if(n.on("tree",function(e){i=e}),n.on("error",function(e){o=e}),n.write(e),n.end(),o)throw o;return i}},{"./Parser":46}],53:[function(e,t,n){"use strict";var r=e("inherits"),i=e("events").EventEmitter,o=e("../escape").unescapeXML,s=t.exports=function(){i.call(this);var e,t,n,r,s,a,c,l,u=0,d=0;this._handleTagOpening=function(e,t,n){e?this.emit("endElement",t):(this.emit("startElement",t,n),s&&this.emit("endElement",t))},this.write=function(i){"string"!=typeof i&&(i=i.toString());var h=0;function p(){if("number"==typeof d){var e=i.substring(d,h);return d=void 0,e}}for(e&&(i=e+i,h+=e.length,e=null);h<i.length;h++){if(0===u){var f=i.indexOf("<",h);-1!==f&&h!==f&&(h=f)}else if(8===u){var m=i.indexOf(c,h);-1!==m&&(h=m)}else if(1===u){var g=i.indexOf("--\x3e",h);-1!==g&&(h=g+2)}else if(10===u){var v=i.indexOf("]]>",h);-1!==v&&(h=v+2)}var y=i.charCodeAt(h);switch(u){case 0:if(60===y){var b=p();b&&this.emit("text",o(b)),u=3,d=h+1,n={}}break;case 9:if(93===y&&"]>"===i.substr(h+1,2)){var S=p();S&&this.emit("text",S),u=0}break;case 3:47===y&&d===h?(d=h+1,r=!0):33===y?"[CDATA["===i.substr(h+1,7)?(d=h+8,u=9):(d=void 0,u=1):63===y?(d=void 0,u=2):(y<=32||47===y||62===y)&&(t=p(),h--,u=4);break;case 1:if(62===y){var _=i.charCodeAt(h-1),C=i.charCodeAt(h-2);(45===_&&45===C||93===_&&93===C)&&(u=0)}break;case 2:if(62===y)63===i.charCodeAt(h-1)&&(u=0);break;case 4:62===y?(this._handleTagOpening(r,t,n),t=void 0,n=void 0,r=void 0,s=void 0,u=0,d=h+1):47===y?s=!0:y>32&&(d=h,u=5);break;case 5:(y<=32||61===y)&&(l=p(),h--,u=6);break;case 6:61===y&&(u=7);break;case 7:34!==y&&39!==y||(a=y,c=34===y?'"':"'",u=8,d=h+1);break;case 8:if(y===a){var w=o(p());n[l]=w,l=void 0,u=4}}}"number"==typeof d&&d<=i.length&&(e=i.slice(d),d=0)}};r(s,i),s.prototype.end=function(e){e&&this.write(e),this.write=function(){}}},{"../escape":50,events:37,inherits:41}],54:[function(e,t,n){"use strict";t.exports=function e(t,n,r){"number"==typeof n&&(n=" ".repeat(n)),r||(r=1);var i="";return i+="<"+t.name,Object.keys(t.attrs).forEach(function(e){i+=" "+e+'="'+t.attrs[e]+'"'}),t.children.length?(i+=">",t.children.forEach(function(t,o){n&&(i+="\n"+n.repeat(r)),i+="string"==typeof t?t:e(t,n,r+1)}),n&&(i+="\n"+n.repeat(r-1)),i+="</"+t.name+">"):i+="/>",i}},{}],55:[function(e,t,n){"use strict";var r=e("./tagString"),i=e("./parse");t.exports=function(){return i(r.apply(null,arguments))}},{"./parse":52,"./tagString":56}],56:[function(e,t,n){"use strict";var r=e("./escape").escapeXML;t.exports=function(){for(var e=arguments[0],t="",n=1;n<arguments.length;n++)t+=e[n-1],t+=r(arguments[n]);return t+=e[e.length-1]}},{"./escape":50}],57:[function(e,t,n){"use strict";var r=e("inherits"),i=e("hash-base"),o=e("safe-buffer").Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(e,t){return e<<t|e>>>32-t}function l(e,t,n,r,i,o,s){return c(e+(t&n|~t&r)+i+o|0,s)+t|0}function u(e,t,n,r,i,o,s){return c(e+(t&r|n&~r)+i+o|0,s)+t|0}function d(e,t,n,r,i,o,s){return c(e+(t^n^r)+i+o|0,s)+t|0}function h(e,t,n,r,i,o,s){return c(e+(n^(t|~r))+i+o|0,s)+t|0}r(a,i),a.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=l(n,r,i,o,e[0],3614090360,7),o=l(o,n,r,i,e[1],3905402710,12),i=l(i,o,n,r,e[2],606105819,17),r=l(r,i,o,n,e[3],3250441966,22),n=l(n,r,i,o,e[4],4118548399,7),o=l(o,n,r,i,e[5],1200080426,12),i=l(i,o,n,r,e[6],2821735955,17),r=l(r,i,o,n,e[7],4249261313,22),n=l(n,r,i,o,e[8],1770035416,7),o=l(o,n,r,i,e[9],2336552879,12),i=l(i,o,n,r,e[10],4294925233,17),r=l(r,i,o,n,e[11],2304563134,22),n=l(n,r,i,o,e[12],1804603682,7),o=l(o,n,r,i,e[13],4254626195,12),i=l(i,o,n,r,e[14],2792965006,17),n=u(n,r=l(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=u(o,n,r,i,e[6],3225465664,9),i=u(i,o,n,r,e[11],643717713,14),r=u(r,i,o,n,e[0],3921069994,20),n=u(n,r,i,o,e[5],3593408605,5),o=u(o,n,r,i,e[10],38016083,9),i=u(i,o,n,r,e[15],3634488961,14),r=u(r,i,o,n,e[4],3889429448,20),n=u(n,r,i,o,e[9],568446438,5),o=u(o,n,r,i,e[14],3275163606,9),i=u(i,o,n,r,e[3],4107603335,14),r=u(r,i,o,n,e[8],1163531501,20),n=u(n,r,i,o,e[13],2850285829,5),o=u(o,n,r,i,e[2],4243563512,9),i=u(i,o,n,r,e[7],1735328473,14),n=d(n,r=u(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=d(o,n,r,i,e[8],2272392833,11),i=d(i,o,n,r,e[11],1839030562,16),r=d(r,i,o,n,e[14],4259657740,23),n=d(n,r,i,o,e[1],2763975236,4),o=d(o,n,r,i,e[4],1272893353,11),i=d(i,o,n,r,e[7],4139469664,16),r=d(r,i,o,n,e[10],3200236656,23),n=d(n,r,i,o,e[13],681279174,4),o=d(o,n,r,i,e[0],3936430074,11),i=d(i,o,n,r,e[3],3572445317,16),r=d(r,i,o,n,e[6],76029189,23),n=d(n,r,i,o,e[9],3654602809,4),o=d(o,n,r,i,e[12],3873151461,11),i=d(i,o,n,r,e[15],530742520,16),n=h(n,r=d(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=h(o,n,r,i,e[7],1126891415,10),i=h(i,o,n,r,e[14],2878612391,15),r=h(r,i,o,n,e[5],4237533241,21),n=h(n,r,i,o,e[12],1700485571,6),o=h(o,n,r,i,e[3],2399980690,10),i=h(i,o,n,r,e[10],4293915773,15),r=h(r,i,o,n,e[1],2240044497,21),n=h(n,r,i,o,e[8],1873313359,6),o=h(o,n,r,i,e[15],4264355552,10),i=h(i,o,n,r,e[6],2734768916,15),r=h(r,i,o,n,e[13],1309151649,21),n=h(n,r,i,o,e[4],4149444226,6),o=h(o,n,r,i,e[11],3174756917,10),i=h(i,o,n,r,e[2],718787259,15),r=h(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=a},{"hash-base":39,inherits:41,"safe-buffer":107}],58:[function(e,t,n){var r=1e3,i=60*r,o=60*i,s=24*o,a=365.25*s;function c(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){t=t||{};var n,l=typeof e;if("string"===l&&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|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===l&&!1===isNaN(e))return t.long?c(n=e,s,"day")||c(n,o,"hour")||c(n,i,"minute")||c(n,r,"second")||n+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=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))}},{}],59:[function(e,t,n){(function(e){(function(){"use strict";var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=n=r.fetch,r.fetch&&(n.default=r.fetch.bind(r)),n.Headers=r.Headers,n.Request=r.Request,n.Response=r.Response}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],60:[function(e,t,n){"use strict";var r=e("./lib/Client"),i=e("./lib/sasl"),o=e("node-xmpp-core");t.exports=r,t.exports.Client=r,t.exports.SASL=i,o.exportCoreUtils(t.exports)},{"./lib/Client":61,"./lib/sasl":69,"node-xmpp-core":72}],61:[function(e,t,n){(function(n){(function(){"use strict";var r,i,o,s=e("./session"),a=e("node-xmpp-core"),c=a.JID,l=a.Stanza,u=a.Element,d=a.inherits,h=e("./sasl"),p=e("./authentication/anonymous"),f=e("./authentication/plain"),m=e("./authentication/digestmd5"),g=e("./authentication/xoauth2"),v=e("./authentication/external"),y=e("child_process").exec,b=e("debug")("xmpp:client"),S=e("path"),_="urn:ietf:params:xml:ns:xmpp-sasl",C="urn:ietf:params:xml:ns:xmpp-bind";if(void 0===w)var w=null,T=null;function E(e){this.options={},e&&(this.options=e),this.availableSaslMechanisms=[g,v,m,f,p],!1!==this.options.autostart&&this.connect()}"function"==typeof w?r=function(e){return T(e)}:(o=e("buffer").Buffer,r=function(e){return new o(e,"base64").toString("utf8")}),"function"==typeof T?i=function(e){return w(e)}:(o=e("buffer").Buffer,i=function(e){return new o(e,"utf8").toString("base64")}),d(E,s),E.NS_CLIENT="jabber:client",E.prototype.connect=function(){if(this.options.bosh&&this.options.bosh.prebind)return this._connectViaBosh();this._useStandardConnect()},E.prototype._useStandardConnect=function(){this.options.xmlns="jabber:client",delete this.did_bind,delete this.did_session,this.state=0,this.on("end",function(){this.state=0,delete this.did_bind,delete this.did_session}),s.call(this,this.options),this.options.jid=this.jid,this.connection.on("disconnect",function(e){this.state=0,this.connection.reconnect||(e&&this.emit("error",e),this.emit("offline")),delete this.did_bind,delete this.did_session}.bind(this)),this.options.preferred?this.preferredSaslMechanism=this.options.preferred:this.preferredSaslMechanism="DIGEST-MD5";var e=h.detectMechanisms(this.options,this.availableSaslMechanisms);this.availableSaslMechanisms=e},E.prototype._connectViaBosh=function(){b("load bosh prebind");var e=this.options.bosh.prebind;delete this.options.bosh.prebind;var t="node "+S.join(n,"prebind.js")+" "+encodeURI(JSON.stringify(this.options));y(t,function(t,n,r){if(t)e(t,null);else{var i=n.match(/rid:+[ 0-9]*/i),o=n.match(/sid:+[ a-z+'"-_A-Z+0-9]*/i);if(!i||!o)return e(r);if(i=i[0].split(":")[1].trim(),o=o[0].split(":")[1].replace("'","").replace("'","").trim(),i&&o)return e(null,{rid:i,sid:o});e(r)}})},E.prototype.onStanza=function(e){return"stream:error"===e.name?this._handleStreamError(e):5!==this.state&&e.is("features")?(this.streamFeatures=e,this.useFeatures()):void this._handleStanza(e)},E.prototype._handleStanza=function(e){switch(this.state){case 5:this.emit("stanza",e);break;case 0:this.emit("stanza:preauth",e);break;case 1:this._handleAuthState(e);break;case 3:e.is("iq")&&"bind"===e.attrs.id&&this._handleBindState(e);break;case 4:!0===e.is("iq")&&"sess"===e.attrs.id&&this._handleSessionState(e)}},E.prototype._handleStreamError=function(e){this.reconnect||this.emit("error",e)},E.prototype._handleSessionState=function(e){"result"===e.attrs.type?(this.state=2,this.did_session=!0,this.useFeatures()):this.emit("error","Cannot bind resource")},E.prototype._handleBindState=function(e){if("result"===e.attrs.type){this.state=2,this.did_bind=!0;var t=e.getChild("bind",C);t&&t.getChild("jid")&&(this.jid=new c(t.getChild("jid").getText())),this.useFeatures()}else this.emit("error","Cannot bind resource")},E.prototype._handleAuthState=function(e){if(e.is("challenge",_)){var t=r(e.getText()),n=i(this.mech.challenge(t)),o=new u("response",{xmlns:_}).t(n);this.send(o)}else e.is("success",_)?(this.mech=null,this.state=2,this.emit("auth")):this.emit("error","XMPP authentication failure")},E.prototype._handlePreAuthState=function(){this.state=1;var e=this.streamFeatures.getChild("mechanisms",_).getChildren("mechanism",_).map(function(e){return e.getText()});if(this.mech=h.selectMechanism(e,this.preferredSaslMechanism,this.availableSaslMechanisms),this.mech){this.mech.authzid=this.jid.bare().toString(),this.mech.authcid=this.jid.local,this.mech.password=this.password,this.mech.api_key=this.api_key,this.mech.access_token=this.access_token,this.mech.oauth2_token=this.oauth2_token,this.mech.oauth2_auth=this.oauth2_auth,this.mech.realm=this.jid.domain,this.actAs&&(this.mech.actAs=this.actAs.user),this.mech.digest_uri="xmpp/"+this.jid.domain;var t=i(this.mech.auth()),n=this.mech.authAttrs();n.xmlns=_,n.mechanism=this.mech.name,this.send(new u("auth",n).t(t))}else this.emit("error",new Error("No usable SASL mechanism"))},E.prototype.useFeatures=function(){if(0===this.state&&this.register)delete this.register,this.doRegister();else if(0===this.state&&this.streamFeatures.getChild("mechanisms",_))this._handlePreAuthState();else if(2===this.state&&!this.did_bind&&this.streamFeatures.getChild("bind",C)){this.state=3;var e=new l("iq",{type:"set",id:"bind"}).c("bind",{xmlns:C});this.jid.resource&&e.c("resource").t(this.jid.resource),this.send(e)}else if(2===this.state&&!this.did_session&&this.streamFeatures.getChild("session","urn:ietf:params:xml:ns:xmpp-session")){this.state=4;var t=new l("iq",{type:"set",to:this.jid.domain,id:"sess"}).c("session",{xmlns:"urn:ietf:params:xml:ns:xmpp-session"});this.send(t)}else 2===this.state&&(this.state=5,this.emit("online",{jid:this.jid}))},E.prototype.doRegister=function(){var e="register"+Math.ceil(99999*Math.random()),t=new l("iq",{type:"set",id:e,to:this.jid.domain}).c("query",{xmlns:"jabber:iq:register"}).c("username").t(this.jid.local).up().c("password").t(this.password);this.send(t);var n=this,r=function(t){t.is("iq")&&t.attrs.id===e&&(n.removeListener("stanza",r),"result"===t.attrs.type?n.useFeatures():n.emit("error",new Error("Registration error")))};this.on("stanza:preauth",r)},E.prototype.getSaslMechanisms=function(){return this.availableSaslMechanisms},E.prototype.clearSaslMechanism=function(){this.availableSaslMechanisms=[]},E.prototype.registerSaslMechanism=function(e){-1===this.availableSaslMechanisms.indexOf(e)&&this.availableSaslMechanisms.push(e)},E.prototype.unregisterSaslMechanism=function(e){var t=this.availableSaslMechanisms.indexOf(e);t>=0&&(this.availableSaslMechanisms=this.availableSaslMechanisms.splice(t,1))},t.exports=E}).call(this)}).call(this,"/node_modules/node-xmpp-client/lib")},{"./authentication/anonymous":62,"./authentication/digestmd5":63,"./authentication/external":64,"./authentication/plain":66,"./authentication/xoauth2":67,"./sasl":69,"./session":70,buffer:27,child_process:26,debug:35,"node-xmpp-core":72,path:25}],62:[function(e,t,n){"use strict";var r=e("./mechanism");function i(){}(0,e("node-xmpp-core").inherits)(i,r),i.prototype.name="ANONYMOUS",i.prototype.auth=function(){return this.authzid},i.prototype.match=function(){return!0},t.exports=i},{"./mechanism":65,"node-xmpp-core":72}],63:[function(e,t,n){"use strict";var r=e("node-xmpp-core").inherits,i=e("./mechanism"),o=e("crypto"),s=e("md5.js");function a(e,t){return(o.createHash?o.createHash("md5"):new s).update(e,"binary").digest(t||"binary")}function c(e){return a(e,"hex")}function l(e){for(var t={};e;){var n;(n=/^(.+?)=(.*?[^\\]),\s*(.*)/.exec(e))?(t[n[1]]=n[2].replace(/"/g,""),e=n[3]):(n=/^(.+?)=(.+?),\s*(.*)/.exec(e))?(t[n[1]]=n[2],e=n[3]):(n=/^(.+?)="(.*?[^\\])"$/.exec(e))?(t[n[1]]=n[2],e=n[3]):(n=/^(.+?)=(.+?)$/.exec(e))?(t[n[1]]=n[2],e=n[3]):e=null}return t}function u(e){var t="";for(var n in e){var r=e[n];r&&(t+=","+n+'="'+r+'"')}return t.substr(1)}function d(){for(var e="",t=0;t<8;t++)e+=String.fromCharCode(48+Math.ceil(10*Math.random()));return e}function h(){this.nonce_count=0,this.cnonce=d(),this.authcid=null,this.actAs=null,this.realm=null,this.password=null}r(h,i),h.prototype.name="DIGEST-MD5",h.prototype.auth=function(){return""},h.prototype.getNC=function(){return function(e,t,n){for(;e.length<t;)e=n+e;return e}(this.nonce_count.toString(),8,"0")},h.prototype.responseValue=function(e){var t,n=l(e);if(n.realm&&(this.realm=n.realm),n.nonce&&n.qop){this.nonce_count++;var r=a(this.authcid+":"+this.realm+":"+this.password)+":"+n.nonce+":"+this.cnonce;this.actAs&&(r+=":"+this.actAs);var i="AUTHENTICATE:"+this.digest_uri;"auth-int"!==n.qop&&"auth-conf"!==n.qop||(i+=":00000000000000000000000000000000"),t=c(c(r)+":"+n.nonce+":"+this.getNC()+":"+this.cnonce+":"+n.qop+":"+c(i))}return t},h.prototype.challenge=function(e){var t,n=l(e);if(n.realm&&(this.realm=n.realm),n.nonce&&n.qop){var r=this.responseValue(e);t={username:this.authcid,realm:this.realm,nonce:n.nonce,cnonce:this.cnonce,nc:this.getNC(),qop:n.qop,"digest-uri":this.digest_uri,response:r,charset:"utf-8"},this.actAs&&(t.authzid=this.actAs)}else if(n.rspauth)return"";return u(t)},h.prototype.serverChallenge=function(){var e={realm:""};return this.nonce=e.nonce=d(),e.qop="auth",this.charset=e.charset="utf-8",e.algorithm="md5-sess",u(e)},h.prototype.response=function(e){var t=l(e);return this.authcid=t.username,t.nonce===this.nonce&&(!!t.cnonce&&(this.cnonce=t.cnonce,this.charset===t.charset&&(this.response=t.response,!0)))},h.prototype.match=function(e){return!!e.password},t.exports=h},{"./mechanism":65,crypto:25,"md5.js":57,"node-xmpp-core":72}],64:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="EXTERNAL",r.prototype.auth=function(){return this.authzid},r.prototype.match=function(e){return!!e.credentials},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],65:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("events").EventEmitter),r.prototype.authAttrs=function(){return{}},t.exports=r},{events:37,"node-xmpp-core":72}],66:[function(e,t,n){"use strict";function r(){}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="PLAIN",r.prototype.auth=function(){return this.authzid+"\0"+this.authcid+"\0"+this.password},r.prototype.match=function(e){return!!e.password},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],67:[function(e,t,n){"use strict";function r(){this.oauth2_auth=null,this.authzid=null}(0,e("node-xmpp-core").inherits)(r,e("./mechanism")),r.prototype.name="X-OAUTH2",r.prototype.NS_GOOGLE_AUTH="http://www.google.com/talk/protocol/auth",r.prototype.auth=function(){return"\0"+this.authzid+"\0"+this.oauth2_token},r.prototype.authAttrs=function(){return{"auth:service":"oauth2","xmlns:auth":this.oauth2_auth}},r.prototype.match=function(e){return e.oauth2_auth===r.prototype.NS_GOOGLE_AUTH},t.exports=r},{"./mechanism":65,"node-xmpp-core":72}],68:[function(e,t,n){(function(n){(function(){"use strict";var r=e("events").EventEmitter,i=e("node-xmpp-core"),o=i.inherits,s=i.ltx,a=e("request"),c=e("debug")("xmpp:client:bosh");function l(e){var t=this;if(r.call(this),this.boshURL=e.bosh.url,this.jid=e.jid,this.wait=e.bosh.wait||60,this.xmlnsAttrs={xmlns:"http://jabber.org/protocol/httpbind","xmlns:xmpp":"urn:xmpp:xbosh","xmlns:stream":"http://etherx.jabber.org/streams"},e.xmlns)for(var i in e.xmlns)i?this.xmlnsAttrs["xmlns:"+i]=e.xmlns[i]:this.xmlnsAttrs.xmlns=e.xmlns[i];this.currentRequests=0,this.queue=[],this.rid=Math.ceil(9999999999*Math.random()),this.request({to:this.jid.domain,ver:"1.6",wait:this.wait,hold:"1",content:this.contentType,"xmpp:version":"1.0"},[],function(e,r){e?t.emit("error",e):r&&r.attrs&&(t.sid=r.attrs.sid,t.maxRequests=parseInt(r.attrs.requests,10)||2,t.sid&&t.maxRequests>0?(t.emit("connect"),t.processResponse(r),n.nextTick(t.mayRequest.bind(t))):t.emit("error","Invalid parameters"))})}o(l,r),l.prototype.contentType="text/xml; charset=utf-8",l.prototype.send=function(e){this.queue.push(e.root()),n.nextTick(this.mayRequest.bind(this))},l.prototype.startStream=function(){var e=this;this.rid++,this.request({to:this.jid.domain,"xmpp:restart":"true"},[],function(t,r){t?(e.emit("error",t),e.emit("disconnect"),e.emit("end"),delete e.sid,e.emit("close")):(e.streamOpened=!0,r&&e.processResponse(r),n.nextTick(e.mayRequest.bind(e)))})},l.prototype.processResponse=function(e){if(c("process bosh server response "+e.toString()),e&&e.children)for(var t=0;t<e.children.length;t++){var n=e.children[t];n.name&&n.attrs&&n.children&&this.emit("stanza",n)}e&&"terminate"===e.attrs.type&&(this.shutdown&&!e.attrs.condition||this.emit("error",new Error(e.attrs.condition||"Session terminated")),this.emit("disconnect"),this.emit("end"),this.emit("close"))},l.prototype.mayRequest=function(){if(this.sid&&(0===this.currentRequests||this.queue.length>0&&this.currentRequests<this.maxRequests)){var e=this.queue;this.queue=[],this.rid++,this.request({},e,function(e,t){e?(this.emit("error",e),this.emit("disconnect"),this.emit("end"),delete this.sid,this.emit("close")):(t&&this.processResponse(t),n.nextTick(this.mayRequest.bind(this)))}.bind(this))}},l.prototype.end=function(e){typeof(e=e||[])!==Array&&(e=[e]),e=this.queue.concat(e),this.shutdown=!0,this.queue=[],this.rid++,this.request({type:"terminate"},e,function(e,t){e||t&&this.processResponse(t),this.emit("disconnect"),this.emit("end"),delete this.sid,this.emit("close")}.bind(this))},l.prototype.maxHTTPRetries=5,l.prototype.request=function(e,t,n,r){var i=this;for(var o in r=r||0,e.rid=this.rid.toString(),this.sid&&(e.sid=this.sid),this.xmlnsAttrs)e[o]=this.xmlnsAttrs[o];for(var l=new s.Element("body",e),u=0;u<t.length;u++)l.cnode(t[u]);c("send bosh request:"+l.toString()),a({uri:this.boshURL,method:"POST",headers:{"Content-Type":this.contentType},body:l.toString()},function(o,a,c){if(i.currentRequests--,o)return r<i.maxHTTPRetries?i.request(e,t,n,r+1):n(o);if(a.statusCode<200||a.statusCode>=400)return n(new Error("HTTP status "+a.statusCode));var l;try{l=s.parse(c)}catch(e){return n(e)}l&&"terminate"===l.attrs.type&&l.attrs.condition?n(new Error(l.attrs.condition)):l?n(null,l):n(new Error("no <body/>"))}),this.currentRequests++},t.exports=l}).call(this)}).call(this,e("_process"))},{_process:89,debug:35,events:37,"node-xmpp-core":72,request:24}],69:[function(e,t,n){"use strict";var r=e("./authentication/mechanism");n.selectMechanism=function(e,t,n){var r,i=[],o={};return Array.isArray(n)&&(i=i.concat(n)),i.forEach(function(e){o[e.prototype.name]=e}),o[t]&&e.indexOf(t)>=0&&(r=o[t]),i.forEach(function(t){!r&&e.indexOf(t.prototype.name)>=0&&(r=t)}),r?new r:null},n.detectMechanisms=function(e,t){var n=[];return(t||[]).forEach(function(t){(0,t.prototype.match)(e)&&n.push(t)}),n},n.AbstractMechanism=r},{"./authentication/mechanism":65}],70:[function(e,t,n){(function(n){(function(){"use strict";var r=e("tls"),i=e("events").EventEmitter,o=e("node-xmpp-core"),s=o.inherits,a=o.Connection,c=o.JID,l=o.SRV,u=e("./bosh"),d=e("./websockets"),h=e("debug")("xmpp:client:session");function p(e){i.call(this),this.setOptions(e),e.websocket&&e.websocket.url?(h("start websocket connection"),this._setupWebsocketConnection(e)):e.bosh&&e.bosh.url?(h("start bosh connection"),this._setupBoshConnection(e)):(h("start socket connection"),this._setupSocketConnection(e))}s(p,i),p.prototype._setupSocketConnection=function(e){var t={xmlns:{"":e.xmlns},streamAttrs:{version:"1.0",to:this.jid.domain},serialized:e.serialized};for(var n in e)n in t||(t[n]=e[n]);if(this.connection=new a(t),this._addConnectionListeners(),e.host||e.port)this._socketConnectionToHost(e);else{if(!l)throw new Error("Cannot load SRV");this._performSrvLookup(e)}},p.prototype._socketConnectionToHost=function(e){var t=this;e.legacySSL?(this.connection.allowTLS=!1,this.connection.connect({socket:function(){return r.connect(e.port||5223,e.host||"localhost",e.credentials||{},function(){this.socket.authorized?t.emit("connect",this.socket):t.emit("error","unauthorized")}.bind(this))}})):(e.credentials&&(this.connection.credentials=r.createSecureContext(e.credentials)),e.disallowTLS&&(this.connection.allowTLS=!1),this.connection.listen({socket:function(){n.nextTick(function(){this.socket.connect(e.port||5222,e.host)}.bind(this));var t=e.socket;return e.socket=null,t}}))},p.prototype._performSrvLookup=function(e){if(e.legacySSL)throw new Error("LegacySSL mode does not support DNS lookups");e.credentials&&(this.connection.credentials=r.createSecureContext(e.credentials)),e.disallowTLS&&(this.connection.allowTLS=!1),this.connection.listen({socket:l.connect({socket:e.socket,services:["_xmpp-client._tcp"],domain:this.jid.domain,defaultPort:5222})})},p.prototype._setupBoshConnection=function(e){this.connection=new u({jid:this.jid,bosh:e.bosh}),this._addConnectionListeners(),this.connection.on("connected",function(){this.connection.startStream&&this.connection.startStream()}.bind(this))},p.prototype._setupWebsocketConnection=function(e){this.connection=new d({jid:this.jid,websocket:e.websocket}),this._addConnectionListeners(),this.connection.on("connected",function(){this.connection.startStream&&this.connection.startStream()}.bind(this))},p.prototype.setOptions=function(e){this.jid="string"==typeof e.jid?new c(e.jid):e.jid,this.password=e.password,this.preferredSaslMechanism=e.preferredSaslMechanism,this.api_key=e.api_key,this.access_token=e.access_token,this.oauth2_token=e.oauth2_token,this.oauth2_auth=e.oauth2_auth,this.register=e.register,"string"==typeof e.actAs?this.actAs=new c(e.actAs):this.actAs=e.actAs},p.prototype._addConnectionListeners=function(e){(e=e||this.connection).on("stanza",this.onStanza.bind(this)),e.on("drain",this.emit.bind(this,"drain")),e.on("end",this.emit.bind(this,"end")),e.on("close",this.emit.bind(this,"close")),e.on("error",this.emit.bind(this,"error")),e.on("connect",this.emit.bind(this,"connect")),e.on("reconnect",this.emit.bind(this,"reconnect")),e.on("disconnect",this.emit.bind(this,"disconnect")),e.startStream&&(e.on("connect",function(){e.startStream()}),this.on("auth",function(){e.startStream()}))},p.prototype.pause=function(){this.connection&&this.connection.pause&&this.connection.pause()},p.prototype.resume=function(){this.connection&&this.connection.resume&&this.connection.resume()},p.prototype.send=function(e){return!!this.connection&&this.connection.send(e)},p.prototype.end=function(){this.connection&&this.connection.end()},p.prototype.onStanza=function(){},t.exports=p}).call(this)}).call(this,e("_process"))},{"./bosh":68,"./websockets":71,_process:89,debug:35,events:37,"node-xmpp-core":72,tls:26}],71:[function(e,t,n){"use strict";var r=e("events").EventEmitter,i=e("node-xmpp-core"),o=i.Element,s=i.StreamParser,a=i.Connection,c=i.inherits,l=e("ws"),u=l.Server?l:window.WebSocket,d=e("debug")("xmpp:client:websocket"),h="urn:ietf:params:xml:ns:xmpp-framing";function p(e){r.call(this),this.url=e.websocket.url,this.jid=e.jid,this.xmlns={"":h},this.websocket=new u(this.url,["xmpp"],e.websocket.options),this.websocket.onopen=this.onopen.bind(this),this.websocket.onmessage=this.onmessage.bind(this),this.websocket.onclose=this.onclose.bind(this),this.websocket.onerror=this.onerror.bind(this)}c(p,r),p.prototype.maxStanzaSize=65535,p.prototype.xmppVersion="1.0",p.prototype.onopen=function(){this.startParser(),this.emit("connected")},p.prototype.startParser=function(){var e=this;this.parser=new s(this.maxStanzaSize),this.parser.on("start",function(t){for(var n in e.streamAttrs=t,e.streamNsAttrs={},t)"xmlns"!==n&&"xmlns:"!==n.substr(0,6)||(e.streamNsAttrs[n]=t[n]);e.emit("streamStart",t)}),this.parser.on("stanza",function(t){e.onStanza(t)}),this.parser.on("error",this.onerror.bind(this)),this.parser.on("end",function(){e.stopParser(),e.end()})},p.prototype.stopParser=function(){this.parser&&delete this.parser},p.prototype.onmessage=function(e){d("ws msg <--",e.data),e&&e.data&&this.parser&&this.parser.write(e.data)},p.prototype.onStanza=function(e){e.is("error",a.NS_STREAM)?this.emit("error",e):this.emit("stanza",e)},p.prototype.startStream=function(){var e={};for(var t in this.xmlns)this.xmlns.hasOwnProperty(t)&&(t?e["xmlns:"+t]=this.xmlns[t]:e.xmlns=this.xmlns[t]);this.xmppVersion&&(e.version=this.xmppVersion),this.streamTo&&(e.to=this.streamTo),this.jid&&(e.to=this.jid.domain),this.send(new o("open",e)),this.streamOpened=!0},p.prototype.send=function(e){e.root&&(e=e.root()),!e.attrs.xmlns&&(e.is("iq")||e.is("presence")||e.is("message"))&&(e.attrs.xmlns="jabber:client"),e=e.toString(),d("ws send --\x3e",e),this.websocket.send(e)},p.prototype.onclose=function(){this.emit("disconnect"),this.emit("close")},p.prototype.end=function(){this.send(new o("close",{xmlns:h})),this.emit("disconnect"),this.emit("end"),this.websocket&&this.websocket.close()},p.prototype.onerror=function(e){this.emit("error",e)},t.exports=p},{debug:35,events:37,"node-xmpp-core":72,ws:25}],72:[function(e,t,n){"use strict";var r=e("./lib/Connection"),i=e("@xmpp/streamparser"),o=e("@xmpp/jid"),s=e("@xmpp/xml"),a=e("inherits");n.SRV=e("./lib/SRV"),n.exportCoreUtils=function(e){e.Connection=r,e.StreamParser=i,e.JID=o,e.inherits=a,e.stanza=s,e.Stanza=s.Stanza,e.createStanza=s.createStanza,e.IQ=s.IQ,e.Presence=s.Presence,e.Message=s.Message,e.Parser=s.Parser,e.parse=s.parse,e.ltx=s.ltx,e.createElement=s.createElement,e.Element=s.Element,e.escapeXML=s.escapeXML,e.escapeXMLText=s.escapeXMLText},n.exportCoreUtils(n)},{"./lib/Connection":73,"./lib/SRV":25,"@xmpp/jid":74,"@xmpp/streamparser":7,"@xmpp/xml":78,inherits:41}],73:[function(e,t,n){"use strict";var r=e("net"),i=e("events").EventEmitter,o=e("inherits"),s=e("@xmpp/xml").Element,a=e("reconnect-core"),c=e("@xmpp/streamparser"),l=e("node-xmpp-tls-connect"),u=e("debug")("xmpp:connection"),d=e("lodash.assign"),h="http://etherx.jabber.org/streams",p="urn:ietf:params:xml:ns:xmpp-streams",f=1e3,m=3e4,g="stream:stream",v="</stream:stream>";function y(e){i.call(this),this.streamAttrs=e&&e.streamAttrs||{},this.xmlns=e&&e.xmlns||{},this.xmlns.stream=h,this.streamOpen=e&&e.streamOpen||g,this.streamClose=e&&e.streamClose||v,this.rejectUnauthorized=!(!e||!e.rejectUnauthorized),this.serialized=!(!e||!e.serialized),this.requestCert=!(!e||!e.requestCert),this.servername=e&&e.servername,this.boundOnData=this.onData.bind(this),this.boundOnClose=this.onClose.bind(this),this.boundEmitData=this.emit.bind(this,"data"),this.boundEmitDrain=this.emit.bind(this,"drain"),this._setupSocket(function(e,t){var n=d({},t);return n.initialDelay=t&&(t.initialReconnectDelay||t.reconnectDelay)||f,n.maxDelay=t&&t.maxReconnectDelay||m,n.immediate=t&&t.socket&&"function"!=typeof t.socket,n.type=t&&t.delayType,n.emitter=e,n}(this,e)),this.once("reconnect",function(){this.reconnect=e&&e.reconnect})}o(y,i),y.prototype.NS_XMPP_TLS="urn:ietf:params:xml:ns:xmpp-tls",y.NS_STREAM=h,y.prototype.NS_XMPP_STREAMS=p,y.prototype.allowTLS=!0,y.prototype._setupSocket=function(e){u("setup socket");var t={},n=a(function(e){var i=this.socket;return"on"===e.preserve?(e.preserve=t,t=e):e=t=e.preserve?e.preserve:e||t,"function"==typeof e.socket?(u("use lazy socket"),this.socket=e.socket.call(this)):(u("use standard socket"),this.socket=e.socket,e.socket=null,this.socket&&this.once("connect",function(){n.options.immediate=!1})),this.socket=this.socket||new r.Socket,i!==this.socket&&this.setupStream(),this.socket}.bind(this));n(n.options=e);var i=this.end;this.end=this.disconnect=function(){this.closeStream(),i()},this.on("connection",function(){this.parser||this.startParser()}),this.on("end",function(){t={}})},y.prototype.setupStream=function(){u("setup stream"),this.socket.on("end",this.onEnd.bind(this)),this.socket.on("data",this.boundOnData),this.socket.on("close",this.boundOnClose),this.socket.on("data",this.boundEmitData),this.socket.on("drain",this.boundEmitDrain),this.socket.on("error",function(){}),this.socket.serializeStanza||(this.serialized?this.socket.serializeStanza=function(e,t){e.write(function(e){t(e)})}:this.socket.serializeStanza=function(e,t){t(e.toString())})},y.prototype.pause=function(){this.socket.pause&&this.socket.pause()},y.prototype.resume=function(){this.socket.resume&&this.socket.resume()},y.prototype.send=function(e){if(this.socket&&this.streamOpened){if(this.socket.writable){u("send: "+e.toString());var t=!0;if(e.root){var n=this.rmXmlns(e.root());this.socket.serializeStanza(n,function(e){t=this.write(e)}.bind(this.socket))}else t=this.socket.write(e);return t}this.socket.end()}},y.prototype.startParser=function(){var e=this;this.parser=new c(this.maxStanzaSize),this.parser.on("streamStart",function(t){for(var n in e.streamNsAttrs={},t)"xmlns"!==n&&"xmlns:"!==n.substr(0,6)||(e.streamNsAttrs[n]=t[n]);e.emit("streamStart",t)}),this.parser.on("stanza",function(t){e.onStanza(e.addStreamNs(t))}),this.parser.on("error",function(t){e.error(t.condition||"internal-server-error",t.message)}),this.parser.once("end",function(){e.stopParser(),e.reconnect?e.once("reconnect",e.startParser.bind(e)):e.end()})},y.prototype.stopParser=function(){if(this.parser){var e=this.parser;this.parser=null,e.end()}},y.prototype.openStream=function(){var e={};for(var t in this.xmlns)this.xmlns.hasOwnProperty(t)&&(t?e["xmlns:"+t]=this.xmlns[t]:e.xmlns=this.xmlns[t]);for(t in this.streamAttrs)this.streamAttrs.hasOwnProperty(t)&&(e[t]=this.streamAttrs[t]);this.streamTo&&(e.to=this.streamTo);var n,r=new s(this.streamOpen,e);if("stream:stream"===r.name){r.t(" ");var i=r.toString();n=i.substr(0,i.indexOf(" </stream:stream>"))}else n=r.toString();this.streamOpened=!0,this.send(n)},y.prototype.startStream=y.prototype.openStream,y.prototype.closeStream=function(){this.send(this.streamClose),this.streamOpened=!1},y.prototype.endStream=y.prototype.closeStream,y.prototype.onData=function(e){u("receive: "+e.toString("utf8")),this.parser&&this.parser.write(e)},y.prototype.setSecure=function(e,t,n){this.socket.removeListener("data",this.boundOnData),this.socket.removeListener("data",this.boundEmitData),this.socket.removeListener("drain",this.boundEmitDrain),this.socket.removeListener("close",this.boundOnClose),this.socket.clearTimer&&this.socket.clearTimer();var r=l({socket:this.socket,rejectUnauthorized:this.rejectUnauthorized,credentials:e||this.credentials,requestCert:this.requestCert,isServer:!!t,servername:t&&n},function(){this.isSecure=!0,this.once("disconnect",function(){this.isSecure=!1}),r.emit("connect",r)}.bind(this));r.on("clientError",this.emit.bind(this,"error")),this.reconnect||(this.reconnect=!0,this.once("reconnect",function(){this.reconnect=!1})),this.stopParser(),this.listen({socket:r,preserve:"on"})},y.prototype.onStanza=function(e){if(e.is("error",h)){var t=new Error(""+function e(t){return t.children?t.children.reduce(function(t,n){return t+e(n)},""):t}(e));t.stanza=e,this.socket.emit("error",t)}else e.is("features",this.NS_STREAM)&&this.allowTLS&&!this.isSecure&&e.getChild("starttls",this.NS_XMPP_TLS)?this.send(new s("starttls",{xmlns:this.NS_XMPP_TLS})):this.allowTLS&&e.is("proceed",this.NS_XMPP_TLS)?this.setSecure():this.emit("stanza",e)},y.prototype.addStreamNs=function(e){for(var t in this.streamNsAttrs)e.attrs[t]||"xmlns"===t&&this.streamNsAttrs[t]===this.xmlns[""]||(e.attrs[t]=this.streamNsAttrs[t]);return e},y.prototype.rmXmlns=function(e){for(var t in this.xmlns){var n=t?"xmlns:"+t:"xmlns";e.attrs[n]===this.xmlns[t]&&(e.attrs[n]=null)}return e},y.prototype.onEnd=function(){this.closeStream(),this.reconnect||this.emit("end")},y.prototype.onClose=function(){this.reconnect||this.emit("close")},y.prototype.error=function(e,t){if(this.emit("error",new Error(t)),this.socket&&this.socket.writable){this.streamOpened||this.openStream();var n=new s("stream:error");n.c(e,{xmlns:p}),t&&n.c("text",{xmlns:p,"xml:lang":"en"}).t(t),this.send(n),this.end()}},t.exports=y},{"@xmpp/streamparser":7,"@xmpp/xml":78,debug:35,events:37,inherits:41,"lodash.assign":43,net:26,"node-xmpp-tls-connect":25,"reconnect-core":105}],74:[function(e,t,n){"use strict";var r=e("./lib/JID"),i=e("./lib/tag");t.exports=function(e,t,n){return Array.isArray(e)?i.apply(null,arguments):new r(e,t,n)},t.exports.JID=r,t.exports.tag=i,t.exports.equal=function(e,t){return e.equals(t)},t.exports.is=function(e){return e instanceof r}},{"./lib/JID":75,"./lib/tag":77}],75:[function(e,t,n){"use strict";var r=e("./escaping");function i(e,t,n){if(this._local=null,this.user=null,this._domain=null,this._resource=null,!e||t||n){if(!t)throw new Error("Argument error");this.setLocal(e),this.setDomain(t),this.setResource(n)}else this.parseJID(e)}i.prototype.parseJID=function(e){var t=e.indexOf("/");-1!==t&&(this.setResource(e.substr(t+1)),e=e.substr(0,t));var n=e.indexOf("@");-1!==n&&(this.setLocal(e.substr(0,n)),e=e.substr(n+1)),this.setDomain(e)},i.prototype.toString=function(e){var t=this._domain;return this._local&&(t=this.getLocal(e)+"@"+t),this._resource&&(t=t+"/"+this._resource),t},i.prototype.bare=function(){return this._resource?new i(this._local,this._domain,null):this},i.prototype.equals=function(e){return this._local===e._local&&this._domain===e._domain&&this._resource===e._resource},i.prototype.setLocal=function(e,t){return(t=t||r.detect(e))&&(e=r.escape(e)),this._local=e&&e.toLowerCase(),this.user=this._local,this},i.prototype.setUser=function(){console.log("JID.setUser: Use JID.setLocal instead"),this.setLocal.apply(this,arguments)},i.prototype.getUser=function(){return console.log("JID.getUser: Use JID.getLocal instead"),this.getLocal.apply(this,arguments)},i.prototype.getLocal=function(e){return(e=e||!1)?r.unescape(this._local):this._local},Object.defineProperty(i.prototype,"local",{get:i.prototype.getLocal,set:i.prototype.setLocal}),i.prototype.setDomain=function(e){return this._domain=e.toLowerCase(),this},i.prototype.getDomain=function(){return this._domain},Object.defineProperty(i.prototype,"domain",{get:i.prototype.getDomain,set:i.prototype.setDomain}),i.prototype.setResource=function(e){return this._resource=e,this},i.prototype.getResource=function(){return this._resource},Object.defineProperty(i.prototype,"resource",{get:i.prototype.getResource,set:i.prototype.setResource}),i.prototype.detectEscape=r.detectEscape,i.prototype.escapeLocal=r.escape,i.prototype.unescapeLocal=r.unescape,t.exports=i},{"./escaping":76}],76:[function(e,t,n){"use strict";t.exports.detect=function(e){return!!e&&-1!==e.replace(/\\20/g,"").replace(/\\22/g,"").replace(/\\26/g,"").replace(/\\27/g,"").replace(/\\2f/g,"").replace(/\\3a/g,"").replace(/\\3c/g,"").replace(/\\3e/g,"").replace(/\\40/g,"").replace(/\\5c/g,"").search(/\\| |"|&|'|\/|:|<|>|@/g)},t.exports.escape=function(e){return null===e?null:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/"/g,"\\22").replace(/&/g,"\\26").replace(/'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40").replace(/\3a/g,"c3a")},t.exports.unescape=function(e){return null===e?null:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")}},{}],77:[function(e,t,n){"use strict";var r=e("./JID");t.exports=function(){for(var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n="",i=0;i<t.length;i++)n+=e[i],n+=t[i];return n+=e[e.length-1],new r(n)}},{"./JID":75}],78:[function(e,t,n){arguments[4][8][0].apply(n,arguments)},{"./lib/IQ":79,"./lib/Message":80,"./lib/Parser":81,"./lib/Presence":82,"./lib/Stanza":83,"./lib/createStanza":84,"./lib/parse":85,"./lib/tag":86,dup:8,ltx:44}],79:[function(e,t,n){arguments[4][9][0].apply(n,arguments)},{"./Stanza":83,dup:9,inherits:41}],80:[function(e,t,n){arguments[4][10][0].apply(n,arguments)},{"./Stanza":83,dup:10,inherits:41}],81:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{"./createStanza":84,dup:11,inherits:41,ltx:44}],82:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./Stanza":83,dup:12,inherits:41}],83:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,inherits:41,ltx:44}],84:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{"./Stanza":83,dup:14,ltx:44}],85:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{"./Parser":81,dup:15,ltx:44}],86:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./parse":85,dup:16,ltx:44}],87:[function(e,t,n){n.endianness=function(){return"LE"},n.hostname=function(){return"undefined"!=typeof location?location.hostname:""},n.loadavg=function(){return[]},n.uptime=function(){return 0},n.freemem=function(){return Number.MAX_VALUE},n.totalmem=function(){return Number.MAX_VALUE},n.cpus=function(){return[]},n.type=function(){return"Browser"},n.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},n.networkInterfaces=n.getNetworkInterfaces=function(){return{}},n.arch=function(){return"javascript"},n.platform=function(){return"browser"},n.tmpdir=n.tmpDir=function(){return"/tmp"},n.EOL="\n"},{}],88:[function(e,t,n){(function(e){(function(){"use strict";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,n,r,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick(function(){t.apply(null,o)})}}}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:89}],89:[function(e,t,n){var r,i,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!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:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var l,u=[],d=!1,h=-1;function p(){d&&l&&(d=!1,l.length?u=l.concat(u):h=-1,u.length&&f())}function f(){if(!d){var e=c(p);d=!0;for(var t=u.length;t;){for(l=u,u=[];++h<t;)l&&l[h].run();h=-1,t=u.length}l=null,d=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new m(e,t)),1!==u.length||d||c(f)},m.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=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,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}},{}],90:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":91}],91:[function(e,t,n){"use strict";var r=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=d;var o=Object.create(e("core-util-is"));o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(d,s);for(var c=i(a.prototype),l=0;l<c.length;l++){var u=c[l];d.prototype[u]||(d.prototype[u]=a.prototype[u])}function d(e){if(!(this instanceof d))return new d(e);s.call(this,e),a.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",h)}function h(){this.allowHalfOpen||this._writableState.ended||r.nextTick(p,this)}function p(e){e.end()}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(d.prototype,"destroyed",{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)}}),d.prototype._destroy=function(e,t){this.push(null),this.end(),r.nextTick(t,e)}},{"./_stream_readable":93,"./_stream_writable":95,"core-util-is":28,inherits:41,"process-nextick-args":88}],92:[function(e,t,n){"use strict";t.exports=o;var r=e("./_stream_transform"),i=Object.create(e("core-util-is"));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=e("inherits"),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":94,"core-util-is":28,inherits:41}],93:[function(e,t,n){(function(n,r){(function(){"use strict";var i=e("process-nextick-args");t.exports=b;var o,s=e("isarray");b.ReadableState=y;e("events").EventEmitter;var a=function(e,t){return e.listeners(t).length},c=e("./internal/streams/stream"),l=e("safe-buffer").Buffer,u=(void 0!==r?r:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var d=Object.create(e("core-util-is"));d.inherits=e("inherits");var h=e("util"),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var f,m=e("./internal/streams/BufferList"),g=e("./internal/streams/destroy");d.inherits(b,c);var v=["error","close","destroy","pause","resume"];function y(t,n){t=t||{};var r=n instanceof(o=o||e("./_stream_duplex"));this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,s=t.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,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.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function b(t){if(o=o||e("./_stream_duplex"),!(this instanceof b))return new b(t);this._readableState=new y(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),c.call(this)}function S(e,t,n,r,i){var o,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,T(e)}(e,s)):(i||(o=function(e,t){var n;r=t,l.isBuffer(r)||r instanceof u||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),r?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):_(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?_(e,s,t,!1):x(e,s)):_(e,s,t,!1))):r||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(s)}function _(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&T(e)),x(e,t)}Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(e,t){this.push(null),t(e)},b.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=l.from(e,t),t=""),n=!0),S(this,e,t,!1,n)},b.prototype.unshift=function(e){return S(this,e,null,!0,!1)},b.prototype.isPaused=function(){return!1===this._readableState.flowing},b.prototype.setEncoding=function(t){return f||(f=e("string_decoder/").StringDecoder),this._readableState.decoder=new f(t),this._readableState.encoding=t,this};var C=8388608;function w(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>=C?e=C:(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 T(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(E,e):E(e))}function E(e){p("emit readable"),e.emit("readable"),N(e)}function x(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(R,e,t))}function R(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(p("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function k(e){p("readable nexttick read 0"),e.read(0)}function I(e,t){t.reading||(p("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),N(e),t.flowing&&!t.reading&&e.read(0)}function N(e){var t=e._readableState;for(p("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):r=e===t.head.data.length?t.shift():n?function(e,t){var n=t.head,r=1,i=n.data;e-=i.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}(e,t):function(e,t){var n=l.allocUnsafe(e),r=t.head,i=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),0===(e-=s)){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function A(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function L(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}b.prototype.read=function(e){p("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?A(this):T(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&A(this),null;var r,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&p("length less than watermark",i=!0),t.ended||t.reading?p("reading or ended",i=!1):i&&(p("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=w(n,t))),null===(r=e>0?D(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&A(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},b.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,p("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:b;function l(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",v),e.removeListener("finish",y),e.removeListener("drain",d),e.removeListener("error",g),e.removeListener("unpipe",l),r.removeListener("end",u),r.removeListener("end",b),r.removeListener("data",m),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||d())}function u(){p("onend"),e.end()}o.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",l);var d=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,N(e))}}(r);e.on("drain",d);var h=!1;var f=!1;function m(t){p("ondata"),f=!1,!1!==e.write(t)||f||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==L(o.pipes,e))&&!h&&(p("false write response, pause",o.awaitDrain),o.awaitDrain++,f=!0),r.pause())}function g(t){p("onerror",t),b(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",y),b()}function y(){p("onfinish"),e.removeListener("close",v),b()}function b(){p("unpipe"),r.unpipe(e)}return r.on("data",m),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",g),e.once("close",v),e.once("finish",y),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},b.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=L(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},b.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&T(this):i.nextTick(k,this))}return n},b.prototype.addListener=b.prototype.on,b.prototype.resume=function(){var e=this._readableState;return e.flowing||(p("resume"),e.flowing=!0,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(I,e,t))}(this,e)),this},b.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},b.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(p("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(p("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<v.length;o++)e.on(v[o],this.emit.bind(this,v[o]));return this._read=function(t){p("wrapped _read",t),r&&(r=!1,e.resume())},this},Object.defineProperty(b.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),b._fromList=D}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":91,"./internal/streams/BufferList":96,"./internal/streams/destroy":97,"./internal/streams/stream":98,_process:89,"core-util-is":28,events:37,inherits:41,isarray:42,"process-nextick-args":88,"safe-buffer":99,"string_decoder/":100,util:25}],94:[function(e,t,n){"use strict";t.exports=s;var r=e("./_stream_duplex"),i=Object.create(e("core-util-is"));function o(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function s(e){if(!(this instanceof s))return new s(e);r.call(this,e),this._transformState={afterTransform:o.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",a)}function a(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){c(e,t,n)}):c(this,null,null)}function c(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}i.inherits=e("inherits"),i.inherits(s,r),s.prototype.push=function(e,t){return this._transformState.needTransform=!1,r.prototype.push.call(this,e,t)},s.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")},s.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},s.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},s.prototype._destroy=function(e,t){var n=this;r.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},{"./_stream_duplex":91,"core-util-is":28,inherits:41}],95:[function(e,t,n){(function(n,r,i){(function(){"use strict";var o=e("process-nextick-args");function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}t.exports=y;var a,c=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?i:o.nextTick;y.WritableState=v;var l=Object.create(e("core-util-is"));l.inherits=e("inherits");var u={deprecate:e("util-deprecate")},d=e("./internal/streams/stream"),h=e("safe-buffer").Buffer,p=(void 0!==r?r:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var f,m=e("./internal/streams/destroy");function g(){}function v(t,n){a=a||e("./_stream_duplex"),t=t||{};var r=n instanceof a;this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,l=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(l||0===l)?l:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var d=!1===t.decodeStrings;this.decodeStrings=!d,this.defaultEncoding=t.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 n=e._writableState,r=n.sync,i=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(o.nextTick(i,r),o.nextTick(T,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(i(r),e._writableState.errorEmitted=!0,e.emit("error",r),T(e,t))}(e,n,r,t,i);else{var s=C(n);s||n.corked||n.bufferProcessing||!n.bufferedRequest||_(e,n),r?c(S,e,n,s,i):S(e,n,s,i)}}(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function y(t){if(a=a||e("./_stream_duplex"),!(f.call(y,this)||this instanceof a))return new y(t);this._writableState=new v(t,this),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)),d.call(this)}function b(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function S(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),T(e,t)}function _(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,b(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback;if(b(e,t,!1,t.objectMode?1:l.length,l,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function C(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function w(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),T(e,t)})}function T(e,t){var n=C(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(w,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}l.inherits(y,d),v.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(v.prototype,"buffer",{get:u.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]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===y&&(e&&e._writableState instanceof v)}})):f=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,n){var r,i=this._writableState,s=!1,a=!i.objectMode&&(r=e,h.isBuffer(r)||r instanceof p);return a&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=g),i.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),o.nextTick(t,n)}(this,n):(a||function(e,t,n,r){var i=!0,s=!1;return null===n?s=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(r,s),i=!1),i}(this,i,e,n))&&(i.pendingcb++,s=function(e,t,n,r,i,o){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,n));return t}(t,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=t.objectMode?1:r.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:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else b(e,t,!1,a,r,i,o);return c}(this,i,a,e,t,n)),s},y.prototype.cork=function(){this._writableState.corked++},y.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||_(this,e))},y.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 TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,T(e,t),n&&(t.finished?o.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":91,"./internal/streams/destroy":97,"./internal/streams/stream":98,_process:89,"core-util-is":28,inherits:41,"process-nextick-args":88,"safe-buffer":99,timers:112,"util-deprecate":113}],96:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=e("util");t.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}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=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}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);for(var t,n,i,o=r.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,i=a,t.copy(n,i),a+=s.data.length,s=s.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":99,util:25}],97:[function(e,t,n){"use strict";var r=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var n=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(i,this,e)):r.nextTick(i,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,r.nextTick(i,n,e)):r.nextTick(i,n,e):t&&t(e)}),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)}}},{"process-nextick-args":88}],98:[function(e,t,n){t.exports=e("events").EventEmitter},{events:37}],99:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:27}],100:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=r.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 o(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&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=d,t=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.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,n=function(e,t,n){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!==n?n: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 c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?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-n))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}n.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=s(t[r]);if(i>=0)return i>0&&(e.lastNeed=i-1),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(e.lastNeed=i-2),i;if(--r<n||-2===i)return 0;if((i=s(t[r]))>=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},o.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}},{"safe-buffer":99}],101:[function(e,t,n){t.exports=e("./readable").PassThrough},{"./readable":102}],102:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":91,"./lib/_stream_passthrough.js":92,"./lib/_stream_readable.js":93,"./lib/_stream_transform.js":94,"./lib/_stream_writable.js":95}],103:[function(e,t,n){t.exports=e("./readable").Transform},{"./readable":102}],104:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":95}],105:[function(e,t,n){var r=e("events").EventEmitter,i=e("backoff"),o=function(){};t.exports=function(e){return function(t,n){n="function"==typeof t?t:n,t="object"==typeof t?t:{initialDelay:1e3,maxDelay:3e4},n||(n=t.onConnect);var s=t.emitter||new r;s.connected=!1,s.reconnect=!0,n&&s.on("connect",n);var a,c=(i[t.type]||i.fibonacci)(t);c.on("backoff",function(e,t){s.emit("backoff",e,t)});var l=o;function u(r,i){if(s.reconnect){l(),s.emit("reconnect",r,i);var u=e.apply(null,a);u!==s._connection&&s.emit("connection",u),s._connection=u,l=d,u.on("error",h).on("close",h).on("end",h),t.immediate||"Request"==u.constructor.name?(s.connected=!0,s.emit("connect",u),u.once("data",function(){c.reset()})):u.on("connect",p)}function d(e){l=o,u.removeListener("connect",p),u.removeListener("error",h),u.removeListener("close",h),u.removeListener("end",h),"Request"==u.constructor.name&&u.on("error",o)}function h(e){if(s.connected=!1,d(),s.emit("disconnect",e),s.reconnect)try{c.backoff()}catch(e){}}function p(){c.reset(),s.connected=!0,n&&u.removeListener("connect",n),s.emit("connect",u)}}return c.on("ready",u),s.connect=s.listen=function(){return this.reconnect=!0,c.reset(),a=[].slice.call(arguments),u(0,0),s},s.end=s.disconnect=function(){return s.reconnect=!1,s._connection&&s._connection.end(),s.emit("disconnect"),s},s}}},{backoff:17,events:37}],106:[function(e,t,n){"use strict";var r=e("sdp");function i(e,t,n,i,o){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":o||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var c="msid:"+(i?i.id:"-")+" "+a+"\r\n";s+="a="+c,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),s=r(t.parameters.apt,i);return o&&s&&o.name.toLowerCase()===s.name.toLowerCase()};return e.codecs.forEach(function(r){for(var o=0;o<t.codecs.length;o++){var s=t.codecs[o];if(r.name.toLowerCase()===s.name.toLowerCase()&&r.clockRate===s.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&s.parameters.apt&&!i(r,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(r.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function s(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function a(e,t){var n=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});return n||e.addRemoteCandidate(t),!n}function c(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}t.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function l(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout(function(){t._dispatchEvent("track",o)})}var u=function(n){var i=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){i[e]=o[e].bind(o)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}})}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var s=n.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(u.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(u.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),u.prototype.onicecandidate=null,u.prototype.onaddstream=null,u.prototype.ontrack=null,u.prototype.onremovestream=null,u.prototype.onsignalingstatechange=null,u.prototype.oniceconnectionstatechange=null,u.prototype.onconnectionstatechange=null,u.prototype.onicegatheringstatechange=null,u.prototype.onnegotiationneeded=null,u.prototype.ondatachannel=null,u.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},u.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},u.prototype.getConfiguration=function(){return this._config},u.prototype.getLocalStreams=function(){return this.localStreams},u.prototype.getRemoteStreams=function(){return this.remoteStreams},u.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},u.prototype.addTrack=function(t,n){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find(function(e){return e.track===t}))throw c("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},u.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach(function(t){n.addTrack(t,e)});else{var r=e.clone();e.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)})}},u.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find(function(e){return e.rtpSender===t});if(!n)throw c("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map(function(e){return e.stream}).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},u.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var n=t.getSenders().find(function(t){return t.track===e});n&&t.removeTrack(n)})},u.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},u.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},u.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},u.prototype._gather=function(t,n){var i=this,o=this.transceivers[n].iceGatherer;if(!o.onlocalcandidate){var s=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,c=!a||0===Object.keys(a).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),a.component=1,a.ufrag=o.getLocalParameters().usernameFragment;var l=r.writeCandidate(a);s.candidate=Object.assign(s.candidate,r.parseCandidate(l)),s.candidate.candidate=l,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var u=r.getMediaSections(i._localDescription.sdp);u[s.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=r.getDescription(i._localDescription.sdp)+u.join("");var d=i.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",s),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout(function(){s.forEach(function(e){o.onlocalcandidate(e)})},0)}},u.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},u.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},u.prototype._transceive=function(e,n,i){var s=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(s.encodings=e.sendEncodingParameters,s.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(s.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(s)),i&&e.rtpReceiver&&s.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach(function(e){delete e.rtx}),e.recvEncodingParameters.length?s.encodings=e.recvEncodingParameters:s.encodings=[{}],s.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(s.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(s.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(s))},u.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!s("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=r.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n}),i.transceivers.forEach(function(e,t){i._gather(e.mid,t)});else if("answer"===e.type){t=r.splitSections(i._remoteDescription.sdp),n=t.shift();var a=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var s=i.transceivers[t],c=s.iceGatherer,l=s.iceTransport,u=s.dtlsTransport,d=s.localCapabilities,h=s.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var p=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);a&&(f.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===l.state&&l.start(c,p,a?"controlling":"controlled"),"new"===u.state&&u.start(f));var m=o(d,h);i._transceive(s,m.codecs.length>0,!1)}})}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},u.prototype.setRemoteDescription=function(i){var u=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!s("setRemoteDescription",i.type,u.signalingState)||u._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+u.signalingState));var d={};u.remoteStreams.forEach(function(e){d[e.id]=e});var h=[],p=r.splitSections(i.sdp),f=p.shift(),m=r.matchPrefix(f,"a=ice-lite").length>0,g=r.matchPrefix(f,"a=group:BUNDLE ").length>0;u.usingBundle=g;var v=r.matchPrefix(f,"a=ice-options:")[0];return u.canTrickleIceCandidates=!!v&&v.substr(14).split(" ").indexOf("trickle")>=0,p.forEach(function(s,c){var l=r.splitLines(s),p=r.getKind(s),v=r.isRejected(s)&&0===r.matchPrefix(s,"a=bundle-only").length,y=l[0].substr(2).split(" ")[2],b=r.getDirection(s,f),S=r.parseMsid(s),_=r.getMid(s)||r.generateIdentifier();if(v||"application"===p&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))u.transceivers[c]={mid:_,kind:p,protocol:y,rejected:!0};else{var C,w,T,E,x,R,k,I,N;!v&&u.transceivers[c]&&u.transceivers[c].rejected&&(u.transceivers[c]=u._createTransceiver(p,!0));var D,A,O=r.parseRtpParameters(s);v||(D=r.getIceParameters(s,f),(A=r.getDtlsParameters(s,f)).role="client"),k=r.parseRtpEncodingParameters(s);var L=r.parseRtcpParameters(s),P=r.matchPrefix(s,"a=end-of-candidates",f).length>0,M=r.matchPrefix(s,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return 1===e.component});if(("offer"===i.type||"answer"===i.type)&&!v&&g&&c>0&&u.transceivers[c]&&(u._disposeIceAndDtlsTransports(c),u.transceivers[c].iceGatherer=u.transceivers[0].iceGatherer,u.transceivers[c].iceTransport=u.transceivers[0].iceTransport,u.transceivers[c].dtlsTransport=u.transceivers[0].dtlsTransport,u.transceivers[c].rtpSender&&u.transceivers[c].rtpSender.setTransport(u.transceivers[0].dtlsTransport),u.transceivers[c].rtpReceiver&&u.transceivers[c].rtpReceiver.setTransport(u.transceivers[0].dtlsTransport)),"offer"!==i.type||v){if("answer"===i.type&&!v){w=(C=u.transceivers[c]).iceGatherer,T=C.iceTransport,E=C.dtlsTransport,x=C.rtpReceiver,R=C.sendEncodingParameters,I=C.localCapabilities,u.transceivers[c].recvEncodingParameters=k,u.transceivers[c].remoteCapabilities=O,u.transceivers[c].rtcpParameters=L,M.length&&"new"===T.state&&(!m&&!P||g&&0!==c?M.forEach(function(e){a(C.iceTransport,e)}):T.setRemoteCandidates(M)),g&&0!==c||("new"===T.state&&T.start(w,D,"controlling"),"new"===E.state&&E.start(A)),!o(C.localCapabilities,C.remoteCapabilities).codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&C.sendEncodingParameters[0].rtx&&delete C.sendEncodingParameters[0].rtx,u._transceive(C,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!x||"sendrecv"!==b&&"sendonly"!==b?delete C.rtpReceiver:(N=x.track,S?(d[S.stream]||(d[S.stream]=new e.MediaStream),n(N,d[S.stream]),h.push([N,x,d[S.stream]])):(d.default||(d.default=new e.MediaStream),n(N,d.default),h.push([N,x,d.default])))}}else{(C=u.transceivers[c]||u._createTransceiver(p)).mid=_,C.iceGatherer||(C.iceGatherer=u._createIceGatherer(c,g)),M.length&&"new"===C.iceTransport.state&&(!P||g&&0!==c?M.forEach(function(e){a(C.iceTransport,e)}):C.iceTransport.setRemoteCandidates(M)),I=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(I.codecs=I.codecs.filter(function(e){return"rtx"!==e.name})),R=C.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,q=!1;if("sendrecv"===b||"sendonly"===b){if(q=!C.rtpReceiver,x=C.rtpReceiver||new e.RTCRtpReceiver(C.dtlsTransport,p),q)N=x.track,S&&"-"===S.stream||(S?(d[S.stream]||(d[S.stream]=new e.MediaStream,Object.defineProperty(d[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(N,"id",{get:function(){return S.track}}),j=d[S.stream]):(d.default||(d.default=new e.MediaStream),j=d.default)),j&&(n(N,j),C.associatedRemoteMediaStreams.push(j)),h.push([N,x,j])}else C.rtpReceiver&&C.rtpReceiver.track&&(C.associatedRemoteMediaStreams.forEach(function(t){var n,r,i=t.getTracks().find(function(e){return e.id===C.rtpReceiver.track.id});i&&(n=i,(r=t).removeTrack(n),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:n})))}),C.associatedRemoteMediaStreams=[]);C.localCapabilities=I,C.remoteCapabilities=O,C.rtpReceiver=x,C.rtcpParameters=L,C.sendEncodingParameters=R,C.recvEncodingParameters=k,u._transceive(u.transceivers[c],!1,q)}}}),void 0===u._dtlsRole&&(u._dtlsRole="offer"===i.type?"active":"passive"),u._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?u._updateSignalingState("have-remote-offer"):u._updateSignalingState("stable"),Object.keys(d).forEach(function(t){var n=d[t];if(n.getTracks().length){if(-1===u.remoteStreams.indexOf(n)){u.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout(function(){u._dispatchEvent("addstream",r)})}h.forEach(function(e){var t=e[0],r=e[1];n.id===e[2].id&&l(u,t,r,[n])})}}),h.forEach(function(e){e[2]||l(u,e[0],e[1],[])}),e.setTimeout(function(){u&&u.transceivers&&u.transceivers.forEach(function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},u.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},u.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},u.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0))},u.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++}),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},u.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},u.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter(function(e){return"audio"===e.kind}).length,s=n.transceivers.filter(function(e){return"video"===e.kind}).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(o=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(s=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach(function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--s<0&&(e.wantReceive=!1)});o>0||s>0;)o>0&&(n._createTransceiver("audio"),o--),s>0&&(n._createTransceiver("video"),s--);var l=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach(function(i,o){var s=i.track,a=i.kind,c=i.mid||r.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(o,n.usingBundle));var l=e.RTCRtpSender.getCapabilities(a);t<15019&&(l.codecs=l.codecs.filter(function(e){return"rtx"!==e.name})),l.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach(function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)})}),l.headerExtensions.forEach(function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach(function(t){e.uri===t.uri&&(e.id=t.id)})});var u=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];s&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=l,i.sendEncodingParameters=u}),"max-compat"!==n._config.bundlePolicy&&(l+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),l+="a=ice-options:trickle\r\n",n.transceivers.forEach(function(e,t){l+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),l+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1,l+="a="+r.writeCandidate(e)+"\r\n"}),"completed"===e.iceGatherer.state&&(l+="a=end-of-candidates\r\n"))});var u=new e.RTCSessionDescription({type:"offer",sdp:l});return Promise.resolve(u)},u.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var s=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(s+="a=group:BUNDLE "+n.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n";var a=r.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach(function(e,r){if(!(r+1>a)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?s+="m=application 0 DTLS/SCTP 5000\r\n":s+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?s+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(s+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(s+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var l=o(e.localCapabilities,e.remoteCapabilities);!l.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,s+=i(e,l,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(s+="a=rtcp-rsize\r\n")}});var l=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(l)},u.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(i,o){if(!n._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var l=0;l<n.transceivers.length;l++)if(n.transceivers[l].mid===e.sdpMid){s=l;break}var u=n.transceivers[s];if(!u)return o(c("OperationError","Can not add ICE candidate"));if(u.rejected)return i();var d=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===d.protocol&&(0===d.port||9===d.port))return i();if(d.component&&1!==d.component)return i();if((0===s||s>0&&u.iceTransport!==n.transceivers[0].iceTransport)&&!a(u.iceTransport,d))return o(c("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n._remoteDescription.sdp))[s]+="a="+(d.type?h:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),(t=r.getMediaSections(n._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);i()})},u.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach(function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)}),!n)throw c("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){e[t]&&r.push(e[t].getStats())})}),Promise.all(r).then(function(e){var t=new Map;return e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})}),t})};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then(function(e){var t=new Map;return Object.keys(e).forEach(function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])}),t})}}});var d=["createOffer","createAnswer"];return d.forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then(function(t){"function"==typeof e[0]&&e[0].apply(null,[t])},function(t){"function"==typeof e[1]&&e[1].apply(null,[t])}):t.apply(this,arguments)}}),(d=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)},function(t){"function"==typeof e[2]&&e[2].apply(null,[t])}):t.apply(this,arguments)}}),["getStats"].forEach(function(e){var t=u.prototype[e];u.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then(function(){"function"==typeof e[1]&&e[1].apply(null)}):t.apply(this,arguments)}}),u}},{sdp:108}],107:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,n),n.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:27}],108:[function(e,t,n){"use strict";var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.getDescription=function(e){var t=r.splitSections(e);return t&&t[0]},r.getMediaSections=function(e){var t=r.splitSections(e);return t.shift(),t},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},r.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},r.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?r.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},r.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},r.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},r.getCryptoParameters=function(e,t){return r.matchPrefix(e+t,"a=crypto:").map(r.parseCryptoLine)},r.getIceParameters=function(e,t){var n=r.matchPrefix(e+t,"a=ice-ufrag:")[0],i=r.matchPrefix(e+t,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substr(12),password:i.substr(10)}:null},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],s=r.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var a=r.parseRtpMap(s),c=r.matchPrefix(e,"a=fmtp:"+o+" ");switch(a.parameters=c.length?r.parseFmtp(c[0]):{},a.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(r.parseRtcpFb),t.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(a.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=a.length>0&&a[0].ssrc,l=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});l.length>0&&l[0].length>1&&l[0][0]===c&&(t=l[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(r.rtx={ssrc:t}),n.push(r),o&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var u=r.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,n.forEach(function(e){e.maxBitrate=u})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=r.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.parseSctpDescription=function(e){var t,n=r.parseMLine(e),i=r.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var o=r.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:n.fmt,maxMessageSize:t};if(r.matchPrefix(e,"a=sctpmap:").length>0){var s=r.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:t}}},r.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},r.generateSessionId=function(){return Math.random().toString().substr(2,21)},r.writeSessionBoilerplate=function(e,t,n){var i=void 0!==t?t:2;return"v=0\r\no="+(n||"thisisadapterortc")+" "+(e||r.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var o=r.writeRtpDescription(e.kind,t);if(o+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),o},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},r.parseMLine=function(e){var t=r.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},r.parseOLine=function(e){var t=r.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},r.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=r.splitLines(e),n=0;n<t.length;n++)if(t[n].length<2||"="!==t[n].charAt(1))return!1;return!0},"object"==typeof t&&(t.exports=r)},{}],109:[function(e,t,n){t.exports=i;var r=e("events").EventEmitter;function i(){r.call(this)}e("inherits")(i,r),i.Readable=e("readable-stream/readable.js"),i.Writable=e("readable-stream/writable.js"),i.Duplex=e("readable-stream/duplex.js"),i.Transform=e("readable-stream/transform.js"),i.PassThrough=e("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function o(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(n.on("end",a),n.on("close",c));var s=!1;function a(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){n.removeListener("data",i),e.removeListener("drain",o),n.removeListener("end",a),n.removeListener("close",c),n.removeListener("error",l),e.removeListener("error",l),n.removeListener("end",u),n.removeListener("close",u),e.removeListener("close",u)}return n.on("error",l),e.on("error",l),n.on("end",u),n.on("close",u),e.on("close",u),e.emit("pipe",n),e}},{events:37,inherits:41,"readable-stream/duplex.js":90,"readable-stream/passthrough.js":101,"readable-stream/readable.js":102,"readable-stream/transform.js":103,"readable-stream/writable.js":104}],110:[function(e,t,n){var r;r=this,function(t){"use strict";const n=function(){if(void 0===globalThis.WebSocket)try{return e("ws")}catch(e){throw new Error('You must install the "ws" package to use Strophe in nodejs.')}return globalThis.WebSocket}(),r=function(){let t=globalThis.DOMParser;if(void 0===t)try{t=e("@xmldom/xmldom").DOMParser}catch(e){throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.')}return t}();function i(){if("undefined"==typeof document)try{return(new(0,e("@xmldom/xmldom").DOMImplementation)).createDocument("jabber:client","strophe",null)}catch(e){throw new Error('You must install the "@xmldom/xmldom" package to use Strophe in nodejs.')}return document.implementation.createDocument("jabber:client","strophe",null)}const o={HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},s={tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"]},a={ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8,REDIRECT:9,CONNTIMEOUT:10,BINDREQUIRED:11,ATTACHFAIL:12,RECONNECTING:13},c={NORMAL:1,TEXT:3,CDATA:4,FRAGMENT:11};function l(e,t){return new p(e,t)}function u(e){return new p("message",e)}function d(e){return new p("iq",e)}function h(e){return new p("presence",e)}class p{constructor(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=o.CLIENT:t||(t={xmlns:o.CLIENT})),this.nodeTree=w(e,t),this.node=this.nodeTree}tree(){return this.nodeTree}toString(){return N(this.nodeTree)}up(){return this.node=this.node.parentElement,this}root(){return this.node=this.nodeTree,this}attrs(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null!=e[t]?this.node.setAttribute(t,e[t].toString()):this.node.removeAttribute(t));return this}c(e,t,n){const r=w(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this}cnode(e){let t;const n=_();try{t=void 0!==n.importNode}catch(e){t=!1}const r=t?n.importNode(e,!0):k(e);return this.node.appendChild(r),this.node=r,this}t(e){const t=C(e);return this.node.appendChild(t),this}h(e){const t=_().createElement("body");t.innerHTML=e;const n=R(t);for(;n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}}function f(e){let t="";const n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=0&&n<=127?t+=e.charAt(r):n>2047?(t+=String.fromCharCode(224|n>>12&15),t+=String.fromCharCode(128|n>>6&63),t+=String.fromCharCode(128|n>>0&63)):(t+=String.fromCharCode(192|n>>6&31),t+=String.fromCharCode(128|n>>0&63))}return t}function m(e,t){const n=new Uint8Array(e),r=new Uint8Array(t),i=new Uint8Array(e.byteLength);for(let t=0;t<e.byteLength;t++)i[t]=n[t]^r[t];return i.buffer}function g(e){let t="";const n=new Uint8Array(e),r=n.byteLength;for(let e=0;e<r;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function v(e){var t;return null===(t=Uint8Array.from(atob(e),e=>e.charCodeAt(0)))||void 0===t?void 0:t.buffer}function y(e){return(new TextEncoder).encode(e).buffer}function b(e){"undefined"==typeof document&&V.log(V.LogLevel.ERROR,"addCookies: not adding any cookies, since there's no document object"),e=e||{};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n="",r="",i="";const o=e[t],s="object"==typeof o,a=escape(unescape(s?o.value:o));s&&(n=o.expires?";expires="+o.expires:"",r=o.domain?";domain="+o.domain:"",i=o.path?";path="+o.path:""),document.cookie=t+"="+a+n+r+i}}let S=null;function _(){return S||(S=i()),S}function C(e){return _().createTextNode(e)}function w(e,t,n){if(!e)return null;const r=_().createElement(e);if(!n||"string"!=typeof n&&"number"!=typeof n){if("string"==typeof t||"number"==typeof t)return r.appendChild(C(t.toString())),r;if(!t)return r}else r.appendChild(C(n.toString()));if(Array.isArray(t))for(const e of t)Array.isArray(e)&&null!=e[0]&&null!=e[1]&&r.setAttribute(e[0],e[1]);else if("object"==typeof t)for(const e of Object.keys(t))e&&null!=t[e]&&r.setAttribute(e,t[e].toString());return r}function T(e){for(let t=0;t<s.tags.length;t++)if(e===s.tags[t])return!0;return!1}function E(e,t){const n=s.attributes[e];if((null==n?void 0:n.length)>0)for(let e=0;e<n.length;e++)if(t===n[e])return!0;return!1}function x(e){for(let t=0;t<s.css.length;t++)if(e===s.css[t])return!0;return!1}function R(e){if(e.nodeType===c.NORMAL)return function(e){let t;const n=e.nodeName.toLowerCase();if(T(n))try{if(t=w(n),n in s.attributes){const i=s.attributes[n];for(let n=0;n<i.length;n++){const o=i[n];let s=e.getAttribute(o);var r;if(null!=s&&""!==s)if("style"===o&&"object"==typeof s&&(s=null!==(r=s.cssText)&&void 0!==r?r:s),"style"===o){const e=[],n=s.split(";");for(let t=0;t<n.length;t++){const r=n[t].split(":"),i=r[0].replace(/^\s*/,"").replace(/\s*$/,"").toLowerCase();if(x(i)){const t=r[1].replace(/^\s*/,"").replace(/\s*$/,"");e.push(i+": "+t)}}e.length>0&&(s=e.join("; "),t.setAttribute(o,s))}else t.setAttribute(o,s)}for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]))}}catch(e){t=C("")}else{t=_().createDocumentFragment();for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]))}return t}(e);if(e.nodeType===c.FRAGMENT){const t=_().createDocumentFragment();for(let n=0;n<e.childNodes.length;n++)t.appendChild(R(e.childNodes[n]));return t}return e.nodeType===c.TEXT?C(e.nodeValue):void 0}function k(e){let t;if(e.nodeType===c.NORMAL){const n=e;t=w(n.tagName);for(let e=0;e<n.attributes.length;e++)t.setAttribute(n.attributes[e].nodeName,n.attributes[e].value);for(let e=0;e<n.childNodes.length;e++)t.appendChild(k(n.childNodes[e]))}else e.nodeType===c.TEXT&&(t=_().createTextNode(e.nodeValue));return t}function I(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&amp;")).replace(/</g,"&lt;")).replace(/>/g,"&gt;")).replace(/'/g,"&apos;")).replace(/"/g,"&quot;")}function N(e){if(!e)return null;const t=e instanceof p?e.tree():e,n=[...Array(t.attributes.length).keys()].map(e=>t.attributes[e].nodeName);n.sort();let r=n.reduce((e,n)=>`${e} ${n}="${I(t.attributes.getNamedItem(n).value)}"`,`<${t.nodeName}`);if(t.childNodes.length>0){r+=">";for(let e=0;e<t.childNodes.length;e++){const n=t.childNodes[e];switch(n.nodeType){case c.NORMAL:r+=N(n);break;case c.TEXT:r+=I(n.nodeValue);break;case c.CDATA:r+="<![CDATA["+n.nodeValue+"]]>"}}r+="</"+t.nodeName+">"}else r+="/>";return r}function D(e,t,n){for(let r=0;r<e.childNodes.length;r++){const i=e.childNodes[r];i.nodeType!==c.NORMAL||t&&!this.isTagEqual(i,t)||n(i)}}function A(e){var t;if(!e)return null;let n="";null!==(t=e.childNodes)&&void 0!==t&&t.length||e.nodeType!==c.TEXT||(n+=e.nodeValue);for(let t=0;null!==(r=t<(null===(i=e.childNodes)||void 0===i?void 0:i.length))&&void 0!==r&&r;t++){var r,i;e.childNodes[t].nodeType===c.TEXT&&(n+=e.childNodes[t].nodeValue)}return I(n)}function O(e){return e?e.split("/")[0]:null}const L={utf16to8:f,xorArrayBuffers:m,arrayBufToBase64:g,base64ToArrayBuf:v,stringToArrayBuf:y,addCookies:b};class P{constructor(e,t,n,r,i,o,s){this.handler=e,this.ns=t,this.name=n,this.type=r,this.id=i,this.options=s||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBareFromJid?this.from=o?O(o):null:this.from=o,this.user=!0}getNamespace(e){let t=e.getAttribute("xmlns");return t&&this.options.ignoreNamespaceFragment&&(t=t.split("#")[0]),t}namespaceMatch(e){let t=!1;return!this.ns||(D(e,null,e=>{this.getNamespace(e)===this.ns&&(t=!0)}),t||this.getNamespace(e)===this.ns)}isMatch(e){let t=e.getAttribute("from");this.options.matchBareFromJid&&(t=O(t));const n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!V.isTagEqual(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(n):n!==this.type)||this.id&&e.getAttribute("id")!==this.id||this.from&&t!==this.from)}run(e){let t=null;try{t=this.handler(e)}catch(e){throw V._handleError(e),e}return t}toString(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}}class M{constructor(e,t){this.period=e,this.handler=t,this.lastCalled=(new Date).getTime(),this.user=!0}run(){return this.lastCalled=(new Date).getTime(),this.handler()}reset(){this.lastCalled=(new Date).getTime()}toString(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}}const j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function q(e){const t=j.indexOf(e);return t<0?void 0:t}const B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function U(e){if(e>=0&&e<64)return B[e]}var F={atob:function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");if((e=(e=`${e}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;let t="",n=0,r=0;for(let i=0;i<e.length;i++)n<<=6,n|=q(e[i]),24===(r+=6)&&(t+=String.fromCharCode((16711680&n)>>16),t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n),n=r=0);return 12===r?(n>>=4,t+=String.fromCharCode(n)):18===r&&(n>>=2,t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n)),t},btoa:function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");let t;for(e=`${e}`,t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return null;let n="";for(t=0;t<e.length;t+=3){const r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(t)>>2,r[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(r[1]|=e.charCodeAt(t+1)>>4,r[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(r[2]|=e.charCodeAt(t+2)>>6,r[3]=63&e.charCodeAt(t+2));for(let e=0;e<r.length;e++)void 0===r[e]?n+="=":n+=U(r[e])}return n}};class H extends Error{constructor(e){super(e),this.name="StropheSessionError"}}class z{constructor(e,t,n){this.mechname=e,this.isClientFirst=t,this.priority=n}test(e){return!0}onStart(e){this._connection=e}onChallenge(e,t){throw new Error("You should implement challenge handling!")}clientChallenge(e){if(!this.isClientFirst)throw new Error("clientChallenge should not be called if isClientFirst is false!");return this.onChallenge(e)}onFailure(){this._connection=null}onSuccess(){this._connection=null}}const Q={async scramResponse(e,t,n,r){const i=e._sasl_data.cnonce,o=function(e){let t,n,r;const i=/([a-z]+)=([^,]+)(,|$)/;for(;e.match(i);){const o=e.match(i);switch(e=e.replace(o[0],""),o[1]){case"r":t=o[2];break;case"s":n=L.base64ToArrayBuf(o[2]);break;case"i":r=parseInt(o[2],10);break;case"m":return}}if(isNaN(r)||r<4096)V.warn("Failing SCRAM authentication because server supplied iteration count < 4096.");else{if(n)return{nonce:t,salt:n,iter:r};V.warn("Failing SCRAM authentication because server supplied incorrect salt.")}}(t);if(!o&&(null==o?void 0:o.nonce.slice(0,i.length))!==i)return V.warn("Failing SCRAM authentication because server supplied incorrect nonce."),e._sasl_data={},e._sasl_failure_cb();let s,a;const{pass:c}=e;if("string"==typeof e.pass||e.pass instanceof String){const e=await async function(e,t,n,r,i){const o=await crypto.subtle.deriveBits({name:"PBKDF2",salt:t,iterations:n,hash:{name:r}},await crypto.subtle.importKey("raw",L.stringToArrayBuf(e),"PBKDF2",!1,["deriveBits"]),i),s=await crypto.subtle.importKey("raw",o,{name:"HMAC",hash:r},!1,["sign"]);return{ck:await crypto.subtle.sign("HMAC",s,L.stringToArrayBuf("Client Key")),sk:await crypto.subtle.sign("HMAC",s,L.stringToArrayBuf("Server Key"))}}(c,o.salt,o.iter,n,r);s=e.ck,a=e.sk}else{if((null==c?void 0:c.name)!==n||(null==c?void 0:c.salt)!==L.arrayBufToBase64(o.salt)||(null==c?void 0:c.iter)!==o.iter)return e._sasl_failure_cb();{const{ck:e,sk:t}=c;s=L.base64ToArrayBuf(e),a=L.base64ToArrayBuf(t)}}const l=e._sasl_data["client-first-message-bare"],u=t,d=`c=biws,r=${o.nonce}`,h=`${l},${u},${d}`,p=await async function(e,t,n){const r=await crypto.subtle.importKey("raw",await crypto.subtle.digest(n,t),{name:"HMAC",hash:n},!1,["sign"]),i=await crypto.subtle.sign("HMAC",r,L.stringToArrayBuf(e));return L.xorArrayBuffers(t,i)}(h,s,n),f=await async function(e,t,n){const r=await crypto.subtle.importKey("raw",t,{name:"HMAC",hash:n},!1,["sign"]);return crypto.subtle.sign("HMAC",r,L.stringToArrayBuf(e))}(h,a,n);return e._sasl_data["server-signature"]=L.arrayBufToBase64(f),e._sasl_data.keys={name:n,iter:o.iter,salt:L.arrayBufToBase64(o.salt),ck:L.arrayBufToBase64(s),sk:L.arrayBufToBase64(a)},`${d},p=${L.arrayBufToBase64(p)}`},clientChallenge(e,t){const n=t||function(){const e=new Uint8Array(16);return L.arrayBufToBase64(crypto.getRandomValues(e).buffer)}(),r=`n=${e.authcid},r=${n}`;return e._sasl_data.cnonce=n,e._sasl_data["client-first-message-bare"]=r,`n,,${r}`}};class G{constructor(e){var t;this._conn=e,this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.hold=1,this.wait=60,this.window=5,this.errors=0,this.inactivity=null,this.strip=null!==(t=G.prototype.strip)&&void 0!==t&&t,this.lastResponseHeaders=null,this._requests=[]}_buildBody(){const e=l("body",{rid:this.rid++,xmlns:V.NS.HTTPBIND});return null!==this.sid&&e.attrs({sid:this.sid}),this._conn.options.keepalive&&this._conn._sessionCachingSupported()&&this._cacheSession(),e}_reset(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_connect(e,t,n){this.wait=e||this.wait,this.hold=t||this.hold,this.errors=0;const r=this._buildBody().attrs({to:this._conn.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":V.NS.BOSH});n&&r.attrs({route:n});const i=this._conn._connect_cb;this._requests.push(new V.Request(r.tree(),this._onRequestStateChange.bind(this,i.bind(this._conn)),Number(r.tree().getAttribute("rid")))),this._throttledRequestHandler()}_attach(e,t,n,r,i,o,s){this._conn.jid=e,this.sid=t,this.rid=n,this._conn.connect_callback=r,this._conn.domain=V.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=i||this.wait,this.hold=o||this.hold,this.window=s||this.window,this._conn._changeConnectStatus(V.Status.ATTACHED,null)}_restore(e,t,n,r,i){const o=JSON.parse(sessionStorage.getItem("strophe-bosh-session"));if(!(null!=o&&o.rid&&o.sid&&o.jid&&(null==e||V.getBareJidFromJid(o.jid)===V.getBareJidFromJid(e)||null===V.getNodeFromJid(e)&&V.getDomainFromJid(o.jid)===e))){const e=new Error("_restore: no restoreable session.");throw e.name="StropheSessionError",e}this._conn.restored=!0,this._attach(o.jid,o.sid,o.rid,t,n,r,i)}_cacheSession(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):sessionStorage.removeItem("strophe-bosh-session")}_connect_cb(e){const t=e.getAttribute("type");if(null!==t&&"terminate"===t){let t=e.getAttribute("condition");V.error("BOSH-Connection failed: "+t);const n=e.getElementsByTagName("conflict");return null!==t?("remote-stream-error"===t&&n.length>0&&(t="conflict"),this._conn._changeConnectStatus(V.Status.CONNFAIL,t)):this._conn._changeConnectStatus(V.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(t),V.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));const n=e.getAttribute("requests");n&&(this.window=parseInt(n,10));const r=e.getAttribute("hold");r&&(this.hold=parseInt(r,10));const i=e.getAttribute("wait");i&&(this.wait=parseInt(i,10));const o=e.getAttribute("inactivity");o&&(this.inactivity=parseInt(o,10))}_disconnect(e){this._sendTerminate(e)}_doDisconnect(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_emptyQueue(){return 0===this._requests.length}_callProtocolErrorHandlers(e){const t=G._getRequestStatus(e),n=this._conn.protocolErrorHandlers.HTTP[t];n&&n.call(this,t)}_hitError(e){this.errors++,V.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()}_no_auth_received(e){V.warn("Server did not yet offer a supported authentication mechanism. Sending a blank poll request."),e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);const t=this._buildBody();this._requests.push(new V.Request(t.tree(),this._onRequestStateChange.bind(this,e),Number(t.tree().getAttribute("rid")))),this._throttledRequestHandler()}_onDisconnectTimeout(){this._abortAllRequests()}_abortAllRequests(){for(;this._requests.length>0;){const e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}}_onIdle(){const e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(V.debug("no requests during idle cycle, sending blank request"),e.push(null)),!this._conn.paused){if(this._requests.length<2&&e.length>0){const t=this._buildBody();for(let n=0;n<e.length;n++)null!==e[n]&&("restart"===e[n]?t.attrs({to:this._conn.domain,"xml:lang":"en","xmpp:restart":"true","xmlns:xmpp":V.NS.BOSH}):t.cnode(e[n]).up());delete this._conn._data,this._conn._data=[],this._requests.push(new V.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),Number(t.tree().getAttribute("rid")))),this._throttledRequestHandler()}if(this._requests.length>0){const e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(V.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(V.TIMEOUT*this.wait)&&(V.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(V.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}}static _getRequestStatus(e,t){let n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){V.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n}_onRequestStateChange(e,t){if(V.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)return void(t.abort=!1);if(4!==t.xhr.readyState)return;const n=G._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this._conn.disconnecting&&n>=400)return this._hitError(n),void this._callProtocolErrorHandlers(t);const r=this._requests[0]===t,i=this._requests[1]===t,o=n>0&&n<500,s=t.sends>this._conn.maxRetries;(o||s)&&(this._removeRequest(t),V.debug("request id "+t.id+" should now be removed")),200===n?((i||r&&this._requests.length>0&&this._requests[0].age()>Math.floor(V.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(t.rid+1),V.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0):0===n||n>=400&&n<600||n>=12e3?(V.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),n>=400&&n<500&&(this._conn._changeConnectStatus(V.Status.DISCONNECTING,null),this._conn._doDisconnect())):V.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),o||s?s&&!this._conn.connected&&this._conn._changeConnectStatus(V.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}_processRequest(e){let t=this._requests[e];const n=G._getRequestStatus(t,-1);if(t.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();const r=t.age(),i=!isNaN(r)&&r>Math.floor(V.TIMEOUT*this.wait),o=null!==t.dead&&t.timeDead()>Math.floor(V.SECONDARY_TIMEOUT*this.wait),s=4===t.xhr.readyState&&(n<1||n>=500);if((i||o||s)&&(o&&V.error(`Request ${this._requests[e].id} timed out (secondary), restarting`),t.abort=!0,t.xhr.abort(),t.xhr.onreadystatechange=function(){},this._requests[e]=new V.Request(t.xmlData,t.origFunc,t.rid,t.sends),t=this._requests[e]),0===t.xhr.readyState){var a,c;V.debug("request id "+t.id+"."+t.sends+" posting");try{const e=this._conn.options.contentType||"text/xml; charset=utf-8";t.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==t.xhr.setRequestHeader&&t.xhr.setRequestHeader("Content-Type",e),this._conn.options.withCredentials&&(t.xhr.withCredentials=!0)}catch(e){return V.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(V.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}const e=()=>{if(t.date=(new Date).valueOf(),this._conn.options.customHeaders){const e=this._conn.options.customHeaders;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.xhr.setRequestHeader(n,e[n])}t.xhr.send(t.data)};if(t.sends>1){const n=1e3*Math.min(Math.floor(V.TIMEOUT*this.wait),Math.pow(t.sends,3));setTimeout(function(){e()},n)}else e();var l,u,d,h;if(t.sends++,this.strip&&"body"===t.xmlData.nodeName&&t.xmlData.childNodes.length)null===(l=(u=this._conn).xmlOutput)||void 0===l||l.call(u,t.xmlData.children[0]);else null===(d=(h=this._conn).xmlOutput)||void 0===d||d.call(h,t.xmlData);null===(a=(c=this._conn).rawOutput)||void 0===a||a.call(c,t.data)}else V.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+t.xhr.readyState)}_removeRequest(e){V.debug("removing request");for(let t=this._requests.length-1;t>=0;t--)e===this._requests[t]&&this._requests.splice(t,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()}_restartRequest(e){const t=this._requests[e];null===t.dead&&(t.dead=new Date),this._processRequest(e)}_reqToData(e){try{return e.getResponse()}catch(e){if("parsererror"!==e.message)throw e;this._conn.disconnect("strophe-parsererror")}}_sendTerminate(e){V.debug("_sendTerminate was called");const t=this._buildBody().attrs({type:"terminate"}),n=e instanceof p?e.tree():e;e&&t.cnode(n);const r=new V.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),Number(t.tree().getAttribute("rid")));this._requests.push(r),this._throttledRequestHandler()}_send(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout(()=>this._conn._onIdle(),100)}_sendRestart(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)}_throttledRequestHandler(){this._requests?V.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):V.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)<this.window&&this._processRequest(1))}}class J{constructor(e){this._conn=e,this.strip="wrapper";const t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){let n="";"ws"===e.options.protocol&&"https:"!==location.protocol?n+="ws":n+="wss",n+="://"+location.host,0!==t.indexOf("/")?n+=location.pathname+t:n+=t,e.service=n}}_buildStream(){return l("open",{xmlns:V.NS.FRAMING,to:this._conn.domain,version:"1.0"})}_checkStreamError(e,t){let n;if(0===(n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(V.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;const r=n[0];let i="",o="";for(let e=0;e<r.childNodes.length;e++){const t=r.children[e];if("urn:ietf:params:xml:ns:xmpp-streams"!==t.getAttribute("xmlns"))break;"text"===t.nodeName?o=t.textContent:i=t.nodeName}let s="WebSocket stream error: ";return s+=i||"unknown",o&&(s+=" - "+o),V.error(s),this._conn._changeConnectStatus(t,i),this._conn._doDisconnect(),!0}_reset(){}_connect(){this._closeSocket(),this.socket=new n(this._conn.service,"xmpp"),this.socket.onopen=(()=>this._onOpen()),this.socket.onerror=(e=>this._onError(e)),this.socket.onclose=(e=>this._onClose(e)),this.socket.onmessage=(e=>this._onInitialMessage(e))}_connect_cb(e){if(this._checkStreamError(e,V.Status.CONNFAIL))return V.Status.CONNFAIL}_handleStreamStart(e){let t=null;const n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in <open />":n!==V.NS.FRAMING&&(t="Wrong xmlns in <open />: "+n);const r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in <open />":"1.0"!==r&&(t="Wrong version in <open />: "+r),!t||(this._conn._changeConnectStatus(V.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)}_onInitialMessage(e){if(0===e.data.indexOf("<open ")||0===e.data.indexOf("<?xml")){const t=e.data.replace(/^(<\?.*?\?>\s*)*/,"");if(""===t)return;const n=(new r).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf("<close ")){const t=(new r).parseFromString(e.data,"text/xml").documentElement;this._conn.xmlInput(t),this._conn.rawInput(e.data);const n=t.getAttribute("see-other-uri");if(n){const e=this._conn.service;(e.indexOf("wss:")>=0&&n.indexOf("wss:")>=0||e.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus(V.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=n,this._connect())}else this._conn._changeConnectStatus(V.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{this._replaceMessageHandler();const t=this._streamWrap(e.data),n=(new r).parseFromString(t,"text/xml").documentElement;this._conn._connect_cb(n,null,e.data)}}_replaceMessageHandler(){this.socket.onmessage=(e=>this._onMessage(e))}_disconnect(e){if(this.socket&&this.socket.readyState!==n.CLOSED){e&&this._conn.send(e);const t=l("close",{xmlns:V.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=V.serialize(t);this._conn.rawOutput(n);try{this.socket.send(n)}catch(e){V.warn("Couldn't send <close /> tag.")}}setTimeout(()=>this._conn._doDisconnect(),0)}_doDisconnect(){V.debug("WebSockets _doDisconnect was called"),this._closeSocket()}_streamWrap(e){return"<wrapper>"+e+"</wrapper>"}_closeSocket(){if(this.socket)try{this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close()}catch(e){V.debug(e.message)}this.socket=null}_emptyQueue(){return!0}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(V.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(V.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(V.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):V.debug("Websocket closed")}_no_auth_received(e){V.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus(V.Status.CONNFAIL,V.ErrorCondition.NO_AUTH_MECH),null==e||e.call(this._conn),this._conn._doDisconnect()}_onDisconnectTimeout(){}_abortAllRequests(){}_onError(e){V.error("Websocket error "+JSON.stringify(e)),this._conn._changeConnectStatus(V.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()}_onIdle(){const e=this._conn._data;if(e.length>0&&!this._conn.paused){for(let t=0;t<e.length;t++)if(null!==e[t]){const n="restart"===e[t]?this._buildStream().tree():e[t];if("restart"===n)throw new Error("Wrong type for stanza");const r=V.serialize(n);this._conn.xmlOutput(n),this._conn.rawOutput(r),this.socket.send(r)}this._conn._data=[]}}_onMessage(e){let t;const n='<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';if(e.data===n)return this._conn.rawInput(n),this._conn.xmlInput(e),void(this._conn.disconnecting||this._conn._doDisconnect());if(0===e.data.search("<open ")){if(t=(new r).parseFromString(e.data,"text/xml").documentElement,!this._handleStreamStart(t))return}else{const n=this._streamWrap(e.data);t=(new r).parseFromString(n,"text/xml").documentElement}return this._checkStreamError(t,V.Status.ERROR)?void 0:this._conn.disconnecting&&"presence"===t.firstElementChild.nodeName&&"unavailable"===t.firstElementChild.getAttribute("type")?(this._conn.xmlInput(t),void this._conn.rawInput(V.serialize(t))):void this._conn._dataRecv(t,e.data)}_onOpen(){V.debug("Websocket open");const e=this._buildStream();this._conn.xmlOutput(e.tree());const t=V.serialize(e);this._conn.rawOutput(t),this.socket.send(t)}_send(){this._conn.flush()}_sendRestart(){clearTimeout(this._conn._idleTimeout),this._conn._onIdle.bind(this._conn)()}}const V={VERSION:"1.6.1",TIMEOUT:1.1,SECONDARY_TIMEOUT:.1,shims:Object.freeze({__proto__:null,WebSocket:n,DOMParser:r,getDummyXMLDOMDocument:i}),Request:class{constructor(e,t,n,r=0){this.id=++V._requestId,this.xmlData=e,this.data=V.serialize(e),this.origFunc=t,this.func=t,this.rid=n,this.date=NaN,this.sends=r,this.abort=!1,this.dead=null,this.age=(()=>this.date?((new Date).valueOf()-this.date.valueOf())/1e3:0),this.timeDead=(()=>this.dead?((new Date).valueOf()-this.dead.valueOf())/1e3:0),this.xhr=this._newXHR()}getResponse(){var e;let t=null===(e=this.xhr.responseXML)||void 0===e?void 0:e.documentElement;if(t){if("parsererror"===t.tagName)throw V.error("invalid response received"),V.error("responseText: "+this.xhr.responseText),V.error("responseXML: "+V.serialize(t)),new Error("parsererror")}else if(this.xhr.responseText){var n;V.debug("Got responseText but no responseXML; attempting to parse it with DOMParser...");const e=null===(n=t=(new r).parseFromString(this.xhr.responseText,"application/xml").documentElement)||void 0===n?void 0:n.querySelector("parsererror");if(!t||e){e&&(V.error("invalid response received: "+e.textContent),V.error("responseText: "+this.xhr.responseText));const t=new Error;throw t.name=V.ErrorCondition.BAD_FORMAT,t}}return t}_newXHR(){const e=new XMLHttpRequest;return e.overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8"),e.onreadystatechange=this.func.bind(null,this),e}},Bosh:G,Websocket:J,WorkerWebsocket:class extends J{constructor(e){super(e),this._conn=e,this.worker=new SharedWorker(this._conn.options.worker,"Strophe XMPP Connection"),this.worker.onerror=(e=>{var t;null===(t=console)||void 0===t||t.error(e),V.log(V.LogLevel.ERROR,`Shared Worker Error: ${e}`)})}_setSocket(){this.socket={send:e=>this.worker.port.postMessage(["send",e]),close:()=>this.worker.port.postMessage(["_closeSocket"]),onopen:()=>{},onerror:e=>this._onError(e),onclose:e=>this._onClose(e),onmessage:()=>{},readyState:null}}_connect(){this._setSocket(),this._messageHandler=(e=>this._onInitialMessage(e)),this.worker.port.start(),this.worker.port.onmessage=(e=>this._onWorkerMessage(e)),this.worker.port.postMessage(["_connect",this._conn.service,this._conn.jid])}_attach(e){this._setSocket(),this._messageHandler=(e=>this._onMessage(e)),this._conn.connect_callback=e,this.worker.port.start(),this.worker.port.onmessage=(e=>this._onWorkerMessage(e)),this.worker.port.postMessage(["_attach",this._conn.service])}_attachCallback(e,t){e===V.Status.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus(V.Status.ATTACHED)):e===V.Status.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus(V.Status.ATTACHFAIL))}_disconnect(e){e&&this._conn.send(e);const t=l("close",{xmlns:V.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=V.serialize(t);this._conn.rawOutput(n),this.worker.port.postMessage(["send",n]),this._conn._doDisconnect()}_closeSocket(){this.socket.close()}_replaceMessageHandler(){this._messageHandler=(e=>this._onMessage(e))}_onWorkerMessage(e){const t={};t.debug=V.LogLevel.DEBUG,t.info=V.LogLevel.INFO,t.warn=V.LogLevel.WARN,t.error=V.LogLevel.ERROR,t.fatal=V.LogLevel.FATAL;const{data:n}=e,r=n[0];if("_onMessage"===r)this._messageHandler(n[1]);else if(r in this)try{this[r].apply(this,e.data.slice(1))}catch(e){V.log(V.LogLevel.ERROR,e)}else if("log"===r){const e=n[1],r=n[2];V.log(t[e],r)}else V.log(V.LogLevel.ERROR,`Found unhandled service worker message: ${n}`)}},SASLAnonymous:class extends z{constructor(e="ANONYMOUS",t=!1,n=20){super(e,t,n)}test(e){return null===e.authcid}},SASLPlain:class extends z{constructor(e="PLAIN",t=!0,n=50){super(e,t,n)}test(e){return null!==e.authcid}onChallenge(e){const{authcid:t,authzid:n,domain:r,pass:i}=e;if(!r)throw new Error("SASLPlain onChallenge: domain is not defined!");let o=n!==`${t}@${r}`?n:"";return o+="\0",o+=t,o+="\0",o+=i,L.utf16to8(o)}},SASLSHA1:class extends z{constructor(e="SCRAM-SHA-1",t=!0,n=60){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-1",160)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA256:class extends z{constructor(e="SCRAM-SHA-256",t=!0,n=70){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-256",256)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA384:class extends z{constructor(e="SCRAM-SHA-384",t=!0,n=71){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-384",384)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLSHA512:class extends z{constructor(e="SCRAM-SHA-512",t=!0,n=72){super(e,t,n)}test(e){return null!==e.authcid}async onChallenge(e,t){return await Q.scramResponse(e,t,"SHA-512",512)}clientChallenge(e,t){return Q.clientChallenge(e,t)}},SASLOAuthBearer:class extends z{constructor(e="OAUTHBEARER",t=!0,n=40){super(e,t,n)}test(e){return null!==e.pass}onChallenge(e){let t="n,";return null!==e.authcid&&(t=t+"a="+e.authzid),t+=",",t+="",t+="auth=Bearer ",t+=e.pass,t+="",t+="",L.utf16to8(t)}},SASLExternal:class extends z{constructor(e="EXTERNAL",t=!0,n=10){super(e,t,n)}onChallenge(e){return e.authcid===e.authzid?"":e.authzid}},SASLXOAuth2:class extends z{constructor(e="X-OAUTH2",t=!0,n=30){super(e,t,n)}test(e){return null!==e.pass}onChallenge(e){let t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,L.utf16to8(t)}},Builder:p,Connection:class{constructor(e,t={}){this.service=e,this.options=t,this.setProtocol(),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_bind=!1,this.do_session=!1,this.mechanisms={},this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.protocolErrorHandlers={HTTP:{},websocket:{}},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout(()=>this._onIdle(),100),b(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),this.iqFallbackHandler=new P(e=>this.send(d({type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("service-unavailable",{xmlns:V.NS.STANZAS})),null,"iq",["get","set"]);for(const e in V._connectionPlugins)if(Object.prototype.hasOwnProperty.call(V._connectionPlugins,e)){const t=function(){};t.prototype=V._connectionPlugins[e],this[e]=new t,this[e].init(this)}}setProtocol(){const e=this.options.protocol||"";this.options.worker?this._proto=new V.WorkerWebsocket(this):0===this.service.indexOf("ws:")||0===this.service.indexOf("wss:")||0===e.indexOf("ws")?this._proto=new V.Websocket(this):this._proto=new V.Bosh(this)}reset(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0}pause(){this.paused=!0}resume(){this.paused=!1}getUniqueId(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}addProtocolErrorHandler(e,t,n){this.protocolErrorHandlers[e][t]=n}connect(e,t,n,r,i,o,s,c=3e3){this.jid=e,this.authzid=V.getBareJidFromJid(this.jid),this.authcid=s||V.getNodeFromJid(this.jid),this.pass=t,this.scram_keys=null,this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.disconnection_timeout=c,this.domain=V.getDomainFromJid(this.jid),this._changeConnectStatus(a.CONNECTING,null),this._proto._connect(r,i,o)}attach(e,t,n,r,i,o,s){if(this._proto instanceof V.Bosh&&"string"==typeof e)return this._proto._attach(e,t,n,r,i,o,s);if(this._proto instanceof V.WorkerWebsocket&&"function"==typeof e){const t=e;return this._proto._attach(t)}throw new H('The "attach" method is not available for your connection protocol')}restore(e,t,n,r,i){if(!(this._proto instanceof V.Bosh&&this._sessionCachingSupported()))throw new H('The "restore" method can only be used with a BOSH connection.');this._sessionCachingSupported()&&this._proto._restore(e,t,n,r,i)}_sessionCachingSupported(){if(this._proto instanceof V.Bosh){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1}xmlInput(e){}xmlOutput(e){}rawInput(e){}rawOutput(e){}nextValidRid(e){}send(e){if(null!==e){if(Array.isArray(e))e.forEach(e=>this._queueData(e instanceof p?e.tree():e));else{const t=e instanceof p?e.tree():e;this._queueData(t)}this._proto._send()}}flush(){clearTimeout(this._idleTimeout),this._onIdle()}sendPresence(e,t,n,r){let i=null;const o=e instanceof p?e.tree():e;let s=o.getAttribute("id");if(s||(s=this.getUniqueId("sendPresence"),o.setAttribute("id",s)),"function"==typeof t||"function"==typeof n){const e=this.addHandler(e=>{i&&this.deleteTimedHandler(i),"error"===e.getAttribute("type")?null==n||n(e):t&&t(e)},null,"presence",null,s);r&&(i=this.addTimedHandler(r,()=>(this.deleteHandler(e),null==n||n(null),!1)))}return this.send(o),s}sendIQ(e,t,n,r){let i=null;const o=e instanceof p?e.tree():e;let s=o.getAttribute("id");if(s||(s=this.getUniqueId("sendIQ"),o.setAttribute("id",s)),"function"==typeof t||"function"==typeof n){const e=this.addHandler(e=>{i&&this.deleteTimedHandler(i);const r=e.getAttribute("type");if("result"===r)null==t||t(e);else{if("error"!==r){const e=new Error(`Got bad IQ type of ${r}`);throw e.name="StropheError",e}null==n||n(e)}},null,"iq",["error","result"],s);r&&(i=this.addTimedHandler(r,()=>(this.deleteHandler(e),null==n||n(null),!1)))}return this.send(o),s}_queueData(e){if(null===e||!e.tagName||!e.childNodes){const e=new Error("Cannot queue non-DOMElement.");throw e.name="StropheError",e}this._data.push(e)}_sendRestart(){this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout(()=>this._onIdle(),100)}addTimedHandler(e,t){const n=new V.TimedHandler(e,t);return this.addTimeds.push(n),n}deleteTimedHandler(e){this.removeTimeds.push(e)}addHandler(e,t,n,r,i,o,s){const a=new P(e,t,n,r,i,o,s);return this.addHandlers.push(a),a}deleteHandler(e){this.removeHandlers.push(e);const t=this.addHandlers.indexOf(e);t>=0&&this.addHandlers.splice(t,1)}registerSASLMechanisms(e){this.mechanisms={},(e||[V.SASLAnonymous,V.SASLExternal,V.SASLOAuthBearer,V.SASLXOAuth2,V.SASLPlain,V.SASLSHA1,V.SASLSHA256,V.SASLSHA384,V.SASLSHA512]).forEach(e=>this.registerSASLMechanism(e))}registerSASLMechanism(e){const t=new e;this.mechanisms[t.mechname]=t}disconnect(e){if(this._changeConnectStatus(a.DISCONNECTING,e),e?V.warn("Disconnect was called because: "+e):V.info("Disconnect was called"),this.connected){let e=null;this.disconnecting=!0,this.authenticated&&(e=h({xmlns:V.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(this.disconnection_timeout,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else V.warn("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()}_changeConnectStatus(e,t,n){for(const n in V._connectionPlugins)if(Object.prototype.hasOwnProperty.call(V._connectionPlugins,n)){const r=this[n];if(r.statusChanged)try{r.statusChanged(e,t)}catch(e){V.error(`${n} plugin caused an exception changing status: ${e}`)}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){V._handleError(e),V.error(`User connection callback caused an exception: ${e}`)}}_doDisconnect(e){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),V.debug("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(a.DISCONNECTED,e),this.connected=!1}_dataRecv(e,t){const n="_reqToData"in this._proto?this._proto._reqToData(e):e;if(null===n)return;for(this.xmlInput!==V.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==V.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(V.serialize(n)));this.removeHandlers.length>0;){const e=this.removeHandlers.pop(),t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();const r=n.getAttribute("type");if(null!==r&&"terminate"===r){if(this.disconnecting)return;let e=n.getAttribute("condition");const t=n.getElementsByTagName("conflict");return null!==e?("remote-stream-error"===e&&t.length>0&&(e="conflict"),this._changeConnectStatus(a.CONNFAIL,e)):this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.UNKNOWN_REASON),void this._doDisconnect(e)}V.forEachChild(n,null,e=>{const t=[];this.handlers=this.handlers.reduce((n,r)=>{try{!r.isMatch(e)||!this.authenticated&&r.user?n.push(r):(r.run(e)&&n.push(r),t.push(r))}catch(e){V.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}return n},[]),!t.length&&this.iqFallbackHandler.isMatch(e)&&this.iqFallbackHandler.run(e)})}_connect_cb(e,t,n){let r,i;V.debug("_connect_cb was called"),this.connected=!0;try{r="_reqToData"in this._proto?this._proto._reqToData(e):e}catch(e){if(e.name!==V.ErrorCondition.BAD_FORMAT)throw e;this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.BAD_FORMAT),this._doDisconnect(V.ErrorCondition.BAD_FORMAT)}if(!r)return;if(this.xmlInput!==V.Connection.prototype.xmlInput&&(r.nodeName===this._proto.strip&&r.childNodes.length?this.xmlInput(r.childNodes[0]):this.xmlInput(r)),this.rawInput!==V.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(V.serialize(r))),this._proto._connect_cb(r)===a.CONNFAIL)return;if(!(i=r.getElementsByTagNameNS?r.getElementsByTagNameNS(V.NS.STREAM,"features").length>0:r.getElementsByTagName("stream:features").length>0||r.getElementsByTagName("features").length>0))return void this._proto._no_auth_received(t);const o=Array.from(r.getElementsByTagName("mechanism")).map(e=>this.mechanisms[e.textContent]).filter(e=>e);0!==o.length||0!==r.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(o):this._proto._no_auth_received(t)}sortMechanismsByPriority(e){for(let t=0;t<e.length-1;++t){let n=t;for(let r=t+1;r<e.length;++r)e[r].priority>e[n].priority&&(n=r);if(n!==t){const r=e[t];e[t]=e[n],e[n]=r}}return e}authenticate(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}_attemptSASLAuth(e){e=this.sortMechanismsByPriority(e||[]);let t=!1;for(let n=0;n<e.length;++n){if(!e[n].test(this))continue;this._sasl_success_handler=this._addSysHandler(this._sasl_success_cb.bind(this),null,"success",null,null),this._sasl_failure_handler=this._addSysHandler(this._sasl_failure_cb.bind(this),null,"failure",null,null),this._sasl_challenge_handler=this._addSysHandler(this._sasl_challenge_cb.bind(this),null,"challenge",null,null),this._sasl_mechanism=e[n],this._sasl_mechanism.onStart(this);const r=l("auth",{xmlns:V.NS.SASL,mechanism:this._sasl_mechanism.mechname});if(this._sasl_mechanism.isClientFirst){const e=this._sasl_mechanism.clientChallenge(this);r.t(F.btoa(e))}this.send(r.tree()),t=!0;break}return t}async _sasl_challenge_cb(e){const t=F.atob(A(e)),n=await this._sasl_mechanism.onChallenge(this,t),r=l("response",{xmlns:V.NS.SASL});return n&&r.t(F.btoa(n)),this.send(r.tree()),!0}_attemptLegacyAuth(){null===V.getNodeFromJid(this.jid)?(this._changeConnectStatus(a.CONNFAIL,V.ErrorCondition.MISSING_JID_NODE),this.disconnect(V.ErrorCondition.MISSING_JID_NODE)):(this._changeConnectStatus(a.AUTHENTICATING,null),this._addSysHandler(this._onLegacyAuthIQResult.bind(this),null,null,null,"_auth_1"),this.send(d({type:"get",to:this.domain,id:"_auth_1"}).c("query",{xmlns:V.NS.AUTH}).c("username",{}).t(V.getNodeFromJid(this.jid)).tree()))}_onLegacyAuthIQResult(){const e="string"==typeof this.pass?this.pass:"",t=d({type:"set",id:"_auth_2"}).c("query",{xmlns:V.NS.AUTH}).c("username",{}).t(V.getNodeFromJid(this.jid)).up().c("password").t(e);return V.getResourceFromJid(this.jid)||(this.jid=V.getBareJidFromJid(this.jid)+"/strophe"),t.up().c("resource",{}).t(V.getResourceFromJid(this.jid)),this._addSysHandler(this._auth2_cb.bind(this),null,null,null,"_auth_2"),this.send(t.tree()),!1}_sasl_success_cb(e){if(this._sasl_data["server-signature"]){let t;const n=/([a-z]+)=([^,]+)(,|$)/,r=F.atob(A(e)).match(n);if("v"===r[1]&&(t=r[2]),t!==this._sasl_data["server-signature"])return this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_data={},this._sasl_failure_cb(null)}V.info("SASL authentication succeeded."),this._sasl_data.keys&&(this.scram_keys=this._sasl_data.keys),this._sasl_mechanism&&this._sasl_mechanism.onSuccess(),this.deleteHandler(this._sasl_failure_handler),this._sasl_failure_handler=null,this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null);const t=[],n=(e,t)=>{for(;e.length;)this.deleteHandler(e.pop());return this._onStreamFeaturesAfterSASL(t),!1};return t.push(this._addSysHandler(e=>n(t,e),null,"stream:features",null,null)),t.push(this._addSysHandler(e=>n(t,e),V.NS.STREAM,"features",null,null)),this._sendRestart(),!1}_onStreamFeaturesAfterSASL(e){this.features=e;for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];"bind"===n.nodeName&&(this.do_bind=!0),"session"===n.nodeName&&(this.do_session=!0)}return this.do_bind?(this.options.explicitResourceBinding?this._changeConnectStatus(a.BINDREQUIRED,null):this.bind(),!1):(this._changeConnectStatus(a.AUTHFAIL,null),!1)}bind(){if(!this.do_bind)return void V.log(V.LogLevel.INFO,'Strophe.Connection.prototype.bind called but "do_bind" is false');this._addSysHandler(this._onResourceBindResultIQ.bind(this),null,null,null,"_bind_auth_2");const e=V.getResourceFromJid(this.jid);e?this.send(d({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:V.NS.BIND}).c("resource",{}).t(e).tree()):this.send(d({type:"set",id:"_bind_auth_2"}).c("bind",{xmlns:V.NS.BIND}).tree())}_onResourceBindResultIQ(e){if("error"===e.getAttribute("type")){let t;return V.warn("Resource binding failed."),e.getElementsByTagName("conflict").length>0&&(t=V.ErrorCondition.CONFLICT),this._changeConnectStatus(a.AUTHFAIL,t,e),!1}const t=e.getElementsByTagName("bind");if(!(t.length>0))return V.warn("Resource binding failed."),this._changeConnectStatus(a.AUTHFAIL,null,e),!1;{const e=t[0].getElementsByTagName("jid");e.length>0&&(this.authenticated=!0,this.jid=A(e[0]),this.do_session?this._establishSession():this._changeConnectStatus(a.CONNECTED,null))}}_establishSession(){if(!this.do_session)throw new Error("Strophe.Connection.prototype._establishSession "+`called but apparently ${V.NS.SESSION} wasn't advertised by the server`);this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(d({type:"set",id:"_session_auth_2"}).c("session",{xmlns:V.NS.SESSION}).tree())}_onSessionResultIQ(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(a.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,V.warn("Session creation failed."),this._changeConnectStatus(a.AUTHFAIL,null,e),!1;return!1}_sasl_failure_cb(e){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(a.AUTHFAIL,null,e),!1}_auth2_cb(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(a.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(a.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}_addSysTimedHandler(e,t){const n=new M(e,t);return n.user=!1,this.addTimeds.push(n),n}_addSysHandler(e,t,n,r,i){const o=new P(e,t,n,r,i);return o.user=!1,this.addHandlers.push(o),o}_onDisconnectTimeout(){return V.debug("_onDisconnectTimeout was called"),this._changeConnectStatus(a.CONNTIMEOUT,null),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1}_onIdle(){for(;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;){const e=this.removeTimeds.pop(),t=this.timedHandlers.indexOf(e);t>=0&&this.timedHandlers.splice(t,1)}const e=(new Date).getTime(),t=[];for(let n=0;n<this.timedHandlers.length;n++){const r=this.timedHandlers[n];!this.authenticated&&r.user||(r.lastCalled+r.period-e<=0?r.run()&&t.push(r):t.push(r))}this.timedHandlers=t,clearTimeout(this._idleTimeout),this._proto._onIdle(),this.connected&&(this._idleTimeout=setTimeout(()=>this._onIdle(),100))}},ElementType:c,ErrorCondition:{BAD_FORMAT:"bad-format",CONFLICT:"conflict",MISSING_JID_NODE:"x-strophe-bad-non-anon-jid",NO_AUTH_MECH:"no-auth-mech",UNKNOWN_REASON:"unknown"},Handler:P,LogLevel:{DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},NS:o,SASLMechanism:z,Status:a,TimedHandler:M,...Object.freeze({__proto__:null,utf16to8:f,xorArrayBuffers:m,arrayBufToBase64:g,base64ToArrayBuf:v,stringToArrayBuf:y,addCookies:b,xmlGenerator:_,xmlTextNode:C,xmlHtmlNode:function(e){return(new r).parseFromString(e,"text/xml")},xmlElement:w,validTag:T,validAttribute:E,validCSS:x,createHtml:R,copyElement:k,xmlescape:I,xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&amp;/g,"&")).replace(/&lt;/g,"<")).replace(/&gt;/g,">")).replace(/&apos;/g,"'")).replace(/&quot;/g,'"')},serialize:N,forEachChild:D,isTagEqual:function(e,t){return e.tagName===t},getText:A,escapeNode:function(e){return"string"!=typeof e?e:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(/</g,"\\3c").replace(/>/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){const t=O(e);if(t.indexOf("@")<0)return t;{const e=t.split("@");return e.splice(0,1),e.join("@")}},getResourceFromJid:function(e){if(!e)return null;const t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:O,default:L}),XHTML:{...s,validTag:T,validCSS:x,validAttribute:E},addNamespace(e,t){V.NS[e]=t},_handleError(e){void 0!==e.stack&&V.fatal(e.stack),V.fatal("error: "+e.message)},log(e,t){var n;e===this.LogLevel.FATAL&&(null===(n=console)||void 0===n||n.error(t))},debug(e){this.log(this.LogLevel.DEBUG,e)},info(e){this.log(this.LogLevel.INFO,e)},warn(e){this.log(this.LogLevel.WARN,e)},error(e){this.log(this.LogLevel.ERROR,e)},fatal(e){this.log(this.LogLevel.FATAL,e)},_requestId:0,_connectionPlugins:{},addConnectionPlugin(e,t){V._connectionPlugins[e]=t}},W="http://www.w3.org/1999/xhtml";function X(e,t){const n=V.xmlHtmlNode(e);if(n.getElementsByTagNameNS(W,"parsererror").length)throw new Error(`Parser Error: ${e}`);const r=n.firstElementChild;if(["message","iq","presence"].includes(r.nodeName.toLowerCase())&&"jabber:client"!==r.namespaceURI&&"jabber:server"!==r.namespaceURI){const e=`Invalid namespaceURI ${r.namespaceURI}`;if(t)throw new Error(e);V.log(V.LogLevel.ERROR,e)}return r}class ${constructor(e,t){this.strings=e,this.values=t}toString(){return this.string=this.string||this.strings.reduce((e,t)=>{const n=this.strings.indexOf(t);return e+t+(this.values.length>n?this.values[n].toString():"")},""),this.string}tree(){var e;return this.node=null!==(e=this.node)&&void 0!==e?e:X(this.toString(),!0),this.node}}globalThis.$build=l,globalThis.$iq=d,globalThis.$msg=u,globalThis.$pres=h,globalThis.Strophe=V,t.$build=l,t.$iq=d,t.$msg=u,t.$pres=h,t.Builder=p,t.Strophe=V,t.stx=function(e,...t){return new $(e,t)},t.toStanza=X,Object.defineProperty(t,"__esModule",{value:!0})}("object"==typeof n&&void 0!==t?n:(r="undefined"!=typeof globalThis?globalThis:r||self).strophe={})},{"@xmldom/xmldom":5,ws:111}],111:[function(e,t,n){"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],112:[function(e,t,n){(function(t,r){(function(){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function l(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new l(o.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new l(o.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete a[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":89,timers:112}],113:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],114:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],115:[function(e,t,n){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],116:[function(e,t,n){(function(t,r){(function(){var i=/%[sdj%]/g;n.format=function(e){if(!v(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,s=String(e).replace(i,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),c=r[n];n<o;c=r[++n])m(c)||!S(c)?s+=" "+c:s+=" "+a(c);return s},n.deprecate=function(e,i){if(y(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(!0===t.noDeprecation)return e;var o=!1;return function(){if(!o){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var o,s={};function a(e,t){var r={seen:[],stylize:l};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),f(t)?r.showHidden=t:t&&n._extend(r,t),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),u(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function u(e,t,r){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return v(i)||(i=u(e,i,r)),i}var o=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(v(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(t))return e.stylize(""+t,"number");if(f(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),C(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(t);if(0===s.length){if(w(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(b(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(C(t))return d(t)}var l,S="",T=!1,E=["{","}"];(p(t)&&(T=!0,E=["[","]"]),w(t))&&(S=" [Function"+(t.name?": "+t.name:"")+"]");return b(t)&&(S=" "+RegExp.prototype.toString.call(t)),_(t)&&(S=" "+Date.prototype.toUTCString.call(t)),C(t)&&(S=" "+d(t)),0!==s.length||T&&0!=t.length?r<0?b(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=T?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)R(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}(e,t,r,a,s):s.map(function(n){return h(e,t,r,a,n,T)}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return 0,t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(l,S,E)):E[0]+S+E[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function v(e){return"string"==typeof e}function y(e){return void 0===e}function b(e){return S(e)&&"[object RegExp]"===T(e)}function S(e){return"object"==typeof e&&null!==e}function _(e){return S(e)&&"[object Date]"===T(e)}function C(e){return S(e)&&("[object Error]"===T(e)||e instanceof Error)}function w(e){return"function"==typeof e}function T(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}n.debuglog=function(e){if(y(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=t.pid;s[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else s[e]=function(){};return s[e]},n.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=f,n.isNull=m,n.isNullOrUndefined=function(e){return null==e},n.isNumber=g,n.isString=v,n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=y,n.isRegExp=b,n.isObject=S,n.isDate=_,n.isError=C,n.isFunction=w,n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":"),[e.getDate(),x[e.getMonth()],t].join(" ")),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":115,_process:89,inherits:114}],117:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=(0,e("./adapter_factory.js").adapterFactory)({window:"undefined"==typeof window?void 0:window});n.default=r},{"./adapter_factory.js":118}],118:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.adapterFactory=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},n=r.log,l=r.detectBrowser(e),u={browserDetails:l,commonShim:c,extractVersion:r.extractVersion,disableLog:r.disableLog,disableWarnings:r.disableWarnings};switch(l.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),u;if(null===l.version)return n("Chrome shim can not determine version, not shimming."),u;n("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,l),i.shimGetUserMedia(e,l),i.shimMediaStream(e,l),i.shimPeerConnection(e,l),i.shimOnTrack(e,l),i.shimAddTrackRemoveTrack(e,l),i.shimGetSendersWithDtmf(e,l),i.shimGetStats(e,l),i.shimSenderReceiverGetStats(e,l),i.fixNegotiationNeeded(e,l),c.shimRTCIceCandidate(e,l),c.shimConnectionState(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l),c.removeExtmapAllowMixed(e,l);break;case"firefox":if(!s||!s.shimPeerConnection||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),u;n("adapter.js shimming firefox."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,l),s.shimGetUserMedia(e,l),s.shimPeerConnection(e,l),s.shimOnTrack(e,l),s.shimRemoveStream(e,l),s.shimSenderGetStats(e,l),s.shimReceiverGetStats(e,l),s.shimRTCDataChannel(e,l),s.shimAddTransceiver(e,l),s.shimGetParameters(e,l),s.shimCreateOffer(e,l),s.shimCreateAnswer(e,l),c.shimRTCIceCandidate(e,l),c.shimConnectionState(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l);break;case"edge":if(!o||!o.shimPeerConnection||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),u;n("adapter.js shimming edge."),u.browserShim=o,o.shimGetUserMedia(e,l),o.shimGetDisplayMedia(e,l),o.shimPeerConnection(e,l),o.shimReplaceTrack(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l);break;case"safari":if(!a||!t.shimSafari)return n("Safari shim is not included in this adapter release."),u;n("adapter.js shimming safari."),u.browserShim=a,c.shimAddIceCandidateNullOrEmpty(e,l),a.shimRTCIceServerUrls(e,l),a.shimCreateOfferLegacy(e,l),a.shimCallbacksAPI(e,l),a.shimLocalStreamsAPI(e,l),a.shimRemoteStreamsAPI(e,l),a.shimTrackEventTransceiver(e,l),a.shimGetUserMedia(e,l),a.shimAudioContext(e,l),c.shimRTCIceCandidate(e,l),c.shimMaxMessageSize(e,l),c.shimSendThrowTypeError(e,l),c.removeExtmapAllowMixed(e,l);break;default:n("Unsupported browser!")}return u};var r=l(e("./utils")),i=l(e("./chrome/chrome_shim")),o=l(e("./edge/edge_shim")),s=l(e("./firefox/firefox_shim")),a=l(e("./safari/safari_shim")),c=l(e("./common_shim"));function l(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}},{"./chrome/chrome_shim":119,"./common_shim":122,"./edge/edge_shim":123,"./firefox/firefox_shim":127,"./safari/safari_shim":130,"./utils":131}],119:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var 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},i=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var o=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}}),n.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},n.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)s.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id}):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)}),t.stream.getTracks().forEach(function(r){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find(function(e){return e.track&&e.track.id===r.id}):{track:r};var o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},n.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var s=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],s.apply(this,[e]),e.getTracks().forEach(function(e){var n=t._senders.find(function(t){return t.track===e});n&&t._senders.splice(t._senders.indexOf(n),1)})}}else if("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},n.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,n=Array.prototype.slice.call(arguments),r=n[0],i=n[1],o=n[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var s=function(e){var t={},n=e.result();return n.forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},a=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(a(s(e)))},r])}return new Promise(function(n,r){t.apply(e,[function(e){n(a(s(e)))},r])}).then(i,o)}},n.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":r(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),s.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return s.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var o=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],n=void 0,r=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(n?i=!0:n=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(r?i=!0:r=e),e.track===t}),i||n&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return o.apply(this,arguments)}},n.shimAddTrackRemoveTrackWithNative=c,n.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=n.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find(function(e){return e.track===t});if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var s=this._streams[n.id];if(s)s.addTrack(t),Promise.resolve().then(function(){r.dispatchEvent(new Event("negotiationneeded"))});else{var a=new e.MediaStream([t]);this._streams[n.id]=a,this._reverseStreams[a.id]=n,this.addStream(a)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=a({},t,function(){var e=this,t=arguments,r=arguments.length&&"function"==typeof arguments[0];return r?n.apply(this,[function(n){var r=o(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(this,arguments).then(function(t){return o(e,t)})});e.RTCPeerConnection.prototype[t]=r[t]});var s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],n=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})),s.apply(this,arguments)):s.apply(this,arguments);var e,t,n};var l=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=l.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");var n=e._pc===this;if(!n)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var r=void 0;Object.keys(this._streams).forEach(function(n){var i=t._streams[n].getTracks().find(function(t){return e.track===t});i&&(r=t._streams[n])}),r&&(1===r.getTracks().length?this.removeStream(this._reverseStreams[r.id]):r.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},n.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=a({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=r[t]})},n.fixNegotiationNeeded=function(e,t){s.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e})};var s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils.js"));function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var r=this.getSenders();n.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===r.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]}),i.apply(this,arguments)}}},{"../utils.js":131,"./getdisplaymedia":120,"./getusermedia":121}],120:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(function(t){var r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)})}}},{}],121:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimGetUserMedia=function(e,t){var n=e&&e.navigator;if(!n.mediaDevices)return;var o=function(e){if("object"!==(void 0===e?"undefined":r(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var i="object"===r(e[n])?e[n]:{ideal:e[n]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var s={};"number"==typeof i.ideal?(s[o("min",n)]=i.ideal,t.optional.push(s),(s={})[o("max",n)]=i.ideal,t.optional.push(s)):(s[o("",n)]=i.ideal,t.optional.push(s))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[o("",n)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[o(e,n)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},s=function(e,s){if(t.version>=61)return s(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===r(e.audio)){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),a(e.audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=o(e.audio)}if(e&&"object"===r(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":r(c))?c:{ideal:c});var l=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return n.mediaDevices.enumerateDevices().then(function(t){var n=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!n&&t.length&&u.includes("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=c.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=o(e.video),i("chrome: "+JSON.stringify(e)),s(e)})}e.video=o(e.video)}return i("chrome: "+JSON.stringify(e)),s(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){s(e,function(e){n.webkitGetUserMedia(e,t,function(e){r&&r(a(e))})})}.bind(n),n.mediaDevices.getUserMedia){var c=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return s(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(a(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":131}],122:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":r(e))&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=s.default.parseCandidate(e.candidate),o=Object.assign(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,a.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},n.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),r=e.sdpSemantics;"plan-b"===r&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=s.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=s.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),o=function(e){var n=65536;"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return n}(i),a=function(e,n){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var i=s.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637);return r}(arguments[0],i),c=void 0;c=0===o&&0===a?Number.POSITIVE_INFINITY:0===o||0===a?Math.max(o,a):Math.min(o,a);var l={};Object.defineProperty(l,"maxMessageSize",{get:function(){return c}}),this._sctp=l}return n.apply(this,arguments)}},n.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}var n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=n.apply(this,arguments);return t(e,this),e},a.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},n.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(e){var n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})},n.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return n.apply(this,arguments)}},n.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var n=e.RTCPeerConnection.prototype.addIceCandidate;if(!n||0===n.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,o=e("sdp"),s=(i=o)&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("./utils"))},{"./utils":131,sdp:108}],123:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var r=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return r.shimGetUserMedia}});var i=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return i.shimGetDisplayMedia}}),n.shimPeerConnection=function(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var n=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){n.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}});e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var r=(0,l.default)(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=(0,a.filterIceServers)(e.iceServers,t.version),s.log("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype},n.shimReplaceTrack=function(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)};var o,s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils")),a=e("./filtericeservers"),c=e("rtcpeerconnection-shim"),l=(o=c)&&o.__esModule?o:{default:o}},{"../utils":131,"./filtericeservers":124,"./getdisplaymedia":125,"./getusermedia":126,"rtcpeerconnection-shim":106}],124:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.filterIceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&r.deprecated("RTCIceServer.url","RTCIceServer.urls");var i="string"==typeof t;return i&&(t=[t]),t=t.filter(function(e){if(0===e.indexOf("stun:"))return!1;var t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!n?(n=!0,!0):t&&!n}),delete e.url,e.urls=i?t[0]:t,!!t.length}})};var r=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131}],125:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e){if(!("getDisplayMedia"in e.navigator))return;if(!e.navigator.mediaDevices)return;if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)}},{}],126:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetUserMedia=function(e){var t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))})}}},{}],127:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=n.shimGetUserMedia=void 0;var 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},i=e("./getusermedia");Object.defineProperty(n,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var o=e("./getdisplaymedia");Object.defineProperty(n,"shimGetDisplayMedia",{enumerable:!0,get:function(){return o.shimGetDisplayMedia}}),n.shimOnTrack=function(e){"object"===(void 0===e?"undefined":r(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},n.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var n=e.RTCPeerConnection.prototype[t],r=function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=r[t]});var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),r=e[0],o=e[1],s=e[2];return i.apply(this,[r||null]).then(function(e){if(t.version<53&&!o)try{e.forEach(function(e){e.type=n[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(o,s)}},n.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e});e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}},n.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(this,[]);return n.forEach(function(t){return t._pc=e}),n});s.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},n.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;s.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)})}},n.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},n.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var r=t.apply(this,arguments);if(n){var i=r.sender,o=i.getParameters();"encodings"in o&&(1!==o.encodings.length||0!==Object.keys(o.encodings[0]).length)||(o.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(o).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return r})},n.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},n.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,n=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,n)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},n.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,n=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,n)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131,"./getdisplaymedia":128,"./getusermedia":129}],128:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)}}},{}],129:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimGetUserMedia=function(e,t){var n=e&&e.navigator,o=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var s=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":r(e))&&"object"===r(e.audio)&&(e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","mozAutoGainControl"),s(e.audio,"noiseSuppression","mozNoiseSuppression")),a(e)},o&&o.prototype.getSettings){var c=o.prototype.getSettings;o.prototype.getSettings=function(){var e=c.apply(this,arguments);return s(e,"mozAutoGainControl","autoGainControl"),s(e,"mozNoiseSuppression","noiseSuppression"),e}}if(o&&o.prototype.applyConstraints){var l=o.prototype.applyConstraints;o.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":r(e))&&(e=JSON.parse(JSON.stringify(e)),s(e,"autoGainControl","mozAutoGainControl"),s(e,"noiseSuppression","mozNoiseSuppression")),l.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"))},{"../utils":131}],130:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(r){return t.call(n,r,e)}),e.getVideoTracks().forEach(function(r){return t.call(n,r,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=this,r=arguments.length,i=Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i&&i.forEach(function(e){n._localStreams?n._localStreams.includes(e)||n._localStreams.push(e):n._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var n=this._localStreams.indexOf(e);if(-1!==n){this._localStreams.splice(n,1);var r=e.getTracks();this.getSenders().forEach(function(e){r.includes(e.track)&&t.removeTrack(e)})}})},n.shimRemoteStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;"getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]});if(!("onaddstream"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}})})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}})}),t.apply(e,arguments)}}},n.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":r(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,n=t.createOffer,i=t.createAnswer,o=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r};var c=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=c,c=function(e,t,n){var r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=c,c=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=c},n.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=function(e){return r(o(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))},n.shimConstraints=o,n.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var r=[],o=0;o<e.iceServers.length;o++){var s=e.iceServers[o];!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")?(i.deprecated("RTCIceServer.url","RTCIceServer.urls"),(s=JSON.parse(JSON.stringify(s))).urls=s.url,delete s.url,r.push(s)):r.push(e.iceServers[o])}e.iceServers=r}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})},n.shimTrackEventTransceiver=function(e){"object"===(void 0===e?"undefined":r(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},n.shimCreateOfferLegacy=function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var n=this.getTransceivers().find(function(e){return"audio"===e.receiver.track.kind});!1===e.offerToReceiveAudio&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveAudio||n||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var r=this.getTransceivers().find(function(e){return"video"===e.receiver.track.kind});!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}},n.shimAudioContext=function(e){if("object"!==(void 0===e?"undefined":r(e))||e.AudioContext)return;e.AudioContext=e.webkitAudioContext};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(e("../utils"));function o(e){return e&&void 0!==e.video?Object.assign({},e,{video:i.compactObject(e.video)}):e}},{"../utils":131}],131:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var 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};n.extractVersion=s,n.wrapPeerConnectionEvent=function(e,t,n){if(!e.RTCPeerConnection)return;var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};var o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);var r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})},n.disableLog=function(e){if("boolean"!=typeof e)return new Error("Argument type: "+(void 0===e?"undefined":r(e))+". Please use a boolean.");return i=e,e?"adapter.js logging disabled":"adapter.js logging enabled"},n.disableWarnings=function(e){if("boolean"!=typeof e)return new Error("Argument type: "+(void 0===e?"undefined":r(e))+". Please use a boolean.");return o=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled")},n.log=function(){if("object"===("undefined"==typeof window?"undefined":r(window))){if(i)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},n.deprecated=function(e,t){if(!o)return;console.warn(e+" is deprecated, please use "+t+" instead.")},n.detectBrowser=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var n=e.navigator;if(n.mozGetUserMedia)t.browser="firefox",t.version=s(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=s(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=s(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=s(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t},n.compactObject=function e(t){if(!a(t))return t;return Object.keys(t).reduce(function(n,r){var i=a(t[r]),o=i?e(t[r]):t[r],s=i&&!Object.keys(o).length;return void 0===o||s?n:Object.assign(n,function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n;return e}({},r,o))},{})},n.walkStats=c,n.filterStats=function(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach(function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(function(t){e.forEach(function(n){n.type===r&&n.trackId===t.id&&c(e,n,i)})}),i};var i=!0,o=!0;function s(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(function(r){r.endsWith("Id")?c(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach(function(t){c(e,e.get(t),n)})}))}},{}],132:[function(e,t,n){"use strict";var r,i=e("./qbChatHelpers"),o=e("../../qbConfig"),s=e("../../qbUtils"),a=e("../../plugins/streamManagement"),c="This function isn't supported outside of the browser (...yet)";if(s.getEnv().browser){var l=e("../../qbStrophe");Strophe.addNamespace("CARBONS",i.MARKERS.CARBONS),Strophe.addNamespace("CHAT_MARKERS",i.MARKERS.CHAT),Strophe.addNamespace("PRIVACY_LIST",i.MARKERS.PRIVACY),Strophe.addNamespace("CHAT_STATES",i.MARKERS.STATES)}else s.getEnv().nativescript?r=e("nativescript-xmpp-client"):s.getEnv().node&&(r=e("node-xmpp-client"));function u(e){var t,n=this;n.webrtcSignalingProcessor=null,s.getEnv().browser?(n.connection=l(n._OnLogListener.bind(this)),n.connection.XHandlerReferences=[],n.connection.XAddTrackedHandler=function(e,t,r,i,o,s,a){n.connection.XHandlerReferences.push(n.connection.addHandler(e,t,r,i,o,s,a))},n.connection.XDeleteHandlers=function(){for(;n.connection.XHandlerReferences.length;)n.connection.deleteHandler(n.connection.XHandlerReferences.pop())},t=n.connection.send,n.connection.send=function(e){if(!n.connection.connected)throw new i.ChatNotConnectedError("Chat is not connected");t.call(n.connection,e)}):(s.getEnv().nativescript?n.Client=new r.Client({websocket:{url:o.chatProtocol.websocket},autostart:!1}):s.getEnv().node&&(n.Client=new r({autostart:!1})),t=n.Client.send,n.Client.send=function(e){s.QBLog("[QBChat]","SENT:",e.toString()),t.call(n.Client,e)},n.nodeStanzasCallbacks={}),this.service=e,this.isConnected=!1,this._isConnecting=!1,this._isLogout=!1,this._checkConnectionTimer=void 0,this._checkConnectionPingTimer=void 0,this._chatPingFailedCounter=0,this._onlineStatus=!0,this._checkExpiredSessionTimer=void 0,this._sessionHasExpired=!1,this._pings={},this.helpers=new f;var c={service:e,helpers:n.helpers,stropheClient:n.connection,xmppClient:n.Client,nodeStanzasCallbacks:n.nodeStanzasCallbacks};this.roster=new d(c),this.privacylist=new p(c),this.muc=new h(c),this.chatUtils=i,o.streamManagement.enable&&(2===o.chatProtocol.active?(this.streamManagement=new a(o.streamManagement),n._sentMessageCallback=function(e,t){"function"==typeof n.onSentMessageCallback&&(t?n.onSentMessageCallback(null,t):n.onSentMessageCallback(e))}):s.QBLog("[QBChat] StreamManagement:",'BOSH protocol doesn\'t support stream management. Set WebSocket as the "chatProtocol" parameter to use this functionality. https://quickblox.com/developers/Javascript#Configuration')),this._onMessage=function(e){var t,r,o,a,c=i.getAttr(e,"from"),l=(i.getAttr(e,"to"),i.getAttr(e,"type")),u=i.getAttr(e,"id"),d=i.getElement(e,"markable"),h=i.getElement(e,"received"),p=i.getElement(e,"displayed"),f=i.getElement(e,"composing"),m=i.getElement(e,"paused"),g=i.getElement(e,"invite"),v=i.getElement(e,"delay"),y=i.getElement(e,"extraParams"),b=i.getElementText(e,"body"),S=i.getElement(e,"forwarded");if(s.getEnv().browser)o=e.querySelector("forwarded")?e.querySelector("forwarded").querySelector("message").getAttribute("to"):null,a=n.connection.jid;else{var _=S?i.getElement(S,"message"):null;o=_?i.getAttr(_,"to"):null,a=n.Client.options.jid.user}r=o?n.helpers.getIdFromNode(o):null;var C="groupchat"===l?n.helpers.getDialogIdFromNode(c):null,w="groupchat"===l?n.helpers.getIdFromResource(c):n.helpers.getIdFromNode(c),T=h||p||null;if(g)return!0;if(y&&(t=i.parseExtraParams(y)).dialogId&&(C=t.dialogId),f||m)return"function"!=typeof n.onMessageTypingListener||"chat"!==l&&"groupchat"!==l&&v||s.safeCallbackCall(n.onMessageTypingListener,!!f,w,C),!0;if(T)return h?"function"==typeof n.onDeliveredStatusListener&&"chat"===l&&s.safeCallbackCall(n.onDeliveredStatusListener,i.getAttr(h,"id"),C,w):"function"==typeof n.onReadStatusListener&&"chat"===l&&s.safeCallbackCall(n.onReadStatusListener,i.getAttr(p,"id"),C,w),!0;if(d&&w!=n.helpers.getIdFromNode(a)){var E={messageId:u,userId:w,dialogId:C};n.sendDeliveredStatus(E)}var x={id:u,dialog_id:C,recipient_id:r,type:l,body:b,extension:t?t.extension:null,delay:v};return d&&(x.markable=1),"function"!=typeof n.onMessageListener||"chat"!==l&&"groupchat"!==l||s.safeCallbackCall(n.onMessageListener,w,x),!0},this._onPresence=function(e){var t,o,a,c,l,u=i.getAttr(e,"from"),d=(i.getAttr(e,"to"),i.getAttr(e,"id")),h=i.getAttr(e,"type"),p=n.helpers.getIdFromNode(n.helpers.userCurrentJid(s.getEnv().browser?n.connection:n.Client)),f=i.getElement(e,"x");if(f&&(t=i.getAttr(f,"xmlns"),(o=i.getElement(f,"status"))&&(a=i.getAttr(o,"code"))),t&&"http://jabber.org/protocol/muc#user"==t){if(c=n.helpers.getDialogIdFromNode(u),l=n.helpers.getUserIdFromRoomJid(u),o&&"301"==a){if("function"==typeof n.onKickOccupant){var m=i.getElement(i.getElement(f,"item"),"actor"),g=i.getAttr(m,"jid");s.safeCallbackCall(n.onKickOccupant,c,n.helpers.getIdFromNode(g))}return delete n.muc.joinedRooms[n.helpers.getRoomJidFromRoomFullJid(u)],!0}if(!o&&l!=p)return h&&"unavailable"===h?("function"==typeof n.onLeaveOccupant&&s.safeCallbackCall(n.onLeaveOccupant,c,parseInt(l)),!0):("function"==typeof n.onJoinOccupant&&s.safeCallbackCall(n.onJoinOccupant,c,parseInt(l)),!0)}if(!s.getEnv().browser&&t)if("http://jabber.org/protocol/muc#user"==t){if(h&&"unavailable"===h)return o&&"110"==a&&"function"==typeof n.nodeStanzasCallbacks["muc:leave"]&&s.safeCallbackCall(n.nodeStanzasCallbacks["muc:leave"],null),!0;if(d.endsWith(":join")&&o&&"110"==a)return"function"==typeof n.nodeStanzasCallbacks[d]&&n.nodeStanzasCallbacks[d](e),!0}else if(h&&"error"===h&&"http://jabber.org/protocol/muc"==t)return d.endsWith(":join")&&"function"==typeof n.nodeStanzasCallbacks[d]&&n.nodeStanzasCallbacks[d](e),!0;if(l=n.helpers.getIdFromNode(u),h)switch(h){case"subscribe":n.roster.contacts[l]&&"to"===n.roster.contacts[l].subscription?(n.roster.contacts[l]={subscription:"both",ask:null},n.roster._sendSubscriptionPresence({jid:u,type:"subscribed"})):"function"==typeof n.onSubscribeListener&&s.safeCallbackCall(n.onSubscribeListener,l);break;case"subscribed":n.roster.contacts[l]&&"from"===n.roster.contacts[l].subscription?n.roster.contacts[l]={subscription:"both",ask:null}:(n.roster.contacts[l]={subscription:"to",ask:null},"function"==typeof n.onConfirmSubscribeListener&&s.safeCallbackCall(n.onConfirmSubscribeListener,l));break;case"unsubscribed":n.roster.contacts[l]={subscription:"none",ask:null},"function"==typeof n.onRejectSubscribeListener&&s.safeCallbackCall(n.onRejectSubscribeListener,l);break;case"unsubscribe":n.roster.contacts[l]={subscription:"to",ask:null};break;case"unavailable":"function"==typeof n.onContactListListener&&n.roster.contacts[l]&&"none"!==n.roster.contacts[l].subscription&&s.safeCallbackCall(n.onContactListListener,l,h),l===p&&(s.getEnv().browser?n.connection.send($pres()):n.Client.send(i.createStanza(r.Stanza,null,"presence")))}else"function"==typeof n.onContactListListener&&n.roster.contacts[l]&&"none"!==n.roster.contacts[l].subscription&&s.safeCallbackCall(n.onContactListListener,l);return!0},this._onIQ=function(e){var t=i.getAttr(e,"id"),o=t.indexOf("lastActivity")>-1,a=t.indexOf("ping")>-1,c=i.getElement(e,"ping"),l=i.getAttr(e,"type"),u=i.getAttr(e,"from"),d=u?n.helpers.getIdFromNode(u):null;if("function"==typeof n.onLastUserActivityListener&&o){var h=i.getElement(e,"query"),p=i.getElement(e,"error")?void 0:+i.getAttr(h,"seconds");s.safeCallbackCall(n.onLastUserActivityListener,d,p)}if((c||a)&&l)if("get"===l&&c&&n.isConnected){var f=s.getEnv().browser?$iq:r.Stanza,m={from:n.helpers.getUserCurrentJid(),id:t,to:u,type:"result"},g=i.createStanza(f,m,"iq");s.getEnv().browser?n.connection.send(g):n.Client.send(g)}else{var v=n._pings[t];v&&(v.callback&&v.callback(null),v.interval&&clearInterval(v.interval),n._pings[t]=void 0,delete n._pings[t])}return s.getEnv().browser||n.nodeStanzasCallbacks[t]&&(s.safeCallbackCall(n.nodeStanzasCallbacks[t],e),delete n.nodeStanzasCallbacks[t]),!0},this._onSystemMessageListener=function(e){var t,r=i.getAttr(e,"from"),o=(i.getAttr(e,"to"),i.getAttr(e,"id")),a=i.getElement(e,"extraParams"),c=n.helpers.getIdFromNode(r),l=i.getElement(e,"delay"),u=i.getElementText(a,"moduleIdentifier"),d=i.getElementText(e,"body"),h=i.parseExtraParams(a);return"SystemNotifications"===u&&"function"==typeof n.onSystemMessageListener?(t={id:o,userId:c,body:d,extension:h.extension},s.safeCallbackCall(n.onSystemMessageListener,t)):n.webrtcSignalingProcessor&&!l&&"WebRTCVideoChat"===u&&n.webrtcSignalingProcessor._onMessage(r,a,l,c,h.extension),!0},this._onMessageErrorListener=function(e){var t=i.getAttr(e,"id"),r=i.getErrorFromXMLNode(e);return"function"==typeof n.onMessageErrorListener&&s.safeCallbackCall(n.onMessageErrorListener,t,r),!0}}function d(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks,this.contacts={}}function h(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks,this.joinedRooms={}}function p(e){this.service=e.service,this.helpers=e.helpers,this.connection=e.stropheClient,this.Client=e.xmppClient,this.nodeStanzasCallbacks=e.nodeStanzasCallbacks}function f(){this._userCurrentJid=""}u.prototype={_OnLogListener:function(e){"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,e)},connect:function(e,t){s.QBLog("[QBChat]","Connect with parameters "+JSON.stringify(e));var n,r=this,a=i.buildUserJid(e),c="function"==typeof t;return r._isConnecting?(n=s.getError(422,"Status.REJECT - The connection is still in the Status.CONNECTING state","QBChat"),void(c&&t(n,null))):r.isConnected?(s.QBLog("[QBChat]","Status.CONNECTED - You are already connected"),void(c&&t(null,r.roster.contacts))):(r._isConnecting=!0,r._isLogout=!1,s.getEnv().browser&&(s.QBLog("[QBChat]","!!---Browser env - connected--!!"),r.connection.connect(a,e.password,function(a,l,u){switch(s.QBLog("[QBChat]","self.connection.connect called with status "+a),s.QBLog("[QBChat]","self.connection.connect called with condition "+l),s.QBLog("[QBChat]","self.connection.connect called with elem "+u),a){case Strophe.Status.ERROR:s.QBLog("[QBChat]","Status.ERROR at "+i.getLocalTime()),s.QBLog("[QBChat]","ERROR CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ERROR at "+i.getLocalTime()+" ERROR CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(422,"Status.ERROR - An error has occurred","QBChat"),c&&t(n,null);break;case Strophe.Status.CONNFAIL:s.QBLog("[QBChat]","Status.CONNFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNFAIL at "+i.getLocalTime()+" CONNFAIL CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(422,"Status.CONNFAIL - The connection attempt failed","QBChat"),c&&t(n,null);break;case Strophe.Status.AUTHENTICATING:s.QBLog("[QBChat]","Status.AUTHENTICATING at "+i.getLocalTime()),s.QBLog("[QBChat]","AUTHENTICATING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.AUTHENTICATING at "+i.getLocalTime()+" AUTHENTICATING CONDITION: "+l);break;case Strophe.Status.AUTHFAIL:s.QBLog("[QBChat]","Status.AUTHFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","AUTHFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.AUTHFAIL at "+i.getLocalTime()+" AUTHFAIL CONDITION: "+l),r.isConnected=!1,r._isConnecting=!1,n=s.getError(401,"Status.AUTHFAIL - The authentication attempt failed","QBChat"),c&&t(n,null),r.isConnected||"function"!=typeof r.onReconnectFailedListener||s.safeCallbackCall(r.onReconnectFailedListener,n);break;case Strophe.Status.CONNECTING:s.QBLog("[QBChat]","Status.CONNECTING","(Chat Protocol - "+(1===o.chatProtocol.active?"BOSH":"WebSocket)")),s.QBLog("[QBChat]","Status.CONNECTING at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNECTING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNECTING at (Chat Protocol - "+o.chatProtocol.active===1?"BOSH":"WebSocket)"+i.getLocalTime()+" CONNECTING CONDITION: "+l);break;case Strophe.Status.CONNECTED:s.QBLog("[QBChat]","Status.CONNECTED at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNECTED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNECTED at "+i.getLocalTime()+" CONNECTED CONDITION: "+l),r.connection.XDeleteHandlers(),r.connection.XAddTrackedHandler(r._onMessage,null,"message","chat"),r.connection.XAddTrackedHandler(r._onMessage,null,"message","groupchat"),r.connection.XAddTrackedHandler(r._onPresence,null,"presence"),r.connection.XAddTrackedHandler(r._onIQ,null,"iq"),r.connection.XAddTrackedHandler(r._onSystemMessageListener,null,"message","headline"),r.connection.XAddTrackedHandler(r._onMessageErrorListener,null,"message","error");var d=void 0===r._checkConnectionPingTimer;if((d=0!==o.pingLocalhostTimeInterval&&d)&&(s.QBLog("[QBChat]","Init ping to chat at ",s.getCurrentTime()),r._checkConnectionPingTimer=setInterval(function(){try{r.pingchat(function(t){t?(s.QBLog("[QBChat]","Chat Ping: ","failed, at ",s.getCurrentTime(),"_chatPingFailedCounter: ",r._chatPingFailedCounter," error: ",t),r._chatPingFailedCounter+=1,r._chatPingFailedCounter>=o.chatPingMissLimit&&(r.isConnected&&"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r._chatPingFailedCounter=0,r._establishConnection(e,"CONNECTED have SDK ping failed"))):(s.QBLog("[QBChat]","Chat Ping: ","ok, at ",s.getCurrentTime(),"_chatPingFailedCounter: ",r._chatPingFailedCounter),r._chatPingFailedCounter=0)})}catch(e){s.QBLog("[QBChat]","Chat Ping: ","Exception, at ",s.getCurrentTime(),", detail info: ",e)}},1e3*o.pingLocalhostTimeInterval)),"function"==typeof r.onSessionExpiredListener)void 0===r._checkExpiredSessionTimer&&(s.QBLog("[QBChat]","Init timer for check session expired at ",(new Date).toTimeString().split(" ")[0]),r._checkExpiredSessionTimer=setInterval(function(){var e=new Date;void 0!==o.qbTokenExpirationDate&&(Math.round((e.getTime()-o.qbTokenExpirationDate.getTime())/6e4)>=0&&(r._sessionHasExpired=!0,s.safeCallbackCall(r.onSessionExpiredListener,null)))},5e3));r._postConnectActions(function(e){t(null,e)},c);break;case Strophe.Status.DISCONNECTING:s.QBLog("[QBChat]","Status.DISCONNECTING at "+i.getLocalTime()),s.QBLog("[QBChat]","DISCONNECTING CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.DISCONNECTING at "+i.getLocalTime()+" DISCONNECTING CONDITION: "+l);break;case Strophe.Status.DISCONNECTED:s.QBLog("[QBChat]","Status.DISCONNECTED at "+i.getLocalTime()),s.QBLog("[QBChat]","DISCONNECTED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.DISCONNECTED at "+i.getLocalTime()+" DISCONNECTED CONDITION: "+l),r.isConnected&&"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r.connection.reset(),r._establishConnection(e,"DISCONNECTED");break;case Strophe.Status.ATTACHED:s.QBLog("[QBChat]","Status.ATTACHED at "+i.getLocalTime()),s.QBLog("[QBChat]","ATTACHED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ATTACHED at "+i.getLocalTime()+" ATTACHED CONDITION: "+l);break;case Strophe.Status.REDIRECT:s.QBLog("[QBChat]","Status.REDIRECT at "+i.getLocalTime()),s.QBLog("[QBChat]","REDIRECT CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.REDIRECT at "+i.getLocalTime()+" REDIRECT CONDITION: "+l);break;case Strophe.Status.CONNTIMEOUT:s.QBLog("[QBChat]","Status.CONNTIMEOUT at "+i.getLocalTime()),s.QBLog("[QBChat]","CONNTIMEOUT CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.CONNTIMEOUT at "+i.getLocalTime()+" CONNTIMEOUT CONDITION: "+l);break;case Strophe.Status.BINDREQUIRED:s.QBLog("[QBChat]","Status.BINDREQUIRED at "+i.getLocalTime()),s.QBLog("[QBChat]","BINDREQUIRED CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.BINDREQUIRED at "+i.getLocalTime()+" BINDREQUIRED CONDITION: "+l);break;case Strophe.Status.ATTACHFAIL:s.QBLog("[QBChat]","Status.ATTACHFAIL at "+i.getLocalTime()),s.QBLog("[QBChat]","ATTACHFAIL CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status.ATTACHFAIL at "+i.getLocalTime()+" ATTACHFAIL CONDITION: "+l);break;default:s.QBLog("[QBChat]","Status is unknown at "+i.getLocalTime()),s.QBLog("[QBChat]","unknown CONDITION: "+l),"function"==typeof r.onLogListener&&s.safeCallbackCall(r.onLogListener,"[QBChat][SDK v"+o.version+"] Status is unknown at "+i.getLocalTime()+" unknown CONDITION: "+l)}})),void(s.getEnv().browser||(s.QBLog("[QBChat]","!!--call branch code connect for node--!!"),r.Client.removeAllListeners(),r.Client.on("connect",function(){s.QBLog("[QBChat]","Status.CONNECTING","(Chat Protocol - "+(1===o.chatProtocol.active?"BOSH":"WebSocket)"))}),r.Client.on("auth",function(){s.QBLog("[QBChat]","Status.AUTHENTICATING")}),r.Client.on("online",function(){r._postConnectActions(function(e){t(null,e)},c)}),r.Client.on("stanza",function(e){s.QBLog("[QBChat] RECV:",e.toString()),e.is("presence")?r._onPresence(e):e.is("iq")?r._onIQ(e):e.is("message")&&("headline"===e.attrs.type?r._onSystemMessageListener(e):"error"===e.attrs.type?r._onMessageErrorListener(e):r._onMessage(e))}),r.Client.on("disconnect",function(){s.QBLog("[QBChat]","Status.DISCONNECTED - "+i.getLocalTime()),"function"==typeof r.onDisconnectedListener&&s.safeCallbackCall(r.onDisconnectedListener),r.isConnected=!1,r._isConnecting=!1,r._establishConnection(e,"NODE:DISCONNECTED")}),r.Client.on("error",function(){s.QBLog("[QBChat]","Status.ERROR - "+i.getLocalTime()),n=s.getError(422,"Status.ERROR - An error has occurred","QBChat"),c&&t(n,null),r.isConnected=!1,r._isConnecting=!1}),r.Client.on("end",function(){r.Client.removeAllListeners()}),r.Client.options.jid=a,r.Client.options.password=e.password,r.Client.connect())))},_postConnectActions:function(e,t){s.QBLog("[QBChat]","Status.CONNECTED at "+i.getLocalTime());var n=this,a=s.getEnv().browser,c=a?n.connection:n.Client,l=a?$pres():i.createStanza(r.Stanza,null,"presence");if(o.streamManagement.enable&&2===o.chatProtocol.active&&(n.streamManagement.enable(n.connection,null),n.streamManagement.sentMessageCallback=n._sentMessageCallback),n.helpers.setUserCurrentJid(n.helpers.userCurrentJid(c)),n.isConnected=!0,n._isConnecting=!1,n._sessionHasExpired=!1,n._enableCarbons(),t)n.roster.get(function(t){c.send(l),n.roster.contacts=t,e(n.roster.contacts)});else{var u=Object.keys(n.muc.joinedRooms);c.send(l),s.QBLog("[QBChat]","Re-joining "+u.length+" rooms...");for(var d=0,h=u.length;d<h;d++)n.muc.join(u[d]);"function"==typeof n.onReconnectListener&&s.safeCallbackCall(n.onReconnectListener)}},_establishConnection:function(e,t){var n=this;if(s.QBLog("[QBChat]","_establishConnection called in "+t),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]_establishConnection called in "+t),n._isLogout||n._checkConnectionTimer)return s.QBLog("[QBChat]","_establishConnection return"),void("function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,(n._isLogout,n._isLogout)));var r=function(){s.QBLog("[QBChat]","call _connect() in _establishConnection in "+t),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat] call _connect() in _establishConnection in "+t),n.isConnected||n._isConnecting||n._sessionHasExpired?(s.QBLog("[QBChat]","stop timer in _establishConnection "),clearInterval(n._checkConnectionTimer),n._checkConnectionTimer=void 0,"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]stop timer in _establishConnection in "+t)):(s.QBLog("[QBChat]"," start EXECUTE connect() in _establishConnection "),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat] start EXECUTE connect() in _establishConnection in "+t+" self.isConnected: "+n.isConnected+" self._isConnecting: "+n._isConnecting+" self._sessionHasExpired: "+n._sessionHasExpired),n.connect(e),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]call _connect() in _establishConnection in "+t+" is executed"))};r(),n._checkConnectionTimer=setInterval(function(){s.QBLog("[QBChat]","self._checkConnectionTimer called with config.chatReconnectionTimeInterval = "+o.chatReconnectionTimeInterval),"function"==typeof n.onLogListener&&s.safeCallbackCall(n.onLogListener,"[QBChat]self._checkConnectionTimer called with config.chatReconnectionTimeInterval = "+o.chatReconnectionTimeInterval),r()},1e3*o.chatReconnectionTimeInterval)},reconnect:function(){s.QBLog("[QBChat]","Call reconnect "),"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,"[QBChat][SDK v"+o.version+"] Call reconnect "+i.getLocalTime()),clearInterval(this._checkConnectionTimer),this._checkConnectionTimer=void 0,this.muc.joinedRooms={},this.helpers.setUserCurrentJid(""),s.getEnv().browser?(this.connection.flush(),this.connection.disconnect("call Qb.chat.reconnect")):this.Client.end()},send:function(e,t){s.QBLog("[QBChat]","Call send "+JSON.stringify(t));var n=s.getEnv().browser?$msg:r.Stanza,a={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:t.type?t.type:"chat",id:t.id?t.id:s.getBsonObjectId()},c=i.createStanza(n,a);return t.body&&c.c("body",{xmlns:i.MARKERS.CLIENT}).t(t.body).up(),t.markable&&c.c("markable",{xmlns:i.MARKERS.CHAT}).up(),t.extension&&(c.c("extraParams",{xmlns:i.MARKERS.CLIENT}),c=i.filledExtraParams(c,t.extension)),s.getEnv().browser?o.streamManagement.enable?(t.id=a.id,t.jid_or_user_id=e,this.connection.send(c,t)):this.connection.send(c):o.streamManagement.enable?(t.id=a.id,t.jid_or_user_id=e,this.Client.send(c,t)):this.Client.send(c),a.id},sendSystemMessage:function(e,t){s.QBLog("[QBChat]","Call sendSystemMessage "+JSON.stringify(t));var n=s.getEnv().browser?$msg:r.Stanza,o={type:"headline",id:t.id?t.id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e)},a=i.createStanza(n,o);return t.body&&a.c("body",{xmlns:i.MARKERS.CLIENT}).t(t.body).up(),s.getEnv().browser?(t.extension&&(a.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("moduleIdentifier").t("SystemNotifications").up(),a=i.filledExtraParams(a,t.extension)),this.connection.send(a)):(t.extension&&(a.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("moduleIdentifier").t("SystemNotifications"),a=i.filledExtraParams(a,t.extension)),this.Client.send(a)),o.id},sendIsTypingStatus:function(e){s.QBLog("[QBChat]","Call sendIsTypingStatus ");var t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("composing",{xmlns:i.MARKERS.STATES}),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendIsStopTypingStatus:function(e){s.QBLog("[QBChat]","Call sendIsStopTypingStatus ");var t={from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e),type:this.helpers.typeChat(e)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("paused",{xmlns:i.MARKERS.STATES}),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendDeliveredStatus:function(e){s.QBLog("[QBChat]","Call sendDeliveredStatus ");var t={type:"chat",from:this.helpers.getUserCurrentJid(),id:s.getBsonObjectId(),to:this.helpers.jidOrUserId(e.userId)},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("received",{xmlns:i.MARKERS.MARKERS,id:e.messageId}).up(),o.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("dialog_id").t(e.dialogId),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},sendReadStatus:function(e){s.QBLog("[QBChat]","Call sendReadStatus "+JSON.stringify(e));var t={type:"chat",from:this.helpers.getUserCurrentJid(),to:this.helpers.jidOrUserId(e.userId),id:s.getBsonObjectId()},n=s.getEnv().browser?$msg:r.Stanza,o=i.createStanza(n,t);o.c("displayed",{xmlns:i.MARKERS.MARKERS,id:e.messageId}).up(),o.c("extraParams",{xmlns:i.MARKERS.CLIENT}).c("dialog_id").t(e.dialogId),s.getEnv().browser?this.connection.send(o):this.Client.send(o)},getLastUserActivity:function(e){var t,n,o;s.QBLog("[QBChat]","Call getLastUserActivity "),t={from:this.helpers.getUserCurrentJid(),id:this.helpers.getUniqueId("lastActivity"),to:this.helpers.jidOrUserId(e),type:"get"},n=s.getEnv().browser?$iq:r.Stanza,(o=i.createStanza(n,t,"iq")).c("query",{xmlns:i.MARKERS.LAST}),s.getEnv().browser?this.connection.sendIQ(o):this.Client.send(o)},pingchat:function(e){s.QBLog("[QBChat]","ping chat");var t,n,a,c=this,l=this.helpers.getUniqueId("ping"),u=s.getEnv().browser?$iq:r.Stanza;t=o.endpoints.chat?o.endpoints.chat:"chat.quickblox.com",n=e;var d={from:this.helpers.getUserCurrentJid(),id:l,to:t,type:"get"};(a=i.createStanza(u,d,"iq")).c("ping",{xmlns:"urn:xmpp:ping"});return s.getEnv().browser?this.connection.send(a):this.Client.send(a),this._pings[l]={callback:n,interval:setTimeout(function(){n("Chat ping No answer"),c._pings[l]=void 0,delete c._pings[l]},1e3*o.pingTimeout)},l},ping:function(e,t){s.QBLog("[QBChat]","Call ping ");var n,a,c,l=this,u=this.helpers.getUniqueId("ping"),d=s.getEnv().browser?$iq:r.Stanza;if("string"!=typeof e&&"number"!=typeof e||"function"!=typeof t){if("function"!=typeof e||t)throw new Error("Invalid arguments provided. Either userId/jid (number/string) and callback or only callback should be provided.");n=o.endpoints.chat,a=e}else n=this.helpers.jidOrUserId(e),a=t;var h={from:this.helpers.getUserCurrentJid(),id:u,to:n,type:"get"};(c=i.createStanza(d,h,"iq")).c("ping",{xmlns:"urn:xmpp:ping"});return s.getEnv().browser?this.connection.send(c):this.Client.send(c),this._pings[u]={callback:a,interval:setTimeout(function(){a("No answer"),l._pings[u]=void 0,delete l._pings[u]},1e3*o.pingTimeout)},u},disconnect:function(){s.QBLog("[QBChat]","Call disconnect "),"function"==typeof this.onLogListener&&s.safeCallbackCall(this.onLogListener,"[QBChat][SDK v"+o.version+"] Call disconnect "+i.getLocalTime()),clearInterval(this._checkConnectionTimer),clearInterval(this._checkExpiredSessionTimer),this._checkConnectionTimer=void 0,this._checkExpiredSessionTimer=void 0,this.muc.joinedRooms={},this._isLogout=!0,this.helpers.setUserCurrentJid(""),s.getEnv().browser?(this.connection.flush(),this.connection.disconnect("call QB.chat.disconnect"),void 0!==this._checkConnectionPingTimer&&(s.QBLog("[QBChat]","Stop ping"),clearInterval(this._checkConnectionPingTimer),this._checkConnectionPingTimer=void 0)):this.Client.end()},addListener:function(e,t){if(s.QBLog("[Deprecated!]","Avoid using it, this feature will be removed in future version."),!s.getEnv().browser)throw new Error(c);return this.connection.XAddTrackedHandler(function(){return t(),!1!==e.live},null,e.name||null,e.type||null,e.id||null,e.from||null)},deleteListener:function(e){if(s.QBLog("[Deprecated!]","Avoid using it, this feature will be removed in future version."),!s.getEnv().browser)throw new Error(c);this.connection.deleteHandler(e)},_enableCarbons:function(e){var t={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("enableCarbons")},n=s.getEnv().browser?$iq:r.Stanza,o=i.createStanza(n,t,"iq");o.c("enable",{xmlns:i.MARKERS.CARBONS}),s.getEnv().browser?this.connection.sendIQ(o):this.Client.send(o)}},d.prototype={get:function(e){var t=this,n={},o={type:"get",from:t.helpers.getUserCurrentJid(),id:i.getUniqueId("getRoster")},a=s.getEnv().browser?$iq:r.Stanza,c=i.createStanza(a,o,"iq");function l(r){for(var o=function(e){return s.getEnv().browser?e.getElementsByTagName("item"):e.getChild("query").children}(r),a=0,c=o.length;a<c;a++){var l=t.helpers.getIdFromNode(i.getAttr(o[a],"jid")),u=i.getAttr(o[a],"ask"),d=i.getAttr(o[a],"subscription");n[l]={subscription:d,ask:u||null}}e(n)}c.c("query",{xmlns:i.MARKERS.ROSTER}),s.getEnv().browser?t.connection.sendIQ(c,l):(t.nodeStanzasCallbacks[o.id]=l,t.Client.send(c))},add:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"none",ask:"subscribe"},this._sendSubscriptionPresence({jid:n,type:"subscribe"}),"function"==typeof t&&t()},confirm:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"from",ask:"subscribe"},this._sendSubscriptionPresence({jid:n,type:"subscribed"}),this._sendSubscriptionPresence({jid:n,type:"subscribe"}),"function"==typeof t&&t()},reject:function(e,t){var n=this.helpers.jidOrUserId(e),r=this.helpers.getIdFromNode(n).toString();this.contacts[r]={subscription:"none",ask:null},this._sendSubscriptionPresence({jid:n,type:"unsubscribed"}),"function"==typeof t&&t()},remove:function(e,t){var n=this,o=this.helpers.jidOrUserId(e),a=this.helpers.getIdFromNode(o),c={type:"set",from:n.connection?n.connection.jid:n.Client.jid.user,id:i.getUniqueId("getRoster")},l=s.getEnv().browser?$iq:r.Stanza,u=i.createStanza(l,c,"iq");function d(){delete n.contacts[a],"function"==typeof t&&t()}u.c("query",{xmlns:i.MARKERS.ROSTER}).c("item",{jid:o,subscription:"remove"}),s.getEnv().browser?n.connection.sendIQ(u,d):(n.nodeStanzasCallbacks[c.id]=d,n.Client.send(u))},_sendSubscriptionPresence:function(e){var t=s.getEnv().browser?$pres:r.Stanza,n={to:e.jid,type:e.type},o=i.createStanza(t,n,"presence");s.getEnv().browser?this.connection.send(o):this.Client.send(o)}},h.prototype={join:function(e,t){var n=this,o=i.getUniqueId("join"),a=this.helpers.getDialogJid(e),c={id:o,from:n.helpers.getUserCurrentJid(),to:n.helpers.getRoomJid(a)},l=s.getEnv().browser?$pres:r.Stanza,u=i.createStanza(l,c,"presence");function d(e){var r=i.getAttr(e,"id"),o=i.getAttr(e,"from"),a=n.helpers.getDialogIdFromNode(o),c=i.getElement(e,"x"),l=i.getAttr(c,"xmlns"),u=i.getElement(c,"status"),d=i.getAttr(u,"code");if(1==t.length)return s.safeCallbackCall(t,e),!0;if(u&&"110"==d)s.safeCallbackCall(t,null,{dialogId:a});else{var h=i.getAttr(e,"type");if(h&&"error"===h&&"http://jabber.org/protocol/muc"==l&&r.endsWith(":join")){var p=i.getElement(e,"error"),f=i.getAttr(p,"code"),m=i.getElementText(p,"text");s.safeCallbackCall(t,{code:f||500,message:m||"Unknown issue"},{dialogId:a})}}}u.c("x",{xmlns:i.MARKERS.MUC}).c("history",{maxstanzas:0}),this.joinedRooms[a]=!0,s.getEnv().browser?("function"==typeof t&&n.connection.XAddTrackedHandler(d,null,"presence",null,o),n.connection.send(u)):("function"==typeof t&&(n.nodeStanzasCallbacks[o]=d),n.Client.send(u))},leave:function(e,t){var n=this,o={type:"unavailable",from:n.helpers.getUserCurrentJid(),to:n.helpers.getRoomJid(e)},a=s.getEnv().browser?$pres:r.Stanza,c=i.createStanza(a,o,"presence");function l(e){var r=i.getAttr(e,"id"),o=i.getAttr(e,"from"),a=n.helpers.getDialogIdFromNode(o),c=i.getElement(e,"x"),l=i.getAttr(c,"xmlns"),u=i.getElement(c,"status"),d=i.getAttr(u,"code");if(u&&"110"==d)s.safeCallbackCall(t,null,{dialogId:a});else{var h=i.getAttr(e,"type");if(h&&"error"===h&&"http://jabber.org/protocol/muc"==l&&r.endsWith(":join")){var p=i.getElement(e,"error"),f=i.getAttr(p,"code"),m=i.getElementText(p,"text");s.safeCallbackCall(t,{code:f||500,message:m||"Unknown issue"},null)}}}if(delete this.joinedRooms[e],s.getEnv().browser){var u=n.helpers.getRoomJid(e);"function"==typeof t&&n.connection.XAddTrackedHandler(l,null,"presence",o.type,null,u),n.connection.send(c)}else"function"==typeof t&&(n.nodeStanzasCallbacks["muc:leave"]=l),n.Client.send(c)},listOnlineUsers:function(e,t){var n=this,o=[],a={type:"get",to:e,from:n.helpers.getUserCurrentJid(),id:i.getUniqueId("muc_disco_items")},c=s.getEnv().browser?$iq:r.Stanza,l=i.createStanza(c,a,"iq");l.c("query",{xmlns:"http://jabber.org/protocol/disco#items"}),s.getEnv().browser?n.connection.sendIQ(l,function(e){for(var r,i=e.getElementsByTagName("item"),s=0,a=i.length;s<a;s++)r=n.helpers.getUserIdFromRoomJid(i[s].getAttribute("jid")),o.push(parseInt(r));t(o)}):(n.Client.send(l),n.nodeStanzasCallbacks[a.id]=function(e){var r=e.attrs.id;if(n.nodeStanzasCallbacks[r]){for(var i,o=[],s=e.getChild("query").getChildElements("item"),a=0,c=s.length;a<c;a++)i=n.helpers.getUserIdFromRoomJid(s[a].attrs.jid),o.push(parseInt(i));t(o)}})}},p.prototype={create:function(e,t){for(var n,o,a,c,l,u,d={},h=e.items.length-1;h>=0;h--){var p=e.items[h];d[p.user_id]={action:p.action,mutualBlock:!0===p.mutualBlock}}u=Object.keys(d);var f={type:"set",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("edit")},m=s.getEnv().browser?$iq:r.Stanza,g=i.createStanza(m,f,"iq");function v(e,t){s.getEnv().browser?e.c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up():e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).c("message",{}).up().c("presence-in",{}).up().c("presence-out",{}).up().c("iq",{}).up().up();return e}function y(e,t){s.getEnv().browser?e.c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up():e.getChild("query").getChild("list").c("item",{type:"jid",value:t.jidOrMuc,action:t.userAction,order:t.order}).up();return e}g.c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e.name});for(var b=0,S=0,_=u.length;b<_;b++,S+=2)l=d[n=u[b]].mutualBlock,c=d[n].action,o=this.helpers.jidOrUserId(parseInt(n,10)),a=this.helpers.getUserNickWithMucDomain(n),l&&"deny"===c?(g=y(g,{order:S+1,jidOrMuc:o,userAction:c}),g=y(g,{order:S+2,jidOrMuc:a,userAction:c}).up().up()):(g=v(g,{order:S+1,jidOrMuc:o,userAction:c}),g=v(g,{order:S+2,jidOrMuc:a,userAction:c}));s.getEnv().browser?this.connection.sendIQ(g,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))}):(this.Client.send(g),this.nodeStanzasCallbacks[f.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)})},getList:function(e,t){var n,o,a,c=this,l=[],u={type:"get",from:c.helpers.getUserCurrentJid(),id:i.getUniqueId("getlist")},d=s.getEnv().browser?$iq:r.Stanza,h=i.createStanza(d,u,"iq");h.c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e}),s.getEnv().browser?c.connection.sendIQ(h,function(r){for(var i=0,s=(n=r.getElementsByTagName("item")).length;i<s;i+=2)o=n[i].getAttribute("value"),a=c.helpers.getIdFromNode(o),l.push({user_id:a,action:n[i].getAttribute("action")});t(null,{name:e,items:l})},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n,null)}else t(s.getError(408),null)}):(c.nodeStanzasCallbacks[u.id]=function(e){for(var n,r,i=e.getChild("query"),o=i?i.getChild("list"):null,s=o?o.getChildElements("item"):null,a=[],l=0,d=s.length;l<d;l+=2)n=s[l].attrs.value,r=c.helpers.getIdFromNode(n),a.push({user_id:r,action:s[l].attrs.action});o={name:o.attrs.name,items:a},t(null,o),delete c.nodeStanzasCallbacks[u.id]},c.Client.send(h))},update:function(e,t){var n=this;n.getList(e.name,function(r,i){if(r)t(r,null);else{var o={};o.items=s.MergeArrayOfObjects(i.items,e.items),o.name=e.name,n.create(o,function(e,n){r?t(e,null):t(null,n)})}})},getNames:function(e){var t,n={type:"get",from:this.helpers.getUserCurrentJid(),id:i.getUniqueId("getNames")};s.getEnv().browser?(t=$iq(n).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}),this.connection.sendIQ(t,function(t){for(var n=[],r=t.getElementsByTagName("default"),i=t.getElementsByTagName("active"),o=t.getElementsByTagName("list"),s=r&&r.length>0?r[0].getAttribute("name"):null,a=i&&i.length>0?i[0].getAttribute("name"):null,c=0,l=o.length;c<l;c++)n.push(o[c].getAttribute("name"));e(null,{default:s,active:a,names:n})},function(t){if(t){var n=i.getErrorFromXMLNode(t);e(n,null)}else e(s.getError(408),null)})):((t=new r.Stanza("iq",n)).c("query",{xmlns:i.MARKERS.PRIVACY}),this.nodeStanzasCallbacks[t.attrs.id]=function(t){if("error"!==t.attrs.type){for(var n=[],r=t.getChild("query"),i=r.getChild("default"),o=r.getChild("active"),a=r.getChildElements("list"),c=i?i.attrs.name:null,l=o?o.attrs.name:null,u=0,d=a.length;u<d;u++)n.push(a[u].attrs.name);e(null,{default:c,active:l,names:n})}else e(s.getError(408))},this.Client.send(t))},delete:function(e,t){var n,o={from:this.connection?this.connection.jid:this.Client.jid.user,type:"set",id:i.getUniqueId("remove")};s.getEnv().browser?(n=$iq(o).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("list",{name:e||""}),this.connection.sendIQ(n,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((n=new r.Stanza("iq",o)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("list",{name:e||""}),this.nodeStanzasCallbacks[o.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)},this.Client.send(n))},setAsDefault:function(e,t){var n,o=this,a={from:this.connection?this.connection.jid:this.Client.jid.user,type:"set",id:i.getUniqueId("default")};function c(n){var o,a={from:n.connection?n.connection.jid:n.Client.jid.user,type:"set",id:i.getUniqueId("active1")};s.getEnv().browser?(o=$iq(a).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("active",e&&e.length>0?{name:e}:{}),n.connection.sendIQ(o,function(e){t(null)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((o=new r.Stanza("iq",a)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("active",e&&e.length>0?{name:e}:{}),n.nodeStanzasCallbacks[a.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):t(null)},n.Client.send(o))}s.getEnv().browser?(n=$iq(a).c("query",{xmlns:Strophe.NS.PRIVACY_LIST}).c("default",e&&e.length>0?{name:e}:{}),this.connection.sendIQ(n,function(e){c(o)},function(e){if(e){var n=i.getErrorFromXMLNode(e);t(n)}else t(s.getError(408))})):((n=new r.Stanza("iq",a)).c("query",{xmlns:i.MARKERS.PRIVACY}).c("default",e&&e.length>0?{name:e}:{}),this.nodeStanzasCallbacks[a.id]=function(e){e.getChildElements("error").length?t(s.getError(408)):c(o)},this.Client.send(n))}},f.prototype={getUniqueId:i.getUniqueId,jidOrUserId:function(e){var t;if("string"==typeof e)t=e;else{if("number"!=typeof e)throw new Error('The method "jidOrUserId" may take jid or id');t=e+"-"+o.creds.appId+"@"+o.endpoints.chat}return t},typeChat:function(e){var t;if("string"==typeof e)t=e.indexOf("muc")>-1?"groupchat":"chat";else{if("number"!=typeof e)throw new Error(c);t="chat"}return t},getRecipientId:function(e,t){var n=null;return e.forEach(function(e){e!=t&&(n=e)}),n},getUserJid:function(e,t){return t?e+"-"+t+"@"+o.endpoints.chat:e+"-"+o.creds.appId+"@"+o.endpoints.chat},getUserNickWithMucDomain:function(e){return o.endpoints.muc+"/"+e},getIdFromNode:function(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])},getDialogIdFromNode:function(e){return e.indexOf("@")<0?null:e.split("@")[0].split("_")[1]},getRoomJidFromDialogId:function(e){return o.creds.appId+"_"+e+"@"+o.endpoints.muc},getRoomJid:function(e){return e+"/"+this.getIdFromNode(this._userCurrentJid)},getIdFromResource:function(e){var t=e.split("/");return t.length<2?null:(t.splice(0,1),parseInt(t.join("/")))},getRoomJidFromRoomFullJid:function(e){var t=e.split("/");return t.length<2?null:t[0]},getBsonObjectId:function(){return s.getBsonObjectId()},getUserIdFromRoomJid:function(e){var t=e.toString().split("/");return 0===t.length?null:t[t.length-1]},userCurrentJid:function(e){try{return e instanceof Strophe.Connection?e.jid:e.jid.user+"@"+e.jid._domain+"/"+e.jid._resource}catch(t){return e.jid.user+"@"+e.jid._domain+"/"+e.jid._resource}},getUserCurrentJid:function(){return this._userCurrentJid},setUserCurrentJid:function(e){this._userCurrentJid=e},getDialogJid:function(e){return e.indexOf("@")>0?e:this.getRoomJidFromDialogId(e)}},t.exports=u},{"../../plugins/streamManagement":150,"../../qbConfig":151,"../../qbStrophe":154,"../../qbUtils":155,"./qbChatHelpers":133,"nativescript-xmpp-client":void 0,"node-xmpp-client":60}],133:[function(e,t,n){"use strict";var r=e("../../qbUtils"),i=e("../../qbConfig"),o="Unknown interface. SDK support browser / node env.";function s(e,t,n){var r=new Error(e,t,n);return r.name="ChatNotConnectedError",Object.setPrototypeOf(r,Object.getPrototypeOf(this)),Error.captureStackTrace&&Error.captureStackTrace(r,s),r}s.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(s,Error):s.__proto__=Error;var a={MARKERS:{CLIENT:"jabber:client",CHAT:"urn:xmpp:chat-markers:0",STATES:"http://jabber.org/protocol/chatstates",MARKERS:"urn:xmpp:chat-markers:0",CARBONS:"urn:xmpp:carbons:2",ROSTER:"jabber:iq:roster",MUC:"http://jabber.org/protocol/muc",PRIVACY:"jabber:iq:privacy",LAST:"jabber:iq:last"},ChatNotConnectedError:s,buildUserJid:function(e){var t;return"userId"in e?(t=e.userId+"-"+i.creds.appId+"@"+i.endpoints.chat,"resource"in e&&(t=t+"/"+e.resource)):"jid"in e&&(t=e.jid),t},createStanza:function(e,t,n){return r.getEnv().browser?e(t):new e(n||"message",t)},getAttr:function(e,t){var n;return e?("function"==typeof e.getAttribute?n=e.getAttribute(t):e.attrs&&(n=e.attrs[t]),n||null):null},getElement:function(e,t){var n;if("function"==typeof e.querySelector)n=e.querySelector(t);else{if("function"!=typeof e.getChild)throw o;n=e.getChild(t)||e.children.find(e=>"function"==typeof e.getChild&&this.getElement(e,t))}return n||null},getAllElements:function(e,t){var n;if("function"==typeof e.querySelectorAll)n=e.querySelectorAll(t);else{if("function"!=typeof e.getChild)throw o;n=e.getChild(t)}return n||null},getElementText:function(e,t){var n,r;if("function"==typeof e.querySelector)r=(n=e.querySelector(t))?n.textContent:null;else{if("function"!=typeof e.getChildText)throw o;r=e.getChildText(t)||e.children.find(e=>"function"==typeof e.getChildText&&this.getElementText(e,t))}return r||null},_JStoXML:function(e,t,n){var r=this;n.c(e),Object.keys(t).forEach(function(e){"object"==typeof t[e]?r._JStoXML(e,t[e],n):n.c(e).t(t[e]).up()}),n.up()},_XMLtoJS:function(e,t,n){e[t]={};for(var r=0,i=n.childNodes.length;r<i;r++)n.childNodes[r].childNodes.length>1?e[t]=this._XMLtoJS(e[t],n.childNodes[r].tagName,n.childNodes[r]):e[t][n.childNodes[r].tagName]=n.childNodes[r].textContent;return e},filledExtraParams:function(e,t){var n=this;return Object.keys(t).forEach(function(i){"attachments"===i?t[i].forEach(function(t){r.getEnv().browser?e.c("attachment",t).up():e.getChild("extraParams").c("attachment",t).up()}):"object"==typeof t[i]?n._JStoXML(i,t[i],e):r.getEnv().browser?e.c(i).t(t[i]).up():e.getChild("extraParams").c(i).t(t[i]).up()}),e.up(),e},parseExtraParams:function(e){if(!e)return null;var t,n,i,o={},s=[];if(r.getEnv().browser)for(var a=0,c=e.childNodes.length;a<c;a++)if("attachment"===e.childNodes[a].tagName){n={};for(var l=0,u=(i=e.childNodes[a].attributes).length;l<u;l++)"size"===i[l].name?n[i[l].name]=parseInt(i[l].value):n[i[l].name]=i[l].value;s.push(n)}else if("dialog_id"===e.childNodes[a].tagName)t=e.childNodes[a].textContent,o.dialog_id=t;else{if(e.childNodes[a].childNodes.length>1)if(e.childNodes[a].textContent.length>4096){for(var d="",h=0;h<e.childNodes[a].childNodes.length;++h)d+=e.childNodes[a].childNodes[h].textContent;o[e.childNodes[a].tagName]=d}else o=this._XMLtoJS(o,e.childNodes[a].tagName,e.childNodes[a]);else o[e.childNodes[a].tagName]=e.childNodes[a].textContent}else for(var p=0,f=e.children.length;p<f;p++){if("attachment"===e.children[p].name){n={},i=e.children[p].attrs;for(var m=Object.keys(i),g=0;g<m.length;g++)"size"===m[g]?n.size=parseInt(i.size):n[m[g]]=i[m[g]];s.push(n)}else"dialog_id"===e.children[p].name&&(t=e.getChildText("dialog_id"),o.dialog_id=t);if(1===e.children[p].children.length){var v=e.children[p];o[v.name]=v.children[0]}}if(s.length>0&&(o.attachments=s),o.moduleIdentifier&&delete o.moduleIdentifier,o.date_sent){var y=Number(o.date_sent);Number.isFinite(y)&&(o.date_sent=Math.trunc(y).toString())}return{extension:o,dialogId:t}},getUniqueId:function(e){var t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)});return"string"==typeof e||"number"==typeof e?t+":"+e:t+""},getErrorFromXMLNode:function(e){var t=this.getElement(e,"error"),n=parseInt(this.getAttr(t,"code")),i=this.getElementText(t,"text");return r.getError(n,i)},getLocalTime:function(){return(new Date).toTimeString().split(" ")[0]}};t.exports=a},{"../../qbConfig":151,"../../qbUtils":155}],134:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("../../qbUtils"),o=r.urls.chat+"/Dialog";function s(e){this.service=e}s.prototype={list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e={}),this.service.ajax({url:i.getUrl(o),data:e},t)},create:function(e,t){e&&e.occupants_ids&&i.isArray(e.occupants_ids)&&(e.occupants_ids=e.occupants_ids.join(", ")),e&&void 0!==e.is_join_required&&null!==e.is_join_required&&0!==e.is_join_required&&1!==e.is_join_required&&(i.QBLog("[QBChat]","Warning: is_join_required must be 0 or 1, got: "+e.is_join_required+". Parameter ignored."),delete e.is_join_required),this.service.ajax({url:i.getUrl(o),type:"POST",data:e},t)},update:function(e,t,n){t&&void 0!==t.is_join_required&&(i.QBLog("[QBChat]","Warning: is_join_required is not supported in dialog.update(). Parameter ignored."),delete t.is_join_required),this.service.ajax({url:i.getUrl(o,e),type:"PUT",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:t},n)},delete:function(e,t,n){var r={url:i.getUrl(o,e),type:"DELETE",dataType:"text"};2===arguments.length?this.service.ajax(r,t):3===arguments.length&&(r.data=t,this.service.ajax(r,n))}},t.exports=s},{"../../qbConfig":151,"../../qbUtils":155}],135:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("../../qbUtils"),o=r.urls.chat+"/Message";function s(e){this.service=e}s.prototype={list:function(e,t){this.service.ajax({url:i.getUrl(o),data:e},t)},create:function(e,t){this.service.ajax({url:i.getUrl(o),type:"POST",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:e},t)},update:function(e,t,n){var r={type:"PUT",dataType:"text",url:i.getUrl(o,e),data:t};this.service.ajax(r,n)},delete:function(e,t,n){var r={url:i.getUrl(o,e),type:"DELETE",dataType:"text"};2===arguments.length?this.service.ajax(r,t):3===arguments.length&&(r.data=t,this.service.ajax(r,n))},unreadCount:function(e,t){e&&e.chat_dialog_ids&&i.isArray(e.chat_dialog_ids)&&(e.chat_dialog_ids=e.chat_dialog_ids.join()),this.service.ajax({url:i.getUrl(o+"/unread"),data:e},t)}},t.exports=s},{"../../qbConfig":151,"../../qbUtils":155}],136:[function(e,t,n){"use strict";var r=e("../qbUtils"),i="ai/ai_extensions";function o(e){this.service=e}o.prototype={answerAssist:function(e,t,n,o){if(!o||"function"!=typeof o)throw new Error("Callback function is required and must be a function");if(function(e){var t="user",n="assistant";if(null!=e){if(!Array.isArray(e))throw new Error("History must be an array");for(var r=0;r<e.length;r++){var i=e[r];if("object"!=typeof i||null===i||Array.isArray(i))throw new Error("Each element of history must be an object");if(!("role"in i&&"message"in i))throw new Error("Each element of history must have an role and message fields");if(i.role!==t&&i.role!==n)throw new Error("Invalid role in history item");if("string"!=typeof i.message)throw new Error("Message of history item must be a string")}}return!0}(n)){var s=n?{smart_chat_assistant_id:e,message:t,history:n}:{smart_chat_assistant_id:e,message:t},a={type:"POST",url:r.formatUrl(i+"/ai_answer_assist"),data:s,contentType:"application/json; charset=utf-8",isNeedStringify:!0};this.service.ajax(a,o)}},translate:function(e,t,n,o){if(!o||"function"!=typeof o)throw new Error("Callback function is required and must be a function");var s={smart_chat_assistant_id:e,text:t,to_language:n||"en"},a={type:"POST",url:r.formatUrl(i+"/ai_translate"),data:s};this.service.ajax(a,o)},gateway:function(e,t,n,o){var s,a;if("function"==typeof n?(a=n,s={}):(s=n||{},a=o),!a||"function"!=typeof a)throw new Error("Callback function is required and must be a function");if(!e||"string"!=typeof e)throw new Error("smartChatAssistantId is required and must be a string");this._validateGatewayMessages(t);var c={smart_chat_assistant_id:e,messages:t},l={type:"POST",url:r.formatUrl(i+"/ai_gateway"),data:c,contentType:"application/json; charset=utf-8",isNeedStringify:!0};s.apiKey&&(l.headers={Authorization:"ApiKey "+s.apiKey}),this.service.ajax(l,a)},_validateGatewayMessages:function(e){var t=["user","assistant","developer"],n=["text","image_url"];if(!e||!Array.isArray(e))throw new Error("messages is required and must be an array");if(0===e.length)throw new Error("messages array cannot be empty");for(var r=0;r<e.length;r++){var i=e[r];if("object"!=typeof i||null===i||Array.isArray(i))throw new Error("Each message must be an object");if(!i.role||-1===t.indexOf(i.role))throw new Error("Each message must have a valid role (user, assistant, or developer)");if(void 0===i.content||null===i.content)throw new Error("Each message must have content (string or array)");if("string"!=typeof i.content){if(!Array.isArray(i.content))throw new Error("Message content must be a string or array");if(0===i.content.length)throw new Error("Content array cannot be empty");for(var o=0;o<i.content.length;o++){var s=i.content[o];if("object"!=typeof s||null===s)throw new Error("Each content item must be an object");if(!s.type||-1===n.indexOf(s.type))throw new Error("Each content item must have a valid type (text or image_url)");if("text"===s.type){if("string"!=typeof s.text)throw new Error("Text content item must have a text string")}else if("image_url"===s.type&&(!s.image_url||"string"!=typeof s.image_url.url))throw new Error("Image content item must have image_url.url string")}}else if(0===i.content.length)throw new Error("String content cannot be empty")}return!0},summarize:function(e,t,n){if(!n||"function"!=typeof n)throw new Error("Callback function is required and must be a function");if(!e||"string"!=typeof e)throw new Error("smartChatAssistantId is required and must be a string");if(!t||"string"!=typeof t)throw new Error("dialogId is required and must be a string");var o={smart_chat_assistant_id:e,dialog_id:t},s={type:"POST",url:r.formatUrl(i+"/ai_summarize"),data:o,contentType:"application/json; charset=utf-8",isNeedStringify:!0};this.service.ajax(s,n)}},t.exports=o},{"../qbUtils":155}],137:[function(e,t,n){"use strict";var r=e("../qbUtils"),i=e("../qbConfig");function o(e){this.service=e}function s(e){return!!(e&&e.constructor&&e.call&&e.apply)}o.prototype={uploadAddressBook:function(e,t,n){if(Array.isArray(e)){var o,a;s(t)?a=t:(o=t,a=n);var c={contacts:e};o&&(o.force&&(c.force=o.force),o.udid&&(c.udid=o.udid)),this.service.ajax({type:"POST",url:r.getUrl(i.urls.addressbook),data:c,contentType:"application/json; charset=utf-8",isNeedStringify:!0},function(e,t){e?a(e,null):a(null,t)})}else new Error("First parameter must be an Array.")},_isFakeErrorEmptyAddressBook:function(e){var t=e.detail?e.detail:e.message.errors;return 404===e.code&&"Empty address book"===t[0]},get:function(e,t){var n,o,a=this;if(s(e)?o=e:(n=e,o=t),!s(o))throw new Error("The QB.addressbook.get accept callback function is required.");var c={type:"GET",url:r.getUrl(i.urls.addressbook),contentType:"application/json; charset=utf-8",isNeedStringify:!0};n&&(c.data={udid:n}),this.service.ajax(c,function(e,t){e?a._isFakeErrorEmptyAddressBook(e)?o(null,[]):o(e,null):o(null,t)})},getRegisteredUsers:function(e,t){var n,o,a=this;if(s(e)?o=e:(n=e,o=t),!s(o))throw new Error("The QB.addressbook.get accept callback function is required.");var c={type:"GET",url:r.getUrl(i.urls.addressbookRegistered),contentType:"application/json; charset=utf-8"};n&&(c.data={compact:1}),this.service.ajax(c,function(e,t){e?a._isFakeErrorEmptyAddressBook(e)?o(null,[]):o(e,null):o(null,t)})}},t.exports=o},{"../qbConfig":151,"../qbUtils":155}],138:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o=e("crypto-js/hmac-sha1"),s=e("crypto-js/hmac-sha256");function a(e){this.service=e}a.prototype={getSession:function(e){this.service.ajax({url:i.getUrl(r.urls.session)},function(t,n){e(t,t?null:n)})},createSession:function(e,t){if(""===r.creds.appId||""===r.creds.authKey||""===r.creds.authSecret)throw new Error("Cannot create a new session without app credentials (app ID, auth key and auth secret)");var n,a=this;"function"==typeof e&&void 0===t&&(t=e,e={}),(n=function(e){var t={application_id:r.creds.appId,auth_key:r.creds.authKey,nonce:i.randomNonce(),timestamp:i.unixTime()};e.login&&e.password?t.user={login:e.login,password:e.password}:e.email&&e.password?t.user={email:e.email,password:e.password}:e.provider&&(t.provider=e.provider,e.scope&&(t.scope=e.scope),e.keys&&e.keys.token&&(t.keys={token:e.keys.token}),e.keys&&e.keys.secret&&(t.keys.secret=e.keys.secret));return t}(e)).signature=function(e,t){var n,i=Object.keys(e).map(function(t){return"object"==typeof e[t]?Object.keys(e[t]).map(function(n){return t+"["+n+"]="+e[t][n]}).sort().join("&"):t+"="+e[t]}).sort().join("&");if("sha1"===r.hash)n=o(i,t).toString();else{if("sha256"!==r.hash)throw new Error("Quickblox SDK: unknown crypto standards, available sha1 or sha256");n=s(i,t).toString()}return n}(n,r.creds.authSecret),this.service.ajax({url:i.getUrl(r.urls.session),type:"POST",data:n},function(e,n){e?t(e,null):(a.service.setSession(n.session),t(null,n.session))})},destroySession:function(e){var t=this;this.service.ajax({url:i.getUrl(r.urls.session),type:"DELETE",dataType:"text"},function(n,r){n?e(n,null):(t.service.setSession(null),e(null,r))})},login:function(e,t){var n={type:"POST",url:i.getUrl(r.urls.login),data:e};this.service.ajax(n,function(e,n){e?t(e,null):t(null,n.user)})},logout:function(e){this.service.ajax({url:i.getUrl(r.urls.login),type:"DELETE",dataType:"text"},e)}},t.exports=a},{"../qbConfig":151,"../qbUtils":155,"crypto-js/hmac-sha1":30,"crypto-js/hmac-sha256":31}],139:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils");function o(e){this.service=e}function s(e){for(var t=s.options,n=t.parser[t.strictMode?"strict":"loose"].exec(e),r={},i=14;i--;)r[t.key[i]]=n[i]||"";return r[t.q.name]={},r[t.key[12]].replace(t.q.parser,function(e,n,i){n&&(r[t.q.name][n]=i)}),r}o.prototype={list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e=null),this.service.ajax({url:i.getUrl(r.urls.blobs),data:e,type:"GET"},function(e,n){t(e,e?null:n)})},create:function(e,t){this.service.ajax({type:"POST",data:{blob:e},url:i.getUrl(r.urls.blobs)},function(e,n){t(e,e?null:n.blob)})},delete:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e),type:"DELETE",dataType:"text"},function(e,n){e?t(e,null):t(null,!0)})},createAndUpload:function(e,t){var n,r,i,o,a,c=this,l={};JSON.parse(JSON.stringify(e)).file.data="...",n=e.file,r=e.name||n.name,i=e.type||n.type,o=e.size||n.size,l.name=r,l.content_type=i,e.public&&(l.public=e.public),e.tag_list&&(l.tag_list=e.tag_list),this.create(l,function(e,i){if(e)t(e,null);else{var l=s(i.blob_object_access.params),u={url:l.protocol+"://"+l.authority+l.path},d={};a=i.id,i.size=o,Object.keys(l.queryKey).forEach(function(e){d[e]=decodeURIComponent(l.queryKey[e])}),d.file=n,d.name=r,u.data=d,c.upload(u,function(e,n){e?t(e,null):c.markUploaded({id:a,size:o},function(e,n){e?t(e,null):t(null,i)})})}})},upload:function(e,t){var n=Object.assign({},e.data),r={data:e.data.file,name:e.data.name||e.data.file.name};n.file=r;var i={type:"POST",dataType:"text",contentType:!1,url:e.url,data:n,fileToCustomObject:!0};this.service.ajax(i,function(e,n){e?t(e,null):t(null,{})})},markUploaded:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e.id+"/complete"),type:"PUT",data:{size:e.size},dataType:"text"},function(e,n){e?t(e,null):t(null,n)})},getInfo:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e)},function(e,n){e?t(e,null):t(null,n)})},getFile:function(e,t){this.service.ajax({url:i.getUrl(r.urls.blobs,e)},function(e,n){e?t(e,null):t(null,n)})},update:function(e,t){var n={blob:{}};void 0!==e.name&&(n.blob.name=e.name),this.service.ajax({url:i.getUrl(r.urls.blobs,e.id),data:n},function(e,n){e?t(e,null):t(null,n)})},privateUrl:function(e){return"https://"+r.endpoints.api+"/blobs/"+e+"?token="+this.service.getSession().token},publicUrl:function(e){return"https://"+r.endpoints.api+"/blobs/"+e}},t.exports=o,s.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}}},{"../qbConfig":151,"../qbUtils":155}],140:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils");function o(e){this.service=e}o.prototype={create:function(e,t,n){var o={type:"POST",data:t,isNeedStringify:!0,contentType:"application/json; charset=utf-8",url:i.getUrl(r.urls.data,e)};this.service.ajax(o,function(e,t){n(e,e?null:t)})},list:function(e,t,n){void 0===n&&"function"==typeof t&&(n=t,t=null),this.service.ajax({url:i.getUrl(r.urls.data,e),data:t},function(e,t){n(e,e?null:t)})},update:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t._id),type:"PUT",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:t},function(e,t){n(e,e?null:t)})},delete:function(e,t,n){var o,s={id:1,ids:2,criteria:3},a={deleted:[],deletedCount:0},c={type:"DELETE",dataType:"text"};"string"==typeof t?o=s.id:i.isArray(t)?o=s.ids:i.isObject(t)&&(o=s.criteria),o===s.id?c.url=i.getUrl(r.urls.data,e+"/"+t):o===s.ids?c.url=i.getUrl(r.urls.data,e+"/"+t.toString()):o===s.criteria&&(c.url=i.getUrl(r.urls.data,e+"/by_criteria"),c.data=t),this.service.ajax(c,function(e,r){var i;e?n(e,null):(o===s.id?(a.deleted.push(t),a.deletedCount=a.deleted.length):o===s.ids?(i=JSON.parse(r),a.deleted=i.SuccessfullyDeleted.ids.slice(0),a.deletedCount=a.deleted.length):o===s.criteria&&(i=JSON.parse(r),a.deleted=null,a.deletedCount=i.total_deleted),n(e,a))})},uploadFile:function(e,t,n){var o={field_name:t.field_name,file:{data:t.file,name:t.name}};this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t.id+"/file"),type:"POST",fileToCustomObject:!0,contentType:!1,data:o},function(e,t){n(e,e?null:t)})},downloadFile:function(e,t,n){var o=i.getUrl(r.urls.data,e+"/"+t.id+"/file");n(null,o+="?field_name="+t.field_name+"&token="+this.service.getSession().token)},fileUrl:function(e,t){var n=i.getUrl(r.urls.data,e+"/"+t.id+"/file");return n+="?field_name="+t.field_name+"&token="+this.service.getSession().token},deleteFile:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.data,e+"/"+t.id+"/file"),data:{field_name:t.field_name},dataType:"text",type:"DELETE"},function(e,t){n(e,!e||null)})}},t.exports=o},{"../qbConfig":151,"../qbUtils":155}],141:[function(e,t,n){(function(n){(function(){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o="undefined"!=typeof window;function s(e){this.service=e}function a(e){this.service=e}s.prototype={create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.subscriptions),type:"POST",data:e},t)},list:function(e){this.service.ajax({url:i.getUrl(r.urls.subscriptions)},e)},delete:function(e,t){var n={type:"DELETE",dataType:"text",url:i.getUrl(r.urls.subscriptions,e)};this.service.ajax(n,function(e,n){e?t(e,null):t(null,!0)})}},a.prototype={create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events),type:"POST",contentType:"application/json; charset=utf-8",isNeedStringify:!0,data:{event:e}},t)},list:function(e,t){"function"==typeof e&&void 0===t&&(t=e,e=null),this.service.ajax({url:i.getUrl(r.urls.events),data:e},t)},get:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e)},t)},delete:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e),dataType:"text",type:"DELETE"},t)},status:function(e,t){this.service.ajax({url:i.getUrl(r.urls.events,e+"/status")},t)}},t.exports=function(e){this.service=e,this.subscriptions=new s(e),this.events=new a(e),this.base64Encode=function(e){return o?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)})):new n(e).toString("base64")}}}).call(this)}).call(this,e("buffer").Buffer)},{"../qbConfig":151,"../qbUtils":155,buffer:27}],142:[function(e,t,n){"use strict";var r=e("../qbConfig"),i=e("../qbUtils"),o=["created_at","updated_at","last_request_at"],s=["id","external_user_id"],a=r.urls.users+"/password/reset";function c(e){this.service=e}function l(e){var t=e.field in o?"date":typeof e.value;return i.isArray(e.value)&&("object"===t&&(t=typeof e.value[0]),e.value=e.value.toString()),[t,e.field,e.param,e.value].join(" ")}c.prototype={listUsers:function(e,t){var n,a,c,u={},d=[];"function"==typeof e&&void 0===t&&(t=e,e={}),e&&e.filter&&(i.isArray(e.filter)?e.filter.forEach(function(e){n=l(e),d.push(n)}):(n=l(e.filter),d.push(n)),u.filter=d),e.order&&(u.order=(a=e.order,c=a.field in o?"date":a.field in s?"number":"string",[a.sort,c,a.field].join(" "))),e.page&&(u.page=e.page),e.per_page&&(u.per_page=e.per_page),this.service.ajax({url:i.getUrl(r.urls.users),data:u},t)},get:function(e,t){var n;"number"==typeof e?(n=e,e={}):e.login?n="by_login":e.full_name?n="by_full_name":e.facebook_id?n="by_facebook_id":e.twitter_id?n="by_twitter_id":e.phone?n="phone":e.email?n="by_email":e.tags?n="by_tags":e.external&&(n="external/"+e.external,e={}),this.service.ajax({url:i.getUrl(r.urls.users,n),data:e},function(e,n){e?t(e,null):t(null,n.user||n)})},create:function(e,t){this.service.ajax({url:i.getUrl(r.urls.users),type:"POST",data:{user:e}},function(e,n){e?t(e,null):t(null,n.user)})},update:function(e,t,n){this.service.ajax({url:i.getUrl(r.urls.users,e),type:"PUT",data:{user:t}},function(e,t){e?n(e,null):n(null,t.user)})},delete:function(e,t){var n;"number"==typeof e?n=e:e.external&&(n="external/"+e.external),this.service.ajax({url:i.getUrl(r.urls.users,n),type:"DELETE",dataType:"text"},t)},resetPassword:function(e,t){this.service.ajax({url:i.getUrl(a),data:{email:e},dataType:"text"},t)}},t.exports=c},{"../qbConfig":151,"../qbUtils":155}],143:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("./qbWebRTCHelpers"),o=function(e){this._pc=new window.RTCPeerConnection(e),this.remoteStream=void 0,this.preferredCodec="VP8"};function s(e,t,n,r,i,o){if(void 0===o&&(o="asc"),"asc"===(o=o||"asc")){for(var s=-1!==n?n:e.length,a=t;a<s;++a)if(0===e[a].indexOf(r)&&(!i||-1!==e[a].toLowerCase().indexOf(i.toLowerCase())))return a}else for(var c=-1!==t?t:e.length-1;c>=0;--c)if(0===e[c].indexOf(r)&&(!i||-1!==e[c].toLowerCase().indexOf(i.toLowerCase())))return c;return null}function a(e,t){var n=e.split(" "),r=n.slice(0,3);r.push(t);for(var i=3;i<n.length;i++)n[i]!==t&&r.push(n[i]);return r.join(" ")}function c(e,t,n){if(!n)return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"");for(var r=e.split("\n"),o=-1,s=i.getVersionFirefox()?"TIAS":"AS",a=i.getVersionFirefox()?1024*n:n,c=0;c<r.length;c++)if(0===r[c].indexOf("m="+t)){o=c;break}if(-1===o)return e;for(o++;0===r[o].indexOf("i=")||0===r[o].indexOf("c=");)o++;if(0===r[o].indexOf("b"))return r[o]="b="+s+":"+a,r.join("\n");var l=r.slice(0,o);return l.push("b="+s+":"+a),(l=l.concat(r.slice(o,r.length))).join("\n")}o.State={NEW:1,CONNECTING:2,CHECKING:3,CONNECTED:4,DISCONNECTED:5,FAILED:6,CLOSED:7,COMPLETED:8},o.prototype._init=function(e,t,n,r){i.trace("RTCPeerConnection init.","userID: ",t,", sessionID: ",n,", polite: ",r),this.delegate=e,this.localIceCandidates=[],this.remoteIceCandidates=[],this.remoteSDP=void 0,this.sessionID=n,this.polite=r,this.userID=t,this._reconnecting=!1,this.state=o.State.NEW,this._pc.onicecandidate=this.onIceCandidateCallback.bind(this),this._pc.onsignalingstatechange=this.onSignalingStateCallback.bind(this),this._pc.oniceconnectionstatechange=this.onIceConnectionStateCallback.bind(this),this._pc.ontrack=this.onTrackCallback.bind(this),this.dialingTimer=null,this.answerTimeInterval=0,this.statsReportTimer=null},o.prototype.release=function(){this._clearDialingTimer(),this._clearStatsReportTimer(),this._pc.close(),this.state=o.State.CLOSED,this._pc.onicecandidate=null,this._pc.onsignalingstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.ontrack=null,navigator.userAgent.includes("Edge")&&(this.connectionState="closed",this.iceConnectionState="closed")},o.prototype.negotiate=function(){var e=this;return this.setLocalSessionDescription({type:"offer",options:{iceRestart:!0}},function(t){if(t)return i.traceError("Error in 'negotiate': "+t);var n=e._pc.localDescription.toJSON();e.delegate.update({reason:"reconnect",sessionDescription:{offerId:e.offerId,sdp:n.sdp,type:n.type}},e.userID)})},o.prototype.setRemoteSDP=function(e){if(!e)throw new Error("sdp string can't be empty.");this.remoteSDP=e},o.prototype.getRemoteSDP=function(){return this.remoteSDP},o.prototype.setLocalSessionDescription=function(e,t){var n=this;function r(e){var r=function(e){e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n"));return e}(e);r.sdp=function(e,t,n){if(!n)return e;var r=e.split("\r\n"),i=s(r,0,-1,"m=",t);if(null===i)return e;for(var o=null,c=r.length-1;c>=0;--c){var l=s(r,c,0,"a=rtpmap",n,"desc");if(null===l)break;c=l,u=r[l],d=void 0,h=void 0,d=new RegExp("a=rtpmap:(\\d+) [a-zA-Z0-9-]+\\/\\d+"),h=u.match(d),(o=h&&2===h.length?h[1]:null)&&(r[i]=a(r[i],o))}var u,d,h;return e=r.join("\r\n")}(r.sdp,"video",n.preferredCodec),n.delegate.bandwidth&&(r.sdp=c(r.sdp,"video",n.delegate.bandwidth)),n._pc.setLocalDescription(r).then(function(){t(null)}).catch(function(e){i.traceError("Error in 'setLocalSessionDescription': "+e),t(e)})}n.state=o.State.CONNECTING,window.RTCRtpTransceiver&&"setCodecPreferences"in window.RTCRtpTransceiver.prototype&&Boolean(i.getVersionSafari())&&n._pc.getTransceivers().forEach(function(e){var t=e.sender.track.kind,r=window.RTCRtpSender.getCapabilities(t).codecs,i=window.RTCRtpReceiver.getCapabilities(t).codecs;if("video"===t){var o=r.findIndex(function(e){return e.mimeType.toLowerCase().includes(n.preferredCodec.toLowerCase())});if(-1!==o){var s=r.splice(o,1);r.unshift(s[0])}var a=i.findIndex(function(e){return e.mimeType.toLowerCase().includes(n.preferredCodec.toLowerCase())});if(-1!==a){var c=i.splice(a,1);i.unshift(c[0])}var l=r.filter(function(e){return!e.mimeType.toLowerCase().includes("h264")}),u=i.filter(function(e){return!e.mimeType.toLowerCase().includes("h264")}),d=l.concat(u);e.setCodecPreferences(d)}}),"answer"===e.type?this._pc.createAnswer(e.options).then(r).catch(t):this._pc.createOffer(e.options).then(r).catch(t)},o.prototype.setRemoteSessionDescription=function(e,t){var n=this.delegate.bandwidth?{type:e.type,sdp:c(e.sdp,"video",this.delegate.bandwidth)}:e;this._pc.setRemoteDescription(n).then(function(){t()}).catch(function(e){i.traceError("Error in 'setRemoteSessionDescription': "+e),t(e)})},o.prototype.addLocalStream=function(e){if(!e)throw new Error("'qbRTCPeerConnection.addLocalStream' error: stream is not defined");var t=this;e.getTracks().forEach(function(n){t._pc.addTrack(n,e)})},o.prototype._addIceCandidate=function(e){return this._pc.addIceCandidate(e).catch(function(e){i.traceError("Error on 'addIceCandidate': "+e)})},o.prototype.addCandidates=function(e){var t=this;e.forEach(function(e){t.remoteIceCandidates.push(e)}),this._pc.remoteDescription&&t.remoteIceCandidates.forEach(function(e){t._addIceCandidate(e)})},o.prototype.toString=function(){return"sessionID: "+this.sessionID+", userID: "+this.userID+", state: "+this.state},o.prototype.onSignalingStateCallback=function(){if("stable"===this._pc.signalingState&&this.localIceCandidates.length>0)for(this.delegate.processIceCandidates(this,this.localIceCandidates);this.localIceCandidates.length;)this.localIceCandidates.pop()},o.prototype.onIceCandidateCallback=function(e){if(e.candidate){var t={candidate:e.candidate.candidate,sdpMid:e.candidate.sdpMid,sdpMLineIndex:e.candidate.sdpMLineIndex};"stable"===this._pc.signalingState?this.delegate.processIceCandidates(this,[t]):this.localIceCandidates.push(t)}},o.prototype.onTrackCallback=function(e){this.remoteStream=e.streams[0],"function"==typeof this.delegate._onRemoteStreamListener&&["connected","completed"].includes(this._pc.iceConnectionState)&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream),this._getStatsWrap()},o.prototype.onIceConnectionStateCallback=function(){i.trace("onIceConnectionStateCallback: "+this._pc.iceConnectionState);var e=null;switch(this._pc.iceConnectionState){case"checking":this.state=o.State.CHECKING,e=i.SessionConnectionState.CONNECTING;break;case"connected":this._reconnecting&&this.delegate._stopReconnectTimer(this.userID),this.state=o.State.CONNECTED,e=i.SessionConnectionState.CONNECTED;break;case"completed":this._reconnecting&&this.delegate._stopReconnectTimer(this.userID),this.state=o.State.COMPLETED,e=i.SessionConnectionState.COMPLETED;break;case"failed":this.delegate._startReconnectTimer(this.userID),this.state=o.State.FAILED,e=i.SessionConnectionState.FAILED;break;case"disconnected":this.delegate._startReconnectTimer(this.userID),this.state=o.State.DISCONNECTED,e=i.SessionConnectionState.DISCONNECTED;break;case"closed":this.delegate._stopReconnectTimer(this.userID),this.state=o.State.CLOSED,e=i.SessionConnectionState.CLOSED}"function"==typeof this.delegate._onSessionConnectionStateChangedListener&&e&&this.delegate._onSessionConnectionStateChangedListener(this.userID,e),"connected"===this._pc.iceConnectionState&&"function"==typeof this.delegate._onRemoteStreamListener&&this.delegate._onRemoteStreamListener(this.userID,this.remoteStream)},o.prototype._clearStatsReportTimer=function(){this.statsReportTimer&&(clearInterval(this.statsReportTimer),this.statsReportTimer=null)},o.prototype._getStatsWrap=function(){var e,t,n=this;if(r.webrtc&&r.webrtc.statsReportTimeInterval&&!n.statsReportTimer){if(isNaN(+r.webrtc.statsReportTimeInterval))return void i.traceError("statsReportTimeInterval ("+r.webrtc.statsReportTimeInterval+") must be integer.");e=1e3*r.webrtc.statsReportTimeInterval;i.trace("Stats tracker has been started."),n.statsReportTimer=setInterval(function(){!function(e,t,n,r){var o={local:{audio:{},video:{},candidate:{}},remote:{audio:{},video:{},candidate:{}}};if(i.getVersionFirefox()){var s=e.getLocalStreams().length?e.getLocalStreams()[0]:e.delegate.localStream,a=s.getVideoTracks().length?s.getVideoTracks()[0].getSettings():null;o.local.video.frameHeight=a&&a.height,o.local.video.frameWidth=a&&a.width}function c(e,t,n){var r,i=t&&t.get(e.id),o=i?(e.timestamp-i.timestamp)/1e3:5;return r=i?n?8*(e.bytesSent-i.bytesSent)/(1024*o):8*(e.bytesReceived-i.bytesReceived)/(1024*o):0,Math.round(r)}function l(e,t,n){var r,i=t&&t.get(e.id),o=i?(e.timestamp-i.timestamp)/1e3:5;return r=i?n?(e.framesSent-i.framesSent)/o:(e.framesReceived-i.framesReceived)/o:0,Math.round(10*r)/10}e.getStats(null).then(function(e){e.forEach(function(e){var n;e.bytesReceived&&"inbound-rtp"===e.type?((n=o.remote[e.mediaType]).bitrate=c(e,t,!1),n.bytesReceived=e.bytesReceived,n.packetsReceived=e.packetsReceived,n.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(n.framesPerSecond=Math.round(10*e.framerateMean)/10)):e.bytesSent&&"outbound-rtp"===e.type?((n=o.local[e.mediaType]).bitrate=c(e,t,!0),n.bytesSent=e.bytesSent,n.packetsSent=e.packetsSent,n.timestamp=e.timestamp,"video"===e.mediaType&&e.framerateMean&&(n.framesPerSecond=Math.round(10*e.framerateMean)/10)):"local-candidate"===e.type?(n=o.local.candidate,"host"===e.candidateType&&"udp"===e.mozLocalTransport&&"udp"===e.transport?(n.protocol=e.transport,n.ip=e.ipAddress,n.port=e.portNumber):i.getVersionFirefox()||(n.protocol=e.protocol,n.ip=e.ip,n.port=e.port)):"remote-candidate"===e.type?((n=o.remote.candidate).protocol=e.protocol||e.transport,n.ip=e.ip||e.ipAddress,n.port=e.port||e.portNumber):"track"!==e.type||"video"!==e.kind||i.getVersionFirefox()||(e.remoteSource?((n=o.remote.video).frameHeight=e.frameHeight,n.frameWidth=e.frameWidth,n.framesPerSecond=l(e,t,!1)):((n=o.local.video).frameHeight=e.frameHeight,n.frameWidth=e.frameWidth,n.framesPerSecond=l(e,t,!0)))}),n(o,e)},r)}(n._pc,t,function(e,r){t=r,n.delegate._onCallStatsReport(n.userID,e,null)},function(e){i.traceError("_getStats error. "+e.name+": "+e.message),n.delegate._onCallStatsReport(n.userID,null,e)})},e)}},o.prototype._clearDialingTimer=function(){this.dialingTimer&&(i.trace("_clearDialingTimer"),clearInterval(this.dialingTimer),this.dialingTimer=null,this.answerTimeInterval=0)},o.prototype._startDialingTimer=function(e){var t=this,n=1e3*r.webrtc.dialingTimeInterval;i.trace("_startDialingTimer, dialingTimeInterval: "+n);var o=function(e,o){o||(t.answerTimeInterval+=n),i.trace("_dialingCallback, answerTimeInterval: "+t.answerTimeInterval),t.answerTimeInterval>=1e3*r.webrtc.answerTimeInterval?(t._clearDialingTimer(),t.delegate.processOnNotAnswer(t)):t.delegate.processCall(t,e)};t.dialingTimer=setInterval(o,n,e,!1),o(e,!0)},t.exports=o},{"../../qbConfig":151,"./qbWebRTCHelpers":145}],144:[function(e,t,n){"use strict";var r=e("./qbWebRTCSession"),i=e("./qbWebRTCSignalingProcessor"),o=e("./qbWebRTCSignalingProvider"),s=e("./qbWebRTCHelpers"),a=e("./qbRTCPeerConnection"),c=e("./qbWebRTCSignalingConstants"),l=e("../../qbUtils"),u=e("../../qbConfig"),d=[r.State.NEW,r.State.CONNECTING,r.State.ACTIVE];function h(e,t){this.chat=t,this.signalingProcessor=new i(e,this),this.signalingProvider=new o(e,t),t.webrtcSignalingProcessor=this.signalingProcessor,this.SessionConnectionState=s.SessionConnectionState,this.CallType=s.CallType,this.PeerConnectionState=a.State,this.sessions={},navigator.mediaDevices&&"ondevicechange"in navigator.mediaDevices&&(navigator.mediaDevices.ondevicechange=this._onDevicesChangeListener.bind(this))}h.prototype.getMediaDevices=function(e){var t=[],n="Browser does not support output device selection.";return new Promise(function(r,i){navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?navigator.mediaDevices.enumerateDevices().then(function(n){e?(n.forEach(function(n,r){n.kind===e&&t.push(n)}),r(t)):r(n)}):(i(n),s.traceWarning(n))})},h.prototype.sessions={},h.prototype.createNewSession=function(e,t,n,i){var o=function(e){var t=[];Object.keys(e).length>0&&Object.keys(e).forEach(function(n,i,o){var s=e[n];s.state!==r.State.NEW&&s.state!==r.State.ACTIVE||t.push(s.opponentsIDs)});return t}(this.sessions),a=n||s.getIdFromNode(this.chat.connection.jid),c=i&&i.bandwidth&&!isNaN(i.bandwidth)?+i.bandwidth:0,l=t||2;if(!e)throw new Error("Can't create a session without the opponentsIDs.");if(!Array.isArray(e))throw new Error('"opponentsIDs" should be Array of numbers');if(e.forEach(function(e){var t=parseInt(e);if(isNaN(t))throw new Error('"opponentsIDs" should be Array of numbers');e=t}),function(e,t){var n=!1,r=t.sort();e.length&&e.forEach(function(e){var t=e.sort();n=t.length==r.length&&t.every(function(e,t){return e===r[t]})});return n}(o,e))throw new Error("Can't create a session with the same opponentsIDs. There is a session already in NEW or ACTIVE state.");return this._createAndStoreSession(null,a,e,l,c)},h.prototype._createAndStoreSession=function(e,t,n,i,o){var a=new r({sessionID:e,initiatorID:t,opIDs:n,callType:i,signalingProvider:this.signalingProvider,currentUserID:s.getIdFromNode(this.chat.connection.jid),bandwidth:o});return a.onUserNotAnswerListener=this.onUserNotAnswerListener,a.onReconnectListener=this.onReconnectListener,a.onRemoteStreamListener=this.onRemoteStreamListener,a.onSessionConnectionStateChangedListener=this.onSessionConnectionStateChangedListener,a.onSessionCloseListener=this.onSessionCloseListener,a.onCallStatsReport=this.onCallStatsReport,this.sessions[a.ID]=a,a},h.prototype.clearSession=function(e){delete h.sessions[e]},h.prototype.isExistLiveSessionExceptSessionID=function(e){var t=!1,n=this.sessions;return Object.keys(n).length>0&&(t=Object.keys(n).some(function(t){var r=n[t];return d.includes(r.state)&&r.ID!==e})),t},h.prototype.getNewSessionsCount=function(e){var t=this.sessions;return Object.keys(t).reduce(function(n,i){var o=t[i];return o.ID===e?n:o.state===r.State.NEW?n+1:n},0)},h.prototype._onCallListener=function(e,t,n){var r=n.userInfo||{},i=s.getIdFromNode(this.chat.connection.jid);if(e!==i||n.opponentsIDs.includes(i)){s.trace("onCall. UserID:"+e+". SessionID: "+t);var o=this.isExistLiveSessionExceptSessionID(t),a=this.getNewSessionsCount(t);if(o&&!this.sessions[t]&&a++,o&&(u.webrtc.autoReject||a>u.webrtc.incomingLimit))s.trace("User with id "+e+" is busy at the moment."),delete n.sessionDescription,delete n.platform,n.sessionID=t,this.signalingProvider.sendMessage(e,n,c.SignalingType.REJECT),"function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onCall",t,e,r);else{var d=this.sessions[t],h=+r.bandwidth||0;d||(d=this._createAndStoreSession(t,n.callerID,n.opponentsIDs,n.callType,h),"function"==typeof this.onCallListener&&l.safeCallbackCall(this.onCallListener,d,r)),d.processOnCall(e,n)}}else s.trace('Ignore "onCall" signal from current user. userID:'+e+", sessionID: "+t)},h.prototype._onAcceptListener=function(e,t,n){var i=this.sessions[t],o=n.userInfo||{};s.trace("onAccept. UserID:"+e+". SessionID: "+t),i?i.state===r.State.CONNECTING||i.state===r.State.ACTIVE?("function"==typeof this.onAcceptCallListener&&l.safeCallbackCall(this.onAcceptCallListener,i,e,o),i.processOnAccept(e,n)):("function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onAccept",i,e,o),s.traceWarning("Ignore 'onAccept', the session( "+t+" ) has invalid state.")):s.traceError("Ignore 'onAccept', there is no information about session "+t+" by some reason.")},h.prototype._onRejectListener=function(e,t,n){var r=this.sessions[t];if(s.trace("onReject. UserID:"+e+". SessionID: "+t),r){var i=n.userInfo||{};"function"==typeof this.onRejectCallListener&&l.safeCallbackCall(this.onRejectCallListener,r,e,i),r.processOnReject(e,n)}else s.traceError("Ignore 'onReject', there is no information about session "+t+" by some reason.")},h.prototype._onStopListener=function(e,t,n){s.trace("onStop. UserID:"+e+". SessionID: "+t);var r=this.sessions[t],i=n.userInfo||{};r&&d.includes(r.state)?("function"==typeof this.onStopCallListener&&l.safeCallbackCall(this.onStopCallListener,r,e,i),setTimeout(r.processOnStop.bind(r),10,e,n)):("function"==typeof this.onInvalidEventsListener&&l.safeCallbackCall(this.onInvalidEventsListener,"onStop",r,e,i),s.traceError("Ignore 'onStop', there is no information about session "+t+" by some reason."))},h.prototype._onIceCandidatesListener=function(e,t,n){var i=this.sessions[t];s.trace("onIceCandidates. UserID:"+e+". SessionID: "+t+". ICE candidates count: "+n.iceCandidates.length),i?i.state===r.State.CONNECTING||i.state===r.State.ACTIVE?i.processOnIceCandidates(e,n):s.traceWarning("Ignore 'OnIceCandidates', the session ( "+t+" ) has invalid state."):s.traceError("Ignore 'OnIceCandidates', there is no information about session "+t+" by some reason.")},h.prototype._onUpdateListener=function(e,t,n){var r=this.sessions[t],i=n.userInfo||{};s.trace("onUpdate. UserID:"+e+". SessionID: "+t+". Extension: "+JSON.stringify(i)),r&&(n.reason&&r.processOnUpdate(e,n),"function"==typeof this.onUpdateCallListener&&l.safeCallbackCall(this.onUpdateCallListener,r,e,i))},h.prototype._onDevicesChangeListener=function(){"function"==typeof this.onDevicesChangeListener&&l.safeCallbackCall(this.onDevicesChangeListener)},t.exports=h},{"../../qbConfig":151,"../../qbUtils":155,"./qbRTCPeerConnection":143,"./qbWebRTCHelpers":145,"./qbWebRTCSession":146,"./qbWebRTCSignalingConstants":147,"./qbWebRTCSignalingProcessor":148,"./qbWebRTCSignalingProvider":149}],145:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i={getUserJid:function(e,t){return e+"-"+t+"@"+r.endpoints.chat},getIdFromNode:function(e){return e.indexOf("@")<0?null:parseInt(e.split("@")[0].split("-")[0])},trace:function(e){r.debug&&console.log("[QBWebRTC]:",e)},traceWarning:function(e){r.debug&&console.warn("[QBWebRTC]:",e)},traceError:function(e){r.debug&&console.error("[QBWebRTC]:",e)},getLocalTime:function(){return(new Date).toString().split(" ").slice(1,5).join("-")},isIOS:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent;return Boolean(e.match(/iP(ad|hone)/i))},isIOSSafari:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent,t=Boolean(e.match(/iP(ad|hone)/i)),n=Boolean(e.match(/WebKit/i)),r=Boolean(e.match(/CriOS/i));return t&&n&&!r},isIOSChrome:function(){if(!window||!window.navigator||!window.navigator.userAgent)return!1;var e=window.navigator.userAgent,t=Boolean(e.match(/iP(ad|hone)/i)),n=Boolean(e.match(/WebKit/i)),r=Boolean(e.match(/CriOS/i));return t&&!n&&r},getVersionFirefox:function(){var e,t=!!navigator&&navigator.userAgent;if(t){var n=t.match(/(?:firefox)[ \/](\d+)/i)||[];e=n[1]?+n[1]:null}return e},getVersionSafari:function(){var e,t=!!navigator&&navigator.userAgent;if(t)if((t.match(/(?:safari)[ \/](\d+)/i)||[]).length){var n=t.match(/(?:version)[ \/](\d+)/i)||[];e=n&&n[1]?+n[1]:null}else e=null;return e},delay:function(e){return e="number"==typeof e&&e>0?e:0,new Promise(function(t){setTimeout(t,e)})},SessionConnectionState:{UNDEFINED:0,CONNECTING:1,CONNECTED:2,FAILED:3,DISCONNECTED:4,CLOSED:5,COMPLETED:6},CallType:{VIDEO:1,AUDIO:2}};t.exports=i},{"../../qbConfig":151}],146:[function(e,t,n){"use strict";var r=e("../../qbConfig"),i=e("./qbRTCPeerConnection"),o=e("../../qbUtils"),s=e("./qbWebRTCHelpers"),a=e("./qbWebRTCSignalingConstants");d.State={NEW:1,ACTIVE:2,HUNGUP:3,REJECTED:4,CLOSED:5};var c="reconnecting",l="reconnected",u="failed";function d(e){this.ID=e.sessionID?e.sessionID:h(),this.state=d.State.NEW,this.initiatorID=parseInt(e.initiatorID),this.opponentsIDs=e.opIDs,this.callType=parseInt(e.callType),this.peerConnections={},this.mediaParams=null,this.iceConnectTimers={},this.reconnectTimers={},this.signalingProvider=e.signalingProvider,this.currentUserID=e.currentUserID,this.bandwidth=e.bandwidth,this.answerTimer=null,this.startCallTime=0,this.acceptCallTime=0,this.localStream=void 0}function h(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?n:3&n|8).toString(16)})}function p(e){var t={};try{if("[object Object]"!=={}.toString.call(e))throw new Error('Invalid type of "extension" object.');t.userInfo=e,t=JSON.parse(JSON.stringify(t).replace(/null/g,'""'))}catch(e){s.traceWarning(e.message)}return t}d.prototype.getUserMedia=function(e,t){if(!navigator.mediaDevices.getUserMedia)throw new Error("getUserMedia() is not supported in your browser");var n=this,r={audio:e.audio||!1,video:e.video||!1};navigator.mediaDevices.getUserMedia(r).then(function(r){n.localStream=r,n.mediaParams=Object.assign({},e),e.elemId&&n.attachMediaStream(e.elemId,r,e.options),t&&"function"==typeof t&&t(void 0,r)}).catch(t)},d.prototype.connectionStateForUser=function(e){var t=this.peerConnections[e];return t?t.state:void 0},d.prototype.attachMediaStream=function(e,t,n){var r=document.getElementById(e);if(!r)throw new Error('Unable to attach media stream, cannot find element by Id "'+e+'"');if(!(r instanceof HTMLMediaElement))throw new Error('Cannot attach media stream to element with id "'+e+'" because it is not of type HTMLMediaElement');"srcObject"in r?r.srcObject=t:r.src=window.URL.createObjectURL(t),n&&n.muted&&(r.muted=!0),n&&n.mirror&&(r.style.transform="scaleX(-1)"),r.autoplay||(r.onloadedmetadata=function(){r.play()})},d.prototype.detachMediaStream=function(e,t){var n=document.getElementById(e);n&&n instanceof HTMLMediaElement&&(n.pause(),t&&t.stopTracks&&n.srcObject&&"object"==typeof n.srcObject&&n.srcObject.getTracks().forEach(function(e){e.stop(),e.enabled=!1}),n.srcObject=null,n.removeAttribute("src"),n.removeAttribute("srcObject"))},d.prototype.switchMediaTracks=function(e,t){if(!navigator.mediaDevices.getUserMedia)throw new Error("getUserMedia() is not supported in your browser");var n=this;e&&e.audio&&(this.mediaParams.audio.deviceId=e.audio),e&&e.video&&(this.mediaParams.video.deviceId=e.video),this.localStream.getTracks().forEach(function(e){e.stop()}),navigator.mediaDevices.getUserMedia({audio:n.mediaParams.audio||!1,video:n.mediaParams.video||!1}).then(function(e){return n._replaceTracks(e).then(function(){t(null,e)})}).catch(function(e){t(e,null)})},d.prototype.replaceVideoTrack=function(e){var t=this.localStream,n=this.mediaParams.elemId,r=t.getVideoTracks()[0];if(r&&(r.stop(),t.removeTrack(r)),t.addTrack(e),n){var i=document.getElementById(n);i&&i instanceof HTMLMediaElement&&(i.srcObject=t)}return Promise.all(Object.values(this.peerConnections).map(function(e){return e._pc}).map(function(t){var n=t.getSenders().find(function(e){return e.track&&"video"===e.track.kind});return n?n.replaceTrack(e):Promise.resolve()}))},d.prototype._replaceTracks=function(e){var t=this.localStream,n=this.mediaParams.elemId,r=e.getTracks();if(r.forEach(function(e){var n=t.getTracks().find(function(t){return t.kind===e.kind});n&&(n.stop(),t.removeTrack(n)),t.addTrack(e)}),n){var i=document.getElementById(n);i&&i instanceof HTMLMediaElement&&(i.srcObject=t)}return Promise.all(Object.values(this.peerConnections).map(function(e){return e._pc}).map(function(e){return Promise.all(e.getSenders().filter(function(e){return null!==e.track}).map(function(e){var t=r.find(function(t){return t.kind===e.track.kind});return t?e.replaceTrack(t):Promise.resolve()}))}))},d.prototype.call=function(e,t){var n=this,r=p(e);s.trace("Call, extension: "+JSON.stringify(r.userInfo)),n.state=d.State.ACTIVE,n._reconnectToChat(function(){n.state===d.State.ACTIVE&&n.opponentsIDs.forEach(function(e){n._callInternal(e,r)})}),"function"==typeof t&&t(null)},d.prototype._callInternal=function(e,t){var n=this._createPeer(e,this.currentUserID<e);this.peerConnections[e]=n,n.addLocalStream(this.localStream),n.setLocalSessionDescription({type:"offer"},function(e){e?s.trace("setLocalSessionDescription error: "+e):(s.trace("setLocalSessionDescription success"),n._startDialingTimer(t))})},d.prototype.accept=function(e){var t=this,n=p(e);if(s.trace("Accept, extension: "+JSON.stringify(n.userInfo)),t.state!==d.State.ACTIVE){if(t.state===d.State.CLOSED)return s.traceError("Can't accept, the session is already closed, return."),void t.stop({});t.state=d.State.ACTIVE,t.acceptCallTime=new Date,t._clearAnswerTimer(),t._acceptInternal(t.initiatorID,n);var r=t._uniqueOpponentsIDsWithoutInitiator();if(r.length>0){var i=(t.acceptCallTime-t.startCallTime)/1e3;t._startWaitingOfferOrAnswerTimer(i),r.forEach(function(e,n,r){t.currentUserID>e&&t._callInternal(e,{},!0)})}}else s.traceError("Can't accept, the session is already active, return.")},d.prototype._acceptInternal=function(e,t){var n=this,r=this.peerConnections[e];if(r){var i=r.getRemoteSDP();r.addLocalStream(n.localStream),r.setRemoteSessionDescription(i,function(i){i?s.traceError("'setRemoteSessionDescription' error: "+i):(s.trace("'setRemoteSessionDescription' success"),r.setLocalSessionDescription({type:"answer"},function(i){i?s.trace("setLocalSessionDescription error: "+i):(s.trace("'setLocalSessionDescription' success"),t.sessionID=n.ID,t.callType=n.callType,t.callerID=n.initiatorID,t.opponentsIDs=n.opponentsIDs,r._pc.localDescription&&(t.sdp=r._pc.localDescription.toJSON().sdp),n.signalingProvider.sendMessage(e,t,a.SignalingType.ACCEPT))}))})}else s.traceError("Can't accept the call, peer connection for userID "+e+" was not found")},d.prototype.reject=function(e){var t=this,n=p(e);s.trace("Reject, extension: "+JSON.stringify(n.userInfo)),t.state=d.State.REJECTED,t._clearAnswerTimer(),n.sessionID=t.ID,n.callType=t.callType,n.callerID=t.initiatorID,n.opponentsIDs=t.opponentsIDs,Object.keys(t.peerConnections).forEach(function(e){var r=t.peerConnections[e];t.signalingProvider.sendMessage(r.userID,n,a.SignalingType.REJECT)}),t._close()},d.prototype.stop=function(e){var t=this,n=p(e);s.trace("Stop, extension: "+JSON.stringify(n.userInfo)),t.state=d.State.HUNGUP,t.answerTimer&&t._clearAnswerTimer(),n.sessionID=t.ID,n.callType=t.callType,n.callerID=t.initiatorID,n.opponentsIDs=t.opponentsIDs,Object.keys(t.peerConnections).forEach(function(e){var r=t.peerConnections[e];t.signalingProvider.sendMessage(r.userID,n,a.SignalingType.STOP)}),t._close()},d.prototype.closeConnection=function(e){var t=this.peerConnections[e];if(!t)return s.traceWarn("Not found connection with user ("+e+")"),!1;try{t.release()}catch(e){s.traceError(e)}finally{this._closeSessionIfAllConnectionsClosed()}},d.prototype.update=function(e,t){var n="object"==typeof e?e:{};if(s.trace("Update, extension: "+JSON.stringify(e)),null!==e)if(n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,t)this.signalingProvider.sendMessage(t,n,a.SignalingType.PARAMETERS_CHANGED);else for(var r in this.peerConnections){var i=this.peerConnections[r];this.signalingProvider.sendMessage(i.userID,n,a.SignalingType.PARAMETERS_CHANGED)}else s.trace("extension is null, no parameters to update")},d.prototype.mute=function(e){this._muteStream(0,e)},d.prototype.unmute=function(e){this._muteStream(1,e)},d.prototype.processOnCall=function(e,t){var n=this;n._uniqueOpponentsIDs().forEach(function(r){var i=n.peerConnections[r];i||(i=n._createPeer(r,n.currentUserID<r),n.peerConnections[r]=i,r==e&&n._startAnswerTimer()),r==e&&(i.setRemoteSDP(new window.RTCSessionDescription({sdp:t.sdp,type:"offer"})),e!=n.initiatorID&&n.state===d.State.ACTIVE&&n._acceptInternal(e,{}))})},d.prototype.processOnAccept=function(e,t){var n=this,r=this.peerConnections[e];if(r)if(r._clearDialingTimer(),"stable"!==r._pc.signalingState){var i=new window.RTCSessionDescription({sdp:t.sdp,type:"answer"});r.setRemoteSDP(i),r.setRemoteSessionDescription(i,function(e){e?s.traceError("'setRemoteSessionDescription' error: "+e):(s.trace("'setRemoteSessionDescription' success"),n.state!==d.State.ACTIVE&&(n.state=d.State.ACTIVE))})}else s.traceError("Ignore 'onAccept', PeerConnection is already in 'stable' state");else s.traceError("Ignore 'OnAccept': peer connection for user with Id "+e+" was not found")},d.prototype.processOnReject=function(e,t){var n=this.peerConnections[e];this._clearWaitingOfferOrAnswerTimer(),n?n.release():s.traceError("Ignore 'OnReject', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnStop=function(e,t){this._clearAnswerTimer();var n=this.peerConnections[e];n?(n.release(),n._reconnecting&&(n._reconnecting=!1),this._stopReconnectTimer(e)):s.traceError("Ignore 'OnStop', there is no information about peer connection by some reason."),this._closeSessionIfAllConnectionsClosed()},d.prototype.processOnIceCandidates=function(e,t){var n=this.peerConnections[e];n?n.addCandidates(t.iceCandidates):s.traceError("Ignore 'OnIceCandidates', there is no information about peer connection by some reason.")},d.prototype.processOnUpdate=function(e,t){var n=t.sessionDescription,r=t.reason;this.state===d.State.ACTIVE&&r&&"reconnect"===r&&(this.peerConnections[e]?n&&("offer"===n.type?this._processReconnectOffer(e,n):this._processReconnectAnswer(e,n)):s.traceError("Ignore 'OnUpdate': peer connection for user with Id "+e+" was not found"))},d.prototype._processReconnectOffer=function(e,t){var n=this;if(this.peerConnections[e].polite){this._reconnect(this.peerConnections[e]);var r=this.peerConnections[e],i=t.offerId,o=new window.RTCSessionDescription({sdp:t.sdp,type:t.type});r.setRemoteSDP(o),r.setRemoteSessionDescription(o,function(t){t?s.traceError('"setRemoteSessionDescription" error:'+t.message):r.setLocalSessionDescription({type:"answer"},function(){var t=r._pc.localDescription.toJSON(),o={reason:"reconnect",sessionDescription:{offerId:i,sdp:t.sdp,type:t.type}};n.update(o,e)})})}else this._reconnect(this.peerConnections[e],!0)},d.prototype._processReconnectAnswer=function(e,t){var n=this.peerConnections[e],r=t.offerId;if(n&&n.offerId&&r&&n.offerId===r){var i=new window.RTCSessionDescription({sdp:t.sdp,type:t.type});n.setRemoteSDP(i),n.setRemoteSessionDescription(i,function(e){e&&s.traceError('"setRemoteSessionDescription" error:'+e.message)})}},d.prototype.processCall=function(e,t){var n=t||{};e._pc.localDescription&&(n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,n.sdp=e._pc.localDescription.sdp,n.userInfo=t&&t.userInfo?t.userInfo:{},n.userInfo.bandwidth=this.bandwidth,this.signalingProvider.sendMessage(e.userID,n,a.SignalingType.CALL))},d.prototype.processIceCandidates=function(e,t){var n={};n.sessionID=this.ID,n.callType=this.callType,n.callerID=this.initiatorID,n.opponentsIDs=this.opponentsIDs,this.signalingProvider.sendCandidate(e.userID,t,n)},d.prototype.processOnNotAnswer=function(e){s.trace("Answer timeout callback for session "+this.ID+" for user "+e.userID),this._clearWaitingOfferOrAnswerTimer(),e.release(),"function"==typeof this.onUserNotAnswerListener&&o.safeCallbackCall(this.onUserNotAnswerListener,this,e.userID),this._closeSessionIfAllConnectionsClosed()},d.prototype._onRemoteStreamListener=function(e,t){"function"==typeof this.onRemoteStreamListener&&o.safeCallbackCall(this.onRemoteStreamListener,this,e,t)},d.prototype._onCallStatsReport=function(e,t,n){"function"==typeof this.onCallStatsReport&&o.safeCallbackCall(this.onCallStatsReport,this,e,t,n)},d.prototype._onSessionConnectionStateChangedListener=function(e,t){var n=s.SessionConnectionState.CLOSED,r=this.peerConnections[e];"function"==typeof this.onSessionConnectionStateChangedListener&&o.safeCallbackCall(this.onSessionConnectionStateChangedListener,this,e,t),t===n&&r&&(r._pc.onicecandidate=null,r._pc.onsignalingstatechange=null,r._pc.ontrack=null,r._pc.oniceconnectionstatechange=null,delete this.peerConnections[e])},d.prototype._createPeer=function(e,t){if(!window.RTCPeerConnection)throw new Error("_createPeer error: RTCPeerConnection is not supported in your browser");this.startCallTime=new Date;const n={iceServers:r.webrtc.iceServers},o=void 0===r.webrtc.iceTransportPolicy?{}:{iceTransportPolicy:r.webrtc.iceTransportPolicy},a=Object.assign({},n,o);s.trace("_createPeer configuration: "+JSON.stringify(a));var c=new i(a);return c._init(this,e,this.ID,t),c},d.prototype._startReconnectTimer=function(e){var t=this,n=1e3*r.webrtc.disconnectTimeInterval,i=this.peerConnections[e];i._reconnecting=!0;var a=function(){s.trace("disconnectTimeInterval reached for userID "+e),t._stopReconnectTimer(e),t.peerConnections[e].release(),t._onSessionConnectionStateChangedListener(e,s.SessionConnectionState.CLOSED),t._closeSessionIfAllConnectionsClosed()};"function"==typeof this.onReconnectListener&&o.safeCallbackCall(this.onReconnectListener,this,e,c),s.trace("_startReconnectTimer for userID:"+e+", timeout: "+n);this.iceConnectTimers[e]||(this.iceConnectTimers[e]=setTimeout(function(){s.trace("iceConnectTimeout reached for user "+e),t.iceConnectTimers[e]&&(clearTimeout(t.iceConnectTimers[e]),t.iceConnectTimers[e]=void 0,t.reconnectTimers[e]||(t.reconnectTimers[e]=setTimeout(a,n-5e3),t._reconnectToChat(function(){t.state===d.State.ACTIVE&&t.reconnectTimers[e]&&t._reconnect(i,!0)})))},5e3))},d.prototype._stopReconnectTimer=function(e){var t=this.peerConnections[e];if(this.iceConnectTimers[e]&&(clearTimeout(this.iceConnectTimers[e]),this.iceConnectTimers[e]=void 0),this.reconnectTimers[e]&&(s.trace("_stopReconnectTimer for userID: "+e),clearTimeout(this.reconnectTimers[e]),this.reconnectTimers[e]=void 0),t&&t._reconnecting&&(t._reconnecting=!1,"function"==typeof this.onReconnectListener)){var n=t._pc.iceConnectionState;o.safeCallbackCall(this.onReconnectListener,this,e,"connected"===n?l:u)}},d.prototype._reconnectToChat=function(e){var t=this,n=this.signalingProvider,r=function(){var t=n.chat.onReconnectListener;n.chat.onReconnectListener=function(){"function"==typeof t&&t(),n.chat.onReconnectListener=t,e()},n.chat.reconnect()};if(n&&n.chat)try{n.chat.ping(function(n){t.state!==d.State.CLOSED&&(n?r():e())})}catch(e){t.state!==d.State.CLOSED&&r()}},d.prototype._reconnect=function(e,t){if(!e||!e.userID)return;var n=e.userID,o=e.polite,a=e._reconnecting;e.release();const c={iceServers:r.webrtc.iceServers},l=void 0===r.webrtc.iceTransportPolicy?{}:{iceTransportPolicy:r.webrtc.iceTransportPolicy},u=Object.assign({},c,l);s.trace("_reconnect peer configuration: "+JSON.stringify(u));var d=new i(u);this.peerConnections[n]=d,d._init(this,n,this.ID,o),d._reconnecting=a,d.addLocalStream(this.localStream),t&&(d.offerId=h(),d.negotiate())},d.prototype._close=function(){for(var e in s.trace("_close"),this.peerConnections){var t=this.peerConnections[e];this._stopReconnectTimer(t.userID);try{t.release()}catch(e){console.warn("Peer close error:",e)}}this._closeLocalMediaStream(),"function"==typeof this._detectSilentAudioTaskCleanup&&(this._detectSilentAudioTaskCleanup(),this._detectSilentAudioTaskCleanup=void 0),"function"==typeof this._detectSilentVideoTaskCleanup&&(this._detectSilentVideoTaskCleanup(),this._detectSilentVideoTaskCleanup=void 0),this.state=d.State.CLOSED,"function"==typeof this.onSessionCloseListener&&o.safeCallbackCall(this.onSessionCloseListener,this)},d.prototype._closeSessionIfAllConnectionsClosed=function(){var e=Object.values(this.peerConnections).every(function(e){return e.state===i.State.CLOSED});s.trace("All peer connections closed: "+e),e&&(this._closeLocalMediaStream(),"function"==typeof this.onSessionCloseListener&&this.onSessionCloseListener(this),this.state=d.State.CLOSED)},d.prototype._closeLocalMediaStream=function(){this.localStream&&(this.localStream.getTracks().forEach(function(e){e.stop(),e.enabled=!1}),this.localStream=null)},d.prototype._muteStream=function(e,t){"audio"===t&&this.localStream.getAudioTracks().length>0?this.localStream.getAudioTracks().forEach(function(t){t.enabled=!!e}):"video"===t&&this.localStream.getVideoTracks().length>0&&this.localStream.getVideoTracks().forEach(function(t){t.enabled=!!e})},d.prototype._clearAnswerTimer=function(){this.answerTimer&&(s.trace("_clearAnswerTimer"),clearTimeout(this.answerTimer),this.answerTimer=null)},d.prototype._startAnswerTimer=function(){s.trace("_startAnswerTimer");var e=this,t=1e3*r.webrtc.answerTimeInterval;this.answerTimer=setTimeout(function(){s.trace("_answerTimeoutCallback"),"function"==typeof e.onSessionCloseListener&&e._close(),e.answerTimer=null},t)},d.prototype._clearWaitingOfferOrAnswerTimer=function(){this.waitingOfferOrAnswerTimer&&(s.trace("_clearWaitingOfferOrAnswerTimer"),clearTimeout(this.waitingOfferOrAnswerTimer),this.waitingOfferOrAnswerTimer=null)},d.prototype._startWaitingOfferOrAnswerTimer=function(e){var t=this,n=r.webrtc.answerTimeInterval-e<0?1:r.webrtc.answerTimeInterval-e;s.trace("_startWaitingOfferOrAnswerTimer, timeout: "+n),this.waitingOfferOrAnswerTimer=setTimeout(function(){s.trace("waitingOfferOrAnswerTimeoutCallback"),Object.keys(t.peerConnections).length>0&&Object.keys(t.peerConnections).forEach(function(e){var n=t.peerConnections[e];n.state!==i.State.CONNECTING&&n.state!==i.State.NEW||t.processOnNotAnswer(n)}),t.waitingOfferOrAnswerTimer=null},1e3*n)},d.prototype._uniqueOpponentsIDs=function(){var e=this,t=[];return this.initiatorID!==this.currentUserID&&t.push(this.initiatorID),this.opponentsIDs.forEach(function(n,r,i){n!=e.currentUserID&&t.push(parseInt(n))}),t},d.prototype._uniqueOpponentsIDsWithoutInitiator=function(){var e=this,t=[];return this.opponentsIDs.forEach(function(n,r,i){n!=e.currentUserID&&t.push(parseInt(n))}),t},d.prototype.toString=function(){return"ID: "+this.ID+", initiatorID: "+this.initiatorID+", opponentsIDs: "+this.opponentsIDs+", state: "+this.state+", callType: "+this.callType},t.exports=d},{"../../qbConfig":151,"../../qbUtils":155,"./qbRTCPeerConnection":143,"./qbWebRTCHelpers":145,"./qbWebRTCSignalingConstants":147}],147:[function(e,t,n){"use strict";function r(){}r.MODULE_ID="WebRTCVideoChat",r.SignalingType={CALL:"call",ACCEPT:"accept",REJECT:"reject",STOP:"hangUp",CANDIDATE:"iceCandidates",PARAMETERS_CHANGED:"update"},t.exports=r},{}],148:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbWebRTCSignalingConstants");t.exports=function(e,t){var n=this;n.service=e,n.delegate=t,this._onMessage=function(e,t,r,i){var s=n._getExtension(t),a=s.sessionID,c=s.signalType;switch(delete s.moduleIdentifier,delete s.sessionID,delete s.signalType,c){case o.SignalingType.CALL:"function"==typeof n.delegate._onCallListener&&n.delegate._onCallListener(i,a,s);break;case o.SignalingType.ACCEPT:"function"==typeof n.delegate._onAcceptListener&&n.delegate._onAcceptListener(i,a,s);break;case o.SignalingType.REJECT:"function"==typeof n.delegate._onRejectListener&&n.delegate._onRejectListener(i,a,s);break;case o.SignalingType.STOP:"function"==typeof n.delegate._onStopListener&&n.delegate._onStopListener(i,a,s);break;case o.SignalingType.CANDIDATE:"function"==typeof n.delegate._onIceCandidatesListener&&n.delegate._onIceCandidatesListener(i,a,s);break;case o.SignalingType.PARAMETERS_CHANGED:"function"==typeof n.delegate._onUpdateListener&&n.delegate._onUpdateListener(i,a,s)}},this._getExtension=function(e){if(!e)return{};var t={},r=[],i=[];return e.childNodes.forEach(function(e){"iceCandidates"===e.nodeName?e.childNodes.forEach(function(e){var t={};e.childNodes.forEach(function(e){t[e.nodeName]=e.textContent}),r.push(t)}):"opponentsIDs"===e.nodeName?e.childNodes.forEach(function(e){var t=e.textContent;i.push(parseInt(t))}):e.childNodes.length>1?t=n._XMLtoJS(t,e.nodeName,e):"userInfo"===e.nodeName?t=n._XMLtoJS(t,e.nodeName,e):t[e.nodeName]=e.textContent}),r.length>0&&(t.iceCandidates=r),i.length>0&&(t.opponentsIDs=i),t},this._XMLtoJS=function(e,t,n){var r=this;return e[t]={},n.childNodes.forEach(function(n){n.childNodes.length>1?e[t]=r._XMLtoJS(e[t],n.nodeName,n):e[t][n.nodeName]=n.textContent}),e}}},{"./qbWebRTCSignalingConstants":147,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],149:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbWebRTCHelpers"),s=e("./qbWebRTCSignalingConstants"),a=e("../../qbUtils"),c=e("../../qbConfig");function l(e,t){this.service=e,this.chat=t}l.prototype.sendCandidate=function(e,t,n){var r=n||{};r.iceCandidates=t,this.sendMessage(e,r,s.SignalingType.CANDIDATE)},l.prototype.sendMessage=function(e,t,n){var r=t||{},l=this;r.moduleIdentifier=s.MODULE_ID,r.signalType=n,r.platform="web",r.userInfo&&!Object.keys(r.userInfo).length&&delete r.userInfo;var u={to:o.getUserJid(e,c.creds.appId),type:"headline",id:a.getBsonObjectId()},d=$msg(u).c("extraParams",{xmlns:i.NS.CLIENT});Object.keys(r).forEach(function(e){"iceCandidates"===e?(d.c("iceCandidates"),r[e].forEach(function(e){d.c("iceCandidate"),Object.keys(e).forEach(function(t){d.c(t).t(e[t]).up()}),d.up()}),d.up()):"opponentsIDs"===e?(d.c("opponentsIDs"),r[e].forEach(function(e){d.c("opponentID").t(e).up()}),d.up()):"object"==typeof r[e]?l._JStoXML(e,r[e],d):d.c(e).t(r[e]).up()}),this.chat.connection.send(d)},l.prototype._JStoXML=function(e,t,n){var r=this;n.c(e),Object.keys(t).forEach(function(e){"object"==typeof t[e]?r._JStoXML(e,t[e],n):n.c(e).t(t[e]).up()}),n.up()},t.exports=l},{"../../qbConfig":151,"../../qbUtils":155,"./qbWebRTCHelpers":145,"./qbWebRTCSignalingConstants":147,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],150:[function(e,t,n){"use strict";var r=e("../qbUtils"),i=e("../modules/chat/qbChatHelpers");function o(e){this._NS="urn:xmpp:sm:3",this._isStreamManagementEnabled=!1,this._clientProcessedStanzasCounter=null,this._clientSentStanzasCounter=null,this._intervalId=null,this._timeInterval=r.getTimeIntervalForCallBackMessage(),this.sentMessageCallback=null,r.getEnv().browser&&(this._parser=new DOMParser),this._c=null,this._nodeBuilder=null,this._originalSend=null,this._stanzasQueue=[]}o.prototype.enable=function(e,t){var n,o={xmlns:this._NS};this._isStreamManagementEnabled||(this._c=e,this._originalSend=this._c.send,this._c.send=this.send.bind(this)),r.getEnv().browser?(this._clientProcessedStanzasCounter=null,this._clientSentStanzasCounter=null,this._addEnableHandlers(),n=$build("enable",o)):(this._nodeBuilder=t.Stanza,this._addEnableHandlers(),n=i.createStanza(this._nodeBuilder,o,"enable")),this._c.send(n)},o.prototype._timeoutCallback=function(){var e=Date.now(),t=[];if(this._stanzasQueue.length){for(var n=0;n<this._stanzasQueue.length;n++)this._stanzasQueue[n]&&this._stanzasQueue[n].time<e?this.sentMessageCallback(this._stanzasQueue[n].message):t.push(this._stanzasQueue[n]);this._stanzasQueue=t}},o.prototype._addEnableHandlers=function(){var e=this;function t(t){var n=t.name||t.tagName||t.nodeTree.tagName;if("enabled"===n)return e._isStreamManagementEnabled=!0,!0;if(e._isStreamManagementEnabled&&"message"===n)return clearInterval(e._intervalId),e._intervalId=setInterval(e._timeoutCallback.bind(e),e._timeInterval),!0;if(i.getAttr(t,"xmlns")!==e._NS&&e._increaseReceivedStanzasCounter(),"r"===n){var o={xmlns:e._NS,h:e._clientProcessedStanzasCounter},s=r.getEnv().browser?$build("a",o):i.createStanza(e._nodeBuilder,o,"a");return e._originalSend.call(e._c,s),!0}if("a"===n){var a=parseInt(i.getAttr(t,"h"));e._checkCounterOnIncomeStanza(a)}return!0}r.getEnv().browser?e._c.XAddTrackedHandler(t.bind(e)):e._c.on("stanza",t.bind(e))},o.prototype.send=function(e,t){var n=e.nodeTree?this._parser.parseFromString(e.nodeTree.outerHTML,"application/xml").childNodes[0]:e,o=n.name||n.tagName||n.nodeTree.tagName,s=i.getAttr(n,"type"),a=i.getElementText(n,"body")||"",c=i.getAllElements(n,"attachment")||"";try{this._originalSend.call(this._c,e)}catch(e){r.QBLog("[QBChat]",e.message)}finally{"message"!==o||"chat"!==s&&"groupchat"!==s||!a&&!c.length||this._sendStanzasRequest({message:t,time:Date.now()+this._timeInterval,expect:this._clientSentStanzasCounter}),this._clientSentStanzasCounter++}},o.prototype._sendStanzasRequest=function(e){if(this._isStreamManagementEnabled){this._stanzasQueue.push(e);var t=r.getEnv().browser?$build("r",{xmlns:this._NS}):i.createStanza(this._nodeBuilder,{xmlns:this._NS},"r");this._c.connected?this._originalSend.call(this._c,t):this._checkCounterOnIncomeStanza()}},o.prototype.getClientSentStanzasCounter=function(){return this._clientSentStanzasCounter},o.prototype._checkCounterOnIncomeStanza=function(e){var t=[];if(this._stanzasQueue.length){for(var n=0;n<this._stanzasQueue.length;n++)this._stanzasQueue[n].expect==e?this.sentMessageCallback(null,this._stanzasQueue[n].message):t.push(this._stanzasQueue[n]);this._stanzasQueue=t}},o.prototype._increaseReceivedStanzasCounter=function(){this._clientProcessedStanzasCounter++},t.exports=o},{"../modules/chat/qbChatHelpers":133,"../qbUtils":155}],151:[function(e,t,n){"use strict";var r={version:"2.23.0",buildNumber:"1178",creds:{appId:0,authKey:"",authSecret:"",accountKey:""},endpoints:{api:"api.quickblox.com",chat:"chat.quickblox.com",muc:"muc.chat.quickblox.com"},hash:"sha1",streamManagement:{enable:!1},chatProtocol:{bosh:"https://chat.quickblox.com:5281",websocket:"wss://chat.quickblox.com:5291",active:2},pingTimeout:1,pingDebug:!1,initBlockOnSettings:!1,initBlockDurationMs:3e3,pingLocalhostTimeInterval:5,chatReconnectionTimeInterval:3,chatPingMissLimit:3,webrtc:{answerTimeInterval:60,autoReject:!0,incomingLimit:1,dialingTimeInterval:5,disconnectTimeInterval:30,statsReportTimeInterval:!1,iceTransportPolicy:void 0,iceServers:[{urls:["turn:turn.quickblox.com","stun:turn.quickblox.com"],username:"quickblox",credential:"baccb97ba2d92d71e26eb9886da5f1e0"}]},urls:{account:"account_settings",session:"session",login:"login",users:"users",chat:"chat",blobs:"blobs",geodata:"geodata",pushtokens:"push_tokens",subscriptions:"subscriptions",events:"events",data:"data",addressbook:"address_book",addressbookRegistered:"address_book/registered_users",type:".json"},on:{sessionExpired:null},timeout:null,debug:{mode:0,file:null},addISOTime:!1,qbTokenExpirationDate:null,liveSessionInterval:120,callBackInterval:30,set:function(e){"object"==typeof e.endpoints&&e.endpoints.chat&&(r.endpoints.muc="muc."+e.endpoints.chat,r.chatProtocol.bosh="https://"+e.endpoints.chat+":5281",r.chatProtocol.websocket="wss://"+e.endpoints.chat+":5291"),Object.keys(e).forEach(function(t){"set"!==t&&Object.prototype.hasOwnProperty.call(r,t)&&("object"!=typeof e[t]||null===e[t]?void 0!==e[t]&&(r[t]=e[t]):Object.keys(e[t]).forEach(function(n){Object.prototype.hasOwnProperty.call(r[t],n)&&void 0!==e[t][n]&&(r[t][n]=e[t][n])})),"iceServers"===t&&void 0!==e[t]&&(r.webrtc.iceServers=e[t]),"iceTransportPolicy"===t&&void 0!==e[t]&&(r.webrtc.iceTransportPolicy=e[t])})},updateSessionExpirationDate:function(e,t=!1){var n;if(t){var i=e.replaceAll("-","/");(n=new Date(i)).setMinutes(n.getMinutes()-1)}else(n=new Date(e)).setMinutes(n.getMinutes()-1),n.setMinutes(n.getMinutes()+r.liveSessionInterval);r.qbTokenExpirationDate=n}};t.exports=r},{}],152:[function(e,t,n){"use strict";var r=e("./qbConfig"),i=e("./qbUtils");function o(){}o.prototype={version:r.version,buildNumber:r.buildNumber,_getOS:i.getOS.bind(i),init:function(t,n,o,s,a){console.log("current platform: ",i.getEnv()),"string"==typeof s&&s.length?(a&&"object"==typeof a&&r.set(a),r.creds.accountKey=s):(console.warn('Parameter "accountKey" is missing. This will lead to error in next major release'),console.warn('NOTE: Account migration will not work without "accountKey"'),"object"==typeof s&&r.set(s));var c="api.quickblox.com",l=e("./qbProxy"),u=e("./modules/qbAuth"),d=e("./modules/qbUsers"),h=e("./modules/qbContent"),p=e("./modules/qbPushNotifications"),f=e("./modules/qbData"),m=e("./modules/qbAddressBook"),g=e("./modules/chat/qbChat"),v=e("./modules/chat/qbDialog"),y=e("./modules/chat/qbMessage"),b=e("./modules/qbAI");if(this.service=new l,this.auth=new u(this.service),this.users=new d(this.service),this.content=new h(this.service),this.pushnotifications=new p(this.service),this.data=new f(this.service),this.addressbook=new m(this.service),this.chat=new g(this.service),this.chat.dialog=new v(this.service),this.chat.message=new y(this.service),this.ai=new b(this.service),i.getEnv().browser)if(e("webrtc-adapter"),i.isWebRTCAvailble()){var S=e("./modules/webrtc/qbWebRTCClient");this.webrtc=new S(this.service,this.chat)}else this.webrtc=!1;else this.webrtc=!1;this._initReady=Promise.resolve();var _="boolean"!=typeof r.initBlockOnSettings||r.initBlockOnSettings,C="number"==typeof r.initBlockDurationMs?r.initBlockDurationMs:3e3;"string"!=typeof t||n&&"number"!=typeof n||o?(r.creds.appId=t,r.creds.authKey=n,r.creds.authSecret=o):("number"==typeof n&&(r.creds.appId=n),this.service.setSession({token:t}));var w=r.creds.accountKey&&(!r.endpoints.api||r.endpoints.api===c||!r.endpoints.chat||"chat.quickblox.com"===r.endpoints.chat);if(w){var T=["https://",c,"/",r.urls.account,r.urls.type].join(""),E=function(e){var t={};return e?(Object.keys(e).forEach(function(n){/^on[A-Z]/.test(n)&&"function"==typeof e[n]&&(t[n]=e[n])}),t):t},x=function(e,t){e&&t&&Object.keys(t).forEach(function(n){e[n]=t[n]})},R=this;this._initReady=new Promise(function(t){R.service.ajax({url:T},function(n,o){if(!n&&"object"==typeof o){var s={endpoints:{api:o.api_endpoint.replace(/^https?:\/\//,""),chat:o.chat_endpoint}};r.set(s);var a=E(R.chat),c=E(R.webrtc);if(R.pushnotifications=new p(R.service),R.chat=new g(R.service),R.chat.dialog=new v(R.service),R.chat.message=new y(R.service),i.getEnv().browser)if(e("webrtc-adapter"),i.isWebRTCAvailble()){var l=e("./modules/webrtc/qbWebRTCClient");R.webrtc=new l(R.service,R.chat)}else R.webrtc=!1;else R.webrtc=!1;x(R.chat,a),x(R.webrtc,c)}t()})})}if(w&&_)try{for(var k=Date.now()+C;Date.now()<k;);}catch(e){}},ready:function(){return this._initReady||Promise.resolve()},initWithAppId:function(e,t,n){if("number"!=typeof e)throw new Error("Type of appId must be a number");if(""===e||null==e||""===t||null==t)throw new Error("Cannot init QuickBlox without app credentials (app ID, auth key)");this.init("",e,null,t,n)},getSession:function(e){this.auth.getSession(e)},startSessionWithToken:function(e,t){if(void 0===e)throw new Error("Cannot start session with undefined token");if(""===e)throw new Error("Cannot start session with empty string token");if(null===e)throw new Error("Cannot start session with null value token");if("function"!=typeof t)throw new Error("Cannot start session without callback function");try{this.service.setSession({token:e})}catch(e){t(e,null)}if("function"==typeof t)try{this.auth.getSession(t)}catch(e){t(e,null)}},createSession:function(e,t){this.auth.createSession(e,t)},destroySession:function(e){this.auth.destroySession(e)},login:function(e,t){this.auth.login(e,t)},logout:function(e){this.auth.logout(e)}};var s=new o;s.QuickBlox=o,t.exports=s},{"./modules/chat/qbChat":132,"./modules/chat/qbDialog":134,"./modules/chat/qbMessage":135,"./modules/qbAI":136,"./modules/qbAddressBook":137,"./modules/qbAuth":138,"./modules/qbContent":139,"./modules/qbData":140,"./modules/qbPushNotifications":141,"./modules/qbUsers":142,"./modules/webrtc/qbWebRTCClient":144,"./qbConfig":151,"./qbProxy":153,"./qbUtils":155,"webrtc-adapter":117}],153:[function(e,t,n){"use strict";var r,i,o=e("./qbConfig"),s=e("./qbUtils");function a(){this.qbInst={config:o,session:null},this.reqCount=0}s.getEnv().node?(r=e("node-fetch"),i=e("form-data")):(r=fetch,i=FormData),a.prototype={_fetchingSettings:!1,_queue:[],setSession:function(e){this.qbInst.session=e},getSession:function(){return this.qbInst.session},handleResponse:function(e,t,n,r){if(e){const i=e.message?JSON.stringify(e.message).toLowerCase():"";"function"==typeof o.on.sessionExpired&&401===e.code&&i.indexOf("session does not exist")>-1?o.on.sessionExpired(function(){n(e,t)},r):n(e,null)}else o.addISOTime&&(t=s.injectISOTimes(t)),n(null,t)},startLogger:function(e){var t;++this.reqCount,e.data&&e.data.file?(t=JSON.parse(JSON.stringify(e.data))).file="...":t=s.getEnv().nativescript?JSON.stringify(e.data):e.data,s.QBLog("[Request]["+this.reqCount+"]",(e.type||"GET")+" "+e.url,t||"")},ajax:function(e,t){if(this._fetchingSettings)this._queue.push([e,t]);else{this.startLogger(e);var n,a,c=this,l=!e.type||"GET"===e.type||"HEAD"===e.type,u=c.qbInst&&c.qbInst.session&&c.qbInst.session.token,d=-1===e.url.indexOf("s3.amazonaws.com"),h=!1===e.contentType,p=e.dataType||"json",f=e.url,m={};m.method=e.type||"GET",e.data&&(n=function(){var t,n=e.data;h?(t=new i,Object.keys(n).forEach(function(r){e.fileToCustomObject&&"file"===r?t.append(r,n[r].data,n[r].name):t.append(r,e.data[r])})):t=e.isNeedStringify?JSON.stringify(n):Object.keys(n).map(function(e){return s.isObject(n[e])?Object.keys(n[e]).map(function(t){return g(e)+"["+(s.isArray(n[e])?"":t)+"]="+g(n[e][t])}).sort().join("&"):g(e)+(s.isArray(n[e])?"[]":"")+"="+g(n[e])}).sort().join("&");return t}(),l?f+="?"+n:m.body=n),h||(m.headers={"Content-Type":e.contentType||"application/x-www-form-urlencoded; charset=UTF-8"}),d&&(m.headers||(m.headers={}),m.headers["QB-OS"]=s.getOS(),m.headers["QB-SDK"]="JS "+o.version+" - Client",u&&(m.headers["QB-Token"]=u),e.url.indexOf(o.urls.account)>-1&&(m.headers["QB-Account-Key"]=o.creds.accountKey,this._fetchingSettings=!0)),e.headers&&Object.keys(e.headers).forEach(function(t){m.headers[t]=e.headers[t]}),o.timeout&&(m.timeout=o.timeout),r(f,m).then(function(e){if(a=e,"GET"===m.method||"POST"===m.method){var t=a.headers.get("qb-token-expirationdate"),n=!(null==t);t=n?t:new Date,c.qbInst.config.updateSessionExpirationDate(t,n),s.QBLog("[Request][ajax]","header has token:",n),s.QBLog("[Request][ajax]","updateSessionExpirationDate ... Set value: ",c.qbInst.config.qbTokenExpirationDate)}return"text"===p?e.text():e.json()},function(){return a={status:200}," "}).then(function(e){v(null,a,e)},function(e){v(e)}).catch(e=>{console.log("qbProxy fetch ... catch, error: ",e),v(e)})}function g(e){return encodeURIComponent(e).replace(/[#$&+,/:;=?@\[\]]/g,function(e){return"%"+e.charCodeAt(0).toString(16)})}function v(e,n,r){var i,o,a=n&&(n.status||n.statusCode);if(e||200!==a&&201!==a&&202!==a){var l;try{l={code:n&&a||e&&e.code,status:n&&n.headers&&n.headers.status||"error",message:r||e&&e.errno,detail:r&&r.errors||e&&e.syscall}}catch(t){l=e}o=r||e||r.errors,i=s.getEnv().nativescript?JSON.stringify(o):o,s.QBLog("[Response]["+c.reqCount+"]","error",a,i),c.handleResponse(l,null,t,y)}else o=r&&" "!==r?r:"empty body",i=s.getEnv().nativescript?JSON.stringify(o):o,s.QBLog("[Response]["+c.reqCount+"]",i),c.handleResponse(null,r,t,y);if(c._fetchingSettings){c._fetchingSettings=!1;var u="api.quickblox.com",d="chat.quickblox.com";u=u.replace(/^https?:\/\//i,"").replace(/\/+$/,""),d=d.replace(/^https?:\/\//i,"").replace(/\/+$/,"");for(var h=new RegExp("^https?://"+u.replace(/\./g,"\\.")+"(?=[:/]|$)","i"),p=new RegExp("^https?://"+d.replace(/\./g,"\\.")+"(?=[:/]|$)","i"),f="https://"+(c.qbInst.config.endpoints.api||"").replace(/^https?:\/\//i,"").replace(/\/+$/,""),m="https://"+(c.qbInst.config.endpoints.chat||"").replace(/^https?:\/\//i,"").replace(/\/+$/,"");c._queue.length;){var g=c._queue.shift(),v=g&&g[0];if(v&&"string"==typeof v.url){var b=v.url,S=!1;h.test(b)&&(b=b.replace(h,f),S=!0),p.test(b)&&(b=b.replace(p,m),S=!0),S&&(v.url=b)}c.ajax.apply(c,g)}}}function y(n){n&&(c.setSession(n),c.ajax(e,t))}}},t.exports=a},{"./qbConfig":151,"./qbUtils":155,"form-data":38,"node-fetch":59}],154:[function(e,t,n){"use strict";var r;try{r=e("strophe.js/dist/strophe.umd.js")}catch(t){r=e("strophe.js")}var i=r&&(r.Strophe||r.default||r)||void 0;if(!i||!i.Connection)throw new Error("[QBChat] Strophe import failed: Connection class not found");var o=e("./qbConfig"),s=o.chatProtocol,a=e("./qbUtils");t.exports=function(e){var t=1===s.active?s.bosh:s.websocket,n=new i.Connection(t),r=o.debug?e:null,c=function(t,n){if((r=o.debug?e:null)&&"function"==typeof r){var i=n&&n.id?n.id:"",s=n&&n.innerHTML?n.innerHTML:"",c=n&&n.outerHTML?n.outerHTML:"";a.safeCallbackCall(r,"[QBChat][QBStrophe]"+t+" id:"+i+" innerHTML: "+s+" outerHTML: "+c+JSON.stringify(n))}};return 1===s.active?(n.xmlInput=function(e){if(e.childNodes[0])for(var t=0,n=e.childNodes.length;t<n;t++)a.QBLog("[QBChat]","RECV:",e.childNodes[t]),c("RECV:",e.childNodes[t])},n.xmlOutput=function(e){if(e.childNodes[0])for(var t=0,n=e.childNodes.length;t<n;t++)a.QBLog("[QBChat]","SENT:",e.childNodes[t]),c("SENT",e.childNodes[t])}):(n.xmlInput=function(e){a.QBLog("[QBChat]","RECV:",e),c("RECV:",e);try{let t=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("error");if(t.length>0){let e=t[0].getElementsByTagName("condition");if(e.length>0){let t=e[0].textContent;console.log("Disconnect condition:",t),c("DISCONNECTED CONDITION:",t)}}}catch(e){console.error("Error parsing XML input:",e)}},n.xmlOutput=function(e){a.QBLog("[QBChat]","SENT:",e),c("SENT",e)}),n}},{"./qbConfig":151,"./qbUtils":155,"strophe.js":110,"strophe.js/dist/strophe.umd.js":110}],155:[function(e,t,n){(function(r){(function(){"use strict";var i=e("./qbConfig"),o="object"==typeof r&&(r.hasOwnProperty("android")||r.hasOwnProperty("NSObject")),s="undefined"==typeof window&&"object"==typeof n&&!o,a="undefined"!=typeof window;if(s)var c=e("fs"),l=e("os");var u={machine:Math.floor(16777216*Math.random()).toString(16),pid:Math.floor(32767*Math.random()).toString(16),increment:0},d={getEnv:function(){return{nativescript:o,browser:a,node:s}},_getOSInfoFromNodeJS:function(){return l.platform()},_getOSInfoFromBrowser:function(){return window.navigator.userAgent},_getOSInfoFromNativeScript:function(){return(r&&r.hasOwnProperty("android")?"Android":"iOS")+" - NativeScript"},getOS:function(){var e,t="An unknown OS";if(this.getEnv().browser)e=this._getOSInfoFromBrowser();else if(this.getEnv().node)e=this._getOSInfoFromNodeJS();else if(this.getEnv().nativescript)return this._getOSInfoFromNativeScript();return[{osName:"Windows",codeNames:["Windows","win32"]},{osName:"Linux",codeNames:["Linux","linux"]},{osName:"macOS",codeNames:["Mac OS","darwin"]}].forEach(function(n){n.codeNames.forEach(function(r){-1!==e.indexOf(r)&&(t=n.osName)})}),t},safeCallbackCall:function(){for(var e,t=arguments[0].toString().split("(")[0].split(" ")[1],n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);e=n.shift();try{e.apply(null,n)}catch(e){""===t?console.error("Error: "+e):console.error("Error in listener "+t+": "+e)}},randomNonce:function(){return Math.floor(1e4*Math.random())},unixTime:function(){return Math.floor(Date.now()/1e3)},getUrl:function(e,t){var n=t?"/"+t:"";return"https://"+i.endpoints.api+"/"+e+n+i.urls.type},formatUrl:function(e,t){var n=t?"/"+t:"";return"https://"+i.endpoints.api+"/"+e+n},isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},isObject:function(e){return"[object Object]"===Object.prototype.toString.call(e)},getBsonObjectId:function(){var e=this.unixTime().toString(16),t=(u.increment++).toString(16);return t>16777215&&(u.increment=0),"00000000".substr(0,8-e.length)+e+"000000".substr(0,6-u.machine.length)+u.machine+"0000".substr(0,4-u.pid.length)+u.pid+"000000".substr(0,6-t.length)+t},getCurrentTime:function(){return(new Date).toTimeString().split(" ")[0]},injectISOTimes:function(e){if(e.created_at)"number"==typeof e.created_at&&(e.iso_created_at=new Date(1e3*e.created_at).toISOString()),"number"==typeof e.updated_at&&(e.iso_updated_at=new Date(1e3*e.updated_at).toISOString());else if(e.items)for(var t=0,n=e.items.length;t<n;++t)"number"==typeof e.items[t].created_at&&(e.items[t].iso_created_at=new Date(1e3*e.items[t].created_at).toISOString()),"number"==typeof e.items[t].updated_at&&(e.items[t].iso_updated_at=new Date(1e3*e.items[t].updated_at).toISOString());return e},QBLog:function(){var e=Array.prototype.slice.call(arguments);let t=i&&!1===i.pingDebug,n=e.some(function(e){try{if(null==e)return!1;if("string"==typeof e)return-1!==e.toLowerCase().indexOf("ping");if("number"==typeof e||"boolean"==typeof e)return!1;if("object"==typeof e){if("string"==typeof e.outerHTML){var t=e.outerHTML.replace(/\s+/g," ").toLowerCase();if(-1!==t.indexOf("urn:xmpp:sm:3")&&(/^<\s*r\b/.test(t)||/^<\s*a\b/.test(t)))return!0}for(var n=[e.textContent,e.innerHTML,e.outerHTML,e.nodeName,e.tagName,e.id],r=0;r<n.length;r++){var i=n[r];if("string"==typeof i&&-1!==i.toLowerCase().indexOf("ping"))return!0}}}catch(e){}return!1}),r=t&&n;if(this.loggers)for(var o=0;o<this.loggers.length;++o)r||this.loggers[o](arguments);else{var s;this.loggers=[];var a=function(){return function(e){console.log.apply(console,Array.prototype.slice.call(e))}},l=function(){return function(e){if(!c)throw"This function isn't supported outside of the browser (...yet)";for(var t=[],n=0;n<e.length;n++)t.push(JSON.stringify(e[n]));t=t.join(" ");var r="\n"+new Date+". "+t;c.appendFile(i.debug.file,r,function(e){if(e)return console.error("Error while writing log to file. Error: "+e)})}};if("object"==typeof i.debug){if("number"==typeof i.debug.mode)1==i.debug.mode?(s=a(),this.loggers.push(s)):2==i.debug.mode&&(s=l(),this.loggers.push(s));else if("object"==typeof i.debug.mode){var u=this;i.debug.mode.forEach(function(e){1===e?(s=a(),u.loggers.push(s)):2===e&&(s=l(),u.loggers.push(s))})}}else"boolean"==typeof i.debug&&i.debug&&(s=a(),this.loggers.push(s));if(this.loggers)for(var d=0;d<this.loggers.length;++d)r||this.loggers[d](arguments)}},isWebRTCAvailble:function(){var e=window.RTCPeerConnection,t=window.RTCIceCandidate,n=window.RTCSessionDescription,r=window.navigator.mediaDevices;return Boolean(e)&&Boolean(t)&&Boolean(n)&&Boolean(r)},getError:function(e,t,n){var r={code:e,status:"error",detail:t};switch(e){case 401:r.message="Unauthorized";break;case 403:r.message="Forbidden";break;case 408:r.message="Request Timeout";break;case 422:r.message="Unprocessable Entity";break;case 502:r.message="Bad Gateway";break;default:r.message="Unknown error"}return this.QBLog("["+n+"]","Error:",t),r},MergeArrayOfObjects:function(e,t){var n=JSON.parse(JSON.stringify(e));e:for(var r=0;r<t.length;r++){for(var i=t[r],o=0;o<n.length;o++)if(i.user_id===n[o].user_id){n[o]=i;continue e}n.push(i)}return n},getTimeIntervalForCallBackMessage:function(){return 1e3*(void 0===i.callBackInterval?2:i.callBackInterval)}};t.exports=d}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./qbConfig":151,fs:26,os:87}]},{},[152])(152)});