/*! For license information please see converse.min.js.LICENSE.txt */ (()=>{var e,t,n,s,i={8926:e=>{function t(e,t,n,s,i,o,r){try{var a=e[o](r),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(s,i)}e.exports=function(e){return function(){var n=this,s=arguments;return new Promise((function(i,o){var r=e.apply(n,s);function a(e){t(r,i,o,a,c,"next",e)}function c(e){t(r,i,o,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},9713:e=>{e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},5318:e=>{e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},1553:e=>{var t=function(e){"use strict";var t,n=Object.prototype,s=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",r=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function l(e,t,n,s){var i=t&&t.prototype instanceof p?t:p,o=Object.create(i.prototype),r=new j(s||[]);return o._invoke=function(e,t,n){var s=u;return function(i,o){if(s===m)throw new Error("Generator is already running");if(s===g){if("throw"===i)throw o;return $()}for(n.method=i,n.arg=o;;){var r=n.delegate;if(r){var a=A(r,n);if(a){if(a===f)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(s===u)throw s=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);s=m;var c=d(e,t,n);if("normal"===c.type){if(s=n.done?g:h,c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(s=g,n.method="throw",n.arg=c.arg)}}}(e,n,r),o}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var u="suspendedStart",h="suspendedYield",m="executing",g="completed",f={};function p(){}function v(){}function _(){}var y={};c(y,o,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(T([])));w&&w!==n&&s.call(w,o)&&(y=w);var S=_.prototype=p.prototype=Object.create(y);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,o,r,a){var c=d(e[i],e,o);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&s.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,r,a)}),(function(e){n("throw",e,r,a)})):t.resolve(u).then((function(e){l.value=e,r(l)}),(function(e){return n("throw",e,r,a)}))}a(c.arg)}var i;this._invoke=function(e,s){function o(){return new t((function(t,i){n(e,s,t,i)}))}return i=i?i.then(o,o):o()}}function A(e,n){var s=e.iterator[n.method];if(s===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,A(e,n),"throw"===n.method))return f;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var i=d(s,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,f;var o=i.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,f):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function T(e){if(e){var n=e[o];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function n(){for(;++i=0;--o){var r=this.tryEntries[o],a=r.completion;if("root"===r.tryLoc)return i("end");if(r.tryLoc<=this.prev){var c=s.call(r,"catchLoc"),l=s.call(r,"finallyLoc");if(c&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var s=n.completion;if("throw"===s.type){var i=s.arg;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,s){return this.delegate={iterator:T(e),resultName:n,nextLoc:s},"next"===this.method&&(this.arg=t),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},7757:(e,t,n)=>{e.exports=n(1553)},9494:(e,t,n)=>{"use strict";const s=n(7672),i=n(4817);e.exports={atob:s,btoa:i}},7672:e=>{"use strict";function t(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);return t<0?void 0:t}e.exports=function(e){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 n="",s=0,i=0;for(let o=0;o>16),n+=String.fromCharCode((65280&s)>>8),n+=String.fromCharCode(255&s),s=i=0);return 12===i?(s>>=4,n+=String.fromCharCode(s)):18===i&&(s>>=2,n+=String.fromCharCode((65280&s)>>8),n+=String.fromCharCode(255&s)),n}},4817:e=>{"use strict";function t(e){if(e>=0&&e<64)return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e]}e.exports=function(e){let n;for(e=`${e}`,n=0;n255)return null;let s="";for(n=0;n>2,i[1]=(3&e.charCodeAt(n))<<4,e.length>n+1&&(i[1]|=e.charCodeAt(n+1)>>4,i[2]=(15&e.charCodeAt(n+1))<<2),e.length>n+2&&(i[2]|=e.charCodeAt(n+2)>>6,i[3]=63&e.charCodeAt(n+2));for(let e=0;e{var s;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function o(e){return a(l(e),arguments)}function r(e,t){return o.apply(null,[e].concat(t||[]))}function a(e,t){var n,s,r,a,c,l,d,u,h,m=1,g=e.length,f="";for(s=0;s=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?f+=n:(!i.number.test(a.type)||u&&!a.sign?h="":(h=u?"+":"-",n=n.toString().replace(i.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",d=a.width-(h+n).length,c=a.width&&d>0?l.repeat(d):"",f+=a.align?h+n+c:"0"===l?h+c+n:c+h+n)}return f}var c=Object.create(null);function l(e){if(c[e])return c[e];for(var t,n=e,s=[],o=0;n;){if(null!==(t=i.text.exec(n)))s.push(t[0]);else if(null!==(t=i.modulo.exec(n)))s.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){o|=1;var r=[],a=t[2],l=[];if(null===(l=i.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(r.push(l[1]);""!==(a=a.substring(l[0].length));)if(null!==(l=i.key_access.exec(a)))r.push(l[1]);else{if(null===(l=i.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");r.push(l[1])}t[2]=r}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");s.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return c[e]=s}t.sprintf=o,t.vsprintf=r,"undefined"!=typeof window&&(window.sprintf=o,window.vsprintf=r,void 0===(s=function(){return{sprintf:o,vsprintf:r}}.call(t,n,t,e))||(e.exports=s))}()},8677:function(e,t,n){var s,i;!function(o,r){"use strict";e.exports?e.exports=r():void 0===(i="function"==typeof(s=r)?s.call(t,n,t,e):s)||(e.exports=i)}(0,(function(e){"use strict";var t=e&&e.IPv6;return{best:function(e){var t,n,s=e.toLowerCase().split(":"),i=s.length,o=8;for(""===s[0]&&""===s[1]&&""===s[2]?(s.shift(),s.shift()):""===s[0]&&""===s[1]?s.shift():""===s[i-1]&&""===s[i-2]&&s.pop(),-1!==s[(i=s.length)-1].indexOf(".")&&(o=7),t=0;t1);a++)n.splice(0,1);s[r]=n.join("")}var c=-1,l=0,d=0,u=-1,h=!1;for(r=0;rl&&(c=u,l=d)):"0"===s[r]&&(h=!0,u=r,d=1);d>l&&(c=u,l=d),l>1&&s.splice(c,l,""),i=s.length;var m="";for(""===s[0]&&(m=":"),r=0;r=e.length-1)return!1;var s=e.lastIndexOf(".",t-1);if(s<=0||s>=t-1)return!1;var i=n.list[e.slice(t+1)];return!!i&&i.indexOf(" "+e.slice(s+1,t)+" ")>=0},is:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return!1;if(e.lastIndexOf(".",t-1)>=0)return!1;var s=n.list[e.slice(t+1)];return!!s&&s.indexOf(" "+e.slice(0,t)+" ")>=0},get:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return null;var s=e.lastIndexOf(".",t-1);if(s<=0||s>=t-1)return null;var i=n.list[e.slice(t+1)];return i?i.indexOf(" "+e.slice(s+1,t)+" ")<0?null:e.slice(s+1):null},noConflict:function(){return e.SecondLevelDomains===this&&(e.SecondLevelDomains=t),this}};return n}))},5215:function(e,t,n){var s,i,o;!function(r,a){"use strict";e.exports?e.exports=a(n(7819),n(8677),n(9827)):(i=[n(7819),n(8677),n(9827)],void 0===(o="function"==typeof(s=a)?s.apply(t,i):s)||(e.exports=o))}(0,(function(e,t,n,s){"use strict";var i=s&&s.URI;function o(e,t){var n=arguments.length>=1,s=arguments.length>=2;if(!(this instanceof o))return n?s?new o(e,t):new o(e):new o;if(void 0===e){if(n)throw new TypeError("undefined is not a valid argument for URI");e="undefined"!=typeof location?location.href+"":""}if(null===e&&n)throw new TypeError("null is not a valid argument for URI");return this.href(e),void 0!==t?this.absoluteTo(t):this}o.version="1.19.11";var r=o.prototype,a=Object.prototype.hasOwnProperty;function c(e){return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function l(e){return void 0===e?"Undefined":String(Object.prototype.toString.call(e)).slice(8,-1)}function d(e){return"Array"===l(e)}function u(e,t){var n,s,i={};if("RegExp"===l(t))i=null;else if(d(t))for(n=0,s=t.length;n]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,o.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},o.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,o.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,o.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},o.hostProtocols=["http","https"],o.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,o.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},o.getDomAttribute=function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();if("input"!==t||"image"===e.type)return o.domAttributes[t]}},o.encode=p,o.decode=decodeURIComponent,o.iso8859=function(){o.encode=escape,o.decode=unescape},o.unicode=function(){o.encode=p,o.decode=decodeURIComponent},o.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},o.encodeQuery=function(e,t){var n=o.encode(e+"");return void 0===t&&(t=o.escapeQuerySpace),t?n.replace(/%20/g,"+"):n},o.decodeQuery=function(e,t){e+="",void 0===t&&(t=o.escapeQuerySpace);try{return o.decode(t?e.replace(/\+/g,"%20"):e)}catch(t){return e}};var v,_={encode:"encode",decode:"decode"},y=function(e,t){return function(n){try{return o[t](n+"").replace(o.characters[e][t].expression,(function(n){return o.characters[e][t].map[n]}))}catch(e){return n}}};for(v in _)o[v+"PathSegment"]=y("pathname",_[v]),o[v+"UrnPathSegment"]=y("urnpath",_[v]);var b=function(e,t,n){return function(s){var i;i=n?function(e){return o[t](o[n](e))}:o[t];for(var r=(s+"").split(e),a=0,c=r.length;a-1&&(t.fragment=e.substring(n+1)||null,e=e.substring(0,n)),(n=e.indexOf("?"))>-1&&(t.query=e.substring(n+1)||null,e=e.substring(0,n)),"//"===(e=(e=e.replace(/^(https?|ftp|wss?)?:+[/\\]*/i,"$1://")).replace(/^[/\\]{2,}/i,"//")).substring(0,2)?(t.protocol=null,e=e.substring(2),e=o.parseAuthority(e,t)):(n=e.indexOf(":"))>-1&&(t.protocol=e.substring(0,n)||null,t.protocol&&!t.protocol.match(o.protocol_expression)?t.protocol=void 0:"//"===e.substring(n+1,n+3).replace(/\\/g,"/")?(e=e.substring(n+3),e=o.parseAuthority(e,t)):(e=e.substring(n+1),t.urn=!0)),t.path=e,t},o.parseHost=function(e,t){e||(e="");var n,s,i=(e=e.replace(/\\/g,"/")).indexOf("/");if(-1===i&&(i=e.length),"["===e.charAt(0))n=e.indexOf("]"),t.hostname=e.substring(1,n)||null,t.port=e.substring(n+2,i)||null,"/"===t.port&&(t.port=null);else{var r=e.indexOf(":"),a=e.indexOf("/"),c=e.indexOf(":",r+1);-1!==c&&(-1===a||c-1?i:e.length-1);return r>-1&&(-1===i||r-1?m.slice(0,g)+m.slice(g).replace(r,""):m.replace(r,"")).length<=l[0].length||n.ignore&&n.ignore.test(m))){var v=t(m,d,h=d+m.length,e);void 0!==v?(v=String(v),e=e.slice(0,d)+v+e.slice(h),s.lastIndex=d+v.length):s.lastIndex=h}}return s.lastIndex=0,e},o.ensureValidHostname=function(t,n){var s=!!t,i=!1;if(!!n&&(i=h(o.hostProtocols,n)),i&&!s)throw new TypeError("Hostname cannot be empty, if protocol is "+n);if(t&&t.match(o.invalid_hostname_characters)){if(!e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(e.toASCII(t).match(o.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]')}},o.ensureValidPort=function(e){if(e){var t=Number(e);if(!(/^[0-9]+$/.test(t)&&t>0&&t<65536))throw new TypeError('Port "'+e+'" is not a valid port')}},o.noConflict=function(e){if(e){var t={URI:this.noConflict()};return s.URITemplate&&"function"==typeof s.URITemplate.noConflict&&(t.URITemplate=s.URITemplate.noConflict()),s.IPv6&&"function"==typeof s.IPv6.noConflict&&(t.IPv6=s.IPv6.noConflict()),s.SecondLevelDomains&&"function"==typeof s.SecondLevelDomains.noConflict&&(t.SecondLevelDomains=s.SecondLevelDomains.noConflict()),t}return s.URI===this&&(s.URI=i),this},r.build=function(e){return!0===e?this._deferred_build=!0:(void 0===e||this._deferred_build)&&(this._string=o.build(this._parts),this._deferred_build=!1),this},r.clone=function(){return new o(this)},r.valueOf=r.toString=function(){return this.build(!1)._string},r.protocol=w("protocol"),r.username=w("username"),r.password=w("password"),r.hostname=w("hostname"),r.port=w("port"),r.query=S("query","?"),r.fragment=S("fragment","#"),r.search=function(e,t){var n=this.query(e,t);return"string"==typeof n&&n.length?"?"+n:n},r.hash=function(e,t){var n=this.fragment(e,t);return"string"==typeof n&&n.length?"#"+n:n},r.pathname=function(e,t){if(void 0===e||!0===e){var n=this._parts.path||(this._parts.hostname?"/":"");return e?(this._parts.urn?o.decodeUrnPath:o.decodePath)(n):n}return this._parts.urn?this._parts.path=e?o.recodeUrnPath(e):"":this._parts.path=e?o.recodePath(e):"/",this.build(!t),this},r.path=r.pathname,r.href=function(e,t){var n;if(void 0===e)return this.toString();this._string="",this._parts=o._parts();var s=e instanceof o,i="object"==typeof e&&(e.hostname||e.path||e.pathname);e.nodeName&&(e=e[o.getDomAttribute(e)]||"",i=!1);if(!s&&i&&void 0!==e.pathname&&(e=e.toString()),"string"==typeof e||e instanceof String)this._parts=o.parse(String(e),this._parts);else{if(!s&&!i)throw new TypeError("invalid input");var r=s?e._parts:e;for(n in r)"query"!==n&&a.call(this._parts,n)&&(this._parts[n]=r[n]);r.query&&this.query(r.query,!1)}return this.build(!t),this},r.is=function(e){var t=!1,s=!1,i=!1,r=!1,a=!1,c=!1,l=!1,d=!this._parts.urn;switch(this._parts.hostname&&(d=!1,s=o.ip4_expression.test(this._parts.hostname),i=o.ip6_expression.test(this._parts.hostname),a=(r=!(t=s||i))&&n&&n.has(this._parts.hostname),c=r&&o.idn_expression.test(this._parts.hostname),l=r&&o.punycode_expression.test(this._parts.hostname)),e.toLowerCase()){case"relative":return d;case"absolute":return!d;case"domain":case"name":return r;case"sld":return a;case"ip":return t;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return i;case"idn":return c;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return l}return null};var x=r.protocol,E=r.port,A=r.hostname;r.protocol=function(e,t){if(e&&!(e=e.replace(/:(\/\/)?$/,"")).match(o.protocol_expression))throw new TypeError('Protocol "'+e+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return x.call(this,e,t)},r.scheme=r.protocol,r.port=function(e,t){return this._parts.urn?void 0===e?"":this:(void 0!==e&&(0===e&&(e=null),e&&(":"===(e+="").charAt(0)&&(e=e.substring(1)),o.ensureValidPort(e))),E.call(this,e,t))},r.hostname=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0!==e){var n={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==o.parseHost(e,n))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');e=n.hostname,this._parts.preventInvalidHostname&&o.ensureValidHostname(e,this._parts.protocol)}return A.call(this,e,t)},r.origin=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var n=this.protocol();return this.authority()?(n?n+"://":"")+this.authority():""}var s=o(e);return this.protocol(s.protocol()).authority(s.authority()).build(!t),this},r.host=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?o.buildHost(this._parts):"";if("/"!==o.parseHost(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},r.authority=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?o.buildAuthority(this._parts):"";if("/"!==o.parseAuthority(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},r.userinfo=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var n=o.buildUserinfo(this._parts);return n?n.substring(0,n.length-1):n}return"@"!==e[e.length-1]&&(e+="@"),o.parseUserinfo(e,this._parts),this.build(!t),this},r.resource=function(e,t){var n;return void 0===e?this.path()+this.search()+this.hash():(n=o.parse(e),this._parts.path=n.path,this._parts.query=n.query,this._parts.fragment=n.fragment,this.build(!t),this)},r.subdomain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,n)||""}var s=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,s),r=new RegExp("^"+c(i));if(e&&"."!==e.charAt(e.length-1)&&(e+="."),-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");return e&&o.ensureValidHostname(e,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(r,e),this.build(!t),this},r.domain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.match(/\./g);if(n&&n.length<2)return this._parts.hostname;var s=this._parts.hostname.length-this.tld(t).length-1;return s=this._parts.hostname.lastIndexOf(".",s-1)+1,this._parts.hostname.substring(s)||""}if(!e)throw new TypeError("cannot set domain empty");if(-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");if(o.ensureValidHostname(e,this._parts.protocol),!this._parts.hostname||this.is("IP"))this._parts.hostname=e;else{var i=new RegExp(c(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(i,e)}return this.build(!t),this},r.tld=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),i=this._parts.hostname.substring(s+1);return!0!==t&&n&&n.list[i.toLowerCase()]&&n.get(this._parts.hostname)||i}var o;if(!e)throw new TypeError("cannot set TLD empty");if(e.match(/[^a-zA-Z0-9-]/)){if(!n||!n.is(e))throw new TypeError('TLD "'+e+'" contains characters other than [A-Z0-9]');o=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,e)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");o=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(o,e)}return this.build(!t),this},r.directory=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var n=this._parts.path.length-this.filename().length-1,s=this._parts.path.substring(0,n)||(this._parts.hostname?"/":"");return e?o.decodePath(s):s}var i=this._parts.path.length-this.filename().length,r=this._parts.path.substring(0,i),a=new RegExp("^"+c(r));return this.is("relative")||(e||(e="/"),"/"!==e.charAt(0)&&(e="/"+e)),e&&"/"!==e.charAt(e.length-1)&&(e+="/"),e=o.recodePath(e),this._parts.path=this._parts.path.replace(a,e),this.build(!t),this},r.filename=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("string"!=typeof e){if(!this._parts.path||"/"===this._parts.path)return"";var n=this._parts.path.lastIndexOf("/"),s=this._parts.path.substring(n+1);return e?o.decodePathSegment(s):s}var i=!1;"/"===e.charAt(0)&&(e=e.substring(1)),e.match(/\.?\//)&&(i=!0);var r=new RegExp(c(this.filename())+"$");return e=o.recodePath(e),this._parts.path=this._parts.path.replace(r,e),i?this.normalizePath(t):this.build(!t),this},r.suffix=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path||"/"===this._parts.path)return"";var n,s,i=this.filename(),r=i.lastIndexOf(".");return-1===r?"":(n=i.substring(r+1),s=/^[a-z0-9%]+$/i.test(n)?n:"",e?o.decodePathSegment(s):s)}"."===e.charAt(0)&&(e=e.substring(1));var a,l=this.suffix();if(l)a=e?new RegExp(c(l)+"$"):new RegExp(c("."+l)+"$");else{if(!e)return this;this._parts.path+="."+o.recodePath(e)}return a&&(e=o.recodePath(e),this._parts.path=this._parts.path.replace(a,e)),this.build(!t),this},r.segment=function(e,t,n){var s=this._parts.urn?":":"/",i=this.path(),o="/"===i.substring(0,1),r=i.split(s);if(void 0!==e&&"number"!=typeof e&&(n=t,t=e,e=void 0),void 0!==e&&"number"!=typeof e)throw new Error('Bad segment "'+e+'", must be 0-based integer');if(o&&r.shift(),e<0&&(e=Math.max(r.length+e,0)),void 0===t)return void 0===e?r:r[e];if(null===e||void 0===r[e])if(d(t)){r=[];for(var a=0,c=t.length;a= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=Math.floor,g=String.fromCharCode;function f(e){throw new RangeError(h[e])}function p(e,t){for(var n=e.length,s=[];n--;)s[n]=t(e[n]);return s}function v(e,t){var n=e.split("@"),s="";return n.length>1&&(s=n[0]+"@",e=n[1]),s+p((e=e.replace(u,".")).split("."),t).join(".")}function _(e){for(var t,n,s=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=g(e)})).join("")}function b(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var s=0;for(e=n?m(e/700):e>>1,e+=m(e/t);e>455;s+=c)e=m(e/35);return m(s+36*e/(e+38))}function S(e){var t,n,s,i,o,r,l,d,u,h,g,p=[],v=e.length,_=0,b=128,S=72;for((n=e.lastIndexOf("-"))<0&&(n=0),s=0;s=128&&f("not-basic"),p.push(e.charCodeAt(s));for(i=n>0?n+1:0;i=v&&f("invalid-input"),((d=(g=e.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:c)>=c||d>m((a-_)/r))&&f("overflow"),_+=d*r,!(d<(u=l<=S?1:l>=S+26?26:l-S));l+=c)r>m(a/(h=c-u))&&f("overflow"),r*=h;S=w(_-o,t=p.length+1,0==o),m(_/t)>a-b&&f("overflow"),b+=m(_/t),_%=t,p.splice(_++,0,b)}return y(p)}function x(e){var t,n,s,i,o,r,l,d,u,h,p,v,y,S,x,E=[];for(v=(e=_(e)).length,t=128,n=0,o=72,r=0;r=t&&pm((a-n)/(y=s+1))&&f("overflow"),n+=(l-t)*y,t=l,r=0;ra&&f("overflow"),p==t){for(d=n,u=c;!(d<(h=u<=o?1:u>=o+26?26:u-o));u+=c)x=d-h,S=c-h,E.push(g(b(h+x%S,0))),d=m(x/S);E.push(g(b(d,0))),o=w(n,y,s==i),n=0,++s}++n,++t}return E.join("")}r={version:"1.3.2",ucs2:{decode:_,encode:y},decode:S,encode:x,toASCII:function(e){return v(e,(function(e){return d.test(e)?"xn--"+x(e):e}))},toUnicode:function(e){return v(e,(function(e){return l.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(s=function(){return r}.call(t,n,t,e))||(e.exports=s)}()},517:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>mk});var s=n(5215),i=n.n(s),o=n(4223);const r={initialize(){},__(){return(0,o.sprintf)(...arguments)}};const a=function(e){return null!=e&&"object"==typeof e};const c="object"==typeof global&&global&&global.Object===Object&&global;var l="object"==typeof self&&self&&self.Object===Object&&self;const d=c||l||Function("return this")();const u=d.Symbol;var h=Object.prototype,m=h.hasOwnProperty,g=h.toString,f=u?u.toStringTag:void 0;const p=function(e){var t=m.call(e,f),n=e[f];try{e[f]=void 0;var s=!0}catch(e){}var i=g.call(e);return s&&(t?e[f]=n:delete e[f]),i};var v=Object.prototype.toString;const _=function(e){return v.call(e)};var y=u?u.toStringTag:void 0;const b=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":y&&y in Object(e)?p(e):_(e)};const w=function(e,t){return function(n){return e(t(n))}};const S=w(Object.getPrototypeOf,Object);var x=Function.prototype,E=Object.prototype,A=x.toString,C=E.hasOwnProperty,k=A.call(Object);const j=function(e){if(!a(e)||"[object Object]"!=b(e))return!1;var t=S(e);if(null===t)return!0;var n=C.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&A.call(n)==k};const T=function(e){return a(e)&&1===e.nodeType&&!j(e)};var $,N,O,I;const M={debug:0,info:1,warn:2,error:3,fatal:4},R=Object.assign({debug:null!==($=console)&&void 0!==$&&$.log?console.log.bind(console):function(){},error:null!==(N=console)&&void 0!==N&&N.log?console.log.bind(console):function(){},info:null!==(O=console)&&void 0!==O&&O.log?console.log.bind(console):function(){},warn:null!==(I=console)&&void 0!==I&&I.log?console.log.bind(console):function(){}},console),D={setLogLevel(e){if(!["debug","info","warn","error","fatal"].includes(e))throw new Error(`Invalid loglevel: ${e}`);this.loglevel=e},log(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(M[t]>16)+(t>>16)+(n>>16)<<16|65535&n},U=function(e){if("string"!=typeof e)throw new Error("str2binl was passed a non-string");const t=[];for(let n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<>>32-a,n);var r,a},q=function(e,t,n,s,i,o,r){return B(t&n|~t&s,e,t,i,o,r)},H=function(e,t,n,s,i,o,r){return B(t&s|n&~s,e,t,i,o,r)},G=function(e,t,n,s,i,o,r){return B(t^n^s,e,t,i,o,r)},W=function(e,t,n,s,i,o,r){return B(n^(t|~s),e,t,i,o,r)},V=function(e,t){e[t>>5]|=128<>>9<<4)]=t;let n,s,i,o,r=1732584193,a=-271733879,c=-1732584194,l=271733878;for(let t=0;t>2]>>s%4*8+4&15)+t.charAt(e[s>>2]>>s%4*8&15);return n}(V(U(e),8*e.length))},hash:function(e){return function(e){let t="";for(let n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(V(U(e),8*e.length))}};class Q{constructor(e,t,n){this.mechname=e,this.isClientFirst=t,this.priority=n}test(){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 Z=function(e){var t,n,s="",i=e.length;for(t=0;t=0&&n<=127?s+=e.charAt(t):n>2047?(s+=String.fromCharCode(224|n>>12&15),s+=String.fromCharCode(128|n>>6&63),s+=String.fromCharCode(128|n>>0&63)):(s+=String.fromCharCode(192|n>>6&31),s+=String.fromCharCode(128|n>>0&63));return s},K=function(e){e=e||{};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n="",s="",i="";const o=e[t],r="object"==typeof o,a=escape(unescape(r?o.value:o));r&&(n=o.expires?";expires="+o.expires:"",s=o.domain?";domain="+o.domain:"",i=o.path?";path="+o.path:""),document.cookie=t+"="+a+n+s+i}};function Y(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;var n,s,i,o,r,a,c,l,d=new Array(80),u=1732584193,h=-271733879,m=-1732584194,g=271733878,f=-1009589776;for(n=0;n16&&(n=Y(n,8*e.length));for(var s=new Array(16),i=new Array(16),o=0;o<16;o++)s[o]=909522486^n[o],i[o]=1549556828^n[o];var r=Y(s.concat(ie(t)),512+8*t.length);return Y(i.concat(r),672)}function ne(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function se(e,t){return e<>>32-t}function ie(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function oe(e){for(var t,n,s="",i=0;i<4*e.length;i+=3)for(t=(e[i>>2]>>8*(3-i%4)&255)<<16|(e[i+1>>2]>>8*(3-(i+1)%4)&255)<<8|e[i+2>>2]>>8*(3-(i+2)%4)&255,n=0;n<4;n++)8*i+6*n>32*e.length?s+="=":s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return s}function re(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}const ae={b64_hmac_sha1:function(e,t){return oe(te(e,t))},b64_sha1:function(e){return oe(Y(ie(e),8*e.length))},binb2str:re,core_hmac_sha1:te,str_hmac_sha1:function(e,t){return re(te(e,t))},str_sha1:function(e){return re(Y(ie(e),8*e.length))}};var ce=n(9494);function le(e,t){return new me.Builder(e,t)}function de(e){return new me.Builder("message",e)}function ue(e){return new me.Builder("iq",e)}function he(e){return new me.Builder("presence",e)}const me={VERSION:"1.5.0",NS:{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"},XHTML:{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"],validTag(e){for(let t=0;t0)for(let n=0;ne.tagName===t,_xmlGenerator:null,xmlGenerator:()=>(me._xmlGenerator||(me._xmlGenerator=document.implementation.createDocument("jabber:client","strophe",null)),me._xmlGenerator),xmlElement(e){if(!e)return null;const t=me.xmlGenerator().createElement(e);for(let e=1;ee=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(//g,">")).replace(/'/g,"'")).replace(/"/g,"""),xmlunescape:e=>e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"'),xmlTextNode:e=>me.xmlGenerator().createTextNode(e),xmlHtmlNode(e){let t;if(P){t=(new P).parseFromString(e,"text/xml")}else t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e);return t},getText(e){if(!e)return null;let t="";0===e.childNodes.length&&e.nodeType===me.ElementType.TEXT&&(t+=e.nodeValue);for(let n=0;n0&&(o=e.join("; "),t.setAttribute(i,o))}else t.setAttribute(i,o)}for(let n=0;n"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,"\\3e").replace(/@/g,"\\40"),unescapeNode:e=>"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:e=>e.indexOf("@")<0?null:e.split("@")[0],getDomainFromJid(e){const t=me.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;{const e=t.split("@");return e.splice(0,1),e.join("@")}},getResourceFromJid(e){if(!e)return null;const t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:e=>e?e.split("/")[0]:null,_handleError(e){void 0!==e.stack&&me.fatal(e.stack),e.sourceURL?me.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?me.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):me.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)},serialize(e){if(!e)return null;"function"==typeof e.tree&&(e=e.tree());const t=[...Array(e.attributes.length).keys()].map((t=>e.attributes[t].nodeName));t.sort();let n=t.reduce(((t,n)=>`${t} ${n}="${me.xmlescape(e.attributes.getNamedItem(n).value)}"`),`<${e.nodeName}`);if(e.childNodes.length>0){n+=">";for(let t=0;t"}}n+=""}else n+="/>";return n},_requestId:0,_connectionPlugins:{},addConnectionPlugin(e,t){me._connectionPlugins[e]=t},Builder:class{constructor(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=me.NS.CLIENT:t||(t={xmlns:me.NS.CLIENT})),this.nodeTree=me.xmlElement(e,t),this.node=this.nodeTree}tree(){return this.nodeTree}toString(){return me.serialize(this.nodeTree)}up(){return this.node=this.node.parentNode,this}root(){return this.node=this.nodeTree,this}attrs(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this}c(e,t,n){const s=me.xmlElement(e,t,n);return this.node.appendChild(s),"string"!=typeof n&&"number"!=typeof n&&(this.node=s),this}cnode(e){let t;const n=me.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}const s=t?n.importNode(e,!0):me.copyElement(e);return this.node.appendChild(s),this.node=s,this}t(e){const t=me.xmlTextNode(e);return this.node.appendChild(t),this}h(e){const t=me.xmlGenerator().createElement("body");t.innerHTML=e;const n=me.createHtml(t);for(;n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}},Handler:function(e,t,n,s,i,o,r){this.handler=e,this.ns=t,this.name=n,this.type=s,this.id=i,this.options=r||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBare&&(me.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.'),this.options.matchBareFromJid=this.options.matchBare,delete this.options.matchBare),this.options.matchBareFromJid?this.from=o?me.getBareJidFromJid(o):null:this.from=o,this.user=!0}};me.Handler.prototype={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||(me.forEachChild(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=me.getBareJidFromJid(t));const n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!me.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 me._handleError(e),e}return t},toString(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},me.TimedHandler=class{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+")}"}},me.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),K(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),this.iqFallbackHandler=new me.Handler((e=>this.send(ue({type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("service-unavailable",{xmlns:me.NS.STANZAS}))),null,"iq",["get","set"]);for(const e in me._connectionPlugins)if(Object.prototype.hasOwnProperty.call(me._connectionPlugins,e)){const t=function(){};t.prototype=me._connectionPlugins[e],this[e]=new t,this[e].init(this)}}setProtocol(){const e=this.options.protocol||"";this.options.worker?this._proto=new me.WorkerWebsocket(this):0===this.service.indexOf("ws:")||0===this.service.indexOf("wss:")||0===e.indexOf("ws")?this._proto=new me.Websocket(this):this._proto=new me.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,s,i,o,r){let a=arguments.length>7&&void 0!==arguments[7]?arguments[7]:3e3;this.jid=e,this.authzid=me.getBareJidFromJid(this.jid),this.authcid=r||me.getNodeFromJid(this.jid),this.pass=t,this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.disconnection_timeout=a,this.domain=me.getDomainFromJid(this.jid),this._changeConnectStatus(me.Status.CONNECTING,null),this._proto._connect(s,i,o)}attach(e,t,n,s,i,o,r){if(this._proto._attach)return this._proto._attach(e,t,n,s,i,o,r);{const e=new Error('The "attach" method is not available for your connection protocol');throw e.name="StropheSessionError",e}}restore(e,t,n,s,i){if(!this._sessionCachingSupported()){const e=new Error('The "restore" method can only be used with a BOSH connection.');throw e.name="StropheSessionError",e}this._proto._restore(e,t,n,s,i)}_sessionCachingSupported(){if(this._proto instanceof me.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("function"==typeof e.sort)for(let t=0;t{i&&this.deleteTimedHandler(i),"error"===e.getAttribute("type")?n&&n(e):t&&t(e)}),null,"presence",null,o);s&&(i=this.addTimedHandler(s,(()=>(this.deleteHandler(e),n&&n(null),!1))))}return this.send(e),o}sendIQ(e,t,n,s){let i=null;"function"==typeof e.tree&&(e=e.tree());let o=e.getAttribute("id");if(o||(o=this.getUniqueId("sendIQ"),e.setAttribute("id",o)),"function"==typeof t||"function"==typeof n){const e=this.addHandler((e=>{i&&this.deleteTimedHandler(i);const s=e.getAttribute("type");if("result"===s)t&&t(e);else{if("error"!==s){const e=new Error(`Got bad IQ type of ${s}`);throw e.name="StropheError",e}n&&n(e)}}),null,"iq",["error","result"],o);s&&(i=this.addTimedHandler(s,(()=>(this.deleteHandler(e),n&&n(null),!1))))}return this.send(e),o}_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 me.TimedHandler(e,t);return this.addTimeds.push(n),n}deleteTimedHandler(e){this.removeTimeds.push(e)}addHandler(e,t,n,s,i,o,r){const a=new me.Handler(e,t,n,s,i,o,r);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=e||[me.SASLAnonymous,me.SASLExternal,me.SASLOAuthBearer,me.SASLXOAuth2,me.SASLPlain,me.SASLSHA1]).forEach((e=>this.registerSASLMechanism(e)))}registerSASLMechanism(e){const t=new e;this.mechanisms[t.mechname]=t}disconnect(e){if(this._changeConnectStatus(me.Status.DISCONNECTING,e),e?me.warn("Disconnect was called because: "+e):me.info("Disconnect was called"),this.connected){let e=!1;this.disconnecting=!0,this.authenticated&&(e=he({xmlns:me.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(this.disconnection_timeout,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else me.warn("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()}_changeConnectStatus(e,t,n){for(const n in me._connectionPlugins)if(Object.prototype.hasOwnProperty.call(me._connectionPlugins,n)){const s=this[n];if(s.statusChanged)try{s.statusChanged(e,t)}catch(e){me.error(`${n} plugin caused an exception changing status: ${e}`)}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){me._handleError(e),me.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),me.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(me.Status.DISCONNECTED,e),this.connected=!1}_dataRecv(e,t){const n=this._proto._reqToData(e);if(null===n)return;for(this.xmlInput!==me.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==me.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(me.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 s=n.getAttribute("type");if(null!==s&&"terminate"===s){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(me.Status.CONNFAIL,e)):this._changeConnectStatus(me.Status.CONNFAIL,me.ErrorCondition.UNKOWN_REASON),void this._doDisconnect(e)}me.forEachChild(n,null,(e=>{const t=[];this.handlers=this.handlers.reduce(((n,s)=>{try{!s.isMatch(e)||!this.authenticated&&s.user?n.push(s):(s.run(e)&&n.push(s),t.push(s))}catch(e){me.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 s;me.debug("_connect_cb was called"),this.connected=!0;try{s=this._proto._reqToData(e)}catch(e){if(e.name!==me.ErrorCondition.BAD_FORMAT)throw e;this._changeConnectStatus(me.Status.CONNFAIL,me.ErrorCondition.BAD_FORMAT),this._doDisconnect(me.ErrorCondition.BAD_FORMAT)}if(!s)return;this.xmlInput!==me.Connection.prototype.xmlInput&&(s.nodeName===this._proto.strip&&s.childNodes.length?this.xmlInput(s.childNodes[0]):this.xmlInput(s)),this.rawInput!==me.Connection.prototype.rawInput&&(n?this.rawInput(n):this.rawInput(me.serialize(s)));if(this._proto._connect_cb(s)===me.Status.CONNFAIL)return;let i;if(i=s.getElementsByTagNameNS?s.getElementsByTagNameNS(me.NS.STREAM,"features").length>0:s.getElementsByTagName("stream:features").length>0||s.getElementsByTagName("features").length>0,!i)return void this._proto._no_auth_received(t);const o=Array.from(s.getElementsByTagName("mechanism")).map((e=>this.mechanisms[e.textContent])).filter((e=>e));0!==o.length||0!==s.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(o):this._proto._no_auth_received(t)}sortMechanismsByPriority(e){for(let t=0;te[n].priority&&(n=s);if(n!==t){const s=e[t];e[t]=e[n],e[n]=s}}return e}authenticate(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}_attemptSASLAuth(e){e=this.sortMechanismsByPriority(e||[]);let t=!1;for(let n=0;n{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)),me.NS.STREAM,"features",null,null)),this._sendRestart(),!1}_onStreamFeaturesAfterSASL(e){this.features=e;for(let t=0;t0&&(t=me.ErrorCondition.CONFLICT),this._changeConnectStatus(me.Status.AUTHFAIL,t,e),!1}const t=e.getElementsByTagName("bind");if(!(t.length>0))return me.warn("Resource binding failed."),this._changeConnectStatus(me.Status.AUTHFAIL,null,e),!1;{const e=t[0].getElementsByTagName("jid");e.length>0&&(this.authenticated=!0,this.jid=me.getText(e[0]),this.do_session?this._establishSession():this._changeConnectStatus(me.Status.CONNECTED,null))}}_establishSession(){if(!this.do_session)throw new Error(`Strophe.Connection.prototype._establishSession called but apparently ${me.NS.SESSION} wasn't advertised by the server`);this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(ue({type:"set",id:"_session_auth_2"}).c("session",{xmlns:me.NS.SESSION}).tree())}_onSessionResultIQ(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(me.Status.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,me.warn("Session creation failed."),this._changeConnectStatus(me.Status.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(me.Status.AUTHFAIL,null,e),!1}_auth2_cb(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(me.Status.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(me.Status.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}_addSysTimedHandler(e,t){const n=new me.TimedHandler(e,t);return n.user=!1,this.addTimeds.push(n),n}_addSysHandler(e,t,n,s,i){const o=new me.Handler(e,t,n,s,i);return o.user=!1,this.addHandlers.push(o),o}_onDisconnectTimeout(){return me.debug("_onDisconnectTimeout was called"),this._changeConnectStatus(me.Status.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;nthis._onIdle()),100))}},me.SASLMechanism=Q,me.SASLAnonymous=class extends Q{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ANONYMOUS",arguments.length>1&&void 0!==arguments[1]&&arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:20)}test(e){return null===e.authcid}},me.SASLPlain=class extends Q{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"PLAIN",!(arguments.length>1&&void 0!==arguments[1])||arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:50)}test(e){return null!==e.authcid}onChallenge(e){const{authcid:t,authzid:n,domain:s,pass:i}=e;if(!s)throw new Error("SASLPlain onChallenge: domain is not defined!");let o=n!==`${t}@${s}`?n:"";return o+="\0",o+=t,o+="\0",o+=i,Z(o)}},me.SASLSHA1=class extends Q{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SCRAM-SHA-1",!(arguments.length>1&&void 0!==arguments[1])||arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:60)}test(e){return null!==e.authcid}onChallenge(e,t){let n,s,i,o,r,a,c,l,d="c=biws,",u=`${e._sasl_data["client-first-message-bare"]},${t},`;const h=e._sasl_data.cnonce,m=/([a-z]+)=([^,]+)(,|$)/;for(;t.match(m);){const e=t.match(m);switch(t=t.replace(e[0],""),e[1]){case"r":n=e[2];break;case"s":s=e[2];break;case"i":i=e[2]}}if(n.slice(0,h.length)!==h)return e._sasl_data={},e._sasl_failure_cb();d+="r="+n,u+=d,s=atob(s),s+="\0\0\0";const g=Z(e.pass);for(o=a=ae.core_hmac_sha1(g,s),c=1;c0&&void 0!==arguments[0]?arguments[0]:"OAUTHBEARER",!(arguments.length>1&&void 0!==arguments[1])||arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:40)}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+="",Z(t)}},me.SASLExternal=class extends Q{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"EXTERNAL",!(arguments.length>1&&void 0!==arguments[1])||arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:10)}onChallenge(e){return e.authcid===e.authzid?"":e.authzid}},me.SASLXOAuth2=class extends Q{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"X-OAUTH2",!(arguments.length>1&&void 0!==arguments[1])||arguments[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:30)}test(e){return null!==e.pass}onChallenge(e){let t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,Z(t)}};const ge={Strophe:me,$build:le,$iq:ue,$msg:de,$pres:he,SHA1:ae,MD5:J,b64_hmac_sha1:ae.b64_hmac_sha1,b64_sha1:ae.b64_sha1,str_hmac_sha1:ae.str_hmac_sha1,str_sha1:ae.str_sha1};me.Request=class{constructor(e,t,n,s){this.id=++me._requestId,this.xmlData=e,this.data=me.serialize(e),this.origFunc=t,this.func=t,this.rid=n,this.date=NaN,this.sends=s||0,this.abort=!1,this.dead=null,this.age=function(){if(!this.date)return 0;return(new Date-this.date)/1e3},this.timeDead=function(){if(!this.dead)return 0;return(new Date-this.dead)/1e3},this.xhr=this._newXHR()}getResponse(){let e=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){if(e=this.xhr.responseXML.documentElement,"parsererror"===e.tagName)throw me.error("invalid response received"),me.error("responseText: "+this.xhr.responseText),me.error("responseXML: "+me.serialize(this.xhr.responseXML)),new Error("parsererror")}else if(this.xhr.responseText){if(me.debug("Got responseText but no responseXML; attempting to parse it with DOMParser..."),e=(new P).parseFromString(this.xhr.responseText,"application/xml").documentElement,!e)throw new Error("Parsing produced null node");if(e.querySelector("parsererror")){me.error("invalid response received: "+e.querySelector("parsererror").textContent),me.error("responseText: "+this.xhr.responseText);const t=new Error;throw t.name=me.ErrorCondition.BAD_FORMAT,t}}return e}_newXHR(){let e=null;return window.XMLHttpRequest?(e=new XMLHttpRequest,e.overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8")):window.ActiveXObject&&(e=new ActiveXObject("Microsoft.XMLHTTP")),e.onreadystatechange=this.func.bind(null,this),e}},me.Bosh=class e{constructor(e){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.lastResponseHeaders=null,this._requests=[]}_buildBody(){const e=le("body",{rid:this.rid++,xmlns:me.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()&&window.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 s=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":me.NS.BOSH});n&&s.attrs({route:n});const i=this._conn._connect_cb;this._requests.push(new me.Request(s.tree(),this._onRequestStateChange.bind(this,i.bind(this._conn)),s.tree().getAttribute("rid"))),this._throttledRequestHandler()}_attach(e,t,n,s,i,o,r){this._conn.jid=e,this.sid=t,this.rid=n,this._conn.connect_callback=s,this._conn.domain=me.getDomainFromJid(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=i||this.wait,this.hold=o||this.hold,this.window=r||this.window,this._conn._changeConnectStatus(me.Status.ATTACHED,null)}_restore(e,t,n,s,i){const o=JSON.parse(window.sessionStorage.getItem("strophe-bosh-session"));if(!(null!=o&&o.rid&&o.sid&&o.jid&&(null==e||me.getBareJidFromJid(o.jid)===me.getBareJidFromJid(e)||null===me.getNodeFromJid(e)&&me.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,s,i)}_cacheSession(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&window.sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):window.sessionStorage.removeItem("strophe-bosh-session")}_connect_cb(e){const t=e.getAttribute("type");if(null!==t&&"terminate"===t){let t=e.getAttribute("condition");me.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(me.Status.CONNFAIL,t)):this._conn._changeConnectStatus(me.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(t),me.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));const n=e.getAttribute("requests");n&&(this.window=parseInt(n,10));const s=e.getAttribute("hold");s&&(this.hold=parseInt(s,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()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_emptyQueue(){return 0===this._requests.length}_callProtocolErrorHandlers(t){const n=e._getRequestStatus(t),s=this._conn.protocolErrorHandlers.HTTP[n];s&&s.call(this,n)}_hitError(e){this.errors++,me.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()}_no_auth_received(e){me.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 me.Request(t.tree(),this._onRequestStateChange.bind(this,e),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&&(me.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;n0){const e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(me.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(me.TIMEOUT*this.wait)&&(me.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(me.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){me.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n}_onRequestStateChange(t,n){if(me.debug("request id "+n.id+"."+n.sends+" state changed to "+n.xhr.readyState),n.abort)return void(n.abort=!1);if(4!==n.xhr.readyState)return;const s=e._getRequestStatus(n);if(this.lastResponseHeaders=n.xhr.getAllResponseHeaders(),this._conn.disconnecting&&s>=400)return this._hitError(s),void this._callProtocolErrorHandlers(n);const i=this._requests[0]===n,o=this._requests[1]===n,r=s>0&&s<500,a=n.sends>this._conn.maxRetries;(r||a)&&(this._removeRequest(n),me.debug("request id "+n.id+" should now be removed")),200===s?((o||i&&this._requests.length>0&&this._requests[0].age()>Math.floor(me.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(n.rid)+1),me.debug("request id "+n.id+"."+n.sends+" got 200"),t(n),this.errors=0):0===s||s>=400&&s<600||s>=12e3?(me.error("request id "+n.id+"."+n.sends+" error "+s+" happened"),this._hitError(s),this._callProtocolErrorHandlers(n),s>=400&&s<500&&(this._conn._changeConnectStatus(me.Status.DISCONNECTING,null),this._conn._doDisconnect())):me.error("request id "+n.id+"."+n.sends+" error "+s+" happened"),r||a?a&&!this._conn.connected&&this._conn._changeConnectStatus(me.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}_processRequest(t){let n=this._requests[t];const s=e._getRequestStatus(n,-1);if(n.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();const i=n.age(),o=!isNaN(i)&&i>Math.floor(me.TIMEOUT*this.wait),r=null!==n.dead&&n.timeDead()>Math.floor(me.SECONDARY_TIMEOUT*this.wait),a=4===n.xhr.readyState&&(s<1||s>=500);if((o||r||a)&&(r&&me.error(`Request ${this._requests[t].id} timed out (secondary), restarting`),n.abort=!0,n.xhr.abort(),n.xhr.onreadystatechange=function(){},this._requests[t]=new me.Request(n.xmlData,n.origFunc,n.rid,n.sends),n=this._requests[t]),0===n.xhr.readyState){me.debug("request id "+n.id+"."+n.sends+" posting");try{const e=this._conn.options.contentType||"text/xml; charset=utf-8";n.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==n.xhr.setRequestHeader&&n.xhr.setRequestHeader("Content-Type",e),this._conn.options.withCredentials&&(n.xhr.withCredentials=!0)}catch(e){return me.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(me.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}const e=()=>{if(n.date=new Date,this._conn.options.customHeaders){const e=this._conn.options.customHeaders;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.xhr.setRequestHeader(t,e[t])}n.xhr.send(n.data)};if(n.sends>1){const t=1e3*Math.min(Math.floor(me.TIMEOUT*this.wait),Math.pow(n.sends,3));setTimeout((function(){e()}),t)}else e();n.sends++,this._conn.xmlOutput!==me.Connection.prototype.xmlOutput&&(n.xmlData.nodeName===this.strip&&n.xmlData.childNodes.length?this._conn.xmlOutput(n.xmlData.childNodes[0]):this._conn.xmlOutput(n.xmlData)),this._conn.rawOutput!==me.Connection.prototype.rawOutput&&this._conn.rawOutput(n.data)}else me.debug("_processRequest: "+(0===t?"first":"second")+" request has readyState of "+n.xhr.readyState)}_removeRequest(e){me.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){me.debug("_sendTerminate was called");const t=this._buildBody().attrs({type:"terminate"});e&&t.cnode(e.tree());const n=new me.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),t.tree().getAttribute("rid"));this._requests.push(n),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?me.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):me.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._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,me.Status.CONNFAIL))return me.Status.CONNFAIL}_handleStreamStart(e){let t=!1;const n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in ":n!==me.NS.FRAMING&&(t="Wrong xmlns in : "+n);const s=e.getAttribute("version");return"string"!=typeof s?t="Missing version in ":"1.0"!==s&&(t="Wrong version in : "+s),!t||(this._conn._changeConnectStatus(me.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)}_onInitialMessage(e){if(0===e.data.indexOf("\s*)*/,"");if(""===t)return;const n=(new P).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("=0&&n.indexOf("wss:")>=0||e.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus(me.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=n,this._connect())}else this._conn._changeConnectStatus(me.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{this._replaceMessageHandler();const t=this._streamWrap(e.data),n=(new P).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!==L.CLOSED){e&&this._conn.send(e);const t=le("close",{xmlns:me.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=me.serialize(t);this._conn.rawOutput(n);try{this.socket.send(n)}catch(e){me.warn("Couldn't send tag.")}}setTimeout((()=>this._conn._doDisconnect),0)}_doDisconnect(){me.debug("WebSockets _doDisconnect was called"),this._closeSocket()}_streamWrap(e){return""+e+""}_closeSocket(){if(this.socket)try{this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close()}catch(e){me.debug(e.message)}this.socket=null}_emptyQueue(){return!0}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(me.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(me.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(me.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):me.debug("Websocket closed")}_no_auth_received(e){me.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus(me.Status.CONNFAIL,me.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()}_onDisconnectTimeout(){}_abortAllRequests(){}_onError(e){me.error("Websocket error "+JSON.stringify(e)),this._conn._changeConnectStatus(me.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{var t;null===(t=console)||void 0===t||t.error(e),me.log(me.LogLevel.ERROR,`Shared Worker Error: ${e}`)}}get socket(){return{send:e=>this.worker.port.postMessage(["send",e])}}_connect(){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._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===me.Status.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus(me.Status.ATTACHED)):e===me.Status.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus(me.Status.ATTACHFAIL))}_disconnect(e,t){t&&this._conn.send(t);const n=le("close",{xmlns:me.NS.FRAMING});this._conn.xmlOutput(n.tree());const s=me.serialize(n);this._conn.rawOutput(s),this.worker.port.postMessage(["send",s]),this._conn._doDisconnect()}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(me.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected?(me.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(me.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):me.debug("Websocket closed")}_closeSocket(){this.worker.port.postMessage(["_closeSocket"])}_replaceMessageHandler(){this._messageHandler=e=>this._onMessage(e)}_onWorkerMessage(e){const{data:t}=e,n=t[0];if("_onMessage"===n)this._messageHandler(t[1]);else if(n in this)try{this[n].apply(this,e.data.slice(1))}catch(e){me.log(me.LogLevel.ERROR,e)}else if("log"===n){const e=t[1],n=t[2];me.log(fe[e],n)}else me.log(me.LogLevel.ERROR,`Found unhandled service worker message: ${t}`)}},n.g.$build=ge.$build,n.g.$iq=ge.$iq,n.g.$msg=ge.$msg,n.g.$pres=ge.$pres,n.g.Strophe=ge.Strophe;const{b64_sha1:pe}=ae,ve={};ve[me.Status.ATTACHED]="ATTACHED",ve[me.Status.AUTHENTICATING]="AUTHENTICATING",ve[me.Status.AUTHFAIL]="AUTHFAIL",ve[me.Status.CONNECTED]="CONNECTED",ve[me.Status.CONNECTING]="CONNECTING",ve[me.Status.CONNFAIL]="CONNFAIL",ve[me.Status.DISCONNECTED]="DISCONNECTED",ve[me.Status.DISCONNECTING]="DISCONNECTING",ve[me.Status.ERROR]="ERROR",ve[me.Status.RECONNECTING]="RECONNECTING",ve[me.Status.REDIRECT]="REDIRECT";const _e=["converse-adhoc","converse-bookmarks","converse-bosh","converse-caps","converse-carbons","converse-chat","converse-chatboxes","converse-disco","converse-emoji","converse-headlines","converse-mam","converse-muc","converse-ping","converse-pubsub","converse-roster","converse-smacks","converse-status","converse-vcard"],ye={start:/(\b|_)(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi},be={TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESCAPE:27,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,FORWARD_SLASH:47,AT:50,META:91,META_RIGHT:93};const we=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const Se=function(e){if(!we(e))return!1;var t=b(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const xe=d["__core-js_shared__"];var Ee,Ae=(Ee=/[^.]+$/.exec(xe&&xe.keys&&xe.keys.IE_PROTO||""))?"Symbol(src)_1."+Ee:"";const Ce=function(e){return!!Ae&&Ae in e};var ke=Function.prototype.toString;const je=function(e){if(null!=e){try{return ke.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var Te=/^\[object .+?Constructor\]$/,$e=Function.prototype,Ne=Object.prototype,Oe=$e.toString,Ie=Ne.hasOwnProperty,Me=RegExp("^"+Oe.call(Ie).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Re=function(e){return!(!we(e)||Ce(e))&&(Se(e)?Me:Te).test(je(e))};const De=function(e,t){return null==e?void 0:e[t]};const ze=function(e,t){var n=De(e,t);return Re(n)?n:void 0};const Le=function(){try{var e=ze(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const Pe=function(e,t,n){"__proto__"==t&&Le?Le(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n};const Fe=function(e,t){return e===t||e!=e&&t!=t};var Ue=Object.prototype.hasOwnProperty;const Be=function(e,t,n){var s=e[t];Ue.call(e,t)&&Fe(s,n)&&(void 0!==n||t in e)||Pe(e,t,n)};const qe=function(e,t,n,s){var i=!n;n||(n={});for(var o=-1,r=t.length;++o0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Qe);const Ye=function(e,t){return Ke(Ve(e,t,He),e+"")};const Xe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};const et=function(e){return null!=e&&Xe(e.length)&&!Se(e)};var tt=/^(?:0|[1-9]\d*)$/;const nt=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&tt.test(e))&&e>-1&&e%1==0&&e1?n[i-1]:void 0,r=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,r&&st(n[0],n[1],r)&&(o=i<3?void 0:o,i=1),t=Object(t);++s-1};const Bt=function(e,t){var n=this.__data__,s=zt(n,e);return s<0?(++this.size,n.push([e,t])):n[s][1]=t,this};function qt(e){var t=-1,n=null==e?0:e.length;for(this.clear();++ta))return!1;var l=o.get(e),d=o.get(t);if(l&&d)return l==t&&d==e;var u=-1,h=!0,m=2&n?new Sn:void 0;for(o.set(e,t),o.set(t,e);++u0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}};const gi=function(e){return mi(2,e)};var fi=0;const pi=function(e){var t=++fi;return Is(e)+t},vi={},_i=/\s+/;let yi;const bi=function(e,t,n,s,i){let o,r=0;if(n&&"object"==typeof n){void 0!==s&&"context"in i&&void 0===i.context&&(i.context=s);for(o=Un(n);r{e.resolve=t,e.reject=n}));return Object.assign(t,e),t.then((function(e){return t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e}),(function(e){throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e})),t}function Pi(){throw new Error('A "url" property or function must be specified')}function Fi(e,t){const n=t.error;t.error=function(s){n&&n.call(t.context,e,s,t),e.trigger("error",e,s,t)}}const Ui={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"};function Bi(e){const t=Di(e,"browserStorage")||Di(e.collection,"browserStorage");return t?t.sync():qi}function qi(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=Ui[e],i={type:s,dataType:"json"};n.url||(i.url=Di(t,"url")||Pi()),null!=n.data||!t||"create"!==e&&"update"!==e&&"patch"!==e||(i.contentType="application/json",i.data=JSON.stringify(n.attrs||t.toJSON(n))),"GET"!==i.type&&(i.processData=!1);const o=n.error;n.error=function(e,t,s){n.textStatus=t,n.errorThrown=s,o&&o.call(n.context,e,t,s)};const r=n.xhr=Hi(Mt(i,n));return t.trigger("request",t,r,n),r}function Hi(){return fetch.apply(this,arguments)}const Gi=function(){this.handlers=[],this.checkUrl=this.checkUrl.bind(this),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)};Gi.extend=zi;const Wi=/^[#\/]|\s+$/g,Vi=/^\/+|\/+$/g,Ji=/#.*$/;Gi.started=!1,Object.assign(Gi.prototype,vi,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root&&!this.getSearch()},matchRoot:function(){return this.decodeFragment(this.location.pathname).slice(0,this.root.length-1)+"/"===this.root},decodeFragment:function(e){return decodeURI(e.replace(/%25/g,"%2525"))},getSearch:function(){const e=this.location.href.replace(/#.*/,"").match(/\?.+/);return e?e[0]:""},getHash:function(e){const t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getPath:function(){const e=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return"/"===e.charAt(0)?e.slice(1):e},getFragment:function(e){return null==e&&(e=this._usePushState||!this._wantsHashChange?this.getPath():this.getHash()),e.replace(Wi,"")},start:function(e){if(Gi.started)throw new Error("history has already been started");if(Gi.started=!0,this.options=Mt({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._hasHashChange="onhashchange"in window&&(void 0===document.documentMode||document.documentMode>7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(Vi,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){const e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;const e=document.body,t=e.insertBefore(this.iframe,e.firstChild).contentWindow;t.document.open(),t.document.close(),t.location.hash="#"+this.fragment}if(this._usePushState?addEventListener("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?addEventListener("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){this._usePushState?removeEventListener("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&removeEventListener("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),Gi.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(e){let t=this.getFragment();if(t===this.fragment&&this.iframe&&(t=this.getHash(this.iframe.contentWindow)),t===this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()},loadUrl:function(e){return!!this.matchRoot()&&(e=this.fragment=this.getFragment(e),Ys(this.handlers,(function(t){if(t.route.test(e))return t.callback(e),!0})))},navigate:function(e,t){if(!Gi.started)return!1;t&&!0!==t||(t={trigger:!!t}),e=this.getFragment(e||"");let n=this.root;""!==e&&"?"!==e.charAt(0)||(n=n.slice(0,-1)||"/");const s=n+e;e=e.replace(Ji,"");const i=this.decodeFragment(e);if(this.fragment!==i){if(this.fragment=i,this._usePushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,s);else{if(!this._wantsHashChange)return this.location.assign(s);if(this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getHash(this.iframe.contentWindow)){const n=this.iframe.contentWindow;t.replace||(n.document.open(),n.document.close()),this._updateHash(n.location,e,t.replace)}}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,n){if(n){const n=e.href.replace(/(javascript:|#).*$/,"");e.replace(n+"#"+t)}else e.hash="#"+t}});const Qi=Gi;const Zi=function(e){return a(e)&&"[object RegExp]"==b(e)};var Ki=xt&&xt.isRegExp;const Yi=Ki?yt(Ki):Zi,Xi=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.history=e.history||new Qi,this.preinitialize.apply(this,arguments),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};Xi.extend=zi;const eo=/\((.*?)\)/g,to=/(\(\?)?:\w+/g,no=/\*\w+/g,so=/[\-{}\[\]+?.,\\\^$|#\s]/g;Object.assign(Xi.prototype,vi,{preinitialize:function(){},initialize:function(){},route:function(e,t,n){return Yi(e)||(e=this._routeToRegExp(e)),Se(t)&&(n=t,t=""),n||(n=this[t]),this.history.route(e,(s=>{const i=this._extractParameters(e,s);!1!==this.execute(n,i,t)&&(this.trigger.apply(this,["route:"+t].concat(i)),this.trigger("route",t,i),this.history.trigger("route",this,t,i))})),this},execute:function(e,t,n){e&&e.apply(this,t)},navigate:function(e,t){return this.history.navigate(e,t),this},_bindRoutes:function(){if(!this.routes)return;let e;this.routes=Di(this,"routes");const t=Un(this.routes);for(;null!=(e=t.pop());)this.route(e,this.routes[e])},_routeToRegExp:function(e){return e=e.replace(so,"\\$&").replace(eo,"(?:$1)?").replace(to,(function(e,t){return t?e:"([^/?]+)"})).replace(no,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){const n=e.exec(t).slice(1);return n.map((function(e,t){return t===n.length-1?e||null:e?decodeURIComponent(e):null}))}});class io extends Error{}var oo=n(3245);const ro=function(e,t){for(var n=-1,s=null==e?0:e.length;++n=43)}})).catch((function(){return!1}))}(e).then((function(e){return er=e,er}))}function rr(e){var t=tr[e.name],n={};n.promise=new Jo((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function ar(e){var t=tr[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function cr(e,t){var n=tr[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function lr(e,t){return new Jo((function(n,s){if(tr[e.name]=tr[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);rr(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var o=Go.open.apply(Go,i);t&&(o.onupgradeneeded=function(t){var n=o.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(Xo)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),s(o.error)},o.onsuccess=function(){var t=o.result;t.onversionchange=function(e){e.target.close()},n(t),ar(e)}}))}function dr(e){return lr(e,!1)}function ur(e){return lr(e,!0)}function hr(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),s=e.versione.db.version;if(s&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||n){if(n){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function mr(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),s=new Uint8Array(n),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return Jo.resolve().then((()=>{if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ur(e)})).then((()=>function(e){rr(e);for(var t=tr[e.name],n=t.forages,s=0;s(e.db=t,hr(e)?ur(e):t))).then((s=>{e.db=t.db=s;for(var i=0;i{throw cr(e,t),t}))}(e).then((function(){pr(e,t,n,s-1)})))).catch(n);n(i)}}var vr={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var s in e)n[s]=e[s];var i=tr[n.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},tr[n.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=fr);var o=[];function r(){return Jo.resolve()}for(var a=0;a{const n=tr[e.name],s=n.forages;n.db=t;for(var i=0;i{if(!t.objectStoreNames.contains(e.storeName))return;const n=t.version+1;rr(e);const s=tr[e.name],i=s.forages;t.close();for(let e=0;e{const i=Go.open(e.name,n);i.onerror=e=>{i.result.close(),s(e)},i.onupgradeneeded=()=>{i.result.deleteObjectStore(e.storeName)},i.onsuccess=()=>{const e=i.result;e.close(),t(e)}}));return o.then((e=>{s.db=e;for(let t=0;t{throw(cr(e,t)||Jo.resolve()).catch((()=>{})),t}))})):t.then((t=>{rr(e);const n=tr[e.name],s=n.forages;t.close();for(var i=0;i{var s=Go.deleteDatabase(e.name);s.onerror=()=>{const e=s.result;e&&e.close(),n(s.error)},s.onblocked=()=>{console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},s.onsuccess=()=>{const e=s.result;e&&e.close(),t(e)}}));return o.then((e=>{n.db=e;for(var t=0;t{throw(cr(e,t)||Jo.resolve()).catch((()=>{})),t}))}))}else s=Jo.reject("Invalid arguments");return Qo(s,t),s}};const _r=vr;const yr=function(){return"function"==typeof openDatabase};var br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wr=/^~~local_forage_type~([^~]+)~/,Sr="__lfsc__:",xr=Sr.length,Er="arbf",Ar="blob",Cr="si08",kr="ui08",jr="uic8",Tr="si16",$r="si32",Nr="ur16",Or="ui32",Ir="fl32",Mr="fl64",Rr=xr+Er.length,Dr=Object.prototype.toString;function zr(e){var t,n,s,i,o,r=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(r--,"="===e[e.length-2]&&r--);var l=new ArrayBuffer(r),d=new Uint8Array(l);for(t=0;t>4,d[c++]=(15&s)<<4|i>>2,d[c++]=(3&i)<<6|63&o;return l}function Lr(e){var t,n=new Uint8Array(e),s="";for(t=0;t>2],s+=br[(3&n[t])<<4|n[t+1]>>4],s+=br[(15&n[t+1])<<2|n[t+2]>>6],s+=br[63&n[t+2]];return n.length%3==2?s=s.substring(0,s.length-1)+"=":n.length%3==1&&(s=s.substring(0,s.length-2)+"=="),s}var Pr={serialize:function(e,t){var n="";if(e&&(n=Dr.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Dr.call(e.buffer))){var s,i=Sr;e instanceof ArrayBuffer?(s=e,i+=Er):(s=e.buffer,"[object Int8Array]"===n?i+=Cr:"[object Uint8Array]"===n?i+=kr:"[object Uint8ClampedArray]"===n?i+=jr:"[object Int16Array]"===n?i+=Tr:"[object Uint16Array]"===n?i+=Nr:"[object Int32Array]"===n?i+=$r:"[object Uint32Array]"===n?i+=Or:"[object Float32Array]"===n?i+=Ir:"[object Float64Array]"===n?i+=Mr:t(new Error("Failed to get type for BinaryArray"))),t(i+Lr(s))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var n="~~local_forage_type~"+e.type+"~"+Lr(this.result);t("__lfsc__:blob"+n)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,xr)!==Sr)return JSON.parse(e);var t,n=e.substring(Rr),s=e.substring(xr,Rr);if(s===Ar&&wr.test(n)){var i=n.match(wr);t=i[1],n=n.substring(i[0].length)}var o=zr(n);switch(s){case Er:return o;case Ar:return Vo([o],{type:t});case Cr:return new Int8Array(o);case kr:return new Uint8Array(o);case jr:return new Uint8ClampedArray(o);case Tr:return new Int16Array(o);case Nr:return new Uint16Array(o);case $r:return new Int32Array(o);case Or:return new Uint32Array(o);case Ir:return new Float32Array(o);case Mr:return new Float64Array(o);default:throw new Error("Unkown type: "+s)}},stringToBuffer:zr,bufferToString:Lr};const Fr=Pr;function Ur(e,t,n,s){e.executeSql(`CREATE TABLE IF NOT EXISTS ${t.storeName} (id INTEGER PRIMARY KEY, key unique, value)`,[],n,s)}function Br(e,t,n,s,i,o){e.executeSql(n,s,i,(function(e,r){r.code===r.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?o(e,r):Ur(e,t,(function(){e.executeSql(n,s,i,o)}),o)}),o):o(e,r)}),o)}function qr(e,t,n,s){var i=this;e=Ko(e);var o=new Jo((function(o,r){i.ready().then((function(){void 0===t&&(t=null);var a=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,l){l?r(l):c.db.transaction((function(n){Br(n,c,`INSERT OR REPLACE INTO ${c.storeName} (key, value) VALUES (?, ?)`,[e,t],(function(){o(a)}),(function(e,t){r(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(s>0)return void o(qr.apply(i,[e,a,n,s-1]));r(t)}}))}))})).catch(r)}));return Qo(o,n),o}function Hr(e){return new Jo((function(t,n){e.transaction((function(s){s.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,s){for(var i=[],o=0;o0}var Qr={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=Vr(e,this._defaultConfig),Jr()?(this._dbInfo=t,t.serializer=Fr,Jo.resolve()):Jo.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,s=n.ready().then((function(){for(var t=n._dbInfo,s=t.keyPrefix,i=s.length,o=localStorage.length,r=1,a=0;a=0;n--){var s=localStorage.key(n);0===s.indexOf(e)&&localStorage.removeItem(s)}}));return Qo(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return Qo(t,e),t},key:function(e,t){var n=this,s=n.ready().then((function(){var t,s=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(s.keyPrefix.length)),t}));return Qo(s,t),s},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,s=[],i=0;i=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):Jo.reject("Invalid arguments"),Qo(s,t),s}};const Zr=Qr,Kr=(e,t)=>e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t),Yr=(e,t)=>{const n=e.length;let s=0;for(;s{}))}config(e){if("object"==typeof e){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(let t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config}defineDriver(e,t,n){const s=new Jo((function(t,n){try{const s=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(i);const o=oa.concat("_initStorage");for(let t=0,s=o.length;t(null===t._ready&&(t._ready=t._initDriver()),t._ready)));return Zo(n,e,e),n}setDriver(e,t,n){const s=this;Xr(e)||(e=[e]);const i=this._getSupportedDrivers(e);function o(){s._config.driver=s.driver()}function r(e){return s._extend(e),o(),s._ready=s._initStorage(s._config),s._ready}const a=null!==this._driverSet?this._driverSet.catch((()=>Jo.resolve())):Jo.resolve();return this._driverSet=a.then((()=>{const e=i[0];return s._dbInfo=null,s._ready=null,s.getDriver(e).then((e=>{s._driver=e._driver,o(),s._wrapLibraryMethodsWithReady(),s._initDriver=function(e){return function(){let t=0;return function n(){for(;t{o();const e=new Error("No available storage method found.");return s._driverSet=Jo.reject(e),s._driverSet})),Zo(this._driverSet,t,n),this._driverSet}supports(e){return!!ta[e]}_extend(e){ca(this,e)}_getSupportedDrivers(e){const t=[];for(let n=0,s=e.length;n{e.resolve=t,e.reject=n}));return Object.assign(t,e),t.then((function(e){return t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e}),(function(e){throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e})),t}const wa="Expected a function",Sa=Math.max,xa=Math.min;const Ea=function(e,t){let n,s,i,o,r,a,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=0,d=!1,u=c.promise?ba():null;if("function"!=typeof e)throw new TypeError(wa);function h(t){const i=n,r=s,a=u;return n=s=void 0,l=t,o=e.apply(r,i),c.promise&&(a.resolve(o),u=ba()),c.promise?a:o}function m(e){return l=e,r=setTimeout(p,t),c.promise?u:o}function g(e){const n=t-(e-a);return d?xa(n,i-(e-l)):n}function f(e){const n=e-a;return void 0===a||n>=t||n<0||d&&e-l>=i}function p(){const e=ya();if(f(e))return v(e);r=setTimeout(p,g(e))}function v(e){return r=void 0,n?h(e):(n=s=void 0,c.promise?u:o)}function _(){void 0!==r&&clearTimeout(r),l=0,n=a=s=r=void 0}function y(){return void 0===r?o:v(ya())}function b(e,t){if(Array.isArray(e)&&Array.isArray(t))return null!=c&&c.dedupeArrays?e.concat(t.filter((t=>-1===e.indexOf(t)))):e.concat(t)}function w(e){var t;return null!==(t=n)&&void 0!==t&&t.length?e.length?null!=c&&c.concatArrays||null!=c&&c.dedupeArrays?_a(n,e,b):va(n,e):n:e||[]}function S(){const e=ya(),i=f(e);if(n=w(Array.from(arguments)),s=this,a=e,i){if(void 0===r)return m(a);if(d)return clearTimeout(r),r=setTimeout(p,t),h(a)}return void 0===r&&(r=setTimeout(p,t)),c.promise?u:o}return t=li(t)||0,we(c)&&(d="maxWait"in c,i=d?Sa(li(c.maxWait)||0,t):i),S.cancel=_,S.flush=y,S};function Aa(e,t){let n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}const Ca={serializer:{serialize:Fr.serialize,deserialize:Fr.deserialize}};const ka={_driver:"sessionStorageWrapper",_initStorage:function(e){if(Ca.keyPrefix=Aa(e,this._defaultConfig),e)for(const t in e)Ca[t]=e[t]},_support:function(){try{if(sessionStorage&&"setItem"in sessionStorage)return!0}catch(e){console.log(e)}return!1}(),iterate:function(e,t){const n=this.ready().then((function(){const t=Ca.keyPrefix,n=t.length,s=sessionStorage.length;let i=1;for(let o=0;o=0;t--){const n=sessionStorage.key(t);0===n.indexOf(e)&&sessionStorage.removeItem(n)}}));return Qo(t,e),t},length:function(e){const t=this.keys().then((function(e){return e.length}));return Qo(t,e),t},key:function(e,t){const n=this.ready().then((function(){let t;try{t=sessionStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(Ca.keyPrefix.length)),t}));return Qo(n,t),n},keys:function(e){const t=this.ready().then((function(){const e=sessionStorage.length,t=[];for(let n=0;n=0;t--){const n=sessionStorage.key(t);0===n.indexOf(e)&&sessionStorage.removeItem(n)}})):Promise.reject(new Error("Invalid arguments")),Qo(s,t),s}},ja=ka;var Ta=n(1459),$a=n(642);const Na=oo._driver;function Oa(){return(65536*(1+Math.random())|0).toString(16).substring(1)}da.defineDriver(oo),(0,Ta.extendPrototype)(da),(0,$a.extendPrototype)(da);class Ia{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("local"===t&&!window.localStorage)throw new Error("Skeletor.storage: Environment does not support localStorage.");if("session"===t&&!window.sessionStorage)throw new Error("Skeletor.storage: Environment does not support sessionStorage.");Ho(t)?this.storeInitialized=this.initStore(t,n):(this.store=t,n&&(this.store.debouncedSetItems=Ea((e=>this.store.setItems(e)),50,{promise:!0})),this.storeInitialized=Promise.resolve()),this.name=e}async initStore(e,t){if("session"===e)da.setDriver(ja._driver);else if("local"===e)await da.config({driver:da.LOCALSTORAGE});else if("in_memory"===e)da.config({driver:Na});else if("indexed"!==e)throw new Error("Skeletor.storage: No storage type was specified");this.store=da,t&&(this.store.debouncedSetItems=Ea((e=>this.store.setItems(e)),50,{promise:!0}))}flush(){var e;return null===(e=this.store.debouncedSetItems)||void 0===e?void 0:e.flush()}async clear(){await this.store.removeItem(this.name).catch((e=>console.error(e)));const e=new RegExp(`^${this.name}-`),t=(await this.store.keys()).filter((t=>e.test(t)));await Promise.all(t.map((e=>this.store.removeItem(e).catch((e=>console.error(e))))))}sync(){const e=this;async function t(t,n,s){let i,o,r,a;const c=n.collection;["patch","update"].includes(t)&&(a=qo(n.attributes)),await e.storeInitialized;try{const o=n.attributes;switch(t){case"read":i=void 0!==n.id?await e.find(n):await e.findAll();break;case"create":i=await e.create(n,s);break;case"patch":case"update":s.wait&&(n.attributes=a),r=e.update(n,s),s.wait&&(n.attributes=o),i=await r;break;case"delete":i=await e.destroy(n,c)}}catch(t){o=22===t.code&&0===e.getStorageSize()?"Private browsing is unsupported":t.message}if(i){if(s&&s.success){const e="read"===t?i:null;s.success(e,s)}}else o=o||"Record Not Found",s&&s.error&&s.error(o)}return t.__name__="localSync",t}removeCollectionReference(e,t){if(!t)return;const n=t.filter((t=>t.id!==e.id)).map((e=>this.getItemName(e.id)));return this.store.setItem(this.name,n)}addCollectionReference(e,t){if(!t)return;const n=t.map((e=>this.getItemName(e.id))),s=this.getItemName(e.id);return n.includes(s)||n.push(s),this.store.setItem(this.name,n)}getCollectionReferenceData(e){if(!e.collection)return{};const t=e.collection.map((e=>this.getItemName(e.id))),n=this.getItemName(e.id);t.includes(n)||t.push(n);const s={};return s[this.name]=t,s}async save(e){if(this.store.setItems){const t={};return t[this.getItemName(e.id)]=e.toJSON(),Object.assign(t,this.getCollectionReferenceData(e)),this.store.debouncedSetItems?this.store.debouncedSetItems(t):this.store.setItems(t)}{const t=this.getItemName(e.id),n=await this.store.setItem(t,e.toJSON());return await this.addCollectionReference(e,e.collection),n}}create(e,t){return e.id||(e.id=Oa()+Oa()+"-"+Oa()+"-"+Oa()+"-"+Oa()+"-"+Oa()+Oa()+Oa(),e.set(e.idAttribute,e.id,t)),this.save(e)}update(e){return this.save(e)}find(e){return this.store.getItem(this.getItemName(e.id))}async findAll(){const e=await this.store.getItem(this.name);if(null!=e&&e.length){const t=await this.store.getItems(e);return Object.values(t)}return[]}async destroy(e,t){return await this.flush(),await this.store.removeItem(this.getItemName(e.id)),await this.removeCollectionReference(e,t),e}getStorageSize(){return this.store.length}getItemName(e){return this.name+"-"+e}}Ia.sessionStorageInitialized=da.defineDriver(ja),Ia.localForage=da;const Ma=Ia;function Ra(){if(ul.config.get("trusted")){return"sessionStorage"===bu.settings.get("persistent_store")?"session":"persistent"}return"session"}function Da(e){return"persistent"===e&&"IndexedDB"===bu.settings.get("persistent_store")}function za(e,t){const n=t||Ra(),s=ul.storage[n];if(void 0===s)throw new TypeError(`createStore: Could not find store for ${e}`);return new Ma(e,s,Da(t))}function La(e,t,n){const s=n||Ra();if(e.browserStorage=za(t,s),Da(s)){const t=()=>e.browserStorage.flush();window.addEventListener(ul.unloadevent,t),e.on("destroy",(()=>window.removeEventListener(ul.unloadevent,t))),e.listenTo(ul,"beforeLogout",t)}}const Pa=function(e,t){return hs(e,t)};const Fa=function(e,t,n,s){if(!we(e))return e;for(var i=-1,o=(t=Ms(t,e)).length,r=o-1,a=e;null!=a&&++i0&&s(c)?n>1?e(c,n-1,s,i,o):Nn(o,c):i||(o[o.length]=c)}return o};const Wa=function(e){return(null==e?0:e.length)?Ga(e,1):[]};const Va=function(e){return Ke(Ve(e,void 0,Wa),e+"")};const Ja=Va((function(e,t){return null==e?{}:Ba(e,t)}));var Qa=n(7856),Za=n.n(Qa);const Ka=function(e){for(var t=-1,n=null==e?0:e.length,s=0,i=[];++t2?t[2]:void 0;for(i&&st(t[0],t[1],i)&&(s=1);++n":">",'"':""","'":"'"});var dc=/[&<>"']/g,uc=RegExp(dc.source);const hc=function(e){return(e=Is(e))&&uc.test(e)?e.replace(dc,lc):e};const mc=function(e,t,n,s){return Js(e,(function(e,i,o){t(s,n(e),i,o)})),s};const gc=function(e,t){return function(n,s){return mc(n,e,t(s),{})}};var fc=Object.prototype.toString,pc=gc((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=fc.call(t)),e[t]=n}),Je(He));const vc=pc;const _c=function(e){return Gs("function"==typeof e?e:Bo(e,1))};const yc=function(e,t,n){var s=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++s1),t})),qe(e,yo(e),n),s&&(n=Bo(n,7,Sc));for(var i=t.length;i--;)wc(n,t[i]);return n}));const Ec=xc,Ac=function(e,t){let n=e||{};t||(t={}),this.preinitialize.apply(this,arguments),this.cid=pi(this.cidPrefix),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(n=this.parse(n,t)||{});const s=Di(this,"defaults");n=oc(Mt({},s,n),s),this.set(n,t),this.changed={},this.initialize.apply(this,arguments)};Ac.extend=zi,Object.assign(Ac.prototype,vi,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(e){return tc(this.attributes)},sync:function(e,t,n){return Bi(this)(e,t,n)},get:function(e){return this.attributes[e]},keys:function(){return Object.keys(this.attributes)},values:function(){return Object.values(this.attributes)},pairs:function(){return this.entries()},entries:function(){return Object.entries(this.attributes)},invert:function(){return vc(this.attributes)},pick:function(){for(var e=arguments.length,t=new Array(e),n=0;n=t||n<0||u&&e-l>=o}function p(){var e=ya();if(f(e))return v(e);a=setTimeout(p,function(e){var n=t-(e-c);return u?kc(n,o-(e-l)):n}(e))}function v(e){return a=void 0,h&&s?m(e):(s=i=void 0,r)}function _(){var e=ya(),n=f(e);if(s=arguments,i=this,c=e,n){if(void 0===a)return g(c);if(u)return clearTimeout(a),a=setTimeout(p,t),m(c)}return void 0===a&&(a=setTimeout(p,t)),r}return t=li(t)||0,we(n)&&(d=!!n.leading,o=(u="maxWait"in n)?Cc(li(n.maxWait)||0,t):o,h="trailing"in n?!!n.trailing:h),_.cancel=function(){void 0!==a&&clearTimeout(a),l=0,s=c=i=a=void 0},_.flush=function(){return void 0===a?r:v(ya())},_};var Tc=n(7002),$c=n(1063);const Nc=Object.keys(me.Status).reduce(((e,t)=>Math.max(e,me.Status[t])),0);me.Status.RECONNECTING=Nc+1;class Oc extends me.Connection{constructor(e,t){super(e,t),this.debouncedReconnect=jc(this.reconnect,3e3)}static generateResource(){return`/converse.js-${Math.floor(139749528*Math.random()).toString()}`}async bind(){await bu.trigger("beforeResourceBinding",{synchronous:!0}),super.bind()}async onDomainDiscovered(e){const t=await e.text(),n=(new window.DOMParser).parseFromString(t,"text/xml").firstElementChild;if("XRD"!=n.nodeName||"http://docs.oasis-open.org/ns/xri/xrd-1.0"!=n.namespaceURI)return z.warn("Could not discover XEP-0156 connection methods");const s=ec()('Link[rel="urn:xmpp:alt-connections:xbosh"]',n),i=ec()('Link[rel="urn:xmpp:alt-connections:websocket"]',n),o=s.map((e=>e.getAttribute("href"))),r=i.map((e=>e.getAttribute("href")));0===o.length&&0===r.length?z.warn("Neither BOSH nor WebSocket connection methods have been specified with XEP-0156."):(bu.settings.set("websocket_url",r.pop()),bu.settings.set("bosh_service_url",o.pop()),this.service=bu.settings.get("websocket_url")||bu.settings.get("bosh_service_url"),this.setProtocol())}async discoverConnectionMethods(e){const t={mode:"cors",headers:{Accept:"application/xrd+xml, text/xml"}},n=`https://${e}/.well-known/host-meta`;let s;try{s=await fetch(n,t)}catch(e){return z.error(`Failed to discover alternative connection methods at ${n}`),void z.error(e)}s.status>=200&&s.status<400?await this.onDomainDiscovered(s):z.warn("Could not discover XEP-0156 connection methods")}async connect(e,t,n){if(bu.settings.get("discover_connection_methods")){const t=me.getDomainFromJid(e);await this.discoverConnectionMethods(t)}if(!bu.settings.get("bosh_service_url")&&!bu.settings.get("websocket_url"))throw new Error("You must supply a value for either the bosh_service_url or websocket_url or both.");super.connect(e,t,n||this.onConnectStatusChanged,59)}async switchTransport(){bu.connection.isType("websocket")&&bu.settings.get("bosh_service_url")?(await Rc(ul.bare_jid),this._proto._doDisconnect(),this._proto=new me.Bosh(this),this.service=bu.settings.get("bosh_service_url")):bu.connection.isType("bosh")&&bu.settings.get("websocket_url")&&(bu.settings.get("authentication")===ul.ANONYMOUS?await Rc(bu.settings.get("jid")):await Rc(ul.bare_jid),this._proto._doDisconnect(),this._proto=new me.Websocket(this),this.service=bu.settings.get("websocket_url"))}async reconnect(){z.debug("RECONNECTING: the connection has dropped, attempting to reconnect."),this.reconnecting=!0,await Gc();const e=ul.connfeedback.get("connection_status");return e===me.Status.CONNFAIL?this.switchTransport():e===me.Status.AUTHFAIL&&bu.settings.get("authentication")===ul.ANONYMOUS&&await Rc(bu.settings.get("jid")),bu.trigger("will-reconnect"),bu.settings.get("authentication")===ul.ANONYMOUS&&await wu(),bu.user.login()}async onConnected(e){delete this.reconnecting,this.flush(),await Rc(this.jid),await bu.trigger("afterResourceBinding",e,{synchronous:!0}),e?bu.trigger("reconnected"):bu.trigger("connected")}setDisconnectionCause(e,t,n){void 0===e?(delete this.disconnection_cause,delete this.disconnection_reason):(void 0===this.disconnection_cause||n)&&(this.disconnection_cause=e,this.disconnection_reason=t)}setConnectionStatus(e,t){this.status=e,ul.connfeedback.set({connection_status:e,message:t})}async finishDisconnection(){z.debug("DISCONNECTED"),delete this.reconnecting,this.reset(),Gc(),await wu(),delete ul.connection,bu.trigger("disconnected")}onDisconnected(){if(!bu.settings.get("auto_reconnect"))return this.finishDisconnection();{const e=this.disconnection_reason;if(this.disconnection_cause===me.Status.AUTHFAIL)return bu.settings.get("credentials_url")||bu.settings.get("authentication")===ul.ANONYMOUS?bu.connection.reconnect():this.finishDisconnection();if(this.status===me.Status.CONNECTING){const{__:e}=ul;return this.setConnectionStatus(me.Status.CONNFAIL,e("An error occurred while connecting to the chat server.")),this.finishDisconnection()}if(this.disconnection_cause===ul.LOGOUT||e===me.ErrorCondition.NO_AUTH_MECH||"host-unknown"===e||"remote-connection-failed"===e)return this.finishDisconnection();bu.connection.reconnect()}}onConnectStatusChanged(e,t){const{__:n}=ul;var s;if(z.debug(`Status changed to: ${ul.CONNECTION_STATUS[e]}`),e===me.Status.ATTACHFAIL)this.setConnectionStatus(e),null===(s=this.worker_attach_promise)||void 0===s||s.resolve(!1);else if(e===me.Status.CONNECTED||e===me.Status.ATTACHED){var i,o;if(null!==(i=this.worker_attach_promise)&&void 0!==i&&i.isResolved&&this.status===me.Status.ATTACHED)return;this.setConnectionStatus(e),null===(o=this.worker_attach_promise)||void 0===o||o.resolve(!0),ul.send_initial_presence=!0,this.setDisconnectionCause(),this.reconnecting?(z.debug(e===me.Status.CONNECTED?"Reconnected":"Reattached"),this.onConnected(!0)):(z.debug(e===me.Status.CONNECTED?"Connected":"Attached"),this.restored&&(ul.send_initial_presence=!1),this.onConnected())}else if(e===me.Status.DISCONNECTED)this.setDisconnectionCause(e,t),this.onDisconnected();else if(e===me.Status.BINDREQUIRED)this.bind();else if(e===me.Status.ERROR)this.setConnectionStatus(e,n("An error occurred while connecting to the chat server."));else if(e===me.Status.CONNECTING)this.setConnectionStatus(e);else if(e===me.Status.AUTHENTICATING)this.setConnectionStatus(e);else if(e===me.Status.AUTHFAIL)t||(t=n("Your XMPP address and/or password is incorrect. Please try again.")),this.setConnectionStatus(e,t),this.setDisconnectionCause(e,t,!0),this.onDisconnected();else if(e===me.Status.CONNFAIL){var r;let s=t;"host-unknown"===t||"remote-connection-failed"==t?s=n("Sorry, we could not connect to the XMPP host with domain: %1$s",`"${me.getDomainFromJid(this.jid)}"`):void 0!==t&&t===(null==me||null===(r=me.ErrorCondition)||void 0===r?void 0:r.NO_AUTH_MECH)&&(s=n("The XMPP server did not offer a supported authentication mechanism")),this.setConnectionStatus(e,s),this.setDisconnectionCause(e,t)}else e===me.Status.DISCONNECTING&&this.setDisconnectionCause(e,t)}isType(e){return"websocket"===e.toLowerCase()?this._proto instanceof me.Websocket:"bosh"===e.toLowerCase()?me.Bosh&&this._proto instanceof me.Bosh:void 0}hasResumed(){var e;return null!==(e=bu.settings.get("connection_options"))&&void 0!==e&&e.worker||this.isType("bosh")?ul.connfeedback.get("connection_status")===me.Status.ATTACHED:!this.do_bind}restoreWorkerSession(){return this.attach(this.onConnectStatusChanged),this.worker_attach_promise=ba(),this.worker_attach_promise}}class Ic extends Oc{constructor(e,t){super(e,t),this.sent_stanzas=[],this.IQ_stanzas=[],this.IQ_ids=[],this.features=me.xmlHtmlNode('').firstChild,this._proto._processRequest=()=>{},this._proto._disconnect=()=>this._onDisconnectTimeout(),this._proto._onDisconnectTimeout=()=>{},this._proto._connect=()=>{this.connected=!0,this.mock=!0,this.jid="romeo@montague.lit/orchard",this._changeConnectStatus(me.Status.BINDREQUIRED)}}_processRequest(){}sendIQ(e,t,n){T(e)||(e=e.nodeTree),this.IQ_stanzas.push(e);const s=super.sendIQ(e,t,n);return this.IQ_ids.push(s),s}send(e){return T(e)?this.sent_stanzas.push(e):this.sent_stanzas.push(e.nodeTree),super.send(e)}async bind(){await bu.trigger("beforeResourceBinding",{synchronous:!0}),this.authenticated=!0,ul.no_connection_on_bind||this._changeConnectStatus(me.Status.CONNECTED)}}function Mc(e,t){t=e.session.get("jid")||t,e.api.settings.get("authentication")===e.ANONYMOUS||me.getResourceFromJid(t)||(t=t.toLowerCase()+Oc.generateResource()),e.jid=t,e.bare_jid=me.getBareJidFromJid(t),e.resource=me.getResourceFromJid(t),e.domain=me.getDomainFromJid(t),e.session.save({jid:t,bare_jid:e.bare_jid,resource:e.resource,domain:e.domain,active:!0}),e.connection.jid=t}async function Rc(e){return await async function(e,t){var n;const s=e.api.settings.get("connection_options").worker,i=me.getBareJidFromJid(t).toLowerCase(),o=`converse.session-${i}`;(null===(n=e.session)||void 0===n?void 0:n.get("id"))!==o?(!function(e,t){if("sessionStorage"===e.api.settings.get("persistent_store"))return;if("BrowserExtLocal"===e.api.settings.get("persistent_store"))return Ma.localForage.defineDriver(Tc.Z).then((()=>Ma.localForage.setDriver("webExtensionLocalStorage"))),void(e.storage.persistent=Ma.localForage);if("BrowserExtSync"===e.api.settings.get("persistent_store"))return Ma.localForage.defineDriver($c.Z).then((()=>Ma.localForage.setDriver("webExtensionSyncStorage"))),void(e.storage.persistent=Ma.localForage);const n={name:e.isTestEnv()?"converse-test-persistent":"converse-persistent",storeName:t};"localStorage"===e.api.settings.get("persistent_store")?(n.description="localStorage instance",n.driver=[Ma.localForage.LOCALSTORAGE]):"IndexedDB"===e.api.settings.get("persistent_store")&&(n.description="indexedDB instance",n.driver=[Ma.localForage.INDEXEDDB]),e.storage.persistent=Ma.localForage.createInstance(n)}(e,i),e.session=new Ac({id:o}),La(e.session,o,s?"persistent":"session"),await new Promise((t=>e.session.fetch({success:t,error:t}))),!s&&e.session.get("active")&&(e.session.clear(),e.session.save({id:o})),Mc(e,t),e.api.trigger("userSessionInitialized")):Mc(e,t)}(ul,e),ul.api.trigger("setUserJID"),e}async function Dc(e){var t;const{api:n}=e;await n.trigger("cleanup",{synchronous:!0}),e.router.history.stop(),function(e){const{api:t}=e;document.removeEventListener("visibilitychange",e.saveWindowState),t.trigger("unregisteredGlobalEventHandlers")}(e),null===(t=e.connection)||void 0===t||t.reset(),e.stopListening(),e.off(),e.promises.initialized.isResolved&&n.promises.add("initialized")}function zc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise(jc((async(e,t)=>{let n=new XMLHttpRequest;n.open("GET",ul.api.settings.get("credentials_url"),!0),n.setRequestHeader("Accept","application/json, text/javascript"),n.onload=()=>{if(n.status>=200&&n.status<400){const t=JSON.parse(n.responseText);Rc(t.jid).then((()=>{e({jid:t.jid,password:t.password})}))}else t(new Error(`${n.status}: ${n.responseText}`))},n.onerror=t,n=await ul.api.hook("beforeFetchLoginCredentials",this,n),n.send()}),e))}async function Lc(e,t){const{api:n}=ul;n.settings.get("authentication")===ul.LOGIN?e?Fc(e):n.settings.get("credentials_url")?Fc(await async function(){let e,t=0;for(;!e;){try{e=await zc(t)}catch(e){z.error("Could not fetch login credentials"),z.error(e)}t=2e3}return e}()):ul.jid&&(n.settings.get("password")||ul.connection.pass)?Fc():!ul.isTestEnv()&&"credentials"in navigator?Fc(await async function(){try{const e=await navigator.credentials.get({password:!0});if(e&&"password"==e.type&&Wc.isValidJID(e.id))return await Rc(e.id),{jid:e.id,password:e.password}}catch(e){z.error(e)}}()):!ul.isTestEnv()&&z.warn("attemptNonPreboundSession: Couldn't find credentials to log in with"):![ul.ANONYMOUS,ul.EXTERNAL].includes(n.settings.get("authentication"))||t&&!n.settings.get("auto_login")||Fc()}function Pc(){const{api:e}=ul;return("WebSocket"in window||"MozWebSocket"in window)&&e.settings.get("websocket_url")?e.settings.get("websocket_url"):e.settings.get("bosh_service_url")?e.settings.get("bosh_service_url"):""}function Fc(e){const{api:t}=ul;if([ul.ANONYMOUS,ul.EXTERNAL].includes(t.settings.get("authentication"))){if(!ul.jid)throw new Error("Config Error: when using anonymous login you need to provide the server's domain via the 'jid' option. Either when calling converse.initialize, or when calling _converse.api.user.login.");ul.connection.reconnecting||ul.connection.reset(),ul.connection.connect(ul.jid.toLowerCase())}else if(t.settings.get("authentication")===ul.LOGIN){var n;const s=(null==e?void 0:e.password)??((null===(n=ul.connection)||void 0===n?void 0:n.pass)||t.settings.get("password"));if(!s){if(t.settings.get("auto_login"))throw new Error("autoLogin: If you use auto_login and authentication='login' then you also need to provide a password.");return ul.connection.setDisconnectionCause(me.Status.AUTHFAIL,void 0,!0),void t.connection.disconnect()}ul.connection.reconnecting||(ul.connection.reset(),ul.connection.service=Pc()),ul.connection.connect(ul.jid,s)}}const Uc={extend:e=>function(e){nl.merge(sl,e);const t=Object.keys(Ja(e,Object.keys(sl))),n=Ja(rl,t),s=Mt(Ja(e,t),n);nl.merge(il,s)}(e),update(e){return z.warn("The api.settings.update method has been deprecated and will be removed. Please use api.settings.extend instead."),this.extend(e)},get:e=>function(e){if(Object.keys(sl).includes(e))return il[e]}(e),set(e,t){!function(e,t){if(null==e)return this;let n;we(e)?n=e:"string"==typeof e&&(n={},n[e]=t);const s=Object.keys(Ja(n,Object.keys(sl))),i={};s.forEach((e=>{const t=n[e];Pa(il[e],t)||(i[e]=t,il[e]=t)})),Object.keys(i).forEach((e=>il.trigger("change:"+e,i[e]))),il.trigger("change",i)}(e,t)},listen:{on(e,t,n){!function(e,t,n){il.on(e,t,n)}(e,t,n)},not(e,t){!function(e,t){il.off(e,t)}(e,t)}}},Bc={getModel:()=>ll(),async get(e,t){const n=await ll();return void 0===n.get(e)?t:n.get(e)},set(e,t){if(we(e))return dl(e,{promise:!0});{const n={};return n[e]=t,dl(n,{promise:!0})}},clear:()=>async function(){return await cl(),ol.clear()}()};function qc(e){return e instanceof Ac&&(e=e.attributes),!(e.oob_url||e.file||e.is_encrypted&&e.plaintext||e.message)}function Hc(){return["mobile","fullscreen","embedded"].includes(Uc.get("view_mode"))}async function Gc(){return await ul.api.trigger("beforeTearDown",{synchronous:!0}),window.removeEventListener("click",ul.onUserActivity),window.removeEventListener("focus",ul.onUserActivity),window.removeEventListener("keypress",ul.onUserActivity),window.removeEventListener("mousemove",ul.onUserActivity),window.removeEventListener(ul.unloadevent,ul.onUserActivity),window.clearInterval(ul.everySecondTrigger),ul.api.trigger("afterTearDown"),ul}const Wc={isTagEqual:function(e,t){if(e.nodeTree)return Wc.isTagEqual(e.nodeTree,t);if(e instanceof Element)return me.isTagEqual(e,t);throw Error("isTagEqual called with value which isn't an element or Strophe.Builder instance")}},Vc=new DOMParser,Jc=Vc.parseFromString("invalid","text/xml").getElementsByTagName("parsererror")[0].namespaceURI;function Qc(e){let t=e.getMessageText();return(e.get("references")||[]).sort(((e,t)=>t.begin-e.begin)).forEach((e=>{t=`${t.slice(0,e.begin)}@${t.slice(e.begin)}`})),t}function Zc(e,t,n){Wc.isPersistableModel(e)?e.save(t,n):e.set(t,n)}function Kc(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}function Yc(e,t){clearTimeout(e),clearInterval(t)}function Xc(e){const t=ul.promises[e];if(!t)throw new Error(`Tried to replace non-existing promise: ${e}`);if(t.replace){const n=ba();n.replace=t.replace,ul.promises[e]=n}else z.debug(`Not replacing promise "${e}"`)}Wc.getJIDFromURI=function(e){return e.startsWith("xmpp:")&&e.endsWith("?join")?e.replace(/^xmpp:/,"").replace(/\?join$/,""):e},Wc.toStanza=function(e){const t=Vc.parseFromString(e,"text/xml");if(t.getElementsByTagNameNS(Jc,"parsererror").length)throw new Error(`Parser Error: ${e}`);return t.firstElementChild},Wc.getLongestSubstring=function(e,t){return t.reduce((function(t,n){return e.startsWith(n)&&n.length>t.length?n:t}),"")},Wc.isValidJID=function(e){return"string"==typeof e&&(2===Ka(e.split("@")).length&&!e.startsWith("@")&&!e.endsWith("@"))},Wc.isValidMUCJID=function(e){return!e.startsWith("@")&&!e.endsWith("@")},Wc.isSameBareJID=function(e,t){return"string"==typeof e&&"string"==typeof t&&me.getBareJidFromJid(e).toLowerCase()===me.getBareJidFromJid(t).toLowerCase()},Wc.isSameDomain=function(e,t){return"string"==typeof e&&"string"==typeof t&&me.getDomainFromJid(e).toLowerCase()===me.getDomainFromJid(t).toLowerCase()},Wc.isNewMessage=function(e){return e instanceof Element?!(ec()(`result[xmlns="${me.NS.MAM}"]`,e).length&&ec()(`delay[xmlns="${me.NS.DELAY}"]`,e).length):(e instanceof Ac&&(e=e.attributes),!(e.is_delayed&&e.is_archived))},Wc.shouldCreateMessage=function(e){return e.retracted||!qc(e)},Wc.shouldCreateGroupchatMessage=function(e){return e.nick&&(Wc.shouldCreateMessage(e)||e.is_tombstone)},Wc.isChatRoom=function(e){return e&&"chatroom"===e.get("type")},Wc.isErrorObject=function(e){return e instanceof Error},Wc.isErrorStanza=function(e){return!!T(e)&&"error"===e.getAttribute("type")},Wc.isForbiddenError=function(e){return!!T(e)&&ec()(`error[type="auth"] forbidden[xmlns="${me.NS.STANZAS}"]`,e).length>0},Wc.isServiceUnavailableError=function(e){return!!T(e)&&ec()(`error[type="cancel"] service-unavailable[xmlns="${me.NS.STANZAS}"]`,e).length>0},Wc.merge=function e(t,n){for(const s in n)we(t[s])?e(t[s],n[s]):t[s]=n[s]},Wc.getOuterWidth=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.offsetWidth;if(!t)return n;const s=window.getComputedStyle(e);return n+=parseInt(s.marginLeft?s.marginLeft:0,10)+parseInt(s.marginRight?s.marginRight:0,10),n},Wc.stringToElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild},Wc.matchesSelector=function(e,t){const n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return!!n&&n.call(e,t)},Wc.queryChildren=function(e,t){return Array.from(e.childNodes).filter((e=>Wc.matchesSelector(e,t)))},Wc.contains=function(e,t){const n=(e,n)=>e.get(n).toLowerCase().includes(t.toLowerCase());return function(t){if("object"==typeof e)return Object.keys(e).reduce(((e,s)=>e||n(t,s)),!1);if("string"==typeof e)return n(t,e);throw new TypeError("contains: wrong attribute type. Must be string or array.")}},Wc.isOfType=function(e,t){return t.get("type")==e},Wc.isInstance=function(e,t){return t instanceof e},Wc.getAttribute=function(e,t){return t.get(e)},Wc.contains.not=function(e,t){return function(n){return!Wc.contains(e,t)(n)}},Wc.rootContains=function(e,t){return e!==document||e.contains?e.contains?e.contains(t):window.HTMLElement.prototype.contains.call(e,t):document.head.contains(t)||document.body.contains(t)},Wc.createFragmentFromText=function(e){var t,n=document.createDocumentFragment(),s=document.createElement("body");for(s.innerHTML=e;t=s.firstChild;)n.appendChild(t);return n},Wc.isPersistableModel=function(e){return e.collection&&e.collection.browserStorage},Wc.getResolveablePromise=ba,Wc.getOpenPromise=ba,Wc.interpolate=function(e,t){return e.replace(/{{{([^{}]*)}}}/g,((e,n)=>{var s=t[n];return"string"==typeof s||"number"==typeof s?s:e}))},Wc.onMultipleEvents=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=[];function s(s){n.push(s),e.length===n.length&&(t(n),n=[])}e.forEach((e=>e.object.on(e.event,s)))},Wc.safeSave=Zc,Wc.siblingIndex=function(e){for(var t=0;e=e.previousElementSibling;t++);return t},Wc.getCurrentWord=function(e,t,n){t||(t=e.selectionEnd||void 0);let[s]=e.value.slice(0,t).split(/\s/).slice(-1);return n&&([s]=s.split(n).slice(-1)),s},Wc.isMentionBoundary=e=>"@"!==e&&RegExp("(\\p{Z}|\\p{P})","u").test(e),Wc.replaceCurrentWord=function(e,t){const n=e.selectionEnd||void 0,s=Ya(e.value.slice(0,n).split(/\s/)),i=e.value,o=Wc.isMentionBoundary(s[0])?s[0]:"";e.value=i.slice(0,n-s.length)+o+`${t} `+i.slice(n);const r=n-s.length+t.length+1;e.selectionEnd=o?r+1:r},Wc.triggerEvent=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Event",s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];const o=document.createEvent(n);o.initEvent(t,s,i),e.dispatchEvent(o)},Wc.getSelectValues=function(e){const t=[],n=e&&e.options;for(var s=0,i=n.length;se.setSelectionRange(t,t)),1),this.scrollTop=999999},Wc.httpToGeoUri=function(e){return e.replace(Uc.get("geouri_regex"),"geo:$1,$2")},Wc.waitUntil=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3;try{const t=e();if(t)return Promise.resolve(t)}catch(e){return Promise.reject(e)}const s=ba(),i=new Error;function o(){try{const t=e();t&&(Yc(c,r),s.resolve(t))}catch(e){Yc(c,r),s.reject(e)}}const r=setInterval(o,n);function a(){Yc(c,r);const e=`Wait until promise timed out: \n\n${i.stack}`;console.trace(),z.error(e),s.reject(new Error(e))}const c=setTimeout(a,t);return s};const el=document.createElement("div");function tl(e){return e&&"string"==typeof e&&(el.innerHTML=Za().sanitize(e),e=el.textContent,el.textContent=""),e}const nl=Object.assign({prefixMentions:Qc,isEmptyMessage:qc,getUniqueId:Kc},Wc),sl={allow_non_roster_messaging:!1,allow_url_history_change:!0,assets_path:"/dist",authentication:"login",auto_login:!1,auto_reconnect:!0,blacklisted_plugins:[],clear_cache_on_logout:!1,connection_options:{},credentials_url:null,discover_connection_methods:!0,geouri_regex:/https\:\/\/www.openstreetmap.org\/.*#map=[0-9]+\/([\-0-9.]+)\/([\-0-9.]+)\S*/g,geouri_replacement:"https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2",i18n:void 0,jid:void 0,keepalive:!0,loglevel:"info",locales:["af","ar","bg","ca","cs","da","de","el","eo","es","eu","en","fa","fi","fr","gl","he","hi","hu","id","it","ja","lt","nb","nl","mr","oc","pl","pt","pt_BR","ro","ru","sv","th","tr","uk","vi","zh_CN","zh_TW"],nickname:void 0,password:void 0,persistent_store:"IndexedDB",rid:void 0,root:window.document,sid:void 0,singleton:!1,strict_plugin_dependencies:!1,view_mode:"overlayed",websocket_url:void 0,whitelisted_plugins:[]};let il,ol,rl={};function al(){return il}function cl(){var e;if(!ul.bare_jid){const e="No JID to fetch user settings for";throw z.error(e),Error(e)}if(null===(e=ol)||void 0===e||!e.fetched){const e=`converse.user-settings.${ul.bare_jid}`;ol=new Ac({id:e}),La(ol,e),ol.fetched=ol.fetch({promise:!0})}return ol.fetched}async function ll(){return await cl(),ol}async function dl(e,t){return await cl(),ol.save(e,t)}const ul={log:z,CONNECTION_STATUS:ve,templates:{},promises:{initialized:ba()},STATUS_WEIGHTS:{offline:6,unavailable:5,xa:4,away:3,dnd:2,chat:1,online:1},ANONYMOUS:"anonymous",CLOSED:"closed",EXTERNAL:"external",LOGIN:"login",LOGOUT:"logout",OPENED:"opened",PREBIND:"prebind",STANZA_TIMEOUT:2e4,SUCCESS:"success",FAILURE:"failure",DEFAULT_IMAGE_TYPE:"image/svg+xml",DEFAULT_IMAGE:"PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+CiA8cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iIzU1NSIvPgogPGNpcmNsZSBjeD0iNjQiIGN5PSI0MSIgcj0iMjQiIGZpbGw9IiNmZmYiLz4KIDxwYXRoIGQ9Im0yOC41IDExMiB2LTEyIGMwLTEyIDEwLTI0IDI0LTI0IGgyMyBjMTQgMCAyNCAxMiAyNCAyNCB2MTIiIGZpbGw9IiNmZmYiLz4KPC9zdmc+Cg==",TIMEOUTS:{PAUSED:1e4,INACTIVE:9e4},INACTIVE:"inactive",ACTIVE:"active",COMPOSING:"composing",PAUSED:"paused",GONE:"gone",PRIVATE_CHAT_TYPE:"chatbox",CHATROOMS_TYPE:"chatroom",HEADLINES_TYPE:"headline",CONTROLBOX_TYPE:"controlbox",default_connection_options:{explicitResourceBinding:!0},router:new Xi,TimeoutError:io,isTestEnv:()=>"montague.lit/http-bind"===rl.bosh_service_url,getDefaultStore:Ra,createStore:za,__:function(){return r.__(...arguments)},___:e=>e};var hl=n(8734),ml=n.n(hl);const gl={connected(){var e;return(null==ul||null===(e=ul.connection)||void 0===e?void 0:e.connected)&&!0},disconnect(){ul.connection&&ul.connection.disconnect()},reconnect(){const{__:e,connection:t}=ul;return t.setConnectionStatus(me.Status.RECONNECTING,e("The connection has dropped, attempting to reconnect.")),null!=t&&t.reconnecting?t.debouncedReconnect():t.reconnect()},isType:e=>ul.connection.isType(e)};var fl=n(7484),pl=n.n(fl);const vl=function(e,t,n){t=Ms(t,e);var s=null==(e=bc(e,t))?e:e[Rs(Ya(t))];return null==s?void 0:Ge(s,e,n)};const _l=Ye(vl);function yl(e,t,n,s){"function"==typeof n&&(void 0===this.__super__&&(this.__super__=s),this.__super__[e]=n.bind(this));for(var i=arguments.length,o=new Array(i>4?i-4:0),r=4;r{const n=this.plugins[t];if(n){var s;if(null!==(s=n.dependencies)&&void 0!==s&&s.includes(e.__name__))throw'Found a circular dependency between the plugins "'+e.__name__+'" and "'+t+'"';this.initializePlugin(n)}else this.throwUndefinedDependencyError('Could not find dependency "'+t+'" for the plugin "'+e.__name__+"\". If it's needed, make sure it's loaded by require.js")}))}throwUndefinedDependencyError(e){if(this.plugged.strict_plugin_dependencies)throw e;console.warn?console.warn(e):console.log(e)}applyOverrides(e){Object.keys(e.overrides||{}).forEach((t=>{const n=e.overrides[t];"object"==typeof n?void 0===this.plugged[t]?this.throwUndefinedDependencyError(`Plugin "${e.__name__}" tried to override "${t}" but it's not found.`):this._extendObject(this.plugged[t],n):this._overrideAttribute(t,e)}))}initializePlugin(e){var t;Object.keys(this.allowed_plugins).includes(e.__name__)&&(this.initialized_plugins.includes(e.__name__)||("boolean"==typeof e.enabled&&e.enabled||null!==(t=e.enabled)&&void 0!==t&&t.call(e,this.plugged)||null==e.enabled)&&(Object.assign(e,this.properties),e.dependencies&&this.loadPluginDependencies(e),this.applyOverrides(e),"function"==typeof e.initialize&&e.initialize.bind(e)(this),this.initialized_plugins.push(e.__name__)))}registerPlugin(e,t){if(e in this.plugins)throw new Error("Error: Plugin name "+e+" is already taken");t.__name__=e,this.plugins[e]=t}initializePlugins(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(Object.keys(this.plugins).length){this.properties=e,this.allowed_plugins={};for(const[e,s]of Object.entries(this.plugins))t.length&&!t.includes(e)||n.includes(e)||(this.allowed_plugins[e]=s);Object.values(this.allowed_plugins).forEach((e=>this.initializePlugin(e)))}}}const wl={enable:function(e,t,n){return void 0===n&&(n="pluginSocket"),void 0===t&&(t="plugged"),e[n]=new bl(e,t),e}};const Sl=function(e,t,n,s){for(var i=-1,o=null==e?0:e.length;++i-1};const Il=function(e,t,n){for(var s=-1,i=null==e?0:e.length;++s=200&&(o=xn,r=!1,t=new Sn(t));e:for(;++it||o&&r&&c&&!a&&!l||s&&r&&c||!n&&c||!i)return 1;if(!s&&!o&&!l&&e=a?c:c*("desc"==n[s]?-1:1)}return e.index-t.index};const od=function(e,t,n){t=t.length?Ts(t,(function(e){return ut(e)?function(t){return Ds(t,1===e.length?e[0]:e)}:e})):[He];var s=-1;t=Ts(t,yt(Gs));var i=td(e,(function(e,n,i){var o=Ts(t,(function(t){return t(e)}));return{criteria:o,index:++s,value:e}}));return nd(i,(function(e,t){return id(e,t,n)}))};var rd=Ye((function(e,t){if(null==e)return[];var n=t.length;return n>1&&st(e,t[0],t[1])?t=[]:n>2&&st(t[0],t[1],t[2])&&(t=[t[0]]),od(e,Ga(t,1),[])}));const ad=rd,cd=Array.prototype.slice,ld=function(e,t){t||(t={}),this.preinitialize.apply(this,arguments),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,Mt({silent:!0},t))};ld.extend=zi;const dd={add:!0,remove:!0,merge:!0},ud={add:!0,remove:!1},hd=function(e,t,n){n=Math.min(Math.max(n,0),e.length);const s=Array(e.length-n),i=t.length;let o;for(o=0;othis.length&&(s=this.length),s<0&&(s+=this.length+1);const i=[],o=[],r=[],a=[],c={},l=t.add,d=t.merge,u=t.remove;let h=!1;const m=this.comparator&&null==s&&!1!==t.sort,g=Ho(this.comparator)?this.comparator:null;let f,p;for(p=0;pe!==i[t])),this.models.length=0,hd(this.models,i,0),this.length=this.models.length):o.length&&(m&&(h=!0),hd(this.models,o,null==s?this.length:s),this.length=this.models.length),h&&this.sort({silent:!0}),!t.silent){for(p=0;p0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;await Promise.all(this.models.filter(t).map((t=>new Promise((n=>{t.destroy(Object.assign(e,{success:n,error:(e,t)=>{console.error(t),n()}}))}))))),await this.browserStorage.clear(),this.reset()},reset:function(e,t){t=t?tc(t):{};for(let e=0;et.matches(e),t)},every:function(e){return Ll(this.models.map((e=>e.attributes)),e)},difference:function(e){return Rl(this.models,e)},max:function(){return Math.max.apply(Math,this.models)},min:function(){return Math.min.apply(Math,this.models)},drop:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return this.models.slice(e)},some:function(e){return Ys(this.models.map((e=>e.attributes)),e)},sortBy:function(e){return ad(this.models,Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e))},isEmpty:function(){return ei(this.models)},keyBy:function(e){return Zl(this.models,e)},each:function(e,t){return this.forEach(e,t)},forEach:function(e,t){return this.models.forEach(e,t)},includes:function(e){return this.models.includes(e)},size:function(){return this.models.length},countBy:function(e){return kl(this.models,Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e))},groupBy:function(e){return Wl(this.models,Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e))},indexOf:function(e){return Jl(this.models,e)},findLastIndex:function(e,t){return ql(this.models,Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e),t)},lastIndexOf:function(e){return ed(this.models,e)},findIndex:function(e){return Fl(this.models,Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e))},last:function(){const e=null==this.models?0:this.models.length;return e?this.models[e-1]:void 0},head:function(){return this.models[0]},first:function(){return this.head()},map:function(e,t){return this.models.map(Se(e)?e:t=>Ho(e)?t.get(e):t.matches(e),t)},reduce:function(e,t){return this.models.reduce(e,t||this.models[0])},reduceRight:function(e,t){return this.models.reduceRight(e,t||this.models[0])},toArray:function(){return Array.from(this.models)},get:function(e){if(null!=e)return this._byId[e]||this._byId[this.modelId(this._isModel(e)?e.attributes:e)]||e.cid&&this._byId[e.cid]},has:function(e){return null!=this.get(e)},at:function(e){return e<0&&(e+=this.length),this.models[e]},where:function(e,t){return this[t?"find":"filter"](e)},findWhere:function(e){return this.where(e,!0)},find:function(e,t){const n=Se(e)?e:t=>t.matches(e);return this.models.find(n,t)},sort:function(e){let t=this.comparator;if(!t)throw new Error("Cannot sort a set without a comparator");e||(e={});const n=t.length;return Se(t)&&(t=t.bind(this)),1===n||Ho(t)?this.models=this.sortBy(t):this.models.sort(t),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return this.map(e+"")},fetch:function(e){const t=(e=Mt({parse:!0},e)).success,n=this,s=e.promise&&Li();return e.success=function(i){const o=e.reset?"reset":"set";n[o](i,e),t&&t.call(e.context,n,i,e),s&&s.resolve(),n.trigger("sync",n,i,e)},Fi(this,e),s||this.sync("read",this,e)},create:function(e,t){const n=(t=t?tc(t):{}).wait,s=t.promise,i=s&&Li();if(!(e=this._prepareModel(e,t)))return!1;n||this.add(e,t);const o=this,r=t.success,a=t.error;return t.success=function(e,t,a){n&&o.add(e,a),r&&r.call(a.context,e,t,a),s&&i.resolve(e)},t.error=function(e,t,n){a&&a.call(n.context,e,t,n),s&&i.reject(t)},e.save(null,Object.assign(t,{promise:!1})),s?i:e},parse:function(e,t){return e},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(e){var t;return e[(null===(t=this.model.prototype)||void 0===t?void 0:t.idAttribute)||"id"]},values:function(){return new gd(this,fd)},keys:function(){return new gd(this,pd)},entries:function(){return new gd(this,vd)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(this._isModel(e))return e.collection||(e.collection=this),e;(t=t?tc(t):{}).collection=this;const n=new this.model(e,t);return n.validationError?(this.trigger("invalid",this,n.validationError,t),!1):n},_removeModels:function(e,t){const n=[];for(let s=0;snew wd("string"==typeof e?e:e+"",yd),xd=_d?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return Sd(t)})(e):e;var Ed;const Ad=window.trustedTypes,Cd=Ad?Ad.emptyScript:"",kd=window.reactiveElementPolyfillSupport,jd={toAttribute(e,t){switch(t){case Boolean:e=e?Cd:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},Td=(e,t)=>t!==e&&(t==t||e==e),$d={attribute:!0,type:String,converter:jd,reflect:!1,hasChanged:Td};class Nd extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(e){var t;null!==(t=this.l)&&void 0!==t||(this.l=[]),this.l.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,n)=>{const s=this._$Eh(n,t);void 0!==s&&(this._$Eu.set(s,n),e.push(s))})),e}static createProperty(e,t=$d){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const n="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,n,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(s){const i=this[e];this[t]=s,this.requestUpdate(e,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||$d}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const n of t)this.createProperty(n,e[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(xd(e))}else void 0!==e&&t.push(xd(e));return t}static _$Eh(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}o(){var e;this._$Ep=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,n;(null!==(t=this._$Eg)&&void 0!==t?t:this._$Eg=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}removeController(e){var t;null===(t=this._$Eg)||void 0===t||t.splice(this._$Eg.indexOf(e)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Et.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{_d?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style"),s=window.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=t.cssText,e.appendChild(n)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ES(e,t,n=$d){var s,i;const o=this.constructor._$Eh(e,n);if(void 0!==o&&!0===n.reflect){const r=(null!==(i=null===(s=n.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==i?i:jd.toAttribute)(t,n.type);this._$Ei=e,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$Ei=null}}_$AK(e,t){var n,s,i;const o=this.constructor,r=o._$Eu.get(e);if(void 0!==r&&this._$Ei!==r){const e=o.getPropertyOptions(r),a=e.converter,c=null!==(i=null!==(s=null===(n=a)||void 0===n?void 0:n.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==i?i:jd.fromAttribute;this._$Ei=r,this[r]=c(t,e.type),this._$Ei=null}}requestUpdate(e,t,n){let s=!0;void 0!==e&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||Td)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===n.reflect&&this._$Ei!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,n))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((e,t)=>this[t]=e)),this._$Et=void 0);let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),null===(e=this._$Eg)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(n)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;null===(t=this._$Eg)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$ES(t,this[t],e))),this._$EC=void 0),this._$EU()}updated(e){}firstUpdated(e){}}var Od;Nd.finalized=!0,Nd.elementProperties=new Map,Nd.elementStyles=[],Nd.shadowRootOptions={mode:"open"},null==kd||kd({ReactiveElement:Nd}),(null!==(Ed=globalThis.reactiveElementVersions)&&void 0!==Ed?Ed:globalThis.reactiveElementVersions=[]).push("1.3.0");const Id=globalThis.trustedTypes,Md=Id?Id.createPolicy("lit-html",{createHTML:e=>e}):void 0,Rd=`lit$${(Math.random()+"").slice(9)}$`,Dd="?"+Rd,zd=`<${Dd}>`,Ld=document,Pd=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Ld.createComment(e)},Fd=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Ud=Array.isArray,Bd=e=>{var t;return Ud(e)||"function"==typeof(null===(t=e)||void 0===t?void 0:t[Symbol.iterator])},qd=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Hd=/-->/g,Gd=/>/g,Wd=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,Vd=/'/g,Jd=/"/g,Qd=/^(?:script|style|textarea|title)$/i,Zd=e=>function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i{var s,i;const o=null!==(s=null==n?void 0:n.renderBefore)&&void 0!==s?s:t;let r=o._$litPart$;if(void 0===r){const e=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:null;o._$litPart$=r=new au(t.insertBefore(Pd(),e),e,void 0,null!=n?n:{})}return r._$AI(e),r},nu=Ld.createTreeWalker(Ld,129,null,!1),su=(e,t)=>{const n=e.length-1,s=[];let i,o=2===t?"":"",r=qd;for(let t=0;t"===c[0]?(r=null!=i?i:qd,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,a=c[1],r=void 0===c[3]?Wd:'"'===c[3]?Jd:Vd):r===Jd||r===Vd?r=Wd:r===Hd||r===Gd?r=qd:(r=Wd,i=void 0);const u=r===Wd&&e[t+1].startsWith("/>")?" ":"";o+=r===qd?n+zd:l>=0?(s.push(a),n.slice(0,l)+"$lit$"+n.slice(l)+Rd+u):n+Rd+(-2===l?(s.push(void 0),t):u)}const a=o+(e[n]||"")+(2===t?"":"");if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==Md?Md.createHTML(a):a,s]};class iu{constructor(e,t){let n,{strings:s,_$litType$:i}=e;this.parts=[];let o=0,r=0;const a=s.length-1,c=this.parts,[l,d]=su(s,i);if(this.el=iu.createElement(l,t),nu.currentNode=this.el.content,2===i){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(n=nu.nextNode())&&c.length0){n.textContent=Id?Id.emptyScript:"";for(let s=0;s2&&void 0!==arguments[2]?arguments[2]:e,s=arguments.length>3?arguments[3]:void 0;var i,o,r,a;if(t===Yd)return t;let c=void 0!==s?null===(i=n._$Cl)||void 0===i?void 0:i[s]:n._$Cu;const l=Fd(t)?void 0:t._$litDirective$;return(null==c?void 0:c.constructor)!==l&&(null===(o=null==c?void 0:c._$AO)||void 0===o||o.call(c,!1),void 0===l?c=void 0:(c=new l(e),c._$AT(e,n,s)),void 0!==s?(null!==(r=(a=n)._$Cl)&&void 0!==r?r:a._$Cl=[])[s]=c:n._$Cu=c),void 0!==c&&(t=ou(e,c._$AS(e,t.values),c,s)),t}class ru{constructor(e,t){this.v=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(e){var t;const{el:{content:n},parts:s}=this._$AD,i=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Ld).importNode(n,!0);nu.currentNode=i;let o=nu.nextNode(),r=0,a=0,c=s[0];for(;void 0!==c;){if(r===c.index){let t;2===c.type?t=new au(o,o.nextSibling,this,e):1===c.type?t=new c.ctor(o,c.name,c.strings,this,e):6===c.type&&(t=new mu(o,this,e)),this.v.push(t),c=s[++a]}r!==(null==c?void 0:c.index)&&(o=nu.nextNode(),r++)}return i}m(e){let t=0;for(const n of this.v)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class au{constructor(e,t,n,s){var i;this.type=2,this._$AH=Xd,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=s,this._$Cg=null===(i=null==s?void 0:s.isConnected)||void 0===i||i}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cg}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e){e=ou(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),Fd(e)?e===Xd||null==e||""===e?(this._$AH!==Xd&&this._$AR(),this._$AH=Xd):e!==this._$AH&&e!==Yd&&this.$(e):void 0!==e._$litType$?this.T(e):void 0!==e.nodeType?this.k(e):Bd(e)?this.S(e):this.$(e)}A(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._$AB;return this._$AA.parentNode.insertBefore(e,t)}k(e){this._$AH!==e&&(this._$AR(),this._$AH=this.A(e))}$(e){this._$AH!==Xd&&Fd(this._$AH)?this._$AA.nextSibling.data=e:this.k(Ld.createTextNode(e)),this._$AH=e}T(e){var t;const{values:n,_$litType$:s}=e,i="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=iu.createElement(s.h,this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===i)this._$AH.m(n);else{const e=new ru(i,this),t=e.p(this.options);e.m(n),this.k(t),this._$AH=e}}_$AC(e){let t=eu.get(e.strings);return void 0===t&&eu.set(e.strings,t=new iu(e)),t}S(e){Ud(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,s=0;for(const i of e)s===t.length?t.push(n=new au(this.A(Pd()),this.A(Pd()),this,this.options)):n=t[s],n._$AI(i),s++;s0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,t=arguments.length>1?arguments[1]:void 0;var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cg=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class cu{constructor(e,t,n,s,i){this.type=1,this._$AH=Xd,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Xd}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;const i=this.strings;let o=!1;if(void 0===i)e=ou(this,e,t,0),o=!Fd(e)||e!==this._$AH&&e!==Yd,o&&(this._$AH=e);else{const s=e;let r,a;for(e=i[0],r=0;r1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==t?t:Xd)===Yd)return;const n=this._$AH,s=e===Xd&&n!==Xd||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==Xd&&(n===Xd||s);s&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==n?n:this.element,e):this._$AH.handleEvent(e)}}class mu{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){ou(this,e)}}const gu={P:"$lit$",L:Rd,V:Dd,I:1,N:su,R:ru,D:Bd,j:ou,H:au,O:cu,F:uu,B:hu,W:lu,Z:mu},fu=window.litHtmlPolyfillSupport;var pu,vu;null==fu||fu(iu,au),(null!==(Od=globalThis.litHtmlVersions)&&void 0!==Od?Od:globalThis.litHtmlVersions=[]).push("2.2.0");class _u extends Nd{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Dt=tu(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Dt)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Dt)||void 0===e||e.setConnected(!1)}render(){return Yd}}_u.finalized=!0,_u._$litElement$=!0,null===(pu=globalThis.litElementHydrateSupport)||void 0===pu||pu.call(globalThis,{LitElement:_u});const yu=globalThis.litElementPolyfillSupport;null==yu||yu({LitElement:_u});(null!==(vu=globalThis.litElementVersions)&&void 0!==vu?vu:globalThis.litElementVersions=[]).push("3.2.0"),pl().extend(ml()),me.addNamespace("ACTIVITY","http://jabber.org/protocol/activity"),me.addNamespace("CARBONS","urn:xmpp:carbons:2"),me.addNamespace("CHATSTATES","http://jabber.org/protocol/chatstates"),me.addNamespace("CSI","urn:xmpp:csi:0"),me.addNamespace("DELAY","urn:xmpp:delay"),me.addNamespace("EME","urn:xmpp:eme:0"),me.addNamespace("FASTEN","urn:xmpp:fasten:0"),me.addNamespace("FORWARD","urn:xmpp:forward:0"),me.addNamespace("HINTS","urn:xmpp:hints"),me.addNamespace("HTTPUPLOAD","urn:xmpp:http:upload:0"),me.addNamespace("MAM","urn:xmpp:mam:2"),me.addNamespace("MARKERS","urn:xmpp:chat-markers:0"),me.addNamespace("MENTIONS","urn:xmpp:mmn:0"),me.addNamespace("MESSAGE_CORRECT","urn:xmpp:message-correct:0"),me.addNamespace("MODERATE","urn:xmpp:message-moderate:0"),me.addNamespace("NICK","http://jabber.org/protocol/nick"),me.addNamespace("OCCUPANTID","urn:xmpp:occupant-id:0"),me.addNamespace("OMEMO","eu.siacs.conversations.axolotl"),me.addNamespace("OUTOFBAND","jabber:x:oob"),me.addNamespace("PUBSUB","http://jabber.org/protocol/pubsub"),me.addNamespace("RAI","urn:xmpp:rai:0"),me.addNamespace("RECEIPTS","urn:xmpp:receipts"),me.addNamespace("REFERENCE","urn:xmpp:reference:0"),me.addNamespace("REGISTER","jabber:iq:register"),me.addNamespace("RETRACT","urn:xmpp:message-retract:0"),me.addNamespace("ROSTERX","http://jabber.org/protocol/rosterx"),me.addNamespace("RSM","http://jabber.org/protocol/rsm"),me.addNamespace("SID","urn:xmpp:sid:0"),me.addNamespace("SPOILER","urn:xmpp:spoiler:0"),me.addNamespace("STANZAS","urn:ietf:params:xml:ns:xmpp-stanzas"),me.addNamespace("STYLING","urn:xmpp:styling:0"),me.addNamespace("VCARD","vcard-temp"),me.addNamespace("VCARDUPDATE","vcard-temp:x:update"),me.addNamespace("XFORM","jabber:x:data"),me.addNamespace("XHTML","http://www.w3.org/1999/xhtml"),ul.VERSION_NAME="v9.1.1",Object.assign(ul,vi),wl.enable(ul,"_converse","pluggable");const bu=ul.api={connection:gl,settings:Uc,async trigger(e){if(!ul._events)return;const t=Array.from(arguments),n=t.pop();if(n&&n.synchronous){const n=ul._events[e]||[],s=t.splice(1);await Promise.all(n.map((e=>e.callback.apply(e.ctx,s))))}else ul.trigger.apply(ul,arguments);const s=ul.promises[e];void 0!==s&&s.resolve()},hook(e,t,n){const s=ul._events[e]||[];return s.length?s.reduce(((e,n)=>e.then((e=>n.callback(t,e)))),Promise.resolve(n)):n},user:{settings:Bc,jid:()=>ul.connection.jid,async login(e,t){var n,s;let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e=e||bu.settings.get("jid"),(null===(n=ul.connection)||void 0===n||!n.jid||e&&!nl.isSameDomain(ul.connection.jid,e))&&await ul.initConnection(),null!==(s=bu.settings.get("connection_options"))&&void 0!==s&&s.worker&&await ul.connection.restoreWorkerSession())return;e&&(e=await Rc(e));const o=ul.pluggable.plugins["converse-bosh"];if(null!=o&&o.enabled()){if(await ul.restoreBOSHSession())return;if(bu.settings.get("authentication")===ul.PREBIND&&(!i||bu.settings.get("auto_login")))return ul.startNewPreboundBOSHSession()}t=t||bu.settings.get("password");Lc(e&&t?{jid:e,password:t}:null,i)},async logout(){await bu.trigger("beforeLogout",{synchronous:!0});const e=ba(),t=()=>{Object.keys(ul.promises).forEach(Xc),delete ul.jid,bu.trigger("logout"),e.resolve()};return ul.connection.setDisconnectionCause(ul.LOGOUT,void 0,!0),void 0!==ul.connection?(bu.listen.once("disconnected",(()=>t())),ul.connection.disconnect()):t(),e}},promises:{add(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(e=Array.isArray(e)?e:[e]).forEach((e=>{const n=ba();n.replace=t,ul.promises[e]=n}))}},listen:{once:ul.once.bind(ul),on:ul.on.bind(ul),not:ul.off.bind(ul),stanza(e,t,n){Se(t)?(n=t,t={}):t=t||{},ul.connection.addHandler(n,t.ns,e,t.type,t.id,t.from,t)}},waitUntil(e){if(Se(e))return nl.waitUntil(e);{const t=ul.promises[e];return void 0===t?null:t}},send(e){var t;return bu.connection.connected()?("string"==typeof e?e=nl.toStanza(e):null!==(t=e)&&void 0!==t&&t.nodeTree&&(e=e.nodeTree),"iq"===e.tagName?bu.sendIQ(e):(ul.connection.send(e),void bu.trigger("send",e))):(z.warn("Not sending stanza because we're not connected!"),void z.warn(me.serialize(e)))},sendIQ(e){var t;let n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ul.STANZA_TIMEOUT,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e=(null===(t=e)||void 0===t?void 0:t.nodeTree)??e,["get","set"].includes(e.getAttribute("type"))?(s=s||ul.STANZA_TIMEOUT,i?(n=new Promise(((t,n)=>ul.connection.sendIQ(e,t,n,s))),n.catch((t=>{if(null===t)throw new io(`Timeout error after ${s}ms for the following IQ stanza: ${me.serialize(e)}`)}))):n=new Promise((t=>ul.connection.sendIQ(e,t,t,s)))):(ul.connection.sendIQ(e),n=Promise.resolve()),bu.trigger("send",e),n}};function wu(){var e;return null===(e=ul.session)||void 0===e||e.destroy(),delete ul.session,ul.shouldClearCache()&&ul.api.user.settings.clear(),ul.api.trigger("clearSession",{synchronous:!0})}ul.shouldClearCache=()=>!ul.config.get("trusted")||bu.settings.get("clear_cache_on_logout")||ul.isTestEnv(),ul.initConnection=function(){const e=ul.api;if(!e.settings.get("bosh_service_url")&&e.settings.get("authentication")===ul.PREBIND)throw new Error("authentication is set to 'prebind' but we don't have a BOSH connection");const t=ul.isTestEnv()?Ic:Oc;ul.connection=new t(Pc(),Object.assign(ul.default_connection_options,e.settings.get("connection_options"),{keepalive:e.settings.get("keepalive")})),function(){const e={};e[me.LogLevel.DEBUG]="debug",e[me.LogLevel.INFO]="info",e[me.LogLevel.WARN]="warn",e[me.LogLevel.ERROR]="error",e[me.LogLevel.FATAL]="fatal",me.log=(t,n)=>z.log(n,e[t]),me.error=e=>z.error(e),ul.connection.xmlInput=e=>z.debug(e.outerHTML,"color: darkgoldenrod"),ul.connection.xmlOutput=e=>z.debug(e.outerHTML,"color: darkcyan")}(),e.trigger("connectionInitialized")},ul.saveWindowState=function(e){let t;const n={focus:"visible",focusin:"visible",pageshow:"visible",blur:"hidden",focusout:"hidden",pagehide:"hidden"};t=(e=e||document.createEvent("Events")).type in n?n[e.type]:document.hidden?"hidden":"visible",ul.windowState=t,bu.trigger("windowStateChanged",{state:t})},ul.ConnectionFeedback=Ac.extend({defaults:{connection_status:me.Status.DISCONNECTED,message:""},initialize(){this.on("change",(()=>bu.trigger("connfeedback",ul.connfeedback)))}});const Su=window.converse||{};Object.assign(Su,{CHAT_STATES:["active","composing","gone","inactive","paused"],keycodes:be,async initialize(e){var t;if(await Dc(ul),"onpagehide"in window?ul.unloadevent="pagehide":"onbeforeunload"in window?ul.unloadevent="beforeunload":"onunload"in window&&(ul.unloadevent="unload"),function(e){rl=e,il={},Object.assign(il,vi);const t=Ja(e,Object.keys(sl));Mt(il,sl,t)}(e),ul.strict_plugin_dependencies=e.strict_plugin_dependencies,z.setLogLevel(bu.settings.get("loglevel")),bu.settings.get("authentication")===ul.ANONYMOUS&&bu.settings.get("auto_login")&&!bu.settings.get("jid"))throw new Error("Config Error: you need to provide the server's domain via the 'jid' option when using anonymous authentication with auto_login.");ul.router.route(/^converse\?loglevel=(debug|info|warn|error|fatal)$/,"loglevel",(e=>z.setLogLevel(e))),ul.connfeedback=new ul.ConnectionFeedback,ul.send_initial_presence=!0,await async function(e){await Ma.sessionStorageInitialized,e.storage={session:Ma.localForage.createInstance({name:e.isTestEnv()?"converse-test-session":"converse-session",description:"sessionStorage instance",driver:["sessionStorageWrapper"]})}}(ul),await async function(e){const t="converse.client-config";e.config=new Ac({id:t,trusted:!0}),e.config.browserStorage=za(t,"session"),await new Promise((t=>e.config.fetch({success:t,error:t}))),e.api.trigger("clientConfigInitialized")}(ul),await r.initialize(),function(e){e.pluggable.initialized_plugins=[];const t=_e.concat(e.api.settings.get("whitelisted_plugins"));e.api.settings.get("singleton")&&["converse-bookmarks","converse-controlbox","converse-headline","converse-register"].forEach((t=>e.api.settings.get("blacklisted_plugins").push(t))),e.pluggable.initializePlugins({_converse:e},t,e.api.settings.get("blacklisted_plugins")),e.api.trigger("pluginsInitialized")}(ul),null===(t=bu.elements)||void 0===t||t.register(),function(e){document.addEventListener("visibilitychange",e.saveWindowState),e.saveWindowState({type:document.hidden?"blur":"focus"}),e.api.trigger("registeredGlobalEventHandlers")}(ul);try{!History.started&&ul.router.history.start()}catch(e){z.error(e)}const n=ul.pluggable.plugins;if((bu.settings.get("auto_login")||bu.settings.get("keepalive")&&_l(n["converse-bosh"],"enabled"))&&await bu.user.login(null,null,!0),bu.trigger("initialized"),ul.isTestEnv())return ul},plugins:{add(e,t){if(t.__name__=e,void 0!==ul.pluggable.plugins[e])throw new TypeError(`Error: plugin with name "${e}" has already been registered!`);ul.pluggable.plugins[e]=t}},env:{$build:le,$iq:ue,$msg:de,$pres:he,utils:nl,Collection:ld,Model:Ac,Promise,Strophe:me,URI:i(),dayjs:pl(),html:Kd,log:z,sizzle:ec(),sprintf:o.sprintf,u:nl}});const xu=Su.env.utils;function Eu(e,t){bu.send(de({to:e.getAttribute("from"),type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("not-allowed",{xmlns:"urn:ietf:params:xml:ns:xmpp-stanzas"}).up().c("text",{xmlns:"urn:ietf:params:xml:ns:xmpp-stanzas"}).t(t)),z.warn(`Rejecting message stanza with the following reason: ${t}`),z.warn(e)}function Au(e,t,n,s){const i=de({from:ul.connection.jid,id:xu.getUniqueId(),to:e,type:s||"chat"}).c(n,{xmlns:me.NS.MARKERS,id:t});bu.send(i)}const{u:Cu}=Su.env;function ku(e){const t=ju(e),{protocol:n}=window.location;return!!["chrome-extension:","file:"].includes(n)||("http:"===n||"https:"===n&&["https","aesgcm"].includes(t.protocol().toLowerCase()))}function ju(e){try{return e instanceof i()?e:new(i())(e)}catch(e){return z.debug(e),null}}function Tu(e,t){const n=ju(t);if(null===n)throw new Error(`checkFileTypes: could not parse url ${t}`);const s=n.filename().toLowerCase();return!!e.filter((e=>s.endsWith(e))).length}function $u(e,t){const n=ju(t),s=n.subdomain(),i=n.domain(),o=`${s?`${s}.`:""}${i}`;return e.includes(i)||e.includes(o)}function Nu(e,t){if(!ku(e))return!1;const n=bu.settings.get("render_media"),s=Iu(e,`allowed_${t}_domains`);return Array.isArray(n)?s&&$u(n,e):s&&n}function Ou(e){const t=bu.settings.get("filter_url_query_params");if(!t)return e;return ju(e).removeQuery(t).toString()}function Iu(e,t){const n=bu.settings.get(t);if(!Array.isArray(n))return!0;try{return $u(n,e)}catch(e){return z.debug(e),!1}}function Mu(e){return e.is_audio&&Iu(e.url,"allowed_audio_domains")||e.is_video&&Iu(e.url,"allowed_video_domains")||e.is_image&&Iu(e.url,"allowed_image_domains")}function Ru(e){return Tu([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".svg"],e)}function Du(e){return Tu([".gif"],e)}function zu(e){return Tu([".ogg",".mp3",".m4a"],e)}function Lu(e){return Tu([".mp4",".webm"],e)}function Pu(e){const t=bu.settings.get("image_urls_regex");return(null==t?void 0:t.test(e))||Ru(e)}function Fu(e){return e.startsWith("aesgcm://")}Object.assign(Cu,{isAudioURL:zu,isGIFURL:Du,isVideoURL:Lu,isImageURL:Pu,isURLWithImageExtension:Ru,checkFileTypes:Tu,getURI:ju,shouldRenderMediaFromURL:Nu,isAllowedProtocolForMedia:ku});const{NS:Uu}=me;class Bu extends Error{constructor(e,t){super(e,t),this.name="StanzaParseError",this.stanza=t}}function qu(e,t){const n={},s=ec()(`stanza-id[xmlns="${me.NS.SID}"]`,e).reduce(((e,t)=>(e[`stanza_id ${t.getAttribute("by")}`]=t.getAttribute("id"),e)),{});Object.assign(n,s);const i=ec()(`message > result[xmlns="${me.NS.MAM}"]`,t).pop();if(i){n[`stanza_id ${t.getAttribute("from")||ul.bare_jid}`]=i.getAttribute("id")}const o=ec()(`origin-id[xmlns="${me.NS.SID}"]`,e).pop();return o&&(n.origin_id=o.getAttribute("id")),n}function Hu(e){const t=ec()(`encryption[xmlns="${me.NS.EME}"]`,e).pop(),n=null==t?void 0:t.getAttribute("namespace"),s={};return n?(s.is_encrypted=!0,s.encryption_namespace=n):ec()(`encrypted[xmlns="${me.NS.OMEMO}"]`,e).pop()&&(s.is_encrypted=!0,s.encryption_namespace=me.NS.OMEMO),s}function Gu(e,t){const n=ec()(`> apply-to[xmlns="${me.NS.FASTEN}"]`,e).pop();if(n){const e=n.getAttribute("id");if(ec()(`> retract[xmlns="${me.NS.RETRACT}"]`,n).pop()){const n=ec()(`delay[xmlns="${me.NS.DELAY}"]`,t).pop();return{editable:!1,retracted:n?pl()(n.getAttribute("stamp")).toISOString():(new Date).toISOString(),retracted_id:e}}}else{const t=ec()(`> retracted[xmlns="${me.NS.RETRACT}"]`,e).pop();if(t)return{editable:!1,is_tombstone:!0,retracted:t.getAttribute("stamp")}}return{}}function Wu(e,t){const n=ec()(`replace[xmlns="${me.NS.MESSAGE_CORRECT}"]`,e).pop();if(n){const e=n.getAttribute("id");if(e){const n=ec()(`delay[xmlns="${me.NS.DELAY}"]`,t).pop();return{replace_id:e,edited:n?pl()(n.getAttribute("stamp")).toISOString():(new Date).toISOString()}}}return{}}function Vu(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=[];if(!e)return{};try{i().withinString(e,((e,s,i)=>(e.startsWith("_")&&(e=e.slice(1),s+=1),e.endsWith("_")&&(e=e.slice(0,e.length-1),i-=1),n.push({url:e,start:s+t,end:i+t}),e)),ye)}catch(e){z.debug(e)}const s=n.map((e=>({end:e.end,is_audio:zu(e.url),is_image:Pu(e.url),is_video:Lu(e.url),is_encrypted:Fu(e.url),start:e.start})));return s.length?{media_urls:s}:{}}function Ju(e){const t=ec()(`spoiler[xmlns="${me.NS.SPOILER}"]`,e).pop();return{is_spoiler:!!t,spoiler_hint:null==t?void 0:t.textContent}}function Qu(e){const t=ec()(`x[xmlns="${me.NS.OUTOFBAND}"]`,e).pop();var n,s;return t?{oob_url:null===(n=t.querySelector("url"))||void 0===n?void 0:n.textContent,oob_desc:null===(s=t.querySelector("desc"))||void 0===s?void 0:s.textContent}:{}}function Zu(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error"),n=ec()(`text[xmlns="${me.NS.STANZAS}"]`,t).pop();return{is_error:!0,error_text:null==n?void 0:n.textContent,error_type:t.getAttribute("type"),error_condition:t.firstElementChild.nodeName}}return{}}function Ku(e){return ec()(`reference[xmlns="${me.NS.REFERENCE}"]`,e).map((t=>{var n;const s=t.getAttribute("anchor"),i=null===(n=e.querySelector(s?`#${s}`:"body"))||void 0===n?void 0:n.textContent;if(!i)return z.warn(`Could not find referenced text for ${t}`),null;const o=t.getAttribute("begin"),r=t.getAttribute("end");return{begin:o,end:r,type:t.getAttribute("type"),value:i.slice(o,r),uri:t.getAttribute("uri")}})).filter((e=>e))}function Yu(e){const t=ec()(`received[xmlns="${me.NS.RECEIPTS}"]`,e).pop();return null==t?void 0:t.getAttribute("id")}function Xu(e){const t=me.NS.CARBONS;return ec()(`message > received[xmlns="${t}"]`,e).length>0||ec()(`message > sent[xmlns="${t}"]`,e).length>0}function eh(e){var t;return null===(t=ec()(`\n composing[xmlns="${Uu.CHATSTATES}"],\n paused[xmlns="${Uu.CHATSTATES}"],\n inactive[xmlns="${Uu.CHATSTATES}"],\n active[xmlns="${Uu.CHATSTATES}"],\n gone[xmlns="${Uu.CHATSTATES}"]`,e).pop())||void 0===t?void 0:t.nodeName}function th(e,t){return"me"!==t.sender&&!t.is_carbon&&!t.is_archived&&ec()(`request[xmlns="${me.NS.RECEIPTS}"]`,e).length}function nh(e){if(ec()(`message > forwarded[xmlns="${me.NS.FORWARD}"]`,e).length){Eu(e,"Forwarded messages not part of an encapsulating protocol are not supported");const t=e.getAttribute("from");throw new Bu(`Ignoring unencapsulated forwarded message from ${t}`,e)}}function sh(e){return ec()(`\n acknowledged[xmlns="${me.NS.MARKERS}"],\n displayed[xmlns="${me.NS.MARKERS}"],\n received[xmlns="${me.NS.MARKERS}"]`,e).pop()}function ih(e){return"headline"===e.getAttribute("type")}function oh(e){if(ec()(`mentions[xmlns="${me.NS.MENTIONS}"]`,e).pop())return!1;const t=e.getAttribute("from");return!("error"===e.getAttribute("type")||!t||t.includes("@"))}function rh(e){return!!ec()(`message > result[xmlns="${me.NS.MAM}"]`,e).pop()}function ah(e){return e.getAttributeNames().reduce(((t,n)=>(t[n]=me.xmlunescape(e.getAttribute(n)),t)),{})}const{Strophe:ch}=Su.env;let lh,dh;ch.addNamespace("ADHOC","http://jabber.org/protocol/commands");const uh={adhoc:{async getCommands(e){let t=[];try{n=await dh.disco.items(e,ch.NS.ADHOC),t=ec()(`query[xmlns="${ch.NS.DISCO_ITEMS}"][node="${ch.NS.ADHOC}"] item`,n).map(ah)}catch(t){null===t?z.error(`Error: timeout while fetching ad-hoc commands for ${e}`):(z.error(`Error while fetching ad-hoc commands for ${e}`),z.error(t))}var n;return t}}};Su.plugins.add("converse-adhoc",{dependencies:["converse-disco"],initialize(){lh=this._converse,dh=lh.api,Object.assign(dh,uh)}});const hh=Ac.extend({initialize(){this.rosterContactAdded=ba()},async setRosterContact(e){const t=await bu.contacts.get(e);t&&(this.contact=t,this.set("nickname",t.get("nickname")),this.rosterContactAdded.resolve())}}),mh=hh;var gh=n(6755),fh=n.n(gh);const ph=function(e,t){return e===t||ms(e,t,fs(t))},{u:vh}=Su.env;function _h(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return e.map((e=>{const s=e.start-n,i=e.end-n;return s<0||s>=t.length?null:Object.assign({},e,{start:s,end:i,url:t.substring(e.start-n,e.end-n)})})).filter((e=>e))}const yh=jc((function(e){const t=bu.settings.get("prune_messages_above");if(t&&"number"==typeof t&&e.messages.length>t){const n=e.messages.filter((e=>!vh.isEmptyMessage(e)));if(n.length>t){for(;n.length>t;)n.shift().destroy();bu.trigger("historyPruned",e)}}}),500),{Strophe:bh,sizzle:wh}=Su.env;async function Sh(e){var t,n,s,i,o,r;nh(e);let a=e.getAttribute("to");const c=bh.getResourceFromJid(a);if(bu.settings.get("filter_by_resource")&&c&&c!==ul.resource)return new Bu(`Ignoring incoming message intended for a different resource: ${a}`,e);const l=e;let d=e.getAttribute("from")||ul.bare_jid;if(Xu(e)){if(d!==ul.bare_jid)return Eu(e,"Rejecting carbon from invalid JID"),new Bu(`Rejecting carbon from invalid JID ${a}`,e);{const t=`[xmlns="${bh.NS.CARBONS}"] > forwarded[xmlns="${bh.NS.FORWARD}"] > message`;a=(e=wh(t,e).pop()).getAttribute("to"),d=e.getAttribute("from")}}const u=rh(e);if(u){if(d!==ul.bare_jid)return new Bu(`Invalid Stanza: alleged MAM message from ${e.getAttribute("from")}`,e);{const t=`[xmlns="${bh.NS.MAM}"] > forwarded[xmlns="${bh.NS.FORWARD}"] > message`;a=(e=wh(t,e).pop()).getAttribute("to"),d=e.getAttribute("from")}}const h=bh.getBareJidFromJid(d),m=h===ul.bare_jid;if(m&&null===a)return new Bu(`Don't know how to handle message stanza without 'to' attribute. ${e.outerHTML}`,e);const g=ih(e),f=oh(e);let p,v;if(!g&&!f&&(v=m?bh.getBareJidFromJid(a):h,p=await bu.contacts.get(v),void 0===p&&!bu.settings.get("allow_non_roster_messaging")))return z.error(e),new Bu("Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.",e);const _=wh(`delay[xmlns="${bh.NS.DELAY}"]`,l).pop(),y=sh(e),b=(new Date).toISOString();let w=Object.assign({contact_jid:v,is_archived:u,is_headline:g,is_server_message:f,body:null===(t=e.querySelector("body"))||void 0===t||null===(n=t.textContent)||void 0===n?void 0:n.trim(),chat_state:eh(e),from:bh.getBareJidFromJid(e.getAttribute("from")),is_carbon:Xu(l),is_delayed:!!_,is_markable:!!wh(`markable[xmlns="${bh.NS.MARKERS}"]`,e).length,is_marker:!!y,is_unstyled:!!wh(`unstyled[xmlns="${bh.NS.STYLING}"]`,e).length,marker_id:y&&y.getAttribute("id"),msgid:e.getAttribute("id")||l.getAttribute("id"),nick:null===(s=p)||void 0===s||null===(i=s.attributes)||void 0===i?void 0:i.nickname,receipt_id:Yu(e),received:(new Date).toISOString(),references:Ku(e),sender:m?"me":"them",subject:null===(o=e.querySelector("subject"))||void 0===o?void 0:o.textContent,thread:null===(r=e.querySelector("thread"))||void 0===r?void 0:r.textContent,time:_?pl()(_.getAttribute("stamp")).toISOString():b,to:e.getAttribute("to"),type:e.getAttribute("type")},Zu(e),Qu(e),Ju(e),Wu(e,l),qu(e,l),Gu(e,l),Hu(e));if(w.is_archived){const t=l.getAttribute("from");if(t&&t!==ul.bare_jid)return new Bu(`Invalid Stanza: Forged MAM message from ${t}`,e)}return await bu.emojis.initialize(),w=Object.assign({message:w.body||w.error,is_only_emojis:!!w.body&&nl.isOnlyEmojis(w.body),is_valid_receipt_request:th(e,w)},w),w.id=w.origin_id||w[`stanza_id ${w.from}`]||nl.getUniqueId(),w=await bu.hook("parseMessage",e,w),Object.assign(w,Vu(w.is_encrypted?w.plaintext:w.body))}const{Strophe:xh,$msg:Eh}=Su.env,Ah=Su.env.utils,Ch=mh.extend({defaults(){return{bookmarked:!1,chat_state:void 0,hidden:Hc()&&!bu.settings.get("singleton"),message_type:"chat",nickname:void 0,num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),time_sent:new Date(0).toISOString(),type:ul.PRIVATE_CHAT_TYPE,url:""}},async initialize(){this.initialized=ba(),mh.prototype.initialize.apply(this,arguments);const e=this.get("jid");e&&(this.set({box_id:`box-${e}`}),this.initNotifications(),this.initUI(),this.initMessages(),this.get("type")===ul.PRIVATE_CHAT_TYPE&&(this.presence=ul.presences.get(e)||ul.presences.create({jid:e}),await this.setRosterContact(e),this.presence.on("change:show",(e=>this.onPresenceChanged(e)))),this.on("change:chat_state",this.sendChatState,this),this.ui.on("change:scrolled",this.onScrolledChanged,this),await this.fetchMessages(),await bu.trigger("chatBoxInitialized",this,{Synchronous:!0}),this.initialized.resolve())},getMessagesCollection:()=>new ul.Messages,getMessagesCacheKey(){return`converse.messages-${this.get("jid")}-${ul.bare_jid}`},initMessages(){this.messages=this.getMessagesCollection(),this.messages.fetched=ba(),this.messages.fetched.then((()=>{this.pruneHistoryWhenScrolledDown(),bu.trigger("afterMessagesFetched",this)})),this.messages.chatbox=this,La(this.messages,this.getMessagesCacheKey()),this.listenTo(this.messages,"change:upload",this.onMessageUploadChanged,this),this.listenTo(this.messages,"add",this.onMessageAdded,this)},initUI(){this.ui=new Ac},initNotifications(){this.notifications=new Ac},getNotificationsText(){var e,t,n;const{__:s}=ul;return(null===(e=this.notifications)||void 0===e?void 0:e.get("chat_state"))===ul.COMPOSING?s("%1$s is typing",this.getDisplayName()):(null===(t=this.notifications)||void 0===t?void 0:t.get("chat_state"))===ul.PAUSED?s("%1$s has stopped typing",this.getDisplayName()):(null===(n=this.notifications)||void 0===n?void 0:n.get("chat_state"))===ul.GONE?s("%1$s has gone away",this.getDisplayName()):""},afterMessagesFetched(){bu.trigger("afterMessagesFetched",this)},fetchMessages(){if(this.messages.fetched_flag)return void z.info(`Not re-fetching messages for ${this.get("jid")}`);this.messages.fetched_flag=!0;const e=this.messages.fetched.resolve;return this.messages.fetch({add:!0,success:t=>{this.afterMessagesFetched(t),e()},error:()=>{this.afterMessagesFetched(),e()}}),this.messages.fetched},async handleErrorMessageStanza(e){const{__:t}=ul,n=await Sh(e);if(!await this.shouldShowErrorMessage(n))return;const s=this.getMessageReferencedByError(n);if(s){const e={error:n.error,error_condition:n.error_condition,error_text:n.error_text,error_type:n.error_type,editable:!1};n.msgid===s.get("retraction_id")?(e.retraction_id=void 0,n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to retract your message."):e.error=t("Sorry, an error occurred while trying to retract your message."))):n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to send a message."):e.error=t("Sorry, an error occurred while trying to send your message.")),s.save(e)}else this.createMessage(n)},queueMessage(e){return this.msg_chain=(this.msg_chain||this.messages.fetched).then((()=>this.onMessage(e))).catch((e=>z.error(e))),this.msg_chain},async onMessage(e){if(e=await e,Ah.isErrorObject(e))return e.stanza&&z.error(e.stanza),z.error(e.message);const t=this.getDuplicateMessage(e);if(t)this.updateMessage(t,e);else if(!this.handleReceipt(e)&&!this.handleChatMarker(e)&&!await this.handleRetraction(e)&&(this.setEditable(e,e.time),e.chat_state&&"them"===e.sender&&this.notifications.set("chat_state",e.chat_state),Ah.shouldCreateMessage(e))){const t=this.handleCorrection(e)||await this.createMessage(e);this.notifications.set({chat_state:null}),this.handleUnreadMessage(t)}},async onMessageUploadChanged(e){if(e.get("upload")===ul.SUCCESS){const t={body:e.get("body"),spoiler_hint:e.get("spoiler_hint"),oob_url:e.get("oob_url")};await this.sendMessage(t),e.destroy()}},onMessageAdded(e){!bu.settings.get("prune_messages_above")||"scrolled"!==bu.settings.get("pruning_behavior")&&this.ui.get("scrolled")||Ah.isEmptyMessage(e)||yh(this)},async clearMessages(){try{await this.messages.clearStore()}catch(e){this.messages.trigger("reset"),z.error(e)}finally{this.messages.fetched.resolve()}},async close(){bu.connection.connected()&&(this.setChatState(ul.INACTIVE),this.sendChatState());try{await new Promise(((e,t)=>this.destroy({success:e,error:(e,n)=>t(n)})))}catch(e){z.error(e)}finally{bu.settings.get("clear_messages_on_reconnection")&&await this.clearMessages()}bu.trigger("chatBoxClosed",this)},announceReconnection(){bu.trigger("chatReconnected",this)},async onReconnection(){bu.settings.get("clear_messages_on_reconnection")&&await this.clearMessages(),this.announceReconnection()},onPresenceChanged(e){const{__:t}=ul,n=e.get("show"),s=this.getDisplayName();let i;"offline"===n?i=t("%1$s has gone offline",s):"away"===n?i=t("%1$s has gone away",s):"dnd"===n?i=t("%1$s is busy",s):"online"===n&&(i=t("%1$s is online",s)),i&&this.createMessage({message:i,type:"info"})},onScrolledChanged(){this.ui.get("scrolled")||(this.clearUnreadMsgCounter(),this.pruneHistoryWhenScrolledDown())},pruneHistoryWhenScrolledDown(){bu.settings.get("prune_messages_above")&&"unscrolled"===bu.settings.get("pruning_behavior")&&!this.ui.get("scrolled")&&yh(this)},validate(e){if(!e.jid)return"Ignored ChatBox without JID";const t=bu.settings.get("auto_join_rooms").map((e=>we(e)?e.jid:e)),n=bu.settings.get("auto_join_private_chats").concat(t);if(bu.settings.get("singleton")&&!n.includes(e.jid)&&!bu.settings.get("auto_join_on_invite")){const t=`${e.jid} is not allowed because singleton is true and it's not being auto_joined`;return z.warn(t),t}},getDisplayName(){return this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("jid")},async createMessageFromError(e){if(e instanceof ul.TimeoutError){(await this.createMessage({type:"error",message:e.message,retry_event_id:e.retry_event_id,is_ephemeral:3e4})).error=e}},editEarlierMessage(){let e,t=this.messages.findLastIndex("correcting");if(t>=0)for(this.messages.at(t).save("correcting",!1);t>0;){t-=1;const n=this.messages.at(t);if(n.get("editable")){e=n;break}}e=e||this.messages.filter({sender:"me"}).reverse().find((e=>e.get("editable"))),e&&e.save("correcting",!0)},editLaterMessage(){let e,t=this.messages.findLastIndex("correcting");if(t>=0)for(this.messages.at(t).save("correcting",!1);t=0;e--){const t=this.messages.at(e);if(t.get("type")===this.get("message_type"))return t}},getUpdatedMessageAttributes:(e,t)=>t.error_type||"Decryption"!==e.get("error_type")?{is_archived:t.is_archived}:Object.assign({},t,{error_condition:void 0,error_message:void 0,error_text:void 0,error_type:void 0,is_archived:t.is_archived,is_ephemeral:!1,is_error:!1}),updateMessage(e,t){const n=this.getUpdatedMessageAttributes(e,t);n&&e.save(n)},setChatState(e,t){return void 0!==this.chat_state_timeout&&(window.clearTimeout(this.chat_state_timeout),delete this.chat_state_timeout),e===ul.COMPOSING?this.chat_state_timeout=window.setTimeout(this.setChatState.bind(this),ul.TIMEOUTS.PAUSED,ul.PAUSED):e===ul.PAUSED&&(this.chat_state_timeout=window.setTimeout(this.setChatState.bind(this),ul.TIMEOUTS.INACTIVE,ul.INACTIVE)),this.set("chat_state",e,t),this},getMessageReferencedByError(e){const t=e.msgid;return t&&this.messages.models.find((e=>[e.get("msgid"),e.get("retraction_id")].includes(t)))},shouldShowErrorMessage(e){if(this.getMessageReferencedByError(e)||!e.chat_state)return!0},isSameUser:(e,t)=>Ah.isSameBareJID(e,t),findDanglingRetraction(e){if(!e.origin_id||!this.messages.length)return null;if(this.messages.last().get("time")>e.time){const t=Array.from(this.messages.models);return t.reverse(),t.find((t=>{let{attributes:n}=t;return n.retracted_id===e.origin_id&&n.from===e.from&&!n.moderated_by}))}},async handleRetraction(e){const t=["retracted","retracted_id","editable"];if(e.retracted){if(e.is_tombstone)return!1;const n=this.messages.findWhere({origin_id:e.retracted_id,from:e.from});return n?(n.save(Ja(e,t)),!0):(e.dangling_retraction=!0,await this.createMessage(e),!0)}{const n=this.findDanglingRetraction(e);if(n){const s=Ja(n.attributes,t),i=Object.assign({dangling_retraction:!1},e,s);return delete i.id,n.save(i),!0}}return!1},handleCorrection(e){if(!e.replace_id||!e.from)return;const t=this.messages.findWhere({msgid:e.replace_id,from:e.from});if(!t)return;const n=t.get("older_versions")||{};return e.timee));return this.messages.models.find((e=>t.reduce(((t,n)=>t||ph(e.attributes,n)),!1)))},getOriginIdQueryAttrs:e=>e.origin_id&&{origin_id:e.origin_id,from:e.from},getStanzaIdQueryAttrs(e){const t=Object.keys(e).filter((e=>e.startsWith("stanza_id ")));return t.map((t=>{const n={};return n[`stanza_id ${t.replace(/^stanza_id /,"")}`]=e[t],n}))},getMessageBodyQueryAttrs(e){if(e.msgid){const t={from:e.from,msgid:e.msgid};return!e.is_encrypted&&e.body&&(t.body=e.body),t}},retractOwnMessage(e){this.sendRetractionMessage(e),e.save({retracted:(new Date).toISOString(),retracted_id:e.get("origin_id"),retraction_id:e.get("id"),is_ephemeral:!0,editable:!1})},sendRetractionMessage(e){const t=e.get("origin_id");if(!t)throw new Error("Can't retract message without a XEP-0359 Origin ID");const n=Eh({id:Ah.getUniqueId(),to:this.get("jid"),type:"chat"}).c("store",{xmlns:xh.NS.HINTS}).up().c("apply-to",{id:t,xmlns:xh.NS.FASTEN}).c("retract",{xmlns:xh.NS.RETRACT});return ul.connection.send(n)},sendMarkerForLastMessage(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"displayed",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=Array.from(this.messages.models);n.reverse();const s=n.find((e=>"them"===e.get("sender")&&(t||e.get("is_markable"))));s&&this.sendMarkerForMessage(s,e,t)},sendMarkerForMessage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"displayed",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e&&bu.settings.get("send_chat_markers").includes(t)&&(null!=e&&e.get("is_markable")||n)){Au(xh.getBareJidFromJid(e.get("from")),e.get("msgid"),t,e.get("type"))}},handleChatMarker(e){if(xh.getBareJidFromJid(e.to)!==ul.bare_jid)return!1;if(e.is_markable)return!this.contact||e.is_archived||e.is_carbon||Au(e.from,e.msgid,"received"),!1;if(e.marker_id){const t=this.messages.findWhere({msgid:e.marker_id}),n=`marker_${e.marker}`;return t&&!t.get(n)&&t.save({field_name:(new Date).toISOString()}),!0}},sendReceiptStanza(e,t){const n=Eh({from:ul.connection.jid,id:Ah.getUniqueId(),to:e,type:"chat"}).c("received",{xmlns:xh.NS.RECEIPTS,id:t}).up().c("store",{xmlns:xh.NS.HINTS}).up();bu.send(n)},handleReceipt(e){if("them"===e.sender)if(e.is_valid_receipt_request)this.sendReceiptStanza(e.from,e.msgid);else if(e.receipt_id){const t=this.messages.findWhere({msgid:e.receipt_id});return t&&!t.get("received")&&t.save({received:(new Date).toISOString()}),!0}return!1},async createMessageStanza(e){const t=Eh({from:ul.connection.jid,to:this.get("jid"),type:this.get("message_type"),id:e.get("edited")&&Ah.getUniqueId()||e.get("msgid")}).c("body").t(e.get("body")).up().c(ul.ACTIVE,{xmlns:xh.NS.CHATSTATES}).root();"chat"===e.get("type")&&t.c("request",{xmlns:xh.NS.RECEIPTS}).root(),e.get("is_encrypted")||(e.get("is_spoiler")&&(e.get("spoiler_hint")?t.c("spoiler",{xmlns:xh.NS.SPOILER},e.get("spoiler_hint")).root():t.c("spoiler",{xmlns:xh.NS.SPOILER}).root()),(e.get("references")||[]).forEach((e=>{const n={xmlns:xh.NS.REFERENCE,begin:e.begin,end:e.end,type:e.type};e.uri&&(n.uri=e.uri),t.c("reference",n).root()})),e.get("oob_url")&&t.c("x",{xmlns:xh.NS.OUTOFBAND}).c("url").t(e.get("oob_url")).root()),e.get("edited")&&t.c("replace",{xmlns:xh.NS.MESSAGE_CORRECT,id:e.get("msgid")}).root(),e.get("origin_id")&&t.c("origin-id",{xmlns:xh.NS.SID,id:e.get("origin_id")}).root(),t.root();return(await bu.hook("createMessageStanza",this,{message:e,stanza:t})).stanza},async getOutgoingMessageAttributes(e){var t;const n=!!this.get("composing_spoiler"),s=Ah.getUniqueId(),i=null===(t=e)||void 0===t?void 0:t.body,o=i?Ah.httpToGeoUri(Ah.shortnamesToUnicode(i),ul):void 0;return e=Object.assign({},e,{from:ul.bare_jid,fullname:ul.xmppstatus.get("fullname"),id:s,is_only_emojis:!!i&&Ah.isOnlyEmojis(i),jid:this.get("jid"),message:o,msgid:s,nickname:this.get("nickname"),sender:"me",time:(new Date).toISOString(),type:this.get("message_type"),body:o,is_spoiler:n,origin_id:s},Vu(i)),e=await bu.hook("getOutgoingMessageAttributes",this,e)},setEditable(e,t){if(!e.is_headline&&!Ah.isEmptyMessage(e)&&"me"===e.sender)if("all"===bu.settings.get("allow_message_corrections"))e.editable=!(e.file||e.retracted||"oob_url"in e);else if("last"===bu.settings.get("allow_message_corrections")&&t>this.get("time_sent")){this.set({time_sent:t});const n=this.messages.findWhere({editable:!0});n&&n.save({editable:!1}),e.editable=!(e.file||e.retracted||"oob_url"in e)}},async createMessage(e,t){return e.time=e.time||(new Date).toISOString(),await this.messages.fetched,this.messages.create(e,t)},async sendMessage(e){e=await this.getOutgoingMessageAttributes(e);let t=this.messages.findWhere("correcting");if(t){const n=t.get("older_versions")||{};n[t.get("edited")||t.get("time")]=t.getMessageText();const s=e.is_encrypted?e.message:void 0;t.save({body:e.body,message:e.body,correcting:!1,edited:(new Date).toISOString(),is_only_emojis:e.is_only_emojis,origin_id:Ah.getUniqueId(),received:void 0,references:e.references,older_versions:n,plaintext:s})}else this.setEditable(e,(new Date).toISOString()),t=await this.createMessage(e);try{const e=await this.createMessageStanza(t);bu.send(e)}catch(e){return t.destroy(),void z.error(e)}return bu.trigger("sendMessage",{chatbox:this,message:t}),t},sendChatState(){if(bu.settings.get("send_chat_state_notifications")&&this.get("chat_state")){const e=bu.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;bu.send(Eh({id:Ah.getUniqueId(),to:this.get("jid"),type:"chat"}).c(this.get("chat_state"),{xmlns:xh.NS.CHATSTATES}).up().c("no-store",{xmlns:xh.NS.HINTS}).up().c("no-permanent-store",{xmlns:xh.NS.HINTS}))}},async sendFiles(e){var t;const{__:n}=ul,s=(await bu.disco.features.get(xh.NS.HTTPUPLOAD,ul.domain)).pop();if(!s)return void this.createMessage({message:n("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0});const i=s.dataforms.where({FORM_TYPE:{value:xh.NS.HTTPUPLOAD,type:"hidden"}}).pop(),o=window.parseInt(null===(t=((null==i?void 0:i.attributes)||{})["max-file-size"])||void 0===t?void 0:t.value),r=null==s?void 0:s.id;r?Array.from(e).forEach((async e=>{if(e=await bu.hook("beforeFileUpload",this,e),!window.isNaN(o)&&window.parseInt(e.size)>o)return this.createMessage({message:n("The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.",e.name,fh()(o)),type:"error",is_ephemeral:!0});{const t=await this.getOutgoingMessageAttributes(),n=Object.assign(t,{file:!0,progress:0,slot_request_url:r});this.setEditable(n,(new Date).toISOString());const s=await this.createMessage(n,{silent:!0});s.file=e,this.messages.trigger("add",s),s.getRequestSlotURL()}})):this.createMessage({message:n("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0})},maybeShow(e){if(!Hc())return Ah.safeSave(this,{hidden:!1}),this.trigger("show"),this;{const t=e=>!e.get("hidden")&&e.get("jid")!==this.get("jid")&&"controlbox"!==e.get("id"),n=ul.chatboxes.filter(t);(e||0===n.length)&&(n.forEach((e=>Ah.safeSave(e,{hidden:!0}))),Ah.safeSave(this,{hidden:!1}))}},isHidden(){return this.get("hidden")||this.isScrolledUp()||"hidden"===ul.windowState},handleUnreadMessage(e){null!=e&&e.get("body")&&Ah.isNewMessage(e)&&("me"===e.get("sender")?this.ui.set("scrolled",!1):this.isHidden()?this.incrementUnreadMsgsCounter(e):this.sendMarkerForMessage(e))},incrementUnreadMsgsCounter(e){const t={num_unread:this.get("num_unread")+1};0===this.get("num_unread")&&(t.first_unread_id=e.get("id")),this.save(t)},clearUnreadMsgCounter(){this.get("num_unread")>0&&this.sendMarkerForMessage(this.messages.last()),Ah.safeSave(this,{num_unread:0})},isScrolledUp(){return this.ui.get("scrolled")}}),kh=Ch,{Strophe:jh,sizzle:Th,u:$h}=Su.env,Nh={defaults:()=>({msgid:$h.getUniqueId(),time:(new Date).toISOString(),is_ephemeral:!1}),async initialize(){this.checkValidity()&&(this.initialized=ba(),this.get("file")&&this.on("change:put",(()=>this.uploadFile())),this.on("change:type",(()=>this.setContact())),this.on("change:is_ephemeral",(()=>this.setTimerForEphemeralMessage())),await this.setContact(),this.setTimerForEphemeralMessage(),await bu.trigger("messageInitialized",this,{Synchronous:!0}),this.initialized.resolve())},setContact(){"chat"===this.get("type")&&(mh.prototype.initialize.apply(this,arguments),this.setRosterContact(jh.getBareJidFromJid(this.get("from"))))},setTimerForEphemeralMessage(){this.ephemeral_timer&&clearTimeout(this.ephemeral_timer);const e=this.isEphemeral();if(e){const t="number"==typeof e?e:1e4;this.ephemeral_timer=window.setTimeout((()=>this.safeDestroy()),t)}},checkValidity(){return 3!==Object.keys(this.attributes).length||(this.validationError="Empty message",this.safeDestroy(),!1)},mayBeRetracted(){const e="me"===this.get("sender"),t="cancel"!==this.get("error_type");return e&&t&&["all","own"].includes(bu.settings.get("allow_message_retraction"))},safeDestroy(){try{this.destroy()}catch(e){z.warn(`safeDestroy: ${e}`)}},isEphemeral(){return this.get("is_ephemeral")},isMeCommand(){const e=this.getMessageText();return!!e&&e.startsWith("/me ")},isFollowup(){const e=this.collection.models,t=e.indexOf(this),n=t?e[t-1]:null;if(null===n)return!1;const s=pl()(this.get("time"));return this.get("from")===n.get("from")&&!this.isMeCommand()&&!n.isMeCommand()&&"info"!==this.get("type")&&"info"!==n.get("type")&&s.isBefore(pl()(n.get("time")).add(10,"minutes"))&&!!this.get("is_encrypted")==!!n.get("is_encrypted")},getDisplayName(){return this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("from")},getMessageText(){if(this.get("is_encrypted")){const{__:e}=ul;return this.get("plaintext")||this.get("body")||e("Undecryptable OMEMO message")}return["groupchat","chat"].includes(this.get("type"))?this.get("body"):this.get("message")},sendSlotRequestStanza(){if(!this.file)return Promise.reject(new Error("file is undefined"));const e=Su.env.$iq({from:ul.jid,to:this.get("slot_request_url"),type:"get"}).c("request",{xmlns:jh.NS.HTTPUPLOAD,filename:this.file.name,size:this.file.size,"content-type":this.file.type});return bu.sendIQ(e)},getUploadRequestMetadata:e=>({headers:Th(`slot[xmlns="${jh.NS.HTTPUPLOAD}"] put header`,e).map((e=>({name:e.getAttribute("name"),value:e.textContent}))).filter((e=>["Authorization","Expires"].includes(e.name)))}),async getRequestSlotURL(){const{__:e}=ul;let t;try{t=await this.sendSlotRequestStanza()}catch(t){return z.error(t),this.save({type:"error",message:e("Sorry, could not determine upload URL."),is_ephemeral:!0})}const n=Th(`slot[xmlns="${jh.NS.HTTPUPLOAD}"]`,t).pop();if(!n)return this.save({type:"error",message:e("Sorry, could not determine file upload URL."),is_ephemeral:!0});this.upload_metadata=this.getUploadRequestMetadata(t),this.save({get:n.querySelector("get").getAttribute("url"),put:n.querySelector("put").getAttribute("url")})},uploadFile(){var e;const t=new XMLHttpRequest;t.onreadystatechange=async()=>{if(t.readyState===XMLHttpRequest.DONE)if(z.info("Status: "+t.status),200===t.status||201===t.status){let e={upload:ul.SUCCESS,oob_url:this.get("get"),message:this.get("get"),body:this.get("get")};e=await bu.hook("afterFileUploaded",this,e),this.save(e)}else t.onerror()},t.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.set("progress",e.loaded/e.total)}),!1),t.onerror=()=>{const{__:e}=ul;let n;n=t.responseText?e('Sorry, could not succesfully upload your file. Your server’s response: "%1$s"',t.responseText):e("Sorry, could not succesfully upload your file."),this.save({type:"error",upload:ul.FAILURE,message:n,is_ephemeral:!0})},t.open("PUT",this.get("put"),!0),t.setRequestHeader("Content-type",this.file.type),null===(e=this.upload_metadata.headers)||void 0===e||e.forEach((e=>t.setRequestHeader(e.name,e.value))),t.send(this.file)}},Oh=Nh,Ih={chats:{async create(e,t){if("string"==typeof e){if(t&&(null==t||!t.fullname)){var n;const s=await bu.contacts.get(e);t.fullname=null==s||null===(n=s.attributes)||void 0===n?void 0:n.fullname}const s=bu.chats.get(e,t,!0);return s||void z.error("Could not open chatbox for JID: "+e)}return Array.isArray(e)?Promise.all(e.forEach((async n=>{var s;const i=await bu.contacts.get(e);return t.fullname=null==i||null===(s=i.attributes)||void 0===s?void 0:s.fullname,bu.chats.get(n,t,!0).maybeShow()}))):(z.error("chats.create: You need to provide at least one JID"),null)},async open(e,t,n){if("string"==typeof e){const s=await bu.chats.get(e,t,!0);return s?s.maybeShow(n):s}if(Array.isArray(e))return Promise.all(e.map((e=>bu.chats.get(e,t,!0).then((e=>e&&e.maybeShow(n))))).filter((e=>e)));const s="chats.open: You need to provide at least one JID";throw z.error(s),new Error(s)},async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];async function s(e){let s=await bu.chatboxes.get(e);return!s&&n?s=await bu.chatboxes.create(e,t,ul.ChatBox):(s=s&&s.get("type")===ul.PRIVATE_CHAT_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}if(await bu.waitUntil("chatBoxesFetched"),void 0===e){return(await bu.chatboxes.get()).filter((e=>e.get("type")===ul.PRIVATE_CHAT_TYPE))}return"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}},{Strophe:Mh,sizzle:Rh,u:Dh}=Su.env;function zh(e){if(!Dh.isValidJID(e))return z.warn(`Invalid JID "${e}" provided in URL fragment`);bu.chats.open(e)}async function Lh(){if(ul.shouldClearCache()){await Promise.all(ul.chatboxes.map((e=>e.messages&&e.messages.clearStore({silent:!0}))));const e=e=>e.get("type")!==ul.CONTROLBOX_TYPE;ul.chatboxes.clearStore({silent:!0},e)}}function Ph(){bu.settings.get("auto_join_private_chats").forEach((e=>{ul.chatboxes.where({jid:e}).length||("string"==typeof e?bu.chats.open(e):z.error('Invalid jid criteria specified for "auto_join_private_chats"'))})),bu.trigger("privateChatsAutoJoined")}function Fh(){ul.connection.addHandler((e=>Rh(`message > result[xmlns="${Mh.NS.MAM}"]`,e).pop()?(z.warn('Received a MAM message with type "chat".'),!0):(ul.handleMessageStanza(e),!0)),null,"message","chat"),ul.connection.addHandler((e=>(null!==e.getAttribute("type")||ul.handleMessageStanza(e),!0)),Mh.NS.RECEIPTS,"message"),ul.connection.addHandler((e=>(async function(e){const t=Mh.getBareJidFromJid(e.getAttribute("from"));if(Dh.isSameBareJID(t,ul.bare_jid))return;const n=await bu.chatboxes.get(t);n.get("type")===ul.PRIVATE_CHAT_TYPE&&(null==n||n.handleErrorMessageStanza(e))}(e),!0)),null,"message","error")}async function Uh(e){if(oh(e)){const t=e.getAttribute("from");return z.info(`handleMessageStanza: Ignoring incoming server message from JID: ${t}`)}let t;try{t=await Sh(e)}catch(e){return z.error(e)}if(Dh.isErrorObject(t))return t.stanza&&z.error(t.stanza),z.error(t.message);const n=!(!t.body&&!t.plaintext),s=await bu.chats.get(t.contact_jid,{nickname:t.nick},n);await(null==s?void 0:s.queueMessage(t));const i={stanza:e,attrs:t,chatbox:s};bu.trigger("message",i)}Su.plugins.add("converse-chat",{dependencies:["converse-chatboxes","converse-disco"],initialize(){bu.settings.extend({allow_message_corrections:"all",allow_message_retraction:"all",allow_message_styling:!0,auto_join_private_chats:[],clear_messages_on_reconnection:!1,filter_by_resource:!1,prune_messages_above:void 0,pruning_behavior:"unscrolled",send_chat_markers:["received","displayed","acknowledged"],send_chat_state_notifications:!0}),ul.Message=mh.extend(Oh),ul.Messages=ld.extend({model:ul.Message,comparator:"time"}),Object.assign(ul,{ChatBox:kh,handleMessageStanza:Uh}),Object.assign(bu,Ih),ul.router.route("converse/chat?jid=:jid",zh),bu.listen.on("chatBoxesFetched",Ph),bu.listen.on("presencesInitialized",Fh),bu.listen.on("clearSession",Lh)}});const{Strophe:Bh}=Su.env,qh=Ac.extend({idAttribute:"jid",async initialize(e,t){this.waitUntilFeaturesDiscovered=ba(),this.dataforms=new ld;let n=`converse.dataforms-${this.get("jid")}`;this.dataforms.browserStorage=ul.createStore(n,"session"),this.features=new ld,n=`converse.features-${this.get("jid")}`,this.features.browserStorage=ul.createStore(n,"session"),this.listenTo(this.features,"add",this.onFeatureAdded),this.fields=new ld,n=`converse.fields-${this.get("jid")}`,this.fields.browserStorage=ul.createStore(n,"session"),this.listenTo(this.fields,"add",this.onFieldAdded),this.items=new ul.DiscoEntities,n=`converse.disco-items-${this.get("jid")}`,this.items.browserStorage=ul.createStore(n,"session"),await new Promise((e=>this.items.fetch({success:e,error:e}))),this.identities=new ld,n=`converse.identities-${this.get("jid")}`,this.identities.browserStorage=ul.createStore(n,"session"),this.fetchFeatures(t)},async getIdentity(e,t){return await this.waitUntilFeaturesDiscovered,this.identities.findWhere({category:e,type:t})},async hasFeature(e){if(await this.waitUntilFeaturesDiscovered,this.features.findWhere({var:e}))return this},onFeatureAdded(e){e.entity=this,bu.trigger("serviceDiscovered",e)},onFieldAdded(e){e.entity=this,bu.trigger("discoExtensionFieldDiscovered",e)},async fetchFeatures(e){if(e.ignore_cache)this.queryInfo();else{const e=this.features.browserStorage.name,t=await this.features.browserStorage.store.getItem(e);t&&0===t.length||null===t?this.queryInfo():(this.features.fetch({add:!0,success:()=>{this.waitUntilFeaturesDiscovered.resolve(this),this.trigger("featuresDiscovered")}}),this.identities.fetch({add:!0}))}},async queryInfo(){let e;try{e=await bu.disco.info(this.get("jid"),null)}catch(e){return null===e?z.error(`Timeout for disco#info query for ${this.get("jid")}`):z.error(e),void this.waitUntilFeaturesDiscovered.resolve(this)}this.onInfo(e)},onDiscoItems(e){ec()(`query[xmlns="${Bh.NS.DISCO_ITEMS}"] item`,e).forEach((e=>{if(e.getAttribute("node"))return;const t=e.getAttribute("jid");if(void 0===this.items.get(t)){const n=ul.disco_entities,s=n.get(t)||n.create({jid:t,name:e.getAttribute("name")});this.items.add(s)}}))},async queryForItems(){if(0===this.identities.where({category:"server"}).length)return;const e=await bu.disco.items(this.get("jid"));this.onDiscoItems(e)},onInfo(e){Array.from(e.querySelectorAll("identity")).forEach((e=>{this.identities.create({category:e.getAttribute("category"),type:e.getAttribute("type"),name:e.getAttribute("name")})})),ec()(`x[type="result"][xmlns="${Bh.NS.XFORM}"]`,e).forEach((e=>{const t={};ec()("field",e).forEach((e=>{var n;t[e.getAttribute("var")]={value:null===(n=e.querySelector("value"))||void 0===n?void 0:n.textContent,type:e.getAttribute("type")}})),this.dataforms.create(t)})),e.querySelector(`feature[var="${Bh.NS.DISCO_ITEMS}"]`)&&this.queryForItems(),Array.from(e.querySelectorAll("feature")).forEach((t=>{this.features.create({var:t.getAttribute("var"),from:e.getAttribute("from")})})),ec()('x[type="result"][xmlns="jabber:x:data"] field',e).forEach((t=>{var n;this.fields.create({var:t.getAttribute("var"),value:null===(n=t.querySelector("value"))||void 0===n?void 0:n.textContent,from:e.getAttribute("from")})})),this.waitUntilFeaturesDiscovered.resolve(this),this.trigger("featuresDiscovered")}}),Hh=qh,Gh=ld.extend({model:Hh,fetchEntities(){return new Promise(((e,t)=>{this.fetch({add:!0,success:e,error(e,n){z.error(n),t(new Error("Could not fetch disco entities"))}})}))}}),Wh=Gh,{Strophe:Vh,$iq:Jh}=Su.env;async function Qh(){bu.disco.own.identities.add("client","web","Converse"),bu.disco.own.features.add(Vh.NS.CHATSTATES),bu.disco.own.features.add(Vh.NS.DISCO_INFO),bu.disco.own.features.add(Vh.NS.ROSTERX),bu.settings.get("message_carbons")&&bu.disco.own.features.add(Vh.NS.CARBONS),bu.trigger("addClientFeatures"),ul.connection.addHandler((e=>function(e){const t=e.getElementsByTagName("query")[0].getAttribute("node"),n={xmlns:Vh.NS.DISCO_INFO};t&&(n.node=t);const s=Jh({type:"result",id:e.getAttribute("id")}),i=e.getAttribute("from");return null!==i&&s.attrs({to:i}),s.c("query",n),ul.disco._identities.forEach((e=>{const t={category:e.category,type:e.type};e.name&&(t.name=e.name),e.lang&&(t["xml:lang"]=e.lang),s.c("identity",t).up()})),ul.disco._features.forEach((e=>s.c("feature",{var:e}).up())),bu.send(s.tree()),!0}(e)),Vh.NS.DISCO_INFO,"iq","get",null,null),ul.disco_entities=new ul.DiscoEntities;const e=`converse.disco-entities-${ul.bare_jid}`;ul.disco_entities.browserStorage=ul.createStore(e,"session");const t=await ul.disco_entities.fetchEntities();0!==t.length&&t.get(ul.domain)||ul.disco_entities.create({jid:ul.domain}),bu.trigger("discoInitialized")}function Zh(){if(!ul.stream_features){const e=`converse.stream-features-${Vh.getBareJidFromJid(ul.jid)}`;bu.promises.add("streamFeaturesAdded"),ul.stream_features=new ld,ul.stream_features.browserStorage=ul.createStore(e,"session")}}function Kh(){bu.trigger("streamFeaturesAdded")}function Yh(){Zh(),Array.from(ul.connection.features.childNodes).forEach((e=>{ul.stream_features.create({name:e.nodeName,xmlns:e.getAttribute("xmlns")})})),Kh()}function Xh(){var e,t,n,s,i;null===(e=ul.disco_entities)||void 0===e||e.forEach((e=>e.features.clearStore())),null===(t=ul.disco_entities)||void 0===t||t.forEach((e=>e.identities.clearStore())),null===(n=ul.disco_entities)||void 0===n||n.forEach((e=>e.dataforms.clearStore())),null===(s=ul.disco_entities)||void 0===s||s.forEach((e=>e.fields.clearStore())),null===(i=ul.disco_entities)||void 0===i||i.clearStore(),delete ul.disco_entities}const{Strophe:em,$iq:tm}=Su.env,nm={disco:{stream:{async getFeature(e,t){if(await bu.waitUntil("streamFeaturesAdded"),!e||!t)throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature");if(void 0!==ul.stream_features||bu.connection.connected())return ul.stream_features.findWhere({name:e,xmlns:t});{const n=`Tried to get feature ${e} ${t} but _converse.stream_features has been torn down`;z.warn(n)}}},own:{identities:{add(e,t,n,s){for(var i=0;iul.disco._identities},features:{add(e){for(var t=0;tul.disco._features}},info(e,t){const n={xmlns:em.NS.DISCO_INFO};t&&(n.node=t);const s=tm({from:ul.connection.jid,to:e,type:"get"}).c("query",n);return bu.sendIQ(s)},items(e,t){const n={xmlns:em.NS.DISCO_ITEMS};return t&&(n.node=t),bu.sendIQ(tm({from:ul.connection.jid,to:e,type:"get"}).c("query",n))},entities:{async get(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(await bu.waitUntil("discoInitialized"),!e)return ul.disco_entities;if(void 0===ul.disco_entities){const t=`Tried to look up entity ${e} but _converse.disco_entities has been torn down`;return void z.warn(t)}const n=ul.disco_entities.get(e);return n||!t?n:bu.disco.entities.create(e)},create:(e,t)=>ul.disco_entities.create({jid:e},t)},features:{async get(e,t){if(!t)throw new TypeError("You need to provide an entity JID");await bu.waitUntil("discoInitialized");let n=await bu.disco.entities.get(t,!0);if(void 0===ul.disco_entities&&!bu.connection.connected()){const n=`Tried to get feature ${e} for ${t} but _converse.disco_entities has been torn down`;return void z.warn(n)}n=await n.waitUntilFeaturesDiscovered;const s=[...n.items.map((t=>t.hasFeature(e))),n.hasFeature(e)];return(await Promise.all(s)).filter(we)}},supports:async(e,t)=>(await bu.disco.features.get(e,t)||[]).length>0,async refresh(e){if(!e)throw new TypeError("api.disco.refresh: You need to provide an entity JID");await bu.waitUntil("discoInitialized");let t=await bu.disco.entities.get(e);return t?(t.features.reset(),t.fields.reset(),t.identities.reset(),t.waitUntilFeaturesDiscovered.isPending||(t.waitUntilFeaturesDiscovered=ba()),t.queryInfo()):t=await bu.disco.entities.create(e,{ignore_cache:!0}),t.waitUntilFeaturesDiscovered},refreshFeatures:e=>bu.refresh(e),async getFeatures(e){if(!e)throw new TypeError("api.disco.getFeatures: You need to provide an entity JID");await bu.waitUntil("discoInitialized");let t=await bu.disco.entities.get(e,!0);return t=await t.waitUntilFeaturesDiscovered,t.features},async getFields(e){if(!e)throw new TypeError("api.disco.getFields: You need to provide an entity JID");await bu.waitUntil("discoInitialized");let t=await bu.disco.entities.get(e,!0);return t=await t.waitUntilFeaturesDiscovered,t.fields},async getIdentity(e,t,n){const s=await bu.disco.entities.get(n,!0);if(void 0!==s||bu.connection.connected())return s.getIdentity(e,t);{const t=`Tried to look up category ${e} for ${n} but _converse.disco_entities has been torn down`;z.warn(t)}}}},{Strophe:sm}=Su.env;Su.plugins.add("converse-disco",{initialize(){Object.assign(bu,nm),bu.promises.add("discoInitialized"),bu.promises.add("streamFeaturesAdded"),ul.DiscoEntity=Hh,ul.DiscoEntities=Wh,ul.disco={_identities:[],_features:[]},bu.listen.on("userSessionInitialized",(async()=>{Zh(),ul.connfeedback.get("connection_status")===sm.Status.ATTACHED&&(await new Promise(((e,t)=>ul.stream_features.fetch({success:e,error:t}))),Kh())})),bu.listen.on("beforeResourceBinding",Yh),bu.listen.on("reconnected",Qh),bu.listen.on("connected",Qh),bu.listen.on("beforeTearDown",(async()=>{bu.promises.add("streamFeaturesAdded"),ul.stream_features&&(await ul.stream_features.clearStore(),delete ul.stream_features)})),bu.listen.on("will-reconnect",Xh),bu.listen.on("clearSession",Xh)}}),Su.emojis={initialized:!1,initialized_promise:ba()},Su.plugins.add("converse-emoji",{initialize(){const{___:e}=ul;bu.settings.extend({emoji_image_path:"https://twemoji.maxcdn.com/v/12.1.6/",emoji_categories:{smileys:":grinning:",people:":thumbsup:",activity:":soccer:",travel:":motorcycle:",objects:":bomb:",nature:":rainbow:",food:":hotdog:",symbols:":musical_note:",flags:":flag_ac:",custom:null},emoji_category_labels:{smileys:e("Smileys and emotions"),people:e("People"),activity:e("Activities"),travel:e("Travel"),objects:e("Objects"),nature:e("Animals and nature"),food:e("Food and drink"),symbols:e("Symbols"),flags:e("Flags"),custom:e("Stickers")}}),ul.EmojiPicker=Ac.extend({defaults:{current_category:"smileys",current_skintone:"",scroll_position:0}}),Object.assign(bu,{emojis:{async initialize(){if(!Su.emojis.initialized){Su.emojis.initialized=!0;const{default:e}=await n.e(4610).then(n.t.bind(n,5175,19));Su.emojis.json=e,Su.emojis.by_sn=Object.keys(e).reduce(((t,n)=>Object.assign(t,e[n])),{}),Su.emojis.list=Object.values(Su.emojis.by_sn),Su.emojis.list.sort(((e,t)=>e.snt.sn?1:0)),Su.emojis.shortnames=Su.emojis.list.map((e=>e.sn));const t=()=>Su.emojis.shortnames.map((e=>e.replace(/[+]/g,"\\$&"))).join("|");Su.emojis.shortnames_regex=new RegExp(t(),"gi"),Su.emojis.initialized_promise.resolve()}return Su.emojis.initialized_promise}}})}});const im={initialize(){this.checkValidity()&&(this.get("file")&&this.on("change:put",(()=>this.uploadFile())),this.on("change:type",(()=>this.setOccupant())),this.on("change:is_ephemeral",(()=>this.setTimerForEphemeralMessage())),this.setTimerForEphemeralMessage(),this.setOccupant(),bu.trigger("chatRoomMessageInitialized",this))},getDisplayName(){var e;return(null===(e=this.occupant)||void 0===e?void 0:e.getDisplayName())||this.get("nick")},mayBeModerated(){if(void 0!==this.get("from_muc"))return["all","moderator"].includes(bu.settings.get("allow_message_retraction"))&&this.get(`stanza_id ${this.get("from_muc")}`)&&this.collection.chatbox.canModerateMessages()},checkValidity(){const e=ul.Message.prototype.checkValidity.call(this);return!e&&this.collection.chatbox.debouncedRejoin(),e},onOccupantRemoved(){var e;this.stopListening(this.occupant),delete this.occupant;const t=null==this||null===(e=this.collection)||void 0===e?void 0:e.chatbox;if(!t)return z.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);this.listenTo(t.occupants,"add",this.onOccupantAdded)},onOccupantAdded(e){var t;if(this.get("occupant_id")){if(e.get("occupant_id")!==this.get("occupant_id"))return}else if(e.get("nick")!==me.getResourceFromJid(this.get("from")))return;const n=null==this||null===(t=this.collection)||void 0===t?void 0:t.chatbox;if(!n)return z.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);this.occupant=e,e.get("jid")&&this.save("from_real_jid",e.get("jid")),this.trigger("occupantAdded"),this.listenTo(this.occupant,"destroy",this.onOccupantRemoved),this.stopListening(n.occupants,"add",this.onOccupantAdded)},setOccupant(){var e;if("groupchat"!==this.get("type")||this.isEphemeral()||this.occupant)return;const t=null==this||null===(e=this.collection)||void 0===e?void 0:e.chatbox;if(!t)return z.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);const n=me.getResourceFromJid(this.get("from")),s=this.get("occupant_id");if(this.occupant=t.occupants.findOccupant({nick:n,occupant_id:s}),!this.occupant&&bu.settings.get("muc_send_probes")){this.occupant=t.occupants.create({nick:n,occupant_id:s,type:"unavailable"});const e=`${t.get("jid")}/${n}`;bu.user.presence.send("probe",e)}this.occupant?this.listenTo(this.occupant,"destroy",this.onOccupantRemoved):this.listenTo(t.occupants,"add",this.onOccupantAdded)}},om=im,rm={},am=(e,t)=>e.replace(RegExp("\\"+t,"ig"),"\\"+t);rm.escapeCharacters=e=>t=>e.split("").reduce(am,t),rm.escapeRegexString=rm.escapeCharacters("[\\^$.?*+(){}|"),rm.findFirstMatchInArray=e=>t=>{for(let n=0;n{let[s,i]=e,o=s,{begin:r,end:a}=t;const{value:c}=t;return r-=n,a=a-n-1,o=`${o.slice(0,r)}${c}${o.slice(a+1)}`,[o,[...i,{...t,begin:r,end:a}]]};rm.reduceTextFromReferences=(e,t)=>t.reduce(cm,[e,[]]);const lm=rm;nl.webForm2xForm=function(e){const t=e.getAttribute("name");if(!t)return null;let n;return n="checkbox"===e.getAttribute("type")?e.checked?1:0:"TEXTAREA"==e.tagName?e.value.split("\n").filter((e=>e.trim())):"SELECT"==e.tagName?nl.getSelectValues(e):e.value,nl.toStanza(`\n \n ${n.constructor===Array?n.map((e=>`${e}`)):`${n}`}\n `)};const dm=nl;const um=function(e,t,n){for(var s=-1,i=e.length,o=t.length,r={};++s{var i;const o=null===(i=t.querySelector("text"))||void 0===i?void 0:i.textContent;if(o){var r;const i=Ku(e),a=null===(r=t.querySelector("reason"))||void 0===r?void 0:r.textContent;return{from:n,msgid:s,message:o,reason:a,references:i,type:"mep"}}return{}}))}function _m(e,t){var n;if(t.features.get(mm.NS.OCCUPANTID))return null===(n=gm(`occupant-id[xmlns="${mm.NS.OCCUPANTID}"]`,e).pop())||void 0===n?void 0:n.getAttribute("id")}async function ym(e,t){var n,s,i,o,r;nh(e);const a=`[xmlns="${pm.MAM}"] > forwarded[xmlns="${pm.FORWARD}"] > message`,c=e;if(e=gm(a,e).pop()||e,gm(`message > forwarded[xmlns="${mm.NS.FORWARD}"]`,e).length)return new Bu(`Invalid Stanza: Forged MAM groupchat message from ${e.getAttribute("from")}`,e);const l=gm(`delay[xmlns="${mm.NS.DELAY}"]`,c).pop(),d=e.getAttribute("from"),u=mm.getBareJidFromJid(d),h=mm.unescapeNode(mm.getResourceFromJid(d)),m=sh(e),g=(new Date).toISOString();let f=Object.assign({from:d,from_muc:u,nick:h,is_forwarded:!!e.querySelector("forwarded"),activities:vm(e),body:null===(n=e.querySelector("body"))||void 0===n||null===(s=n.textContent)||void 0===s?void 0:s.trim(),chat_state:eh(e),is_archived:rh(c),is_carbon:Xu(c),is_delayed:!!l,is_headline:ih(e),is_markable:!!gm(`markable[xmlns="${mm.NS.MARKERS}"]`,e).length,is_marker:!!m,is_unstyled:!!gm(`unstyled[xmlns="${mm.NS.STYLING}"]`,e).length,marker_id:m&&m.getAttribute("id"),msgid:e.getAttribute("id")||c.getAttribute("id"),occupant_id:_m(e,t),receipt_id:Yu(e),received:(new Date).toISOString(),references:Ku(e),subject:null===(i=e.querySelector("subject"))||void 0===i?void 0:i.textContent,thread:null===(o=e.querySelector("thread"))||void 0===o?void 0:o.textContent,time:l?pl()(l.getAttribute("stamp")).toISOString():g,to:e.getAttribute("to"),type:e.getAttribute("type")},Zu(e),Qu(e),Ju(e),Wu(e,c),qu(e,c),function(e){const t=ec()(`> apply-to[xmlns="${me.NS.FASTEN}"]`,e).pop();if(t){const e=t.getAttribute("id"),n=ec()(`> meta[xmlns="${me.NS.XHTML}"]`,t);if(n.length){const t=bu.settings.get("message_limit"),s=n.reduce(((e,n)=>{const s=n.getAttribute("property");if(s){let i=tl(n.getAttribute("content")||"");t&&"og:description"===s&&i.length>=t&&(i=`${i.slice(0,t)}${tl("…")}`),e[s]=i}return e}),{ogp_for_id:e});if("og:description"in s||"og:title"in s||"og:image"in s)return s}}return{}}(e),Gu(e,c),function(e){const t=gm(`apply-to[xmlns="${mm.NS.FASTEN}"]`,e).pop();if(t){const e=t.getAttribute("id"),s=gm(`moderated[xmlns="${mm.NS.MODERATE}"]`,t).pop();var n;if(s)if(gm(`retract[xmlns="${mm.NS.RETRACT}"]`,s).pop())return{editable:!1,moderated:"retracted",moderated_by:s.getAttribute("by"),moderated_id:e,moderation_reason:null===(n=s.querySelector("reason"))||void 0===n?void 0:n.textContent}}else{const t=gm(`> moderated[xmlns="${mm.NS.MODERATE}"]`,e).pop();var s;if(t)if(gm(`retracted[xmlns="${mm.NS.RETRACT}"]`,t).pop())return{editable:!1,is_tombstone:!0,moderated_by:t.getAttribute("by"),retracted:t.getAttribute("stamp"),moderation_reason:null===(s=t.querySelector("reason"))||void 0===s?void 0:s.textContent}}return{}}(e),Hu(e));await bu.emojis.initialize();const p=f.is_archived&&function(e){const t=gm(`x[xmlns="${mm.NS.MUC_USER}"] item`,e).pop();return null==t?void 0:t.getAttribute("jid")}(e)||(null===(r=t.occupants.findOccupant(f))||void 0===r?void 0:r.get("jid"));return f=Object.assign({from_real_jid:p,is_only_emojis:!!f.body&&fm.isOnlyEmojis(f.body),is_valid_receipt_request:th(e,f),message:f.body||f.error,sender:f.nick===t.get("nick")?"me":"them"},f),f.is_archived&&c.getAttribute("from")!==f.from_muc?new Bu(`Invalid Stanza: Forged MAM message from ${c.getAttribute("from")}`,e):f.is_archived&&c.getAttribute("from")!==t.get("jid")?new Bu(`Invalid Stanza: Forged MAM groupchat message from ${e.getAttribute("from")}`,e):f.is_carbon?new Bu("Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied",e):(f.id=f.origin_id||f[`stanza_id ${f.from_muc||f.from}`]||fm.getUniqueId(),f=await bu.hook("parseMUCMessage",e,f),Object.assign(f,Vu(f.is_encrypted?f.plaintext:f.body)))}const{Strophe:bm,$iq:wm,u:Sm}=Su.env;async function xm(e,t){const{__:n}=ul,s=wm({to:t,type:"get"}).c("query",{xmlns:bm.NS.MUC_ADMIN}).c("item",{affiliation:e}),i=await bu.sendIQ(s,null,!1);if(null===i){const s=n("Error: timeout while fetching %1s list for MUC %2s",e,t),i=new Error(s);return z.warn(s),i}if(Sm.isErrorStanza(i)){const s=n("Error: not allowed to fetch %1s list for MUC %2s",e,t),o=new Error(s);return z.warn(s),z.warn(i),o}return function(e){return gm(`query[xmlns="${mm.NS.MUC_ADMIN}"] item`,e).map((e=>{const t={affiliation:e.getAttribute("affiliation")},n=e.getAttribute("jid");fm.isValidJID(n)?t.jid=n:t.nick=n;const s=e.getAttribute("nick");return s&&(t.nick=s),e.getAttribute("role")&&(t.role=s),t}))}(i).filter((e=>e)).sort(((e,t)=>e.nickt.nick?1:0))}function Em(e){let t=bu.settings.get("modtools_disable_assign");return Array.isArray(t)||(t=t?rg:[]),"owner"===e.get("affiliation")?rg.filter((e=>!t.includes(e))):"admin"===e.get("affiliation")?rg.filter((e=>!["owner","admin",...t].includes(e))):[]}function Am(e,t){const n=[...new Set(t.map((e=>e.affiliation)))];return Promise.all(n.map((n=>Cm(n,e,t))))}function Cm(e,t,n){return Array.isArray(t)||(t=[t]),n=n.filter((t=>[void 0,e].includes(t.affiliation))),Promise.all(t.reduce(((t,s)=>[...t,...n.map((t=>function(e,t,n){const s=wm({to:t,type:"set"}).c("query",{xmlns:bm.NS.MUC_ADMIN}).c("item",{affiliation:n.affiliation||e,nick:n.nick,jid:n.jid});void 0!==n.reason&&s.c("reason",n.reason);return bu.sendIQ(s)}(e,s,t)))]),[]))}function km(e,t,n,s){const i=n.map((e=>e.jid)),o=s.map((e=>e.jid));let r=Rl(i,o).map((e=>n[Jl(i,e)]));return e||(r=r.concat(n.filter((e=>{const t=Jl(o,e.jid);return t>=0&&e.affiliation!==s[t].affiliation})))),t&&(r=r.concat(Rl(o,i).map((e=>({jid:e,affiliation:"none"}))))),r}ul.getAssignableAffiliations=Em;const jm=["owner"],Tm=["admin","ban","deop","destroy","member","op","revoke"],$m=["kick","mute","voice","modtools"],Nm=["nick"],Om=["og:article:author","og:article:published_time","og:description","og:image","og:image:height","og:image:width","og:site_name","og:title","og:type","og:url","og:video:height","og:video:secure_url","og:video:tag","og:video:type","og:video:url","og:video:width"],Im=["301","303","333","307","321","322"],Mm=Ac.extend({defaults:()=>({connection_status:Su.ROOMSTATUS.DISCONNECTED})}),Rm={defaults(){return{bookmarked:!1,chat_state:void 0,has_activity:!1,hidden:Hc()&&!bu.settings.get("singleton"),hidden_occupants:!!bu.settings.get("hide_muc_participants"),message_type:"groupchat",name:"",num_unread_general:0,num_unread:0,roomconfig:{},time_opened:this.get("time_opened")||(new Date).getTime(),time_sent:new Date(0).toISOString(),type:ul.CHATROOMS_TYPE}},async initialize(){this.initialized=ba(),this.debouncedRejoin=jc(this.rejoin,250),this.set("box_id",`box-${this.get("jid")}`),this.initNotifications(),this.initMessages(),this.initUI(),this.initOccupants(),this.initDiscoModels(),this.registerHandlers(),this.on("change:chat_state",this.sendChatState,this),this.on("change:hidden",this.onHiddenChange,this),this.on("destroy",this.removeHandlers,this),this.ui.on("change:scrolled",this.onScrolledChanged,this),await this.restoreSession(),this.session.on("change:connection_status",this.onConnectionStatusChanged,this),this.listenTo(this.occupants,"add",this.onOccupantAdded),this.listenTo(this.occupants,"remove",this.onOccupantRemoved),this.listenTo(this.occupants,"change:show",this.onOccupantShowChanged),this.listenTo(this.occupants,"change:affiliation",this.createAffiliationChangeMessage),this.listenTo(this.occupants,"change:role",this.createRoleChangeMessage);await this.restoreFromCache()||this.join(),await bu.trigger("chatRoomInitialized",this,{Synchronous:!0}),this.initialized.resolve()},isEntered(){return this.session.get("connection_status")===Su.ROOMSTATUS.ENTERED},async restoreFromCache(){return this.isEntered()&&await this.isJoined()?(await new Promise((e=>this.features.fetch({success:e,error:e}))),await new Promise((e=>this.config.fetch({success:e,error:e}))),await this.fetchOccupants().catch((e=>z.error(e))),await this.fetchMessages().catch((e=>z.error(e))),!0):(this.session.save("connection_status",Su.ROOMSTATUS.DISCONNECTED),this.clearOccupantsCache(),!1)},async join(e,t){return this.isEntered()?this:(this.session.save("connection_status",Su.ROOMSTATUS.CONNECTING),await this.refreshDiscoInfo(),(e=await this.getAndPersistNickname(e))?(bu.send(await this.constructJoinPresence(t)),this):(Zc(this.session,{connection_status:Su.ROOMSTATUS.NICKNAME_REQUIRED}),bu.settings.get("muc_show_logs_before_join")&&await this.fetchMessages(),this))},rejoin(){return this.session.save("connection_status",Su.ROOMSTATUS.DISCONNECTED),this.registerHandlers(),this.clearOccupantsCache(),this.join()},async constructJoinPresence(e){let t=he({id:Kc(),from:ul.connection.jid,to:this.getRoomJIDAndNick()}).c("x",{xmlns:me.NS.MUC}).c("history",{maxstanzas:this.features.get("mam_enabled")?0:bu.settings.get("muc_history_max_stanzas")}).up();return(e=e||this.get("password"))&&t.cnode(me.xmlElement("password",[],e)),t.up(),t=await bu.hook("constructedMUCPresence",this,t),t},clearOccupantsCache(){this.occupants.length?this.occupants.filter((e=>!e.isMember())).forEach((e=>e.destroy())):this.occupants.clearStore()},sendMarkerForMessage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"displayed",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e&&bu.settings.get("send_chat_markers").includes(t)&&"groupchat"===(null==e?void 0:e.get("type"))&&(null!=e&&e.get("is_markable")||n)){const n=`stanza_id ${this.get("jid")}`,s=e.get(n);if(!s)return void z.error(`Can't send marker for message without stanza ID: ${n}`);Au(me.getBareJidFromJid(e.get("from")),s,t,e.get("type"))}},enableRAI(){if(bu.settings.get("muc_subscribe_to_rai")){const e=me.getDomainFromJid(this.get("jid"));bu.user.presence.send(null,e,null,le("rai",{xmlns:me.NS.RAI}))}},async onHiddenChange(){const e=Su.ROOMSTATUS,t=this.session.get("connection_status");this.get("hidden")?t===e.ENTERED&&bu.settings.get("muc_subscribe_to_rai")&&"none"!==this.getOwnAffiliation()&&(this.sendMarkerForLastMessage("received",!0),await this.leave(),this.enableRAI()):(t===e.DISCONNECTED&&this.rejoin(),this.clearUnreadMsgCounter())},onOccupantAdded(e){ul.isInfoVisible(Su.MUC_TRAFFIC_STATES.ENTERED)&&this.session.get("connection_status")===Su.ROOMSTATUS.ENTERED&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Su.MUC_TRAFFIC_STATES.ENTERED)},onOccupantRemoved(e){ul.isInfoVisible(Su.MUC_TRAFFIC_STATES.EXITED)&&this.isEntered()&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Su.MUC_TRAFFIC_STATES.EXITED)},onOccupantShowChanged(e){e.get("states").includes("303")||("offline"===e.get("show")&&ul.isInfoVisible(Su.MUC_TRAFFIC_STATES.EXITED)?this.updateNotifications(e.get("nick"),Su.MUC_TRAFFIC_STATES.EXITED):"online"===e.get("show")&&ul.isInfoVisible(Su.MUC_TRAFFIC_STATES.ENTERED)&&this.updateNotifications(e.get("nick"),Su.MUC_TRAFFIC_STATES.ENTERED))},async onRoomEntered(){await this.occupants.fetchMembers(),bu.settings.get("clear_messages_on_reconnection")?await this.clearMessages():await this.fetchMessages(),bu.trigger("enteredNewRoom",this),bu.settings.get("auto_register_muc_nickname")&&await bu.disco.supports(me.NS.MUC_REGISTER,this.get("jid"))&&this.registerNickname()},async onConnectionStatusChanged(){if(this.isEntered())if(this.get("hidden")&&bu.settings.get("muc_subscribe_to_rai")&&"none"!==this.getOwnAffiliation()){try{await this.leave()}catch(e){z.error(e)}this.enableRAI()}else await this.onRoomEntered()},async onReconnection(){await this.rejoin(),this.announceReconnection()},getMessagesCollection:()=>new ul.ChatRoomMessages,restoreSession(){const e=`muc.session-${ul.bare_jid}-${this.get("jid")}`;return this.session=new Mm({id:e}),La(this.session,e,"session"),new Promise((e=>this.session.fetch({success:e,error:e})))},initDiscoModels(){let e=`converse.muc-features-${ul.bare_jid}-${this.get("jid")}`;this.features=new Ac(Object.assign({id:e},hm(Su.ROOM_FEATURES,Su.ROOM_FEATURES.map((()=>!1))))),this.features.browserStorage=ul.createStore(e,"session"),this.features.listenTo(ul,"beforeLogout",(()=>this.features.browserStorage.flush())),e=`converse.muc-config-${ul.bare_jid}-${this.get("jid")}`,this.config=new Ac({id:e}),this.config.browserStorage=ul.createStore(e,"session"),this.config.listenTo(ul,"beforeLogout",(()=>this.config.browserStorage.flush()))},initOccupants(){this.occupants=new ul.ChatRoomOccupants;const e=`converse.occupants-${ul.bare_jid}${this.get("jid")}`;this.occupants.browserStorage=ul.createStore(e,"session"),this.occupants.chatroom=this,this.occupants.listenTo(ul,"beforeLogout",(()=>this.occupants.browserStorage.flush()))},fetchOccupants(){return this.occupants.fetched=new Promise((e=>{this.occupants.fetch({add:!0,silent:!0,success:e,error:e})})),this.occupants.fetched},handleAffiliationChangedMessage(e){const t=ec()(`x[xmlns="${me.NS.MUC_USER}"] item`,e).pop();if(t){const n=e.getAttribute("from"),s=e.getAttribute("type"),i=t.getAttribute("affiliation"),o=t.getAttribute("jid"),r={from:n,type:s,affiliation:i,states:[],show:"unavailable"==s?"offline":"online",role:t.getAttribute("role"),jid:me.getBareJidFromJid(o),resource:me.getResourceFromJid(o)},a=this.occupants.findOccupant({jid:r.jid});a?a.save(r):this.occupants.create(r)}},async handleErrorMessageStanza(e){const{__:t}=ul,n=await ym(e,this);if(!await this.shouldShowErrorMessage(n))return;const s=this.getMessageReferencedByError(n);if(s){const e={error:n.error,error_condition:n.error_condition,error_text:n.error_text,error_type:n.error_type,editable:!1};n.msgid===s.get("retraction_id")?(e.retracted=void 0,e.retraction_id=void 0,e.retracted_id=void 0,n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to retract your message."):"not-acceptable"===n.error_condition?e.error=t("Your retraction was not delivered because you're not present in the groupchat."):e.error=t("Sorry, an error occurred while trying to retract your message."))):n.error||("forbidden"===n.error_condition?e.error=t("Your message was not delivered because you weren't allowed to send it."):"not-acceptable"===n.error_condition?e.error=t("Your message was not delivered because you're not present in the groupchat."):e.error=t("Sorry, an error occurred while trying to send your message.")),s.save(e)}else this.createMessage(n)},handleMessageFromMUCHost(e){if(this.isEntered())return;const t=ec()(`rai[xmlns="${me.NS.RAI}"]`,e).pop(),n=Array.from((null==t?void 0:t.querySelectorAll("activity"))||[]).map((e=>e.textContent));n.includes(this.get("jid"))&&this.save({has_activity:!0,num_unread_general:0})},handleForwardedMentions(e){if(this.isEntered())return;const t=ec()(`mentions[xmlns="${me.NS.MENTIONS}"] forwarded[xmlns="${me.NS.FORWARD}"] message[type="groupchat"]`,e),n=this.get("jid"),s=t.filter((e=>me.getBareJidFromJid(e.getAttribute("from"))===n));s.length&&(this.save({has_activity:!0,num_unread:this.get("num_unread")+s.length}),s.forEach((async e=>{const t={stanza:e,attrs:await ym(e,this),chatbox:this};bu.trigger("message",t)})))},async handleMessageStanza(e){const t=e.getAttribute("type");if("error"===t)return this.handleErrorMessageStanza(e);if("groupchat"===t){if(rh(e))return z.warn('Received a MAM message with type "groupchat"');this.createInfoMessages(e),this.fetchFeaturesIfConfigurationChanged(e)}else if(!t)return this.handleForwardedMentions(e);let n;try{n=await ym(e,this)}catch(e){return z.error(e)}const s={stanza:e,attrs:n,chatbox:this};return bu.trigger("message",s),n&&this.queueMessage(n)},registerHandlers(){const e=this.get("jid"),t=me.getDomainFromJid(e);this.removeHandlers(),this.presence_handler=ul.connection.addHandler((e=>this.onPresence(e)||!0),null,"presence",null,null,e,{ignoreNamespaceFragment:!0,matchBareFromJid:!0}),this.domain_presence_handler=ul.connection.addHandler((e=>this.onPresenceFromMUCHost(e)||!0),null,"presence",null,null,t),this.message_handler=ul.connection.addHandler((e=>!!this.handleMessageStanza(e)||!0),null,"message",null,null,e,{matchBareFromJid:!0}),this.domain_message_handler=ul.connection.addHandler((e=>this.handleMessageFromMUCHost(e)||!0),null,"message",null,null,t),this.affiliation_message_handler=ul.connection.addHandler((e=>this.handleAffiliationChangedMessage(e)||!0),me.NS.MUC_USER,"message",null,null,e)},removeHandlers(){return this.message_handler&&(ul.connection&&ul.connection.deleteHandler(this.message_handler),delete this.message_handler),this.domain_message_handler&&(ul.connection&&ul.connection.deleteHandler(this.domain_message_handler),delete this.domain_message_handler),this.presence_handler&&(ul.connection&&ul.connection.deleteHandler(this.presence_handler),delete this.presence_handler),this.domain_presence_handler&&(ul.connection&&ul.connection.deleteHandler(this.domain_presence_handler),delete this.domain_presence_handler),this.affiliation_message_handler&&(ul.connection&&ul.connection.deleteHandler(this.affiliation_message_handler),delete this.affiliation_message_handler),this},invitesAllowed(){return bu.settings.get("allow_muc_invitations")&&(this.features.get("open")||"owner"===this.getOwnAffiliation())},getDisplayName(){const e=this.get("name");return e||("hidden"===bu.settings.get("locked_muc_domain")?me.getNodeFromJid(this.get("jid")):this.get("jid"))},sendTimedMessage(e){"function"==typeof e.tree&&(e=e.tree());let t=e.getAttribute("id");t||(t=this.getUniqueId("sendIQ"),e.setAttribute("id",t));const n=ba(),s=ul.connection.addTimedHandler(ul.STANZA_TIMEOUT,(()=>{ul.connection.deleteHandler(i);const e=new ul.TimeoutError("Timeout Error: No response from server");return n.resolve(e),!1})),i=ul.connection.addHandler((e=>{s&&ul.connection.deleteTimedHandler(s),n.resolve(e)}),null,"message",["error","groupchat"],t);return bu.send(e),n},async retractOwnMessage(e){const t=ul.__,n=e.get("origin_id");if(!n)throw new Error("Can't retract message without a XEP-0359 Origin ID");const s=e.get("editable"),i=de({id:Kc(),to:this.get("jid"),type:"groupchat"}).c("store",{xmlns:me.NS.HINTS}).up().c("apply-to",{id:n,xmlns:me.NS.FASTEN}).c("retract",{xmlns:me.NS.RETRACT});e.set({retracted:(new Date).toISOString(),retracted_id:n,retraction_id:i.nodeTree.getAttribute("id"),editable:!1});const o=await this.sendTimedMessage(i);dm.isErrorStanza(o)?z.error(o):o instanceof ul.TimeoutError&&(z.error(o),e.save({editable:s,error_type:"timeout",error:t("A timeout happened while while trying to retract your message."),retracted:void 0,retracted_id:void 0,retraction_id:void 0}))},async retractOtherMessage(e,t){const n=e.get("editable");e.save({moderated:"retracted",moderated_by:ul.bare_jid,moderated_id:e.get("msgid"),moderation_reason:t,editable:!1});const s=await this.sendRetractionIQ(e,t);return(null===s||dm.isErrorStanza(s))&&e.save({editable:n,moderated:void 0,moderated_by:void 0,moderated_id:void 0,moderation_reason:void 0}),s},sendRetractionIQ(e,t){const n=ue({to:this.get("jid"),type:"set"}).c("apply-to",{id:e.get(`stanza_id ${this.get("jid")}`),xmlns:me.NS.FASTEN}).c("moderate",{xmlns:me.NS.MODERATE}).c("retract",{xmlns:me.NS.RETRACT}).up().c("reason").t(t||"");return bu.sendIQ(n,null,!1)},sendDestroyIQ(e,t){const n=le("destroy");t&&n.attrs({jid:t});const s=ue({to:this.get("jid"),type:"set"}).c("query",{xmlns:me.NS.MUC_OWNER}).cnode(n.node);return e&&e.length>0&&s.c("reason",e),bu.sendIQ(s)},async leave(e){var t;bu.connection.connected()&&bu.user.presence.send("unavailable",this.getRoomJIDAndNick(),e),this.features&&await new Promise((e=>this.features.destroy({success:e,error:(t,n)=>{z.error(n),e()}})));const n=null===(t=ul.disco_entities)||void 0===t?void 0:t.get(this.get("jid"));n&&await new Promise((e=>n.destroy({success:e,error:(t,n)=>{z.error(n),e()}}))),Zc(this.session,{connection_status:Su.ROOMSTATUS.DISCONNECTED})},async close(e){return Zc(this.session,{connection_status:Su.ROOMSTATUS.CLOSING}),this.sendMarkerForLastMessage("received",!0),await this.unregisterNickname(),await this.leave(),this.occupants.clearStore(),"closeAllChatBoxes"!==(null==e?void 0:e.name)&&bu.settings.get("muc_clear_messages_on_leave")&&this.clearMessages(),await new Promise((e=>this.session.destroy({success:e,error:(t,n)=>{z.error(n),e()}}))),ul.ChatBox.prototype.close.call(this)},canModerateMessages(){const e=this.getOwnOccupant();return e&&e.isModerator()&&bu.disco.supports(me.NS.MODERATE,this.get("jid"))},getAllKnownNicknames(){return[...new Set([...this.occupants.map((e=>e.get("nick"))),...this.messages.map((e=>e.get("nick")))])].filter((e=>e))},getAllKnownNicknamesRegex(){const e=this.getAllKnownNicknames().map((e=>lm.escapeRegexString(e))).join("|");return RegExp(`(?:\\p{P}|\\p{Z}|^)@(${e})(?![\\w@-])`,"uig")},getOccupantByJID(e){return this.occupants.findOccupant({jid:e})},getOccupantByNickname(e){return this.occupants.findOccupant({nick:e})},parseTextForReferences(e){if(!e||!/(\p{P}|\p{Z}|^)([@][\w_-]+(?:\.\w+)*)/giu.test(e))return[e,[]];const t=lm.findFirstMatchInArray(this.getAllKnownNicknames()),n=e=>{const t=this.get("jid"),n=this.getOccupant(e)||this.getOccupant(t),s=this.features.get("nonanonymous")&&(null==n?void 0:n.get("jid"))||`${t}/${e}`;return encodeURI(`xmpp:${s}`)},s=this.getAllKnownNicknamesRegex(),i=[...e.matchAll(s)].filter((e=>!e[0].startsWith("/"))),o=i.map((e=>{let s=e[0].indexOf("@");"@"===e[0][s+1]&&(s+=1);const i=e.index+s,o=i+e[0].length-s,r=t(e[1]);return{begin:i,end:o,value:r,type:"mention",uri:n(r)}})),[r,a]=lm.reduceTextFromReferences(e,o);return[r,a]},async getOutgoingMessageAttributes(e){var t;const n=this.get("composing_spoiler");let s,i="";null!==(t=e)&&void 0!==t&&t.body&&([i,s]=this.parseTextForReferences(e.body));const o=Kc(),r=i?dm.httpToGeoUri(dm.shortnamesToUnicode(i),ul):void 0;return e=Object.assign({},e,{body:r,is_spoiler:n,origin_id:o,references:s,id:o,msgid:o,from:`${this.get("jid")}/${this.get("nick")}`,fullname:this.get("nick"),is_only_emojis:!!i&&dm.isOnlyEmojis(i),message:r,nick:this.get("nick"),sender:"me",type:"groupchat"},Vu(i)),e=await bu.hook("getOutgoingMessageAttributes",this,e)},getRoomJIDAndNick(){const e=this.get("nick");return me.getBareJidFromJid(this.get("jid"))+(null!==e?`/${e}`:"")},sendChatState(){if(!bu.settings.get("send_chat_state_notifications")||!this.get("chat_state")||!this.isEntered()||this.features.get("moderated")&&"visitor"===this.getOwnRole())return;const e=bu.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;const t=this.get("chat_state");t!==ul.GONE&&bu.send(de({to:this.get("jid"),type:"groupchat"}).c(t,{xmlns:me.NS.CHATSTATES}).up().c("no-store",{xmlns:me.NS.HINTS}).up().c("no-permanent-store",{xmlns:me.NS.HINTS}))},directInvite(e,t){this.features.get("membersonly")&&this.updateMemberLists([{jid:e,affiliation:"member",reason:t}]);const n={xmlns:"jabber:x:conference",jid:this.get("jid")};null!==t&&(n.reason=t),this.get("password")&&(n.password=this.get("password"));const s=de({from:ul.connection.jid,to:e,id:Kc()}).c("x",n);bu.send(s),bu.trigger("roomInviteSent",{room:this,recipient:e,reason:t})},refreshDiscoInfo(){return bu.disco.refresh(this.get("jid")).then((()=>this.getDiscoInfo())).catch((e=>z.error(e)))},getDiscoInfo(){return bu.disco.getIdentity("conference","text",this.get("jid")).then((e=>this.save({name:null==e?void 0:e.get("name")}))).then((()=>this.getDiscoInfoFields())).then((()=>this.getDiscoInfoFeatures())).catch((e=>z.error(e)))},async getDiscoInfoFields(){const e=(await bu.disco.getFields(this.get("jid"))).reduce(((e,t)=>{const n=t.get("var");return null!=n&&n.startsWith("muc#roominfo_")&&(e[n.replace("muc#roominfo_","")]=t.get("value")),e}),{});this.config.save(e)},async getDiscoInfoFeatures(){const e=await bu.disco.getFeatures(this.get("jid")),t=Object.assign(hm(Su.ROOM_FEATURES,Su.ROOM_FEATURES.map((()=>!1))),{fetched:(new Date).toISOString()});e.each((e=>{const n=e.get("var");n.startsWith("muc_")?t[n.replace("muc_","")]=!0:n===me.NS.MAM?t.mam_enabled=!0:t[n]=!0})),this.features.save(t)},addFieldValue(e){const t=e.getAttribute("type");if("fixed"===t)return e;const n=e.getAttribute("var").replace("muc#roomconfig_",""),s=this.get("roomconfig");if(n in s){let i;switch(t){case"boolean":i=[s[n]?1:0];break;case"list-multi":i=s[n];break;default:i=[s[n]]}e.innerHTML=i.map((e=>le("value").t(e))).join("")}return e},async autoConfigureChatRoom(){const e=await this.fetchRoomConfiguration(),t=ec()("field",e).map((e=>this.addFieldValue(e)));if(t.length)return this.sendConfiguration(t)},fetchRoomConfiguration(){return bu.sendIQ(ue({to:this.get("jid"),type:"get"}).c("query",{xmlns:me.NS.MUC_OWNER}))},sendConfiguration(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=ue({to:this.get("jid"),type:"set"}).c("query",{xmlns:me.NS.MUC_OWNER}).c("x",{xmlns:me.NS.XFORM,type:"submit"});return e.forEach((e=>t.cnode(e).up())),bu.sendIQ(t)},onCommandError(e){const{__:t}=ul;z.fatal(e);const n=t("Sorry, an error happened while running the command.")+" "+t("Check your browser's developer console for details.");this.createMessage({message:n,type:"error"})},getNickOrJIDFromCommandArgs(e){const{__:t}=ul;if(dm.isValidJID(e.trim()))return e.trim();e.startsWith("@")||(e="@"+e);const[n,s]=this.parseTextForReferences(e);if(!s.length){const e=t("Error: couldn't find a groupchat participant based on your arguments");return void this.createMessage({message:e,type:"error"})}if(s.length>1){const e=t("Error: found multiple groupchat participant based on your arguments");return void this.createMessage({message:e,type:"error"})}const i=s.pop().value,o=e.split(i,2)[1];if(!o||o.startsWith(" "))return i;{const e=t("Error: couldn't find a groupchat participant based on your arguments");this.createMessage({message:e,type:"error"})}},validateRoleOrAffiliationChangeArgs(e,t){const{__:n}=ul;if(!t){const t=n('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.',e);return this.createMessage({message:t,type:"error"}),!1}return!0},getAllowedCommands(){let e=["clear","help","me","nick","register"];(this.config.get("changesubject")||["owner","admin"].includes(this.getOwnAffiliation()))&&(e=[...e,"subject","topic"]);const t=this.occupants.findWhere({jid:ul.bare_jid});return this.verifyAffiliations(["owner"],t,!1)?e=e.concat(jm).concat(Tm):this.verifyAffiliations(["admin"],t,!1)&&(e=e.concat(Tm)),this.verifyRoles(["moderator"],t,!1)?e=e.concat($m).concat(Nm):this.verifyRoles(["visitor","participant","moderator"],t,!1)||(e=e.concat(Nm)),e.sort(),Array.isArray(bu.settings.get("muc_disable_slash_commands"))?e.filter((e=>!bu.settings.get("muc_disable_slash_commands").includes(e))):e},verifyAffiliations(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const{__:s}=ul;if(!Array.isArray(e))throw new TypeError("affiliations must be an Array");if(!e.length)return!0;if(t=t||this.occupants.findWhere({jid:ul.bare_jid})){const n=t.get("affiliation");if(e.includes(n))return!0}if(n){const e=s("Forbidden: you do not have the necessary affiliation in order to do that.");this.createMessage({message:e,type:"error"})}return!1},verifyRoles(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const{__:s}=ul;if(!Array.isArray(e))throw new TypeError("roles must be an Array");if(!e.length)return!0;if(t=t||this.occupants.findWhere({jid:ul.bare_jid})){const n=t.get("role");if(e.includes(n))return!0}if(n){const e=s("Forbidden: you do not have the necessary role in order to do that.");this.createMessage({message:e,type:"error",is_ephemeral:2e4})}return!1},getOwnRole(){var e,t;return null===(e=this.getOwnOccupant())||void 0===e||null===(t=e.attributes)||void 0===t?void 0:t.role},getOwnAffiliation(){var e,t;return(null===(e=this.getOwnOccupant())||void 0===e||null===(t=e.attributes)||void 0===t?void 0:t.affiliation)||"none"},getOwnOccupant(){return this.occupants.getOwnOccupant()},async setNickname(e){if(bu.settings.get("auto_register_muc_nickname")&&await bu.disco.supports(me.NS.MUC_REGISTER,this.get("jid"))){const t=this.get("nick");this.set({nick:e});try{await this.registerNickname()}catch(e){const{__:n}=ul;z.error(e);const s=n("Error: couldn't register new nickname in members only room");return this.createMessage({message:s,type:"error",is_ephemeral:!0}),void this.set({nick:t})}}const t=me.getBareJidFromJid(this.get("jid"));bu.send(he({from:ul.connection.jid,to:`${t}/${e}`,id:Kc()}).tree())},setRole(e,t,n,s,i){const o=le("item",{nick:e.get("nick"),role:t}),r=ue({to:this.get("jid"),type:"set"}).c("query",{xmlns:me.NS.MUC_ADMIN}).cnode(o.node);return null!==n&&r.c("reason",n),bu.sendIQ(r).then(s).catch(i)},getOccupant(e){return dm.isValidJID(e)?this.getOccupantByJID(e):this.getOccupantByNickname(e)},getOccupantsWithRole(e){return this.getOccupantsSortedBy("nick").filter((t=>t.get("role")===e)).map((e=>({jid:e.get("jid"),nick:e.get("nick"),role:e.get("role")})))},getOccupantsWithAffiliation(e){return this.getOccupantsSortedBy("nick").filter((t=>t.get("affiliation")===e)).map((e=>({jid:e.get("jid"),nick:e.get("nick"),affiliation:e.get("affiliation")})))},getOccupantsSortedBy(e){return Array.from(this.occupants.models).sort(((t,n)=>t.get(e)n.get(e)?1:0))},async updateMemberLists(e){const t=this.get("jid"),n=await Promise.all(["member","admin","owner"].map((e=>xm(e,t)))),s=n.reduce(((e,t)=>dm.isErrorObject(t)?e:[...t,...e]),[]);await Am(t,km(!0,!1,e,s)),await this.occupants.fetchMembers()},async getAndPersistNickname(e){return(e=e||this.get("nick")||await this.getReservedNick()||ul.getDefaultMUCNickname())&&Zc(this,{nick:e},{silent:!0}),e},async getReservedNick(){const e=ue({to:this.get("jid"),from:ul.connection.jid,type:"get"}).c("query",{xmlns:me.NS.DISCO_INFO,node:"x-roomuser-item"}),t=await bu.sendIQ(e,null,!1);if(dm.isErrorObject(t))throw t;const n=null==t?void 0:t.querySelector('query[node="x-roomuser-item"] identity');return n?n.getAttribute("name"):null},async registerNickname(){const{__:e}=ul,t=this.get("nick"),n=this.get("jid");let s,i;try{s=await bu.sendIQ(ue({to:n,type:"get"}).c("query",{xmlns:me.NS.MUC_REGISTER}))}catch(t){return ec()(`not-allowed[xmlns="${me.NS.STANZAS}"]`,t).length?i=e("You're not allowed to register yourself in this groupchat."):ec()(`registration-required[xmlns="${me.NS.STANZAS}"]`,t).length&&(i=e("You're not allowed to register in this groupchat because it's members-only.")),z.error(t),i}const o=ec()("field required",s).map((e=>e.parentElement));if(o.length>1&&"muc#register_roomnick"!==o[0].getAttribute("var"))return z.error(`Can't register the user register in the groupchat ${n} due to the required fields`);try{await bu.sendIQ(ue({to:n,type:"set"}).c("query",{xmlns:me.NS.MUC_REGISTER}).c("x",{xmlns:me.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#register").up().up().c("field",{var:"muc#register_roomnick"}).c("value").t(t))}catch(t){return ec()(`service-unavailable[xmlns="${me.NS.STANZAS}"]`,t).length?i=e("Can't register your nickname in this groupchat, it doesn't support registration."):ec()(`bad-request[xmlns="${me.NS.STANZAS}"]`,t).length&&(i=e("Can't register your nickname in this groupchat, invalid data form supplied.")),z.error(i),z.error(t),i}},async unregisterNickname(){if("unregister"===bu.settings.get("auto_register_muc_nickname"))try{await bu.disco.supports(me.NS.MUC_REGISTER,this.get("jid"))&&await this.sendUnregistrationIQ()}catch(e){z.error(e)}},sendUnregistrationIQ(){const e=ue({to:this.get("jid"),type:"set"}).c("query",{xmlns:me.NS.MUC_REGISTER}).c("remove");return bu.sendIQ(e).catch((e=>z.error(e)))},updateOccupantsOnPresence(e){var t,n;const s=function(e,t){const n=e.getAttribute("from"),s=e.getAttribute("type"),i={from:n,occupant_id:_m(e,t),nick:mm.getResourceFromJid(n),type:s,states:[],hats:[],show:"unavailable"!==s?"online":"offline"};return Array.from(e.children).forEach((e=>{if(e.matches("status"))i.status=e.textContent||null;else if(e.matches("show"))i.show=e.textContent||"online";else if(e.matches("x")&&e.getAttribute("xmlns")===mm.NS.MUC_USER)Array.from(e.children).forEach((e=>{"item"===e.nodeName?(i.affiliation=e.getAttribute("affiliation"),i.role=e.getAttribute("role"),i.jid=e.getAttribute("jid"),i.nick=e.getAttribute("nick")||i.nick):"status"==e.nodeName&&e.getAttribute("code")&&i.states.push(e.getAttribute("code"))}));else if(e.matches("x")&&e.getAttribute("xmlns")===mm.NS.VCARDUPDATE){var t;i.image_hash=null===(t=e.querySelector("photo"))||void 0===t?void 0:t.textContent}else e.matches("hats")&&e.getAttribute("xmlns")===mm.NS.MUC_HATS&&(i.hats=Array.from(e.children).map((e=>e.matches("hat")&&{title:e.getAttribute("title"),uri:e.getAttribute("uri")})))})),i}(e,this);if("error"===s.type||!s.jid&&!s.nick&&!s.occupant_id)return!0;const i=this.occupants.findOccupant(s);if("unavailable"===s.type&&i&&!s.states.includes(Su.MUC_NICK_CHANGED_CODE)&&!["admin","owner","member"].includes(s.affiliation))return i.set(s),void i.destroy();const o=s.jid||"",r={...s,jid:me.getBareJidFromJid(o)||(null==i||null===(t=i.attributes)||void 0===t?void 0:t.jid),resource:me.getResourceFromJid(o)||(null==i||null===(n=i.attributes)||void 0===n?void 0:n.resource)};i?i.save(r):this.occupants.create(r)},fetchFeaturesIfConfigurationChanged(e){const t=["104","170","171","172","173","174"];ec()("status",e).filter((e=>t.includes(e.getAttribute("status")))).length&&this.refreshDiscoInfo()},isSameUser(e,t){const n=me.getBareJidFromJid(e),s=me.getBareJidFromJid(t),i=me.getResourceFromJid(e),o=me.getResourceFromJid(t);if(dm.isSameBareJID(e,t))return n!==this.get("jid")||i===o;return(n===this.get("jid")?this.occupants.findOccupant({nick:i}):this.occupants.findOccupant({jid:n}))===(s===this.get("jid")?this.occupants.findOccupant({nick:o}):this.occupants.findOccupant({jid:s}))},async isSubjectHidden(){return(await bu.user.settings.get("mucs_with_hidden_subject",[])).includes(this.get("jid"))},async toggleSubjectHiddenState(){const e=this.get("jid"),t=await bu.user.settings.get("mucs_with_hidden_subject",[]);t.includes(this.get("jid"))?bu.user.settings.set("mucs_with_hidden_subject",t.filter((t=>t!==e))):bu.user.settings.set("mucs_with_hidden_subject",[...t,e])},async handleSubjectChange(e){const t=ul.__;if("string"==typeof e.subject&&!e.thread&&!e.message){const n=e.subject,s=e.nick;if(Zc(this,{subject:{author:s,text:e.subject||""}}),!e.is_delayed&&s){const i=t(n?"Topic set by %1$s":"Topic cleared by %1$s",s),o=this.messages.last();(null==o?void 0:o.get("nick"))===e.nick&&"info"===(null==o?void 0:o.get("type"))&&(null==o?void 0:o.get("message"))===i||this.createMessage({message:i,nick:e.nick,type:"info",is_ephemeral:!0}),await this.isSubjectHidden()&&this.toggleSubjectHiddenState()}return!0}return!1},setSubject(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";bu.send(de({to:this.get("jid"),from:ul.connection.jid,type:"groupchat"}).c("subject",{xmlns:"jabber:client"}).t(e).tree())},ignorableCSN(e){return e.chat_state&&!e.body&&(e.is_delayed||this.isOwnMessage(e))},isOwnMessage(e){let t;return t=T(e)?e.getAttribute("from"):e instanceof ul.Message?e.get("from"):e.from,me.getResourceFromJid(t)==this.get("nick")},getUpdatedMessageAttributes(e,t){const n=ul.ChatBox.prototype.getUpdatedMessageAttributes.call(this,e,t);if(n.from_muc=t.from_muc,this.isOwnMessage(t)){const s=Object.keys(t).filter((e=>e.startsWith("stanza_id")));Object.assign(n,Ja(t,s)),e.get("received")||(n.received=(new Date).toISOString())}return n},async isJoined(){const e=this.get("jid"),t=ue({to:`${e}/${this.get("nick")}`,type:"get"}).c("ping",{xmlns:me.NS.PING});try{await bu.sendIQ(t)}catch(t){return null===t?z.warn(`isJoined: Timeout error while checking whether we're joined to MUC: ${e}`):z.warn(`isJoined: Apparently we're no longer connected to MUC: ${e}`),!1}return!0},async sendStatusPresence(e,t,n){if(this.session.get("connection_status")===Su.ROOMSTATUS.ENTERED){const s=await ul.xmppstatus.constructPresence(e,this.getRoomJIDAndNick(),t);null==n||n.map((e=>(null==e?void 0:e.tree())??e)).forEach((e=>s.cnode(e).up())),bu.send(s)}},async rejoinIfNecessary(){if(!await this.isJoined())return this.rejoin(),!0},async shouldShowErrorMessage(e){if("Decryption"===e.error_type){if("Message key not found. The counter was repeated or the key was not filled."===e.error_message)return!1;if("not-encrypted-for-this-device"===e.error_condition)return!1}else if("not-acceptable"===e.error_condition&&await this.rejoinIfNecessary())return!1;return ul.ChatBox.prototype.shouldShowErrorMessage.call(this,e)},findDanglingModeration(e){if(!this.messages.length)return null;if(this.messages.last().get("time")>e.time){const t=Array.from(this.messages.models),n=e[`stanza_id ${this.get("jid")}`];return n?(t.reverse(),t.find((e=>{let{attributes:t}=e;return"retracted"===t.moderated&&t.moderated_id===n&&t.moderated_by}))):null}},async handleModeration(e){const t=["editable","moderated","moderated_by","moderated_id","moderation_reason"];if("retracted"===e.moderated){const n={};n[`stanza_id ${this.get("jid")}`]=e.moderated_id;const s=this.messages.findWhere(n);return s?(s.save(Ja(e,t)),!0):(e.dangling_moderation=!0,await this.createMessage(e),!0)}{const n=this.findDanglingModeration(e);if(n){const s=Ja(n.attributes,t),i=Object.assign({dangling_moderation:!1},e,s);return delete i.id,n.save(i),!0}}return!1},getNotificationsText(){const{__:e}=ul,t=this.notifications.toJSON(),n=bu.settings.get("muc_show_info_messages").filter((e=>Su.MUC_ROLE_CHANGES_LIST.includes(e))),s=bu.settings.get("muc_show_info_messages").filter((e=>Su.MUC_TRAFFIC_STATES_LIST.includes(e)));return[...Su.CHAT_STATES,...s,...n].reduce(((n,s)=>{const i=t[s];if(null==i||!i.length)return n;const o=i.map((e=>{var t;return(null===(t=this.getOccupant(e))||void 0===t?void 0:t.getDisplayName())||e}));if(1===o.length){if("composing"===s)return`${n}${e("%1$s is typing",o[0])}\n`;if("paused"===s)return`${n}${e("%1$s has stopped typing",o[0])}\n`;if(s===ul.GONE)return`${n}${e("%1$s has gone away",o[0])}\n`;if("entered"===s)return`${n}${e("%1$s has entered the groupchat",o[0])}\n`;if("exited"===s)return`${n}${e("%1$s has left the groupchat",o[0])}\n`;if("op"===s)return`${n}${e("%1$s is now a moderator",o[0])}\n`;if("deop"===s)return`${n}${e("%1$s is no longer a moderator",o[0])}\n`;if("voice"===s)return`${n}${e("%1$s has been given a voice",o[0])}\n`;if("mute"===s)return`${n}${e("%1$s has been muted",o[0])}\n`}else if(o.length>1){let t;if(o.length>3)t=`${Array.from(o).slice(0,2).join(", ")} and others`;else{const n=o.pop();t=e("%1$s and %2$s",o.join(", "),n)}if("composing"===s)return`${n}${e("%1$s are typing",t)}\n`;if("paused"===s)return`${n}${e("%1$s have stopped typing",t)}\n`;if(s===ul.GONE)return`${n}${e("%1$s have gone away",t)}\n`;if("entered"===s)return`${n}${e("%1$s have entered the groupchat",t)}\n`;if("exited"===s)return`${n}${e("%1$s have left the groupchat",t)}\n`;if("op"===s)return`${n}${e("%1$s are now moderators",o[0])}\n`;if("deop"===s)return`${n}${e("%1$s are no longer moderators",o[0])}\n`;if("voice"===s)return`${n}${e("%1$s have been given voices",o[0])}\n`;if("mute"===s)return`${n}${e("%1$s have been muted",o[0])}\n`}return n}),"")},removeNotification(e,t){const n=this.notifications.toJSON();(t=Array.isArray(t)?t:[t]).forEach((t=>{const s=Array.from(n[t]||[]);if(s.includes(e)){const n=s.indexOf(e);s.splice(n,1),this.notifications.set(t,Array.from(s))}}))},updateNotifications(e,t){const n=this.notifications.toJSON(),s=n[t]||[];if(s.includes(e))return;const i=(i,o)=>(i[o]=o===t?[...s,e]:(n[o]||[]).filter((t=>t!==e)),i),o=Su.CHAT_STATES.reduce(i,{}),r=Su.MUC_TRAFFIC_STATES_LIST.reduce(i,{}),a=Su.MUC_ROLE_CHANGES_LIST.reduce(i,{});this.notifications.set(Object.assign(o,r,a)),window.setTimeout((()=>this.removeNotification(e,t)),1e4)},handleMetadataFastening(e){if(e.ogp_for_id){if(e.from!==this.get("jid"))return!1;const t=this.messages.findWhere({origin_id:e.ogp_for_id});if(t){const n=t.get("ogp_metadata")||[];if(n.filter((t=>t["og:url"]===e["og:url"])).length)return!1;const s=[...n,Ja(e,Om)];return t.save("ogp_metadata",s),!0}}return!1},handleMEPNotification(e){var t;return!(e.from!==this.get("jid")||!e.activities)&&(null===(t=e.activities)||void 0===t||t.forEach((t=>{const n=Object.assign(e,t);this.createMessage(n),bu.trigger("message",{attrs:n,chatbox:this})})),!!e.activities.length)},getDuplicateMessage(e){var t;return null!==(t=e.activities)&&void 0!==t&&t.length?this.messages.findWhere({type:"mep",msgid:e.msgid}):ul.ChatBox.prototype.getDuplicateMessage.call(this,e)},async onMessage(e){if(e=await e,dm.isErrorObject(e))return e.stanza&&z.error(e.stanza),z.error(e.message);if("error"===e.type&&!await this.shouldShowErrorMessage(e))return;const t=this.getDuplicateMessage(e);if(t)"groupchat"===t.get("type")&&this.updateMessage(t,e);else if(!(e.receipt_id||e.is_marker||this.ignorableCSN(e)))if(this.handleMetadataFastening(e)||this.handleMEPNotification(e)||await this.handleRetraction(e)||await this.handleModeration(e)||await this.handleSubjectChange(e))e.nick&&this.removeNotification(e.nick,["composing","paused"]);else if(this.setEditable(e,e.time),e.chat_state&&this.updateNotifications(e.nick,e.chat_state),dm.shouldCreateGroupchatMessage(e)){const t=this.handleCorrection(e)||await this.createMessage(e);this.removeNotification(e.nick,["composing","paused"]),this.handleUnreadMessage(t)}},handleModifyError(e){var t;const n=null===(t=e.querySelector("error text"))||void 0===t?void 0:t.textContent;if(n)if(this.session.get("connection_status")===Su.ROOMSTATUS.CONNECTING)this.setDisconnectionState(n);else{const e={type:"error",message:n,is_ephemeral:!0};this.createMessage(e)}},handleDisconnection(e){var t;const n=null!==e.querySelector("status[code='110']"),s=ec()(`x[xmlns="${me.NS.MUC_USER}"]`,e).pop();if(!s)return;const i=Object.keys(ul.muc.disconnect_messages),o=ec()("status",s).map((e=>e.getAttribute("code"))).filter((e=>i.includes(e)));if(!(n&&o.length>0))return;const r=s.querySelector("item"),a=r?null===(t=r.querySelector("reason"))||void 0===t?void 0:t.textContent:void 0,c=r?_l(r.querySelector("actor"),"getAttribute","nick"):void 0,l=ul.muc.disconnect_messages[o[0]],d=o.includes("301")?Su.ROOMSTATUS.BANNED:Su.ROOMSTATUS.DISCONNECTED;this.setDisconnectionState(l,a,c,d)},getActionInfoMessage(e,t,n){const s=ul.__;return"301"===e?n?s("%1$s has been banned by %2$s",t,n):s("%1$s has been banned",t):"303"===e?s("%1$s's nickname has changed",t):"307"===e?n?s("%1$s has been kicked out by %2$s",t,n):s("%1$s has been kicked out",t):"321"===e?s("%1$s has been removed because of an affiliation change",t):"322"===e?s("%1$s has been removed for not being a member",t):void 0},createAffiliationChangeMessage(e){const t=ul.__,n=e._previousAttributes.affiliation;if(!n)return;const s=e.get("affiliation");"admin"===n&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.EXADMIN)?this.createMessage({type:"info",message:t("%1$s is no longer an admin of this groupchat",e.get("nick"))}):"owner"===n&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.EXOWNER)?this.createMessage({type:"info",message:t("%1$s is no longer an owner of this groupchat",e.get("nick"))}):"outcast"===n&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.EXOUTCAST)&&this.createMessage({type:"info",message:t("%1$s is no longer banned from this groupchat",e.get("nick"))}),"none"===s&&"member"===n&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.EXMEMBER)&&this.createMessage({type:"info",message:t("%1$s is no longer a member of this groupchat",e.get("nick"))}),"member"===s&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.MEMBER)?this.createMessage({type:"info",message:t("%1$s is now a member of this groupchat",e.get("nick"))}):("admin"===s&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.ADMIN)||"owner"==s&&ul.isInfoVisible(Su.AFFILIATION_CHANGES.OWNER))&&this.createMessage({type:"info",message:t("%1$s is now an %2$s of this groupchat",e.get("nick"),s)})},createRoleChangeMessage(e,t){if("none"===t||e.changed.affiliation)return;const n=e._previousAttributes.role;"moderator"===n&&ul.isInfoVisible(Su.MUC_ROLE_CHANGES.DEOP)?this.updateNotifications(e.get("nick"),Su.MUC_ROLE_CHANGES.DEOP):"visitor"===n&&ul.isInfoVisible(Su.MUC_ROLE_CHANGES.VOICE)&&this.updateNotifications(e.get("nick"),Su.MUC_ROLE_CHANGES.VOICE),"visitor"===e.get("role")&&ul.isInfoVisible(Su.MUC_ROLE_CHANGES.MUTE)?this.updateNotifications(e.get("nick"),Su.MUC_ROLE_CHANGES.MUTE):"moderator"===e.get("role")&&!["owner","admin"].includes(e.get("affiliation"))&&ul.isInfoVisible(Su.MUC_ROLE_CHANGES.OP)&&this.updateNotifications(e.get("nick"),Su.MUC_ROLE_CHANGES.OP)},createInfoMessage(e,t,n){const s=ul.__,i={type:"info",is_ephemeral:!0};if(ul.isInfoVisible(e)&&"110"!==e&&("100"!==e||n)){if(e in ul.muc.info_messages)i.message=ul.muc.info_messages[e];else if(!n&&Im.includes(e)){var o,r;const n=me.getResourceFromJid(t.getAttribute("from")),s=ec()(`x[xmlns="${me.NS.MUC_USER}"] item`,t).pop();i.actor=s?null===(o=s.querySelector("actor"))||void 0===o?void 0:o.getAttribute("nick"):void 0,i.reason=s?null===(r=s.querySelector("reason"))||void 0===r?void 0:r.textContent:void 0,i.message=this.getActionInfoMessage(e,n,i.actor)}else if(n&&e in ul.muc.new_nickname_messages){let o;n&&"210"===e?o=me.getResourceFromJid(t.getAttribute("from")):n&&"303"===e&&(o=ec()(`x[xmlns="${me.NS.MUC_USER}"] item`,t).pop().getAttribute("nick")),this.save("nick",o),i.message=s(ul.muc.new_nickname_messages[e],o)}if(i.message){if("201"===e&&this.messages.findWhere(i))return;this.createMessage(i)}}},createInfoMessages(e){const t=ec()(`x[xmlns="${me.NS.MUC_USER}"] status`,e).map((e=>e.getAttribute("code")));t.includes("333")&&t.includes("307")&&t.splice(t.indexOf("307"),1);const n=t.includes("110");t.forEach((t=>this.createInfoMessage(t,e,n)))},setDisconnectionState(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Su.ROOMSTATUS.DISCONNECTED;this.session.save({connection_status:s,disconnection_actor:n,disconnection_message:e,disconnection_reason:t})},onNicknameClash(e){const t=ul.__;if(bu.settings.get("muc_nickname_from_jid")){const t=e.getAttribute("from").split("/")[1];if(t===ul.getDefaultMUCNickname())this.join(t+"-2");else{const e=t.lastIndexOf("-"),n=t.substring(e+1,t.length);this.join(t.substring(0,e+1)+String(Number(n)+1))}}else this.save({nickname_validation_message:t("The nickname you chose is reserved or currently in use, please choose a different one.")}),this.session.save({connection_status:Su.ROOMSTATUS.NICKNAME_REQUIRED})},onErrorPresence(e){var t;const n=ul.__,s=e.querySelector("error"),i=s.getAttribute("type"),o=null===(t=ec()(`text[xmlns="${me.NS.STANZAS}"]`,s).pop())||void 0===t?void 0:t.textContent;if("modify"===i)this.handleModifyError(e);else if("auth"===i)if(ec()(`not-authorized[xmlns="${me.NS.STANZAS}"]`,s).length&&(this.save({password_validation_message:o||n("Password incorrect")}),this.session.save({connection_status:Su.ROOMSTATUS.PASSWORD_REQUIRED})),s.querySelector("registration-required")){const e=n("You are not on the member list of this groupchat.");this.setDisconnectionState(e,o)}else s.querySelector("forbidden")&&this.setDisconnectionState(ul.muc.disconnect_messages[301],o,null,Su.ROOMSTATUS.BANNED);else if("cancel"===i)if(s.querySelector("not-allowed")){const e=n("You are not allowed to create new groupchats.");this.setDisconnectionState(e,o)}else if(s.querySelector("not-acceptable")){const e=n("Your nickname doesn't conform to this groupchat's policies.");this.setDisconnectionState(e,o)}else if(ec()(`gone[xmlns="${me.NS.STANZAS}"]`,s).length){var r;const e=null===(r=ec()(`gone[xmlns="${me.NS.STANZAS}"]`,s).pop())||void 0===r?void 0:r.textContent.replace(/^xmpp:/,"").replace(/\?join$/,"");this.save({moved_jid:e,destroyed_reason:o}),this.session.save({connection_status:Su.ROOMSTATUS.DESTROYED})}else if(s.querySelector("conflict"))this.onNicknameClash(e);else if(s.querySelector("item-not-found")){const e=n("This groupchat does not (yet) exist.");this.setDisconnectionState(e,o)}else if(s.querySelector("service-unavailable")){const e=n("This groupchat has reached its maximum number of participants.");this.setDisconnectionState(e,o)}else if(s.querySelector("remote-server-not-found")){const e=n("Remote server not found");this.setDisconnectionState(e,o)}else if(s.querySelector("forbidden")){const e=n("You're not allowed to enter this groupchat");this.setDisconnectionState(e,o)}else{const e=n("An error happened while trying to enter this groupchat");this.setDisconnectionState(e,o)}},onPresenceFromMUCHost(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error");"wait"===(null==t?void 0:t.getAttribute("type"))&&null!=t&&t.querySelector("resource-constraint")&&this.session.get("connection_status")===Su.ROOMSTATUS.DISCONNECTED&&this.rejoin()}},onPresence(e){if("error"===e.getAttribute("type"))return this.onErrorPresence(e);this.createInfoMessages(e),e.querySelector("status[code='110']")?(this.onOwnPresence(e),"none"!==this.getOwnRole()&&this.session.get("connection_status")===Su.ROOMSTATUS.CONNECTING&&this.session.save("connection_status",Su.ROOMSTATUS.CONNECTED)):this.updateOccupantsOnPresence(e)},async onOwnPresence(e){await this.occupants.fetched;const t=this.session.get("connection_status");if("unavailable"!==e.getAttribute("type")&&t!==Su.ROOMSTATUS.ENTERED&&t!==Su.ROOMSTATUS.CLOSING?(this.session.save("connection_status",Su.ROOMSTATUS.ENTERED,{silent:!0}),this.updateOccupantsOnPresence(e),this.session.trigger("change:connection_status",this.session,t)):this.updateOccupantsOnPresence(e),"unavailable"!==e.getAttribute("type")){if(e.querySelector("status[code='201']"))if(this.get("auto_configure"))this.autoConfigureChatRoom().then((()=>this.refreshDiscoInfo()));else{if(!bu.settings.get("muc_instant_rooms"))return void this.session.save({view:Su.MUC.VIEWS.CONFIG});this.sendConfiguration().then((()=>this.refreshDiscoInfo()))}else this.features.get("fetched")||("owner"===this.getOwnAffiliation()&&this.get("auto_configure")?this.autoConfigureChatRoom().then((()=>this.refreshDiscoInfo())):this.getDiscoInfo())}else this.handleDisconnection(e)},isUserMentioned(e){const t=this.get("nick");if(e.get("references").length){return e.get("references").filter((e=>"mention"===e.type)).map((e=>e.value)).includes(t)}return new RegExp(`\\b${t}\\b`).test(e.get("body"))},incrementUnreadMsgsCounter(e){const t={num_unread_general:this.get("num_unread_general")+1};0===this.get("num_unread_general")&&(t.first_unread_id=e.get("id")),this.isUserMentioned(e)&&(t.num_unread=this.get("num_unread")+1),this.save(t)},clearUnreadMsgCounter(){(this.get("num_unread_general")>0||this.get("num_unread")>0||this.get("has_activity"))&&this.sendMarkerForMessage(this.messages.last()),Zc(this,{has_activity:!1,num_unread:0,num_unread_general:0})}},Dm=Rm;const zm=class extends Ac{defaults(){return{hats:[],show:"offline",states:[]}}save(e,t,n){let s;return null==e?super.save(e,t,n):("object"==typeof e?(s=e,n=t):(s={})[e]=t,s.occupant_id&&(s.id=s.occupant_id),super.save(s,n))}getDisplayName(){return this.get("nick")||this.get("jid")}isMember(){return["admin","owner","member"].includes(this.get("affiliation"))}isModerator(){return["admin","owner"].includes(this.get("affiliation"))||"moderator"===this.get("role")}isSelf(){return this.get("states").includes("110")}},Lm={moderator:1,participant:2,visitor:3,none:2},{Strophe:Pm,sizzle:Fm,u:Um}=Su.env;function Bm(){const e=bu.settings.get("muc_fetch_members");return Array.isArray(e)?e:e?["member","admin","owner"]:[]}function qm(e){let t=bu.settings.get("modtools_disable_assign");return Array.isArray(t)||(t=t?og:[]),"moderator"===e.get("role")?og.filter((e=>!t.includes(e))):[]}function Hm(){ul.connection.addHandler((e=>(ul.onDirectMUCInvitation(e),!0)),"jabber:x:conference","message")}function Gm(){return ul.chatboxes.filter((e=>e.get("type")===ul.CHATROOMS_TYPE)).forEach((e=>e.session.save({connection_status:Su.ROOMSTATUS.DISCONNECTED})))}async function Wm(e){if("visible"===e.state&&bu.connection.connected()){(await bu.rooms.get()).forEach((e=>e.rejoinIfNecessary()))}}async function Vm(e){if(!Um.isValidMUCJID(e))return z.warn(`invalid jid "${e}" provided in url fragment`);await bu.waitUntil("roomsAutoJoined"),bu.settings.get("allow_bookmarks")&&await bu.waitUntil("bookmarksInitialized"),bu.rooms.open(e)}async function Jm(e){const{__:t}=ul,n=Fm('x[xmlns="jabber:x:conference"]',e).pop(),s=Pm.getBareJidFromJid(e.getAttribute("from")),i=n.getAttribute("jid"),o=n.getAttribute("reason");let r;if(bu.settings.get("auto_join_on_invite"))r=!0;else{let e=ul.roster.get(s);e=e?e.getDisplayName():s,r=o?confirm(t('%1$s has invited you to join a groupchat: %2$s, and left the following reason: "%3$s"',e,i,o)):confirm(t("%1$s has invited you to join a groupchat: %2$s",e,i))}if(!0===r){(await async function(e,t){t.type=ul.CHATROOMS_TYPE,t.id=e;const n=await bu.rooms.get(e,t,!0);return n.maybeShow(!0),n}(i,{password:n.getAttribute("password")})).session.get("connection_status")===Su.ROOMSTATUS.DISCONNECTED&&ul.chatboxes.get(i).rejoin()}}function Qm(){if(!ul.xmppstatus)throw new Error("Can't call _converse.getDefaultMUCNickname before the statusInitialized has been fired.");const e=ul.xmppstatus.getNickname();return e||(bu.settings.get("muc_nickname_from_jid")?Pm.unescapeNode(Pm.getNodeFromJid(ul.bare_jid)):void 0)}function Zm(e){return!!bu.settings.get("muc_show_info_messages").includes(e)}async function Km(){await Promise.all(bu.settings.get("auto_join_rooms").map((e=>"string"==typeof e?ul.chatboxes.where({jid:e}).length?Promise.resolve():bu.rooms.open(e):we(e)?bu.rooms.open(e.jid,{...e}):(z.error('Invalid muc criteria specified for "auto_join_rooms"'),Promise.resolve())))),bu.trigger("roomsAutoJoined")}function Ym(){bu.disco.own.features.add(Pm.NS.MUC),bu.settings.get("allow_muc_invitations")&&bu.disco.own.features.add("jabber:x:conference")}function Xm(){ul.chatboxes.where({type:ul.CHATROOMS_TYPE}).forEach((e=>Zc(e.session,{connection_status:Su.ROOMSTATUS.DISCONNECTED})))}function eg(){window.addEventListener(ul.unloadevent,(()=>{!bu.connection.isType("websocket")||bu.settings.get("enable_smacks")&&ul.session.get("smacks_stream_id")||Gm()}))}function tg(){ul.connection.addHandler((e=>{const t=Pm.getBareJidFromJid(e.getAttribute("from"));return ul.chatboxes.get(t)||bu.waitUntil("chatBoxesFetched").then((async()=>{const n=ul.chatboxes.get(t);n&&(await n.initialized,n.message_handler.run(e))})),!0}),null,"message","groupchat")}Object.assign(ul,{getAssignableRoles:qm});const ng=class extends ld{constructor(){super(...arguments),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"model",zm)}comparator(e,t){const n=e.get("role")||"none",s=t.get("role")||"none";if(Lm[n]===Lm[s]){const n=e.getDisplayName().toLowerCase(),s=t.getDisplayName().toLowerCase();return ns?1:0}return Lm[n]xm(e,n)))),i=s.reduce(((e,t)=>dm.isErrorObject(t)?e:[...t,...e]),[]),o=t.filter((e=>!dm.isErrorObject(s[t.indexOf(e)]))),r=i.map((e=>e.jid)).filter((e=>void 0!==e)),a=i.map((e=>!e.jid&&e.nick||void 0)).filter((e=>void 0!==e)),c=this.filter((e=>o.includes(e.get("affiliation"))&&!a.includes(e.get("nick"))&&!r.includes(e.get("jid"))));c.forEach((e=>{e.get("jid")!==ul.bare_jid&&("offline"===e.get("show")?e.destroy():e.save("affiliation",null))})),i.forEach((e=>{const t=this.findOccupant(e);t?t.save(e):this.create(e)})),bu.trigger("membersFetched")}findOccupant(e){if(e.occupant_id&&this.get(e.occupant_id))return this.get(e.occupant_id);const t=e.jid&&me.getBareJidFromJid(e.jid);return t&&this.findWhere({jid:t})||e.nick&&this.findWhere({nick:e.nick})}},sg={affiliations:{set:(e,t)=>(t=Array.isArray(t)?t:[t],Am(e=Array.isArray(e)?e:[e],t))}},ig={rooms:{create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t="string"==typeof t?{nick:t}:t||{},!t.nick&&bu.settings.get("muc_nickname_from_jid")&&(t.nick=me.getNodeFromJid(ul.bare_jid)),void 0===e)throw new TypeError("rooms.create: You need to provide at least one JID");return"string"==typeof e?bu.rooms.get(dm.getJIDFromURI(e),t,!0):e.map((e=>bu.rooms.get(dm.getJIDFromURI(e),t,!0)))},async open(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(await bu.waitUntil("chatBoxesFetched"),void 0===e){const e="rooms.open: You need to provide at least one JID";throw z.error(e),new TypeError(e)}if("string"==typeof e){const s=await bu.rooms.get(e,t,!0);return!t.hidden&&(null==s||s.maybeShow(n)),s}{const s=await Promise.all(e.map((e=>bu.rooms.get(e,t,!0))));return s.forEach((e=>!t.hidden&&e.maybeShow(n))),s}},async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];async function s(e){e=dm.getJIDFromURI(e);let s=await bu.chatboxes.get(e);return!s&&n?s=await bu.chatboxes.create(e,t,ul.ChatRoom):(s=s&&s.get("type")===ul.CHATROOMS_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}if(await bu.waitUntil("chatBoxesFetched"),void 0===e){return(await bu.chatboxes.get()).filter((e=>e.get("type")===ul.CHATROOMS_TYPE))}return"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}},og=["moderator","participant","visitor"],rg=["owner","admin","member","outcast","none"];Su.AFFILIATION_CHANGES={OWNER:"owner",ADMIN:"admin",MEMBER:"member",EXADMIN:"exadmin",EXOWNER:"exowner",EXOUTCAST:"exoutcast",EXMEMBER:"exmember"},Su.AFFILIATION_CHANGES_LIST=Object.values(Su.AFFILIATION_CHANGES),Su.MUC_TRAFFIC_STATES={ENTERED:"entered",EXITED:"exited"},Su.MUC_TRAFFIC_STATES_LIST=Object.values(Su.MUC_TRAFFIC_STATES),Su.MUC_ROLE_CHANGES={OP:"op",DEOP:"deop",VOICE:"voice",MUTE:"mute"},Su.MUC_ROLE_CHANGES_LIST=Object.values(Su.MUC_ROLE_CHANGES),Su.MUC={},Su.MUC.INFO_CODES={visibility_changes:["100","102","103","172","173","174"],self:["110"],non_privacy_changes:["104","201"],muc_logging_changes:["170","171"],nickname_changes:["210","303"],disconnected:["301","307","321","322","332","333"],affiliation_changes:[...Su.AFFILIATION_CHANGES_LIST],join_leave_events:[...Su.MUC_TRAFFIC_STATES_LIST],role_changes:[...Su.MUC_ROLE_CHANGES_LIST]};const{Strophe:ag}=Su.env;ag.addNamespace("MUC_ADMIN",ag.NS.MUC+"#admin"),ag.addNamespace("MUC_OWNER",ag.NS.MUC+"#owner"),ag.addNamespace("MUC_REGISTER","jabber:iq:register"),ag.addNamespace("MUC_ROOMCONF",ag.NS.MUC+"#roomconfig"),ag.addNamespace("MUC_USER",ag.NS.MUC+"#user"),ag.addNamespace("MUC_HATS","xmpp:prosody.im/protocol/hats:1"),ag.addNamespace("CONFINFO","urn:ietf:params:xml:ns:conference-info"),Su.MUC_NICK_CHANGED_CODE="303",Su.ROOM_FEATURES=["passwordprotected","unsecured","hidden","publicroom","membersonly","open","persistent","temporary","nonanonymous","semianonymous","moderated","unmoderated","mam_enabled"],Su.ROOMSTATUS={CONNECTED:0,CONNECTING:1,NICKNAME_REQUIRED:2,PASSWORD_REQUIRED:3,DISCONNECTED:4,ENTERED:5,DESTROYED:6,BANNED:7,CLOSING:8},Su.plugins.add("converse-muc",{dependencies:["converse-chatboxes","converse-chat","converse-disco"],overrides:{ChatBoxes:{model(e,t){const{_converse:n}=this.__super__;return e&&e.type==n.CHATROOMS_TYPE?new n.ChatRoom(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){const{__:e,___:t}=ul;if(bu.settings.extend({allow_muc_invitations:!0,auto_join_on_invite:!1,auto_join_rooms:[],auto_register_muc_nickname:!1,hide_muc_participants:!1,locked_muc_domain:!1,modtools_disable_assign:!1,muc_clear_messages_on_leave:!0,muc_domain:void 0,muc_fetch_members:!0,muc_history_max_stanzas:void 0,muc_instant_rooms:!0,muc_nickname_from_jid:!1,muc_send_probes:!1,muc_show_info_messages:[...Su.MUC.INFO_CODES.visibility_changes,...Su.MUC.INFO_CODES.self,...Su.MUC.INFO_CODES.non_privacy_changes,...Su.MUC.INFO_CODES.muc_logging_changes,...Su.MUC.INFO_CODES.nickname_changes,...Su.MUC.INFO_CODES.disconnected,...Su.MUC.INFO_CODES.affiliation_changes,...Su.MUC.INFO_CODES.join_leave_events,...Su.MUC.INFO_CODES.role_changes],muc_show_logs_before_join:!1,muc_subscribe_to_rai:!1}),bu.promises.add(["roomsAutoJoined"]),bu.settings.get("locked_muc_domain")&&"string"!=typeof bu.settings.get("muc_domain"))throw new Error("Config Error: it makes no sense to set locked_muc_domain to true when muc_domain is not set");Su.env.muc_utils={computeAffiliationsDelta:km},Object.assign(bu,ig),Object.assign(bu.rooms,sg),ul.muc={info_messages:{100:e("This groupchat is not anonymous"),102:e("This groupchat now shows unavailable members"),103:e("This groupchat does not show unavailable members"),104:e("The groupchat configuration has changed"),170:e("Groupchat logging is now enabled"),171:e("Groupchat logging is now disabled"),172:e("This groupchat is now no longer anonymous"),173:e("This groupchat is now semi-anonymous"),174:e("This groupchat is now fully-anonymous"),201:e("A new groupchat has been created")},new_nickname_messages:{210:t("Your nickname has been automatically set to %1$s"),303:t("Your nickname has been changed to %1$s")},disconnect_messages:{301:e("You have been banned from this groupchat"),333:e("You have exited this groupchat due to a technical problem"),307:e("You have been kicked from this groupchat"),321:e("You have been removed from this groupchat because of an affiliation change"),322:e("You have been removed from this groupchat because the groupchat has changed to members-only and you're not a member"),332:e("You have been removed from this groupchat because the service hosting it is being shut down")}},ul.router.route("converse/room?jid=:jid",Vm),ul.ChatRoom=ul.ChatBox.extend(Dm),ul.ChatRoomMessage=ul.Message.extend(om),ul.ChatRoomOccupants=ng,ul.ChatRoomOccupant=zm,ul.ChatRoomMessages=ld.extend({model:ul.ChatRoomMessage,comparator:"time"}),Object.assign(ul,{getDefaultMUCNickname:Qm,isInfoVisible:Zm,onDirectMUCInvitation:Jm}),bu.settings.get("allow_muc_invitations")&&(bu.listen.on("connected",Hm),bu.listen.on("reconnected",Hm)),bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(`${ag.NS.CONFINFO}+notify`))),bu.listen.on("addClientFeatures",Ym),bu.listen.on("beforeResourceBinding",tg),bu.listen.on("beforeTearDown",Xm),bu.listen.on("chatBoxesFetched",Km),bu.listen.on("disconnected",Gm),bu.listen.on("statusInitialized",eg),bu.listen.on("windowStateChanged",Wm)}});const{Strophe:cg}=Su.env,lg=Ac.extend({idAttribute:"jid",getDisplayName(){return cg.xmlunescape(this.get("name"))}}),{Strophe:dg,$iq:ug,sizzle:hg}=Su.env,mg={model:lg,comparator:e=>e.get("name").toLowerCase(),async initialize(){this.on("add",(e=>this.openBookmarkedRoom(e).then((e=>this.markRoomAsBookmarked(e))).catch((e=>z.fatal(e))))),this.on("remove",this.markRoomAsUnbookmarked,this),this.on("remove",this.sendBookmarkStanza,this);const e=`converse.room-bookmarks${ul.bare_jid}`;this.fetched_flag=e+"fetched",La(this,e),await this.fetchBookmarks(),bu.trigger("bookmarksInitialized",this)},async openBookmarkedRoom(e){if(bu.settings.get("muc_respect_autojoin")&&e.get("autojoin")){(await bu.rooms.create(e.get("jid"),{nick:e.get("nick")})).maybeShow()}return e},fetchBookmarks(){const e=ba();return window.sessionStorage.getItem(this.fetched_flag)?this.fetch({success:()=>e.resolve(),error:()=>e.resolve()}):this.fetchBookmarksFromServer(e),e},createBookmark(e){this.create(e),this.sendBookmarkStanza().catch((t=>this.onBookmarkError(t,e)))},sendBookmarkStanza(){const e=ug({type:"set",from:ul.connection.jid}).c("pubsub",{xmlns:dg.NS.PUBSUB}).c("publish",{node:dg.NS.BOOKMARKS}).c("item",{id:"current"}).c("storage",{xmlns:dg.NS.BOOKMARKS});return this.forEach((t=>{e.c("conference",{name:t.get("name"),autojoin:t.get("autojoin"),jid:t.get("jid")}).c("nick").t(t.get("nick")).up().up()})),e.up().up().up(),e.c("publish-options").c("x",{xmlns:dg.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t("http://jabber.org/protocol/pubsub#publish-options").up().up().c("field",{var:"pubsub#persist_items"}).c("value").t("true").up().up().c("field",{var:"pubsub#access_model"}).c("value").t("whitelist"),bu.sendIQ(e)},onBookmarkError(e,t){var n;const{__:s}=ul;z.error("Error while trying to add bookmark"),z.error(e),bu.alert("error",s("Error"),[s("Sorry, something went wrong while trying to save your bookmark.")]),null===(n=this.get(t.jid))||void 0===n||n.destroy()},fetchBookmarksFromServer(e){const t=ug({from:ul.connection.jid,type:"get"}).c("pubsub",{xmlns:dg.NS.PUBSUB}).c("items",{node:dg.NS.BOOKMARKS});bu.sendIQ(t).then((t=>this.onBookmarksReceived(e,t))).catch((t=>this.onBookmarksReceivedError(e,t)))},markRoomAsBookmarked(e){const t=ul.chatboxes.get(e.get("jid"));null==t||t.save("bookmarked",!0)},markRoomAsUnbookmarked(e){const t=ul.chatboxes.get(e.get("jid"));null==t||t.save("bookmarked",!1)},createBookmarksFromStanza(e){const t=dg.NS.BOOKMARKS;hg(`items[node="${t}"] item storage[xmlns="${t}"] conference`,e).forEach((e=>{var t;const n=e.getAttribute("jid"),s=this.get(n),i={jid:n,name:e.getAttribute("name")||n,autojoin:"true"===e.getAttribute("autojoin"),nick:(null===(t=e.querySelector("nick"))||void 0===t?void 0:t.textContent)||""};s?s.save(i):this.create(i)}))},onBookmarksReceived(e,t){if(this.createBookmarksFromStanza(t),window.sessionStorage.setItem(this.fetched_flag,!0),void 0!==e)return e.resolve()},onBookmarksReceivedError(e,t){const{__:n}=ul;if(null===t)z.error("Error: timeout while fetching bookmarks"),bu.alert("error",n("Timeout Error"),[n("The server did not return your bookmarks within the allowed time. You can reload the page to request them again.")]);else{if(e)return t.querySelector('error[type="cancel"] item-not-found')?(window.sessionStorage.setItem(this.fetched_flag,!0),e.resolve()):(z.error("Error while fetching bookmarks"),z.error(t),e.reject(new Error("Could not fetch bookmarks")));z.error("Error while fetching bookmarks"),z.error(t)}},async getUnopenedBookmarks(){return await bu.waitUntil("bookmarksInitialized"),await bu.waitUntil("chatBoxesFetched"),this.filter((e=>!ul.chatboxes.get(e.get("jid"))))}},gg=mg,{Strophe:fg,sizzle:pg}=Su.env;async function vg(){const e=await bu.disco.getIdentity("pubsub","pep",ul.bare_jid);return bu.settings.get("allow_public_bookmarks")?!!e:bu.disco.supports(fg.NS.PUBSUB+"#publish-options",ul.bare_jid)}function _g(e){return pg(`event[xmlns="${fg.NS.PUBSUB}#event"] items[node="${fg.NS.BOOKMARKS}"]`,e).length&&bu.waitUntil("bookmarksInitialized").then((()=>ul.bookmarks.createBookmarksFromStanza(e))).catch((e=>z.fatal(e))),!0}const{Strophe:yg}=Su.env;yg.addNamespace("BOOKMARKS","storage:bookmarks"),Su.plugins.add("converse-bookmarks",{dependencies:["converse-chatboxes","converse-muc"],overrides:{ChatRoom:{getDisplayName(){var e;const{_converse:t,getDisplayName:n}=this.__super__,s=this.get("bookmarked")?null===(e=t.bookmarks)||void 0===e?void 0:e.get(this.get("jid")):null;return(null==s?void 0:s.get("name"))||n.apply(this,arguments)},getAndPersistNickname(e){var t,n,s;return e=e||(t=this.get("jid"),bu.settings.get("allow_bookmarks")?null===(n=ul.bookmarks)||void 0===n||null===(s=n.get(t))||void 0===s?void 0:s.get("nick"):null),this.__super__.getAndPersistNickname.call(this,e)}}},initialize(){bu.settings.extend({allow_bookmarks:!0,allow_public_bookmarks:!1,muc_respect_autojoin:!0}),bu.promises.add("bookmarksInitialized"),ul.Bookmark=lg,ul.Bookmarks=ld.extend(gg),ul.BookmarksList=Ac.extend({defaults:{"toggle-state":ul.OPENED}}),bu.listen.on("addClientFeatures",(()=>{bu.settings.get("allow_bookmarks")&&bu.disco.own.features.add(yg.NS.BOOKMARKS+"+notify")})),bu.listen.on("clearSession",(()=>{ul.bookmarks&&(ul.bookmarks.clearStore({silent:!0}),window.sessionStorage.removeItem(ul.bookmarks.fetched_flag),delete ul.bookmarks)})),bu.listen.on("connected",(async()=>{const{connection:e}=ul;e.addHandler(_g,null,"message","headline",null,ul.bare_jid),await Promise.all([bu.waitUntil("chatBoxesFetched")]),async function(){bu.settings.get("allow_bookmarks")&&await vg()&&(ul.bookmarks=new ul.Bookmarks)}()}))}});const{Strophe:bg}=Su.env,wg="converse.bosh-session";Su.plugins.add("converse-bosh",{enabled:()=>!ul.api.settings.get("blacklisted_plugins").includes("converse-bosh"),initialize(){bu.settings.extend({bosh_service_url:void 0,prebind_url:null}),ul.startNewPreboundBOSHSession=function(){if(!bu.settings.get("prebind_url"))throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url");const e=new XMLHttpRequest;e.open("GET",bu.settings.get("prebind_url"),!0),e.setRequestHeader("Accept","application/json, text/javascript"),e.onload=async function(){if(e.status>=200&&e.status<400){const t=JSON.parse(e.responseText),n=await Rc(t.jid);ul.connection.attach(n,t.sid,t.rid,ul.connection.onConnectStatusChanged,59)}else e.onerror()},e.onerror=function(){delete ul.connection,bu.trigger("noResumeableBOSHSession",ul)},e.send()},ul.restoreBOSHSession=async function(){const e=(await async function(){const e=wg;if(ul.bosh_session||(ul.bosh_session=new Ac({id:e}),ul.bosh_session.browserStorage=ul.createStore(e,"session"),await new Promise((e=>ul.bosh_session.fetch({success:e,error:e})))),ul.jid){if(ul.bosh_session.get("jid")!==ul.jid){const e=await Rc(ul.jid);ul.bosh_session.clear({silent:!0}),ul.bosh_session.save({jid:e})}}else{const e=ul.bosh_session.get("jid");e&&await Rc(e)}return ul.bosh_session}()).get("jid");if(e&&ul.connection._proto instanceof bg.Bosh)try{return ul.connection.restore(e,ul.connection.onConnectStatusChanged),!0}catch(t){return!ul.isTestEnv()&&z.warn("Could not restore session for jid: "+e+" Error message: "+t.message),!1}return!1},bu.listen.on("clearSession",(()=>{if(void 0===ul.bosh_session){const e=wg;sessionStorage.removeItem(e),sessionStorage.removeItem(`${e}-${e}`)}else ul.bosh_session.destroy(),delete ul.bosh_session})),bu.listen.on("setUserJID",(()=>{void 0!==ul.bosh_session&&ul.bosh_session.save({jid:ul.jid})})),bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(bg.NS.BOSH))),Object.assign(bu,{tokens:{get:e=>void 0===ul.connection?null:"rid"===e.toLowerCase()?ul.connection.rid||ul.connection._proto.rid:"sid"===e.toLowerCase()?ul.connection.sid||ul.connection._proto.sid:void 0}})}});const{Strophe:Sg,$build:xg}=Su.env;function Eg(e,t){return e.sort(((e,n)=>e[t]>n[t]?-1:1))}function Ag(){const e=ul.api.disco.own.identities.get(),t=ul.api.disco.own.features.get();e.length>1&&(Eg(e,"category"),Eg(e,"type"),Eg(e,"lang"));let n=e.reduce(((e,t)=>`${e}${t.category}/${t.type}/${(null==t?void 0:t.lang)??""}/${t.name}<`),"");return t.sort(),n=t.reduce(((e,t)=>`${e}${t}<`),n),ae.b64_sha1(n)}function Cg(){return xg("c",{xmlns:Sg.NS.CAPS,hash:"sha-1",node:"https://conversejs.org",ver:Ag()}).nodeTree}const{Strophe:kg}=Su.env;kg.addNamespace("CAPS","http://jabber.org/protocol/caps"),Su.plugins.add("converse-caps",{dependencies:["converse-status"],initialize(){bu.listen.on("constructedPresence",((e,t)=>t.root().cnode(Cg()).up()&&t)),bu.listen.on("constructedMUCPresence",((e,t)=>t.root().cnode(Cg()).up()&&t))}});const{u:jg}=Su.env;async function Tg(e){var t;if(e&&ul.session.get("carbons_enabled")){if(ul.session.get("smacks_enabled"))return;ul.session.set({carbons_enabled:!1})}if(!bu.settings.get("message_carbons")||null!==(t=ul.session)&&void 0!==t&&t.get("carbons_enabled"))return;const n=new me.Builder("iq",{from:ul.connection.jid,type:"set"}).c("enable",{xmlns:me.NS.CARBONS}),s=await bu.sendIQ(n,null,!1);null===s?z.warn("A timeout occurred while trying to enable carbons"):jg.isErrorStanza(s)?(z.warn("An error occurred while trying to enable message carbons."),z.error(s)):(ul.session.set({carbons_enabled:!0}),z.debug("Message carbons have been enabled.")),ul.session.save()}Su.plugins.add("converse-carbons",{initialize(){bu.settings.extend({message_carbons:!0}),bu.listen.on("connected",(()=>Tg())),bu.listen.on("reconnected",(()=>Tg(!0)))}});const $g=ld.extend({comparator:"time_opened",model:(e,t)=>new ul.ChatBox(e,t),onChatBoxesFetched(e){e.filter((e=>!e.isValid())).forEach((e=>e.destroy())),bu.trigger("chatBoxesFetched")},onConnected(e){e||(La(this,`converse.chatboxes-${ul.bare_jid}`),this.fetch({add:!0,success:e=>this.onChatBoxesFetched(e)}))}}),Ng=$g,{Strophe:Og}=Su.env;async function Ig(e,t,n){let s;e=Og.getBareJidFromJid(e.toLowerCase()),Object.assign(t,{jid:e,id:e});try{s=new n(t,{collection:ul.chatboxes})}catch(e){return z.error(e),null}return await s.initialized,s.isValid()?(ul.chatboxes.add(s),s):(s.destroy(),null)}const Mg={async create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return await bu.waitUntil("chatBoxesFetched"),"string"==typeof e?Ig(e,t,n):Promise.all(e.map((e=>Ig(e,t,n))))},get:async e=>(await bu.waitUntil("chatBoxesFetched"),void 0===e?ul.chatboxes.models:"string"==typeof e?ul.chatboxes.get(e.toLowerCase()):(e=e.map((e=>e.toLowerCase())),ul.chatboxes.models.filter((t=>e.includes(t.get("jid"))))))},{Strophe:Rg}=Su.env;Su.plugins.add("converse-chatboxes",{dependencies:["converse-emoji","converse-roster","converse-vcard"],initialize(){bu.promises.add(["chatBoxesFetched","chatBoxesInitialized","privateChatsAutoJoined"]),Object.assign(bu,{chatboxes:Mg}),ul.ChatBoxes=Ng,bu.listen.on("addClientFeatures",(()=>{bu.disco.own.features.add(Rg.NS.MESSAGE_CORRECT),bu.disco.own.features.add(Rg.NS.HTTPUPLOAD),bu.disco.own.features.add(Rg.NS.OUTOFBAND)})),bu.listen.on("pluginsInitialized",(()=>{ul.chatboxes=new ul.ChatBoxes,bu.trigger("chatBoxesInitialized")})),bu.listen.on("presencesInitialized",(e=>ul.chatboxes.onConnected(e))),bu.listen.on("reconnected",(()=>ul.chatboxes.forEach((e=>e.onReconnection()))))}}),Su.plugins.add("converse-headlines",{dependencies:["converse-chat"],overrides:{ChatBoxes:{model(e,t){const{_converse:n}=this.__super__;return e.type==n.HEADLINES_TYPE?new n.HeadlinesBox(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){function e(){ul.connection.addHandler((e=>async function(e){if(ih(e)||oh(e)){const t=e.getAttribute("from");if(await bu.waitUntil("rosterInitialized"),t.includes("@")&&!ul.roster.get(t)&&!bu.settings.get("allow_non_roster_messaging"))return;if(null===e.querySelector("body"))return;const n=ul.chatboxes.create({id:t,jid:t,type:ul.HEADLINES_TYPE,from:t}),s=await Sh(e);await n.createMessage(s),bu.trigger("message",{chatbox:n,stanza:e,attrs:s})}}(e)||!0),null,"message")}ul.HeadlinesBox=ul.ChatBox.extend({defaults(){return{bookmarked:!1,hidden:["mobile","fullscreen"].includes(bu.settings.get("view_mode")),message_type:"headline",num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),type:ul.HEADLINES_TYPE}},async initialize(){this.set({box_id:`box-${this.get("jid")}`}),this.initUI(),this.initMessages(),await this.fetchMessages(),bu.trigger("headlinesBoxInitialized",this)}}),bu.listen.on("connected",e),bu.listen.on("reconnected",e),Object.assign(bu,{headlines:{async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];async function s(e){let s=await bu.chatboxes.get(e);return!s&&n?s=await bu.chatboxes.create(e,t,ul.HeadlinesBox):(s=s&&s.get("type")===ul.HEADLINES_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}if(void 0===e){return(await bu.chatboxes.get()).filter((e=>e.get("type")===ul.HEADLINES_TYPE))}return"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}})}});const Dg=Su.env.utils;class zg extends Ac{defaults(){return{msgid:Dg.getUniqueId(),is_ephemeral:!1}}}const{Strophe:Lg,$build:Pg}=Su.env;Lg.addNamespace("RSM","http://jabber.org/protocol/rsm");const Fg=["after","before","index","max"],Ug=e=>Number(e),Bg=e=>e.toString(),qg={after:Bg,before:Bg,count:Ug,first:Bg,index:Ug,last:Bg,max:Ug},Hg=e=>void 0===e,Gg=Object.keys(qg);class Wg{static getQueryParameters(){return Ja(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Fg)}static parseXMLResult(e){const t={};for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.query=Wg.getQueryParameters(e),this.result=e.xml?Wg.parseXMLResult(e.xml):{}}toXML(){const e=Pg("set",{xmlns:Lg.NS.RSM});return Fg.reduce(((e,t)=>Hg(this.query[t])?e:e.c(t).t((this.query[t]||"").toString()).up()),e).tree()}next(e,t){const n=Object.assign({},this.query,{after:this.result.last,before:t,max:e});return new Wg(n)}previous(e,t){const n=Object.assign({},this.query,{after:t,before:this.result.first,max:e});return new Wg(n)}}ul.RSM_ATTRIBUTES=Gg,ul.RSM=Wg;const{Strophe:Vg,$iq:Jg,dayjs:Qg}=Su.env,{NS:Zg}=Vg,Kg=Su.env.utils,Yg={archive:{async query(e){if(!bu.connection.connected())throw new Error("Can't call `api.archive.query` before having established an XMPP session");const t={type:"set"};if(e&&e.groupchat){if(!e.with)throw new Error('You need to specify a "with" value containing the chat room JID, when querying groupchat messages.');t.to=e.with}const n=t.to||ul.bare_jid;if(!await bu.disco.supports(Zg.MAM,n))return z.warn(`Did not fetch MAM archive for ${n} because it doesn't support ${Zg.MAM}`),{messages:[]};const s=Kg.getUniqueId(),i=Jg(t).c("query",{xmlns:Zg.MAM,queryid:s});if(e){i.c("x",{xmlns:Zg.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(Zg.MAM).up().up(),e.with&&!e.groupchat&&i.c("field",{var:"with"}).c("value").t(e.with).up().up(),["start","end"].forEach((t=>{if(e[t]){const n=Qg(e[t]);if(!n.isValid())throw new TypeError(`archive.query: invalid date provided for: ${t}`);i.c("field",{var:t}).c("value").t(n.toISOString()).up().up()}})),i.up();const t=new Wg(e);Object.keys(t.query).length&&i.cnode(t.toXML())}const o=[],r=ul.connection.addHandler((t=>{const n=ec()(`message > result[xmlns="${Zg.MAM}"]`,t).pop();if(void 0===n||n.getAttribute("queryid")!==s)return!0;const i=t.getAttribute("from")||ul.bare_jid;if(e.groupchat){if(i!==e.with)return z.warn(`Ignoring alleged groupchat MAM message from ${t.getAttribute("from")}`),!0}else if(i!==ul.bare_jid)return z.warn(`Ignoring alleged MAM message from ${t.getAttribute("from")}`),!0;return o.push(t),!0}),Zg.MAM);let a;const c=bu.settings.get("message_archiving_timeout"),l=await bu.sendIQ(i,c,!1);if(null===l){const{__:e}=ul,t=e("Timeout while trying to fetch archived messages.");return z.error(t),a=new ul.TimeoutError(t),{messages:o,error:a}}if(Kg.isErrorStanza(l)){const{__:e}=ul,t=e("An error occurred while querying for archived messages.");return z.error(t),z.error(l),a=new Error(t),{messages:o,error:a}}let d;ul.connection.deleteHandler(r);const u=l&&ec()(`fin[xmlns="${Zg.MAM}"]`,l).pop(),h="true"===(null==u?void 0:u.getAttribute("complete")),m=ec()(`set[xmlns="${Zg.RSM}"]`,u).pop();return m&&(d=new Wg({...e,xml:m})),{messages:o,rsm:d,complete:h}}}},{Strophe:Xg,$iq:ef}=Su.env,{NS:tf}=Xg,nf=Su.env.utils;function sf(e){null!=e&&e.querySelectorAll("feature-not-implemented").length?z.warn(`Message Archive Management (XEP-0313) not supported by ${e.getAttribute("from")}`):(z.error(`Error while trying to set archiving preferences for ${e.getAttribute("from")}.`),z.error(e))}function of(e,t){const n=ec()(`prefs[xmlns="${tf.MAM}"]`,e).pop();if(n.getAttribute("default")!==bu.settings.get("message_archiving")){const e=ef({type:"set"}).c("prefs",{xmlns:tf.MAM,default:bu.settings.get("message_archiving")});Array.from(n.children).forEach((t=>e.cnode(t).up())),bu.sendIQ(e).then((()=>t.save({preferences:{default:bu.settings.get("message_archiving")}}))).catch(ul.onMAMError)}else t.save({preferences:{default:bu.settings.get("message_archiving")}})}function rf(e){const t=e.get("preferences")||{};e.get("var")===tf.MAM&&void 0!==bu.settings.get("message_archiving")&&t.default!==bu.settings.get("message_archiving")&&bu.sendIQ(ef({type:"get"}).c("prefs",{xmlns:tf.MAM})).then((t=>ul.onMAMPreferences(t,e))).catch(ul.onMAMError)}function af(e){bu.settings.get("muc_show_logs_before_join")&&e.features.get("mam_enabled")&&!e.get("prejoin_mam_fetched")&&(uf(e),e.save({prejoin_mam_fetched:!0}))}async function cf(e,t,n,s,i){await bu.emojis.initialize();const o=e.get("type")===ul.CHATROOMS_TYPE,r=await Promise.all(t.messages.map((t=>o?ym(t,e):Sh(t))));t.messages=r;const a={query:n,chatbox:e,messages:r};if(await bu.trigger("MAMResult",a,{synchronous:!0}),r.forEach((t=>e.queueMessage(t))),t.error){const n=t.error.retry_event_id=nf.getUniqueId();bu.listen.once(n,(()=>lf(e,s,i))),e.createMessageFromError(t.error)}}async function lf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(e.disable_mam)return;const s=e.get("type")===ul.CHATROOMS_TYPE,i=s?e.get("jid"):ul.bare_jid;if(!await bu.disco.supports(tf.MAM,i))return;const o=bu.settings.get("archived_messages_page_size"),r=Object.assign({groupchat:s,max:o,with:e.get("jid")},t),a=await bu.archive.query(r);if(await cf(e,a,r,t,n),a.rsm&&!a.complete){if(n)return"forwards"===n?t=a.rsm.next(o,t.before).query:"backwards"===n&&(t=a.rsm.previous(o,t.after).query),lf(e,t,n);df(e,t,a)}}async function df(e,t,n){if(""==t.before&&(0===e.messages.length||!t.start))return;if(t.before&&!t.start)return;if(null==t.before)return;const s=await Promise.all(n.messages),{rsm:i}=n,o=`stanza_id ${e.get("jid")}`,r=s.find((e=>e[o]===i.result.first)),a={template_hook:"getMessageTemplate",time:new Date(new Date(r.time)-1).toISOString(),before:i.result.first,start:t.start};e.messages.add(new zg(a))}function uf(e){if(e.disable_mam)return;const t=e.getMostRecentMessage();if(t&&!bu.settings.get("clear_messages_on_reconnection")){if(bu.settings.get("mam_request_all_pages")){const n=t.get(`stanza_id ${e.get("jid")}`);lf(e,n?{after:n}:{start:t.get("time")},"forwards")}else lf(e,{before:"",start:t.get("time")})}else lf(e,{before:""})}const{Strophe:hf}=Su.env,{NS:mf}=hf;Su.plugins.add("converse-mam",{dependencies:["converse-disco","converse-muc"],initialize(){bu.settings.extend({archived_messages_page_size:"50",mam_request_all_pages:!0,message_archiving:void 0,message_archiving_timeout:2e4}),Object.assign(bu,Yg),Object.assign(ul,{onMAMError:sf,onMAMPreferences:of,handleMAMResult:cf,MAMPlaceholderMessage:zg}),bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(mf.MAM))),bu.listen.on("serviceDiscovered",rf),bu.listen.on("chatRoomViewInitialized",(e=>{bu.settings.get("muc_show_logs_before_join")&&(af(e.model),e.model.features.on("change:mam_enabled",(()=>af(e.model))))})),bu.listen.on("enteredNewRoom",(e=>e.features.get("mam_enabled")&&uf(e))),bu.listen.on("chatReconnected",(e=>{e.get("type")===ul.PRIVATE_CHAT_TYPE&&uf(e)})),bu.listen.on("afterMessagesFetched",(e=>{e.get("type")!==ul.PRIVATE_CHAT_TYPE||ul.connection.restored||uf(e)}))}});const{Strophe:gf,$iq:ff}=Su.env;let pf;function vf(e){"visible"===e.state&&bu.connection.connected()&&bu.ping(null,5e3)}function _f(e){pf=new Date;const t=e.getAttribute("from"),n=e.getAttribute("id"),s=ff({type:"result",to:t,id:n});return ul.connection.sendIQ(s),!0}function yf(){!function(){const{connection:e}=ul;e.disco&&bu.disco.own.features.add(gf.NS.PING),e.addHandler(_f,gf.NS.PING,"iq","get")}(),ul.connection.addHandler((()=>{if(bu.settings.get("ping_interval")>0)return pf=new Date,!0}))}function bf(){if(ul.isTestEnv()||!bu.connection.connected())return;const e=bu.settings.get("ping_interval");if(e>0){const t=new Date;pf||(pf=t),(t-pf)/1e3>e&&bu.ping()}}const{Strophe:wf,$iq:Sf,u:xf}=Su.env,Ef={async ping(e,t){var n;if(n=new Date,pf=n,e=e||wf.getDomainFromJid(ul.bare_jid),ul.connection){const n=Sf({type:"get",to:e,id:xf.getUniqueId("ping")}).c("ping",{xmlns:wf.NS.PING}),s=await bu.sendIQ(n,t||1e4,!1);return null===s?(z.warn(`Timeout while pinging ${e}`),e===wf.getDomainFromJid(ul.bare_jid)&&bu.connection.reconnect()):xf.isErrorStanza(s)&&(z.error(`Error while pinging ${e}`),z.error(s)),!0}return!1}},{Strophe:Af}=Su.env;Af.addNamespace("PING","urn:xmpp:ping"),Su.plugins.add("converse-ping",{initialize(){bu.settings.extend({ping_interval:60}),Object.assign(bu,Ef),setInterval(bf,1e3),bu.listen.on("connected",yf),bu.listen.on("reconnected",yf),bu.listen.on("windowStateChanged",vf)}});const{Strophe:Cf,$iq:kf}=Su.env;Cf.addNamespace("PUBSUB_ERROR",Cf.NS.PUBSUB+"#errors"),Su.plugins.add("converse-pubsub",{dependencies:["converse-disco"],initialize(){Object.assign(ul.api,{pubsub:{async publish(e,t,n,s){let i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];const o=kf({from:ul.bare_jid,type:"set",to:e}).c("pubsub",{xmlns:Cf.NS.PUBSUB}).c("publish",{node:t}).cnode(n.tree()).up().up();s&&(e=e||ul.bare_jid,await bu.disco.supports(Cf.NS.PUBSUB+"#publish-options",e)?(o.c("publish-options").c("x",{xmlns:Cf.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(`${Cf.NS.PUBSUB}#publish-options`).up().up(),Object.keys(s).forEach((e=>o.c("field",{var:e}).c("value").t(s[e]).up().up()))):z.warn(`_converse.api.publish: ${e} does not support #publish-options, so we didn't set them even though they were provided.`));try{await bu.sendIQ(o)}catch(e){if(!(e instanceof Element&&i&&e.querySelector(`precondition-not-met[xmlns="${Cf.NS.PUBSUB_ERROR}"]`)))throw e;{const e=o.nodeTree;e.querySelector("publish-options").outerHTML="",z.warn(`PubSub: Republishing without publish options. ${e.outerHTML}`),await bu.sendIQ(e)}}}}})}});const jf=function(e){return"number"==typeof e||a(e)&&"[object Number]"==b(e)};const Tf=function(e){return jf(e)&&e!=+e},{Strophe:$f,$pres:Nf}=Su.env,Of=Ac.extend({defaults:()=>({status:bu.settings.get("default_state")}),initialize(){this.on("change",(e=>{we(e.changed)&&("status"in e.changed||"status_message"in e.changed)&&bu.user.presence.send(this.get("status"),null,this.get("status_message"))}))},getNickname:()=>bu.settings.get("nickname"),getFullname:()=>"",async constructPresence(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2?arguments[2]:void 0;e="string"==typeof e?e:this.get("status")||bu.settings.get("default_state"),s="string"==typeof s?s:this.get("status_message");const i={to:n};"unavailable"===e||"probe"===e||"error"===e||"unsubscribe"===e||"unsubscribed"===e||"subscribe"===e||"subscribed"===e?(i.type=e,t=Nf(i)):"offline"===e?(i.type="unavailable",t=Nf(i)):t="online"===e?Nf(i):Nf(i).c("show").t(e).up(),s&&t.c("status").t(s).up();const o=bu.settings.get("priority");if(t.c("priority").t(Tf(Number(o))?0:o).up(),ul.idle){const e=new Date;e.setSeconds(e.getSeconds()-ul.idle_seconds),t.c("idle",{xmlns:$f.NS.IDLE,since:e.toISOString()})}return t=await bu.hook("constructedPresence",null,t),t}}),If=Of,Mf={presence:{async send(e,t,n,s){var i;await bu.waitUntil("statusInitialized"),s&&!Array.isArray(s)&&(s=[s]);const o=ul.xmppstatus,r=await o.constructPresence(e,t,n);if(null===(i=s)||void 0===i||i.map((e=>(null==e?void 0:e.tree())??e)).forEach((e=>r.cnode(e).up())),bu.send(r),["away","chat","dnd","online","xa",void 0].includes(e)){(await bu.rooms.get()).forEach((t=>t.sendStatusPresence(e,n,s)))}}},status:{get:async()=>(await bu.waitUntil("statusInitialized"),ul.xmppstatus.get("status")),async set(e,t){const n={status:e};if(!Object.keys(ul.STATUS_WEIGHTS).includes(e))throw new Error("Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1");"string"==typeof t&&(n.status_message=t),await bu.waitUntil("statusInitialized"),ul.xmppstatus.save(n)},message:{get:async()=>(await bu.waitUntil("statusInitialized"),ul.xmppstatus.get("status_message")),async set(e){await bu.waitUntil("statusInitialized"),ul.xmppstatus.save({status_message:e})}}}},{Strophe:Rf,$build:Df}=Su.env;function zf(e){bu.trigger("statusInitialized",e)}function Lf(e){if(e=void 0!==ul.xmppstatus&&e)zf(e);else{const t=`converse.xmppstatus-${ul.bare_jid}`;ul.xmppstatus=new ul.XMPPStatus({id:t}),La(ul.xmppstatus,t,"session"),ul.xmppstatus.fetch({success:()=>zf(e),error:()=>zf(e),silent:!0})}}function Pf(){var e;ul.idle_seconds>0&&(ul.idle_seconds=0),null!==(e=ul.connection)&&void 0!==e&&e.authenticated&&(ul.inactive&&ul.sendCSI(ul.ACTIVE),ul.idle&&(ul.idle=!1,bu.user.presence.send()),!0===ul.auto_changed_status&&(ul.auto_changed_status=!1,ul.xmppstatus.set("status",bu.settings.get("default_state"))))}function Ff(){var e;if(null===(e=ul.connection)||void 0===e||!e.authenticated)return;const t=ul.xmppstatus.get("status");ul.idle_seconds++,bu.settings.get("csi_waiting_time")>0&&ul.idle_seconds>bu.settings.get("csi_waiting_time")&&!ul.inactive&&ul.sendCSI(ul.INACTIVE),bu.settings.get("idle_presence_timeout")>0&&ul.idle_seconds>bu.settings.get("idle_presence_timeout")&&!ul.idle&&(ul.idle=!0,bu.user.presence.send()),bu.settings.get("auto_away")>0&&ul.idle_seconds>bu.settings.get("auto_away")&&"away"!==t&&"xa"!==t&&"dnd"!==t?(ul.auto_changed_status=!0,ul.xmppstatus.set("status","away")):bu.settings.get("auto_xa")>0&&ul.idle_seconds>bu.settings.get("auto_xa")&&"xa"!==t&&"dnd"!==t&&(ul.auto_changed_status=!0,ul.xmppstatus.set("status","xa"))}function Uf(e){bu.send(Df(e,{xmlns:Rf.NS.CSI})),ul.inactive=e===ul.INACTIVE}function Bf(){if(bu.settings.get("auto_away")<1&&bu.settings.get("auto_xa")<1&&bu.settings.get("csi_waiting_time")<1&&bu.settings.get("idle_presence_timeout")<1)return;ul.idle_seconds=0,ul.auto_changed_status=!1;const{unloadevent:e}=ul;window.addEventListener("click",ul.onUserActivity),window.addEventListener("focus",ul.onUserActivity),window.addEventListener("keypress",ul.onUserActivity),window.addEventListener("mousemove",ul.onUserActivity),window.addEventListener(e,ul.onUserActivity,{once:!0,passive:!0}),window.addEventListener(e,(()=>{var e;return null===(e=ul.session)||void 0===e?void 0:e.save("active",!1)})),ul.everySecondTrigger=window.setInterval(ul.onEverySecond,1e3)}function qf(e,t){const{xmppstatus:n}=ul,s=n.get("status");["away","chat","dnd","xa"].includes(s)&&t.c("show").t(s).up();const i=n.get("status_message");return i&&t.c("status").t(i).up(),t}const{Strophe:Hf}=Su.env;Hf.addNamespace("IDLE","urn:xmpp:idle:1"),Su.plugins.add("converse-status",{initialize(){bu.settings.extend({auto_away:0,auto_xa:0,csi_waiting_time:0,default_state:"online",idle_presence_timeout:300,priority:0}),bu.promises.add(["statusInitialized"]),ul.XMPPStatus=If,ul.onUserActivity=Pf,ul.onEverySecond=Ff,ul.sendCSI=Uf,ul.registerIntervalHandler=Bf,Object.assign(ul.api.user,Mf),bu.settings.get("idle_presence_timeout")>0&&bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(Hf.NS.IDLE))),bu.listen.on("presencesInitialized",(e=>{e||ul.registerIntervalHandler()})),bu.listen.on("clearSession",(()=>{ul.shouldClearCache()&&ul.xmppstatus&&(ul.xmppstatus.destroy(),delete ul.xmppstatus,bu.promises.add(["statusInitialized"]))})),bu.listen.on("connected",(()=>Lf(!1))),bu.listen.on("reconnected",(()=>Lf(!0))),bu.listen.on("constructedMUCPresence",qf)}});const Gf=Ac.extend({initialize(){this.set({filter_text:"",filter_type:"contacts",chat_state:"online"})}}),{$pres:Wf}=Su.env;function Vf(e){var t;const n=null===(t=ul.roster)||void 0===t?void 0:t.get(e.get("jid"));null==n||n.save({num_unread:e.get("num_unread")})}function Jf(){void 0!==ul.presence_ref&&(ul.connection.deleteHandler(ul.presence_ref),delete ul.presence_ref)}async function Qf(){var e;await(null===(e=ul.presences)||void 0===e?void 0:e.clearStore())}async function Zf(){var e;(await Qf(),ul.shouldClearCache())&&(ul.rostergroups&&(await ul.rostergroups.clearStore(),delete ul.rostergroups),ul.roster&&(null===(e=ul.roster.data)||void 0===e||e.destroy(),await ul.roster.clearStore(),delete ul.roster))}function Kf(e){e?bu.trigger("rosterReadyAfterReconnection"):function(){const e=ul.roster=new ul.RosterContacts;let t=`converse.contacts-${ul.bare_jid}`;La(e,t);const n=ul.roster_filter=new Gf;n.id=`_converse.rosterfilter-${ul.bare_jid}`,La(n,n.id),n.fetch(),t=`converse-roster-model-${ul.bare_jid}`,e.data=new Ac,e.data.id=t,La(e.data,t),e.data.fetch(),bu.trigger("rosterInitialized")}(),ul.roster.onConnected(),Jf(),ul.presence_ref=ul.connection.addHandler((e=>(ul.roster.presenceHandler(e),!0)),null,"presence",null),async function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(ul.send_initial_presence=!0);try{await ul.roster.fetchRosterContacts(),bu.trigger("rosterContactsFetched")}catch(e){z.error(e)}finally{ul.send_initial_presence&&bu.user.presence.send()}}(!ul.connection.restored)}async function Yf(e){if(e)!ul.connection.hasResumed()&&await Qf();else{ul.presences=new ul.Presences;const e=`converse.presences-${ul.bare_jid}`;La(ul.presences,e,"session"),ul.presences.fetch()}bu.trigger("presencesInitialized",e)}function Xf(){ul.chatboxes.on("change:num_unread",Vf),ul.chatboxes.on("add",(e=>{e.get("type")===ul.PRIVATE_CHAT_TYPE&&e.setRosterContact(e.get("jid"))}))}function ep(){ul.roster.on("add",(e=>{const t=ul.chatboxes.findWhere({jid:e.get("jid")});null==t||t.setRosterContact(e.get("jid"))}))}function tp(e,t){const n=Wf({to:e,type:"unsubscribed"});t&&""!==t&&n.c("status").t(t),bu.send(n)}function np(e,t){const n=e.presence.get("show")||"offline",s=t.presence.get("show")||"offline";if(ul.STATUS_WEIGHTS[n]===ul.STATUS_WEIGHTS[s]){const n=e.getDisplayName().toLowerCase(),s=t.getDisplayName().toLowerCase();return ns?1:0}return ul.STATUS_WEIGHTS[n]t.toLowerCase()?1:0;if(o&&r)return s[e]s[t]?1:0;if(!o&&r){const e=ul.HEADER_CURRENT_CONTACTS;return s[e]s[t]?1:0}if(o&&!r){const t=ul.HEADER_CURRENT_CONTACTS;return s[e]s[t]?1:0}}const{Strophe:ip,$iq:op,$pres:rp}=Su.env,ap=Ac.extend({idAttribute:"jid",defaults:{chat_state:void 0,groups:[],image:ul.DEFAULT_IMAGE,image_type:ul.DEFAULT_IMAGE_TYPE,num_unread:0,status:void 0},async initialize(e){this.initialized=ba(),this.setPresence();const{jid:t}=e;this.set({...e,jid:ip.getBareJidFromJid(t).toLowerCase(),user_id:ip.getNodeFromJid(t)}),this.listenTo(this.presence,"change:show",(()=>bu.trigger("contactPresenceChanged",this))),this.listenTo(this.presence,"change:show",(()=>this.trigger("presenceChanged"))),await bu.trigger("rosterContactInitialized",this,{Synchronous:!0}),this.initialized.resolve()},setPresence(){const e=this.get("jid");this.presence=ul.presences.findWhere(e)||ul.presences.create({jid:e})},openChat(){const e=this.attributes;bu.chats.open(e.jid,e,!0)},getFilterCriteria(){const e=this.get("nickname"),t=this.get("jid");let n=this.getDisplayName();return n=n.includes(t)?n:n.concat(` ${t}`),n=n.includes(e)?n:n.concat(` ${e}`),n.toLowerCase()},getDisplayName(){return this.get("nickname")?this.get("nickname"):this.get("jid")},getFullname(){return this.get("jid")},subscribe(e){const t=rp({to:this.get("jid"),type:"subscribe"});e&&""!==e&&t.c("status").t(e).up();const n=ul.xmppstatus.getNickname()||ul.xmppstatus.getFullname();return n&&t.c("nick",{xmlns:ip.NS.NICK}).t(n).up(),bu.send(t),this.save("ask","subscribe"),this},ackSubscribe(){bu.send(rp({type:"subscribe",to:this.get("jid")}))},ackUnsubscribe(){bu.send(rp({type:"unsubscribe",to:this.get("jid")})),this.removeFromRoster(),this.destroy()},unauthorize(e){return tp(this.get("jid"),e),this},authorize(e){const t=rp({to:this.get("jid"),type:"subscribed"});return e&&""!==e&&t.c("status").t(e),bu.send(t),this},removeFromRoster(){const e=op({type:"set"}).c("query",{xmlns:ip.NS.ROSTER}).c("item",{jid:this.get("jid"),subscription:"remove"});return bu.sendIQ(e)}}),cp=ap;const lp=function(e,t){for(var n,s=-1,i=e.length;++s(ul.roster.onRosterPush(e),!0)),up.NS.ROSTER,"iq","set")},registerRosterXHandler(){let e=0;ul.connection.addHandler((function(t){return window.setTimeout((function(){ul.connection.flush(),ul.roster.subscribeToSuggestedItems.bind(ul.roster)(t)}),e),e+=250*t.querySelectorAll("item").length,!0}),up.NS.ROSTERX,"message",null)},async fetchRosterContacts(){const e=await new Promise(((e,t)=>{this.fetch({add:!0,silent:!0,success:e,error:(e,n)=>t(n)})}));if(gp.isErrorObject(e)&&(z.error(e),ul.session.save("roster_cached",!1),this.data.save("version",void 0)),!ul.session.get("roster_cached"))return ul.send_initial_presence=!0,ul.roster.fetchFromServer();bu.trigger("cachedRoster",e)},subscribeToSuggestedItems:e=>(Array.from(e.querySelectorAll("item")).forEach((e=>{"add"===e.getAttribute("action")&&ul.roster.addAndSubscribe(e.getAttribute("jid"),ul.xmppstatus.getNickname()||ul.xmppstatus.getFullname())})),!0),isSelf:e=>gp.isSameBareJID(e,ul.connection.jid),async addAndSubscribe(e,t,n,s,i){const o=await this.addContactToRoster(e,t,n,i);o instanceof ul.RosterContact&&o.subscribe(s)},sendContactAddIQ(e,t,n){t=t||null;const s=hp({type:"set"}).c("query",{xmlns:up.NS.ROSTER}).c("item",{jid:e,name:t});return n.forEach((e=>s.c("group").t(e).up())),bu.sendIQ(s)},async addContactToRoster(e,t,n,s){await bu.waitUntil("rosterContactsFetched"),n=n||[];try{await this.sendContactAddIQ(e,t,n)}catch(n){const{__:s}=ul;return z.error(n),alert(s("Sorry, there was an error while trying to add %1$s as a contact.",t||e)),n}return this.create(Object.assign({ask:void 0,nickname:t,groups:n,jid:e,requesting:!1,subscription:"none"},s),{sort:!1})},async subscribeBack(e,t){const n=this.get(e);if(n instanceof ul.RosterContact)n.authorize().subscribe();else{var s;const n=(null===(s=mp(`nick[xmlns="${up.NS.NICK}"]`,t).pop())||void 0===s?void 0:s.textContent)||null,i=await this.addContactToRoster(e,n,[],{subscription:"from"});i instanceof ul.RosterContact&&i.authorize().subscribe()}},getNumOnlineContacts(){const e=["offline","unavailable"];return dp(this.models.filter((t=>!e.includes(t.presence.get("show")))))},onRosterPush(e){const t=e.getAttribute("id"),n=e.getAttribute("from");if(n&&n!==ul.bare_jid)return void z.warn(`Ignoring roster illegitimate roster push message from ${e.getAttribute("from")}`);bu.send(hp({type:"result",id:t,from:ul.connection.jid}));const s=mp(`query[xmlns="${up.NS.ROSTER}"]`,e).pop();this.data.save("version",s.getAttribute("ver"));const i=mp("item",s);if(i.length>1)throw z.error(e),new Error('Roster push query may not contain more than one "item" element.');if(0===i.length)return z.warn(e),void z.warn('Received a roster push stanza without an "item" element.');this.updateContact(i.pop()),bu.trigger("rosterPush",e)},rosterVersioningSupported(){return bu.disco.stream.getFeature("ver","urn:xmpp:features:rosterver")&&this.data.get("version")},async fetchFromServer(){const e=hp({type:"get",id:gp.getUniqueId("roster")}).c("query",{xmlns:up.NS.ROSTER});this.rosterVersioningSupported()&&e.attrs({ver:this.data.get("version")});const t=await bu.sendIQ(e,null,!1);if("result"===t.getAttribute("type")){const e=mp(`query[xmlns="${up.NS.ROSTER}"]`,t).pop();if(e){const t=mp("item",e);if(!this.data.get("version")){const e=t.map((e=>e.getAttribute("jid")));this.models.forEach((t=>!t.get("requesting")&&!e.includes(t.get("jid"))&&t.destroy()))}t.forEach((e=>this.updateContact(e))),this.data.save("version",e.getAttribute("ver"))}}else if(!gp.isServiceUnavailableError(t))return z.error(t),void z.error("Error while trying to fetch roster from the server");ul.session.save("roster_cached",!0),bu.trigger("roster",t)},updateContact(e){const t=e.getAttribute("jid"),n=this.get(t),s=e.getAttribute("subscription"),i=e.getAttribute("ask"),o=[...new Set(mp("group",e).map((e=>e.textContent)))];if(n){if("remove"===s)return n.destroy();n.save({subscription:s,ask:i,nickname:e.getAttribute("name"),requesting:null,groups:o})}else{if("none"===s&&null===i||"remove"===s)return;this.create({ask:i,nickname:e.getAttribute("name"),groups:o,jid:t,subscription:s},{sort:!1})}},createRequestingContact(e){var t;const n={jid:up.getBareJidFromJid(e.getAttribute("from")),subscription:"none",ask:null,requesting:!0,nickname:(null===(t=mp(`nick[xmlns="${up.NS.NICK}"]`,e).pop())||void 0===t?void 0:t.textContent)||null};bu.trigger("contactRequest",this.create(n))},handleIncomingSubscription(e){const t=e.getAttribute("from"),n=up.getBareJidFromJid(t),s=this.get(n);if(!bu.settings.get("allow_contact_requests")){const{__:e}=ul;tp(t,e("This client does not allow presence subscriptions"))}bu.settings.get("auto_subscribe")?s&&"to"===s.get("subscription")?s.authorize():this.subscribeBack(n,e):s?("none"!==s.get("subscription")||"subscribe"===s.get("ask"))&&s.authorize():this.createRequestingContact(e)},handleOwnPresence(e){const t=e.getAttribute("from"),n=up.getResourceFromJid(t),s=e.getAttribute("type");if(ul.connection.jid!==t&&"unavailable"!==s&&(!0===bu.settings.get("synchronize_availability")||bu.settings.get("synchronize_availability")===n)){var i,o;const t=(null===(i=e.querySelector("show"))||void 0===i?void 0:i.textContent)||"online";ul.xmppstatus.save({status:t},{silent:!0});const n=null===(o=e.querySelector("status"))||void 0===o?void 0:o.textContent;n&&ul.xmppstatus.save({status_message:n})}ul.jid===t&&"unavailable"===s&&bu.user.presence.send()},presenceHandler(e){var t;const n=e.getAttribute("type");if("error"===n)return!0;const s=e.getAttribute("from"),i=up.getBareJidFromJid(s);if(this.isSelf(i))return this.handleOwnPresence(e);if(mp(`query[xmlns="${up.NS.MUC}"]`,e).length)return;const o=null===(t=e.querySelector("status"))||void 0===t?void 0:t.textContent,r=this.get(i);if(r&&o!==r.get("status")&&r.save({status:o}),"subscribed"===n&&r)r.ackSubscribe();else if("unsubscribed"===n&&r)r.ackUnsubscribe();else{if("unsubscribe"===n)return;if("subscribe"===n)this.handleIncomingSubscription(e);else if("unavailable"===n&&r){const e=up.getResourceFromJid(s);r.presence.removeResource(e)}else r&&r.presence.addResource(e)}}}),pp=fp,{Strophe:vp}=Su.env,_p={contacts:{async get(e){await bu.waitUntil("rosterContactsFetched");const t=e=>ul.roster.get(vp.getBareJidFromJid(e));if(void 0===e)e=ul.roster.pluck("jid");else if("string"==typeof e)return t(e);return e.map(t)},async add(e,t){if(await bu.waitUntil("rosterContactsFetched"),"string"!=typeof e||!e.includes("@"))throw new TypeError("contacts.add: invalid jid");return ul.roster.addAndSubscribe(e,t)}}},{Strophe:yp,dayjs:bp,sizzle:wp}=Su.env,Sp=Ac.extend({idAttribute:"name"}),xp=ld.extend({model:Sp}),Ep=Ac.extend({idAttribute:"jid",defaults:{show:"offline"},initialize(){this.resources=new xp;const e=`converse.identities-${this.get("jid")}`;La(this.resources,e,"session"),this.listenTo(this.resources,"update",this.onResourcesChanged),this.listenTo(this.resources,"change",this.onResourcesChanged)},onResourcesChanged(){var e;const t=this.getHighestPriorityResource(),n=(null==t||null===(e=t.attributes)||void 0===e?void 0:e.show)||"offline";this.get("show")!==n&&this.save({show:n})},getHighestPriorityResource(){return this.resources.sortBy((e=>`${e.get("priority")}-${e.get("timestamp")}`)).reverse()[0]},addResource(e){var t,n;const s=e.getAttribute("from"),i=yp.getResourceFromJid(s),o=wp(`delay[xmlns="${yp.NS.DELAY}"]`,e).pop(),r=(null===(t=e.querySelector("priority"))||void 0===t?void 0:t.textContent)??0,a=this.resources.get(i),c={name:i,priority:Tf(parseInt(r,10))?0:parseInt(r,10),show:(null===(n=e.querySelector("show"))||void 0===n?void 0:n.textContent)??"online",timestamp:o?bp(o.getAttribute("stamp")).toISOString():(new Date).toISOString()};a?a.save(c):this.resources.create(c)},removeResource(e){const t=this.resources.get(e);t&&t.destroy()}}),Ap=ld.extend({model:Ep});Su.plugins.add("converse-roster",{dependencies:["converse-status"],initialize(){bu.settings.extend({allow_contact_requests:!0,auto_subscribe:!1,synchronize_availability:!0}),bu.promises.add(["cachedRoster","roster","rosterContactsFetched","rosterInitialized"]),Object.assign(ul.api,_p);const{__:e}=ul;ul.HEADER_CURRENT_CONTACTS=e("My contacts"),ul.HEADER_PENDING_CONTACTS=e("Pending contacts"),ul.HEADER_REQUESTING_CONTACTS=e("Contact requests"),ul.HEADER_UNGROUPED=e("Ungrouped"),ul.HEADER_UNREAD=e("New messages"),ul.Presence=Ep,ul.Presences=Ap,ul.RosterContact=cp,ul.RosterContacts=pp,bu.listen.on("beforeTearDown",(()=>Jf())),bu.listen.on("chatBoxesInitialized",Xf),bu.listen.on("clearSession",Zf),bu.listen.on("presencesInitialized",Kf),bu.listen.on("statusInitialized",Yf),bu.listen.on("streamResumptionFailed",(()=>ul.session.set("roster_cached",!1))),bu.waitUntil("rosterContactsFetched").then(ep)}});const{Strophe:Cp}=Su.env,kp=Su.env.utils;function jp(){return!(bu.connection.isType("bosh")&&!ul.isTestEnv())&&bu.disco.stream.getFeature("sm",Cp.NS.SM)}function Tp(e){if(!ul.session.get("smacks_enabled"))return!0;const t=parseInt(e.getAttribute("h"),10),n=ul.session.get("num_stanzas_handled_by_server"),s=t-n;if(s<0){const e=`New reported stanza count lower than previous. New: ${t} - Previous: ${n}`;z.error(e)}const i=ul.session.get("unacked_stanzas");if(s>i.length){const e=`Higher reported acknowledge count than unacknowledged stanzas. Reported Acknowledged Count: ${s} -Unacknowledged Stanza Count: ${i.length} -New: ${t} - Previous: ${n}`;z.error(e)}return ul.session.save({num_stanzas_handled_by_server:t,num_stanzas_since_last_ack:0,unacked_stanzas:i.slice(s)}),!0}function $p(){if(ul.session.get("smacks_enabled")){const e=ul.session.get("num_stanzas_handled"),t=kp.toStanza(``);bu.send(t)}return!0}function Np(e){if(ul.session.get("smacks_enabled")&&(kp.isTagEqual(e,"iq")||kp.isTagEqual(e,"presence")||kp.isTagEqual(e,"message"))){const e=ul.session.get("num_stanzas_handled");ul.session.save("num_stanzas_handled",e+1)}return!0}function Op(){ul.session.save({smacks_enabled:ul.session.get("smacks_enabled")||!1,num_stanzas_handled:ul.session.get("num_stanzas_handled")||0,num_stanzas_handled_by_server:ul.session.get("num_stanzas_handled_by_server")||0,num_stanzas_since_last_ack:ul.session.get("num_stanzas_since_last_ack")||0,unacked_stanzas:ul.session.get("unacked_stanzas")||[]})}function Ip(){var e;null===(e=ul.session)||void 0===e||e.save({smacks_enabled:!1,num_stanzas_handled:0,num_stanzas_handled_by_server:0,num_stanzas_since_last_ack:0,unacked_stanzas:[]})}function Mp(e){const t={smacks_enabled:!0};return["1","true"].includes(e.getAttribute("resume"))&&(t.smacks_stream_id=e.getAttribute("id")),ul.session.save(t),!0}function Rp(e){return e.querySelector("item-not-found")?z.warn("Could not resume previous SMACKS session, session id not found. A new session will be established."):(z.error("Failed to enable stream management"),z.error(e.outerHTML)),Ip(),bu.trigger("streamResumptionFailed"),!0}function Dp(e){Mp(e),Tp(e),function(){const e=ul.session.get("unacked_stanzas");ul.session.save("unacked_stanzas",[]),e.forEach((e=>bu.send(e)))}(),ul.connection.do_bind=!1,ul.connection.authenticated=!0,ul.connection.restored=!0,ul.connection._changeConnectStatus(Cp.Status.CONNECTED,null)}async function zp(){if(bu.settings.get("enable_smacks")&&!ul.session.get("smacks_enabled")&&await jp()){const e=ba();ul.connection._addSysHandler((t=>e.resolve(Mp(t))),Cp.NS.SM,"enabled"),ul.connection._addSysHandler((t=>e.resolve(Rp(t))),Cp.NS.SM,"failed");const t=bu.connection.isType("websocket")||ul.isTestEnv(),n=kp.toStanza(``);bu.send(n),ul.connection.flush(),await e}}const Lp=[];async function Pp(){var e;if(!bu.settings.get("enable_smacks"))return;if(!await jp())return;const t=ul.connection;for(;Lp.length;)t.deleteHandler(Lp.pop());Lp.push(t.addHandler(Np)),Lp.push(t.addHandler($p,Cp.NS.SM,"r")),Lp.push(t.addHandler(Tp,Cp.NS.SM,"a")),null!==(e=ul.session)&&void 0!==e&&e.get("smacks_stream_id")?await async function(){const e=ba();ul.connection._addSysHandler((t=>e.resolve(Dp(t))),Cp.NS.SM,"resumed"),ul.connection._addSysHandler((t=>e.resolve(Rp(t))),Cp.NS.SM,"failed");const t=ul.session.get("smacks_stream_id"),n=ul.session.get("num_stanzas_handled"),s=kp.toStanza(``);bu.send(s),ul.connection.flush(),await e}():Ip()}function Fp(e){if(ul.session){if(ul.session.get("smacks_enabled")&&(kp.isTagEqual(e,"iq")||kp.isTagEqual(e,"presence")||kp.isTagEqual(e,"message"))){const t=Cp.serialize(e);ul.session.save("unacked_stanzas",(ul.session.get("unacked_stanzas")||[]).concat([t]));const n=bu.settings.get("smacks_max_unacked_stanzas");if(n>0){const e=ul.session.get("num_stanzas_since_last_ack")+1;e%n==0&&bu.send(kp.toStanza(``)),ul.session.save({num_stanzas_since_last_ack:e})}}}else z.warn("No _converse.session!")}const{Strophe:Up}=Su.env;Up.addNamespace("SM","urn:xmpp:sm:3"),Su.plugins.add("converse-smacks",{initialize(){bu.settings.extend({enable_smacks:!0,smacks_max_unacked_stanzas:5}),bu.listen.on("afterResourceBinding",zp),bu.listen.on("beforeResourceBinding",Pp),bu.listen.on("send",Fp),bu.listen.on("userSessionInitialized",Op)}});const Bp=Ac.extend({idAttribute:"jid",defaults:{image:ul.DEFAULT_IMAGE,image_type:ul.DEFAULT_IMAGE_TYPE},set(e,t,n){let s;return"object"==typeof e?(s=e,n=t):(s={})[e]=t,"image"in s&&!s.image?(s.image=ul.DEFAULT_IMAGE,s.image_type=ul.DEFAULT_IMAGE_TYPE,Ac.prototype.set.call(this,s,n)):Ac.prototype.set.apply(this,arguments)},getDisplayName(){return this.get("nickname")||this.get("fullname")||this.get("jid")}}),qp=Bp,{Strophe:Hp,$iq:Gp,u:Wp}=Su.env;function Vp(e,t,n){const s=Gp(t?{type:e,to:t}:{type:e});return n?s.cnode(n):s.c("vCard",{xmlns:Hp.NS.VCARD}),s}async function Jp(e){let t;if(e instanceof ul.Message){if(["error","info"].includes(e.get("type")))return;t=e.get("from")}else t=e.get("jid");t?(await bu.waitUntil("VCardsInitialized"),e.vcard=ul.vcards.get(t)||ul.vcards.create({jid:t}),e.vcard.on("change",(()=>e.trigger("vcard:change"))),e.trigger("vcard:add")):z.warn("Could not set VCard on model because no JID found!")}async function Qp(e){await bu.waitUntil("VCardsInitialized"),e.vcard=function(e){var t;const n=null==e||null===(t=e.collection)||void 0===t?void 0:t.chatroom,s=e.get("nick");if(s&&(null==n?void 0:n.get("nick"))===s)return ul.xmppstatus.vcard;{const t=e.get("jid")||e.get("from");return t?ul.vcards.get(t)||ul.vcards.create({jid:t}):void z.warn("Could not get VCard for occupant because no JID found!")}}(e),e.vcard&&(e.vcard.on("change",(()=>e.trigger("vcard:change"))),e.trigger("vcard:add"))}async function Zp(e){["error","info"].includes(e.get("type"))||(await bu.waitUntil("VCardsInitialized"),e.vcard=function(e){var t;const n=null==e||null===(t=e.collection)||void 0===t?void 0:t.chatbox,s=Hp.getResourceFromJid(e.get("from"));if(s&&(null==n?void 0:n.get("nick"))===s)return ul.xmppstatus.vcard;{var i;const t=(null===(i=e.occupant)||void 0===i?void 0:i.get("jid"))||e.get("from");return t?ul.vcards.get(t)||ul.vcards.create({jid:t}):void z.warn(`Could not get VCard for message because no JID found! msgid: ${e.get("msgid")}`)}}(e),e.vcard&&(e.vcard.on("change",(()=>e.trigger("vcard:change"))),e.trigger("vcard:add")))}async function Kp(){ul.vcards=new ul.VCards;const e=`${ul.bare_jid}-converse.vcards`;La(ul.vcards,e),await new Promise((e=>{ul.vcards.fetch({success:e,error:e},{silent:!0})}));const t=ul.vcards;if(ul.session){const e=ul.session.get("bare_jid"),n=ul.xmppstatus;n.vcard=t.get(e)||t.create({jid:e}),n.vcard&&(n.vcard.on("change",(()=>n.trigger("vcard:change"))),n.trigger("vcard:add"))}bu.trigger("VCardsInitialized")}async function Yp(e){const t=Hp.getBareJidFromJid(e)===ul.bare_jid?null:e;let n;try{n=await bu.sendIQ(Vp("get",t))}catch(n){return{jid:e,stanza:n,vcard_error:(new Date).toISOString()}}return async function(e,t){const n=t.querySelector("vCard");let s={};var i,o,r,a,c,l,d;if(null!==n&&(s={stanza:t,fullname:null===(i=n.querySelector("FN"))||void 0===i?void 0:i.textContent,nickname:null===(o=n.querySelector("NICKNAME"))||void 0===o?void 0:o.textContent,image:null===(r=n.querySelector("PHOTO BINVAL"))||void 0===r?void 0:r.textContent,image_type:null===(a=n.querySelector("PHOTO TYPE"))||void 0===a?void 0:a.textContent,url:null===(c=n.querySelector("URL"))||void 0===c?void 0:c.textContent,role:null===(l=n.querySelector("ROLE"))||void 0===l?void 0:l.textContent,email:null===(d=n.querySelector("EMAIL USERID"))||void 0===d?void 0:d.textContent,vcard_updated:(new Date).toISOString(),vcard_error:void 0}),s.image){const e=Wp.base64ToArrayBuffer(s.image),t=await crypto.subtle.digest("SHA-1",e);s.image_hash=Wp.arrayBufferToHex(t)}return s}(0,n)}const{dayjs:Xp,u:ev}=Su.env,tv={vcard:{async set(e,t){if(!e)throw Error("No jid provided for the VCard data");const n=document.createElement("div"),s=ev.toStanza(`\n \n ${t.fn}\n ${t.nickname}\n ${t.url}\n ${t.role}\n ${t.email}\n \n ${t.image_type}\n ${t.image}\n \n `,n);let i;try{i=await bu.sendIQ(Vp("set",e,s))}catch(e){throw e}return await bu.vcard.update(e,!0),i},get(e,t){if("string"==typeof e)return Yp(e);const n=e.get("vcard_error"),s=n&&Xp(n).isSame(new Date,"day");if(t||!e.get("vcard_updated")&&!s){const t=e.get("jid");return t||z.error("No JID to get vcard for"),Yp(t)}return Promise.resolve({})},async update(e,t){const n=await this.get(e,t);(e="string"==typeof e?ul.vcards.get(e):e)?Object.keys(n).length&&(delete n.stanza,e.save(n)):z.error(`Could not find a VCard model for ${e}`)}}},{Strophe:nv}=Su.env;Su.plugins.add("converse-vcard",{dependencies:["converse-status","converse-roster"],overrides:{XMPPStatus:{getNickname(){const{_converse:e}=this.__super__,t=this.__super__.getNickname.apply(this);return!t&&e.xmppstatus.vcard?e.xmppstatus.vcard.get("nickname"):t},getFullname(){const{_converse:e}=this.__super__,t=this.__super__.getFullname.apply(this);return!t&&e.xmppstatus.vcard?e.xmppstatus.vcard.get("fullname"):t}},RosterContact:{getDisplayName(){return!this.get("nickname")&&this.vcard?this.vcard.getDisplayName():this.__super__.getDisplayName.apply(this)},getFullname(){return this.vcard?this.vcard.get("fullname"):this.__super__.getFullname.apply(this)}}},initialize(){bu.promises.add("VCardsInitialized"),ul.VCard=qp,ul.VCards=ld.extend({model:ul.VCard,initialize(){this.on("add",(e=>e.get("jid")&&bu.vcard.update(e)))}}),bu.listen.on("chatRoomInitialized",(e=>{Jp(e),e.occupants.forEach(Qp),e.listenTo(e.occupants,"add",Qp),e.listenTo(e.occupants,"change:image_hash",(e=>function(e){const t=e.get("image_hash"),n=[];e.get("jid")&&n.push(ul.vcards.get(e.get("jid"))),n.push(ul.vcards.get(e.get("from"))),n.forEach((e=>t&&(null==e?void 0:e.get("image_hash"))!==t&&bu.vcard.update(e,!0)))}(e)))})),bu.listen.on("chatBoxInitialized",(e=>Jp(e))),bu.listen.on("chatRoomMessageInitialized",(e=>Zp(e))),bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(nv.NS.VCARD))),bu.listen.on("clearSession",(()=>{ul.shouldClearCache()&&(bu.promises.add("VCardsInitialized"),ul.vcards&&(ul.vcards.clearStore(),delete ul.vcards))})),bu.listen.on("messageInitialized",(e=>Jp(e))),bu.listen.on("rosterContactInitialized",(e=>Jp(e))),bu.listen.on("statusInitialized",Kp),Object.assign(ul.api,tv)}});var sv=n(2353),iv=n.n(sv);const{dayjs:ov}=Su.env;function rv(e,t){return"string"==typeof e&&t.includes(e)}function av(e,t){return"string"!=typeof e||"en"!==e&&!t(e)?function(e){let t;if(window.navigator.userLanguage&&(t=cv(window.navigator.userLanguage,e)),window.navigator.languages&&!t)for(let n=0;nav(e,(e=>rv(e,t))),translate(e){if(!lv)return iv().sprintf.apply(iv(),arguments);const t=lv.translate(e);return arguments.length>1?t.fetch.apply(t,[].slice.call(arguments,1)):t.fetch()},async initialize(){if(ul.isTestEnv())ul.locale="en";else try{const e=bu.settings.get("i18n");ul.locale=r.getLocale(e,bu.settings.get("locales")),await async function(e){const{api:t,locale:s}=e,i=s.toLowerCase().replace("_","-");if(!rv(s,t.settings.get("locales"))||"en"===s)return;const{default:o}=await n(7521)(`./${s}/LC_MESSAGES/converse.po`);await n(9434)(`./${i}.js`),ov.locale(av(i,(e=>ov.locale(e)))),lv=new(iv())(o)}(ul)}catch(e){z.fatal(e.message),ul.locale="en"}},__(){return r.translate(...arguments)}});const dv=r.__,uv={};bu.elements={registry:uv,define:function(e,t){this.registry[e]=t},register:function(){Object.keys(uv).forEach((e=>{customElements.get(e)||customElements.define(e,uv[e])}))}};class hv extends _u{createRenderRoot(){return this}connectedCallback(){var e;super.connectedCallback(),null===(e=this.initialize)||void 0===e||e.call(this)}disconnectedCallback(){super.disconnectedCallback(),this.stopListening()}}Object.assign(hv.prototype,vi);const mv=["converse-bookmark-views","converse-chatboxviews","converse-chatview","converse-controlbox","converse-dragresize","converse-fullscreen","converse-headlines-view","converse-mam-views","converse-minimize","converse-modal","converse-muc-views","converse-notification","converse-omemo","converse-profile","converse-push","converse-register","converse-roomslist","converse-rootview","converse-rosterview","converse-singleton"];var gv=n(3379),fv=n.n(gv),pv=n(7795),vv=n.n(pv),_v=n(569),yv=n.n(_v),bv=n(3565),wv=n.n(bv),Sv=n(9216),xv=n.n(Sv),Ev=n(4589),Av=n.n(Ev),Cv=n(9537),kv={};kv.styleTagTransform=Av(),kv.setAttributes=wv(),kv.insert=yv().bind(null,"head"),kv.domAPI=vv(),kv.insertStyleElement=xv();fv()(Cv.Z,kv);Cv.Z&&Cv.Z.locals&&Cv.Z.locals;class jv extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid),this.bookmark=ul.bookmarks.get(this.model.get("jid"))}render(){return(e=>{var t,n;const s=(null===(t=e.bookmark)||void 0===t?void 0:t.get("name"))??e.name,i=(null===(n=e.bookmark)||void 0===n?void 0:n.get("nick"))??e.nick,o=dv('Bookmark for "%1$s"',s),r=dv("Would you like this groupchat to be automatically joined upon startup?"),a=dv("Remove"),c=dv("The name for this bookmark:"),l=dv("What should your nickname for this groupchat be?"),d=e.bookmark?dv("Update"):dv("Save");return Kd`
${o}
${e.bookmark?Kd``:""}
`})(Object.assign(this.model.toJSON(),{bookmark:this.bookmark,onCancel:e=>this.removeBookmark(e),onSubmit:e=>this.onBookmarkFormSubmitted(e)}))}onBookmarkFormSubmitted(e){var t,n,s;e.preventDefault(),ul.bookmarks.createBookmark({jid:this.model.get("jid"),autojoin:(null===(t=e.target.querySelector('input[name="autojoin"]'))||void 0===t?void 0:t.checked)||!1,name:null===(n=e.target.querySelector("input[name=name]"))||void 0===n?void 0:n.value,nick:null===(s=e.target.querySelector("input[name=nick]"))||void 0===s?void 0:s.value}),this.closeBookmarkForm(e)}removeBookmark(e){var t;null===(t=this.bookmark)||void 0===t||t.destroy(),this.closeBookmarkForm(e)}closeBookmarkForm(e){e.preventDefault();const t=document.createEvent("Event");t.initEvent("hide.bs.modal",!0,!0),this.dispatchEvent(t)}}bu.elements.define("converse-muc-bookmark-form",jv);const Tv=jv;var $v=n(6151),Nv=n.n($v);const Ov=/^\s*this.onHide()),!1)},onHide(){Pv.removeClass("selected",this.trigger_el),!this.persistent&&bu.modal.remove(this)},insertIntoDOM(){document.querySelector("#converse-modals").insertAdjacentElement("beforeEnd",this.el)},switchTab(e){e.stopPropagation(),e.preventDefault(),Lv(".nav-link.active",this.el).forEach((e=>{Pv.removeClass("active",this.el.querySelector(e.getAttribute("href"))),Pv.removeClass("active",e)})),Pv.addClass("active",e.target),Pv.addClass("active",this.el.querySelector(e.target.getAttribute("href")))},alert(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"primary";const n=this.el.querySelector(".modal-alert");if(null===n)return void z.error("Could not find a .modal-alert element in the modal to show an alert message in!");tu((e=>Kd``)({type:`alert-${t}`,message:e}),n);const s=n.firstElementChild;setTimeout((()=>{Pv.addClass("fade-out",s),setTimeout((()=>Pv.removeElement(s)),600)}),5e3)},show(e){e&&(e.preventDefault(),this.trigger_el=e.target,!Pv.hasClass("chat-image",this.trigger_el)&&Pv.addClass("selected",this.trigger_el)),this.modal.show()}}),Uv=Fv,Bv=Kd``,qv=Kd``,Hv=Uv.extend({id:"converse-bookmark-modal",initialize(e){this.jid=e.jid,this.affiliation=e.affiliation,Uv.prototype.initialize.apply(this,arguments)},toHTML(){return(e=>{const t=dv("Bookmark");return Kd` `})(this)}}),Gv=Hv;var Wv=Ye((function(e,t,n){var s=-1,i="function"==typeof t,o=et(e)?Array(e.length):[];return Zs(e,(function(e){o[++s]=i?Ge(t,e,n):vl(e,t,n)})),o}));const Vv=Wv;function Jv(e,t){if(bu.settings.get("allow_bookmarks")&&e.model.get("type")===ul.CHATROOMS_TYPE){const n=e.model.get("bookmarked"),s={i18n_title:dv(n?"Unbookmark this groupchat":"Bookmark this groupchat"),i18n_text:dv(n?"Unbookmark":"Bookmark"),handler:t=>e.showBookmarkModal(t),a_class:"toggle-bookmark",icon_class:"fa-bookmark",name:"bookmark"},i=t.map((e=>e.name)).indexOf("details"),o=vg().then((e=>e?s:null));return i>-1?[...t.slice(0,i),o,...t.slice(i)]:[o,...t]}return t}function Qv(e){e.preventDefault();const t=e.target.getAttribute("data-bookmark-name"),n=e.target.getAttribute("data-room-jid");confirm(dv('Are you sure you want to remove the bookmark "%1$s"?',t))&&Vv(ul.bookmarks.where({jid:n}),Ac.prototype.destroy)}function Zv(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid");bu.modal.show(Gv,{jid:t},e)}function Kv(e){e.preventDefault();const{Strophe:t}=Su.env,n=e.target.textContent,s=e.target.getAttribute("data-room-jid"),i={name:n||t.unescapeNode(t.getNodeFromJid(s))||s};bu.rooms.open(s,i,!0)}const Yv=e=>{const t=e.get("jid"),n=!(!bu.settings.get("hide_open_bookmarks")||!ul.chatboxes.get(t)),s=dv("Unbookmark this groupchat"),i=dv("Click to open this groupchat");return Kd`
`},Xv=2,e_=e=>function(){for(var t=arguments.length,n=new Array(t),s=0;sdocument.createComment(""),i_=(e,t,n)=>{var s;const i=e._$AA.parentNode,o=void 0===t?e._$AB:t._$AA;if(void 0===n){const t=i.insertBefore(s_(),o),s=i.insertBefore(s_(),o);n=new n_(t,s,e,e.options)}else{const t=n._$AB.nextSibling,r=n._$AM,a=r!==e;if(a){let t;null===(s=n._$AQ)||void 0===s||s.call(n,e),n._$AM=e,void 0!==n._$AP&&(t=e._$AU)!==r._$AU&&n._$AP(t)}if(t!==o||a){let e=n._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,o),e=t}}}return n},o_=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;return e._$AI(t,n),e},r_={},a_=e=>{var t;null===(t=e._$AP)||void 0===t||t.call(e,!1,!0);let n=e._$AA;const s=e._$AB.nextSibling;for(;n!==s;){const e=n.nextSibling;n.remove(),n=e}},c_=(e,t)=>{var n,s;const i=e._$AN;if(void 0===i)return!1;for(const e of i)null===(s=(n=e)._$AO)||void 0===s||s.call(n,t,!1),c_(e,t);return!0},l_=e=>{let t,n;do{if(void 0===(t=e._$AM))break;n=t._$AN,n.delete(e),e=t}while(0===(null==n?void 0:n.size))},d_=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(void 0===n)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),m_(t)}};function u_(e){void 0!==this._$AN?(l_(this),this._$AM=e,d_(this)):this._$AM=e}function h_(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=this._$AH,i=this._$AN;if(void 0!==i&&0!==i.size)if(t)if(Array.isArray(s))for(let e=n;e{var t,n,s,i;e.type==Xv&&(null!==(t=(s=e)._$AP)&&void 0!==t||(s._$AP=h_),null!==(n=(i=e)._$AQ)&&void 0!==n||(i._$AQ=u_))};class g_ extends t_{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),d_(this),this.isConnected=e._$AU}_$AO(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var n,s;e!==this.isConnected&&(this.isConnected=e,e?null===(n=this.reconnected)||void 0===n||n.call(this):null===(s=this.disconnected)||void 0===s||s.call(this)),t&&(c_(this,e),l_(this))}setValue(e){if((e=>void 0===e.strings)(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}class f_{constructor(e){this.U=e}disconnect(){this.U=void 0}reconnect(e){this.U=e}deref(){return this.U}}class p_{constructor(){this.Y=void 0,this.q=void 0}get(){return this.Y}pause(){var e;null!==(e=this.Y)&&void 0!==e||(this.Y=new Promise((e=>this.q=e)))}resume(){var e;null===(e=this.q)||void 0===e||e.call(this),this.Y=this.q=void 0}}const v_=e=>!(e=>null===e||"object"!=typeof e&&"function"!=typeof e)(e)&&"function"==typeof e.then;const __=e_(class extends g_{constructor(){super(...arguments),this._$Cwt=1073741823,this._$Cyt=[],this._$CG=new f_(this),this._$CK=new p_}render(){for(var e,t=arguments.length,n=new Array(t),s=0;s!v_(e))))&&void 0!==e?e:Yd}update(e,t){const n=this._$Cyt;let s=n.length;this._$Cyt=t;const i=this._$CG,o=this._$CK;this.isConnected||this.disconnected();for(let e=0;ethis._$Cwt);e++){const r=t[e];if(!v_(r))return this._$Cwt=e,r;e{for(;o.get();)await o.get();const t=i.deref();if(void 0!==t){const n=t._$Cyt.indexOf(r);n>-1&&n{const t=ul.bookmarks.getUnopenedBookmarks();return __(t.then((t=>((e,t)=>{const n=dv("Click to toggle the bookmarks list"),s=dv("Bookmarks"),i=e.model.get("toggle-state");return Kd`
e.toggleBookmarksList()}> ${s}
${ul.bookmarks.map((e=>Yv(e)))}
`})(e,t))),"")};class b_ extends hv{async initialize(){await bu.waitUntil("bookmarksInitialized");const{bookmarks:e,chatboxes:t}=ul;this.listenTo(e,"add",(()=>this.requestUpdate())),this.listenTo(e,"remove",(()=>this.requestUpdate())),this.listenTo(t,"add",(()=>this.requestUpdate())),this.listenTo(t,"remove",(()=>this.requestUpdate()));const n=`converse.bookmarks-list-model-${ul.bare_jid}`;this.model=new ul.BookmarksList({id:n}),La(this.model,n),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.model.fetch({success:()=>this.requestUpdate(),error:()=>this.requestUpdate()})}render(){return ul.bookmarks&&this.model?y_(this):""}toggleBookmarksList(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const{CLOSED:n,OPENED:s}=ul;this.model.save({"toggle-state":this.model.get("toggle-state")===n?s:n})}}bu.elements.define("converse-bookmarks",b_);const{u:w_}=Su.env,S_={setBookmarkState(){if(void 0!==ul.bookmarks){ul.bookmarks.where({jid:this.model.get("jid")}).length?this.model.save("bookmarked",!0):this.model.save("bookmarked",!1)}},renderBookmarkForm(){if(!this.bookmark_form){this.bookmark_form=new ul.MUCBookmarkForm({model:this.model,chatroomview:this});this.querySelector(".chatroom-body").insertAdjacentElement("beforeend",this.bookmark_form.el)}w_.showElement(this.bookmark_form.el)},showBookmarkModal(e){null==e||e.preventDefault();const t=this.model.get("jid");bu.modal.show(Gv,{jid:t},e)}};var x_=n(5251),E_={};E_.styleTagTransform=Av(),E_.setAttributes=wv(),E_.insert=yv().bind(null,"head"),E_.domAPI=vv(),E_.insertStyleElement=xv();fv()(x_.Z,E_);x_.Z&&x_.Z.locals&&x_.Z.locals;Su.plugins.add("converse-bookmark-views",{dependencies:["converse-chatboxes","converse-muc","converse-muc-views"],initialize(){bu.settings.extend({hide_open_bookmarks:!0}),ul.removeBookmarkViaEvent=Qv,ul.addBookmarkViaEvent=Zv,Object.assign(ul.ChatRoomView.prototype,S_),ul.MUCBookmarkForm=Tv,ul.BookmarksView=b_,bu.listen.on("getHeadingButtons",Jv),bu.listen.on("chatRoomViewInitialized",(e=>e.setBookmarkState()))}});const A_=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},C_=e_(class extends t_{constructor(e){if(super(e),e.type!==Xv)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;void 0===n?n=t:void 0!==t&&(s=t);const i=[],o=[];let r=0;for(const t of e)i[r]=s?s(t,r):r,o[r]=n(t,r),r++;return{values:o,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,t){let[n,s,i]=t;var o;const r=(e=>e._$AH)(e),{values:a,keys:c}=this.dt(n,s,i);if(!Array.isArray(r))return this.ut=c,a;const l=null!==(o=this.ut)&&void 0!==o?o:this.ut=[],d=[];let u,h,m=0,g=r.length-1,f=0,p=a.length-1;for(;m<=g&&f<=p;)if(null===r[m])m++;else if(null===r[g])g--;else if(l[m]===c[f])d[f]=o_(r[m],a[f]),m++,f++;else if(l[g]===c[p])d[p]=o_(r[g],a[p]),g--,p--;else if(l[m]===c[p])d[p]=o_(r[m],a[p]),i_(e,d[p+1],r[m]),m++,p--;else if(l[g]===c[f])d[f]=o_(r[g],a[f]),i_(e,r[m],r[g]),g--,f++;else if(void 0===u&&(u=A_(c,f,p),h=A_(l,m,g)),u.has(l[m]))if(u.has(l[g])){const t=h.get(c[f]),n=void 0!==t?r[t]:null;if(null===n){const t=i_(e,r[m]);o_(t,a[f]),d[f]=t}else d[f]=o_(n,a[f]),i_(e,r[m],n),r[t]=null;f++}else a_(r[g]),g--;else a_(r[m]),m++;for(;f<=p;){const t=i_(e,d[p+1]);o_(t,a[f]),d[f++]=t}for(;m<=g;){const e=r[m++];null!==e&&a_(e)}return this.ut=c,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r_;e._$AH=t}(e,d),Yd}});function k_(e){const{CONTROLBOX_TYPE:t}=ul,n="overlayed"===bu.settings.get("view_mode")&&e.get("minimized");return e.get("type")===t||!(e.get("hidden")||n)}bu.elements.define("converse-chats",class extends hv{initialize(){this.model=ul.chatboxes,this.listenTo(this.model,"add",(()=>this.requestUpdate())),this.listenTo(this.model,"change:closed",(()=>this.requestUpdate())),this.listenTo(this.model,"change:hidden",(()=>this.requestUpdate())),this.listenTo(this.model,"change:jid",(()=>this.requestUpdate())),this.listenTo(this.model,"change:minimized",(()=>this.requestUpdate())),this.listenTo(this.model,"destroy",(()=>this.requestUpdate())),this.listenTo(ul,"connected",(()=>this.requestUpdate())),this.listenTo(ul,"reconnected",(()=>this.requestUpdate())),this.listenTo(ul,"disconnected",(()=>this.requestUpdate()));const e=al();this.listenTo(e,"change:view_mode",(()=>this.requestUpdate())),this.listenTo(e,"change:singleton",(()=>this.requestUpdate()));const t=document.getElementById("conversejs-bg");t&&!t.innerHTML.trim()&&tu(Kd`
Logo Converse converse.js
${"overlayed"===bu.settings.get("view_mode")?Kd`
`:""}
`,t);document.querySelector("body").classList.add(`converse-${bu.settings.get("view_mode")}`),bu.trigger("chatBoxViewsInitialized")}render(){return(()=>{const{chatboxes:e,CONTROLBOX_TYPE:t,CHATROOMS_TYPE:n,HEADLINES_TYPE:s}=ul,i=bu.settings.get("view_mode"),o=null==ul?void 0:ul.connection,r=!(null!=o&&o.connected)||!(null!=o&&o.authenticated)||(null==o?void 0:o.disconnecting);return Kd` ${r||"overlayed"!==i?"":Kd``} ${C_(e.filter(k_),(e=>e.get("jid")),(e=>e.get("type")===t?Kd` ${"overlayed"===i?Kd``:""} `:e.get("type")===n?Kd` `:e.get("type")===s?Kd` `:Kd` `))} `})()}});const j_=class{constructor(){this.views={}}add(e,t){this.views[e]=t}get(e){return this.views[e]}xget(e){return this.keys().filter((t=>t!==e)).reduce(((e,t)=>(e[t]=this.views[t],e)),{})}getAll(){return Object.values(this.views)}keys(){return Object.keys(this.views)}remove(e){delete this.views[e]}map(e){return Object.values(this.views).map(e)}forEach(e){return Object.values(this.views).forEach(e)}filter(e){return Object.values(this.views).filter(e)}closeAllChatBoxes(){return Promise.all(Object.values(this.views).map((e=>e.close({name:"closeAllChatBoxes"}))))}};function T_(){const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)}var $_=n(6931),N_={};N_.styleTagTransform=Av(),N_.setAttributes=wv(),N_.insert=yv().bind(null,"head"),N_.domAPI=vv(),N_.insertStyleElement=xv();fv()($_.Z,N_);$_.Z&&$_.Z.locals&&$_.Z.locals;Su.plugins.add("converse-chatboxviews",{dependencies:["converse-chatboxes","converse-vcard"],initialize(){bu.promises.add(["chatBoxViewsInitialized"]),bu.settings.extend({animate:!0}),ul.chatboxviews=new j_,bu.listen.on("chatBoxesInitialized",(()=>{ul.chatboxes.on("destroy",(e=>ul.chatboxviews.remove(e.get("jid"))))})),bu.listen.on("cleanup",(()=>delete ul.chatboxviews)),bu.listen.on("clearSession",(()=>ul.chatboxviews.closeAllChatBoxes())),bu.listen.on("chatBoxViewsInitialized",T_),window.addEventListener("resize",T_),Object.assign(Su,{insertInto(e){var t;const n=null===(t=ul.chatboxviews)||void 0===t?void 0:t.el;if(n&&!e.contains(n))e.insertAdjacentElement("afterBegin",n);else if(!n)throw new Error("Cannot insert non-existing #conversejs element into the DOM")}})}});const O_=Uv.extend({id:"alert-modal",initialize(){Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render)},toHTML(){return(e=>Kd` `)(Object.assign({__:dv},this.model.toJSON()))}}),I_=O_,M_=e=>Kd` `,R_=Uv.extend({id:"confirm-modal",events:{"submit .confirm":"onConfimation"},initialize(){this.confirmation=ba(),Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.el.addEventListener("closed.bs.modal",(()=>this.confirmation.reject()),!1)},toHTML(){return M_(this.model.toJSON())},afterRender(){this.close_handler_registered||(this.el.addEventListener("closed.bs.modal",(()=>{this.confirmation.isResolved||this.confirmation.reject()}),!1),this.close_handler_registered=!0)},onConfimation(e){e.preventDefault();const t=new FormData(e.target),n=(this.model.get("fields")||[]).map((e=>{const n=t.get(e.name).trim();return e.value=n,e.challenge&&(e.challenge_failed=n!==e.challenge),e}));if(n.filter((e=>e.challenge_failed)).length)return this.model.set("fields",n),void this.model.trigger("change");this.confirmation.resolve(n),this.modal.hide()}}),D_=R_;let z_=[];const L_={modal:{show(e,t,n){const s=this.get(e.id)||this.create(e,t);return s.show(n),s},get:e=>z_.filter((t=>t.id==e)).pop(),create(e,t){const n=new e(t);return z_.push(n),n},remove(e){z_=z_.filter((t=>t!==e)),e.remove()},removeAll(){z_.forEach((e=>e.remove())),z_=[]}},async confirm(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];"string"==typeof t&&(t=[t]);const n=new Ac({title:e,messages:t,fields:arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],type:"confirm"}),s=new D_({model:n});let i;s.show();try{i=await s.confirmation}catch(e){i=!1}return s.remove(),i},async prompt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];"string"==typeof t&&(t=[t]);const n=new Ac({title:e,messages:t,fields:[{name:"reason",placeholder:arguments.length>2&&void 0!==arguments[2]?arguments[2]:""}],type:"prompt"}),s=new D_({model:n});let i;s.show();try{var o;i=null===(o=(await s.confirmation).pop())||void 0===o?void 0:o.value}catch(e){i=!1}return s.remove(),i},alert(e,t,n){let s;"string"==typeof n&&(n=[n]),"error"===e?s="alert-danger":"info"===e?s="alert-info":"warn"===e&&(s="alert-warning");const i=new Ac({title:t,messages:n,level:s,type:"alert"});L_.modal.show(I_,{model:i})}},P_=L_;Su.env.BootstrapModal=Uv,Su.plugins.add("converse-modal",{initialize(){bu.listen.on("disconnect",(()=>{const e=document.querySelector("#converse-modals");e&&(e.innerHTML="")})),bu.listen.on("clearSession",(()=>bu.modal.removeAll())),Object.assign(ul.api,P_)}});var F_=n(4166),U_={};U_.styleTagTransform=Av(),U_.setAttributes=wv(),U_.insert=yv().bind(null,"head"),U_.domAPI=vv(),U_.insertStyleElement=xv();fv()(F_.Z,U_);F_.Z&&F_.Z.locals&&F_.Z.locals;const{Strophe:B_,u:q_}=Su.env;class H_ extends hv{static get properties(){return{is_retracted:{type:Boolean},model:{type:Object}}}initialize(){const e=al();this.listenTo(e,"change:allowed_audio_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:allowed_image_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:allowed_video_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:render_media",(()=>this.requestUpdate())),this.listenTo(this.model,"change",(()=>this.requestUpdate()))}render(){return Kd`${__(this.renderActions(),"")}`}async renderActions(){const e=this.model.collection.length>2&&this.model===this.model.collection.last(),t=(await this.getActionButtons()).map((e=>H_.getActionsDropdownItem(e)));return t.length?Kd``:""}static getActionsDropdownItem(e){return Kd` `}onMessageEditButtonClicked(e){var t,n;e.preventDefault();const s=this.model.collection.findWhere("correcting"),i=null===(t=q_.ancestor(this,".chatbox"))||void 0===t||null===(n=t.querySelector(".chat-textarea"))||void 0===n?void 0:n.value;(!i||s&&s.getMessageText()===i||confirm(dv("You have an unsent message which will be lost if you continue. Are you sure?")))&&(s!==this.model?(null==s||s.save("correcting",!1),this.model.save("correcting",!0)):this.model.save("correcting",!1))}async onDirectMessageRetractButtonClicked(){if("me"!==this.model.get("sender"))return z.error("onMessageRetractButtonClicked called for someone else's message!");const e=dv("Be aware that other XMPP/Jabber clients (and servers) may not yet support retractions and that this message may not be removed everywhere."),t=[dv("Are you sure you want to retract this message?")];bu.settings.get("show_retraction_warning")&&(t[1]=e);if(await bu.confirm(dv("Confirm"),t)){this.model.collection.chatbox.retractOwnMessage(this.model)}}async retractOtherMessage(e){const t=this.model.collection.chatbox,n=await t.retractOtherMessage(this.model,e);if(null===n){const e=dv("A timeout occurred while trying to retract the message");bu.alert("error",dv("Error"),e),z(e,B_.LogLevel.WARN)}else if(q_.isErrorStanza(n)){const e=dv("Sorry, you're not allowed to retract this message.");bu.alert("error",dv("Error"),e),z(e,B_.LogLevel.WARN),z(n,B_.LogLevel.WARN)}}async onMUCMessageRetractButtonClicked(){const e=dv("Be aware that other XMPP/Jabber clients (and servers) may not yet support retractions and that this message may not be removed everywhere.");if(this.model.mayBeRetracted()){const t=[dv("Are you sure you want to retract this message?")];if(bu.settings.get("show_retraction_warning")&&(t[1]=e),await bu.confirm(dv("Confirm"),t)){this.model.collection.chatbox.retractOwnMessage(this.model)}}else if(await this.model.mayBeModerated())if("me"===this.model.get("sender")){let t=[dv("Are you sure you want to retract this message?")];bu.settings.get("show_retraction_warning")&&(t=[t[0],e,t[1]]),await bu.confirm(dv("Confirm"),t)&&this.retractOtherMessage()}else{let t=[dv("You are about to retract this message."),dv("You may optionally include a message, explaining the reason for the retraction.")];bu.settings.get("show_retraction_warning")&&(t=[t[0],e,t[1]]);const n=await bu.prompt(dv("Message Retraction"),t,dv("Optional reason"));!1!==n&&this.retractOtherMessage(n)}else{const e=dv("Sorry, you're not allowed to retract this message");bu.alert("error",dv("Error"),e)}}onMessageRetractButtonClicked(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);this.model.collection.chatbox.get("type")===ul.CHATROOMS_TYPE?this.onMUCMessageRetractButtonClicked():this.onDirectMessageRetractButtonClicked()}onMediaToggleClicked(e){var t;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.hasHiddenMedia(this.getMediaURLs()))this.model.save({hide_url_previews:!1,url_preview_transition:"fade-in"});else{(this.model.get("ogp_metadata")||[]).length?this.model.set("url_preview_transition","fade-out"):this.model.save({hide_url_previews:!0,url_preview_transition:"fade-in"})}}hasHiddenMedia(e){if("boolean"==typeof this.model.get("hide_url_previews"))return this.model.get("hide_url_previews");const t=bu.settings.get("render_media");return Array.isArray(t)?e.reduce(((e,n)=>e||!$u(t,n)),!1):!t}getMediaURLs(){const e=(this.model.get("ogp_metadata")||[]).map((e=>({url:e["og:image"],is_image:!0}))).filter((e=>Mu(e))),t=_h(this.model.get("media_urls")||[],this.model.get("body")).filter((e=>Mu(e)));return[...new Set([...t.map((e=>e.url)),...e.map((e=>e.url))])]}addMediaRenderingToggle(e){const t=this.getMediaURLs();if(t.length){const n=this.hasHiddenMedia(t);e.push({i18n_text:dv(n?"Show media":"Hide media"),handler:e=>this.onMediaToggleClicked(e),button_class:"chat-msg__action-hide-previews",icon_class:n?"fas fa-eye":"fas fa-eye-slash",name:"hide"})}}async getActionButtons(){const e=[];this.model.get("editable")&&e.push({i18n_text:this.model.get("correcting")?dv("Cancel Editing"):dv("Edit"),handler:e=>this.onMessageEditButtonClicked(e),button_class:"chat-msg__action-edit",icon_class:"fa fa-pencil-alt",name:"edit"});const t=["groupchat","mep"].includes(this.model.get("type"))&&await this.model.mayBeModerated();return!this.is_retracted&&(this.model.mayBeRetracted()||t)&&e.push({i18n_text:dv("Retract"),handler:e=>this.onMessageRetractButtonClicked(e),button_class:"chat-msg__action-retract",icon_class:"fas fa-trash-alt",name:"retract"}),this.model.collection?(this.addMediaRenderingToggle(e),bu.hook("getMessageActionButtons",this,e)):[]}}bu.elements.define("converse-message-actions",H_);const G_=Uv.extend({id:"image-modal",toHTML(){return(e=>Kd` `)({src:this.src,onload:e=>e.target.parentElement.style.height=`${e.target.height}px`})}}),W_=(e,t)=>Kd`${t?"":Kd`${e}`}`;class V_{constructor(e){e.toString().indexOf("ArrayBuffer")>0&&(e=new Uint8Array(e)),this.data=e,this.len=this.data.length,this.pos=0}readByte(){if(this.pos>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.pos++]:255&this.data.charCodeAt(this.pos++)}readBytes(e){const t=[];for(let n=0;n=0;n--)t.push(!!(e&1<>3)&1<<(7&n)&&(s|=1<ey(e,t)),0)}class ty{constructor(e,t){this.options=Object.assign({width:null,height:null,autoplay:!0,loop:!0,show_progress_bar:!0,progress_bg_color:"rgba(0,0,0,0.4)",progress_color:"rgba(255,0,22,.8)",progress_bar_height:5},t),this.el=e,this.gif_el=e.querySelector("img"),this.canvas=e.querySelector("canvas"),this.ctx=this.canvas.getContext("2d"),this.offscreenCanvas=document.createElement("canvas"),this.ctx_scaled=!1,this.disposal_method=null,this.disposal_restore_from_idx=null,this.frame=null,this.frame_offsets=[],this.frames=[],this.last_disposal_method=null,this.last_img=null,this.load_error=null,this.playing=this.options.autoplay,this.transparency=null,this.frame_idx=0,this.iteration_count=0,this.start=null,this.initialize()}async initialize(){this.options.width&&this.options.height&&this.setSizes(this.options.width,this.options.height);const e=await this.fetchGIF(this.gif_el.src);requestAnimationFrame((()=>this.startParsing(e)))}initPlayer(){if(!this.load_error&&(this.options.width&&this.options.height||this.ctx.scale(this.getCanvasScale(),this.getCanvasScale()),this.frame_idx=0,this.putFrame(this.frame_idx),this.options.autoplay)){var e;const t=10*((null===(e=this.frames[this.frame_idx])||void 0===e?void 0:e.delay)??0);setTimeout((()=>this.play()),t)}}getNextFrameNo(){return(this.frame_idx+1+this.frames.length)%this.frames.length}onIterationEnd(){var e,t;return this.iteration_count++,null===(e=(t=this.options).onIterationEnd)||void 0===e||e.call(t,this),!this.options.loop&&(this.pause(),!0)}onAnimationFrame(e,t,n){var s;if(!this.playing)return;if(e-tthis.onAnimationFrame(e,t,n)));const i=this.getNextFrameNo();if(0===i&&this.onIterationEnd())return;this.frame_idx=i,this.putFrame(this.frame_idx);const o=10*((null===(s=this.frames[this.frame_idx])||void 0===s?void 0:s.delay)||8);requestAnimationFrame((t=>this.onAnimationFrame(t,e,o)))}setSizes(e,t){this.canvas.width=e*this.getCanvasScale(),this.canvas.height=t*this.getCanvasScale(),this.offscreenCanvas.width=e,this.offscreenCanvas.height=t,this.offscreenCanvas.style.width=e+"px",this.offscreenCanvas.style.height=t+"px",this.offscreenCanvas.getContext("2d").setTransform(1,0,0,1,0,0)}setFrameOffset(e,t){this.frame_offsets[e]?(void 0!==t.x&&(this.frame_offsets[e].x=t.x),void 0!==t.y&&(this.frame_offsets[e].y=t.y)):this.frame_offsets[e]=t}doShowProgress(e,t,n){if(n&&this.options.show_progress_bar){let n=this.options.progress_bar_height;const s=(this.canvas.height-n)/(this.ctx_scaled?this.getCanvasScale():1),i=e/t*this.canvas.width/(this.ctx_scaled?this.getCanvasScale():1),o=this.canvas.width/(this.ctx_scaled?this.getCanvasScale():1);n/=this.ctx_scaled?this.getCanvasScale():1,this.ctx.fillStyle=this.options.progress_bg_color,this.ctx.fillRect(i,s,o-i,n),this.ctx.fillStyle=this.options.progress_color,this.ctx.fillRect(0,s,i,n)}}startParsing(e){const t=new V_(e),n={hdr:this.withProgress(t,(e=>this.handleHeader(e))),gce:this.withProgress(t,(e=>this.handleGCE(e))),com:this.withProgress(t),img:this.withProgress(t,(e=>this.doImg(e)),!0),eof:()=>this.handleEOF(t)};try{!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};X_(e,null==t?void 0:t.hdr),setTimeout((()=>ey(e,t)),0)}(t,n)}catch(e){this.showError("parse")}}drawError(){this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.options.width?this.options.width:this.hdr.width,this.options.height?this.options.height:this.hdr.height),this.ctx.strokeStyle="red",this.ctx.lineWidth=3,this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width?this.options.width:this.hdr.width,this.options.height?this.options.height:this.hdr.height),this.ctx.moveTo(0,this.options.height?this.options.height:this.hdr.height),this.ctx.lineTo(this.options.width?this.options.width:this.hdr.width,0),this.ctx.stroke()}showError(e){this.load_error=e,this.hdr={width:this.gif_el.width,height:this.gif_el.height},this.frames=[],this.drawError(),this.el.requestUpdate()}handleHeader(e){this.hdr=e,this.setSizes(this.options.width??this.hdr.width,this.options.height??this.hdr.height)}handleGCE(e){this.pushFrame(e.delayTime),this.clear(),this.transparency=e.transparencyGiven?e.transparencyIndex:null,this.disposal_method=e.disposalMethod}handleEOF(e){this.doDecodeProgress(e,!1),this.options.width&&this.options.height||(this.canvas.width=this.hdr.width*this.getCanvasScale(),this.canvas.height=this.hdr.height*this.getCanvasScale()),this.initPlayer(),!this.options.autoplay&&this.drawPlayIcon()}pushFrame(e){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:e}),this.frame_offsets.push({x:0,y:0}))}doImg(e){this.frame=this.frame||this.offscreenCanvas.getContext("2d");const t=this.frames.length,n=e.lctFlag?e.lct:this.hdr.gct;t>0&&(3===this.last_disposal_method?null!==this.disposal_restore_from_idx?this.frame.putImageData(this.frames[this.disposal_restore_from_idx].data,0,0):this.frame.clearRect(this.last_img.leftPos,this.last_img.topPos,this.last_img.width,this.last_img.height):this.disposal_restore_from_idx=t-1,2===this.last_disposal_method&&this.frame.clearRect(this.last_img.leftPos,this.last_img.topPos,this.last_img.width,this.last_img.height));const s=this.frame.getImageData(e.leftPos,e.topPos,e.width,e.height);e.pixels.forEach(((e,t)=>{e!==this.transparency&&(s.data[4*t+0]=n[e][0],s.data[4*t+1]=n[e][1],s.data[4*t+2]=n[e][2],s.data[4*t+3]=255)})),this.frame.putImageData(s,e.leftPos,e.topPos),this.ctx_scaled||(this.ctx.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctx_scaled=!0),this.last_img||this.ctx.drawImage(this.offscreenCanvas,0,0),this.last_img=e}putFrame(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];(e=parseInt(e,10))>this.frames.length-1&&(e=0),e<0&&(e=0);const n=this.frame_offsets[e];this.offscreenCanvas.getContext("2d").putImageData(this.frames[e].data,n.x,n.y),this.ctx.globalCompositeOperation="copy",this.ctx.drawImage(this.offscreenCanvas,0,0),t&&this.hovering&&this.drawPauseIcon()}clear(){this.transparency=null,this.last_disposal_method=this.disposal_method,this.disposal_method=null,this.frame=null}play(){this.playing=!0,requestAnimationFrame((e=>this.onAnimationFrame(e,0,0)))}pause(){this.playing=!1,requestAnimationFrame((()=>this.drawPlayIcon()))}drawPauseIcon(){if(!this.playing)return;this.putFrame(this.frame_idx,!1),this.ctx.globalCompositeOperation="source-over",this.ctx.fillStyle="rgb(0, 0, 0, 0.25)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);const e=.1*this.canvas.height;this.ctx.lineWidth=.04*this.canvas.height,this.ctx.beginPath(),this.ctx.moveTo(this.canvas.width/2-e/2,this.canvas.height/2-e),this.ctx.lineTo(this.canvas.width/2-e/2,this.canvas.height/2+e),this.ctx.fillStyle="rgb(200, 200, 200, 0.75)",this.ctx.stroke(),this.ctx.beginPath(),this.ctx.moveTo(this.canvas.width/2+e/2,this.canvas.height/2-e),this.ctx.lineTo(this.canvas.width/2+e/2,this.canvas.height/2+e),this.ctx.fillStyle="rgb(200, 200, 200, 0.75)",this.ctx.stroke(),this.ctx.lineWidth=.02*this.canvas.height,this.ctx.strokeStyle="rgb(200, 200, 200, 0.75)",this.ctx.beginPath(),this.ctx.arc(this.canvas.width/2,this.canvas.height/2,1.5*e,0,2*Math.PI),this.ctx.stroke()}drawPlayIcon(){if(this.playing)return;this.putFrame(this.frame_idx,!1),this.ctx.globalCompositeOperation="source-over",this.ctx.fillStyle="rgb(0, 0, 0, 0.25)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);const e=.1*this.canvas.height,t=new Path2D;t.moveTo(this.canvas.width/2+e,this.canvas.height/2),t.lineTo(this.canvas.width/2-e/2,this.canvas.height/2+e),t.lineTo(this.canvas.width/2-e/2,this.canvas.height/2-e),t.closePath(),this.ctx.fillStyle="rgb(200, 200, 200, 0.75)",this.ctx.fill(t);const n=1.5*e;this.ctx.lineWidth=.02*this.canvas.height,this.ctx.strokeStyle="rgb(200, 200, 200, 0.75)",this.ctx.beginPath(),this.ctx.arc(this.canvas.width/2,this.canvas.height/2,n,0,2*Math.PI),this.ctx.stroke()}doDecodeProgress(e,t){this.doShowProgress(e.pos,e.data.length,t)}withProgress(e,t,n){return s=>{null==t||t(s),this.doDecodeProgress(e,n)}}getCanvasScale(){let e;return e=this.options.max_width&&this.hdr&&this.hdr.width>this.options.max_width?this.options.max_width/this.hdr.width:1,e}fetchGIF(e){const t=ba(),n=new XMLHttpRequest;return n.open("GET",e,!0),null==n||n.overrideMimeType("text/plain; charset=x-user-defined"),n.onload=()=>{if(200!=n.status)return this.showError("xhr - response"),t.reject();t.resolve(n.response)},n.onprogress=e=>e.lengthComputable&&this.doShowProgress(e.loaded,e.total,!0),n.onerror=()=>this.showError("xhr"),n.send(),t}}const ny=(e,t)=>{const n=dv('Download file "%1$s"',t);return Kd`${n}`},sy=e=>Kd`
${"hidden"!==e.type?Kd``:""} ${"password"===e.type&&e.fixed_username?Kd` `:""}
`,iy=e=>{var t;return Kd`
`},oy=e=>Kd` `,ry=e=>Kd`
${e.label?Kd``:""}
${e.domain}
`;function ay(e){e.preventDefault(),bu.rooms.open(e.target.href)}const cy=(e,t)=>{let n=e.normalizePath().toString();return e._parts.protocol||t.startsWith("http://")||t.startsWith("https://")||(n="http://"+n),"xmpp"===e._parts.protocol&&"join"===e._parts.query?Kd` ${t}`:Kd`${t}`},ly=(e,t)=>Kd`${t?"":Kd`${e}`}`,{sizzle:dy}=Su.env,uy=["http","https","xmpp","mailto"];function hy(e,t){return{"muc#roomconfig_lang":"language","muc#roomconfig_roomsecret":null!=t&&t.new_password?"new-password":"current-password"}[e]}const my={"text-private":"password","text-single":"text",fixed:"label",boolean:"checkbox",hidden:"hidden","jid-multi":"textarea","list-single":"dropdown","list-multi":"dropdown"},gy={"xs:anyURI":"url","xs:byte":"number","xs:date":"date","xs:dateTime":"datetime","xs:int":"number","xs:integer":"number","xs:time":"time"};function fy(e){const t=my[e.getAttribute("type")];if("text"==t){const n=e.getElementsByTagNameNS("http://jabber.org/protocol/xdata-validate","validate");if(1===n.length){const e=n[0].getAttribute("datatype");return gy[e]||t}}return t}function py(e){e.removeAttribute("data-slider-marker"),e.classList.remove("collapsed"),e.style.overflow="",e.style.height=""}function vy(e){try{return decodeURI(e.filename())}catch(t){return z.debug(t),e.filename()}}function _y(e){const t=ju(e);return null===t?e:Lu(t)?ly(e):zu(t)?W_(e):(Pu(t),ny(t.toString(),vy(t)))}function yy(e,t){let n=e;for(;null!==n&&!dy.matchesSelector(n,t);)n=n.parentElement;return n}function by(e){const t=RegExp("^w{3}.","ig").test(e)?`http://${e}`:e,n=ju(e);return null===n||!function(e){try{return!!new URL(e)}catch(e){return!1}}(t)||!function(e){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:uy).includes(e)}(n._parts.protocol)&&n._parts.protocol?e:cy(n,e)}function wy(e,t){e.classList.remove("visible"),Se(t)&&t()}nl.calculateElementHeight=function(e){return Array.from(e.children).reduce(((e,t)=>e+t.offsetHeight),0)},nl.getNextElement=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=e.nextElementSibling;for(;null!==n&&!dy.matchesSelector(n,t);)n=n.nextElementSibling;return n},nl.getPreviousElement=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=e.previousElementSibling;for(;null!==n&&!dy.matchesSelector(n,t);)n=n.previousElementSibling;return n},nl.getFirstChildElement=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=e.firstElementChild;for(;null!==n&&!dy.matchesSelector(n,t);)n=n.nextElementSibling;return n},nl.getLastChildElement=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=e.lastElementChild;for(;null!==n&&!dy.matchesSelector(n,t);)n=n.previousElementSibling;return n},nl.hasClass=function(e,t){return t instanceof Element&&t.classList.contains(e)},nl.toggleClass=function(e,t){nl.hasClass(e,t)?nl.removeClass(e,t):nl.addClass(e,t)},nl.addClass=function(e,t){return t instanceof Element&&t.classList.add(e),t},nl.removeClass=function(e,t){return t instanceof Element&&t.classList.remove(e),t},nl.removeElement=function(e){return e instanceof Element&&e.parentNode&&e.parentNode.removeChild(e),e},nl.getElementFromTemplateResult=function(e){const t=document.createElement("div");return tu(e,t),t.firstElementChild},nl.showElement=e=>{nl.removeClass("collapsed",e),nl.removeClass("hidden",e)},nl.hideElement=function(e){return e instanceof Element&&e.classList.add("hidden"),e},nl.nextUntil=function(e,t){const n=[];let s=e.nextElementSibling;for(;null!==s&&!s.matches(t);)n.push(s),s=s.nextElementSibling;return n},nl.unescapeHTML=function(e){var t=document.createElement("div");return t.innerHTML=e,t.innerText},nl.escapeHTML=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},nl.slideInAllElements=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300;return Promise.all(Array.from(e).map((e=>nl.slideIn(e,t))))},nl.slideToggleElement=function(e,t){return nl.hasClass("collapsed",e)||nl.hasClass("hidden",e)?nl.slideOut(e,t):nl.slideIn(e,t)},nl.slideOut=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return new Promise(((n,s)=>{if(!e){const e="An element needs to be passed in to slideOut";return z.warn(e),void s(new Error(e))}const i=e.getAttribute("data-slider-marker");i&&(e.removeAttribute("data-slider-marker"),window.cancelAnimationFrame(i));const o=nl.calculateElementHeight(e);if(window.converse_disable_effects)return e.style.height=o+"px",py(e),void n();if(!nl.hasClass("collapsed",e)&&!nl.hasClass("hidden",e))return void n();const r=t/17;let a=0;e.style.height="0",e.style.overflow="hidden",e.classList.remove("hidden"),e.classList.remove("collapsed"),e.setAttribute("data-slider-marker",window.requestAnimationFrame((function t(){a+=o/r,a1&&void 0!==arguments[1]?arguments[1]:200;return new Promise(((n,s)=>{if(!e){const e="An element needs to be passed in to slideIn";return z.warn(e),s(new Error(e))}if(nl.hasClass("collapsed",e))return n(e);if(window.converse_disable_effects)return e.classList.add("collapsed"),e.style.height="",n(e);const i=e.getAttribute("data-slider-marker");i&&(e.removeAttribute("data-slider-marker"),window.cancelAnimationFrame(i));const o=e.offsetHeight,r=t/17;let a=o;e.style.overflow="hidden",e.setAttribute("data-slider-marker",window.requestAnimationFrame((function t(){a-=o/r,a>0?(e.style.height=a+"px",e.setAttribute("data-slider-marker",window.requestAnimationFrame(t))):(e.removeAttribute("data-slider-marker"),e.classList.add("collapsed"),e.style.height="",n(e))})))}))},nl.isInDOM=function(e){return document.querySelector("body").contains(e)},nl.isVisible=function(e){return null!==e&&(!nl.hasClass("hidden",e)&&(e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0))},nl.fadeIn=function(e,t){if(e||z.warn("An element needs to be passed in to fadeIn"),window.converse_disable_effects)return e.classList.remove("hidden"),wy(e,t);nl.hasClass("hidden",e)?(e.classList.add("visible"),e.classList.remove("hidden"),e.addEventListener("webkitAnimationEnd",(()=>wy(e,t))),e.addEventListener("animationend",(()=>wy(e,t))),e.addEventListener("oanimationend",(()=>wy(e,t)))):wy(e,t)},nl.xForm2TemplateResult=function(e,t,n){if("list-single"===e.getAttribute("type")||"list-multi"===e.getAttribute("type")){const t=nl.queryChildren(e,"value").map((e=>null==e?void 0:e.textContent)),n=nl.queryChildren(e,"option").map((n=>{var s;const i=null===(s=n.querySelector("value"))||void 0===s?void 0:s.textContent;return{value:i,label:n.getAttribute("label"),selected:t.includes(i),required:!!e.querySelector("required")}}));return iy({options:n,id:nl.getUniqueId(),label:e.getAttribute("label"),multiple:"list-multi"===e.getAttribute("type"),name:e.getAttribute("var"),required:!!e.querySelector("required")})}if("fixed"===e.getAttribute("type")){var s;return(e=>Kd`

${e.text}

`)({text:null===(s=e.querySelector("value"))||void 0===s?void 0:s.textContent})}var i,o,r;if("jid-multi"===e.getAttribute("type"))return(e=>Kd` `)({name:e.getAttribute("var"),label:e.getAttribute("label")||"",value:null===(i=e.querySelector("value"))||void 0===i?void 0:i.textContent,required:!!e.querySelector("required")});if("boolean"===e.getAttribute("type")){var a;const t=null===(a=e.querySelector("value"))||void 0===a?void 0:a.textContent;return(e=>Kd`
`)({id:nl.getUniqueId(),name:e.getAttribute("var"),label:e.getAttribute("label")||"",checked:"1"===t||"true"===t?'checked="1"':"",required:!!e.querySelector("required")})}if("url"===e.getAttribute("var"))return oy({label:e.getAttribute("label")||"",value:null===(o=e.querySelector("value"))||void 0===o?void 0:o.textContent});if("username"===e.getAttribute("var"))return ry({domain:" @"+n.domain,name:e.getAttribute("var"),type:fy(e),label:e.getAttribute("label")||"",value:null===(r=e.querySelector("value"))||void 0===r?void 0:r.textContent,required:!!e.querySelector("required")});if("ocr"===e.getAttribute("var")){const n=e.querySelector("uri"),s=dy('data[cid="'+n.textContent.replace(/^cid:/,"")+'"]',t)[0];return(e=>Kd`
${e.label?Kd``:""}
`)({label:e.getAttribute("label"),name:e.getAttribute("var"),data:null==s?void 0:s.textContent,type:n.getAttribute("type"),required:!!e.querySelector("required")})}{var c;const t=e.getAttribute("var");return sy({id:nl.getUniqueId(),label:e.getAttribute("label")||"",name:t,fixed_username:null==n?void 0:n.fixed_username,autocomplete:hy(t,n),placeholder:null,required:!!e.querySelector("required"),type:fy(e),value:null===(c=e.querySelector("value"))||void 0===c?void 0:c.textContent})}},Object.assign(nl,{getOOBURLMarkup:_y,ancestor:yy});const Sy=nl;var xy=n(4903),Ey={};Ey.styleTagTransform=Av(),Ey.setAttributes=wv(),Ey.insert=yv().bind(null,"head"),Ey.domAPI=vv(),Ey.insertStyleElement=xv();fv()(xy.Z,Ey);xy.Z&&xy.Z.locals&&xy.Z.locals;bu.elements.define("converse-gif",class extends hv{static get properties(){return{autoplay:{type:Boolean},noloop:{type:Boolean},progress_color:{type:String},fallback:{type:String},src:{type:String}}}constructor(){super(),this.autoplay=!1,this.noloop=!1,this.fallback="url"}initGIF(){const e={autoplay:this.autoplay,loop:!this.noloop};this.progress_color&&(e.progress_color=this.progress_color),this.supergif=new ty(this,e)}updated(e){this.supergif&&!e.has("src")?(e.has("autoplay")&&(this.supergif.options.autoplay=this.autoplay),e.has("noloop")&&(this.supergif.options.loop=!this.noloop),e.has("progress_color")&&(this.supergif.options.progress_color=this.progress_color)):this.initGIF()}render(){var e;return null!==(e=this.supergif)&&void 0!==e&&e.load_error&&["url","empty"].includes(this.fallback)?this.renderErrorFallback():Kd`this.setHover()} @mouseleave=${()=>this.unsetHover()} @click=${e=>this.onControlsClicked(e)}>`}renderErrorFallback(){return"url"===this.fallback?by(this.src):"empty"===this.fallback?"":void 0}setHover(){this.supergif&&(this.supergif.hovering=!0,this.hover_timeout&&clearTimeout(this.hover_timeout),this.hover_timeout=setTimeout((()=>this.unsetHover()),2e3))}unsetHover(){this.supergif&&(this.supergif.hovering=!1)}onControlsClicked(e){e.preventDefault(),this.supergif.playing?this.supergif.pause():(this.supergif.options.loop=!0,this.supergif.play())}});const Ay=(e,t)=>Kd`${t?"":Kd`${e}`}`,{URI:Cy}=Su.env;const ky=e_(class extends g_{render(e,t,n,s){return t?Kd`${this.renderImage(e,t,n,s)}`:this.renderImage(e,t,n,s)}renderImage(e,t,n,s){return Kd`this.onError(e,t,n,s)} @load=${n}/>`}onError(e,t,n,s){if(Ru(e))t&&this.setValue(by(t));else{const i=new Cy(e),o=i.filename();i.filename(`${o}.png`),this.setValue(ky(i.toString(),t,n,s))}}}),jy=e=>Kd`${ky(e.src||e.url,e.href,e.onLoad,e.onClick)}`;const Ty=e_(class extends t_{render(e,t,n){const s=new cb(e,t,Object.assign(n,{show_images:!1,embed_videos:!1,embed_audio:!1}));return Kd`${__(async function(e){try{await e.addTemplates()}catch(e){z.error(e)}return e.payload}(s),Kd`${s}`)}`}}),$y=["*","_","~","`"],Ny=[...$y,"```",">"],Oy={"*":{name:"strong",type:"span"},_:{name:"emphasis",type:"span"},"~":{name:"strike",type:"span"},"`":{name:"preformatted",type:"span"},"```":{name:"preformatted_block",type:"block"},">":{name:"quote",type:"block"}},Iy=["_",">","`","~"],My={emphasis:(e,t,n)=>Kd`_${Ty(e,t,n)}_`,preformatted:e=>Kd`\`${e}\``,preformatted_block:e=>Kd`
\`\`\`
${e}
\`\`\`
`,quote:(e,t,n)=>Kd`
${Ty(e,t,n)}
`,strike:(e,t,n)=>Kd`~${Ty(e,t,n)}~`,strong:(e,t,n)=>Kd`*${Ty(e,t,n)}*`};function Ry(e,t,n,s){if(s){const s=RegExp(Iy.includes(e)?`^(\\p{L}|\\p{N})${e}`:`^(\\p{L}|\\p{N})\\${e}`,"u");if(n>1&&s.test(t.slice(n-1)))return!1;if(Ly(e)&&n>0&&"\n"!==t[n-1])return!1;if($y.includes(e)&&t[n+1]===e)return!1}else{const s=RegExp(Iy.includes(e)?`^${e}(\\p{L}|\\p{N})`:`^\\${e}(\\p{L}|\\p{N})`,"u");if(n2&&void 0!==arguments[2])||arguments[2];if(!/(^```\s*\n|^```\s*$)/.test(e.slice(t))||0!==t&&"\n"!==e[t-1]&&">"!==e[t-1]){if(!Ny.includes(e.slice(t,t+1)))return null;if(n=e.slice(t,t+1),!Ry(n,e,t,s))return null}else n=e.slice(t,t+3);return n}function zy(e,t){const n=Dy(e,t),s=n?function(e,t,n){if(!e)return 0;const s=n;if(n+=e.length,Ly(e))return(n+=t.slice(n).split(/\n[^>]/).shift().length)-s;if("span"===Oy[e].type){const s=t.slice(n).split("\n").shift();let i=0,o=s.indexOf(e);for(;-1!==o;){if(Dy(t,n+o,!1)===e)return o+2*e.length;o=s.indexOf(e,i++)}return 0}{const s=t.slice(n+1);let i=0,o=s.indexOf(e);for(;-1!==o;){if(Dy(t,n+1+o,!1)===e)return o+1+2*e.length;o=s.indexOf(e,i++)}return 0}}(n,e,t):0;return s>0?{d:n,length:s}:{}}const Ly=e=>[">",">"].includes(e);function Py(e,t,n,s){const i=My[Oy[e].name];if(Ly(e)){return i(t.replace(/\n>/g,"\n").replace(/\n$/,""),n,s)}return i(t,n,s)}var Fy=n(3279),Uy=n.n(Fy);const By=new RegExp("]*>.*?|]*>.*?|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|((\\s|^)(\\*\\\\0\\/\\*|\\*\\\\O\\/\\*|\\-___\\-|\\:'\\-\\)|'\\:\\-\\)|'\\:\\-D|\\>\\:\\-\\)|>\\:\\-\\)|'\\:\\-\\(|\\>\\:\\-\\(|>\\:\\-\\(|\\:'\\-\\(|O\\:\\-\\)|0\\:\\-3|0\\:\\-\\)|0;\\^\\)|O;\\-\\)|0;\\-\\)|O\\:\\-3|\\-__\\-|\\:\\-Þ|\\:\\-Þ|\\<\\/3|<\\/3|\\:'\\)|\\:\\-D|'\\:\\)|'\\=\\)|'\\:D|'\\=D|\\>\\:\\)|>\\:\\)|\\>;\\)|>;\\)|\\>\\=\\)|>\\=\\)|;\\-\\)|\\*\\-\\)|;\\-\\]|;\\^\\)|'\\:\\(|'\\=\\(|\\:\\-\\*|\\:\\^\\*|\\>\\:P|>\\:P|X\\-P|\\>\\:\\[|>\\:\\[|\\:\\-\\(|\\:\\-\\[|\\>\\:\\(|>\\:\\(|\\:'\\(|;\\-\\(|\\>\\.\\<|>\\.<|#\\-\\)|%\\-\\)|X\\-\\)|\\\\0\\/|\\\\O\\/|0\\:3|0\\:\\)|O\\:\\)|O\\=\\)|O\\:3|B\\-\\)|8\\-\\)|B\\-D|8\\-D|\\-_\\-|\\>\\:\\\\|>\\:\\\\|\\>\\:\\/|>\\:\\/|\\:\\-\\/|\\:\\-\\.|\\:\\-P|\\:Þ|\\:Þ|\\:\\-b|\\:\\-O|O_O|\\>\\:O|>\\:O|\\:\\-X|\\:\\-#|\\:\\-\\)|\\(y\\)|\\<3|<3|\\:D|\\=D|;\\)|\\*\\)|;\\]|;D|\\:\\*|\\=\\*|\\:\\(|\\:\\[|\\=\\(|\\:@|;\\(|D\\:|\\:\\$|\\=\\$|#\\)|%\\)|X\\)|B\\)|8\\)|\\:\\/|\\:\\\\|\\=\\/|\\=\\\\|\\:L|\\=L|\\:P|\\=P|\\:b|\\:O|\\:X|\\:#|\\=X|\\=#|\\:\\)|\\=\\]|\\=\\)|\\:\\])(?=\\s|$|[!,.?]))","gi"),qy=/(?:\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d])|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5\udeeb\udeec\udef4-\udefa\udfe0-\udfeb]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd71\udd73-\udd76\udd7a-\udda2\udda5-\uddaa\uddae-\uddb4\uddb7\uddba\uddbc-\uddca\uddd0\uddde-\uddff\ude70-\ude73\ude78-\ude7a\ude80-\ude82\ude90-\ude95]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g,{u:Hy}=Su.env,Gy={},Wy={"*\\0/*":"1f646","*\\O/*":"1f646","-___-":"1f611",":'-)":"1f602","':-)":"1f605","':-D":"1f605",">:-)":"1f606","':-(":"1f613",">:-(":"1f620",":'-(":"1f622","O:-)":"1f607","0:-3":"1f607","0:-)":"1f607","0;^)":"1f607","O;-)":"1f607","0;-)":"1f607","O:-3":"1f607","-__-":"1f611",":-Þ":"1f61b",":)":"1f606",">;)":"1f606",">=)":"1f606",";-)":"1f609","*-)":"1f609",";-]":"1f609",";^)":"1f609","':(":"1f613","'=(":"1f613",":-*":"1f618",":^*":"1f618",">:P":"1f61c","X-P":"1f61c",">:[":"1f61e",":-(":"1f61e",":-[":"1f61e",">:(":"1f620",":'(":"1f622",";-(":"1f622",">.<":"1f623","#-)":"1f635","%-)":"1f635","X-)":"1f635","\\0/":"1f646","\\O/":"1f646","0:3":"1f607","0:)":"1f607","O:)":"1f607","O=)":"1f607","O:3":"1f607","B-)":"1f60e","8-)":"1f60e","B-D":"1f60e","8-D":"1f60e","-_-":"1f611",">:\\":"1f615",">:/":"1f615",":-/":"1f615",":-.":"1f615",":-P":"1f61b",":Þ":"1f61b",":-b":"1f61b",":-O":"1f62e",O_O:"1f62e",">:O":"1f62e",":-X":"1f636",":-#":"1f636",":-)":"1f642","(y)":"1f44d","<3":"2764",":D":"1f603","=D":"1f603",";)":"1f609","*)":"1f609",";]":"1f609",";D":"1f609",":*":"1f618","=*":"1f618",":(":"1f61e",":[":"1f61e","=(":"1f61e",":@":"1f620",";(":"1f622","D:":"1f628",":$":"1f633","=$":"1f633","#)":"1f635","%)":"1f635","X)":"1f635","B)":"1f60e","8)":"1f60e",":/":"1f615",":\\":"1f615","=/":"1f615","=\\":"1f615",":L":"1f615","=L":"1f615",":P":"1f61b","=P":"1f61b",":b":"1f61b",":O":"1f62e",":X":"1f636",":#":"1f636","=X":"1f636","=#":"1f636",":)":"1f642","=]":"1f642","=)":"1f642",":]":"1f642"};function Vy(e){if(e.indexOf("-")>-1){const t=[],n=e.split("-");for(let e=0;e=65536&&s<=1114111){const e=Math.floor((s-65536)/1024)+55296,t=(s-65536)%1024+56320;s=String.fromCharCode(e)+String.fromCharCode(t)}else s=String.fromCharCode(s);t.push(s)}return t.join("")}return function(e){let t="string"==typeof e?parseInt(e,16):e;return t<65536?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}(e)}function Jy(e){return e.replace(By,((e,t,n,s)=>{if(void 0===s||""===s||!(Hy.unescapeHTML(s)in Wy))return e;s=Hy.unescapeHTML(s);return n+Vy(Wy[s].toUpperCase())}))}function Qy(e){if(!Su.emojis.initialized)throw new Error("getShortnameReferences called before emojis are initialized. To avoid this problem, first await the converse.emojis.initilaized_promise.");return[...e.matchAll(Su.emojis.shortnames_regex)].filter((e=>e[0].length>0)).map((e=>{const t=Su.emojis.by_sn[e[0]].cp;return{cp:t,begin:e.index,end:e.index+e[0].length,shortname:e[0],emoji:t?Vy(t):null}}))}function Zy(e){const t=[];return function(e,t){const n=/\uFE0F/g,s=String.fromCharCode(8205);String(e).replace(qy,((e,i,o)=>{const r=function(e){const t=[];let n=0,s=0;for(;s{var i;t.push({begin:s,cp:e,emoji:n,end:s+n.length,shortname:(null===(i=Ky("cp")[e])||void 0===i?void 0:i.sn)||""})})),t}function Ky(e){if(Gy[e])return Gy[e];if("category"===e)return Su.emojis.json;const t=Su.emojis.list.map((t=>t[e])).filter(((e,t,n)=>n.indexOf(e)==t));return Gy[e]={},t.forEach((t=>Gy[e][t]=Su.emojis.list.find((n=>n[e]===t)))),Gy[e]}Object.assign(Hy,{getEmojisByAtrribute:Ky,isOnlyEmojis:function(e){const t=e.trim().split(/\s+/);if(0===t.length||t.length>3)return!1;const n=t.filter((e=>{const t=Zy(Hy.shortnamesToUnicode(e));return 1===t.length&&(e===t[0].shortname||e===t[0].emoji)}));return n.length===t.length},shortnamesToUnicode:function(e){return function(e){let t=[e];return[...Qy(e),...Zy(e)].sort(((e,t)=>t.begin-e.begin)).forEach((e=>{const n=t.shift(),s=e.emoji||e.shortname;t=[n.slice(0,e.begin)+s+n.slice(e.end),...t]})),t}(Jy(e)).pop()}});const{dayjs:Yy,u:Xy}=Su.env;function eb(e){if(!e.isHidden()&&bu.settings.get("allow_url_history_change")){const t=window.location.hash;t&&e.messages.get(t.slice(1))&&ul.router.history.navigate()}}const tb=Uy()((e=>function(e){const t=e.target;if("converse-chat-content"!==t.nodeName.toLowerCase())return;let n=!0;const s=0===Math.floor(t.scrollTop),i=Math.ceil(t.clientHeight-t.scrollTop)>=t.scrollHeight-Math.ceil(t.scrollHeight/20);s?(n=!1,eb(t.model)):i&&bu.trigger("chatBoxScrolledUp",t),t.model.get("scolled")!==n&&t.model.ui.set({scrolled:n})}(e)),50);function nb(e){var t;const n=null===(t=e.collection)||void 0===t?void 0:t.models;if(!n)return;const s=n.indexOf(e),i=n[s-1];if(!i||Yy(e.get("time")).isAfter(Yy(i.get("time")),"day")){const t=Yy(e.get("time")).startOf("day");return(e=>Kd`

`)({type:"date",time:t.toISOString(),datestring:t.format("dddd MMM Do YYYY")})}}function sb(e){if("groupchat"===e.get("type")){var t;const n=bu.settings.get("muc_hats").filter((e=>e)).map((e=>e.toLowerCase()));let s=[];n.includes("vcard_roles")&&(s=e.vcard?e.vcard.get("role"):null,s=s?s.split(",").filter((e=>e)).map((e=>({title:e}))):[]);const i=[...e.occupant?[e.occupant.get("role")]:[],...e.occupant?[e.occupant.get("affiliation")]:[]].filter((e=>e)).filter((e=>n.includes(e.toLowerCase()))).map((e=>({title:e})));return[...n.includes("xep317")&&(null===(t=e.occupant)||void 0===t?void 0:t.get("hats"))||[],...s,...i]}return[]}function ib(){var e;return Su.emojis.toned||(Su.emojis.toned=(e=Object.values(Su.emojis.json.people).filter((e=>e.sn.includes("_tone"))).map((e=>e.sn.replace(/_tone[1-5]/,""))),[...new Set(e)])),Su.emojis.toned}function ob(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{unicode_only:!1,add_title_wrapper:!1};const n=e.emoji,s=e.shortname;if(n){if(t.unicode_only)return n;if(bu.settings.get("use_system_emojis"))return t.add_title_wrapper&&s?Kd`${n}`:n;{const t=bu.settings.get("emoji_image_path");return Kd`${n}`}}return t.unicode_only?s:Kd`${s}`}function rb(e,t){let n=[e];return[...Qy(e),...Zy(e)].sort(((e,t)=>t.begin-e.begin)).forEach((e=>{const s=n.shift(),i=ob(e,t);n="string"==typeof i?[s.slice(0,e.begin)+i+s.slice(e.end),...n]:[s.slice(0,e.begin),i,s.slice(e.end),...n]})),n}Object.assign(Xy,{shortnamesToEmojis:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{unicode_only:!1,add_title_wrapper:!1};return rb(e=Jy(e),t)}});const ab=e=>"string"==typeof e;class cb extends String{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(e),this.embed_audio=null==n?void 0:n.embed_audio,this.embed_videos=null==n?void 0:n.embed_videos,this.mentions=(null==n?void 0:n.mentions)||[],this.media_urls=null==n?void 0:n.media_urls,this.nick=null==n?void 0:n.nick,this.offset=t,this.onImgClick=null==n?void 0:n.onImgClick,this.onImgLoad=null==n?void 0:n.onImgLoad,this.options=n,this.payload=[],this.references=[],this.render_styling=null==n?void 0:n.render_styling,this.show_images=null==n?void 0:n.show_images,this.hide_media_urls=null==n?void 0:n.hide_media_urls}shouldRenderMedia(e,t){let n;return"image"===t?n=this.show_images:"audio"===t?n=this.embed_audio:"video"===t&&(n=this.embed_videos),"boolean"==typeof n?n:Nu(e,t)}addHyperlinks(e,t){const n=t+this.offset;_h(this.media_urls||Vu(e,t).media_urls||[],e,n).filter((e=>!e.is_encrypted)).forEach((e=>{const n=e.url,s=Ou(n);let i;i=Du(n)&&this.shouldRenderMedia(n,"image")?Ay(s,this.hide_media_urls):Pu(n)&&this.shouldRenderMedia(n,"image")?jy({src:s,href:this.hide_media_urls?null:s,onClick:this.onImgClick,onLoad:this.onImgLoad}):Lu(n)&&this.shouldRenderMedia(n,"video")?ly(s,this.hide_media_urls):zu(n)&&this.shouldRenderMedia(n,"audio")?W_(s,this.hide_media_urls):by(s),this.addTemplateResult(e.start+t,e.end+t,i)}))}addMapURLs(e,t){const n=/geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g,s=e.matchAll(n);for(const e of s)this.addTemplateResult(e.index+t,e.index+e[0].length+t,by(e[0].replace(n,bu.settings.get("geouri_replacement"))))}addEmojis(e,t){[...Qy(e.toString()),...Zy(e.toString())].forEach((e=>{this.addTemplateResult(e.begin+t,e.end+t,ob(e,{add_title_wrapper:!0}))}))}addMentions(e,t){var n;const s=t+this.offset;null===(n=this.mentions)||void 0===n||n.forEach((n=>{const i=Number(n.begin)-s;if(i<0||i>=s+e.length)return;const o=Number(n.end)-s,r=e.slice(i,o);r===this.nick?this.addTemplateResult(i+t,o+t,(e=>Kd`${e.mention}`)({mention:r})):this.addTemplateResult(i+t,o+t,(e=>Kd`${e.mention}`)({mention:r}))}))}addStyling(){const e=[];if(function(e){for(let t=0;tArray.from({length:Number(e.end)},((t,n)=>Number(e.begin)+n))));let n=0;for(;ne.includes(n))).length){n++;continue}const{d:s,length:i}=zy(this,n);if(s&&i){const t=Ly(s),o=n+i,r=t?o:o-s.length;let a="```"===s?n+s.length+1:n+s.length;t&&" "===this[a]&&(a+=1);const c=a,l=this.slice(a,r);e.push({begin:n,template:Py(s,l,c,this.options),end:o}),n=o}n++}}e.forEach((e=>this.addTemplateResult(e.begin,e.end,e.template)))}trimMeMessage(){0===this.offset&&this.isMeCommand()&&(this.payload[0]=this.payload[0].substring(4))}addAnnotations(e){const t=this.marshall();let n=0;for(const s of t)s&&(ab(s)?(e.call(this,s,n),n+=s.length):n=s.end)}async addTemplates(){await bu.trigger("beforeMessageBodyTransformed",this,{Synchronous:!0}),this.render_styling&&this.addStyling(),this.addAnnotations(this.addMentions),this.addAnnotations(this.addHyperlinks),this.addAnnotations(this.addMapURLs),await bu.emojis.initialize(),this.addAnnotations(this.addEmojis),await bu.trigger("afterMessageBodyTransformed",this,{Synchronous:!0}),this.payload=this.marshall(),this.options.show_me_message&&this.trimMeMessage(),this.payload=this.payload.map((e=>ab(e)?e:e.template))}addTemplateResult(e,t,n){this.references.push({begin:e,end:t,template:n})}isMeCommand(){const e=this.toString();return!!e&&e.startsWith("/me ")}marshall(){let e=[this.toString()];return this.references.sort(((e,t)=>t.begin-e.begin)).forEach((t=>{const n=e.shift();e=[n.slice(0,t.begin),t,n.slice(t.end),...e]})),e.reduce(((e,t)=>{return ab(t)?[...e,Jy((n=t,n.replace(/\n\n+/g,(e=>`\n${"​".repeat(e.length-2)}\n`))))]:[...e,t];var n}),[])}}class lb{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.offset=t,this.options=n,this.text=e}async transform(){const e=new cb(this.text,this.offset,this.options);try{await e.addTemplates()}catch(e){z.error(e)}return e.payload}render(){return Kd`${__(this.transform(),Kd`${this.text}`)}`}}const db=e_(class extends t_{render(e,t,n,s){const i=new lb(e,t,n).render();return null==s||s(),i}}),ub=db;var hb=n(6278),mb={};mb.styleTagTransform=Av(),mb.setAttributes=wv(),mb.insert=yv().bind(null,"head"),mb.domAPI=vv(),mb.insertStyleElement=xv();fv()(hb.Z,mb);hb.Z&&hb.Z.locals&&hb.Z.locals;bu.elements.define("converse-chat-message-body",class extends hv{static get properties(){return{hide_url_previews:{type:String},is_me_message:{type:Boolean},model:{type:Object},text:{type:String}}}initialize(){const e=al();this.listenTo(e,"change:allowed_audio_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:allowed_image_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:allowed_video_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:render_media",(()=>this.requestUpdate()))}onImgClick(e){e.preventDefault(),bu.modal.create(G_,{src:e.target.src},e).show(e)}onImgLoad(){this.dispatchEvent(new CustomEvent("imageLoaded",{detail:this,bubbles:!0}))}render(){const e={media_urls:this.model.get("media_urls"),mentions:this.model.get("references"),nick:this.model.collection.chatbox.get("nick"),onImgClick:e=>this.onImgClick(e),onImgLoad:()=>this.onImgLoad(),render_styling:!this.model.get("is_unstyled")&&bu.settings.get("allow_message_styling"),show_me_message:!0};return"false"===this.hide_url_previews?(e.embed_audio=!0,e.embed_videos=!0,e.show_images=!0):"true"===this.hide_url_previews&&(e.embed_audio=!1,e.embed_videos=!1,e.show_images=!1),ub(this.text,0,e,(()=>{var e;return null===(e=this.model.collection)||void 0===e?void 0:e.trigger("rendered",this.model)}))}});var gb=n(6450),fb={};fb.styleTagTransform=Av(),fb.setAttributes=wv(),fb.insert=yv().bind(null,"head"),fb.domAPI=vv(),fb.insertStyleElement=xv();fv()(gb.Z,fb);gb.Z&&gb.Z.locals&&gb.Z.locals;customElements.define("converse-icon",class extends hv{static get properties(){return{color:String,class_name:{attribute:"class"},style:String,size:String}}constructor(){super(),this.class_name="",this.style="",this.size="",this.color=""}getSource(){return`#icon-${this.class_name.trim().split(" ")[1].replace("fa-","")}`}getStyles(){var e;const t=null===(e=this.color.match(/var\((--.*)\)/))||void 0===e?void 0:e[1],n=t?getComputedStyle(this).getPropertyValue(t):this.color;return`\n ${this.size?`width: ${this.size};`:""}\n ${this.size?`height: ${this.size};`:""}\n ${n?`fill: ${n};`:""}\n ${this.style}\n `}render(){return Kd` `}});const{keycodes:pb}=Su;function vb(e){let t=0;do{isNaN(e.offsetTop)||(t+=e.offsetTop)}while(e=e.offsetParent);return t}function _b(e){let t=0;do{isNaN(e.offsetLeft)||(t+=e.offsetLeft)}while(e=e.offsetParent);return t}class yb{static get DIRECTION(){return{down:"down",end:"end",home:"home",left:"left",right:"right",up:"up"}}static get DEFAULTS(){return{home:[`${pb.SHIFT}+${pb.UP_ARROW}`],end:[`${pb.SHIFT}+${pb.DOWN_ARROW}`],up:[pb.UP_ARROW],down:[pb.DOWN_ARROW],left:[pb.LEFT_ARROW,`${pb.SHIFT}+${pb.TAB}`],right:[pb.RIGHT_ARROW,pb.TAB],getSelector:null,jump_to_picked:null,jump_to_picked_direction:null,jump_to_picked_selector:"picked",onSelected:null,selected:"selected",selector:"li"}}static getClosestElement(e,t){return e.reduce(((e,n)=>{const s=t(n);return sthis.keys[e]=yb.DIRECTION.down)),this.options.end.forEach((e=>this.keys[e]=yb.DIRECTION.end)),this.options.home.forEach((e=>this.keys[e]=yb.DIRECTION.home)),this.options.left.forEach((e=>this.keys[e]=yb.DIRECTION.left)),this.options.right.forEach((e=>this.keys[e]=yb.DIRECTION.right)),this.options.up.forEach((e=>this.keys[e]=yb.DIRECTION.up))}enable(){this.getElements(),this.keydownHandler=e=>this.handleKeydown(e),this.doc.addEventListener("keydown",this.keydownHandler),this.enabled=!0}disable(){this.keydownHandler&&this.doc.removeEventListener("keydown",this.keydownHandler),this.unselect(),this.elements={},this.enabled=!1}destroy(){this.disable(),this.container.domNavigator&&delete this.container.domNavigator}getNextElement(e){let t;if(e===yb.DIRECTION.home)t=this.getElements(e)[0];else if(e===yb.DIRECTION.end)t=Array.from(this.getElements(e)).pop();else if(this.selected)if(e===yb.DIRECTION.right){const n=this.getElements(e);t=n.slice(n.indexOf(this.selected))[1]}else if(e==yb.DIRECTION.left){const n=this.getElements(e);t=n.slice(0,n.indexOf(this.selected)).pop()||this.selected}else if(e==yb.DIRECTION.down){const e=this.selected.offsetLeft,n=this.selected.offsetTop+this.selected.offsetHeight,s=this.elementsAfter(0,n),i=t=>Math.abs(t.offsetLeft-e)+Math.abs(t.offsetTop-n);t=yb.getClosestElement(s,i)}else{if(e!=yb.DIRECTION.up)throw new Error("getNextElement: invalid direction value");{const e=this.selected.offsetLeft,n=this.selected.offsetTop-1,s=this.elementsBefore(1/0,n),i=t=>Math.abs(e-t.offsetLeft)+Math.abs(n-t.offsetTop);t=yb.getClosestElement(s,i)}}else t=e===yb.DIRECTION.right||e===yb.DIRECTION.down?this.getElements(e)[1]:this.getElements(e)[0];return this.options.jump_to_picked&&t&&t.matches(this.options.jump_to_picked)&&e===this.options.jump_to_picked_direction&&(t=this.container.querySelector(this.options.jump_to_picked_selector)||t),t}select(e,t){e&&e!==this.selected&&(this.unselect(),t&&this.scrollTo(e,t),e.matches("input")?e.focus():Sy.addClass(this.options.selected,e),this.selected=e,this.options.onSelected&&this.options.onSelected(e))}unselect(){this.selected&&(Sy.removeClass(this.options.selected,this.selected),delete this.selected)}scrollTo(e,t){if(this.inScrollContainerViewport(e)){if(!function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}(e))switch(t){case yb.DIRECTION.left:document.body.scrollLeft=_b(e)-document.body.offsetLeft;break;case yb.DIRECTION.up:document.body.scrollTop=vb(e)-document.body.offsetTop;break;case yb.DIRECTION.right:document.body.scrollLeft=_b(e)-document.body.offsetLeft-(document.documentElement.clientWidth-e.offsetWidth);break;case yb.DIRECTION.down:document.body.scrollTop=vb(e)-document.body.offsetTop-(document.documentElement.clientHeight-e.offsetHeight)}}else{const n=this.scroll_container;if(!n.contains(e))return;switch(t){case yb.DIRECTION.left:n.scrollLeft=e.offsetLeft-n.offsetLeft,n.scrollTop=e.offsetTop-n.offsetTop;break;case yb.DIRECTION.up:n.scrollTop=e.offsetTop-n.offsetTop;break;case yb.DIRECTION.right:n.scrollLeft=e.offsetLeft-n.offsetLeft-(n.offsetWidth-e.offsetWidth),n.scrollTop=e.offsetTop-n.offsetTop-(n.offsetHeight-e.offsetHeight);break;case yb.DIRECTION.down:n.scrollTop=e.offsetTop-n.offsetTop-(n.offsetHeight-e.offsetHeight)}}}inScrollContainerViewport(e){const t=this.scroll_container;return!(e.offsetLeft-t.scrollLeftt.offsetLeft+t.offsetWidth)&&!(e.offsetTop+e.offsetHeight-t.scrollTop>t.offsetTop+t.offsetHeight)))}getElements(e){const t=this.options.getSelector?this.options.getSelector(e):this.options.selector;return this.elements[t]||(this.elements[t]=Array.from(this.container.querySelectorAll(t))),this.elements[t]}elementsAfter(e,t){return this.getElements(yb.DIRECTION.down).filter((n=>n.offsetLeft>=e&&n.offsetTop>=t))}elementsBefore(e,t){return this.getElements(yb.DIRECTION.up).filter((n=>n.offsetLeft<=e&&n.offsetTop<=t))}handleKeydown(e){const t=pb,n=e.shiftKey?this.keys[`${t.SHIFT}+${e.which}`]:this.keys[e.which];if(n){e.preventDefault(),e.stopPropagation();const t=this.getNextElement(n,e);this.select(t,n)}}}const bb=yb,wb=Su.env.utils;class Sb extends hv{connectedCallback(){super.connectedCallback(),this.registerEvents()}registerEvents(){this.clickOutside=e=>this._clickOutside(e),document.addEventListener("click",this.clickOutside)}firstUpdated(){super.firstUpdated(),this.menu=this.querySelector(".dropdown-menu"),this.button=this.querySelector("button"),this.addEventListener("click",(e=>this.toggleMenu(e))),this.addEventListener("keyup",(e=>this.handleKeyUp(e)))}_clickOutside(e){this.contains(e.composedPath()[0])||this.hideMenu(e)}hideMenu(){var e,t;wb.removeClass("show",this.menu),null===(e=this.button)||void 0===e||e.setAttribute("aria-expanded",!1),null===(t=this.button)||void 0===t||t.blur()}showMenu(){wb.addClass("show",this.menu),this.button.setAttribute("aria-expanded",!0)}toggleMenu(e){e.preventDefault(),wb.hasClass("show",this.menu)?this.hideMenu():this.showMenu()}handleKeyUp(e){e.keyCode===Su.keycodes.ESCAPE&&this.hideMenu()}disconnectedCallback(){document.removeEventListener("click",this.clickOutside),super.disconnectedCallback()}}var xb=n(7631),Eb={};Eb.styleTagTransform=Av(),Eb.setAttributes=wv(),Eb.insert=yv().bind(null,"head"),Eb.domAPI=vv(),Eb.insertStyleElement=xv();fv()(xb.Z,Eb);xb.Z&&xb.Z.locals&&xb.Z.locals;class Ab extends Sb{static get properties(){return{icon_classes:{type:String},color:{type:String},items:{type:Array}}}constructor(){super(),this.color="var(--text-color)",this.icon_classes="fa fa-bars"}render(){return Kd` `}firstUpdated(){super.firstUpdated(),this.initArrowNavigation()}connectedCallback(){super.connectedCallback(),this.hideOnEscape=e=>e.keyCode===be.ESCAPE&&this.hideMenu(),document.addEventListener("keydown",this.hideOnEscape)}disconnectedCallback(){document.removeEventListener("keydown",this.hideOnEscape),super.disconnectedCallback()}hideMenu(){var e;super.hideMenu(),null===(e=this.navigator)||void 0===e||e.disable()}initArrowNavigation(){if(!this.navigator){const e={selector:".dropdown-item",onSelected:e=>e.focus()};this.navigator=new bb(this.menu,e)}}enableArrowNavigation(e){e&&(e.preventDefault(),e.stopPropagation()),this.navigator.enable(),this.navigator.select(this.menu.firstElementChild)}handleKeyUp(e){super.handleKeyUp(e),e.keyCode!==be.DOWN_ARROW||this.navigator.enabled||this.enableArrowNavigation(e)}}bu.elements.define("converse-dropdown",Ab);const Cb=e=>{return e.image?Kd` `:"";var t,n};var kb=n(5222),jb={};jb.styleTagTransform=Av(),jb.setAttributes=wv(),jb.insert=yv().bind(null,"head"),jb.domAPI=vv(),jb.insertStyleElement=xv();fv()(kb.Z,jb);kb.Z&&kb.Z.locals&&kb.Z.locals;bu.elements.define("converse-avatar",class extends hv{static get properties(){return{data:{type:Object},width:{type:String},height:{type:String},nonce:{type:String}}}constructor(){super(),this.width=36,this.height=36}render(){var e,t;const n=(null===(e=this.data)||void 0===e?void 0:e.image_type)||ul.DEFAULT_IMAGE_TYPE;let s;if(null!==(t=this.data)&&void 0!==t&&t.data_uri){var i;s=null===(i=this.data)||void 0===i?void 0:i.data_uri}else{var o;s="data:"+n+";base64,"+((null===(o=this.data)||void 0===o?void 0:o.image)||ul.DEFAULT_IMAGE)}return Cb({classes:this.getAttribute("class"),height:this.height,width:this.width,image:s,image_type:n})}});const{dayjs:Tb}=Su.env;bu.elements.define("converse-message-versions",class extends hv{static get properties(){return{model:{type:Object}}}render(){const e=this.model.get("older_versions");return Kd`

Older versions

${Object.keys(e).map((t=>Kd`

: ${e[t]}

`))}

Current version

${this.model.getMessageText()}

`}});const $b=Uv.extend({id:"message-versions-modal",toHTML(){return(e=>Kd` `)(this.model)}}),Nb=Uv.extend({id:"muc-occupant",initialize(){Uv.prototype.initialize.apply(this,arguments),this.model&&this.listenTo(this.model,"change",this.render),bu.trigger("occupantModalInitialized",{model:this.model,message:this.message})},getVcard(){const e=this.model??this.message;if(e.vcard)return e.vcard;const t=(null==e?void 0:e.get("jid"))||(null==e?void 0:e.get("from"));return t?ul.vcards.get(t):null},toHTML(){var e,t,n,s;const i=this.model??this.message;return(e=>{var t,n;return Kd` `})({jid:null==i?void 0:i.get("jid"),vcard:this.getVcard(),display_name:null==i?void 0:i.getDisplayName(),nick:i.get("nick"),occupant_id:i.get("occupant_id"),role:null===(e=this.model)||void 0===e?void 0:e.get("role"),affiliation:null===(t=this.model)||void 0===t?void 0:t.get("affiliation"),hats:null!==(n=this.model)&&void 0!==n&&null!==(s=n.get("hats"))&&void 0!==s&&s.length?this.model.get("hats"):null})}});ul.OccupantModal=Nb;const Ob=Nb,Ib=e=>{const t=dv("XMPP Address"),n=dv("Email"),s=dv("Full Name"),i=dv("Nickname"),o=dv("The User's Profile Image"),r=dv("Refresh"),a=dv("Role"),c=dv("URL"),l={alt_text:o,extra_classes:"mb-3",height:"120",width:"120"};return Kd` `},Mb=Su.env.utils;const Rb=Uv.extend({id:"user-details-modal",persistent:!0,events:{"click button.refresh-contact":"refreshContact"},initialize(){Uv.prototype.initialize.apply(this,arguments),this.model.rosterContactAdded.then((()=>this.registerContactEventHandlers())),this.listenTo(this.model,"change",this.render),this.registerContactEventHandlers(),bu.trigger("userDetailsModalInitialized",this.model)},toHTML(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{};return Ib(Object.assign(this.model.toJSON(),n,{_converse:ul,allow_contact_removal:bu.settings.get("allow_contact_removal"),display_name:this.model.getDisplayName(),is_roster_contact:void 0!==this.model.contact,removeContact:e=>this.removeContact(e),view:this,utils:Mb}))},registerContactEventHandlers(){void 0!==this.model.contact&&(this.listenTo(this.model.contact,"change",this.render),this.listenTo(this.model.contact.vcard,"change",this.render),this.model.contact.on("destroy",(()=>{delete this.model.contact,this.render()})))},async refreshContact(e){e&&e.preventDefault&&e.preventDefault();const t=this.el.querySelector(".fa-refresh");Mb.addClass("fa-spin",t);try{await bu.vcard.update(this.model.contact.vcard,!0)}catch(e){z.fatal(e),this.alert(dv("Sorry, something went wrong while trying to refresh"),"danger")}Mb.removeClass("fa-spin",t)},removeContact(e){var t;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),!bu.settings.get("allow_contact_removal"))return;!0===confirm(dv("Are you sure you want to remove this contact?"))&&(setTimeout((()=>function(e){e.removeFromRoster((()=>e.destroy()),(t=>{t&&z.error(t),bu.alert("error",dv("Error"),[dv("Sorry, there was an error while trying to remove %1$s as a contact.",e.getDisplayName())])}))}(this.model.contact)),1),this.modal.hide())}});ul.UserDetailsModal=Rb;const Db=Rb,{dayjs:zb}=Su.env,{dayjs:Lb}=Su.env;function Pb(e){return!!ju(e).host()}bu.elements.define("converse-image",class extends hv{static get properties(){return{src:{type:String},onImgLoad:{type:Function},href:{type:String}}}render(){return Du(this.src)&&Nu(this.src,"image")?Ay(Ou(this.src),!0):jy({src:Ou(this.src),href:this.href,onClick:this.onImgClick,onLoad:this.onImgLoad})}});const Fb=(e,t)=>e.url&&Pb(e.url)&&!Du(e.image)?Kd`${t(e)}`:t(e),Ub=e=>Kd``,Bb=e=>{const t=(n=e.image)&&Iu(n,"allowed_image_domains")&&Pb(n);var n;const s=e.title||e.description||e.url;return t||s?Kd`
${t?Fb(e,Ub):""} ${s?Kd`
${e.title?Fb(e,(e=>Kd`
${e.title}
`)):""} ${e.description?Kd`

`:""} ${e.url?Kd`

${ju(e.url).domain()}

`:""}
`:""}
`:""};var qb=n(5046),Hb={};Hb.styleTagTransform=Av(),Hb.setAttributes=wv(),Hb.insert=yv().bind(null,"head"),Hb.domAPI=vv(),Hb.insertStyleElement=xv();fv()(qb.Z,Hb);qb.Z&&qb.Z.locals&&qb.Z.locals;bu.elements.define("converse-message-unfurl",class extends hv{static get properties(){return{description:{type:String},image:{type:String},jid:{type:String},title:{type:String},url:{type:String}}}initialize(){const e=al();this.listenTo(e,"change:allowed_image_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:render_media",(()=>this.requestUpdate()))}render(){return Bb(Object.assign({onload:()=>this.onImageLoad()},{description:this.description||"",image:this.image||"",title:this.title||"",url:this.url||""}))}onImageLoad(){this.dispatchEvent(new CustomEvent("imageLoaded",{detail:this,bubbles:!0}))}});const Gb=e=>{const t=dv("Show more"),n="groupchat"===e.model.get("type"),s=dv("Show less"),i=Kd`
${e.model.get("spoiler_hint")} ${e.model.get("is_spoiler_visible")?s:t}
`,o=e.model.get("is_spoiler")?"spoiler "+(e.model.get("is_spoiler_visible")?"":"hidden"):"",r=e.model.getMessageText(),a=e.model.get("oob_url")&&r!==e.model.get("oob_url");return Kd` ${e.model.get("is_spoiler")?i:""} ${e.model.get("subject")?Kd`
${e.model.get("subject")}
`:""} ${!e.model.get("received")||e.model.isMeCommand()||n?"":Kd``} ${e.model.get("edited")?(e=>{const t=dv("This message has been edited");return Kd``})(e):""} ${a?Kd`
${_y(e.model.get("oob_url"))}
`:""}
${e.model.get("error_text")||e.model.get("error")}
`};var Wb=n(9523),Vb={};Vb.styleTagTransform=Av(),Vb.setAttributes=wv(),Vb.insert=yv().bind(null,"head"),Vb.domAPI=vv(),Vb.insertStyleElement=xv();fv()(Wb.Z,Vb);Wb.Z&&Wb.Z.locals&&Wb.Z.locals;const Jb=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return null!==(e=t.classes)&&void 0!==e&&e.includes("hor_centered")?Kd`
`:Kd``},{Strophe:Qb,dayjs:Zb}=Su.env;bu.elements.define("converse-chat-message",class extends hv{static get properties(){return{jid:{type:String},mid:{type:String}}}async initialize(){if(await this.setModels(),!this.model)return void z.error("Could not find module for converse-chat-message");const e=al();this.listenTo(e,"change:render_media",(()=>{this.model.save("hide_url_previews",void 0),this.requestUpdate()})),this.listenTo(this.chatbox,"change:first_unread_id",(()=>this.requestUpdate())),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.model.vcard&&this.listenTo(this.model.vcard,"change",(()=>this.requestUpdate())),"groupchat"===this.model.get("type")&&(this.model.occupant?this.listenTo(this.model.occupant,"change",(()=>this.requestUpdate())):this.listenTo(this.model,"occupantAdded",(()=>{this.requestUpdate(),this.listenTo(this.model.occupant,"change",(()=>this.requestUpdate()))})))}async setModels(){this.chatbox=await bu.chatboxes.get(this.jid),await this.chatbox.initialized,await this.chatbox.messages.fetched,this.model=this.chatbox.messages.get(this.mid),this.model&&this.requestUpdate()}render(){return this.model?this.show_spinner?Jb():this.model.get("file")&&this.model.get("upload")!==ul.SUCCESS?this.renderFileProgress():["mep"].includes(this.model.get("type"))?this.renderMEPMessage():["error","info"].includes(this.model.get("type"))?this.renderInfoMessage():this.renderChatMessage():""}getProps(){return Object.assign(this.model.toJSON(),this.getDerivedMessageProps())}renderRetraction(){return(e=>{const t=e.isRetracted()?e.getRetractionText():null;return Kd`
${t}
${e.model.get("moderation_reason")?Kd`${e.model.get("moderation_reason")}`:""}`})(this)}renderMessageText(){return Gb(this)}renderMEPMessage(){return(e=>{const t=Lb(e.model.get("time")).toISOString();return Kd`
${e.isRetracted()?e.renderRetraction():Kd` ${e.model.get("reason")?Kd``:""} `}
`})(this)}renderInfoMessage(){return(e=>{const t=zb(e.model.get("time")).toISOString(),n=dv("Retry");return Kd`
${e.model.get("reason")?Kd`${e.model.get("reason")}`:""} ${e.model.get("error_text")?Kd`${e.model.get("error_text")}`:""} ${e.model.get("retry_event_id")?Kd`${n}`:""}
`})(this)}renderFileProgress(){return this.model.file?(e=>{var t,n;const s=dv("Uploading file:"),i=e.model.file.name,o=fh()(e.model.file.size);return Kd`
${e.shouldShowAvatar()?Kd` `:""}
${s} ${i}, ${o}
`})(this):""}renderChatMessage(){return((e,t)=>{var n,s,i;const o=dv("New messages"),r=e.model.isFollowup();return Kd` ${t.is_first_unread?Kd`

${o}
`:""}
${t.should_show_avatar&&!r?Kd` `:""}
${t.is_me_message||r?"":Kd` ${t.username} ${t.hats.map((e=>Kd`${e.title}`))} ${t.is_encrypted?Kd``:""} `}
${t.is_me_message?Kd`   ${t.is_me_message?"**":""}${t.username} `:""} ${t.is_retracted?e.renderRetraction():e.renderMessageText()}
${null===(i=e.model.get("ogp_metadata"))||void 0===i?void 0:i.map((t=>{var n;return!0===e.model.get("hide_url_previews")?"":Nu(t["og:image"],"image")?Kd``:""}))}
`})(this,this.getProps())}shouldShowAvatar(){return bu.settings.get("show_message_avatar")&&!this.model.isMeCommand()&&["chat","groupchat"].includes(this.model.get("type"))}onUnfurlAnimationEnd(){"fade-out"===this.model.get("url_preview_transition")&&this.model.save({hide_url_previews:!0,url_preview_transition:"fade-in"})}async onRetryClicked(){this.show_spinner=!0,this.requestUpdate(),await bu.trigger(this.model.get("retry_event_id"),{synchronous:!0}),this.model.destroy(),this.parentElement.removeChild(this)}isRetracted(){return this.model.get("retracted")||"retracted"===this.model.get("moderated")}hasMentions(){return"groupchat"===this.model.get("type")&&"them"===this.model.get("sender")&&this.chatbox.isUserMentioned(this.model)}getOccupantAffiliation(){var e;return null===(e=this.model.occupant)||void 0===e?void 0:e.get("affiliation")}getOccupantRole(){var e;return null===(e=this.model.occupant)||void 0===e?void 0:e.get("role")}getExtraMessageClasses(){const e=[this.model.isFollowup()?"chat-msg--followup":null,this.model.get("is_delayed")?"delayed":null,this.model.isMeCommand()?"chat-msg--action":null,this.isRetracted()?"chat-msg--retracted":null,this.model.get("type"),this.shouldShowAvatar()?"chat-msg--with-avatar":null].map((e=>e));return"groupchat"===this.model.get("type")&&(e.push(this.getOccupantRole()??""),e.push(this.getOccupantAffiliation()??""),"them"===this.model.get("sender")&&this.hasMentions()&&e.push("mentioned")),this.model.get("correcting")&&e.push("correcting"),e.filter((e=>e)).join(" ")}getDerivedMessageProps(){const e=bu.settings.get("time_format");return{pretty_time:Zb(this.model.get("edited")||this.model.get("time")).format(e),has_mentions:this.hasMentions(),hats:sb(this.model),is_first_unread:this.chatbox.get("first_unread_id")===this.model.get("id"),is_me_message:this.model.isMeCommand(),is_retracted:this.isRetracted(),username:this.model.getDisplayName(),should_show_avatar:this.shouldShowAvatar()}}getRetractionText(){if(["groupchat","mep"].includes(this.model.get("type"))&&this.model.get("moderated_by")){const e=this.model.get("moderated_by"),t=this.model.collection.chatbox;this.model.mod||(this.model.mod=t.occupants.findOccupant({jid:e})||t.occupants.findOccupant({nick:Qb.getResourceFromJid(e)}));const n=this.model.mod?this.model.mod.getDisplayName():"A moderator";return dv("%1$s has removed this message",n)}return dv("%1$s has removed this message",this.model.getDisplayName())}showUserModal(e){if("me"===this.model.get("sender"))bu.modal.show(ul.ProfileModal,{model:this.model},e);else if("groupchat"===this.model.get("type"))e.preventDefault(),bu.modal.show(Ob,{model:this.model.occupant,message:this.model},e);else{e.preventDefault();const t=this.model.collection.chatbox;bu.modal.show(Db,{model:t},e)}}showMessageVersionsModal(e){e.preventDefault(),bu.modal.show($b,{model:this.model},e)}toggleSpoilerMessage(e){null==e||e.preventDefault(),this.model.save({is_spoiler_visible:!this.model.get("is_spoiler_visible")})}});bu.elements.define("converse-message-history",class extends hv{static get properties(){return{model:{type:Object},messages:{type:Array}}}render(){const e=this.messages;return e.length?C_(e,(e=>e.get("id")),(e=>Kd`${this.renderMessage(e)}`)):""}renderMessage(e){if(e.get("dangling_retraction")||e.get("is_only_key"))return"";const t=e.get("template_hook");if("string"==typeof t){const n=bu.hook(t,e,"");return __(n,"")}{const t=Kd``,n=nb(e);return n?[n,t]:t}}});var Kb=n(8054),Yb={};Yb.styleTagTransform=Av(),Yb.setAttributes=wv(),Yb.insert=yv().bind(null,"head"),Yb.domAPI=vv(),Yb.insertStyleElement=xv();fv()(Kb.Z,Yb);Kb.Z&&Kb.Z.locals&&Kb.Z.locals;bu.elements.define("converse-chat-content",class extends hv{static get properties(){return{jid:{type:String}}}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("scroll",tb)}async initialize(){await this.setModels(),this.listenTo(this.model,"change:hidden_occupants",this.requestUpdate),this.listenTo(this.model.messages,"add",this.requestUpdate),this.listenTo(this.model.messages,"change",this.requestUpdate),this.listenTo(this.model.messages,"remove",this.requestUpdate),this.listenTo(this.model.messages,"rendered",this.requestUpdate),this.listenTo(this.model.messages,"reset",this.requestUpdate),this.listenTo(this.model.notifications,"change",this.requestUpdate),this.listenTo(this.model.ui,"change",this.requestUpdate),this.listenTo(this.model.ui,"change:scrolled",this.scrollDown),this.model.occupants&&this.listenTo(this.model.occupants,"change",this.requestUpdate),this.addEventListener("scroll",tb)}async setModels(){this.model=await bu.chatboxes.get(this.jid),await this.model.initialized,this.requestUpdate()}render(){var e;return this.model?Kd`
${this.model.getNotificationsText()}
${null!==(e=this.model.ui)&&void 0!==e&&e.get("chat-content-spinner-top")?Jb():""} `:""}scrollDown(){if(!this.model.ui.get("scrolled")){if(this.scrollTo){const e=this.scrollTop?"smooth":"auto";this.scrollTo({top:0,behavior:e})}else this.scrollTop=0;bu.trigger("chatBoxScrolledDown",{chatbox:this.model})}}});class Xb extends t_{constructor(e){if(super(e),this.it=Xd,e.type!==Xv)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===Xd||null==e)return this.ft=void 0,this.it=e;if(e===Yd)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this.ft;this.it=e;const t=[e];return t.raw=t,this.ft={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Xb.directiveName="unsafeHTML",Xb.resultType=1;const ew=e_(Xb);bu.elements.define("converse-chat-help",class extends hv{static get properties(){return{chat_type:{type:String},messages:{type:Array},model:{type:Object},type:{type:String}}}render(){const e=(new Date).toISOString();return[Kd``,...this.messages.map((t=>this.renderHelpMessage({isodate:e,markup:Za().sanitize(t,{ALLOWED_TAGS:["strong"]})})))]}close(){this.model.set({show_help_messages:!1})}renderHelpMessage(e){return Kd`
${ew(e.markup)}
`}});const tw=Su.env.utils,nw=e=>{const t=bu.settings.get("emoji_categories");return Kd`
    ${Object.keys(t).map((n=>t[n]?(e=>Kd`
  • ${e.emoji}
  • `)(Object.assign({category:n,emoji:e.sn2Emoji(t[n])},e)):""))}
`},sw=e=>Kd`
  • ${tw.shortnamesToEmojis(e.emoji.sn)}
  • `,iw=e=>{const t=bu.settings.get("emoji_categories");return Kd` ${Object.keys(t).map((n=>t[n]?(e=>Kd` ${dv(bu.settings.get("emoji_category_labels")[e.category])}
      ${Object.values(Su.emojis.json[e.category]).map((t=>sw(Object.assign({emoji:t},e))))}
    `)(Object.assign({category:n},e)):""))}
    `},ow=e=>{const t=dv("Search");return Kd`
    ${e.query?"":nw(e)}
    ${e.render_emojis?Kd``:""}
    `},{sizzle:rw}=Su.env;bu.elements.define("converse-emoji-picker-content",class extends hv{static get properties(){return{chatview:{type:Object},search_results:{type:Array},current_skintone:{type:String},model:{type:Object},query:{type:String}}}render(){const e={current_skintone:this.current_skintone,insertEmoji:e=>this.insertEmoji(e),query:this.query,search_results:this.search_results,shouldBeHidden:e=>this.shouldBeHidden(e)};return Kd`
    ${(e=>{const t=dv("Search results");return Kd` ${t}
      ${e.search_results.map((t=>sw(Object.assign({emoji:t},e))))}
    `})(e)} ${iw(e)}
    `}firstUpdated(){this.initIntersectionObserver()}initIntersectionObserver(){if(window.IntersectionObserver){if(this.observer)this.observer.disconnect();else{const e={root:this.querySelector(".emoji-picker__lists"),threshold:[.1]},t=e=>this.setCategoryOnVisibilityChange(e);this.observer=new IntersectionObserver(t,e)}rw(".emoji-picker",this).forEach((e=>this.observer.observe(e)))}}setCategoryOnVisibilityChange(e){const t=this.parentElement.navigator.selected,n=e.filter((e=>e.target.contains(t))).pop();let s;if(s=n||e.reduce(((e,t)=>t.intersectionRatio>=((null==e?void 0:e.intersectionRatio)||0)?t:e),null),s&&s.isIntersecting){const e=s.target.getAttribute("data-category");e!==this.model.get("current_category")&&(this.parentElement.preserve_scroll=!0,this.model.save({current_category:e}))}}insertEmoji(e){e.preventDefault(),e.stopPropagation();const t="IMG"===e.target.nodeName?e.target.parentElement:e.target;this.parentElement.insertIntoTextArea(t.getAttribute("data-emoji"))}shouldBeHidden(e){if(e.includes("_tone")){if(!this.current_skintone||!e.includes(this.current_skintone))return!0}else if(this.current_skintone&&ib().includes(e))return!0;return!(!this.query||ul.FILTER_CONTAINS(e,this.query))}});const aw=Su.env.utils;bu.elements.define("converse-emoji-dropdown",class extends Ab{static get properties(){return{chatview:{type:Object}}}constructor(){super(),this.render_emojis=!1}initModel(){return this.init_promise||(this.init_promise=(async()=>{await bu.emojis.initialize();const e=`converse.emoji-${ul.bare_jid}-${this.chatview.model.get("jid")}`;this.model=new ul.EmojiPicker({id:e}),La(this.model,e),await new Promise((e=>this.model.fetch({success:e,error:e}))),this.model.set({autocompleting:null,ac_position:null})})()),this.init_promise}render(){const e=this.chatview.model.get("type")===ul.CHATROOMS_TYPE?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color";return Kd`
    `}connectedCallback(){super.connectedCallback(),this.render_emojis=!1}toggleMenu(e){e.stopPropagation(),e.preventDefault(),aw.hasClass("show",this.menu)?aw.ancestor(e.target,".toggle-emojis")&&this.hideMenu():this.showMenu()}async showMenu(){await this.initModel(),this.render_emojis||(this.render_emojis=!0,this.requestUpdate(),await this.updateComplete),super.showMenu(),setTimeout((()=>{var e;return null===(e=this.querySelector(".emoji-search"))||void 0===e?void 0:e.focus()}))}});var cw=n(8125),lw={};lw.styleTagTransform=Av(),lw.setAttributes=wv(),lw.insert=yv().bind(null,"head"),lw.domAPI=vv(),lw.insertStyleElement=xv();fv()(cw.Z,lw);cw.Z&&cw.Z.locals&&cw.Z.locals;const dw=Su.env.utils;bu.elements.define("converse-emoji-picker",class extends hv{static get properties(){return{chatview:{type:Object},current_category:{type:String,reflect:!0},current_skintone:{type:String,reflect:!0},model:{type:Object},query:{type:String,reflect:!0},render_emojis:{type:Boolean}}}firstUpdated(){super.firstUpdated(),this.listenTo(this.model,"change",(e=>this.onModelChanged(e.changed))),this.initArrowNavigation()}constructor(){super(),this.query="",this._search_results=[],this.debouncedFilter=jc((e=>this.model.set({query:e.value})),250)}get search_results(){return this._search_results}set search_results(e){this._search_results=e,this.requestUpdate()}render(){return ow({chatview:this.chatview,current_category:this.current_category,current_skintone:this.current_skintone,model:this.model,onCategoryPicked:e=>this.chooseCategory(e),onSearchInputBlurred:e=>this.chatview.emitFocused(e),onSearchInputFocus:e=>this.onSearchInputFocus(e),onSearchInputKeyDown:e=>this.onSearchInputKeyDown(e),onSkintonePicked:e=>this.chooseSkinTone(e),query:this.query,search_results:this.search_results,render_emojis:this.render_emojis,sn2Emoji:e=>dw.shortnamesToEmojis(this.getTonedShortname(e))})}updated(e){e.has("query")&&this.updateSearchResults(e),e.has("current_category")&&this.setScrollPosition()}onModelChanged(e){"current_category"in e&&(this.current_category=e.current_category),"current_skintone"in e&&(this.current_skintone=e.current_skintone),"query"in e&&(this.query=e.query)}setScrollPosition(){if(this.preserve_scroll)return void(this.preserve_scroll=!1);const e=this.querySelector(".emoji-lists__container--browse"),t=this.querySelector(`#emoji-picker-${this.current_category}`);t&&(e.scrollTop=t.offsetTop-3*t.offsetHeight+4)}updateSearchResults(e){const t=e.get("query"),n=ul.FILTER_CONTAINS;if(this.query){if(this.query===t)return this.search_results;t&&this.query.includes(t)?this.search_results=this.search_results.filter((e=>n(e.sn,this.query))):this.search_results=Su.emojis.list.filter((e=>n(e.sn,this.query)))}else this.search_results.length&&(this.search_results=[])}registerEvents(){this.onGlobalKeyDown=e=>this._onGlobalKeyDown(e);document.querySelector("body").addEventListener("keydown",this.onGlobalKeyDown)}connectedCallback(){super.connectedCallback(),this.registerEvents()}disconnectedCallback(){document.querySelector("body").removeEventListener("keydown",this.onGlobalKeyDown),this.disableArrowNavigation(),super.disconnectedCallback()}_onGlobalKeyDown(e){this.navigator&&(e.keyCode===be.ENTER&&dw.isVisible(this)?this.onEnterPressed(e):e.keyCode===be.DOWN_ARROW&&!this.navigator.enabled&&dw.isVisible(this)?this.enableArrowNavigation(e):e.keyCode===be.ESCAPE&&(this.disableArrowNavigation(),setTimeout((()=>this.chatview.querySelector(".chat-textarea").focus()),50)))}setCategoryForElement(e){const t=this.current_category,n=(null==e?void 0:e.getAttribute("data-category"))||t;t!==n&&this.model.save({current_category:n})}insertIntoTextArea(e){const t=this.model.get("autocompleting"),n=this.model.get("ac_position");this.model.set({autocompleting:null,query:"",ac_position:null}),this.disableArrowNavigation();const s={bubbles:!0,detail:{value:e,autocompleting:t,ac_position:n,jid:this.chatview.model.get("jid")}};this.dispatchEvent(new CustomEvent("emojiSelected",s))}chooseSkinTone(e){e.preventDefault(),e.stopPropagation();const t=("IMG"===e.target.nodeName?e.target.parentElement:e.target).getAttribute("data-skintone").trim();this.current_skintone===t?this.model.save({current_skintone:""}):this.model.save({current_skintone:t})}chooseCategory(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation();const t=e.target.matches("li")?e.target:dw.ancestor(e.target,"li");this.setCategoryForElement(t),this.navigator.select(t),!this.navigator.enabled&&this.navigator.enable()}onSearchInputKeyDown(e){if(e.keyCode===be.TAB)if(e.target.value){e.preventDefault();const t=Su.emojis.shortnames.find((t=>ul.FILTER_CONTAINS(t,e.target.value)));t&&this.model.set({query:t})}else this.navigator.enabled||this.enableArrowNavigation(e);else e.keyCode!==be.DOWN_ARROW||this.navigator.enabled?e.keyCode!==be.ENTER&&e.keyCode!==be.DOWN_ARROW&&this.debouncedFilter(e.target):this.enableArrowNavigation(e)}onEnterPressed(e){e.preventDefault(),e.stopPropagation(),Su.emojis.shortnames.includes(e.target.value)?this.insertIntoTextArea(e.target.value):1===this.search_results.length?this.insertIntoTextArea(this.search_results[0].sn):this.navigator.selected&&this.navigator.selected.matches(".insert-emoji")?this.insertIntoTextArea(this.navigator.selected.getAttribute("data-emoji")):this.navigator.selected&&this.navigator.selected.matches(".emoji-category")&&this.chooseCategory({target:this.navigator.selected})}onSearchInputFocus(e){this.chatview.emitBlurred(e),this.disableArrowNavigation()}getTonedShortname(e){return ib().includes(e)&&this.current_skintone?`${e.slice(0,e.length-1)}_${this.current_skintone}:`:e}initArrowNavigation(){if(!this.navigator){const e="li:not(.hidden):not(.emoji-skintone), .emoji-search",t={jump_to_picked:".emoji-category",jump_to_picked_selector:".emoji-category.picked",jump_to_picked_direction:bb.DIRECTION.down,picked_selector:".picked",scroll_container:this.querySelector(".emoji-picker__lists"),getSelector:t=>{if(t===bb.DIRECTION.down){const t=this.navigator.selected&&this.navigator.selected.getAttribute("data-category");return t?`ul[data-category="${t}"] li:not(.hidden):not(.emoji-skintone), .emoji-search`:e}return e},onSelected:e=>{e.matches(".insert-emoji")&&this.setCategoryForElement(e.parentElement),e.matches(".insert-emoji, .emoji-category")&&e.firstElementChild.focus(),e.matches(".emoji-search")&&e.focus()}};this.navigator=new bb(this,t)}}disableArrowNavigation(){var e;null===(e=this.navigator)||void 0===e||e.disable()}enableArrowNavigation(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.disableArrowNavigation(),this.navigator.enable(),this.navigator.handleKeydown(e)}});bu.elements.define("converse-message-limit-indicator",class extends hv{static get properties(){return{model:{type:Object}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:draft",this.requestUpdate)}render(){const e=bu.settings.get("message_limit");if(!e)return"";return(e=>{const t=dv("Message characters remaining");return Kd`${e}`})(e-(this.model.get("draft")||"").length)}});const uw=e=>Kd` ${__(e.getButtons(),"")} ${e.show_send_button?function(){const e=dv("Send the message");return Kd``}():""} `;var hw=n(6176),mw={};mw.styleTagTransform=Av(),mw.setAttributes=wv(),mw.insert=yv().bind(null,"head"),mw.domAPI=vv(),mw.insertStyleElement=xv();fv()(hw.Z,mw);hw.Z&&hw.Z.locals&&hw.Z.locals;const gw=Su.env.Strophe;async function fw(e){const t=await e;return t?Kd` ${t.i18n_text} `:""}async function pw(e){const t=await e;return Kd` `}async function vw(e){!0===confirm(dv("Are you sure you want to clear the messages from this conversation?"))&&await e.clearMessages()}function _w(e){if(e.target.value){const t=e.target.scrollHeight+"px";e.target.style.height!=t&&(e.target.style.height="auto",e.target.style.height=t)}else e.target.style=""}window.customElements.define("converse-chat-toolbar",class extends hv{static get properties(){return{hidden_occupants:{type:Boolean},is_groupchat:{type:Boolean},message_limit:{type:Number},model:{type:Object},show_call_button:{type:Boolean},show_emoji_button:{type:Boolean},show_send_button:{type:Boolean},show_spoiler_button:{type:Boolean}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:composing_spoiler",(()=>this.requestUpdate()))}render(){return uw(this)}firstUpdated(){bu.trigger("renderToolbar",this)}getButtons(){var e;const t=[];if(this.show_emoji_button){const e=ul.chatboxviews.get(this.model.get("jid"));t.push(Kd``)}if(this.show_call_button){const e=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color",n=dv("Start a call");t.push(Kd` `)}bu.settings.get("message_limit")&&t.push(Kd` `),this.show_spoiler_button&&t.push(this.getSpoilerButton());const n=bu.disco.supports(gw.NS.HTTPUPLOAD,ul.domain);if(t.push(Kd`${__(n.then((e=>this.getHTTPUploadButton(e))),"")}`),this.is_groupchat&&null!==(e=bu.settings.get("visible_toolbar_buttons"))&&void 0!==e&&e.toggle_occupants){const e=dv("Hide participants"),n=dv("Show participants");t.push(Kd` `)}return ul.api.hook("getToolbarButtons",this,t)}getHTTPUploadButton(e){if(e){const e=dv("Choose a file to send"),t=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color";return Kd` `}return""}getSpoilerButton(){var e;const t=this.model;if(!(this.is_groupchat||null!==(e=t.presence)&&void 0!==e&&e.resources.length))return;let n;n=t.get("composing_spoiler")?dv("Click to write as a normal (non-spoiler) message"):dv("Click to write your message as a spoiler");const s=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color",i=Kd` `;if(this.is_groupchat)return i;{const e=t.get("jid"),n=Promise.all(t.presence.resources.map((t=>bu.disco.supports(gw.NS.SPOILER,`${e}/${t.get("name")}`)))).then((e=>e.reduce(((e,t)=>e&&t),!0)));return Kd`${__(n.then((()=>i)),"")}`}}toggleFileUpload(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.querySelector(".fileupload").click()}onFileSelection(e){this.model.sendFiles(e.target.files)}toggleComposeSpoilerMessage(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.set("composing_spoiler",!this.model.get("composing_spoiler"))}toggleOccupants(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.save({hidden_occupants:!this.model.get("hidden_occupants")})}toggleCall(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),bu.trigger("callButtonClicked",{connection:ul.connection,model:this.model})}});const yw=e=>{var t,n;const s=dv("The User's Profile Image"),i=Kd` `,o=e.model.getDisplayName();return Kd`
    ${ul.api.settings.get("singleton")?"":Kd``} ${e.type!==ul.HEADLINES_TYPE?Kd`${i}`:""}
    ${e.type!==ul.HEADLINES_TYPE?Kd`${o}`:o}
    ${__(async function(e){const t=(await e).filter((e=>!e.standalone));return t.map((e=>fw(e)))}(e.heading_buttons_promise).then((e=>e.length?Kd``:"")),"")} ${__(async function(e){const t=(await e).filter((e=>e.standalone));return t.map((e=>pw(e)))}(e.heading_buttons_promise).then((e=>e.reverse().map((e=>__(e,""))))),"")}
    ${e.status?Kd`

    ${e.status}

    `:""} `};var bw=n(7802),ww={};ww.styleTagTransform=Av(),ww.setAttributes=wv(),ww.insert=yv().bind(null,"head"),ww.domAPI=vv(),ww.insertStyleElement=xv();fv()(bw.Z,ww);bw.Z&&bw.Z.locals&&bw.Z.locals;bu.elements.define("converse-chat-heading",class extends hv{initialize(){var e;this.model=ul.chatboxes.get(this.getAttribute("jid")),this.listenTo(this.model,"change:status",this.requestUpdate),this.listenTo(this.model,"vcard:add",this.requestUpdate),this.listenTo(this.model,"vcard:change",this.requestUpdate),this.model.contact&&this.listenTo(this.model.contact,"destroy",this.requestUpdate),null===(e=this.model.rosterContactAdded)||void 0===e||e.then((()=>{this.listenTo(this.model.contact,"change:nickname",this.requestUpdate),this.requestUpdate()}))}render(){return yw(Object.assign(this.model.toJSON(),{heading_buttons_promise:this.getHeadingButtons(),model:this.model,showUserDetailsModal:e=>this.showUserDetailsModal(e)}))}showUserDetailsModal(e){e.preventDefault(),bu.modal.show(Db,{model:this.model},e)}close(e){e.preventDefault(),this.model.close()}getHeadingButtons(){const e=[{a_class:"show-user-details-modal",handler:e=>this.showUserDetailsModal(e),i18n_text:dv("Details"),i18n_title:dv("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===bu.settings.get("view_mode")}];bu.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:dv("Close"),i18n_title:dv("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===bu.settings.get("view_mode")});const t=ul.chatboxviews.get(this.getAttribute("jid"));return t?ul.api.hook("getHeadingButtons",t,e):e}});"undefined"!=typeof Element&&Element.prototype;const Sw=/^(\S+)\s*(.*)$/,xw=["model","collection","events"];class Ew extends HTMLElement{constructor(e){super(),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"events",{}),this.cid=pi("view"),this._domEvents=[],Mt(this,Ja(e,xw))}createRenderRoot(){return this}connectedCallback(){this._initialized||(this.preinitialize.apply(this,arguments),this.initialize.apply(this,arguments),this._initialized=!0),this.delegateEvents()}disconnectedCallback(){this.undelegateEvents(),this.stopListening()}preinitialize(){}initialize(){}render(){return Se(this.beforeRender)&&this.beforeRender(),Se(this.toHTML)&&tu(this.toHTML(),this),Se(this.afterRender)&&this.afterRender(),this}delegateEvents(){if(!this.events)return this;this.undelegateEvents();for(const e in this.events){let t=this.events[e];if(Se(t)||(t=this[t]),!t)continue;const n=e.match(Sw);this.delegate(n[1],n[2],t.bind(this))}return this}delegate(e,t,n){const s=this;if(!s)return this;if("function"==typeof t&&(n=t,t=null),-1!==["focus","blur"].indexOf(e)){const s=this.querySelectorAll(t);for(let t=0,i=s.length;tthis.render())),this.handleEmojiSelection=e=>{let{detail:t}=e;this.model.get("jid")===t.jid&&this.insertIntoTextArea(t.value,t.autocompleting,!1,t.ac_position)},document.addEventListener("emojiSelected",this.handleEmojiSelection),this.render()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("emojiSelected",this.handleEmojiSelection)}toHTML(){var e,t;return(e=>{const t=e.composing_spoiler?dv("Hidden message"):dv("Message"),n=dv("Optional hint"),s=bu.settings.get("show_send_button");return Kd`
    `})(Object.assign(this.model.toJSON(),{onDrop:e=>this.onDrop(e),hint_value:null===(e=this.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,message_value:null===(t=this.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,onChange:e=>this.model.set({draft:e.target.value}),onKeyDown:e=>this.onKeyDown(e),onKeyUp:e=>this.onKeyUp(e),onPaste:e=>this.onPaste(e),viewUnreadMessages:e=>this.viewUnreadMessages(e)}))}insertIntoTextArea(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3?arguments[3]:void 0;const i=this.querySelector(".chat-textarea");if(n?Aw.addClass("correcting",i):Aw.removeClass("correcting",i),t)i.value=s&&"string"==typeof t?i.value.replace(new RegExp(t,"g"),((n,i)=>i==s-t.length?e+" ":n)):e;else{let t=i.value;t&&" "!==t[t.length-1]&&(t+=" "),i.value=t+e+" "}const o=document.createEvent("HTMLEvents");o.initEvent("change",!1,!0),i.dispatchEvent(o),Aw.placeCaretAtEnd(i)}onMessageCorrecting(e){if(e.get("correcting"))this.insertIntoTextArea(Qc(e),!0,!0);else{const t=this.model.messages.findWhere("correcting");t&&t!==e?this.insertIntoTextArea(Qc(e),!0,!0):this.insertIntoTextArea("",!0,!1)}}onEscapePressed(e){const t=this.model.messages.findLastIndex("correcting"),n=t>=0?this.model.messages.at(t):null;n&&(e.preventDefault(),n.save("correcting",!1),this.insertIntoTextArea("",!0,!1))}onPaste(e){if(e.stopPropagation(),0!==e.clipboardData.files.length)return e.preventDefault(),void this.model.sendFiles(Array.from(e.clipboardData.files));this.model.set({draft:e.clipboardData.getData("text/plain")})}onKeyUp(e){this.model.set({draft:e.target.value})}onKeyDown(e){if(!e.ctrlKey){if(!e.shiftKey&&!e.altKey&&!e.metaKey)if(e.keyCode===Su.keycodes.TAB){const t=Aw.getCurrentWord(e.target,null,/(:.*?:)/g);t.startsWith(":")&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("emoji-picker-autocomplete",e.target,t))}else{if(e.keyCode===Su.keycodes.FORWARD_SLASH)return;if(e.keyCode===Su.keycodes.ESCAPE)return this.onEscapePressed(e,this);if(e.keyCode===Su.keycodes.ENTER)return this.onFormSubmitted(e);if(e.keyCode!==Su.keycodes.UP_ARROW||e.target.selectionEnd){if(e.keyCode===Su.keycodes.DOWN_ARROW&&e.target.selectionEnd===e.target.value.length&&Aw.hasClass("correcting",this.querySelector(".chat-textarea")))return this.model.editLaterMessage()}else{const e=this.querySelector(".chat-textarea");if(!e.value||Aw.hasClass("correcting",e))return this.model.editEarlierMessage()}}[Su.keycodes.SHIFT,Su.keycodes.META,Su.keycodes.META_RIGHT,Su.keycodes.ESCAPE,Su.keycodes.ALT].includes(e.keyCode)||this.model.get("chat_state")!==ul.COMPOSING&&this.model.setChatState(ul.COMPOSING)}}async onFormSubmitted(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const s=this.querySelector(".chat-textarea"),i=s.value.trim();if(bu.settings.get("message_limit")&&i.length>bu.settings.get("message_limit")||!i.replace(/\s/g,"").length)return;if(!ul.connection.authenticated){const e=dv("Sorry, the connection has been lost, and your message could not be sent");return bu.alert("error",dv("Error"),e),void bu.connection.reconnect()}let o,r={};this.model.get("composing_spoiler")&&(r=this.querySelector("form.sendXMPPMessage input.spoiler-hint"),o=r.value),Aw.addClass("disabled",s),s.setAttribute("disabled","disabled"),null===(n=this.querySelector("converse-emoji-dropdown"))||void 0===n||n.hideMenu();const a=await async function(e,t){const n=t.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(n){let i=!1;if(i=await bu.hook("parseMessageForCommands",{model:e,text:t},i),i)return!0;if("clear"===n[1])return vw(e),!0;var s;if("close"===n[1])return null===(s=ul.chatboxviews.get(e.get("jid")))||void 0===s||s.close(),!0;if("help"===n[1])return e.set({show_help_messages:!1},{silent:!0}),e.set({show_help_messages:!0}),!0}return!1}(this.model,i),c=a?null:await this.model.sendMessage({body:i,spoiler_hint:o});if((a||c)&&(r.value="",s.value="",Aw.removeClass("correcting",s),s.style.height="auto",this.model.set({draft:""})),"overlayed"===bu.settings.get("view_mode")){ul.chatboxviews.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display="none"}if(s.removeAttribute("disabled"),Aw.removeClass("disabled",s),"overlayed"===bu.settings.get("view_mode")){ul.chatboxviews.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display=""}this.model.setChatState(ul.ACTIVE,{silent:!0}),s.focus()}}bu.elements.define("converse-message-form",Cw);var kw=n(352),jw={};jw.styleTagTransform=Av(),jw.setAttributes=wv(),jw.insert=yv().bind(null,"head"),jw.domAPI=vv(),jw.insertStyleElement=xv();fv()(kw.Z,jw);kw.Z&&kw.Z.locals&&kw.Z.locals;class Tw extends Ew{constructor(){super(),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"events",{"click .send-button":"sendButtonClicked","click .toggle-clear":"clearMessages"}),this.debouncedRender=jc(this.render,100)}async connectedCallback(){super.connectedCallback(),await this.initialize(),this.render()}async initialize(){this.model=await bu.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.listenTo(this.model,"change:num_unread",this.debouncedRender),this.listenTo(this.model,"emoji-picker-autocomplete",this.autocompleteInPicker),this.addEventListener("focusin",(e=>this.emitFocused(e))),this.addEventListener("focusout",(e=>this.emitBlurred(e)))}render(){tu((e=>{const t=dv("You have unread messages"),n=bu.settings.get("message_limit"),s=bu.settings.get("visible_toolbar_buttons").call,i=bu.settings.get("visible_toolbar_buttons").emoji,o=bu.settings.get("show_send_button"),r=bu.settings.get("visible_toolbar_buttons").spoiler,a=bu.settings.get("show_toolbar");return Kd` ${e.model.ui.get("scrolled")&&e.model.get("num_unread")?Kd`
    e.viewUnreadMessages(t)}>▼ ${t} ▼
    `:""} ${bu.settings.get("show_toolbar")?Kd` `:""} `})({model:this.model,viewUnreadMessages:e=>this.viewUnreadMessages(e)}),this)}sendButtonClicked(e){var t;null===(t=this.querySelector("converse-message-form"))||void 0===t||t.onFormSubmitted(e)}viewUnreadMessages(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.ui.set({scrolled:!1})}emitFocused(e){var t;null===(t=ul.chatboxviews.get(this.getAttribute("jid")))||void 0===t||t.emitFocused(e)}emitBlurred(e){var t;null===(t=ul.chatboxviews.get(this.getAttribute("jid")))||void 0===t||t.emitBlurred(e)}onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))}onDragOver(e){e.preventDefault()}clearMessages(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),vw(this.model)}async autocompleteInPicker(e,t){await bu.emojis.initialize();const n=this.querySelector("converse-emoji-picker");if(n){n.model.set({ac_position:e.selectionStart,autocompleting:t,query:t});const s=this.querySelector("converse-emoji-dropdown");null==s||s.showMenu()}}}bu.elements.define("converse-chat-bottom-panel",Tw);class $w extends hv{static get properties(){return{jid:{type:String}}}disconnectedCallback(){super.disconnectedCallback(),ul.chatboxviews.remove(this.jid,this)}updated(){this.model&&this.jid!==this.model.get("jid")&&(this.stopListening(),ul.chatboxviews.remove(this.model.get("jid"),this),delete this.model,this.requestUpdate(),this.initialize())}close(e){var t;return null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.close(e)}maybeFocus(){bu.settings.get("auto_focus")&&this.focus()}focus(){const e=this.getElementsByClassName("chat-textarea")[0];return e&&document.activeElement!==e&&e.focus(),this}emitBlurred(e){this.contains(document.activeElement)||this.contains(e.relatedTarget)||bu.trigger("chatBoxBlurred",this,e)}emitFocused(e){this.contains(e.relatedTarget)||bu.trigger("chatBoxFocused",this,e)}getBottomPanel(){return this.model.get("type")===ul.CHATROOMS_TYPE?this.querySelector("converse-muc-bottom-panel"):this.querySelector("converse-chat-bottom-panel")}getMessageForm(){return this.model.get("type")===ul.CHATROOMS_TYPE?this.querySelector("converse-muc-message-form"):this.querySelector("converse-message-form")}scrollDown(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.ui.get("scrolled")&&this.model.ui.set({scrolled:!1}),eb(this.model)}onWindowStateChanged(e){"visible"===e.state?this.model.isHidden()||this.model.clearUnreadMsgCounter():"hidden"===e.state&&(this.model.setChatState(ul.INACTIVE,{silent:!0}),this.model.sendChatState())}}class Nw extends $w{constructor(){super(...arguments),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"length",200)}async initialize(){ul.chatboxviews.add(this.jid,this),this.model=ul.chatboxes.get(this.jid),this.listenTo(ul,"windowStateChanged",this.onWindowStateChanged),this.listenTo(this.model,"change:hidden",(()=>!this.model.get("hidden")&&this.afterShown())),this.listenTo(this.model,"change:show_help_messages",this.requestUpdate),await this.model.messages.fetched,!this.model.get("hidden")&&this.afterShown(),bu.trigger("chatBoxViewInitialized",this)}render(){return(e=>Kd`
    ${e.model?Kd`
    ${e.show_help_messages?Kd`
    `:""}
    `:""}
    `)(Object.assign({model:this.model,help_messages:this.getHelpMessages(),show_help_messages:this.model.get("show_help_messages")},this.model.toJSON()))}getHelpMessages(){return[`/clear: ${dv("Remove messages")}`,`/close: ${dv("Close this chat")}`,`/me: ${dv("Write in the third person")}`,`/help: ${dv("Show this menu")}`]}showControlBox(){var e;null===(e=ul.chatboxviews.get("controlbox"))||void 0===e||e.show()}afterShown(){this.model.setChatState(ul.ACTIVE),this.model.clearUnreadMsgCounter(),this.maybeFocus()}}bu.elements.define("converse-chat",Nw);var Ow=n(5599),Iw={};Iw.styleTagTransform=Av(),Iw.setAttributes=wv(),Iw.insert=yv().bind(null,"head"),Iw.domAPI=vv(),Iw.insertStyleElement=xv();fv()(Ow.Z,Iw);Ow.Z&&Ow.Z.locals&&Ow.Z.locals;const{Strophe:Mw}=Su.env;Su.plugins.add("converse-chatview",{dependencies:["converse-chatboxviews","converse-chat","converse-disco","converse-modal"],initialize(){bu.settings.extend({allowed_audio_domains:null,allowed_image_domains:null,allowed_video_domains:null,auto_focus:!0,debounced_content_rendering:!0,filter_url_query_params:null,image_urls_regex:null,message_limit:0,muc_hats:["xep317"],render_media:!0,show_message_avatar:!0,show_retraction_warning:!0,show_send_button:!0,show_toolbar:!0,time_format:"HH:mm",use_system_emojis:!0,visible_toolbar_buttons:{call:!1,clear:!0,emoji:!0,spoiler:!0}}),ul.ChatBoxView=Nw,bu.listen.on("connected",(()=>bu.disco.own.features.add(Mw.NS.SPOILER))),bu.listen.on("chatBoxClosed",(e=>{return t=e.get("jid"),void(ul.router.history.getFragment()===`converse/chat?jid=${t}`&&ul.router.navigate(""));var t}))}});bu.elements.define("converse-brand-byline",class extends hv{render(){const e="fullscreen"===bu.settings.get("view_mode");return Kd` ${e?Kd`

    ${ul.VERSION_NAME}

    Open Source XMPP chat client brought to you by Opkode

    Translate it into your own language

    `:""} `}});bu.elements.define("converse-brand-logo",class extends hv{render(){const e="fullscreen"===bu.settings.get("view_mode");return Kd` converse.js ${e?Kd` `:""} `}});bu.elements.define("converse-brand-heading",class extends hv{render(){return Kd` `}});const{Strophe:Rw}=Su.env,Dw=[Rw.Status.ERROR,Rw.Status.CONNECTING,Rw.Status.CONNFAIL,Rw.Status.AUTHENTICATING,Rw.Status.AUTHFAIL,Rw.Status.DISCONNECTING,Rw.Status.RECONNECTING],zw=Object.fromEntries([[Rw.Status.ERROR,"Error"],[Rw.Status.CONNECTING,"Connecting"],[Rw.Status.CONNFAIL,"Connection failure"],[Rw.Status.AUTHENTICATING,"Authenticating"],[Rw.Status.AUTHFAIL,"Authentication failure"],[Rw.Status.CONNECTED,"Connected"],[Rw.Status.DISCONNECTED,"Disconnected"],[Rw.Status.DISCONNECTING,"Disconnecting"],[Rw.Status.ATTACHED,"Attached"],[Rw.Status.REDIRECT,"Redirect"],[Rw.Status.CONNTIMEOUT,"Connection timeout"],[Rw.Status.RECONNECTING,"Reconnecting"]]),Lw=Object.fromEntries([[Rw.Status.ERROR,"error"],[Rw.Status.CONNECTING,"info"],[Rw.Status.CONNFAIL,"error"],[Rw.Status.AUTHENTICATING,"info"],[Rw.Status.AUTHFAIL,"error"],[Rw.Status.CONNECTED,"info"],[Rw.Status.DISCONNECTED,"error"],[Rw.Status.DISCONNECTING,"warn"],[Rw.Status.ATTACHED,"info"],[Rw.Status.REDIRECT,"info"],[Rw.Status.RECONNECTING,"warn"]]),Pw=e=>{const t=bu.settings.get("authentication"),n=dv("Log in"),s=dv("XMPP Address"),i=bu.settings.get("locked_domain"),o=bu.settings.get("default_domain"),r=(i||o)&&dv("Username")||dv("user@domain"),a=bu.settings.get("allow_user_trust_override");return Kd`
    ${t!==ul.EXTERNAL?(()=>{const e=dv("Password");return Kd`
    `})():""} ${bu.settings.get("show_connection_url_input")?(()=>{const e=dv("Connection URL"),t=dv("HTTP or websocket URL that is used to connect to your XMPP server"),n=dv("e.g. wss://example.org/xmpp-websocket");return Kd`

    ${t}

    `})():""} ${a?(e=>{const t=dv("To improve performance, we cache your data in this browser. Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. It's important that you explicitly log out, otherwise not all cached data might be deleted. Please note, when using an untrusted device, OMEMO encryption is NOT available."),n=dv("This is a trusted device");return Kd` `})("off"!==a):""}
    ${bu.settings.get("allow_registration")&&!bu.settings.get("auto_login")&&ul.pluggable.plugins["converse-register"].enabled(ul)?(()=>{const e=dv("Create an account"),t=dv("Don't have a chat account?");return Kd`

    ${t}

    `})():""} `},Fw=e=>{const t=ul.connfeedback.get("connection_status");let n,s;Dw.includes(t)&&(s=zw[t],n=Lw[t]);const i=ul.connfeedback.get("message");return Kd`
    ${"CONNECTING"===ul.CONNECTION_STATUS[t]?Jb({classes:"hor_centered"}):(e=>{const t=bu.settings.get("authentication"),{ANONYMOUS:n,EXTERNAL:s,LOGIN:i,PREBIND:o}=ul,r=dv("Disconnected"),a=dv("Click here to log in anonymously");return Kd` ${t==i||t==s?Pw(e):""} ${t==n?Kd``:""} ${t==o?Kd`

    ${r}

    `:""} `})(e)}
    `},{Strophe:Uw,u:Bw}=Su.env;function qw(){var e;const t=ul.chatboxes.add(new ul.ControlBox({id:"controlbox"}));return null===(e=ul.chatboxviews.get("controlbox"))||void 0===e||e.setModel(),t}function Hw(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const n=ul.chatboxes.get("controlbox")||qw();Bw.safeSave(n,{closed:!1})}function Gw(){const e=ul.chatboxviews.get("controlbox");return e.model.set({connected:!1}),e}function Ww(){const e=null==ul?void 0:ul.chatboxviews,t=e&&e.get("controlbox");t&&(Bw.safeSave(t.model,{connected:!1}),null!=t&&t.controlbox_pane&&(t.controlbox_pane.remove(),delete t.controlbox_pane))}function Vw(){(ul.chatboxes.get("controlbox")||qw()).save({connected:!0})}const{Strophe:Jw,u:Qw}=Su.env;bu.elements.define("converse-login-form",class extends hv{initialize(){this.listenTo(ul.connfeedback,"change",(()=>this.requestUpdate())),this.handler=()=>this.requestUpdate()}connectedCallback(){super.connectedCallback(),bu.settings.listen.on("change",this.handler)}disconnectedCallback(){super.disconnectedCallback(),bu.settings.listen.not("change",this.handler)}render(){return Fw(this)}firstUpdated(){this.initPopovers()}async onLoginFormSubmitted(e){if(null==e||e.preventDefault(),bu.settings.get("authentication")===ul.ANONYMOUS)return this.connect(ul.jid);(function(e){const t=e.querySelector("input[name=jid]");return!t.value||bu.settings.get("locked_domain")||bu.settings.get("default_domain")||Bw.isValidJID(t.value)?(t.setCustomValidity(""),!0):(t.setCustomValidity(dv("Please enter a valid XMPP address")),!1)})(e.target)&&(!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new FormData(e),s=n.get("connection-url");null!=s&&s.startsWith("ws")?t.websocket_url=s:null!=s&&s.startsWith("http")&&(t.bosh_service_url=s);let i=n.get("jid");if(bu.settings.get("locked_domain")){const e="@"+bu.settings.get("locked_domain");i.endsWith(e)&&(i=i.substr(0,i.length-e.length)),i=Uw.escapeNode(i)+e}else bu.settings.get("default_domain")&&!i.includes("@")&&(i=i+"@"+bu.settings.get("default_domain"));t.jid=i,t.password=n.get("password"),bu.settings.set(t),ul.config.save({trusted:!!n.get("trusted")})}(e.target),bu.settings.get("bosh_service_url")||bu.settings.get("websocket_url")||await this.discoverConnectionMethods(e),bu.settings.get("bosh_service_url")||bu.settings.get("websocket_url")?this.connect():bu.settings.set("show_connection_url_input",!0))}async discoverConnectionMethods(e){var t;if(!bu.settings.get("discover_connection_methods"))return;const n=new FormData(e.target).get("jid"),s=Jw.getDomainFromJid(n);return(null===(t=ul.connection)||void 0===t||!t.jid||n&&!Qw.isSameDomain(ul.connection.jid,n))&&await ul.initConnection(),ul.connection.discoverConnectionMethods(s)}initPopovers(){Array.from(this.querySelectorAll("[data-title]")).forEach((e=>{new(Nv().Popover)(e,{trigger:"mobile"===bu.settings.get("view_mode")?"click":"hover",dismissible:"mobile"===bu.settings.get("view_mode"),container:this.parentElement.parentElement.parentElement})}))}connect(e){var t;["converse/login","converse/register"].includes(ul.router.history.getFragment())&&ul.router.navigate("",{replace:!0}),null===(t=ul.connection)||void 0===t||t.reset(),bu.user.login(e)}});const Zw=e=>Kd`function(e){Hw();const t=ul.chatboxes.get(e);Bw.safeSave(t,{hidden:!0})}(e)}>`;class Kw extends hv{static get properties(){return{jid:{type:String}}}render(){return Zw(this.jid)}}bu.elements.define("converse-controlbox-navback",Kw);const{dayjs:Yw}=Su.env,Xw=Ac.extend({defaults:()=>({bookmarked:!1,box_id:"controlbox",chat_state:void 0,closed:!bu.settings.get("show_controlbox_by_default"),num_unread:0,time_opened:Yw(0).valueOf(),type:ul.CONTROLBOX_TYPE,url:""}),validate(e){return e.type===ul.CONTROLBOX_TYPE?"embedded"===bu.settings.get("view_mode")&&bu.settings.get("singleton")?"Controlbox not relevant in embedded view mode":void 0:ul.ChatBox.prototype.validate.call(this,e)},maybeShow(e){return e||"controlbox"!==this.get("id")?ul.ChatBox.prototype.maybeShow.call(this,e):this},onReconnection(){this.save("connected",!0)}});class eS extends hv{async connectedCallback(){super.connectedCallback(),await bu.waitUntil("initialized"),this.model=ul.chatboxes.get("controlbox"),this.listenTo(this.model,"change:closed",(()=>this.requestUpdate())),this.requestUpdate()}render(){var e;return(e=>{const t=bu.connection.connected()?dv("Chat Contacts"):dv("Toggle chat");return Kd`${t}`})({onClick:Hw,hide:!(null!==(e=this.model)&&void 0!==e&&e.get("closed"))})}}bu.elements.define("converse-controlbox-toggle",eS);const tS=eS,{Strophe:nS}=Su.env;const sS=e=>{const t=e.model.toJSON(),n=bu.settings.get("sticky_controlbox");return Kd`
    ${n?"":Kd` e.close(t)}> `}
    ${t.connected?Kd`
    }`:function(e){const t=ul.connfeedback.get("connection_status");return console.log("connection_status"),console.log(t),[nS.Status.RECONNECTING,nS.Status.CONNECTING].includes(t)?Jb():"register"===e["active-form"]?Kd``:Kd`}`}(t)}
    `},iS=Su.env.utils;class oS extends hv{initialize(){this.setModel(),ul.chatboxviews.add("controlbox",this),this.model.get("connected")&&void 0===this.model.get("closed")&&this.model.set("closed",!bu.settings.get("show_controlbox_by_default")),this.requestUpdate(),bu.trigger("controlBoxInitialized",this)}setModel(){this.model=ul.chatboxes.get("controlbox"),this.listenTo(ul.connfeedback,"change:connection_status",(()=>this.requestUpdate())),this.listenTo(this.model,"change:active-form",(()=>this.requestUpdate())),this.listenTo(this.model,"change:connected",(()=>this.requestUpdate())),this.listenTo(this.model,"change:closed",(()=>!this.model.get("closed")&&this.afterShown())),this.requestUpdate()}render(){return this.model?sS(this):""}close(e){var t;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),("closeAllChatBoxes"!==(null==e?void 0:e.name)||ul.disconnection_cause===ul.LOGOUT&&!bu.settings.get("show_controlbox_by_default"))&&!bu.settings.get("sticky_controlbox"))return iS.safeSave(this.model,{closed:!0}),bu.trigger("controlBoxClosed",this),this}afterShown(){return bu.trigger("controlBoxOpened",this),this}}bu.elements.define("converse-controlbox",oS);const rS=oS,{u:aS}=Su.env,cS={controlbox:{async open(){await bu.waitUntil("chatBoxesFetched");const e=await bu.chatboxes.get("controlbox")||bu.chatboxes.create("controlbox",{},ul.Controlbox);return aS.safeSave(e,{closed:!1}),e},get:()=>ul.chatboxviews.get("controlbox")}};var lS=n(1875),dS={};dS.styleTagTransform=Av(),dS.setAttributes=wv(),dS.insert=yv().bind(null,"head"),dS.domAPI=vv(),dS.insertStyleElement=xv();fv()(lS.Z,dS);lS.Z&&lS.Z.locals&&lS.Z.locals;Su.plugins.add("converse-controlbox",{dependencies:["converse-modal","converse-chatboxes","converse-chat","converse-rosterview","converse-chatview"],enabled:e=>!e.api.settings.get("singleton"),overrides:{ChatBoxes:{model(e,t){return e&&"controlbox"==e.id?new Xw(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){bu.settings.extend({allow_logout:!0,allow_user_trust_override:!0,default_domain:void 0,locked_domain:void 0,show_connection_url_input:!1,show_controlbox_by_default:!1,sticky_controlbox:!1}),bu.promises.add("controlBoxInitialized"),Object.assign(bu,cS),ul.ControlBoxView=rS,ul.ControlBox=Xw,ul.ControlBoxToggle=tS,bu.listen.on("chatBoxesFetched",Vw),bu.listen.on("clearSession",Ww),bu.listen.on("will-reconnect",Gw),bu.waitUntil("chatBoxViewsInitialized").then(qw).catch((e=>z.fatal(e)))}});const{u:uS}=Su.env;function hS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!bu.settings.get("allow_dragresize"))return!0;e.preventDefault();const n=uS.ancestor(e.target,".box-flyout"),s=window.getComputedStyle(n),i=n.parentElement;i.height=parseInt(s.height.replace(/px$/,""),10),ul.resizing={chatbox:i,direction:"top"},i.prev_pageY=e.pageY,t&&bu.trigger("startVerticalResize",i)}function mS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!bu.settings.get("allow_dragresize"))return!0;e.preventDefault();const n=uS.ancestor(e.target,".box-flyout"),s=window.getComputedStyle(n),i=n.parentElement;i.width=parseInt(s.width.replace(/px$/,""),10),ul.resizing={chatbox:i,direction:"left"},i.prev_pageX=e.pageX,t&&bu.trigger("startHorizontalResize",i)}function gS(e){mS(e,!1),hS(e,!1),ul.resizing.direction="topleft",bu.trigger("startDiagonalResize",this)}function fS(e,t){if(void 0===e)return;if(void 0===t)return e;return e!==t&&Math.abs(e-t)<10?t:e}function pS(e){if(!ul.resizing||!bu.settings.get("allow_dragresize"))return!0;e.preventDefault(),ul.resizing.chatbox.resizeChatBox(e)}function vS(e){if(!ul.resizing||!bu.settings.get("allow_dragresize"))return!0;e.preventDefault();const t=fS(ul.resizing.chatbox.height,ul.resizing.chatbox.model.get("default_height")),n=fS(ul.resizing.chatbox.width,ul.resizing.chatbox.model.get("default_width"));bu.connection.connected()?(ul.resizing.chatbox.model.save({height:t}),ul.resizing.chatbox.model.save({width:n})):(ul.resizing.chatbox.model.set({height:t}),ul.resizing.chatbox.model.set({width:n})),ul.resizing=null}const _S=()=>Kd`
    `;customElements.define("converse-dragresize",class extends hv{render(){return _S()}});const yS={initDragResize(){var e;const t=this,n=jc((()=>t.setDimensions()));window.addEventListener("resize",t.debouncedSetDimensions),this.listenTo(this.model,"destroy",(()=>window.removeEventListener("resize",n)));const s=this.querySelector(".box-flyout"),i=window.getComputedStyle(s);if(void 0===this.model.get("height")){const e=parseInt(i.height.replace(/px$/,""),10),t=parseInt(i.width.replace(/px$/,""),10);this.model.set("height",e),this.model.set("default_height",e),this.model.set("width",t),this.model.set("default_width",t)}const o=i["min-width"],r=i["min-height"];return this.model.set("min_width",o.endsWith("px")?Number(o.replace(/px$/,"")):0),this.model.set("min_height",r.endsWith("px")?Number(r.replace(/px$/,"")):0),this.prev_pageY=0,this.prev_pageX=0,null!==(e=ul.connection)&&void 0!==e&&e.connected&&(this.height=this.model.get("height"),this.width=this.model.get("width")),this},resizeChatBox(e){let t;0===ul.resizing.direction.indexOf("top")&&(t=e.pageY-this.prev_pageY,t&&(this.height=this.height-t>(this.model.get("min_height")||0)?this.height-t:this.model.get("min_height"),this.prev_pageY=e.pageY,this.setChatBoxHeight(this.height))),ul.resizing.direction.includes("left")&&(t=this.prev_pageX-e.pageX,t&&(this.width=this.width+t>(this.model.get("min_width")||0)?this.width+t:this.model.get("min_width"),this.prev_pageX=e.pageX,this.setChatBoxWidth(this.width)))},setDimensions(){this.adjustToViewport(),this.setChatBoxHeight(this.model.get("height")),this.setChatBoxWidth(this.model.get("width"))},setChatBoxHeight(e){e=e?fS(e,this.model.get("default_height"))+"px":"";const t=this.querySelector(".box-flyout");null!==t&&(t.style.height=e)},setChatBoxWidth(e){e=e?fS(e,this.model.get("default_width"))+"px":"",this.style.width=e;const t=this.querySelector(".box-flyout");null!==t&&(t.style.width=e)},adjustToViewport(){const e=Math.max(document.documentElement.clientWidth,window.innerWidth||0),t=Math.max(document.documentElement.clientHeight,window.innerHeight||0);e<=480?(this.model.set("height",void 0),this.model.set("width",void 0)):e<=this.model.get("width")?this.model.set("width",void 0):t<=this.model.get("height")&&this.model.set("height",void 0)}};Su.plugins.add("converse-dragresize",{dependencies:["converse-chatview","converse-headlines-view","converse-muc-views"],enabled:e=>"overlayed"==e.api.settings.get("view_mode"),overrides:{ChatBox:{initialize(){const e=this.__super__.initialize.apply(this,arguments),t=this.get("height"),n=this.get("width"),s="controlbox"===this.get("id")?e=>this.set(e):e=>this.save(e);return s({height:fS(t,this.get("default_height")),width:fS(n,this.get("default_width"))}),e}}},initialize(){bu.settings.extend({allow_dragresize:!0}),Object.assign(ul.ChatBoxView.prototype,yS),Object.assign(ul.ChatRoomView.prototype,yS),ul.ControlBoxView&&Object.assign(ul.ControlBoxView.prototype,yS),bu.listen.on("registeredGlobalEventHandlers",(function(){document.addEventListener("mousemove",pS),document.addEventListener("mouseup",vS)})),bu.listen.on("unregisteredGlobalEventHandlers",(function(){document.removeEventListener("mousemove",pS),document.removeEventListener("mouseup",vS)})),bu.listen.on("beforeShowingChatView",(e=>e.initDragResize().setDimensions()))}});var bS=n(1833),wS={};wS.styleTagTransform=Av(),wS.setAttributes=wv(),wS.insert=yv().bind(null,"head"),wS.domAPI=vv(),wS.insertStyleElement=xv();fv()(bS.Z,wS);bS.Z&&bS.Z.locals&&bS.Z.locals;Su.plugins.add("converse-singleton",{enabled:e=>e.api.settings.get("singleton"),initialize(){bu.settings.extend({allow_logout:!1,allow_muc_invitations:!1,hide_muc_server:!0});const e=bu.settings.get("auto_join_rooms"),t=bu.settings.get("auto_join_private_chats");if(!Array.isArray(e)&&!Array.isArray(t))throw new Error("converse-singleton: auto_join_rooms must be an Array");if(0===e.length&&0===t.length)throw new Error("If you set singleton set to true, you need to specify auto_join_rooms or auto_join_private_chats");if(e.length>0&&t.length>0)throw new Error("It doesn't make sense to have singleton set to true and auto_join_rooms or auto_join_private_chats set to more then one, since only one chat room may be open at any time.")}});var SS=n(2791),xS={};xS.styleTagTransform=Av(),xS.setAttributes=wv(),xS.insert=yv().bind(null,"head"),xS.domAPI=vv(),xS.insertStyleElement=xv();fv()(SS.Z,xS);SS.Z&&SS.Z.locals&&SS.Z.locals;Su.plugins.add("converse-fullscreen",{enabled:()=>Hc(),initialize(){bu.settings.extend({chatview_avatar_height:50,chatview_avatar_width:50,hide_open_bookmarks:!0,show_controlbox_by_default:!0,sticky_controlbox:!0})}});bu.elements.define("converse-headlines-heading",class extends Ew{async connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.render()}async render(){const e=await this.generateHeadingTemplate();tu(e,this)}async generateHeadingTemplate(){const e=await this.getHeadingButtons(),t=e.filter((e=>e.standalone)),n=e.filter((e=>!e.standalone));return(e=>Kd`
    ${ul.api.settings.get("singleton")?"":Kd``}
    ${e.display_name}
    ${e.dropdown_btns.length?Kd``:""} ${e.standalone_btns.length?(e=>e.standalone_btns.reverse().map((e=>__(e,""))))(e):""}
    ${e.status?Kd`

    ${e.status}

    `:""} `)(Object.assign(this.model.toJSON(),{display_name:this.model.getDisplayName(),dropdown_btns:n.map((e=>fw(e))),standalone_btns:t.map((e=>pw(e)))}))}getHeadingButtons(){const e=[];return bu.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:dv("Close"),i18n_title:dv("Close these announcements"),icon_class:"fa-times",name:"close",standalone:"overlayed"===bu.settings.get("view_mode")}),ul.api.hook("getHeadingButtons",this,e)}close(e){e.preventDefault(),this.model.close()}});bu.elements.define("converse-headlines",class extends $w{async initialize(){ul.chatboxviews.add(this.jid,this),this.model=ul.chatboxes.get(this.jid),this.model.disable_mam=!0,this.listenTo(ul,"windowStateChanged",this.onWindowStateChanged),this.listenTo(this.model,"change:hidden",(()=>this.afterShown())),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model.messages,"add",this.requestUpdate),this.listenTo(this.model.messages,"remove",this.requestUpdate),this.listenTo(this.model.messages,"reset",this.requestUpdate),await this.model.messages.fetched,this.model.maybeShow(),bu.trigger("headlinesBoxViewInitialized",this)}render(){return(e=>Kd`
    ${e?Kd`
    `:""}
    `)(this.model)}async close(e){var t;return null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),ul.router.history.getFragment()==="converse/chat?jid="+this.model.get("jid")&&ul.router.navigate(""),await this.model.close(e),this}getNotifications(){return[]}afterShown(){this.model.clearUnreadMsgCounter()}});const ES=e=>Kd`
    ${e.headlineboxes.map((t=>(e=>Kd` `)(Object.assign({headlinebox:t},e))))}
    `;class AS extends Ew{constructor(){super(...arguments),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"events",{"click .open-headline":"openHeadline"})}initialize(){this.model=ul.chatboxes,this.listenTo(this.model,"add",this.renderIfHeadline),this.listenTo(this.model,"remove",this.renderIfHeadline),this.listenTo(this.model,"destroy",this.renderIfHeadline),this.render()}toHTML(){return(e=>Kd`
    ${e.heading_headline}
    ${ES(e)} `)({heading_headline:dv("Announcements"),headlineboxes:this.model.filter((e=>e.get("type")===ul.HEADLINES_TYPE)),open_title:dv("Click to open this server message")})}renderIfHeadline(e){return e&&e.get("type")===ul.HEADLINES_TYPE&&this.render()}openHeadline(e){e.preventDefault();const t=e.target.getAttribute("data-headline-jid");ul.chatboxes.get(t).maybeShow(!0)}}bu.elements.define("converse-headlines-panel",AS);var CS=n(5956),kS={};kS.styleTagTransform=Av(),kS.setAttributes=wv(),kS.insert=yv().bind(null,"head"),kS.domAPI=vv(),kS.insertStyleElement=xv();fv()(CS.Z,kS);CS.Z&&CS.Z.locals&&CS.Z.locals;Su.plugins.add("converse-headlines-view",{dependencies:["converse-headlines","converse-chatview"],initialize(){ul.HeadlinesPanel=AS}});var jS=n(9679),TS={};TS.styleTagTransform=Av(),TS.setAttributes=wv(),TS.insert=yv().bind(null,"head"),TS.domAPI=vv(),TS.insertStyleElement=xv();fv()(jS.Z,TS);jS.Z&&jS.Z.locals&&jS.Z.locals;function $S(e,t){return e instanceof zg?Kd``:t}async function NS(e){if(!e.model.ui.get("chat-content-spinner-top")&&e.model.messages.length){const t=e.model.get("type")===ul.CHATROOMS_TYPE,n=e.model.getOldestMessage();if(n){const s=t?e.model.get("jid"):ul.bare_jid,i=n&&n.get(`stanza_id ${s}`);e.model.ui.set("chat-content-spinner-top",!0);try{i?await lf(e.model,{before:i}):await lf(e.model,{end:n.get("time")})}catch(t){return z.error(t),void e.model.ui.set("chat-content-spinner-top",!1)}bu.settings.get("allow_url_history_change")&&ul.router.history.navigate(`#${n.get("msgid")}`),setTimeout((()=>e.model.ui.set("chat-content-spinner-top",!1)),250)}}}bu.elements.define("converse-mam-placeholder",class extends hv{static get properties(){return{model:{type:Object}}}render(){return(e=this).model.get("fetching")?Jb({classes:"hor_centered"}):Kd`
    `;var e}async fetchMissingMessages(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.set("fetching",!0);const n={before:this.model.get("before"),start:this.model.get("start")};await lf(this.model.collection.chatbox,n),this.model.destroy()}}),Su.plugins.add("converse-mam-views",{dependencies:["converse-mam","converse-chatview","converse-muc-views"],initialize(){bu.listen.on("chatBoxScrolledUp",NS),bu.listen.on("getMessageTemplate",$S)}});const OS=Ac.extend({defaults:{collapsed:!1}});bu.elements.define("converse-minimized-chats",class extends hv{async initialize(){this.model=ul.chatboxes,await this.initToggle(),this.listenTo(this.minchats,"change:collapsed",this.requestUpdate),this.listenTo(this.model,"add",this.requestUpdate),this.listenTo(this.model,"change:fullname",this.requestUpdate),this.listenTo(this.model,"change:jid",this.requestUpdate),this.listenTo(this.model,"change:minimized",this.requestUpdate),this.listenTo(this.model,"change:name",this.requestUpdate),this.listenTo(this.model,"change:num_unread",this.requestUpdate),this.listenTo(this.model,"remove",this.requestUpdate),this.listenTo(ul,"connected",this.requestUpdate),this.listenTo(ul,"reconnected",this.requestUpdate),this.listenTo(ul,"disconnected",this.requestUpdate)}render(){const e=this.model.where({minimized:!0}),t=e.reduce(((e,t)=>e+t.get("num_unread")),0),n=e.reduce(((e,t)=>e+(t.get("minimized")?1:0)),0),s={chats:e,num_unread:t,num_minimized:n,collapsed:this.minchats.get("collapsed")};return s.toggle=e=>this.toggle(e),(e=>Kd``)(s)}async initToggle(){const e=`converse.minchatstoggle-${ul.bare_jid}`;this.minchats=new OS({id:e}),La(this.minchats,e,"session"),await new Promise((e=>this.minchats.fetch({success:e,error:e})))}toggle(e){null==e||e.preventDefault(),this.minchats.save({collapsed:!this.minchats.get("collapsed")})}});const{dayjs:IS,u:MS}=Su.env;function RS(e){if("controlbox"===e.model.get("id")){if(MS.isVisible(e))return MS.getOuterWidth(e,!0);{const e=document.querySelector("converse-controlbox-toggle");return e?MS.getOuterWidth(e,!0):0}}return!e.model.get("minimized")&&MS.isVisible(e)?MS.getOuterWidth(e,!0):0}function DS(){const e=document.querySelector("converse-minimized-chats");return ul.chatboxes.pluck("minimized").includes(!0)?MS.getOuterWidth(e,!0):0}function zS(e){const t=e?e.model.get("id"):null,n=e?MS.getOuterWidth(e,!0):0;return Object.values(ul.chatboxviews.xget(t)).reduce(((e,t)=>e+RS(t)),n)}function LS(e){if(ul.isTestEnv()||bu.settings.get("no_trimming")||"overlayed"!==bu.settings.get("view_mode"))return;const t=ul.chatboxviews.filter((e=>!e.model.get("minimized")&&!e.model.get("closed")&&MS.isVisible(e)));if(t.length<=1)return;const n=MS.getOuterWidth(document.querySelector("body"),!0);if(RS(t[0])===n)return;if(document.querySelector("converse-minimized-chats"))for(;DS()+zS(e)>n;){const t=PS([e?e.model.get("id"):null]);if(!t)break;{const e=ul.chatboxes.get(t.get("id"));null==e||e.save("hidden",!0),US(t)}}}function PS(e){e.push("controlbox");let t=0,n=ul.chatboxes.sort().at(t);for(;e.includes(n.get("id"))||!0===n.get("minimized");)if(t++,n=ul.chatboxes.at(t),!n)return null;return n}function FS(e,t){null!=e&&e.preventDefault?e.preventDefault():t=e,MS.safeSave(t,{hidden:!1,minimized:!1,time_opened:(new Date).getTime()})}function US(e,t){null!=e&&e.preventDefault?e.preventDefault():t=e,t.setChatState(ul.INACTIVE),MS.safeSave(t,{hidden:!0,minimized:!0,time_minimized:(new Date).toISOString()})}function BS(e){e.get("minimized")?function(e){bu.trigger("chatBoxMinimized",e)}(e):function(e){e.isScrolledUp()||e.clearUnreadMsgCounter(),e.setChatState(ul.ACTIVE),bu.trigger("chatBoxMaximized",e)}(e)}bu.elements.define("converse-minimized-chat",class extends hv{static get properties(){return{model:{type:Object},title:{type:String},type:{type:String},num_unread:{type:Number}}}render(){return(e=>{const t=dv("Click to restore this chat"),n="chatroom"===e.type?"var(--chatroom-head-color)":"var(--chat-head-text-color)";return Kd` `})({close:e=>this.close(e),num_unread:this.num_unread,restore:e=>this.restore(e),title:this.title,type:this.type})}close(e){null==e||e.preventDefault(),this.model.close()}restore(e){null==e||e.preventDefault(),FS(this.model)}});var qS=n(4915),HS={};HS.styleTagTransform=Av(),HS.setAttributes=wv(),HS.insert=yv().bind(null,"head"),HS.domAPI=vv(),HS.insertStyleElement=xv();fv()(qS.Z,HS);qS.Z&&qS.Z.locals&&qS.Z.locals;Su.plugins.add("converse-minimize",{dependencies:["converse-chatview","converse-controlbox","converse-muc-views","converse-headlines-view","converse-dragresize"],enabled:e=>"overlayed"===e.api.settings.get("view_mode"),overrides:{ChatBox:{maybeShow(e){return!e&&this.get("minimized")?this:this.__super__.maybeShow.apply(this,arguments)},isHidden(){return this.__super__.isHidden.call(this)||this.get("minimized")}},ChatBoxView:{isNewMessageHidden(){return this.model.get("minimized")||this.__super__.isNewMessageHidden.apply(this,arguments)},setChatBoxHeight(e){if(!this.model.get("minimized"))return this.__super__.setChatBoxHeight.call(this,e)},setChatBoxWidth(e){if(!this.model.get("minimized"))return this.__super__.setChatBoxWidth.call(this,e)}}},initialize(){function e(e){!function(e){e.on("change:hidden",(t=>!t.get("hidden")&&FS(e)),e),"controlbox"!==e.get("id")&&e.save({minimized:e.get("minimized")||!1,time_minimized:e.get("time_minimized")||IS()})}(e),e.on("change:minimized",(()=>BS(e)))}bu.settings.extend({no_trimming:!1}),bu.promises.add("minimizedChatsInitialized"),ul.MinimizedChatsToggle=OS,ul.minimize={trimChats:LS,minimize:US,maximize:FS},bu.listen.on("chatBoxViewInitialized",(e=>ul.minimize.trimChats(e))),bu.listen.on("chatRoomViewInitialized",(e=>ul.minimize.trimChats(e))),bu.listen.on("controlBoxOpened",(e=>ul.minimize.trimChats(e))),bu.listen.on("chatBoxInitialized",e),bu.listen.on("chatRoomInitialized",e),bu.listen.on("getHeadingButtons",((e,t)=>e.model.get("type")===ul.CHATROOMS_TYPE?function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>US(t,e.model),i18n_text:dv("Minimize"),i18n_title:dv("Minimize this groupchat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===ul.api.settings.get("view_mode")},s=t.map((e=>e.name)).indexOf("signout");return s>-1?[...t.slice(0,s),n,...t.slice(s)]:[n,...t]}(e,t):function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>US(t,e.model),i18n_text:dv("Minimize"),i18n_title:dv("Minimize this chat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===ul.api.settings.get("view_mode")},s=t.map((e=>e.name)).indexOf("close");return s>-1?[...t.slice(0,s),n,...t.slice(s)]:[n,...t]}(e,t)));const t=jc((()=>ul.minimize.trimChats()),250);bu.listen.on("registeredGlobalEventHandlers",(()=>window.addEventListener("resize",t))),bu.listen.on("unregisteredGlobalEventHandlers",(()=>window.removeEventListener("resize",t)))}});const GS=Su.env.utils,WS={getElement:(e,t)=>"string"==typeof e?(t||document).querySelector(e):e||null,bind(e,t){if(e)for(var n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];n.split(/\s+/).forEach((t=>e.addEventListener(t,s)))}},unbind(e,t){if(e)for(var n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];n.split(/\s+/).forEach((t=>e.removeEventListener(t,s)))}},regExpEscape:e=>e.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&"),isMention:(e,t)=>t.includes(e[0])||GS.isMentionBoundary(e[0])&&t.includes(e[1])},VS=function(e,t){return RegExp(WS.regExpEscape(t.trim()),"i").test(e)},JS=function(e,t){return RegExp("^"+WS.regExpEscape(t.trim()),"i").test(e)},QS=function(e,t){const n=e.query.toLowerCase(),s=e.label.toLowerCase().indexOf(n),i=t.label.toLowerCase().indexOf(n);return s===i?function(e,t){return e.length!==t.length?e.length-t.length:e{t=t.trim();const n=document.createElement("li");n.setAttribute("aria-selected","false");const s=new RegExp("("+t+")","ig");return(t?e.split(s):[e]).forEach((e=>{if(t&&e.match(s)){const t=document.createElement("mark");t.textContent=e,n.appendChild(t)}else n.appendChild(document.createTextNode(e))})),n};const KS=class extends String{constructor(e,t){super();const n=Array.isArray(e)?{label:e[0],value:e[1]}:"object"==typeof e&&"label"in e&&"value"in e?e:{label:e,value:e};this.label=n.label||n.value,this.value=n.value,this.query=t}get lenth(){return this.label.length}toString(){return""+this.label}valueOf(){return this.toString()}},YS=Su.env.utils;class XS{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.suggestions=[],this.is_opened=!1,YS.hasClass("suggestion-box",e)?this.container=e:this.container=e.querySelector(".suggestion-box"),this.input=this.container.querySelector(".suggestion-box__input"),this.input.setAttribute("aria-autocomplete","list"),this.ul=this.container.querySelector(".suggestion-box__results"),this.status=this.container.querySelector(".suggestion-box__additions"),Object.assign(this,{match_current_word:!1,ac_triggers:[],include_triggers:[],min_chars:2,max_items:10,auto_evaluate:!0,auto_first:!1,data:e=>e,filter:VS,sort:!1!==t.sort&&QS,item:ZS},t),this.index=-1,this.bindEvents(),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||t.list||[]}bindEvents(){const e={blur:()=>this.close({reason:"blur"})};this.auto_evaluate&&(e.input=()=>this.evaluate()),this._events={input:e,form:{submit:()=>this.close({reason:"submit"})},ul:{mousedown:e=>this.onMouseDown(e),mouseover:e=>this.onMouseOver(e)}},WS.bind(this.input,this._events.input),WS.bind(this.input.form,this._events.form),WS.bind(this.ul,this._events.ul)}set list(e){if(Array.isArray(e)||"function"==typeof e)this._list=e;else if("string"==typeof e&&e.includes(","))this._list=e.split(/\s*,\s*/);else{var t;const n=(null===(t=WS.getElement(e))||void 0===t?void 0:t.children)||[];this._list=Array.from(n).filter((e=>!e.disabled)).map((e=>{const t=e.textContent.trim(),n=e.value||t,s=e.label||t;return""!==n?{label:s,value:n}:null})).filter((e=>e))}document.activeElement===this.input&&this.evaluate()}get list(){return this._list}get selected(){return this.index>-1}get opened(){return this.is_opened}close(e){this.opened&&(this.ul.setAttribute("hidden",""),this.is_opened=!1,this.index=-1,this.trigger("suggestion-box-close",e||{}))}insertValue(e){this.match_current_word?YS.replaceCurrentWord(this.input,e.value):this.input.value=e.value}open(){this.ul.removeAttribute("hidden"),this.is_opened=!0,this.auto_first&&-1===this.index&&this.goto(0),this.trigger("suggestion-box-open")}destroy(){WS.unbind(this.input,this._events.input),WS.unbind(this.input.form,this._events.form),this.input.removeAttribute("aria-autocomplete")}next(){const e=this.ul.children.length;this.goto(this.index-1&&t.length>0&&(t[e].setAttribute("aria-selected","true"),t[e].focus(),this.status.textContent=t[e].textContent,this.ul.scrollTop=t[e].offsetTop-this.ul.clientHeight+t[e].clientHeight,this.trigger("suggestion-box-highlight",{text:this.suggestions[this.index]}))}select(e){if(e?this.index=YS.siblingIndex(e):e=this.ul.children[this.index],e){const e=this.suggestions[this.index];this.insertValue(e),this.close({reason:"select"}),this.auto_completing=!1,this.trigger("suggestion-box-selectcomplete",{text:e})}}onMouseOver(e){const t=YS.ancestor(e.target,"li");t&&this.goto(Array.prototype.slice.call(this.ul.children).indexOf(t))}onMouseDown(e){if(0!==e.button)return;const t=YS.ancestor(e.target,"li");t&&(e.preventDefault(),this.select(t,e.target))}onKeyDown(e){if(this.opened){if([Su.keycodes.ENTER,Su.keycodes.TAB].includes(e.keyCode)&&this.selected)return e.preventDefault(),e.stopPropagation(),this.select(),!0;if(e.keyCode===Su.keycodes.ESCAPE)return this.close({reason:"esc"}),!0;if([Su.keycodes.UP_ARROW,Su.keycodes.DOWN_ARROW].includes(e.keyCode))return e.preventDefault(),e.stopPropagation(),this[e.keyCode===Su.keycodes.UP_ARROW?"previous":"next"](),!0}if(![Su.keycodes.SHIFT,Su.keycodes.META,Su.keycodes.META_RIGHT,Su.keycodes.ESCAPE,Su.keycodes.ALT].includes(e.keyCode))if(this.ac_triggers.includes(e.key))"Tab"===e.key&&e.preventDefault(),this.auto_completing=!0;else if("Backspace"===e.key){const t=YS.getCurrentWord(e.target,e.target.selectionEnd-1);WS.isMention(t,this.ac_triggers)&&(this.auto_completing=!0)}}async evaluate(e){const t=this.selected&&e&&(e.keyCode===Su.keycodes.UP_ARROW||e.keyCode===Su.keycodes.DOWN_ARROW);if(!this.auto_evaluate&&!this.auto_completing||t)return;const n="function"==typeof this._list?await this._list():this._list;if(0===n.length)return;let s=this.match_current_word?YS.getCurrentWord(this.input):this.input.value;const i=WS.isMention(s,this.ac_triggers);i&&(this.auto_completing=!0,this.include_triggers.includes(e.key)||(s=YS.isMentionBoundary(s[0])?s.slice("2"):s.slice("1"))),(i||s.length)&&s.length>=this.min_chars?(this.index=-1,this.ul.innerHTML="",this.suggestions=n.map((e=>new KS(this.data(e,s),s))).filter((e=>this.filter(e,s))),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.max_items),this.suggestions.forEach((e=>this.ul.appendChild(this.item(e,s)))),0===this.ul.children.length?this.close({reason:"nomatches"}):this.open()):(this.close({reason:"nomatches"}),i||(this.auto_completing=!1))}}Object.assign(XS.prototype,vi);const ex=XS;bu.elements.define("converse-autocomplete",class extends hv{static get properties(){return{getAutoCompleteList:{type:Function},auto_evaluate:{type:Boolean},auto_first:{type:Boolean},filter:{type:String},include_triggers:{type:String},min_chars:{type:Number},name:{type:String},placeholder:{type:String},triggers:{type:String}}}constructor(){super(),this.auto_evaluate=!0,this.auto_first=!1,this.filter="contains",this.include_triggers="",this.match_current_word=!1,this.max_items=10,this.min_chars=1,this.triggers=""}render(){return Kd`
    `}firstUpdated(){this.auto_complete=new ex(this.firstElementChild,{ac_triggers:this.triggers.split(" "),auto_evaluate:this.auto_evaluate,auto_first:this.auto_first,filter:"contains"==this.filter?VS:JS,include_triggers:[],list:()=>this.getAutoCompleteList(),match_current_word:!0,max_items:this.max_items,min_chars:this.min_chars}),this.auto_complete.on("suggestion-box-selectcomplete",(()=>this.auto_completing=!1))}onKeyDown(e){this.auto_complete.onKeyDown(e)}onKeyUp(e){this.auto_complete.evaluate(e)}});var tx=n(4921),nx={};nx.styleTagTransform=Av(),nx.setAttributes=wv(),nx.insert=yv().bind(null,"head"),nx.domAPI=vv(),nx.insertStyleElement=xv();fv()(tx.Z,nx);tx.Z&&tx.Z.locals&&tx.Z.locals;ul.FILTER_CONTAINS=VS,ul.FILTER_STARTSWITH=JS,ul.AutoComplete=ex;const sx=(e,t)=>Kd`
  • ${t.node===e.showform?((e,t)=>{const n=dv("Hide"),s=dv("Execute");return Kd`
    ${t.alert?Kd``:""}

    ${t.instructions}

    ${t.fields}
    `})(e,t):""}
  • `;function ix(e){return"moderator"===e?dv("Moderators are privileged users who can change the roles of other users (except those with admin or owner affiliations."):"participant"===e?dv("The default role, implies that you can read and write messages."):"visitor"==e?dv("Visitors aren't allowed to write messages in a moderated multi-user chat."):void 0}function ox(e){return"owner"===e?dv("Owner is the highest affiliation. Owners can modify roles and affiliations of all other users."):"admin"===e?dv("Admin is the 2nd highest affiliation. Admins can modify roles and affiliations of all other users except owners."):"outcast"===e?dv('To ban a user, you give them the affiliation of "outcast".'):void 0}const rx=e=>Kd`
    • JID: ${e.item.jid}
    • Nickname: ${e.item.nick}
    • Role: ${e.item.role} ${e.assignable_roles.length?(e=>Kd` `)(e):""}
      ${e.assignable_roles.length?(e=>{const t=dv("Change role"),n=dv("New Role"),s=dv("Reason");return Kd` `})(e):""}
  • `,ax=e=>Kd`
    • JID: ${e.item.jid}
    • Nickname: ${e.item.nick}
    • Affiliation: ${e.item.affiliation} ${e.assignable_affiliations.length?(e=>Kd` `)(e):""}
      ${e.assignable_affiliations.length?(e=>{const t=dv("Change affiliation"),n=dv("New affiliation"),s=dv("Reason");return Kd` `})(e):""}
  • `,cx=e=>{const t=dv("Affiliation"),n=dv("No users with that affiliation found."),s=dv("No users with that role found."),i=dv("Type here to filter the search results"),o=dv("Role"),r=dv("Show users"),a=dv("Roles are assigned to users to grant or deny them certain abilities in a multi-user chat. They're assigned either explicitly or implicitly as part of an affiliation. A role that's not due to an affiliation, is only valid for the duration of the user's session."),c=dv("An affiliation is a long-lived entitlement which typically implies a certain role and which grants privileges and responsibilities. For example admins and owners automatically have the moderator role."),l=e.queryable_roles.length&&e.queryable_affiliations.length;return Kd` ${e.alert_message?Kd``:""} ${l?Kd` `:""}
    ${e.queryable_affiliations.length?Kd`

    ${c}

    ${Array.isArray(e.users_with_affiliation)&&e.users_with_affiliation.length>5?Kd``:""}
    ${ox(e.affiliation)?Kd`

    ${ox(e.affiliation)}

    `:""}
      ${e.loading_users_with_affiliation?Kd`
    • ${Jb()}
    • `:""} ${Array.isArray(e.users_with_affiliation)&&0===e.users_with_affiliation.length?Kd`
    • ${n}
    • `:""} ${e.users_with_affiliation instanceof Error?Kd`
    • ${e.users_with_affiliation.message}
    • `:(e.users_with_affiliation||[]).map((t=>(t.nick||t.jid).match(new RegExp(e.affiliations_filter,"i"))?ax(Object.assign({item:t},e)):""))}
    `:""} ${e.queryable_roles.length?Kd`

    ${a}

    ${Array.isArray(e.users_with_role)&&e.users_with_role.length>5?Kd``:""}
    ${ix(e.role)?Kd`

    ${ix(e.role)}

    `:""}
      ${e.loading_users_with_role?Kd`
    • ${Jb()}
    • `:""} ${e.users_with_role&&0===e.users_with_role.length?Kd`
    • ${s}
    • `:""} ${(e.users_with_role||[]).map((t=>t.nick.match(e.roles_filter)?rx(Object.assign({item:t},e)):""))}
    `:""}
    `},{Strophe:lx,sizzle:dx,u:ux}=Su.env;bu.elements.define("converse-modtools",class extends hv{static get properties(){return{affiliation:{type:String},affiliations_filter:{type:String,attribute:!1},alert_message:{type:String,attribute:!1},alert_type:{type:String,attribute:!1},jid:{type:String},muc:{type:Object,attribute:!1},role:{type:String},roles_filter:{type:String,attribute:!1},users_with_affiliation:{type:Array,attribute:!1},users_with_role:{type:Array,attribute:!1}}}constructor(){super(),this.affiliation="",this.affiliations_filter="",this.role="",this.roles_filter=""}updated(e){e.has("role")&&this.onSearchRoleChange(),e.has("affiliation")&&this.onSearchAffiliationChange(),e.has("jid")&&e.get("jid")&&this.initialize()}async initialize(){this.initialized=ba();const e=await bu.rooms.get(this.jid);await e.initialized,this.muc=e,this.initialized.resolve()}render(){var e;if(null!==(e=this.muc)&&void 0!==e&&e.occupants){const e=this.muc.occupants.findWhere({jid:ul.bare_jid});return cx({affiliations_filter:this.affiliations_filter,alert_message:this.alert_message,alert_type:this.alert_type,assignAffiliation:e=>this.assignAffiliation(e),assignRole:e=>this.assignRole(e),assignable_affiliations:Em(e),assignable_roles:qm(e),filterAffiliationResults:e=>this.filterAffiliationResults(e),filterRoleResults:e=>this.filterRoleResults(e),loading_users_with_affiliation:this.loading_users_with_affiliation,queryAffiliation:e=>this.queryAffiliation(e),queryRole:e=>this.queryRole(e),queryable_affiliations:rg.filter((e=>!bu.settings.get("modtools_disable_query").includes(e))),queryable_roles:og.filter((e=>!bu.settings.get("modtools_disable_query").includes(e))),roles_filter:this.roles_filter,switchTab:e=>this.switchTab(e),toggleForm:e=>this.toggleForm(e),users_with_affiliation:this.users_with_affiliation,users_with_role:this.users_with_role})}return""}async onSearchAffiliationChange(){if(this.affiliation){if(await this.initialized,this.clearAlert(),this.loading_users_with_affiliation=!0,this.users_with_affiliation=null,this.shouldFetchAffiliationsList()){const e=await xm(this.affiliation,this.jid);e instanceof Error?(this.alert(e.message,"danger"),this.users_with_affiliation=[]):this.users_with_affiliation=e}else this.users_with_affiliation=this.muc.getOccupantsWithAffiliation(this.affiliation);this.loading_users_with_affiliation=!1}}async onSearchRoleChange(){this.role&&(await this.initialized,this.clearAlert(),this.users_with_role=this.muc.getOccupantsWithRole(this.role))}shouldFetchAffiliationsList(){const e=this.affiliation;if("none"===e)return!1;return!Bm().includes(e)}toggleForm(e){e.stopPropagation(),e.preventDefault();const t=ux.ancestor(e.target,".toggle-form"),n=t.getAttribute("data-form"),s=ux.ancestor(t,".list-group-item").querySelector(`.${n}`);ux.hasClass("hidden",s)?ux.removeClass("hidden",s):ux.addClass("hidden",s)}filterRoleResults(e){this.roles_filter=e.target.value,this.render()}filterAffiliationResults(e){this.affiliations_filter=e.target.value}queryRole(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target).get("role");this.role=null,this.role=t}queryAffiliation(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target).get("affiliation");this.affiliation=null,this.affiliation=t}alert(e,t){this.alert_message=e,this.alert_type=t}clearAlert(){this.alert_message=void 0,this.alert_type=void 0}async assignAffiliation(e){e.stopPropagation(),e.preventDefault(),this.clearAlert();const t=new FormData(e.target),n=t.get("affiliation"),s={jid:t.get("jid"),reason:t.get("reason")},i=this.affiliation,o=this.muc.get("jid");try{await Cm(n,o,[s])}catch(e){return null===e?this.alert(dv("Timeout error while trying to set the affiliation"),"danger"):dx(`not-allowed[xmlns="${lx.NS.STANZAS}"]`,e).length?this.alert(dv("Sorry, you're not allowed to make that change"),"danger"):this.alert(dv("Sorry, something went wrong while trying to set the affiliation"),"danger"),void z.error(e)}await this.muc.occupants.fetchMembers(),this.affiliation=null,this.affiliation=i,this.alert(dv("Affiliation changed"),"primary")}assignRole(e){e.stopPropagation(),e.preventDefault(),this.clearAlert();const t=new FormData(e.target),n=this.muc.getOccupant(t.get("jid")||t.get("nick")),s=t.get("role"),i=t.get("reason"),o=this.role;this.muc.setRole(n,s,i,(()=>{this.alert(dv("Role changed"),"primary"),this.role=null,this.role=o}),(e=>{dx(`not-allowed[xmlns="${lx.NS.STANZAS}"]`,e).length?this.alert(dv("You're not allowed to make that change"),"danger"):(this.alert(dv("Sorry, something went wrong while trying to set the role"),"danger"),ux.isErrorObject(e)&&z.error(e))}))}});const hx=Uv.extend({id:"converse-modtools-modal",persistent:!0,initialize(e){this.jid=e.jid,this.affiliation=e.affiliation,Uv.prototype.initialize.apply(this,arguments)},toHTML(){return(e=>{const t=dv("Moderator Tools");return Kd` `})(this)}}),mx=hx,{Strophe:gx,$iq:fx,sizzle:px,u:vx}=Su.env,_x={admin:"admin",ban:"outcast",member:"member",owner:"owner",revoke:"none"},yx={deop:"participant",kick:"none",mute:"visitor",op:"moderator",voice:"participant"};async function bx(e){const t=[dv("Are you sure you want to destroy this groupchat?")];let n=[{name:"challenge",label:dv("Please enter the XMPP address of this groupchat to confirm"),challenge:e.get("jid"),placeholder:dv("name@example.org"),required:!0},{name:"reason",label:dv("Optional reason for destroying this groupchat"),placeholder:dv("Reason")},{name:"newjid",label:dv("Optional XMPP address for a new groupchat that replaces this one"),placeholder:dv("replacement@example.org")}];try{var s,i;n=await bu.confirm(dv("Confirm"),t,n);const o=null===(s=n.filter((e=>"reason"===e.name)).pop())||void 0===s?void 0:s.value,r=null===(i=n.filter((e=>"newjid"===e.name)).pop())||void 0===i?void 0:i.value;return e.sendDestroyIQ(o,r).then((()=>e.close()))}catch(e){z.error(e)}}function wx(e){const t=e.model.session.get("view"),n=e.model.get("jid"),s=Su.ROOMSTATUS,i=e.model.session.get("connection_status");return t===Su.MUC.VIEWS.CONFIG?Kd``:Kd` ${i==s.PASSWORD_REQUIRED?Kd``:""} ${i==s.ENTERED?Kd``:""} ${i==s.CONNECTING?Jb():""} ${i==s.NICKNAME_REQUIRED?function(e){const t=e.get("jid");return bu.settings.get("muc_show_logs_before_join")?Kd``:Kd``}(e.model):""} ${i==s.DISCONNECTED?Kd``:""} ${i==s.BANNED?Kd``:""} ${i==s.DESTROYED?Kd``:""} `}function Sx(e,t){t=t.trim();const n=document.createElement("li");if(n.setAttribute("aria-selected","false"),bu.settings.get("muc_mention_autocomplete_show_avatar")){const t=document.createElement("img");let s="data:"+ul.DEFAULT_IMAGE_TYPE+";base64,"+ul.DEFAULT_IMAGE;if(ul.vcards){const t=ul.vcards.findWhere({nickname:e});t&&(s="data:"+t.get("image_type")+";base64,"+t.get("image"))}t.setAttribute("src",s),t.setAttribute("width","22"),t.setAttribute("class","avatar avatar-autocomplete"),n.appendChild(t)}const s=new RegExp("("+t+")","ig");return(t?e.split(s):[e]).forEach((e=>{if(t&&e.match(s)){const t=document.createElement("mark");t.textContent=e,n.appendChild(t)}else n.appendChild(document.createTextNode(e))})),n}async function xx(){const e=[...await bu.rooms.get(),...await bu.contacts.get()],t=[...new Set(e.map((e=>gx.getDomainFromJid(e.get("jid")))))];return t}function Ex(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];const o=yx[t];if(!o)throw Error(`ChatRoomView#setRole called with invalid command: ${t}`);if(!e.verifyAffiliations(s)||!e.verifyRoles(i))return!1;if(!e.validateRoleOrAffiliationChangeArgs(t,n))return!1;const r=e.getNickOrJIDFromCommandArgs(n);if(!r)return!1;const a=n.split(r,2)[1].trim(),c=e.getOccupant(r);return e.setRole(c,o,a,void 0,(t=>e.onCommandError(t))),!0}function Ax(e,t,n,s){const i=_x[t];if(!i)throw Error(`verifyAffiliations called with invalid command: ${t}`);if(!e.verifyAffiliations(s))return!1;if(!e.validateRoleOrAffiliationChangeArgs(t,n))return!1;const o=e.getNickOrJIDFromCommandArgs(n);if(!o)return!1;let r;const a=n.split(o,2)[1].trim(),c=e.getOccupant(o);if(c)r=c.get("jid");else{if(!vx.isValidJID(o)){const t=dv("Couldn't find a participant with that nickname. They might have left the groupchat.");return void e.createMessage({message:t,type:"error"})}r=o}const l={jid:r,reason:a};c&&bu.settings.get("auto_register_muc_nickname")&&(l.nick=c.get("nick")),Cm(i,e.get("jid"),[l]).then((()=>e.occupants.fetchMembers())).catch((t=>e.onCommandError(t)))}function Cx(e,t){if(!e.verifyRoles(["moderator"]))return;let n=bu.modal.get(mx.id);n?(n.affiliation=t,n.render()):n=bu.modal.create(mx,{affiliation:t,jid:e.get("jid")}),n.show()}function kx(e,t){const n=e.model;if(t||n.get("type")!==ul.CHATROOMS_TYPE||bu.settings.get("muc_disable_slash_commands")&&!Array.isArray(bu.settings.get("muc_disable_slash_commands")))return t;let s=e.text;s=s.replace(/^\s*/,"");const i=(s.match(/^\/([a-zA-Z]*) ?/)||[""]).pop().toLowerCase();if(!i)return!1;const o=s.slice(("/"+i).length+1).trim(),r=n.getAllowedCommands()??[];if("admin"===i&&r.includes(i))return Ax(n,i,o,["owner"]),!0;if("ban"===i&&r.includes(i))return Ax(n,i,o,["admin","owner"]),!0;if("modtools"===i&&r.includes(i))return Cx(n,o),!0;if("deop"===i&&r.includes(i))return Ex(n,i,o,["admin","owner"]),!0;if("destroy"===i&&r.includes(i))return!n.verifyAffiliations(["owner"])||(bx(n).catch((e=>n.onCommandError(e))),!0);if("help"===i&&r.includes(i))return n.set({show_help_messages:!1},{silent:!0}),n.set({show_help_messages:!0}),!0;if("kick"===i&&r.includes(i))return Ex(n,i,o,[],["moderator"]),!0;if("mute"===i&&r.includes(i))return Ex(n,i,o,[],["moderator"]),!0;if("member"===i&&r.includes(i))return Ax(n,i,o,["admin","owner"]),!0;if("nick"===i&&r.includes(i)){if(!n.verifyRoles(["visitor","participant","moderator"]))return!0;if(0===o.length){const e=dv('Your nickname is "%1$s"',n.get("nick"));n.createMessage({message:e,type:"error"})}else n.setNickname(o);return!0}return"owner"===i&&r.includes(i)?(Ax(n,i,o,["owner"]),!0):"op"===i&&r.includes(i)?(Ex(n,i,o,["admin","owner"]),!0):"register"===i&&r.includes(i)?(o.length>1?n.createMessage({message:dv("Error: invalid number of arguments"),type:"error"}):n.registerNickname().then((e=>{e&&n.createMessage({message:e,type:"error"})})),!0):"revoke"===i&&r.includes(i)?(Ax(n,i,o,["admin","owner"]),!0):"topic"===i&&r.includes(i)||"subject"===i&&r.includes(i)?(n.setSubject(o),!0):!("voice"!==i||!r.includes(i))&&(Ex(n,i,o,[],["moderator"]),!0)}const jx=e=>{const t=dv("On which entity do you want to run commands?"),n=dv("Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them."),s=dv("Commands found"),i=dv("List available commands"),o=dv("XMPP Address"),r=dv("No commands found");return Kd` ${e.alert?Kd``:""}
    ${"list-commands"===e.view?Kd`
    • ${e.commands.length?s:r}:
    • ${e.commands.map((t=>sx(e,t)))}
    `:""}
    `},{Strophe:Tx,$iq:$x,sizzle:Nx,u:Ox}=Su.env;bu.elements.define("converse-adhoc-commands",class extends hv{static get properties(){return{alert:{type:String},alert_type:{type:String},nonce:{type:String},showform:{type:String},view:{type:String}}}constructor(){super(),this.view="choose-service",this.showform="",this.commands=[]}render(){return jx({alert:this.alert,alert_type:this.alert_type,commands:this.commands,fetchCommands:e=>this.fetchCommands(e),hideCommandForm:e=>this.hideCommandForm(e),runCommand:e=>this.runCommand(e),showform:this.showform,toggleCommandForm:e=>this.toggleCommandForm(e),view:this.view})}async fetchCommands(e){e.preventDefault(),delete this.alert_type,delete this.alert;const t=new FormData(e.target).get("jid").trim();let n;try{n=await bu.disco.supports(Tx.NS.ADHOC,t)}catch(e){z.error(e)}if(n)try{this.commands=await bu.adhoc.getCommands(t),this.view="list-commands"}catch(e){return z.error(e),this.alert_type="danger",this.alert=dv("Sorry, an error occurred while looking for commands on that entity."),this.commands=[],void z.error(e)}else this.alert_type="danger",this.alert=dv("The specified entity doesn't support ad-hoc commands")}async toggleCommandForm(e){e.preventDefault();const t=e.target.getAttribute("data-command-node"),n=this.commands.filter((e=>e.node===t))[0];this.showform!==t&&await async function(e){const t=e.node,n=e.jid,s=fx({type:"set",to:n}).c("command",{xmlns:gx.NS.ADHOC,node:t,action:"execute"});try{var i;const t=await bu.sendIQ(s),n=px(`command[xmlns="${gx.NS.ADHOC}"]`,t).pop();e.sessionid=n.getAttribute("sessionid"),e.instructions=null===(i=px('x[type="form"][xmlns="jabber:x:data"] instructions',n).pop())||void 0===i?void 0:i.textContent,e.fields=px('x[type="form"][xmlns="jabber:x:data"] field',n).map((e=>vx.xForm2TemplateResult(e,n)))}catch(t){null===t?z.error(`Error: timeout while trying to execute command for ${n}`):(z.error(`Error while trying to execute command for ${n}`),z.error(t)),e.fields=[]}}(n),this.showform=t}hideCommandForm(e){e.preventDefault(),this.showform=""}async runCommand(e){e.preventDefault();const t=new FormData(e.target),n=t.get("command_jid").trim(),s=t.get("command_node").trim(),i=this.commands.filter((e=>e.node===s))[0];i.alert=null,this.nonce=Ox.getUniqueId();const o=Nx(":input:not([type=button]):not([type=submit])",e.target).filter((e=>!["command_jid","command_node"].includes(e.getAttribute("name")))).map(Ox.webForm2xForm).filter((e=>e)),r=$x({to:n,type:"set"}).c("command",{sessionid:i.sessionid,node:i.node,xmlns:Tx.NS.ADHOC}).c("x",{xmlns:Tx.NS.XFORM,type:"submit"});let a;o.forEach((e=>r.cnode(e).up()));try{a=await bu.sendIQ(r)}catch(e){i.alert_type="danger",i.alert=dv("Sorry, an error occurred while trying to execute the command. See the developer console for details"),z.error("Error while trying to execute an ad-hoc command"),z.error(e)}var c;a?i.alert=null===(c=a.querySelector("note"))||void 0===c?void 0:c.textContent:i.alert="Done";i.alert_type="primary",this.nonce=Ox.getUniqueId()}});bu.elements.define("converse-muc-message-form",class extends Cw{async connectedCallback(){super.connectedCallback(),await this.model.initialized}toHTML(){var e,t;return(e=>{const t=e.composing_spoiler?dv("Hidden message"):dv("Message"),n=dv("Optional hint"),s=bu.settings.get("show_send_button");return Kd`
    `})(Object.assign(this.model.toJSON(),{hint_value:null===(e=this.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,message_value:null===(t=this.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,onChange:e=>this.model.set({draft:e.target.value}),onDrop:e=>this.onDrop(e),onKeyDown:e=>this.onKeyDown(e),onKeyUp:e=>this.onKeyUp(e),onPaste:e=>this.onPaste(e),scrolled:this.model.ui.get("scrolled"),viewUnreadMessages:e=>this.viewUnreadMessages(e)}))}afterRender(){const e=this.model.session.get("connection_status")===Su.ROOMSTATUS.ENTERED,t=e&&!(this.model.features.get("moderated")&&"visitor"===this.model.getOwnRole());e&&t&&this.initMentionAutoComplete()}initMentionAutoComplete(){this.mention_auto_complete=new ul.AutoComplete(this,{auto_first:!0,auto_evaluate:!1,min_chars:bu.settings.get("muc_mention_autocomplete_min_chars"),match_current_word:!0,list:()=>this.getAutoCompleteList(),filter:"contains"==bu.settings.get("muc_mention_autocomplete_filter")?ul.FILTER_CONTAINS:ul.FILTER_STARTSWITH,ac_triggers:["Tab","@"],include_triggers:[],item:Sx}),this.mention_auto_complete.on("suggestion-box-selectcomplete",(()=>this.auto_completing=!1))}getAutoCompleteList(){return this.model.getAllKnownNicknames().map((e=>({label:e,value:`@${e}`})))}onKeyDown(e){this.mention_auto_complete.onKeyDown(e)||super.onKeyDown(e)}onKeyUp(e){this.mention_auto_complete.evaluate(e),super.onKeyUp(e)}});var Ix=n(6233),Mx={};Mx.styleTagTransform=Av(),Mx.setAttributes=wv(),Mx.insert=yv().bind(null,"head"),Mx.domAPI=vv(),Mx.insertStyleElement=xv();fv()(Ix.Z,Mx);Ix.Z&&Ix.Z.locals&&Ix.Z.locals;class Rx extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid)}render(){return(e=>{var t,n,s;const i=dv("Nickname"),o=null!==(t=e.model)&&void 0!==t&&t.isEntered()?dv("Change nickname"):dv("Enter groupchat"),r=bu.settings.get("muc_show_logs_before_join")?dv("Choose a nickname to enter"):dv("Please choose your nickname"),a=null===(n=e.model)||void 0===n?void 0:n.get("nickname_validation_message");return Kd`
    e.submitNickname(t)}>

    ${a}

    `})(this)}submitNickname(e){e.preventDefault();const t=e.target.nick.value.trim();t&&(this.model.isEntered()?(this.model.setNickname(t),this.closeModal()):this.model.join(t))}closeModal(){const e=document.createEvent("Event");e.initEvent("hide.bs.modal",!0,!0),this.dispatchEvent(e)}}bu.elements.define("converse-muc-nickname-form",Rx);const Dx=e=>{const t=dv("You have unread messages"),n=e.model.session.get("connection_status"),s=dv("You're not allowed to send messages in this room");return n===Su.ROOMSTATUS.ENTERED?Kd` ${e.model.ui.get("scrolled")&&e.model.get("num_unread_general")?Kd`
    e.viewUnreadMessages(t)}>▼ ${t} ▼
    `:""} ${e.can_edit?(e=>{const t=dv("You have unread messages"),n=bu.settings.get("message_limit"),s=bu.settings.get("visible_toolbar_buttons").call,i=bu.settings.get("visible_toolbar_buttons").emoji,o=bu.settings.get("show_send_button"),r=bu.settings.get("visible_toolbar_buttons").spoiler,a=bu.settings.get("show_toolbar");return Kd` ${e.model.ui.get("scrolled")&&e.model.get("num_unread")?Kd`
    e.viewUnreadMessages(t)}>▼ ${t} ▼
    `:""} ${a?Kd` `:""} `})(e):Kd`${s}`}`:n!=Su.ROOMSTATUS.NICKNAME_REQUIRED?"":bu.settings.get("muc_show_logs_before_join")?Kd` `:void 0};var zx=n(6916),Lx={};Lx.styleTagTransform=Av(),Lx.setAttributes=wv(),Lx.insert=yv().bind(null,"head"),Lx.domAPI=vv(),Lx.insertStyleElement=xv();fv()(zx.Z,Lx);zx.Z&&zx.Z.locals&&zx.Z.locals;bu.elements.define("converse-muc-bottom-panel",class extends Tw{constructor(){super(...arguments),function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"events",{"click .hide-occupants":"hideOccupants","click .send-button":"sendButtonClicked"})}async initialize(){await super.initialize(),this.listenTo(this.model,"change:hidden_occupants",this.debouncedRender),this.listenTo(this.model,"change:num_unread_general",this.debouncedRender),this.listenTo(this.model.features,"change:moderated",this.debouncedRender),this.listenTo(this.model.occupants,"add",this.renderIfOwnOccupant),this.listenTo(this.model.occupants,"change:role",this.renderIfOwnOccupant),this.listenTo(this.model.session,"change:connection_status",this.debouncedRender)}render(){const e=this.model.session.get("connection_status")===Su.ROOMSTATUS.ENTERED,t=e&&!(this.model.features.get("moderated")&&"visitor"===this.model.getOwnRole());tu(Dx({can_edit:t,entered:e,model:this.model,is_groupchat:!0,viewUnreadMessages:e=>this.viewUnreadMessages(e)}),this)}renderIfOwnOccupant(e){e.get("jid")===ul.bare_jid&&this.debouncedRender()}sendButtonClicked(e){var t;null===(t=this.querySelector("converse-muc-message-form"))||void 0===t||t.onFormSubmitted(e)}hideOccupants(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.save({hidden_occupants:!0})}});const Px={offline:"Offline",unavailable:"Unavailable",xa:"Extended Away",away:"Away",dnd:"Do not disturb",chat:"Chattty",online:"Online"},Fx=e=>{const t=e.get("role"),n=(e=>dv("Click to mention %1$s in your message.",e.get("nick")))(e),s=dv("This user is a moderator."),i=dv("This user can send messages in this groupchat."),o=dv("This user can NOT send messages in this groupchat."),r=e.get("jid")?`${e.get("jid")} `:"";return"moderator"===t?`${r}${s} ${n}`:"participant"===t?`${r}${i} ${n}`:"visitor"===t?`${r}${o} ${n}`:["visitor","participant","moderator"].includes(t)?void 0:`${r}${n}`},Ux=(e,t)=>{var n,s;const i=e.get("affiliation"),o=Px[e.get("show")],r=dv("Admin"),a=dv("Member"),c=dv("Moderator"),l=dv("Owner"),d=dv("Visitor"),u=e.get("role"),h=e.get("show");let m,g;return[m,g]="online"===h?["fa fa-circle","chat-status-online"]:"dnd"===h?["fa fa-minus-circle","chat-status-busy"]:"away"===h?["fa fa-circle","chat-status-away"]:["fa fa-circle","subdued-color"],Kd`
  • ${e.getDisplayName()} ${"owner"===i?Kd`${l}`:""} ${"admin"===i?Kd`${r}`:""} ${"member"===i?Kd`${a}`:""} ${"moderator"===u?Kd`${c}`:""} ${"visitor"===u?Kd`${d}`:""}
  • `};var Bx=n(9959),qx={};qx.styleTagTransform=Av(),qx.setAttributes=wv(),qx.insert=yv().bind(null,"head"),qx.domAPI=vv(),qx.insertStyleElement=xv();fv()(Bx.Z,qx);Bx.Z&&Bx.Z.locals&&Bx.Z.locals;var Hx=n(902),Gx={};Gx.styleTagTransform=Av(),Gx.setAttributes=wv(),Gx.insert=yv().bind(null,"head"),Gx.domAPI=vv(),Gx.insertStyleElement=xv();fv()(Hx.Z,Gx);Hx.Z&&Hx.Z.locals&&Hx.Z.locals;const{u:Wx}=Su.env;bu.elements.define("converse-muc-sidebar",class extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid),this.listenTo(this.model.occupants,"add",this.requestUpdate),this.listenTo(this.model.occupants,"remove",this.requestUpdate),this.listenTo(this.model.occupants,"change",this.requestUpdate),this.listenTo(this.model.occupants,"vcard:change",this.requestUpdate),this.listenTo(this.model.occupants,"vcard:add",this.requestUpdate),this.model.initialized.then((()=>this.requestUpdate()))}render(){const e=(e=>{const t=1===e.occupants.length?dv("Participant"):dv("Participants");return Kd`
    ${e.occupants.length} ${t}
      ${e.occupants.map((t=>Ux(t,e)))}
    `})(Object.assign(this.model.toJSON(),{occupants:[...this.model.occupants.models],closeSidebar:e=>this.closeSidebar(e),onOccupantClicked:e=>this.onOccupantClicked(e)}));return e}closeSidebar(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),Wx.safeSave(this.model,{hidden_occupants:!0})}onOccupantClicked(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const n=ul.chatboxviews.get(this.getAttribute("jid"));null==n||n.getMessageForm().insertIntoTextArea(`@${e.target.textContent}`)}});const{u:Vx}=Su.env;bu.elements.define("converse-muc-chatarea",class extends hv{static get properties(){return{jid:{type:String},show_help_messages:{type:Boolean},type:{type:String}}}async initialize(){this.model=await bu.rooms.get(this.jid),this.listenTo(this.model,"change:show_help_messages",(()=>this.requestUpdate())),this.listenTo(this.model,"change:hidden_occupants",(()=>this.requestUpdate())),this.listenTo(this.model.session,"change:connection_status",(()=>this.requestUpdate())),this.onMouseMove=this._onMouseMove.bind(this),this.onMouseUp=this._onMouseUp.bind(this),this.requestUpdate()}render(){return(e=>{var t;return Kd`
    ${null!==(t=e.model)&&void 0!==t&&t.get("show_help_messages")?Kd`
    `:""}
    ${e.model?Kd` `:""} `})({getHelpMessages:()=>this.getHelpMessages(),jid:this.jid,model:this.model,onMousedown:e=>this.onMousedown(e),show_send_button:bu.settings.get("show_send_button"),shouldShowSidebar:()=>this.shouldShowSidebar(),type:this.type})}shouldShowSidebar(){return!this.model.get("hidden_occupants")&&this.model.session.get("connection_status")===Su.ROOMSTATUS.ENTERED}getHelpMessages(){const e=bu.settings.get("muc_disable_slash_commands"),t=Array.isArray(e)?e:[];return[`/admin: ${dv("Change user's affiliation to admin")}`,`/ban: ${dv("Ban user by changing their affiliation to outcast")}`,`/clear: ${dv("Clear the chat area")}`,`/close: ${dv("Close this groupchat")}`,`/deop: ${dv("Change user role to participant")}`,`/destroy: ${dv("Remove this groupchat")}`,`/help: ${dv("Show this menu")}`,`/kick: ${dv("Kick user from groupchat")}`,`/me: ${dv("Write in 3rd person")}`,`/member: ${dv("Grant membership to a user")}`,`/modtools: ${dv("Opens up the moderator tools GUI")}`,`/mute: ${dv("Remove user's ability to post messages")}`,`/nick: ${dv("Change your nickname")}`,`/op: ${dv("Grant moderator role to user")}`,`/owner: ${dv("Grant ownership of this groupchat")}`,`/register: ${dv("Register your nickname")}`,`/revoke: ${dv("Revoke the user's current affiliation")}`,`/subject: ${dv("Set groupchat subject")}`,`/topic: ${dv("Set groupchat subject (alias for /subject)")}`,`/voice: ${dv("Allow muted user to post messages")}`].filter((e=>t.every((t=>!e.startsWith(t+"<",9))))).filter((e=>this.model.getAllowedCommands().some((t=>e.startsWith(t+"<",9)))))}onMousedown(e){Vx.hasClass("dragresize-occupants-left",e.target)&&this.onStartResizeOccupants(e)}onStartResizeOccupants(e){this.resizing=!0,this.addEventListener("mousemove",this.onMouseMove),this.addEventListener("mouseup",this.onMouseUp);const t=this.querySelector("converse-muc-sidebar"),n=window.getComputedStyle(t);this.width=parseInt(n.width.replace(/px$/,""),10),this.prev_pageX=e.pageX}_onMouseMove(e){if(this.resizing){e.preventDefault();const t=this.prev_pageX-e.pageX;this.resizeSidebarView(t,e.pageX),this.prev_pageX=e.pageX}}_onMouseUp(e){if(this.resizing){e.preventDefault(),this.resizing=!1,this.removeEventListener("mousemove",this.onMouseMove),this.removeEventListener("mouseup",this.onMouseUp);const t=this.querySelector("converse-muc-sidebar").getBoundingClientRect(),n=this.calculateSidebarWidth(t,0);Vx.safeSave(this.model,{occupants_width:n})}}calculateSidebarWidth(e,t){let n=e.width+t;const s=this.clientWidth;return n<.2*s?(n=.2*s,this.is_minimum=!0):n>.75*s?(n=.75*s,this.is_maximum=!0):s-n<250?(n=s-250,this.is_maximum=!0):(this.is_maximum=!1,this.is_minimum=!1),n}resizeSidebarView(e,t){const n=this.querySelector("converse-muc-sidebar"),s=n.getBoundingClientRect();if(this.is_minimum)this.is_minimum=s.leftt;else{const t=this.calculateSidebarWidth(s,e);n.style.flex="0 0 "+t+"px"}}});const{sizzle:Jx}=Su.env,Qx=Su.env.utils,{sizzle:Zx}=Su.env,Kx=Su.env.utils;class Yx extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid),this.listenTo(this.model.features,"change:passwordprotected",this.requestUpdate),this.listenTo(this.model.session,"change:config_stanza",this.requestUpdate),this.getConfig()}render(){return(e=>{const t=bu.settings.get("roomconfig_whitelist"),n=e.model.session.get("config_stanza");let s,i=[],o="";if(n){var r,a;const c=Qx.toStanza(n);i=Jx("field",c),t.length&&(i=i.filter((e=>t.includes(e.getAttribute("var")))));const l={new_password:!e.model.features.get("passwordprotected"),fixed_username:e.model.get("jid")};i=i.map((e=>Qx.xForm2TemplateResult(e,c,l))),o=null===(r=c.querySelector("instructions"))||void 0===r?void 0:r.textContent,s=null===(a=c.querySelector("title"))||void 0===a?void 0:a.textContent}else s=dv("Loading configuration form");const c=dv("Save"),l=dv("Cancel");return Kd`
    ${s} ${s!==o?Kd`

    ${o}

    `:""} ${i.length?i:Jb({classes:"hor_centered"})}
    ${i.length?Kd`
    `:""}
    `})({model:this.model,closeConfigForm:e=>this.closeForm(e),submitConfigForm:e=>this.submitConfigForm(e)})}async getConfig(){const e=await this.model.fetchRoomConfiguration();this.model.session.set("config_stanza",e.outerHTML)}async submitConfigForm(e){e.preventDefault();const t=Zx(":input:not([type=button]):not([type=submit])",e.target).map(Kx.webForm2xForm).filter((e=>e));try{await this.model.sendConfiguration(t)}catch(e){z.error(e);const t=dv("Sorry, an error occurred while trying to submit the config form.")+" "+dv("Check your browser's developer console for details.");bu.alert("error",dv("Error"),t)}await this.model.refreshDiscoInfo(),this.closeForm()}closeForm(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.session.set("view",null)}}bu.elements.define("converse-muc-config-form",Yx);const Xx=e=>{const t=dv("This groupchat no longer exists"),n=dv('The following reason was given: "%1$s"',e.reason||"");return Kd`

    ${t}

    ${e.reason?Kd`

    ${n}

    `:""} ${e.moved_jid?(e=>{const t=dv("The conversation has moved to a new address. Click the link below to enter.");return Kd`

    ${t}

    `})(e):""} `};bu.elements.define("converse-muc-destroyed",class extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid)}render(){const e=this.model.get("destroyed_reason"),t=this.model.get("moved_jid");return Xx({moved_jid:t,reason:e,onSwitch:e=>this.onSwitch(e)})}async onSwitch(e){e.preventDefault();const t=this.model.get("moved_jid");(await bu.rooms.get(t,{},!0)).maybeShow(!0),this.model.destroy()}});bu.elements.define("converse-muc-disconnected",class extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid)}render(){const e=this.model.session.get("disconnection_message");if(!e)return;const t=[e],n=this.model.session.get("disconnection_actor");n&&t.push(dv("This action was done by %1$s.",n));const s=this.model.session.get("disconnection_reason");return s&&t.push(dv('The reason given is: "%1$s".',s)),(e=>Kd`

    ${e[0]}

    ${e.slice(1).map((e=>Kd`

    ${e}

    `))}
    `)(t)}});const eE=Su.env.utils,tE=Uv.extend({id:"muc-invite-modal",initialize(){Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.initInviteWidget()},toHTML(){return(e=>{const t=dv("Invite"),n=dv("Invite someone to this groupchat"),s=dv("user@example.org"),i=dv("Please enter a valid XMPP address"),o=dv("XMPP Address"),r=dv("Optional reason for the invitation");return Kd` `})(Object.assign(this.model.toJSON(),{submitInviteForm:e=>this.submitInviteForm(e)}))},initInviteWidget(){this.invite_auto_complete&&this.invite_auto_complete.destroy();const e=ul.roster.map((e=>({label:e.getDisplayName(),value:e.get("jid")}))),t=this.el.querySelector(".suggestion-box").parentElement;this.invite_auto_complete=new ul.AutoComplete(t,{min_chars:1,list:e})},submitInviteForm(e){e.preventDefault();const t=new FormData(e.target),n=t.get("invitee_jids"),s=t.get("reason");eE.isValidJID(n)?(this.chatroomview.model.directInvite(n,s),this.modal.hide()):this.model.set({invalid_invite_jid:!0})}}),nE=Uv.extend({id:"change-nickname-modal",initialize(e){this.model=e.model,Uv.prototype.initialize.apply(this,arguments)},toHTML(){return(e=>{const t=e.model.get("jid"),n=dv("Change your nickname");return Kd` `})(this)}}),sE=e=>{const t=e.toJSON(),n=e.config.toJSON(),s=dv("Groupchat info for %1$s",e.getDisplayName()),i=e.features.toJSON(),o=e.occupants.filter((e=>"offline"!==e.get("show"))).length,r=dv("XMPP address"),a=dv("Message archiving"),c=dv("Messages are archived on the server"),l=dv("Description"),d=dv("Features"),u=dv("Hidden"),h=dv("This groupchat is not publicly searchable"),m=dv("This groupchat is restricted to members only"),g=dv("Members only"),f=dv("Moderated"),p=dv("Participants entering this groupchat need to request permission to write"),v=dv("Name"),_=dv("This groupchat does not require a password upon entry"),y=dv("No password required"),b=dv("Not anonymous"),w=dv("All other groupchat participants can see your XMPP address"),S=dv("Not moderated"),x=dv("Participants entering this groupchat can write right away"),E=dv("Online users"),A=dv("Open"),C=dv("Anyone can join this groupchat"),k=dv("This groupchat requires a password before entry"),j=dv("Password protected"),T=dv("Persistent"),$=dv("This groupchat persists even if it's unoccupied"),N=dv("Public"),O=dv("Semi-anonymous"),I=dv("Only moderators can see your XMPP address"),M=dv("Temporary"),R=dv("This groupchat will disappear once the last person leaves");return Kd` `};var iE=n(7140),oE={};oE.styleTagTransform=Av(),oE.setAttributes=wv(),oE.insert=yv().bind(null,"head"),oE.domAPI=vv(),oE.insertStyleElement=xv();fv()(iE.Z,oE);iE.Z&&iE.Z.locals&&iE.Z.locals;const rE=Uv.extend({id:"muc-details-modal",initialize(){Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.listenTo(this.model.features,"change",this.render),this.listenTo(this.model.occupants,"add",this.render),this.listenTo(this.model.occupants,"change",this.render)},toHTML(){return sE(this.model)}});var aE=n(307),cE={};cE.styleTagTransform=Av(),cE.setAttributes=wv(),cE.insert=yv().bind(null,"head"),cE.domAPI=vv(),cE.insertStyleElement=xv();fv()(aE.Z,cE);aE.Z&&aE.Z.locals&&aE.Z.locals;bu.elements.define("converse-rich-text",class extends hv{static get properties(){return{embed_audio:{type:Boolean},embed_videos:{type:Boolean},mentions:{type:Array},nick:{type:String},offset:{type:Number},onImgClick:{type:Function},onImgLoad:{type:Function},render_styling:{type:Boolean},show_images:{type:Boolean},hide_media_urls:{type:Boolean},show_me_message:{type:Boolean},text:{type:String}}}constructor(){super(),this.embed_audio=!1,this.embed_videos=!1,this.hide_media_urls=!1,this.mentions=[],this.offset=0,this.render_styling=!1,this.show_image_urls=!0,this.show_images=!1,this.show_me_message=!1}render(){const e={embed_audio:this.embed_audio,embed_videos:this.embed_videos,hide_media_urls:this.hide_media_urls,mentions:this.mentions,nick:this.nick,onImgClick:this.onImgClick,onImgLoad:this.onImgLoad,render_styling:this.render_styling,show_images:this.show_images,show_me_message:this.show_me_message};return ub(this.text,this.offset,e)}});var lE=n(3288),dE={};dE.styleTagTransform=Av(),dE.setAttributes=wv(),dE.insert=yv().bind(null,"head"),dE.domAPI=vv(),dE.insertStyleElement=xv();fv()(lE.Z,dE);lE.Z&&lE.Z.locals&&lE.Z.locals;bu.elements.define("converse-muc-heading",class extends hv{async initialize(){this.model=ul.chatboxes.get(this.getAttribute("jid")),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.listenTo(this.model,"vcard:add",(()=>this.requestUpdate())),this.listenTo(this.model,"vcard:change",(()=>this.requestUpdate())),this.user_settings=await ul.api.user.settings.getModel(),this.listenTo(this.user_settings,"change:mucs_with_hidden_subject",(()=>this.requestUpdate())),await this.model.initialized,this.listenTo(this.model.features,"change:open",(()=>this.requestUpdate())),this.model.occupants.forEach((e=>this.onOccupantAdded(e))),this.listenTo(this.model.occupants,"add",this.onOccupantAdded),this.listenTo(this.model.occupants,"change:affiliation",this.onOccupantAffiliationChanged),this.requestUpdate()}render(){return this.model&&this.user_settings?(e=>{var t,n,s,i,o;const r=e.model.toJSON(),a=null===(t=e.user_settings)||void 0===t||null===(n=t.get("mucs_with_hidden_subject",[]))||void 0===n?void 0:n.includes(e.model.get("jid")),c=dv("Hide the groupchat topic"),l=dv("This groupchat is bookmarked"),d=r.subject?r.subject.text:"",u=d&&!a,h=null===(s=e.model.vcard)||void 0===s?void 0:s.get("image");return Kd`
    ${h&&h!==ul.DEFAULT_IMAGE?Kd` `:""}
    ${ul.api.settings.get("singleton")?"":Kd``}
    ${e.model.getDisplayName()} ${r.bookmarked?Kd``:""}
    ${__(e.getHeadingButtons(a).then((e=>{const t=e.filter((e=>!e.standalone)).map((e=>fw(e)));return Kd` ${e.filter((e=>e.standalone)).reverse().map((e=>__(pw(e),"")))} ${t.length?Kd``:""}`})),"")}
    ${u?Kd`

    `:""} `})(this):""}onOccupantAdded(e){e.get("jid")===ul.bare_jid&&this.requestUpdate()}onOccupantAffiliationChanged(e){e.get("jid")===ul.bare_jid&&this.requestUpdate()}showRoomDetailsModal(e){e.preventDefault(),bu.modal.show(rE,{model:this.model},e)}showInviteModal(e){e.preventDefault(),bu.modal.show(tE,{model:new Ac,chatroomview:this},e)}toggleTopic(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.toggleSubjectHiddenState()}getAndRenderConfigurationForm(){this.model.session.set("view",Su.MUC.VIEWS.CONFIG)}close(e){e.preventDefault(),this.model.close()}destroy(e){e.preventDefault(),bx(this.model)}getHeadingButtons(e){const t=[];t.push({i18n_text:dv("Details"),i18n_title:dv("Show more information about this groupchat"),handler:e=>this.showRoomDetailsModal(e),a_class:"show-muc-details-modal",icon_class:"fa-info-circle",name:"details"}),"owner"===this.model.getOwnAffiliation()&&t.push({i18n_text:dv("Configure"),i18n_title:dv("Configure this groupchat"),handler:()=>this.getAndRenderConfigurationForm(),a_class:"configure-chatroom-button",icon_class:"fa-wrench",name:"configure"}),t.push({i18n_text:dv("Nickname"),i18n_title:dv("Change the nickname you're using in this groupchat"),handler:e=>bu.modal.show(nE,{model:this.model},e),a_class:"open-nickname-modal",icon_class:"fa-smile",name:"nickname"}),this.model.invitesAllowed()&&t.push({i18n_text:dv("Invite"),i18n_title:dv("Invite someone to join this groupchat"),handler:e=>this.showInviteModal(e),a_class:"open-invite-modal",icon_class:"fa-user-plus",name:"invite"});const n=this.model.get("subject");n&&n.text&&t.push({i18n_text:dv(e?"Show topic":"Hide topic"),i18n_title:dv(e?"Show the topic message in the heading":"Hide the topic in the heading"),handler:e=>this.toggleTopic(e),a_class:"hide-topic",icon_class:"fa-minus-square",name:"toggle-topic"});if(this.model.session.get("connection_status")===Su.ROOMSTATUS.ENTERED){const e=this.model.getAllowedCommands();e.includes("modtools")&&t.push({i18n_text:dv("Moderate"),i18n_title:dv("Moderate this groupchat"),handler:()=>Cx(this.model),a_class:"moderate-chatroom-button",icon_class:"fa-user-cog",name:"moderate"}),e.includes("destroy")&&t.push({i18n_text:dv("Destroy"),i18n_title:dv("Remove this groupchat"),handler:e=>this.destroy(e),a_class:"destroy-chatroom-button",icon_class:"fa-trash",name:"destroy"})}bu.settings.get("singleton")||t.push({i18n_text:dv("Leave"),i18n_title:dv("Leave and close this groupchat"),handler:async e=>{e.stopPropagation();const t=[dv("Are you sure you want to leave this groupchat?")];await bu.confirm(dv("Confirm"),t)&&this.close(e)},a_class:"close-chatbox-button",standalone:"overlayed"===bu.settings.get("view_mode"),icon_class:"fa-sign-out-alt",name:"signout"});const s=ul.chatboxviews.get(this.getAttribute("jid"));return s?ul.api.hook("getHeadingButtons",s,t):Promise.resolve(t)}});class uE extends hv{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=ul.chatboxes.get(this.jid),this.listenTo(this.model,"change:password_validation_message",this.render),this.render()}render(){return(e=>{const t=dv("This groupchat requires a password"),n=dv("Password: "),s=dv("Submit");return Kd`

    ${e.validation_message}

    `})({jid:this.model.get("jid"),submitPassword:e=>this.submitPassword(e),validation_message:this.model.get("password_validation_message")})}submitPassword(e){e.preventDefault();const t=this.querySelector("input[type=password]").value;this.model.join(this.model.get("nick"),t),this.model.set("password_validation_message",null)}}bu.elements.define("converse-muc-password-form",uE);function hE(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class mE extends $w{constructor(){super(...arguments),hE(this,"length",300),hE(this,"is_chatroom",!0)}async initialize(){this.model=await bu.rooms.get(this.jid),ul.chatboxviews.add(this.jid,this),this.setAttribute("id",this.model.get("box_id")),this.listenTo(ul,"windowStateChanged",this.onWindowStateChanged),this.listenTo(this.model,"change:composing_spoiler",this.requestUpdateMessageForm),this.listenTo(this.model.session,"change:connection_status",this.onConnectionStatusChanged),this.listenTo(this.model.session,"change:view",this.requestUpdate),this.onConnectionStatusChanged(),this.model.maybeShow(),bu.trigger("chatRoomViewInitialized",this)}render(){return(e=>Kd`
    ${e.model?Kd`
    ${wx(e)}
    `:""}
    `)({model:this.model})}onConnectionStatusChanged(){this.model.session.get("connection_status")===Su.ROOMSTATUS.CONNECTING&&(this.model.session.save({disconnection_actor:void 0,disconnection_message:void 0,disconnection_reason:void 0}),this.model.save({moved_jid:void 0,password_validation_message:void 0,reason:void 0})),this.requestUpdate()}}bu.elements.define("converse-muc",mE);var gE=n(3076),fE={};fE.styleTagTransform=Av(),fE.setAttributes=wv(),fE.insert=yv().bind(null,"head"),fE.domAPI=vv(),fE.insertStyleElement=xv();fv()(gE.Z,fE);gE.Z&&gE.Z.locals&&gE.Z.locals;const{Strophe:pE}=Su.env;Su.MUC.VIEWS={CONFIG:"config-form"},Su.plugins.add("converse-muc-views",{dependencies:["converse-modal","converse-controlbox","converse-chatview"],initialize(){const{_converse:e}=this;bu.settings.extend({auto_list_rooms:!1,cache_muc_messages:!0,locked_muc_nickname:!1,modtools_disable_query:[],muc_disable_slash_commands:!1,muc_mention_autocomplete_filter:"contains",muc_mention_autocomplete_min_chars:0,muc_mention_autocomplete_show_avatar:!0,muc_roomid_policy:null,muc_roomid_policy_hint:null,roomconfig_whitelist:[],show_retraction_warning:!0,visible_toolbar_buttons:{toggle_occupants:!0}}),e.ChatRoomView=mE,bu.settings.get("muc_domain")||bu.listen.on("serviceDiscovered",(async e=>{if((null==e?void 0:e.get("var"))===pE.NS.MUC){if(e.entity.get("jid").includes("@"))return;await e.entity.getIdentity("conference","text")&&bu.settings.set("muc_domain",pE.getDomainFromJid(e.get("from")))}})),bu.listen.on("clearsession",(()=>{const t=e.chatboxviews.get("controlbox");t&&t.roomspanel&&(t.roomspanel.model.destroy(),t.roomspanel.remove(),delete t.roomspanel)})),bu.listen.on("chatBoxClosed",(t=>{var n;t.get("type")===e.CHATROOMS_TYPE&&(n=t.get("jid"),ul.router.history.getFragment()===`converse/room?jid=${n}`&&ul.router.navigate(""))})),bu.listen.on("parseMessageForCommands",kx)}});var vE=n(4023),_E=n.n(vE);const{Strophe:yE}=Su.env,bE="Notification"in window;let wE;function SE(e){var t;return ul.isTestEnv()||((null===(t=ul.chatboxes.get(e.from))||void 0===t?void 0:t.isHidden())??!1)}function xE(){return ul.isTestEnv()||bE&&bu.settings.get("show_desktop_notifications")&&"granted"===Notification.permission}function EE(){var e,t;wE=null,null===(e=(t=navigator).clearAppBadge)||void 0===e||e.call(t).catch((e=>z.error("Could not clear unread count in app badge "+e)))}function AE(){if(bu.settings.get("show_tab_notifications")){var e,t;wE=wE??new Su.env.Favico({type:"circle",animation:"pop"});const n=ul.chatboxes.models.reduce(((e,t)=>e+(t.get("num_unread")||0)),0);wE.badge(n),null===(e=(t=navigator).setAppBadge)||void 0===e||e.call(t,n).catch((e=>z.error("Could set unread count in app badge - "+e)))}}function CE(e,t,n){return e.reduce(((e,s)=>e||(e=>[ul.bare_jid,`${t}/${n}`].includes(e.uri.replace(/^xmpp:/,"")))(s)),!1)}function kE(e){const{attrs:t}=e;if(!t||t.is_forwarded)return!1;if("groupchat"===t.type)return async function(e){if(!(null!=e&&e.body||null!=e&&e.message))return!1;const t=e.from,n=e.from_muc,s=bu.settings.get("notify_all_room_messages"),i=ul.chatboxes.get(n),o=yE.getResourceFromJid(t),r=o&&yE.unescapeNode(o)||"";let a=!1;const c=i.get("nick");bu.settings.get("notify_nicknames_without_references")&&(a=new RegExp(`\\b${c}\\b`).test(e.body));const l=r!==c,d=!0===s||Array.isArray(s)&&s.includes(n)||CE(e.references,n,c)||a;if(l&&d)return await bu.hook("shouldNotifyOfGroupMessage",e,!0);return!1}(t);if("info"===t.type)return async function(e){if(!e.from_muc)return!1;const t=await bu.rooms.get(e.from_muc);if(!t)return!1;const n=t.get("nick"),s=e.from_muc,i=bu.settings.get("notify_all_room_messages");return!0===i||Array.isArray(i)&&i.includes(s)||CE(e.references,s,n)}(t);if(t.is_headline)return SE(t);const n=yE.getBareJidFromJid(t.from)===ul.bare_jid;return!qc(t)&&!n&&("all"===bu.settings.get("show_desktop_notifications")||SE(t))}async function jE(e){if(!await kE(e))return!1;bu.trigger("messageNotification",e),function(){if(bu.settings.get("play_sounds")&&void 0!==window.Audio){const e=new Audio(bu.settings.get("sounds_path")+"msg_received.ogg"),t=e.canPlayType("audio/ogg");if("probably"===t)return e.play();const n=new Audio(bu.settings.get("sounds_path")+"msg_received.mp3"),s=n.canPlayType("audio/mp3");"probably"===s?n.play():"maybe"===t?e.play():"maybe"===s&&n.play()}}(),function(e){const{attrs:t}=e;if(t.is_error)return;if(!xE())return;let n,s;const i=t.from,o=yE.getBareJidFromJid(i);if("info"==t.type)n=t.message;else if("headline"===t.type){if(o.includes("@")&&!bu.settings.get("allow_non_roster_messaging"))return;n=dv("Notification from %1$s",o)}else if(o.includes("@"))if("groupchat"===t.type)n=dv("%1$s says",yE.getResourceFromJid(i));else{if(void 0===ul.roster)return void z.error("Could not send notification, because roster is undefined");if(s=ul.roster.get(o),void 0!==s)n=dv("%1$s says",s.getDisplayName());else{if(!bu.settings.get("allow_non_roster_messaging"))return;n=dv("%1$s says",o)}}else n=dv("Notification from %1$s",o);let r;if("info"==t.type)r=t.reason;else if(r=t.is_encrypted?t.plaintext:t.body,!r)return;const a=new Notification(n,{body:r,lang:ul.locale,icon:bu.settings.get("notification_icon"),requireInteraction:!bu.settings.get("notification_delay")});bu.settings.get("notification_delay")&&setTimeout((()=>a.close()),bu.settings.get("notification_delay")),a.onclick=function(e){e.preventDefault(),window.focus(),ul.chatboxes.get(o).maybeShow(!0)}}(e)}function TE(e){xE()&&function(e){if("error"===e.klass||"warn"===e.klass){const t=new Notification(e.subject,{body:e.message,lang:ul.locale,icon:bu.settings.get("notification_icon")});setTimeout(t.close.bind(t),5e3)}}(e)}function $E(e){xE()&&bu.settings.get("show_chat_state_notifications")&&function(e){var t;if(null!==(t=bu.settings.get("chatstate_notification_blacklist"))&&void 0!==t&&t.includes(e.jid))return;const n=e.presence.get("show");let s=null;if("offline"===n?s=dv("has gone offline"):"away"===n?s=dv("has gone away"):"dnd"===n?s=dv("is busy"):"online"===n&&(s=dv("has come online")),null===s)return;const i=new Notification(e.getDisplayName(),{body:s,lang:ul.locale,icon:bu.settings.get("notification_icon")});setTimeout((()=>i.close()),5e3)}(e)}function NE(e){xE()&&function(e){const t=new Notification(e.getDisplayName(),{body:dv("wants to be your contact"),lang:ul.locale,icon:bu.settings.get("notification_icon")});setTimeout((()=>t.close()),5e3)}(e)}function OE(){bE&&!["denied","granted"].includes(Notification.permission)&&Notification.requestPermission()}Su.env.Favico=_E(),Su.plugins.add("converse-notification",{dependencies:["converse-chatboxes"],initialize(){bu.settings.extend({chatstate_notification_blacklist:[],notification_delay:5e3,notification_icon:"logo/conversejs-filled.svg",notify_all_room_messages:!1,notify_nicknames_without_references:!1,play_sounds:!0,show_chat_state_notifications:!1,show_desktop_notifications:!0,show_tab_notifications:!0,sounds_path:bu.settings.get("assets_path")+"/sounds/"}),bu.listen.on("clearSession",EE),bu.waitUntil("chatBoxesInitialized").then((()=>ul.chatboxes.on("change:num_unread",AE))),bu.listen.on("pluginsInitialized",(function(){bu.listen.on("contactRequest",NE),bu.listen.on("contactPresenceChanged",$E),bu.listen.on("message",jE),bu.listen.on("feedback",TE),bu.listen.on("connected",OE)}))}});const IE={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",cda:"application/x-cdf",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",gz:"application/gzip",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",m4a:"audio/mp4",mid:"audio/midi",midi:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mp4:"video/mp4",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/x-httpd-php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3g2":"video/3gpp2","7z":"application/x-7z-compressed"},ME={name:"AES-GCM",length:128};const RE=function(){var e=arguments.length;if(!e)return[];for(var t=Array(e-1),n=arguments[0],s=e;s--;)t[s-1]=arguments[s];return Nn(ut(n)?go(n):[n],Ga(t,1))},{u:DE}=Su.env;function zE(e,t){const n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}function LE(e){return Array.prototype.map.call(new Uint8Array(e),(e=>("00"+e.toString(16)).slice(-2))).join("")}function PE(e){return new TextDecoder("utf-8").decode(e)}function FE(e){return new TextEncoder("utf-8").encode(e).buffer}function UE(e){return btoa(new Uint8Array(e).reduce(((e,t)=>e+String.fromCharCode(t)),""))}function BE(e){const t=window.atob(e),n=t.length,s=new Uint8Array(n);for(let e=0;eparseInt(e,16))));return t.buffer}Object.assign(DE,{arrayBufferToHex:LE,arrayBufferToString:PE,stringToArrayBuffer:FE,arrayBufferToBase64:UE,base64ToArrayBuffer:BE});const{Strophe:HE,URI:GE,sizzle:WE,u:VE}=Su.env;function JE(e){e=e.replace(/^05/,"");for(let t=1;t<8;t++){const n=8*t+t-1;e=e.slice(0,n)+" "+e.slice(n)}return e}function QE(e,t){return e.get("omemo_active")&&t.body&&(t.is_encrypted=!0,t.plaintext=t.body,t.body=dv("This is an OMEMO encrypted message which your client doesn’t seem to support. Find more information on https://conversations.im/omemo")),t}async function ZE(e){var t;const n=e.hash().slice(1),s="localhost"===window.location.hostname?"http":"https",i=e.toString().replace(/^aesgcm/,s),o=await async function(e){let t;try{t=await fetch(e)}catch(t){return z.error(`${t.name}: Failed to download encrypted media: ${e}`),z.error(t),null}if(t.status>=200&&t.status<400)return t.arrayBuffer()}(i);if(null===o)return z.error(`Could not decrypt file ${e.toString()} since it could not be downloaded`),null;const r=n.slice(0,24),a=n.slice(24);let c;try{c=await async function(e,t,n){const s=await crypto.subtle.importKey("raw",qE(t),"AES-GCM",!1,["decrypt"]),i={name:"AES-GCM",iv:qE(e)};return crypto.subtle.decrypt(i,s,n)}(r,a,o)}catch(t){return z.error(`Could not decrypt file ${e.toString()}`),z.error(t),null}const[l,d]=null===(t=e.filename())||void 0===t?void 0:t.split("."),u=IE[d];try{const e=new File([c],l,{type:u});return URL.createObjectURL(e)}catch(t){return z.error(`Could not decrypt file ${e.toString()}`),z.error(t),null}}function KE(e,t,n){const s=[];try{const t={start:/\b(aesgcm:\/\/)/gi};GE.withinString(e,((e,t,n)=>(s.push({url:e,start:t,end:n}),e)),t)}catch(e){return void z.debug(e)}s.forEach((s=>{const i=ju(e.slice(s.start,s.end)),o=ZE(i).then((e=>function(e,t,n){const s=e.toString();return null===t?s:Pu(s)?jy({src:t,onClick:n.onImgClick,onLoad:n.onImgLoad}):zu(s)?W_(t):Lu(s)?ly(t):ny(t,e.filename())}(i,e,n))),r=Kd`${__(o,"")}`;n.addTemplateResult(s.start+t,s.end+t,r)}))}function YE(e){ul.config.get("trusted")&&e.addAnnotations(((t,n)=>KE(t,n,e)))}async function XE(e,t){var n;if(bu.settings.get("clear_cache_on_logout")||!t.is_encrypted||t.encryption_namespace!==HE.NS.OMEMO)return t;const s=WE(`encrypted[xmlns="${HE.NS.OMEMO}"]`,e).pop(),i=s.querySelector("header");t.encrypted={device_id:i.getAttribute("sid")};const o=await(null===(n=bu.omemo)||void 0===n?void 0:n.getDeviceID()),r=o&&WE(`key[rid="${o}"]`,s).pop();return r?(Object.assign(t.encrypted,{iv:i.querySelector("iv").textContent,key:r.textContent,payload:(null===(a=s.querySelector("payload"))||void 0===a?void 0:a.textContent)||null,prekey:["true","1"].includes(r.getAttribute("prekey"))}),!0===t.encrypted.prekey?async function(e){const t=nA(sA(e),parseInt(e.encrypted.device_id,10)),n=BE(e.encrypted.key);let s;try{s=await t.decryptPreKeyWhisperMessage(n,"binary")}catch(t){return z.error(`${t.name} ${t.message}`),Object.assign(e,oA(t))}try{const t=await iA(e,s);return await ul.omemo_store.generateMissingPreKeys(),await ul.omemo_store.publishBundle(),t?Object.assign(e,{plaintext:t}):Object.assign(e,{is_only_key:!0})}catch(t){return z.error(`${t.name} ${t.message}`),Object.assign(e,oA(t))}}(t):async function(e){const t=nA(sA(e),parseInt(e.encrypted.device_id,10)),n=BE(e.encrypted.key);try{const s=await t.decryptWhisperMessage(n,"binary"),i=await iA(e,s);return Object.assign(e,{plaintext:i})}catch(t){return z.error(`${t.name} ${t.message}`),Object.assign(e,oA(t))}}(t)):Object.assign(t,{error_condition:"not-encrypted-for-this-device",error_type:"Decryption",is_ephemeral:!0,is_error:!0,type:"error"});var a}function eA(){ul.chatboxes.on("add",(e=>{mA(e),e.get("type")===ul.CHATROOMS_TYPE&&(e.occupants.on("add",(t=>async function(e,t){if(t.isSelf()||!e.features.get("nonanonymous")||!e.features.get("membersonly"))return;if(e.get("omemo_active")){await ul.contactHasOMEMOSupport(t.get("jid"))||(e.createMessage({message:dv("%1$s doesn't appear to have a client that supports OMEMO. Encrypted chat will no longer be possible in this grouchat.",t.get("nick")),type:"error"}),e.save({omemo_active:!1,omemo_supported:!1}))}}(e,t))),e.features.on("change",(()=>mA(e))))}))}function tA(e){e.listenTo(e.model.messages,"add",(t=>{t.get("is_encrypted")&&!t.get("is_error")&&e.model.save("omemo_supported",!0)})),e.listenTo(e.model,"change:omemo_supported",(()=>{var t;!e.model.get("omemo_supported")&&e.model.get("omemo_active")?e.model.set("omemo_active",!1):null===(t=e.querySelector("converse-chat-toolbar"))||void 0===t||t.requestUpdate()})),e.listenTo(e.model,"change:omemo_active",(()=>{e.querySelector("converse-chat-toolbar").requestUpdate()}))}function nA(e,t){const n=new libsignal.SignalProtocolAddress(e,t);return new window.libsignal.SessionCipher(ul.omemo_store,n)}function sA(e){const t=e.from_muc?e.from_real_jid:e.from;if(!t)throw Object.assign(e,{error_text:dv("Sorry, could not decrypt a received OMEMO message because we don't have the XMPP address for that user."),error_type:"Decryption",is_ephemeral:!0,is_error:!0,type:"error"}),new Error("Could not find JID to decrypt OMEMO message for");return t}async function iA(e,t){const n=sA(e),s=await bu.omemo.devicelists.get(n,!0),i=e.encrypted;let o=s.devices.get(i.device_id);if(o||(o=await s.devices.create({id:i.device_id,jid:n},{promise:!0})),i.payload){const e=t.slice(0,16),n=t.slice(16),s=await vA.decryptMessage(Object.assign(i,{key:e,tag:n}));return o.save("active",!0),s}}function oA(e){return{error_text:dv("Sorry, could not decrypt a received OMEMO message due to an error.")+` ${e.name} ${e.message}`,error_condition:e.name,error_message:e.message,error_type:"Decryption",is_ephemeral:!0,is_error:!0,type:"error"}}function rA(e){const t=e.querySelector("signedPreKeyPublic"),n=e.querySelector("signedPreKeySignature"),s=WE("prekeys > preKeyPublic",e).map((e=>({id:parseInt(e.getAttribute("preKeyId"),10),key:e.textContent})));return{identity_key:e.querySelector("identityKey").textContent.trim(),signed_prekey:{id:parseInt(t.getAttribute("signedPreKeyId"),10),public_key:t.textContent,signature:n.textContent},prekeys:s}}async function aA(e){var t;if(null!==(t=e.get("bundle"))&&void 0!==t&&t.fingerprint)return;const n=await e.getBundle();n.fingerprint=LE(BE(n.identity_key)),e.save("bundle",n),e.trigger("change:bundle")}async function cA(e){await bu.waitUntil("OMEMOInitialized");const t=await bu.omemo.devicelists.get(e,!0);return await t.fetchDevices(),t.devices}async function lA(e){if(!e.get("bundle"))return z.error(`Could not build an OMEMO session for device ${e.get("id")} because we don't have its bundle`),null;const t=new libsignal.SignalProtocolAddress(e.get("jid"),e.get("id")),n=await ul.omemo_store.loadSession(t.toString());if(n)return n;try{const t=await async function(e){const t=new libsignal.SignalProtocolAddress(e.get("jid"),e.get("id")),n=new libsignal.SessionBuilder(ul.omemo_store,t),s=e.getRandomPreKey(),i=await e.getBundle();return n.processPreKey({registrationId:parseInt(e.get("id"),10),identityKey:BE(i.identity_key),signedPreKey:{keyId:i.signed_prekey.id,publicKey:BE(i.signed_prekey.public_key),signature:BE(i.signed_prekey.signature)},preKey:{keyId:s.id,publicKey:BE(s.key)}})}(e);return t}catch(t){return z.error(`Could not build an OMEMO session for device ${e.get("id")}`),z.error(t),null}}function dA(){ul.connection.addHandler((async e=>{try{WE(`event[xmlns="${HE.NS.PUBSUB}#event"]`,e).length&&(await bu.waitUntil("OMEMOInitialized"),await async function(e){const t=WE(`items[node="${HE.NS.OMEMO_DEVICELIST}"]`,e).pop();if(!t)return;const n=`item list[xmlns="${HE.NS.OMEMO}"] device`,s=WE(n,t).map((e=>e.getAttribute("id"))),i=e.getAttribute("from"),o=await bu.omemo.devicelists.get(i,!0),r=o.devices;Rl(r.pluck("id"),s).forEach((e=>{i===ul.bare_jid&&e===ul.omemo_store.get("device_id")||r.get(e).save("active",!1)})),s.forEach((e=>{const t=r.get(e);t?t.save("active",!0):r.create({id:e,jid:i})})),VE.isSameBareJID(i,ul.bare_jid)&&o.publishCurrentDevice(s)}(e),await async function(e){const t=WE("items",e).pop();if(!t||!t.getAttribute("node").startsWith(HE.NS.OMEMO_BUNDLES))return;const n=t.getAttribute("node").split(":")[1],s=e.getAttribute("from"),i=WE("item > bundle",t).pop(),o=await bu.omemo.devicelists.get(s,!0);(o.devices.get(n)||o.devices.create({id:n,jid:s})).save({bundle:rA(i)})}(e))}catch(e){z.error(e.message)}return!0}),null,"message","headline")}async function uA(){if(void 0===ul.omemo_store){const e=`converse.omemosession-${ul.bare_jid}`;ul.omemo_store=new ul.OMEMOStore({id:e}),La(ul.omemo_store,e)}await ul.omemo_store.fetchSession()}async function hA(e){if(!e)if(ul.config.get("trusted")&&!bu.settings.get("clear_cache_on_logout")){try{await async function(){ul.devicelists=new ul.DeviceLists;const e=`converse.devicelists-${ul.bare_jid}`;La(ul.devicelists,e),await new Promise((e=>{ul.devicelists.fetch({success:e,error:(t,n)=>{z.error(n),e()}})})),await bu.omemo.devicelists.get(ul.bare_jid,!0)}(),await uA(),await ul.omemo_store.publishBundle()}catch(e){return z.error("Could not initialize OMEMO support"),void z.error(e)}bu.trigger("OMEMOInitialized")}else z.warn("Not initializing OMEMO, since this browser is not trusted or clear_cache_on_logout is set to true")}async function mA(e){let t;e.get("type")===ul.CHATROOMS_TYPE?(await bu.waitUntil("OMEMOInitialized"),t=e.features.get("nonanonymous")&&e.features.get("membersonly")):e.get("type")===ul.PRIVATE_CHAT_TYPE&&(t=await ul.contactHasOMEMOSupport(e.get("jid"))),e.set("omemo_supported",t),t&&bu.settings.get("omemo_default")&&e.set("omemo_active",!0)}function gA(e){e.stopPropagation(),e.preventDefault();const t=VE.ancestor(e.target,"converse-chat-toolbar");if(!t.model.get("omemo_supported")){let e;return e=t.model.get("type")===ul.CHATROOMS_TYPE?[dv("Cannot use end-to-end encryption in this groupchat, either the groupchat has some anonymity or not all participants support OMEMO.")]:[dv("Cannot use end-to-end encryption because %1$s uses a client that doesn't support OMEMO.",t.model.contact.getDisplayName())],bu.alert("error",dv("Error"),e)}t.model.save({omemo_active:!t.model.get("omemo_active")})}function fA(e,t){const n=e.model,s=n.get("type")===ul.CHATROOMS_TYPE;let i,o;if(n.get("omemo_supported")){const e=dv("Messages are being sent in plaintext"),t=dv("Messages are sent encrypted");i=n.get("omemo_active")?t:e}else i=dv(s?"This groupchat needs to be members-only and non-anonymous in order to support OMEMO encrypted messages":"OMEMO encryption is not supported");return o=n.get("omemo_supported")?n.get("omemo_active")?s?"var(--muc-color)":"var(--chat-toolbar-btn-color)":"var(--error-color)":"var(--muc-toolbar-btn-disabled-color)",t.push(Kd` `),t}async function pA(e,t){let{stanza:n}=t;const{message:s}=t;if(!s.get("is_encrypted"))return t;if(!s.get("body"))throw new Error("No message body to encrypt!");const i=await async function(e){const t=dv("Sorry, no devices found to which we can send an OMEMO encrypted message.");let n;if(e.get("type")===ul.CHATROOMS_TYPE){const t=await Promise.all(e.occupants.map((e=>cA(e.get("jid")))));n=t.reduce(((e,t)=>RE(e,t.models)),[])}else if(e.get("type")===ul.PRIVATE_CHAT_TYPE){const s=await cA(e.get("jid"));if(0===s.length){const e=new Error(t);throw e.user_facing=!0,e}const i=(await bu.omemo.devicelists.get(ul.bare_jid)).devices;n=[...i.models,...s.models]}const s=ul.omemo_store.get("device_id");n=n.filter((e=>e.get("id")!==s)),await Promise.all(n.map((e=>e.getBundle())));const i=n.filter((e=>e)).map((e=>lA(e)));if(await Promise.all(i),i.includes(null)&&(n=n.filter((e=>i[n.indexOf(e)])),0===n.length)){const e=new Error(t);throw e.user_facing=!0,e}return n}(e);n.c("encrypted",{xmlns:HE.NS.OMEMO}).c("header",{sid:ul.omemo_store.get("device_id")});const{key_and_tag:o,iv:r,payload:a}=await vA.encryptMessage(s.get("plaintext")),c=await Promise.all(i.filter((e=>-1!=e.get("trusted")&&e.get("active"))).map((e=>function(e,t){return nA(t.get("jid"),t.get("id")).encrypt(e).then((e=>({payload:e,device:t})))}(o,e))));return n=await function(e,t,n){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const i=t[s].payload,o=t[s].device,r=3==parseInt(i.type,10);e.c("key",{rid:o.get("id")}).t(btoa(i.body)),r&&e.attrs({prekey:r}),e.up(),s==t.length-1&&e.c("iv").t(n).up().up()}return Promise.resolve(e)}(n,c,r),n.c("payload").t(a).up().up(),n.c("store",{xmlns:HE.NS.HINTS}).up(),n.c("encryption",{xmlns:HE.NS.EME,namespace:HE.NS.OMEMO}),{message:s,stanza:n}}const vA={decryptMessage:async function(e){const t=await crypto.subtle.importKey("raw",e.key,ME,!0,["encrypt","decrypt"]),n=zE(BE(e.payload),e.tag),s={name:"AES-GCM",iv:BE(e.iv),tagLength:128};return PE(await crypto.subtle.decrypt(s,t,n))},encryptMessage:async function(e){const t=crypto.getRandomValues(new window.Uint8Array(12)),n=await crypto.subtle.generateKey(ME,!0,["encrypt","decrypt"]),s={name:"AES-GCM",iv:t,tagLength:128},i=await crypto.subtle.encrypt(s,n,FE(e)),o=i.byteLength-16,r=i.slice(0,o),a=i.slice(o),c=await crypto.subtle.exportKey("raw",n);return{key:c,tag:a,key_and_tag:zE(c,a),payload:UE(r),iv:UE(t)}},formatFingerprint:JE},_A=e=>{const t=dv("OMEMO Fingerprints"),n=dv("No OMEMO-enabled devices found"),s=e.devicelist.devices;return Kd`
    • ${t}
    • ${s.length?s.map((t=>((e,t)=>{const n=dv("Trusted"),s=dv("Untrusted");return t.get("bundle")&&t.get("bundle").fingerprint?Kd`
    • ${JE(t.get("bundle").fingerprint)}
    • `:""})(e,t))):Kd`
    • ${n}
    • `}
    `};bu.elements.define("converse-omemo-fingerprints",class extends hv{static get properties(){return{jid:{type:String}}}async initialize(){this.devicelist=await bu.omemo.devicelists.get(this.jid,!0),this.listenTo(this.devicelist.devices,"change:bundle",this.requestUpdate),this.listenTo(this.devicelist.devices,"change:trusted",this.requestUpdate),this.listenTo(this.devicelist.devices,"remove",this.requestUpdate),this.listenTo(this.devicelist.devices,"add",this.requestUpdate),this.listenTo(this.devicelist.devices,"reset",this.requestUpdate),this.requestUpdate()}render(){return this.devicelist?_A(this):""}toggleDeviceTrust(e){const t=e.target;this.devicelist.devices.get(t.getAttribute("name")).save("trusted",parseInt(t.value,10))}});const yA=e=>Kd` ${e.device.get("bundle")&&e.device.get("bundle").fingerprint?(e=>{const t=dv("Checkbox for selecting the following fingerprint");return Kd`
  • `})(e):(e=>{const t=dv("Device without a fingerprint"),n=dv("Checkbox for selecting the following device");return Kd`
  • `})(e)} `,bA=e=>{var t;const n=dv("This device's OMEMO fingerprint"),s=dv("Generate new keys and fingerprint");return Kd`
    • ${n}
    • ${e.current_device&&e.current_device.get("bundle")&&e.current_device.get("bundle").fingerprint?(e=>Kd` ${JE(e.current_device.get("bundle").fingerprint)}`)(e):Jb()}
    ${null!==(t=e.other_devices)&&void 0!==t&&t.length?(e=>{var t;const n=dv("Other OMEMO-enabled devices"),s=dv("Checkbox to select fingerprints of all other OMEMO devices"),i=dv("Remove checked devices and close"),o=dv("Select all");return Kd`
    • ${null===(t=e.other_devices)||void 0===t?void 0:t.map((t=>yA(Object.assign({device:t},e))))}
    `})(e):""}
    `},{Strophe:wA,sizzle:SA,u:xA}=Su.env;bu.elements.define("converse-omemo-profile",class extends hv{async initialize(){this.devicelist=await bu.omemo.devicelists.get(ul.bare_jid,!0),await this.setAttributes(),this.listenTo(this.devicelist.devices,"change:bundle",(()=>this.requestUpdate())),this.listenTo(this.devicelist.devices,"reset",(()=>this.requestUpdate())),this.listenTo(this.devicelist.devices,"reset",(()=>this.requestUpdate())),this.listenTo(this.devicelist.devices,"remove",(()=>this.requestUpdate())),this.listenTo(this.devicelist.devices,"add",(()=>this.requestUpdate())),this.requestUpdate()}async setAttributes(){this.device_id=await bu.omemo.getDeviceID(),this.current_device=this.devicelist.devices.get(this.device_id),this.other_devices=this.devicelist.devices.filter((e=>e.get("id")!==this.device_id))}render(){return this.devicelist?bA(this):""}selectAll(e){let t=xA.ancestor(e.target,"li");for(;t;)t.querySelector('input[type="checkbox"]').checked=e.target.checked,t=t.nextElementSibling}async removeSelectedFingerprints(e){e.preventDefault(),e.stopPropagation(),e.target.querySelector(".select-all").checked=!1;const t=SA('.fingerprint-removal-item input[type="checkbox"]:checked',e.target).map((e=>e.value));try{await this.devicelist.removeOwnDevices(t)}catch(e){z.error(e),ul.api.alert(wA.LogLevel.ERROR,dv("Error"),[dv("Sorry, an error occurred while trying to remove the devices.")])}await this.setAttributes(),this.requestUpdate()}async generateOMEMODeviceBundle(e){e.preventDefault(),confirm(dv("Are you sure you want to generate new OMEMO keys? This will remove your old keys and all previously encrypted messages will no longer be decryptable on this device."))&&(await bu.omemo.bundle.generate(),await this.setAttributes(),this.requestUpdate())}});const EA=e=>{const t=dv("Settings"),n=dv("%1$s Open Source %2$s XMPP chat client brought to you by %3$s Opkode %2$s",'',"",''),s=dv("%1$s Translate %2$s it into your own language",'',""),i=bu.settings.get("show_client_info"),o=bu.settings.get("allow_adhoc_commands");return Kd` `};let AA;const CA=Uv.extend({id:"converse-client-info-modal",initialize(e){AA=e._converse,Uv.prototype.initialize.apply(this,arguments)},toHTML(){return EA(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{version_name:AA.VERSION_NAME}))}});const kA=e=>{var t,n,s;const i=e.model.get("status")||"offline",o=(null===(t=e.model.vcard)||void 0===t?void 0:t.get("fullname"))||ul.bare_jid,r=e.model.get("status_message")||dv("I am %1$s","chat"===(a=i)?dv("online"):"dnd"===a?dv("busy"):"xa"===a?dv("away for long"):"away"===a?dv("away"):"offline"===a?dv("offline"):dv(a)||dv("online"));var a;const c=dv("Click to change your chat status"),l=bu.settings.get("show_client_info")||bu.settings.get("allow_adhoc_commands");let d,u;return[d,u]="online"===i?["fa fa-circle chat-status","chat-status-online"]:"dnd"===i?["fa fa-minus-circle chat-status","chat-status-busy"]:"away"===i?["fa fa-circle chat-status","chat-status-away"]:["fa fa-circle chat-status","subdued-color"],Kd`
    ${o} ${l?function(e){const t=dv("Show details about this chat client");return Kd` `}(e):""} ${bu.settings.get("allow_logout")?function(e){const t=dv("Log out");return Kd` `}(e):""}
    `};bu.elements.define("converse-user-profile",class extends hv{initialize(){this.model=ul.xmppstatus,this.listenTo(this.model,"change",this.requestUpdate),this.listenTo(this.model,"vcard:add",this.requestUpdate),this.listenTo(this.model,"vcard:change",this.requestUpdate)}render(){return kA(this)}showProfileModal(e){null==e||e.preventDefault(),bu.modal.show(ul.ProfileModal,{model:this.model},e)}showStatusChangeModal(e){null==e||e.preventDefault(),bu.modal.show(ul.ChatStatusModal,{model:this.model},e)}showUserSettingsModal(e){null==e||e.preventDefault(),bu.modal.show(CA,{model:this.model,_converse:ul},e)}logout(e){null==e||e.preventDefault();!0===confirm(dv("Are you sure you want to log out?"))&&bu.user.logout()}});const jA=Su.env.utils,TA=Uv.extend({id:"modal-status-change",events:{"submit form#set-xmpp-status":"onFormSubmitted","click .clear-input":"clearStatusMessage"},toHTML(){return(e=>Kd` `)(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{label_away:dv("Away"),label_busy:dv("Busy"),label_cancel:dv("Cancel"),label_close:dv("Close"),label_custom_status:dv("Custom status"),label_offline:dv("Offline"),label_online:dv("Online"),label_save:dv("Save"),label_xa:dv("Away for long"),modal_title:dv("Change chat status"),placeholder_status_message:dv("Personal status message")}))},afterRender(){this.el.addEventListener("shown.bs.modal",(()=>{this.el.querySelector('input[name="status_message"]').focus()}),!1)},clearStatusMessage(e){e&&e.preventDefault&&(e.preventDefault(),jA.hideElement(this.el.querySelector(".clear-input")));this.el.querySelector('input[name="status_message"]').value=""},onFormSubmitted(e){e.preventDefault();const t=new FormData(e.target);this.model.save({status_message:t.get("status_message"),status:t.get("chat_status")}),this.modal.hide()}});ul.ChatStatusModal=TA;const $A=dv("Your profile picture");bu.elements.define("converse-image-picker",class extends hv{static get properties(){return{height:{type:Number},data:{type:Object},width:{type:Number}}}render(){return Kd` `}openFileSelection(e){e.preventDefault(),this.querySelector('input[type="file"]').click()}updateFilePreview(e){const t=e.target.files[0],n=new FileReader;n.onloadend=()=>{this.data={data_uri:n.result,image_type:t.type}},n.readAsDataURL(t)}});const NA=e=>{var t,n;const s=dv("Your Profile"),i=dv("Email"),o=dv("Full Name"),r=dv("XMPP Address"),a=dv("Nickname"),c=dv("Role"),l=dv("Save and close"),d=dv("Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages."),u=dv("URL"),h=dv("OMEMO"),m=dv("Profile"),g=Kd``;return Kd` `};var OA=n(577),IA=n.n(OA);const{sizzle:MA}=Su.env,RA=new(IA())({targetSize:.1,quality:.75,maxWidth:256,maxHeight:256}),DA=Uv.extend({id:"user-profile-modal",events:{"submit .profile-form":"onFormSubmitted"},initialize(){this.listenTo(this.model,"change",this.render),Uv.prototype.initialize.apply(this,arguments),bu.trigger("profileModalInitialized",this.model)},toHTML(){return NA(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{view:this}))},afterRender(){this.tabs=MA(".nav-item .nav-link",this.el).map((e=>new(Nv().Tab)(e)))},async setVCard(e){try{await bu.vcard.set(ul.bare_jid,e)}catch(e){return z.fatal(e),void this.alert([dv("Sorry, an error happened while trying to save your profile data."),dv("You can check your browser's developer console for any error output.")].join(" "))}this.modal.hide()},onFormSubmitted(e){e.preventDefault();const t=new FileReader,n=new FormData(e.target),s=n.get("image"),i={fn:n.get("fn"),nickname:n.get("nickname"),role:n.get("role"),email:n.get("email"),url:n.get("url")};if(s.size){const e=[s];RA.compress(e).then((e=>{const{photo:n}=e[0];t.onloadend=()=>{Object.assign(i,{image:btoa(t.result),image_type:s.type}),this.setVCard(i)},t.readAsBinaryString(n.data)}))}else Object.assign(i,{image:this.model.vcard.get("image"),image_type:this.model.vcard.get("image_type")}),this.setVCard(i)}});ul.ProfileModal=DA;Su.plugins.add("converse-profile",{dependencies:["converse-status","converse-modal","converse-vcard","converse-chatboxviews"],initialize(){bu.settings.extend({allow_adhoc_commands:!0,show_client_info:!0})}});const zA={generateFingerprints:async function(e){const t=await cA(e);return Promise.all(t.map((e=>aA(e))))},getDeviceForContact:function(e,t){return cA(e).then((e=>e.get(t)))},contactHasOMEMOSupport:async function(e){return(await cA(e)).length>0}},LA=zA;class PA extends Error{constructor(e,t){super(e,t),this.name="IQError",this.iq=t}}const{Strophe:FA,sizzle:UA,u:BA,$iq:qA}=Su.env,HA=Ac.extend({defaults:{trusted:0,active:!0},getRandomPreKey(){const e=this.get("bundle");return e.prekeys[BA.getRandomInt(e.prekeys.length)]},async fetchBundleFromServer(){const e=qA({type:"get",from:ul.bare_jid,to:this.get("jid")}).c("pubsub",{xmlns:FA.NS.PUBSUB}).c("items",{node:`${FA.NS.OMEMO_BUNDLES}:${this.get("id")}`});let t;try{t=await bu.sendIQ(e)}catch(t){return z.error(`Could not fetch bundle for device ${this.get("id")} from ${this.get("jid")}`),z.error(t),null}if(t.querySelector("error"))throw new PA("Could not fetch bundle",t);const n=UA(`items[node="${FA.NS.OMEMO_BUNDLES}:${this.get("id")}"]`,t).pop(),s=rA(UA(`bundle[xmlns="${FA.NS.OMEMO}"]`,n).pop());return this.save("bundle",s),s},getBundle(){return this.get("bundle")?Promise.resolve(this.get("bundle"),this):this.fetchBundleFromServer()}}),{Strophe:GA,$build:WA,$iq:VA,sizzle:JA}=Su.env,QA=Ac.extend({idAttribute:"jid",async initialize(){this.initialized=ba(),await this.initDevices(),this.initialized.resolve()},initDevices(){this.devices=new ul.Devices;const e=`converse.devicelist-${ul.bare_jid}-${this.get("jid")}`;return La(this.devices,e),this.fetchDevices()},async onDevicesFound(e){if(0===e.length){let e=[];try{e=await this.fetchDevicesFromServer()}catch(e){null===e?z.error(`Timeout error while fetching devices for ${this.get("jid")}`):(z.error(`Could not fetch devices for ${this.get("jid")}`),z.error(e)),this.destroy()}this.get("jid")===ul.bare_jid&&this.publishCurrentDevice(e)}},fetchDevices(){return void 0===this._devices_promise&&(this._devices_promise=new Promise((e=>{this.devices.fetch({success:t=>e(this.onDevicesFound(t)),error:(t,n)=>{z.error(n),e()}})}))),this._devices_promise},async getOwnDeviceId(){let e=ul.omemo_store.get("device_id");return this.devices.get(e)||(await ul.omemo_store.generateBundle(),e=ul.omemo_store.get("device_id")),e},async publishCurrentDevice(e){if(this.get("jid")===ul.bare_jid){if(await uA(),ul.omemo_store)return e.includes(await this.getOwnDeviceId())?void 0:this.publishDevices();z.warn("publishCurrentDevice: omemo_store is not defined, likely a timing issue")}},async fetchDevicesFromServer(){const e=VA({type:"get",from:ul.bare_jid,to:this.get("jid")}).c("pubsub",{xmlns:GA.NS.PUBSUB}).c("items",{node:GA.NS.OMEMO_DEVICELIST}),t=await bu.sendIQ(e),n=`list[xmlns="${GA.NS.OMEMO}"] device`,s=JA(n,t).map((e=>e.getAttribute("id"))),i=this.get("jid");return Promise.all(s.map((e=>this.devices.create({id:e,jid:i},{promise:!0}))))},publishDevices(){const e=WA("item",{id:"current"}).c("list",{xmlns:GA.NS.OMEMO});this.devices.filter((e=>e.get("active"))).forEach((t=>e.c("device",{id:t.get("id")}).up()));return bu.pubsub.publish(null,GA.NS.OMEMO_DEVICELIST,e,{"pubsub#access_model":"open"},!1)},async removeOwnDevices(e){if(this.get("jid")!==ul.bare_jid)throw new Error("Cannot remove devices from someone else's device list");return await Promise.all(e.map((e=>this.devices.get(e))).map((e=>new Promise((t=>e.destroy({success:t,error:(e,n)=>{z.error(n),t()}})))))),this.publishDevices()}}),ZA=QA,KA=ld.extend({model:ZA}),YA=ld.extend({model:HA});var XA=Math.ceil,eC=Math.max;const tC=function(e,t,n,s){for(var i=-1,o=eC(XA((t-e)/(n||1)),0),r=Array(o);o--;)r[s?o:++i]=e,e+=n;return r};const nC=function(e){return function(t,n,s){return s&&"number"!=typeof s&&st(t,n,s)&&(n=s=void 0),t=ui(t),void 0===n?(n=t,t=0):n=ui(n),s=void 0===s?t!!t.startsWith("session"+e)&&t)),n={};return t.forEach((e=>{n[e]=void 0})),this.save(n),Promise.resolve()},publishBundle(){const e=this.get("signed_prekey"),t=`${sC.NS.OMEMO_BUNDLES}:${this.get("device_id")}`,n=iC("item").c("bundle",{xmlns:sC.NS.OMEMO}).c("signedPreKeyPublic",{signedPreKeyId:e.id}).t(e.pubKey).up().c("signedPreKeySignature").t(e.signature).up().c("identityKey").t(this.get("identity_keypair").pubKey).up().c("prekeys");Object.values(this.get("prekeys")).forEach(((e,t)=>n.c("preKeyPublic",{preKeyId:t}).t(e.pubKey).up()));return bu.pubsub.publish(null,t,n,{"pubsub#access_model":"open"},!1)},async generateMissingPreKeys(){const e=Rl(Vv(nC(0,ul.NUM_PREKEYS),Number.prototype.toString),Object.keys(this.getPreKeys()));if(e.length<1)return z.warn("No missing prekeys to generate for our own device"),Promise.resolve();(await Promise.all(e.map((e=>libsignal.KeyHelper.generatePreKey(parseInt(e,10)))))).forEach((e=>this.storePreKey(e.keyId,e.keyPair)));const t=Object.keys(this.getPreKeys()).map((e=>({id:e.keyId,key:oC.arrayBufferToBase64(e.pubKey)}))),n=(await bu.omemo.devicelists.get(ul.bare_jid)).devices.get(this.get("device_id")),s=await n.getBundle();n.save("bundle",Object.assign(s,{prekeys:t}))},async generateBundle(){const e=await libsignal.KeyHelper.generateIdentityKeyPair(),t={},n=oC.arrayBufferToBase64(e.pubKey),s=await async function(){const e=(await bu.omemo.devicelists.get(ul.bare_jid,!0)).devices.pluck("id");let t=libsignal.KeyHelper.generateRegistrationId(),n=0;for(;e.includes(t);)if(t=libsignal.KeyHelper.generateRegistrationId(),n++,10===n)throw new Error("Unable to generate a unique device ID");return t.toString()}();t.identity_key=n,t.device_id=s,this.save({device_id:s,identity_keypair:{privKey:oC.arrayBufferToBase64(e.privKey),pubKey:n},identity_key:n});const i=await libsignal.KeyHelper.generateSignedPreKey(e,0);this.storeSignedPreKey(i),t.signed_prekey={id:i.keyId,public_key:oC.arrayBufferToBase64(i.keyPair.pubKey),signature:oC.arrayBufferToBase64(i.signature)};const o=await Promise.all(nC(0,ul.NUM_PREKEYS).map((e=>libsignal.KeyHelper.generatePreKey(e))));o.forEach((e=>this.storePreKey(e.keyId,e.keyPair)));const r=await bu.omemo.devicelists.get(ul.bare_jid),a=await r.devices.create({id:t.device_id,jid:ul.bare_jid},{promise:!0}),c=o.map((e=>({id:e.keyId,key:oC.arrayBufferToBase64(e.keyPair.pubKey)})));t.prekeys=c,a.save("bundle",t)},fetchSession(){return void 0===this._setup_promise&&(this._setup_promise=new Promise(((e,t)=>{this.fetch({success:()=>{this.get("device_id")?e():this.generateBundle().then(e).catch(t)},error:(n,s)=>{z.warn("Could not fetch OMEMO session from cache, we'll generate a new one."),z.warn(s),this.generateBundle().then(e).catch(t)}})}))),this._setup_promise}}),aC=rC,cC={omemo:{getDeviceID:async()=>(await bu.waitUntil("OMEMOInitialized"),ul.omemo_store.get("device_id")),devicelists:{async get(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=ul.devicelists.get(e)||(t?ul.devicelists.create({jid:e}):null);return await(null==n?void 0:n.initialized),n}},bundle:{generate:async()=>{await bu.waitUntil("OMEMOInitialized");const e=await bu.omemo.devicelists.get(ul.bare_jid),t=ul.omemo_store.get("device_id");if(t){const n=e.devices.get(t);ul.omemo_store.unset(t),n&&await new Promise((e=>n.destroy({success:e,error:e}))),e.devices.trigger("remove")}await ul.omemo_store.generateBundle(),await e.publishDevices();const n=aA(e.devices.get(ul.omemo_store.get("device_id")));return await ul.omemo_store.publishBundle(),n}}}},{Strophe:lC}=Su.env;Su.env.omemo=vA,lC.addNamespace("OMEMO_DEVICELIST",lC.NS.OMEMO+".devicelist"),lC.addNamespace("OMEMO_VERIFICATION",lC.NS.OMEMO+".verification"),lC.addNamespace("OMEMO_WHITELISTED",lC.NS.OMEMO+".whitelisted"),lC.addNamespace("OMEMO_BUNDLES",lC.NS.OMEMO+".bundles"),Su.plugins.add("converse-omemo",{enabled:e=>window.libsignal&&e.config.get("trusted")&&!bu.settings.get("clear_cache_on_logout")&&!e.api.settings.get("blacklisted_plugins").includes("converse-omemo"),dependencies:["converse-chatview","converse-pubsub"],initialize(){bu.settings.extend({omemo_default:!1}),bu.promises.add(["OMEMOInitialized"]),ul.NUM_PREKEYS=100,Object.assign(ul,LA),Object.assign(ul.api,cC),ul.OMEMOStore=aC,ul.Device=HA,ul.Devices=YA,ul.DeviceList=ZA,ul.DeviceLists=KA,bu.waitUntil("chatBoxesInitialized").then(eA),bu.listen.on("getOutgoingMessageAttributes",QE),bu.listen.on("createMessageStanza",(async(e,t)=>{try{t=await pA(e,t)}catch(t){!function(e,t){if("IQError"===e.name){t.save("omemo_supported",!1);const n=[];WE(`presence-subscription-required[xmlns="${HE.NS.PUBSUB_ERROR}"]`,e.iq).length?n.push(dv("Sorry, we're unable to send an encrypted message because %1$s requires you to be subscribed to their presence in order to see their OMEMO information",e.iq.getAttribute("from"))):WE('remote-server-not-found[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]',e.iq).length?n.push(dv("Sorry, we're unable to send an encrypted message because the remote server for %1$s could not be found",e.iq.getAttribute("from"))):(n.push(dv("Unable to send an encrypted message due to an unexpected error.")),n.push(e.iq.outerHTML)),bu.alert("error",dv("Error"),n)}else e.user_facing&&bu.alert("error",dv("Error"),[e.message]);throw e}(t,e)}return t})),bu.listen.on("afterFileUploaded",((e,t)=>e.file.xep454_ivkey?function(e,t){const n=t.oob_url.replace(/^https?:/,"aesgcm:")+"#"+e.file.xep454_ivkey;return Object.assign(t,{oob_url:null,message:n,body:n})}(e,t):t)),bu.listen.on("beforeFileUpload",((e,t)=>e.get("omemo_active")?async function(e){const t=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),s=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},n,await e.arrayBuffer()),i=await window.crypto.subtle.exportKey("raw",n),o=new File([s],e.name,{type:e.type,lastModified:e.lastModified});return o.xep454_ivkey=LE(t)+LE(i),o}(t):t)),bu.listen.on("parseMessage",XE),bu.listen.on("parseMUCMessage",XE),bu.listen.on("chatBoxViewInitialized",tA),bu.listen.on("chatRoomViewInitialized",tA),bu.listen.on("connected",dA),bu.listen.on("getToolbarButtons",fA),bu.listen.on("statusInitialized",hA),bu.listen.on("addClientFeatures",(()=>bu.disco.own.features.add(`${lC.NS.OMEMO_DEVICELIST}+notify`))),bu.listen.on("afterMessageBodyTransformed",YE),bu.listen.on("userDetailsModalInitialized",(e=>{const t=e.get("jid");ul.generateFingerprints(t).catch((e=>z.error(e)))})),bu.listen.on("profileModalInitialized",(()=>{ul.generateFingerprints(ul.bare_jid).catch((e=>z.error(e)))})),bu.listen.on("clearSession",(()=>{delete ul.omemo_store,ul.shouldClearCache()&&ul.devicelists&&(ul.devicelists.clearStore(),delete ul.devicelists)}))}});const{Strophe:dC,$iq:uC}=Su.env;async function hC(e){e=e||ul.bare_jid;const t=ul.session.get("push_enabled")||[];if(t.includes(e))return;const n=bu.settings.get("push_app_servers").filter((e=>!e.disable)),s=bu.settings.get("push_app_servers").filter((e=>e.disable)),i=n.map((t=>async function(e,t){if(!t.jid||!t.node)return;if(!await bu.disco.getIdentity("pubsub","push",t.jid))return z.warn(`Not enabling push the service "${t.jid}", it doesn't have the right disco identtiy.`);const n=await Promise.all([bu.disco.supports(dC.NS.PUSH,t.jid),bu.disco.supports(dC.NS.PUSH,e)]);if(!n[0]&&!n[1])return void z.warn(`Not enabling push app server "${t.jid}", no disco support from your server.`);const s=uC({type:"set"});return e!==ul.bare_jid&&s.attrs({to:e}),s.c("enable",{xmlns:dC.NS.PUSH,jid:t.jid,node:t.node}),t.secret&&s.c("x",{xmlns:dC.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE"}).c("value").t(`${dC.NS.PUBSUB}#publish-options`).up().up().c("field",{var:"secret"}).c("value").t(t.secret),bu.sendIQ(s)}(e,t))),o=s.map((t=>async function(e,t){if(!t.jid)return;if(!await bu.disco.supports(dC.NS.PUSH,e||ul.bare_jid))return void z.warn(`Not disabling push app server "${t.jid}", no disco support from your server.`);const n=uC({type:"set"});e!==ul.bare_jid&&n.attrs({to:e}),n.c("disable",{xmlns:dC.NS.PUSH,jid:t.jid}),t.node&&n.attrs({node:t.node}),bu.sendIQ(n).catch((e=>{z.error(`Could not disable push app server for ${t.jid}`),z.error(e)}))}(e,t)));try{await Promise.all(i.concat(o))}catch(e){z.error("Could not enable or disable push App Server"),e&&z.error(e)}finally{t.push(e)}ul.session.save("push_enabled",t)}function mC(e){e.get("type")==ul.CHATROOMS_TYPE&&hC(dC.getDomainFromJid(e.get("jid")))}const{Strophe:gC}=Su.env;gC.addNamespace("PUSH","urn:xmpp:push:0"),Su.plugins.add("converse-push",{initialize(){bu.settings.extend({push_app_servers:[],enable_muc_push:!1}),bu.listen.on("statusInitialized",(()=>hC())),bu.settings.get("enable_muc_push")&&bu.listen.on("chatBoxesInitialized",(()=>ul.chatboxes.on("add",mC)))}});const fC=()=>{const e=bu.settings.get("registration_domain"),t=dv("Create your account"),n=dv("Please enter the XMPP provider to register with:");return Kd`
    ${t}
    ${e||(()=>{const e=bu.settings.get("domain_placeholder"),t=dv("Tip: A list of public XMPP providers is available"),n=dv("here"),s=bu.settings.get("providers_link");return Kd`

    ${t} ${n}.

    `})()}
    ${e?"":(()=>{const e=dv("Fetch registration form"),t=dv("Already have a chat account?"),n=dv("Log in here");return Kd`

    ${t}

    `})()}
    `},pC=e=>Kd` ${0===e.model.get("registration_status")?fC():""} ${1===e.model.get("registration_status")?(()=>{const e=bu.settings.get("registration_domain"),t=dv("Hold tight, we're fetching the registration form…"),n=dv("Cancel");return Kd`
    ${Jb({classes:"hor_centered"})}

    ${t}

    ${e?"":Kd` `}
    `})():""} ${2===e.model.get("registration_status")?(e=>{const t=dv("Choose a different provider"),n=dv("Already have a chat account?"),s=dv("Account Registration:"),i=dv("Log in here"),o=dv("Register"),r=bu.settings.get("registration_domain");return Kd`
    ${s} ${e.domain}

    ${e.title}

    ${e.instructions}

    ${e.form_fields}
    ${e.fields?Kd` `:""} ${r?"":Kd` `}

    ${n}

    `})(e):""} `;function vC(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{Strophe:_C,sizzle:yC,$iq:bC}=Su.env,wC=Su.env.utils,SC=1,xC=2;bu.elements.define("converse-register-panel",class extends Ew{constructor(){super(...arguments),vC(this,"id","converse-register-panel"),vC(this,"className","controlbox-pane fade-in"),vC(this,"events",{"submit form#converse-register":"onFormSubmission","click .button-cancel":"renderProviderChoiceForm"})}initialize(){this.reset();const e=ul.chatboxes.get("controlbox");this.model=e,this.listenTo(ul,"connectionInitialized",this.registerHooks),this.listenTo(this.model,"change:registration_status",this.render);const t=bu.settings.get("registration_domain");t?this.fetchRegistrationForm(t):this.model.set("registration_status",0)}render(){tu(pC({domain:this.domain,fields:this.fields,form_fields:this.form_fields,instructions:this.instructions,model:this.model,title:this.title}),this)}registerHooks(){const e=ul.connection,t=e._connect_cb.bind(e);e._connect_cb=(e,n,s)=>{this._registering?this.getRegistrationFields(e,n)&&(this._registering=!1):t(e,n,s)}}connectedCallback(){super.connectedCallback(),this.render()}getRegistrationFields(e,t){const n=ul.connection;n.connected=!0;const s=n._proto._reqToData(e);if(!s)return;if(n._proto._connect_cb(s)===_C.Status.CONNFAIL)return this.showValidationError(dv("Sorry, we're unable to connect to your chosen provider.")),!1;const i=s.getElementsByTagName("register"),o=s.getElementsByTagName("mechanism");if(0===i.length&&0===o.length)return n._proto._no_auth_received(t),!1;if(0===i.length)return n._changeConnectStatus(_C.Status.REGIFAIL),this.showValidationError(dv("Sorry, the given provider does not support in band account registration. Please try with a different provider.")),!0;n._addSysHandler(this.onRegistrationFields.bind(this),null,"iq",null,null);const r=bC({type:"get"}).c("query",{xmlns:_C.NS.REGISTER}).tree();return r.setAttribute("id",n.getUniqueId("sendIQ")),n.send(r),n.connected=!1,!0}onRegistrationFields(e){return"error"===e.getAttribute("type")?(ul.connection._changeConnectStatus(_C.Status.REGIFAIL,dv('Something went wrong while establishing a connection with "%1$s". Are you sure it exists?',this.domain)),!1):1!==e.getElementsByTagName("query").length?(ul.connection._changeConnectStatus(_C.Status.REGIFAIL,"unknown"),!1):(this.setFields(e),this.model.get("registration_status")===SC&&this.renderRegistrationForm(e),!1)}reset(e){const t={fields:{},urls:[],title:"",instructions:"",registered:!1,_registering:!1,domain:null,form_type:null};Object.assign(this,t),e&&Object.assign(this,Ja(e,Object.keys(t)))}onFormSubmission(e){e&&e.preventDefault&&e.preventDefault(),null===e.target.querySelector("input[name=domain]")?this.submitRegistrationForm(e.target):this.onProviderChosen(e.target)}onProviderChosen(e){const t=e.querySelector("input[name=domain]"),n=null==t?void 0:t.value;n?(e.querySelector("input[type=submit]").classList.add("hidden"),this.fetchRegistrationForm(n.trim())):t.classList.add("error")}async fetchRegistrationForm(e){var t;return this.model.set("registration_status",SC),this.reset({domain:_C.getDomainFromJid(e),_registering:!0}),await ul.initConnection(this.domain),null===(t=ul.connection)||void 0===t||t.connect(this.domain,"",(e=>this.onConnectStatusChanged(e))),!1}giveFeedback(e,t){let n=this.querySelector(".reg-feedback");null!==n&&n.parentNode.removeChild(n);const s=this.querySelector("form");s.insertAdjacentHTML("afterbegin",''),n=s.querySelector(".reg-feedback"),n.textContent=e,t&&n.classList.add(t)}showSpinner(){const e=this.querySelector("form");return tu(Jb(),e),this}onConnectStatusChanged(e){z.debug("converse-register: onConnectStatusChanged"),[_C.Status.DISCONNECTED,_C.Status.CONNFAIL,_C.Status.REGIFAIL,_C.Status.NOTACCEPTABLE,_C.Status.CONFLICT].includes(e)?(z.error(`Problem during registration: Strophe.Status is ${ul.CONNECTION_STATUS[e]}`),this.abortRegistration()):e===_C.Status.REGISTERED&&(z.debug("Registered successfully."),ul.connection.reset(),this.showSpinner(),["converse/login","converse/register"].includes(ul.router.history.getFragment())&&ul.router.navigate("",{replace:!0}),this.fields.password&&this.fields.username?(ul.connection.connect(this.fields.username.toLowerCase()+"@"+this.domain.toLowerCase(),this.fields.password,ul.onConnectStatusChanged),this.giveFeedback(dv("Now logging you in"),"info")):ul.giveFeedback(dv("Registered successfully")),this.reset())}getLegacyFormFields(){const e=Object.keys(this.fields).map((e=>"username"===e?ry({domain:` @${this.domain}`,name:e,type:"text",label:e,value:"",required:!0}):sy({label:e,name:e,placeholder:e,required:!0,type:"password"===e||"email"===e?e:"text",value:""}))),t=this.urls.map((e=>oy({label:"",value:e})));return[...e,...t]}getFormFields(e){return"xform"===this.form_type?Array.from(e.querySelectorAll("field")).map((t=>dm.xForm2TemplateResult(t,e,{domain:this.domain}))):this.getLegacyFormFields()}renderRegistrationForm(e){this.form_fields=this.getFormFields(e),this.model.set("registration_status",xC)}showValidationError(e){const t=this.querySelector("form");let n=t.querySelector(".form-errors");if(null===n){n='';const e=t.querySelector("p.instructions");null===e?t.insertAdjacentHTML("afterbegin",n):e.insertAdjacentHTML("afterend",n),n=t.querySelector(".form-errors")}else n.innerHTML="";n.insertAdjacentHTML("beforeend",'

    '+e+"

    "),n.classList.remove("hidden")}reportErrors(e){const t=e.querySelectorAll("error");if(t.forEach((e=>this.showValidationError(e.textContent))),!t.length){const e=dv("The provider rejected your registration attempt. Please check the values you entered for correctness.");this.showValidationError(e)}}renderProviderChoiceForm(e){e&&e.preventDefault&&e.preventDefault(),ul.connection._proto._abortAllRequests(),ul.connection.reset(),this.render()}abortRegistration(){ul.connection._proto._abortAllRequests(),ul.connection.reset(),[SC,xC].includes(this.model.get("registration_status"))?bu.settings.get("registration_domain")&&this.fetchRegistrationForm(bu.settings.get("registration_domain")):this.render()}submitRegistrationForm(e){const t=Array.from(this.querySelectorAll("input.required")).reduce(((e,t)=>""===t.value?(t.classList.add("error"),e+1):e),0);if(t)return;const n=yC(":input:not([type=button]):not([type=submit])",e),s=bC({type:"set",id:wC.getUniqueId()}).c("query",{xmlns:_C.NS.REGISTER});if("xform"===this.form_type){s.c("x",{xmlns:_C.NS.XFORM,type:"submit"});const e=n.map((e=>dm.webForm2xForm(e))).filter((e=>e));e.forEach((e=>s.cnode(e).up()))}else n.forEach((e=>s.c(e.getAttribute("name"),{},e.value)));ul.connection._addSysHandler(this._onRegisterIQ.bind(this),null,"iq",null,null),ul.connection.send(s),this.setFields(s.tree())}setFields(e){const t=e.querySelector("query"),n=yC(`x[xmlns="${_C.NS.XFORM}"]`,t);n.length>0?this._setFieldsFromXForm(n.pop()):this._setFieldsFromLegacy(t)}_setFieldsFromLegacy(e){[].forEach.call(e.children,(e=>{"instructions"!==e.tagName.toLowerCase()?"x"!==e.tagName.toLowerCase()?this.fields[e.tagName.toLowerCase()]=_C.getText(e):"jabber:x:oob"===e.getAttribute("xmlns")&&this.urls.concat(yC("url",e).map((e=>e.textContent))):this.instructions=_C.getText(e)})),this.form_type="legacy"}_setFieldsFromXForm(e){var t,n;this.title=null===(t=e.querySelector("title"))||void 0===t?void 0:t.textContent,this.instructions=null===(n=e.querySelector("instructions"))||void 0===n?void 0:n.textContent,e.querySelectorAll("field").forEach((e=>{const t=e.getAttribute("var");var n;t?this.fields[t.toLowerCase()]=(null===(n=e.querySelector("value"))||void 0===n?void 0:n.textContent)??"":z.warn("Found field we couldn't parse")})),this.form_type="xform"}_onRegisterIQ(e){if("error"===e.getAttribute("type")){z.error("Registration failed."),this.reportErrors(e);let t=e.getElementsByTagName("error");if(1!==t.length)return ul.connection._changeConnectStatus(_C.Status.REGIFAIL,"unknown"),!1;t=t[0].firstElementChild.tagName.toLowerCase(),"conflict"===t?ul.connection._changeConnectStatus(_C.Status.CONFLICT,t):"not-acceptable"===t?ul.connection._changeConnectStatus(_C.Status.NOTACCEPTABLE,t):ul.connection._changeConnectStatus(_C.Status.REGIFAIL,t)}else ul.connection._changeConnectStatus(_C.Status.REGISTERED,null);return!1}});const{Strophe:EC}=Su.env;EC.addNamespace("REGISTER","jabber:iq:register");const AC=Object.keys(EC.Status).reduce(((e,t)=>Math.max(e,EC.Status[t])),0);EC.Status.REGIFAIL=AC+1,EC.Status.REGISTERED=AC+2,EC.Status.CONFLICT=AC+3,EC.Status.NOTACCEPTABLE=AC+5,Su.plugins.add("converse-register",{dependencies:["converse-controlbox"],enabled:()=>!0,initialize(){async function e(e){await bu.waitUntil("controlBoxInitialized");ul.chatboxes.get("controlbox").set({"active-form":e})}ul.CONNECTION_STATUS[EC.Status.REGIFAIL]="REGIFAIL",ul.CONNECTION_STATUS[EC.Status.REGISTERED]="REGISTERED",ul.CONNECTION_STATUS[EC.Status.CONFLICT]="CONFLICT",ul.CONNECTION_STATUS[EC.Status.NOTACCEPTABLE]="NOTACCEPTABLE",bu.settings.extend({allow_registration:!0,domain_placeholder:dv(" e.g. conversejs.org"),providers_link:"https://compliance.conversations.im/",registration_domain:""}),ul.router.route("converse/login",(()=>e("login"))),ul.router.route("converse/register",(()=>e("register"))),bu.listen.on("controlBoxInitialized",(e=>{e.model.on("change:active-form",e.showLoginOrRegisterForm,e)}))}});const{Strophe:CC}=Su.env,kC=Ac.extend({defaults:function(){return{muc_domain:bu.settings.get("muc_domain"),nick:ul.getDefaultMUCNickname(),"toggle-state":ul.OPENED}},initialize(){bu.settings.listen.on("change:muc_domain",(e=>this.setDomain(e)))},setDomain(e){bu.settings.get("locked_muc_domain")||this.save("muc_domain",CC.getDomainFromJid(e))}}),jC=e=>{const t=dv("Join"),n=dv("Enter a new Groupchat");return Kd` `},TC=Su.env.utils,{Strophe:$C}=Su.env,NC=Uv.extend({persistent:!0,id:"add-chatroom-modal",events:{"submit form.add-chatroom":"openChatRoom","keyup .roomjid-input":"checkRoomidPolicy","change .roomjid-input":"checkRoomidPolicy"},initialize(){Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:muc_domain",this.render),this.muc_roomid_policy_error_msg=null},toHTML(){let e="";if(!bu.settings.get("locked_muc_domain")){const t=this.model.get("muc_domain")||bu.settings.get("muc_domain");e=t?`name@${t}`:dv("name@conference.example.org")}return jC(Object.assign(this.model.toJSON(),{_converse:ul,label_room_address:bu.settings.get("muc_domain")?dv("Groupchat name"):dv("Groupchat address"),chatroom_placeholder:e,muc_roomid_policy_error_msg:this.muc_roomid_policy_error_msg,muc_roomid_policy_hint:bu.settings.get("muc_roomid_policy_hint")}))},afterRender(){this.el.addEventListener("shown.bs.modal",(()=>{this.el.querySelector('input[name="chatroom"]').focus()}),!1)},parseRoomDataFromEvent(e){const t=new FormData(e),n=t.get("chatroom");let s;if(bu.settings.get("locked_muc_nickname")){if(s=ul.getDefaultMUCNickname(),!s)throw new Error("Using locked_muc_nickname but no nickname found!")}else s=t.get("nickname").trim();return{jid:n,nick:s}},openChatRoom(e){e.preventDefault();const t=this.parseRoomDataFromEvent(e.target);let n;""===t.nick&&(t.nick=void 0),bu.settings.get("locked_muc_domain")||bu.settings.get("muc_domain")&&!TC.isValidJID(t.jid)?n=`${$C.escapeNode(t.jid)}@${bu.settings.get("muc_domain")}`:(n=t.jid,this.model.setDomain(n)),bu.rooms.open(n,Object.assign(t,{jid:n}),!0),this.modal.hide(),e.target.reset()},checkRoomidPolicy(){if(bu.settings.get("muc_roomid_policy")&&bu.settings.get("muc_domain")){let e=this.el.querySelector(".roomjid-input").value;!bu.settings.get("locked_muc_domain")&&TC.isValidJID(e)||(e=`${$C.escapeNode(e)}@${bu.settings.get("muc_domain")}`);const t=$C.getNodeFromJid(e),n=$C.getDomainFromJid(e);bu.settings.get("muc_domain")!==n||bu.settings.get("muc_roomid_policy").test(t)?this.muc_roomid_policy_error_msg=null:this.muc_roomid_policy_error_msg=dv("Groupchat id is invalid."),this.render()}}});const OC=function(e){return e&&e.length?e[0]:void 0},IC=e=>{const t=dv("Query for Groupchats");return Kd` `},{Strophe:MC,$iq:RC,sizzle:DC}=Su.env,zC=Su.env.utils;function LC(e,t){var n,s;e.querySelector("span.spinner").remove(),e.querySelector("a.room-info").classList.add("selected"),e.insertAdjacentHTML("beforeEnd",zC.getElementFromTemplateResult((e=>{const t=dv("Description:"),n=dv("Groupchat XMPP Address:"),s=dv("Participants:"),i=dv("Features:"),o=dv("Requires authentication"),r=dv("Hidden"),a=dv("Requires an invitation"),c=dv("Moderated"),l=dv("Non-anonymous"),d=dv("Open"),u=dv("Permanent"),h=dv("Public"),m=dv("Semi-anonymous"),g=dv("Temporary"),f=dv("Unmoderated");return Kd`

    ${n} ${e.jid}

    ${t} ${e.desc}

    ${s} ${e.occ}

    ${i}

      ${e.passwordprotected?Kd`
    • ${o}
    • `:""} ${e.hidden?Kd`
    • ${r}
    • `:""} ${e.membersonly?Kd`
    • ${a}
    • `:""} ${e.moderated?Kd`
    • ${c}
    • `:""} ${e.nonanonymous?Kd`
    • ${l}
    • `:""} ${e.open?Kd`
    • ${d}
    • `:""} ${e.persistent?Kd`
    • ${u}
    • `:""} ${e.publicroom?Kd`
    • ${h}
    • `:""} ${e.semianonymous?Kd`
    • ${m}
    • `:""} ${e.temporary?Kd`
    • ${g}
    • `:""} ${e.unmoderated?Kd`
    • ${f}
    • `:""}

    `})({jid:t.getAttribute("from"),desc:null===(n=OC(DC('field[var="muc#roominfo_description"] value',t)))||void 0===n?void 0:n.textContent,occ:null===(s=OC(DC('field[var="muc#roominfo_occupants"] value',t)))||void 0===s?void 0:s.textContent,hidden:DC('feature[var="muc_hidden"]',t).length,membersonly:DC('feature[var="muc_membersonly"]',t).length,moderated:DC('feature[var="muc_moderated"]',t).length,nonanonymous:DC('feature[var="muc_nonanonymous"]',t).length,open:DC('feature[var="muc_open"]',t).length,passwordprotected:DC('feature[var="muc_passwordprotected"]',t).length,persistent:DC('feature[var="muc_persistent"]',t).length,publicroom:DC('feature[var="muc_publicroom"]',t).length,semianonymous:DC('feature[var="muc_semianonymous"]',t).length,temporary:DC('feature[var="muc_temporary"]',t).length,unmoderated:DC('feature[var="muc_unmoderated"]',t).length})))}const PC=Uv.extend({id:"muc-list-modal",persistent:!0,initialize(){this.items=[],this.loading_items=!1,Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:muc_domain",this.onDomainChange),this.listenTo(this.model,"change:feedback_text",(()=>this.render())),this.el.addEventListener("shown.bs.modal",(()=>bu.settings.get("locked_muc_domain")?this.updateRoomsList():this.el.querySelector('input[name="server"]').focus())),this.model.save("feedback_text","")},toHTML(){return IC(Object.assign(this.model.toJSON(),{show_form:!bu.settings.get("locked_muc_domain"),server_placeholder:this.model.get("muc_domain")||dv("conference.example.org"),items:this.items,loading_items:this.loading_items,openRoom:e=>this.openRoom(e),setDomainFromEvent:e=>this.setDomainFromEvent(e),submitForm:e=>this.showRooms(e),toggleRoomInfo:e=>this.toggleRoomInfo(e)}))},openRoom(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid"),n=e.target.getAttribute("data-room-name");this.modal.hide(),bu.rooms.open(t,{name:n},!0)},toggleRoomInfo(e){e.preventDefault(),function(e){const t=zC.ancestor(e.target,".room-item"),n=t.querySelector("div.room-info");n?(zC.slideIn(n).then(zC.removeElement),t.querySelector("a.room-info").classList.remove("selected")):(t.insertAdjacentElement("beforeend",zC.getElementFromTemplateResult(Jb())),bu.disco.info(e.target.getAttribute("data-room-jid"),null).then((e=>LC(t,e))).catch((e=>z.error(e))))}(e)},onDomainChange(){bu.settings.get("auto_list_rooms")&&this.updateRoomsList()},onRoomsFound(e){this.loading_items=!1;const t=e?DC("query item",e):[];return t.length?(this.model.set({feedback_text:dv("Groupchats found")},{silent:!0}),this.items=t.map(ah)):(this.items=[],this.model.set({feedback_text:dv("No groupchats found")},{silent:!0})),this.render(),!0},updateRoomsList(){const e=RC({to:this.model.get("muc_domain"),from:ul.connection.jid,type:"get"}).c("query",{xmlns:MC.NS.DISCO_ITEMS});bu.sendIQ(e).then((e=>this.onRoomsFound(e))).catch((()=>this.onRoomsFound()))},showRooms(e){e.preventDefault(),this.loading_items=!0,this.render();const t=new FormData(e.target);this.model.setDomain(t.get("server")),this.updateRoomsList()},setDomainFromEvent(e){this.model.setDomain(e.target.value)},setNick(e){this.model.save({nick:e.target.value})}}),FC=e=>{const t=dv("Leave this groupchat"),n=e.room.get("num_unread_general")||e.room.get("has_activity");return Kd`
    ${e.room.get("num_unread")?(e=>Kd`${e.room.get("num_unread")}`)(e):e.room.get("has_activity")?Kd``:""} ${e.room.getDisplayName()} ${bu.settings.get("allow_bookmarks")?(e=>{const t=dv("Bookmark this groupchat"),n=dv("Unbookmark this groupchat");return e.bookmarked?Kd` `:Kd` `})(e):""}
    `},{Strophe:UC,u:BC}=Su.env;bu.elements.define("converse-rooms-list",class extends hv{initialize(){const e=`converse.roomspanel${ul.bare_jid}`;this.model=new kC({id:e}),La(this.model,e),this.model.fetch(),this.listenTo(ul.chatboxes,"add",this.renderIfChatRoom),this.listenTo(ul.chatboxes,"remove",this.renderIfChatRoom),this.listenTo(ul.chatboxes,"destroy",this.renderIfChatRoom),this.listenTo(ul.chatboxes,"change",this.renderIfRelevantChange),this.requestUpdate()}renderIfChatRoom(e){BC.isChatRoom(e)&&this.requestUpdate()}renderIfRelevantChange(e){const t=["bookmarked","hidden","name","num_unread","num_unread_general","has_activity"],n=e.changed||{};BC.isChatRoom(e)&&Object.keys(n).filter((e=>t.includes(e))).length&&this.requestUpdate()}render(){return(e=>{const t=dv("Click to toggle the list of open groupchats"),n=dv("Groupchats"),s=dv("Query for groupchats"),i=dv("Add a new groupchat");return Kd`
    ${dv("Open Groupchats")}
    ${e.rooms.map((t=>FC(Object.assign({room:t},e))))}
    `})({addBookmark:e=>this.addBookmark(e),allow_bookmarks:bu.settings.get("allow_bookmarks")&&ul.bookmarks,closeRoom:e=>this.closeRoom(e),collapsed:this.model.get("toggle-state")!==ul.OPENED,currently_open:e=>Hc()&&!e.get("hidden"),model:this.model,openRoom:e=>this.openRoom(e),removeBookmark:e=>this.removeBookmark(e),rooms:ul.chatboxes.filter((e=>e.get("type")===ul.CHATROOMS_TYPE)),showRoomDetailsModal:e=>this.showRoomDetailsModal(e),toggleRoomsList:e=>this.toggleRoomsList(e),toggle_state:this.model.get("toggle-state")})}showRoomDetailsModal(e){const t=e.target.getAttribute("data-room-jid"),n=ul.chatboxes.get(t);e.preventDefault(),bu.modal.show(rE,{model:n},e)}async openRoom(e){e.preventDefault();const t=e.target.textContent,n=e.target.getAttribute("data-room-jid"),s={name:t||UC.unescapeNode(UC.getNodeFromJid(n))||n};await bu.rooms.open(n,s,!0)}async closeRoom(e){e.preventDefault();const t=e.target.getAttribute("data-room-name");if(confirm(dv("Are you sure you want to leave the groupchat %1$s?",t))){const t=e.target.getAttribute("data-room-jid");(await bu.rooms.get(t)).close()}}removeBookmark(e){ul.removeBookmarkViaEvent(e)}addBookmark(e){ul.addBookmarkViaEvent(e)}toggleRoomsList(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const n=e.target.matches(".fa")?e.target:e.target.querySelector(".fa");n.classList.contains("fa-caret-down")?BC.slideIn(this.querySelector(".open-rooms-list")).then((()=>{this.model.save({"toggle-state":ul.CLOSED}),n.classList.remove("fa-caret-down"),n.classList.add("fa-caret-right")})):BC.slideOut(this.querySelector(".open-rooms-list")).then((()=>{this.model.save({"toggle-state":ul.OPENED}),n.classList.remove("fa-caret-right"),n.classList.add("fa-caret-down")}))}}),Su.plugins.add("converse-roomslist",{dependencies:["converse-singleton","converse-controlbox","converse-muc","converse-bookmarks"],initialize(){}});window.customElements.define("converse-fontawesome",class extends hv{render(){return Kd` `}});function qC(){if(!bu.settings.get("auto_insert"))return;const e=bu.settings.get("root");if(!e.querySelector("converse-root")){const t=document.createElement("converse-root"),n=e.querySelector("body");n?n.appendChild(t):e.appendChild(t)}}var HC=n(1513),GC={};GC.styleTagTransform=Av(),GC.setAttributes=wv(),GC.insert=yv().bind(null,"head"),GC.domAPI=vv(),GC.insertStyleElement=xv();fv()(HC.Z,GC);HC.Z&&HC.Z.locals&&HC.Z.locals;class WC extends hv{render(){return(()=>{const e=bu.settings.get("singleton")?["converse-singleton"]:[];return e.push(`converse-${bu.settings.get("view_mode")}`),Kd`
    `})()}initialize(){this.setAttribute("id","conversejs"),this.setClasses();const e=al();this.listenTo(e,"change:view_mode",(()=>this.setClasses())),this.listenTo(e,"change:singleton",(()=>this.setClasses())),window.matchMedia("(prefers-color-scheme: dark)").addListener((()=>this.setClasses())),window.matchMedia("(prefers-color-scheme: light)").addListener((()=>this.setClasses()))}setClasses(){this.className="",this.classList.add("conversejs"),this.classList.add(`converse-${bu.settings.get("view_mode")}`),this.classList.add(`theme-${window.matchMedia("(prefers-color-scheme: dark)").matches?bu.settings.get("dark_theme"):bu.settings.get("theme")}`),this.requestUpdate()}}Su.plugins.add("converse-rootview",{initialize(){bu.settings.extend({auto_insert:!0,theme:"classic",dark_theme:"dracula"}),bu.listen.on("chatBoxesInitialized",qC),bu.elements.define("converse-root",WC)}});const{Strophe:VC}=Su.env,JC=Su.env.utils,QC=Uv.extend({id:"add-contact-modal",events:{"submit form":"addContactFromForm"},initialize(){Uv.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render)},toHTML(){const e=bu.settings.get("xhr_user_search_url")?dv("Contact name"):dv("Optional nickname");return(e=>{const t=dv("name@example.org"),n=dv("Add"),s=dv("Please enter a valid XMPP address"),i=dv("Add a Contact"),o=dv("XMPP Address"),r=dv("Nickname");return Kd` `})(Object.assign(this.model.toJSON(),{_converse:ul,label_nickname:e}))},afterRender(){"string"==typeof bu.settings.get("xhr_user_search_url")?this.initXHRAutoComplete():this.initJIDAutoComplete();const e=this.el.querySelector('input[name="jid"]');this.el.addEventListener("shown.bs.modal",(()=>e.focus()),!1)},initJIDAutoComplete(){if(!bu.settings.get("autocomplete_add_contact"))return;const e=this.el.querySelector(".suggestion-box__jid").parentElement;this.jid_auto_complete=new ul.AutoComplete(e,{data:(e,t)=>`${t.slice(0,t.indexOf("@"))}@${e}`,filter:ul.FILTER_STARTSWITH,list:[...new Set(ul.roster.map((e=>VC.getDomainFromJid(e.get("jid")))))]})},initXHRAutoComplete(){if(!bu.settings.get("autocomplete_add_contact"))return this.initXHRFetch();const e=this.el.querySelector(".suggestion-box__name").parentElement;this.name_auto_complete=new ul.AutoComplete(e,{auto_evaluate:!1,filter:ul.FILTER_STARTSWITH,list:[]});const t=new window.XMLHttpRequest;t.onload=()=>{if(t.responseText){const e=t.responseText;this.name_auto_complete.list=JSON.parse(e).map((e=>({label:e.fullname||e.jid,value:e.jid}))),this.name_auto_complete.auto_completing=!0,this.name_auto_complete.evaluate()}};const n=this.el.querySelector('input[name="name"]');n.addEventListener("input",jc((()=>{t.open("GET",`${bu.settings.get("xhr_user_search_url")}q=${encodeURIComponent(n.value)}`,!0),t.send()}),300)),this.name_auto_complete.on("suggestion-box-selectcomplete",(e=>{this.el.querySelector('input[name="name"]').value=e.text.label,this.el.querySelector('input[name="jid"]').value=e.text.value}))},initXHRFetch(){this.xhr=new window.XMLHttpRequest,this.xhr.onload=()=>{if(this.xhr.responseText){const e=this.xhr.responseText,t=JSON.parse(e).map((e=>({label:e.fullname||e.jid,value:e.jid})));if(1!==t.length){const e=this.el.querySelector(".invalid-feedback");return e.textContent=dv("Sorry, could not find a contact with that name"),void JC.addClass("d-block",e)}const n=t[0].value;if(this.validateSubmission(n)){const e=this.el.querySelector("form"),s=t[0].label;this.afterSubmission(e,n,s)}}}},validateSubmission(e){const t=this.el.querySelector(".invalid-feedback");return!e||Ka(e.split("@")).length<2?(JC.addClass("is-invalid",this.el.querySelector('input[name="jid"]')),JC.addClass("d-block",t),!1):ul.roster.get(VC.getBareJidFromJid(e))?(t.textContent=dv("This contact has already been added"),JC.addClass("d-block",t),!1):(JC.removeClass("d-block",t),!0)},afterSubmission(e,t,n){ul.roster.addAndSubscribe(t,n),this.model.clear(),this.modal.hide()},addContactFromForm(e){e.preventDefault();const t=new FormData(e.target),n=(t.get("jid")||"").trim();if(!n&&"string"==typeof bu.settings.get("xhr_user_search_url")){const e=this.el.querySelector('input[name="name"]');return this.xhr.open("GET",`${bu.settings.get("xhr_user_search_url")}q=${encodeURIComponent(e.value)}`,!0),void this.xhr.send()}this.validateSubmission(n)&&this.afterSubmission(e.target,n,t.get("name"))}});ul.AddContactModal=QC;function ZC(e){var t,n;null===(t=ul.roster)||void 0===t||null===(n=t.get(e.get("jid")))||void 0===n||n.trigger("highlight")}function KC(e,t){const n=ul.roster_filter,s=n.get("filter_type"),i="state"===s?n.get("chat_state").toLowerCase():n.get("filter_text").toLowerCase();if(!i)return!1;if("state"===s){return![ul.HEADER_REQUESTING_CONTACTS,ul.HEADER_UNREAD].includes(t)&&("unread_messages"===i?0===e.get("num_unread"):"online"===i?["offline","unavailable"].includes(e.presence.get("show")):!e.presence.get("show").includes(i))}return"contacts"===s?!e.getFilterCriteria().includes(i):void 0}function YC(e){const t=ul.roster_filter;if("groups"===t.get("filter_type")){var n;const s=null===(n=t.get("filter_text"))||void 0===n?void 0:n.toLowerCase();if(!s)return!0;if(!e.toLowerCase().includes(s))return!1}return!0}const{u:XC}=Su.env;function ek(e){const t=e.get("jid"),n=[];if(Hc()){const e=ul.chatboxes.get(t);e&&!e.get("hidden")&&n.push("open")}const s=e.get("ask"),i=e.get("requesting"),o=e.get("subscription");return"subscribe"===s||"from"===o?n.push("pending-xmpp-contact"):!0===i?n.push("requesting-xmpp-contact"):("both"===o||"to"===o||XC.isSameBareJID(t,ul.connection.jid))&&(n.push("current-xmpp-contact"),n.push(o),n.push(e.presence.get("show"))),Kd`
  • `}const tk=e=>{const t=dv("Click to hide these contacts"),n=ul.roster.state.get("collapsed_groups");return Kd` `};const nk=e=>{const t=dv("Contacts"),n=dv("Add a contact"),s=dv("Re-sync your contacts"),i=(ul.roster||[]).reduce(((e,t)=>function(e,t){if("subscribe"===t.get("ask")){const n=ul.HEADER_PENDING_CONTACTS;e[n]?e[n].push(t):e[n]=[t]}else if(t.get("requesting")){const n=ul.HEADER_REQUESTING_CONTACTS;e[n]?e[n].push(t):e[n]=[t]}else{let n;bu.settings.get("roster_groups")?(n=t.get("groups"),n=0===n.length?[ul.HEADER_UNGROUPED]:n):n=[ul.HEADER_CURRENT_CONTACTS];for(const s of n)e[s]?e[s].push(t):e[s]=[t]}if(t.get("num_unread")){const n=ul.HEADER_UNREAD;e[n]?e[n].push(t):e[n]=[t]}return e}(e,t)),{}),o=Object.keys(i).filter(YC);return o.sort(sp),Kd`
    ${C_(o,(e=>e),(e=>{const t=i[e].filter((t=>function(e,t){const n=e.presence.get("show");return bu.settings.get("hide_offline_users")&&"offline"===n?("subscribe"===e.get("ask")||"from"===e.get("subscription")||!0===e.get("requesting"))&&!KC(e,t):!KC(e,t)}(t,e)));return t.sort(np),t.length?tk({contacts:t,name:e}):""}))}
    `};bu.elements.define("converse-roster",class extends hv{async initialize(){await bu.waitUntil("rosterInitialized"),this.listenTo(ul,"rosterContactsFetched",this.requestUpdate),this.listenTo(ul.presences,"change:show",this.requestUpdate),this.listenTo(ul.roster,"add",this.requestUpdate),this.listenTo(ul.roster,"destroy",this.requestUpdate),this.listenTo(ul.roster,"remove",this.requestUpdate),this.listenTo(ul.roster,"change",this.requestUpdate),this.listenTo(ul.roster.state,"change",this.requestUpdate),bu.trigger("rosterViewInitialized")}firstUpdated(){this.listenToRosterFilter()}render(){return nk(this)}listenToRosterFilter(){this.filter_view=this.querySelector("converse-roster-filter"),this.filter_view.addEventListener("update",(()=>this.requestUpdate()))}showAddContactModal(e){bu.modal.show(ul.AddContactModal,{model:new Ac},e)}async syncContacts(e){e.preventDefault(),this.syncing_contacts=!0,this.requestUpdate(),ul.roster.data.save("version",null),await ul.roster.fetchFromServer(),bu.user.presence.send(),this.syncing_contacts=!1,this.requestUpdate()}});const sk=e=>Kd`${e.display_name}`,ik=e=>Kd`${e.display_name}`,ok={dnd:dv("This contact is busy"),online:dv("This contact is online"),offline:dv("This contact is offline"),unavailable:dv("This contact is unavailable"),xa:dv("This contact is away for an extended period"),away:dv("This contact is away")},rk=(e,t)=>{var n,s;const i=t.presence.get("show")||"offline";let o,r;[o,r]="online"===i?["fa fa-circle","chat-status-online"]:"dnd"===i?["fa fa-minus-circle","chat-status-busy"]:"away"===i?["fa fa-circle","chat-status-away"]:["fa fa-circle","subdued-color"];const a=ok[i],c=t.get("num_unread")||0,l=t.getDisplayName(),d=dv("Click to chat with %1$s (XMPP address: %2$s)",l,e.model.get("jid"));return Kd` ${c?Kd`${c}`:""} ${l} ${bu.settings.get("allow_contact_removal")?((e,t)=>{const n=t.getDisplayName(),s=dv("Click to remove %1$s as a contact",n);return Kd` `})(e,t):""}`},ak=Su.env.utils;class ck extends hv{static get properties(){return{model:{type:Object}}}initialize(){this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.listenTo(this.model,"highlight",(()=>this.requestUpdate())),this.listenTo(this.model,"vcard:add",(()=>this.requestUpdate())),this.listenTo(this.model,"vcard:change",(()=>this.requestUpdate()))}render(){const e=this.model.get("ask"),t=this.model.get("requesting"),n=this.model.get("subscription"),s=this.model.get("jid");if("subscribe"===e||"from"===n){const e=this.model.getDisplayName();return(e=>{const t=dv("Click to remove %1$s as a contact",e.display_name);return Kd` ${bu.settings.get("allow_chat_pending_contacts")?Kd`${sk(e)}`:sk(e)} `})(Object.assign(this.model.toJSON(),{display_name:e,openChat:e=>this.openChat(e),removeContact:e=>this.removeContact(e)}))}if(!0===t){const e=this.model.getDisplayName();return(e=>Kd` ${bu.settings.get("allow_chat_pending_contacts")?Kd`${ik(e)}`:ik(e)} `)(Object.assign(this.model.toJSON(),{display_name:e,openChat:e=>this.openChat(e),acceptRequest:e=>this.acceptRequest(e),declineRequest:e=>this.declineRequest(e),desc_accept:dv("Click to accept the contact request from %1$s",e),desc_decline:dv("Click to decline the contact request from %1$s",e),allow_chat_pending_contacts:bu.settings.get("allow_chat_pending_contacts")}))}if("both"===n||"to"===n||ak.isSameBareJID(s,ul.connection.jid))return this.renderRosterItem(this.model)}renderRosterItem(e){return rk(this,e)}openChat(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.openChat()}removeContact(e){var t;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),bu.settings.get("allow_contact_removal")&&confirm(dv("Are you sure you want to remove this contact?")))try{this.model.removeFromRoster(),this.model.collection&&this.model.destroy()}catch(e){z.error(e),bu.alert("error",dv("Error"),[dv("Sorry, there was an error while trying to remove %1$s as a contact.",this.model.getDisplayName())])}}async acceptRequest(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),await ul.roster.sendContactAddIQ(this.model.get("jid"),this.model.getFullname(),[]),this.model.authorize().subscribe()}declineRequest(e){e&&e.preventDefault&&e.preventDefault();return!0===confirm(dv("Are you sure you want to decline this contact request?"))&&this.model.unauthorize().destroy(),this}}bu.elements.define("converse-roster-contact",ck);class lk extends hv{async initialize(){await bu.waitUntil("rosterInitialized"),this.model=ul.roster_filter,this.liveFilter=jc((()=>{this.model.save({filter_text:this.querySelector(".roster-filter").value})}),250),this.listenTo(ul,"rosterContactsFetched",(()=>this.requestUpdate())),this.listenTo(ul.presences,"change:show",(()=>this.requestUpdate())),this.listenTo(ul.roster,"add",(()=>this.requestUpdate())),this.listenTo(ul.roster,"destroy",(()=>this.requestUpdate())),this.listenTo(ul.roster,"remove",(()=>this.requestUpdate())),this.listenTo(this.model,"change",this.dispatchUpdateEvent),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.requestUpdate()}render(){return this.model?(e=>{const t=dv("Filter"),n=dv("Filter by contact name"),s=dv("Filter by group name"),i=dv("Filter by status"),o=dv("Any"),r=dv("Unread"),a=dv("Online"),c=dv("Chatty"),l=dv("Busy"),d=dv("Away"),u=dv("Extended Away"),h=dv("Offline");return Kd`
    `})(Object.assign(this.model.toJSON(),{visible:this.shouldBeVisible(),changeChatStateFilter:e=>this.changeChatStateFilter(e),changeTypeFilter:e=>this.changeTypeFilter(e),clearFilter:e=>this.clearFilter(e),liveFilter:e=>this.liveFilter(e),submitFilter:e=>this.submitFilter(e)})):""}dispatchUpdateEvent(){this.dispatchEvent(new CustomEvent("update",{detail:this.model.changed}))}changeChatStateFilter(e){e&&e.preventDefault(),this.model.save({chat_state:this.querySelector(".state-type").value})}changeTypeFilter(e){var t;e&&e.preventDefault();const n=(null===(t=yy(e.target,"converse-icon"))||void 0===t?void 0:t.dataset.type)||"contacts";"state"===n?this.model.save({filter_type:n,chat_state:this.querySelector(".state-type").value}):this.model.save({filter_type:n,filter_text:this.querySelector(".roster-filter").value})}submitFilter(e){e&&e.preventDefault(),this.liveFilter()}isActive(){return"state"===this.model.get("filter_type")||this.model.get("filter_text")}shouldBeVisible(){var e;return(null===(e=ul.roster)||void 0===e?void 0:e.length)>=5||this.isActive()}clearFilter(e){e&&e.preventDefault(),this.model.save({filter_text:""})}}bu.elements.define("converse-roster-filter",lk);var dk=n(1984),uk={};uk.styleTagTransform=Av(),uk.setAttributes=wv(),uk.insert=yv().bind(null,"head"),uk.domAPI=vv(),uk.insertStyleElement=xv();fv()(dk.Z,uk);dk.Z&&dk.Z.locals&&dk.Z.locals;Su.plugins.add("converse-rosterview",{dependencies:["converse-roster","converse-modal","converse-chatboxviews"],initialize(){bu.settings.extend({autocomplete_add_contact:!0,allow_chat_pending_contacts:!0,allow_contact_removal:!0,hide_offline_users:!1,roster_groups:!0,xhr_user_search_url:null}),bu.promises.add("rosterViewInitialized"),ul.RosterFilter=Gf,ul.RosterFilterView=lk,ul.RosterContactView=ck,bu.listen.on("chatBoxesInitialized",(()=>{ul.chatboxes.on("destroy",(e=>ZC(e))),ul.chatboxes.on("change:hidden",(e=>ZC(e)))})),bu.listen.on("afterTearDown",(()=>{var e;return null===(e=ul.rotergroups)||void 0===e?void 0:e.off().reset()}))}}),ul.CustomElement=hv;const hk=Su.initialize;Su.initialize=function(e,t){return Array.isArray(e.whitelisted_plugins)?e.whitelisted_plugins=e.whitelisted_plugins.concat(mv):e.whitelisted_plugins=mv,hk(e,t)};const mk=Su},6151:function(e,t,n){var s,i,o;i=[],void 0===(o="function"==typeof(s=function(){"use strict";var e=void 0!==n.g?n.g:this||window,t=document,s=t.documentElement,i="body",o=e.BSN={},r=o.supports=[],a="data-toggle",c="data-dismiss",l="Alert",d="Button",u="Collapse",h="Dropdown",m="Modal",g="Popover",f="Tab",p="data-backdrop",v="data-keyboard",_="data-target",y="data-height",b="data-title",w="data-dismissible",S="data-trigger",x="data-animation",E="data-container",A="data-placement",C="data-delay",k="backdrop",j="keyboard",T="delay",$="content",N="target",O="currentTarget",I="animation",M="placement",R="container",D="offsetTop",z="offsetLeft",L="scrollTop",P="scrollLeft",F="clientWidth",U="clientHeight",B="offsetWidth",q="offsetHeight",H="innerWidth",G="scrollHeight",W="height",V="aria-expanded",J="aria-hidden",Q="aria-selected",Z="click",K="focus",Y="hover",X="keydown",ee="keyup",te="resize",ne="onmouseleave"in t?["mouseenter","mouseleave"]:["mouseover","mouseout"],se="show",ie="shown",oe="hide",re="hidden",ae="close",ce="closed",le="change",de="getAttribute",ue="setAttribute",he="hasAttribute",me="createElement",ge="appendChild",fe="innerHTML",pe="getElementsByTagName",ve="preventDefault",_e="getBoundingClientRect",ye="querySelectorAll",be="getElementsByClassName",we="getComputedStyle",Se="indexOf",xe="parentNode",Ee="length",Ae="toLowerCase",Ce="Transition",ke="Duration",je="Webkit",Te="style",$e="push",Ne="tabindex",Oe="contains",Ie="active",Me="show",Re="collapsing",De="left",ze="right",Le="top",Pe="bottom",Fe=/\b(top|bottom|left|right)+/,Ue=0,Be="fixed-top",qe="fixed-bottom",He=je+Ce in s[Te]||Ce[Ae]()in s[Te],Ge=je+Ce in s[Te]?je[Ae]()+Ce+"End":Ce[Ae]()+"end",We=je+ke in s[Te]?je[Ae]()+Ce+ke:Ce[Ae]()+ke,Ve=function(e){e.focus?e.focus():e.setActive()},Je=function(e,t){e.classList.add(t)},Qe=function(e,t){e.classList.remove(t)},Ze=function(e,t){return e.classList[Oe](t)},Ke=function(e,t){return[].slice.call(e[be](t))},Ye=function(e,n){return"object"==typeof e?e:(n||t).querySelector(e)},Xe=function(e,n){var s=n.charAt(0),i=n.substr(1);if("."===s){for(;e&&e!==t;e=e[xe])if(null!==Ye(n,e[xe])&&Ze(e,i))return e}else if("#"===s)for(;e&&e!==t;e=e[xe])if(e.id===i)return e;return!1},et=function(e,t,n,s){s=s||!1,e.addEventListener(t,n,s)},tt=function(e,t,n,s){s=s||!1,e.removeEventListener(t,n,s)},nt=function(e,t,n,s){et(e,t,(function i(o){n(o),tt(e,t,i,s)}),s)},st=!!function(){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){t=!0}});nt(e,"testPassive",null,n)}catch(e){}return t}()&&{passive:!0},it=function(t){var n=He?e[we](t)[We]:0;return n="number"!=typeof(n=parseFloat(n))||isNaN(n)?0:1e3*n},ot=function(e,t){var n=0;it(e)?nt(e,Ge,(function(e){!n&&t(e),n=1})):setTimeout((function(){!n&&t(),n=1}),17)},rt=function(e,t,n){var s=new CustomEvent(e+".bs."+t);s.relatedTarget=n,this.dispatchEvent(s)},at=function(){return{y:e.pageYOffset||s[L],x:e.pageXOffset||s[P]}},ct=function(e,n,o,r){var a,c,l,d,u,h,m={w:n[B],h:n[q]},g=s[F]||t[i][F],f=s[U]||t[i][U],p=e[_e](),v=r===t[i]?at():{x:r[z]+r[P],y:r[D]+r[L]},_={w:p[ze]-p[De],h:p[Pe]-p[Le]},y=Ze(n,"popover"),b=Ye(".arrow",n),w=p[Le]+_.h/2-m.h/2<0,S=p[De]+_.w/2-m.w/2<0,x=p[De]+m.w/2+_.w/2>=g,E=p[Le]+m.h/2+_.h/2>=f,A=p[Le]-m.h<0,C=p[De]-m.w<0,k=p[Le]+m.h+_.h>=f,j=p[De]+m.w+_.w>=g;o=(o=(o=(o=(o=(o===De||o===ze)&&C&&j?Le:o)===Le&&A?Pe:o)===Pe&&k?Le:o)===De&&C?ze:o)===ze&&j?De:o,-1===n.className[Se](o)&&(n.className=n.className.replace(Fe,o)),u=b[B],h=b[q],o===De||o===ze?(c=o===De?p[De]+v.x-m.w-(y?u:0):p[De]+v.x+_.w,w?(a=p[Le]+v.y,l=_.h/2-u):E?(a=p[Le]+v.y-m.h+_.h,l=m.h-_.h/2-u):(a=p[Le]+v.y-m.h/2+_.h/2,l=m.h/2-(y?.9*h:h/2))):o!==Le&&o!==Pe||(a=o===Le?p[Le]+v.y-m.h-(y?h:0):p[Le]+v.y+_.h,S?(c=0,d=p[De]+_.w/2-u):x?(c=g-1.01*m.w,d=m.w-(g-p[De])+_.w/2-u/2):(c=p[De]+v.x-m.w/2+_.w/2,d=m.w/2-(y?u:u/2))),n[Te][Le]=a+"px",n[Te][De]=c+"px",l&&(b[Te][Le]=l+"px"),d&&(b[Te][De]=d+"px")};o.version="2.0.27";var lt=function(e){e=Ye(e);var t=this,n="alert",s=Xe(e,"."+n),i=function(){Ze(s,"fade")?ot(s,r):r()},o=function(i){s=Xe(i[N],"."+n),(e=Ye("["+c+'="'+n+'"]',s))&&s&&(e===i[N]||e[Oe](i[N]))&&t.close()},r=function(){rt.call(s,ce,n),tt(e,Z,o),s[xe].removeChild(s)};this.close=function(){s&&e&&Ze(s,Me)&&(rt.call(s,ae,n),Qe(s,Me),s&&i())},l in e||et(e,Z,o),e[l]=t};r[$e]([l,lt,"["+c+'="alert"]']);var dt=function(e){e=Ye(e);var n=!1,s="button",i="checked",o="LABEL",r="INPUT",a=function(e){32===(e.which||e.keyCode)&&e[N]===t.activeElement&&l(e)},c=function(e){32===(e.which||e.keyCode)&&e[ve]()},l=function(t){var a=t[N].tagName===o?t[N]:t[N][xe].tagName===o?t[N][xe]:null;if(a){var c=Ke(a[xe],"btn"),l=a[pe](r)[0];if(l){if("checkbox"===l.type&&(l[i]?(Qe(a,Ie),l[de](i),l.removeAttribute(i),l[i]=!1):(Je(a,Ie),l[de](i),l[ue](i,i),l[i]=!0),n||(n=!0,rt.call(l,le,s),rt.call(e,le,s))),"radio"===l.type&&!n&&(!l[i]||0===t.screenX&&0==t.screenY)){Je(a,Ie),Je(a,K),l[ue](i,i),l[i]=!0,rt.call(l,le,s),rt.call(e,le,s),n=!0;for(var d=0,u=c[Ee];d1?r-1:0:40===i&&r×',j=Ye(s[R]),$=Ye(d),O=Xe(n,".modal"),D=Xe(n,"."+Be),z=Xe(n,"."+qe);this[h]=s[h]?s[h]:null,this[m]=s[m]?s[m]:o||Y,this[I]=s[I]&&s[I]!==v?s[I]:r||v,this[M]=s[M]?s[M]:a||Le,this[T]=parseInt(s[T]||l)||200,this[y]=!(!s[y]&&"true"!==c),this[R]=j||$||D||z||O||t[i];var L=this,P=s.title||n[de](b)||null,F=s.content||n[de](_)||null;if(F||this[h]){var U=null,B=0,q=this[M],H=function(e){null!==U&&e[N]===Ye(".close",U)&&L.hide()},G=function(){L[R].removeChild(U),B=null,U=null},W=function(){P=s.title||n[de](b),F=(F=s.content||n[de](_))?F.trim():null,U=t[me](p);var e=t[me](p);if(e[ue](f,"arrow"),U[ge](e),null!==F&&null===L[h]){if(U[ue]("role","tooltip"),null!==P){var i=t[me]("h3");i[ue](f,u+"-header"),i[fe]=L[y]?P+k:P,U[ge](i)}var o=t[me](p);o[ue](f,u+"-body"),o[fe]=L[y]&&null===P?F+k:F,U[ge](o)}else{var r=t[me](p);L[h]=L[h].trim(),r[fe]=L[h],U[fe]=r.firstChild[fe]}L[R][ge](U),U[Te].display="block",U[ue](f,u+" bs-"+u+"-"+q+" "+L[I])},V=function(){!Ze(U,Me)&&Je(U,Me)},J=function(){ct(n,U,q,L[R])},Q=function(s){Z!=L[m]&&"focus"!=L[m]||!L[y]&&s(n,"blur",L.hide),L[y]&&s(t,Z,H),s(e,te,L.hide,st)},K=function(){Q(et),rt.call(n,ie,u)},X=function(){Q(tt),G(),rt.call(n,re,u)};this.toggle=function(){null===U?L.show():L.hide()},this.show=function(){clearTimeout(B),B=setTimeout((function(){null===U&&(q=L[M],W(),J(),V(),rt.call(n,se,u),L[I]?ot(U,K):K())}),20)},this.hide=function(){clearTimeout(B),B=setTimeout((function(){U&&null!==U&&Ze(U,Me)&&(rt.call(n,oe,u),Qe(U,Me),L[I]?ot(U,X):X())}),L[T])},g in n||(L[m]===Y?(et(n,ne[0],L.show),L[y]||et(n,ne[1],L.hide)):Z!=L[m]&&"focus"!=L[m]||et(n,L[m],L.toggle)),n[g]=L}};r[$e]([g,gt,"["+a+'="popover"]']);var ft=function(e,t){var n=(e=Ye(e))[de](y),s="tab",i="height",o="float",r="isAnimating";t=t||{},this[i]=!!He&&(t[i]||"true"===n);var a,c,l,d,u,h,m,g=this,p=Xe(e,".nav"),v=!1,_=p&&Ye(".dropdown-toggle",p),b=function(){v[Te][i]="",Qe(v,Re),p[r]=!1},w=function(){v?h?b():setTimeout((function(){v[Te][i]=m+"px",v[B],ot(v,b)}),50):p[r]=!1,rt.call(a,ie,s,c)},S=function(){v&&(l[Te][o]=De,d[Te][o]=De,u=l[G]),Je(d,Ie),rt.call(a,se,s,c),Qe(l,Ie),rt.call(c,re,s,a),v&&(m=d[G],h=m===u,Je(v,Re),v[Te][i]=u+"px",v[q],l[Te][o]="",d[Te][o]=""),Ze(d,"fade")?setTimeout((function(){Je(d,Me),ot(d,w)}),20):w()};if(p){p[r]=!1;var x=function(){var e,t=Ke(p,Ie);return 1!==t[Ee]||Ze(t[0][xe],"dropdown")?t[Ee]>1&&(e=t[t[Ee]-1]):e=t[0],e},E=function(){return Ye(x()[de]("href"))},A=function(e){e[ve](),a=e[O],!p[r]&&!Ze(a,Ie)&&g.show()};this.show=function(){d=Ye((a=a||e)[de]("href")),c=x(),l=E(),p[r]=!0,Qe(c,Ie),c[ue](Q,"false"),Je(a,Ie),a[ue](Q,"true"),_&&(Ze(e[xe],"dropdown-menu")?Ze(_,Ie)||Je(_,Ie):Ze(_,Ie)&&Qe(_,Ie)),rt.call(c,oe,s,a),Ze(l,"fade")?(Qe(l,Me),ot(l,S)):S()},f in e||et(e,Z,A),g[i]&&(v=E()[xe]),e[f]=g}};r[$e]([f,ft,"["+a+'="tab"]']);var pt=function(e,t){for(var n=0,s=t[Ee];n{window,e.exports=function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:s})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.loadImageElement=function(e,t){return new Promise((function(n,s){e.addEventListener("load",(function(){n(e)}),!1),e.addEventListener("error",(function(e){s(e)}),!1),e.src=t}))},t.resize=function(e,t,n,s){if(!n&&!s)return{currentWidth:e,currentHeight:t};var i=e/t,o=void 0,r=void 0;return i>n/s?r=(o=Math.min(e,n))/i:o=(r=Math.min(t,s))*i,{width:o,height:r}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.base64ToFile=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg",n=window.atob(e),s=[],i=0;i8)return o.drawImage(e,0,0,i.width,i.height),i;switch(s>4&&(i.width=n,i.height=t),s){case 2:o.translate(t,0),o.scale(-1,1);break;case 3:o.translate(t,n),o.rotate(Math.PI);break;case 4:o.translate(0,n),o.scale(1,-1);break;case 5:o.rotate(.5*Math.PI),o.scale(1,-1);break;case 6:o.rotate(.5*Math.PI),o.translate(0,-n);break;case 7:o.rotate(.5*Math.PI),o.translate(t,-n),o.scale(-1,1);break;case 8:o.rotate(-.5*Math.PI),o.translate(-t,0)}return s>4?o.drawImage(e,0,0,i.height,i.width):o.drawImage(e,0,0,i.width,i.height),i},t.canvasToBlob=function(e,t){return new Promise((function(n,s){e.toBlob((function(e){n(e)}),"image/jpeg",t)}))},t.size=function(e){return{kB:.001*e,MB:1e-6*e}},t.blobToBase64=function(e){return new Promise((function(t,n){var s=new window.FileReader;s.addEventListener("load",(function(e){t(e.target.result)}),!1),s.addEventListener("error",(function(e){n(e)}),!1),s.readAsDataURL(e)}))}},function(e,t,n){e.exports=n(6)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractOrientation=function(e){return new Promise((function(t,n){var s=new window.FileReader;s.onload=function(e){var n=new DataView(e.target.result);65496!==n.getUint16(0,!1)&&t(-2);for(var s=n.byteLength,i=2;i=0;--o){var r=this.tryEntries[o],a=r.completion;if("root"===r.tryLoc)return s("end");if(r.tryLoc<=this.prev){var c=i.call(r,"catchLoc"),l=i.call(r,"finallyLoc");if(c&&l){if(this.prev=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var s=n.completion;if("throw"===s.type){var i=s.arg;T(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,s){return this.delegate={iterator:N(e),resultName:t,nextLoc:s},"next"===this.method&&(this.arg=n),f}}}function b(e,t,n,s){var i=t&&t.prototype instanceof S?t:S,o=Object.create(i.prototype),r=new $(s||[]);return o._invoke=function(e,t,n){var s=u;return function(i,o){if(s===m)throw new Error("Generator is already running");if(s===g){if("throw"===i)throw o;return O()}for(n.method=i,n.arg=o;;){var r=n.delegate;if(r){var a=k(r,n);if(a){if(a===f)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(s===u)throw s=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);s=m;var c=w(e,t,n);if("normal"===c.type){if(s=n.done?g:h,c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(s=g,n.method="throw",n.arg=c.arg)}}}(e,n,r),o}function w(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function S(){}function x(){}function E(){}function A(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e){var t;this._invoke=function(n,s){function o(){return new Promise((function(t,o){!function t(n,s,o,r){var a=w(e[n],e,s);if("throw"!==a.type){var c=a.arg,l=c.value;return l&&"object"==typeof l&&i.call(l,"__await")?Promise.resolve(l.__await).then((function(e){t("next",e,o,r)}),(function(e){t("throw",e,o,r)})):Promise.resolve(l).then((function(e){c.value=e,o(c)}),r)}r(a.arg)}(n,s,t,o)}))}return t=t?t.then(o,o):o()}}function k(e,t){var s=e.iterator[t.method];if(s===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,k(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var i=w(s,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function $(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function N(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var s=-1,o=function t(){for(;++s=0,o=i&&s.regeneratorRuntime;if(s.regeneratorRuntime=void 0,e.exports=n(5),i)s.regeneratorRuntime=o;else try{delete s.regeneratorRuntime}catch(e){s.regeneratorRuntime=void 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=c(n(2)),i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.setOptions(t)}return i(e,[{key:"setOptions",value:function(e){var t={targetSize:1/0,quality:.75,minQuality:.5,qualityStepSize:.1,maxWidth:1920,maxHeight:1920,resize:!0,throwIfSizeNotReached:!1,autoRotate:!0},n=new Proxy(e,{get:function(e,n){return n in e?e[n]:t[n]}});this.options=n}},{key:"_compressFile",value:function(){var e=l(s.default.mark((function e(t){var n,i;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new a.default(t),(i={}).start=window.performance.now(),i.quality=this.options.quality,i.startType=n.type,e.next=7,n.load();case 7:return e.next=9,this._compressImage(n,i);case 9:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_compressImage",value:function(){var e=l(s.default.mark((function e(t,n){var i,a,c,l,d;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n.startWidth=t.width,n.startHeight=t.height,i=void 0,a=void 0,this.options.resize?(c=(0,r.resize)(t.width,t.height,this.options.maxWidth,this.options.maxHeight),i=c.width,a=c.height):(i=t.width,a=t.height),n.endWidth=i,n.endHeight=a,l=this.doAutoRotation?void 0:1,d=t.getCanvas(i,a,l),n.iterations=0,n.startSizeMB=o.size(t.size).MB,e.next=12,this._loopCompression(d,t,n);case 12:return n.endSizeMB=o.size(t.size).MB,n.sizeReducedInPercent=(n.startSizeMB-n.endSizeMB)/n.startSizeMB*100,n.end=window.performance.now(),n.elapsedTimeInSeconds=(n.end-n.start)/1e3,n.endType=t.type,e.abrupt("return",{photo:t,info:n});case 18:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()},{key:"_loopCompression",value:function(){var e=l(s.default.mark((function e(t,n,i){var r;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i.iterations++,e.t0=n,e.next=4,o.canvasToBlob(t,i.quality);case 4:if(e.t1=e.sent,e.t0.setData.call(e.t0,e.t1),1==i.iterations&&(n.width=i.endWidth,n.height=i.endHeight),!(o.size(n.size).MB>this.options.targetSize)){e.next=24;break}if(!(i.quality.toFixed(10)-.1{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6931:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},352:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},7802:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},5599:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1875:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},2791:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},5956:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},9679:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},4915:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1638:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},3076:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6916:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},7140:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},3288:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},902:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6233:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1513:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1984:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},1833:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},4921:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},5222:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},8054:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},8125:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},4166:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6278:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},9523:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6176:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},5046:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},7631:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},4903:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},6450:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},307:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},9537:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},9959:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});var s=n(7537),i=n.n(s),o=n(3645),r=n.n(o)()(i());r.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=r},3645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",s=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),s&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),s&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,s,i,o){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(s)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=o),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),t.push(d))}},t}},7537:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var s=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),o="/*# ".concat(i," */"),r=n.sources.map((function(e){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(e," */")}));return[t].concat(r).concat([o]).join("\n")}return[t].join("\n")}},7484:function(e){e.exports=function(){"use strict";var e=1e3,t=6e4,n=36e5,s="millisecond",i="second",o="minute",r="hour",a="day",c="week",l="month",d="quarter",u="year",h="date",m="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},v=function(e,t,n){var s=String(e);return!s||s.length>=t?e:""+Array(t+1-s.length).join(n)+e},_={s:v,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),s=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+v(s,2,"0")+":"+v(i,2,"0")},m:function e(t,n){if(t.date()1)return e(r[0])}else{var a=t.name;b[a]=t,i=a}return!s&&i&&(y=i),i||!s&&y},x=function(e,t){if(w(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new A(n)},E=_;E.l=S,E.i=w,E.w=function(e,t){return x(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var A=function(){function p(e){this.$L=S(e.locale,null,!0),this.parse(e)}var v=p.prototype;return v.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(E.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var s=t.match(g);if(s){var i=s[2]-1||0,o=(s[7]||"0").substring(0,3);return n?new Date(Date.UTC(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,o)):new Date(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,o)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},v.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},v.$utils=function(){return E},v.isValid=function(){return!(this.$d.toString()===m)},v.isSame=function(e,t){var n=x(e);return this.startOf(t)<=n&&n<=this.endOf(t)},v.isAfter=function(e,t){return x(e){var s={"./af.js":[5903,9210],"./am.js":[9911,5073],"./ar-dz.js":[7200,9406],"./ar-iq.js":[7719,2990],"./ar-kw.js":[2376,9897],"./ar-ly.js":[8540,3521],"./ar-ma.js":[6817,5313],"./ar-sa.js":[1573,485],"./ar-tn.js":[9339,8040],"./ar.js":[3939,6755],"./az.js":[8092,4963],"./be.js":[504,9478],"./bg.js":[9091,578],"./bi.js":[9149,2984],"./bm.js":[5287,2263],"./bn-bd.js":[4067,1351],"./bn.js":[5254,280],"./bo.js":[2502,9950],"./br.js":[8864,760],"./bs.js":[4502,9833],"./ca.js":[3646,102],"./cs.js":[8507,7400],"./cv.js":[6636,4481],"./cy.js":[8792,6740],"./da.js":[7427,2548],"./de-at.js":[3237,7175],"./de-ch.js":[6148,1679],"./de.js":[790,52],"./dv.js":[1794,5569],"./el.js":[5423,1606],"./en-au.js":[5109,5485],"./en-ca.js":[5105,4035],"./en-gb.js":[9517,6031],"./en-ie.js":[758,8129],"./en-il.js":[5805,3463],"./en-in.js":[8529,6898],"./en-nz.js":[302,8547],"./en-sg.js":[5941,1735],"./en-tt.js":[6183,6105],"./en.js":[5054,535],"./eo.js":[4990,5121],"./es-do.js":[3864,8758],"./es-mx.js":[7118,7416],"./es-pr.js":[3521,911],"./es-us.js":[6165,3208],"./es.js":[7763,3411],"./et.js":[9670,4153],"./eu.js":[6629,1396],"./fa.js":[6953,5544],"./fi.js":[7822,2130],"./fo.js":[9197,8745],"./fr-ca.js":[7989,7363],"./fr-ch.js":[4254,7952],"./fr.js":[6023,1910],"./fy.js":[3220,6376],"./ga.js":[7467,688],"./gd.js":[4855,5050],"./gl.js":[229,5818],"./gom-latn.js":[6312,825],"./gu.js":[7632,3623],"./he.js":[5418,9372],"./hi.js":[7573,8010],"./hr.js":[6257,7419],"./ht.js":[8889,5822],"./hu.js":[8562,8214],"./hy-am.js":[8242,5407],"./id.js":[3783,9513],"./is.js":[8980,1194],"./it-ch.js":[3706,6010],"./it.js":[5551,1880],"./ja.js":[6831,1107],"./jv.js":[2641,4305],"./ka.js":[6622,5186],"./kk.js":[2921,5206],"./km.js":[5567,2475],"./kn.js":[1113,7523],"./ko.js":[9132,3446],"./ku.js":[4888,7024],"./ky.js":[466,5055],"./lb.js":[1796,5215],"./lo.js":[8894,1204],"./lt.js":[8768,7899],"./lv.js":[953,631],"./me.js":[8066,145],"./mi.js":[8602,7454],"./mk.js":[1560,4951],"./ml.js":[4017,7679],"./mn.js":[4717,8618],"./mr.js":[5473,5600],"./ms-my.js":[7387,882],"./ms.js":[5742,9095],"./mt.js":[8477,9665],"./my.js":[2966,5166],"./nb.js":[9682,646],"./ne.js":[4149,9030],"./nl-be.js":[7496,3155],"./nl.js":[9182,1520],"./nn.js":[2722,7050],"./oc-lnc.js":[6159,7203],"./pa-in.js":[5914,5850],"./pl.js":[1987,1211],"./pt-br.js":[7548,5274],"./pt.js":[5001,265],"./rn.js":[123,4678],"./ro.js":[8146,8022],"./ru.js":[600,559],"./rw.js":[6509,3221],"./sd.js":[5437,1298],"./se.js":[772,1942],"./si.js":[7109,9333],"./sk.js":[5627,6783],"./sl.js":[2544,9625],"./sq.js":[8341,8603],"./sr-cyrl.js":[7101,3435],"./sr.js":[617,7390],"./ss.js":[4127,9238],"./sv-fi.js":[6421,9997],"./sv.js":[1876,9652],"./sw.js":[2030,9733],"./ta.js":[5596,7645],"./te.js":[5159,7714],"./tet.js":[9157,555],"./tg.js":[9928,2446],"./th.js":[2019,1729],"./tk.js":[5817,5256],"./tl-ph.js":[6513,9443],"./tlh.js":[7296,2814],"./tr.js":[3035,8665],"./tzl.js":[7797,2843],"./tzm-latn.js":[261,3933],"./tzm.js":[4722,4342],"./ug-cn.js":[313,6890],"./uk.js":[4144,1619],"./ur.js":[2957,9568],"./uz-latn.js":[8727,1110],"./uz.js":[7486,3153],"./vi.js":[7553,8073],"./x-pseudo.js":[5321,4423],"./yo.js":[4724,8692],"./zh-cn.js":[3852,9630],"./zh-hk.js":[2390,3755],"./zh-tw.js":[3901,6776],"./zh.js":[2009,8458]};function i(e){if(!n.o(s,e))return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=s[e],i=t[0];return n.e(t[1]).then((()=>n.t(i,23)))}i.keys=()=>Object.keys(s),i.id=9434,e.exports=i},8734:function(e){e.exports=function(){"use strict";return function(e,t,n){var s=t.prototype,i=s.format;n.en.ordinal=function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"},s.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return i.bind(this)(e);var s=this.$utils(),o=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return n.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return n.ordinal(t.week(),"W");case"w":case"ww":return s.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return s.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return s.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return"["+t.offsetName()+"]";case"zzz":return"["+t.offsetName("long")+"]";default:return e}}));return i.bind(this)(o)}}}()},7856:function(e){e.exports=function(){"use strict";function e(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1?n-1:0),i=1;i/gm),F=a(/^data-[\-\w.\u00B7-\uFFFF]/),U=a(/^aria-[\-\w]+$/),B=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=a(/^(?:\w+script|data):/i),H=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G=a(/^html$/i),W="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};function V(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:J(),t=function(e){return Z(e)};if(t.version="2.3.6",t.removed=[],!e||!e.document||9!==e.document.nodeType)return t.isSupported=!1,t;var n=e.document,s=e.document,i=e.DocumentFragment,o=e.HTMLTemplateElement,a=e.Node,c=e.Element,l=e.NodeFilter,d=e.NamedNodeMap,u=void 0===d?e.NamedNodeMap||e.MozNamedAttrMap:d,S=e.HTMLFormElement,x=e.DOMParser,K=e.trustedTypes,Y=c.prototype,X=C(Y,"cloneNode"),ee=C(Y,"nextSibling"),te=C(Y,"childNodes"),ne=C(Y,"parentNode");if("function"==typeof o){var se=s.createElement("template");se.content&&se.content.ownerDocument&&(s=se.content.ownerDocument)}var ie=Q(K,n),oe=ie?ie.createHTML(""):"",re=s,ae=re.implementation,ce=re.createNodeIterator,le=re.createDocumentFragment,de=re.getElementsByTagName,ue=n.importNode,he={};try{he=A(s).documentMode?s.documentMode:{}}catch(e){}var me={};t.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==he;var ge=L,fe=P,pe=F,ve=U,_e=q,ye=H,be=B,we=null,Se=E({},[].concat(V(k),V(j),V(T),V(N),V(I))),xe=null,Ee=E({},[].concat(V(M),V(R),V(D),V(z))),Ae=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ce=null,ke=null,je=!0,Te=!0,$e=!1,Ne=!1,Oe=!1,Ie=!1,Me=!1,Re=!1,De=!1,ze=!1,Le=!0,Pe=!0,Fe=!1,Ue={},Be=null,qe=E({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),He=null,Ge=E({},["audio","video","img","source","image","track"]),We=null,Ve=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Je="http://www.w3.org/1998/Math/MathML",Qe="http://www.w3.org/2000/svg",Ze="http://www.w3.org/1999/xhtml",Ke=Ze,Ye=!1,Xe=void 0,et=["application/xhtml+xml","text/html"],tt="text/html",nt=void 0,st=null,it=s.createElement("form"),ot=function(e){return e instanceof RegExp||e instanceof Function},rt=function(e){st&&st===e||(e&&"object"===(void 0===e?"undefined":W(e))||(e={}),e=A(e),we="ALLOWED_TAGS"in e?E({},e.ALLOWED_TAGS):Se,xe="ALLOWED_ATTR"in e?E({},e.ALLOWED_ATTR):Ee,We="ADD_URI_SAFE_ATTR"in e?E(A(Ve),e.ADD_URI_SAFE_ATTR):Ve,He="ADD_DATA_URI_TAGS"in e?E(A(Ge),e.ADD_DATA_URI_TAGS):Ge,Be="FORBID_CONTENTS"in e?E({},e.FORBID_CONTENTS):qe,Ce="FORBID_TAGS"in e?E({},e.FORBID_TAGS):{},ke="FORBID_ATTR"in e?E({},e.FORBID_ATTR):{},Ue="USE_PROFILES"in e&&e.USE_PROFILES,je=!1!==e.ALLOW_ARIA_ATTR,Te=!1!==e.ALLOW_DATA_ATTR,$e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,De=e.RETURN_DOM_FRAGMENT||!1,ze=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Le=!1!==e.SANITIZE_DOM,Pe=!1!==e.KEEP_CONTENT,Fe=e.IN_PLACE||!1,be=e.ALLOWED_URI_REGEXP||be,Ke=e.NAMESPACE||Ze,e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ae.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Xe=Xe=-1===et.indexOf(e.PARSER_MEDIA_TYPE)?tt:e.PARSER_MEDIA_TYPE,nt="application/xhtml+xml"===Xe?function(e){return e}:f,Ne&&(Te=!1),De&&(Re=!0),Ue&&(we=E({},[].concat(V(I))),xe=[],!0===Ue.html&&(E(we,k),E(xe,M)),!0===Ue.svg&&(E(we,j),E(xe,R),E(xe,z)),!0===Ue.svgFilters&&(E(we,T),E(xe,R),E(xe,z)),!0===Ue.mathMl&&(E(we,N),E(xe,D),E(xe,z))),e.ADD_TAGS&&(we===Se&&(we=A(we)),E(we,e.ADD_TAGS)),e.ADD_ATTR&&(xe===Ee&&(xe=A(xe)),E(xe,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&E(We,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(Be===qe&&(Be=A(Be)),E(Be,e.FORBID_CONTENTS)),Pe&&(we["#text"]=!0),Oe&&E(we,["html","head","body"]),we.table&&(E(we,["tbody"]),delete Ce.tbody),r&&r(e),st=e)},at=E({},["mi","mo","mn","ms","mtext"]),ct=E({},["foreignobject","desc","title","annotation-xml"]),lt=E({},j);E(lt,T),E(lt,$);var dt=E({},N);E(dt,O);var ut=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Ze,tagName:"template"});var n=f(e.tagName),s=f(t.tagName);if(e.namespaceURI===Qe)return t.namespaceURI===Ze?"svg"===n:t.namespaceURI===Je?"svg"===n&&("annotation-xml"===s||at[s]):Boolean(lt[n]);if(e.namespaceURI===Je)return t.namespaceURI===Ze?"math"===n:t.namespaceURI===Qe?"math"===n&&ct[s]:Boolean(dt[n]);if(e.namespaceURI===Ze){if(t.namespaceURI===Qe&&!ct[s])return!1;if(t.namespaceURI===Je&&!at[s])return!1;var i=E({},["title","style","font","a","script"]);return!dt[n]&&(i[n]||!lt[n])}return!1},ht=function(e){g(t.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=oe}catch(t){e.remove()}}},mt=function(e,n){try{g(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch(e){g(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),"is"===e&&!xe[e])if(Re||De)try{ht(n)}catch(e){}else try{n.setAttribute(e,"")}catch(e){}},gt=function(e){var t=void 0,n=void 0;if(Me)e=""+e;else{var i=p(e,/^[\r\n\t ]+/);n=i&&i[0]}"application/xhtml+xml"===Xe&&(e=''+e+"");var o=ie?ie.createHTML(e):e;if(Ke===Ze)try{t=(new x).parseFromString(o,Xe)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Ke,"template",null);try{t.documentElement.innerHTML=Ye?"":o}catch(e){}}var r=t.body||t.documentElement;return e&&n&&r.insertBefore(s.createTextNode(n),r.childNodes[0]||null),Ke===Ze?de.call(t,Oe?"html":"body")[0]:Oe?t.documentElement:r},ft=function(e){return ce.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT,null,!1)},pt=function(e){return e instanceof S&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},vt=function(e){return"object"===(void 0===a?"undefined":W(a))?e instanceof a:e&&"object"===(void 0===e?"undefined":W(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},_t=function(e,n,s){me[e]&&h(me[e],(function(e){e.call(t,n,s,st)}))},yt=function(e){var n=void 0;if(_t("beforeSanitizeElements",e,null),pt(e))return ht(e),!0;if(p(e.nodeName,/[\u0080-\uFFFF]/))return ht(e),!0;var s=nt(e.nodeName);if(_t("uponSanitizeElement",e,{tagName:s,allowedTags:we}),!vt(e.firstElementChild)&&(!vt(e.content)||!vt(e.content.firstElementChild))&&b(/<[/\w]/g,e.innerHTML)&&b(/<[/\w]/g,e.textContent))return ht(e),!0;if("select"===s&&b(/