/*! For license information please see converse.min.js.LICENSE.txt */ (()=>{var e,t,s,n,i={169:(e,t,s)=>{var n;!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 r(e){return function(e,t){var s,n,o,a,c,l,d,u,h,m=1,g=e.length,f="";for(n=0;n=0),a.type){case"b":s=parseInt(s,10).toString(2);break;case"c":s=String.fromCharCode(parseInt(s,10));break;case"d":case"i":s=parseInt(s,10);break;case"j":s=JSON.stringify(s,null,a.width?parseInt(a.width):0);break;case"e":s=a.precision?parseFloat(s).toExponential(a.precision):parseFloat(s).toExponential();break;case"f":s=a.precision?parseFloat(s).toFixed(a.precision):parseFloat(s);break;case"g":s=a.precision?String(Number(s.toPrecision(a.precision))):parseFloat(s);break;case"o":s=(parseInt(s,10)>>>0).toString(8);break;case"s":s=String(s),s=a.precision?s.substring(0,a.precision):s;break;case"t":s=String(!!s),s=a.precision?s.substring(0,a.precision):s;break;case"T":s=Object.prototype.toString.call(s).slice(8,-1).toLowerCase(),s=a.precision?s.substring(0,a.precision):s;break;case"u":s=parseInt(s,10)>>>0;break;case"v":s=s.valueOf(),s=a.precision?s.substring(0,a.precision):s;break;case"x":s=(parseInt(s,10)>>>0).toString(16);break;case"X":s=(parseInt(s,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?f+=s:(!i.number.test(a.type)||u&&!a.sign?h="":(h=u?"+":"-",s=s.toString().replace(i.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",d=a.width-(h+s).length,c=a.width&&d>0?l.repeat(d):"",f+=a.align?h+s+c:"0"===l?h+c+s:c+h+s)}return f}(function(e){if(a[e])return a[e];var t,s=e,n=[],r=0;for(;s;){if(null!==(t=i.text.exec(s)))n.push(t[0]);else if(null!==(t=i.modulo.exec(s)))n.push("%");else{if(null===(t=i.placeholder.exec(s)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){r|=1;var o=[],c=t[2],l=[];if(null===(l=i.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(l[1]);""!==(c=c.substring(l[0].length));)if(null!==(l=i.key_access.exec(c)))o.push(l[1]);else{if(null===(l=i.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(l[1])}t[2]=o}else r|=2;if(3===r)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.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]})}s=s.substring(t[0].length)}return a[e]=n}(e),arguments)}function o(e,t){return r.apply(null,[e].concat(t||[]))}var a=Object.create(null);t.sprintf=r,t.vsprintf=o,"undefined"!=typeof window&&(window.sprintf=r,window.vsprintf=o,void 0===(n=function(){return{sprintf:r,vsprintf:o}}.call(t,s,t,e))||(e.exports=n))}()},4335:function(e,t,s){var n,i;!function(r,o){"use strict";e.exports?e.exports=o():void 0===(i="function"==typeof(n=o)?n.call(t,s,t,e):n)||(e.exports=i)}(0,(function(e){"use strict";var t=e&&e.IPv6;return{best:function(e){var t,s,n=e.toLowerCase().split(":"),i=n.length,r=8;for(""===n[0]&&""===n[1]&&""===n[2]?(n.shift(),n.shift()):""===n[0]&&""===n[1]?n.shift():""===n[i-1]&&""===n[i-2]&&n.pop(),-1!==n[(i=n.length)-1].indexOf(".")&&(r=7),t=0;t1);a++)s.splice(0,1);n[o]=s.join("")}var c=-1,l=0,d=0,u=-1,h=!1;for(o=0;ol&&(c=u,l=d)):"0"===n[o]&&(h=!0,u=o,d=1);d>l&&(c=u,l=d),l>1&&n.splice(c,l,""),i=n.length;var m="";for(""===n[0]&&(m=":"),o=0;o=e.length-1)return!1;var n=e.lastIndexOf(".",t-1);if(n<=0||n>=t-1)return!1;var i=s.list[e.slice(t+1)];return!!i&&i.indexOf(" "+e.slice(n+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 n=s.list[e.slice(t+1)];return!!n&&n.indexOf(" "+e.slice(0,t)+" ")>=0},get:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return null;var n=e.lastIndexOf(".",t-1);if(n<=0||n>=t-1)return null;var i=s.list[e.slice(t+1)];return i?i.indexOf(" "+e.slice(n+1,t)+" ")<0?null:e.slice(n+1):null},noConflict:function(){return e.SecondLevelDomains===this&&(e.SecondLevelDomains=t),this}};return s}))},9542:function(e,t,s){var n,i,r;!function(o,a){"use strict";e.exports?e.exports=a(s(5413),s(4335),s(4817)):(i=[s(5413),s(4335),s(4817)],void 0===(r="function"==typeof(n=a)?n.apply(t,i):n)||(e.exports=r))}(0,(function(e,t,s,n){"use strict";var i=n&&n.URI;function r(e,t){var s=arguments.length>=1;if(!(this instanceof r))return s?arguments.length>=2?new r(e,t):new r(e):new r;if(void 0===e){if(s)throw new TypeError("undefined is not a valid argument for URI");e="undefined"!=typeof location?location.href+"":""}if(null===e&&s)throw new TypeError("null is not a valid argument for URI");return this.href(e),void 0!==t?this.absoluteTo(t):this}r.version="1.19.11";var o=r.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 s,n,i={};if("RegExp"===l(t))i=null;else if(d(t))for(s=0,n=t.length;s]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},r.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,r.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.hostProtocols=["http","https"],r.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,r.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"},r.getDomAttribute=function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();if("input"!==t||"image"===e.type)return r.domAttributes[t]}},r.encode=p,r.decode=decodeURIComponent,r.iso8859=function(){r.encode=escape,r.decode=unescape},r.unicode=function(){r.encode=p,r.decode=decodeURIComponent},r.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"}}}},r.encodeQuery=function(e,t){var s=r.encode(e+"");return void 0===t&&(t=r.escapeQuerySpace),t?s.replace(/%20/g,"+"):s},r.decodeQuery=function(e,t){e+="",void 0===t&&(t=r.escapeQuerySpace);try{return r.decode(t?e.replace(/\+/g,"%20"):e)}catch(t){return e}};var v,y={encode:"encode",decode:"decode"},b=function(e,t){return function(s){try{return r[t](s+"").replace(r.characters[e][t].expression,(function(s){return r.characters[e][t].map[s]}))}catch(e){return s}}};for(v in y)r[v+"PathSegment"]=b("pathname",y[v]),r[v+"UrnPathSegment"]=b("urnpath",y[v]);var _=function(e,t,s){return function(n){var i;i=s?function(e){return r[t](r[s](e))}:r[t];for(var o=(n+"").split(e),a=0,c=o.length;a-1&&(t.fragment=e.substring(s+1)||null,e=e.substring(0,s)),(s=e.indexOf("?"))>-1&&(t.query=e.substring(s+1)||null,e=e.substring(0,s)),"//"===(e=(e=e.replace(/^(https?|ftp|wss?)?:+[/\\]*/i,"$1://")).replace(/^[/\\]{2,}/i,"//")).substring(0,2)?(t.protocol=null,e=e.substring(2),e=r.parseAuthority(e,t)):(s=e.indexOf(":"))>-1&&(t.protocol=e.substring(0,s)||null,t.protocol&&!t.protocol.match(r.protocol_expression)?t.protocol=void 0:"//"===e.substring(s+1,s+3).replace(/\\/g,"/")?(e=e.substring(s+3),e=r.parseAuthority(e,t)):(e=e.substring(s+1),t.urn=!0)),t.path=e,t},r.parseHost=function(e,t){e||(e="");var s,n,i=(e=e.replace(/\\/g,"/")).indexOf("/");if(-1===i&&(i=e.length),"["===e.charAt(0))s=e.indexOf("]"),t.hostname=e.substring(1,s)||null,t.port=e.substring(s+2,i)||null,"/"===t.port&&(t.port=null);else{var o=e.indexOf(":"),a=e.indexOf("/"),c=e.indexOf(":",o+1);-1!==c&&(-1===a||c-1?i:e.length-1);return o>-1&&(-1===i||o-1?m.slice(0,g)+m.slice(g).replace(o,""):m.replace(o,"")).length<=l[0].length||s.ignore&&s.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),n.lastIndex=d+v.length):n.lastIndex=h}}return n.lastIndex=0,e},r.ensureValidHostname=function(t,s){var n=!!t,i=!1;if(!!s&&(i=h(r.hostProtocols,s)),i&&!n)throw new TypeError("Hostname cannot be empty, if protocol is "+s);if(t&&t.match(r.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(r.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]')}},r.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')}},r.noConflict=function(e){if(e){var t={URI:this.noConflict()};return n.URITemplate&&"function"==typeof n.URITemplate.noConflict&&(t.URITemplate=n.URITemplate.noConflict()),n.IPv6&&"function"==typeof n.IPv6.noConflict&&(t.IPv6=n.IPv6.noConflict()),n.SecondLevelDomains&&"function"==typeof n.SecondLevelDomains.noConflict&&(t.SecondLevelDomains=n.SecondLevelDomains.noConflict()),t}return n.URI===this&&(n.URI=i),this},o.build=function(e){return!0===e?this._deferred_build=!0:(void 0===e||this._deferred_build)&&(this._string=r.build(this._parts),this._deferred_build=!1),this},o.clone=function(){return new r(this)},o.valueOf=o.toString=function(){return this.build(!1)._string},o.protocol=w("protocol"),o.username=w("username"),o.password=w("password"),o.hostname=w("hostname"),o.port=w("port"),o.query=S("query","?"),o.fragment=S("fragment","#"),o.search=function(e,t){var s=this.query(e,t);return"string"==typeof s&&s.length?"?"+s:s},o.hash=function(e,t){var s=this.fragment(e,t);return"string"==typeof s&&s.length?"#"+s:s},o.pathname=function(e,t){if(void 0===e||!0===e){var s=this._parts.path||(this._parts.hostname?"/":"");return e?(this._parts.urn?r.decodeUrnPath:r.decodePath)(s):s}return this._parts.urn?this._parts.path=e?r.recodeUrnPath(e):"":this._parts.path=e?r.recodePath(e):"/",this.build(!t),this},o.path=o.pathname,o.href=function(e,t){var s;if(void 0===e)return this.toString();this._string="",this._parts=r._parts();var n=e instanceof r,i="object"==typeof e&&(e.hostname||e.path||e.pathname);e.nodeName&&(e=e[r.getDomAttribute(e)]||"",i=!1);if(!n&&i&&void 0!==e.pathname&&(e=e.toString()),"string"==typeof e||e instanceof String)this._parts=r.parse(String(e),this._parts);else{if(!n&&!i)throw new TypeError("invalid input");var o=n?e._parts:e;for(s in o)"query"!==s&&a.call(this._parts,s)&&(this._parts[s]=o[s]);o.query&&this.query(o.query,!1)}return this.build(!t),this},o.is=function(e){var t=!1,n=!1,i=!1,o=!1,a=!1,c=!1,l=!1,d=!this._parts.urn;switch(this._parts.hostname&&(d=!1,n=r.ip4_expression.test(this._parts.hostname),i=r.ip6_expression.test(this._parts.hostname),a=(o=!(t=n||i))&&s&&s.has(this._parts.hostname),c=o&&r.idn_expression.test(this._parts.hostname),l=o&&r.punycode_expression.test(this._parts.hostname)),e.toLowerCase()){case"relative":return d;case"absolute":return!d;case"domain":case"name":return o;case"sld":return a;case"ip":return t;case"ip4":case"ipv4":case"inet4":return n;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=o.protocol,A=o.port,E=o.hostname;o.protocol=function(e,t){if(e&&!(e=e.replace(/:(\/\/)?$/,"")).match(r.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)},o.scheme=o.protocol,o.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)),r.ensureValidPort(e))),A.call(this,e,t))},o.hostname=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0!==e){var s={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==r.parseHost(e,s))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');e=s.hostname,this._parts.preventInvalidHostname&&r.ensureValidHostname(e,this._parts.protocol)}return E.call(this,e,t)},o.origin=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var s=this.protocol();return this.authority()?(s?s+"://":"")+this.authority():""}var n=r(e);return this.protocol(n.protocol()).authority(n.authority()).build(!t),this},o.host=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?r.buildHost(this._parts):"";if("/"!==r.parseHost(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},o.authority=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?r.buildAuthority(this._parts):"";if("/"!==r.parseAuthority(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},o.userinfo=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var s=r.buildUserinfo(this._parts);return s?s.substring(0,s.length-1):s}return"@"!==e[e.length-1]&&(e+="@"),r.parseUserinfo(e,this._parts),this.build(!t),this},o.resource=function(e,t){var s;return void 0===e?this.path()+this.search()+this.hash():(s=r.parse(e),this._parts.path=s.path,this._parts.query=s.query,this._parts.fragment=s.fragment,this.build(!t),this)},o.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 s=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,s)||""}var n=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,n),o=new RegExp("^"+c(i));if(e&&"."!==e.charAt(e.length-1)&&(e+="."),-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");return e&&r.ensureValidHostname(e,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(o,e),this.build(!t),this},o.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 s=this._parts.hostname.match(/\./g);if(s&&s.length<2)return this._parts.hostname;var n=this._parts.hostname.length-this.tld(t).length-1;return n=this._parts.hostname.lastIndexOf(".",n-1)+1,this._parts.hostname.substring(n)||""}if(!e)throw new TypeError("cannot set domain empty");if(-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");if(r.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},o.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 n=this._parts.hostname.lastIndexOf("."),i=this._parts.hostname.substring(n+1);return!0!==t&&s&&s.list[i.toLowerCase()]&&s.get(this._parts.hostname)||i}var r;if(!e)throw new TypeError("cannot set TLD empty");if(e.match(/[^a-zA-Z0-9-]/)){if(!s||!s.is(e))throw new TypeError('TLD "'+e+'" contains characters other than [A-Z0-9]');r=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,e)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");r=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,e)}return this.build(!t),this},o.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 s=this._parts.path.length-this.filename().length-1,n=this._parts.path.substring(0,s)||(this._parts.hostname?"/":"");return e?r.decodePath(n):n}var i=this._parts.path.length-this.filename().length,o=this._parts.path.substring(0,i),a=new RegExp("^"+c(o));return this.is("relative")||(e||(e="/"),"/"!==e.charAt(0)&&(e="/"+e)),e&&"/"!==e.charAt(e.length-1)&&(e+="/"),e=r.recodePath(e),this._parts.path=this._parts.path.replace(a,e),this.build(!t),this},o.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 s=this._parts.path.lastIndexOf("/"),n=this._parts.path.substring(s+1);return e?r.decodePathSegment(n):n}var i=!1;"/"===e.charAt(0)&&(e=e.substring(1)),e.match(/\.?\//)&&(i=!0);var o=new RegExp(c(this.filename())+"$");return e=r.recodePath(e),this._parts.path=this._parts.path.replace(o,e),i?this.normalizePath(t):this.build(!t),this},o.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 s,n,i=this.filename(),o=i.lastIndexOf(".");return-1===o?"":(s=i.substring(o+1),n=/^[a-z0-9%]+$/i.test(s)?s:"",e?r.decodePathSegment(n):n)}"."===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+="."+r.recodePath(e)}return a&&(e=r.recodePath(e),this._parts.path=this._parts.path.replace(a,e)),this.build(!t),this},o.segment=function(e,t,s){var n=this._parts.urn?":":"/",i=this.path(),r="/"===i.substring(0,1),o=i.split(n);if(void 0!==e&&"number"!=typeof e&&(s=t,t=e,e=void 0),void 0!==e&&"number"!=typeof e)throw new Error('Bad segment "'+e+'", must be 0-based integer');if(r&&o.shift(),e<0&&(e=Math.max(o.length+e,0)),void 0===t)return void 0===e?o:o[e];if(null===e||void 0===o[e])if(d(t)){o=[];for(var a=0,c=t.length;a= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=c-l,w=Math.floor,S=String.fromCharCode;function x(e){throw new RangeError(b[e])}function A(e,t){for(var s=e.length,n=[];s--;)n[s]=t(e[s]);return n}function E(e,t){var s=e.split("@"),n="";return s.length>1&&(n=s[0]+"@",e=s[1]),n+A((e=e.replace(y,".")).split("."),t).join(".")}function C(e){for(var t,s,n=[],i=0,r=e.length;i=55296&&t<=56319&&i65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function j(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function k(e,t,s){var n=0;for(e=s?w(e/h):e>>1,e+=w(e/t);e>_*d>>1;n+=c)e=w(e/_);return w(n+(_+1)*e/(e+u))}function T(e){var t,s,n,i,r,o,u,h,p,v,y,b=[],_=e.length,S=0,A=g,E=m;for((s=e.lastIndexOf(f))<0&&(s=0),n=0;n=128&&x("not-basic"),b.push(e.charCodeAt(n));for(i=s>0?s+1:0;i<_;){for(r=S,o=1,u=c;i>=_&&x("invalid-input"),((h=(y=e.charCodeAt(i++))-48<10?y-22:y-65<26?y-65:y-97<26?y-97:c)>=c||h>w((a-S)/o))&&x("overflow"),S+=h*o,!(h<(p=u<=E?l:u>=E+d?d:u-E));u+=c)o>w(a/(v=c-p))&&x("overflow"),o*=v;E=k(S-r,t=b.length+1,0==r),w(S/t)>a-A&&x("overflow"),A+=w(S/t),S%=t,b.splice(S++,0,A)}return $(b)}function I(e){var t,s,n,i,r,o,u,h,p,v,y,b,_,A,E,$=[];for(b=(e=C(e)).length,t=g,s=0,r=m,o=0;o=t&&yw((a-s)/(_=n+1))&&x("overflow"),s+=(u-t)*_,t=u,o=0;oa&&x("overflow"),y==t){for(h=s,p=c;!(h<(v=p<=r?l:p>=r+d?d:p-r));p+=c)E=h-v,A=c-v,$.push(S(j(v+E%A,0))),h=w(E/A);$.push(S(j(h,0))),r=k(s,_,n==i),s=0,++n}++s,++t}return $.join("")}o={version:"1.3.2",ucs2:{decode:C,encode:$},decode:T,encode:I,toASCII:function(e){return E(e,(function(e){return v.test(e)?"xn--"+I(e):e}))},toUnicode:function(e){return E(e,(function(e){return p.test(e)?T(e.slice(4).toLowerCase()):e}))}},void 0===(n=function(){return o}.call(t,s,t,e))||(e.exports=n)}()},3945:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>sI});var n={};s.r(n),s.d(n,{DOMParser:()=>x,WebSocket:()=>S,getDummyXMLDOMDocument:()=>A});var i={};s.r(i),s.d(i,{addCookies:()=>P,arrayBufToBase64:()=>D,base64ToArrayBuf:()=>z,copyElement:()=>J,createHtml:()=>Q,default:()=>ae,escapeNode:()=>te,forEachChild:()=>X,getBareJidFromJid:()=>oe,getDomainFromJid:()=>ie,getNodeFromJid:()=>ne,getResourceFromJid:()=>re,getText:()=>ee,handleError:()=>N,isTagEqual:()=>Z,stringToArrayBuf:()=>L,unescapeNode:()=>se,utf16to8:()=>M,validAttribute:()=>W,validCSS:()=>V,validTag:()=>G,xmlElement:()=>H,xmlGenerator:()=>F,xmlHtmlNode:()=>q,xmlTextNode:()=>B,xmlescape:()=>K,xmlunescape:()=>Y,xorArrayBuffers:()=>R});var r={};s.r(r),s.d(r,{ACTIVE:()=>rt,ANONYMOUS:()=>Ve,BOSH_WAIT:()=>He,CHATROOMS_TYPE:()=>dt,CHAT_STATES:()=>pt,CLOSED:()=>Qe,COMPOSING:()=>ot,CONNECTION_STATUS:()=>mt,CONTROLBOX_TYPE:()=>ht,CORE_PLUGINS:()=>gt,DEFAULT_IMAGE:()=>nt,DEFAULT_IMAGE_TYPE:()=>st,EXTERNAL:()=>Je,FAILURE:()=>tt,GONE:()=>ct,HEADLINES_TYPE:()=>ut,INACTIVE:()=>it,KEYCODES:()=>vt,LOGIN:()=>Ke,LOGOUT:()=>Ye,OPENED:()=>Xe,PAUSED:()=>at,PREBIND:()=>Ze,PRIVATE_CHAT_TYPE:()=>lt,STATUS_WEIGHTS:()=>We,SUCCESS:()=>et,URL_PARSE_OPTIONS:()=>ft,VERSION_NAME:()=>Ge});var o={};s.r(o),s.d(o,{decodeHTMLEntities:()=>Ct,isElement:()=>_t,isTagEqual:()=>wt,queryChildren:()=>xt,siblingIndex:()=>At,stringToElement:()=>St});var a={};s.r(a),s.d(a,{isError:()=>tu,isFunction:()=>su,merge:()=>eu});var c={};s.r(c),s.d(c,{clearSession:()=>gu,getUnloadEvent:()=>du,isTestEnv:()=>lu,isUniView:()=>cu,replacePromise:()=>uu,shouldClearCache:()=>hu,tearDown:()=>mu});var l={};s.r(l),s.d(l,{createStore:()=>Tu,getDefaultStore:()=>ju,initStorage:()=>Iu});var d={};s.r(d),s.d(d,{getJIDFromURI:()=>zu,isSameBareJID:()=>Ru,isSameDomain:()=>Du,isValidJID:()=>Nu,isValidMUCJID:()=>Mu});var u={};s.r(u),s.d(u,{getAttributes:()=>xh,isErrorStanza:()=>_h,isForbiddenError:()=>wh,isServiceUnavailableError:()=>Sh});var h={};s.r(h),s.d(h,{getCurrentWord:()=>jh,getSelectValues:()=>Ch,isMentionBoundary:()=>kh,placeCaretAtEnd:()=>Ih,replaceCurrentWord:()=>Th,webForm2xForm:()=>$h});var m={};s.r(m),s.d(m,{appendArrayBuffer:()=>Oh,arrayBufferToBase64:()=>Dh,arrayBufferToHex:()=>Nh,arrayBufferToString:()=>Mh,base64ToArrayBuffer:()=>zh,hexToArrayBuffer:()=>Lh,stringToArrayBuffer:()=>Rh});var g={};s.r(g),s.d(g,{checkFileTypes:()=>Hh,filterQueryParamsFromURL:()=>Gh,getMediaURLs:()=>Zh,getMediaURLsMetadata:()=>Xh,getURI:()=>qh,isAudioURL:()=>Qh,isEncryptedFileURL:()=>Yh,isGIFURL:()=>Vh,isImageURL:()=>Kh,isURLWithImageExtension:()=>Wh,isValidURL:()=>Bh,isVideoURL:()=>Jh});var f={};s.r(f),s.d(f,{AFFILIATIONS:()=>df,AFFILIATION_CHANGES:()=>hf,AFFILIATION_CHANGES_LIST:()=>mf,INFO_CODES:()=>yf,MUC_NICK_CHANGED_CODE:()=>wf,MUC_ROLE_CHANGES:()=>pf,MUC_ROLE_CHANGES_LIST:()=>vf,MUC_ROLE_WEIGHTS:()=>uf,MUC_TRAFFIC_STATES:()=>gf,MUC_TRAFFIC_STATES_LIST:()=>ff,ROLES:()=>lf,ROOMSTATUS:()=>bf,ROOM_FEATURES:()=>_f});var p=s(1615),v=s.n(p),y=s(5569),b=s.n(y),_=s(9807),w=s.n(_);const S=window.WebSocket,x=window.DOMParser;function A(){return document.implementation.createDocument("jabber:client","strophe",null)}const E={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"},C={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"]},$={ERROR:0,CONNECTING:1,CONNFAIL:2,AUTHENTICATING:3,AUTHFAIL:4,CONNECTED:5,DISCONNECTED:6,DISCONNECTING:7,ATTACHED:8,REDIRECT:9,CONNTIMEOUT:10,BINDREQUIRED:11,ATTACHFAIL:12,RECONNECTING:13},j={BAD_FORMAT:"bad-format",CONFLICT:"conflict",MISSING_JID_NODE:"x-strophe-bad-non-anon-jid",NO_AUTH_MECH:"no-auth-mech",UNKNOWN_REASON:"unknown"},k={DEBUG:0,INFO:1,WARN:2,ERROR:3,FATAL:4},T={NORMAL:1,TEXT:3,CDATA:4,FRAGMENT:11};let I=k.DEBUG;const O={setLogLevel(e){if(ek.FATAL)throw new Error("Invalid log level supplied to setLogLevel");I=e},log(e,t){e=k.ERROR?console?.error(t):e===k.INFO?console?.info(t):e===k.WARN?console?.warn(t):e===k.DEBUG&&console?.debug(t))},debug(e){this.log(k.DEBUG,e)},info(e){this.log(k.INFO,e)},warn(e){this.log(k.WARN,e)},error(e){this.log(k.ERROR,e)},fatal(e){this.log(k.FATAL,e)}};function N(e){void 0!==e.stack&&O.fatal(e.stack),O.fatal("error: "+e.message)}function M(e){let t="";const s=e.length;for(let n=0;n=0&&s<=127?t+=e.charAt(n):s>2047?(t+=String.fromCharCode(224|s>>12&15),t+=String.fromCharCode(128|s>>6&63),t+=String.fromCharCode(128|63&s)):(t+=String.fromCharCode(192|s>>6&31),t+=String.fromCharCode(128|63&s))}return t}function R(e,t){const s=new Uint8Array(e),n=new Uint8Array(t),i=new Uint8Array(e.byteLength);for(let t=0;te.charCodeAt(0)))?.buffer}function L(e){return(new TextEncoder).encode(e).buffer}function P(e){"undefined"==typeof document&&O.error("addCookies: not adding any cookies, since there's no document object"),e=e||{};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let s="",n="",i="";const r=e[t],o="object"==typeof r,a=escape(unescape(o?r.value:r));o&&(s=r.expires?";expires="+r.expires:"",n=r.domain?";domain="+r.domain:"",i=r.path?";path="+r.path:""),document.cookie=t+"="+a+s+n+i}}let U=null;function F(){return U||(U=A()),U}function B(e){return F().createTextNode(e)}function q(e){return(new x).parseFromString(e,"text/xml")}function H(e,t,s){if(!e)return null;const n=F().createElement(e);if(!s||"string"!=typeof s&&"number"!=typeof s){if("string"==typeof t||"number"==typeof t)return n.appendChild(B(t.toString())),n;if(!t)return n}else n.appendChild(B(s.toString()));if(Array.isArray(t))for(const e of t)Array.isArray(e)&&null!=e[0]&&null!=e[1]&&n.setAttribute(e[0],e[1]);else if("object"==typeof t)for(const e of Object.keys(t))e&&null!=t[e]&&n.setAttribute(e,t[e].toString());return n}function G(e){for(let t=0;t0)for(let e=0;e0&&(r=e.join("; "),t.setAttribute(i,r))}else t.setAttribute(i,r)}for(let s=0;s/g,">")).replace(/'/g,"'")).replace(/"/g,""")}function Y(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')}function X(e,t,s){for(let n=0;n/g,"\\3e").replace(/@/g,"\\40")}function se(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")}function ne(e){return e.indexOf("@")<0?null:e.split("@")[0]}function ie(e){const t=oe(e);if(t.indexOf("@")<0)return t;{const e=t.split("@");return e.splice(0,1),e.join("@")}}function re(e){if(!e)return null;const t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))}function oe(e){return e?e.split("/")[0]:null}const ae={utf16to8:M,xorArrayBuffers:R,arrayBufToBase64:D,base64ToArrayBuf:z,stringToArrayBuf:L,addCookies:P};function ce(e,t){return new he(e,t)}function le(e){return new he("message",e)}function de(e){return new he("iq",e)}function ue(e){return new he("presence",e)}class he{constructor(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=E.CLIENT:t||(t={xmlns:E.CLIENT})),this.nodeTree=H(e,t),this.node=this.nodeTree}static serialize(e){if(!e)return null;const t=e instanceof he?e.tree():e,s=[...Array(t.attributes.length).keys()].map((e=>t.attributes[e].nodeName));s.sort();let n=s.reduce(((e,s)=>`${e} ${s}="${K(t.attributes.getNamedItem(s).value)}"`),`<${t.nodeName}`);if(t.childNodes.length>0){n+=">";for(let e=0;e"}}n+=""}else n+="/>";return n}tree(){return this.nodeTree}toString(){return he.serialize(this.nodeTree)}up(){return this.node=this.node.parentElement,this}root(){return this.node=this.nodeTree,this}attrs(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(null!=e[t]?this.node.setAttribute(t,e[t].toString()):this.node.removeAttribute(t));return this}c(e,t,s){const n=H(e,t,s);return this.node.appendChild(n),"string"!=typeof s&&"number"!=typeof s&&(this.node=n),this}cnode(e){let t;const s=F();try{t=void 0!==s.importNode}catch(e){t=!1}const n=t?s.importNode(e,!0):J(e);return this.node.appendChild(n),this.node=n,this}t(e){const t=B(e);return this.node.appendChild(t),this}h(e){const t=F().createElement("body");t.innerHTML=e;const s=Q(t);for(;s.childNodes.length>0;)this.node.appendChild(s.childNodes[0]);return this}}const me=he;let ge=0;const fe=class{constructor(e,t,s,n=0){this.id=++ge,this.xmlData=e,this.data=me.serialize(e),this.origFunc=t,this.func=t,this.rid=s,this.date=NaN,this.sends=n,this.abort=!1,this.dead=null,this.age=()=>this.date?((new Date).valueOf()-this.date.valueOf())/1e3:0,this.timeDead=()=>this.dead?((new Date).valueOf()-this.dead.valueOf())/1e3:0,this.xhr=this._newXHR()}getResponse(){let e=this.xhr.responseXML?.documentElement;if(e){if("parsererror"===e.tagName)throw O.error("invalid response received"),O.error("responseText: "+this.xhr.responseText),O.error("responseXML: "+me.serialize(e)),new Error("parsererror")}else if(this.xhr.responseText){O.debug("Got responseText but no responseXML; attempting to parse it with DOMParser..."),e=(new x).parseFromString(this.xhr.responseText,"application/xml").documentElement;const t=e?.querySelector("parsererror");if(!e||t){t&&(O.error("invalid response received: "+t.textContent),O.error("responseText: "+this.xhr.responseText));const e=new Error;throw e.name=j.BAD_FORMAT,e}}return e}_newXHR(){const e=new XMLHttpRequest;return e.overrideMimeType&&e.overrideMimeType("text/xml; charset=utf-8"),e.onreadystatechange=this.func.bind(null,this),e}};let pe=1.1,ve=.1;class ye{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.strip=ye.prototype.strip??!1,this.lastResponseHeaders=null,this._requests=[]}static setTimeoutMultiplier(e){pe=e}static getTimeoutMultplier(){return pe}static setSecondaryTimeoutMultiplier(e){ve=e}static getSecondaryTimeoutMultplier(){return ve}_buildBody(){const e=ce("body",{rid:this.rid++,xmlns:E.HTTPBIND});return null!==this.sid&&e.attrs({sid:this.sid}),this._conn.options.keepalive&&this._conn._sessionCachingSupported()&&this._cacheSession(),e}_reset(){this.rid=Math.floor(4294967295*Math.random()),this.sid=null,this.errors=0,this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_connect(e,t,s){this.wait=e||this.wait,this.hold=t||this.hold,this.errors=0;const n=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":E.BOSH});s&&n.attrs({route:s});const i=this._conn._connect_cb;this._requests.push(new fe(n.tree(),this._onRequestStateChange.bind(this,i.bind(this._conn)),Number(n.tree().getAttribute("rid")))),this._throttledRequestHandler()}_attach(e,t,s,n,i,r,o){this._conn.jid=e,this.sid=t,this.rid=s,this._conn.connect_callback=n,this._conn.domain=ie(this._conn.jid),this._conn.authenticated=!0,this._conn.connected=!0,this.wait=i||this.wait,this.hold=r||this.hold,this.window=o||this.window,this._conn._changeConnectStatus($.ATTACHED,null)}_restore(e,t,s,n,i){const r=JSON.parse(sessionStorage.getItem("strophe-bosh-session"));if(!(null!=r&&r.rid&&r.sid&&r.jid&&(null==e||oe(r.jid)===oe(e)||null===ne(e)&&ie(r.jid)===e))){const e=new Error("_restore: no restoreable session.");throw e.name="StropheSessionError",e}this._conn.restored=!0,this._attach(r.jid,r.sid,r.rid,t,s,n,i)}_cacheSession(){this._conn.authenticated?this._conn.jid&&this.rid&&this.sid&&sessionStorage.setItem("strophe-bosh-session",JSON.stringify({jid:this._conn.jid,rid:this.rid,sid:this.sid})):sessionStorage.removeItem("strophe-bosh-session")}_connect_cb(e){const t=e.getAttribute("type");if(null!==t&&"terminate"===t){let t=e.getAttribute("condition");O.error("BOSH-Connection failed: "+t);const s=e.getElementsByTagName("conflict");return null!==t?("remote-stream-error"===t&&s.length>0&&(t="conflict"),this._conn._changeConnectStatus($.CONNFAIL,t)):this._conn._changeConnectStatus($.CONNFAIL,"unknown"),this._conn._doDisconnect(t),$.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));const s=e.getAttribute("requests");s&&(this.window=parseInt(s,10));const n=e.getAttribute("hold");n&&(this.hold=parseInt(n,10));const i=e.getAttribute("wait");i&&(this.wait=parseInt(i,10));const r=e.getAttribute("inactivity");r&&(this.inactivity=parseInt(r,10))}_disconnect(e){this._sendTerminate(e)}_doDisconnect(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_emptyQueue(){return 0===this._requests.length}_callProtocolErrorHandlers(e){const t=ye._getRequestStatus(e),s=this._conn.protocolErrorHandlers.HTTP[t];s&&s.call(this,t)}_hitError(e){this.errors++,O.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()}_no_auth_received(e){O.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 fe(t.tree(),this._onRequestStateChange.bind(this,e),Number(t.tree().getAttribute("rid")))),this._throttledRequestHandler()}_onDisconnectTimeout(){this._abortAllRequests()}_abortAllRequests(){for(;this._requests.length>0;){const e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}}_onIdle(){const e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(O.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 s=0;s0){const e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(pe*this.wait)&&this._throttledRequestHandler(),e>Math.floor(pe*this.wait)&&(O.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(pe*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}}static _getRequestStatus(e,t){let s;if(4===e.xhr.readyState)try{s=e.xhr.status}catch(e){O.error("Caught an error while retrieving a request's status, reqStatus: "+s)}return void 0===s&&(s="number"==typeof t?t:0),s}_onRequestStateChange(e,t){if(O.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)return void(t.abort=!1);if(4!==t.xhr.readyState)return;const s=ye._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this._conn.disconnecting&&s>=400)return this._hitError(s),void this._callProtocolErrorHandlers(t);const n=this._requests[0]===t,i=this._requests[1]===t,r=s>0&&s<500,o=t.sends>this._conn.maxRetries;(r||o)&&(this._removeRequest(t),O.debug("request id "+t.id+" should now be removed")),200===s?((i||n&&this._requests.length>0&&this._requests[0].age()>Math.floor(pe*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(t.rid+1),O.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0):0===s||s>=400&&s<600||s>=12e3?(O.error("request id "+t.id+"."+t.sends+" error "+s+" happened"),this._hitError(s),this._callProtocolErrorHandlers(t),s>=400&&s<500&&(this._conn._changeConnectStatus($.DISCONNECTING,null),this._conn._doDisconnect())):O.error("request id "+t.id+"."+t.sends+" error "+s+" happened"),r||o?o&&!this._conn.connected&&this._conn._changeConnectStatus($.CONNFAIL,"giving-up"):this._throttledRequestHandler()}_processRequest(e){let t=this._requests[e];const s=ye._getRequestStatus(t,-1);if(t.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();const n=t.age(),i=!isNaN(n)&&n>Math.floor(pe*this.wait),r=null!==t.dead&&t.timeDead()>Math.floor(ve*this.wait),o=4===t.xhr.readyState&&(s<1||s>=500);if((i||r||o)&&(r&&O.error(`Request ${this._requests[e].id} timed out (secondary), restarting`),t.abort=!0,t.xhr.abort(),t.xhr.onreadystatechange=function(){},this._requests[e]=new fe(t.xmlData,t.origFunc,t.rid,t.sends),t=this._requests[e]),0===t.xhr.readyState){O.debug("request id "+t.id+"."+t.sends+" posting");try{const e=this._conn.options.contentType||"text/xml; charset=utf-8";t.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==t.xhr.setRequestHeader&&t.xhr.setRequestHeader("Content-Type",e),this._conn.options.withCredentials&&(t.xhr.withCredentials=!0)}catch(e){return O.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus($.CONNFAIL,"bad-service"),void this._conn.disconnect()}const e=()=>{if(t.date=(new Date).valueOf(),this._conn.options.customHeaders){const e=this._conn.options.customHeaders;for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.xhr.setRequestHeader(s,e[s])}t.xhr.send(t.data)};if(t.sends>1){const s=1e3*Math.min(Math.floor(pe*this.wait),Math.pow(t.sends,3));setTimeout((function(){e()}),s)}else e();t.sends++,this.strip&&"body"===t.xmlData.nodeName&&t.xmlData.childNodes.length?this._conn.xmlOutput?.(t.xmlData.children[0]):this._conn.xmlOutput?.(t.xmlData),this._conn.rawOutput?.(t.data)}else O.debug("_processRequest: "+(0===e?"first":"second")+" request has readyState of "+t.xhr.readyState)}_removeRequest(e){O.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){O.debug("_sendTerminate was called");const t=this._buildBody().attrs({type:"terminate"}),s=e instanceof me?e.tree():e;e&&t.cnode(s);const n=new fe(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),Number(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?O.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):O.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.getNamespace(e)===this.ns&&(t=!0)})),t||this.getNamespace(e)===this.ns)}isMatch(e){let t=e.getAttribute("from");this.options.matchBareFromJid&&(t=oe(t));const s=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!Z(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(s):s!==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 N(e),e}return t}toString(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}};const Se=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+")}"}};const xe=class{constructor(e,t,s){this.mechname=e,this.isClientFirst=t,this.priority=s}test(e){return!0}onStart(e){this._connection=e}onChallenge(e,t){throw new Error("You should implement challenge handling!")}clientChallenge(e){if(!this.isClientFirst)throw new Error("clientChallenge should not be called if isClientFirst is false!");return this.onChallenge(e)}onFailure(){this._connection=null}onSuccess(){this._connection=null}};const Ae=class extends xe{constructor(e="ANONYMOUS",t=!1,s=20){super(e,t,s)}test(e){return null===e.authcid}};const Ee=class extends xe{constructor(e="EXTERNAL",t=!0,s=10){super(e,t,s)}onChallenge(e){return e.authcid===e.authzid?"":e.authzid}};const Ce=class extends xe{constructor(e="OAUTHBEARER",t=!0,s=40){super(e,t,s)}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+="",ae.utf16to8(t)}};const $e=class extends xe{constructor(e="PLAIN",t=!0,s=50){super(e,t,s)}test(e){return null!==e.authcid}onChallenge(e){const{authcid:t,authzid:s,domain:n,pass:i}=e;if(!n)throw new Error("SASLPlain onChallenge: domain is not defined!");let r=s!==`${t}@${n}`?s:"";return r+="\0",r+=t,r+="\0",r+=i,ae.utf16to8(r)}};const je={async scramResponse(e,t,s,n){const i=e._sasl_data.cnonce,r=function(e){let t,s,n;const i=/([a-z]+)=([^,]+)(,|$)/;for(;e.match(i);){const r=e.match(i);switch(e=e.replace(r[0],""),r[1]){case"r":t=r[2];break;case"s":s=ae.base64ToArrayBuf(r[2]);break;case"i":n=parseInt(r[2],10);break;case"m":return}}if(isNaN(n)||n<4096)O.warn("Failing SCRAM authentication because server supplied iteration count < 4096.");else{if(s)return{nonce:t,salt:s,iter:n};O.warn("Failing SCRAM authentication because server supplied incorrect salt.")}}(t);if(!r&&r?.nonce.slice(0,i.length)!==i)return O.warn("Failing SCRAM authentication because server supplied incorrect nonce."),e._sasl_data={},e._sasl_failure_cb();let o,a;const{pass:c}=e;if("string"==typeof e.pass||e.pass instanceof String){const e=await async function(e,t,s,n,i){const r=await crypto.subtle.deriveBits({name:"PBKDF2",salt:t,iterations:s,hash:{name:n}},await crypto.subtle.importKey("raw",ae.stringToArrayBuf(e),"PBKDF2",!1,["deriveBits"]),i),o=await crypto.subtle.importKey("raw",r,{name:"HMAC",hash:n},!1,["sign"]);return{ck:await crypto.subtle.sign("HMAC",o,ae.stringToArrayBuf("Client Key")),sk:await crypto.subtle.sign("HMAC",o,ae.stringToArrayBuf("Server Key"))}}(c,r.salt,r.iter,s,n);o=e.ck,a=e.sk}else{if(c?.name!==s||c?.salt!==ae.arrayBufToBase64(r.salt)||c?.iter!==r.iter)return e._sasl_failure_cb();{const{ck:e,sk:t}=c;o=ae.base64ToArrayBuf(e),a=ae.base64ToArrayBuf(t)}}const l=e._sasl_data["client-first-message-bare"],d=t,u=`c=biws,r=${r.nonce}`,h=`${l},${d},${u}`,m=await async function(e,t,s){const n=await crypto.subtle.importKey("raw",await crypto.subtle.digest(s,t),{name:"HMAC",hash:s},!1,["sign"]),i=await crypto.subtle.sign("HMAC",n,ae.stringToArrayBuf(e));return ae.xorArrayBuffers(t,i)}(h,o,s),g=await async function(e,t,s){const n=await crypto.subtle.importKey("raw",t,{name:"HMAC",hash:s},!1,["sign"]);return crypto.subtle.sign("HMAC",n,ae.stringToArrayBuf(e))}(h,a,s);return e._sasl_data["server-signature"]=ae.arrayBufToBase64(g),e._sasl_data.keys={name:s,iter:r.iter,salt:ae.arrayBufToBase64(r.salt),ck:ae.arrayBufToBase64(o),sk:ae.arrayBufToBase64(a)},`${u},p=${ae.arrayBufToBase64(m)}`},clientChallenge(e,t){const s=t||function(){const e=new Uint8Array(16);return ae.arrayBufToBase64(crypto.getRandomValues(e).buffer)}(),n=`n=${e.authcid},r=${s}`;return e._sasl_data.cnonce=s,e._sasl_data["client-first-message-bare"]=n,`n,,${n}`}};const ke=class extends xe{constructor(e="SCRAM-SHA-1",t=!0,s=60){super(e,t,s)}test(e){return null!==e.authcid}async onChallenge(e,t){return await je.scramResponse(e,t,"SHA-1",160)}clientChallenge(e,t){return je.clientChallenge(e,t)}};const Te=class extends xe{constructor(e="SCRAM-SHA-256",t=!0,s=70){super(e,t,s)}test(e){return null!==e.authcid}async onChallenge(e,t){return await je.scramResponse(e,t,"SHA-256",256)}clientChallenge(e,t){return je.clientChallenge(e,t)}};const Ie=class extends xe{constructor(e="SCRAM-SHA-384",t=!0,s=71){super(e,t,s)}test(e){return null!==e.authcid}async onChallenge(e,t){return await je.scramResponse(e,t,"SHA-384",384)}clientChallenge(e,t){return je.clientChallenge(e,t)}};const Oe=class extends xe{constructor(e="SCRAM-SHA-512",t=!0,s=72){super(e,t,s)}test(e){return null!==e.authcid}async onChallenge(e,t){return await je.scramResponse(e,t,"SHA-512",512)}clientChallenge(e,t){return je.clientChallenge(e,t)}};const Ne=class extends xe{constructor(e="X-OAUTH2",t=!0,s=30){super(e,t,s)}test(e){return null!==e.pass}onChallenge(e){let t="\0";return null!==e.authcid&&(t+=e.authzid),t+="\0",t+=e.pass,ae.utf16to8(t)}};class Me extends Error{constructor(e){super(e),this.name="StropheSessionError"}}const Re=class{constructor(e){this._conn=e,this.strip="wrapper";const t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){let s="";"ws"===e.options.protocol&&"https:"!==location.protocol?s+="ws":s+="wss",s+="://"+location.host,0!==t.indexOf("/")?s+=location.pathname+t:s+=t,e.service=s}}_buildStream(){return ce("open",{xmlns:E.FRAMING,to:this._conn.domain,version:"1.0"})}_checkStreamError(e,t){let s;if(s=e.getElementsByTagNameNS?e.getElementsByTagNameNS(E.STREAM,"error"):e.getElementsByTagName("stream:error"),0===s.length)return!1;const n=s[0];let i="",r="";for(let e=0;ethis._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,$.CONNFAIL))return $.CONNFAIL}_handleStreamStart(e){let t=null;const s=e.getAttribute("xmlns");"string"!=typeof s?t="Missing xmlns in ":s!==E.FRAMING&&(t="Wrong xmlns in : "+s);const n=e.getAttribute("version");return"string"!=typeof n?t="Missing version in ":"1.0"!==n&&(t="Wrong version in : "+n),!t||(this._conn._changeConnectStatus($.CONNFAIL,t),this._conn._doDisconnect(),!1)}_onInitialMessage(e){if(0===e.data.indexOf("\s*)*/,"");if(""===t)return;const s=(new x).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(s),this._conn.rawInput(e.data),this._handleStreamStart(s)&&this._connect_cb(s)}else if(0===e.data.indexOf("=0&&s.indexOf("wss:")>=0||e.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus($.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=s,this._connect())}else this._conn._changeConnectStatus($.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{this._replaceMessageHandler();const t=this._streamWrap(e.data),s=(new x).parseFromString(t,"text/xml").documentElement;this._conn._connect_cb(s,null,e.data)}}_replaceMessageHandler(){this.socket.onmessage=e=>this._onMessage(e)}_disconnect(e){if(this.socket&&this.socket.readyState!==S.CLOSED){e&&this._conn.send(e);const t=ce("close",{xmlns:E.FRAMING});this._conn.xmlOutput(t.tree());const s=me.serialize(t);this._conn.rawOutput(s);try{this.socket.send(s)}catch(e){O.warn("Couldn't send tag.")}}setTimeout((()=>this._conn._doDisconnect()),0)}_doDisconnect(){O.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){O.debug(e.message)}this.socket=null}_emptyQueue(){return!0}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(O.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(O.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus($.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):O.debug("Websocket closed")}_no_auth_received(e){O.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus($.CONNFAIL,j.NO_AUTH_MECH),e?.call(this._conn),this._conn._doDisconnect()}_onDisconnectTimeout(){}_abortAllRequests(){}_onError(e){O.error("Websocket error "+JSON.stringify(e)),this._conn._changeConnectStatus($.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{console?.error(e),O.error(`Shared Worker Error: ${e}`)}}_setSocket(){this.socket={send:e=>this.worker.port.postMessage(["send",e]),close:()=>this.worker.port.postMessage(["_closeSocket"]),onopen:()=>{},onerror:e=>this._onError(e),onclose:e=>this._onClose(e),onmessage:()=>{},readyState:null}}_connect(){this._setSocket(),this._messageHandler=e=>this._onInitialMessage(e),this.worker.port.start(),this.worker.port.onmessage=e=>this._onWorkerMessage(e),this.worker.port.postMessage(["_connect",this._conn.service,this._conn.jid])}_attach(e){this._setSocket(),this._messageHandler=e=>this._onMessage(e),this._conn.connect_callback=e,this.worker.port.start(),this.worker.port.onmessage=e=>this._onWorkerMessage(e),this.worker.port.postMessage(["_attach",this._conn.service])}_attachCallback(e,t){e===$.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus($.ATTACHED)):e===$.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus($.ATTACHFAIL))}_disconnect(e){e&&this._conn.send(e);const t=ce("close",{xmlns:E.FRAMING});this._conn.xmlOutput(t.tree());const s=me.serialize(t);this._conn.rawOutput(s),this.worker.port.postMessage(["send",s]),this._conn._doDisconnect()}_closeSocket(){this.socket.close()}_replaceMessageHandler(){this._messageHandler=e=>this._onMessage(e)}_onWorkerMessage(e){const{data:t}=e,s=t[0];if("_onMessage"===s)this._messageHandler(t[1]);else if(s in this)try{this[s].apply(this,e.data.slice(1))}catch(e){O.error(e)}else if("log"===s){const e={debug:k.DEBUG,info:k.INFO,warn:k.WARN,error:k.ERROR,fatal:k.FATAL},s=t[1],n=t[2];O.log(e[s],n)}else O.error(`Found unhandled service worker message: ${t}`)}},ze={};class Le{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),P(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms),this.iqFallbackHandler=new we((e=>this.send(de({type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("service-unavailable",{xmlns:E.STANZAS}))),null,"iq",["get","set"]);for(const e in ze)if(Object.prototype.hasOwnProperty.call(ze,e)){const t=function(){};t.prototype=ze[e],this[e]=new t,this[e].init(this)}}static addConnectionPlugin(e,t){ze[e]=t}setProtocol(){const e=this.options.protocol||"";this.options.worker?this._proto=new De(this):0===this.service.indexOf("ws:")||0===this.service.indexOf("wss:")||0===e.indexOf("ws")?this._proto=new Re(this):this._proto=new be(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,s){this.protocolErrorHandlers[e][t]=s}connect(e,t,s,n,i,r,o,a=3e3){this.jid=e,this.authzid=oe(this.jid),this.authcid=o||ne(this.jid),this.pass=t,this.scram_keys=null,this.connect_callback=s,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.disconnection_timeout=a,this.domain=ie(this.jid),this._changeConnectStatus($.CONNECTING,null),this._proto._connect(n,i,r)}attach(e,t,s,n,i,r,o){if(this._proto instanceof be&&"string"==typeof e)return this._proto._attach(e,t,s,n,i,r,o);if(this._proto instanceof De&&"function"==typeof e){const t=e;return this._proto._attach(t)}throw new Me('The "attach" method is not available for your connection protocol')}restore(e,t,s,n,i){if(!(this._proto instanceof be&&this._sessionCachingSupported()))throw new Me('The "restore" method can only be used with a BOSH connection.');this._sessionCachingSupported()&&this._proto._restore(e,t,s,n,i)}_sessionCachingSupported(){if(this._proto instanceof be){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1}xmlInput(e){}xmlOutput(e){}rawInput(e){}rawOutput(e){}nextValidRid(e){}send(e){if(null!==e){if(Array.isArray(e))e.forEach((e=>this._queueData(e instanceof me?e.tree():e)));else{const t=e instanceof me?e.tree():e;this._queueData(t)}this._proto._send()}}flush(){clearTimeout(this._idleTimeout),this._onIdle()}sendPresence(e,t,s,n){let i=null;const r=e instanceof me?e.tree():e;let o=r.getAttribute("id");if(o||(o=this.getUniqueId("sendPresence"),r.setAttribute("id",o)),"function"==typeof t||"function"==typeof s){const e=this.addHandler((e=>{i&&this.deleteTimedHandler(i),"error"===e.getAttribute("type")?s?.(e):t&&t(e)}),null,"presence",null,o);n&&(i=this.addTimedHandler(n,(()=>(this.deleteHandler(e),s?.(null),!1))))}return this.send(r),o}sendIQ(e,t,s,n){let i=null;const r=e instanceof me?e.tree():e;let o=r.getAttribute("id");if(o||(o=this.getUniqueId("sendIQ"),r.setAttribute("id",o)),"function"==typeof t||"function"==typeof s){const e=this.addHandler((e=>{i&&this.deleteTimedHandler(i);const n=e.getAttribute("type");if("result"===n)t?.(e);else{if("error"!==n){const e=new Error(`Got bad IQ type of ${n}`);throw e.name="StropheError",e}s?.(e)}}),null,"iq",["error","result"],o);n&&(i=this.addTimedHandler(n,(()=>(this.deleteHandler(e),s?.(null),!1))))}return this.send(r),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 s=new Se(e,t);return this.addTimeds.push(s),s}deleteTimedHandler(e){this.removeTimeds.push(e)}addHandler(e,t,s,n,i,r,o){const a=new we(e,t,s,n,i,r,o);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||[Ae,Ee,Ce,Ne,$e,ke,Te,Ie,Oe]).forEach((e=>this.registerSASLMechanism(e)))}registerSASLMechanism(e){const t=new e;this.mechanisms[t.mechname]=t}disconnect(e){if(this._changeConnectStatus($.DISCONNECTING,e),e?O.info("Disconnect was called because: "+e):O.debug("Disconnect was called"),this.connected){let e=null;this.disconnecting=!0,this.authenticated&&(e=ue({xmlns:E.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(this.disconnection_timeout,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else O.debug("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()}_changeConnectStatus(e,t,s){for(const s in ze)if(Object.prototype.hasOwnProperty.call(ze,s)){const n=this[s];if(n.statusChanged)try{n.statusChanged(e,t)}catch(e){O.error(`${s} plugin caused an exception changing status: ${e}`)}}if(this.connect_callback)try{this.connect_callback(e,t,s)}catch(e){N(e),O.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),O.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($.DISCONNECTED,e),this.connected=!1}_dataRecv(e,t){const s="_reqToData"in this._proto?this._proto._reqToData(e):e;if(null===s)return;for(this.xmlInput!==Le.prototype.xmlInput&&(s.nodeName===this._proto.strip&&s.childNodes.length?this.xmlInput(s.childNodes[0]):this.xmlInput(s)),this.rawInput!==Le.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(me.serialize(s)));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 n=s.getAttribute("type");if(null!==n&&"terminate"===n){if(this.disconnecting)return;let e=s.getAttribute("condition");const t=s.getElementsByTagName("conflict");return null!==e?("remote-stream-error"===e&&t.length>0&&(e="conflict"),this._changeConnectStatus($.CONNFAIL,e)):this._changeConnectStatus($.CONNFAIL,j.UNKNOWN_REASON),void this._doDisconnect(e)}X(s,null,(e=>{const t=[];this.handlers=this.handlers.reduce(((s,n)=>{try{!n.isMatch(e)||!this.authenticated&&n.user?s.push(n):(n.run(e)&&s.push(n),t.push(n))}catch(e){O.warn("Removing Strophe handlers due to uncaught exception: "+e.message)}return s}),[]),!t.length&&this.iqFallbackHandler.isMatch(e)&&this.iqFallbackHandler.run(e)}))}_connect_cb(e,t,s){let n;O.debug("_connect_cb was called"),this.connected=!0;try{n="_reqToData"in this._proto?this._proto._reqToData(e):e}catch(e){if(e.name!==j.BAD_FORMAT)throw e;this._changeConnectStatus($.CONNFAIL,j.BAD_FORMAT),this._doDisconnect(j.BAD_FORMAT)}if(!n)return;this.xmlInput!==Le.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==Le.prototype.rawInput&&(s?this.rawInput(s):this.rawInput(me.serialize(n)));if(this._proto._connect_cb(n)===$.CONNFAIL)return;let i;if(i=n.getElementsByTagNameNS?n.getElementsByTagNameNS(E.STREAM,"features").length>0:n.getElementsByTagName("stream:features").length>0||n.getElementsByTagName("features").length>0,!i)return void this._proto._no_auth_received(t);const r=Array.from(n.getElementsByTagName("mechanism")).map((e=>this.mechanisms[e.textContent])).filter((e=>e));0!==r.length||0!==n.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(r):this._proto._no_auth_received(t)}sortMechanismsByPriority(e){for(let t=0;te[s].priority&&(s=n);if(s!==t){const n=e[t];e[t]=e[s],e[s]=n}}return e}authenticate(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}_attemptSASLAuth(e){e=this.sortMechanismsByPriority(e||[]);let t=!1;for(let s=0;s{for(;e.length;)this.deleteHandler(e.pop());return this._onStreamFeaturesAfterSASL(t),!1};return t.push(this._addSysHandler((e=>s(t,e)),null,"stream:features",null,null)),t.push(this._addSysHandler((e=>s(t,e)),E.STREAM,"features",null,null)),this._sendRestart(),!1}_onStreamFeaturesAfterSASL(e){this.features=e;for(let t=0;t0&&(t=j.CONFLICT),this._changeConnectStatus($.AUTHFAIL,t,e),!1}const t=e.getElementsByTagName("bind");if(!(t.length>0))return O.warn("Resource binding failed."),this._changeConnectStatus($.AUTHFAIL,null,e),!1;{const e=t[0].getElementsByTagName("jid");e.length>0&&(this.authenticated=!0,this.jid=ee(e[0]),this.do_session?this._establishSession():this._changeConnectStatus($.CONNECTED,null))}}_establishSession(){if(!this.do_session)throw new Error(`Connection.prototype._establishSession called but apparently ${E.SESSION} wasn't advertised by the server`);this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(de({type:"set",id:"_session_auth_2"}).c("session",{xmlns:E.SESSION}).tree())}_onSessionResultIQ(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus($.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,O.warn("Session creation failed."),this._changeConnectStatus($.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($.AUTHFAIL,null,e),!1}_auth2_cb(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus($.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus($.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}_addSysTimedHandler(e,t){const s=new Se(e,t);return s.user=!1,this.addTimeds.push(s),s}_addSysHandler(e,t,s,n,i){const r=new we(e,t,s,n,i);return r.user=!1,this.addHandlers.push(r),r}_onDisconnectTimeout(){return O.debug("_onDisconnectTimeout was called"),this._changeConnectStatus($.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 s=0;sthis._onIdle()),100))}}const Pe=Le,Ue="http://www.w3.org/1999/xhtml";function Fe(e,t){const s=q(e);if(s.getElementsByTagNameNS(Ue,"parsererror").length)throw new Error(`Parser Error: ${e}`);const n=s.firstElementChild;if(["message","iq","presence"].includes(n.nodeName.toLowerCase())&&"jabber:client"!==n.namespaceURI&&"jabber:server"!==n.namespaceURI){const e=`Invalid namespaceURI ${n.namespaceURI}`;if(t)throw new Error(e);O.error(e)}return n}class Be{constructor(e,t){this.strings=e,this.values=t}toString(){return this.string=this.string||this.strings.reduce(((e,t)=>{const s=this.strings.indexOf(t);return e+t+(this.values.length>s?this.values[s].toString():"")}),""),this.string}tree(){return this.node=this.node??Fe(this.toString(),!0),this.node}}const qe={VERSION:"3.0.0",get TIMEOUT(){return be.getTimeoutMultplier()},set TIMEOUT(e){be.setTimeoutMultiplier(e)},get SECONDARY_TIMEOUT(){return be.getSecondaryTimeoutMultplier()},set SECONDARY_TIMEOUT(e){be.setSecondaryTimeoutMultiplier(e)},...i,...O,shims:n,Request:fe,Bosh:be,Websocket:Re,WorkerWebsocket:De,Connection:Pe,Handler:we,SASLAnonymous:Ae,SASLPlain:$e,SASLSHA1:ke,SASLSHA256:Te,SASLSHA384:Ie,SASLSHA512:Oe,SASLOAuthBearer:Ce,SASLExternal:Ee,SASLXOAuth2:Ne,Builder:me,ElementType:T,ErrorCondition:j,LogLevel:k,NS:E,SASLMechanism:xe,Status:$,TimedHandler:Se,XHTML:{...C,validTag:G,validCSS:V,validAttribute:W},serialize:e=>me.serialize(e),setLogLevel(e){O.setLogLevel(e)},addNamespace(e,t){qe.NS[e]=t},addConnectionPlugin(e,t){Pe.addConnectionPlugin(e,t)}};globalThis.$build=ce,globalThis.$iq=de,globalThis.$msg=le,globalThis.$pres=ue,globalThis.Strophe=qe;const He=59,Ge="v11.0.0",We={offline:6,unavailable:5,xa:4,away:3,dnd:2,chat:1,online:1},Ve="anonymous",Qe="closed",Je="external",Ke="login",Ye="logout",Xe="opened",Ze="prebind",et="success",tt="failure",st="image/svg+xml",nt="PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+CiA8cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iIzU1NSIvPgogPGNpcmNsZSBjeD0iNjQiIGN5PSI0MSIgcj0iMjQiIGZpbGw9IiNmZmYiLz4KIDxwYXRoIGQ9Im0yOC41IDExMiB2LTEyIGMwLTEyIDEwLTI0IDI0LTI0IGgyMyBjMTQgMCAyNCAxMiAyNCAyNCB2MTIiIGZpbGw9IiNmZmYiLz4KPC9zdmc+Cg==",it="inactive",rt="active",ot="composing",at="paused",ct="gone",lt="chatbox",dt="chatroom",ut="headline",ht="controlbox",mt={};mt[qe.Status.ATTACHED]="ATTACHED",mt[qe.Status.AUTHENTICATING]="AUTHENTICATING",mt[qe.Status.AUTHFAIL]="AUTHFAIL",mt[qe.Status.CONNECTED]="CONNECTED",mt[qe.Status.CONNECTING]="CONNECTING",mt[qe.Status.CONNFAIL]="CONNFAIL",mt[qe.Status.DISCONNECTED]="DISCONNECTED",mt[qe.Status.DISCONNECTING]="DISCONNECTING",mt[qe.Status.ERROR]="ERROR",mt[qe.Status.RECONNECTING]="RECONNECTING",mt[qe.Status.REDIRECT]="REDIRECT",qe.addNamespace("ACTIVITY","http://jabber.org/protocol/activity"),qe.addNamespace("CARBONS","urn:xmpp:carbons:2"),qe.addNamespace("CHATSTATES","http://jabber.org/protocol/chatstates"),qe.addNamespace("CSI","urn:xmpp:csi:0"),qe.addNamespace("DELAY","urn:xmpp:delay"),qe.addNamespace("EME","urn:xmpp:eme:0"),qe.addNamespace("FASTEN","urn:xmpp:fasten:0"),qe.addNamespace("FORWARD","urn:xmpp:forward:0"),qe.addNamespace("HINTS","urn:xmpp:hints"),qe.addNamespace("HTTPUPLOAD","urn:xmpp:http:upload:0"),qe.addNamespace("MAM","urn:xmpp:mam:2"),qe.addNamespace("MARKERS","urn:xmpp:chat-markers:0"),qe.addNamespace("MENTIONS","urn:xmpp:mmn:0"),qe.addNamespace("MESSAGE_CORRECT","urn:xmpp:message-correct:0"),qe.addNamespace("MODERATE","urn:xmpp:message-moderate:0"),qe.addNamespace("NICK","http://jabber.org/protocol/nick"),qe.addNamespace("OCCUPANTID","urn:xmpp:occupant-id:0"),qe.addNamespace("OMEMO","eu.siacs.conversations.axolotl"),qe.addNamespace("OUTOFBAND","jabber:x:oob"),qe.addNamespace("PUBSUB","http://jabber.org/protocol/pubsub"),qe.addNamespace("RAI","urn:xmpp:rai:0"),qe.addNamespace("RECEIPTS","urn:xmpp:receipts"),qe.addNamespace("REFERENCE","urn:xmpp:reference:0"),qe.addNamespace("REGISTER","jabber:iq:register"),qe.addNamespace("RETRACT","urn:xmpp:message-retract:0"),qe.addNamespace("ROSTERX","http://jabber.org/protocol/rosterx"),qe.addNamespace("RSM","http://jabber.org/protocol/rsm"),qe.addNamespace("SID","urn:xmpp:sid:0"),qe.addNamespace("SPOILER","urn:xmpp:spoiler:0"),qe.addNamespace("STANZAS","urn:ietf:params:xml:ns:xmpp-stanzas"),qe.addNamespace("STYLING","urn:xmpp:styling:0"),qe.addNamespace("VCARD","vcard-temp"),qe.addNamespace("VCARDUPDATE","vcard-temp:x:update"),qe.addNamespace("XFORM","jabber:x:data"),qe.addNamespace("XHTML","http://www.w3.org/1999/xhtml");const gt=["converse-adhoc","converse-bookmarks","converse-bosh","converse-caps","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"],ft={start:/(\b|_)(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi},pt=["active","composing","gone","inactive","paused"],vt={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};var yt=s(8870),bt=s.n(yt);function _t(e){return e instanceof Element||e instanceof HTMLDocument}function wt(e,t){if(e instanceof qe.Builder)return wt(e.tree(),t);if(e instanceof Element)return qe.isTagEqual(e,t);throw Error("isTagEqual called with value which isn't an element or Strophe.Builder instance")}function St(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}function xt(e,t){return Array.from(e.childNodes).filter((e=>e instanceof Element&&e.matches(t)))}function At(e){for(var t=0;e=e.previousElementSibling;t++);return t}const Et=document.createElement("div");function Ct(e){return e&&"string"==typeof e&&(Et.innerHTML=bt().sanitize(e),e=Et.textContent,Et.textContent=""),e}const $t={debug:0,info:1,warn:2,error:3,fatal:4},jt=Object.assign({debug:console?.log?console.log.bind(console):function(){},error:console?.log?console.log.bind(console):function(){},info:console?.log?console.log.bind(console):function(){},warn:console?.log?console.log.bind(console):function(){}},console),kt={setLogLevel(e){if(!["debug","info","warn","error","fatal"].includes(e))throw new Error(`Invalid loglevel: ${e}`);this.loglevel=e},log(e,t,s=""){if($t[t]<$t[this.loglevel])return;"error"===t||"fatal"===t?s=s||"color: maroon":"debug"===t&&(s=s||"color: green"),e instanceof Error?e=e.stack:_t(e)&&(e=e.outerHTML);const n=s?"%c":"";"error"===t?jt.error(`${n} ERROR: ${e}`,s):"warn"===t?jt.warn(`${n} ${(new Date).toISOString()} WARNING: ${e}`,s):"fatal"===t?jt.error(`${n} FATAL: ${e}`,s):"debug"===t?jt.debug(`${n} ${(new Date).toISOString()} DEBUG: ${e}`,s):jt.info(`${n} ${(new Date).toISOString()} INFO: ${e}`,s)},debug(e,t){this.log(e,"debug",t)},error(e,t){this.log(e,"error",t)},info(e,t){this.log(e,"info",t)},warn(e,t){this.log(e,"warn",t)},fatal(e,t){this.log(e,"fatal",t)}};var Tt=s(169);const It={async initialize(){},__:(...e)=>(0,Tt.sprintf)(...e)};function Ot(e,t,s,n,...i){return"function"==typeof s&&(void 0===this.__super__&&(this.__super__=n),this.__super__[e]=s.bind(this)),t.apply(this,i)}class Nt{constructor(e,t){this.name=t,this.plugged=e,void 0===this.plugged.__super__?this.plugged.__super__={}:"string"==typeof this.plugged.__super__&&(this.plugged.__super__={__string__:this.plugged.__super__}),this.plugged.__super__[t]=this.plugged,this.plugins={},this.initialized_plugins=[]}_overrideAttribute(e,t){const s=t.overrides[e];if("function"==typeof s){const t={};t[this.name]=this.plugged;const n=this.plugged[e];this.plugged[e]=function(...i){return Ot.apply(this,[e,s,n,t,...i])}}else this.plugged[e]=s}_extendObject(e,t){e.prototype.__super__||(e.prototype.__super__={},e.prototype.__super__[this.name]=this.plugged);for(const[s,n]of Object.entries(t))if("events"===s)e.prototype[s]=Object.assign(n,e.prototype[s]);else if("function"==typeof n){const t={};t[this.name]=this.plugged;const i=e.prototype[s];e.prototype[s]=function(...e){return Ot.apply(this,[s,n,i,t,...e])}}else e.prototype[s]=n}loadPluginDependencies(e){e.dependencies?.forEach((t=>{const s=this.plugins[t];if(s){if(s.dependencies?.includes(e.__name__))throw'Found a circular dependency between the plugins "'+e.__name__+'" and "'+t+'"';this.initializePlugin(s)}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 s=e.overrides[t];"object"==typeof s?void 0===this.plugged[t]?this.throwUndefinedDependencyError(`Plugin "${e.__name__}" tried to override "${t}" but it's not found.`):this._extendObject(this.plugged[t],s):this._overrideAttribute(t,e)}))}initializePlugin(e){Object.keys(this.allowed_plugins).includes(e.__name__)&&(this.initialized_plugins.includes(e.__name__)||("boolean"==typeof e.enabled&&e.enabled||e.enabled?.(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(e={},t=[],s=[]){if(Object.keys(this.plugins).length){this.properties=e,this.allowed_plugins={};for(const[e,n]of Object.entries(this.plugins))t.length&&!t.includes(e)||s.includes(e)||(this.allowed_plugins[e]=n);Object.values(this.allowed_plugins).forEach((e=>this.initializePlugin(e)))}}}const Mt={enable:function(e,t,s){return void 0===s&&(s="pluginSocket"),void 0===t&&(t="plugged"),e[s]=new Nt(e,t),e}};const Rt="object"==typeof global&&global&&global.Object===Object&&global;var Dt="object"==typeof self&&self&&self.Object===Object&&self;const zt=Rt||Dt||Function("return this")();const Lt=zt.Symbol;const Pt=function(e,t){for(var s=-1,n=null==e?0:e.length,i=Array(n);++se}):void 0,cs="$lit$",ls=`lit$${(Math.random()+"").slice(9)}$`,ds="?"+ls,us=`<${ds}>`,hs=document,ms=()=>hs.createComment(""),gs=e=>null===e||"object"!=typeof e&&"function"!=typeof e,fs=Array.isArray,ps=e=>fs(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]),vs="[ \t\n\f\r]",ys=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bs=/-->/g,_s=/>/g,ws=RegExp(`>|${vs}(?:([^\\s"'>=/]+)(${vs}*=${vs}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Ss=/'/g,xs=/"/g,As=/^(?:script|style|textarea|title)$/i,Es=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),Cs=Es(1),$s=(Es(2),Symbol.for("lit-noChange")),js=Symbol.for("lit-nothing"),ks=new WeakMap,Ts=hs.createTreeWalker(hs,129,null,!1);function Is(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==as?as.createHTML(t):t}const Os=(e,t)=>{const s=e.length-1,n=[];let i,r=2===t?"":"",o=ys;for(let t=0;t"===c[0]?(o=null!=i?i:ys,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?ws:'"'===c[3]?xs:Ss):o===xs||o===Ss?o=ws:o===bs||o===_s?o=ys:(o=ws,i=void 0);const u=o===ws&&e[t+1].startsWith("/>")?" ":"";r+=o===ys?s+us:l>=0?(n.push(a),s.slice(0,l)+cs+s.slice(l)+ls+u):s+ls+(-2===l?(n.push(void 0),t):u)}return[Is(e,r+(e[s]||"")+(2===t?"":"")),n]};class Ns{constructor({strings:e,_$litType$:t},s){let n;this.parts=[];let i=0,r=0;const o=e.length-1,a=this.parts,[c,l]=Os(e,t);if(this.el=Ns.createElement(c,s),Ts.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(n=Ts.nextNode())&&a.length0){n.textContent=os?os.emptyScript:"";for(let s=0;s2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=js}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,s,n){const i=this.strings;let r=!1;if(void 0===i)e=Ms(this,e,t,0),r=!gs(e)||e!==this._$AH&&e!==$s,r&&(this._$AH=e);else{const n=e;let o,a;for(e=i[0],o=0;o{var n,i;const r=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:t;let o=r._$litPart$;if(void 0===o){const e=null!==(i=null==s?void 0:s.renderBefore)&&void 0!==i?i:null;r._$litPart$=o=new Ds(t.insertBefore(ms(),e),e,void 0,null!=s?s:{})}return o._$AI(e),o};var Ws=/\s/;const Vs=function(e){for(var t=e.length;t--&&Ws.test(e.charAt(t)););return t};var Qs=/^\s+/;const Js=function(e){return e?e.slice(0,Vs(e)+1).replace(Qs,""):e};const Ks=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var Ys=/^[-+]0x[0-9a-f]+$/i,Xs=/^0b[01]+$/i,Zs=/^0o[0-7]+$/i,en=parseInt;const tn=function(e){if("number"==typeof e)return e;if(Yt(e))return NaN;if(Ks(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ks(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Js(e);var s=Xs.test(e);return s||Zs.test(e)?en(e.slice(2),s?2:8):Ys.test(e)?NaN:+e};var sn=1/0;const nn=function(e){return e?(e=tn(e))===sn||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};const rn=function(e){var t=nn(e),s=t%1;return t==t?s?t-s:t:0};const on=function(e,t){var s;if("function"!=typeof t)throw new TypeError("Expected a function");return e=rn(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=void 0),s}};const an=function(e){return on(2,e)};const cn=function(e,t){for(var s=-1,n=Array(e);++s-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var Sn={};Sn["[object Float32Array]"]=Sn["[object Float64Array]"]=Sn["[object Int8Array]"]=Sn["[object Int16Array]"]=Sn["[object Int32Array]"]=Sn["[object Uint8Array]"]=Sn["[object Uint8ClampedArray]"]=Sn["[object Uint16Array]"]=Sn["[object Uint32Array]"]=!0,Sn["[object Arguments]"]=Sn["[object Array]"]=Sn["[object ArrayBuffer]"]=Sn["[object Boolean]"]=Sn["[object DataView]"]=Sn["[object Date]"]=Sn["[object Error]"]=Sn["[object Function]"]=Sn["[object Map]"]=Sn["[object Number]"]=Sn["[object Object]"]=Sn["[object RegExp]"]=Sn["[object Set]"]=Sn["[object String]"]=Sn["[object WeakMap]"]=!1;const xn=function(e){return Kt(e)&&wn(e.length)&&!!Sn[Jt(e)]};const An=function(e){return function(t){return e(t)}};var En="object"==typeof exports&&exports&&!exports.nodeType&&exports,Cn=En&&"object"==typeof module&&module&&!module.nodeType&&module,$n=Cn&&Cn.exports===En&&Rt.process;const jn=function(){try{var e=Cn&&Cn.require&&Cn.require("util").types;return e||$n&&$n.binding&&$n.binding("util")}catch(e){}}();var kn=jn&&jn.isTypedArray;const Tn=kn?An(kn):xn;var In=Object.prototype.hasOwnProperty;const On=function(e,t){var s=Ut(e),n=!s&&mn(e),i=!s&&!n&&yn(e),r=!s&&!n&&!i&&Tn(e),o=s||n||i||r,a=o?cn(e.length,String):[],c=a.length;for(var l in e)!t&&!In.call(e,l)||o&&("length"==l||i&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||_n(l,c))||a.push(l);return a};var Nn=Object.prototype;const Mn=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Nn)};const Rn=function(e,t){return function(s){return e(t(s))}};const Dn=Rn(Object.keys,Object);var zn=Object.prototype.hasOwnProperty;const Ln=function(e){if(!Mn(e))return Dn(e);var t=[];for(var s in Object(e))zn.call(e,s)&&"constructor"!=s&&t.push(s);return t};const Pn=function(e){if(!Ks(e))return!1;var t=Jt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const Un=function(e){return null!=e&&wn(e.length)&&!Pn(e)};const Fn=function(e){return Un(e)?On(e):Ln(e)},Bn=/\s+/;function qn(e,t,s,n,i){let r,o=0;if(s&&"object"==typeof s){void 0!==n&&"context"in i&&void 0===i.context&&(i.context=n);for(r=Fn(s);o-1};const qi=function(e,t){var s=this.__data__,n=Li(s,e);return n<0?(++this.size,s.push([e,t])):s[n][1]=t,this};function Hi(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t=43)}})).catch((function(){return!1}))}(e).then((function(e){return Ro=e,Ro}))}function Fo(e){var t=Do[e.name],s={};s.promise=new ko((function(e,t){s.resolve=e,s.reject=t})),t.deferredOperations.push(s),t.dbReady?t.dbReady=t.dbReady.then((function(){return s.promise})):t.dbReady=s.promise}function Bo(e){var t=Do[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function qo(e,t){var s=Do[e.name].deferredOperations.pop();if(s)return s.reject(t),s.promise}function Ho(e,t){return new ko((function(s,n){if(Do[e.name]=Do[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return s(e.db);Fo(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var r=Co.open.apply(Co,i);t&&(r.onupgradeneeded=function(t){var s=r.result;try{s.createObjectStore(e.storeName),t.oldVersion<=1&&s.createObjectStore(Mo)}catch(s){if("ConstraintError"!==s.name)throw s;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),n(r.error)},r.onsuccess=function(){var t=r.result;t.onversionchange=function(e){e.target.close()},s(t),Bo(e)}}))}function Go(e){return Ho(e,!1)}function Wo(e){return Ho(e,!0)}function Vo(e,t){if(!e.db)return!0;var s=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(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||s){if(s){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function Qo(e){var t=function(e){for(var t=e.length,s=new ArrayBuffer(t),n=new Uint8Array(s),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return ko.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),Wo(e)})).then((()=>function(e){Fo(e);for(var t=Do[e.name],s=t.forages,n=0;n(e.db=t,Vo(e)?Wo(e):t))).then((n=>{e.db=t.db=n;for(var i=0;i{throw qo(e,t),t}))}(e).then((function(){Yo(e,t,s,n-1)})))).catch(s);s(i)}}var Xo={_driver:"asyncStorage",_initStorage:function(e){var t=this,s={db:null};if(e)for(var n in e)s[n]=e[n];var i=Do[s.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},Do[s.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=Ko);var r=[];function o(){return ko.resolve()}for(var a=0;a{const s=Do[e.name],n=s.forages;s.db=t;for(var i=0;i{if(!t.objectStoreNames.contains(e.storeName))return;const s=t.version+1;Fo(e);const n=Do[e.name],i=n.forages;t.close();for(let e=0;e{const i=Co.open(e.name,s);i.onerror=e=>{i.result.close(),n(e)},i.onupgradeneeded=()=>{i.result.deleteObjectStore(e.storeName)},i.onsuccess=()=>{const e=i.result;e.close(),t(e)}}));return r.then((e=>{n.db=e;for(let t=0;t{throw(qo(e,t)||ko.resolve()).catch((()=>{})),t}))})):t.then((t=>{Fo(e);const s=Do[e.name],n=s.forages;t.close();for(var i=0;i{var n=Co.deleteDatabase(e.name);n.onerror=()=>{const e=n.result;e&&e.close(),s(n.error)},n.onblocked=()=>{console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},n.onsuccess=()=>{const e=n.result;e&&e.close(),t(e)}}));return r.then((e=>{s.db=e;for(var t=0;t{throw(qo(e,t)||ko.resolve()).catch((()=>{})),t}))}))}else s=ko.reject("Invalid arguments");return To(s,t),s}};const Zo=Xo;const ea=function(){return"function"==typeof openDatabase};var ta="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sa=/^~~local_forage_type~([^~]+)~/,na="__lfsc__:",ia="arbf",ra="blob",oa="si08",aa="ui08",ca="uic8",la="si16",da="si32",ua="ur16",ha="ui32",ma="fl32",ga="fl64",fa=Object.prototype.toString;function pa(e){var t,s,n,i,r,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);var l=new ArrayBuffer(o),d=new Uint8Array(l);for(t=0;t>4,d[c++]=(15&n)<<4|i>>2,d[c++]=(3&i)<<6|63&r;return l}function va(e){var t,s=new Uint8Array(e),n="";for(t=0;t>2],n+=ta[(3&s[t])<<4|s[t+1]>>4],n+=ta[(15&s[t+1])<<2|s[t+2]>>6],n+=ta[63&s[t+2]];return s.length%3==2?n=n.substring(0,n.length-1)+"=":s.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var ya={serialize:function(e,t){var s="";if(e&&(s=fa.call(e)),e&&("[object ArrayBuffer]"===s||e.buffer&&"[object ArrayBuffer]"===fa.call(e.buffer))){var n,i=na;e instanceof ArrayBuffer?(n=e,i+=ia):(n=e.buffer,"[object Int8Array]"===s?i+=oa:"[object Uint8Array]"===s?i+=aa:"[object Uint8ClampedArray]"===s?i+=ca:"[object Int16Array]"===s?i+=la:"[object Uint16Array]"===s?i+=ua:"[object Int32Array]"===s?i+=da:"[object Uint32Array]"===s?i+=ha:"[object Float32Array]"===s?i+=ma:"[object Float64Array]"===s?i+=ga:t(new Error("Failed to get type for BinaryArray"))),t(i+va(n))}else if("[object Blob]"===s){var r=new FileReader;r.onload=function(){var s="~~local_forage_type~"+e.type+"~"+va(this.result);t(na+ra+s)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(s){console.error("Couldn't convert value into a JSON string: ",e),t(null,s)}},deserialize:function(e){if(e.substring(0,9)!==na)return JSON.parse(e);var t,s=e.substring(13),n=e.substring(9,13);if(n===ra&&sa.test(s)){var i=s.match(sa);t=i[1],s=s.substring(i[0].length)}var r=pa(s);switch(n){case ia:return r;case ra:return jo([r],{type:t});case oa:return new Int8Array(r);case aa:return new Uint8Array(r);case ca:return new Uint8ClampedArray(r);case la:return new Int16Array(r);case ua:return new Uint16Array(r);case da:return new Int32Array(r);case ha:return new Uint32Array(r);case ma:return new Float32Array(r);case ga:return new Float64Array(r);default:throw new Error("Unkown type: "+n)}},stringToBuffer:pa,bufferToString:va};const ba=ya;function _a(e,t,s,n){e.executeSql(`CREATE TABLE IF NOT EXISTS ${t.storeName} (id INTEGER PRIMARY KEY, key unique, value)`,[],s,n)}function wa(e,t,s,n,i,r){e.executeSql(s,n,i,(function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?r(e,o):_a(e,t,(function(){e.executeSql(s,n,i,r)}),r)}),r):r(e,o)}),r)}function Sa(e,t,s,n){var i=this;e=Oo(e);var r=new ko((function(r,o){i.ready().then((function(){void 0===t&&(t=null);var a=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,l){l?o(l):c.db.transaction((function(s){wa(s,c,`INSERT OR REPLACE INTO ${c.storeName} (key, value) VALUES (?, ?)`,[e,t],(function(){r(a)}),(function(e,t){o(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(n>0)return void r(Sa.apply(i,[e,a,s,n-1]));o(t)}}))}))})).catch(o)}));return To(r,s),r}var xa={_driver:"webSQLStorage",_initStorage:function(e){var t=this,s={db:null};if(e)for(var n in e)s[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new ko((function(e,n){try{s.db=openDatabase(s.name,String(s.version),s.description,s.size)}catch(e){return n(e)}s.db.transaction((function(i){_a(i,s,(function(){t._dbInfo=s,e()}),(function(e,t){n(t)}))}),n)}));return s.serializer=ba,i},_support:ea(),iterate:function(e,t){var s=this,n=new ko((function(t,n){s.ready().then((function(){var i=s._dbInfo;i.db.transaction((function(s){wa(s,i,`SELECT * FROM ${i.storeName}`,[],(function(s,n){for(var r=n.rows,o=r.length,a=0;a '__WebKitDatabaseInfoTable__'",[],(function(s,n){for(var i=[],r=0;r0}var $a={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var s in e)t[s]=e[s];return t.keyPrefix=Ea(e,this._defaultConfig),Ca()?(this._dbInfo=t,t.serializer=ba,ko.resolve()):ko.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var s=this,n=s.ready().then((function(){for(var t=s._dbInfo,n=t.keyPrefix,i=n.length,r=localStorage.length,o=1,a=0;a=0;s--){var n=localStorage.key(s);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return To(s,e),s},length:function(e){var t=this.keys().then((function(e){return e.length}));return To(t,e),t},key:function(e,t){var s=this,n=s.ready().then((function(){var t,n=s._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t}));return To(n,t),n},keys:function(e){var t=this,s=t.ready().then((function(){for(var e=t._dbInfo,s=localStorage.length,n=[],i=0;i=0;t--){var s=localStorage.key(t);0===s.indexOf(e)&&localStorage.removeItem(s)}})):ko.reject("Invalid arguments"),To(n,t),n}};const ja=$a,ka=(e,t)=>e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t),Ta=(e,t)=>{const s=e.length;let n=0;for(;n{}))}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,s){const n=new ko((function(t,s){try{const n=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void s(i);const r=za.concat("_initStorage");for(let t=0,n=r.length;t(null===t._ready&&(t._ready=t._initDriver()),t._ready)));return Io(s,e,e),s}setDriver(e,t,s){const n=this;Ia(e)||(e=[e]);const i=this._getSupportedDrivers(e);function r(){n._config.driver=n.driver()}function o(e){return n._extend(e),r(),n._ready=n._initStorage(n._config),n._ready}const a=null!==this._driverSet?this._driverSet.catch((()=>ko.resolve())):ko.resolve();return this._driverSet=a.then((()=>{const e=i[0];return n._dbInfo=null,n._ready=null,n.getDriver(e).then((e=>{n._driver=e._driver,r(),n._wrapLibraryMethodsWithReady(),n._initDriver=function(e){return function(){let t=0;return function s(){for(;t{r();const e=new Error("No available storage method found.");return n._driverSet=ko.reject(e),n._driverSet})),Io(this._driverSet,t,s),this._driverSet}supports(e){return!!Na[e]}_extend(e){Ua(this,e)}_getSupportedDrivers(e){const t=[];for(let s=0,n=e.length;s0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(cc);const uc=function(e,t){return dc(oc(e,t,nc),e+"")};const hc=function(e,t,s){if(!Ks(s))return!1;var n=typeof t;return!!("number"==n?Un(s)&&_n(t,s.length):"string"==n&&t in s)&&zi(s[t],e)};const mc=function(e){return uc((function(t,s){var n=-1,i=s.length,r=i>1?s[i-1]:void 0,o=i>2?s[2]:void 0;for(r=e.length>3&&"function"==typeof r?(i--,r):void 0,o&&hc(s[0],s[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++n{e.resolve=t,e.reject=s}));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 yc=Math.max,bc=Math.min;const _c=function(e,t,s={}){let n,i,r,o,a,c,l=0,d=!1,u=s.promise?vc():null;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){const r=n,a=i,c=u;return n=i=void 0,l=t,o=e.apply(a,r),s.promise&&(c.resolve(o),u=vc()),s.promise?c:o}function m(e){const s=e-c;return void 0===c||s>=t||s<0||d&&e-l>=r}function g(){const e=pc();if(m(e))return f(e);a=setTimeout(g,function(e){const s=t-(e-c);return d?bc(s,r-(e-l)):s}(e))}function f(e){return a=void 0,n?h(e):(n=i=void 0,s.promise?u:o)}function p(e,t){if(Array.isArray(e)&&Array.isArray(t))return s?.dedupeArrays?e.concat(t.filter((t=>-1===e.indexOf(t)))):e.concat(t)}function v(){const e=pc(),r=m(e);var f;if(f=Array.from(arguments),n=n?.length?f.length?s?.concatArrays||s?.dedupeArrays?fc(n,f,p):gc(n,f):n:f||[],i=this,c=e,r){if(void 0===a)return function(e){return l=e,a=setTimeout(g,t),s.promise?u:o}(c);if(d)return clearTimeout(a),a=setTimeout(g,t),h(c)}return void 0===a&&(a=setTimeout(g,t)),s.promise?u:o}return t=tn(t)||0,Ks(s)&&(d="maxWait"in s,r=d?yc(tn(s.maxWait)||0,t):r),v.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=i=a=void 0},v.flush=function(){return void 0===a?o:f(pc())},v};function wc(e,t){let s=e.name+"/";return e.storeName!==t.storeName&&(s+=e.storeName+"/"),s}const Sc={serializer:{serialize:ba.serialize,deserialize:ba.deserialize}};const xc={_driver:"sessionStorageWrapper",_initStorage:function(e){if(Sc.keyPrefix=wc(e,this._defaultConfig),e)for(const t in e)Sc[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 s=this.ready().then((function(){const t=Sc.keyPrefix,s=t.length,n=sessionStorage.length;let i=1;for(let r=0;r{if(i)throw i;try{sessionStorage.setItem(Sc.keyPrefix+e,t),To(Promise.resolve(n),s)}catch(e){if("QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)throw console.error("Your sesionStorage capacity is used up."),e;throw e}}))},removeItem:function(e,t){e=Oo(e);const s=this.ready().then((function(){sessionStorage.removeItem(Sc.keyPrefix+e)}));return To(s,t),s},clear:function(e){const t=this.ready().then((function(){const e=Sc.keyPrefix;for(let t=sessionStorage.length-1;t>=0;t--){const s=sessionStorage.key(t);0===s.indexOf(e)&&sessionStorage.removeItem(s)}}));return To(t,e),t},length:function(e){const t=this.keys().then((function(e){return e.length}));return To(t,e),t},key:function(e,t){const s=this.ready().then((function(){let t;try{t=sessionStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(Sc.keyPrefix.length)),t}));return To(s,t),s},keys:function(e){const t=this.ready().then((function(){const e=sessionStorage.length,t=[];for(let s=0;s=0;t--){const s=sessionStorage.key(t);0===s.indexOf(e)&&sessionStorage.removeItem(s)}})):Promise.reject(new Error("Invalid arguments")),To(n,t),n}},Ac=xc;var Ec=s(9212),Cc=s(9214);function $c(e){return $c.result?$c.result:e&&"function"==typeof e.getSerializer?($c.result=e.getSerializer(),$c.result):Promise.reject(new Error("localforage.getSerializer() was not available! localforage v1.4+ is required!"))}function jc(e,t){return t&&e.then((function(e){t(null,e)}),(function(e){t(e)})),e}function kc(e,t){var s=this.getItem(e).then((function(t){return{key:e,value:t}}));return jc(s,t),s}function Tc(e){var t=this,s=new Promise((function(s,n){for(var i=[],r=0,o=e.length;rt?1:0}var n=new Promise((function(n,i){t.ready().then((function(){var r,o=t._dbInfo,a=o.db.transaction(o.storeName,"readonly").objectStore(o.storeName),c=e.sort(s),l=Oc.bound(e[0],e[e.length-1],!1,!1);if("getAll"in a)(r=a.getAll(l)).onsuccess=function(){var e=r.result;void 0===e&&(e=null),n(e)};else{r=a.openCursor(l);var d={},u=0;r.onsuccess=function(){var e=r.result;if(e){for(var t=e.key;t>c[u];)if(++u===c.length)return void n(d);if(t===c[u]){var s=e.value;void 0===s&&(s=null),d[t]=s,e.continue()}else e.continue(c[u])}else n(d)}}r.onerror=function(){i(r.error)}})).catch(i)}));return n}function Mc(e){var t=this,s=new Promise((function(s,n){t.ready().then((function(){return $c(t)})).then((function(i){var r=t._dbInfo;r.db.transaction((function(t){for(var o=new Array(e.length),a=0,c=e.length;a{e.resolve=t,e.reject=s}));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 Xc(){throw new Error('A "url" property or function must be specified')}function Zc(e,t){const s=t.error;t.error=function(n){s&&s.call(t.context,e,n,t),e.trigger("error",e,n,t)}}const el={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"};function tl(e){const t=Jc(e,"browserStorage")||Jc(e.collection,"browserStorage");return t?t.sync():sl}function sl(e,t,s={}){let n=s.data;null!=n||!t||"create"!==e&&"update"!==e&&"patch"!==e||(n=s.attrs||t.toJSON());const i={method:el[e],body:n?JSON.stringify(n):"",success:s.success,error:s.error},r=s.url||Jc(t,"url")||Xc(),o=s.xhr=fetch(r,i);return t.trigger("request",t,o,{...i,xhr:o}),o}const nl=Ri._driver;Ba.defineDriver(Ri),(0,Ec.extendPrototype)(Ba),Dc(Ba);class il{constructor(e,t,s=!1){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.");Eo(t)?this.storeInitialized=this.initStore(t,s):(this.store=t,s&&(this.store.debouncedSetItems=_c((e=>this.store.setItems(e)),50,{promise:!0})),this.storeInitialized=Promise.resolve()),this.name=e}async initStore(e,t){if("session"===e)await Ba.setDriver(Ac._driver);else if("local"===e)await Ba.config({driver:Ba.LOCALSTORAGE});else if("in_memory"===e)await Ba.config({driver:nl});else if("indexed"!==e)throw new Error("Skeletor.storage: No storage type was specified");this.store=Ba,t&&(this.store.debouncedSetItems=_c((e=>this.store.setItems(e)),50,{promise:!0}))}flush(){return this.store.debouncedSetItems?.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,s,n){let i,r,o,a;const c=s.collection;["patch","update"].includes(t)&&(a=Ao(s.attributes)),await e.storeInitialized;try{const r=s.attributes;switch(t){case"read":i=void 0!==s.id?await e.find(s):await e.findAll();break;case"create":i=await e.create(s,n);break;case"patch":case"update":n.wait&&(s.attributes=a),o=e.update(s),n.wait&&(s.attributes=r),i=await o;break;case"delete":i=await e.destroy(s,c)}}catch(t){r=22===t.code&&0===e.getStorageSize()?"Private browsing is unsupported":t.message}if(i){if(n&&n.success){const e="read"===t?i:null;n.success(e,n)}}else r=r||"Record Not Found",n&&n.error&&n.error(r)}return t.__name__="localSync",t}removeCollectionReference(e,t){if(!t)return;const s=t.filter((t=>t.id!==e.id)).map((e=>this.getItemName(e.id)));return this.store.setItem(this.name,s)}addCollectionReference(e,t){if(!t)return;const s=t.map((e=>this.getItemName(e.id))),n=this.getItemName(e.id);return s.includes(n)||s.push(n),this.store.setItem(this.name,s)}getCollectionReferenceData(e){if(!e.collection)return{};const t=e.collection.map((e=>this.getItemName(e.id))),s=this.getItemName(e.id);t.includes(s)||t.push(s);const n={};return n[this.name]=t,n}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),s=await this.store.setItem(t,e.toJSON());return await this.addCollectionReference(e,e.collection),s}}create(e,t){return e.id||(e.id=Kc()+Kc()+"-"+Kc()+"-"+Kc()+"-"+Kc()+"-"+Kc()+Kc()+Kc(),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(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}}il.sessionStorageInitialized=Ba.defineDriver(Ac),il.localForage=Ba;const rl=il;const ol=function(e){return xo(e,4)};var al=Object.prototype,cl=al.hasOwnProperty,ll=uc((function(e,t){e=Object(e);var s=-1,n=t.length,i=n>2?t[2]:void 0;for(i&&hc(t[0],t[1],i)&&(n=1);++sa))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var u=-1,h=!0,m=2&s?new Cl:void 0;for(r.set(e,t),r.set(t,e);++ui?0:i+t),(s=s>i?i:s)<0&&(s+=i),i=t>s?0:s-t>>>0,t>>>=0;for(var r=Array(i);++n0&&n(c)?s>1?e(c,s-1,n,i,r):Br(r,c):i||(r[r.length]=c)}return r};const md=function(e){return(null==e?0:e.length)?hd(e,1):[]};const gd=function(e){return dc(oc(e,void 0,md),e+"")};var fd=gd((function(e,t){var s={};if(null==e)return s;var n=!1;t=Pt(t,(function(t){return t=Vc(t,e),n||(n=t.length>1),t})),xr(e,Jr(e),s),n&&(s=xo(s,7,ld));for(var i=t.length;i--;)cd(s,t[i]);return s}));const pd=fd;const vd=function(e,t,s,n){if(!Ks(e))return e;for(var i=-1,r=(t=Vc(t,e)).length,o=r-1,a=e;null!=a&&++i{const n=e.parse?this.parse(s,e):s;if(!this.set(n,e))return!1;t&&t.call(e.context,this,s,e),this.trigger("sync",this,s,e)},Zc(this,e),this.sync("read",this,e)}save(e,t,s){let n;null==e||"object"==typeof e?(n=e,s=t):(n={})[e]=t;const i=(s=Object.assign({validate:!0,parse:!0},s)).wait,r=s.promise,o=r&&Yc();if(n&&!i){if(!this.set(n,s))return!1}else if(!this._validate(n,s))return!1;const a=s.success,c=s.error,l=this.attributes;s.success=e=>{this.attributes=l;let t=s.parse?this.parse(e,s):e;if(i&&(t=Object.assign({},n,t)),t&&!this.set(t,s))return!1;a&&a.call(s.context,this,e,s),this.trigger("sync",this,e,s),r&&o.resolve()},s.error=(e,t,s)=>{c&&c.call(s.context,e,t,s),r&&o.reject(t)},Zc(this,s),n&&i&&(this.attributes=Object.assign({},l,n));const d=this.isNew()?"create":s.patch?"patch":"update";"patch"!==d||s.attrs||(s.attrs=n);const u=this.sync(d,this,s);return this.attributes=l,r?o:u}destroy(e){const t=(e=e?ol(e):{}).success,s=e.wait,n=()=>{this.stopListening(),this.trigger("destroy",this,this.collection,e)};e.success=i=>{s&&n(),t&&t.call(e.context,this,i,e),this.isNew()||this.trigger("sync",this,i,e)};let i=!1;return this.isNew()?hl(e.success):(Zc(this,e),i=this.sync("delete",this,e)),s||n(),i}url(){const e=Jc(this,"urlRoot")||Jc(this.collection,"url")||Xc();if(this.isNew())return e;const t=this.get(this.idAttribute);return e.replace(/[^\/]$/,"$&/")+encodeURIComponent(t)}parse(e,t){return e}isNew(){return!this.has(this.idAttribute)}isValid(e){return this._validate({},Object.assign({},e,{validate:!0}))}_validate(e,t){if(!t.validate||!this.validate)return!0;e=Object.assign({},this.attributes,e);const s=this.validationError=this.validate(e,t)||null;return!s||(this.trigger("invalid",this,s,Object.assign(t,{validationError:s})),!1)}}const Sd=function(e,t,s,n){for(var i=-1,r=null==e?0:e.length;++it||r&&o&&c&&!a&&!l||n&&o&&c||!s&&c||!i)return 1;if(!n&&!r&&!l&&e=a?c:c*("desc"==s[n]?-1:1)}return e.index-t.index};const Pd=function(e,t,s){t=t.length?Pt(t,(function(e){return Ut(e)?function(t){return Jl(t,1===e.length?e[0]:e)}:e})):[nc];var n=-1;t=Pt(t,An(nd));var i=Rd(e,(function(e,s,i){var r=Pt(t,(function(t){return t(e)}));return{criteria:r,index:++n,value:e}}));return Dd(i,(function(e,t){return Ld(e,t,s)}))};var Ud=uc((function(e,t){if(null==e)return[];var s=t.length;return s>1&&hc(e,t[0],t[1])?t=[]:s>2&&hc(t[0],t[1],t[2])&&(t=[t[0]]),Pd(e,hd(t,1),[])}));const Fd=Ud,Bd=Array.prototype.slice,qd={add:!0,remove:!0,merge:!0},Hd={add:!0,remove:!1};class Gd extends(Ii(Object)){constructor(e,t){super(),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,Object.assign({silent:!0},t)),this[Symbol.iterator]=this.values}set browserStorage(e){this._browserStorage=e}get browserStorage(){return this._browserStorage}get model(){return this._model??wd}set model(e){this._model=e}get length(){return this.models.length}preinitialize(){}initialize(){}toJSON(e){return this.map((function(t){return t.toJSON(e)}))}sync(e,t,s){return tl(this)(e,t,s)}add(e,t){return this.set(e,Object.assign({merge:!1},t,Hd))}remove(e,t){t=Object.assign({},t);const s=!Array.isArray(e),n=s?[e]:e.slice(),i=this._removeModels(n,t);return!t.silent&&i.length&&(t.changes={added:[],merged:[],removed:i},this.trigger("update",this,t)),s?i[0]:i}set(e,t){if(null==e)return;(t=Object.assign({},qd,t)).parse&&!this._isModel(e)&&(e=this.parse(e,t)||[]);const s=!Array.isArray(e);e=s?[e]:e.slice();let n=t.at;null!=n&&(n=+n),n>this.length&&(n=this.length),n<0&&(n+=this.length+1);const i=[],r=[],o=[],a=[],c={},l=t.add,d=t.merge,u=t.remove;let h=!1;const m=this.comparator&&null==n&&!1!==t.sort,g=Eo(this.comparator)?this.comparator:null;let f,p;for(p=0;pe!==i[t])),this.models.length=0,this.models.splice(0,0,...i);else if(r.length){m&&(h=!0);let e=null==n?this.length:n;e=Math.min(Math.max(e,0),this.models.length),this.models.splice(e,0,...r)}if(h&&this.sort({silent:!0}),!t.silent){for(p=0;pe)){await Promise.all(this.models.filter(t).map((t=>new Promise((s=>{t.destroy(Object.assign(e,{success:s,error:(e,t)=>{console.error(t),s()}}))}))))),await this.browserStorage.clear(),this.reset()}reset(e,t){t=t?ol(t):{};for(let e=0;et.matches(e),t)}every(e){return Pn(e)?this.models.map((e=>e.attributes)).every(e):this.models.every((t=>t.matches(e)))}difference(e){return this.models.filter((t=>!e.includes(t)))}max(){return Math.max.apply(Math,this.models)}min(){return Math.min.apply(Math,this.models)}drop(e=1){return this.models.slice(e)}some(e){return Pn(e)?this.models.map((e=>e.attributes)).some(e):this.models.some((t=>t.matches(e)))}sortBy(e){return Fd(this.models,Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e))}isEmpty(){return!this.models.length}keyBy(e){return Md(this.models,e)}each(e,t){return this.forEach(e,t)}forEach(e,t){return this.models.forEach(e,t)}includes(e){return this.models.includes(e)}size(){return this.models.length}countBy(e){return kd(this.models,Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e))}groupBy(e){return Od(this.models,Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e))}indexOf(e){return this.models.indexOf(e)}findLastIndex(e,t){return this.models.findLastIndex(Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e),t)}lastIndexOf(e){return this.models.lastIndexOf(e)}findIndex(e){return this.models.findIndex(Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e))}last(){const e=null==this.models?0:this.models.length;return e?this.models[e-1]:void 0}head(){return this.models[0]}first(){return this.head()}map(e,t){return this.models.map(Pn(e)?e:t=>Eo(e)?t.get(e):t.matches(e),t)}reduce(e,t){return this.models.reduce(e,t||this.models[0])}reduceRight(e,t){return this.models.reduceRight(e,t||this.models[0])}toArray(){return Array.from(this.models)}get(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(e){return null!=this.get(e)}at(e){return e<0&&(e+=this.length),this.models[e]}where(e,t){return this[t?"find":"filter"](e)}findWhere(e){return this.where(e,!0)}find(e,t){const s=Pn(e)?e:t=>t.matches(e);return this.models.find(s,t)}sort(e){let t=this.comparator;if(!t)throw new Error("Cannot sort a set without a comparator");e||(e={});const s=t.length;return Pn(t)&&(t=t.bind(this)),1===s||Eo(t)?this.models=this.sortBy(t):this.models.sort(t),e.silent||this.trigger("sort",this,e),this}pluck(e){return this.map(e+"")}fetch(e){const t=(e=Object.assign({parse:!0},e)).success,s=this,n=e.promise&&Yc();return e.success=function(i){const r=e.reset?"reset":"set";s[r](i,e),t&&t.call(e.context,s,i,e),n&&n.resolve(),s.trigger("sync",s,i,e)},Zc(this,e),n||this.sync("read",this,e)}create(e,t){const s=(t=t?ol(t):{}).wait,n=t.promise,i=n&&Yc();if(!(e=this._prepareModel(e,t)))return!1;s||this.add(e,t);const r=this,o=t.success,a=t.error;return t.success=function(e,t,a){s&&r.add(e,a),o&&o.call(a.context,e,t,a),n&&i.resolve(e)},t.error=function(e,t,s){a&&a.call(s.context,e,t,s),n&&i.reject(t)},e.save(null,Object.assign(t,{promise:!1})),n?i:e}parse(e,t){return e}modelId(e){return e[this.model.prototype?.idAttribute||"id"]}values(){return new Jd(this,Wd)}keys(){return new Jd(this,Vd)}entries(){return new Jd(this,Qd)}_reset(){this.models=[],this._byId={}}createModel(e,t){return new(0,this.model)(e,t)}_prepareModel(e,t){if(this._isModel(e))return e.collection||(e.collection=this),e;(t=t?ol(t):{}).collection=this;const s=this.createModel(e,t);return s.validationError?(this.trigger("invalid",this,s.validationError,t),null):s}_removeModels(e,t){const s=[];for(let n=0;nfunction(e){eu(Zd,e);const t=Object.keys(e).filter((e=>e in Zd)),s=_d(iu,t),n=Object.assign(_d(e,t),s);eu(nu,n)}(e),update(e){return kt.warn("The api.settings.update method has been deprecated and will be removed. Please use api.settings.extend instead."),this.extend(e)},get:e=>e?function(e){if(Object.keys(Zd).includes(e))return nu[e]}(e):nu,set(e,t){!function(e,t){if(null==e)return this;let s;e instanceof Object?s=e:"string"==typeof e&&(s={},s[e]=t);const n=Object.keys(s).filter((e=>e in Zd)),i={};n.forEach((e=>{const t=s[e];ql(nu[e],t)||(i[e]=t,nu[e]=t)})),Object.keys(i).forEach((e=>nu.trigger("change:"+e,i[e]))),nu.trigger("change",i)}(e,t)},listen:{on(e,t,s){!function(e,t,s){nu.on(e,t,s)}(e,t,s)},not(e,t){!function(e,t){nu.off(e,t)}(e,t)}}},au=ou;function cu(){return["mobile","fullscreen","embedded"].includes(au.get("view_mode"))}function lu(){return"montague.lit/http-bind"===iu.bosh_service_url}function du(){return"onpagehide"in window?"pagehide":"onbeforeunload"in window?"beforeunload":"unload"}function uu(e,t){const s=e.promises[t];if(!s)throw new Error(`Tried to replace non-existing promise: ${t}`);if(s.replace){const n=vc();n.replace=s.replace,e.promises[t]=n}else kt.debug(`Not replacing promise "${t}"`)}function hu(e){const{api:t}=e;return!e.state.config.get("trusted")||t.settings.get("clear_cache_on_logout")||lu()}async function mu(e){const{api:t}=e;return await t.trigger("beforeTearDown",{synchronous:!0}),t.trigger("afterTearDown"),e}function gu(e){return hu(e)&&e.api.user.settings.clear(),e.initSession(),e.api.trigger("clearSession",{synchronous:!0})}const fu={chatboxes:null,bookmarks:null,ANONYMOUS:Ve,CLOSED:Qe,EXTERNAL:Je,LOGIN:Ke,LOGOUT:Ye,OPENED:Xe,PREBIND:Ze,SUCCESS:et,FAILURE:tt,INACTIVE:it,ACTIVE:rt,COMPOSING:ot,PAUSED:at,GONE:ct};class pu extends(Ii(Object)){constructor(){super();const e=new Proxy(this,{get:(e,t)=>(lu()||"string"!=typeof t||Object.keys(fu).includes(t)&&kt.warn(`Accessing ${t} on _converse is DEPRECATED`),Reflect.get(e,t))});return e.initialize(),e}initialize(){this.VERSION_NAME=Ge,this.strict_plugin_dependencies=!1,this.pluggable=null,this.templates={},this.storage={},this.promises={initialized:vc()},this.DEFAULT_IMAGE_TYPE=st,this.DEFAULT_IMAGE=nt,this.NUM_PREKEYS=100,this.TIMEOUTS={PAUSED:1e4,INACTIVE:9e4},Object.assign(this,fu),this.api=null,this.labels={},this.exports={},this.state={},this.initSession()}initSession(){this.session?.destroy(),this.session=new wd,Object.assign(this,{jid:void 0,bare_jid:void 0,domain:void 0,resource:void 0})}__(...e){return It.__(...e)}___(e){return e}}const vu=new pu;Mt.enable(vu,"_converse","pluggable");const yu=vu,bu={async trigger(e){if(!yu._events)return;const t=Array.from(arguments),s=t.pop();if(s&&s.synchronous){const s=yu._events[e]||[],n=t.splice(1);await Promise.all(s.map((e=>e.callback.apply(e.ctx,n))))}else yu.trigger.apply(yu,arguments);const n=yu.promises[e];void 0!==n&&n.resolve()},hook(e,t,s){const n=yu._events[e]||[];return n.length?n.reduce(((e,s)=>e.then((e=>s.callback(t,e)))),Promise.resolve(s)):s},listen:{once:yu.once.bind(yu),on:yu.on.bind(yu),not:yu.off.bind(yu),stanza(e,t,s){su(t)?(s=t,t={}):t=t||{},yu.api.connection.get().addHandler(s,t.ns,e,t.type,t.id,t.from,t)}}};var _u=Math.max,wu=Math.min;const Su=function(e,t,s){var n,i,r,o,a,c,l=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var s=n,r=i;return n=i=void 0,l=t,o=e.apply(r,s)}function g(e){var s=e-c;return void 0===c||s>=t||s<0||u&&e-l>=r}function f(){var e=pc();if(g(e))return p(e);a=setTimeout(f,function(e){var s=t-(e-c);return u?wu(s,r-(e-l)):s}(e))}function p(e){return a=void 0,h&&n?m(e):(n=i=void 0,o)}function v(){var e=pc(),s=g(e);if(n=arguments,i=this,c=e,s){if(void 0===a)return function(e){return l=e,a=setTimeout(f,t),d?m(e):o}(c);if(u)return clearTimeout(a),a=setTimeout(f,t),m(c)}return void 0===a&&(a=setTimeout(f,t)),o}return t=tn(t)||0,Ks(s)&&(d=!!s.leading,r=(u="maxWait"in s)?_u(tn(s.maxWait)||0,t):r,h="trailing"in s?!!s.trailing:h),v.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=i=a=void 0},v.flush=function(){return void 0===a?o:p(pc())},v};var xu=s(4360),Au=s.n(xu),Eu=s(4103),Cu=s(6245);const $u=ou;function ju(){if(yu.state.config.get("trusted")){return"sessionStorage"===$u.get("persistent_store")?"session":"persistent"}return"session"}function ku(e){return"persistent"===e&&"IndexedDB"===$u.get("persistent_store")}function Tu(e,t){const s=t||ju(),n=yu.storage[s];if(void 0===n)throw new TypeError(`createStore: Could not find store for ${e}`);return new rl(e,n,ku(t))}function Iu(e,t,s){const n=s||ju();if(e.browserStorage=Tu(t,n),ku(n)){const t=()=>e.browserStorage.flush(),s=du();window.addEventListener(s,t),e.on("destroy",(()=>window.removeEventListener(s,t))),e.listenTo(yu,"beforeLogout",t)}}function Ou(){return("WebSocket"in window||"MozWebSocket"in window)&&ou.get("websocket_url")?ou.get("websocket_url"):ou.get("bosh_service_url")?ou.get("bosh_service_url"):""}function Nu(e){return"string"==typeof e&&(2===e.split("@").filter((e=>!!e)).length&&!e.startsWith("@")&&!e.endsWith("@"))}function Mu(e){return!e.startsWith("@")&&!e.endsWith("@")}function Ru(e,t){return"string"==typeof e&&"string"==typeof t&&qe.getBareJidFromJid(e).toLowerCase()===qe.getBareJidFromJid(t).toLowerCase()}function Du(e,t){return"string"==typeof e&&"string"==typeof t&&qe.getDomainFromJid(e).toLowerCase()===qe.getDomainFromJid(t).toLowerCase()}function zu(e){return e.startsWith("xmpp:")&&e.endsWith("?join")?e.replace(/^xmpp:/,"").replace(/\?join$/,""):e}function Lu(e,t){const{api:s}=e;s.settings.get("authentication")===Ve||qe.getResourceFromJid(t)||(t=t.toLowerCase()+`/converse.js-${Math.floor(139749528*Math.random()).toString()}`);const n=qe.getBareJidFromJid(t),i=qe.getResourceFromJid(t),r=qe.getDomainFromJid(t);Object.assign(e,{jid:t,bare_jid:n,resource:i,domain:r}),e.session.save({jid:t,bare_jid:n,resource:i,domain:r,active:!0}),s.connection.get().jid=t}async function Pu(e){return await async function(e,t){const s=e.api.settings.get("connection_options").worker,n=qe.getBareJidFromJid(t).toLowerCase(),i=`converse.session-${n}`;e.session?.get("id")!==i?(!function(e,t){if("sessionStorage"===e.api.settings.get("persistent_store"))return;if("BrowserExtLocal"===e.api.settings.get("persistent_store"))return rl.localForage.defineDriver(Eu.A).then((()=>rl.localForage.setDriver("webExtensionLocalStorage"))),void(e.storage.persistent=rl.localForage);if("BrowserExtSync"===e.api.settings.get("persistent_store"))return rl.localForage.defineDriver(Cu.A).then((()=>rl.localForage.setDriver("webExtensionSyncStorage"))),void(e.storage.persistent=rl.localForage);const s={name:lu()?"converse-test-persistent":"converse-persistent",storeName:t};"localStorage"===e.api.settings.get("persistent_store")?(s.description="localStorage instance",s.driver=[rl.localForage.LOCALSTORAGE]):"IndexedDB"===e.api.settings.get("persistent_store")&&(s.description="indexedDB instance",s.driver=[rl.localForage.INDEXEDDB]),e.storage.persistent=rl.localForage.createInstance(s)}(e,n),e.session.set({id:i}),Iu(e.session,i,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:i})),Lu(e,t),window.addEventListener(du(),(()=>e.session?.save("active",!1))),e.api.trigger("userSessionInitialized")):Lu(e,t)}(yu,e),yu.api.trigger("setUserJID"),e}function Uu(e=0){return new Promise(Su((async(e,t)=>{let s=new XMLHttpRequest;s.open("GET",yu.api.settings.get("credentials_url"),!0),s.setRequestHeader("Accept","application/json, text/javascript"),s.onload=()=>{if(s.status>=200&&s.status<400){const t=JSON.parse(s.responseText);Pu(t.jid).then((()=>{e({jid:t.jid,password:t.password})}))}else t(new Error(`${s.status}: ${s.responseText}`))},s.onerror=t,s=await yu.api.hook("beforeFetchLoginCredentials",this,s),s.send()}),e))}async function Fu(e,t){const{api:s}=yu;if(s.settings.get("authentication")===Ke){const t=yu.session.get("jid");if(e)return qu(e);if(s.settings.get("credentials_url"))return qu(await async function(){let e,t=0;for(;!e;){try{e=await Uu(t)}catch(e){kt.error("Could not fetch login credentials"),kt.error(e)}t=2e3}return e}());if(t&&(s.settings.get("password")||s.connection.get().pass))return qu();if(s.settings.get("reuse_scram_keys")){const e=await async function(){const e=localStorage.getItem("conversejs-session-jid");if(!e)return null;await Pu(e);const t=(await Bu(e)).get("scram_keys");return t?{jid:e,password:t}:null}();if(e)return qu(e)}if(!lu()&&"credentials"in navigator){const e=await async function(){if(!localStorage.getItem("conversejs-session-jid"))return null;try{const e=await navigator.credentials.get({password:!0});if(e&&"password"==e.type&&Nu(e.id))return await Pu(e.id),{jid:e.id,password:e.password}}catch(e){return kt.error(e),null}}();if(e)return qu(e)}lu()||kt.warn("attemptNonPreboundSession: Couldn't find credentials to log in with")}else![Ve,Je].includes(s.settings.get("authentication"))||t&&!s.settings.get("auto_login")||qu()}async function Bu(e){const t=`converse.scram-keys-${qe.getBareJidFromJid(e)}`,s=new wd({id:t});return Iu(s,t,"persistent"),await new Promise((e=>s.fetch({success:e,error:e}))),s}async function qu(e){const{api:t}=yu,s=yu.session.get("jid"),n=t.connection.get();if([Ve,Je].includes(t.settings.get("authentication"))){if(!s)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.");n.reconnecting||n.reset(),n.connect(s.toLowerCase())}else if(t.settings.get("authentication")===Ke){const i=e?.password??(n?.pass||t.settings.get("password"));if(!i){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 n.setDisconnectionCause(qe.Status.AUTHFAIL,void 0,!0),void t.connection.disconnect()}let r;if(n.reconnecting||(n.reset(),n.service=Ou()),yu.state.config.get("trusted")&&s&&t.settings.get("reuse_scram_keys")&&!i?.ck){const e=await Bu(s);r=t=>{const{scram_keys:s}=n;s&&e.save({scram_keys:s}),n.onConnectStatusChanged(t)}}n.connect(s,i,r)}}const Hu=Object.keys(qe.Status).reduce(((e,t)=>Math.max(e,qe.Status[t])),0);qe.Status.RECONNECTING=Hu+1;class Gu extends qe.Connection{constructor(e,t){super(e,t),this.send_initial_presence=!0,this.debouncedReconnect=Su(this.reconnect,3e3)}xmlInput(e){kt.debug(e.outerHTML,"color: darkgoldenrod")}xmlOutput(e){kt.debug(e.outerHTML,"color: darkcyan")}async bind(){const{api:e}=yu;await e.trigger("beforeResourceBinding",{synchronous:!0}),super.bind()}async onDomainDiscovered(e){const{api:t}=yu,s=await e.text(),n=(new DOMParser).parseFromString(s,"text/xml").firstElementChild;if("XRD"!=n.nodeName||"http://docs.oasis-open.org/ns/xri/xrd-1.0"!=n.namespaceURI)return kt.warn("Could not discover XEP-0156 connection methods");const i=Au()('Link[rel="urn:xmpp:alt-connections:xbosh"]',n),r=Au()('Link[rel="urn:xmpp:alt-connections:websocket"]',n),o=i.map((e=>e.getAttribute("href"))),a=r.map((e=>e.getAttribute("href")));0===o.length&&0===a.length?kt.warn("Neither BOSH nor WebSocket connection methods have been specified with XEP-0156."):(t.settings.set("websocket_url",a.pop()),t.settings.set("bosh_service_url",o.pop()),this.service=t.settings.get("websocket_url")||t.settings.get("bosh_service_url"),this.setProtocol())}async discoverConnectionMethods(e){const t={mode:"cors",headers:{Accept:"application/xrd+xml, text/xml"}},s=`https://${e}/.well-known/host-meta`;let n;try{n=await fetch(s,t)}catch(e){return kt.error(`Failed to discover alternative connection methods at ${s}`),void kt.error(e)}n.status>=200&&n.status<400?await this.onDomainDiscovered(n):kt.warn("Could not discover XEP-0156 connection methods")}async connect(e,t,s){const{api:n}=yu;if(n.settings.get("discover_connection_methods")){const t=qe.getDomainFromJid(e);await this.discoverConnectionMethods(t)}if(!n.settings.get("bosh_service_url")&&!n.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,s||this.onConnectStatusChanged,He)}disconnect(e){super.disconnect(e),this.send_initial_presence=!0}async switchTransport(){const{api:e}=yu,t=yu.session.get("bare_jid");e.connection.isType("websocket")&&e.settings.get("bosh_service_url")?(await Pu(t),this._proto._doDisconnect(),this._proto=new qe.Bosh(this),this.service=e.settings.get("bosh_service_url")):e.connection.isType("bosh")&&e.settings.get("websocket_url")&&(e.settings.get("authentication")===Ve?await Pu(e.settings.get("jid")):await Pu(t),this._proto._doDisconnect(),this._proto=new qe.Websocket(this),this.service=e.settings.get("websocket_url"))}async reconnect(){const{api:e}=yu;kt.debug("RECONNECTING: the connection has dropped, attempting to reconnect."),this.reconnecting=!0,await mu(yu);const t=yu.state.connfeedback.get("connection_status");t===qe.Status.CONNFAIL?this.switchTransport():t===qe.Status.AUTHFAIL&&e.settings.get("authentication")===Ve&&await Pu(e.settings.get("jid")),e.trigger("will-reconnect"),e.settings.get("authentication")===Ve&&await gu(yu);const s=yu.session.get("jid");return e.user.login(s)}async onConnected(e){const{api:t}=yu;if(delete this.reconnecting,this.flush(),await Pu(this.jid),yu.state.config.get("trusted")){const e=yu.session.get("bare_jid");localStorage.setItem("conversejs-session-jid",e)}await t.trigger("afterResourceBinding",e,{synchronous:!0}),e?t.trigger("reconnected"):t.trigger("connected")}setDisconnectionCause(e,t,s){void 0===e?(delete this.disconnection_cause,delete this.disconnection_reason):(void 0===this.disconnection_cause||s)&&(this.disconnection_cause=e,this.disconnection_reason=t)}setConnectionStatus(e,t){this.status=e,yu.state.connfeedback.set({connection_status:e,message:t})}async finishDisconnection(){const{api:e}=yu;kt.debug("DISCONNECTED"),delete this.reconnecting,this.reset(),mu(yu),await gu(yu),e.connection.destroy(),e.trigger("disconnected")}onDisconnected(){const{api:e}=yu;if(!e.settings.get("auto_reconnect"))return this.finishDisconnection();{const t=this.disconnection_reason;if(this.disconnection_cause===qe.Status.AUTHFAIL)return e.settings.get("credentials_url")||e.settings.get("authentication")===Ve?e.connection.reconnect():this.finishDisconnection();if(this.status===qe.Status.CONNECTING){const{__:e}=yu;return this.setConnectionStatus(qe.Status.CONNFAIL,e("An error occurred while connecting to the chat server.")),this.finishDisconnection()}if(this.disconnection_cause===Ye||t===qe.ErrorCondition.NO_AUTH_MECH||"host-unknown"===t||"remote-connection-failed"===t)return this.finishDisconnection();e.connection.reconnect()}}onConnectStatusChanged(e,t){const{__:s}=yu;if(kt.debug(`Status changed to: ${mt[e]}`),e===qe.Status.ATTACHFAIL)this.setConnectionStatus(e),this.worker_attach_promise?.resolve(!1);else if(e===qe.Status.CONNECTED||e===qe.Status.ATTACHED){if(this.worker_attach_promise?.isResolved&&this.status===qe.Status.ATTACHED)return;this.setConnectionStatus(e),this.worker_attach_promise?.resolve(!0),this.setDisconnectionCause(),this.reconnecting?(kt.debug(e===qe.Status.CONNECTED?"Reconnected":"Reattached"),this.onConnected(!0)):(kt.debug(e===qe.Status.CONNECTED?"Connected":"Attached"),this.restored&&(this.send_initial_presence=!1),this.onConnected())}else if(e===qe.Status.DISCONNECTED)this.setDisconnectionCause(e,t),this.onDisconnected();else if(e===qe.Status.BINDREQUIRED)this.bind();else if(e===qe.Status.ERROR)this.setConnectionStatus(e,s("An error occurred while connecting to the chat server."));else if(e===qe.Status.CONNECTING)this.setConnectionStatus(e);else if(e===qe.Status.AUTHENTICATING)this.setConnectionStatus(e);else if(e===qe.Status.AUTHFAIL)t||(t=s("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===qe.Status.CONNFAIL){let n=t;"host-unknown"===t||"remote-connection-failed"==t?n=s("Sorry, we could not connect to the XMPP host with domain: %1$s",`"${qe.getDomainFromJid(this.jid)}"`):void 0!==t&&t===qe?.ErrorCondition?.NO_AUTH_MECH&&(n=s("The XMPP server did not offer a supported authentication mechanism")),this.setConnectionStatus(e,n),this.setDisconnectionCause(e,t)}else e===qe.Status.DISCONNECTING&&this.setDisconnectionCause(e,t)}isType(e){return"websocket"===e.toLowerCase()?this._proto instanceof qe.Websocket:"bosh"===e.toLowerCase()?qe.Bosh&&this._proto instanceof qe.Bosh:void 0}hasResumed(){const{api:e}=yu;return e.settings.get("connection_options")?.worker||this.isType("bosh")?yu.state.connfeedback.get("connection_status")===qe.Status.ATTACHED:!this.do_bind}restoreWorkerSession(){return this.attach(this.onConnectStatusChanged),this.worker_attach_promise=vc(),this.worker_attach_promise}}class Wu extends Gu{constructor(e,t){super(e,t),this.sent_stanzas=[],this.IQ_stanzas=[],this.IQ_ids=[],this.features=qe.xmlHtmlNode('').firstElementChild,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(qe.Status.BINDREQUIRED)}}_processRequest(){}sendIQ(e,t,s){e=e.tree?.()??e,this.IQ_stanzas.push(e);const n=super.sendIQ(e,t,s);return this.IQ_ids.push(n),n}send(e){return e=e.tree?.()??e,this.sent_stanzas.push(e),super.send(e)}async bind(){const{api:e}=yu;await e.trigger("beforeResourceBinding",{synchronous:!0}),this.authenticated=!0,this._changeConnectStatus(qe.Status.CONNECTED)}}let Vu;const Qu={explicitResourceBinding:!0},Ju={init(e){if(e&&Vu?.jid&&Du(Vu.jid,e))return Vu;if(!ou.get("bosh_service_url")&&ou.get("authentication")===Ze)throw new Error("authentication is set to 'prebind' but we don't have a BOSH connection");const t=lu()?Wu:Gu;return Vu=new t(Ou(),Object.assign(Qu,ou.get("connection_options"),{keepalive:ou.get("keepalive")})),function(){const e=ou.get("loglevel");qe.setLogLevel(qe.LogLevel[e.toUpperCase()]);const t={};t[qe.LogLevel.DEBUG]="debug",t[qe.LogLevel.INFO]="info",t[qe.LogLevel.WARN]="warn",t[qe.LogLevel.ERROR]="error",t[qe.LogLevel.FATAL]="fatal",qe.log=(e,s)=>kt.log(s,t[e]),qe.error=e=>kt.error(e)}(),bu.trigger("connectionInitialized"),Vu},get:()=>Vu,destroy(){this.disconnect(),Vu?.disconnect(),Vu=void 0},authenticated:()=>Vu?.authenticated&&!0,connected:()=>Vu?.connected&&!0,disconnect(){Vu?.disconnect()},reconnect:()=>(Vu.setConnectionStatus(qe.Status.RECONNECTING,"The connection has dropped, attempting to reconnect."),Vu?.reconnecting?Vu.debouncedReconnect():Vu.reconnect()),isType:e=>Vu.isType(e)};function Ku(e,t){clearTimeout(e),clearInterval(t)}function Yu(e,t=300,s=3){try{const t=e();if(t)return Promise.resolve(t)}catch(e){return Promise.reject(e)}const n=vc(),i=new Error;const r=setInterval((function(){try{const t=e();t&&(Ku(o,r),n.resolve(t))}catch(e){Ku(o,r),n.reject(e)}}),s);const o=setTimeout((function(){Ku(o,r);const e=`Wait until promise timed out: \n\n${i.stack}`;console.trace(),kt.error(e),n.reject(new Error(e))}),t);return n}const Xu={promises:{add(e,t=!0){(e=Array.isArray(e)?e:[e]).forEach((e=>{const s=vc();s.replace=t,yu.promises[e]=s}))}},waitUntil(e){if(su(e))return Yu(e);{const t=yu.promises[e];return void 0===t?null:t}}};class Zu extends Error{constructor(e){super(e),this.retry_event_id=null}}const eh={send(e){const{api:t}=yu;return t.connection.connected()?("string"==typeof e?e=Fe(e):e?.tree&&(e=e.tree()),"iq"===e.tagName?t.sendIQ(e):(t.connection.get().send(e),void t.trigger("send",e))):(kt.warn("Not sending stanza because we're not connected!"),void kt.warn(qe.serialize(e)))},sendIQ(e,t,s=!0){const{api:n}=yu;if(!n.connection.connected())throw new Error("Not sending IQ stanza because we're not connected!");const i=n.connection.get();let r;return e=e.tree?.()??e,["get","set"].includes(e.getAttribute("type"))?(t=t||n.settings.get("stanza_timeout"),s?(r=new Promise(((s,n)=>i.sendIQ(e,s,n,t))),r.catch((s=>{if(null===s)throw new Zu(`Timeout error after ${t}ms for the following IQ stanza: ${qe.serialize(e)}`)}))):r=new Promise((s=>i.sendIQ(e,s,s,t)))):(i.sendIQ(e),r=Promise.resolve()),n.trigger("send",e),r}};async function th(e,t,s){let n;e=qe.getBareJidFromJid(e.toLowerCase()),Object.assign(t,{jid:e,id:e});try{n=new s(t,{collection:yu.state.chatboxes})}catch(e){return kt.error(e),null}return await n.initialized,n.isValid()?(yu.state.chatboxes.add(n),n):(n.destroy(),null)}const{waitUntil:sh}=Xu,nh={},ih={create:async(e=[],t={},s)=>(await sh("chatBoxesFetched"),"string"==typeof e?th(e,t,s):Promise.all(e.map((e=>th(e,t,s))))),async get(e){await sh("chatBoxesFetched");const{chatboxes:t}=yu.state;return void 0===e?t.models:"string"==typeof e?t.get(e.toLowerCase()):(e=e.map((e=>e.toLowerCase())),t.models.filter((t=>e.includes(t.get("jid")))))},registry:{add(e,t){nh[e]=t},get:e=>nh[e]}},{waitUntil:rh}=Xu,oh={create(e,t={}){if(!(t="string"==typeof t?{nick:t}:t||{}).nick&&ou.get("muc_nickname_from_jid")){const e=yu.session.get("bare_jid");t.nick=qe.getNodeFromJid(e)}if(void 0===e)throw new TypeError("rooms.create: You need to provide at least one JID");return"string"==typeof e?oh.get(zu(e),t,!0):Promise.all(e.map((e=>oh.get(zu(e),t,!0))))},async open(e,t={},s=!1){if(await rh("chatBoxesFetched"),void 0===e){const e="rooms.open: You need to provide at least one JID";throw kt.error(e),new TypeError(e)}if("string"==typeof e){const n=await oh.get(e,t,!0);return!t.hidden&&n?.maybeShow(s),n}{const n=await Promise.all(e.map((e=>n.get(e,t,!0))));return n.forEach((e=>!t.hidden&&e.maybeShow(s))),n}},async get(e,t={},s=!1){async function n(e){e=zu(e);let n=await ih.get(e);return!n&&s?n=await ih.create(e,t,yu.exports.MUC):(n=n&&n.get("type")===dt?n:null,n&&Object.keys(t).length&&n.save(t)),n}if(await rh("chatBoxesFetched"),void 0===e){return(await ih.get()).filter((e=>e.get("type")===dt))}return"string"==typeof e?n(e):Promise.all(e.map((e=>n(e))))}},ah={rooms:oh},{waitUntil:ch}=Xu,{send:lh}=eh,{rooms:dh}=ah,uh={presence:{async send(e,t,s,n){await ch("statusInitialized");let i=[];n&&(i=Array.isArray(n)?n:[n]);const r=yu.state.xmppstatus,o=await r.constructPresence(e,t,s);if(i.map((e=>e?.tree()??e)).forEach((e=>o.cnode(e).up())),lh(o),["away","chat","dnd","online","xa",void 0].includes(e)){(await dh.get()).forEach((t=>t.sendStatusPresence(e,s,i)))}}}};let hh;function mh(){const e=yu.session.get("bare_jid");if(!e){const e="No JID to fetch user settings for";throw kt.error(e),Error(e)}const t=`converse.user-settings.${e}`;if(hh?.get("id")!==t)return hh=new wd({id:t}),Iu(hh,t),hh.fetch({promise:!0})}async function gh(){return await mh(),hh}async function fh(e,t){return await mh(),hh.save(e,t)}const ph={getModel:()=>gh(),async get(e,t){const s=await gh();return void 0===s.get(e)?t:s.get(e)},set(e,t){if(e instanceof Object)return fh(e,{promise:!0});{const s={};return s[e]=t,fh(s,{promise:!0})}},clear:()=>async function(){if(yu.session.get("bare_jid"))return await mh(),hh.clear();hh=void 0}()},vh={user:{settings:ph,...uh,jid:()=>Ju.get()?.jid,async login(e,t,s=!1){const{api:n}=yu;e=e||n.settings.get("jid");const i=Ju.init(e);if(n.settings.get("connection_options")?.worker&&await i.restoreWorkerSession())return;e&&(e=await Pu(e));const{success:r}=await yu.api.hook("login",this,{jid:e,password:t,automatic:s});if(r)return;t=t||n.settings.get("password");const o=e&&t?{jid:e,password:t}:null;await Fu(o,s)},async logout(){const{api:e}=yu;await e.trigger("beforeLogout",{synchronous:!0});const t=vc(),s=()=>{Object.keys(yu.promises).forEach((e=>uu(yu,e))),localStorage.removeItem("conversejs-session-jid"),e.trigger("logout"),t.resolve()},n=Ju.get();return n?(n.setDisconnectionCause(Ye,void 0,!0),e.listen.once("disconnected",(()=>s())),n.disconnect()):s(),t}}},yh=vh,bh={connection:Ju,settings:ou,...eh,...yh,...bu,...Xu,disco:null,elements:null,contacts:null};function _h(e){return!!_t(e)&&"error"===e.getAttribute("type")}function wh(e){return!!_t(e)&&Au()(`error[type="auth"] forbidden[xmlns="${qe.NS.STANZAS}"]`,e).length>0}function Sh(e){return!!_t(e)&&Au()(`error[type="cancel"] service-unavailable[xmlns="${qe.NS.STANZAS}"]`,e).length>0}function xh(e){return e.getAttributeNames().reduce(((t,s)=>(t[s]=qe.xmlunescape(e.getAttribute(s)),t)),{})}const Ah=(e,t)=>`${t}`,Eh=e=>`${e}`;function Ch(e){const t=[],s=e?.options;for(let e=0,n=s.length;ee.trim())):"SELECT"==e.tagName?Ch(e):e.value,Fe(Ah(t,Array.isArray(s)?s.map(Eh):Eh(s)))}function jh(e,t,s){t||(t=e.selectionEnd||void 0);let[n]=e.value.slice(0,t).split(/\s/).slice(-1);return s&&([n]=n.split(s).slice(-1)),n}function kh(e){return"@"!==e&&RegExp("(\\p{Z}|\\p{P})","u").test(e)}function Th(e,t){const s=e.selectionEnd||void 0,n=e.value.slice(0,s).split(/\s/).pop(),i=e.value,r=kh(n[0])?n[0]:"";e.value=i.slice(0,s-n.length)+r+`${t} `+i.slice(s);const o=s-n.length+t.length+1;e.selectionEnd=r?o+1:o}function Ih(e){e!==document.activeElement&&e.focus();const t=2*e.value.length;setTimeout((()=>e.setSelectionRange(t,t)),1),e.scrollTop=999999}function Oh(e,t){const s=new Uint8Array(e.byteLength+t.byteLength);return s.set(new Uint8Array(e),0),s.set(new Uint8Array(t),e.byteLength),s.buffer}function Nh(e){return Array.prototype.map.call(new Uint8Array(e),(e=>("00"+e.toString(16)).slice(-2))).join("")}function Mh(e){return new TextDecoder("utf-8").decode(e)}function Rh(e){return(new TextEncoder).encode(e).buffer}function Dh(e){return btoa(new Uint8Array(e).reduce(((e,t)=>e+String.fromCharCode(t)),""))}function zh(e){const t=atob(e),s=t.length,n=new Uint8Array(s);for(let e=0;eparseInt(e,16))));return t.buffer}var Ph=s(9542),Uh=s.n(Ph);const Fh=ou;function Bh(e){try{return!!new URL(e)}catch(e){return kt.error(e),!1}}function qh(e){try{return e instanceof Uh()?e:new(Uh())(e)}catch(e){return kt.debug(e),null}}function Hh(e,t){const s=qh(t);if(null===s)throw new Error(`checkFileTypes: could not parse url ${t}`);const n=s.filename().toLowerCase();return!!e.filter((e=>n.endsWith(e))).length}function Gh(e){const t=Fh.get("filter_url_query_params");if(!t)return e;return qh(e).removeQuery(t).toString()}function Wh(e){return Hh([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".svg"],e)}function Vh(e){return Hh([".gif"],e)}function Qh(e){return Hh([".ogg",".mp3",".m4a"],e)}function Jh(e){return Hh([".mp4",".webm"],e)}function Kh(e){const t=Fh.get("image_urls_regex");return t?.test(e)||Wh(e)}function Yh(e){return e.startsWith("aesgcm://")}function Xh(e,t=0){const s=[];if(!e)return{};try{Uh().withinString(e,((e,n,i)=>(e.startsWith("_")&&(e=e.slice(1),n+=1),e.endsWith("_")&&(e=e.slice(0,e.length-1),i-=1),s.push({url:e,start:n+t,end:i+t}),e)),ft)}catch(e){kt.debug(e)}const n=s.map((e=>({end:e.end,is_audio:Qh(e.url),is_image:Kh(e.url),is_video:Jh(e.url),is_encrypted:Yh(e.url),start:e.start})));return n.length?{media_urls:n}:{}}function Zh(e,t,s=0){return e.map((e=>{const n=e.start-s,i=e.end-s;return n<0||n>=t.length?null:Object.assign({},e,{start:n,end:i,url:t.substring(e.start-s,e.end-s)})})).filter((e=>e))}function em(e){if(location.hash.startsWith("#converse?loglevel=")){e?.preventDefault();const t=location.hash.split("=").pop();Object.keys($t).includes(t)?kt.setLogLevel(t):kt.error(`Could not set loglevel of ${t}`)}}function tm(e){return e instanceof wd&&(e=e.attributes),!(e.oob_url||e.file||e.is_encrypted&&e.plaintext||e.message||e.body)}function sm(e){return e instanceof Error}function nm(e,t,s){!function(e){return e.collection&&e.collection.browserStorage}(e)?e.set(t,s):e.save(t,s)}function im(e){return Math.random()*e|0}function rm(e){const t=crypto.randomUUID?.()??"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=im(16);return("x"===e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t}const om=Object.assign({...m,...h,...o,...d,...a,...c,...u,...l,...g,getLongestSubstring:function(e,t){return t.reduce((function(t,s){return e.startsWith(s)&&s.length>t.length?s:t}),"")},getOpenPromise:vc,getRandomInt:im,getUniqueId:rm,isEmptyMessage:tm,isErrorObject:sm,onMultipleEvents:function(e=[],t){let s=[];function n(n){s.push(n),e.length===s.length&&(t(s),s=[])}e.forEach((e=>e.object.on(e.event,n)))},prefixMentions:function(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},safeSave:nm,shouldCreateMessage:function(e){return e.retracted||!tm(e)},toStanza:Fe,triggerEvent:function(e,t,s="Event",n=!0,i=!0){const r=document.createEvent(s);r.initEvent(t,n,i),e.dispatchEvent(r)},waitUntil:Yu},{muc:null,mam:null});const am=class extends wd{defaults(){return{connection_status:qe.Status.DISCONNECTED,message:""}}initialize(){super.initialize();const{api:e}=yu;this.on("change",(()=>e.trigger("connfeedback",yu.state.connfeedback)))}},cm="array",lm="bit",dm="bits",um="byte",hm="bytes",mm="",gm="exponent",fm="function",pm="iec",vm="Invalid number",ym="Invalid rounding method",bm="jedec",_m="object",wm=".",Sm="round",xm="s",Am="si",Em="kbit",Cm="kB",$m=" ",jm="string",km="0",Tm={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Im(e,{bits:t=!1,pad:s=!1,base:n=-1,round:i=2,locale:r=mm,localeOptions:o={},separator:a=mm,spacer:c=$m,symbols:l={},standard:d=mm,output:u=jm,fullform:h=!1,fullforms:m=[],exponent:g=-1,roundingMethod:f=Sm,precision:p=0}={}){let v=g,y=Number(e),b=[],_=0,w=mm;d===Am?(n=10,d=bm):d===pm||d===bm?n=2:2===n?d=pm:(n=10,d=bm);const S=10===n?1e3:1024,x=!0===h,A=y<0,E=Math[f];if("bigint"!=typeof e&&isNaN(e))throw new TypeError(vm);if(typeof E!==fm)throw new TypeError(ym);if(A&&(y=-y),(-1===v||isNaN(v))&&(v=Math.floor(Math.log(y)/Math.log(S)),v<0&&(v=0)),v>8&&(p>0&&(p+=8-v),v=8),u===gm)return v;if(0===y)b[0]=0,w=b[1]=Tm.symbol[d][t?dm:hm][v];else{_=y/(2===n?Math.pow(2,10*v):Math.pow(1e3,v)),t&&(_*=8,_>=S&&v<8&&(_/=S,v++));const e=Math.pow(10,v>0?i:0);b[0]=E(_*e)/e,b[0]===S&&v<8&&-1===g&&(b[0]=1,v++),w=b[1]=10===n&&1===v?t?Em:Cm:Tm.symbol[d][t?dm:hm][v]}if(A&&(b[0]=-b[0]),p>0&&(b[0]=b[0].toPrecision(p)),b[1]=l[b[1]]||b[1],!0===r?b[0]=b[0].toLocaleString():r.length>0?b[0]=b[0].toLocaleString(r,o):a.length>0&&(b[0]=b[0].toString().replace(wm,a)),s&&!1===Number.isInteger(b[0])&&i>0){const e=a||wm,t=b[0].toString().split(e),s=t[1]||mm,n=s.length,r=i-n;b[0]=`${t[0]}${e}${s.padEnd(n+r,km)}`}return x&&(b[1]=m[v]?m[v]:Tm.fullform[d][v]+(t?lm:um)+(1===b[0]?mm:xm)),u===cm?b:u===_m?{value:b[0],symbol:b[1],exponent:v,unit:w}:b.join(c)}const Om=window,Nm=Om.ShadowRoot&&(void 0===Om.ShadyCSS||Om.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Mm=Symbol(),Rm=new WeakMap;class Dm{constructor(e,t,s){if(this._$cssResult$=!0,s!==Mm)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Nm&&void 0===e){const s=void 0!==t&&1===t.length;s&&(e=Rm.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&Rm.set(t,e))}return e}toString(){return this.cssText}}const zm=Nm?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return(e=>new Dm("string"==typeof e?e:e+"",void 0,Mm))(t)})(e):e;var Lm;const Pm=window,Um=Pm.trustedTypes,Fm=Um?Um.emptyScript:"",Bm=Pm.reactiveElementPolyfillSupport,qm={toAttribute(e,t){switch(t){case Boolean:e=e?Fm:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=null!==e;break;case Number:s=null===e?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch(e){s=null}}return s}},Hm=(e,t)=>t!==e&&(t==t||e==e),Gm={attribute:!0,type:String,converter:qm,reflect:!1,hasChanged:Hm},Wm="finalized";class Vm extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,s)=>{const n=this._$Ep(s,t);void 0!==n&&(this._$Ev.set(n,s),e.push(n))})),e}static createProperty(e,t=Gm){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const s="symbol"==typeof e?Symbol():"__"+e,n=this.getPropertyDescriptor(e,s,t);void 0!==n&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,s){return{get(){return this[t]},set(n){const i=this[e];this[t]=n,this.requestUpdate(e,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Gm}static finalize(){if(this.hasOwnProperty(Wm))return!1;this[Wm]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of t)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const e of s)t.unshift(zm(e))}else void 0!==e&&t.push(zm(e));return t}static _$Ep(e,t){const s=t.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,s;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(s=e.hostConnected)||void 0===s||s.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.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)=>{Nm?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const s=document.createElement("style"),n=Om.litNonce;void 0!==n&&s.setAttribute("nonce",n),s.textContent=t.cssText,e.appendChild(s)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||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._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$EO(e,t,s=Gm){var n;const i=this.constructor._$Ep(e,s);if(void 0!==i&&!0===s.reflect){const r=(void 0!==(null===(n=s.converter)||void 0===n?void 0:n.toAttribute)?s.converter:qm).toAttribute(t,s.type);this._$El=e,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$El=null}}_$AK(e,t){var s;const n=this.constructor,i=n._$Ev.get(e);if(void 0!==i&&this._$El!==i){const e=n.getPropertyOptions(i),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(s=e.converter)||void 0===s?void 0:s.fromAttribute)?e.converter:qm;this._$El=i,this[i]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,s){let n=!0;void 0!==e&&(((s=s||this.constructor.getPropertyOptions(e)).hasChanged||Hm)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===s.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,s))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}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._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(s)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(s)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||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)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}var Qm,Jm;Vm[Wm]=!0,Vm.elementProperties=new Map,Vm.elementStyles=[],Vm.shadowRootOptions={mode:"open"},null==Bm||Bm({ReactiveElement:Vm}),(null!==(Lm=Pm.reactiveElementVersions)&&void 0!==Lm?Lm:Pm.reactiveElementVersions=[]).push("1.6.3");class Km extends Vm{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const s=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=s.firstChild),s}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Gs(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return $s}}Km.finalized=!0,Km._$litElement$=!0,null===(Qm=globalThis.litElementHydrateSupport)||void 0===Qm||Qm.call(globalThis,{LitElement:Km});const Ym=globalThis.litElementPolyfillSupport;null==Ym||Ym({LitElement:Km});(null!==(Jm=globalThis.litElementVersions)&&void 0!==Jm?Jm:globalThis.litElementVersions=[]).push("3.3.3"),yu.api=bh;const Xm=Object.assign(window.converse||{},{CHAT_STATES:pt,keycodes:vt,async initialize(e){const{api:t}=yu;if(await async function(e){const{api:t}=e;await t.trigger("cleanup",{synchronous:!0}),function(e){e.api.trigger("unregisteredGlobalEventHandlers")}(e),t.connection.get()?.reset(),e.stopListening(),e.off(),e.promises.initialized.isResolved&&t.promises.add("initialized")}(yu),function(e){iu=e,nu=new ru;const t=_d(e,Object.keys(Zd));Object.assign(nu,Zd,t)}(e),yu.strict_plugin_dependencies=e.strict_plugin_dependencies,kt.setLogLevel(t.settings.get("loglevel")),t.settings.get("authentication")===Ve&&t.settings.get("auto_login")&&!t.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.");em(),addEventListener("hashchange",em);const s=new am;Object.assign(yu,{connfeedback:s}),Object.assign(yu.state,{connfeedback:s}),await async function(e){await rl.sessionStorageInitialized,e.storage.session=rl.localForage.createInstance({name:lu()?"converse-test-session":"converse-session",description:"sessionStorage instance",driver:["sessionStorageWrapper"]})}(yu),await async function(e){const t="converse.client-config",s=new wd({id:t,trusted:!0});s.browserStorage=Tu(t,"session"),Object.assign(e,{config:s}),Object.assign(e.state,{config:s}),await new Promise((e=>s.fetch({success:e,error:e}))),e.api.trigger("clientConfigInitialized")}(yu),await It.initialize(),function(e){e.pluggable.initialized_plugins=[];const t=gt.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")}(yu),t.elements?.register(),function(e){e.api.trigger("registeredGlobalEventHandlers")}(yu);const n=yu.pluggable.plugins;if((t.settings.get("auto_login")||t.settings.get("keepalive")&&n["converse-bosh"]?.enabled())&&await t.user.login(null,null,!0),t.trigger("initialized"),lu())return yu},plugins:{add(e,t){if(t.__name__=e,void 0!==yu.pluggable.plugins[e])throw new TypeError(`Error: plugin with name "${e}" has already been registered!`);yu.pluggable.plugins[e]=t}},env:{$build:ce,$iq:de,$msg:le,$pres:ue,utils:om,Collection:Gd,Model:wd,Promise,Strophe:qe,TimeoutError:Zu,URI:Uh(),VERSION_NAME:Ge,dayjs:b(),filesize:Im,html:Cs,log:kt,sizzle:Au(),sprintf:Tt.sprintf,stx:function(e,...t){return new Be(e,t)},u:om}}),Zm=Xm;const eg=class extends wd{defaults(){return{current_category:"smileys",current_skintone:"",scroll_position:0}}},tg=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"),sg=/(?:\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:ng}=Zm.env,ig={},rg={"*\\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 og(e){if(e.indexOf("-")>-1){const t=[],s=e.split("-");for(let e=0;e=65536&&n<=1114111){const e=Math.floor((n-65536)/1024)+55296,s=(n-65536)%1024+56320;t.push(String.fromCharCode(e)+String.fromCharCode(s))}else t.push(String.fromCharCode(n))}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 ag(e){return e.replace(tg,((e,t,s,n)=>{if(void 0===n||""===n||!(ng.unescapeHTML(n)in rg))return e;n=ng.unescapeHTML(n);return s+og(rg[n].toUpperCase())}))}function cg(e){if(!Zm.emojis.initialized)throw new Error("getShortnameReferences called before emojis are initialized. To avoid this problem, first await the converse.emojis.initialized_promise");return[...e.matchAll(Zm.emojis.shortnames_regex)].filter((e=>e[0].length>0)).map((e=>{const t=Zm.emojis.by_sn[e[0]].cp;return{cp:t,begin:e.index,end:e.index+e[0].length,shortname:e[0],emoji:t?og(t):null}}))}function lg(e){const t=[];return function(e,t){const s=/\uFE0F/g,n=String.fromCharCode(8205);String(e).replace(sg,((e,i,r)=>{const o=function(e){const t=[];let s=0,n=0;for(;n{t.push({begin:n,cp:e,emoji:s,end:n+s.length,shortname:dg("cp")[e]?.sn||""})})),t}function dg(e){if(ig[e])return ig[e];if("category"===e)return Zm.emojis.json;const t=Zm.emojis.list.map((t=>t[e])).filter(((e,t,s)=>s.indexOf(e)==t));return ig[e]={},t.forEach((t=>ig[e][t]=Zm.emojis.list.find((s=>s[e]===t)))),ig[e]}Object.assign(ng,{getCodePointReferences:lg,getShortnameReferences:cg,convertASCII2Emoji:ag,getEmojisByAtrribute:dg,isOnlyEmojis:function(e){const t=e.trim().split(/\s+/);if(0===t.length||t.length>3)return!1;return t.filter((e=>{const t=lg(ng.shortnamesToUnicode(e));return 1===t.length&&(e===t[0].shortname||e===t[0].emoji)})).length===t.length},shortnamesToUnicode:function(e){return function(e){let t=[e];return[...cg(e),...lg(e)].sort(((e,t)=>t.begin-e.begin)).forEach((e=>{const s=t.shift(),n=e.emoji||e.shortname;t=[s.slice(0,e.begin)+n+s.slice(e.end),...t]})),t}(ag(e)).pop()}}),Zm.emojis={initialized:!1,initialized_promise:vc()},Zm.plugins.add("converse-emoji",{initialize(){const{___:e}=yu;bh.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")}});const t={EmojiPicker:eg};Object.assign(yu,t),Object.assign(yu.exports,t),Object.assign(bh,{emojis:{async initialize(){if(!Zm.emojis.initialized){Zm.emojis.initialized=!0;const e=await s.e(2974).then(s.t.bind(s,7641,19)),t=Zm.emojis.json=e.default;Zm.emojis.by_sn=Object.keys(t).reduce(((e,s)=>Object.assign(e,t[s])),{}),Zm.emojis.list=Object.values(Zm.emojis.by_sn),Zm.emojis.list.sort(((e,t)=>e.snt.sn?1:0)),Zm.emojis.shortnames=Zm.emojis.list.map((e=>e.sn));const n=()=>Zm.emojis.shortnames.map((e=>e.replace(/[+]/g,"\\$&"))).join("|");Zm.emojis.shortnames_regex=new RegExp(n(),"gi"),Zm.emojis.initialized_promise.resolve()}return Zm.emojis.initialized_promise}}})}});const{Strophe:ug}=Zm.env;const hg=class extends wd{get idAttribute(){return"jid"}getDisplayName(){return ug.xmlunescape(this.get("name"))}};const mg=class extends wd{initialize(){super.initialize(),this.rosterContactAdded=vc(),this.contact=null,this.vcard=null}async setRosterContact(e){const t=await bh.contacts.get(e);t&&(this.contact=t,this.set("nickname",t.get("nickname")),this.rosterContactAdded.resolve())}};const gg=class extends mg{defaults(){return{msgid:rm(),time:(new Date).toISOString(),is_ephemeral:!1}}constructor(e,t){super(e,t),this.file=null}async initialize(){super.initialize(),this.checkValidity()&&(this.initialized=vc(),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 bh.trigger("messageInitialized",this,{Synchronous:!0}),this.initialized.resolve())}setContact(){if(["chat","normal"].includes(this.get("type")))return mg.prototype.initialize.apply(this,arguments),this.setRosterContact(qe.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=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(bh.settings.get("allow_message_retraction"))}safeDestroy(){try{this.destroy()}catch(e){kt.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),s=t?e[t-1]:null;if(null===s)return!1;const n=b()(this.get("time"));return this.get("from")===s.get("from")&&!this.isMeCommand()&&!s.isMeCommand()&&!!this.get("is_encrypted")==!!s.get("is_encrypted")&&this.get("type")===s.get("type")&&"info"!==this.get("type")&&n.isBefore(b()(s.get("time")).add(10,"minutes"))&&("groupchat"!==this.get("type")||this.get("occupant_id")===s.get("occupant_id"))}getDisplayName(){return this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("from")}getMessageText(){if(this.get("is_encrypted")){const{__:e}=yu;return this.get("plaintext")||this.get("body")||e("Undecryptable OMEMO message")}return["groupchat","chat","normal"].includes(this.get("type"))?this.get("body"):this.get("message")}sendSlotRequestStanza(){if(!this.file)return Promise.reject(new Error("file is undefined"));const e=de({from:yu.session.get("jid"),to:this.get("slot_request_url"),type:"get"}).c("request",{xmlns:qe.NS.HTTPUPLOAD,filename:this.file.name,size:this.file.size,"content-type":this.file.type});return bh.sendIQ(e)}getUploadRequestMetadata(e){return{headers:Au()(`slot[xmlns="${qe.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}=yu;let t;try{t=await this.sendSlotRequestStanza()}catch(t){return kt.error(t),this.save({type:"error",message:e("Sorry, could not determine upload URL."),is_ephemeral:!0})}const s=Au()(`slot[xmlns="${qe.NS.HTTPUPLOAD}"]`,t).pop();if(!s)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:s.querySelector("get").getAttribute("url"),put:s.querySelector("put").getAttribute("url")})}uploadFile(){const e=new XMLHttpRequest;e.onreadystatechange=async t=>{if(e.readyState===XMLHttpRequest.DONE)if(kt.info("Status: "+e.status),200===e.status||201===e.status){let e={upload:et,oob_url:this.get("get"),message:this.get("get"),body:this.get("get")};e=await bh.hook("afterFileUploaded",this,e),this.save(e)}else kt.error(t),e.onerror(new ProgressEvent(`Response status: ${e.status}`))},e.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.set("progress",e.loaded/e.total)}),!1),e.onerror=()=>{const{__:t}=yu;let s;s=e.responseText?t('Sorry, could not succesfully upload your file. Your server’s response: "%1$s"',e.responseText):t("Sorry, could not succesfully upload your file."),this.save({type:"error",upload:tt,message:s,is_ephemeral:!0})},e.open("PUT",this.get("put"),!0),e.setRequestHeader("Content-type",this.file.type),this.upload_metadata.headers?.forEach((t=>e.setRequestHeader(t.name,t.value))),e.send(this.file)}};const fg=class extends gg{async initialize(){this.chatbox=this.collection?.chatbox,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(),bh.trigger("chatRoomMessageInitialized",this))}getDisplayName(){return this.occupant?.getDisplayName()||this.get("nick")}mayBeModerated(){if(void 0!==this.get("from_muc"))return["all","moderator"].includes(bh.settings.get("allow_message_retraction"))&&this.get(`stanza_id ${this.get("from_muc")}`)&&this.chatbox.canModerateMessages()}checkValidity(){const e=yu.exports.Message.prototype.checkValidity.call(this);return!e&&this.chatbox.debouncedRejoin(),e}onOccupantRemoved(){this.stopListening(this.occupant),delete this.occupant,this.listenTo(this.chatbox.occupants,"add",this.onOccupantAdded)}onOccupantAdded(e){if(this.get("occupant_id")){if(e.get("occupant_id")!==this.get("occupant_id"))return}else if(e.get("nick")!==qe.getResourceFromJid(this.get("from")))return;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(this.chatbox.occupants,"add",this.onOccupantAdded)}getOccupant(){return this.occupant||this.setOccupant(),this.occupant}setOccupant(){if("groupchat"!==this.get("type")||this.isEphemeral()||this.occupant)return;const e=qe.getResourceFromJid(this.get("from")),t=this.get("occupant_id");if(this.occupant=this.chatbox.occupants.findOccupant({nick:e,occupant_id:t}),!this.occupant&&(this.occupant=this.chatbox.occupants.create({nick:e,occupant_id:t,jid:this.get("from_real_jid")}),bh.settings.get("muc_send_probes"))){const t=`${this.chatbox.get("jid")}/${e}`;bh.user.presence.send("probe",t)}this.listenTo(this.occupant,"destroy",this.onOccupantRemoved)}};const pg=class extends Gd{constructor(e,t={}){super(e,Object.assign({comparator:"time"},t)),this.model=fg}};const vg=function(e,t){return e===t||Hl(e,t,Wl(t))},{u:yg}=Zm.env;async function bg(e,t){if(!t.replace_id||!t.from)return;const s="groupchat"===t.type&&t.occupant_id?({attributes:e})=>e.msgid===t.replace_id&&e.occupant_id==t.occupant_id:({attributes:e})=>e.msgid===t.replace_id&&e.from===t.from&&null==e.occupant_id,n=e.messages.models.find(s);if(!n)return t.older_versions={},await e.createMessage(t);const i=n.get("older_versions")||{};return t.timet){const s=e.messages.filter((e=>!yg.isEmptyMessage(e)));if(s.length>t){for(;s.length>t;)s.shift().destroy();bh.trigger("historyPruned",e)}}}),500,{maxWait:2e3}),wg=Zm.env.utils;function Sg(e,t){bh.send(le({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)),kt.warn(`Rejecting message stanza with the following reason: ${t}`),kt.warn(e)}function xg(e,t,s,n){const i=le({from:bh.connection.get().jid,id:wg.getUniqueId(),to:e,type:n||"chat"}).c(s,{xmlns:qe.NS.MARKERS,id:t});bh.send(i)}const{NS:Ag}=qe;class Eg extends Error{constructor(e,t){super(e),this.name="StanzaParseError",this.stanza=t}}function Cg(e,t){const s={},n=Au()(`stanza-id[xmlns="${qe.NS.SID}"]`,e).reduce(((e,t)=>(e[`stanza_id ${t.getAttribute("by")}`]=t.getAttribute("id"),e)),{});Object.assign(s,n);const i=Au()(`message > result[xmlns="${qe.NS.MAM}"]`,t).pop();if(i){const e=yu.session.get("bare_jid");s[`stanza_id ${t.getAttribute("from")||e}`]=i.getAttribute("id")}const r=Au()(`origin-id[xmlns="${qe.NS.SID}"]`,e).pop();return r&&(s.origin_id=r.getAttribute("id")),s}function $g(e){const t=Au()(`encryption[xmlns="${qe.NS.EME}"]`,e).pop(),s=t?.getAttribute("namespace"),n={};return s?(n.is_encrypted=!0,n.encryption_namespace=s):Au()(`encrypted[xmlns="${qe.NS.OMEMO}"]`,e).pop()&&(n.is_encrypted=!0,n.encryption_namespace=qe.NS.OMEMO),n}function jg(e,t){const s=Au()(`> apply-to[xmlns="${qe.NS.FASTEN}"]`,e).pop();if(s){const e=s.getAttribute("id");if(Au()(`> retract[xmlns="${qe.NS.RETRACT}"]`,s).pop()){const s=Au()(`delay[xmlns="${qe.NS.DELAY}"]`,t).pop();return{editable:!1,retracted:s?b()(s.getAttribute("stamp")).toISOString():(new Date).toISOString(),retracted_id:e}}}else{const t=Au()(`> retracted[xmlns="${qe.NS.RETRACT}"]`,e).pop();if(t)return{editable:!1,is_tombstone:!0,retracted:t.getAttribute("stamp")}}return{}}function kg(e,t){const s=Au()(`replace[xmlns="${qe.NS.MESSAGE_CORRECT}"]`,e).pop();if(s){const e=s.getAttribute("id");if(e){const s=Au()(`delay[xmlns="${qe.NS.DELAY}"]`,t).pop();return{replace_id:e,edited:s?b()(s.getAttribute("stamp")).toISOString():(new Date).toISOString()}}}return{}}function Tg(e){const t=Au()(`spoiler[xmlns="${qe.NS.SPOILER}"]`,e).pop();return{is_spoiler:!!t,spoiler_hint:t?.textContent}}function Ig(e){const t=Au()(`x[xmlns="${qe.NS.OUTOFBAND}"]`,e).pop();return t?{oob_url:t.querySelector("url")?.textContent,oob_desc:t.querySelector("desc")?.textContent}:{}}function Og(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error"),s=Au()(`text[xmlns="${qe.NS.STANZAS}"]`,t).pop();return{is_error:!0,error_text:s?.textContent,error_type:t.getAttribute("type"),error_condition:t.firstElementChild.nodeName}}return{}}function Ng(e){return Au()(`reference[xmlns="${qe.NS.REFERENCE}"]`,e).map((t=>{const s=t.getAttribute("anchor"),n=e.querySelector(s?`#${s}`:"body")?.textContent;if(!n)return kt.warn(`Could not find referenced text for ${t}`),null;const i=t.getAttribute("begin"),r=t.getAttribute("end");return{begin:i,end:r,type:t.getAttribute("type"),value:n.slice(i,r),uri:t.getAttribute("uri")}})).filter((e=>e))}function Mg(e){const t=Au()(`received[xmlns="${qe.NS.RECEIPTS}"]`,e).pop();return t?.getAttribute("id")}function Rg(e){const t=qe.NS.CARBONS;return Au()(`message > received[xmlns="${t}"]`,e).length>0||Au()(`message > sent[xmlns="${t}"]`,e).length>0}function Dg(e){return Au()(`\n composing[xmlns="${Ag.CHATSTATES}"],\n paused[xmlns="${Ag.CHATSTATES}"],\n inactive[xmlns="${Ag.CHATSTATES}"],\n active[xmlns="${Ag.CHATSTATES}"],\n gone[xmlns="${Ag.CHATSTATES}"]`,e).pop()?.nodeName}function zg(e,t){return"me"!==t.sender&&!t.is_carbon&&!t.is_archived&&Au()(`request[xmlns="${qe.NS.RECEIPTS}"]`,e).length}function Lg(e){if(Au()(`message > forwarded[xmlns="${qe.NS.FORWARD}"]`,e).length){Sg(e,"Forwarded messages not part of an encapsulating protocol are not supported");const t=e.getAttribute("from");throw new Eg(`Ignoring unencapsulated forwarded message from ${t}`,e)}}function Pg(e){return Au()(`\n acknowledged[xmlns="${qe.NS.MARKERS}"],\n displayed[xmlns="${qe.NS.MARKERS}"],\n received[xmlns="${qe.NS.MARKERS}"]`,e).pop()}function Ug(e){return"headline"===e.getAttribute("type")}function Fg(e){if(Au()(`mentions[xmlns="${qe.NS.MENTIONS}"]`,e).pop())return!1;const t=e.getAttribute("from");return!("error"===e.getAttribute("type")||!t||t.includes("@"))}function Bg(e){return!!Au()(`message > result[xmlns="${qe.NS.MAM}"]`,e).pop()}const{Strophe:qg,sizzle:Hg}=Zm.env;async function Gg(e){Lg(e);let t=e.getAttribute("to");const s=qg.getResourceFromJid(t),n=yu.session.get("resource");if(bh.settings.get("filter_by_resource")&&s&&s!==n)return new Eg(`Ignoring incoming message intended for a different resource: ${t}`,e);const i=yu.session.get("bare_jid"),r=e;let o=e.getAttribute("from")||i;if(Rg(e)){if(o!==i)return Sg(e,"Rejecting carbon from invalid JID"),new Eg(`Rejecting carbon from invalid JID ${t}`,e);{const s=`[xmlns="${qg.NS.CARBONS}"] > forwarded[xmlns="${qg.NS.FORWARD}"] > message`;t=(e=Hg(s,e).pop()).getAttribute("to"),o=e.getAttribute("from")}}const a=Bg(e);if(a){if(o!==i)return new Eg(`Invalid Stanza: alleged MAM message from ${e.getAttribute("from")}`,e);{const s=`[xmlns="${qg.NS.MAM}"] > forwarded[xmlns="${qg.NS.FORWARD}"] > message`;t=(e=Hg(s,e).pop()).getAttribute("to"),o=e.getAttribute("from")}}const c=qg.getBareJidFromJid(o),l=c===i;if(l&&null===t)return new Eg(`Don't know how to handle message stanza without 'to' attribute. ${e.outerHTML}`,e);const d=Ug(e),u=Fg(e);let h,m;if(!d&&!u&&(m=l?qg.getBareJidFromJid(t):c,h=await bh.contacts.get(m),void 0===h&&!bh.settings.get("allow_non_roster_messaging")))return kt.error(e),new Eg("Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.",e);const g=Hg(`delay[xmlns="${qg.NS.DELAY}"]`,r).pop(),f=Pg(e),p=(new Date).toISOString();let v=Object.assign({contact_jid:m,is_archived:a,is_headline:d,is_server_message:u,body:e.querySelector("body")?.textContent?.trim(),chat_state:Dg(e),from:qg.getBareJidFromJid(e.getAttribute("from")),is_carbon:Rg(r),is_delayed:!!g,is_markable:!!Hg(`markable[xmlns="${qg.NS.MARKERS}"]`,e).length,is_marker:!!f,is_unstyled:!!Hg(`unstyled[xmlns="${qg.NS.STYLING}"]`,e).length,marker_id:f&&f.getAttribute("id"),msgid:e.getAttribute("id")||r.getAttribute("id"),nick:h?.attributes?.nickname,receipt_id:Mg(e),received:(new Date).toISOString(),references:Ng(e),sender:l?"me":"them",subject:e.querySelector("subject")?.textContent,thread:e.querySelector("thread")?.textContent,time:g?b()(g.getAttribute("stamp")).toISOString():p,to:e.getAttribute("to"),type:e.getAttribute("type")||"normal"},Og(e),Ig(e),Tg(e),kg(e,r),Cg(e,r),jg(e,r),$g(e));if(v.is_archived){const t=r.getAttribute("from");if(t&&t!==i)return new Eg(`Invalid Stanza: Forged MAM message from ${t}`,e)}return await bh.emojis.initialize(),v=Object.assign({message:v.body||v.error,is_only_emojis:!!v.body&&om.isOnlyEmojis(v.body),is_valid_receipt_request:zg(e,v)},v),v.id=v.origin_id||v[`stanza_id ${v.from}`]||om.getUniqueId(),v=await bh.hook("parseMessage",e,v),Object.assign(v,om.getMediaURLsMetadata(v.is_encrypted?v.plaintext:v.body))}const{Strophe:Wg,u:Vg}=Zm.env;function Qg(e){if(!location.hash.startsWith("#converse/chat?jid="))return;e?.preventDefault();const t=location.hash.split("=").pop();if(!Vg.isValidJID(t))return kt.warn(`Invalid JID "${t}" provided in URL fragment`);bh.chats.open(t)}async function Jg(){if(hu(yu)){const{chatboxes:e}=yu.state;await Promise.all(e.map((e=>e.messages?.clearStore({silent:!0})))),e.clearStore({silent:!0},(e=>e.get("type")!==ht))}}function Kg(){bh.settings.get("auto_join_private_chats").forEach((e=>{yu.state.chatboxes.where({jid:e}).length||("string"==typeof e?bh.chats.open(e):kt.error('Invalid jid criteria specified for "auto_join_private_chats"'))})),bh.trigger("privateChatsAutoJoined")}function Yg(){bh.connection.get().addHandler((e=>!!(["groupchat","error"].includes(e.getAttribute("type"))||Ug(e)||Fg(e)||Bg(e))||(yu.exports.handleMessageStanza(e)||!0)),null,"message"),bh.connection.get().addHandler((e=>(async function(e){const t=Wg.getBareJidFromJid(e.getAttribute("from")),s=yu.session.get("bare_jid");if(Vg.isSameBareJID(t,s))return;const n=await bh.chatboxes.get(t);n?.get("type")===lt&&n?.handleErrorMessageStanza(e)}(e),!0)),null,"message","error")}async function Xg(e){if(Fg(e=e instanceof Element?e:e.tree())){const t=e.getAttribute("from");return kt.info(`handleMessageStanza: Ignoring incoming server message from JID: ${t}`)}let t;try{t=await Gg(e)}catch(e){return kt.error(e)}if(Vg.isErrorObject(t))return t.stanza&&kt.error(t.stanza),kt.error(t.message);const s=!(!t.body&&!t.plaintext),n=await bh.chats.get(t.contact_jid,{nickname:t.nick},s);await(n?.queueMessage(t));const i={stanza:e,attrs:t,chatbox:n};bh.trigger("message",i)}async function Zg(){const e=yu.session.get("bare_jid"),t=Wg.getDomainFromJid(e);if(!await bh.disco.supports(Wg.NS.CARBONS,t))return void kt.warn("Not enabling carbons because it's not supported!");const s=new Wg.Builder("iq",{from:bh.connection.get().jid,type:"set"}).c("enable",{xmlns:Wg.NS.CARBONS}),n=await bh.sendIQ(s,null,!1);null===n?kt.warn("A timeout occurred while trying to enable carbons"):Vg.isErrorStanza(n)?(kt.warn("An error occurred while trying to enable message carbons."),kt.error(n)):kt.debug("Message carbons have been enabled.")}const{Strophe:ef,$msg:tf,u:sf}=Zm.env;const nf=class extends mg{defaults(){return{bookmarked:!1,hidden:cu()&&!bh.settings.get("singleton"),message_type:"chat",num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),time_sent:new Date(0).toISOString(),type:lt}}constructor(e,t){super(e,t),this.disable_mam=!1}async initialize(){super.initialize(),this.initialized=vc();const e=this.get("jid");if(e){if(this.set({box_id:`box-${e}`}),this.initNotifications(),this.initUI(),this.initMessages(),this.get("type")===lt){const{presences:t}=yu.state;this.presence=t.get(e)||t.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 bh.trigger("chatBoxInitialized",this,{Synchronous:!0}),this.initialized.resolve()}}getMessagesCollection(){return new yu.exports.Messages}getMessagesCacheKey(){return`converse.messages-${this.get("jid")}-${yu.session.get("bare_jid")}`}initMessages(){this.messages=this.getMessagesCollection(),this.messages.fetched=vc(),this.messages.chatbox=this,Iu(this.messages,this.getMessagesCacheKey()),this.listenTo(this.messages,"change:upload",(e=>this.onMessageUploadChanged(e))),this.listenTo(this.messages,"add",(e=>this.onMessageAdded(e)))}initUI(){this.ui=new wd}initNotifications(){this.notifications=new wd}getNotificationsText(){const{__:e}=yu;return this.notifications?.get("chat_state")===ot?e("%1$s is typing",this.getDisplayName()):this.notifications?.get("chat_state")===at?e("%1$s has stopped typing",this.getDisplayName()):this.notifications?.get("chat_state")===ct?e("%1$s has gone away",this.getDisplayName()):""}afterMessagesFetched(){this.pruneHistoryWhenScrolledDown(),bh.trigger("afterMessagesFetched",this)}fetchMessages(){if(this.messages.fetched_flag)return void kt.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:()=>{this.afterMessagesFetched(),e()},error:()=>{this.afterMessagesFetched(),e()}}),this.messages.fetched}async handleErrorMessageStanza(e){const{__:t}=yu,s=await Gg(e);if(!await this.shouldShowErrorMessage(s))return;const n=this.getMessageReferencedByError(s);if(n){const e={error:s.error,error_condition:s.error_condition,error_text:s.error_text,error_type:s.error_type,editable:!1};s.msgid===n.get("retraction_id")?(e.retraction_id=void 0,s.error||("forbidden"===s.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."))):s.error||("forbidden"===s.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.")),n.save(e)}else this.createMessage(s)}queueMessage(e){return this.msg_chain=(this.msg_chain||this.messages.fetched).then((()=>this.onMessage(e))).catch((e=>kt.error(e))),this.msg_chain}async onMessage(e){const t=await e;if(sf.isErrorObject(t))return t.stanza&&kt.error(t.stanza),kt.error(t.message);const s=this.getDuplicateMessage(t);if(s)this.updateMessage(s,t);else if(!this.handleReceipt(t)&&!this.handleChatMarker(t)&&!await this.handleRetraction(t)&&(this.setEditable(t,t.time),t.chat_state&&"them"===t.sender&&this.notifications.set("chat_state",t.chat_state),sf.shouldCreateMessage(t))){const e=await bg(this,t)||await this.createMessage(t);this.notifications.set({chat_state:null}),this.handleUnreadMessage(e)}}async onMessageUploadChanged(e){if(e.get("upload")===et){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){!bh.settings.get("prune_messages_above")||"scrolled"!==bh.settings.get("pruning_behavior")&&this.ui.get("scrolled")||tm(e)||_g(this)}async clearMessages(){try{await this.messages.clearStore()}catch(e){this.messages.trigger("reset"),kt.error(e)}finally{this.messages.fetched.resolve()}}async close(){bh.connection.connected()&&(this.setChatState(it),this.sendChatState());try{await new Promise(((e,t)=>this.destroy({success:e,error:(e,s)=>t(s)})))}catch(e){kt.error(e)}finally{bh.settings.get("clear_messages_on_reconnection")&&await this.clearMessages()}bh.trigger("chatBoxClosed",this)}announceReconnection(){bh.trigger("chatReconnected",this)}async onReconnection(){bh.settings.get("clear_messages_on_reconnection")&&await this.clearMessages(),this.announceReconnection()}onPresenceChanged(e){const{__:t}=yu,s=e.get("show"),n=this.getDisplayName();let i;"offline"===s?i=t("%1$s has gone offline",n):"away"===s?i=t("%1$s has gone away",n):"dnd"===s?i=t("%1$s is busy",n):"online"===s&&(i=t("%1$s is online",n)),i&&this.createMessage({message:i,type:"info"})}onScrolledChanged(){this.ui.get("scrolled")||(this.clearUnreadMsgCounter(),this.pruneHistoryWhenScrolledDown())}pruneHistoryWhenScrolledDown(){bh.settings.get("prune_messages_above")&&"unscrolled"===bh.settings.get("pruning_behavior")&&!this.ui.get("scrolled")&&_g(this)}validate(e){if(!e.jid)return"Ignored ChatBox without JID";const t=bh.settings.get("auto_join_rooms").map((e=>e instanceof Object?e.jid:e)),s=bh.settings.get("auto_join_private_chats").concat(t);if(bh.settings.get("singleton")&&!s.includes(e.jid)&&!bh.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 kt.warn(t),t}}getDisplayName(){return this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("jid")}async createMessageFromError(e){if(e instanceof Zu){(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 s=this.messages.at(t);if(s.get("editable")){e=s;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){return 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 s=this.getUpdatedMessageAttributes(e,t);s&&e.save(s)}setChatState(e,t){return void 0!==this.chat_state_timeout&&(clearTimeout(this.chat_state_timeout),delete this.chat_state_timeout),e===ot?this.chat_state_timeout=setTimeout(this.setChatState.bind(this),yu.TIMEOUTS.PAUSED,at):e===at&&(this.chat_state_timeout=setTimeout(this.setChatState.bind(this),yu.TIMEOUTS.INACTIVE,it)),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 Promise.resolve(!0)}isSameUser(e,t){return sf.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((({attributes:t})=>t.retracted_id===e.origin_id&&t.from===e.from&&!t.moderated_by))}}async handleRetraction(e){const t=["retracted","retracted_id","editable"];if(e.retracted){if(e.is_tombstone)return!1;const s=this.messages.findWhere({origin_id:e.retracted_id,from:e.from});return s?(s.save(_d(e,t)),!0):(e.dangling_retraction=!0,await this.createMessage(e),!0)}{const s=this.findDanglingRetraction(e);if(s){const n=_d(s.attributes,t),i=Object.assign({dangling_retraction:!1},e,n);return delete i.id,s.save(i),!0}}return!1}getDuplicateMessage(e){const t=[...this.getStanzaIdQueryAttrs(e),this.getOriginIdQueryAttrs(e),this.getMessageBodyQueryAttrs(e)].filter((e=>e));return this.messages.models.find((e=>t.reduce(((t,s)=>t||vg(e.attributes,s)),!1)))}getOriginIdQueryAttrs(e){return 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 s={};return s[`stanza_id ${t.replace(/^stanza_id /,"")}`]=e[t],s}))}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 s=tf({id:sf.getUniqueId(),to:this.get("jid"),type:"chat"}).c("store",{xmlns:ef.NS.HINTS}).up().c("apply-to",{id:t,xmlns:ef.NS.FASTEN}).c("retract",{xmlns:ef.NS.RETRACT});return bh.connection.get().send(s)}sendMarkerForLastMessage(e="displayed",t=!1){const s=Array.from(this.messages.models);s.reverse();const n=s.find((e=>"them"===e.get("sender")&&(t||e.get("is_markable"))));n&&this.sendMarkerForMessage(n,e,t)}sendMarkerForMessage(e,t="displayed",s=!1){if(e&&bh.settings.get("send_chat_markers").includes(t)&&(e?.get("is_markable")||s)){xg(ef.getBareJidFromJid(e.get("from")),e.get("msgid"),t,e.get("type"))}}handleChatMarker(e){if(ef.getBareJidFromJid(e.to)!==yu.session.get("bare_jid"))return!1;if(e.is_markable)return!this.contact||e.is_archived||e.is_carbon||xg(e.from,e.msgid,"received"),!1;if(e.marker_id){const t=this.messages.findWhere({msgid:e.marker_id}),s=`marker_${e.marker}`;return t&&!t.get(s)&&t.save({field_name:(new Date).toISOString()}),!0}}sendReceiptStanza(e,t){const s=tf({from:bh.connection.get().jid,id:sf.getUniqueId(),to:e,type:"chat"}).c("received",{xmlns:ef.NS.RECEIPTS,id:t}).up().c("store",{xmlns:ef.NS.HINTS}).up();bh.send(s)}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=tf({from:bh.connection.get().jid,to:this.get("jid"),type:this.get("message_type"),id:e.get("edited")&&sf.getUniqueId()||e.get("msgid")}).c("body").t(e.get("body")).up().c(rt,{xmlns:ef.NS.CHATSTATES}).root();"chat"===e.get("type")&&t.c("request",{xmlns:ef.NS.RECEIPTS}).root(),e.get("is_encrypted")||(e.get("is_spoiler")&&(e.get("spoiler_hint")?t.c("spoiler",{xmlns:ef.NS.SPOILER},e.get("spoiler_hint")).root():t.c("spoiler",{xmlns:ef.NS.SPOILER}).root()),(e.get("references")||[]).forEach((e=>{const s={xmlns:ef.NS.REFERENCE,begin:e.begin,end:e.end,type:e.type};e.uri&&(s.uri=e.uri),t.c("reference",s).root()})),e.get("oob_url")&&t.c("x",{xmlns:ef.NS.OUTOFBAND}).c("url").t(e.get("oob_url")).root()),e.get("edited")&&t.c("replace",{xmlns:ef.NS.MESSAGE_CORRECT,id:e.get("msgid")}).root(),e.get("origin_id")&&t.c("origin-id",{xmlns:ef.NS.SID,id:e.get("origin_id")}).root(),t.root();return(await bh.hook("createMessageStanza",this,{message:e,stanza:t})).stanza}async getOutgoingMessageAttributes(e){await bh.emojis.initialize();const t=!!this.get("composing_spoiler"),s=sf.getUniqueId(),n=e?.body,i=n?sf.shortnamesToUnicode(n):void 0;return e=Object.assign({},e,{from:yu.session.get("bare_jid"),fullname:yu.state.xmppstatus.get("fullname"),id:s,is_only_emojis:!!n&&sf.isOnlyEmojis(n),jid:this.get("jid"),message:i,msgid:s,nickname:this.get("nickname"),sender:"me",time:(new Date).toISOString(),type:this.get("message_type"),body:i,is_spoiler:t,origin_id:s},sf.getMediaURLsMetadata(n)),e=await bh.hook("getOutgoingMessageAttributes",this,e)}setEditable(e,t){e.is_headline||tm(e)||"me"!==e.sender||("all"===bh.settings.get("allow_message_corrections")?e.editable=!(e.file||e.retracted||"oob_url"in e):"last"===bh.settings.get("allow_message_corrections")&&t>this.get("time_sent")&&(this.set({time_sent:t}),this.messages.findWhere({editable:!0})?.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 s=t.get("older_versions")||{};s[t.get("edited")||t.get("time")]=t.getMessageText(),t.save({..._d(e,["body","is_only_emojis","media_urls","references","is_encrypted"]),correcting:!1,edited:(new Date).toISOString(),message:e.body,ogp_metadata:[],origin_id:sf.getUniqueId(),received:void 0,older_versions:s,plaintext:e.is_encrypted?e.message:void 0})}else this.setEditable(e,(new Date).toISOString()),t=await this.createMessage(e);try{const e=await this.createMessageStanza(t);bh.send(e)}catch(e){return t.destroy(),void kt.error(e)}return bh.trigger("sendMessage",{chatbox:this,message:t}),t}sendChatState(){if(bh.settings.get("send_chat_state_notifications")&&this.get("chat_state")){const e=bh.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;bh.send(tf({id:sf.getUniqueId(),to:this.get("jid"),type:"chat"}).c(this.get("chat_state"),{xmlns:ef.NS.CHATSTATES}).up().c("no-store",{xmlns:ef.NS.HINTS}).up().c("no-permanent-store",{xmlns:ef.NS.HINTS}))}}async sendFiles(e){const{__:t,session:s}=yu,n=(await bh.disco.features.get(ef.NS.HTTPUPLOAD,s.get("domain"))).pop();if(!n)return void this.createMessage({message:t("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0});const i=n.dataforms.where({FORM_TYPE:{value:ef.NS.HTTPUPLOAD,type:"hidden"}}).pop(),r=parseInt((i?.attributes||{})["max-file-size"]?.value,10),o=n?.id;o?Array.from(e).forEach((async e=>{if(e=await bh.hook("beforeFileUpload",this,e),!isNaN(r)&&e.size>r){const s=Im(r),n=Array.isArray(s)?t("The size of your file, %1$s, exceeds the maximum allowed by your server.",e.name):t("The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.",e.name,s);return this.createMessage({message:n,type:"error",is_ephemeral:!0})}{const t=await this.getOutgoingMessageAttributes(),s=Object.assign(t,{file:!0,progress:0,slot_request_url:o});this.setEditable(s,(new Date).toISOString());const n=await this.createMessage(s,{silent:!0});n.file=e,this.messages.trigger("add",n),n.getRequestSlotURL()}})):this.createMessage({message:t("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0})}maybeShow(e){if(!cu())return sf.safeSave(this,{hidden:!1}),this.trigger("show"),this;{const t=e=>!e.get("hidden")&&e.get("jid")!==this.get("jid")&&"controlbox"!==e.get("id"),s=yu.state.chatboxes.filter(t);(e||0===s.length)&&(s.forEach((e=>sf.safeSave(e,{hidden:!0}))),sf.safeSave(this,{hidden:!1}))}}isHidden(){return this.get("hidden")||this.isScrolledUp()||document.hidden}handleUnreadMessage(e){e?.get("body")&&function(e){return e instanceof Element?!(Au()(`result[xmlns="${Wg.NS.MAM}"]`,e).length&&Au()(`delay[xmlns="${Wg.NS.DELAY}"]`,e).length):(e instanceof wd&&(e=e.attributes),!(e.is_delayed&&e.is_archived))}(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()),sf.safeSave(this,{num_unread:0})}isScrolledUp(){return this.ui.get("scrolled")}canPostMessages(){return!0}},rf={},of=(e,t)=>e.replace(RegExp("\\"+t,"ig"),"\\"+t);rf.escapeCharacters=e=>t=>e.split("").reduce(of,t),rf.escapeRegexString=rf.escapeCharacters("[\\^$.?*+(){}|"),rf.findFirstMatchInArray=e=>t=>{for(let s=0;s{let i=e,{begin:r,end:o}=s;const{value:a}=s;return r-=n,o=o-n-1,i=`${i.slice(0,r)}${a}${i.slice(o+1)}`,[i,[...t,{...s,begin:r,end:o}]]};rf.reduceTextFromReferences=(e,t)=>t.reduce(af,[e,[]]);const cf=rf,lf=["moderator","participant","visitor"],df=["owner","admin","member","outcast","none"],uf={moderator:1,participant:2,visitor:3,none:2},hf={OWNER:"owner",ADMIN:"admin",MEMBER:"member",EXADMIN:"exadmin",EXOWNER:"exowner",EXOUTCAST:"exoutcast",EXMEMBER:"exmember"},mf=Object.values(hf),gf={ENTERED:"entered",EXITED:"exited"},ff=Object.values(gf),pf={OP:"op",DEOP:"deop",VOICE:"voice",MUTE:"mute"},vf=Object.values(pf),yf={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:[...mf],join_leave_events:[...ff],role_changes:[...vf]},bf={CONNECTED:0,CONNECTING:1,NICKNAME_REQUIRED:2,PASSWORD_REQUIRED:3,DISCONNECTED:4,ENTERED:5,DESTROYED:6,BANNED:7,CLOSING:8},_f=["passwordprotected","unsecured","hidden","publicroom","membersonly","open","persistent","temporary","nonanonymous","semianonymous","moderated","unmoderated","mam_enabled"],wf="303",{Strophe:Sf,sizzle:xf,u:Af}=Zm.env,{NS:Ef}=Sf;function Cf(e){const t=xf(`items[node="${Sf.NS.CONFINFO}"]`,e).pop();if(!t)return null;const s=e.getAttribute("from"),n=e.getAttribute("id"),i=`item conference-info[xmlns="${Sf.NS.CONFINFO}"] activity[xmlns="${Sf.NS.ACTIVITY}"]`;return xf(i,t).map((t=>{const i=t.querySelector("text")?.textContent;if(i){const r=Ng(e),o=t.querySelector("reason")?.textContent;return{from:s,msgid:n,message:i,reason:o,references:r,type:"mep"}}return{}}))}function $f(e,t){if(t.features.get(Sf.NS.OCCUPANTID))return xf(`occupant-id[xmlns="${Sf.NS.OCCUPANTID}"]`,e).pop()?.getAttribute("id")}function jf(e,t){let s;const n=t.get("occupant_id");if(n)s=e.occupant_id===n;else if(e.from_real_jid){const t=yu.session.get("bare_jid");s=Sf.getBareJidFromJid(e.from_real_jid)===t}else s=e.nick===t.get("nick");return s?"me":"them"}async function kf(e,t){Lg(e);const s=`[xmlns="${Ef.MAM}"] > forwarded[xmlns="${Ef.FORWARD}"] > message`,n=e;if(e=xf(s,e).pop()||e,xf(`message > forwarded[xmlns="${Sf.NS.FORWARD}"]`,e).length)return new Eg(`Invalid Stanza: Forged MAM groupchat message from ${e.getAttribute("from")}`,e);const i=xf(`delay[xmlns="${Sf.NS.DELAY}"]`,n).pop(),r=e.getAttribute("from"),o=Pg(e);let a=Object.assign({from:r,activities:Cf(e),body:e.querySelector(":scope > body")?.textContent?.trim(),chat_state:Dg(e),from_muc:Sf.getBareJidFromJid(r),is_archived:Bg(n),is_carbon:Rg(n),is_delayed:!!i,is_forwarded:!!e.querySelector("forwarded"),is_headline:Ug(e),is_markable:!!xf(`markable[xmlns="${Sf.NS.MARKERS}"]`,e).length,is_marker:!!o,is_unstyled:!!xf(`unstyled[xmlns="${Sf.NS.STYLING}"]`,e).length,marker_id:o&&o.getAttribute("id"),msgid:e.getAttribute("id")||n.getAttribute("id"),nick:Sf.unescapeNode(Sf.getResourceFromJid(r)),occupant_id:$f(e,t),receipt_id:Mg(e),received:(new Date).toISOString(),references:Ng(e),subject:e.querySelector("subject")?.textContent,thread:e.querySelector("thread")?.textContent,time:i?b()(i.getAttribute("stamp")).toISOString():(new Date).toISOString(),to:e.getAttribute("to"),type:e.getAttribute("type")},Og(e),Ig(e),Tg(e),kg(e,n),Cg(e,n),function(e){const t=Au()(`> apply-to[xmlns="${qe.NS.FASTEN}"]`,e).pop();if(t){const e=t.getAttribute("id"),s=Au()(`> meta[xmlns="${qe.NS.XHTML}"]`,t);if(s.length){const t=bh.settings.get("message_limit"),n=s.reduce(((e,s)=>{const n=s.getAttribute("property");if(n){let i=Ct(s.getAttribute("content")||"");t&&"og:description"===n&&i.length>=t&&(i=`${i.slice(0,t)}${Ct("…")}`),e[n]=i}return e}),{ogp_for_id:e});if("og:description"in n||"og:title"in n||"og:image"in n)return n}}return{}}(e),jg(e,n),function(e){const t=xf(`apply-to[xmlns="${Sf.NS.FASTEN}"]`,e).pop();if(t){const e=t.getAttribute("id"),s=xf(`moderated[xmlns="${Sf.NS.MODERATE}"]`,t).pop();if(s&&xf(`retract[xmlns="${Sf.NS.RETRACT}"]`,s).pop())return{editable:!1,moderated:"retracted",moderated_by:s.getAttribute("by"),moderated_id:e,moderation_reason:s.querySelector("reason")?.textContent}}else{const t=xf(`> moderated[xmlns="${Sf.NS.MODERATE}"]`,e).pop();if(t&&xf(`retracted[xmlns="${Sf.NS.RETRACT}"]`,t).pop())return{editable:!1,is_tombstone:!0,moderated_by:t.getAttribute("by"),retracted:t.getAttribute("stamp"),moderation_reason:t.querySelector("reason")?.textContent}}return{}}(e),$g(e));return await bh.emojis.initialize(),a.from_real_jid=a.is_archived&&function(e){const t=xf(`x[xmlns="${Sf.NS.MUC_USER}"] item`,e).pop();return t?.getAttribute("jid")}(e)||t.occupants.findOccupant(a)?.get("jid"),a=Object.assign({is_only_emojis:!!a.body&&Af.isOnlyEmojis(a.body),is_valid_receipt_request:zg(e,a),message:a.body||a.error,sender:jf(a,t)},a),a.is_archived&&n.getAttribute("from")!==a.from_muc?new Eg(`Invalid Stanza: Forged MAM message from ${n.getAttribute("from")}`,e):a.is_archived&&n.getAttribute("from")!==t.get("jid")?new Eg(`Invalid Stanza: Forged MAM groupchat message from ${e.getAttribute("from")}`,e):a.is_carbon?new Eg("Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied",e):(a.id=a.origin_id||a[`stanza_id ${a.from_muc||a.from}`]||Af.getUniqueId(),a=await bh.hook("parseMUCMessage",e,a),Object.assign(a,Af.getMediaURLsMetadata(a.is_encrypted?a.plaintext:a.body)))}const{Strophe:Tf,$iq:If,u:Of}=Zm.env;async function Nf(e,t){const{__:s}=yu,n=If({to:t,type:"get"}).c("query",{xmlns:Tf.NS.MUC_ADMIN}).c("item",{affiliation:e}),i=await bh.sendIQ(n,null,!1);if(null===i){const n=s("Error: timeout while fetching %1s list for MUC %2s",e,t),i=new Error(n);return kt.warn(n),i}if(Of.isErrorStanza(i)){const n=s("Error: not allowed to fetch %1s list for MUC %2s",e,t),r=new Error(n);return kt.warn(n),kt.warn(i),r}return function(e){return xf(`query[xmlns="${Sf.NS.MUC_ADMIN}"] item`,e).map((e=>{const t={affiliation:e.getAttribute("affiliation")},s=e.getAttribute("jid");Af.isValidJID(s)?t.jid=s:t.nick=s;const n=e.getAttribute("nick");return n&&(t.nick=n),e.getAttribute("role")&&(t.role=n),t}))}(i).filter((e=>e)).sort(((e,t)=>e.nickt.nick?1:0))}function Mf(e,t){const s=[...new Set(t.map((e=>e.affiliation)))];return Promise.all(s.map((s=>Rf(s,e,t))))}function Rf(e,t,s){return Array.isArray(t)||(t=[t]),s=s.filter((t=>[void 0,e].includes(t.affiliation))),Promise.all(t.reduce(((t,n)=>[...t,...s.map((t=>function(e,t,s){const n=If({to:t,type:"set"}).c("query",{xmlns:Tf.NS.MUC_ADMIN}).c("item",{affiliation:s.affiliation||e,nick:s.nick,jid:s.jid});void 0!==s.reason&&n.c("reason",s.reason);return bh.sendIQ(n)}(e,n,t)))]),[]))}function Df(e,t,s,n){const i=s.map((e=>e.jid)),r=n.map((e=>e.jid));let o=i.filter((e=>!r.includes(e))).map((e=>s[i.indexOf(e)]));return e||(o=o.concat(s.filter((e=>{const t=r.indexOf(e.jid);return t>=0&&e.affiliation!==n[t].affiliation})))),t&&(o=o.concat(r.filter((e=>!i.includes(e))).map((e=>({jid:e,affiliation:"none"}))))),o}const{Strophe:zf,sizzle:Lf,u:Pf}=Zm.env;function Uf(e,t){const s=e.get("role")||"none",n=t.get("role")||"none";if(uf[s]===uf[n]){const s=e.getDisplayName().toLowerCase(),n=t.getDisplayName().toLowerCase();return sn?1:0}return uf[s](yu.exports.onDirectMUCInvitation(e),!0)),"jabber:x:conference","message")}function Bf(){return yu.state.chatboxes.filter((e=>e.get("type")===dt)).forEach((e=>e.session.save({connection_status:Zm.ROOMSTATUS.DISCONNECTED})))}async function qf(){if(!document.hidden&&bh.connection.connected()){(await bh.rooms.get()).forEach((e=>e.rejoinIfNecessary()))}}async function Hf(e){if(!location.hash.startsWith("#converse/room?jid="))return;e?.preventDefault();const t=location.hash.split("=").pop();if(!Pf.isValidMUCJID(t))return kt.warn(`invalid jid "${t}" provided in url fragment`);await bh.waitUntil("roomsAutoJoined"),bh.settings.get("allow_bookmarks")&&await bh.waitUntil("bookmarksInitialized"),bh.rooms.open(t,{},!0)}async function Gf(e){const t=Lf('x[xmlns="jabber:x:conference"]',e).pop(),s=zf.getBareJidFromJid(e.getAttribute("from")),n=t.getAttribute("jid"),i=t.getAttribute("reason");let r;if(bh.settings.get("auto_join_on_invite"))r=!0;else{const e=yu.state.roster.get(s)?.getDisplayName()??s;r=await bh.hook("confirmDirectMUCInvitation",{contact:e,reason:i,jid:n},!1)}if(r){const e=await async function(e,t){t.type=dt,t.id=e;const s=await bh.rooms.get(e,t,!0);return s.maybeShow(!0),s}(n,{password:t.getAttribute("password")});e.session.get("connection_status")===Zm.ROOMSTATUS.DISCONNECTED&&yu.state.chatboxes.get(n).rejoin()}}function Wf(){const{xmppstatus:e}=yu.state;if(!e)throw new Error("Can't call _converse.getDefaultMUCNickname before the statusInitialized has been fired.");const t=e.getNickname();if(t)return t;if(bh.settings.get("muc_nickname_from_jid")){const e=yu.session.get("bare_jid");return zf.unescapeNode(zf.getNodeFromJid(e))}}function Vf(e){return!!bh.settings.get("muc_show_info_messages").includes(e)}async function Qf(){await Promise.all(bh.settings.get("auto_join_rooms").map((e=>"string"==typeof e?yu.state.chatboxes.where({jid:e}).length?Promise.resolve():bh.rooms.open(e):e instanceof Object?bh.rooms.open(e.jid,{...e}):(kt.error('Invalid muc criteria specified for "auto_join_rooms"'),Promise.resolve())))),bh.trigger("roomsAutoJoined")}function Jf(){bh.disco.own.features.add(zf.NS.MUC),bh.settings.get("allow_muc_invitations")&&bh.disco.own.features.add("jabber:x:conference")}function Kf(){yu.state.chatboxes.where({type:dt}).forEach((e=>nm(e.session,{connection_status:Zm.ROOMSTATUS.DISCONNECTED})))}function Yf(){window.addEventListener(du(),(()=>{!bh.connection.isType("websocket")||bh.settings.get("enable_smacks")&&yu.session.get("smacks_stream_id")||Bf()}))}function Xf(){bh.connection.get().addHandler((e=>{const t=zf.getBareJidFromJid(e.getAttribute("from"));return yu.state.chatboxes.get(t)||bh.waitUntil("chatBoxesFetched").then((async()=>{const s=yu.state.chatboxes.get(t);s&&(await s.initialized,s.message_handler.run(e))})),!0}),null,"message","groupchat")}const{u:Zf}=Zm.env,ep=["owner"],tp=["admin","ban","deop","destroy","member","op","revoke"],sp=["kick","mute","voice","modtools"],np=["nick"],ip=["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"],rp=["301","303","333","307","321","322"];class op extends wd{defaults(){return{connection_status:bf.DISCONNECTED}}}const ap=class extends nf{defaults(){return{bookmarked:!1,chat_state:void 0,has_activity:!1,hidden:cu()&&!bh.settings.get("singleton"),hidden_occupants:!!bh.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:dt}}async initialize(){this.initialized=vc(),this.debouncedRejoin=Su(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 bh.trigger("chatRoomInitialized",this,{Synchronous:!0}),this.initialized.resolve()}isEntered(){return this.session.get("connection_status")===bf.ENTERED}isRAICandidate(){return this.get("hidden")&&bh.settings.get("muc_subscribe_to_rai")&&"none"!==this.getOwnAffiliation()}async restoreFromCache(){if(this.isEntered()){if(await this.fetchOccupants().catch((e=>kt.error(e))),this.isRAICandidate())return this.session.save("connection_status",bf.DISCONNECTED),this.enableRAI(),!0;if(await this.isJoined())return await new Promise((e=>this.config.fetch({success:e,error:e}))),await new Promise((e=>this.features.fetch({success:e,error:e}))),await this.fetchMessages().catch((e=>kt.error(e))),!0}return this.session.save("connection_status",bf.DISCONNECTED),this.clearOccupantsCache(),!1}async join(e,t){return this.isEntered()?this:(this.session.save("connection_status",bf.CONNECTING),await this.refreshDiscoInfo(),(e=await this.getAndPersistNickname(e))?(bh.send(await this.constructJoinPresence(t)),this):(nm(this.session,{connection_status:bf.NICKNAME_REQUIRED}),bh.settings.get("muc_show_logs_before_join")&&await this.fetchMessages(),this))}rejoin(){return this.session.save("connection_status",bf.DISCONNECTED),this.registerHandlers(),this.clearOccupantsCache(),this.join()}async constructJoinPresence(e){let t=ue({id:rm(),from:bh.connection.get().jid,to:this.getRoomJIDAndNick()}).c("x",{xmlns:qe.NS.MUC}).c("history",{maxstanzas:this.features.get("mam_enabled")?0:bh.settings.get("muc_history_max_stanzas")}).up();return(e=e||this.get("password"))&&t.cnode(qe.xmlElement("password",[],e)),t.up(),t=await bh.hook("constructedMUCPresence",this,t),t}clearOccupantsCache(){this.occupants.length?this.occupants.filter((e=>!e.isMember())).forEach((e=>e.destroy())):this.occupants.clearStore()}sendMarkerForMessage(e,t="displayed",s=!1){if(e&&bh.settings.get("send_chat_markers").includes(t)&&"groupchat"===e?.get("type")&&(e?.get("is_markable")||s)){const s=`stanza_id ${this.get("jid")}`,n=e.get(s);if(!n)return void kt.error(`Can't send marker for message without stanza ID: ${s}`);xg(qe.getBareJidFromJid(e.get("from")),n,t,e.get("type"))}}enableRAI(){if(bh.settings.get("muc_subscribe_to_rai")){const e=qe.getDomainFromJid(this.get("jid"));bh.user.presence.send(null,e,null,ce("rai",{xmlns:qe.NS.RAI}))}}async onHiddenChange(){const e=bf,t=this.session.get("connection_status");this.get("hidden")?t===e.ENTERED&&this.isRAICandidate()&&(this.sendMarkerForLastMessage("received",!0),await this.leave(),this.enableRAI()):(t===e.DISCONNECTED&&this.rejoin(),this.clearUnreadMsgCounter())}onOccupantAdded(e){Vf(Zm.MUC_TRAFFIC_STATES.ENTERED)&&this.session.get("connection_status")===bf.ENTERED&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Zm.MUC_TRAFFIC_STATES.ENTERED)}onOccupantRemoved(e){Vf(Zm.MUC_TRAFFIC_STATES.EXITED)&&this.isEntered()&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Zm.MUC_TRAFFIC_STATES.EXITED)}onOccupantShowChanged(e){e.get("states").includes("303")||("offline"===e.get("show")&&Vf(Zm.MUC_TRAFFIC_STATES.EXITED)?this.updateNotifications(e.get("nick"),Zm.MUC_TRAFFIC_STATES.EXITED):"online"===e.get("show")&&Vf(Zm.MUC_TRAFFIC_STATES.ENTERED)&&this.updateNotifications(e.get("nick"),Zm.MUC_TRAFFIC_STATES.ENTERED))}async onRoomEntered(){await this.occupants.fetchMembers(),bh.settings.get("clear_messages_on_reconnection")?await this.clearMessages():await this.fetchMessages(),bh.trigger("enteredNewRoom",this),bh.settings.get("auto_register_muc_nickname")&&await bh.disco.supports(qe.NS.MUC_REGISTER,this.get("jid"))&&this.registerNickname()}async onConnectionStatusChanged(){if(this.isEntered())if(this.isRAICandidate()){try{await this.leave()}catch(e){kt.error(e)}this.enableRAI()}else await this.onRoomEntered()}async onReconnection(){await this.rejoin(),this.announceReconnection()}getMessagesCollection(){return new yu.exports.MUCMessages}restoreSession(){const e=`muc.session-${yu.session.get("bare_jid")}-${this.get("jid")}`;return this.session=new op({id:e}),Iu(this.session,e,"session"),new Promise((e=>this.session.fetch({success:e,error:e})))}initDiscoModels(){const e=yu.session.get("bare_jid");let t=`converse.muc-features-${e}-${this.get("jid")}`;this.features=new wd(Object.assign({id:t},Zm.ROOM_FEATURES.reduce(((e,t)=>(e[t]=!1,e)),{}))),this.features.browserStorage=Tu(t,"session"),this.features.listenTo(yu,"beforeLogout",(()=>this.features.browserStorage.flush())),t=`converse.muc-config-${e}-${this.get("jid")}`,this.config=new wd({id:t}),this.config.browserStorage=Tu(t,"session"),this.config.listenTo(yu,"beforeLogout",(()=>this.config.browserStorage.flush()))}initOccupants(){this.occupants=new yu.exports.MUCOccupants;const e=`converse.occupants-${yu.session.get("bare_jid")}${this.get("jid")}`;this.occupants.browserStorage=Tu(e,"session"),this.occupants.chatroom=this,this.occupants.listenTo(yu,"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=Au()(`x[xmlns="${qe.NS.MUC_USER}"] item`,e).pop();if(t){const s=e.getAttribute("from"),n=e.getAttribute("type"),i=t.getAttribute("affiliation"),r=t.getAttribute("jid"),o={from:s,type:n,affiliation:i,states:[],show:"unavailable"==n?"offline":"online",role:t.getAttribute("role"),jid:qe.getBareJidFromJid(r),resource:qe.getResourceFromJid(r)},a=this.occupants.findOccupant({jid:o.jid});a?a.save(o):this.occupants.create(o)}}async handleErrorMessageStanza(e){const{__:t}=yu,s=await kf(e,this);if(!await this.shouldShowErrorMessage(s))return;const n=this.getMessageReferencedByError(s);if(n){const e={error:s.error,error_condition:s.error_condition,error_text:s.error_text,error_type:s.error_type,editable:!1};s.msgid===n.get("retraction_id")?(e.retracted=void 0,e.retraction_id=void 0,e.retracted_id=void 0,s.error||("forbidden"===s.error_condition?e.error=t("You're not allowed to retract your message."):"not-acceptable"===s.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."))):s.error||("forbidden"===s.error_condition?e.error=t("Your message was not delivered because you weren't allowed to send it."):"not-acceptable"===s.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.")),n.save(e)}else this.createMessage(s)}handleMessageFromMUCHost(e){if(this.isEntered())return;const t=Au()(`rai[xmlns="${qe.NS.RAI}"]`,e).pop(),s=Array.from(t?.querySelectorAll("activity")||[]).map((e=>e.textContent));s.includes(this.get("jid"))&&this.save({has_activity:!0,num_unread_general:0})}handleForwardedMentions(e){if(this.isEntered())return;const t=Au()(`mentions[xmlns="${qe.NS.MENTIONS}"] forwarded[xmlns="${qe.NS.FORWARD}"] message[type="groupchat"]`,e),s=this.get("jid"),n=t.filter((e=>qe.getBareJidFromJid(e.getAttribute("from"))===s));n.length&&(this.save({has_activity:!0,num_unread:this.get("num_unread")+n.length}),n.forEach((async e=>{const t={stanza:e,attrs:await kf(e,this),chatbox:this};bh.trigger("message",t)})))}async handleMessageStanza(e){const t=(e=e.tree?.()??e).getAttribute("type");if("error"===t)return this.handleErrorMessageStanza(e);if("groupchat"===t){if(Bg(e))return kt.warn('Received a MAM message with type "groupchat"');this.createInfoMessages(e),this.fetchFeaturesIfConfigurationChanged(e)}else if(!t)return this.handleForwardedMentions(e);let s;try{s=await kf(e,this)}catch(e){return kt.error(e)}const n={stanza:e,attrs:s,chatbox:this};return bh.trigger("message",n),s&&this.queueMessage(s)}registerHandlers(){const e=this.get("jid"),t=qe.getDomainFromJid(e);this.removeHandlers();const s=bh.connection.get();this.presence_handler=s.addHandler((e=>(this.onPresence(e),!0)),null,"presence",null,null,e,{ignoreNamespaceFragment:!0,matchBareFromJid:!0}),this.domain_presence_handler=s.addHandler((e=>(this.onPresenceFromMUCHost(e),!0)),null,"presence",null,null,t),this.message_handler=s.addHandler((e=>(this.handleMessageStanza(e),!0)),null,"message",null,null,e,{matchBareFromJid:!0}),this.domain_message_handler=s.addHandler((e=>(this.handleMessageFromMUCHost(e),!0)),null,"message",null,null,t),this.affiliation_message_handler=s.addHandler((e=>(this.handleAffiliationChangedMessage(e),!0)),qe.NS.MUC_USER,"message",null,null,e)}removeHandlers(){const e=bh.connection.get();return this.message_handler&&(e?.deleteHandler(this.message_handler),delete this.message_handler),this.domain_message_handler&&(e?.deleteHandler(this.domain_message_handler),delete this.domain_message_handler),this.presence_handler&&(e?.deleteHandler(this.presence_handler),delete this.presence_handler),this.domain_presence_handler&&(e?.deleteHandler(this.domain_presence_handler),delete this.domain_presence_handler),this.affiliation_message_handler&&(e?.deleteHandler(this.affiliation_message_handler),delete this.affiliation_message_handler),this}invitesAllowed(){return bh.settings.get("allow_muc_invitations")&&(this.features.get("open")||"owner"===this.getOwnAffiliation())}getDisplayName(){const e=this.get("name");return e||("hidden"===bh.settings.get("locked_muc_domain")?qe.getNodeFromJid(this.get("jid")):this.get("jid"))}sendTimedMessage(e){const t=e instanceof Element?e:e.tree();let s=t.getAttribute("id");s||(s=rm("sendIQ"),t.setAttribute("id",s));const n=vc(),i=bh.settings.get("stanza_timeout"),r=bh.connection.get(),o=r.addTimedHandler(i,(()=>{r.deleteHandler(a);const e=new Zu("Timeout Error: No response from server");return n.resolve(e),!1})),a=r.addHandler((e=>{o&&r.deleteTimedHandler(o),n.resolve(e)}),null,"message",["error","groupchat"],s);return bh.send(t),n}async retractOwnMessage(e){const t=yu.__,s=e.get("origin_id");if(!s)throw new Error("Can't retract message without a XEP-0359 Origin ID");const n=e.get("editable"),i=le({id:rm(),to:this.get("jid"),type:"groupchat"}).c("store",{xmlns:qe.NS.HINTS}).up().c("apply-to",{id:s,xmlns:qe.NS.FASTEN}).c("retract",{xmlns:qe.NS.RETRACT});e.set({retracted:(new Date).toISOString(),retracted_id:s,retraction_id:i.tree().getAttribute("id"),editable:!1});const r=await this.sendTimedMessage(i);Zf.isErrorStanza(r)?kt.error(r):r instanceof Zu&&(kt.error(r),e.save({editable:n,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 s=e.get("editable"),n=yu.session.get("bare_jid");e.save({moderated:"retracted",moderated_by:n,moderated_id:e.get("msgid"),moderation_reason:t,editable:!1});const i=await this.sendRetractionIQ(e,t);return(null===i||Zf.isErrorStanza(i))&&e.save({editable:s,moderated:void 0,moderated_by:void 0,moderated_id:void 0,moderation_reason:void 0}),i}sendRetractionIQ(e,t){const s=de({to:this.get("jid"),type:"set"}).c("apply-to",{id:e.get(`stanza_id ${this.get("jid")}`),xmlns:qe.NS.FASTEN}).c("moderate",{xmlns:qe.NS.MODERATE}).c("retract",{xmlns:qe.NS.RETRACT}).up().c("reason").t(t||"");return bh.sendIQ(s,null,!1)}sendDestroyIQ(e,t){const s=ce("destroy");t&&s.attrs({jid:t});const n=de({to:this.get("jid"),type:"set"}).c("query",{xmlns:qe.NS.MUC_OWNER}).cnode(s.node);return e&&e.length>0&&n.c("reason",e),bh.sendIQ(n)}async leave(e){bh.connection.connected()&&bh.user.presence.send("unavailable",this.getRoomJIDAndNick(),e),this.features&&await new Promise((e=>this.features.destroy({success:e,error:(t,s)=>{kt.error(s),e()}})));const t=yu.state.disco_entities?.get(this.get("jid"));t&&await new Promise((e=>t.destroy({success:e,error:(t,s)=>{kt.error(s),e()}}))),nm(this.session,{connection_status:bf.DISCONNECTED})}async close(e){const{ENTERED:t,CLOSING:s}=bf,n=this.session.get("connection_status")===t;return nm(this.session,{connection_status:s}),n&&this.sendMarkerForLastMessage("received",!0),await this.unregisterNickname(),await this.leave(),this.occupants.clearStore(),"closeAllChatBoxes"!==e?.name&&bh.settings.get("muc_clear_messages_on_leave")&&this.clearMessages(),await new Promise((e=>this.session.destroy({success:e,error:(t,s)=>{kt.error(s),e()}}))),yu.exports.ChatBox.prototype.close.call(this)}canModerateMessages(){const e=this.getOwnOccupant();return e&&e.isModerator()&&bh.disco.supports(qe.NS.MODERATE,this.get("jid"))}canPostMessages(){return this.isEntered()&&!(this.features.get("moderated")&&"visitor"===this.getOwnRole())}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=>cf.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})}getReferenceURIFromNickname(e){const t=this.get("jid"),s=this.getOccupant(e),n=this.features.get("nonanonymous")&&s?.get("jid")||`${t}/${e}`;return encodeURI(`xmpp:${n}`)}parseTextForReferences(e){if(!e||!/(\p{P}|\p{Z}|^)([@][\w_-]+(?:\.\w+)*)/giu.test(e))return[e,[]];const t=cf.findFirstMatchInArray(this.getAllKnownNicknames()),s=this.getAllKnownNicknamesRegex(),n=[...e.matchAll(s)].filter((e=>!e[0].startsWith("/"))),i=n.map((e=>{let s=e[0].indexOf("@");"@"===e[0][s+1]&&(s+=1);const n=e.index+s,i=n+e[0].length-s,r=t(e[1]);return{begin:n,end:i,value:r,type:"mention",uri:this.getReferenceURIFromNickname(r)}})),[r,o]=cf.reduceTextFromReferences(e,i);return[r,o]}async getOutgoingMessageAttributes(e){await bh.emojis.initialize();const t=this.get("composing_spoiler");let s,n="";e?.body&&([n,s]=this.parseTextForReferences(e.body));const i=rm(),r=n?Zf.shortnamesToUnicode(n):void 0;return e=Object.assign({},e,{body:r,is_spoiler:t,origin_id:i,references:s,id:i,msgid:i,from:`${this.get("jid")}/${this.get("nick")}`,fullname:this.get("nick"),is_only_emojis:!!n&&Zf.isOnlyEmojis(n),message:r,nick:this.get("nick"),sender:"me",type:"groupchat"},Zf.getMediaURLsMetadata(n)),e=await bh.hook("getOutgoingMessageAttributes",this,e)}getRoomJIDAndNick(){const e=this.get("nick");return qe.getBareJidFromJid(this.get("jid"))+(null!==e?`/${e}`:"")}sendChatState(){if(!bh.settings.get("send_chat_state_notifications")||!this.get("chat_state")||!this.isEntered()||this.features.get("moderated")&&"visitor"===this.getOwnRole())return;const e=bh.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;const t=this.get("chat_state");t!==ct&&bh.send(le({to:this.get("jid"),type:"groupchat"}).c(t,{xmlns:qe.NS.CHATSTATES}).up().c("no-store",{xmlns:qe.NS.HINTS}).up().c("no-permanent-store",{xmlns:qe.NS.HINTS}))}directInvite(e,t){this.features.get("membersonly")&&this.updateMemberLists([{jid:e,affiliation:"member",reason:t}]);const s={xmlns:"jabber:x:conference",jid:this.get("jid")};null!==t&&(s.reason=t),this.get("password")&&(s.password=this.get("password"));const n=le({from:bh.connection.get().jid,to:e,id:rm()}).c("x",s);bh.send(n),bh.trigger("roomInviteSent",{room:this,recipient:e,reason:t})}refreshDiscoInfo(){return bh.disco.refresh(this.get("jid")).then((()=>this.getDiscoInfo())).catch((e=>kt.error(e)))}getDiscoInfo(){return bh.disco.getIdentity("conference","text",this.get("jid")).then((e=>this.save({name:e?.get("name")}))).then((()=>this.getDiscoInfoFields())).then((()=>this.getDiscoInfoFeatures())).catch((e=>kt.error(e)))}async getDiscoInfoFields(){const e=(await bh.disco.getFields(this.get("jid"))).reduce(((e,t)=>{const s=t.get("var");return s?.startsWith("muc#roominfo_")&&(e[s.replace("muc#roominfo_","")]=t.get("value")),e}),{});this.config.save(e)}async getDiscoInfoFeatures(){const e=await bh.disco.getFeatures(this.get("jid")),t=Zm.ROOM_FEATURES.reduce(((e,t)=>(e[t]=!1,e)),{fetched:(new Date).toISOString()});e.each((e=>{const s=e.get("var");s.startsWith("muc_")?t[s.replace("muc_","")]=!0:s===qe.NS.MAM?t.mam_enabled=!0:t[s]=!0})),this.features.save(t)}addFieldValue(e){const t=e.getAttribute("type");if("fixed"===t)return e;const s=e.getAttribute("var").replace("muc#roomconfig_",""),n=this.get("roomconfig");if(s in n){let i;switch(t){case"boolean":i=[n[s]?1:0];break;case"list-multi":i=n[s];break;default:i=[n[s]]}e.innerHTML=i.map((e=>ce("value").t(e))).join("")}return e}async autoConfigureChatRoom(){const e=await this.fetchRoomConfiguration(),t=Au()("field",e).map((e=>this.addFieldValue(e)));if(t.length)return this.sendConfiguration(t)}fetchRoomConfiguration(){return bh.sendIQ(de({to:this.get("jid"),type:"get"}).c("query",{xmlns:qe.NS.MUC_OWNER}))}sendConfiguration(e=[]){const t=de({to:this.get("jid"),type:"set"}).c("query",{xmlns:qe.NS.MUC_OWNER}).c("x",{xmlns:qe.NS.XFORM,type:"submit"});return e.forEach((e=>t.cnode(e).up())),bh.sendIQ(t)}onCommandError(e){const{__:t}=yu;kt.fatal(e);const s=t("Sorry, an error happened while running the command.")+" "+t("Check your browser's developer console for details.");this.createMessage({message:s,type:"error"})}getNickOrJIDFromCommandArgs(e){const{__:t}=yu;if(Zf.isValidJID(e.trim()))return e.trim();e.startsWith("@")||(e="@"+e);const s=this.parseTextForReferences(e)[1];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 n=s.pop().value,i=e.split(n,2)[1];if(!i||i.startsWith(" "))return n;{const e=t("Error: couldn't find a groupchat participant based on your arguments");this.createMessage({message:e,type:"error"})}}validateRoleOrAffiliationChangeArgs(e,t){const{__:s}=yu;if(!t){const t=s('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=yu.session.get("bare_jid"),s=this.occupants.findWhere({jid:t});return this.verifyAffiliations(["owner"],s,!1)?e=e.concat(ep).concat(tp):this.verifyAffiliations(["admin"],s,!1)&&(e=e.concat(tp)),this.verifyRoles(["moderator"],s,!1)?e=e.concat(sp).concat(np):this.verifyRoles(["visitor","participant","moderator"],s,!1)||(e=e.concat(np)),e.sort(),Array.isArray(bh.settings.get("muc_disable_slash_commands"))?e.filter((e=>!bh.settings.get("muc_disable_slash_commands").includes(e))):e}verifyAffiliations(e,t,s=!0){const{__:n}=yu;if(!Array.isArray(e))throw new TypeError("affiliations must be an Array");if(!e.length)return!0;const i=yu.session.get("bare_jid");if(t=t||this.occupants.findWhere({jid:i})){const s=t.get("affiliation");if(e.includes(s))return!0}if(s){const e=n("Forbidden: you do not have the necessary affiliation in order to do that.");this.createMessage({message:e,type:"error"})}return!1}verifyRoles(e,t,s=!0){const{__:n}=yu;if(!Array.isArray(e))throw new TypeError("roles must be an Array");if(!e.length)return!0;const i=yu.session.get("bare_jid");if(t=t||this.occupants.findWhere({jid:i})){const s=t.get("role");if(e.includes(s))return!0}if(s){const e=n("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(){return this.getOwnOccupant()?.get("role")}getOwnAffiliation(){return this.getOwnOccupant()?.get("affiliation")||"none"}getOwnOccupant(){return this.occupants.getOwnOccupant()}async setNickname(e){if(bh.settings.get("auto_register_muc_nickname")&&await bh.disco.supports(qe.NS.MUC_REGISTER,this.get("jid"))){const t=this.get("nick");this.set({nick:e});try{await this.registerNickname()}catch(e){const{__:s}=yu;kt.error(e);const n=s("Error: couldn't register new nickname in members only room");return this.createMessage({message:n,type:"error",is_ephemeral:!0}),void this.set({nick:t})}}const t=qe.getBareJidFromJid(this.get("jid"));bh.send(ue({from:bh.connection.get().jid,to:`${t}/${e}`,id:rm()}).tree())}setRole(e,t,s,n,i){const r=ce("item",{nick:e.get("nick"),role:t}),o=de({to:this.get("jid"),type:"set"}).c("query",{xmlns:qe.NS.MUC_ADMIN}).cnode(r.node);return null!==s&&o.c("reason",s),bh.sendIQ(o).then(n).catch(i)}getOccupant(e){return Zf.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,s)=>t.get(e)s.get(e)?1:0))}async updateMemberLists(e){const t=this.get("jid"),s=await Promise.all(["member","admin","owner"].map((e=>Nf(e,t)))),n=s.reduce(((e,t)=>t instanceof Error?(kt.error(t),e):[...t,...e]),[]);await Mf(t,Df(!0,!1,e,n)),await this.occupants.fetchMembers()}async getAndPersistNickname(e){return(e=e||this.get("nick")||await this.getReservedNick()||yu.exports.getDefaultMUCNickname())&&nm(this,{nick:e},{silent:!0}),e}async getReservedNick(){const e=de({to:this.get("jid"),from:bh.connection.get().jid,type:"get"}).c("query",{xmlns:qe.NS.DISCO_INFO,node:"x-roomuser-item"}),t=await bh.sendIQ(e,null,!1);if(sm(t))throw t;const s=t?.querySelector('query[node="x-roomuser-item"] identity');return s?s.getAttribute("name"):null}async registerNickname(){const{__:e}=yu,t=this.get("nick"),s=this.get("jid");let n,i;try{n=await bh.sendIQ(de({to:s,type:"get"}).c("query",{xmlns:qe.NS.MUC_REGISTER}))}catch(t){return Au()(`not-allowed[xmlns="${qe.NS.STANZAS}"]`,t).length?i=e("You're not allowed to register yourself in this groupchat."):Au()(`registration-required[xmlns="${qe.NS.STANZAS}"]`,t).length&&(i=e("You're not allowed to register in this groupchat because it's members-only.")),kt.error(t),i}const r=Au()("field required",n).map((e=>e.parentElement));if(r.length>1&&"muc#register_roomnick"!==r[0].getAttribute("var"))return kt.error(`Can't register the user register in the groupchat ${s} due to the required fields`);try{await bh.sendIQ(de({to:s,type:"set"}).c("query",{xmlns:qe.NS.MUC_REGISTER}).c("x",{xmlns:qe.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 Au()(`service-unavailable[xmlns="${qe.NS.STANZAS}"]`,t).length?i=e("Can't register your nickname in this groupchat, it doesn't support registration."):Au()(`bad-request[xmlns="${qe.NS.STANZAS}"]`,t).length&&(i=e("Can't register your nickname in this groupchat, invalid data form supplied.")),kt.error(i),kt.error(t),i}}async unregisterNickname(){if("unregister"===bh.settings.get("auto_register_muc_nickname"))try{await bh.disco.supports(qe.NS.MUC_REGISTER,this.get("jid"))&&await this.sendUnregistrationIQ()}catch(e){kt.error(e)}}sendUnregistrationIQ(){const e=de({to:this.get("jid"),type:"set"}).c("query",{xmlns:qe.NS.MUC_REGISTER}).c("remove");return bh.sendIQ(e).catch((e=>kt.error(e)))}updateOccupantsOnPresence(e){const t=function(e,t){const s=e.getAttribute("from"),n=e.getAttribute("type"),i={is_me:!!e.querySelector("status[code='110']"),from:s,occupant_id:$f(e,t),nick:Sf.getResourceFromJid(s),type:n,states:[],hats:[],show:"unavailable"!==n?"online":"offline"};return Array.from(e.children).forEach((e=>{e.matches("status")?i.status=e.textContent||null:e.matches("show")?i.show=e.textContent||"online":e.matches("x")&&e.getAttribute("xmlns")===Sf.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"))})):e.matches("x")&&e.getAttribute("xmlns")===Sf.NS.VCARDUPDATE?i.image_hash=e.querySelector("photo")?.textContent:e.matches("hats")&&e.getAttribute("xmlns")===Sf.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"===t.type||!t.jid&&!t.nick&&!t.occupant_id)return!0;const s=this.occupants.findOccupant(t);if("unavailable"===t.type&&s&&!t.states.includes(Zm.MUC_NICK_CHANGED_CODE)&&!["admin","owner","member"].includes(t.affiliation))return s.set(t),void s.destroy();const n=t.jid||"",i={...t,jid:qe.getBareJidFromJid(n)||s?.attributes?.jid,resource:qe.getResourceFromJid(n)||s?.attributes?.resource};if(t.is_me){let e=!1;t.states.includes(Zm.MUC_NICK_CHANGED_CODE)&&(e=!0,this.set("nick",t.nick)),this.features.get(qe.NS.OCCUPANTID)&&this.get("occupant-id")!==t.occupant_id&&(e=!0,this.set("occupant_id",t.occupant_id)),e&&this.save()}s?s.save(i):this.occupants.create(i)}fetchFeaturesIfConfigurationChanged(e){const t=["104","170","171","172","173","174"];Au()("status",e).filter((e=>t.includes(e.getAttribute("code")))).length&&this.refreshDiscoInfo()}isSameUser(e,t){const s=qe.getBareJidFromJid(e),n=qe.getBareJidFromJid(t),i=qe.getResourceFromJid(e),r=qe.getResourceFromJid(t);if(Zf.isSameBareJID(e,t))return s!==this.get("jid")||i===r;return(s===this.get("jid")?this.occupants.findOccupant({nick:i}):this.occupants.findOccupant({jid:s}))===(n===this.get("jid")?this.occupants.findOccupant({nick:r}):this.occupants.findOccupant({jid:n}))}async isSubjectHidden(){return(await bh.user.settings.get("mucs_with_hidden_subject",[])).includes(this.get("jid"))}async toggleSubjectHiddenState(){const e=this.get("jid"),t=await bh.user.settings.get("mucs_with_hidden_subject",[]);t.includes(this.get("jid"))?bh.user.settings.set("mucs_with_hidden_subject",t.filter((t=>t!==e))):bh.user.settings.set("mucs_with_hidden_subject",[...t,e])}async handleSubjectChange(e){const t=yu.__;if("string"==typeof e.subject&&!e.thread&&!e.message){const s=e.subject,n=e.nick;if(nm(this,{subject:{author:n,text:e.subject||""}}),!e.is_delayed&&n){const i=t(s?"Topic set by %1$s":"Topic cleared by %1$s",n),r=this.messages.last();r?.get("nick")===e.nick&&"info"===r?.get("type")&&r?.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(e=""){bh.send(le({to:this.get("jid"),from:bh.connection.get().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=e instanceof Element?e.getAttribute("from"):e instanceof yu.exports.MUCMessage?e.get("from"):e.from,qe.getResourceFromJid(t)==this.get("nick")}getUpdatedMessageAttributes(e,t){const s={...yu.exports.ChatBox.prototype.getUpdatedMessageAttributes.call(this,e,t),..._d(t,["from_muc","occupant_id"])};if(this.isOwnMessage(t)){const n=Object.keys(t).filter((e=>e.startsWith("stanza_id")));Object.assign(s,_d(t,n)),e.get("received")||(s.received=(new Date).toISOString())}return s}async isJoined(){return this.isEntered()?(bh.connection.connected()||await new Promise((e=>bh.listen.once("reconnected",e))),bh.ping(`${this.get("jid")}/${this.get("nick")}`)):(kt.info(`isJoined: not pinging MUC ${this.get("jid")} since we're not entered`),!1)}async sendStatusPresence(e,t,s){if(this.session.get("connection_status")===bf.ENTERED){const n=await yu.state.xmppstatus.constructPresence(e,this.getRoomJIDAndNick(),t);s?.map((e=>e?.tree()??e)).forEach((e=>n.cnode(e).up())),bh.send(n)}}async rejoinIfNecessary(){return this.isRAICandidate()?(kt.debug(`rejoinIfNecessary: not rejoining hidden MUC "${this.get("jid")}" since we're using RAI`),!0):await this.isJoined()?void 0:(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 yu.exports.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),s=e[`stanza_id ${this.get("jid")}`];return s?(t.reverse(),t.find((({attributes:e})=>"retracted"===e.moderated&&e.moderated_id===s&&e.moderated_by))):null}}async handleModeration(e){const t=["editable","moderated","moderated_by","moderated_id","moderation_reason"];if("retracted"===e.moderated){const s={};s[`stanza_id ${this.get("jid")}`]=e.moderated_id;const n=this.messages.findWhere(s);return n?(n.save(_d(e,t)),!0):(e.dangling_moderation=!0,await this.createMessage(e),!0)}{const s=this.findDanglingModeration(e);if(s){const n=_d(s.attributes,t),i=Object.assign({dangling_moderation:!1},e,n);return delete i.id,s.save(i),!0}}return!1}getNotificationsText(){const{__:e}=yu,t=this.notifications.toJSON(),s=bh.settings.get("muc_show_info_messages").filter((e=>Zm.MUC_ROLE_CHANGES_LIST.includes(e))),n=bh.settings.get("muc_show_info_messages").filter((e=>Zm.MUC_TRAFFIC_STATES_LIST.includes(e)));return[...Zm.CHAT_STATES,...n,...s].reduce(((s,n)=>{const i=t[n];if(!i?.length)return s;const r=i.map((e=>this.getOccupant(e)?.getDisplayName()||e));if(1===r.length){if("composing"===n)return`${s}${e("%1$s is typing",r[0])}\n`;if("paused"===n)return`${s}${e("%1$s has stopped typing",r[0])}\n`;if(n===ct)return`${s}${e("%1$s has gone away",r[0])}\n`;if("entered"===n)return`${s}${e("%1$s has entered the groupchat",r[0])}\n`;if("exited"===n)return`${s}${e("%1$s has left the groupchat",r[0])}\n`;if("op"===n)return`${s}${e("%1$s is now a moderator",r[0])}\n`;if("deop"===n)return`${s}${e("%1$s is no longer a moderator",r[0])}\n`;if("voice"===n)return`${s}${e("%1$s has been given a voice",r[0])}\n`;if("mute"===n)return`${s}${e("%1$s has been muted",r[0])}\n`}else if(r.length>1){let t;if(r.length>3)t=`${Array.from(r).slice(0,2).join(", ")} and others`;else{const s=r.pop();t=e("%1$s and %2$s",r.join(", "),s)}if("composing"===n)return`${s}${e("%1$s are typing",t)}\n`;if("paused"===n)return`${s}${e("%1$s have stopped typing",t)}\n`;if(n===ct)return`${s}${e("%1$s have gone away",t)}\n`;if("entered"===n)return`${s}${e("%1$s have entered the groupchat",t)}\n`;if("exited"===n)return`${s}${e("%1$s have left the groupchat",t)}\n`;if("op"===n)return`${s}${e("%1$s are now moderators",r[0])}\n`;if("deop"===n)return`${s}${e("%1$s are no longer moderators",r[0])}\n`;if("voice"===n)return`${s}${e("%1$s have been given voices",r[0])}\n`;if("mute"===n)return`${s}${e("%1$s have been muted",r[0])}\n`}return s}),"")}removeNotification(e,t){const s=this.notifications.toJSON();(t=Array.isArray(t)?t:[t]).forEach((t=>{const n=Array.from(s[t]||[]);if(n.includes(e)){const s=n.indexOf(e);n.splice(s,1),this.notifications.set(t,Array.from(n))}}))}updateNotifications(e,t){const s=this.notifications.toJSON(),n=s[t]||[];if(n.includes(e))return;const i=(i,r)=>(i[r]=r===t?[...n,e]:(s[r]||[]).filter((t=>t!==e)),i),r=Zm.CHAT_STATES.reduce(i,{}),o=Zm.MUC_TRAFFIC_STATES_LIST.reduce(i,{}),a=Zm.MUC_ROLE_CHANGES_LIST.reduce(i,{});this.notifications.set(Object.assign(r,o,a)),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 s=t.get("ogp_metadata")||[];if(s.filter((t=>t["og:url"]===e["og:url"])).length)return!1;const n=[...s,_d(e,ip)];return t.save("ogp_metadata",n),!0}}return!1}handleMEPNotification(e){return!(e.from!==this.get("jid")||!e.activities)&&(e.activities?.forEach((t=>{const s=Object.assign(e,t);this.createMessage(s),bh.trigger("message",{attrs:s,chatbox:this})})),!!e.activities.length)}getDuplicateMessage(e){return e.activities?.length?this.messages.findWhere({type:"mep",msgid:e.msgid}):yu.exports.ChatBox.prototype.getDuplicateMessage.call(this,e)}async onMessage(e){if(sm(e=await e))return e.stanza&&kt.error(e.stanza),kt.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),function(e){return e.nick&&(Pf.shouldCreateMessage(e)||e.is_tombstone)}(e)){const t=await bg(this,e)||await this.createMessage(e);this.removeNotification(e.nick,["composing","paused"]),this.handleUnreadMessage(t)}}handleModifyError(e){const t=e.querySelector("error text")?.textContent;if(t)if(this.session.get("connection_status")===bf.CONNECTING)this.setDisconnectionState(t);else{const e={type:"error",message:t,is_ephemeral:!0};this.createMessage(e)}}handleDisconnection(e){const t=null!==e.querySelector("status[code='110']"),s=Au()(`x[xmlns="${qe.NS.MUC_USER}"]`,e).pop();if(!s)return;const n=yu.labels.muc,i=Object.keys(n.disconnect_messages),r=Au()("status",s).map((e=>e.getAttribute("code"))).filter((e=>i.includes(e)));if(!(t&&r.length>0))return;const o=s.querySelector("item"),a=o?o.querySelector("reason")?.textContent:void 0,c=o?o.querySelector("actor")?.getAttribute("nick"):void 0,l=n.disconnect_messages[r[0]],d=r.includes("301")?bf.BANNED:bf.DISCONNECTED;this.setDisconnectionState(l,a,c,d)}getActionInfoMessage(e,t,s){const n=yu.__;return"301"===e?s?n("%1$s has been banned by %2$s",t,s):n("%1$s has been banned",t):"303"===e?n("%1$s's nickname has changed",t):"307"===e?s?n("%1$s has been kicked out by %2$s",t,s):n("%1$s has been kicked out",t):"321"===e?n("%1$s has been removed because of an affiliation change",t):"322"===e?n("%1$s has been removed for not being a member",t):void 0}createAffiliationChangeMessage(e){const t=yu.__,s=e._previousAttributes.affiliation;if(!s)return;const n=e.get("affiliation");"admin"===s&&Vf(Zm.AFFILIATION_CHANGES.EXADMIN)?this.createMessage({type:"info",message:t("%1$s is no longer an admin of this groupchat",e.get("nick"))}):"owner"===s&&Vf(Zm.AFFILIATION_CHANGES.EXOWNER)?this.createMessage({type:"info",message:t("%1$s is no longer an owner of this groupchat",e.get("nick"))}):"outcast"===s&&Vf(Zm.AFFILIATION_CHANGES.EXOUTCAST)&&this.createMessage({type:"info",message:t("%1$s is no longer banned from this groupchat",e.get("nick"))}),"none"===n&&"member"===s&&Vf(Zm.AFFILIATION_CHANGES.EXMEMBER)&&this.createMessage({type:"info",message:t("%1$s is no longer a member of this groupchat",e.get("nick"))}),"member"===n&&Vf(Zm.AFFILIATION_CHANGES.MEMBER)?this.createMessage({type:"info",message:t("%1$s is now a member of this groupchat",e.get("nick"))}):("admin"===n&&Vf(Zm.AFFILIATION_CHANGES.ADMIN)||"owner"==n&&Vf(Zm.AFFILIATION_CHANGES.OWNER))&&this.createMessage({type:"info",message:t("%1$s is now an %2$s of this groupchat",e.get("nick"),n)})}createRoleChangeMessage(e,t){if("none"===t||e.changed.affiliation)return;const s=e._previousAttributes.role;"moderator"===s&&Vf(Zm.MUC_ROLE_CHANGES.DEOP)?this.updateNotifications(e.get("nick"),Zm.MUC_ROLE_CHANGES.DEOP):"visitor"===s&&Vf(Zm.MUC_ROLE_CHANGES.VOICE)&&this.updateNotifications(e.get("nick"),Zm.MUC_ROLE_CHANGES.VOICE),"visitor"===e.get("role")&&Vf(Zm.MUC_ROLE_CHANGES.MUTE)?this.updateNotifications(e.get("nick"),Zm.MUC_ROLE_CHANGES.MUTE):"moderator"===e.get("role")&&!["owner","admin"].includes(e.get("affiliation"))&&Vf(Zm.MUC_ROLE_CHANGES.OP)&&this.updateNotifications(e.get("nick"),Zm.MUC_ROLE_CHANGES.OP)}createInfoMessage(e,t,s){const n=yu.__,i={type:"info",is_ephemeral:!0},{info_messages:r,new_nickname_messages:o}=yu.labels.muc;if(Vf(e)&&"110"!==e&&("100"!==e||s)){if(e in r)i.message=r[e];else if(!s&&rp.includes(e)){const s=qe.getResourceFromJid(t.getAttribute("from")),n=Au()(`x[xmlns="${qe.NS.MUC_USER}"] item`,t).pop();i.actor=n?n.querySelector("actor")?.getAttribute("nick"):void 0,i.reason=n?n.querySelector("reason")?.textContent:void 0,i.message=this.getActionInfoMessage(e,s,i.actor)}else if(s&&e in o){let s;"210"===e?s=qe.getResourceFromJid(t.getAttribute("from")):"303"===e&&(s=Au()(`x[xmlns="${qe.NS.MUC_USER}"] item`,t).pop().getAttribute("nick")),this.save("nick",s),i.message=n(o[e],s)}if(i.message){if("201"===e&&this.messages.findWhere(i))return;this.createMessage(i)}}}createInfoMessages(e){const t=Au()(`x[xmlns="${qe.NS.MUC_USER}"] status`,e).map((e=>e.getAttribute("code")));t.includes("333")&&t.includes("307")&&t.splice(t.indexOf("307"),1);const s=t.includes("110");t.forEach((t=>this.createInfoMessage(t,e,s)))}setDisconnectionState(e,t,s,n=bf.DISCONNECTED){this.session.save({connection_status:n,disconnection_actor:s,disconnection_message:e,disconnection_reason:t})}onNicknameClash(e){const t=yu.__;if(bh.settings.get("muc_nickname_from_jid")){const t=e.getAttribute("from").split("/")[1];if(t===yu.exports.getDefaultMUCNickname())this.join(t+"-2");else{const e=t.lastIndexOf("-"),s=t.substring(e+1,t.length);this.join(t.substring(0,e+1)+String(Number(s)+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:bf.NICKNAME_REQUIRED})}onErrorPresence(e){const t=yu.__,s=yu.labels.muc,n=e.querySelector("error"),i=n.getAttribute("type"),r=Au()(`text[xmlns="${qe.NS.STANZAS}"]`,n).pop()?.textContent;if("modify"===i)this.handleModifyError(e);else if("auth"===i)if(Au()(`not-authorized[xmlns="${qe.NS.STANZAS}"]`,n).length&&(this.save({password_validation_message:r||t("Password incorrect")}),this.session.save({connection_status:bf.PASSWORD_REQUIRED})),n.querySelector("registration-required")){const e=t("You are not on the member list of this groupchat.");this.setDisconnectionState(e,r)}else n.querySelector("forbidden")&&this.setDisconnectionState(s.disconnect_messages[301],r,null,bf.BANNED);else if("cancel"===i)if(n.querySelector("not-allowed")){const e=t("You are not allowed to create new groupchats.");this.setDisconnectionState(e,r)}else if(n.querySelector("not-acceptable")){const e=t("Your nickname doesn't conform to this groupchat's policies.");this.setDisconnectionState(e,r)}else if(Au()(`gone[xmlns="${qe.NS.STANZAS}"]`,n).length){const e=Au()(`gone[xmlns="${qe.NS.STANZAS}"]`,n).pop()?.textContent.replace(/^xmpp:/,"").replace(/\?join$/,"");this.save({moved_jid:e,destroyed_reason:r}),this.session.save({connection_status:bf.DESTROYED})}else if(n.querySelector("conflict"))this.onNicknameClash(e);else if(n.querySelector("item-not-found")){const e=t("This groupchat does not (yet) exist.");this.setDisconnectionState(e,r)}else if(n.querySelector("service-unavailable")){const e=t("This groupchat has reached its maximum number of participants.");this.setDisconnectionState(e,r)}else if(n.querySelector("remote-server-not-found")){const e=t("Remote server not found");this.setDisconnectionState(e,r)}else if(n.querySelector("forbidden")){const e=t("You're not allowed to enter this groupchat");this.setDisconnectionState(e,r)}else{const e=t("An error happened while trying to enter this groupchat");this.setDisconnectionState(e,r)}}onPresenceFromMUCHost(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error");"wait"===t?.getAttribute("type")&&t?.querySelector("resource-constraint")&&this.session.get("connection_status")===bf.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")===bf.CONNECTING&&this.session.save("connection_status",bf.CONNECTED)):this.updateOccupantsOnPresence(e)}async onOwnPresence(e){if(await this.occupants.fetched,"unavailable"===e.getAttribute("type"))return void this.handleDisconnection(e);const t=this.session.get("connection_status");t!==bf.ENTERED&&t!==bf.CLOSING?(this.session.save("connection_status",bf.ENTERED,{silent:!0}),this.updateOccupantsOnPresence(e),this.session.trigger("change:connection_status",this.session,t)):this.updateOccupantsOnPresence(e);e.querySelector("status[code='201']")&&(this.get("auto_configure")?await this.autoConfigureChatRoom().then((()=>this.refreshDiscoInfo())):bh.settings.get("muc_instant_rooms")?await this.sendConfiguration().then((()=>this.refreshDiscoInfo())):this.session.save({view:Zm.MUC.VIEWS.CONFIG}))}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()),nm(this,{has_activity:!1,num_unread:0,num_unread_general:0})}};const cp=class extends wd{constructor(e,t){super(e,t),this.vcard=null}defaults(){return{hats:[],show:"offline",states:[]}}save(e,t,s){let n;return null==e?super.save(e,t,s):("object"==typeof e?(n=e,s=t):(n={})[e]=t,n.occupant_id&&(n.id=n.occupant_id),super.save(n,s))}getDisplayName(){return this.get("nick")||this.get("jid")}getAssignableRoles(){let e=bh.settings.get("modtools_disable_assign");return Array.isArray(e)||(e=e?lf:[]),"moderator"===this.get("role")?lf.filter((t=>!e.includes(t))):[]}getAssignableAffiliations(){let e=bh.settings.get("modtools_disable_assign");return Array.isArray(e)||(e=e?df:[]),"owner"===this.get("affiliation")?df.filter((t=>!e.includes(t))):"admin"===this.get("affiliation")?df.filter((t=>!["owner","admin",...e].includes(t))):[]}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")}},{u:lp}=Zm.env;class dp extends Gd{constructor(e,t){super(e,Object.assign({comparator:Uf},t)),this.chatroom=null}get model(){return cp}initialize(){this.on("change:nick",(()=>this.sort())),this.on("change:role",(()=>this.sort()))}static getAutoFetchedAffiliationLists(){const e=bh.settings.get("muc_fetch_members");return Array.isArray(e)?e:e?["member","admin","owner"]:[]}create(e,t){return e.id||e instanceof wd||(e.id=e.occupant_id||rm()),super.create(e,t)}async fetchMembers(){if(!["member","admin","owner"].includes(this.getOwnOccupant()?.get("affiliation")))return;const e=dp.getAutoFetchedAffiliationLists();if(0===e.length)return;const t=this.chatroom.get("jid"),s=await Promise.all(e.map((e=>Nf(e,t)))),n=s.reduce(((e,t)=>t instanceof Error?(kt.error(t),e):[...t,...e]),[]),i=e.filter((t=>!lp.isErrorObject(s[e.indexOf(t)]))),r=n.map((e=>e.jid)).filter((e=>void 0!==e)),o=n.map((e=>!e.jid&&e.nick||void 0)).filter((e=>void 0!==e)),a=this.filter((e=>i.includes(e.get("affiliation"))&&!o.includes(e.get("nick"))&&!r.includes(e.get("jid")))),c=yu.session.get("bare_jid");a.forEach((e=>{e.get("jid")!==c&&("offline"===e.get("show")?e.destroy():e.save("affiliation",null))})),n.forEach((e=>{const t=this.findOccupant(e);t?t.save(e):this.create(e)})),bh.trigger("membersFetched")}findOccupant(e){if(e.occupant_id)return this.get(e.occupant_id);const t=e.jid&&qe.getBareJidFromJid(e.jid);return t&&this.findWhere({jid:t})||e.nick&&this.findWhere({nick:e.nick})}getOwnOccupant(){const e=yu.session.get("bare_jid");return this.findOccupant({jid:e,occupant_id:this.chatroom.get("occupant_id")})}}const up=dp;const hp=class extends Gd{constructor(){super(),this.comparator="time",this.model=gg,this.fetched=null,this.chatbox=null}},mp={chats:{async create(e,t){if("string"==typeof e){if(t&&!t?.fullname){const s=await bh.contacts.get(e);t.fullname=s?.attributes?.fullname}const s=bh.chats.get(e,t,!0);return s||void kt.error("Could not open chatbox for JID: "+e)}return Array.isArray(e)?Promise.all(e.map((async s=>{const n=await bh.contacts.get(e);return t.fullname=n?.attributes?.fullname,bh.chats.get(s,t,!0).maybeShow()}))):(kt.error("chats.create: You need to provide at least one JID"),null)},async open(e,t,s){if("string"==typeof e){const n=await bh.chats.get(e,t,!0);return n?n.maybeShow(s):n}if(Array.isArray(e))return Promise.all(e.map((e=>bh.chats.get(e,t,!0).then((e=>e&&e.maybeShow(s))))).filter((e=>e)));const n="chats.open: You need to provide at least one JID";throw kt.error(n),new Error(n)},async get(e,t={},s=!1){async function n(e){let n=await bh.chatboxes.get(e);return!n&&s?n=await bh.chatboxes.create(e,t,yu.exports.ChatBox):(n=n&&n.get("type")===lt?n:null,n&&Object.keys(t).length&&n.save(t)),n}if(await bh.waitUntil("chatBoxesFetched"),void 0===e){return(await bh.chatboxes.get()).filter((e=>e.get("type")===lt))}return"string"==typeof e?n(e):Promise.all(e.map((e=>n(e))))}}};Zm.plugins.add("converse-chat",{dependencies:["converse-chatboxes","converse-disco"],initialize(){bh.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});const e={ChatBox:nf,Message:gg,Messages:hp,handleMessageStanza:Xg};Object.assign(yu,e),Object.assign(yu.exports,e),Object.assign(bh,mp),ih.registry.add(lt,nf),Qg(),addEventListener("hashchange",Qg),bh.listen.on("chatBoxesFetched",Kg),bh.listen.on("presencesInitialized",Yg),bh.listen.on("clearSession",Jg),bh.listen.on("connected",(()=>Zg())),bh.listen.on("reconnected",(()=>Zg()))}});const{Strophe:gp}=Zm.env;const fp=class extends wd{get idAttribute(){return"jid"}initialize(e,t){super.initialize(),this.waitUntilFeaturesDiscovered=vc(),this.dataforms=new Gd;let s=`converse.dataforms-${this.get("jid")}`;this.dataforms.browserStorage=Tu(s,"session"),this.features=new Gd,s=`converse.features-${this.get("jid")}`,this.features.browserStorage=Tu(s,"session"),this.listenTo(this.features,"add",this.onFeatureAdded),this.fields=new Gd,s=`converse.fields-${this.get("jid")}`,this.fields.browserStorage=Tu(s,"session"),this.listenTo(this.fields,"add",this.onFieldAdded),this.identities=new Gd,s=`converse.identities-${this.get("jid")}`,this.identities.browserStorage=Tu(s,"session"),this.fetchFeatures(t)}async getIdentity(e,t){return await this.waitUntilFeaturesDiscovered,this.identities.findWhere({category:e,type:t})}async getFeature(e){if(await this.waitUntilFeaturesDiscovered,this.features.findWhere({var:e}))return this}onFeatureAdded(e){e.entity=this,bh.trigger("serviceDiscovered",e)}onFieldAdded(e){e.entity=this,bh.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 bh.disco.info(this.get("jid"),null)}catch(e){return null===e?kt.error(`Timeout for disco#info query for ${this.get("jid")}`):kt.error(e),void this.waitUntilFeaturesDiscovered.resolve(this)}this.onInfo(e)}onDiscoItems(e){Au()(`query[xmlns="${gp.NS.DISCO_ITEMS}"] item`,e).forEach((e=>{if(e.getAttribute("node"))return;const t=e.getAttribute("jid"),s=yu.state.disco_entities.get(t);s?s.set({parent_jids:[this.get("jid")]}):bh.disco.entities.create({jid:t,parent_jids:[this.get("jid")],name:e.getAttribute("name")})}))}async queryForItems(){if(0===this.identities.where({category:"server"}).length)return;const e=await bh.disco.items(this.get("jid"));this.onDiscoItems(e)}async onInfo(e){Array.from(e.querySelectorAll("identity")).forEach((e=>{this.identities.create({category:e.getAttribute("category"),type:e.getAttribute("type"),name:e.getAttribute("name")})})),Au()(`x[type="result"][xmlns="${gp.NS.XFORM}"]`,e).forEach((e=>{const t={};Au()("field",e).forEach((e=>{t[e.getAttribute("var")]={value:e.querySelector("value")?.textContent,type:e.getAttribute("type")}})),this.dataforms.create(t)})),e.querySelector(`feature[var="${gp.NS.DISCO_ITEMS}"]`)&&await this.queryForItems(),Array.from(e.querySelectorAll("feature")).forEach((t=>{this.features.create({var:t.getAttribute("var"),from:e.getAttribute("from")})})),Au()('x[type="result"][xmlns="jabber:x:data"] field',e).forEach((t=>{this.fields.create({var:t.getAttribute("var"),value:t.querySelector("value")?.textContent,from:e.getAttribute("from")})})),this.waitUntilFeaturesDiscovered.resolve(this),this.trigger("featuresDiscovered")}};const pp=class extends Gd{constructor(){super(),this.model=fp}fetchEntities(){return new Promise(((e,t)=>{this.fetch({add:!0,success:e,error(e,s){kt.error(s),t(new Error("Could not fetch disco entities"))}})}))}},{Strophe:vp,$iq:yp}=Zm.env,bp={disco:{stream:{async getFeature(e,t){await bh.waitUntil("streamFeaturesAdded");const s=yu.state.stream_features;if(!e||!t)throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature");if(void 0!==s||bh.connection.connected())return s.findWhere({name:e,xmlns:t});{const s=`Tried to get feature ${e} ${t} but stream_features has been torn down`;kt.warn(s)}}},own:{identities:{add(e,t,s,n){const i=yu.state.disco;for(var r=0;ryu.state.disco._identities},features:{add(e){const t=yu.state.disco;for(let s=0;syu.state.disco._features}},info(e,t){const s={xmlns:vp.NS.DISCO_INFO};t&&(s.node=t);const n=yp({from:bh.connection.get().jid,to:e,type:"get"}).c("query",s);return bh.sendIQ(n)},items(e,t){const s={xmlns:vp.NS.DISCO_ITEMS};return t&&(s.node=t),bh.sendIQ(yp({from:bh.connection.get().jid,to:e,type:"get"}).c("query",s))},entities:{async get(e,t=!1){await bh.waitUntil("discoInitialized");const s=yu.state.disco_entities;if(!e)return s;if(void 0===s)return void kt.warn(`Tried to look up entity ${e} but disco_entities has been torn down`);const n=s.get(e);return n||!t?n:bh.disco.entities.create({jid:e})},items:e=>yu.state.disco_entities.filter((t=>t.get("parent_jids")?.includes(e))),create:(e,t)=>yu.state.disco_entities.create(e,t)},features:{async get(e,t){if(!t)throw new TypeError("You need to provide an entity JID");const s=await bh.disco.entities.get(t,!0);if(void 0===yu.state.disco_entities&&!bh.connection.connected())return kt.warn(`Tried to get feature ${e} for ${t} but _converse.disco_entities has been torn down`),[];const n=[s.getFeature(e),...bh.disco.entities.items(t).map((t=>t.getFeature(e)))];return(await Promise.all(n)).filter((e=>e instanceof Object))},async has(e,t){if(!t)throw new TypeError("You need to provide an entity JID");const s=await bh.disco.entities.get(t,!0);if(void 0===yu.state.disco_entities&&!bh.connection.connected())return kt.warn(`Tried to check if ${t} supports feature ${e}`),!1;if(await s.getFeature(e))return!0;const n=await Promise.all(bh.disco.entities.items(t).map((t=>t.getFeature(e))));return n.map((e=>e instanceof Object)).includes(!0)}},supports:(e,t)=>bh.disco.features.has(e,t),async refresh(e){if(!e)throw new TypeError("api.disco.refresh: You need to provide an entity JID");await bh.waitUntil("discoInitialized");let t=await bh.disco.entities.get(e);return t?(t.features.reset(),t.fields.reset(),t.identities.reset(),t.waitUntilFeaturesDiscovered.isPending||(t.waitUntilFeaturesDiscovered=vc()),t.queryInfo()):t=await bh.disco.entities.create({jid:e},{ignore_cache:!0}),t.waitUntilFeaturesDiscovered},refreshFeatures:e=>bh.refresh(e),async getFeatures(e){if(!e)throw new TypeError("api.disco.getFeatures: You need to provide an entity JID");await bh.waitUntil("discoInitialized");let t=await bh.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 bh.waitUntil("discoInitialized");let t=await bh.disco.entities.get(e,!0);return t=await t.waitUntilFeaturesDiscovered,t.fields},async getIdentity(e,t,s){const n=await bh.disco.entities.get(s,!0);if(void 0!==n||bh.connection.connected())return n.getIdentity(e,t);{const t=`Tried to look up category ${e} for ${s} but _converse.disco_entities has been torn down`;kt.warn(t)}}}},{Strophe:_p,$iq:wp}=Zm.env;async function Sp(){bh.disco.own.identities.add("client","web","Converse"),bh.disco.own.features.add(_p.NS.CHATSTATES),bh.disco.own.features.add(_p.NS.DISCO_INFO),bh.disco.own.features.add(_p.NS.ROSTERX),bh.disco.own.features.add(_p.NS.CARBONS),bh.trigger("addClientFeatures"),bh.connection.get().addHandler((e=>function(e){const t=e.getElementsByTagName("query")[0].getAttribute("node"),s={xmlns:_p.NS.DISCO_INFO};t&&(s.node=t);const n=wp({type:"result",id:e.getAttribute("id")}),i=e.getAttribute("from");return null!==i&&n.attrs({to:i}),n.c("query",s),yu.state.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),n.c("identity",t).up()})),yu.state.disco._features.forEach((e=>n.c("feature",{var:e}).up())),bh.send(n.tree()),!0}(e)),_p.NS.DISCO_INFO,"iq","get",null,null);const e=new yu.exports.DiscoEntities;Object.assign(yu,{disco_entities:e}),Object.assign(yu.state,{disco_entities:e});const t=`converse.disco-entities-${yu.session.get("bare_jid")}`;e.browserStorage=Tu(t,"session");const s=await e.fetchEntities(),n=yu.session.get("domain");0!==s.length&&s.get(n)||bh.disco.entities.create({jid:n},{ignore_cache:!0}),bh.trigger("discoInitialized")}function xp(){if(!yu.state.stream_features){const e=`converse.stream-features-${yu.session.get("bare_jid")}`;bh.promises.add("streamFeaturesAdded");const t=new Gd;t.browserStorage=Tu(e,"session"),Object.assign(yu,{stream_features:t}),Object.assign(yu.state,{stream_features:t})}}function Ap(){bh.trigger("streamFeaturesAdded")}function Ep(){xp(),Array.from(bh.connection.get().features.childNodes).forEach((e=>{yu.state.stream_features.create({name:e.nodeName,xmlns:e.getAttribute("xmlns")})})),Ap()}function Cp(){const{disco_entities:e}=yu.state;e?.forEach((e=>e.features.clearStore())),e?.forEach((e=>e.identities.clearStore())),e?.forEach((e=>e.dataforms.clearStore())),e?.forEach((e=>e.fields.clearStore())),e?.clearStore(),delete yu.state.disco_entities,Object.assign(yu,{disco_entities:void 0})}const{Strophe:$p}=Zm.env;Zm.plugins.add("converse-disco",{initialize(){Object.assign(bh,bp),bh.promises.add("discoInitialized"),bh.promises.add("streamFeaturesAdded");const e={DiscoEntity:fp,DiscoEntities:pp};Object.assign(yu,e),Object.assign(yu.exports,e);const t={_identities:[],_features:[]};Object.assign(yu,{disco:t}),Object.assign(yu.state,{disco:t}),bh.listen.on("userSessionInitialized",(async()=>{xp(),yu.state.connfeedback.get("connection_status")===$p.Status.ATTACHED&&(await new Promise(((e,t)=>yu.state.stream_features.fetch({success:e,error:t}))),Ap())})),bh.listen.on("beforeResourceBinding",Ep),bh.listen.on("reconnected",Sp),bh.listen.on("connected",Sp),bh.listen.on("beforeTearDown",(async()=>{bh.promises.add("streamFeaturesAdded");const{stream_features:e}=yu.state;e&&(await e.clearStore(),delete yu.state.stream_features,Object.assign(yu,{stream_features:void 0}))})),bh.listen.on("will-reconnect",Cp),bh.listen.on("clearSession",Cp)}});const jp={affiliations:{set:(e,t)=>(t=Array.isArray(t)?t:[t],Mf(e=Array.isArray(e)?e:[e],t)),get:(e,t)=>Nf(e,t)}};Zm.AFFILIATION_CHANGES=hf,Zm.AFFILIATION_CHANGES_LIST=mf,Zm.MUC_TRAFFIC_STATES=gf,Zm.MUC_TRAFFIC_STATES_LIST=ff,Zm.MUC_ROLE_CHANGES=pf,Zm.MUC_ROLE_CHANGES_LIST=vf,Zm.MUC={INFO_CODES:yf},Zm.MUC_NICK_CHANGED_CODE=wf,Zm.ROOM_FEATURES=_f,Zm.ROOMSTATUS=bf;const{Strophe:kp}=Zm.env;kp.addNamespace("MUC_ADMIN",kp.NS.MUC+"#admin"),kp.addNamespace("MUC_OWNER",kp.NS.MUC+"#owner"),kp.addNamespace("MUC_REGISTER","jabber:iq:register"),kp.addNamespace("MUC_ROOMCONF",kp.NS.MUC+"#roomconfig"),kp.addNamespace("MUC_USER",kp.NS.MUC+"#user"),kp.addNamespace("MUC_HATS","xmpp:prosody.im/protocol/hats:1"),kp.addNamespace("CONFINFO","urn:ietf:params:xml:ns:conference-info"),Zm.plugins.add("converse-muc",{dependencies:["converse-chatboxes","converse-chat","converse-disco"],initialize(){const{__:e,___:t}=yu;if(bh.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:[...Zm.MUC.INFO_CODES.visibility_changes,...Zm.MUC.INFO_CODES.self,...Zm.MUC.INFO_CODES.non_privacy_changes,...Zm.MUC.INFO_CODES.muc_logging_changes,...Zm.MUC.INFO_CODES.nickname_changes,...Zm.MUC.INFO_CODES.disconnected,...Zm.MUC.INFO_CODES.affiliation_changes,...Zm.MUC.INFO_CODES.join_leave_events,...Zm.MUC.INFO_CODES.role_changes],muc_show_logs_before_join:!1,muc_subscribe_to_rai:!1}),bh.promises.add(["roomsAutoJoined"]),bh.settings.get("locked_muc_domain")&&"string"!=typeof bh.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");Zm.env.muc_utils={computeAffiliationsDelta:Df},Object.assign(bh,ah),Object.assign(bh.rooms,jp);const s={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")}}};Object.assign(yu.labels,s),Object.assign(yu,s),Hf(),addEventListener("hashchange",Hf);const n={ChatRoom:ap,ChatRoomMessage:fg,ChatRoomMessages:pg,ChatRoomOccupant:cp,ChatRoomOccupants:up};Object.assign(yu,n);const i={MUC:ap,MUCMessage:fg,MUCMessages:pg,MUCOccupant:cp,MUCOccupants:up,getDefaultMUCNickname:Wf,isInfoVisible:Vf,onDirectMUCInvitation:Gf};Object.assign(yu.exports,i),Object.assign(yu,i),bh.chatboxes.registry.add(dt,ap),bh.settings.get("allow_muc_invitations")&&(bh.listen.on("connected",Ff),bh.listen.on("reconnected",Ff)),bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(`${kp.NS.CONFINFO}+notify`))),bh.listen.on("addClientFeatures",Jf),bh.listen.on("beforeResourceBinding",Xf),bh.listen.on("beforeTearDown",Kf),bh.listen.on("chatBoxesFetched",Qf),bh.listen.on("disconnected",Bf),bh.listen.on("statusInitialized",Yf),document.addEventListener("visibilitychange",qf)}}),Object.assign(om,{muc:{isChatRoom:function(e){return"chatroom"===e?.get("type")},setAffiliation:Rf}});const{Strophe:Tp,$iq:Ip,sizzle:Op}=Zm.env;const Np=class extends Gd{async initialize(){this.on("add",(e=>this.openBookmarkedRoom(e).then((e=>this.markRoomAsBookmarked(e))).catch((e=>kt.fatal(e))))),this.on("remove",this.markRoomAsUnbookmarked,this),this.on("remove",this.sendBookmarkStanza,this);const{session:e}=yu,t=`converse.room-bookmarks${e.get("bare_jid")}`;this.fetched_flag=t+"fetched",Iu(this,t),await this.fetchBookmarks(),bh.trigger("bookmarksInitialized",this)}static async checkBookmarksSupport(){const e=yu.session.get("bare_jid");if(!e)return!1;const t=await bh.disco.getIdentity("pubsub","pep",e);return bh.settings.get("allow_public_bookmarks")?!!t:bh.disco.supports(Tp.NS.PUBSUB+"#publish-options",e)}constructor(){super([],{comparator:e=>e.get("name").toLowerCase()}),this.model=hg}async openBookmarkedRoom(e){if(bh.settings.get("muc_respect_autojoin")&&e.get("autojoin")){(await bh.rooms.create(e.get("jid"),{nick:e.get("nick")})).maybeShow()}return e}fetchBookmarks(){const e=vc();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=Ip({type:"set",from:bh.connection.get().jid}).c("pubsub",{xmlns:Tp.NS.PUBSUB}).c("publish",{node:Tp.NS.BOOKMARKS}).c("item",{id:"current"}).c("storage",{xmlns:Tp.NS.BOOKMARKS});return this.forEach((t=>{e.c("conference",{name:t.get("name"),autojoin:t.get("autojoin"),jid:t.get("jid")});const s=t.get("nick");s?e.c("nick").t(s).up().up():e.up()})),e.up().up().up(),e.c("publish-options").c("x",{xmlns:Tp.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"),bh.sendIQ(e)}onBookmarkError(e,t){const{__:s}=yu;kt.error("Error while trying to add bookmark"),kt.error(e),bh.alert("error",s("Error"),[s("Sorry, something went wrong while trying to save your bookmark.")]),this.get(t.jid)?.destroy()}fetchBookmarksFromServer(e){const t=Ip({from:bh.connection.get().jid,type:"get"}).c("pubsub",{xmlns:Tp.NS.PUBSUB}).c("items",{node:Tp.NS.BOOKMARKS});bh.sendIQ(t).then((t=>this.onBookmarksReceived(e,t))).catch((t=>this.onBookmarksReceivedError(e,t)))}markRoomAsBookmarked(e){const{chatboxes:t}=yu.state,s=t.get(e.get("jid"));s?.save("bookmarked",!0)}markRoomAsUnbookmarked(e){const{chatboxes:t}=yu.state,s=t.get(e.get("jid"));s?.save("bookmarked",!1)}createBookmarksFromStanza(e){const t=Tp.NS.BOOKMARKS;Op(`items[node="${t}"] item storage[xmlns="${t}"] conference`,e).forEach((e=>{const t=e.getAttribute("jid"),s=this.get(t),n={jid:t,name:e.getAttribute("name")||t,autojoin:"true"===e.getAttribute("autojoin"),nick:e.querySelector("nick")?.textContent||""};s?s.save(n):this.create(n)}))}onBookmarksReceived(e,t){if(this.createBookmarksFromStanza(t),window.sessionStorage.setItem(this.fetched_flag,"true"),void 0!==e)return e.resolve()}onBookmarksReceivedError(e,t){const{__:s}=yu;if(null===t)kt.error("Error: timeout while fetching bookmarks"),bh.alert("error",s("Timeout Error"),[s("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,"true"),e.resolve()):(kt.error("Error while fetching bookmarks"),kt.error(t),e.reject(new Error("Could not fetch bookmarks")));kt.error("Error while fetching bookmarks"),kt.error(t)}}async getUnopenedBookmarks(){await bh.waitUntil("bookmarksInitialized"),await bh.waitUntil("chatBoxesFetched");const{chatboxes:e}=yu.state;return this.filter((t=>!e.get(t.get("jid"))))}},{Strophe:Mp,sizzle:Rp}=Zm.env;function Dp(e){return Rp(`event[xmlns="${Mp.NS.PUBSUB}#event"] items[node="${Mp.NS.BOOKMARKS}"]`,e).length&&bh.waitUntil("bookmarksInitialized").then((()=>yu.state.bookmarks.createBookmarksFromStanza(e))).catch((e=>kt.fatal(e))),!0}const{Strophe:zp}=Zm.env;zp.addNamespace("BOOKMARKS","storage:bookmarks"),Zm.plugins.add("converse-bookmarks",{dependencies:["converse-chatboxes","converse-muc"],overrides:{ChatRoom:{getDisplayName(){const{_converse:e,getDisplayName:t}=this.__super__,s=this.get("bookmarked")?e.bookmarks?.get(this.get("jid")):null;return s?.get("name")||t.apply(this,arguments)},getAndPersistNickname(e){var t;return e=e||(t=this.get("jid"),bh.settings.get("allow_bookmarks")?yu.state.bookmarks?.get(t)?.get("nick"):null),this.__super__.getAndPersistNickname.call(this,e)}}},initialize(){bh.settings.extend({allow_bookmarks:!0,allow_public_bookmarks:!1,muc_respect_autojoin:!0}),bh.promises.add("bookmarksInitialized");const e={Bookmark:hg,Bookmarks:Np};Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("addClientFeatures",(()=>{bh.settings.get("allow_bookmarks")&&bh.disco.own.features.add(zp.NS.BOOKMARKS+"+notify")})),bh.listen.on("clearSession",(()=>{const{state:e}=yu;e.bookmarks&&(e.bookmarks.clearStore({silent:!0}),window.sessionStorage.removeItem(e.bookmarks.fetched_flag),delete e.bookmarks)})),bh.listen.on("connected",(async()=>{const e=yu.session.get("bare_jid");bh.connection.get().addHandler(Dp,null,"message","headline",null,e),await Promise.all([bh.waitUntil("chatBoxesFetched")]),async function(){bh.settings.get("allow_bookmarks")&&await Np.checkBookmarksSupport()&&(yu.state.bookmarks=new yu.exports.Bookmarks,Object.assign(yu,{bookmarks:yu.state.bookmarks}))}()}))}});const Lp={tokens:{get(e){const t=bh.connection.get();return t?"rid"===e.toLowerCase()?t.rid||t._proto.rid:"sid"===e.toLowerCase()?t.sid||t._proto.sid:void 0:null}}},Pp="converse.bosh-session";let Up;async function Fp(e,t){if(t.success)return t;const{automatic:s}=t;return await async function(){const e=(await async function(){const e=Pp;Up||(Up=new wd({id:e}),Up.browserStorage=Tu(e,"session"),await new Promise((e=>Up.fetch({success:e,error:e}))));let t=yu.session.get("jid");if(t)Up.get("jid")!==t&&(t=await Pu(t),Up.clear({silent:!0}),Up.save({jid:t}));else{const e=Up.get("jid");e&&await Pu(e)}return Up}()).get("jid"),t=bh.connection.get();if(e&&t._proto instanceof qe.Bosh)try{return t.restore(e,t.onConnectStatusChanged),!0}catch(t){return!lu()&&kt.warn("Could not restore session for jid: "+e+" Error message: "+t.message),!1}return!1}()?{...t,success:!0}:bh.settings.get("authentication")!==Ze||s&&!bh.settings.get("auto_login")?t:(function(){if(!bh.settings.get("prebind_url"))throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url");const e=bh.connection.get(),t=new XMLHttpRequest;t.open("GET",bh.settings.get("prebind_url"),!0),t.setRequestHeader("Accept","application/json, text/javascript"),t.onload=async function(s){if(t.status>=200&&t.status<400){const s=JSON.parse(t.responseText),n=await Pu(s.jid);e.attach(n,s.sid,s.rid,e.onConnectStatusChanged,He)}else t.onerror(s)},t.onerror=function(){bh.connection.destroy(),bh.trigger("noResumeableBOSHSession",yu)},t.send()}(),{...t,success:!0})}function Bp(){void 0!==Up&&Up.save({jid:yu.session.get("jid")})}function qp(){if(void 0===Up){const e=Pp;sessionStorage.removeItem(e),sessionStorage.removeItem(`${e}-${e}`)}else Up.destroy(),Up=void 0}Zm.plugins.add("converse-bosh",{enabled:()=>!yu.api.settings.get("blacklisted_plugins").includes("converse-bosh"),initialize(){bh.settings.extend({bosh_service_url:void 0,prebind_url:null}),Object.assign(bh,Lp),bh.listen.on("clearSession",qp),bh.listen.on("setUserJID",Bp),bh.listen.on("login",Fp),bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(qe.NS.BOSH)))}});const{Strophe:Hp,$build:Gp}=Zm.env;function Wp(e,t){return e.sort(((e,s)=>e[t]>s[t]?-1:1))}async function Vp(){const e=yu.api.disco.own.identities.get(),t=yu.api.disco.own.features.get();e.length>1&&(Wp(e,"category"),Wp(e,"type"),Wp(e,"lang"));let s=e.reduce(((e,t)=>`${e}${t.category}/${t.type}/${t?.lang??""}/${t.name}<`),"");t.sort(),s=t.reduce(((e,t)=>`${e}${t}<`),s);return Dh(await crypto.subtle.digest("SHA-1",Rh(s)))}async function Qp(e){const t=await async function(){return Gp("c",{xmlns:Hp.NS.CAPS,hash:"sha-1",node:"https://conversejs.org",ver:await Vp()}).tree()}();return e.root().cnode(t).up(),e}const{Strophe:Jp}=Zm.env;Jp.addNamespace("CAPS","http://jabber.org/protocol/caps"),Zm.plugins.add("converse-caps",{dependencies:["converse-status"],initialize(){bh.listen.on("constructedPresence",((e,t)=>Qp(t))),bh.listen.on("constructedMUCPresence",((e,t)=>Qp(t)))}});const Kp=class extends Gd{constructor(e,t){super(e,Object.assign({comparator:"time_opened"},t))}onChatBoxesFetched(e){e.filter((e=>!e.isValid())).forEach((e=>e.destroy())),bh.trigger("chatBoxesFetched")}onConnected(e){if(e)return;Iu(this,`converse.chatboxes-${yu.session.get("bare_jid")}`),this.fetch({add:!0,success:e=>this.onChatBoxesFetched(e)})}createModel(e,t){if(!e.type)throw new Error("You need to specify a type of chatbox to be created");return new(bh.chatboxes.registry.get(e.type))(e,t)}},{Strophe:Yp}=Zm.env;Zm.plugins.add("converse-chatboxes",{dependencies:["converse-emoji","converse-roster","converse-vcard"],initialize(){let e;bh.promises.add(["chatBoxesFetched","chatBoxesInitialized","privateChatsAutoJoined"]),Object.assign(bh,{chatboxes:ih}),Object.assign(yu,{ChatBoxes:Kp}),Object.assign(yu.exports,{ChatBoxes:Kp}),bh.listen.on("addClientFeatures",(()=>{bh.disco.own.features.add(Yp.NS.MESSAGE_CORRECT),bh.disco.own.features.add(Yp.NS.HTTPUPLOAD),bh.disco.own.features.add(Yp.NS.OUTOFBAND)})),bh.listen.on("pluginsInitialized",(()=>{e=new yu.exports.ChatBoxes,Object.assign(yu,{chatboxes:e}),Object.assign(yu.state,{chatboxes:e}),bh.trigger("chatBoxesInitialized")})),bh.listen.on("presencesInitialized",(t=>e.onConnected(t))),bh.listen.on("reconnected",(()=>e.forEach((e=>e.onReconnection()))))}});const{Strophe:Xp,u:Zp}=Zm.env;function ev(e,t){const s=Au()(`command[xmlns="${Xp.NS.ADHOC}"]`,e).pop(),n=s.querySelector("note"),i={sessionid:s.getAttribute("sessionid"),instructions:Au()('x[type="form"][xmlns="jabber:x:data"] instructions',s).pop()?.textContent,fields:Au()('x[type="form"][xmlns="jabber:x:data"] field',s).map((e=>Zp.xForm2TemplateResult(e,s,{domain:t}))),actions:Array.from(s.querySelector("actions")?.children??[]).map((e=>e.nodeName.toLowerCase())),note:n?{text:n.textContent,type:n.getAttribute("type")}:null};return i}const{Strophe:tv,$iq:sv,u:nv,stx:iv}=Zm.env,rv={adhoc:{async getCommands(e){try{return t=await bh.disco.items(e,tv.NS.ADHOC),Au()(`query[xmlns="${Xp.NS.DISCO_ITEMS}"][node="${Xp.NS.ADHOC}"] item`,t).map(Zp.getAttributes)}catch(t){return null===t?kt.error(`Error: timeout while fetching ad-hoc commands for ${e}`):(kt.error(`Error while fetching ad-hoc commands for ${e}`),kt.error(t)),[]}var t},async fetchCommandForm(e,t){const s=sv({type:"set",to:e}).c("command",{xmlns:tv.NS.ADHOC,action:"execute",node:t});return ev(await bh.sendIQ(s),e)},async runCommand(e,t,s,n,i){const r=iv` ${["cancel","prev"].includes(n)?"":iv` ${i.reduce(((e,{name:t,value:s})=>e+`${s}`),"")} `} `,o=await bh.sendIQ(r,null,!1);if(null===o){kt.warn("A timeout occurred while trying to run an ad-hoc command");const{__:e}=yu;return{status:"error",note:e("A timeout occurred")}}nv.isErrorStanza(o)&&(kt.error("Error while trying to execute an ad-hoc command"),kt.error(o));const a=o.querySelector("command"),c=a?.getAttribute("status");return{status:c,..."executing"===c?ev(o):{},note:o.querySelector("note")?.textContent}}}},{Strophe:ov}=Zm.env;ov.addNamespace("ADHOC","http://jabber.org/protocol/commands"),Zm.plugins.add("converse-adhoc",{dependencies:["converse-disco"],initialize(){Object.assign(this._converse.api,rv)}});class av extends nf{defaults(){return{bookmarked:!1,hidden:["mobile","fullscreen"].includes(bh.settings.get("view_mode")),message_type:"headline",num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),time_sent:void 0,type:ut}}constructor(e,t){super(e,t),this.disable_mam=!0}async initialize(){super.initialize(),this.set({box_id:`box-${this.get("jid")}`}),this.initUI(),this.initMessages(),await this.fetchMessages(),bh.trigger("headlinesFeedInitialized",this)}}const cv={headlines:{async get(e,t={},s=!1){async function n(e){let n=await bh.chatboxes.get(e);if(!n&&s){const{HeadlinesFeed:s}=yu.exports;n=await bh.chatboxes.create(e,t,s)}else n=n&&n.get("type")===ut?n:null,n&&Object.keys(t).length&&n.save(t);return n}if(void 0===e){return(await bh.chatboxes.get()).filter((e=>e.get("type")===ut))}return"string"==typeof e?n(e):Promise.all(e.map((e=>n(e))))}}};Zm.plugins.add("converse-headlines",{dependencies:["converse-chat"],initialize(){const e={HeadlinesFeed:av};function t(){bh.connection.get()?.addHandler((e=>(async function(e){if(Ug(e)||Fg(e)){const t=e.getAttribute("from");if(await bh.waitUntil("rosterInitialized"),t.includes("@")&&!yu.state.roster.get(t)&&!bh.settings.get("allow_non_roster_messaging"))return;if(null===e.querySelector("body"))return;const s=await bh.chatboxes.create(t,{id:t,jid:t,type:ut,from:t},av),n=await Gg(e);await s.createMessage(n),bh.trigger("message",{chatbox:s,stanza:e,attrs:n})}}(e),!0)),null,"message")}Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("connected",t),bh.listen.on("reconnected",t),Object.assign(bh,cv),bh.chatboxes.registry.add(ut,av)}});class lv extends wd{defaults(){return{msgid:rm(),is_ephemeral:!1}}}const{NS:dv}=qe,uv=Zm.env.utils;function hv(e){e?.querySelectorAll("feature-not-implemented").length?kt.warn(`Message Archive Management (XEP-0313) not supported by ${e.getAttribute("from")}`):(kt.error(`Error while trying to set archiving preferences for ${e.getAttribute("from")}.`),kt.error(e))}function mv(e,t){const s=Au()(`prefs[xmlns="${dv.MAM}"]`,e).pop();if(s.getAttribute("default")!==bh.settings.get("message_archiving")){const e=de({type:"set"}).c("prefs",{xmlns:dv.MAM,default:bh.settings.get("message_archiving")});Array.from(s.children).forEach((t=>e.cnode(t).up())),bh.sendIQ(e).then((()=>t.save({preferences:{default:bh.settings.get("message_archiving")}}))).catch(yu.exports.onMAMError)}else t.save({preferences:{default:bh.settings.get("message_archiving")}})}function gv(e){const t=e.get("preferences")||{};e.get("var")===dv.MAM&&void 0!==bh.settings.get("message_archiving")&&t.default!==bh.settings.get("message_archiving")&&bh.sendIQ(de({type:"get"}).c("prefs",{xmlns:dv.MAM})).then((t=>yu.exports.onMAMPreferences(t,e))).catch(yu.exports.onMAMError)}function fv(e){bh.settings.get("muc_show_logs_before_join")&&e.features.get("mam_enabled")&&!e.get("prejoin_mam_fetched")&&(yv(e),e.save({prejoin_mam_fetched:!0}))}async function pv(e,t,s,n,i){await bh.emojis.initialize();const r=e.get("type")===dt,o=await Promise.all(t.messages.map((t=>r?kf(t,e):Gg(t))));t.messages=o;const a={query:s,chatbox:e,messages:o};if(await bh.trigger("MAMResult",a,{synchronous:!0}),o.forEach((t=>e.queueMessage(t))),t.error){const s=t.error.retry_event_id=uv.getUniqueId();bh.listen.once(s,(()=>vv(e,n,i))),e.createMessageFromError(t.error)}}async function vv(e,t={},s=null){if(e.disable_mam)return;const n=e.get("type")===dt,i=yu.session.get("bare_jid"),r=n?e.get("jid"):i;if(!await bh.disco.supports(dv.MAM,r))return;const o=bh.settings.get("archived_messages_page_size"),a=Object.assign({groupchat:n,max:o,with:e.get("jid")},t),c=await bh.archive.query(a);if(await pv(e,c,a,t,s),c.rsm&&!c.complete){if(s)return"forwards"===s?t=c.rsm.next(o,t.before).query:"backwards"===s&&(t=c.rsm.previous(o,t.after).query),vv(e,t,s);!async function(e,t,s){if(""==t.before&&(0===e.messages.length||!t.start))return;if(t.before&&!t.start)return;if(null==t.before)return;const n=await Promise.all(s.messages),{rsm:i}=s,r=`stanza_id ${e.get("jid")}`,o=n.find((e=>e[r]===i.result.first)),a=new Date(o.time),c={template_hook:"getMessageTemplate",time:new Date(a.getTime()-1).toISOString(),before:i.result.first,start:t.start};e.messages.add(new lv(c))}(e,t,c)}}function yv(e){if(e.disable_mam)return;const t=e.getMostRecentMessage();if(t&&!bh.settings.get("clear_messages_on_reconnection")){if(bh.settings.get("mam_request_all_pages")){const s=t.get(`stanza_id ${e.get("jid")}`);vv(e,s?{after:s}:{start:t.get("time")},"forwards")}else vv(e,{before:"",start:t.get("time")})}else vv(e,{before:""})}const{Strophe:bv,$build:_v}=Zm.env;bv.addNamespace("RSM","http://jabber.org/protocol/rsm");const wv=["after","before","index","max"],Sv=e=>Number(e),xv=e=>e.toString(),Av={after:xv,before:xv,count:Sv,first:xv,index:Sv,last:xv,max:Sv},Ev=e=>void 0===e,Cv=Object.keys(Av);class $v{static getQueryParameters(e={}){return _d(e,wv)}static parseXMLResult(e){const t={};for(var s=0;sEv(this.query[t])?e:e.c(t).t((this.query[t]||"").toString()).up()),e).tree()}next(e,t){const s=Object.assign({},this.query,{after:this.result.last,before:t,max:e});return new $v(s)}previous(e,t){const s=Object.assign({},this.query,{after:t,before:this.result.first,max:e});return new $v(s)}}const{NS:jv}=qe,kv=Zm.env.utils,Tv={archive:{async query(e){if(!bh.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 s=yu.session.get("bare_jid"),n=t.to||s;if(!await bh.disco.supports(jv.MAM,n))return kt.warn(`Did not fetch MAM archive for ${n} because it doesn't support ${jv.MAM}`),{messages:[]};const i=kv.getUniqueId(),r=de(t).c("query",{xmlns:jv.MAM,queryid:i});if(e){r.c("x",{xmlns:jv.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(jv.MAM).up().up(),e.with&&!e.groupchat&&r.c("field",{var:"with"}).c("value").t(e.with).up().up(),["start","end"].forEach((t=>{if(e[t]){const s=b()(e[t]);if(!s.isValid())throw new TypeError(`archive.query: invalid date provided for: ${t}`);r.c("field",{var:t}).c("value").t(s.toISOString()).up().up()}})),r.up();const t=new $v(e);Object.keys(t.query).length&&r.cnode(t.toXML())}const o=bh.connection.get(),a=[],c=o.addHandler((t=>{const n=Au()(`message > result[xmlns="${jv.MAM}"]`,t).pop();if(void 0===n||n.getAttribute("queryid")!==i)return!0;const r=t.getAttribute("from")||s;if(e.groupchat){if(r!==e.with)return kt.warn(`Ignoring alleged groupchat MAM message from ${t.getAttribute("from")}`),!0}else if(r!==s)return kt.warn(`Ignoring alleged MAM message from ${t.getAttribute("from")}`),!0;return a.push(t),!0}),jv.MAM);let l;const d=bh.settings.get("message_archiving_timeout"),u=await bh.sendIQ(r,d,!1);if(null===u){const{__:e}=yu,t=e("Timeout while trying to fetch archived messages.");return kt.error(t),l=new Zu(t),{messages:a,error:l}}if(kv.isErrorStanza(u)){const{__:e}=yu,t=e("An error occurred while querying for archived messages.");return kt.error(t),kt.error(u),l=new Error(t),{messages:a,error:l}}let h;o.deleteHandler(c);const m=u&&Au()(`fin[xmlns="${jv.MAM}"]`,u).pop(),g="true"===m?.getAttribute("complete"),f=Au()(`set[xmlns="${jv.RSM}"]`,m).pop();return f&&(h=new $v({...e,xml:f})),{messages:a,rsm:h,complete:g}}}},{NS:Iv}=qe;Zm.plugins.add("converse-mam",{dependencies:["converse-disco","converse-muc"],initialize(){bh.settings.extend({archived_messages_page_size:"50",mam_request_all_pages:!0,message_archiving:void 0,message_archiving_timeout:2e4}),Object.assign(bh,Tv);const e={onMAMError:hv,onMAMPreferences:mv,handleMAMResult:pv,MAMPlaceholderMessage:lv};Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(Iv.MAM))),bh.listen.on("serviceDiscovered",gv),bh.listen.on("chatRoomViewInitialized",(e=>{bh.settings.get("muc_show_logs_before_join")&&(fv(e.model),e.model.features.on("change:mam_enabled",(()=>fv(e.model))))})),bh.listen.on("enteredNewRoom",(e=>e.features.get("mam_enabled")&&yv(e))),bh.listen.on("chatReconnected",(e=>{e.get("type")===lt&&yv(e)})),bh.listen.on("afterMessagesFetched",(e=>{e.get("type")===lt&&yv(e)}))}}),Object.assign(om,{mam:{fetchArchivedMessages:vv}});const{Strophe:Ov,$iq:Nv}=Zm.env;let Mv,Rv;function Dv(){document.hidden||bh.ping(null,5e3)}function zv(e){Mv=new Date;const t=e.getAttribute("from"),s=e.getAttribute("id"),n=Nv({type:"result",to:t,id:s});return bh.sendIQ(n),!0}function Lv(){!function(){const e=bh.connection.get();e.disco&&bh.disco.own.features.add(Ov.NS.PING),e.addHandler(zv,Ov.NS.PING,"iq","get")}(),bh.connection.get()?.addHandler((()=>{if(bh.settings.get("ping_interval")>0)return Mv=new Date,!0})),clearInterval(Rv),Rv=setInterval(Uv,1e3)}function Pv(){clearInterval(Rv)}function Uv(){if(lu()||!bh.connection.authenticated())return;const e=bh.settings.get("ping_interval");if(e>0){const t=new Date;Mv=Mv??t,(t.valueOf()-Mv.valueOf())/1e3>e&&bh.ping()}}const{Strophe:Fv,$iq:Bv,u:qv}=Zm.env,Hv={async ping(e,t){if(!bh.connection.authenticated())return kt.warn("Not pinging when we know we're not authenticated"),null;var s;s=new Date,Mv=s;const n=yu.session.get("bare_jid");e=e||Fv.getDomainFromJid(n);const i=Bv({type:"get",to:e,id:qv.getUniqueId("ping")}).c("ping",{xmlns:Fv.NS.PING}),r=await bh.sendIQ(i,t||1e4,!1);return null===r?(kt.warn(`Timeout while pinging ${e}`),e===Fv.getDomainFromJid(n)&&bh.connection.reconnect(),!1):!qv.isErrorStanza(r)||(kt.error(`Error while pinging ${e}`),kt.error(r),!1)}},{Strophe:Gv}=Zm.env;Gv.addNamespace("PING","urn:xmpp:ping"),Zm.plugins.add("converse-ping",{initialize(){bh.settings.extend({ping_interval:60}),Object.assign(bh,Hv),bh.listen.on("connected",Lv),bh.listen.on("reconnected",Lv),bh.listen.on("disconnected",Pv),document.addEventListener("visibilitychange",Dv)}});const{Strophe:Wv,$iq:Vv}=Zm.env;Wv.addNamespace("PUBSUB_ERROR",Wv.NS.PUBSUB+"#errors"),Zm.plugins.add("converse-pubsub",{dependencies:["converse-disco"],initialize(){Object.assign(yu.api,{pubsub:{async publish(e,t,s,n,i=!0){const r=yu.session.get("bare_jid"),o=Vv({from:r,type:"set",to:e}).c("pubsub",{xmlns:Wv.NS.PUBSUB}).c("publish",{node:t}).cnode(s.tree()).up().up();n&&(e=e||r,await bh.disco.supports(Wv.NS.PUBSUB+"#publish-options",e)?(o.c("publish-options").c("x",{xmlns:Wv.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(`${Wv.NS.PUBSUB}#publish-options`).up().up(),Object.keys(n).forEach((e=>o.c("field",{var:e}).c("value").t(n[e]).up().up()))):kt.warn(`_converse.api.publish: ${e} does not support #publish-options, so we didn't set them even though they were provided.`));try{await bh.sendIQ(o)}catch(e){if(!(e instanceof Element&&i&&e.querySelector(`precondition-not-met[xmlns="${Wv.NS.PUBSUB_ERROR}"]`)))throw e;{const e=o.tree();e.querySelector("publish-options").outerHTML="",kt.warn(`PubSub: Republishing without publish options. ${e.outerHTML}`),await bh.sendIQ(e)}}}}})}});const Qv={status:{get:async()=>(await bh.waitUntil("statusInitialized"),yu.state.xmppstatus.get("status")),async set(e,t){const s={status:e};if(!Object.keys(We).includes(e))throw new Error("Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1");"string"==typeof t&&(s.status_message=t),await bh.waitUntil("statusInitialized"),yu.state.xmppstatus.save(s)},message:{get:async()=>(await bh.waitUntil("statusInitialized"),yu.state.xmppstatus.get("status_message")),async set(e){await bh.waitUntil("statusInitialized"),yu.state.xmppstatus.save({status_message:e})}}}};class Jv extends wd{initialize(){super.initialize(),this.set({text:"",type:"items",state:"online"})}}const{$pres:Kv}=Zm.env;function Yv(e){const t=yu.state.roster,s=t?.get(e.get("jid"));s?.save({num_unread:e.get("num_unread")})}let Xv;function Zv(){if(Xv){bh.connection.get().deleteHandler(Xv),Xv=null}}async function ey(){await(yu.state.presences?.clearStore())}async function ty(){if(await ey(),hu(yu)){const e=yu.state.roster;e&&(e.data?.destroy(),await e.clearStore(),delete yu.state.roster,Object.assign(yu,{roster:void 0}))}}function sy(e){e?bh.trigger("rosterReadyAfterReconnection"):function(){const e=new yu.exports.RosterContacts;Object.assign(yu,{roster:e}),Object.assign(yu.state,{roster:e});const t=yu.session.get("bare_jid");let s=`converse.contacts-${t}`;Iu(e,s);const n=new Jv;Object.assign(yu,{roster_filter:n}),Object.assign(yu.state,{roster_filter:n}),n.id=`_converse.rosterfilter-${t}`,Iu(n,n.id),n.fetch(),s=`converse-roster-model-${t}`,e.data=new wd,e.data.id=s,Iu(e.data,s),e.data.fetch(),bh.trigger("rosterInitialized")}();yu.state.roster.onConnected(),function(){Zv();const e=bh.connection.get();Xv=e.addHandler((e=>(yu.state.roster.presenceHandler(e),!0)),null,"presence",null)}(),async function(e=!1){const t=bh.connection.get();e&&(t.send_initial_presence=!0);const s=yu.state.roster;try{await s.fetchRosterContacts(),bh.trigger("rosterContactsFetched")}catch(e){kt.error(e)}finally{t.send_initial_presence&&bh.user.presence.send()}}(!bh.connection.get().restored)}async function ny(e){if(e)!bh.connection.get().hasResumed()&&await ey();else{const e=new yu.exports.Presences;Object.assign(yu,{presences:e}),Object.assign(yu.state,{presences:e});Iu(e,`converse.presences-${yu.session.get("bare_jid")}`,"session"),e.fetch()}bh.trigger("presencesInitialized",e)}function iy(){const{chatboxes:e}=yu.state;e.on("change:num_unread",Yv),e.on("add",(e=>{e.get("type")===lt&&e.setRosterContact(e.get("jid"))}))}function ry(){yu.state.roster.on("add",(e=>{const t=yu.state.chatboxes.findWhere({jid:e.get("jid")});t?.setRosterContact(e.get("jid"))}))}function oy(e,t){const s=Kv({to:e,type:"unsubscribed"});t&&""!==t&&s.c("status").t(t),bh.send(s)}const{Strophe:ay,$iq:cy,$pres:ly}=Zm.env;const dy=class extends wd{get idAttribute(){return"jid"}defaults(){return{chat_state:void 0,groups:[],image:yu.DEFAULT_IMAGE,image_type:yu.DEFAULT_IMAGE_TYPE,num_unread:0,status:void 0}}async initialize(e){super.initialize(),this.initialized=vc(),this.setPresence();const{jid:t}=e;this.set({...e,jid:ay.getBareJidFromJid(t).toLowerCase(),user_id:ay.getNodeFromJid(t)}),this.listenTo(this.presence,"change:show",(()=>bh.trigger("contactPresenceChanged",this))),this.listenTo(this.presence,"change:show",(()=>this.trigger("presenceChanged"))),await bh.trigger("rosterContactInitialized",this,{Synchronous:!0}),this.initialized.resolve()}setPresence(){const e=this.get("jid"),{presences:t}=yu.state;this.presence=t.findWhere(e)||t.create({jid:e})}openChat(){bh.chats.open(this.get("jid"),this.attributes,!0)}getFilterCriteria(){const e=this.get("nickname"),t=this.get("jid");let s=this.getDisplayName();return s=s.includes(t)?s:s.concat(` ${t}`),s=s.includes(e)?s:s.concat(` ${e}`),s.toLowerCase()}getDisplayName(){return this.get("nickname")?this.get("nickname"):this.get("jid")}getFullname(){return this.get("jid")}subscribe(e){return bh.user.presence.send("subscribe",this.get("jid"),e),this.save("ask","subscribe"),this}ackSubscribe(){bh.send(ly({type:"subscribe",to:this.get("jid")}))}ackUnsubscribe(){bh.send(ly({type:"unsubscribe",to:this.get("jid")})),this.removeFromRoster(),this.destroy()}unauthorize(e){return oy(this.get("jid"),e),this}authorize(e){const t=ly({to:this.get("jid"),type:"subscribed"});return e&&""!==e&&t.c("status").t(e),bh.send(t),this}removeFromRoster(){const e=cy({type:"set"}).c("query",{xmlns:ay.NS.ROSTER}).c("item",{jid:this.get("jid"),subscription:"remove"});return bh.sendIQ(e)}},{Strophe:uy,$iq:hy,sizzle:my,u:gy}=Zm.env;const fy=class extends Gd{constructor(){super(),this.model=dy,this.data=null}initialize(){const e=`roster.state-${yu.session.get("bare_jid")}-${this.get("jid")}`;this.state=new wd({id:e,collapsed_groups:[]}),Iu(this.state,e),this.state.fetch()}onConnected(){this.registerRosterHandler(),this.registerRosterXHandler()}registerRosterHandler(){bh.connection.get().addHandler((e=>(yu.state.roster.onRosterPush(e),!0)),uy.NS.ROSTER,"iq","set")}registerRosterXHandler(){let e=0;bh.connection.get().addHandler((t=>(setTimeout((()=>{const{roster:e}=yu.state;bh.connection.get().flush(),e.subscribeToSuggestedItems(t)}),e),e+=250*t.querySelectorAll("item").length,!0)),uy.NS.ROSTERX,"message",null)}async fetchRosterContacts(){const e=await new Promise(((e,t)=>{this.fetch({add:!0,silent:!0,success:e,error:(e,s)=>t(s)})}));if(gy.isErrorObject(e)&&(kt.error(e),yu.session.save("roster_cached",!1),this.data.save("version",void 0)),!yu.session.get("roster_cached"))return bh.connection.get().send_initial_presence=!0,yu.state.roster.fetchFromServer();bh.trigger("cachedRoster",e)}subscribeToSuggestedItems(e){const{xmppstatus:t}=yu.state;return Array.from(e.querySelectorAll("item")).forEach((e=>{"add"===e.getAttribute("action")&&yu.state.roster.addAndSubscribe(e.getAttribute("jid"),t.getNickname()||t.getFullname())})),!0}isSelf(e){return gy.isSameBareJID(e,bh.connection.get().jid)}async addAndSubscribe(e,t,s,n,i){const r=await this.addContactToRoster(e,t,s,i);r instanceof yu.exports.RosterContact&&r.subscribe(n)}sendContactAddIQ(e,t,s){t=t||null;const n=hy({type:"set"}).c("query",{xmlns:uy.NS.ROSTER}).c("item",{jid:e,name:t});return s.forEach((e=>n.c("group").t(e).up())),bh.sendIQ(n)}async addContactToRoster(e,t,s,n){await bh.waitUntil("rosterContactsFetched"),s=s||[];try{await this.sendContactAddIQ(e,t,s)}catch(s){const{__:n}=yu;return kt.error(s),alert(n("Sorry, there was an error while trying to add %1$s as a contact.",t||e)),s}return this.create(Object.assign({ask:void 0,nickname:t,groups:s,jid:e,requesting:!1,subscription:"none"},n),{sort:!1})}async subscribeBack(e,t){const s=this.get(e),{RosterContact:n}=yu.exports;if(s instanceof n)s.authorize().subscribe();else{const s=my(`nick[xmlns="${uy.NS.NICK}"]`,t).pop()?.textContent||null,i=await this.addContactToRoster(e,s,[],{subscription:"from"});i instanceof n&&i.authorize().subscribe()}}onRosterPush(e){const t=e.getAttribute("id"),s=e.getAttribute("from"),n=yu.session.get("bare_jid");if(s&&s!==n)return void kt.warn(`Ignoring roster illegitimate roster push message from ${e.getAttribute("from")}`);bh.send(hy({type:"result",id:t,from:bh.connection.get().jid}));const i=my(`query[xmlns="${uy.NS.ROSTER}"]`,e).pop();this.data.save("version",i.getAttribute("ver"));const r=my("item",i);if(r.length>1)throw kt.error(e),new Error('Roster push query may not contain more than one "item" element.');if(0===r.length)return kt.warn(e),void kt.warn('Received a roster push stanza without an "item" element.');this.updateContact(r.pop()),bh.trigger("rosterPush",e)}rosterVersioningSupported(){return bh.disco.stream.getFeature("ver","urn:xmpp:features:rosterver")&&this.data.get("version")}async fetchFromServer(){const e=hy({type:"get",id:gy.getUniqueId("roster")}).c("query",{xmlns:uy.NS.ROSTER});this.rosterVersioningSupported()&&e.attrs({ver:this.data.get("version")});const t=await bh.sendIQ(e,null,!1);if("result"===t.getAttribute("type")){const e=my(`query[xmlns="${uy.NS.ROSTER}"]`,t).pop();if(e){const t=my("item",e);if(!this.data.get("version")&&this.models.length){const e=t.map((e=>e.getAttribute("jid")));this.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(!gy.isServiceUnavailableError(t))return kt.error(t),void kt.error("Error while trying to fetch roster from the server");yu.session.save("roster_cached",!0),bh.trigger("roster",t)}updateContact(e){const t=e.getAttribute("jid"),s=this.get(t),n=e.getAttribute("subscription");if("remove"===n)return s?.destroy();const i=e.getAttribute("ask"),r=e.getAttribute("name"),o=[...new Set(my("group",e).map((e=>e.textContent)))];s?s.save({subscription:n,ask:i,nickname:r,groups:o,requesting:null}):this.create({nickname:r,ask:i,groups:o,jid:t,subscription:n},{sort:!1})}createRequestingContact(e){const t={jid:uy.getBareJidFromJid(e.getAttribute("from")),subscription:"none",ask:null,requesting:!0,nickname:my(`nick[xmlns="${uy.NS.NICK}"]`,e).pop()?.textContent||null};bh.trigger("contactRequest",this.create(t))}handleIncomingSubscription(e){const t=e.getAttribute("from"),s=uy.getBareJidFromJid(t),n=this.get(s);if(!bh.settings.get("allow_contact_requests")){const{__:e}=yu;oy(t,e("This client does not allow presence subscriptions"))}bh.settings.get("auto_subscribe")?n&&"to"===n.get("subscription")?n.authorize():this.subscribeBack(s,e):n?("none"!==n.get("subscription")||"subscribe"===n.get("ask"))&&n.authorize():this.createRequestingContact(e)}handleOwnPresence(e){const t=e.getAttribute("from"),s=uy.getResourceFromJid(t),n=e.getAttribute("type"),{xmppstatus:i}=yu.state;if(bh.connection.get().jid!==t&&"unavailable"!==n&&(!0===bh.settings.get("synchronize_availability")||bh.settings.get("synchronize_availability")===s)){const t=e.querySelector("show")?.textContent||"online";i.save({status:t},{silent:!0});const s=e.querySelector("status")?.textContent;s&&i.save({status_message:s})}yu.session.get("jid")===t&&"unavailable"===n&&bh.user.presence.send()}presenceHandler(e){const t=e.getAttribute("type");if("error"===t)return!0;const s=e.getAttribute("from"),n=uy.getBareJidFromJid(s);if(this.isSelf(n))return this.handleOwnPresence(e);if(my(`query[xmlns="${uy.NS.MUC}"]`,e).length)return;const i=this.get(n);if(i){const t=e.querySelector("status")?.textContent;i.get("status")!==t&&i.save({status:t})}if("subscribed"===t&&i)i.ackSubscribe();else if("unsubscribed"===t&&i)i.ackUnsubscribe();else{if("unsubscribe"===t)return;if("subscribe"===t)this.handleIncomingSubscription(e);else if("unavailable"===t&&i){const e=uy.getResourceFromJid(s);i.presence.removeResource(e)}else i&&i.presence.addResource(e)}}};const py=class extends wd{get idAttribute(){return"name"}};const vy=class extends Gd{constructor(){super(),this.model=py}},{Strophe:yy,dayjs:by,sizzle:_y}=Zm.env;const wy=class extends wd{get idAttribute(){return"jid"}defaults(){return{show:"offline"}}initialize(){super.initialize(),this.resources=new vy;const e=`converse.identities-${this.get("jid")}`;Iu(this.resources,e,"session"),this.listenTo(this.resources,"update",this.onResourcesChanged),this.listenTo(this.resources,"change",this.onResourcesChanged)}onResourcesChanged(){const e=this.getHighestPriorityResource(),t=e?.attributes?.show||"offline";this.get("show")!==t&&this.save({show:t})}getHighestPriorityResource(){return this.resources.sortBy((e=>`${e.get("priority")}-${e.get("timestamp")}`)).reverse()[0]}addResource(e){const t=e.getAttribute("from"),s=yy.getResourceFromJid(t),n=_y(`delay[xmlns="${yy.NS.DELAY}"]`,e).pop(),i=e.querySelector("priority")?.textContent,r=this.resources.get(s),o={name:s,priority:Number.isNaN(parseInt(i,10))?0:parseInt(i,10),show:e.querySelector("show")?.textContent??"online",timestamp:n?by(n.getAttribute("stamp")).toISOString():(new Date).toISOString()};r?r.save(o):this.resources.create(o)}removeResource(e){const t=this.resources.get(e);t?.destroy()}};const Sy=class extends Gd{constructor(){super(),this.model=wy}},{Strophe:xy,$build:Ay}=Zm.env;function Ey(e){bh.trigger("statusInitialized",e)}function Cy(e){if(e=void 0!==yu.state.xmppstatus&&e)Ey(e);else{const t=`converse.xmppstatus-${yu.session.get("bare_jid")}`;yu.state.xmppstatus=new yu.exports.XMPPStatus({id:t}),Object.assign(yu,{xmppstatus:yu.state.xmppstatus}),Iu(yu.state.xmppstatus,t,"session"),yu.state.xmppstatus.fetch({success:()=>Ey(e),error:()=>Ey(e),silent:!0})}}let $y,jy=0,ky=!1,Ty=!1,Iy=!1;function Oy(){jy>0&&(jy=0),bh.connection.get()?.authenticated&&(Iy&&My(rt),ky&&(ky=!1,bh.user.presence.send()),!0===Ty&&(Ty=!1,yu.state.xmppstatus.set("status",bh.settings.get("default_state"))))}function Ny(){if(!bh.connection.get()?.authenticated)return;const{xmppstatus:e}=yu.state,t=e.get("status");jy++,bh.settings.get("csi_waiting_time")>0&&jy>bh.settings.get("csi_waiting_time")&&!Iy&&My(it),bh.settings.get("idle_presence_timeout")>0&&jy>bh.settings.get("idle_presence_timeout")&&!ky&&(ky=!0,bh.user.presence.send()),bh.settings.get("auto_away")>0&&jy>bh.settings.get("auto_away")&&"away"!==t&&"xa"!==t&&"dnd"!==t?(Ty=!0,e.set("status","away")):bh.settings.get("auto_xa")>0&&jy>bh.settings.get("auto_xa")&&"xa"!==t&&"dnd"!==t&&(Ty=!0,e.set("status","xa"))}function My(e){bh.send(Ay(e,{xmlns:xy.NS.CSI})),Iy=e===it}function Ry(){if(bh.settings.get("auto_away")<1&&bh.settings.get("auto_xa")<1&&bh.settings.get("csi_waiting_time")<1&&bh.settings.get("idle_presence_timeout")<1)return;jy=0,Ty=!1;const{onUserActivity:e,onEverySecond:t}=yu.exports;window.addEventListener("click",e),window.addEventListener("focus",e),window.addEventListener("keypress",e),window.addEventListener("mousemove",e),window.addEventListener(du(),e,{once:!0,passive:!0}),$y=setInterval(t,1e3)}function Dy(){const{onUserActivity:e}=yu.exports;window.removeEventListener("click",e),window.removeEventListener("focus",e),window.removeEventListener("keypress",e),window.removeEventListener("mousemove",e),window.removeEventListener(du(),e),$y&&(clearInterval($y),$y=null)}function zy(e,t){const{xmppstatus:s}=yu.state,n=s.get("status");["away","chat","dnd","xa"].includes(n)&&t.c("show").t(n).up();const i=s.get("status_message");return i&&t.c("status").t(i).up(),t}const{Strophe:Ly,$pres:Py}=Zm.env;class Uy extends wd{constructor(e,t){super(e,t),this.vcard=null}defaults(){return{status:bh.settings.get("default_state")}}initialize(){this.on("change",(e=>{e.changed instanceof Object&&("status"in e.changed||"status_message"in e.changed)&&bh.user.presence.send(this.get("status"),null,this.get("status_message"))}))}getDisplayName(){return this.getFullname()||this.getNickname()||yu.session.get("bare_jid")}getNickname(){return bh.settings.get("nickname")}getFullname(){return""}async constructPresence(e,t=null,s){let n;if(e="string"==typeof e?e:this.get("status")||bh.settings.get("default_state"),s="string"==typeof s?s:this.get("status_message"),"subscribe"===e){n=Py({to:t,type:e});const{xmppstatus:s}=yu.state,i=s.getNickname();i&&n.c("nick",{xmlns:Ly.NS.NICK}).t(i).up()}else n="unavailable"===e||"probe"===e||"error"===e||"unsubscribe"===e||"unsubscribed"===e||"subscribed"===e?Py({to:t,type:e}):"offline"===e?Py({to:t,type:"unavailable"}):"online"===e?Py({to:t}):Py({to:t}).c("show").t(e).up();s&&n.c("status").t(s).up();const i=bh.settings.get("priority");if(n.c("priority").t(Number.isNaN(Number(i))?0:i).up(),ky){const e=new Date;e.setSeconds(e.getSeconds()-jy),n.c("idle",{xmlns:Ly.NS.IDLE,since:e.toISOString()})}return n=await bh.hook("constructedPresence",null,n),n}}const{Strophe:Fy}=Zm.env;Fy.addNamespace("IDLE","urn:xmpp:idle:1"),Zm.plugins.add("converse-status",{initialize(){bh.settings.extend({auto_away:0,auto_xa:0,csi_waiting_time:0,default_state:"online",idle_presence_timeout:300,priority:0}),bh.promises.add(["statusInitialized"]);const e={XMPPStatus:Uy,onUserActivity:Oy,onEverySecond:Ny,sendCSI:My,registerIntervalHandler:Ry};Object.assign(yu,e),Object.assign(yu.exports,e),Object.assign(yu.api.user,Qv),bh.settings.get("idle_presence_timeout")>0&&bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(Fy.NS.IDLE))),bh.listen.on("presencesInitialized",(e=>!e&&Ry())),bh.listen.on("beforeTearDown",Dy),bh.listen.on("clearSession",(()=>{hu(yu)&&yu.state.xmppstatus&&(yu.state.xmppstatus.destroy(),delete yu.state.xmppstatus,Object.assign(yu,{xmppstatus:void 0}),bh.promises.add(["statusInitialized"]))})),bh.listen.on("connected",(()=>Cy(!1))),bh.listen.on("reconnected",(()=>Cy(!0))),bh.listen.on("constructedMUCPresence",zy)}});const{Strophe:By}=Zm.env,qy={contacts:{async get(e){await bh.waitUntil("rosterContactsFetched");const{roster:t}=yu.state,s=e=>t.get(By.getBareJidFromJid(e));if(void 0===e)e=t.pluck("jid");else if("string"==typeof e)return s(e);return e.map(s)},async add(e,t){if(await bh.waitUntil("rosterContactsFetched"),"string"!=typeof e||!e.includes("@"))throw new TypeError("contacts.add: invalid jid");return yu.state.roster.addAndSubscribe(e,t)}}};Zm.plugins.add("converse-roster",{dependencies:["converse-status"],initialize(){bh.settings.extend({allow_contact_requests:!0,auto_subscribe:!1,synchronize_availability:!0}),bh.promises.add(["cachedRoster","roster","rosterContactsFetched","rosterInitialized"]),Object.assign(yu.api,qy);const{__:e}=yu,t={HEADER_CURRENT_CONTACTS:e("My contacts"),HEADER_PENDING_CONTACTS:e("Pending contacts"),HEADER_REQUESTING_CONTACTS:e("Contact requests"),HEADER_UNGROUPED:e("Ungrouped"),HEADER_UNREAD:e("New messages")};Object.assign(yu,t),Object.assign(yu.labels,t);const s={Presence:wy,Presences:Sy,RosterContact:dy,RosterContacts:fy};Object.assign(yu,s),Object.assign(yu.exports,s),bh.listen.on("beforeTearDown",(()=>Zv())),bh.listen.on("chatBoxesInitialized",iy),bh.listen.on("clearSession",ty),bh.listen.on("presencesInitialized",sy),bh.listen.on("statusInitialized",ny),bh.listen.on("streamResumptionFailed",(()=>yu.session.set("roster_cached",!1))),bh.waitUntil("rosterContactsFetched").then(ry)}});const{Strophe:Hy}=Zm.env,Gy=Zm.env.utils;function Wy(){return!(bh.connection.isType("bosh")&&!lu())&&bh.disco.stream.getFeature("sm",Hy.NS.SM)}function Vy(e){if(!yu.session.get("smacks_enabled"))return!0;const t=parseInt(e.getAttribute("h"),10),s=yu.session.get("num_stanzas_handled_by_server"),n=t-s;if(n<0){const e=`New reported stanza count lower than previous. New: ${t} - Previous: ${s}`;kt.error(e)}const i=yu.session.get("unacked_stanzas");if(n>i.length){const e=`Higher reported acknowledge count than unacknowledged stanzas. Reported Acknowledged Count: ${n} -Unacknowledged Stanza Count: ${i.length} -New: ${t} - Previous: ${s}`;kt.error(e)}return yu.session.save({num_stanzas_handled_by_server:t,num_stanzas_since_last_ack:0,unacked_stanzas:i.slice(n)}),!0}function Qy(){if(yu.session.get("smacks_enabled")){const e=yu.session.get("num_stanzas_handled"),t=Gy.toStanza(``);bh.send(t)}return!0}function Jy(e){if(yu.session.get("smacks_enabled")&&(Gy.isTagEqual(e,"iq")||Gy.isTagEqual(e,"presence")||Gy.isTagEqual(e,"message"))){const e=yu.session.get("num_stanzas_handled");yu.session.save("num_stanzas_handled",e+1)}return!0}function Ky(){yu.session.save({smacks_enabled:yu.session.get("smacks_enabled")||!1,num_stanzas_handled:yu.session.get("num_stanzas_handled")||0,num_stanzas_handled_by_server:yu.session.get("num_stanzas_handled_by_server")||0,num_stanzas_since_last_ack:yu.session.get("num_stanzas_since_last_ack")||0,unacked_stanzas:yu.session.get("unacked_stanzas")||[]})}function Yy(){yu.session?.save({smacks_enabled:!1,num_stanzas_handled:0,num_stanzas_handled_by_server:0,num_stanzas_since_last_ack:0,unacked_stanzas:[]})}function Xy(e){const t={smacks_enabled:!0};return["1","true"].includes(e.getAttribute("resume"))&&(t.smacks_stream_id=e.getAttribute("id")),yu.session.save(t),!0}function Zy(e){if(Yy(),bh.trigger("streamResumptionFailed"),e.querySelector("item-not-found"))kt.warn("Could not resume previous SMACKS session, session id not found. A new session will be established.");else{kt.error("Failed to enable stream management"),kt.error(e.outerHTML);bh.connection.get()._changeConnectStatus(Hy.Status.DISCONNECTED,null)}return!0}function eb(e){Xy(e),Vy(e),function(){const e=yu.session.get("unacked_stanzas");yu.session.save("unacked_stanzas",[]),e.forEach((e=>bh.send(e)))}();const t=bh.connection.get();t.do_bind=!1,t.authenticated=!0,t.restored=!0,t._changeConnectStatus(Hy.Status.CONNECTED,null)}async function tb(){if(bh.settings.get("enable_smacks")&&!yu.session.get("smacks_enabled")&&await Wy()){const e=vc(),t=bh.connection.get();t._addSysHandler((t=>e.resolve(Xy(t))),Hy.NS.SM,"enabled"),t._addSysHandler((t=>e.resolve(Zy(t))),Hy.NS.SM,"failed");const s=bh.connection.isType("websocket")||lu(),n=Gy.toStanza(``);bh.send(n),t.flush(),await e}}const sb=[];async function nb(){if(!bh.settings.get("enable_smacks"))return;if(!await Wy())return;const e=bh.connection.get();for(;sb.length;)e.deleteHandler(sb.pop());sb.push(e.addHandler(Jy)),sb.push(e.addHandler(Qy,Hy.NS.SM,"r")),sb.push(e.addHandler(Vy,Hy.NS.SM,"a")),yu.session?.get("smacks_stream_id")?await async function(){const e=vc(),t=bh.connection.get();t._addSysHandler((t=>e.resolve(eb(t))),Hy.NS.SM,"resumed"),t._addSysHandler((t=>e.resolve(Zy(t))),Hy.NS.SM,"failed");const s=yu.session.get("smacks_stream_id"),n=yu.session.get("num_stanzas_handled"),i=Gy.toStanza(``);bh.send(i),t.flush(),await e}():Yy()}function ib(e){if(yu.session){if(yu.session.get("smacks_enabled")&&(Gy.isTagEqual(e,"iq")||Gy.isTagEqual(e,"presence")||Gy.isTagEqual(e,"message"))){const t=Hy.serialize(e);yu.session.save("unacked_stanzas",(yu.session.get("unacked_stanzas")||[]).concat([t]));const s=bh.settings.get("smacks_max_unacked_stanzas");if(s>0){const e=yu.session.get("num_stanzas_since_last_ack")+1;e%s==0&&bh.send(Gy.toStanza(``)),yu.session.save({num_stanzas_since_last_ack:e})}}}else kt.warn("No _converse.session!")}const{Strophe:rb}=Zm.env;rb.addNamespace("SM","urn:xmpp:sm:3"),Zm.plugins.add("converse-smacks",{initialize(){bh.settings.extend({enable_smacks:!0,smacks_max_unacked_stanzas:5}),bh.listen.on("afterResourceBinding",tb),bh.listen.on("beforeResourceBinding",nb),bh.listen.on("send",ib),bh.listen.on("userSessionInitialized",Ky)}});const ob=class extends wd{get idAttribute(){return"jid"}defaults(){return{image:yu.DEFAULT_IMAGE,image_type:yu.DEFAULT_IMAGE_TYPE}}set(e,t,s){let n;return"object"==typeof e?(n=e,s=t):(n={})[e]=t,"image"in n&&!n.image?(n.image=yu.DEFAULT_IMAGE,n.image_type=yu.DEFAULT_IMAGE_TYPE,wd.prototype.set.call(this,n,s)):wd.prototype.set.apply(this,arguments)}getDisplayName(){return this.get("nickname")||this.get("fullname")||this.get("jid")}},{Strophe:ab,$iq:cb,u:lb}=Zm.env;function db(e,t,s){const n=cb(t?{type:e,to:t}:{type:e});return s?n.cnode(s):n.c("vCard",{xmlns:ab.NS.VCARD}),n}async function ub(e){let t;if(e instanceof yu.exports.Message){if(["error","info"].includes(e.get("type")))return;t=e.get("from")}else t=e.get("jid");if(!t)return void kt.warn("Could not set VCard on model because no JID found!");await bh.waitUntil("VCardsInitialized");const{vcards:s}=yu.state;e.vcard=s.get(t)||s.create({jid:t}),e.vcard.on("change",(()=>e.trigger("vcard:change"))),e.trigger("vcard:add")}async function hb(e){await bh.waitUntil("VCardsInitialized"),e.vcard=function(e){const{vcards:t,xmppstatus:s}=yu.state,n=e?.collection?.chatroom,i=e.get("nick");if(i&&n?.get("nick")===i)return s.vcard;{const s=e.get("jid")||e.get("from");return s?t.get(s)||t.create({jid:s}):void kt.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 mb(e){["error","info"].includes(e.get("type"))||(await bh.waitUntil("VCardsInitialized"),e.vcard=function(e){const{vcards:t,xmppstatus:s}=yu.state,n=e?.collection?.chatbox,i=ab.getResourceFromJid(e.get("from"));if(i&&n?.get("nick")===i)return s.vcard;{const s=e.occupant?.get("jid")||e.get("from");return s?t.get(s)||t.create({jid:s}):void kt.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 gb(){const e=new yu.exports.VCards;yu.state.vcards=e,Object.assign(yu,{vcards:e});const t=yu.session.get("bare_jid");Iu(e,`${t}-converse.vcards`),await new Promise((t=>{e.fetch({success:t,error:t},{silent:!0})}));const{xmppstatus:s}=yu.state;s.vcard=e.get(t)||e.create({jid:t}),s.vcard&&(s.vcard.on("change",(()=>s.trigger("vcard:change"))),s.trigger("vcard:add")),bh.trigger("VCardsInitialized")}async function fb(e){const t=yu.session.get("bare_jid"),s=ab.getBareJidFromJid(e)===t?null:e;let n;try{n=await bh.sendIQ(db("get",s))}catch(t){return{jid:e,stanza:_t(t)?t:null,error:_t(t)?null:t,vcard_error:(new Date).toISOString()}}return async function(e){const t=e.querySelector("vCard");let s={};if(null!==t&&(s={stanza:e,fullname:t.querySelector("FN")?.textContent,nickname:t.querySelector("NICKNAME")?.textContent,image:t.querySelector("PHOTO BINVAL")?.textContent,image_type:t.querySelector("PHOTO TYPE")?.textContent,url:t.querySelector("URL")?.textContent,role:t.querySelector("ROLE")?.textContent,email:t.querySelector("EMAIL USERID")?.textContent,vcard_updated:(new Date).toISOString(),vcard_error:void 0,image_hash:void 0}),s.image){const e=lb.base64ToArrayBuffer(s.image),t=await crypto.subtle.digest("SHA-1",e);s.image_hash=lb.arrayBufferToHex(t)}return s}(n)}const{dayjs:pb,u:vb}=Zm.env,yb={vcard:{async set(e,t){if(!e)throw Error("No jid provided for the VCard data");const s=document.createElement("div"),n=vb.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 `,s);let i;try{i=await bh.sendIQ(db("set",e,n))}catch(e){throw e}return await bh.vcard.update(e,!0),i},get(e,t){if("string"==typeof e)return fb(e);const s=e.get("vcard_error"),n=s&&pb(s).isSame(new Date,"day");if(t||!e.get("vcard_updated")&&!n){const t=e.get("jid");return t||kt.error("No JID to get vcard for"),fb(t)}return Promise.resolve({})},async update(e,t){const s=await this.get(e,t);(e="string"==typeof e?yu.exports.vcards.get(e):e)?Object.keys(s).length&&(delete s.stanza,e.save(s)):kt.error(`Could not find a VCard model for ${e}`)}}};const bb=class extends Gd{constructor(){super(),this.model=ob}initialize(){this.on("add",(e=>e.get("jid")&&yb.vcard.update(e)))}},{Strophe:_b}=Zm.env;Zm.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(){bh.promises.add("VCardsInitialized");const e={VCard:ob,VCards:bb};Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("chatRoomInitialized",(e=>{ub(e),e.occupants.forEach(hb),e.listenTo(e.occupants,"add",hb),e.listenTo(e.occupants,"change:image_hash",(e=>function(e){const t=e.get("image_hash"),s=[];e.get("jid")&&s.push(yu.state.vcards.get(e.get("jid"))),s.push(yu.state.vcards.get(e.get("from"))),s.forEach((e=>t&&e?.get("image_hash")!==t&&bh.vcard.update(e,!0)))}(e)))})),bh.listen.on("chatBoxInitialized",(e=>ub(e))),bh.listen.on("chatRoomMessageInitialized",(e=>mb(e))),bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(_b.NS.VCARD))),bh.listen.on("clearSession",(()=>{hu(yu)&&(bh.promises.add("VCardsInitialized"),yu.state.vcards&&(yu.state.vcards.clearStore(),Object.assign(yu,{vcards:void 0}),delete yu.state.vcards))})),bh.listen.on("messageInitialized",(e=>ub(e))),bh.listen.on("rosterContactInitialized",(e=>ub(e))),bh.listen.on("statusInitialized",gb),Object.assign(yu.api,yb)}}),b().extend(w());const wb=Object.assign({},r,f),{dayjs:Sb}=Zm.env;let xb,Ab="en";function Eb(e,t){return t.includes(e)}function Cb(e,t){if("en"===e||t(e))return e;const{languages:s}=window.navigator;let n;for(let e=0;eAb,translate(e,t){if(!xb)return v().sprintf.apply(v(),arguments);const s=xb.translate(e);return arguments.length>1?s.fetch.apply(s,t):s.fetch()},async initialize(){if(om.isTestEnv())Ab="en";else try{const e=bh.settings.get("i18n"),t=bh.settings.get("locales");Ab=Cb(e,(e=>Eb(e,t))),xb=await async function(){const e=function(e){const t=e.toLowerCase().replace("_","-");return"ug"===t?"ug-cn":t}(Ab);if(!Eb(Ab,bh.settings.get("locales"))||"en"===Ab)return;const{default:t}=await s(3883)(`./${Ab}/LC_MESSAGES/converse.po`);return await s(9499)(`./${e}.js`),Sb.locale(Cb(e,(e=>Sb.locale(e)))),new(v())(t)}()}catch(e){kt.fatal(e.message),Ab="en"}},__:(e,...t)=>jb.translate(e,t)}),kb=jb.__,Tb={},Ib={registry:Tb,define(e,t){this.registry[e]=t},register(){Object.keys(Tb).forEach((e=>{customElements.get(e)||customElements.define(e,Tb[e])}))}};Object.assign(bh,{elements:Ib});class Ob extends(Ii(Km)){createRenderRoot(){return this}initialize(){return null}connectedCallback(){return super.connectedCallback(),this.initialize()}disconnectedCallback(){super.disconnectedCallback(),this.stopListening()}}const Nb=["converse-adhoc-views","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 Mb=s(5072),Rb=s.n(Mb),Db=s(7825),zb=s.n(Db),Lb=s(7659),Pb=s.n(Lb),Ub=s(5056),Fb=s.n(Ub),Bb=s(540),qb=s.n(Bb),Hb=s(1113),Gb=s.n(Hb),Wb=s(804),Vb={};Vb.styleTagTransform=Gb(),Vb.setAttributes=Fb(),Vb.insert=Pb().bind(null,"head"),Vb.domAPI=zb(),Vb.insertStyleElement=qb();Rb()(Wb.A,Vb);Wb.A&&Wb.A.locals&&Wb.A.locals;var Qb=s(5160),Jb=s.n(Qb);const Kb=Cs``,Yb=Cs``,Xb=e=>{const t=e.model?.get("alert"),s=e.model?.get("level")??"";return Cs``};var Zb=s(5495),e_={};e_.styleTagTransform=Gb(),e_.setAttributes=Fb(),e_.insert=Pb().bind(null,"head"),e_.domAPI=zb(),e_.insertStyleElement=qb();Rb()(Zb.A,e_);Zb.A&&Zb.A.locals&&Zb.A.locals;const t_=class extends Mi{constructor(e){super(),this.model=null,this.className="modal",this.initialized=vc(),Object.assign(this,e),setTimeout((()=>this.insertIntoDOM())),this.addEventListener("hide.bs.modal",(()=>this.onHide()),!1)}initialize(){this.modal=new(Jb().Modal)(this,{backdrop:!0,keyboard:!0}),this.initialized.resolve(),this.render()}toHTML(){return Xb(this)}getModalTitle(){return""}switchTab(e){e?.stopPropagation(),e?.preventDefault(),this.tab=e.target.getAttribute("data-name"),this.render()}onHide(){this.modal.hide()}insertIntoDOM(){document.querySelector("#converse-modals").insertAdjacentElement("beforeend",this)}alert(e,t="primary"){this.model.set("alert",{message:e,type:t}),setTimeout((()=>{this.model.set("alert",void 0)}),5e3)}async show(){await this.initialized,this.modal.show(),this.render()}};bh.elements.define("converse-alert-modal",class extends t_{initialize(){super.initialize(),this.listenTo(this.model,"change",(()=>this.render())),this.addEventListener("hide.bs.modal",(()=>this.remove()),!1)}renderModal(){return(e=>Cs``)(this.model.toJSON())}getModalTitle(){return this.model.get("title")}});const s_=e=>Cs`
${e.model.get("messages")?.map((e=>Cs`

${e}

`))}
${e.model.get("fields")?.map((e=>(e=>Cs`
`)(e)))}
`;class n_ extends t_{constructor(e){super(e),this.confirmation=vc()}initialize(){super.initialize(),this.listenTo(this.model,"change",(()=>this.render())),this.addEventListener("hide.bs.modal",(()=>{this.confirmation.isResolved||this.confirmation.reject()}),!1)}renderModal(){return s_(this)}getModalTitle(){return this.model.get("title")}onConfimation(e){e.preventDefault();const t=new FormData(e.target),s=(this.model.get("fields")||[]).map((e=>{const s=t.get(e.name).trim();return e.value=s,e.challenge&&(e.challenge_failed=s!==e.challenge),e}));if(s.filter((e=>e.challenge_failed)).length)return this.model.set("fields",s),void this.model.trigger("change");this.confirmation.resolve(s),this.modal.hide()}renderModalFooter(){return""}}bh.elements.define("converse-confirm-modal",n_);let i_=[],r_={};const o_={modal:{show(e,t,s){let n;if("string"==typeof e)n=this.get(e)??this.create(e,t),Object.assign(n,t);else{const s=e,i=s.id??t.id;n=this.get(i)??this.create(s,t)}return n.show(s),n},get:e=>r_[e]??i_.filter((t=>t.id==e)).pop(),create(e,t){const s=customElements.get(e);return r_[e]=new s(t)},remove(e){let t;"string"==typeof e?(t=r_[e],delete r_[e]):(t=e,i_=i_.filter((e=>e!==t))),t?.remove()},removeAll(){i_.forEach((e=>e.remove())),i_=[],r_={}}},async confirm(e,t=[],s=[]){"string"==typeof t&&(t=[t]);const n=new wd({title:e,messages:t,fields:s,type:"confirm"}),i=new n_({model:n});let r;i.show();try{r=await i.confirmation}catch(e){r=!1}return i.remove(),r},async prompt(e,t=[],s=""){"string"==typeof t&&(t=[t]);const n=new wd({title:e,messages:t,fields:[{name:"reason",placeholder:s}],type:"prompt"}),i=new n_({model:n});let r;i.show();try{r=(await i.confirmation).pop()?.value}catch(e){r=!1}return i.remove(),r},alert(e,t,s){let n;"string"==typeof s&&(s=[s]),"error"===e?n="alert-danger":"info"===e?n="alert-info":"warn"===e&&(n="alert-warning");const i=new wd({title:t,messages:s,level:n,type:"alert"});o_.modal.show("converse-alert-modal",{model:i})}},a_=o_;Object.assign(Zm.env,{BaseModal:t_}),Zm.plugins.add("converse-modal",{initialize(){bh.listen.on("disconnect",(()=>{const e=document.querySelector("#converse-modals");e&&(e.innerHTML="")})),bh.listen.on("clearSession",(()=>bh.modal.removeAll())),Object.assign(yu.api,a_)}});const c_=class extends String{constructor(e,t){super();const s=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=s.label||s.value,this.value=s.value,this.query=t}get lenth(){return this.label.length}toString(){return""+this.label}valueOf(){return this.toString()}},l_=Zm.env.utils,d_={getElement:(e,t)=>"string"==typeof e?(t||document).querySelector(e):e||null,bind(e,t){if(e)for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const n=t[s];s.split(/\s+/).forEach((t=>e.addEventListener(t,n)))}},unbind(e,t){if(e)for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;const n=t[s];s.split(/\s+/).forEach((t=>e.removeEventListener(t,n)))}},regExpEscape:e=>e.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&"),isMention:(e,t)=>t.includes(e[0])||l_.isMentionBoundary(e[0])&&t.includes(e[1])},u_=function(e,t){return RegExp(d_.regExpEscape(t.trim()),"i").test(e)},h_=function(e,t){return RegExp("^"+d_.regExpEscape(t.trim()),"i").test(e)},m_=function(e,t){const s=e.query.toLowerCase(),n=e.label.toLowerCase().indexOf(s),i=t.label.toLowerCase().indexOf(s);return n===i?function(e,t){return e.length!==t.length?e.length-t.length:e{t=t.trim();const s=document.createElement("li");s.setAttribute("aria-selected","false");const n=new RegExp("("+t+")","ig");return(t?e.split(n):[e]).forEach((e=>{if(t&&e.match(n)){const t=document.createElement("mark");t.textContent=e,s.appendChild(t)}else s.appendChild(document.createTextNode(e))})),s},{siblingIndex:f_}=om;class p_ extends(Ii(Object)){constructor(e,t={}){super(),this.suggestions=[],this.is_opened=!1,this.auto_evaluate=!0,this.match_current_word=!1,this.sort=!1===t.sort?null:m_,this.filter=u_,this.ac_triggers=[],this.include_triggers=[],this.min_chars=2,this.max_items=10,this.auto_first=!1,this.data=(e,t)=>e,this.item=g_,om.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,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=e=>this.evaluate(e)),this._events={input:e,form:{submit:()=>this.close({reason:"submit"})},ul:{mousedown:e=>this.onMouseDown(e),mouseover:e=>this.onMouseOver(e)}},d_.bind(this.input,this._events.input),d_.bind(this.input.form,this._events.form),d_.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{const t=d_.getElement(e)?.children||[];this._list=Array.from(t).filter((e=>!e.disabled)).map((e=>{const t=e.textContent.trim(),s=e.value||t,n=e.label||t;return""!==s?{label:n,value:s}: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?om.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(){d_.unbind(this.input,this._events.input),d_.unbind(this.input.form,this._events.form),this.input.removeAttribute("aria-autocomplete")}next(){const e=this.ul.children.length;this.goto(this.indexe instanceof HTMLElement));this.selected&&s[this.index].setAttribute("aria-selected","false"),this.index=e,e>-1&&s.length>0&&(s[e].setAttribute("aria-selected","true"),s[e].focus(),this.status.textContent=s[e].textContent,t&&(this.ul.scrollTop=s[e].offsetTop-this.ul.clientHeight+s[e].clientHeight),this.trigger("suggestion-box-highlight",{text:this.suggestions[this.index]}))}select(e){if(e?this.index=f_(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=om.ancestor(e.target,"li");if(t){const e=Array.prototype.slice.call(this.ul.children).indexOf(t);this.goto(e,!1)}}onMouseDown(e){if(0!==e.button)return;const t=om.ancestor(e.target,"li");t&&(e.preventDefault(),this.select(t))}onKeyDown(e){if(this.opened){if([Zm.keycodes.ENTER,Zm.keycodes.TAB].includes(e.keyCode)&&this.selected)return e.preventDefault(),e.stopPropagation(),this.select(),!0;if(e.keyCode===Zm.keycodes.ESCAPE)return this.close({reason:"esc"}),!0;if([Zm.keycodes.UP_ARROW,Zm.keycodes.DOWN_ARROW].includes(e.keyCode))return e.preventDefault(),e.stopPropagation(),this[e.keyCode===Zm.keycodes.UP_ARROW?"previous":"next"](),!0}if(![Zm.keycodes.SHIFT,Zm.keycodes.META,Zm.keycodes.META_RIGHT,Zm.keycodes.ESCAPE,Zm.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=om.getCurrentWord(e.target,e.target.selectionEnd-1);d_.isMention(t,this.ac_triggers)&&(this.auto_completing=!0)}}async evaluate(e){const t=this.selected&&e&&(e.keyCode===Zm.keycodes.UP_ARROW||e.keyCode===Zm.keycodes.DOWN_ARROW);if(!this.auto_evaluate&&!this.auto_completing||t)return;let s=this.match_current_word?om.getCurrentWord(this.input):this.input.value;const n=d_.isMention(s,this.ac_triggers);n&&!this.include_triggers.includes(e.key)&&(s=om.isMentionBoundary(s[0])?s.slice(2):s.slice(1));const i=s.length&&s.length>=this.min_chars;if(n||i){this.auto_completing=!0;const e="function"==typeof this._list?await this._list(s):this._list;if(0===e.length||!this.auto_completing)return void this.close({reason:"nomatches"});this.index=-1,this.ul.innerHTML="",this.suggestions=e.map((e=>new c_(this.data(e,s),s))).filter((e=>this.filter(e,s))),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()}else this.close({reason:"nomatches"}),n||(this.auto_completing=!1)}}const v_=p_;bh.elements.define("converse-autocomplete",class extends Ob{static get properties(){return{position:{type:String},autofocus:{type:Boolean},getAutoCompleteList:{type:Function},data:{type:Function},list:{type:Array},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},value:{type:String},triggers:{type:String},required:{type:Boolean}}}constructor(){super(),this.data=e=>e,this.value="",this.position="above",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="",this.getAutoCompleteList=null,this.list=null,this.name="",this.placeholder="",this.required=!1}render(){const e=`suggestion-box__results--${this.position}`;return Cs`
`}firstUpdated(){this.auto_complete=new v_(this.firstElementChild,{ac_triggers:this.triggers.split(" "),auto_evaluate:this.auto_evaluate,auto_first:this.auto_first,filter:"contains"==this.filter?u_:h_,include_triggers:[],list:this.list??(e=>this.getAutoCompleteList(e)),data:this.data,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 y_=s(7434),b_={};b_.styleTagTransform=Gb(),b_.setAttributes=Fb(),b_.insert=Pb().bind(null,"head"),b_.domAPI=zb(),b_.insertStyleElement=qb();Rb()(y_.A,b_);y_.A&&y_.A.locals&&y_.A.locals;const __={AutoComplete:v_};Object.assign(yu,__),Object.assign(yu.exports,__);const w_={execute:kb("Execute"),prev:kb("Previous"),next:kb("Next"),complete:kb("Complete")},S_={info:"primary",warn:"secondary",error:"danger"},x_=(e,t)=>Cs`
  • ${t.node===e.showform?((e,t)=>{const s=kb("Cancel");return Cs`
    ${t.alert?Cs``:""} ${t.note?Cs``:""}
    ${t.instructions?Cs`

    ${t.instructions}

    `:""} ${t.fields??[]}
    ${t.actions?.length?Cs`
    ${t.actions?.map((t=>Cs``))}
    `:""}
    `})(e,t):""}
  • `,A_=(e={})=>e.classes?.includes("hor_centered")?Cs`
    `:Cs``,E_=e=>{return e.image?Cs``:"";var t,s};var C_=s(7688),$_={};$_.styleTagTransform=Gb(),$_.setAttributes=Fb(),$_.insert=Pb().bind(null,"head"),$_.domAPI=zb(),$_.insertStyleElement=qb();Rb()(C_.A,$_);C_.A&&C_.A.locals&&C_.A.locals;bh.elements.define("converse-avatar",class extends Ob{static get properties(){return{data:{type:Object},width:{type:String},height:{type:String},nonce:{type:String}}}constructor(){super(),this.data=null,this.width=36,this.height=36}render(){const e=this.data?.image_type||yu.DEFAULT_IMAGE_TYPE;let t;if(this.data?.data_uri)t=this.data?.data_uri;else{t="data:"+e+";base64,"+(this.data?.image||yu.DEFAULT_IMAGE)}return E_({classes:this.getAttribute("class"),height:this.height,width:this.width,image:t,image_type:e})}});const{I:j_}=qs,k_=()=>document.createComment(""),T_=(e,t,s)=>{var n;const i=e._$AA.parentNode,r=void 0===t?e._$AB:t._$AA;if(void 0===s){const t=i.insertBefore(k_(),r),n=i.insertBefore(k_(),r);s=new j_(t,n,e,e.options)}else{const t=s._$AB.nextSibling,o=s._$AM,a=o!==e;if(a){let t;null===(n=s._$AQ)||void 0===n||n.call(s,e),s._$AM=e,void 0!==s._$AP&&(t=e._$AU)!==o._$AU&&s._$AP(t)}if(t!==r||a){let e=s._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,r),e=t}}}return s},I_=(e,t,s=e)=>(e._$AI(t,s),e),O_={},N_=e=>{var t;null===(t=e._$AP)||void 0===t||t.call(e,!1,!0);let s=e._$AA;const n=e._$AB.nextSibling;for(;s!==n;){const e=s.nextSibling;s.remove(),s=e}},M_=2,R_=e=>(...t)=>({_$litDirective$:e,values:t});class D_{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,s){this._$Ct=e,this._$AM=t,this._$Ci=s}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}const z_=(e,t)=>{var s,n;const i=e._$AN;if(void 0===i)return!1;for(const e of i)null===(n=(s=e)._$AO)||void 0===n||n.call(s,t,!1),z_(e,t);return!0},L_=e=>{let t,s;do{if(void 0===(t=e._$AM))break;s=t._$AN,s.delete(e),e=t}while(0===(null==s?void 0:s.size))},P_=e=>{for(let t;t=e._$AM;e=t){let s=t._$AN;if(void 0===s)t._$AN=s=new Set;else if(s.has(e))break;s.add(e),B_(t)}};function U_(e){void 0!==this._$AN?(L_(this),this._$AM=e,P_(this)):this._$AM=e}function F_(e,t=!1,s=0){const n=this._$AH,i=this._$AN;if(void 0!==i&&0!==i.size)if(t)if(Array.isArray(n))for(let e=s;e{var t,s,n,i;e.type==M_&&(null!==(t=(n=e)._$AP)&&void 0!==t||(n._$AP=F_),null!==(s=(i=e)._$AQ)&&void 0!==s||(i._$AQ=U_))};class q_ extends D_{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,s){super._$AT(e,t,s),P_(this),this.isConnected=e._$AU}_$AO(e,t=!0){var s,n;e!==this.isConnected&&(this.isConnected=e,e?null===(s=this.reconnected)||void 0===s||s.call(this):null===(n=this.disconnected)||void 0===n||n.call(this)),t&&(z_(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 H_{constructor(e){this.G=e}disconnect(){this.G=void 0}reconnect(e){this.G=e}deref(){return this.G}}class G_{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){var e;null!==(e=this.Y)&&void 0!==e||(this.Y=new Promise((e=>this.Z=e)))}resume(){var e;null===(e=this.Z)||void 0===e||e.call(this),this.Y=this.Z=void 0}}const W_=e=>!(e=>null===e||"object"!=typeof e&&"function"!=typeof e)(e)&&"function"==typeof e.then,V_=1073741823;const Q_=R_(class extends q_{constructor(){super(...arguments),this._$C_t=V_,this._$Cwt=[],this._$Cq=new H_(this),this._$CK=new G_}render(...e){var t;return null!==(t=e.find((e=>!W_(e))))&&void 0!==t?t:$s}update(e,t){const s=this._$Cwt;let n=s.length;this._$Cwt=t;const i=this._$Cq,r=this._$CK;this.isConnected||this.disconnected();for(let e=0;ethis._$C_t);e++){const o=t[e];if(!W_(o))return this._$C_t=e,o;e{for(;r.get();)await r.get();const t=i.deref();if(void 0!==t){const s=t._$Cwt.indexOf(o);s>-1&&sthis.alert(kb("Affiliation changed")))),this.addEventListener("roleChanged",(()=>this.alert(kb("role changed"))))}initialize(){super.initialize();const e=this.model??this.message;this.listenTo(e,"change",(()=>this.render())),bh.trigger("occupantModalInitialized",{model:this.model,message:this.message})}getVcard(){const e=this.model??this.message;if(e.vcard)return e.vcard;const t=e?.get("jid")||e?.get("from");return t?yu.state.vcards.get(t):null}renderModal(){return(e=>{const t=e.model??e.message,s=t?.get("jid"),n=e.getVcard(),i=t.get("nick"),r=t.get("occupant_id"),o=e.model?.get("role"),a=e.model?.get("affiliation"),c=e.model?.get("hats")?.length?e.model.get("hats"):null,l=e.model.collection.chatroom,d=l.getAllowedCommands().includes("modtools"),u=kb("Add to Contacts"),h=l.features.get("nonanonymous")||"moderator"===l.getOwnRole(),m=s!=yu.session.get("bare_jid"),g=bh.contacts.get(s).then((e=>!e&&m&&h)).then((t=>t?Cs`
  • `:""));return Cs`
    • ${i?Cs`
      ${kb("Nickname")}:
      ${i}
      `:""}
    • ${s?Cs`
      ${kb("XMPP Address")}:
      ${s}
      `:""}
    • ${kb("Affiliation")}:
      ${a}  ${d?Cs`${e.show_affiliation_form?Cs``:""}`:""}
    • ${kb("Role")}:
      ${o}  ${d&&o?Cs`${e.show_role_form?Cs``:""}`:""}
    • ${c?Cs`
      ${kb("Hats")}:
      ${c}
      `:""}
    • ${r?Cs`
      ${kb("Occupant Id")}:
      ${r}
      `:""}
    • ${Q_(g,"")}
    `})(this)}getModalTitle(){const e=this.model??this.message;return e?.getDisplayName()}addToContacts(){const e=(this.model??this.message).get("jid");e&&bh.modal.show("converse-add-contact-modal",{model:new wd({jid:e})})}toggleForm(e){"row-form"===J_.ancestor(e.target,".toggle-form").getAttribute("data-form")?this.show_role_form=!this.show_role_form:this.show_affiliation_form=!this.show_affiliation_form,this.render()}});const X_=(e,t)=>Cs`
    • JID: ${t.item.jid}
    • Nickname: ${t.item.nick}
    • Role: ${t.item.role} ${t.assignable_roles.length?(e=>Cs``)(t):""}
      ${t.assignable_roles.length?Cs``:""}
  • `,Z_=(e,t)=>Cs`
    • JID: ${t.item.jid}
    • Nickname: ${t.item.nick}
    • Affiliation: ${t.item.affiliation} ${t.assignable_affiliations.length?(e=>Cs``)(t):""}
      ${t.assignable_affiliations.length?Cs``:""}
  • `,ew=(e,t)=>{const s=kb("Affiliation"),n=kb("No users with that affiliation found."),i=kb("No users with that role found."),r=kb("Type here to filter the search results"),o=kb("Role"),a=kb("Show users"),c=kb("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."),l=kb("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."),d=t.queryable_roles.length&&t.queryable_affiliations.length;return Cs`${t.alert_message?Cs``:""} ${d?(e=>Cs``)(t):""}
    ${t.queryable_affiliations.length?Cs`

    ${l}

    ${Array.isArray(t.users_with_affiliation)&&t.users_with_affiliation.length>5?Cs``:""}
    ${Y_(t.affiliation)?Cs`

    ${Y_(t.affiliation)}

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

    ${c}

    ${Array.isArray(t.users_with_role)&&t.users_with_role.length>5?Cs``:""}
    ${K_(t.role)?Cs`

    ${K_(t.role)}

    `:""}
      ${t.loading_users_with_role?Cs`
    • ${A_()}
    • `:""} ${t.users_with_role&&0===t.users_with_role.length?Cs`
    • ${i}
    • `:""} ${(t.users_with_role||[]).map((s=>s.nick.match(t.roles_filter)?X_(e,Object.assign({item:s},t)):""))}
    `:""}
    `};var tw=s(5101),sw={};sw.styleTagTransform=Gb(),sw.setAttributes=Fb(),sw.insert=Pb().bind(null,"head"),sw.domAPI=zb(),sw.insertStyleElement=qb();Rb()(tw.A,sw);tw.A&&tw.A.locals&&tw.A.locals;const{u:nw}=Zm.env,{AFFILIATIONS:iw,ROLES:rw}=wb;bh.elements.define("converse-modtools",class extends Ob{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},tab:{type:String},users_with_affiliation:{type:Array,attribute:!1},users_with_role:{type:Array,attribute:!1}}}constructor(){super(),this.jid=null,this.tab="affiliations",this.affiliation=null,this.affiliations_filter="",this.role="",this.roles_filter="",this.addEventListener("affiliationChanged",(()=>{this.alert(kb("Affiliation changed"),"primary"),this.onSearchAffiliationChange(),this.requestUpdate()})),this.addEventListener("roleChanged",(()=>{this.alert(kb("Role changed"),"primary"),this.requestUpdate()}))}updated(e){e.has("role")&&this.onSearchRoleChange(),e.has("affiliation")&&this.onSearchAffiliationChange(),e.has("jid")&&e.get("jid")&&this.initialize()}async initialize(){this.initialized=vc();const e=await bh.rooms.get(this.jid);await e.initialized,this.muc=e,this.initialized.resolve()}render(){if(this.muc?.occupants){const e=this.muc.occupants.getOwnOccupant();return ew(this,{affiliations_filter:this.affiliations_filter,alert_message:this.alert_message,alert_type:this.alert_type,assignable_affiliations:e.getAssignableAffiliations(),assignable_roles:e.getAssignableRoles(),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:iw.filter((e=>!bh.settings.get("modtools_disable_query").includes(e))),queryable_roles:rw.filter((e=>!bh.settings.get("modtools_disable_query").includes(e))),roles_filter:this.roles_filter,switchTab:e=>this.switchTab(e),tab:this.tab,toggleForm:e=>this.toggleForm(e),users_with_affiliation:this.users_with_affiliation,users_with_role:this.users_with_role})}return""}switchTab(e){e.stopPropagation(),e.preventDefault(),this.tab=e.target.getAttribute("data-name"),this.requestUpdate()}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 bh.rooms.affiliations.get(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!up.getAutoFetchedAffiliationLists().includes(e)}toggleForm(e){e.stopPropagation(),e.preventDefault();const t=nw.ancestor(e.target,".toggle-form"),s=t.getAttribute("data-form"),n=nw.ancestor(t,".list-group-item").querySelector(s);nw.hasClass("hidden",n)?nw.removeClass("hidden",n):nw.addClass("hidden",n)}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}});bh.elements.define("converse-modtools-modal",class extends t_{constructor(e){super(e),this.id="converse-modtools-modal",this.affiliation=e.affiliation,this.jid=e.jid}renderModal(){return Cs``}getModalTitle(){return kb("Moderator Tools")}});const{Strophe:ow,u:aw}=Zm.env,{CHATROOMS_TYPE:cw}=wb,lw={admin:"admin",ban:"outcast",member:"member",owner:"owner",revoke:"none"},dw={deop:"participant",kick:"none",mute:"visitor",op:"moderator",voice:"participant"};function uw({contact:e,jid:t,reason:s}){return s?bh.confirm(kb('%1$s has invited you to join a groupchat: %2$s, and left the following reason: "%3$s"',e,t,s)):bh.confirm(kb("%1$s has invited you to join a groupchat: %2$s",e,t))}async function hw(e){const t=[kb("Are you sure you want to destroy this groupchat?")];let s=[{name:"challenge",label:kb("Please enter the XMPP address of this groupchat to confirm"),challenge:e.get("jid"),placeholder:kb("name@example.org"),required:!0},{name:"reason",label:kb("Optional reason for destroying this groupchat"),placeholder:kb("Reason")},{name:"newjid",label:kb("Optional XMPP address for a new groupchat that replaces this one"),placeholder:kb("replacement@example.org")}];try{s=await bh.confirm(kb("Confirm"),t,s);const n=s.filter((e=>"reason"===e.name)).pop()?.value,i=s.filter((e=>"newjid"===e.name)).pop()?.value;return e.sendDestroyIQ(n,i).then((()=>e.close()))}catch(e){kt.error(e)}}function mw(e){const t=e.model.session.get("view"),s=e.model.get("jid"),n=Zm.ROOMSTATUS,i=e.model.session.get("connection_status");return t===Zm.MUC.VIEWS.CONFIG?Cs``:Cs`${i==n.PASSWORD_REQUIRED?Cs``:""} ${i==n.ENTERED?Cs``:""} ${i==n.CONNECTING?A_():""} ${i==n.NICKNAME_REQUIRED?function(e){const t=e.get("jid");return bh.settings.get("muc_show_logs_before_join")?Cs``:Cs``}(e.model):""} ${i==n.DISCONNECTED?Cs``:""} ${i==n.BANNED?Cs``:""} ${i==n.DESTROYED?Cs``:""}`}function gw(e,t){t=t.trim();const s=document.createElement("li");if(s.setAttribute("aria-selected","false"),bh.settings.get("muc_mention_autocomplete_show_avatar")){const t=document.createElement("img");let n="data:"+yu.DEFAULT_IMAGE_TYPE+";base64,"+yu.DEFAULT_IMAGE;const{vcards:i}=yu.state;if(i){const t=i.findWhere({nickname:e});t&&(n="data:"+t.get("image_type")+";base64,"+t.get("image"))}t.setAttribute("src",n),t.setAttribute("width","22"),t.setAttribute("class","avatar avatar-autocomplete"),s.appendChild(t)}const n=new RegExp("("+t+")","ig");return(t?e.split(n):[e]).forEach((e=>{if(t&&e.match(n)){const t=document.createElement("mark");t.textContent=e,s.appendChild(t)}else s.appendChild(document.createTextNode(e))})),s}async function fw(){const e=[...await bh.rooms.get(),...await bh.contacts.get()],t=[...new Set(e.map((e=>ow.getDomainFromJid(e.get("jid")))))];return t}function pw(e,t,s,n=[],i=[]){const r=dw[t];if(!r)throw Error(`ChatRoomView#setRole called with invalid command: ${t}`);if(!e.verifyAffiliations(n)||!e.verifyRoles(i))return!1;if(!e.validateRoleOrAffiliationChangeArgs(t,s))return!1;const o=e.getNickOrJIDFromCommandArgs(s);if(!o)return!1;const a=s.split(o,2)[1].trim(),c=e.getOccupant(o);return e.setRole(c,r,a,void 0,(t=>e.onCommandError(t))),!0}function vw(e,t,s,n){const i=lw[t];if(!i)throw Error(`verifyAffiliations called with invalid command: ${t}`);if(!e.verifyAffiliations(n))return!1;if(!e.validateRoleOrAffiliationChangeArgs(t,s))return!1;const r=e.getNickOrJIDFromCommandArgs(s);if(!r)return!1;let o;const a=s.split(r,2)[1].trim(),c=e.getOccupant(r);if(c)o=c.get("jid");else{if(!aw.isValidJID(r)){const t=kb("Couldn't find a participant with that nickname. They might have left the groupchat.");return void e.createMessage({message:t,type:"error"})}o=r}const l={jid:o,reason:a};c&&bh.settings.get("auto_register_muc_nickname")&&(l.nick=c.get("nick")),aw.muc.setAffiliation(i,e.get("jid"),[l]).then((()=>e.occupants.fetchMembers())).catch((t=>e.onCommandError(t)))}function yw(e,t){if(!e.verifyRoles(["moderator"]))return;let s=bh.modal.get("converse-modtools-modal");s?(s.affiliation=t,s.render()):s=bh.modal.create("converse-modtools-modal",{affiliation:t,jid:e.get("jid")}),s.show()}function bw(e,t){const s=e.model;if(t||s.get("type")!==cw||bh.settings.get("muc_disable_slash_commands")&&!Array.isArray(bh.settings.get("muc_disable_slash_commands")))return t;let n=e.text;n=n.replace(/^\s*/,"");const i=(n.match(/^\/([a-zA-Z]*) ?/)||[""]).pop().toLowerCase();if(!i)return!1;const r=n.slice(("/"+i).length+1).trim(),o=s.getAllowedCommands()??[];if("admin"===i&&o.includes(i))return vw(s,i,r,["owner"]),!0;if("ban"===i&&o.includes(i))return vw(s,i,r,["admin","owner"]),!0;if("modtools"===i&&o.includes(i))return yw(s,r),!0;if("deop"===i&&o.includes(i))return pw(s,i,r,["admin","owner"]),!0;if("destroy"===i&&o.includes(i))return!s.verifyAffiliations(["owner"])||(hw(s).catch((e=>s.onCommandError(e))),!0);if("help"===i&&o.includes(i))return s.set({show_help_messages:!1},{silent:!0}),s.set({show_help_messages:!0}),!0;if("kick"===i&&o.includes(i))return pw(s,i,r,[],["moderator"]),!0;if("mute"===i&&o.includes(i))return pw(s,i,r,[],["moderator"]),!0;if("member"===i&&o.includes(i))return vw(s,i,r,["admin","owner"]),!0;if("nick"===i&&o.includes(i)){if(!s.verifyRoles(["visitor","participant","moderator"]))return!0;if(0===r.length){const e=kb('Your nickname is "%1$s"',s.get("nick"));s.createMessage({message:e,type:"error"})}else s.setNickname(r);return!0}return"owner"===i&&o.includes(i)?(vw(s,i,r,["owner"]),!0):"op"===i&&o.includes(i)?(pw(s,i,r,["admin","owner"]),!0):"register"===i&&o.includes(i)?(r.length>1?s.createMessage({message:kb("Error: invalid number of arguments"),type:"error"}):s.registerNickname().then((e=>{e&&s.createMessage({message:e,type:"error"})})),!0):"revoke"===i&&o.includes(i)?(vw(s,i,r,["admin","owner"]),!0):"topic"===i&&o.includes(i)||"subject"===i&&o.includes(i)?(s.setSubject(r),!0):!("voice"!==i||!o.includes(i))&&(pw(s,i,r,[],["moderator"]),!0)}const _w=e=>{const t=kb("On which entity do you want to run commands?"),s=kb("Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them."),n=kb("Commands found"),i=kb("List available commands"),r=kb("XMPP Address"),o=kb("No commands found");return Cs`${e.alert?Cs``:""} ${e.note?Cs`

    ${e.note}

    `:""}
    ${e.fetching?A_():Cs``}
    ${"list-commands"===e.view?Cs`
    • ${e.commands.length?n:o}:
    • ${e.commands.map((t=>x_(e,t)))}
    `:""}
    `},ww=(e,t)=>Cs`${t?"":Cs`${e}`}`,Sw=(e,t)=>{const s=kb('Download file "%1$s"',t);return Cs`${s}`},xw=e=>Cs`
    ${"hidden"!==e.type?Cs``:""} ${"password"===e.type&&e.fixed_username?Cs``:""}
    `,Aw=e=>Cs`
    `,Ew=e=>Cs``,Cw=e=>Cs`
    ${e.label?Cs``:""}
    ${e.domain}
    `;function $w(e){e.preventDefault(),bh.rooms.open(e.target.href)}const jw=(e,t)=>{let s=e.normalizePath().toString();return e._parts.protocol||t.startsWith("http://")||t.startsWith("https://")||(s="http://"+s),"xmpp"===e._parts.protocol&&"join"===e._parts.query?Cs`${t}`:Cs`${t}`},kw=(e,t)=>Cs`${t?"":Cs`${e}`}`,{sizzle:Tw,Strophe:Iw}=Zm.env,{getURI:Ow,isAudioURL:Nw,isImageURL:Mw,isVideoURL:Rw,isValidURL:Dw,queryChildren:zw}=om,Lw=["http","https","xmpp","mailto"],Pw={"text-private":"password","text-single":"text",fixed:"label",boolean:"checkbox",hidden:"hidden","jid-multi":"textarea","list-single":"dropdown","list-multi":"dropdown"},Uw={"xs:anyURI":"url","xs:byte":"number","xs:date":"date","xs:dateTime":"datetime","xs:int":"number","xs:integer":"number","xs:time":"time"},Fw=/\s*\n\s*/;function Bw(e){let t;(e instanceof me||e instanceof Be)&&(e=e.tree());const s=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>"body"===e.parentElement.nodeName.toLowerCase()?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT));for(;t=n.nextNode();)s.push(t);return s.forEach((e=>Fw.test(e.data)&&e.parentElement.removeChild(e))),e}function qw(e,t){return{"muc#roomconfig_lang":"language","muc#roomconfig_roomsecret":t?.new_password?"new-password":"current-password"}[e]}const Hw=new XMLSerializer;function Gw(e){const t=e.getAttribute("name");if(!t)return null;let s;return s="checkbox"===e.getAttribute("type")?e.checked?1:0:"TEXTAREA"==e.tagName?e.value.split("\n").filter((e=>e.trim())):"SELECT"==e.tagName?om.getSelectValues(e):e.value,{name:t,value:s}}function Ww(e){const t=Pw[e.getAttribute("type")];if("text"==t){const s=e.getElementsByTagNameNS("http://jabber.org/protocol/xdata-validate","validate");if(1===s.length){const e=s[0].getAttribute("datatype");return Uw[e]||t}}return t}function Vw(e){const t=Ow(e);try{return decodeURI(t.filename())}catch(e){return kt.debug(e),t.filename()}}function Qw(e){const t=Ow(e);return null===t?e:Rw(t)?kw(e):Nw(t)?ww(e):(Mw(t),Sw(t.toString(),Vw(t)))}function Jw(e){return Array.from(e.children).reduce(((e,t)=>t instanceof HTMLElement?e+t.offsetHeight:e),0)}function Kw(e,t){return t instanceof Element&&t.classList.contains(e)}function Yw(e,t){return t instanceof Element&&t.classList.remove(e),t}function Xw(e){const t=RegExp("^w{3}.","ig").test(e)?`http://${e}`:e,s=Ow(e);return null===s||!Dw(t)||!function(e,t=Lw){return!!t.includes(e)}(s._parts.protocol)&&s._parts.protocol?e:jw(s,e)}function Zw(e,t=200){return new Promise(((s,n)=>{if(!e){const e="An element needs to be passed in to slideOut";return kt.warn(e),void n(new Error(e))}const i=e.getAttribute("data-slider-marker");i&&!Number.isNaN(Number(i))&&(e.removeAttribute("data-slider-marker"),cancelAnimationFrame(Number(i)));const r=Jw(e);if(bh.settings.get("disable_effects"))return e.style.height=r+"px",function(e){e.removeAttribute("data-slider-marker"),e.classList.remove("collapsed"),e.style.overflow="",e.style.height=""}(e),void s();if(!Kw("collapsed",e)&&!Kw("hidden",e))return void s();const o=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",requestAnimationFrame((function t(){a+=r/o,a{if(!e){const e="An element needs to be passed in to slideIn";return kt.warn(e),n(new Error(e))}if(Kw("collapsed",e))return s(e);if(bh.settings.get("disable_effects"))return e.classList.add("collapsed"),e.style.height="",s(e);const i=e.getAttribute("data-slider-marker");i&&!Number.isNaN(Number(i))&&(e.removeAttribute("data-slider-marker"),cancelAnimationFrame(Number(i)));const r=e.offsetHeight,o=t/17;let a=r;e.style.overflow="hidden",e.setAttribute("data-slider-marker",requestAnimationFrame((function t(){a-=r/o,a>0?(e.style.height=a+"px",e.setAttribute("data-slider-marker",requestAnimationFrame(t).toString())):(e.removeAttribute("data-slider-marker"),e.classList.add("collapsed"),e.style.height="",s(e))})).toString())}))}Object.assign(om,{addClass:function(e,t){return t instanceof Element&&t.classList.add(e),t},ancestor:function(e,t){let s=e;for(;null!==s&&!Tw.matchesSelector(s,t);)s=s.parentElement;return s},calculateElementHeight:Jw,escapeHTML:function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},getElementFromTemplateResult:function(e){const t=document.createElement("div");return Gs(e,t),t.firstElementChild},getNextElement:function(e,t="*"){let s=e.nextElementSibling;for(;null!==s&&!Tw.matchesSelector(s,t);)s=s.nextElementSibling;return s},getOOBURLMarkup:Qw,getOuterWidth:function(e,t=!1){let s=e.offsetWidth;if(!t)return s;const n=window.getComputedStyle(e);return s+=parseInt(n.marginLeft?n.marginLeft:"0",10)+parseInt(n.marginRight?n.marginRight:"0",10),s},hasClass:Kw,hideElement:function(e){return e instanceof Element&&e.classList.add("hidden"),e},isEqualNode:function(e,t){if(!om.isElement(e))throw new Error("Element being compared must be an Element!");e=Bw(e),t=Bw(t);let s=e.isEqualNode(t);if(!s){const{xmlHtmlNode:n}=Iw,i=Hw.serializeToString(e),r=Hw.serializeToString(t);s=i===r||n(i).isEqualNode(n(r))}return s},isInDOM:function(e){return document.querySelector("body").contains(e)},isVisible:function(e){return null!==e&&(!Kw("hidden",e)&&(e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0))},nextUntil:function(e,t){const s=[];let n=e.nextElementSibling;for(;null!==n&&!n.matches(t);)s.push(n),n=n.nextElementSibling;return s},removeClass:Yw,removeElement:function(e){return e instanceof Element&&e.parentNode&&e.parentNode.removeChild(e),e},showElement:function(e){Yw("collapsed",e),Yw("hidden",e)},slideIn:eS,slideOut:Zw,unescapeHTML:function(e){var t=document.createElement("div");return t.innerHTML=e,t.innerText},xForm2TemplateResult:function(e,t,s={}){if("list-single"===e.getAttribute("type")||"list-multi"===e.getAttribute("type")){const t=zw(e,"value").map((e=>e?.textContent)),s=zw(e,"option").map((s=>{const n=s.querySelector("value")?.textContent;return{value:n,label:s.getAttribute("label"),selected:t.includes(n),required:!!e.querySelector("required")}}));return Aw({options:s,id:om.getUniqueId(),label:e.getAttribute("label"),multiple:"list-multi"===e.getAttribute("type"),name:e.getAttribute("var"),required:!!e.querySelector("required")})}if("fixed"===e.getAttribute("type")){const t=e.querySelector("value")?.textContent;return(e=>Cs`

    ${e.text}

    `)({text:t})}if("jid-multi"===e.getAttribute("type"))return(e=>{const t=om.getUniqueId();return Cs`
    `})({name:e.getAttribute("var"),label:e.getAttribute("label")||"",value:e.querySelector("value")?.textContent,required:!!e.querySelector("required")});if("boolean"===e.getAttribute("type")){const t=e.querySelector("value")?.textContent;return(e=>Cs`
    `)({id:om.getUniqueId(),name:e.getAttribute("var"),label:e.getAttribute("label")||"",checked:"1"===t||"true"===t?'checked="1"':""})}if("url"===e.getAttribute("var"))return Ew({label:e.getAttribute("label")||"",value:e.querySelector("value")?.textContent});if("username"===e.getAttribute("var"))return Cw({domain:" @"+s.domain,name:e.getAttribute("var"),type:Ww(e),label:e.getAttribute("label")||"",value:e.querySelector("value")?.textContent,required:!!e.querySelector("required")});if("password"===e.getAttribute("var"))return xw({name:e.getAttribute("var"),type:"password",label:e.getAttribute("label")||"",value:e.querySelector("value")?.textContent,required:!!e.querySelector("required")});if("ocr"===e.getAttribute("var")){const s=e.querySelector("uri"),n=Tw('data[cid="'+s.textContent.replace(/^cid:/,"")+'"]',t)[0];return(e=>Cs`
    ${e.label?Cs``:""}
    `)({label:e.getAttribute("label"),name:e.getAttribute("var"),data:n?.textContent,type:s.getAttribute("type"),required:!!e.querySelector("required")})}{const t=e.getAttribute("var");return xw({id:om.getUniqueId(),label:e.getAttribute("label")||"",name:t,fixed_username:s?.fixed_username,autocomplete:qw(t,s),placeholder:null,required:!!e.querySelector("required"),type:Ww(e),value:e.querySelector("value")?.textContent})}}});const tS=om,{Strophe:sS,sizzle:nS}=Zm.env;bh.elements.define("converse-adhoc-commands",class extends Ob{static get properties(){return{alert:{type:String},alert_type:{type:String},commands:{type:Array},fetching:{type:Boolean},showform:{type:String},view:{type:String}}}constructor(){super(),this.view="choose-service",this.fetching=!1,this.showform="",this.commands=[]}render(){return _w(this)}async fetchCommands(e){if(e.preventDefault(),!(e.target instanceof HTMLFormElement))return this.alert_type="danger",void(this.alert="Form could not be submitted");this.fetching=!0,delete this.alert_type,delete this.alert;const t=new FormData(e.target).get("jid").trim();let s;try{s=await bh.disco.supports(sS.NS.ADHOC,t)}catch(e){kt.error(e)}finally{this.fetching=!1}if(s)try{this.commands=await bh.adhoc.getCommands(t),this.view="list-commands"}catch(e){return kt.error(e),this.alert_type="danger",this.alert=kb("Sorry, an error occurred while looking for commands on that entity."),this.commands=[],void kt.error(e)}else this.commands=[],this.alert_type="danger",this.alert=kb("The specified entity doesn't support ad-hoc commands")}async toggleCommandForm(e){e.preventDefault();const t=e.target.getAttribute("data-command-node"),s=this.commands.filter((e=>e.node===t))[0],{jid:n}=s;if(this.showform===t)this.showform="",this.requestUpdate();else{try{const{sessionid:e,instrucions:i,fields:r,actions:o,note:a,status:c}=await bh.adhoc.fetchCommandForm(n,t);Object.assign(s,{sessionid:e,instrucions:i,fields:r,actions:o,note:a,status:c})}catch(e){null===e?kt.error(`Error: timeout while trying to execute command for ${n}`):(kt.error(`Error while trying to execute command for ${n}`),kt.error(e)),s.alert=kb("An error occurred while trying to fetch the command form"),s.alert_type="danger"}this.showform=t}}executeAction(e){e.preventDefault();const t=e.target.getAttribute("data-action");["execute","next","prev","complete"].includes(t)?this.runCommand(e.target.form,t):kt.error(`Unknown action: ${t}`)}clearCommand(e){delete e.alert,delete e.instructions,delete e.sessionid,delete e.alert_type,delete e.status,e.fields=[],e.acions=[],this.showform=""}async runCommand(e,t){const s=new FormData(e),n=s.get("command_jid").trim(),i=s.get("command_node").trim(),r=this.commands.filter((e=>e.node===i))[0];delete r.alert,this.requestUpdate();const o="prev"===t?[]:nS(":input:not([type=button]):not([type=submit])",e).filter((e=>!["command_jid","command_node"].includes(e.getAttribute("name")))).map(Gw).filter((e=>e)),a=await bh.adhoc.runCommand(n,r.sessionid,r.node,t,o),{fields:c,status:l,note:d,instructions:u,actions:h}=a;if("error"===l)return r.status=l,r.alert_type="danger",r.alert=kb("Sorry, an error occurred while trying to execute the command. See the developer console for details"),this.requestUpdate();"executing"===l?(Object.assign(r,{fields:c,instructions:u,actions:h,status:l}),r.alert=kb("Executing"),r.alert_type="primary"):"completed"===l?(this.alert_type="primary",this.alert=kb("Completed"),this.note=d,this.clearCommand(r)):(kt.error(`Unexpected status for ad-hoc command: ${l}`),r.alert=kb("Completed"),r.alert_type="primary"),this.requestUpdate()}async cancel(e){e.preventDefault(),this.showform="",this.requestUpdate();const t=new FormData(e.target.form),s=t.get("command_jid").trim(),n=t.get("command_node").trim(),i=this.commands.filter((e=>e.node===n))[0];delete i.alert,this.requestUpdate();const{status:r}=await bh.adhoc.runCommand(s,i.sessionid,i.node,"cancel",[]);"error"===r?(i.alert_type="danger",i.alert=kb("An error occurred while trying to cancel the command. See the developer console for details")):"canceled"===r?(this.alert_type="",this.alert="",this.clearCommand(i)):(kt.error(`Unexpected status for ad-hoc command: ${r}`),i.alert=kb("Error: unexpected result"),i.alert_type="danger"),this.requestUpdate()}}),Zm.plugins.add("converse-adhoc-views",{dependencies:["converse-controlbox","converse-muc"],initialize(){bh.settings.extend({allow_adhoc_commands:!0})}});const{CHATROOMS_TYPE:iS}=wb;function rS(e,t){if(bh.settings.get("allow_bookmarks")&&e.model.get("type")===iS){const s={i18n_title:kb("Bookmark this groupchat"),i18n_text:kb("Bookmark"),handler:t=>e.showBookmarkModal(t),a_class:"toggle-bookmark",icon_class:"fa-bookmark",name:"bookmark"},n=t.map((e=>e.name)).indexOf("details"),i=Np.checkBookmarksSupport().then((e=>e?s:null));return n>-1?[...t.slice(0,n),i,...t.slice(n)]:[i,...t]}return t}async function oS(e){e.preventDefault();const t=e.currentTarget.getAttribute("data-bookmark-name"),s=e.currentTarget.getAttribute("data-room-jid");await bh.confirm(kb('Are you sure you want to remove the bookmark "%1$s"?',t))&&yu.state.bookmarks.where({jid:s}).forEach((e=>e.destroy()))}function aS(e){e.preventDefault();const t=e.currentTarget.getAttribute("data-room-jid");bh.modal.show("converse-bookmark-form-modal",{jid:t},e)}function cS(e){e.preventDefault();const{Strophe:t}=Zm.env,s=e.target.textContent,n=e.target.getAttribute("data-room-jid"),i={name:s||t.unescapeNode(t.getNodeFromJid(n))||n};bh.rooms.open(n,i,!0)}const lS=e=>{const t=e.get("jid"),s=kb("Unbookmark this groupchat"),n=kb("Click to open this groupchat");return Cs``};var dS=s(1904),uS={};uS.styleTagTransform=Gb(),uS.setAttributes=Fb(),uS.insert=Pb().bind(null,"head"),uS.domAPI=zb(),uS.insertStyleElement=qb();Rb()(dS.A,uS);dS.A&&dS.A.locals&&dS.A.locals;const{initStorage:hS}=om;class mS extends Ob{async initialize(){await bh.waitUntil("bookmarksInitialized");const{bookmarks:e,chatboxes:t}=yu.state;this.liveFilter=Su((e=>this.model.set({text:e.target.value})),100),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 s=`converse.bookmarks-list-model-${yu.session.get("bare_jid")}`;this.model=new wd({id:s}),hS(this.model,s),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.model.fetch({success:()=>this.requestUpdate(),error:()=>this.requestUpdate()})}render(){return yu.state.bookmarks&&this.model?(e=>{const t=kb("Filter"),s=e.model.get("text"),{bookmarks:n}=yu.state,i=s?n.filter((e=>((e,t)=>e.get("name")?.includes(t)||e.get("jid")?.includes(t))(e,s))):n;return Cs`
    ${i.map((e=>lS(e)))}
    `})(this):A_()}clearFilter(e){e?.stopPropagation?.(),this.model.set("text","")}}bh.elements.define("converse-bookmarks",mS);bh.elements.define("converse-bookmark-list-modal",class extends t_{renderModal(){return Cs``}getModalTitle(){return kb("Bookmarks")}});class gS extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}willUpdate(e){const{chatboxes:t,bookmarks:s}=yu.state;e.has("jid")&&(this.model=t.get(this.jid),this.bookmark=s.get(this.jid))}render(){return(e=>{const t=e.model.getDisplayName(),s=e.bookmark?.get("nick")??e.model.get("nick"),n=kb('Bookmark for "%1$s"',t),i=kb("Would you like this groupchat to be automatically joined upon startup?"),r=kb("Remove"),o=kb("The name for this bookmark:"),a=kb("What should your nickname for this groupchat be?"),c=e.bookmark?kb("Update"):kb("Save");return Cs`
    ${n}
    ${e.bookmark?Cs``:""}
    `})(this)}onBookmarkFormSubmitted(e){e.preventDefault();const{bookmarks:t}=yu.state;t.createBookmark({jid:this.jid,autojoin:e.target.querySelector('input[name="autojoin"]')?.checked||!1,name:e.target.querySelector("input[name=name]")?.value,nick:e.target.querySelector("input[name=nick]")?.value}),this.closeBookmarkForm(e)}removeBookmark(e){this.bookmark?.destroy(),this.closeBookmarkForm(e)}closeBookmarkForm(e){e.preventDefault();const t=document.createEvent("Event");t.initEvent("hide.bs.modal",!0,!0),this.dispatchEvent(t)}}bh.elements.define("converse-muc-bookmark-form",gS);const fS=gS;bh.elements.define("converse-bookmark-form-modal",class extends t_{constructor(e){super(e),this.jid=null}renderModal(){return Cs``}getModalTitle(){return kb("Bookmark")}});const{u:pS}=Zm.env,vS={setBookmarkState(){const{bookmarks:e}=yu.state;if(e){e.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 yu.state.MUCBookmarkForm({model:this.model,chatroomview:this});this.querySelector(".chatroom-body").insertAdjacentElement("beforeend",this.bookmark_form.el)}pS.showElement(this.bookmark_form.el)},showBookmarkModal(e){e?.preventDefault();const t=this.model.get("jid");bh.modal.show("converse-bookmark-form-modal",{jid:t},e)}};Zm.plugins.add("converse-bookmark-views",{dependencies:["converse-chatboxes","converse-muc","converse-muc-views"],initialize(){bh.settings.extend({hide_open_bookmarks:!0});const e={removeBookmarkViaEvent:oS,addBookmarkViaEvent:aS,MUCBookmarkForm:fS,BookmarksView:mS};Object.assign(yu,e),Object.assign(yu.exports,e),Object.assign(yu.exports.ChatRoomView.prototype,vS),bh.listen.on("getHeadingButtons",rS),bh.listen.on("chatRoomViewInitialized",(e=>e.setBookmarkState()))}});const yS=(e,t,s)=>{const n=new Map;for(let i=t;i<=s;i++)n.set(e[i],i);return n},bS=R_(class extends D_{constructor(e){if(super(e),e.type!==M_)throw Error("repeat() can only be used in text expressions")}ct(e,t,s){let n;void 0===s?s=t:void 0!==t&&(n=t);const i=[],r=[];let o=0;for(const t of e)i[o]=n?n(t,o):o,r[o]=s(t,o),o++;return{values:r,keys:i}}render(e,t,s){return this.ct(e,t,s).values}update(e,[t,s,n]){var i;const r=(e=>e._$AH)(e),{values:o,keys:a}=this.ct(t,s,n);if(!Array.isArray(r))return this.ut=a,o;const c=null!==(i=this.ut)&&void 0!==i?i:this.ut=[],l=[];let d,u,h=0,m=r.length-1,g=0,f=o.length-1;for(;h<=m&&g<=f;)if(null===r[h])h++;else if(null===r[m])m--;else if(c[h]===a[g])l[g]=I_(r[h],o[g]),h++,g++;else if(c[m]===a[f])l[f]=I_(r[m],o[f]),m--,f--;else if(c[h]===a[f])l[f]=I_(r[h],o[f]),T_(e,l[f+1],r[h]),h++,f--;else if(c[m]===a[g])l[g]=I_(r[m],o[g]),T_(e,r[h],r[m]),m--,g++;else if(void 0===d&&(d=yS(a,g,f),u=yS(c,h,m)),d.has(c[h]))if(d.has(c[m])){const t=u.get(a[g]),s=void 0!==t?r[t]:null;if(null===s){const t=T_(e,r[h]);I_(t,o[g]),l[g]=t}else l[g]=I_(s,o[g]),T_(e,r[h],s),r[t]=null;g++}else N_(r[m]),m--;else N_(r[h]),h++;for(;g<=f;){const t=T_(e,l[f+1]);I_(t,o[g]),l[g++]=t}for(;h<=m;){const e=r[h++];null!==e&&N_(e)}return this.ut=a,((e,t=O_)=>{e._$AH=t})(e,l),$s}}),{CONTROLBOX_TYPE:_S,CHATROOMS_TYPE:wS,HEADLINES_TYPE:SS}=wb;function xS(e){const t="overlayed"===bh.settings.get("view_mode")&&e.get("minimized");return e.get("type")===_S||!(e.get("hidden")||t)}bh.elements.define("converse-chats",class extends Ob{initialize(){this.model=yu.state.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(yu,"connected",(()=>this.requestUpdate())),this.listenTo(yu,"reconnected",(()=>this.requestUpdate())),this.listenTo(yu,"disconnected",(()=>this.requestUpdate()));const e=bh.settings.get();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()&&Gs(Cs`
    Logo Converse converse.js
    ${"overlayed"===bh.settings.get("view_mode")?Cs`
    `:""}
    `,t);document.querySelector("body").classList.add(`converse-${bh.settings.get("view_mode")}`),bh.trigger("chatBoxViewsInitialized")}render(){return(()=>{const{chatboxes:e}=yu.state,t=bh.settings.get("view_mode"),s=bh.connection.get(),n=!s?.connected||!s?.authenticated||s?.disconnecting;return Cs`${n||"overlayed"!==t?"":Cs``} ${bS(e.filter(xS),(e=>e.get("jid")),(e=>e.get("type")===_S?Cs`${"overlayed"===t?Cs``:""}`:e.get("type")===wS?Cs``:e.get("type")===SS?Cs``:Cs``))}`})()}});const AS=class{constructor(){this.views={},this.el=null}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 ES(){const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)}var CS=s(2270),$S={};$S.styleTagTransform=Gb(),$S.setAttributes=Fb(),$S.insert=Pb().bind(null,"head"),$S.domAPI=zb(),$S.insertStyleElement=qb();Rb()(CS.A,$S);CS.A&&CS.A.locals&&CS.A.locals;Zm.plugins.add("converse-chatboxviews",{dependencies:["converse-chatboxes","converse-vcard"],initialize(){bh.promises.add(["chatBoxViewsInitialized"]),bh.settings.extend({animate:!0});const e=new AS;Object.assign(yu,{chatboxviews:e}),Object.assign(yu.state,{chatboxviews:e}),bh.listen.on("chatBoxesInitialized",(()=>{yu.state.chatboxes.on("destroy",(t=>e.remove(t.get("jid"))))})),bh.listen.on("cleanup",(()=>Object.assign(yu,{chatboxviews:null}))),bh.listen.on("cleanup",(()=>delete yu.state.chatboxviews)),bh.listen.on("clearSession",(()=>e.closeAllChatBoxes())),bh.listen.on("chatBoxViewsInitialized",ES),window.addEventListener("resize",ES),Object.assign(Zm,{insertInto(t){const s=e.el;if(s&&!t.contains(s))t.insertAdjacentElement("afterbegin",s);else if(!s)throw new Error("Cannot insert non-existing #conversejs element into the DOM")}})}});const{getURI:jS}=om;function kS(e,t){const s=jS(t),n=s.subdomain(),i=s.domain(),r=`${n?`${n}.`:""}${i}`;return e.includes(i)||e.includes(r)}function TS(e,t){const s=bh.settings.get(t);if(!Array.isArray(s))return!0;try{return kS(s,e)}catch(e){return kt.debug(e),!1}}function IS(e){return e.is_audio&&TS(e.url,"allowed_audio_domains")||e.is_video&&TS(e.url,"allowed_video_domains")||e.is_image&&TS(e.url,"allowed_image_domains")}function OS(e,t){if(!function(e){const t=jS(e),{protocol:s}=window.location;return!!["chrome-extension:","file:"].includes(s)||"http:"===s||"https:"===s&&["https","aesgcm"].includes(t.protocol().toLowerCase())}(e))return!1;const s=bh.settings.get("render_media"),n=TS(e,`allowed_${t}_domains`);return Array.isArray(s)?n&&kS(s,e):n&&s}var NS=s(4808),MS={};MS.styleTagTransform=Gb(),MS.setAttributes=Fb(),MS.insert=Pb().bind(null,"head"),MS.domAPI=zb(),MS.insertStyleElement=qb();Rb()(NS.A,MS);NS.A&&NS.A.locals&&NS.A.locals;const{getMediaURLs:RS}=om,{CHATROOMS_TYPE:DS}=wb;class zS extends Ob{static get properties(){return{is_retracted:{type:Boolean},model:{type:Object}}}constructor(){super(),this.model=null,this.is_retracted=null}initialize(){const e=bh.settings.get();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())),this.listenTo(this.model.collection.chatbox.features,"change:moderated",(()=>this.requestUpdate())),this.listenTo(this.model.collection.chatbox.occupants,"add",this.updateIfOwnOccupant),this.listenTo(this.model.collection.chatbox.occupants,"change:role",this.updateIfOwnOccupant),this.listenTo(this.model.collection.chatbox.session,"change:connection_status",(()=>this.requestUpdate()))}updateIfOwnOccupant(e){const t=yu.session.get("bare_jid");e.get("jid")===t&&this.requestUpdate()}render(){return Cs`${Q_(this.renderActions(),"")}`}async renderActions(){if(!this.model.collection)return"";const e=(await this.getActionButtons()).map((e=>zS.getActionsDropdownItem(e)));if(e.length){const t=this.model.collection.length>3&&this.model===this.model.collection.last();return Cs``}return""}static getActionsDropdownItem(e){return Cs``}async onMessageEditButtonClicked(e){e.preventDefault();const t=this.model.collection.findWhere("correcting"),s=om.ancestor(this,".chatbox")?.querySelector(".chat-textarea")?.value;if(s&&(!t||t.getMessageText()!==s)){if(!await bh.confirm(kb("You have an unsent message which will be lost if you continue. Are you sure?")))return}t!==this.model?(t?.save("correcting",!1),this.model.save("correcting",!0)):this.model.save("correcting",!1)}async onDirectMessageRetractButtonClicked(){if("me"!==this.model.get("sender"))return kt.error("onMessageRetractButtonClicked called for someone else's message!");const e=kb("Be aware that other XMPP/Jabber clients (and servers) may not yet support retractions and that this message may not be removed everywhere."),t=[kb("Are you sure you want to retract this message?")];bh.settings.get("show_retraction_warning")&&(t[1]=e);if(await bh.confirm(kb("Confirm"),t)){this.model.collection.chatbox.retractOwnMessage(this.model)}}async retractOtherMessage(e){const t=this.model.collection.chatbox,s=await t.retractOtherMessage(this.model,e);if(null===s){const e=kb("A timeout occurred while trying to retract the message");bh.alert("error",kb("Error"),e),kt.warn(e)}else if(om.isErrorStanza(s)){const e=kb("Sorry, you're not allowed to retract this message.");bh.alert("error",kb("Error"),e),kt.warn(e),kt.error(s)}}async onMUCMessageRetractButtonClicked(){const e=kb("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=[kb("Are you sure you want to retract this message?")];if(bh.settings.get("show_retraction_warning")&&(t[1]=e),await bh.confirm(kb("Confirm"),t)){this.model.collection.chatbox.retractOwnMessage(this.model)}}else if(await this.model.mayBeModerated())if("me"===this.model.get("sender")){let t=[kb("Are you sure you want to retract this message?")];bh.settings.get("show_retraction_warning")&&(t=[t[0],e,t[1]]),await bh.confirm(kb("Confirm"),t)&&this.retractOtherMessage()}else{let t=[kb("You are about to retract this message."),kb("You may optionally include a message, explaining the reason for the retraction.")];bh.settings.get("show_retraction_warning")&&(t=[t[0],e,t[1]]);const s=await bh.prompt(kb("Message Retraction"),t,kb("Optional reason"));!1!==s&&this.retractOtherMessage(s)}else{const e=kb("Sorry, you're not allowed to retract this message");bh.alert("error",kb("Error"),e)}}onMessageRetractButtonClicked(e){e?.preventDefault?.();this.model.collection.chatbox.get("type")===DS?this.onMUCMessageRetractButtonClicked():this.onDirectMessageRetractButtonClicked()}onMediaToggleClicked(e){if(e?.preventDefault?.(),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=bh.settings.get("render_media");return Array.isArray(t)?e.reduce(((e,s)=>e||!kS(t,s)),!1):!t}getMediaURLs(){const e=(this.model.get("ogp_metadata")||[]).map((e=>({url:e["og:image"],is_image:!0}))).filter((e=>IS(e))),t=RS(this.model.get("media_urls")||[],this.model.get("body")).filter((e=>IS(e)));return[...new Set([...t.map((e=>e.url)),...e.map((e=>e.url))])]}addMediaRenderingToggle(e){const t=this.getMediaURLs();if(t.length){const s=this.hasHiddenMedia(t);e.push({i18n_text:kb(s?"Show media":"Hide media"),handler:e=>this.onMediaToggleClicked(e),button_class:"chat-msg__action-hide-previews",icon_class:s?"fas fa-eye":"fas fa-eye-slash",name:"hide"})}}async onMessageCopyButtonClicked(e){e?.preventDefault?.(),await navigator.clipboard.writeText(this.model.getMessageText())}onMessageQuoteButtonClicked(e){e?.preventDefault?.();const{chatboxviews:t}=yu.state,s=t.get(this.model.collection.chatbox.get("jid"));s?.getMessageForm().insertIntoTextArea(this.model.getMessageText().replaceAll(/^/gm,"> "),!1,!1,null,"\n")}async getActionButtons(){const e=[];this.model.get("editable")&&e.push({i18n_text:this.model.get("correcting")?kb("Cancel Editing"):kb("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:kb("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),e.push({i18n_text:kb("Copy"),handler:e=>this.onMessageCopyButtonClicked(e),button_class:"chat-msg__action-copy",icon_class:"fas fa-copy",name:"copy"}),this.model.collection.chatbox.canPostMessages()&&e.push({i18n_text:kb("Quote"),handler:e=>this.onMessageQuoteButtonClicked(e),button_class:"chat-msg__action-quote",icon_class:"fas fa-quote-right",name:"quote"}),bh.hook("getMessageActionButtons",this,e)):[]}}bh.elements.define("converse-message-actions",zS);var LS=s(9956),PS={};PS.styleTagTransform=Gb(),PS.setAttributes=Fb(),PS.insert=Pb().bind(null,"head"),PS.domAPI=zb(),PS.insertStyleElement=qb();Rb()(LS.A,PS);LS.A&&LS.A.locals&&LS.A.locals;bh.elements.define("converse-image-modal",class extends t_{constructor(e){super(e),this.src=e.src}renderModal(){return(e=>Cs``)({src:this.src})}getModalTitle(){return Cs`${kb("Image: ")}${Vw(this.src)}`}});var US=s(9641);class FS{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.patchCanvas=document.createElement("canvas"),this.ctx_scaled=!1,this.frames=[],this.load_error=null,this.playing=this.options.autoplay,this.frame_idx=0,this.iteration_count=0,this.start=null,this.hovering=null,this.frameImageData=null,this.disposal_restore_from_idx=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.handleGIFResponse(e)))}initPlayer(){if(!this.load_error&&(this.options.width&&this.options.height||this.ctx.scale(this.getCanvasScale(),this.getCanvasScale()),this.frame_idx=0,this.renderImage(),this.options.autoplay)){const e=this.frames[this.frame_idx]?.delay??0;setTimeout((()=>this.play()),e)}}getNextFrameNo(){return 0===this.frames.length?0:(this.frame_idx+1+this.frames.length)%this.frames.length}onIterationEnd(){return this.iteration_count++,this.options.onIterationEnd?.(this),!this.options.loop&&(this.pause(),!0)}onAnimationFrame(e,t,s){if(!this.playing)return;if(e-tthis.onAnimationFrame(e,t,s)));const n=this.getNextFrameNo();if(0===n&&this.onIterationEnd())return;this.frame_idx=n,this.renderImage();const i=this.frames[this.frame_idx]?.delay||8;requestAnimationFrame((t=>this.onAnimationFrame(t,e,i)))}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)}doShowProgress(e,t,s){if(s&&this.options.show_progress_bar){let s=this.options.progress_bar_height;const n=(this.canvas.height-s)/(this.ctx_scaled?this.getCanvasScale():1),i=e/t*this.canvas.width/(this.ctx_scaled?this.getCanvasScale():1),r=this.canvas.width/(this.ctx_scaled?this.getCanvasScale():1);s/=this.ctx_scaled?this.getCanvasScale():1,this.ctx.fillStyle=this.options.progress_bg_color,this.ctx.fillRect(i,n,r-i,s),this.ctx.fillStyle=this.options.progress_color,this.ctx.fillRect(0,n,i,s)}}handleGIFResponse(e){try{const t=(0,US.O5)(e);this.hdr=t.header,this.lsd=t.lsd,this.setSizes(this.options.width??this.lsd.width,this.options.height??this.lsd.height),this.frames=(0,US.Ud)(t,!0)}catch(e){this.showError()}this.initPlayer(),!this.options.autoplay&&this.drawPlayIcon()}drawError(){this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.options.width,this.options.height),this.ctx.strokeStyle="red",this.ctx.lineWidth=3,this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width,this.options.height),this.ctx.moveTo(0,this.options.height),this.ctx.lineTo(this.options.width,0),this.ctx.stroke()}showError(){this.load_error=!0,this.hdr={width:this.gif_el.width,height:this.gif_el.height},this.frames=[],this.drawError(),this.el.requestUpdate()}manageDisposal(e){if(e<=0)return;const t=this.offscreenCanvas.getContext("2d"),s=this.frames[e-1].disposalType;e>1&&(3===s?null!=this.disposal_restore_from_idx&&t.putImageData(this.frames[this.disposal_restore_from_idx].data,0,0):this.disposal_restore_from_idx=e-1),2===s&&t.clearRect(this.last_frame.dims.left,this.last_frame.dims.top,this.last_frame.dims.width,this.last_frame.dims.height)}renderImage(e=!0){if(!this.frames.length)return;let t=this.frame_idx;t=parseInt(t.toString(),10),(t>this.frames.length-1||t<0)&&(t=0),this.manageDisposal(t);const s=this.frames[t],n=this.patchCanvas.getContext("2d"),i=this.offscreenCanvas.getContext("2d"),r=s.dims;this.frameImageData&&r.width==this.frameImageData.width&&r.height==this.frameImageData.height||(this.patchCanvas.width=r.width,this.patchCanvas.height=r.height,this.frameImageData=n.createImageData(r.width,r.height)),this.frameImageData.data.set(s.patch),n.putImageData(this.frameImageData,0,0),i.drawImage(this.patchCanvas,r.left,r.top);const o=i.getImageData(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height);this.ctx.putImageData(o,0,0),this.ctx.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height),e&&this.hovering&&this.drawPauseIcon(),this.last_frame=s}play(){this.playing=!0,requestAnimationFrame((e=>this.onAnimationFrame(e,0,0)))}pause(){this.playing=!1,requestAnimationFrame((()=>this.drawPlayIcon()))}drawPauseIcon(){if(!this.playing)return;this.renderImage(!1),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.renderImage(!1),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 s=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,s,0,2*Math.PI),this.ctx.stroke()}getCanvasScale(){let e;return e=this.options.max_width&&this.hdr&&this.lsd.width>this.options.max_width?this.options.max_width/this.lsd.width:1,e}fetchGIF(e){const t=vc(),s=new XMLHttpRequest;return s.open("GET",e,!0),s.responseType="arraybuffer",s?.overrideMimeType("text/plain; charset=x-user-defined"),s.onload=()=>{if(200!=s.status)return this.showError(),t.reject();t.resolve(s.response)},s.onprogress=e=>e.lengthComputable&&this.doShowProgress(e.loaded,e.total,!0),s.onerror=e=>{kt.error(e),this.showError()},s.send(),t}}var BS=s(7561),qS={};qS.styleTagTransform=Gb(),qS.setAttributes=Fb(),qS.insert=Pb().bind(null,"head"),qS.domAPI=zb(),qS.insertStyleElement=qb();Rb()(BS.A,qS);BS.A&&BS.A.locals&&BS.A.locals;bh.elements.define("converse-gif",class extends Ob{static get properties(){return{autoplay:{type:Boolean},noloop:{type:Boolean},progress_color:{type:String},fallback:{type:String},src:{type:String}}}constructor(){super(),this.src=null,this.autoplay=!1,this.noloop=!1,this.fallback="url",this.progress_color=null}initGIF(){const e={autoplay:this.autoplay,loop:!this.noloop};this.progress_color&&(e.progress_color=this.progress_color),this.supergif=new FS(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(){return this.supergif?.load_error&&["url","empty"].includes(this.fallback)?this.renderErrorFallback():Cs``}renderErrorFallback(){return"url"===this.fallback?Xw(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.frames.length>0&&(this.supergif.options.loop=!0,this.supergif.play())}});const HS=(e,t)=>Cs`${t?"":Cs`${e}`}`,{URI:GS}=Zm.env,{isURLWithImageExtension:WS}=om;const VS=R_(class extends q_{render(e,t,s,n){return t?Cs`${this.renderImage(e,t,s,n)}`:this.renderImage(e,t,s,n)}renderImage(e,t,s,n){return Cs``}onError(e,t,s,n){if(WS(e))t&&this.setValue(Xw(t));else{const i=new GS(e),r=i.filename();i.filename(`${r}.png`),this.setValue(VS(i.toString(),t,s,n))}}}),QS=e=>Cs`${VS(e.src||e.url,e.href,e.onLoad,e.onClick)}`,{dayjs:JS,u:KS}=Zm.env,{convertASCII2Emoji:YS,getShortnameReferences:XS,getCodePointReferences:ZS}=KS;function ex(e){return e.then((e=>e.filter((e=>e.standalone)).map((e=>async function(e){const t=await e;return Cs``}(e))).reverse().map((e=>Q_(e,"")))))}function tx(e){return e.then((e=>{const t=e.filter((e=>!e.standalone)).map((e=>async function(e){const t=await e;return t?Cs`${t.i18n_text}`:""}(e)));return t.length?Cs``:""}))}function sx(e){if(!e.isHidden()&&bh.settings.get("allow_url_history_change")){const t=window.location.hash;t&&e.messages.get(t.slice(1))&&history.pushState(null,"",window.location.pathname)}}const nx=Su((e=>function(e){const t=e.target;if("converse-chat-content"!==t.nodeName.toLowerCase())return;let s=!0;const n=0===Math.floor(t.scrollTop),i=Math.ceil(t.clientHeight-t.scrollTop)>=t.scrollHeight-Math.ceil(t.scrollHeight/20);n?(s=!1,sx(t.model)):i&&bh.trigger("chatBoxScrolledUp",t),t.model.get("scolled")!==s&&t.model.ui.set({scrolled:s})}(e)),50);function ix(e){const t=e.collection?.models;if(!t)return;const s=t.indexOf(e),n=t[s-1];if(!n||JS(e.get("time")).isAfter(JS(n.get("time")),"day")){const t=JS(e.get("time")).startOf("day");return(e=>Cs`

    `)({type:"date",time:t.toISOString(),datestring:t.format("dddd MMM Do YYYY")})}}function rx(e){if("groupchat"===e.get("type")){const t=bh.settings.get("muc_hats").filter((e=>e)).map((e=>e.toLowerCase()));let s=[];t.includes("vcard_roles")&&(s=e.vcard?e.vcard.get("role"):null,s=s?s.split(",").filter((e=>e)).map((e=>({title:e}))):[]);const n=[...e.occupant?[e.occupant.get("role")]:[],...e.occupant?[e.occupant.get("affiliation")]:[]].filter((e=>e)).filter((e=>t.includes(e.toLowerCase()))).map((e=>({title:e})));return[...t.includes("xep317")&&e.occupant?.get("hats")||[],...s,...n]}return[]}function ox(){var e;return Zm.emojis.toned||(Zm.emojis.toned=(e=Object.values(Zm.emojis.json.people).filter((e=>e.sn.includes("_tone"))).map((e=>e.sn.replace(/_tone[1-5]/,""))),[...new Set(e)])),Zm.emojis.toned}function ax(e,t={unicode_only:!1,add_title_wrapper:!1}){const s=e.emoji,n=e.shortname;if(s){if(t.unicode_only)return s;if(bh.settings.get("use_system_emojis"))return t.add_title_wrapper&&n?Cs`${s}`:s;{const t=bh.settings.get("emoji_image_path");return Cs`${s}`}}return t.unicode_only?n:Cs`${n}`}Object.assign(KS,{shortnamesToEmojis:function(e,t={unicode_only:!1,add_title_wrapper:!1}){return function(e,t){let s=[e];return[...XS(e),...ZS(e)].sort(((e,t)=>t.begin-e.begin)).forEach((e=>{const n=s.shift(),i=ax(e,t);s="string"==typeof i?[n.slice(0,e.begin)+i+n.slice(e.end),...s]:[n.slice(0,e.begin),i,n.slice(e.end),...s]})),s}(e=YS(e),t)}});const{convertASCII2Emoji:cx,filterQueryParamsFromURL:lx,getCodePointReferences:dx,getMediaURLs:ux,getMediaURLsMetadata:hx,getShortnameReferences:mx,isAudioURL:gx,isGIFURL:fx,isImageURL:px,isVideoURL:vx}=om;class yx extends String{constructor(e,t=0,s={}){super(e),this.embed_audio=s?.embed_audio,this.embed_videos=s?.embed_videos,this.mentions=s?.mentions||[],this.media_urls=s?.media_urls,this.nick=s?.nick,this.offset=t,this.onImgClick=s?.onImgClick,this.onImgLoad=s?.onImgLoad,this.options=s,this.payload=[],this.references=[],this.render_styling=s?.render_styling,this.show_images=s?.show_images,this.hide_media_urls=s?.hide_media_urls}shouldRenderMedia(e,t){let s;return"image"===t?s=this.show_images:"audio"===t?s=this.embed_audio:"video"===t&&(s=this.embed_videos),"boolean"==typeof s?s:OS(e,t)}addHyperlinks(e,t){const s=t+this.offset,n=this.media_urls||hx(e,t).media_urls||[];ux(n,e,s).filter((e=>!e.is_encrypted)).forEach((e=>{const s=e.url,n=lx(s);let i;i=fx(s)&&this.shouldRenderMedia(s,"image")?HS(n,this.hide_media_urls):px(s)&&this.shouldRenderMedia(s,"image")?QS({src:n,href:this.hide_media_urls?null:n,onClick:this.onImgClick,onLoad:this.onImgLoad}):vx(s)&&this.shouldRenderMedia(s,"video")?kw(n,this.hide_media_urls):gx(s)&&this.shouldRenderMedia(s,"audio")?ww(n,this.hide_media_urls):Xw(n),this.addTemplateResult(e.start+t,e.end+t,i)}))}addMapURLs(e,t){const s=/geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g,n=e.matchAll(s);for(const e of n)this.addTemplateResult(e.index+t,e.index+e[0].length+t,Xw(e[0].replace(s,bh.settings.get("geouri_replacement"))))}addEmojis(e,t){[...mx(e.toString()),...dx(e.toString())].forEach((e=>{this.addTemplateResult(e.begin+t,e.end+t,ax(e,{add_title_wrapper:!0}))}))}addMentions(e,t){const s=t+this.offset;this.mentions?.forEach((n=>{const i=Number(n.begin)-s;if(i<0||i>=s+e.length)return;const r=Number(n.end)-s,o=e.slice(i,r);o===this.nick?this.addTemplateResult(i+t,r+t,wx({...n,mention:o})):this.addTemplateResult(i+t,r+t,Sx({...n,mention:o}))}))}addStyling(){if(!function(e){for(let t=0;tArray.from({length:Number(e.end)},((t,s)=>Number(e.begin)+s))));let s=0;for(;se.includes(s))).length){s++;continue}const{d:n,length:i}=Tx(this,s);if(n&&i){const t=Ix(n),r=s+i,o=t?r:r-n.length;let a="```"===n?s+n.length+1:s+n.length;t&&" "===this[a]&&(a+=1);const c=a,l=this.slice(a,o);e.push({begin:s,template:Ox(n,l,c,this.options),end:r}),s=r}s++}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 s=0;for(const n of t)n&&(bx(n)?(e.call(this,n,s),s+=n.length):s=n.end)}async addTemplates(){await bh.trigger("beforeMessageBodyTransformed",this,{Synchronous:!0}),this.render_styling&&this.addStyling(),this.addAnnotations(this.addMentions),this.addAnnotations(this.addHyperlinks),this.addAnnotations(this.addMapURLs),await bh.emojis.initialize(),this.addAnnotations(this.addEmojis),await bh.trigger("afterMessageBodyTransformed",this,{Synchronous:!0}),this.payload=this.marshall(),this.options.show_me_message&&this.trimMeMessage(),this.payload=this.payload.map((e=>bx(e)?e:e.template))}addTemplateResult(e,t,s){this.references.push({begin:e,end:t,template:s})}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 s=e.shift();e=[s.slice(0,t.begin),t,s.slice(t.end),...e]})),e.reduce(((e,t)=>bx(t)?[...e,cx(_x(t))]:[...e,t]),[])}}const bx=e=>"string"==typeof e,_x=e=>e.replace(/\n(\u200B*\n)+/g,(e=>`\n${"​".repeat(e.length-2)}\n`)),wx=e=>Cs`${e.mention}`,Sx=e=>Cs`${e.mention}`;const xx=R_(class extends D_{render(e,t,s){const n=new yx(e,t,Object.assign(s,{show_images:!1,embed_videos:!1,embed_audio:!1}));return Cs`${Q_(async function(e){try{await e.addTemplates()}catch(e){kt.error(e)}return e.payload}(n),Cs`${n}`)}`}}),Ax=["*","_","~","`"],Ex=[...Ax,"```",">"],Cx={"*":{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"}},$x=["_",">","`","~"],jx={emphasis:(e,t,s)=>Cs`_${xx(e,t,s)}_`,preformatted:e=>Cs`\`${e}\``,preformatted_block:e=>Cs`
    \`\`\`
    ${e}
    \`\`\`
    `,quote:(e,t,s)=>Cs`
    ${xx(e,t,s)}
    `,strike:(e,t,s)=>Cs`~${xx(e,t,s)}~`,strong:(e,t,s)=>Cs`*${xx(e,t,s)}*`};function kx(e,t,s=!0){let n;if(/(^```[\s,\u200B]*\n)|(^```[\s,\u200B]*$)/.test(e.slice(t))&&(0===t||">"===e[t-1]||/\n\u200B{0,2}$/.test(e.slice(0,t))))n=e.slice(t,t+3);else{if(!Ex.includes(e.slice(t,t+1)))return null;if(n=e.slice(t,t+1),!function(e,t,s,n){if(n){const n=RegExp($x.includes(e)?`^(\\p{L}|\\p{N})${e}`:`^(\\p{L}|\\p{N})\\${e}`,"u");if(s>1&&n.test(t.slice(s-1)))return!1;if(Ix(e)&&s>0&&"\n"!==t[s-1])return!1;if(Ax.includes(e)&&t[s+1]===e)return!1}else{const n=RegExp($x.includes(e)?`^${e}(\\p{L}|\\p{N})`:`^\\${e}(\\p{L}|\\p{N})`,"u");if(s\u200B]/).shift().length)-n;if("span"===Cx[e].type){const n=t.slice(s).split("\n").shift();let i=0,r=n.indexOf(e);for(;-1!==r;){if(kx(t,s+r,!1)===e)return r+2*e.length;r=n.indexOf(e,i++)}return 0}{const n=t.slice(s+1);let i=0,r=n.indexOf(e);for(;-1!==r;){if(kx(t,s+1+r,!1)===e)return r+1+2*e.length;r=n.indexOf(e,i++)}return 0}}(s,e,t):0;return n>0?{d:s,length:n}:{}}const Ix=e=>[">",">"].includes(e);function Ox(e,t,s,n){const i=jx[Cx[e].name];if(Ix(e)){const e=t.replace(/\n\u200B*>[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?/g,(e=>`\n${"​".repeat(e.length-1)}`)).replace(/\n$/,"");return i(e,s,n)}return i(t,s,n)}class Nx{constructor(e,t,s={}){this.offset=t,this.options=s,this.text=e}async transform(){const e=new yx(this.text,this.offset,this.options);try{await e.addTemplates()}catch(e){kt.error(e)}return e.payload}render(){return Cs`${Q_(this.transform(),Cs`${this.text}`)}`}}const Mx=R_(class extends D_{render(e,t,s,n){const i=new Nx(e,t,s).render();return n?.(),i}}),Rx=Mx;var Dx=s(7013),zx={};zx.styleTagTransform=Gb(),zx.setAttributes=Fb(),zx.insert=Pb().bind(null,"head"),zx.domAPI=zb(),zx.insertStyleElement=qb();Rb()(Dx.A,zx);Dx.A&&Dx.A.locals&&Dx.A.locals;bh.elements.define("converse-chat-message-body",class extends Ob{static get properties(){return{hide_url_previews:{type:String},is_me_message:{type:Boolean},model:{type:Object},text:{type:String}}}constructor(){super(),this.text=null,this.model=null,this.hide_url_previews=null}initialize(){const e=bh.settings.get();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(),bh.modal.show("converse-image-modal",{src:e.target.src},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")&&bh.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),Rx(this.text,0,e,(()=>this.model.collection?.trigger("rendered",this.model)))}});var Lx=s(2608),Px={};Px.styleTagTransform=Gb(),Px.setAttributes=Fb(),Px.insert=Pb().bind(null,"head"),Px.domAPI=zb(),Px.insertStyleElement=qb();Rb()(Lx.A,Px);Lx.A&&Lx.A.locals&&Lx.A.locals;bh.elements.define("converse-icon",class extends Ob{static get properties(){return{color:{type:String},class_name:{attribute:"class"},css:{type:String},size:{type:String}}}constructor(){super(),this.class_name="",this.css="",this.size="",this.color=""}getSource(){return`#icon-${this.class_name.trim().split(" ")[1].replace("fa-","")}`}getStyles(){const e=this.color.match(/var\((--.*)\)/)?.[1],t=e?getComputedStyle(this).getPropertyValue(e):this.color;return`\n ${this.size?`width: ${this.size};`:""}\n ${this.size?`height: ${this.size};`:""}\n ${t?`fill: ${t};`:""}\n ${this.css}\n `}render(){return Cs``}});const{keycodes:Ux}=Zm;function Fx(e){let t=0;do{isNaN(e.offsetTop)||(t+=e.offsetTop)}while(e=e.offsetParent);return t}function Bx(e){let t=0;do{isNaN(e.offsetLeft)||(t+=e.offsetLeft)}while(e=e.offsetParent);return t}class qx{static get DIRECTION(){return{down:"down",end:"end",home:"home",left:"left",right:"right",up:"up"}}static get DEFAULTS(){return{home:[`${Ux.SHIFT}+${Ux.UP_ARROW}`],end:[`${Ux.SHIFT}+${Ux.DOWN_ARROW}`],up:[Ux.UP_ARROW],down:[Ux.DOWN_ARROW],left:[Ux.LEFT_ARROW,`${Ux.SHIFT}+${Ux.TAB}`],right:[Ux.RIGHT_ARROW,Ux.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,s)=>{const n=t(s);return nthis.keys[e]=qx.DIRECTION.down)),this.options.end.forEach((e=>this.keys[e]=qx.DIRECTION.end)),this.options.home.forEach((e=>this.keys[e]=qx.DIRECTION.home)),this.options.left.forEach((e=>this.keys[e]=qx.DIRECTION.left)),this.options.right.forEach((e=>this.keys[e]=qx.DIRECTION.right)),this.options.up.forEach((e=>this.keys[e]=qx.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()}getNextElement(e){let t;if(e===qx.DIRECTION.home)t=this.getElements(e)[0];else if(e===qx.DIRECTION.end)t=Array.from(this.getElements(e)).pop();else if(this.selected)if(e===qx.DIRECTION.right){const s=this.getElements(e);t=s.slice(s.indexOf(this.selected))[1]}else if(e==qx.DIRECTION.left){const s=this.getElements(e);t=s.slice(0,s.indexOf(this.selected)).pop()||this.selected}else if(e==qx.DIRECTION.down){const e=this.selected.offsetLeft,s=this.selected.offsetTop+this.selected.offsetHeight,n=this.elementsAfter(0,s),i=t=>Math.abs(t.offsetLeft-e)+Math.abs(t.offsetTop-s);t=qx.getClosestElement(n,i)}else{if(e!=qx.DIRECTION.up)throw new Error("getNextElement: invalid direction value");{const e=this.selected.offsetLeft,s=this.selected.offsetTop-1,n=this.elementsBefore(1/0,s),i=t=>Math.abs(e-t.offsetLeft)+Math.abs(s-t.offsetTop);t=qx.getClosestElement(n,i)}}else t=e===qx.DIRECTION.right||e===qx.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():tS.addClass(this.options.selected,e),this.selected=e,this.options.onSelected&&this.options.onSelected(e))}unselect(){this.selected&&(tS.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 qx.DIRECTION.left:document.body.scrollLeft=Bx(e)-document.body.offsetLeft;break;case qx.DIRECTION.up:document.body.scrollTop=Fx(e)-document.body.offsetTop;break;case qx.DIRECTION.right:document.body.scrollLeft=Bx(e)-document.body.offsetLeft-(document.documentElement.clientWidth-e.offsetWidth);break;case qx.DIRECTION.down:document.body.scrollTop=Fx(e)-document.body.offsetTop-(document.documentElement.clientHeight-e.offsetHeight)}}else{const s=this.scroll_container;if(!s.contains(e))return;switch(t){case qx.DIRECTION.left:s.scrollLeft=e.offsetLeft-s.offsetLeft,s.scrollTop=e.offsetTop-s.offsetTop;break;case qx.DIRECTION.up:s.scrollTop=e.offsetTop-s.offsetTop;break;case qx.DIRECTION.right:s.scrollLeft=e.offsetLeft-s.offsetLeft-(s.offsetWidth-e.offsetWidth),s.scrollTop=e.offsetTop-s.offsetTop-(s.offsetHeight-e.offsetHeight);break;case qx.DIRECTION.down:s.scrollTop=e.offsetTop-s.offsetTop-(s.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(qx.DIRECTION.down).filter((s=>s.offsetLeft>=e&&s.offsetTop>=t))}elementsBefore(e,t){return this.getElements(qx.DIRECTION.up).filter((s=>s.offsetLeft<=e&&s.offsetTop<=t))}handleKeydown(e){const t=Ux,s=e.shiftKey?this.keys[`${t.SHIFT}+${e.which}`]:this.keys[e.which];if(s){e.preventDefault(),e.stopPropagation();const t=this.getNextElement(s);this.select(t,s)}}}const Hx=qx,Gx=Zm.env.utils;class Wx extends Ob{connectedCallback(){super.connectedCallback(),this.registerEvents()}registerEvents(){this.clickOutside=e=>this._clickOutside(e),document.addEventListener("click",this.clickOutside)}firstUpdated(e){super.firstUpdated(e),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()}hideMenu(){Gx.removeClass("show",this.menu),this.button?.setAttribute("aria-expanded","false"),this.button?.blur()}showMenu(){Gx.addClass("show",this.menu),this.button.setAttribute("aria-expanded","true")}toggleMenu(e){e.preventDefault(),Gx.hasClass("show",this.menu)?this.hideMenu():this.showMenu()}handleKeyUp(e){e.keyCode===Zm.keycodes.ESCAPE&&this.hideMenu()}disconnectedCallback(){document.removeEventListener("click",this.clickOutside),super.disconnectedCallback()}}var Vx=s(7024),Qx={};Qx.styleTagTransform=Gb(),Qx.setAttributes=Fb(),Qx.insert=Pb().bind(null,"head"),Qx.domAPI=zb(),Qx.insertStyleElement=qb();Rb()(Vx.A,Qx);Vx.A&&Vx.A.locals&&Vx.A.locals;const{KEYCODES:Jx}=wb;class Kx extends Wx{static get properties(){return{icon_classes:{type:String},items:{type:Array}}}constructor(){super(),this.icon_classes="fa fa-bars",this.items=[]}render(){return Cs``}firstUpdated(){super.firstUpdated(),this.initArrowNavigation()}connectedCallback(){super.connectedCallback(),this.hideOnEscape=e=>e.keyCode===Jx.ESCAPE&&this.hideMenu(),document.addEventListener("keydown",this.hideOnEscape)}disconnectedCallback(){document.removeEventListener("keydown",this.hideOnEscape),super.disconnectedCallback()}hideMenu(){super.hideMenu(),this.navigator?.disable()}initArrowNavigation(){if(!this.navigator){const e={selector:".dropdown-item",onSelected:e=>e.focus()};this.navigator=new Hx(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!==Jx.DOWN_ARROW||this.navigator.enabled||this.enableArrowNavigation(e)}}bh.elements.define("converse-dropdown",Kx);var Yx=s(1846),Xx={};Xx.styleTagTransform=Gb(),Xx.setAttributes=Fb(),Xx.insert=Pb().bind(null,"head"),Xx.domAPI=zb(),Xx.insertStyleElement=qb();Rb()(Yx.A,Xx);Yx.A&&Yx.A.locals&&Yx.A.locals;const{dayjs:Zx}=Zm.env;bh.elements.define("converse-message-versions",class extends Ob{static get properties(){return{model:{type:Object}}}constructor(){super(),this.model=null}render(){const e=this.model.get("older_versions"),t=Object.keys(e);return Cs`${t.length?Cs`

    ${kb("Older versions")}

    ${t.map((t=>((e,t)=>Cs`

    : ${t[e]}

    `)(t,e)))}`:Cs`

    ${kb("No older versions found")}

    `}

    ${kb("Current version")}

    : ${this.model.getMessageText()}

    `}});bh.elements.define("converse-message-versions-modal",class extends t_{renderModal(){return Cs``}getModalTitle(){return kb("Message versions")}});const eA=e=>{const t=void 0!==e.model.contact,s=kb("Refresh"),n=bh.settings.get("allow_contact_removal");return Cs``},{Strophe:tA}=Zm.env,{STATUS_WEIGHTS:sA}=wb;function nA(e){yu.state.roster?.get(e.get("jid"))?.trigger("highlight")}function iA(e,t){const s=yu.state.roster_filter,n=s.get("type"),i="state"===n?s.get("state").toLowerCase():s.get("text").toLowerCase();if(!i)return!1;if("state"===n){return![yu.labels.HEADER_REQUESTING_CONTACTS,yu.labels.HEADER_UNREAD].includes(t)&&("unread_messages"===i?0===e.get("num_unread"):"online"===i?["offline","unavailable","dnd","away","xa"].includes(e.presence.get("show")):!e.presence.get("show").includes(i))}return"items"===n?!e.getFilterCriteria().includes(i):void 0}function rA(e,t){const s=e.presence.get("show")||"offline",n=t.presence.get("show")||"offline";if(sA[s]===sA[n]){const s=e.getDisplayName().toLowerCase(),n=t.getDisplayName().toLowerCase();return sn?1:0}return sA[s]t.toLowerCase()?1:0;if(d&&u)return c[e]c[t]?1:0;if(!d&&u){const e=r;return c[e]c[t]?1:0}if(d&&!u){const t=r;return c[e]c[t]?1:0}}async function aA(e){const t={mode:"cors",headers:{Accept:"text/json"}},s=`${bh.settings.get("xhr_user_search_url")}q=${encodeURIComponent(e)}`;let n;try{n=await fetch(s,t)}catch(t){return kt.error(`Failed to fetch names for query "${e}"`),kt.error(t),[]}const i=n.json;return Array.isArray(i)?i.map((e=>({label:e.fullname||e.jid,value:e.jid}))):(kt.error('Invalid JSON returned"'),[])}const cA=Zm.env.utils;bh.elements.define("converse-user-details-modal",class extends t_{initialize(){super.initialize(),this.model.rosterContactAdded.then((()=>this.registerContactEventHandlers())),this.listenTo(this.model,"change",this.render),this.registerContactEventHandlers(),bh.trigger("userDetailsModalInitialized",this.model)}renderModal(){return(e=>{const t=e.model?.vcard,s=t?t.toJSON():{},n={...e.model.toJSON(),...s},i=kb("XMPP Address"),r=kb("Email"),o=kb("Full Name"),a=kb("Nickname"),c=kb("The User's Profile Image"),l=kb("Role"),d=kb("URL"),u={alt_text:c,extra_classes:"mb-3",height:"120",width:"120"};return Cs``})(this)}renderModalFooter(){return eA(this)}getModalTitle(){return this.model.getDisplayName()}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.querySelector(".fa-refresh");cA.addClass("fa-spin",t);try{await bh.vcard.update(this.model.contact.vcard,!0)}catch(e){kt.fatal(e),this.alert(kb("Sorry, something went wrong while trying to refresh"),"danger")}cA.removeClass("fa-spin",t)}async removeContact(e){if(e?.preventDefault?.(),!bh.settings.get("allow_contact_removal"))return;await bh.confirm(kb("Are you sure you want to remove this contact?"))&&(setTimeout((()=>function(e){e.removeFromRoster((()=>e.destroy()),(t=>{t&&kt.error(t),bh.alert("error",kb("Error"),[kb("Sorry, there was an error while trying to remove %1$s as a contact.",e.getDisplayName())])}))}(this.model.contact)),1),this.modal.hide())}});const{filesize:lA}=Zm.env,{dayjs:dA}=Zm.env,{dayjs:uA}=Zm.env,{filterQueryParamsFromURL:hA,isGIFURL:mA}=om;bh.elements.define("converse-image",class extends Ob{static get properties(){return{src:{type:String},onImgLoad:{type:Function},href:{type:String}}}constructor(){super(),this.src=null,this.href=null,this.onImgClick=null,this.onImgLoad=null}render(){return mA(this.src)&&OS(this.src,"image")?HS(hA(this.src),!0):QS({src:hA(this.src),href:this.href,onClick:this.onImgClick,onLoad:this.onImgLoad})}});const{getURI:gA,isGIFURL:fA}=om;function pA(e){return!!gA(e).host()}const vA=e=>{const t=(s=e.image)&&TS(s,"allowed_image_domains")&&pA(s);var s;const n=e.title||e.description||e.url;return t||n?Cs`
    ${t?(e=>Cs``)(e):""} ${n?Cs`
    ${e.title?((e,t)=>e.url&&pA(e.url)&&!fA(e.image)?Cs`${t(e)}`:t(e))(e,(e=>Cs`
    ${e.title}
    `)):""} ${e.description?Cs`

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

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

    `:""}
    `:""}
    `:""};var yA=s(1115),bA={};bA.styleTagTransform=Gb(),bA.setAttributes=Fb(),bA.insert=Pb().bind(null,"head"),bA.domAPI=zb(),bA.insertStyleElement=qb();Rb()(yA.A,bA);yA.A&&yA.A.locals&&yA.A.locals;bh.elements.define("converse-message-unfurl",class extends Ob{static get properties(){return{description:{type:String},image:{type:String},jid:{type:String},title:{type:String},url:{type:String}}}constructor(){super(),this.jid=null,this.url=null,this.title=null,this.image=null,this.description=null}initialize(){const e=bh.settings.get();this.listenTo(e,"change:allowed_image_domains",(()=>this.requestUpdate())),this.listenTo(e,"change:render_media",(()=>this.requestUpdate()))}render(){return vA(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 _A=e=>{const t=kb("Show more"),s="groupchat"===e.model.get("type"),n=kb("Show less"),i=Cs`
    ${e.model.get("spoiler_hint")} ${e.model.get("is_spoiler_visible")?n:t}
    `,r=e.model.get("is_spoiler")?"spoiler "+(e.model.get("is_spoiler_visible")?"":"hidden"):"",o=e.model.getMessageText(),a=e.model.get("oob_url")&&o!==e.model.get("oob_url");return Cs`${e.model.get("is_spoiler")?i:""} ${e.model.get("subject")?Cs`
    ${e.model.get("subject")}
    `:""} ${!e.model.get("received")||e.model.isMeCommand()||s?"":Cs``} ${e.model.get("edited")?(e=>{const t=kb("This message has been edited");return Cs``})(e):""} ${a?Cs`
    ${Qw(e.model.get("oob_url"))}
    `:""}
    ${e.model.get("error_text")||e.model.get("error")}
    `};var wA=s(2606),SA={};SA.styleTagTransform=Gb(),SA.setAttributes=Fb(),SA.insert=Pb().bind(null,"head"),SA.domAPI=zb(),SA.insertStyleElement=qb();Rb()(wA.A,SA);wA.A&&wA.A.locals&&wA.A.locals;const{Strophe:xA,dayjs:AA}=Zm.env,{SUCCESS:EA}=wb;bh.elements.define("converse-chat-message",class extends Ob{constructor(){super(),this.jid=null,this.mid=null}static get properties(){return{jid:{type:String},mid:{type:String}}}async initialize(){if(await this.setModels(),!this.model)return void kt.error("Could not find module for converse-chat-message");const e=bh.settings.get();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 bh.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?A_():this.model.get("file")&&this.model.get("upload")!==EA?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 Cs`
    ${t}
    ${e.model.get("moderation_reason")?Cs`${e.model.get("moderation_reason")}`:""}`})(this)}renderMessageText(){return _A(this)}renderMEPMessage(){return(e=>{const t=uA(e.model.get("time")).toISOString();return Cs`
    ${e.isRetracted()?e.renderRetraction():Cs`${e.model.get("reason")?Cs``:""}`}
    `})(this)}renderInfoMessage(){return(e=>{const t=dA(e.model.get("time")).toISOString(),s=kb("Retry");return Cs`
    ${e.model.get("reason")?Cs`${e.model.get("reason")}`:""} ${e.model.get("error_text")?Cs`${e.model.get("error_text")}`:""} ${e.model.get("retry_event_id")?Cs`${s}`:""}
    `})(this)}renderFileProgress(){return this.model.file?(e=>{const t=kb("Uploading file:"),s=e.model.file.name,n=lA(e.model.file.size);return Cs`
    ${e.shouldShowAvatar()?Cs``:""}
    ${t} ${s}, ${n}
    `})(this):""}renderChatMessage(){return((e,t)=>{const s=kb("New messages"),n=e.model.isFollowup();return Cs`${t.is_first_unread?Cs`

    ${s}
    `:""}
    ${t.should_show_avatar&&!n?Cs``:""}
    ${t.is_me_message||n?"":Cs`${t.username} ${t.hats.map((e=>Cs`${e.title}`))} ${t.is_encrypted?Cs``:""}`}
    ${t.is_me_message?Cs`  ${t.is_me_message?"**":""}${t.username} `:""} ${t.is_retracted?e.renderRetraction():e.renderMessageText()}
    ${e.model.get("ogp_metadata")?.map((t=>!0===e.model.get("hide_url_previews")?"":OS(t["og:image"],"image")?Cs``:""))}
    `})(this,this.getProps())}shouldShowAvatar(){return bh.settings.get("show_message_avatar")&&!this.model.isMeCommand()&&["chat","groupchat","normal"].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 bh.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(){return this.model.occupant?.get("affiliation")}getOccupantRole(){return this.model.occupant?.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=bh.settings.get("time_format");return{pretty_time:AA(this.model.get("edited")||this.model.get("time")).format(e),has_mentions:this.hasMentions(),hats:rx(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:xA.getResourceFromJid(e)}));const s=this.model.mod?this.model.mod.getDisplayName():"A moderator";return kb("%1$s has removed this message",s)}return kb("%1$s has removed this message",this.model.getDisplayName())}showUserModal(e){if("me"===this.model.get("sender"))bh.modal.show("converse-profile-modal",{model:this.model},e);else if("groupchat"===this.model.get("type"))e.preventDefault(),bh.modal.show("converse-muc-occupant-modal",{model:this.model.getOccupant(),message:this.model},e);else{e.preventDefault();const t=this.model.collection.chatbox;bh.modal.show("converse-user-details-modal",{model:t},e)}}showMessageVersionsModal(e){e.preventDefault(),bh.modal.show("converse-message-versions-modal",{model:this.model},e)}toggleSpoilerMessage(e){e?.preventDefault(),this.model.save({is_spoiler_visible:!this.model.get("is_spoiler_visible")})}});bh.elements.define("converse-message-history",class extends Ob{constructor(){super(),this.model=null,this.messages=[]}static get properties(){return{model:{type:Object},messages:{type:Array}}}render(){const e=this.messages;return e.length?bS(e,(e=>e.get("id")),(e=>Cs`${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 s=bh.hook(t,e,"");return Q_(s,"")}{const t=Cs``,s=ix(e);return s?[s,t]:t}}});var CA=s(6373),$A={};$A.styleTagTransform=Gb(),$A.setAttributes=Fb(),$A.insert=Pb().bind(null,"head"),$A.domAPI=zb(),$A.insertStyleElement=qb();Rb()(CA.A,$A);CA.A&&CA.A.locals&&CA.A.locals;bh.elements.define("converse-chat-content",class extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("scroll",nx)}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",nx)}async setModels(){this.model=await bh.chatboxes.get(this.jid),await this.model.initialized,this.requestUpdate()}render(){return this.model?Cs`
    ${this.model.getNotificationsText()}
    ${this.model.ui?.get("chat-content-spinner-top")?A_():""}`:""}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;bh.trigger("chatBoxScrolledDown",{chatbox:this.model})}}});class jA extends D_{constructor(e){if(super(e),this.et=js,e.type!==M_)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===js||null==e)return this.ft=void 0,this.et=e;if(e===$s)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.et)return this.ft;this.et=e;const t=[e];return t.raw=t,this.ft={_$litType$:this.constructor.resultType,strings:t,values:[]}}}jA.directiveName="unsafeHTML",jA.resultType=1;const kA=R_(jA);bh.elements.define("converse-chat-help",class extends Ob{constructor(){super(),this.messages=[],this.model=null,this.type=null}static get properties(){return{chat_type:{type:String},messages:{type:Array},model:{type:Object},type:{type:String}}}render(){const e=(new Date).toISOString();return[Cs``,...this.messages.map((t=>this.renderHelpMessage({isodate:e,markup:bt().sanitize(t,{ALLOWED_TAGS:["strong"]})})))]}close(){this.model.set({show_help_messages:!1})}renderHelpMessage(e){return Cs`
    ${kA(e.markup)}
    `}});const TA=Zm.env.utils,IA=e=>{const t=bh.settings.get("emoji_categories");return Cs`
      ${Object.keys(t).map((s=>t[s]?(e=>Cs`
    • ${e.emoji}
    • `)(Object.assign({category:s,emoji:e.sn2Emoji(t[s])},e)):""))}
    `},OA=e=>Cs`
  • ${TA.shortnamesToEmojis(e.emoji.sn)}
  • `,NA=e=>{const t=bh.settings.get("emoji_categories");return Cs`${Object.keys(t).map((s=>t[s]?(e=>Cs`${kb(bh.settings.get("emoji_category_labels")[e.category])}
      ${Object.values(Zm.emojis.json[e.category]).map((t=>OA(Object.assign({emoji:t},e))))}
    `)(Object.assign({category:s},e)):""))}
    `},MA=e=>{const t=kb("Search");return Cs`
    ${e.query?"":IA(e)}
    ${e.render_emojis?Cs``:""}
    `},{sizzle:RA}=Zm.env;bh.elements.define("converse-emoji-picker-content",class extends Ob{static get properties(){return{chatview:{type:Object},search_results:{type:Array},current_skintone:{type:String},model:{type:Object},query:{type:String}}}constructor(){super(),this.model=null,this.current_skintone=null,this.query=null,this.search_results=null}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 Cs`
    ${(e=>{const t=kb("Search results");return Cs`${t}
      ${e.search_results.map((t=>OA(Object.assign({emoji:t},e))))}
    `})(e)} ${NA(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)}RA(".emoji-picker",this).forEach((e=>this.observer.observe(e)))}}setCategoryOnVisibilityChange(e){const t=this.parentElement.navigator.selected,s=e.filter((e=>e.target.contains(t))).pop();let n;if(n=s||e.reduce(((e,t)=>t.intersectionRatio>=(e?.intersectionRatio||0)?t:e),null),n&&n.isIntersecting){const e=n.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&&ox().includes(e))return!0;return!(!this.query||u_(e,this.query))}});const{CHATROOMS_TYPE:DA}=wb,{initStorage:zA}=om;bh.elements.define("converse-emoji-dropdown",class extends Kx{static get properties(){return{chatview:{type:Object},icon_classes:{type:String},items:{type:Array}}}constructor(){super(),this.render_emojis=!1,this.chatview=null}initModel(){return this.init_promise||(this.init_promise=(async()=>{await bh.emojis.initialize();const e=`converse.emoji-${yu.session.get("bare_jid")}-${this.chatview.model.get("jid")}`;this.model=new eg({id:e}),zA(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")===DA?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color";return Cs`
    `}connectedCallback(){super.connectedCallback(),this.render_emojis=!1}toggleMenu(e){e.stopPropagation(),e.preventDefault(),om.hasClass("show",this.menu)?om.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((()=>this.querySelector(".emoji-search")?.focus()))}});var LA=s(6611),PA={};PA.styleTagTransform=Gb(),PA.setAttributes=Fb(),PA.insert=Pb().bind(null,"head"),PA.domAPI=zb(),PA.insertStyleElement=qb();Rb()(LA.A,PA);LA.A&&LA.A.locals&&LA.A.locals;const{KEYCODES:UA}=wb;bh.elements.define("converse-emoji-picker",class extends Ob{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(e){super.firstUpdated(e),this.listenTo(this.model,"change",(e=>this.onModelChanged(e.changed))),this.initArrowNavigation()}constructor(){super(),this.render_emojis=null,this.chatview=null,this.model=null,this.query="",this._search_results=[],this.debouncedFilter=Su((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 MA({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=>om.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 instanceof HTMLElement&&(e.scrollTop=t.offsetTop-3*t.offsetHeight+4)}updateSearchResults(e){const t=e.get("query"),s=u_;if(this.query){if(this.query===t)return this.search_results;t&&this.query.includes(t)?this.search_results=this.search_results.filter((e=>s(e.sn,this.query))):this.search_results=Zm.emojis.list.filter((e=>s(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===UA.ENTER&&om.isVisible(this)?this.onEnterPressed(e):e.keyCode===UA.DOWN_ARROW&&!this.navigator.enabled&&om.isVisible(this)?this.enableArrowNavigation(e):e.keyCode===UA.ESCAPE&&(this.disableArrowNavigation(),setTimeout((()=>this.chatview.querySelector(".chat-textarea").focus()),50)))}setCategoryForElement(e){const t=this.current_category,s=e?.getAttribute("data-category")||t;t!==s&&this.model.save({current_category:s})}insertIntoTextArea(e){const t=this.model.get("autocompleting"),s=this.model.get("ac_position");this.model.set({autocompleting:null,query:"",ac_position:null}),this.disableArrowNavigation();const n={bubbles:!0,detail:{value:e,autocompleting:t,ac_position:s,jid:this.chatview.model.get("jid")}};this.dispatchEvent(new CustomEvent("emojiSelected",n))}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:om.ancestor(e.target,"li");this.setCategoryForElement(t),this.navigator.select(t),!this.navigator.enabled&&this.navigator.enable()}onSearchInputKeyDown(e){if(e.keyCode===UA.TAB)if(e.target.value){e.preventDefault();const t=Zm.emojis.shortnames.find((t=>u_(t,e.target.value)));t&&this.model.set({query:t})}else this.navigator.enabled||this.enableArrowNavigation(e);else e.keyCode!==UA.DOWN_ARROW||this.navigator.enabled?e.keyCode!==UA.ENTER&&e.keyCode!==UA.DOWN_ARROW&&this.debouncedFilter(e.target):this.enableArrowNavigation(e)}onEnterPressed(e){e.preventDefault(),e.stopPropagation(),Zm.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 ox().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:Hx.DIRECTION.down,picked_selector:".picked",scroll_container:this.querySelector(".emoji-picker__lists"),getSelector:t=>{if(t===Hx.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 Hx(this,t)}}disableArrowNavigation(){this.navigator?.disable()}enableArrowNavigation(e){e?.preventDefault?.(),e?.stopPropagation?.(),this.disableArrowNavigation(),this.navigator.enable(),this.navigator.handleKeydown(e)}});bh.elements.define("converse-message-limit-indicator",class extends Ob{constructor(){super(),this.model=null}static get properties(){return{model:{type:Object}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:draft",(()=>this.requestUpdate()))}render(){const e=bh.settings.get("message_limit");if(!e)return"";return(e=>{const t=kb("Message characters remaining");return Cs`${e}`})(e-(this.model.get("draft")||"").length)}});const FA=e=>Cs`${Q_(e.getButtons(),"")} ${e.show_send_button?function(){const e=kb("Send the message");return Cs``}():""}`;var BA=s(1246),qA={};qA.styleTagTransform=Gb(),qA.setAttributes=Fb(),qA.insert=Pb().bind(null,"head"),qA.domAPI=zb(),qA.insertStyleElement=qb();Rb()(BA.A,qA);BA.A&&BA.A.locals&&BA.A.locals;const HA=Zm.env.Strophe;bh.elements.define("converse-chat-toolbar",class extends Ob{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}}}constructor(){super(),this.model=null,this.is_groupchat=null,this.hidden_occupants=null,this.show_spoiler_button=null,this.show_call_button=null,this.show_emoji_button=null}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:composing_spoiler",(()=>this.requestUpdate()))}render(){return FA(this)}firstUpdated(){bh.trigger("renderToolbar",this)}getButtons(){const e=[];if(this.show_emoji_button){const t=yu.state.chatboxviews.get(this.model.get("jid"));e.push(Cs``)}if(this.show_call_button){const t=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color",s=kb("Start a call");e.push(Cs``)}bh.settings.get("message_limit")&&e.push(Cs``),this.show_spoiler_button&&e.push(this.getSpoilerButton());const t=yu.session.get("domain"),s=bh.disco.supports(HA.NS.HTTPUPLOAD,t);if(e.push(Cs`${Q_(s.then((e=>this.getHTTPUploadButton(e))),"")}`),this.is_groupchat&&bh.settings.get("visible_toolbar_buttons")?.toggle_occupants){const t=kb("Hide participants"),s=kb("Show participants");e.push(Cs``)}return yu.api.hook("getToolbarButtons",this,e)}getHTTPUploadButton(e){if(e){const e=kb("Choose a file to send"),t=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color";return Cs` `}return""}getSpoilerButton(){const e=this.model;if(!this.is_groupchat&&!e.presence?.resources.length)return;let t;t=e.get("composing_spoiler")?kb("Click to write as a normal (non-spoiler) message"):kb("Click to write your message as a spoiler");const s=this.is_groupchat?"--muc-toolbar-btn-color":"--chat-toolbar-btn-color",n=Cs``;if(this.is_groupchat)return n;{const t=e.get("jid"),s=Promise.all(e.presence.resources.map((e=>bh.disco.supports(HA.NS.SPOILER,`${t}/${e.get("name")}`)))).then((e=>e.reduce(((e,t)=>e&&t),!0)));return Cs`${Q_(s.then((()=>n)),"")}`}}toggleFileUpload(e){e?.preventDefault?.(),e?.stopPropagation?.(),this.querySelector(".fileupload").click()}onFileSelection(e){this.model.sendFiles(e.target.files)}toggleComposeSpoilerMessage(e){e?.preventDefault?.(),e?.stopPropagation?.(),this.model.set("composing_spoiler",!this.model.get("composing_spoiler"))}toggleOccupants(e){e?.preventDefault?.(),e?.stopPropagation?.(),this.model.save({hidden_occupants:!this.model.get("hidden_occupants")})}toggleCall(e){e?.preventDefault?.(),e?.stopPropagation?.(),bh.trigger("callButtonClicked",{connection:bh.connection.get(),model:this.model})}});const{HEADLINES_TYPE:GA}=wb;var WA=s(3710),VA={};VA.styleTagTransform=Gb(),VA.setAttributes=Fb(),VA.insert=Pb().bind(null,"head"),VA.domAPI=zb(),VA.insertStyleElement=qb();Rb()(WA.A,VA);WA.A&&WA.A.locals&&WA.A.locals;async function QA(e){await bh.confirm(kb("Are you sure you want to clear the messages from this conversation?"))&&await e.clearMessages()}function JA(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=""}bh.elements.define("converse-chat-heading",class extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}initialize(){const{chatboxes:e}=yu.state;this.model=e.get(this.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())),this.model.rosterContactAdded?.then((()=>{this.listenTo(this.model.contact,"change:nickname",(()=>this.requestUpdate())),this.requestUpdate()}))}render(){return(e=>{const t=kb("The User's Profile Image"),s=Cs``,n=e.model.getDisplayName();return Cs`
    ${yu.api.settings.get("singleton")?"":Cs``} ${e.type!==GA?Cs`${s}`:""}
    ${e.type!==GA?Cs`${n}`:n}
    ${Q_(tx(e.heading_buttons_promise),"")} ${Q_(ex(e.heading_buttons_promise),"")}
    ${e.status?Cs`

    ${e.status}

    `:""}`})(Object.assign(this.model.toJSON(),{heading_buttons_promise:this.getHeadingButtons(),model:this.model,showUserDetailsModal:e=>this.showUserDetailsModal(e)}))}showUserDetailsModal(e){e.preventDefault(),bh.modal.show("converse-user-details-modal",{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:kb("Details"),i18n_title:kb("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===bh.settings.get("view_mode")}];bh.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:kb("Close"),i18n_title:kb("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===bh.settings.get("view_mode")});const{chatboxviews:t}=yu.state,s=t.get(this.getAttribute("jid"));return s?yu.api.hook("getHeadingButtons",s,e):e}});const{ACTIVE:KA,COMPOSING:YA}=wb;class XA extends Ob{async initialize(){const{chatboxes:e}=yu.state;this.model=e.get(this.getAttribute("jid")),await this.model.initialized,this.listenTo(this.model.messages,"change:correcting",this.onMessageCorrecting),this.listenTo(this.model,"change:composing_spoiler",(()=>this.requestUpdate())),this.handleEmojiSelection=({detail:e})=>{this.model.get("jid")===e.jid&&this.insertIntoTextArea(e.value,e.autocompleting,!1,e.ac_position)},document.addEventListener("emojiSelected",this.handleEmojiSelection),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("emojiSelected",this.handleEmojiSelection)}render(){return(e=>{const t=e.composing_spoiler?kb("Hidden message"):kb("Message"),s=kb("Optional hint"),n=bh.settings.get("show_send_button");return Cs`
    `})(Object.assign(this.model.toJSON(),{onDrop:e=>this.onDrop(e),hint_value:this.querySelector(".spoiler-hint")?.value,message_value:this.querySelector(".chat-textarea")?.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)}))}insertIntoTextArea(e,t=!1,s=!1,n,i=" "){const r=this.querySelector(".chat-textarea");if(s?om.addClass("correcting",r):om.removeClass("correcting",r),t)r.value=n&&"string"==typeof t?r.value.replace(new RegExp(t,"g"),((s,r)=>r==n-t.length?e+i:s)):e;else{let t=r.value;t&&t[t.length-1]!==i&&(t+=i),r.value=t+e+i}const o=document.createEvent("HTMLEvents");o.initEvent("change",!1,!0),r.dispatchEvent(o),om.placeCaretAtEnd(r)}onMessageCorrecting(e){if(e.get("correcting"))this.insertIntoTextArea(om.prefixMentions(e),!0,!0);else{const t=this.model.messages.findWhere("correcting");t&&t!==e?this.insertIntoTextArea(om.prefixMentions(e),!0,!0):this.insertIntoTextArea("",!0,!1)}}onEscapePressed(e){const t=this.model.messages.findLastIndex("correcting"),s=t>=0?this.model.messages.at(t):null;s&&(e.preventDefault(),s.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")})}onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))}onKeyUp(e){this.model.set({draft:e.target.value})}onKeyDown(e){if(!e.ctrlKey){if(!e.shiftKey&&!e.altKey&&!e.metaKey)if(e.keyCode===Zm.keycodes.TAB){const t=om.getCurrentWord(e.target,null,/(:.*?:)/g);t.startsWith(":")&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("emoji-picker-autocomplete",e.target,t))}else{if(e.keyCode===Zm.keycodes.FORWARD_SLASH)return;if(e.keyCode===Zm.keycodes.ESCAPE)return this.onEscapePressed(e);if(e.keyCode===Zm.keycodes.ENTER)return this.onFormSubmitted(e);if(e.keyCode!==Zm.keycodes.UP_ARROW||e.target.selectionEnd){if(e.keyCode===Zm.keycodes.DOWN_ARROW&&e.target.selectionEnd===e.target.value.length&&om.hasClass("correcting",this.querySelector(".chat-textarea")))return this.model.editLaterMessage()}else{const e=this.querySelector(".chat-textarea");if(!e.value||om.hasClass("correcting",e))return this.model.editEarlierMessage()}}[Zm.keycodes.SHIFT,Zm.keycodes.META,Zm.keycodes.META_RIGHT,Zm.keycodes.ESCAPE,Zm.keycodes.ALT].includes(e.keyCode)||this.model.get("chat_state")!==YA&&this.model.setChatState(YA)}}async onFormSubmitted(e){e?.preventDefault?.();const{chatboxviews:t}=yu.state,s=this.querySelector(".chat-textarea"),n=s.value.trim();if(bh.settings.get("message_limit")&&n.length>bh.settings.get("message_limit")||!n.replace(/\s/g,"").length)return;if(!bh.connection.get().authenticated){const e=kb("Sorry, the connection has been lost, and your message could not be sent");return bh.alert("error",kb("Error"),e),void bh.connection.reconnect()}let i,r={};this.model.get("composing_spoiler")&&(r=this.querySelector("form.sendXMPPMessage input.spoiler-hint"),i=r.value),om.addClass("disabled",s),s.setAttribute("disabled","disabled"),this.querySelector("converse-emoji-dropdown")?.hideMenu();const o=await async function(e,t){const s=t.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(s){let n=!1;if(n=await bh.hook("parseMessageForCommands",{model:e,text:t},n),n)return!0;if("clear"===s[1])return QA(e),!0;if("close"===s[1]){const{chatboxviews:t}=yu.state;return t.get(e.get("jid"))?.close(),!0}if("help"===s[1])return e.set({show_help_messages:!1},{silent:!0}),e.set({show_help_messages:!0}),!0}return!1}(this.model,n),a=o?null:await this.model.sendMessage({body:n,spoiler_hint:i});if((o||a)&&(r.value="",s.value="",om.removeClass("correcting",s),s.style.height="auto",this.model.set({draft:""})),"overlayed"===bh.settings.get("view_mode")){t.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display="none"}if(s.removeAttribute("disabled"),om.removeClass("disabled",s),"overlayed"===bh.settings.get("view_mode")){t.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display=""}this.model.setChatState(KA,{silent:!0}),s.focus()}}bh.elements.define("converse-message-form",XA);var ZA=s(9416),eE={};eE.styleTagTransform=Gb(),eE.setAttributes=Fb(),eE.insert=Pb().bind(null,"head"),eE.domAPI=zb(),eE.insertStyleElement=qb();Rb()(ZA.A,eE);ZA.A&&ZA.A.locals&&ZA.A.locals;class tE extends Ob{async connectedCallback(){super.connectedCallback(),await this.initialize(),this.requestUpdate()}async initialize(){this.model=await bh.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.listenTo(this.model,"change:num_unread",(()=>this.requestUpdate())),this.listenTo(this.model,"emoji-picker-autocomplete",this.autocompleteInPicker),this.addEventListener("focusin",(e=>this.emitFocused(e))),this.addEventListener("focusout",(e=>this.emitBlurred(e))),this.addEventListener("click",(e=>this.sendButtonClicked(e)))}render(){return this.model?(e=>{const t=kb("You have unread messages"),s=bh.settings.get("message_limit"),n=bh.settings.get("visible_toolbar_buttons").call,i=bh.settings.get("visible_toolbar_buttons").emoji,r=bh.settings.get("show_send_button"),o=bh.settings.get("visible_toolbar_buttons").spoiler,a=bh.settings.get("show_toolbar");return Cs`${e.model.ui.get("scrolled")&&e.model.get("num_unread")?Cs`
    ▼ ${t} ▼
    `:""} ${bh.settings.get("show_toolbar")?Cs``:""}`})({model:this.model,viewUnreadMessages:e=>this.viewUnreadMessages(e)}):""}sendButtonClicked(e){if("sendMessage"===e.delegateTarget?.dataset.action){const t=this.querySelector("converse-message-form");t?.onFormSubmitted(e)}}viewUnreadMessages(e){e?.preventDefault?.(),this.model.ui.set({scrolled:!1})}emitFocused(e){const{chatboxviews:t}=yu.state;t.get(this.getAttribute("jid"))?.emitFocused(e)}emitBlurred(e){const{chatboxviews:t}=yu.state;t.get(this.getAttribute("jid"))?.emitBlurred(e)}onDragOver(e){e.preventDefault()}clearMessages(e){e?.preventDefault?.(),QA(this.model)}async autocompleteInPicker(e,t){await bh.emojis.initialize();const s=this.querySelector("converse-emoji-picker");if(s){s.model.set({ac_position:e.selectionStart,autocompleting:t,query:t});const n=this.querySelector("converse-emoji-dropdown");n?.showMenu()}}}bh.elements.define("converse-chat-bottom-panel",tE);const{CHATROOMS_TYPE:sE,INACTIVE:nE}=wb;class iE extends Ob{static get properties(){return{jid:{type:String}}}constructor(){super(),this.jid=null,this.model=null}disconnectedCallback(){super.disconnectedCallback(),yu.state.chatboxviews.remove(this.jid,this)}updated(){this.model&&this.jid!==this.model.get("jid")&&(this.stopListening(),yu.state.chatboxviews.remove(this.model.get("jid"),this),delete this.model,this.requestUpdate(),this.initialize())}close(e){return e?.preventDefault?.(),this.model.close(e)}maybeFocus(){bh.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)||bh.trigger("chatBoxBlurred",this,e)}emitFocused(e){this.contains(e.relatedTarget)||bh.trigger("chatBoxFocused",this,e)}getBottomPanel(){return this.model.get("type")===sE?this.querySelector("converse-muc-bottom-panel"):this.querySelector("converse-chat-bottom-panel")}getMessageForm(){return this.model.get("type")===sE?this.querySelector("converse-muc-message-form"):this.querySelector("converse-message-form")}scrollDown(e){e?.preventDefault?.(),e?.stopPropagation?.(),this.model.ui.get("scrolled")&&this.model.ui.set({scrolled:!1}),sx(this.model)}onWindowStateChanged(){document.hidden?(this.model.setChatState(nE,{silent:!0}),this.model.sendChatState()):this.model.isHidden()||this.model.clearUnreadMsgCounter()}}const{CHATROOMS_TYPE:rE}=wb,{ACTIVE:oE}=wb;class aE extends iE{length=200;async initialize(){const{chatboxviews:e,chatboxes:t}=yu.state;e.add(this.jid,this),this.model=t.get(this.jid),this.listenTo(this.model,"change:hidden",(()=>!this.model.get("hidden")&&this.afterShown())),this.listenTo(this.model,"change:show_help_messages",(()=>this.requestUpdate())),document.addEventListener("visibilitychange",(()=>this.onWindowStateChanged())),await this.model.messages.fetched,!this.model.get("hidden")&&this.afterShown(),bh.trigger("chatBoxViewInitialized",this)}render(){return(e=>Cs`
    ${e.model?Cs`
    ${e.show_help_messages?Cs`
    `:""}
    `:""}
    `)(Object.assign({model:this.model,help_messages:this.getHelpMessages(),show_help_messages:this.model.get("show_help_messages")},this.model.toJSON()))}getHelpMessages(){return[`/clear: ${kb("Remove messages")}`,`/close: ${kb("Close this chat")}`,`/me: ${kb("Write in the third person")}`,`/help: ${kb("Show this menu")}`]}afterShown(){this.model.setChatState(oE),this.model.clearUnreadMsgCounter(),this.maybeFocus()}}bh.elements.define("converse-chat",aE);var cE=s(4865),lE={};lE.styleTagTransform=Gb(),lE.setAttributes=Fb(),lE.insert=Pb().bind(null,"head"),lE.domAPI=zb(),lE.insertStyleElement=qb();Rb()(cE.A,lE);cE.A&&cE.A.locals&&cE.A.locals;const{Strophe:dE}=Zm.env;Zm.plugins.add("converse-chatview",{dependencies:["converse-chatboxviews","converse-chat","converse-disco","converse-modal"],initialize(){bh.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}});const e={ChatBoxView:aE,ChatView:aE};Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("connected",(()=>bh.disco.own.features.add(dE.NS.SPOILER))),bh.listen.on("chatBoxClosed",(e=>{return t=e.get("jid"),void(location.hash===`converse/chat?jid=${t}`&&history.pushState(null,"",window.location.pathname));var t}))}});bh.elements.define("converse-brand-byline",class extends Ob{render(){const e="fullscreen"===bh.settings.get("view_mode");return Cs`${e?Cs`

    ${yu.VERSION_NAME}

    Open Source XMPP chat client brought to you by Opkode

    Translate it into your own language

    `:""}`}});bh.elements.define("converse-brand-logo",class extends Ob{render(){const e="fullscreen"===bh.settings.get("view_mode");return Cs` converse.js ${e?Cs``:""}`}});bh.elements.define("converse-brand-heading",class extends Ob{render(){return Cs``}});const{Strophe:uE}=Zm.env,hE=[uE.Status.ERROR,uE.Status.CONNECTING,uE.Status.CONNFAIL,uE.Status.AUTHENTICATING,uE.Status.AUTHFAIL,uE.Status.DISCONNECTING,uE.Status.RECONNECTING],mE=Object.fromEntries([[uE.Status.ERROR,"Error"],[uE.Status.CONNECTING,"Connecting"],[uE.Status.CONNFAIL,"Connection failure"],[uE.Status.AUTHENTICATING,"Authenticating"],[uE.Status.AUTHFAIL,"Authentication failure"],[uE.Status.CONNECTED,"Connected"],[uE.Status.DISCONNECTED,"Disconnected"],[uE.Status.DISCONNECTING,"Disconnecting"],[uE.Status.ATTACHED,"Attached"],[uE.Status.REDIRECT,"Redirect"],[uE.Status.CONNTIMEOUT,"Connection timeout"],[uE.Status.RECONNECTING,"Reconnecting"]]),gE=Object.fromEntries([[uE.Status.ERROR,"error"],[uE.Status.CONNECTING,"info"],[uE.Status.CONNFAIL,"error"],[uE.Status.AUTHENTICATING,"info"],[uE.Status.AUTHFAIL,"error"],[uE.Status.CONNECTED,"info"],[uE.Status.DISCONNECTED,"error"],[uE.Status.DISCONNECTING,"warn"],[uE.Status.ATTACHED,"info"],[uE.Status.REDIRECT,"info"],[uE.Status.RECONNECTING,"warn"]]),{ANONYMOUS:fE,EXTERNAL:pE,LOGIN:vE,PREBIND:yE,CONNECTION_STATUS:bE}=wb,_E=e=>{const t=bh.settings.get("authentication"),s=kb("Log in"),n=kb("XMPP Address"),i=bh.settings.get("locked_domain"),r=bh.settings.get("default_domain"),o=(i||r)&&kb("Username")||kb("user@domain"),a=bh.settings.get("allow_user_trust_override");return Cs`
    ${t!==pE?(()=>{const e=kb("Password");return Cs`
    `})():""} ${bh.settings.get("show_connection_url_input")?(()=>{const e=kb("Connection URL"),t=kb("HTTP or websocket URL that is used to connect to your XMPP server"),s=kb("e.g. wss://example.org/xmpp-websocket");return Cs`

    ${t}

    `})():""} ${a?(e=>{const t=kb("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."),s=kb("This is a trusted device");return Cs``})("off"!==a):""}
    ${bh.settings.get("allow_registration")&&!bh.settings.get("auto_login")&&yu.pluggable.plugins["converse-register"].enabled(yu)?(()=>{const e=kb("Create an account"),t=kb("Don't have a chat account?");return Cs`

    ${t}

    `})():""}`},wE=e=>{const{connfeedback:t}=yu.state,s=t.get("connection_status");let n,i;hE.includes(s)&&(i=mE[s],n=gE[s]);const r=t.get("message");return Cs`
    ${"CONNECTING"===bE[s]?A_({classes:"hor_centered"}):(e=>{const t=bh.settings.get("authentication"),s=kb("Disconnected"),n=kb("Click here to log in anonymously");return Cs`${t==vE||t==pE?_E(e):""} ${t==fE?Cs``:""} ${t==yE?Cs`

    ${s}

    `:""}`})(e)}
    `},{Strophe:SE,u:xE}=Zm.env;function AE(){const e=yu.state.chatboxes.add(new yu.exports.ControlBox({id:"controlbox"}));return yu.state.chatboxviews.get("controlbox")?.setModel(),e}function EE(e){e?.preventDefault?.();const t=yu.state.chatboxes.get("controlbox")||AE();xE.safeSave(t,{closed:!1})}function CE(){const e=yu.state.chatboxviews.get("controlbox");return e.model.set({connected:!1}),e}function $E(){const e=yu.state.chatboxviews,t=e&&e.get("controlbox");t&&(xE.safeSave(t.model,{connected:!1}),t?.controlbox_pane&&(t.controlbox_pane.remove(),delete t.controlbox_pane))}function jE(){(yu.state.chatboxes.get("controlbox")||AE()).save({connected:!0})}const{Strophe:kE}=Zm.env,{ANONYMOUS:TE}=wb;bh.elements.define("converse-login-form",class extends Ob{initialize(){this.listenTo(yu.state.connfeedback,"change",(()=>this.requestUpdate())),this.handler=()=>this.requestUpdate()}connectedCallback(){super.connectedCallback(),bh.settings.listen.on("change",this.handler)}disconnectedCallback(){super.disconnectedCallback(),bh.settings.listen.not("change",this.handler)}render(){return wE(this)}firstUpdated(){this.initPopovers()}async onLoginFormSubmitted(e){if(e?.preventDefault(),bh.settings.get("authentication")===TE){const e=yu.session.get("jid");return this.connect(e)}(function(e){const t=e.querySelector("input[name=jid]");return!t.value||bh.settings.get("locked_domain")||bh.settings.get("default_domain")||xE.isValidJID(t.value)?(t.setCustomValidity(""),!0):(t.setCustomValidity(kb("Please enter a valid XMPP address")),!1)})(e.target)&&(!function(e,t={}){const s=new FormData(e),n=s.get("connection-url");n?.startsWith("ws")?t.websocket_url=n:n?.startsWith("http")&&(t.bosh_service_url=n);let i=s.get("jid");if(bh.settings.get("locked_domain")){const e="@"+bh.settings.get("locked_domain");i.endsWith(e)&&(i=i.substr(0,i.length-e.length)),i=SE.escapeNode(i)+e}else bh.settings.get("default_domain")&&!i.includes("@")&&(i=i+"@"+bh.settings.get("default_domain"));t.jid=i,t.password=s.get("password"),bh.settings.set(t),yu.state.config.save({trusted:!!s.get("trusted")})}(e.target),bh.settings.get("bosh_service_url")||bh.settings.get("websocket_url")||await this.discoverConnectionMethods(e),bh.settings.get("bosh_service_url")||bh.settings.get("websocket_url")?this.connect():bh.settings.set("show_connection_url_input",!0))}discoverConnectionMethods(e){if(!bh.settings.get("discover_connection_methods"))return;const t=new FormData(e.target).get("jid");if(t instanceof File)throw new Error('Found file instead of string for "jid" field in form');const s=kE.getDomainFromJid(t);return bh.connection.init(t),bh.connection.get().discoverConnectionMethods(s)}initPopovers(){Array.from(this.querySelectorAll("[data-title]")).forEach((e=>{new(Jb().Popover)(e,{trigger:"mobile"===bh.settings.get("view_mode")?"click":"hover",dismissible:"mobile"===bh.settings.get("view_mode"),container:this.parentElement.parentElement.parentElement})}))}connect(e){["converse/login","converse/register"].includes(location.hash)&&history.pushState(null,"",window.location.pathname),bh.connection.get()?.reset(),bh.user.login(e)}});const IE=e=>Cs``;class OE extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}render(){return IE(this.jid)}}bh.elements.define("converse-controlbox-navback",OE);const{dayjs:NE}=Zm.env,{CONTROLBOX_TYPE:ME}=wb;const RE=class extends wd{defaults(){return{bookmarked:!1,box_id:"controlbox",chat_state:void 0,closed:!bh.settings.get("show_controlbox_by_default"),num_unread:0,time_opened:NE(0).valueOf(),type:ME,url:""}}validate(e){return e.type===ME?"embedded"===bh.settings.get("view_mode")&&bh.settings.get("singleton")?"Controlbox not relevant in embedded view mode":void 0:yu.state.ChatBox.prototype.validate.call(this,e)}maybeShow(e){return e||"controlbox"!==this.get("id")?yu.state.ChatBox.prototype.maybeShow.call(this,e):this}onReconnection(){this.save("connected",!0)}};class DE extends Ob{async connectedCallback(){super.connectedCallback(),await bh.waitUntil("initialized");const{chatboxes:e}=yu.state;this.model=e.get("controlbox"),this.listenTo(this.model,"change:closed",(()=>this.requestUpdate())),this.requestUpdate()}render(){return(e=>{const t=bh.connection.connected()?kb("Chat Contacts"):kb("Toggle chat");return Cs`${t}`})({onClick:EE,hide:!this.model?.get("closed")})}}bh.elements.define("converse-controlbox-toggle",DE);const zE=DE,{Strophe:LE}=Zm.env,{ANONYMOUS:PE}=wb;const UE=e=>{const t=e.model.toJSON(),s=bh.settings.get("sticky_controlbox");return Cs`
    ${s?"":Cs``}
    ${t.connected?Cs`
    ${bh.settings.get("authentication")===PE?"":Cs`
    `}`:function(e){const t=yu.state.connfeedback.get("connection_status");return[LE.Status.RECONNECTING,LE.Status.CONNECTING].includes(t)?A_():"register"===e["active-form"]?Cs``:Cs``}(t)}
    `},{LOGOUT:FE}=wb;class BE extends Ob{initialize(){this.setModel();const{chatboxviews:e}=yu.state;e.add("controlbox",this),this.model.get("connected")&&void 0===this.model.get("closed")&&this.model.set("closed",!bh.settings.get("show_controlbox_by_default")),this.requestUpdate(),bh.trigger("controlBoxInitialized",this)}setModel(){this.model=yu.state.chatboxes.get("controlbox"),this.listenTo(yu.state.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?UE(this):""}close(e){e?.preventDefault?.();const t=bh.connection.get();if(("closeAllChatBoxes"!==e?.name||t.disconnection_cause===FE&&!bh.settings.get("show_controlbox_by_default"))&&!bh.settings.get("sticky_controlbox"))return om.safeSave(this.model,{closed:!0}),bh.trigger("controlBoxClosed",this),this}afterShown(){return bh.trigger("controlBoxOpened",this),this}}bh.elements.define("converse-controlbox",BE);const qE=BE,{u:HE}=Zm.env,GE={controlbox:{async open(){await bh.waitUntil("chatBoxesFetched");let e=await bh.chatboxes.get("controlbox");return e||(e=await bh.chatboxes.create("controlbox",{},RE)),HE.safeSave(e,{closed:!1}),e},get:()=>yu.state.chatboxviews.get("controlbox")}};var WE=s(1905),VE={};VE.styleTagTransform=Gb(),VE.setAttributes=Fb(),VE.insert=Pb().bind(null,"head"),VE.domAPI=zb(),VE.insertStyleElement=qb();Rb()(WE.A,VE);WE.A&&WE.A.locals&&WE.A.locals;var QE=s(8025),JE={};JE.styleTagTransform=Gb(),JE.setAttributes=Fb(),JE.insert=Pb().bind(null,"head"),JE.domAPI=zb(),JE.insertStyleElement=qb();Rb()(QE.A,JE);QE.A&&QE.A.locals&&QE.A.locals;const{CONTROLBOX_TYPE:KE}=wb;Zm.plugins.add("converse-controlbox",{dependencies:["converse-modal","converse-chatboxes","converse-chat","converse-rosterview","converse-chatview"],enabled:e=>!e.api.settings.get("singleton"),initialize(){bh.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}),bh.promises.add("controlBoxInitialized",!1),Object.assign(bh,GE);const e={ControlBox:RE,ControlBoxView:qE,ControlBoxToggle:zE};Object.assign(yu,e),Object.assign(yu.exports,e),bh.chatboxes.registry.add(KE,RE),bh.listen.on("chatBoxesFetched",jE),bh.listen.on("clearSession",$E),bh.listen.on("will-reconnect",CE),bh.waitUntil("chatBoxViewsInitialized").then(AE).catch((e=>kt.fatal(e)))}});bh.elements.define("converse-headlines-heading",class extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}async initialize(){this.model=yu.state.chatboxes.get(this.jid),await this.model.initialized,this.requestUpdate()}render(){return(e=>Cs`
    ${yu.api.settings.get("singleton")?"":Cs``}
    ${e.display_name}
    ${Q_(tx(e.heading_buttons_promise),"")} ${Q_(ex(e.heading_buttons_promise),"")}
    ${e.status?Cs`

    ${e.status}

    `:""}`)({...this.model.toJSON(),display_name:this.model.getDisplayName(),heading_buttons_promise:this.getHeadingButtons()})}getHeadingButtons(){const e=[];return bh.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:kb("Close"),i18n_title:kb("Close these announcements"),icon_class:"fa-times",name:"close",standalone:"overlayed"===bh.settings.get("view_mode")}),yu.api.hook("getHeadingButtons",this,e)}close(e){e.preventDefault(),this.model.close()}});class YE extends iE{async initialize(){const{chatboxviews:e,chatboxes:t}=yu.state;e.add(this.jid,this),this.model=t.get(this.jid),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())),document.addEventListener("visibilitychange",(()=>this.onWindowStateChanged())),await this.model.messages.fetched,this.model.maybeShow(),bh.trigger("headlinesBoxViewInitialized",this)}render(){return(e=>Cs`
    ${e?Cs`
    `:""}
    `)(this.model)}async close(e){return e?.preventDefault?.(),location.hash==="converse/chat?jid="+this.model.get("jid")&&history.pushState(null,"",window.location.pathname),await this.model.close(e),this}getNotifications(){return[]}afterShown(){this.model.clearUnreadMsgCounter()}}bh.elements.define("converse-headlines",YE);const{HEADLINES_TYPE:XE}=wb;const ZE=e=>{const t=e.model.filter((e=>e.get("type")===XE)),s=kb("Announcements");return Cs`
    ${s}
    ${t.map((t=>function(e,t){const s=kb("Click to open this server message");return Cs``}(e,t)))}
    `},{HEADLINES_TYPE:eC}=wb;class tC extends Ob{initialize(){this.model=yu.state.chatboxes,this.listenTo(this.model,"add",(e=>this.renderIfHeadline(e))),this.listenTo(this.model,"remove",(e=>this.renderIfHeadline(e))),this.listenTo(this.model,"destroy",(e=>this.renderIfHeadline(e))),this.requestUpdate()}render(){return ZE(this)}renderIfHeadline(e){return e?.get("type")===eC&&this.requestUpdate()}async openHeadline(e){e.preventDefault();const t=e.target.getAttribute("data-headline-jid");(await bh.headlines.get(t)).maybeShow(!0)}}bh.elements.define("converse-headlines-feeds-list",tC);var sC=s(5198),nC={};nC.styleTagTransform=Gb(),nC.setAttributes=Fb(),nC.insert=Pb().bind(null,"head"),nC.domAPI=zb(),nC.insertStyleElement=qb();Rb()(sC.A,nC);sC.A&&sC.A.locals&&sC.A.locals;var iC=s(8451),rC={};rC.styleTagTransform=Gb(),rC.setAttributes=Fb(),rC.insert=Pb().bind(null,"head"),rC.domAPI=zb(),rC.insertStyleElement=qb();Rb()(iC.A,rC);iC.A&&iC.A.locals&&iC.A.locals;Zm.plugins.add("converse-headlines-view",{dependencies:["converse-headlines","converse-chatview"],initialize(){const e={HeadlinesFeedsList:tC,HeadlinesPanel:tC};Object.assign(yu,e),Object.assign(yu.exports,e)}});var oC=s(4159),aC={};aC.styleTagTransform=Gb(),aC.setAttributes=Fb(),aC.insert=Pb().bind(null,"head"),aC.domAPI=zb(),aC.insertStyleElement=qb();Rb()(oC.A,aC);oC.A&&oC.A.locals&&oC.A.locals;bh.elements.define("converse-mam-placeholder",class extends Ob{static get properties(){return{model:{type:Object}}}constructor(){super(),this.model=null}render(){return(e=this).model.get("fetching")?A_({classes:"hor_centered"}):Cs`
    `;var e}async fetchMissingMessages(e){e?.preventDefault?.(),this.model.set("fetching",!0);const t={before:this.model.get("before"),start:this.model.get("start")};await om.mam.fetchArchivedMessages(this.model.collection.chatbox,t),this.model.destroy()}});const{CHATROOMS_TYPE:cC}=wb;function lC(e,t){return e instanceof lv?Cs``:t}async function dC(e){if(!e.model.ui.get("chat-content-spinner-top")&&e.model.messages.length){const t=e.model.get("type")===cC,s=e.model.getOldestMessage();if(s){const n=yu.session.get("bare_jid"),i=t?e.model.get("jid"):n,r=s&&s.get(`stanza_id ${i}`);e.model.ui.set("chat-content-spinner-top",!0);try{r?await om.mam.fetchArchivedMessages(e.model,{before:r}):await om.mam.fetchArchivedMessages(e.model,{end:s.get("time")})}catch(t){return kt.error(t),void e.model.ui.set("chat-content-spinner-top",!1)}bh.settings.get("allow_url_history_change")&&history.pushState(null,"",`#${s.get("msgid")}`),setTimeout((()=>e.model.ui.set("chat-content-spinner-top",!1)),250)}}}Zm.plugins.add("converse-mam-views",{dependencies:["converse-mam","converse-chatview","converse-muc-views"],initialize(){bh.listen.on("chatBoxScrolledUp",dC),bh.listen.on("getMessageTemplate",lC)}});const{Strophe:uC,sizzle:hC}=Zm.env;bh.elements.define("converse-muc-affiliation-form",class extends Ob{static get properties(){return{muc:{type:Object},jid:{type:String},affiliation:{type:String},alert_message:{type:String,attribute:!1},alert_type:{type:String,attribute:!1}}}constructor(){super(),this.jid=null,this.muc=null}render(){return(e=>{const t=kb("Change affiliation"),s=kb("New affiliation"),n=kb("Reason"),i=e.muc.getOwnOccupant().getAssignableAffiliations();return Cs`
    ${e.alert_message?Cs``:""}
    `})(this)}alert(e,t){this.alert_message=e,this.alert_type=t}async assignAffiliation(e){e.stopPropagation(),e.preventDefault(),this.alert();const t=new FormData(e.target),s=t.get("affiliation"),n={jid:this.jid,reason:t.get("reason")},i=this.muc.get("jid");try{await om.muc.setAffiliation(s,i,[n])}catch(e){return null===e?this.alert(kb("Timeout error while trying to set the affiliation"),"danger"):hC(`not-allowed[xmlns="${uC.NS.STANZAS}"]`,e).length?this.alert(kb("Sorry, you're not allowed to make that change"),"danger"):this.alert(kb("Sorry, something went wrong while trying to set the affiliation"),"danger"),void kt.error(e)}await this.muc.occupants.fetchMembers();const r=new CustomEvent("affiliationChanged",{bubbles:!0});this.dispatchEvent(r)}});const{Strophe:mC,sizzle:gC}=Zm.env;bh.elements.define("converse-muc-role-form",class extends Ob{static get properties(){return{muc:{type:Object},jid:{type:String},role:{type:String},alert_message:{type:String,attribute:!1},alert_type:{type:String,attribute:!1}}}constructor(){super(),this.muc=null}render(){return(e=>{const t=kb("Change role"),s=kb("New Role"),n=kb("Reason"),i=e.muc.getOwnOccupant().getAssignableRoles();return Cs`
    `})(this)}alert(e,t){this.alert_message=e,this.alert_type=t}assignRole(e){e.stopPropagation(),e.preventDefault(),this.alert();const t=new FormData(e.target),s=this.muc.getOccupant(t.get("jid")||t.get("nick")),n=t.get("role"),i=t.get("reason");this.muc.setRole(s,n,i,(()=>{const e=new CustomEvent("roleChanged",{bubbles:!0});this.dispatchEvent(e)}),(e=>{gC(`not-allowed[xmlns="${mC.NS.STANZAS}"]`,e).length?this.alert(kb("You're not allowed to make that change"),"danger"):(this.alert(kb("Sorry, something went wrong while trying to set the role"),"danger"),om.isErrorObject(e)&&kt.error(e))}))}});bh.elements.define("converse-muc-message-form",class extends XA{async initialize(){super.initialize(),await this.model.initialized,this.initMentionAutoComplete()}render(){return(e=>{const t=e.composing_spoiler?kb("Hidden message"):kb("Message"),s=kb("Optional hint"),n=bh.settings.get("show_send_button");return Cs`
    `})(Object.assign(this.model.toJSON(),{hint_value:this.querySelector(".spoiler-hint")?.value,message_value:this.querySelector(".chat-textarea")?.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")}))}shouldAutoComplete(){return this.model.session.get("connection_status")===Zm.ROOMSTATUS.ENTERED&&!(this.model.features.get("moderated")&&"visitor"===this.model.getOwnRole())}initMentionAutoComplete(){this.mention_auto_complete=new v_(this,{auto_first:!0,auto_evaluate:!1,min_chars:bh.settings.get("muc_mention_autocomplete_min_chars"),match_current_word:!0,list:()=>this.getAutoCompleteList(),filter:"contains"==bh.settings.get("muc_mention_autocomplete_filter")?u_:h_,ac_triggers:["Tab","@"],include_triggers:[],item:gw}),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.shouldAutoComplete()&&this.mention_auto_complete.onKeyDown(e)||super.onKeyDown(e)}onKeyUp(e){this.shouldAutoComplete()&&this.mention_auto_complete.evaluate(e),super.onKeyUp(e)}});var fC=s(9753),pC={};pC.styleTagTransform=Gb(),pC.setAttributes=Fb(),pC.insert=Pb().bind(null,"head"),pC.domAPI=zb(),pC.insertStyleElement=qb();Rb()(fC.A,pC);fC.A&&fC.A.locals&&fC.A.locals;class vC extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback();const{chatboxes:e}=yu.state;this.model=e.get(this.jid)}render(){return(e=>{const t=kb("Nickname"),s=e.model?.isEntered()?kb("Change nickname"):kb("Enter groupchat"),n=bh.settings.get("muc_show_logs_before_join")?kb("Choose a nickname to enter"):kb("Please choose your nickname"),i=e.model?.get("nickname_validation_message");return Cs`

    ${i}

    `})(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)}}bh.elements.define("converse-muc-nickname-form",vC);const yC=e=>{const t=kb("You have unread messages"),s=e.model.session.get("connection_status"),n=kb("You're not allowed to send messages in this room");return s===Zm.ROOMSTATUS.ENTERED?Cs`${e.model.ui.get("scrolled")&&e.model.get("num_unread_general")?Cs`
    ▼ ${t} ▼
    `:""} ${e.can_post?(e=>{const t=kb("You have unread messages"),s=bh.settings.get("message_limit"),n=bh.settings.get("visible_toolbar_buttons").call,i=bh.settings.get("visible_toolbar_buttons").emoji,r=bh.settings.get("show_send_button"),o=bh.settings.get("visible_toolbar_buttons").spoiler,a=bh.settings.get("show_toolbar");return Cs`${e.model.ui.get("scrolled")&&e.model.get("num_unread")?Cs`
    ▼ ${t} ▼
    `:""} ${a?Cs``:""}`})(e):Cs`${n}`}`:s!=Zm.ROOMSTATUS.NICKNAME_REQUIRED?"":bh.settings.get("muc_show_logs_before_join")?Cs``:void 0};var bC=s(6833),_C={};_C.styleTagTransform=Gb(),_C.setAttributes=Fb(),_C.insert=Pb().bind(null,"head"),_C.domAPI=zb(),_C.insertStyleElement=qb();Rb()(bC.A,_C);bC.A&&bC.A.locals&&bC.A.locals;bh.elements.define("converse-muc-bottom-panel",class extends tE{async initialize(){await super.initialize(),this.listenTo(this.model,"change:hidden_occupants",(()=>this.requestUpdate())),this.listenTo(this.model,"change:num_unread_general",(()=>this.requestUpdate())),this.listenTo(this.model.features,"change:moderated",(()=>this.requestUpdate())),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.requestUpdate()))}render(){if(!this.model)return"";const e=this.model.isEntered(),t=this.model.canPostMessages();return yC({can_post:t,entered:e,model:this.model,is_groupchat:!0,viewUnreadMessages:e=>this.viewUnreadMessages(e)})}renderIfOwnOccupant(e){const t=yu.session.get("bare_jid");e.get("jid")===t&&this.requestUpdate()}sendButtonClicked(e){if("sendMessage"===e.delegateTarget?.dataset.action){const t=this.querySelector("converse-muc-message-form");t?.onFormSubmitted(e)}}});var wC=s(9110),SC={};SC.styleTagTransform=Gb(),SC.setAttributes=Fb(),SC.insert=Pb().bind(null,"head"),SC.domAPI=zb(),SC.insertStyleElement=qb();Rb()(wC.A,SC);wC.A&&wC.A.locals&&wC.A.locals;bh.elements.define("converse-list-filter",class extends Ob{constructor(){super(),this.items=null,this.model=null,this.template=null,this.promise=Promise.resolve()}static get properties(){return{items:{type:Array},model:{type:Object},promise:{type:Promise},template:{type:Object}}}initialize(){this.liveFilter=Su((e=>this.model.save({text:e.target.value})),250),this.listenTo(this.items,"add",(()=>this.requestUpdate())),this.listenTo(this.items,"destroy",(()=>this.requestUpdate())),this.listenTo(this.items,"remove",(()=>this.requestUpdate())),this.listenTo(this.model,"change",(()=>{this.dispatchUpdateEvent(),this.requestUpdate()})),this.promise.then((()=>this.requestUpdate())),this.requestUpdate()}render(){return this.shouldBeVisible()?this.template(this):""}dispatchUpdateEvent(){this.dispatchEvent(new CustomEvent("update",{detail:this.model.changed}))}changeChatStateFilter(e){e&&e.preventDefault();const t=this.querySelector(".state-type").value;this.model.save({state:t})}changeTypeFilter(e){e&&e.preventDefault();const t=e.target,s=t.closest("converse-icon")?.dataset.type||"items";if("state"===s){const e=this.querySelector(".state-type").value;this.model.save({type:s,state:e})}else{const e=this.querySelector(".items-filter").value;this.model.save({type:s,text:e})}}submitFilter(e){e?.preventDefault(),this.liveFilter()}isActive(){return"state"===this.model.get("type")||this.model.get("text")}shouldBeVisible(){return this.items?.length>=5||this.isActive()}clearFilter(e){e&&e.preventDefault(),this.model.save({text:""})}});const xC={offline:"Offline",unavailable:"Unavailable",xa:"Extended Away",away:"Away",dnd:"Do not disturb",chat:"Chattty",online:"Online"},AC=e=>{const t=e.get("role"),s=(e=>kb("Click to mention %1$s in your message.",e.get("nick")))(e),n=kb("This user is a moderator."),i=kb("This user can send messages in this groupchat."),r=kb("This user can NOT send messages in this groupchat."),o=e.get("jid")?`${e.get("jid")} `:"";return"moderator"===t?`${o}${n} ${s}`:"participant"===t?`${o}${i} ${s}`:"visitor"===t?`${o}${r} ${s}`:["visitor","participant","moderator"].includes(t)?void 0:`${o}${s}`},EC=(e,t)=>{const s=e.get("affiliation"),n=xC[e.get("show")],i=kb("Admin"),r=kb("Member"),o=kb("Moderator"),a=kb("Owner"),c=kb("Visitor"),l=e.get("role"),d=e.get("show");let u,h;return[u,h]="online"===d?["fa fa-circle","chat-status-online"]:"dnd"===d?["fa fa-minus-circle","chat-status-busy"]:"away"===d?["fa fa-circle","chat-status-away"]:["fa fa-circle","subdued-color"],Cs`
  • ${e.getDisplayName()} ${"owner"===s?Cs`${a}`:""} ${"admin"===s?Cs`${i}`:""} ${"member"===s?Cs`${r}`:""} ${"moderator"===l?Cs`${o}`:""} ${"visitor"===l?Cs`${c}`:""}
  • `},CC=e=>{const t=kb("Filter"),s=kb("Filter by name"),n=kb("Filter by status"),i=kb("Any"),r=kb("Online"),o=kb("Chatty"),a=kb("Busy"),c=kb("Away"),l=kb("Extended Away"),d=kb("Offline"),u=e.model.get("state"),h=e.model.get("text"),m=e.model.get("type"),g="overlayed"===bh.settings.get("view_mode");return Cs`
    `};const $C=(e,t)=>{const s=1===e.model.occupants?kb("Participant"):kb("Participants"),n=kb("Hide sidebar"),i=kb("Show filter"),r=kb("Hide filter"),o=e.model.get("filter_visible"),a=[];return e.model.occupants<6?a.push(Cs``):(a.push(Cs`${n}`),a.push(Cs`${o?r:i}`)),Cs`
    ${e.model.occupants.length} ${s} ${1===a.length?a[0]:Cs``}
      ${o?Cs``:""} ${bS(e.model.occupants.models,(e=>e.get("jid")),(s=>function(e,t,s){return function(e,t){if(!e.model.get("filter_visible"))return!1;const s=e.filter.get("type"),n="state"===s?e.filter.get("state").toLowerCase():e.filter.get("text").toLowerCase();if(!n)return!1;if("state"===s){const e=t.get("show");return"online"===n?["offline","unavailable"].includes(e):!e.includes(n)}return"items"===s?!t.getDisplayName().toLowerCase().includes(n):void 0}(e,t)?"":EC(t,s)}(e,s,t)))}
    `};var jC=s(2910),kC={};kC.styleTagTransform=Gb(),kC.setAttributes=Fb(),kC.insert=Pb().bind(null,"head"),kC.domAPI=zb(),kC.insertStyleElement=qb();Rb()(jC.A,kC);jC.A&&jC.A.locals&&jC.A.locals;var TC=s(6826),IC={};IC.styleTagTransform=Gb(),IC.setAttributes=Fb(),IC.insert=Pb().bind(null,"head"),IC.domAPI=zb(),IC.insertStyleElement=qb();Rb()(TC.A,IC);TC.A&&TC.A.locals&&TC.A.locals;const{initStorage:OC}=om;bh.elements.define("converse-muc-sidebar",class extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}initialize(){const e=`_converse.occupants-filter-${this.jid}`;this.filter=new Jv,this.filter.id=e,OC(this.filter,e),this.filter.fetch();const{chatboxes:t}=yu.state;this.model=t.get(this.jid);const s=Su((()=>this.requestUpdate()),200,{maxWait:1e3});this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.listenTo(this.model.occupants,"add",s),this.listenTo(this.model.occupants,"remove",s),this.listenTo(this.model.occupants,"change",s),this.listenTo(this.model.occupants,"sort",s),this.listenTo(this.model.occupants,"vcard:change",s),this.listenTo(this.model.occupants,"vcard:add",s),this.model.initialized.then((()=>this.requestUpdate()))}render(){return $C(this,Object.assign(this.model.toJSON(),{occupants:[...this.model.occupants.models],onOccupantClicked:e=>this.onOccupantClicked(e)}))}toggleFilter(e){e?.preventDefault?.(),om.safeSave(this.model,{filter_visible:!this.model.get("filter_visible")})}closeSidebar(e){e?.preventDefault?.(),om.safeSave(this.model,{hidden_occupants:!0})}onOccupantClicked(e){e?.preventDefault?.();const{chatboxviews:t}=yu.state,s=t.get(this.getAttribute("jid")),n=e.target;s?.getMessageForm().insertIntoTextArea(`@${n.textContent}`)}});const{CHATROOMS_TYPE:NC}=wb,{u:MC}=Zm.env;bh.elements.define("converse-muc-chatarea",class extends Ob{static get properties(){return{jid:{type:String},show_help_messages:{type:Boolean},type:{type:String}}}constructor(){super(),this.jid=null,this.type=null}async initialize(){this.model=await bh.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=>Cs`
    ${e.model?.get("show_help_messages")?Cs`
    `:""}
    ${e.model?Cs``:""}`)({getHelpMessages:()=>this.getHelpMessages(),jid:this.jid,model:this.model,onMousedown:e=>this.onMousedown(e),show_send_button:bh.settings.get("show_send_button"),shouldShowSidebar:()=>this.shouldShowSidebar(),type:this.type})}shouldShowSidebar(){return!this.model.get("hidden_occupants")&&this.model.session.get("connection_status")===Zm.ROOMSTATUS.ENTERED}getHelpMessages(){const e=bh.settings.get("muc_disable_slash_commands"),t=Array.isArray(e)?e:[];return[`/admin: ${kb("Change user's affiliation to admin")}`,`/ban: ${kb("Ban user by changing their affiliation to outcast")}`,`/clear: ${kb("Clear the chat area")}`,`/close: ${kb("Close this groupchat")}`,`/deop: ${kb("Change user role to participant")}`,`/destroy: ${kb("Remove this groupchat")}`,`/help: ${kb("Show this menu")}`,`/kick: ${kb("Kick user from groupchat")}`,`/me: ${kb("Write in 3rd person")}`,`/member: ${kb("Grant membership to a user")}`,`/modtools: ${kb("Opens up the moderator tools GUI")}`,`/mute: ${kb("Remove user's ability to post messages")}`,`/nick: ${kb("Change your nickname")}`,`/op: ${kb("Grant moderator role to user")}`,`/owner: ${kb("Grant ownership of this groupchat")}`,`/register: ${kb("Register your nickname")}`,`/revoke: ${kb("Revoke the user's current affiliation")}`,`/subject: ${kb("Set groupchat subject")}`,`/topic: ${kb("Set groupchat subject (alias for /subject)")}`,`/voice: ${kb("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){MC.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"),s=window.getComputedStyle(t);this.width=parseInt(s.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(),s=this.calculateSidebarWidth(t,0);MC.safeSave(this.model,{occupants_width:s})}}calculateSidebarWidth(e,t){let s=e.width+t;const n=this.clientWidth;return s<.2*n?(s=.2*n,this.is_minimum=!0):s>.75*n?(s=.75*n,this.is_maximum=!0):n-s<250?(s=n-250,this.is_maximum=!0):(this.is_maximum=!1,this.is_minimum=!1),s}resizeSidebarView(e,t){const s=this.querySelector("converse-muc-sidebar"),n=s.getBoundingClientRect();if(this.is_minimum)this.is_minimum=n.leftt;else{const t=this.calculateSidebarWidth(n,e);s.style.flex="0 0 "+t+"px"}}});const{sizzle:RC}=Zm.env,DC=Zm.env.utils,{sizzle:zC}=Zm.env,LC=Zm.env.utils;class PC extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.model=yu.state.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=bh.settings.get("roomconfig_whitelist"),s=e.model.session.get("config_stanza");let n,i=[],r="";if(s){const o=DC.toStanza(s);i=RC("field",o),t.length&&(i=i.filter((e=>t.includes(e.getAttribute("var")))));const a={new_password:!e.model.features.get("passwordprotected"),fixed_username:e.model.get("jid")};i=i.map((e=>DC.xForm2TemplateResult(e,o,a))),r=o.querySelector("instructions")?.textContent,n=o.querySelector("title")?.textContent}else n=kb("Loading configuration form");const o=kb("Save"),a=kb("Cancel");return Cs`
    ${n}${n!==r?Cs`

    ${r}

    `:""} ${i.length?i:A_({classes:"hor_centered"})}
    ${i.length?Cs`
    `:""}
    `})({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=zC(":input:not([type=button]):not([type=submit])",e.target).map(LC.webForm2xForm).filter((e=>e));try{await this.model.sendConfiguration(t)}catch(e){kt.error(e);const t=kb("Sorry, an error occurred while trying to submit the config form.")+" "+kb("Check your browser's developer console for details.");bh.alert("error",kb("Error"),t)}await this.model.refreshDiscoInfo(),this.closeForm()}closeForm(e){e?.preventDefault?.(),this.model.session.set("view",null)}}bh.elements.define("converse-muc-config-form",PC);const UC=e=>{const t=kb("This groupchat no longer exists"),s=kb('The following reason was given: "%1$s"',e.reason||"");return Cs`

    ${t}

    ${e.reason?Cs`

    ${s}

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

    ${t}

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

    ${e[0]}

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

    ${e}

    `))}
    `)(t)}});const FC=e=>{const t=e.toJSON(),s=e.config.toJSON(),n=e.features.toJSON(),i=e.occupants.filter((e=>"offline"!==e.get("show"))).length,r=kb("XMPP address"),o=kb("Message archiving"),a=kb("Messages are archived on the server"),c=kb("Description"),l=kb("Features"),d=kb("Hidden"),u=kb("This groupchat is not publicly searchable"),h=kb("This groupchat is restricted to members only"),m=kb("Members only"),g=kb("Moderated"),f=kb("Participants entering this groupchat need to request permission to write"),p=kb("Name"),v=kb("This groupchat does not require a password upon entry"),y=kb("No password required"),b=kb("Not anonymous"),_=kb("All other groupchat participants can see your XMPP address"),w=kb("Not moderated"),S=kb("Participants entering this groupchat can write right away"),x=kb("Online users"),A=kb("Open"),E=kb("Anyone can join this groupchat"),C=kb("This groupchat requires a password before entry"),$=kb("Password protected"),j=kb("Persistent"),k=kb("This groupchat persists even if it's unoccupied"),T=kb("Public"),I=kb("Semi-anonymous"),O=kb("Only moderators can see your XMPP address"),N=kb("Temporary"),M=kb("This groupchat will disappear once the last person leaves");return Cs`

    ${p}: ${t.name}

    ${r}:

    ${c}:

    ${t.subject?(e=>{const t=kb("Topic"),s=kb("Topic author");return Cs`

    ${t}:

    ${s}: ${e.subject&&e.subject.author}

    `})(t):""}

    ${x}: ${i}

    ${l}:

      ${n.passwordprotected?Cs`
    • ${$} - ${C}
    • `:""} ${n.unsecured?Cs`
    • ${y} - ${v}
    • `:""} ${n.hidden?Cs`
    • ${d} - ${u}
    • `:""} ${n.public_room?Cs`
    • ${T} - ${t.__("This groupchat is publicly searchable")}
    • `:""} ${n.membersonly?Cs`
    • ${m} - ${h}
    • `:""} ${n.open?Cs`
    • ${A} - ${E}
    • `:""} ${n.persistent?Cs`
    • ${j} - ${k}
    • `:""} ${n.temporary?Cs`
    • ${N} - ${M}
    • `:""} ${n.nonanonymous?Cs`
    • ${b} - ${_}
    • `:""} ${n.semianonymous?Cs`
    • ${I} - ${O}
    • `:""} ${n.moderated?Cs`
    • ${g} - ${f}
    • `:""} ${n.unmoderated?Cs`
    • ${w} - ${S}
    • `:""} ${n.mam_enabled?Cs`
    • ${o} - ${a}
    • `:""}

    `};var BC=s(3180),qC={};qC.styleTagTransform=Gb(),qC.setAttributes=Fb(),qC.insert=Pb().bind(null,"head"),qC.domAPI=zb(),qC.insertStyleElement=qb();Rb()(BC.A,qC);BC.A&&BC.A.locals&&BC.A.locals;bh.elements.define("converse-muc-details-modal",class extends t_{initialize(){super.initialize(),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()))}renderModal(){return FC(this.model)}getModalTitle(){return kb("Groupchat info for %1$s",this.model.getDisplayName())}});const HC=Zm.env.utils;bh.elements.define("converse-muc-invite-modal",class extends t_{constructor(e){super(e),this.id="converse-modtools-modal",this.chatroomview=e.chatroomview}initialize(){super.initialize(),this.listenTo(this.model,"change",(()=>this.render()))}renderModal(){return(e=>{const t=kb("Invite"),s=kb("user@example.org"),n=kb("Please enter a valid XMPP address"),i=kb("XMPP Address"),r=kb("Optional reason for the invitation");return Cs`
    ${e.model.get("invalid_invite_jid")?Cs`
    ${n}
    `:""}
    `})(this)}getModalTitle(){return kb("Invite someone to this groupchat")}getAutoCompleteList(){return yu.state.roster.map((e=>({label:e.getDisplayName(),value:e.get("jid")})))}submitInviteForm(e){e.preventDefault();const t=new FormData(e.target),s=t.get("invitee_jids")?.trim(),n=t.get("reason");HC.isValidJID(s)?(this.chatroomview.model.directInvite(s,n),this.modal.hide()):this.model.set({invalid_invite_jid:!0})}});bh.elements.define("converse-muc-nickname-modal",class extends t_{renderModal(){return Cs``}getModalTitle(){return kb("Change your nickname")}});var GC=s(1549),WC={};WC.styleTagTransform=Gb(),WC.setAttributes=Fb(),WC.insert=Pb().bind(null,"head"),WC.domAPI=zb(),WC.insertStyleElement=qb();Rb()(GC.A,WC);GC.A&&GC.A.locals&&GC.A.locals;bh.elements.define("converse-rich-text",class extends Ob{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.nick=null,this.onImgClick=null,this.onImgLoad=null,this.text=null,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 Rx(this.text,this.offset,e)}});var VC=s(2444),QC={};QC.styleTagTransform=Gb(),QC.setAttributes=Fb(),QC.insert=Pb().bind(null,"head"),QC.domAPI=zb(),QC.insertStyleElement=qb();Rb()(VC.A,QC);VC.A&&VC.A.locals&&VC.A.locals;bh.elements.define("converse-muc-heading",class extends Ob{async initialize(){const{chatboxes:e}=yu.state;this.model=e.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 yu.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=>{const t=e.model.toJSON(),s=e.user_settings?.get("mucs_with_hidden_subject",[])?.includes(e.model.get("jid")),n=e.getHeadingButtons(s),i=kb("Hide the groupchat topic"),r=kb("This groupchat is bookmarked"),o=t.subject?t.subject.text:"",a=o&&!s,c=e.model.vcard?.get("image");return Cs`
    ${c&&c!==yu.DEFAULT_IMAGE?Cs``:""}
    ${yu.api.settings.get("singleton")?"":Cs``}
    ${e.model.getDisplayName()} ${t.bookmarked?Cs``:""}
    ${Q_(ex(n),"")} ${Q_(tx(n),"")}
    ${a?Cs`

    `:""}`})(this):""}onOccupantAdded(e){const t=yu.session.get("bare_jid");e.get("jid")===t&&this.requestUpdate()}onOccupantAffiliationChanged(e){const t=yu.session.get("bare_jid");e.get("jid")===t&&this.requestUpdate()}showRoomDetailsModal(e){e.preventDefault(),bh.modal.show("converse-muc-details-modal",{model:this.model},e)}showInviteModal(e){e.preventDefault(),bh.modal.show("converse-muc-invite-modal",{model:new wd,chatroomview:this},e)}toggleTopic(e){e?.preventDefault?.(),this.model.toggleSubjectHiddenState()}getAndRenderConfigurationForm(){this.model.session.set("view",Zm.MUC.VIEWS.CONFIG)}close(e){e.preventDefault(),this.model.close()}destroy(e){e.preventDefault(),hw(this.model)}getHeadingButtons(e){const t=[];t.push({i18n_text:kb("Details"),i18n_title:kb("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:kb("Configure"),i18n_title:kb("Configure this groupchat"),handler:()=>this.getAndRenderConfigurationForm(),a_class:"configure-chatroom-button",icon_class:"fa-wrench",name:"configure"}),t.push({i18n_text:kb("Nickname"),i18n_title:kb("Change the nickname you're using in this groupchat"),handler:e=>bh.modal.show("converse-muc-nickname-modal",{model:this.model},e),a_class:"open-nickname-modal",icon_class:"fa-smile",name:"nickname"}),this.model.invitesAllowed()&&t.push({i18n_text:kb("Invite"),i18n_title:kb("Invite someone to join this groupchat"),handler:e=>this.showInviteModal(e),a_class:"open-invite-modal",icon_class:"fa-user-plus",name:"invite"});const s=this.model.get("subject");s&&s.text&&t.push({i18n_text:kb(e?"Show topic":"Hide topic"),i18n_title:kb(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")===Zm.ROOMSTATUS.ENTERED){const e=this.model.getAllowedCommands();e.includes("modtools")&&t.push({i18n_text:kb("Moderate"),i18n_title:kb("Moderate this groupchat"),handler:()=>yw(this.model),a_class:"moderate-chatroom-button",icon_class:"fa-user-cog",name:"moderate"}),e.includes("destroy")&&t.push({i18n_text:kb("Destroy"),i18n_title:kb("Remove this groupchat"),handler:e=>this.destroy(e),a_class:"destroy-chatroom-button",icon_class:"fa-trash",name:"destroy"})}bh.settings.get("singleton")||t.push({i18n_text:kb("Leave"),i18n_title:kb("Leave and close this groupchat"),handler:async e=>{e.stopPropagation();const t=[kb("Are you sure you want to leave this groupchat?")];await bh.confirm(kb("Confirm"),t)&&this.close(e)},a_class:"close-chatbox-button",standalone:"overlayed"===bh.settings.get("view_mode"),icon_class:"fa-sign-out-alt",name:"signout"});const{chatboxviews:n}=yu.state,i=n.get(this.getAttribute("jid"));return i?yu.api.hook("getHeadingButtons",i,t):Promise.resolve(t)}});class JC extends Ob{static get properties(){return{jid:{type:String}}}constructor(){super(),this.jid=null}connectedCallback(){super.connectedCallback();const{chatboxes:e}=yu.state;this.model=e.get(this.jid),this.listenTo(this.model,"change:password_validation_message",this.render),this.render()}render(){return(e=>{const t=kb("This groupchat requires a password"),s=kb("Password: "),n=kb("Submit");return Cs`

    ${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)}}bh.elements.define("converse-muc-password-form",JC);class KC extends iE{length=300;is_chatroom=!0;async initialize(){this.model=await bh.rooms.get(this.jid),yu.state.chatboxviews.add(this.jid,this),this.setAttribute("id",this.model.get("box_id")),this.listenTo(this.model.session,"change:connection_status",this.onConnectionStatusChanged),this.listenTo(this.model.session,"change:view",(()=>this.requestUpdate())),document.addEventListener("visibilitychange",(()=>this.onWindowStateChanged())),this.onConnectionStatusChanged(),this.model.maybeShow(),bh.trigger("chatRoomViewInitialized",this)}render(){return(e=>Cs`
    ${e.model?Cs`
    ${mw(e)}
    `:""}
    `)({model:this.model})}onConnectionStatusChanged(){this.model.session.get("connection_status")===Zm.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()}}bh.elements.define("converse-muc",KC);var YC=s(5628),XC={};XC.styleTagTransform=Gb(),XC.setAttributes=Fb(),XC.insert=Pb().bind(null,"head"),XC.domAPI=zb(),XC.insertStyleElement=qb();Rb()(YC.A,XC);YC.A&&YC.A.locals&&YC.A.locals;const{Strophe:ZC}=Zm.env,{CHATROOMS_TYPE:e$}=wb;Zm.MUC.VIEWS={CONFIG:"config-form"},Zm.plugins.add("converse-muc-views",{dependencies:["converse-modal","converse-controlbox","converse-chatview"],initialize(){const{_converse:e}=this;bh.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,muc_search_service:"api@search.jabber.network",roomconfig_whitelist:[],show_retraction_warning:!0,visible_toolbar_buttons:{toggle_occupants:!0}});const t={ChatRoomView:KC,MUCView:KC};Object.assign(e,t),Object.assign(e.exports,t),bh.settings.get("muc_domain")||bh.listen.on("serviceDiscovered",(async e=>{if(e?.get("var")===ZC.NS.MUC){if(e.entity.get("jid").includes("@"))return;await e.entity.getIdentity("conference","text")&&bh.settings.set("muc_domain",ZC.getDomainFromJid(e.get("from")))}})),bh.listen.on("clearsession",(()=>{const t=e.chatboxviews.get("controlbox");t&&t.roomspanel&&(t.roomspanel.model.destroy(),t.roomspanel.remove(),delete t.roomspanel)})),bh.listen.on("chatBoxClosed",(e=>{var t;e.get("type")===e$&&(t=e.get("jid"),location.hash===`converse/room?jid=${t}`&&history.pushState(null,"",window.location.pathname))})),bh.listen.on("parseMessageForCommands",bw),bh.listen.on("confirmDirectMUCInvitation",uw)}});const t$=class extends wd{defaults(){return{collapsed:!1}}};bh.elements.define("converse-minimized-chats",class extends Ob{async initialize(){this.model=yu.state.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(yu,"connected",(()=>this.requestUpdate())),this.listenTo(yu,"reconnected",(()=>this.requestUpdate())),this.listenTo(yu,"disconnected",(()=>this.requestUpdate()))}render(){const e=this.model.where({minimized:!0}),t=e.reduce(((e,t)=>e+t.get("num_unread")),0),s=e.reduce(((e,t)=>e+(t.get("minimized")?1:0)),0),n={chats:e,num_unread:t,num_minimized:s,collapsed:this.minchats.get("collapsed")};return n.toggle=e=>this.toggle(e),(e=>Cs``)(n)}async initToggle(){const e=`converse.minchatstoggle-${yu.session.get("bare_jid")}`;this.minchats=new t$({id:e}),om.initStorage(this.minchats,e,"session"),await new Promise((e=>this.minchats.fetch({success:e,error:e})))}toggle(e){e?.preventDefault(),this.minchats.save({collapsed:!this.minchats.get("collapsed")})}});const{dayjs:s$}=Zm.env,{ACTIVE:n$,INACTIVE:i$}=wb;function r$(e){if("controlbox"===e.model.get("id")){if(om.isVisible(e))return om.getOuterWidth(e,!0);{const e=document.querySelector("converse-controlbox-toggle");return e?om.getOuterWidth(e,!0):0}}return!e.model.get("minimized")&&om.isVisible(e)?om.getOuterWidth(e,!0):0}function o$(){const e=document.querySelector("converse-minimized-chats");return yu.state.chatboxes.pluck("minimized").includes(!0)?om.getOuterWidth(e,!0):0}function a$(e){const t=e?e.model.get("id"):null,s=e?om.getOuterWidth(e,!0):0;return Object.values(yu.state.chatboxviews.xget(t)).reduce(((e,t)=>e+r$(t)),s)}function c$(e){if(om.isTestEnv()||bh.settings.get("no_trimming")||"overlayed"!==bh.settings.get("view_mode"))return;const t=yu.state.chatboxviews.filter((e=>!e.model.get("minimized")&&!e.model.get("closed")&&om.isVisible(e)));if(t.length<=1)return;const s=om.getOuterWidth(document.querySelector("body"),!0);if(r$(t[0])===s)return;if(document.querySelector("converse-minimized-chats"))for(;o$()+a$(e)>s;){const t=l$([e?e.model.get("id"):null]);if(!t)break;{const e=yu.state.chatboxes.get(t.get("id"));e?.save("hidden",!0),u$(t)}}}function l$(e){e.push("controlbox");let t=0,s=yu.state.chatboxes.sort().at(t);for(;e.includes(s.get("id"))||!0===s.get("minimized");)if(t++,s=yu.state.chatboxes.at(t),!s)return null;return s}function d$(e,t){e?.preventDefault?e.preventDefault():t=e,om.safeSave(t,{hidden:!1,minimized:!1,time_opened:(new Date).getTime()})}function u$(e,t){e?.preventDefault?e.preventDefault():t=e,t.setChatState(i$),om.safeSave(t,{hidden:!0,minimized:!0,time_minimized:(new Date).toISOString()})}function h$(e){e.get("minimized")?function(e){bh.trigger("chatBoxMinimized",e)}(e):function(e){e.isScrolledUp()||e.clearUnreadMsgCounter(),e.setChatState(n$),bh.trigger("chatBoxMaximized",e)}(e)}bh.elements.define("converse-minimized-chat",class extends Ob{static get properties(){return{model:{type:Object},title:{type:String},type:{type:String},num_unread:{type:Number}}}constructor(){super(),this.model=null,this.num_unread=null,this.type=null,this.title=null}render(){return(e=>{const t=kb("Click to restore this chat");let s;return s="chatroom"===e.type?"var(--chatroom-head-color)":"headline"===e.type?"var(--headlines-head-text-color)":"var(--chat-head-text-color)",Cs``})({close:e=>this.close(e),num_unread:this.num_unread,restore:e=>this.restore(e),title:this.title,type:this.type})}close(e){e?.preventDefault(),this.model.close()}restore(e){e?.preventDefault(),d$(this.model)}});var m$=s(8664),g$={};g$.styleTagTransform=Gb(),g$.setAttributes=Fb(),g$.insert=Pb().bind(null,"head"),g$.domAPI=zb(),g$.insertStyleElement=qb();Rb()(m$.A,g$);m$.A&&m$.A.locals&&m$.A.locals;const{CHATROOMS_TYPE:f$}=wb;Zm.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(){bh.settings.extend({no_trimming:!1}),bh.promises.add("minimizedChatsInitialized");const e={MinimizedChatsToggle:t$};function t(e){!function(e){e.on("change:hidden",(t=>!t.get("hidden")&&d$(e)),e),"controlbox"!==e.get("id")&&e.save({minimized:e.get("minimized")||!1,time_minimized:e.get("time_minimized")||s$()})}(e),e.on("change:minimized",(()=>h$(e)))}Object.assign(yu,e),Object.assign(yu.exports,e),Object.assign(yu,{minimize:{trimChats:c$,minimize:u$,maximize:d$}}),Object.assign(yu.exports,{minimize:{trimChats:c$,minimize:u$,maximize:d$}}),bh.listen.on("chatBoxViewInitialized",(e=>yu.exports.minimize.trimChats(e))),bh.listen.on("chatRoomViewInitialized",(e=>yu.exports.minimize.trimChats(e))),bh.listen.on("controlBoxOpened",(e=>yu.exports.minimize.trimChats(e))),bh.listen.on("chatBoxInitialized",t),bh.listen.on("chatRoomInitialized",t),bh.listen.on("getHeadingButtons",((e,t)=>e.model.get("type")===f$?function(e,t){const s={a_class:"toggle-chatbox-button",handler:t=>u$(t,e.model),i18n_text:kb("Minimize"),i18n_title:kb("Minimize this groupchat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===yu.api.settings.get("view_mode")},n=t.map((e=>e.name)).indexOf("signout");return n>-1?[...t.slice(0,n),s,...t.slice(n)]:[s,...t]}(e,t):function(e,t){const s={a_class:"toggle-chatbox-button",handler:t=>u$(t,e.model),i18n_text:kb("Minimize"),i18n_title:kb("Minimize this chat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===yu.api.settings.get("view_mode")},n=t.map((e=>e.name)).indexOf("close");return n>-1?[...t.slice(0,n),s,...t.slice(n)]:[s,...t]}(e,t)));const s=Su((()=>yu.exports.minimize.trimChats()),250);bh.listen.on("registeredGlobalEventHandlers",(()=>window.addEventListener("resize",s))),bh.listen.on("unregisteredGlobalEventHandlers",(()=>window.removeEventListener("resize",s)))}});var p$=s(5838),v$=s.n(p$);const{Strophe:y$,u:b$}=Zm.env,{isEmptyMessage:_$,isTestEnv:w$}=b$,S$="Notification"in window;let x$;function A$(e){return w$()||(yu.state.chatboxes.get(e.from)?.isHidden()??!1)}function E$(){return w$()||S$&&bh.settings.get("show_desktop_notifications")&&"granted"===Notification.permission}function C$(){x$=null,navigator.clearAppBadge?.().catch((e=>kt.error("Could not clear unread count in app badge "+e)))}function $$(){if(bh.settings.get("show_tab_notifications")){x$=x$??new Zm.env.Favico({type:"circle",animation:"pop"});const e=yu.state.chatboxes.models.reduce(((e,t)=>e+(t.get("num_unread")||0)),0);x$.badge(e),navigator.setAppBadge?.(e).catch((e=>kt.error("Could set unread count in app badge - "+e)))}}function j$(e,t,s){const n=yu.session.get("bare_jid");return e.reduce(((e,i)=>e||(e=>[n,`${t}/${s}`].includes(e.uri.replace(/^xmpp:/,"")))(i)),!1)}function k$(e){const{attrs:t}=e;if(!t||t.is_forwarded)return!1;if("groupchat"===t.type)return async function(e){if(!e?.body&&!e?.message)return!1;const t=e.from,s=e.from_muc,n=bh.settings.get("notify_all_room_messages"),i=yu.state.chatboxes.get(s),r=y$.getResourceFromJid(t),o=r&&y$.unescapeNode(r)||"";let a=!1;const c=i.get("nick");bh.settings.get("notify_nicknames_without_references")&&(a=new RegExp(`\\b${c}\\b`).test(e.body));const l=o!==c,d=!0===n||Array.isArray(n)&&n.includes(s)||j$(e.references,s,c)||a;if(l&&d)return await bh.hook("shouldNotifyOfGroupMessage",e,!0);return!1}(t);if("info"===t.type)return async function(e){if(!e.from_muc)return!1;const t=await bh.rooms.get(e.from_muc);if(!t)return!1;const s=t.get("nick"),n=e.from_muc,i=bh.settings.get("notify_all_room_messages");return!0===i||Array.isArray(i)&&i.includes(n)||j$(e.references,n,s)}(t);if(t.is_headline)return A$(t);const s=yu.session.get("bare_jid"),n=y$.getBareJidFromJid(t.from)===s;return!_$(t)&&!n&&("all"===bh.settings.get("show_desktop_notifications")||A$(t))}async function T$(e){if(!await k$(e))return!1;bh.trigger("messageNotification",e),function(){if(bh.settings.get("play_sounds")&&void 0!==window.Audio){const e=new Audio(bh.settings.get("sounds_path")+"msg_received.ogg"),t=e.canPlayType("audio/ogg");if("probably"===t)return e.play();const s=new Audio(bh.settings.get("sounds_path")+"msg_received.mp3"),n=s.canPlayType("audio/mp3");"probably"===n?s.play():"maybe"===t?e.play():"maybe"===n&&s.play()}}(),function(e){const{attrs:t}=e;if(t.is_error)return;if(!E$())return;let s,n;const i=t.from,r=y$.getBareJidFromJid(i);if("info"==t.type)s=t.message;else if("headline"===t.type){if(r.includes("@")&&!bh.settings.get("allow_non_roster_messaging"))return;s=kb("Notification from %1$s",r)}else if(r.includes("@"))if("groupchat"===t.type)s=kb("%1$s says",y$.getResourceFromJid(i));else{if(void 0===yu.state.roster)return void kt.error("Could not send notification, because roster is undefined");if(n=yu.state.roster.get(r),void 0!==n)s=kb("%1$s says",n.getDisplayName());else{if(!bh.settings.get("allow_non_roster_messaging"))return;s=kb("%1$s says",r)}}else s=kb("Notification from %1$s",r);let o;if("info"==t.type)o=t.reason;else if(o=t.is_encrypted?t.plaintext:t.body,!o)return;const a=new Notification(s,{body:o,lang:jb.getLocale(),icon:bh.settings.get("notification_icon"),requireInteraction:!bh.settings.get("notification_delay")});bh.settings.get("notification_delay")&&setTimeout((()=>a.close()),bh.settings.get("notification_delay")),a.onclick=function(e){e.preventDefault(),window.focus(),yu.state.chatboxes.get(r).maybeShow(!0)}}(e)}function I$(e){E$()&&function(e){if("error"===e.klass||"warn"===e.klass){const t=new Notification(e.subject,{body:e.message,lang:jb.getLocale(),icon:bh.settings.get("notification_icon")});setTimeout(t.close.bind(t),5e3)}}(e)}function O$(e){E$()&&bh.settings.get("show_chat_state_notifications")&&function(e){if(bh.settings.get("chatstate_notification_blacklist")?.includes(e.get("jid")))return;const t=e.presence.get("show");let s=null;if("offline"===t?s=kb("has gone offline"):"away"===t?s=kb("has gone away"):"dnd"===t?s=kb("is busy"):"online"===t&&(s=kb("has come online")),null===s)return;const n=new Notification(e.getDisplayName(),{body:s,lang:jb.getLocale(),icon:bh.settings.get("notification_icon")});setTimeout((()=>n.close()),5e3)}(e)}function N$(e){E$()&&function(e){const t=new Notification(e.getDisplayName(),{body:kb("wants to be your contact"),lang:jb.getLocale(),icon:bh.settings.get("notification_icon")});setTimeout((()=>t.close()),5e3)}(e)}function M$(){S$&&!["denied","granted"].includes(Notification.permission)&&Notification.requestPermission()}Zm.env.Favico=v$(),Zm.plugins.add("converse-notification",{dependencies:["converse-chatboxes"],initialize(){bh.settings.extend({chatstate_notification_blacklist:[],notification_delay:5e3,notification_icon:"/images/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:bh.settings.get("assets_path")+"/sounds/"}),bh.listen.on("clearSession",C$),bh.waitUntil("chatBoxesInitialized").then((()=>{const{chatboxes:e}=yu.state;e.on("change:num_unread",$$)})),bh.listen.on("pluginsInitialized",(function(){bh.listen.on("contactRequest",N$),bh.listen.on("contactPresenceChanged",O$),bh.listen.on("message",T$),bh.listen.on("feedback",I$),bh.listen.on("connected",M$)}))}});const R$=Zm.env.utils;bh.elements.define("converse-chat-status-modal",class extends t_{initialize(){super.initialize(),this.render(),this.addEventListener("shown.bs.modal",(()=>{this.querySelector('input[name="status_message"]').focus()}),!1)}renderModal(){return(e=>{const t=kb("Away"),s=kb("Busy"),n=kb("Online"),i=kb("Save"),r=kb("Away for long"),o=kb("Personal status message"),a=e.model.get("status"),c=e.model.get("status_message");return Cs`
    `})(this)}getModalTitle(){return kb("Change chat status")}clearStatusMessage(e){e&&e.preventDefault&&(e.preventDefault(),R$.hideElement(this.querySelector(".clear-input")));this.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()}});const D$=kb("Your profile picture");bh.elements.define("converse-image-picker",class extends Ob{constructor(){super(),this.width=null,this.height=null}static get properties(){return{height:{type:Number},data:{type:Object},width:{type:Number}}}render(){return Cs``}openFileSelection(e){e.preventDefault(),this.querySelector('input[type="file"]').click()}updateFilePreview(e){const t=e.target.files[0],s=new FileReader;s.onloadend=()=>{this.data={data_uri:s.result,image_type:t.type}},s.readAsDataURL(t)}});const z$=e=>{const t={...e.model.toJSON(),...e.model.vcard.toJSON()},s=kb("Email"),n=kb("Full Name"),i=kb("XMPP Address"),r=kb("Nickname"),o=kb("Role"),a=kb("Save and close"),c=kb("Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages."),l=kb("URL"),d=kb("OMEMO"),u=kb("Profile"),h=kb("Reset Password"),m=[Cs``];return m.push(Cs``),yu.pluggable.plugins["converse-omemo"]?.enabled(yu)&&m.push(Cs``),Cs`
    ${t.jid}
    ${c}

    ${"passwordreset"===e.tab?Cs``:""}
    ${yu.pluggable.plugins["converse-omemo"]?.enabled(yu)?(e=>Cs`
    ${"omemo"===e.tab?Cs``:""}
    `)(e):""}
    `};var L$=s(4026),P$=s.n(L$);const{Strophe:U$,$iq:F$,sizzle:B$,u:q$}=Zm.env;bh.elements.define("converse-change-password-form",class extends Ob{static get properties(){return{passwords_mismatched:{type:Boolean},alert_message:{type:String}}}initialize(){this.passwords_mismatched=!1,this.alert_message=""}render(){return(e=>{const t=kb("Submit"),s=kb("The new passwords must match"),n=kb("New password"),i=kb("Confirm new password");return Cs`
    ${e.alert_message?Cs``:""}
    ${e.passwords_mismatched?Cs`${s}`:""}
    `})(this)}checkPasswordsMatch(e){const t=new FormData(e.target.form??e.target),s=t.get("password"),n=t.get("password_check");return this.passwords_mismatched=s&&s!==n,this.passwords_mismatched}async onSubmit(e){if(e.preventDefault(),this.checkPasswordsMatch(e))return;const t=yu.session.get("domain"),s=F$({type:"get",to:t}).c("query",{xmlns:U$.NS.REGISTER}),n=await bh.sendIQ(s);if(null===n)return void(this.alert_message=kb("Timeout error"));if(B$(`error service-unavailable[xmlns="${U$.NS.STANZAS}"]`,n).length)return void(this.alert_message=kb("Your server does not support password reset"));if(q$.isErrorStanza(n))return this.alert_message=kb("Your server responded with an unknown error, check the console for details"),kt.error("Could not set password"),void kt.error(n);const i=n.querySelector("username").textContent,r=new FormData(e.target).get("password"),o=F$({type:"set",to:t}).c("query",{xmlns:U$.NS.REGISTER}).c("username",{},i).c("password",{},r),a=await bh.sendIQ(o);null===a?this.alert_message=kb("Timeout error while trying to set your password"):B$(`error not-allowed[xmlns="${U$.NS.STANZAS}"]`,a).length?this.alert_message=kb("Your server does not allow password reset"):B$(`error forbidden[xmlns="${U$.NS.STANZAS}"]`,a).length||q$.isErrorStanza(a)?this.alert_message=kb("You are not allowed to change your password"):bh.alert("info",kb("Success"),[kb("Your new password has been set")])}});const H$=new(P$())({targetSize:.1,quality:.75,maxWidth:256,maxHeight:256});bh.elements.define("converse-profile-modal",class extends t_{constructor(e){super(e),this.tab="profile"}initialize(){super.initialize(),this.listenTo(this.model,"change",this.render),bh.trigger("profileModalInitialized",this.model)}renderModal(){return z$(this)}getModalTitle(){return kb("Your Profile")}async setVCard(e){const t=yu.session.get("bare_jid");try{await bh.vcard.set(t,e)}catch(e){return kt.fatal(e),void this.alert([kb("Sorry, an error happened while trying to save your profile data."),kb("You can check your browser's developer console for any error output.")].join(" "))}this.modal.hide()}onFormSubmitted(e){e.preventDefault();const t=new FileReader,s=new FormData(e.target),n=s.get("image"),i={fn:s.get("fn"),nickname:s.get("nickname"),role:s.get("role"),email:s.get("email"),url:s.get("url")};if(n.size){const e=[n];H$.compress(e).then((e=>{const{photo:s}=e[0];t.onloadend=()=>{Object.assign(i,{image:btoa(t.result),image_type:n.type}),this.setVCard(i)},t.readAsBinaryString(s.data)}))}else Object.assign(i,{image:this.model.vcard.get("image"),image_type:this.model.vcard.get("image_type")}),this.setVCard(i)}});const G$=e=>{const t=kb("%1$s Open Source %2$s XMPP chat client brought to you by %3$s Opkode %2$s",'',"",''),s=kb("%1$s Translate %2$s it into your own language",'',""),n=bh.settings.get("show_client_info"),i=bh.settings.get("allow_adhoc_commands");return Cs`${n&&i?(e=>{const t=kb("About"),s=kb("Commands");return Cs``})(e):""}
    ${n?Cs`

    Converse

    ${yu.VERSION_NAME}

    ${kA(bt().sanitize(t))}

    ${kA(bt().sanitize(s))}

    `:""} ${i?Cs`
    `:""}
    `};bh.elements.define("converse-user-settings-modal",class extends t_{constructor(e){super(e);const t=bh.settings.get("show_client_info"),s=bh.settings.get("allow_adhoc_commands");t&&s||t?this.tab="about":s&&(this.tab="commands")}renderModal(){return G$(this)}getModalTitle(){return kb("Settings")}});const{Strophe:W$,$iq:V$,sizzle:Q$,u:J$}=Zm.env;async function K$(e){e?.preventDefault();await bh.confirm(kb("Are you sure you want to log out?"))&&bh.user.logout()}function Y$(){const e=kb("Log out");return Cs``}const X$=e=>{const t=e.model.get("status")||"offline",s=e.model.get("status_message")||kb("I am %1$s","chat"===(n=t)?kb("online"):"dnd"===n?kb("busy"):"xa"===n?kb("away for long"):"away"===n?kb("away"):"offline"===n?kb("offline"):kb(n)||kb("online"));var n;const i=kb("Click to change your chat status"),r=bh.settings.get("show_client_info")||bh.settings.get("allow_adhoc_commands");let o,a;return[o,a]="online"===t?["fa fa-circle chat-status","chat-status-online"]:"dnd"===t?["fa fa-minus-circle chat-status","chat-status-busy"]:"away"===t?["fa fa-circle chat-status","chat-status-away"]:["fa fa-circle chat-status","subdued-color"],Cs`
    ${e.model.getDisplayName()} ${r?function(e){const t=kb("Show details about this chat client");return Cs``}(e):""} ${bh.settings.get("allow_logout")?Y$():""}
    `};bh.elements.define("converse-user-profile",class extends Ob{initialize(){this.model=yu.state.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 X$(this)}showProfileModal(e){e?.preventDefault(),bh.modal.show("converse-profile-modal",{model:this.model},e)}showStatusChangeModal(e){e?.preventDefault(),bh.modal.show("converse-chat-status-modal",{model:this.model},e)}showUserSettingsModal(e){e?.preventDefault(),bh.modal.show("converse-user-settings-modal",{model:this.model,_converse:yu},e)}}),Zm.plugins.add("converse-profile",{dependencies:["converse-status","converse-modal","converse-vcard","converse-chatboxviews","converse-adhoc-views"],initialize(){bh.settings.extend({show_client_info:!0})}});const Z$={name:"AES-GCM",length:128},ej={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"};class tj extends Error{constructor(e,t){super(e),this.name="IQError",this.iq=t}}class sj extends Error{constructor(e){super(e),this.name="UserFacingError",this.user_facing=!0}}const{Strophe:nj,$build:ij,$iq:rj,sizzle:oj}=Zm.env;const aj=class extends wd{get idAttribute(){return"jid"}async initialize(){super.initialize(),this.initialized=vc(),await this.initDevices(),this.initialized.resolve()}initDevices(){this.devices=new yu.exports.Devices;const e=`converse.devicelist-${yu.session.get("bare_jid")}-${this.get("jid")}`;return om.initStorage(this.devices,e),this.fetchDevices()}async onDevicesFound(e){if(0===e.length){let e=[];try{e=await this.fetchDevicesFromServer()}catch(e){null===e?kt.error(`Timeout error while fetching devices for ${this.get("jid")}`):(kt.error(`Could not fetch devices for ${this.get("jid")}`),kt.error(e)),this.destroy()}const t=yu.session.get("bare_jid");this.get("jid")===t&&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,s)=>{kt.error(s),e()}})}))),this._devices_promise}async getOwnDeviceId(){const{omemo_store:e}=yu.state;let t=e.get("device_id");return this.devices.get(t)||(await e.generateBundle(),t=e.get("device_id")),t}async publishCurrentDevice(e){const t=yu.session.get("bare_jid");if(this.get("jid")===t){if(await bh.omemo.session.restore(),yu.state.omemo_store)return e.includes(await this.getOwnDeviceId())?void 0:this.publishDevices();kt.warn("publishCurrentDevice: omemo_store is not defined, likely a timing issue")}}async fetchDevicesFromServer(){const e=yu.session.get("bare_jid"),t=rj({type:"get",from:e,to:this.get("jid")}).c("pubsub",{xmlns:nj.NS.PUBSUB}).c("items",{node:nj.NS.OMEMO_DEVICELIST}),s=await bh.sendIQ(t),n=`list[xmlns="${nj.NS.OMEMO}"] device`,i=oj(n,s).map((e=>e.getAttribute("id"))),r=this.get("jid");return Promise.all(i.map((e=>this.devices.create({id:e,jid:r},{promise:!0}))))}publishDevices(){const e=ij("item",{id:"current"}).c("list",{xmlns:nj.NS.OMEMO});this.devices.filter((e=>e.get("active"))).forEach((t=>e.c("device",{id:t.get("id")}).up()));return bh.pubsub.publish(null,nj.NS.OMEMO_DEVICELIST,e,{"pubsub#access_model":"open"},!1)}async removeOwnDevices(e){const t=yu.session.get("bare_jid");if(this.get("jid")!==t)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,s)=>{kt.error(s),t()}})))))),this.publishDevices()}};const cj=class extends Gd{constructor(){super(),this.model=aj}},{Strophe:lj,URI:dj,sizzle:uj}=Zm.env,{CHATROOMS_TYPE:hj,PRIVATE_CHAT_TYPE:mj}=wb,{appendArrayBuffer:gj,arrayBufferToBase64:fj,arrayBufferToHex:pj,arrayBufferToString:vj,base64ToArrayBuffer:yj,getURI:bj,hexToArrayBuffer:_j,initStorage:wj,isAudioURL:Sj,isError:xj,isImageURL:Aj,isVideoURL:Ej,stringToArrayBuffer:Cj}=om;function $j(e){e=e.replace(/^05/,"");for(let t=1;t<8;t++){const s=8*t+t-1;e=e.slice(0,s)+" "+e.slice(s)}return e}async function jj(e){return(await qj(e)).length>0}function kj(e,t){return e.get("omemo_active")&&t.body&&(t.is_encrypted=!0,t.plaintext=t.body,t.body=kb("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 Tj(e){const t="localhost"===window.location.hostname&&"localhost"===e.domain()?"http":"https",s=e.toString().replace(/^aesgcm/,t),n=await async function(e){let t;try{t=await fetch(e)}catch(t){return kt.error(`${t.name}: Failed to download encrypted media: ${e}`),kt.error(t),null}if(t.status>=200&&t.status<400)return t.arrayBuffer()}(s);if(null===n)return kt.error(`Could not decrypt a received encrypted file ${e.toString()} since it could not be downloaded`),new Error(kb("Error: could not decrypt a received encrypted file, because it could not be downloaded"));const i=e.hash().slice(1),r=i.substring(i.length-64),o=i.replace(r,"");let a;try{a=await async function(e,t,s){const n=await crypto.subtle.importKey("raw",_j(t),"AES-GCM",!1,["decrypt"]),i={name:"AES-GCM",iv:_j(e)};return crypto.subtle.decrypt(i,n,s)}(o,r,n)}catch(t){return kt.error(`Could not decrypt file ${e.toString()}`),kt.error(t),null}const[c,l]=e.filename().split("."),d=ej[l];try{const e=new File([a],c,{type:d});return URL.createObjectURL(e)}catch(t){return kt.error(`Could not decrypt file ${e.toString()}`),kt.error(t),null}}function Ij(e,t,s){const n=[];try{const t={start:/\b(aesgcm:\/\/)/gi};dj.withinString(e,((e,t,s)=>(n.push({url:e,start:t,end:s}),e)),t)}catch(e){return void kt.debug(e)}n.forEach((n=>{const i=bj(e.slice(n.start,n.end)),r=Tj(i).then((e=>function(e,t,s){if(xj(t))return Cs`

    ${t.message}

    `;const n=e.toString();return Aj(n)?QS({src:t,onClick:s.onImgClick,onLoad:s.onImgLoad}):Sj(n)?ww(t):Ej(n)?kw(t):Sw(t,e.filename())}(i,e,s))),o=Cs`${Q_(r,"")}`;s.addTemplateResult(n.start+t,n.end+t,o)}))}function Oj(e){yu.state.config.get("trusted")&&e.addAnnotations(((t,s)=>Ij(t,s,e)))}async function Nj(e,t){if(bh.settings.get("clear_cache_on_logout")||!t.is_encrypted||t.encryption_namespace!==lj.NS.OMEMO)return t;const s=uj(`encrypted[xmlns="${lj.NS.OMEMO}"]`,e).pop(),n=s.querySelector("header");t.encrypted={device_id:n.getAttribute("sid")};const i=await(bh.omemo?.getDeviceID()),r=i&&uj(`key[rid="${i}"]`,s).pop();return r?(Object.assign(t.encrypted,{iv:n.querySelector("iv").textContent,key:r.textContent,payload:s.querySelector("payload")?.textContent||null,prekey:["true","1"].includes(r.getAttribute("prekey"))}),!0===t.encrypted.prekey?async function(e){const t=zj(e),s=Dj(t,parseInt(e.encrypted.device_id,10)),n=yj(e.encrypted.key);let i;try{i=await s.decryptPreKeyWhisperMessage(n,"binary")}catch(t){return kt.error(`${t.name} ${t.message}`),Object.assign(e,Pj(t))}try{const t=await Lj(e,i),{omemo_store:s}=yu.state;return await s.generateMissingPreKeys(),await s.publishBundle(),t?Object.assign(e,{plaintext:t}):Object.assign(e,{is_only_key:!0})}catch(t){return kt.error(`${t.name} ${t.message}`),Object.assign(e,Pj(t))}}(t):async function(e){const t=zj(e),s=Dj(t,parseInt(e.encrypted.device_id,10)),n=yj(e.encrypted.key);try{const t=await s.decryptWhisperMessage(n,"binary"),i=await Lj(e,t);return Object.assign(e,{plaintext:i})}catch(t){return kt.error(`${t.name} ${t.message}`),Object.assign(e,Pj(t))}}(t)):Object.assign(t,{error_condition:"not-encrypted-for-this-device",error_type:"Decryption",is_ephemeral:!0,is_error:!0,type:"error"})}function Mj(){yu.state.chatboxes.on("add",(e=>{Vj(e),e.get("type")===hj&&(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 jj(t.get("jid"))||(e.createMessage({message:kb("%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",(()=>Vj(e))))}))}function Rj(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",(()=>{!e.model.get("omemo_supported")&&e.model.get("omemo_active")?e.model.set("omemo_active",!1):e.querySelector("converse-chat-toolbar")?.requestUpdate()})),e.listenTo(e.model,"change:omemo_active",(()=>{e.querySelector("converse-chat-toolbar").requestUpdate()}))}function Dj(e,t){const{libsignal:s}=window,n=new s.SignalProtocolAddress(e,t);return new s.SessionCipher(yu.state.omemo_store,n)}function zj(e){const t=e.from_muc?e.from_real_jid:e.from;if(!t)throw Object.assign(e,{error_text:kb("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 Lj(e,t){const s=zj(e),n=await bh.omemo.devicelists.get(s,!0),i=e.encrypted;let r=n.devices.get(i.device_id);if(r||(r=await n.devices.create({id:i.device_id,jid:s},{promise:!0})),i.payload){const e=t.slice(0,16),s=t.slice(16),n=await Yj.decryptMessage(Object.assign(i,{key:e,tag:s}));return r.save("active",!0),n}}function Pj(e){return{error_text:kb("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 Uj(e){const t=e.querySelector("signedPreKeyPublic"),s=e.querySelector("signedPreKeySignature"),n=uj("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:s.textContent},prekeys:n}}async function Fj(e){const t=await qj(e);return Promise.all(t.map((e=>Bj(e))))}async function Bj(e){if(e.get("bundle")?.fingerprint)return;const t=await e.getBundle();t.fingerprint=pj(yj(t.identity_key)),e.save("bundle",t),e.trigger("change:bundle")}async function qj(e){await bh.waitUntil("OMEMOInitialized");const t=await bh.omemo.devicelists.get(e,!0);return await t.fetchDevices(),t.devices}async function Hj(e){if(!e.get("bundle"))return kt.error(`Could not build an OMEMO session for device ${e.get("id")} because we don't have its bundle`),null;const{libsignal:t}=window,s=new t.SignalProtocolAddress(e.get("jid"),e.get("id")),n=await yu.state.omemo_store.loadSession(s.toString());if(n)return n;try{const t=await async function(e){const{libsignal:t}=window,s=new t.SignalProtocolAddress(e.get("jid"),e.get("id")),n=new t.SessionBuilder(yu.state.omemo_store,s),i=e.getRandomPreKey(),r=await e.getBundle();return n.processPreKey({registrationId:parseInt(e.get("id"),10),identityKey:yj(r.identity_key),signedPreKey:{keyId:r.signed_prekey.id,publicKey:yj(r.signed_prekey.public_key),signature:yj(r.signed_prekey.signature)},preKey:{keyId:i.id,publicKey:yj(i.key)}})}(e);return t}catch(t){return kt.error(`Could not build an OMEMO session for device ${e.get("id")}`),kt.error(t),null}}function Gj(){bh.connection.get().addHandler((async e=>{try{uj(`event[xmlns="${lj.NS.PUBSUB}#event"]`,e).length&&(await bh.waitUntil("OMEMOInitialized"),await async function(e){const t=uj(`items[node="${lj.NS.OMEMO_DEVICELIST}"]`,e).pop();if(!t)return;const s=`item list[xmlns="${lj.NS.OMEMO}"] device`,n=uj(s,t).map((e=>e.getAttribute("id"))),i=e.getAttribute("from"),r=await bh.omemo.devicelists.get(i,!0),o=r.devices,a=o.pluck("id").filter((e=>!n.includes(e))),c=yu.session.get("bare_jid");a.forEach((e=>{i===c&&e===yu.state.omemo_store.get("device_id")||o.get(e).save("active",!1)})),n.forEach((e=>{const t=o.get(e);t?t.save("active",!0):o.create({id:e,jid:i})})),om.isSameBareJID(i,i)&&r.publishCurrentDevice(n)}(e),await async function(e){const t=uj("items",e).pop();if(!t||!t.getAttribute("node").startsWith(lj.NS.OMEMO_BUNDLES))return;const s=t.getAttribute("node").split(":")[1],n=e.getAttribute("from"),i=uj("item > bundle",t).pop(),r=await bh.omemo.devicelists.get(n,!0);(r.devices.get(s)||r.devices.create({id:s,jid:n})).save({bundle:Uj(i)})}(e))}catch(e){kt.error(e.message)}return!0}),null,"message","headline")}async function Wj(e){if(!e)if(yu.state.config.get("trusted")&&!bh.settings.get("clear_cache_on_logout")){try{await async function(){const e=yu.session.get("bare_jid");yu.state.devicelists=new cj;const t=`converse.devicelists-${e}`;wj(yu.state.devicelists,t),await new Promise((e=>{yu.state.devicelists.fetch({success:e,error:(t,s)=>{kt.error(s),e()}})})),await bh.omemo.devicelists.get(e,!0)}(),await bh.omemo.session.restore(),await yu.state.omemo_store.publishBundle()}catch(e){return kt.error("Could not initialize OMEMO support"),void kt.error(e)}bh.trigger("OMEMOInitialized")}else kt.warn("Not initializing OMEMO, since this browser is not trusted or clear_cache_on_logout is set to true")}async function Vj(e){let t;e.get("type")===hj?(await bh.waitUntil("OMEMOInitialized"),t=e.features.get("nonanonymous")&&e.features.get("membersonly")):e.get("type")===mj&&(t=await jj(e.get("jid"))),e.set("omemo_supported",t),t&&bh.settings.get("omemo_default")&&e.set("omemo_active",!0)}function Qj(e){e.stopPropagation(),e.preventDefault();const t=om.ancestor(e.target,"converse-chat-toolbar");if(!t.model.get("omemo_supported")){let e;return e=t.model.get("type")===hj?[kb("Cannot use end-to-end encryption in this groupchat, either the groupchat has some anonymity or not all participants support OMEMO.")]:[kb("Cannot use end-to-end encryption because %1$s uses a client that doesn't support OMEMO.",t.model.contact.getDisplayName())],bh.alert("error",kb("Error"),e)}t.model.save({omemo_active:!t.model.get("omemo_active")})}function Jj(e,t){const s=e.model,n=s.get("type")===hj;let i,r;if(s.get("omemo_supported")){const e=kb("Messages are being sent in plaintext"),t=kb("Messages are sent encrypted");i=s.get("omemo_active")?t:e}else i=kb(n?"This groupchat needs to be members-only and non-anonymous in order to support OMEMO encrypted messages":"OMEMO encryption is not supported");return r=s.get("omemo_supported")?s.get("omemo_active")?n?"var(--muc-color)":"var(--chat-toolbar-btn-color)":"var(--error-color)":"var(--muc-toolbar-btn-disabled-color)",t.push(Cs``),t}async function Kj(e,t){let{stanza:s}=t;const{message:n}=t;if(!n.get("is_encrypted"))return t;if(!n.get("body"))throw new Error("No message body to encrypt!");const i=await async function(e){const t=kb("Sorry, no devices found to which we can send an OMEMO encrypted message.");let s;if(e instanceof ap){const t=await Promise.all(e.occupants.map((e=>qj(e.get("jid")))));s=t.reduce(((e,t)=>e.concat(t.models)),[])}else if(e.get("type")===mj){const n=await qj(e.get("jid"));if(0===n.length)throw new sj(t);const i=yu.session.get("bare_jid"),r=(await bh.omemo.devicelists.get(i)).devices;s=[...r.models,...n.models]}const n=yu.state.omemo_store.get("device_id");s=s.filter((e=>e.get("id")!==n)),await Promise.all(s.map((e=>e.getBundle())));const i=s.filter((e=>e)).map((e=>Hj(e)));if(await Promise.all(i),i.includes(null)&&(s=s.filter((e=>i[s.indexOf(e)])),0===s.length))throw new sj(t);return s}(e);s.c("encrypted",{xmlns:lj.NS.OMEMO}).c("header",{sid:yu.state.omemo_store.get("device_id")});const{key_and_tag:r,iv:o,payload:a}=await Yj.encryptMessage(n.get("plaintext")),c=await Promise.all(i.filter((e=>-1!=e.get("trusted")&&e.get("active"))).map((e=>function(e,t){return Dj(t.get("jid"),t.get("id")).encrypt(e).then((e=>({payload:e,device:t})))}(r,e))));return s=await function(e,t,s){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const n=t[s].payload,i=t[s].device,r=3==parseInt(n.type,10);e.c("key",{rid:i.get("id")}).t(btoa(n.body)),r&&e.attrs({prekey:r}),e.up()}return e.c("iv").t(s).up().up(),Promise.resolve(e)}(s,c,o),s.c("payload").t(a).up().up(),s.c("store",{xmlns:lj.NS.HINTS}).up(),s.c("encryption",{xmlns:lj.NS.EME,namespace:lj.NS.OMEMO}),{message:n,stanza:s}}const Yj={decryptMessage:async function(e){const t=await crypto.subtle.importKey("raw",e.key,Z$,!0,["encrypt","decrypt"]),s=gj(yj(e.payload),e.tag),n={name:"AES-GCM",iv:yj(e.iv),tagLength:128};return vj(await crypto.subtle.decrypt(n,t,s))},encryptMessage:async function(e){const t=crypto.getRandomValues(new window.Uint8Array(12)),s=await crypto.subtle.generateKey(Z$,!0,["encrypt","decrypt"]),n={name:"AES-GCM",iv:t,tagLength:128},i=await crypto.subtle.encrypt(n,s,Cj(e)),r=i.byteLength-16,o=i.slice(0,r),a=i.slice(r),c=await crypto.subtle.exportKey("raw",s);return{key:c,tag:a,key_and_tag:gj(c,a),payload:fj(o),iv:fj(t)}},formatFingerprint:$j},Xj=e=>{const t=kb("OMEMO Fingerprints"),s=kb("No OMEMO-enabled devices found"),n=e.devicelist.devices;return Cs`
    • ${t}
    • ${n.length?n.map((t=>((e,t)=>{const s=kb("Trusted"),n=kb("Untrusted");return t.get("bundle")&&t.get("bundle").fingerprint?Cs`
    • ${$j(t.get("bundle").fingerprint)}
    • `:""})(e,t))):Cs`
    • ${s}
    • `}
    `};bh.elements.define("converse-omemo-fingerprints",class extends Ob{constructor(){super(),this.jid=null}static get properties(){return{jid:{type:String}}}async initialize(){this.devicelist=await bh.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?Xj(this):""}toggleDeviceTrust(e){const t=e.target;this.devicelist.devices.get(t.getAttribute("name")).save("trusted",parseInt(t.value,10))}});const Zj=e=>Cs`${e.device.get("bundle")&&e.device.get("bundle").fingerprint?(e=>{const t=kb("Checkbox for selecting the following fingerprint");return Cs`
  • `})(e):(e=>{const t=kb("Device without a fingerprint"),s=kb("Checkbox for selecting the following device");return Cs`
  • `})(e)}`,ek=e=>{const t=kb("This device's OMEMO fingerprint"),s=kb("Generate new keys and fingerprint");return Cs`
    • ${t}
    • ${e.current_device&&e.current_device.get("bundle")&&e.current_device.get("bundle").fingerprint?(e=>Cs`${$j(e.current_device.get("bundle").fingerprint)}`)(e):A_()}
    ${e.other_devices?.length?(e=>{const t=kb("Other OMEMO-enabled devices"),s=kb("Checkbox to select fingerprints of all other OMEMO devices"),n=kb("Remove checked devices and close"),i=kb("Select all");return Cs`
    • ${e.other_devices?.map((t=>Zj(Object.assign({device:t},e))))}
    `})(e):""}
    `},{Strophe:tk,sizzle:sk,u:nk}=Zm.env;bh.elements.define("converse-omemo-profile",class extends Ob{async initialize(){const e=yu.session.get("bare_jid");this.devicelist=await bh.omemo.devicelists.get(e,!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 bh.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?ek(this):A_()}selectAll(e){let t=nk.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=sk('.fingerprint-removal-item input[type="checkbox"]:checked',e.target).map((e=>e.value));try{await this.devicelist.removeOwnDevices(t)}catch(e){kt.error(e),yu.api.alert(tk.LogLevel.ERROR,kb("Error"),[kb("Sorry, an error occurred while trying to remove the devices.")])}await this.setAttributes(),this.requestUpdate()}async generateOMEMODeviceBundle(e){e.preventDefault();await bh.confirm(kb("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 bh.omemo.bundle.generate(),await this.setAttributes(),this.requestUpdate())}});const{Strophe:ik,sizzle:rk,$iq:ok}=Zm.env;const ak=class extends wd{defaults(){return{trusted:0,active:!0}}getRandomPreKey(){const e=this.get("bundle");return e.prekeys[om.getRandomInt(e.prekeys.length)]}async fetchBundleFromServer(){const e=yu.session.get("bare_jid"),t=ok({type:"get",from:e,to:this.get("jid")}).c("pubsub",{xmlns:ik.NS.PUBSUB}).c("items",{node:`${ik.NS.OMEMO_BUNDLES}:${this.get("id")}`});let s;try{s=await bh.sendIQ(t)}catch(s){return kt.error(`Could not fetch bundle for device ${this.get("id")} from ${this.get("jid")}`),kt.error(s),null}if(s.querySelector("error"))throw new tj("Could not fetch bundle",s);const n=rk(`items[node="${ik.NS.OMEMO_BUNDLES}:${this.get("id")}"]`,s).pop(),i=Uj(rk(`bundle[xmlns="${ik.NS.OMEMO}"]`,n).pop());return this.save("bundle",i),i}getBundle(){return this.get("bundle")?Promise.resolve(this.get("bundle")):this.fetchBundleFromServer()}};const ck=class extends Gd{constructor(){super(),this.model=ak}};var lk=Math.ceil,dk=Math.max;const uk=function(e,t,s,n){for(var i=-1,r=dk(lk((t-e)/(s||1)),0),o=Array(r);r--;)o[n?r:++i]=e,e+=s;return o};const hk=function(e){return function(t,s,n){return n&&"number"!=typeof n&&hc(t,s,n)&&(s=n=void 0),t=nn(t),void 0===s?(s=t,t=0):s=nn(s),n=void 0===n?t!!t.startsWith("session"+e)&&t)),s={};return t.forEach((e=>{s[e]=void 0})),this.save(s),Promise.resolve()}publishBundle(){const e=this.get("signed_prekey"),t=`${mk.NS.OMEMO_BUNDLES}:${this.get("device_id")}`,s=gk("item").c("bundle",{xmlns:mk.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)=>s.c("preKeyPublic",{preKeyId:t}).t(e.pubKey).up()));return bh.pubsub.publish(null,t,s,{"pubsub#access_model":"open"},!1)}async generateMissingPreKeys(){const{libsignal:e}=window,{KeyHelper:t}=e,s=Object.keys(this.getPreKeys()),n=hk(0,yu.NUM_PREKEYS).map((e=>e.toString())).filter((e=>!s.includes(e)));if(n.length<1)return kt.warn("No missing prekeys to generate for our own device"),Promise.resolve();(await Promise.all(n.map((e=>t.generatePreKey(parseInt(e,10)))))).forEach((e=>this.storePreKey(e.keyId,e.keyPair)));const i=this.getPreKeys(),r=Object.keys(i).map((e=>({id:e,key:i[e].pubKey}))),o=yu.session.get("bare_jid"),a=(await bh.omemo.devicelists.get(o)).devices.get(this.get("device_id")),c=await a.getBundle();a.save("bundle",Object.assign(c,{prekeys:r}))}async generatePreKeys(){const e=yu.NUM_PREKEYS,{libsignal:t}=window,{KeyHelper:s}=t,n=await Promise.all(hk(0,e).map((e=>s.generatePreKey(e))));return n.forEach((e=>this.storePreKey(e.keyId,e.keyPair))),n.map((e=>({id:e.keyId,key:fk.arrayBufferToBase64(e.keyPair.pubKey)})))}async generateBundle(){const{libsignal:e}=window,t=await e.KeyHelper.generateIdentityKeyPair(),s=fk.arrayBufferToBase64(t.pubKey),n=await async function(){const{libsignal:e}=window,t=yu.session.get("bare_jid"),s=(await bh.omemo.devicelists.get(t,!0)).devices.pluck("id");let n=e.KeyHelper.generateRegistrationId(),i=0;for(;s.includes(n);)if(n=e.KeyHelper.generateRegistrationId(),i++,10===i)throw new Error("Unable to generate a unique device ID");return n.toString()}();this.save({device_id:n,identity_keypair:{privKey:fk.arrayBufferToBase64(t.privKey),pubKey:s},identity_key:s});const i=await e.KeyHelper.generateSignedPreKey(t,0);this.storeSignedPreKey(i);const r={identity_key:s,device_id:n,prekeys:await this.generatePreKeys()};r.signed_prekey={id:i.keyId,public_key:fk.arrayBufferToBase64(i.keyPair.pubKey),signature:fk.arrayBufferToBase64(i.signature)};const o=yu.session.get("bare_jid"),a=await bh.omemo.devicelists.get(o);(await a.devices.create({id:r.device_id,jid:o},{promise:!0})).save("bundle",r)}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:(s,n)=>{kt.warn("Could not fetch OMEMO session from cache, we'll generate a new one."),kt.warn(n),this.generateBundle().then(e).catch(t)}})}))),this._setup_promise}},vk={omemo:{getDeviceID:async()=>(await bh.waitUntil("OMEMOInitialized"),yu.state.omemo_store.get("device_id")),session:{async restore(){const{state:e}=yu;if(void 0===e.omemo_store){const t=`converse.omemosession-${yu.session.get("bare_jid")}`;e.omemo_store=new pk({id:t}),om.initStorage(e.omemo_store,t)}await e.omemo_store.fetchSession()}},devicelists:{async get(e,t=!1){const s=yu.state.devicelists.get(e)||(t?yu.state.devicelists.create({jid:e}):null);return await(s?.initialized),s}},bundle:{generate:async()=>{await bh.waitUntil("OMEMOInitialized");const e=yu.session.get("bare_jid"),t=await bh.omemo.devicelists.get(e),{omemo_store:s}=yu.state,n=s.get("device_id");if(n){const e=t.devices.get(n);s.unset(n),e&&await new Promise((t=>e.destroy({success:t,error:t}))),t.devices.trigger("remove")}await s.generateBundle(),await t.publishDevices();const i=Bj(t.devices.get(s.get("device_id")));return await s.publishBundle(),i}}}},{Strophe:yk}=Zm.env,{shouldClearCache:bk}=om;Zm.env.omemo=Yj,yk.addNamespace("OMEMO_DEVICELIST",yk.NS.OMEMO+".devicelist"),yk.addNamespace("OMEMO_VERIFICATION",yk.NS.OMEMO+".verification"),yk.addNamespace("OMEMO_WHITELISTED",yk.NS.OMEMO+".whitelisted"),yk.addNamespace("OMEMO_BUNDLES",yk.NS.OMEMO+".bundles"),Zm.plugins.add("converse-omemo",{enabled:e=>window.libsignal&&e.config.get("trusted")&&!bh.settings.get("clear_cache_on_logout")&&!e.api.settings.get("blacklisted_plugins").includes("converse-omemo"),dependencies:["converse-chatview","converse-pubsub","converse-profile"],initialize(){bh.settings.extend({omemo_default:!1}),bh.promises.add(["OMEMOInitialized"]),Object.assign(yu.api,vk);const e={OMEMOStore:pk,Device:ak,Devices:ck,DeviceList:aj,DeviceLists:cj};Object.assign(yu,e),Object.assign(yu.exports,e),bh.waitUntil("chatBoxesInitialized").then(Mj),bh.listen.on("getOutgoingMessageAttributes",kj),bh.listen.on("createMessageStanza",(async(e,t)=>{try{t=await Kj(e,t)}catch(t){!function(e,t){if(e instanceof tj){t.save("omemo_supported",!1);const s=[];uj(`presence-subscription-required[xmlns="${lj.NS.PUBSUB_ERROR}"]`,e.iq).length?s.push(kb("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"))):uj('remote-server-not-found[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]',e.iq).length?s.push(kb("Sorry, we're unable to send an encrypted message because the remote server for %1$s could not be found",e.iq.getAttribute("from"))):(s.push(kb("Unable to send an encrypted message due to an unexpected error.")),s.push(e.iq.outerHTML)),bh.alert("error",kb("Error"),s)}else e instanceof sj&&bh.alert("error",kb("Error"),[e.message]);throw e}(t,e)}return t})),bh.listen.on("afterFileUploaded",((e,t)=>e.file.xep454_ivkey?function(e,t){const s=t.oob_url.replace(/^https?:/,"aesgcm:")+"#"+e.file.xep454_ivkey;return Object.assign(t,{oob_url:null,message:s,body:s})}(e,t):t)),bh.listen.on("beforeFileUpload",((e,t)=>e.get("omemo_active")?async function(e){const t=crypto.getRandomValues(new Uint8Array(12)),s=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:t},s,await e.arrayBuffer()),i=await window.crypto.subtle.exportKey("raw",s),r=new File([n],e.name,{type:e.type,lastModified:e.lastModified});return Object.assign(r,{xep454_ivkey:pj(t)+pj(i)}),r}(t):t)),bh.listen.on("parseMessage",Nj),bh.listen.on("parseMUCMessage",Nj),bh.listen.on("chatBoxViewInitialized",Rj),bh.listen.on("chatRoomViewInitialized",Rj),bh.listen.on("connected",Gj),bh.listen.on("getToolbarButtons",Jj),bh.listen.on("statusInitialized",Wj),bh.listen.on("addClientFeatures",(()=>bh.disco.own.features.add(`${yk.NS.OMEMO_DEVICELIST}+notify`))),bh.listen.on("afterMessageBodyTransformed",Oj),bh.listen.on("userDetailsModalInitialized",(e=>{Fj(e.get("jid")).catch((e=>kt.error(e)))})),bh.listen.on("profileModalInitialized",(()=>{Fj(yu.session.get("bare_jid")).catch((e=>kt.error(e)))})),bh.listen.on("clearSession",(()=>{delete yu.state.omemo_store,bk(yu)&&yu.state.devicelists&&(yu.state.devicelists.clearStore(),delete yu.state.devicelists)}))}});const{Strophe:_k,$iq:wk}=Zm.env,{CHATROOMS_TYPE:Sk}=wb;async function xk(e){if(!e){const t=yu.session.get("bare_jid");e=t}const t=yu.session.get("push_enabled")||[];if(t.includes(e))return;const s=bh.settings.get("push_app_servers").filter((e=>!e.disable)),n=bh.settings.get("push_app_servers").filter((e=>e.disable)),i=s.map((t=>async function(e,t){if(!t.jid||!t.node)return;if(!await bh.disco.getIdentity("pubsub","push",t.jid))return kt.warn(`Not enabling push the service "${t.jid}", it doesn't have the right disco identtiy.`);const s=await Promise.all([bh.disco.supports(_k.NS.PUSH,t.jid),bh.disco.supports(_k.NS.PUSH,e)]);if(!s[0]&&!s[1])return void kt.warn(`Not enabling push app server "${t.jid}", no disco support from your server.`);const n=wk({type:"set"});return e!==yu.session.get("bare_jid")&&n.attrs({to:e}),n.c("enable",{xmlns:_k.NS.PUSH,jid:t.jid,node:t.node}),t.secret&&n.c("x",{xmlns:_k.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE"}).c("value").t(`${_k.NS.PUBSUB}#publish-options`).up().up().c("field",{var:"secret"}).c("value").t(t.secret),bh.sendIQ(n)}(e,t))),r=n.map((t=>async function(e,t){if(!t.jid)return;const s=yu.session.get("bare_jid");if(!await bh.disco.supports(_k.NS.PUSH,e||s))return void kt.warn(`Not disabling push app server "${t.jid}", no disco support from your server.`);const n=wk({type:"set"});e!==s&&n.attrs({to:e}),n.c("disable",{xmlns:_k.NS.PUSH,jid:t.jid}),t.node&&n.attrs({node:t.node}),bh.sendIQ(n).catch((e=>{kt.error(`Could not disable push app server for ${t.jid}`),kt.error(e)}))}(e,t)));try{await Promise.all(i.concat(r))}catch(e){kt.error("Could not enable or disable push App Server"),e&&kt.error(e)}finally{t.push(e)}yu.session.save("push_enabled",t)}function Ak(e){e.get("type")==Sk&&xk(_k.getDomainFromJid(e.get("jid")))}const{Strophe:Ek}=Zm.env;Ek.addNamespace("PUSH","urn:xmpp:push:0"),Zm.plugins.add("converse-push",{initialize(){bh.settings.extend({push_app_servers:[],enable_muc_push:!1}),bh.listen.on("statusInitialized",(()=>xk())),bh.settings.get("enable_muc_push")&&bh.listen.on("chatBoxesInitialized",(()=>yu.state.chatboxes.on("add",Ak)))}});const Ck=()=>{const e=kb("Already have a chat account?"),t=kb("Log in here");return Cs`

    ${e}

    `},$k=e=>{const t=bh.settings.get("registration_domain"),s=kb("Create your account"),n=kb("Please enter the XMPP provider to register with:"),i=!t&&e.status===jk;return Cs`
    ${s}
    ${t||(()=>{const e=bh.settings.get("domain_placeholder"),t=kb("Tip: A list of public XMPP providers is available"),s=kb("here"),n=bh.settings.get("providers_link");return Cs`

    ${t} ${s}.

    `})()}
    ${i?(()=>{const e=kb("Fetch registration form"),t=kb("Already have a chat account?"),s=kb("Log in here");return Cs`

    ${t}

    `})():""}
    `},jk=0,kk=e=>Cs`${e.alert_message?Cs``:""} ${e.status===jk?$k(e):""} ${1===e.status?(e=>{const t=bh.settings.get("registration_domain"),s=kb("Cancel");return Cs`
    ${A_({classes:"hor_centered"})} ${t?"":Cs``}
    `})(e):""} ${2===e.status?(e=>{const t=kb("Choose a different provider"),s=kb("Account Registration:"),n=kb("Register"),i=bh.settings.get("registration_domain");return Cs`
    ${s} ${e.domain}

    ${e.title}

    ${e.instructions}

    ${e.form_fields}
    ${e.fields?Cs``:""} ${i?"":Cs``} ${Ck()}
    `})(e):""} ${3===e.status?Ck():""}`;async function Tk(e){await bh.waitUntil("controlBoxInitialized");const{chatboxes:t}=yu.state;t.get("controlbox").set({"active-form":e})}function Ik(e){"#converse/login"===location.hash?(e?.preventDefault(),Tk("login")):"#converse/register"===location.hash&&(e?.preventDefault(),Tk("register"))}var Ok=s(4788),Nk={};Nk.styleTagTransform=Gb(),Nk.setAttributes=Fb(),Nk.insert=Pb().bind(null,"head"),Nk.domAPI=zb(),Nk.insertStyleElement=qb();Rb()(Ok.A,Nk);Ok.A&&Ok.A.locals&&Ok.A.locals;const{Strophe:Mk,sizzle:Rk,$iq:Dk}=Zm.env,{CONNECTION_STATUS:zk}=wb,Lk=1,Pk=2;bh.elements.define("converse-register-panel",class extends Ob{static get properties(){return{status:{type:String},alert_message:{type:String},alert_type:{type:String}}}constructor(){super(),this.urls=[],this.fields={},this.domain=null,this.alert_type="info",this.setErrorMessage=e=>this.setMessage(e,"danger"),this.setFeedbackMessage=e=>this.setMessage(e,"info")}initialize(){this.reset(),this.listenTo(yu,"connectionInitialized",(()=>this.registerHooks()));const e=bh.settings.get("registration_domain");e?this.fetchRegistrationForm(e):this.status=0}render(){return kk(this)}setMessage(e,t){this.alert_type=t,this.alert_message=e}registerHooks(){const e=bh.connection.get(),t=e._connect_cb.bind(e);e._connect_cb=(e,s,n)=>{this._registering?this.getRegistrationFields(e,s)&&(this._registering=!1):t(e,s,n)}}getRegistrationFields(e,t){const s=bh.connection.get();s.connected=!0;const n=s._proto._reqToData(e);if(!n)return;if(s._proto._connect_cb(n)===Mk.Status.CONNFAIL)return this.status=0,this.setErrorMessage(kb("Sorry, we're unable to connect to your chosen provider.")),!1;const i=n.getElementsByTagName("register"),r=n.getElementsByTagName("mechanism");if(0===i.length&&0===r.length)return s._proto._no_auth_received(t),!1;if(0===i.length)return s._changeConnectStatus(Mk.Status.REGIFAIL),this.alert_type="danger",this.setErrorMessage(kb("Sorry, the given provider does not support in band account registration. Please try with a different provider.")),!0;s._addSysHandler((e=>this.onRegistrationFields(e)),null,"iq",null,null);const o=Dk({type:"get"}).c("query",{xmlns:Mk.NS.REGISTER}).tree();return o.setAttribute("id",s.getUniqueId("sendIQ")),s.send(o),s.connected=!1,!0}onRegistrationFields(e){return"error"===e.getAttribute("type")?(this.reportErrors(e),bh.settings.get("registration_domain")?this.status=3:this.status=0,!1):(this.setFields(e),this.status===Lk&&this.renderRegistrationForm(e),!1)}reset(e){Object.assign(this,{fields:{},urls:[],title:"",instructions:"",registered:!1,_registering:!1,domain:null,form_type:null}),e&&Object.assign(this,e)}onFormSubmission(e){e?.preventDefault?.();const t=e.target;null===t.querySelector("input[name=domain]")?this.submitRegistrationForm(t):this.onProviderChosen(t)}onProviderChosen(e){const t=e.querySelector("input[name=domain]")?.value;t&&this.fetchRegistrationForm(t.trim())}fetchRegistrationForm(e){return this.status=Lk,this.reset({domain:Mk.getDomainFromJid(e),_registering:!0}),bh.connection.init(),bh.connection.get()?.connect(this.domain,"",(e=>this.onConnectStatusChanged(e))),!1}onConnectStatusChanged(e){if(kt.debug("converse-register: onConnectStatusChanged"),[Mk.Status.DISCONNECTED,Mk.Status.CONNFAIL,Mk.Status.REGIFAIL,Mk.Status.NOTACCEPTABLE,Mk.Status.CONFLICT].includes(e))kt.error(`Problem during registration: Strophe.Status is ${zk[e]}`),this.abortRegistration();else if(e===Mk.Status.REGISTERED){if(kt.debug("Registered successfully."),bh.connection.get().reset(),["converse/login","converse/register"].includes(window.location.hash)&&history.pushState(null,"",window.location.pathname),Tk("login"),this.fields.password&&this.fields.username){const e=bh.connection.get();e.connect(this.fields.username.toLowerCase()+"@"+this.domain.toLowerCase(),this.fields.password,e.onConnectStatusChanged),this.setFeedbackMessage(kb("Now logging you in"))}else this.setFeedbackMessage(kb("Registered successfully"));this.reset()}}getLegacyFormFields(){const e=Object.keys(this.fields).map((e=>"username"===e?Cw({domain:` @${this.domain}`,name:e,type:"text",label:e,value:"",required:!0}):xw({label:e,name:e,placeholder:e,required:!0,type:"password"===e||"email"===e?e:"text",value:""}))),t=this.urls.map((e=>Ew({label:"",value:e})));return[...e,...t]}getFormFields(e){return"xform"===this.form_type?Array.from(e.querySelectorAll("field")).map((t=>om.xForm2TemplateResult(t,e,{domain:this.domain}))):this.getLegacyFormFields()}renderRegistrationForm(e){this.form_fields=this.getFormFields(e),this.status=Pk}reportErrors(e){const t=Array.from(e.querySelectorAll("error"));t.length?this.setErrorMessage(t.reduce(((e,t)=>`${e}\n${t.textContent}`),"")):this.setErrorMessage(kb("The provider rejected your registration attempt. Please check the values you entered for correctness."))}renderProviderChoiceForm(e){e?.preventDefault?.();const t=bh.connection.get();t._proto._abortAllRequests(),t.reset(),this.status=0}abortRegistration(){const e=bh.connection.get();e._proto._abortAllRequests(),e.reset(),[Lk,Pk].includes(this.status)?bh.settings.get("registration_domain")&&this.fetchRegistrationForm(bh.settings.get("registration_domain")):this.requestUpdate()}submitRegistrationForm(e){const t=Rk(":input:not([type=button]):not([type=submit])",e),s=Dk({type:"set",id:om.getUniqueId()}).c("query",{xmlns:Mk.NS.REGISTER});if("xform"===this.form_type){s.c("x",{xmlns:Mk.NS.XFORM,type:"submit"});const e=t.map((e=>om.webForm2xForm(e))).filter((e=>e));e.forEach((e=>s.cnode(e).up()))}else t.forEach((e=>s.c(e.getAttribute("name"),{},e.value)));const n=bh.connection.get();n._addSysHandler((e=>this._onRegisterIQ(e)),null,"iq",null,null),n.send(s),this.setFields(s.tree())}setFields(e){const t=e.querySelector("query"),s=Rk(`x[xmlns="${Mk.NS.XFORM}"]`,t);s.length>0?this._setFieldsFromXForm(s.pop()):this._setFieldsFromLegacy(t)}_setFieldsFromLegacy(e){[].forEach.call(e.children,(e=>{"instructions"!==e.tagName.toLowerCase()?"x"!==e.tagName.toLowerCase()?this.fields[e.tagName.toLowerCase()]=Mk.getText(e):"jabber:x:oob"===e.getAttribute("xmlns")&&this.urls.concat(Rk("url",e).map((e=>e.textContent))):this.instructions=Mk.getText(e)})),this.form_type="legacy"}_setFieldsFromXForm(e){this.title=e.querySelector("title")?.textContent??"",this.instructions=e.querySelector("instructions")?.textContent??"",e.querySelectorAll("field").forEach((e=>{const t=e.getAttribute("var");t?this.fields[t.toLowerCase()]=e.querySelector("value")?.textContent??"":kt.warn("Found field we couldn't parse")})),this.form_type="xform"}_onRegisterIQ(e){const t=bh.connection.get();if("error"===e.getAttribute("type")){kt.error("Registration failed."),this.reportErrors(e);const s=e.getElementsByTagName("error");if(1!==s.length)return t._changeConnectStatus(Mk.Status.REGIFAIL,"unknown"),!1;const n=s[0].firstElementChild.tagName.toLowerCase();"conflict"===n?t._changeConnectStatus(Mk.Status.CONFLICT,n):"not-acceptable"===n?t._changeConnectStatus(Mk.Status.NOTACCEPTABLE,n):t._changeConnectStatus(Mk.Status.REGIFAIL,n)}else t._changeConnectStatus(Mk.Status.REGISTERED,null);return!1}});const{Strophe:Uk}=Zm.env,{CONNECTION_STATUS:Fk}=wb;Uk.addNamespace("REGISTER","jabber:iq:register");const Bk=Object.keys(Uk.Status).reduce(((e,t)=>Math.max(e,Uk.Status[t])),0);Uk.Status.REGIFAIL=Bk+1,Uk.Status.REGISTERED=Bk+2,Uk.Status.CONFLICT=Bk+3,Uk.Status.NOTACCEPTABLE=Bk+5,Zm.plugins.add("converse-register",{dependencies:["converse-controlbox"],enabled:()=>!0,initialize(){Fk[Uk.Status.REGIFAIL]="REGIFAIL",Fk[Uk.Status.REGISTERED]="REGISTERED",Fk[Uk.Status.CONFLICT]="CONFLICT",Fk[Uk.Status.NOTACCEPTABLE]="NOTACCEPTABLE",bh.settings.extend({allow_registration:!0,domain_placeholder:kb(" e.g. conversejs.org"),providers_link:"https://compliance.conversations.im/",registration_domain:""}),Ik(),addEventListener("hashchange",Ik)}});const{Strophe:qk}=Zm.env,{OPENED:Hk}=wb;const Gk=class extends wd{defaults(){return{muc_domain:bh.settings.get("muc_domain"),nick:yu.exports.getDefaultMUCNickname(),toggle_state:Hk,collapsed_domains:[]}}initialize(){super.initialize(),bh.settings.listen.on("change:muc_domain",(e=>this.setDomain(e)))}setDomain(e){bh.settings.get("locked_muc_domain")||this.save("muc_domain",qk.getDomainFromJid(e))}},{Strophe:Wk,$iq:Vk,sizzle:Qk}=Zm.env;Wk.addNamespace("MUCSEARCH","https://xmlns.zombofant.net/muclumbus/search/1.0");const Jk={};function Kk(e){return Jk[e]||(Jk[e]=async function(e){const t=bh.settings.get("muc_search_service"),s=yu.session.get("bare_jid"),n=Vk({type:"get",from:s,to:t}).c("search",{xmlns:Wk.NS.MUCSEARCH}).c("set",{xmlns:Wk.NS.RSM}).c("max").t(10).up().up().c("x",{xmlns:Wk.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t("https://xmlns.zombofant.net/muclumbus/search/1.0#params").up().up().c("field",{var:"q",type:"text-single"}).c("value").t(e).up().up().c("field",{var:"sinname",type:"boolean"}).c("value").t("true").up().up().c("field",{var:"sindescription",type:"boolean"}).c("value").t("false").up().up().c("field",{var:"sinaddr",type:"boolean"}).c("value").t("true").up().up().c("field",{var:"min_users",type:"text-single"}).c("value").t("1").up().up().c("field",{var:"key",type:"list-single"}).c("value").t("address").up().c("option").c("value").t("nusers").up().up().c("option").c("value").t("address");let i;try{i=await bh.sendIQ(n)}catch(e){return kt.error(e),[]}const r=`result[xmlns="${Wk.NS.MUCSEARCH}"] item`;return Qk(r,i).map((e=>{const t=e.getAttribute("address");return{label:`${e.querySelector("name")?.textContent} (${t})`,value:t}}))}(e)),Jk[e]}const Yk=e=>{const t=kb("Join"),s=e.model.get("muc_domain")||bh.settings.get("muc_domain");let n="";bh.settings.get("locked_muc_domain")||(n=s?`name@${s}`:kb("name@conference.example.org"));const i=kb(s?"Groupchat name":"Groupchat address"),r=e.muc_roomid_policy_error_msg,o=bh.settings.get("muc_roomid_policy_hint"),a=bh.settings.get("muc_search_service");return Cs`
    ${r?Cs``:""} ${a?Cs``:""}
    ${o?Cs`
    ${kA(bt().sanitize(o,{ALLOWED_TAGS:["b","br","em"]}))}
    `:""} ${bh.settings.get("locked_muc_nickname")?"":(e=>{const t=kb("Nickname"),s=kb("This field is required");return Cs`
    `})(e)}
    `};var Xk=s(33),Zk={};Zk.styleTagTransform=Gb(),Zk.setAttributes=Fb(),Zk.insert=Pb().bind(null,"head"),Zk.domAPI=zb(),Zk.insertStyleElement=qb();Rb()(Xk.A,Zk);Xk.A&&Xk.A.locals&&Xk.A.locals;const eT=Zm.env.utils,{Strophe:tT}=Zm.env;bh.elements.define("converse-add-muc-modal",class extends t_{initialize(){super.initialize(),this.listenTo(this.model,"change:muc_domain",(()=>this.render())),this.muc_roomid_policy_error_msg=null,this.render(),this.addEventListener("shown.bs.modal",(()=>{this.querySelector('input[name="chatroom"]').focus()}),!1)}renderModal(){return Yk(this)}getModalTitle(){return kb("Enter a new Groupchat")}parseRoomDataFromEvent(e){const t=new FormData(e),s=t.get("chatroom")?.trim();let n;if(bh.settings.get("locked_muc_nickname")){if(n=yu.exports.getDefaultMUCNickname(),!n)throw new Error("Using locked_muc_nickname but no nickname found!")}else n=t.get("nickname").trim();return{jid:s,nick:n}}openChatRoom(e){if(e.preventDefault(),this.checkRoomidPolicy())return;const t=this.parseRoomDataFromEvent(e.target);let s;""===t.nick&&(t.nick=void 0),bh.settings.get("locked_muc_domain")||bh.settings.get("muc_domain")&&!eT.isValidJID(t.jid)?s=`${tT.escapeNode(t.jid)}@${bh.settings.get("muc_domain")}`:(s=t.jid,this.model.setDomain(s)),bh.rooms.open(s,Object.assign(t,{jid:s}),!0),e.target.reset(),this.modal.hide()}checkRoomidPolicy(){if(bh.settings.get("muc_roomid_policy")&&bh.settings.get("muc_domain")){let e=this.querySelector("converse-autocomplete input").value;!bh.settings.get("locked_muc_domain")&&eT.isValidJID(e)||(e=`${tT.escapeNode(e)}@${bh.settings.get("muc_domain")}`);const t=tT.getNodeFromJid(e),s=tT.getDomainFromJid(e);if(bh.settings.get("muc_domain")===s&&!bh.settings.get("muc_roomid_policy").test(t))return this.muc_roomid_policy_error_msg=kb("Groupchat id is invalid."),!0;this.muc_roomid_policy_error_msg=null,this.render()}}});const sT=e=>{const t=kb("Description:"),s=kb("Groupchat XMPP Address:"),n=kb("Participants:"),i=kb("Features:"),r=kb("Requires authentication"),o=kb("Hidden"),a=kb("Requires an invitation"),c=kb("Moderated"),l=kb("Non-anonymous"),d=kb("Open"),u=kb("Permanent"),h=kb("Public"),m=kb("Semi-anonymous"),g=kb("Temporary"),f=kb("Unmoderated");return Cs`

    ${s} ${e.jid}

    ${t} ${e.desc}

    ${n} ${e.occ}

    ${i}

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

    `},nT=e=>Cs`${e.show_form?(e=>{const t=kb("Show groupchats"),s=kb("Server address");return Cs`
    `})(e):""}
      ${e.loading_items?Cs`
    • ${A_()}
    • `:""} ${e.feedback_text?Cs`
    • ${e.feedback_text}
    • `:""} ${bS(e.items,(e=>e.jid),(t=>((e,t)=>{const s=kb("Show more information on this groupchat"),n=kb("Click to open this groupchat");return Cs`
    • `})(e,t)))}
    `,{Strophe:iT,$iq:rT,sizzle:oT}=Zm.env,{getAttributes:aT}=om;function cT(e){const t=om.ancestor(e.target,".room-item"),s=t.querySelector("div.room-info");s?(om.slideIn(s).then(om.removeElement),t.querySelector("a.room-info").classList.remove("selected")):(t.insertAdjacentElement("beforeend",om.getElementFromTemplateResult(A_())),bh.disco.info(e.target.getAttribute("data-room-jid"),null).then((e=>function(e,t){e.querySelector("span.spinner").remove(),e.querySelector("a.room-info").classList.add("selected"),e.insertAdjacentHTML("beforeend",om.getElementFromTemplateResult(sT({jid:t.getAttribute("from"),desc:oT('field[var="muc#roominfo_description"] value',t).shift()?.textContent,occ:oT('field[var="muc#roominfo_occupants"] value',t).shift()?.textContent,hidden:oT('feature[var="muc_hidden"]',t).length,membersonly:oT('feature[var="muc_membersonly"]',t).length,moderated:oT('feature[var="muc_moderated"]',t).length,nonanonymous:oT('feature[var="muc_nonanonymous"]',t).length,open:oT('feature[var="muc_open"]',t).length,passwordprotected:oT('feature[var="muc_passwordprotected"]',t).length,persistent:oT('feature[var="muc_persistent"]',t).length,publicroom:oT('feature[var="muc_publicroom"]',t).length,semianonymous:oT('feature[var="muc_semianonymous"]',t).length,temporary:oT('feature[var="muc_temporary"]',t).length,unmoderated:oT('feature[var="muc_unmoderated"]',t).length})))}(t,e))).catch((e=>kt.error(e))))}bh.elements.define("converse-muc-list-modal",class extends t_{constructor(e){super(e),this.items=[],this.loading_items=!1}initialize(){super.initialize(),this.listenTo(this.model,"change:muc_domain",this.onDomainChange),this.listenTo(this.model,"change:feedback_text",(()=>this.render())),this.addEventListener("shown.bs.modal",(()=>bh.settings.get("locked_muc_domain")&&this.updateRoomsList())),this.model.save("feedback_text","")}renderModal(){return nT(Object.assign(this.model.toJSON(),{show_form:!bh.settings.get("locked_muc_domain"),server_placeholder:this.model.get("muc_domain")||kb("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)}))}getModalTitle(){return kb("Query for Groupchats")}openRoom(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid"),s=e.target.getAttribute("data-room-name");this.modal.hide(),bh.rooms.open(t,{name:s},!0)}toggleRoomInfo(e){e.preventDefault(),cT(e)}onDomainChange(){bh.settings.get("auto_list_rooms")&&this.updateRoomsList()}onRoomsFound(e){this.loading_items=!1;const t=e?oT("query item",e):[];return t.length?(this.model.set({feedback_text:kb("Groupchats found")},{silent:!0}),this.items=t.map(aT)):(this.items=[],this.model.set({feedback_text:kb("No groupchats found")},{silent:!0})),this.render(),!0}updateRoomsList(){const e=rT({to:this.model.get("muc_domain"),from:bh.connection.get().jid,type:"get"}).c("query",{xmlns:iT.NS.DISCO_ITEMS});bh.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})}});var lT=s(5052),dT={};dT.styleTagTransform=Gb(),dT.setAttributes=Fb(),dT.insert=Pb().bind(null,"head"),dT.domAPI=zb(),dT.insertStyleElement=qb();Rb()(lT.A,dT);lT.A&&lT.A.locals&&lT.A.locals;const{CHATROOMS_TYPE:uT,CLOSED:hT}=wb,{isUniView:mT}=om;function gT(e){return mT()&&!e.get("hidden")}function fT(e,t){const s=kb("Leave this groupchat"),n=t.get("num_unread_general")||t.get("has_activity");return Cs`
    ${t.get("num_unread")?function(e){return Cs`${e.get("num_unread")}`}(t):t.get("has_activity")?Cs``:""} ${t.getDisplayName()} ${bh.settings.get("allow_bookmarks")?function(e){const t=e.get("bookmarked")??!1,s=kb("Bookmark");return Cs``}(t):""}
    `}function pT(e,t){const s=new Map;for(const e of t){const t=e.get("jid").split("@").at(-1).toLowerCase();s.has(t)?s.get(t).push(e):s.set(t,[e])}const n=Array.from(s.keys());return n.sort(),n.map((t=>function(e,t,s){const n=kb("Click to hide these rooms"),i=e.model.get("collapsed_domains").includes(t);return Cs`
    ${t}
      ${s.map((t=>fT(e,t)))}
    `}(e,t,s.get(t))))}const{Strophe:vT}=Zm.env,{initStorage:yT}=om,{CLOSED:bT,OPENED:_T}=wb;bh.elements.define("converse-rooms-list",class extends Ob{initialize(){const e=`converse.roomspanel${yu.session.get("bare_jid")}`;this.model=new Gk({id:e}),yT(this.model,e),this.model.fetch();const{chatboxes:t}=yu.state;this.listenTo(t,"add",this.renderIfChatRoom),this.listenTo(t,"remove",this.renderIfChatRoom),this.listenTo(t,"destroy",this.renderIfChatRoom),this.listenTo(t,"change",this.renderIfRelevantChange),this.listenTo(this.model,"change",(()=>this.requestUpdate())),this.requestUpdate()}render(){return(e=>{const t=bh.settings.get("muc_grouped_by_domain"),{chatboxes:s}=yu.state,n=s.filter((e=>e.get("type")===uT));n.sort(((e,t)=>e.getDisplayName().toLowerCase()<=t.getDisplayName().toLowerCase()?-1:1));const i=kb("Click to toggle the list of open groupchats"),r=kb("Groupchats"),o=kb("Query server"),a=kb("Add groupchat"),c=kb("Bookmarks"),l=e.model.get("toggle_state")===hT,d=[Cs`${c}`,Cs`${o}`,Cs`${a}`];return Cs`
    ${t?pT(e,n):n.map((t=>fT(e,t)))}
    `})(this)}renderIfChatRoom(e){om.muc.isChatRoom(e)&&this.requestUpdate()}renderIfRelevantChange(e){const t=["bookmarked","hidden","name","num_unread","num_unread_general","has_activity"],s=e.changed||{};om.muc.isChatRoom(e)&&Object.keys(s).filter((e=>t.includes(e))).length&&this.requestUpdate()}showRoomDetailsModal(e){const t=e.currentTarget.getAttribute("data-room-jid"),s=yu.state.chatboxes.get(t);e.preventDefault(),bh.modal.show("converse-muc-details-modal",{model:s},e)}async openRoom(e){e.preventDefault();const t=e.target,s=t.textContent,n=t.getAttribute("data-room-jid"),i={name:s||vT.unescapeNode(vT.getNodeFromJid(n))||n};await bh.rooms.open(n,i,!0)}async closeRoom(e){e.preventDefault();const t=e.currentTarget,s=t.getAttribute("data-room-name"),n=t.getAttribute("data-room-jid");if(await bh.confirm(kb("Are you sure you want to leave the groupchat %1$s?",s))){(await bh.rooms.get(n)).close()}}toggleRoomsList(e){e?.preventDefault?.();const t=this.querySelector(".open-rooms-list");this.model.get("toggle_state")===bT?om.slideOut(t).then((()=>this.model.save({toggle_state:_T}))):om.slideIn(t).then((()=>this.model.save({toggle_state:bT})))}toggleDomainList(e,t){e?.preventDefault?.();const s=this.model.get("collapsed_domains");s.includes(t)?this.model.save({collapsed_domains:s.filter((e=>e!==t))}):this.model.save({collapsed_domains:[...s,t]})}}),Zm.plugins.add("converse-roomslist",{dependencies:["converse-singleton","converse-controlbox","converse-muc","converse-bookmarks"],initialize(){bh.settings.extend({muc_grouped_by_domain:!1})}});bh.elements.define("converse-fontawesome",class extends Ob{render(){return Cs` `}});function wT(){if(!bh.settings.get("auto_insert"))return;const e=bh.settings.get("root");if(!e.querySelector("converse-root")){const t=document.createElement("converse-root"),s=e.querySelector("body");s?s.appendChild(t):e.appendChild(t)}}var ST=s(3937),xT={};xT.styleTagTransform=Gb(),xT.setAttributes=Fb(),xT.insert=Pb().bind(null,"head"),xT.domAPI=zb(),xT.insertStyleElement=qb();Rb()(ST.A,xT);ST.A&&ST.A.locals&&ST.A.locals;class AT extends Ob{render(){return(()=>{const e=bh.settings.get("singleton")?["converse-singleton"]:[];return e.push(`converse-${bh.settings.get("view_mode")}`),Cs`
    `})()}initialize(){this.setAttribute("id","conversejs"),this.setClasses();const e=bh.settings.get();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-${bh.settings.get("view_mode")}`),this.classList.add(`theme-${window.matchMedia("(prefers-color-scheme: dark)").matches?bh.settings.get("dark_theme"):bh.settings.get("theme")}`),this.requestUpdate()}}Zm.plugins.add("converse-rootview",{initialize(){bh.settings.extend({auto_insert:!0,theme:"classic",dark_theme:"dracula"}),bh.listen.on("chatBoxesInitialized",wT),bh.elements.define("converse-root",AT)}});const ET=e=>{const t=kb("Add"),s=kb("name@example.org"),n=kb("Group"),i=kb("Name"),r=kb("XMPP Address"),o=e.model.get("error");return Cs`
    `};bh.elements.define("converse-add-contact-modal",class extends t_{initialize(){super.initialize(),this.listenTo(this.model,"change",(()=>this.render())),this.render(),this.addEventListener("shown.bs.modal",(()=>this.querySelector('input[name="jid"]')?.focus()),!1)}renderModal(){return ET(this)}getModalTitle(){return kb("Add a Contact")}validateSubmission(e){return!e||e.split("@").filter((e=>!!e)).length<2?(this.model.set("error",kb("Please enter a valid XMPP address")),!1):yu.state.roster.get(qe.getBareJidFromJid(e))?(this.model.set("error",kb("This contact has already been added")),!1):(this.model.set("error",null),!0)}afterSubmission(e,t,s,n){n&&!Array.isArray(n)&&(n=[n]),yu.state.roster.addAndSubscribe(t,s,n),this.model.clear(),this.modal.hide()}async addContactFromForm(e){e.preventDefault();const t=new FormData(e.target);let s=(t.get("name")||"").trim(),n=(t.get("jid")||"").trim();if(!n&&"string"==typeof bh.settings.get("xhr_user_search_url")){const e=await aA(s);if(1!==e.length)return this.model.set("error",kb("Sorry, could not find a contact with that name")),void this.render();n=e[0].value,s=e[0].label}this.validateSubmission(n)&&this.afterSubmission(e.target,n,s,t.get("group"))}});const{isUniView:CT}=om;function $T(e){const t=e.get("jid"),s=[];if(CT()){const e=yu.state.chatboxes.get(t);e&&!e.get("hidden")&&s.push("open")}const n=e.get("ask"),i=e.get("requesting"),r=e.get("subscription");return"subscribe"===n||"from"===r?s.push("pending-xmpp-contact"):!0===i?s.push("requesting-xmpp-contact"):("both"===r||"to"===r||om.isSameBareJID(t,bh.connection.get().jid))&&(s.push("current-xmpp-contact"),s.push(r),s.push(e.presence.get("show"))),Cs`
  • `}const jT=e=>{const t=kb("Click to hide these contacts"),s=yu.state.roster.state.get("collapsed_groups");return Cs``},kT=e=>{const t=kb("Filter"),s=kb("Filter by contact name"),n=kb("Filter by group name"),i=kb("Filter by status"),r=kb("Any"),o=kb("Unread"),a=kb("Available"),c=kb("Chatty"),l=kb("Busy"),d=kb("Away"),u=kb("Extended Away"),h=kb("Offline"),m=e.model.get("state"),g=e.model.get("text"),f=e.model.get("type");return Cs`
    `},{CLOSED:TT}=wb,IT=e=>{const t=kb("Contacts"),s=kb("Click to toggle contacts"),n=kb("Add a contact"),i=yu.state.roster||[],r=i.reduce(((e,t)=>function(e,t){if(t.get("requesting")){const s=yu.labels.HEADER_REQUESTING_CONTACTS;e[s]?e[s].push(t):e[s]=[t]}else{let s;bh.settings.get("roster_groups")?(s=t.get("groups"),s=0===s.length?[yu.labels.HEADER_UNGROUPED]:s):s="subscribe"===t.get("ask")?[yu.labels.HEADER_PENDING_CONTACTS]:[yu.labels.HEADER_CURRENT_CONTACTS];for(const n of s)e[n]?e[n].push(t):e[n]=[t]}if(t.get("num_unread")){const s=yu.labels.HEADER_UNREAD;e[s]?e[s].push(t):e[s]=[t]}return e}(e,t)),{}),o=Object.keys(r).filter((t=>function(e,t){if(!t.get("filter_visible"))return!0;const s=yu.state.roster_filter;if("groups"===s.get("type")){const t=s.get("text")?.toLowerCase();if(!t)return!0;if(!e.toLowerCase().includes(t))return!1}return!0}(t,e.model))),a=e.model.get("toggle_state")===TT;o.sort(oA);const c=kb("Show filter"),l=kb("Hide filter"),d=e.model.get("filter_visible"),u=[];if(bh.settings.get("allow_contact_requests")&&u.push(Cs`${n}`),i.length>5&&u.push(Cs`${d?l:c}`),"debug"===bh.settings.get("loglevel")){const t=kb("Re-sync contacts");u.push(Cs`${t}`)}return Cs`
    ${d?Cs``:""} ${bS(o,(e=>e),(t=>{const s=r[t].filter((s=>function(e,t,s){if(!s.get("filter_visible"))return!0;const n=e.presence.get("show");return bh.settings.get("hide_offline_users")&&"offline"===n?("subscribe"===e.get("ask")||"from"===e.get("subscription")||!0===e.get("requesting"))&&!iA(e,t):!iA(e,t)}(s,t,e.model)));return s.sort(rA),s.length?jT({contacts:s,name:t}):""}))}
    `},{initStorage:OT}=om,{CLOSED:NT,OPENED:MT}=wb;bh.elements.define("converse-roster",class extends Ob{async initialize(){const e=`converse.contacts-panel${yu.session.get("bare_jid")}`;this.model=new wd({id:e}),OT(this.model,e),this.model.fetch(),await bh.waitUntil("rosterInitialized");const{chatboxes:t,presences:s,roster:n}=yu.state;this.listenTo(yu,"rosterContactsFetched",(()=>this.requestUpdate())),this.listenTo(s,"change:show",(()=>this.requestUpdate())),this.listenTo(t,"change:hidden",(()=>this.requestUpdate())),this.listenTo(n,"add",(()=>this.requestUpdate())),this.listenTo(n,"destroy",(()=>this.requestUpdate())),this.listenTo(n,"remove",(()=>this.requestUpdate())),this.listenTo(n,"change",(()=>this.requestUpdate())),this.listenTo(n.state,"change",(()=>this.requestUpdate())),this.listenTo(this.model,"change",(()=>this.requestUpdate())),bh.trigger("rosterViewInitialized")}render(){return IT(this)}showAddContactModal(e){bh.modal.show("converse-add-contact-modal",{model:new wd},e)}async syncContacts(e){e?.preventDefault();const{roster:t}=yu.state;this.syncing_contacts=!0,this.requestUpdate(),t.data.save("version",null),await t.fetchFromServer(),bh.user.presence.send(),this.syncing_contacts=!1,this.requestUpdate()}toggleRoster(e){e?.preventDefault?.();const t=this.querySelector(".list-container.roster-contacts");this.model.get("toggle_state")===NT?Zw(t).then((()=>this.model.save({toggle_state:MT}))):eS(t).then((()=>this.model.save({toggle_state:NT})))}toggleFilter(e){e?.preventDefault?.(),this.model.save({filter_visible:!this.model.get("filter_visible")})}});const RT={dnd:kb("This contact is busy"),online:kb("This contact is online"),offline:kb("This contact is offline"),unavailable:kb("This contact is unavailable"),xa:kb("This contact is away for an extended period"),away:kb("This contact is away")},DT=(e,t)=>{const s=t.presence.get("show")||"offline";let n,i;[n,i]="online"===s?["fa fa-circle","chat-status-online"]:"dnd"===s?["fa fa-minus-circle","chat-status-busy"]:"away"===s?["fa fa-circle","chat-status-away"]:["fa fa-circle","subdued-color"];const r=RT[s],o=t.get("num_unread")||0,a=t.getDisplayName(),c=kb("Click to chat with %1$s (XMPP address: %2$s)",a,e.model.get("jid"));return Cs`${o?Cs`${o}`:""} ${a} ${bh.settings.get("allow_contact_removal")?((e,t)=>{const s=t.getDisplayName(),n=kb("Click to remove %1$s as a contact",s);return Cs``})(e,t):""}`};class zT extends Ob{static get properties(){return{model:{type:Object}}}constructor(){super(),this.model=null}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())),this.listenTo(this.model,"presenceChanged",(()=>this.requestUpdate()))}render(){if(!0===this.model.get("requesting")){const e=this.model.getDisplayName();return(e=>Cs`${e.display_name} `)(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:kb("Click to accept the contact request from %1$s",e),desc_decline:kb("Click to decline the contact request from %1$s",e)}))}return DT(this,this.model)}openChat(e){e?.preventDefault?.(),this.model.openChat()}async removeContact(e){if(e?.preventDefault?.(),!bh.settings.get("allow_contact_removal"))return;if(await bh.confirm(kb("Are you sure you want to remove this contact?")))try{this.model.removeFromRoster(),this.model.collection&&this.model.destroy()}catch(e){kt.error(e),bh.alert("error",kb("Error"),[kb("Sorry, there was an error while trying to remove %1$s as a contact.",this.model.getDisplayName())])}}async acceptRequest(e){e?.preventDefault?.(),await yu.state.roster.sendContactAddIQ(this.model.get("jid"),this.model.getFullname(),[]),this.model.authorize().subscribe()}async declineRequest(e){e&&e.preventDefault&&e.preventDefault();return await bh.confirm(kb("Are you sure you want to decline this contact request?"))&&this.model.unauthorize().destroy(),this}}bh.elements.define("converse-roster-contact",zT);var LT=s(2537),PT={};PT.styleTagTransform=Gb(),PT.setAttributes=Fb(),PT.insert=Pb().bind(null,"head"),PT.domAPI=zb(),PT.insertStyleElement=qb();Rb()(LT.A,PT);LT.A&<.A.locals&<.A.locals;Zm.plugins.add("converse-rosterview",{dependencies:["converse-roster","converse-modal","converse-chatboxviews"],initialize(){bh.settings.extend({autocomplete_add_contact:!0,allow_contact_removal:!0,hide_offline_users:!1,roster_groups:!0,xhr_user_search_url:null}),bh.promises.add("rosterViewInitialized");const e={RosterFilter:Jv,RosterContactView:zT};Object.assign(yu,e),Object.assign(yu.exports,e),bh.listen.on("chatBoxesInitialized",(()=>{yu.state.chatboxes.on("destroy",(e=>nA(e))),yu.state.chatboxes.on("change:hidden",(e=>nA(e)))}))}});var UT=s(6047),FT={};FT.styleTagTransform=Gb(),FT.setAttributes=Fb(),FT.insert=Pb().bind(null,"head"),FT.domAPI=zb(),FT.insertStyleElement=qb();Rb()(UT.A,FT);UT.A&&UT.A.locals&&UT.A.locals;Zm.plugins.add("converse-singleton",{enabled:e=>e.api.settings.get("singleton"),initialize(){bh.settings.extend({allow_logout:!1,allow_muc_invitations:!1,hide_muc_server:!0});const e=bh.settings.get("auto_join_rooms"),t=bh.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.")}});const{u:BT}=Zm.env,qT={};function HT(e,t=!0){if(!bh.settings.get("allow_dragresize"))return!0;e.preventDefault();const s=BT.ancestor(e.target,".box-flyout"),n=window.getComputedStyle(s),i=s.parentElement;i.height=parseInt(n.height.replace(/px$/,""),10),qT.chatbox=i,qT.direction="top",i.prev_pageY=e.pageY,t&&bh.trigger("startVerticalResize",i)}function GT(e,t=!0){if(!bh.settings.get("allow_dragresize"))return!0;e.preventDefault();const s=BT.ancestor(e.target,".box-flyout"),n=window.getComputedStyle(s),i=s.parentElement;i.width=parseInt(n.width.replace(/px$/,""),10),qT.chatbox=i,qT.direction="left",i.prev_pageX=e.pageX,t&&bh.trigger("startHorizontalResize",i)}function WT(e){GT(e,!1),HT(e,!1),qT.direction="topleft",bh.trigger("startDiagonalResize",this)}function VT(e,t){if(void 0===e)return;if(void 0===t)return e;return e!==t&&Math.abs(e-t)<10?t:e}function QT(e){if(!qT.chatbox||!bh.settings.get("allow_dragresize"))return!0;e.preventDefault(),qT.chatbox.resizeChatBox(e)}function JT(e){if(!qT.chatbox||!bh.settings.get("allow_dragresize"))return!0;e.preventDefault();const t=VT(qT.chatbox.height,qT.chatbox.model.get("default_height")),s=VT(qT.chatbox.width,qT.chatbox.model.get("default_width"));bh.connection.connected()?(qT.chatbox.model.save({height:t}),qT.chatbox.model.save({width:s})):(qT.chatbox.model.set({height:t}),qT.chatbox.model.set({width:s})),delete qT.chatbox,delete qT.direction}const KT=()=>Cs`
    `;bh.elements.define("converse-dragresize",class extends Ob{render(){return KT()}});const YT={initDragResize(){const e=Su((()=>this.setDimensions()));window.addEventListener("resize",e),this.listenTo(this.model,"destroy",(()=>window.removeEventListener("resize",e)));const t=this.querySelector(".box-flyout"),s=window.getComputedStyle(t);if(void 0===this.model.get("height")){const e=parseInt(s.height.replace(/px$/,""),10),t=parseInt(s.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 n=s["min-width"],i=s["min-height"];return this.model.set("min_width",n.endsWith("px")?Number(n.replace(/px$/,"")):0),this.model.set("min_height",i.endsWith("px")?Number(i.replace(/px$/,"")):0),this.prev_pageY=0,this.prev_pageX=0,bh.connection.get()?.connected&&(this.height=this.model.get("height"),this.width=this.model.get("width")),this},resizeChatBox(e){let t;const s=qT.direction;0===s.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))),s.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?VT(e,this.model.get("default_height"))+"px":"";const t=this.querySelector(".box-flyout");null!==t&&(t.style.height=e)},setChatBoxWidth(e){e=e?VT(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)}};Zm.plugins.add("converse-dragresize",{dependencies:["converse-chatview","converse-headlines-view","converse-muc-views"],enabled:()=>"overlayed"==bh.settings.get("view_mode"),overrides:{ChatBox:{initialize(){const e=this.__super__.initialize.apply(this,arguments),t=this.get("height"),s=this.get("width"),n="controlbox"===this.get("id")?e=>this.set(e):e=>this.save(e);return n({height:VT(t,this.get("default_height")),width:VT(s,this.get("default_width"))}),e}}},initialize(){function e(e){const t=Array.from(document.getElementsByTagName("iframe"));for(const s of t)e.addEventListener("mousedown",(()=>{s.style.pointerEvents="none"}),{once:!0}),e.addEventListener("mouseup",(()=>{s.style.pointerEvents="initial"}),{once:!0})}bh.settings.extend({allow_dragresize:!0}),Object.assign(yu.exports.ChatView.prototype,YT),Object.assign(yu.exports.MUCView.prototype,YT),yu.exports.ControlBoxView&&Object.assign(yu.exports.ControlBoxView.prototype,YT),bh.listen.on("registeredGlobalEventHandlers",(function(){document.addEventListener("mousemove",QT),document.addEventListener("mouseup",JT)})),bh.listen.on("unregisteredGlobalEventHandlers",(function(){document.removeEventListener("mousemove",QT),document.removeEventListener("mouseup",JT)})),bh.listen.on("beforeShowingChatView",(e=>e.initDragResize().setDimensions())),bh.listen.on("startDiagonalResize",e),bh.listen.on("startHorizontalResize",e),bh.listen.on("startVerticalResize",e)}});var XT=s(3596),ZT={};ZT.styleTagTransform=Gb(),ZT.setAttributes=Fb(),ZT.insert=Pb().bind(null,"head"),ZT.domAPI=zb(),ZT.insertStyleElement=qb();Rb()(XT.A,ZT);XT.A&&XT.A.locals&&XT.A.locals;const{isUniView:eI}=om;Zm.plugins.add("converse-fullscreen",{enabled:()=>eI(),initialize(){bh.settings.extend({chatview_avatar_height:50,chatview_avatar_width:50,hide_open_bookmarks:!0,show_controlbox_by_default:!0,sticky_controlbox:!0})}}),yu.exports.CustomElement=Ob;const tI=Zm.initialize;Zm.initialize=function(e,t){return Array.isArray(e.whitelisted_plugins)?e.whitelisted_plugins=e.whitelisted_plugins.concat(Nb):e.whitelisted_plugins=Nb,tI(e,t)};const sI=Zm},5160:function(e,t,s){var n,i,r;i=[],void 0===(r="function"==typeof(n=function(){"use strict";var e=void 0!==s.g?s.g:this||window,t=document,n=t.documentElement,i="body",r=e.BSN={},o=r.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",y="data-target",b="data-height",_="data-title",w="data-dismissible",S="data-trigger",x="data-animation",A="data-container",E="data-placement",C="data-delay",$="backdrop",j="keyboard",k="delay",T="content",I="target",O="currentTarget",N="animation",M="placement",R="container",D="offsetTop",z="offsetLeft",L="scrollTop",P="scrollLeft",U="clientWidth",F="clientHeight",B="offsetWidth",q="offsetHeight",H="innerWidth",G="scrollHeight",W="height",V="aria-expanded",Q="aria-hidden",J="aria-selected",K="click",Y="focus",X="hover",Z="keydown",ee="keyup",te="resize",se="onmouseleave"in t?["mouseenter","mouseleave"]:["mouseover","mouseout"],ne="show",ie="shown",re="hide",oe="hidden",ae="close",ce="closed",le="change",de="getAttribute",ue="setAttribute",he="hasAttribute",me="createElement",ge="appendChild",fe="innerHTML",pe="getElementsByTagName",ve="preventDefault",ye="getBoundingClientRect",be="querySelectorAll",_e="getElementsByClassName",we="getComputedStyle",Se="indexOf",xe="parentNode",Ae="length",Ee="toLowerCase",Ce="Transition",$e="Duration",je="Webkit",ke="style",Te="push",Ie="tabindex",Oe="contains",Ne="active",Me="show",Re="collapsing",De="left",ze="right",Le="top",Pe="bottom",Ue=/\b(top|bottom|left|right)+/,Fe=0,Be="fixed-top",qe="fixed-bottom",He=je+Ce in n[ke]||Ce[Ee]()in n[ke],Ge=je+Ce in n[ke]?je[Ee]()+Ce+"End":Ce[Ee]()+"end",We=je+$e in n[ke]?je[Ee]()+Ce+$e:Ce[Ee]()+$e,Ve=function(e){e.focus?e.focus():e.setActive()},Qe=function(e,t){e.classList.add(t)},Je=function(e,t){e.classList.remove(t)},Ke=function(e,t){return e.classList[Oe](t)},Ye=function(e,t){return[].slice.call(e[_e](t))},Xe=function(e,s){return"object"==typeof e?e:(s||t).querySelector(e)},Ze=function(e,s){var n=s.charAt(0),i=s.substr(1);if("."===n){for(;e&&e!==t;e=e[xe])if(null!==Xe(s,e[xe])&&Ke(e,i))return e}else if("#"===n)for(;e&&e!==t;e=e[xe])if(e.id===i)return e;return!1},et=function(e,t,s,n){n=n||!1,e.addEventListener(t,s,n)},tt=function(e,t,s,n){n=n||!1,e.removeEventListener(t,s,n)},st=function(e,t,s,n){et(e,t,(function i(r){s(r),tt(e,t,i,n)}),n)},nt=!!function(){var t=!1;try{var s=Object.defineProperty({},"passive",{get:function(){t=!0}});st(e,"testPassive",null,s)}catch(e){}return t}()&&{passive:!0},it=function(t){var s=He?e[we](t)[We]:0;return s="number"!=typeof(s=parseFloat(s))||isNaN(s)?0:1e3*s},rt=function(e,t){var s=0;it(e)?st(e,Ge,(function(e){!s&&t(e),s=1})):setTimeout((function(){!s&&t(),s=1}),17)},ot=function(e,t,s){var n=new CustomEvent(e+".bs."+t);n.relatedTarget=s,this.dispatchEvent(n)},at=function(){return{y:e.pageYOffset||n[L],x:e.pageXOffset||n[P]}},ct=function(e,s,r,o){var a,c,l,d,u,h,m={w:s[B],h:s[q]},g=n[U]||t[i][U],f=n[F]||t[i][F],p=e[ye](),v=o===t[i]?at():{x:o[z]+o[P],y:o[D]+o[L]},y={w:p[ze]-p[De],h:p[Pe]-p[Le]},b=Ke(s,"popover"),_=Xe(".arrow",s),w=p[Le]+y.h/2-m.h/2<0,S=p[De]+y.w/2-m.w/2<0,x=p[De]+m.w/2+y.w/2>=g,A=p[Le]+m.h/2+y.h/2>=f,E=p[Le]-m.h<0,C=p[De]-m.w<0,$=p[Le]+m.h+y.h>=f,j=p[De]+m.w+y.w>=g;r=(r=(r=(r=(r=(r===De||r===ze)&&C&&j?Le:r)===Le&&E?Pe:r)===Pe&&$?Le:r)===De&&C?ze:r)===ze&&j?De:r,-1===s.className[Se](r)&&(s.className=s.className.replace(Ue,r)),u=_[B],h=_[q],r===De||r===ze?(c=r===De?p[De]+v.x-m.w-(b?u:0):p[De]+v.x+y.w,w?(a=p[Le]+v.y,l=y.h/2-u):A?(a=p[Le]+v.y-m.h+y.h,l=m.h-y.h/2-u):(a=p[Le]+v.y-m.h/2+y.h/2,l=m.h/2-(b?.9*h:h/2))):r!==Le&&r!==Pe||(a=r===Le?p[Le]+v.y-m.h-(b?h:0):p[Le]+v.y+y.h,S?(c=0,d=p[De]+y.w/2-u):x?(c=g-1.01*m.w,d=m.w-(g-p[De])+y.w/2-u/2):(c=p[De]+v.x-m.w/2+y.w/2,d=m.w/2-(b?u:u/2))),s[ke][Le]=a+"px",s[ke][De]=c+"px",l&&(_[ke][Le]=l+"px"),d&&(_[ke][De]=d+"px")};r.version="2.0.27";var lt=function(e){e=Xe(e);var t=this,s="alert",n=Ze(e,"."+s),i=function(){Ke(n,"fade")?rt(n,o):o()},r=function(i){n=Ze(i[I],"."+s),(e=Xe("["+c+'="'+s+'"]',n))&&n&&(e===i[I]||e[Oe](i[I]))&&t.close()},o=function(){ot.call(n,ce,s),tt(e,K,r),n[xe].removeChild(n)};this.close=function(){n&&e&&Ke(n,Me)&&(ot.call(n,ae,s),Je(n,Me),n&&i())},l in e||et(e,K,r),e[l]=t};o[Te]([l,lt,"["+c+'="alert"]']);var dt=function(e){e=Xe(e);var s=!1,n="button",i="checked",r="LABEL",o="INPUT",a=function(e){32===(e.which||e.keyCode)&&e[I]===t.activeElement&&l(e)},c=function(e){32===(e.which||e.keyCode)&&e[ve]()},l=function(t){var a=t[I].tagName===r?t[I]:t[I][xe].tagName===r?t[I][xe]:null;if(a){var c=Ye(a[xe],"btn"),l=a[pe](o)[0];if(l){if("checkbox"===l.type&&(l[i]?(Je(a,Ne),l[de](i),l.removeAttribute(i),l[i]=!1):(Qe(a,Ne),l[de](i),l[ue](i,i),l[i]=!0),s||(s=!0,ot.call(l,le,n),ot.call(e,le,n))),"radio"===l.type&&!s&&(!l[i]||0===t.screenX&&0==t.screenY)){Qe(a,Ne),Qe(a,Y),l[ue](i,i),l[i]=!0,ot.call(l,le,n),ot.call(e,le,n),s=!0;for(var d=0,u=c[Ae];d1?o-1:0:40===i&&o×',j=Xe(n[R]),T=Xe(d),O=Ze(s,".modal"),D=Ze(s,"."+Be),z=Ze(s,"."+qe);this[h]=n[h]?n[h]:null,this[m]=n[m]?n[m]:r||X,this[N]=n[N]&&n[N]!==v?n[N]:o||v,this[M]=n[M]?n[M]:a||Le,this[k]=parseInt(n[k]||l)||200,this[b]=!(!n[b]&&"true"!==c),this[R]=j||T||D||z||O||t[i];var L=this,P=n.title||s[de](_)||null,U=n.content||s[de](y)||null;if(U||this[h]){var F=null,B=0,q=this[M],H=function(e){null!==F&&e[I]===Xe(".close",F)&&L.hide()},G=function(){L[R].removeChild(F),B=null,F=null},W=function(){P=n.title||s[de](_),U=(U=n.content||s[de](y))?U.trim():null,F=t[me](p);var e=t[me](p);if(e[ue](f,"arrow"),F[ge](e),null!==U&&null===L[h]){if(F[ue]("role","tooltip"),null!==P){var i=t[me]("h3");i[ue](f,u+"-header"),i[fe]=L[b]?P+$:P,F[ge](i)}var r=t[me](p);r[ue](f,u+"-body"),r[fe]=L[b]&&null===P?U+$:U,F[ge](r)}else{var o=t[me](p);L[h]=L[h].trim(),o[fe]=L[h],F[fe]=o.firstChild[fe]}L[R][ge](F),F[ke].display="block",F[ue](f,u+" bs-"+u+"-"+q+" "+L[N])},V=function(){!Ke(F,Me)&&Qe(F,Me)},Q=function(){ct(s,F,q,L[R])},J=function(n){K!=L[m]&&"focus"!=L[m]||!L[b]&&n(s,"blur",L.hide),L[b]&&n(t,K,H),n(e,te,L.hide,nt)},Y=function(){J(et),ot.call(s,ie,u)},Z=function(){J(tt),G(),ot.call(s,oe,u)};this.toggle=function(){null===F?L.show():L.hide()},this.show=function(){clearTimeout(B),B=setTimeout((function(){null===F&&(q=L[M],W(),Q(),V(),ot.call(s,ne,u),L[N]?rt(F,Y):Y())}),20)},this.hide=function(){clearTimeout(B),B=setTimeout((function(){F&&null!==F&&Ke(F,Me)&&(ot.call(s,re,u),Je(F,Me),L[N]?rt(F,Z):Z())}),L[k])},g in s||(L[m]===X?(et(s,se[0],L.show),L[b]||et(s,se[1],L.hide)):K!=L[m]&&"focus"!=L[m]||et(s,L[m],L.toggle)),s[g]=L}};o[Te]([g,gt,"["+a+'="popover"]']);var ft=function(e,t){var s=(e=Xe(e))[de](b),n="tab",i="height",r="float",o="isAnimating";t=t||{},this[i]=!!He&&(t[i]||"true"===s);var a,c,l,d,u,h,m,g=this,p=Ze(e,".nav"),v=!1,y=p&&Xe(".dropdown-toggle",p),_=function(){v[ke][i]="",Je(v,Re),p[o]=!1},w=function(){v?h?_():setTimeout((function(){v[ke][i]=m+"px",v[B],rt(v,_)}),50):p[o]=!1,ot.call(a,ie,n,c)},S=function(){v&&(l[ke][r]=De,d[ke][r]=De,u=l[G]),Qe(d,Ne),ot.call(a,ne,n,c),Je(l,Ne),ot.call(c,oe,n,a),v&&(m=d[G],h=m===u,Qe(v,Re),v[ke][i]=u+"px",v[q],l[ke][r]="",d[ke][r]=""),Ke(d,"fade")?setTimeout((function(){Qe(d,Me),rt(d,w)}),20):w()};if(p){p[o]=!1;var x=function(){var e,t=Ye(p,Ne);return 1!==t[Ae]||Ke(t[0][xe],"dropdown")?t[Ae]>1&&(e=t[t[Ae]-1]):e=t[0],e},A=function(){return Xe(x()[de]("href"))},E=function(e){e[ve](),a=e[O],!p[o]&&!Ke(a,Ne)&&g.show()};this.show=function(){d=Xe((a=a||e)[de]("href")),c=x(),l=A(),p[o]=!0,Je(c,Ne),c[ue](J,"false"),Qe(a,Ne),a[ue](J,"true"),y&&(Ke(e[xe],"dropdown-menu")?Ke(y,Ne)||Qe(y,Ne):Ke(y,Ne)&&Je(y,Ne)),ot.call(c,re,n,a),Ke(l,"fade")?(Je(l,Me),rt(l,S)):S()},f in e||et(e,K,E),g[i]&&(v=A()[xe]),e[f]=g}};o[Te]([f,ft,"["+a+'="tab"]']);var pt=function(e,t){for(var s=0,n=t[Ae];s{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2270:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},9416:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},3710:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},4865:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},1905:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},8025:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},3596:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},8451:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},5198:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},4159:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},8664:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},5495:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},33:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},5628:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},5101:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},6833:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},3180:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2444:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},6826:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},9753:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},4788:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},5052:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},3937:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2537:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},6047:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},7434:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},7688:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},6373:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},6611:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},4808:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},7013:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2606:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},1246:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},1115:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},7024:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},7561:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2608:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},9110:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},1846:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},1549:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},9956:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},804:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},2910:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});var n=s(698),i=s.n(n),r=s(7370),o=s.n(r)()(i());o.push([e.id,"","",{version:3,sources:[],names:[],mappings:"",sourceRoot:""}]);const a=o},9499:(e,t,s)=>{var n={"./af.js":[734,5628],"./am.js":[5763,8489],"./ar-dz.js":[4121,3741],"./ar-iq.js":[9725,6605],"./ar-kw.js":[4985,861],"./ar-ly.js":[8280,1696],"./ar-ma.js":[4057,7385],"./ar-sa.js":[1643,131],"./ar-tn.js":[4645,7801],"./ar.js":[8994,8880],"./az.js":[8010,9080],"./be.js":[6604,2366],"./bg.js":[3046,1072],"./bi.js":[5704,1938],"./bm.js":[3204,6486],"./bn-bd.js":[6560,6124],"./bn.js":[5053,9423],"./bo.js":[7662,1464],"./br.js":[7817,2643],"./bs.js":[5290,1116],"./ca.js":[1065,9395],"./cs.js":[1175,5825],"./cv.js":[6204,2766],"./cy.js":[4049,7003],"./da.js":[5250,6208],"./de-at.js":[6846,5534],"./de-ch.js":[7160,6064],"./de.js":[9310,5036],"./dv.js":[9419,2993],"./el.js":[9144,9782],"./en-au.js":[8681,6121],"./en-ca.js":[4379,5611],"./en-gb.js":[2410,4094],"./en-ie.js":[817,1665],"./en-il.js":[8074,8178],"./en-in.js":[8224,7028],"./en-nz.js":[9059,8343],"./en-sg.js":[7745,3341],"./en-tt.js":[9355,7627],"./en.js":[5586,6824],"./eo.js":[3473,8031],"./es-do.js":[1603,9271],"./es-mx.js":[9871,591],"./es-pr.js":[6156,2856],"./es-us.js":[7570,4182],"./es.js":[7845,1827],"./et.js":[4048,385],"./eu.js":[5351,933],"./fa.js":[1636,598],"./fi.js":[8860,3166],"./fo.js":[4906,7596],"./fr-ca.js":[4658,9870],"./fr-ch.js":[6921,9101],"./fr.js":[573,8431],"./fy.js":[3244,9710],"./ga.js":[3821,7743],"./gd.js":[5074,5284],"./gl.js":[4090,5724],"./gom-latn.js":[8948,8630],"./gu.js":[6305,8443],"./he.js":[9242,2384],"./hi.js":[7902,4852],"./hr.js":[5571,2241],"./ht.js":[3881,6007],"./hu.js":[5178,1712],"./hy-am.js":[226,9589],"./id.js":[7180,4770],"./is.js":[5273,3359],"./it-ch.js":[1206,4718],"./it.js":[6444,4034],"./ja.js":[680,4434],"./jv.js":[7469,9007],"./ka.js":[9313,4523],"./kk.js":[7239,6641],"./km.js":[3045,3287],"./kn.js":[2268,4974],"./ko.js":[3555,8789],"./ku.js":[493,687],"./ky.js":[6713,7491],"./lb.js":[8567,1373],"./lo.js":[516,6042],"./lt.js":[5013,4859],"./lv.js":[6419,9593],"./me.js":[3167,4333],"./mi.js":[9971,3729],"./mk.js":[4245,5059],"./ml.js":[2032,5998],"./mn.js":[2458,1056],"./mr.js":[4830,4260],"./ms-my.js":[9072,4512],"./ms.js":[2221,2091],"./mt.js":[2872,3014],"./my.js":[4035,561],"./nb.js":[9749,7],"./ne.js":[832,5946],"./nl-be.js":[8961,9109],"./nl.js":[4495,7497],"./nn.js":[6481,1275],"./oc-lnc.js":[8033,1719],"./pa-in.js":[5092,2664],"./pl.js":[7001,6343],"./pt-br.js":[8954,2014],"./pt.js":[2129,6191],"./rn.js":[4237,3519],"./ro.js":[8222,4584],"./ru.js":[6684,7806],"./rw.js":[5142,8176],"./sd.js":[2982,3664],"./se.js":[1941,9975],"./si.js":[590,9547],"./sk.js":[7375,6537],"./sl.js":[5070,8232],"./sq.js":[1049,9411],"./sr-cyrl.js":[2863,9331],"./sr.js":[5568,4858],"./ss.js":[6071,2769],"./sv-fi.js":[1800,6660],"./sv.js":[1100,1982],"./sw.js":[2739,2389],"./ta.js":[7730,832],"./te.js":[2478,4636],"./tet.js":[192,8592],"./tg.js":[2244,7962],"./th.js":[2153,6655],"./tk.js":[9200,422],"./tl-ph.js":[5406,8022],"./tlh.js":[3297,8945],"./tr.js":[4655,9557],"./tzl.js":[5027,3683],"./tzm-latn.js":[5300,138],"./tzm.js":[4764,9052],"./ug-cn.js":[9191,3731],"./uk.js":[4413,4107],"./ur.js":[9894,1388],"./uz-latn.js":[9398,5970],"./uz.js":[4974,948],"./vi.js":[4988,3774],"./x-pseudo.js":[2112,5790],"./yo.js":[477,6803],"./zh-cn.js":[1105,4385],"./zh-hk.js":[4013,7013],"./zh-tw.js":[437,7981],"./zh.js":[3239,4497]};function i(e){if(!s.o(n,e))return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=n[e],i=t[0];return s.e(t[1]).then((()=>s.t(i,23)))}i.keys=()=>Object.keys(n),i.id=9499,e.exports=i},2665:(e,t,s)=>{"use strict";const n=s(4505),i=s(4007);e.exports={atob:n,btoa:i}},4505:e=>{"use strict";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s(e){const s=t.indexOf(e);return s<0?void 0:s}e.exports=function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");if((e=(e=`${e}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;let t="",n=0,i=0;for(let r=0;r>16),t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n),n=i=0);return 12===i?(n>>=4,t+=String.fromCharCode(n)):18===i&&(n>>=2,t+=String.fromCharCode((65280&n)>>8),t+=String.fromCharCode(255&n)),t}},4007:e=>{"use strict";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s(e){if(e>=0&&e<64)return t[e]}e.exports=function(e){if(0===arguments.length)throw new TypeError("1 argument required, but only 0 present.");let t;for(e=`${e}`,t=0;t255)return null;let n="";for(t=0;t>2,i[1]=(3&e.charCodeAt(t))<<4,e.length>t+1&&(i[1]|=e.charCodeAt(t+1)>>4,i[2]=(15&e.charCodeAt(t+1))<<2),e.length>t+2&&(i[2]|=e.charCodeAt(t+2)>>6,i[3]=63&e.charCodeAt(t+2));for(let e=0;e{window,e.exports=function(e){var t={};function s(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},s.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=7)}([function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.loadImageElement=function(e,t){return new Promise((function(s,n){e.addEventListener("load",(function(){s(e)}),!1),e.addEventListener("error",(function(e){n(e)}),!1),e.src=t}))},t.resize=function(e,t,s,n){if(!s&&!n)return{currentWidth:e,currentHeight:t};var i=e/t,r=void 0,o=void 0;return i>s/n?o=(r=Math.min(e,s))/i:r=(o=Math.min(t,n))*i,{width:r,height:o}}},function(e,t,s){"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",s=window.atob(e),n=[],i=0;i8)return r.drawImage(e,0,0,i.width,i.height),i;switch(n>4&&(i.width=s,i.height=t),n){case 2:r.translate(t,0),r.scale(-1,1);break;case 3:r.translate(t,s),r.rotate(Math.PI);break;case 4:r.translate(0,s),r.scale(1,-1);break;case 5:r.rotate(.5*Math.PI),r.scale(1,-1);break;case 6:r.rotate(.5*Math.PI),r.translate(0,-s);break;case 7:r.rotate(.5*Math.PI),r.translate(t,-s),r.scale(-1,1);break;case 8:r.rotate(-.5*Math.PI),r.translate(-t,0)}return n>4?r.drawImage(e,0,0,i.height,i.width):r.drawImage(e,0,0,i.width,i.height),i},t.canvasToBlob=function(e,t){return new Promise((function(s,n){e.toBlob((function(e){s(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,s){var n=new window.FileReader;n.addEventListener("load",(function(e){t(e.target.result)}),!1),n.addEventListener("error",(function(e){s(e)}),!1),n.readAsDataURL(e)}))}},function(e,t,s){e.exports=s(6)},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractOrientation=function(e){return new Promise((function(t,s){var n=new window.FileReader;n.onload=function(e){var s=new DataView(e.target.result);65496!==s.getUint16(0,!1)&&t(-2);for(var n=s.byteLength,i=2;i=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(c&&l){if(this.prev=0;--s){var n=this.tryEntries[s];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var s=this.tryEntries[t];if(s.finallyLoc===e)return this.complete(s.completion,s.afterLoc),k(s),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var s=this.tryEntries[t];if(s.tryLoc===e){var n=s.completion;if("throw"===n.type){var i=n.arg;k(s)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:I(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=s),f}}}function _(e,t,s,n){var i=t&&t.prototype instanceof S?t:S,r=Object.create(i.prototype),o=new T(n||[]);return r._invoke=function(e,t,s){var n=u;return function(i,r){if(n===m)throw new Error("Generator is already running");if(n===g){if("throw"===i)throw r;return O()}for(s.method=i,s.arg=r;;){var o=s.delegate;if(o){var a=$(o,s);if(a){if(a===f)continue;return a}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(n===u)throw n=g,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);n=m;var c=w(e,t,s);if("normal"===c.type){if(n=s.done?g:h,c.arg===f)continue;return{value:c.arg,done:s.done}}"throw"===c.type&&(n=g,s.method="throw",s.arg=c.arg)}}}(e,s,o),r}function w(e,t,s){try{return{type:"normal",arg:e.call(t,s)}}catch(e){return{type:"throw",arg:e}}}function S(){}function x(){}function A(){}function E(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function C(e){var t;this._invoke=function(s,n){function r(){return new Promise((function(t,r){!function t(s,n,r,o){var a=w(e[s],e,n);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,r,o)}),(function(e){t("throw",e,r,o)})):Promise.resolve(l).then((function(e){c.value=e,r(c)}),o)}o(a.arg)}(s,n,t,r)}))}return t=t?t.then(r,r):r()}}function $(e,t){var n=e.iterator[t.method];if(n===s){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=s,$(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(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var r=i.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=s),t.delegate=null,f):r:(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n=0,r=i&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,e.exports=s(5),i)n.regeneratorRuntime=r;else try{delete n.regeneratorRuntime}catch(e){n.regeneratorRuntime=void 0}},function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=c(s(2)),i=function(){function e(e,t){for(var s=0;s0&&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},s=new Proxy(e,{get:function(e,s){return s in e?e[s]:t[s]}});this.options=s}},{key:"_compressFile",value:function(){var e=l(n.default.mark((function e(t){var s,i;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=new a.default(t),(i={}).start=window.performance.now(),i.quality=this.options.quality,i.startType=s.type,e.next=7,s.load();case 7:return e.next=9,this._compressImage(s,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(n.default.mark((function e(t,s){var i,a,c,l,d;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s.startWidth=t.width,s.startHeight=t.height,i=void 0,a=void 0,this.options.resize?(c=(0,o.resize)(t.width,t.height,this.options.maxWidth,this.options.maxHeight),i=c.width,a=c.height):(i=t.width,a=t.height),s.endWidth=i,s.endHeight=a,l=this.doAutoRotation?void 0:1,d=t.getCanvas(i,a,l),s.iterations=0,s.startSizeMB=r.size(t.size).MB,e.next=12,this._loopCompression(d,t,s);case 12:return s.endSizeMB=r.size(t.size).MB,s.sizeReducedInPercent=(s.startSizeMB-s.endSizeMB)/s.startSizeMB*100,s.end=window.performance.now(),s.elapsedTimeInSeconds=(s.end-s.start)/1e3,s.endType=t.type,e.abrupt("return",{photo:t,info:s});case 18:case"end":return e.stop()}}),e,this)})));return function(t,s){return e.apply(this,arguments)}}()},{key:"_loopCompression",value:function(){var e=l(n.default.mark((function e(t,s,i){var o;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i.iterations++,e.t0=s,e.next=4,r.canvasToBlob(t,i.quality);case 4:if(e.t1=e.sent,e.t0.setData.call(e.t0,e.t1),1==i.iterations&&(s.width=i.endWidth,s.height=i.endHeight),!(r.size(s.size).MB>this.options.targetSize)){e.next=24;break}if(!(i.quality.toFixed(10)-.1{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var s="",n=void 0!==t[5];return t[4]&&(s+="@supports (".concat(t[4],") {")),t[2]&&(s+="@media ".concat(t[2]," {")),n&&(s+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),s+=e(t),n&&(s+="}"),t[2]&&(s+="}"),t[4]&&(s+="}"),s})).join("")},t.i=function(e,s,n,i,r){"string"==typeof e&&(e=[[null,e,void 0]]);var o={};if(n)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),s&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=s):d[2]=s),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),t.push(d))}},t}},698:e=>{"use strict";e.exports=function(e){var t=e[1],s=e[3];if(!s)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),r="/*# ".concat(i," */");return[t].concat([r]).join("\n")}return[t].join("\n")}},5569:function(e){e.exports=function(){"use strict";var e=1e3,t=6e4,s=36e5,n="millisecond",i="second",r="minute",o="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("_"),ordinal:function(e){var t=["th","st","nd","rd"],s=e%100;return"["+e+(t[(s-20)%10]||t[s]||t[0])+"]"}},v=function(e,t,s){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(s)+e},y={s:v,z:function(e){var t=-e.utcOffset(),s=Math.abs(t),n=Math.floor(s/60),i=s%60;return(t<=0?"+":"-")+v(n,2,"0")+":"+v(i,2,"0")},m:function e(t,s){if(t.date()1)return e(o[0])}else{var a=t.name;_[a]=t,i=a}return!n&&i&&(b=i),i||!n&&b},A=function(e,t){if(S(e))return e.clone();var s="object"==typeof t?t:{};return s.date=e,s.args=arguments,new C(s)},E=y;E.l=x,E.i=S,E.w=function(e,t){return A(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var C=function(){function p(e){this.$L=x(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var v=p.prototype;return v.parse=function(e){this.$d=function(e){var t=e.date,s=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 n=t.match(g);if(n){var i=n[2]-1||0,r=(n[7]||"0").substring(0,3);return s?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,r)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,r)}}return new Date(t)}(e),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 s=A(e);return this.startOf(t)<=s&&s<=this.endOf(t)},v.isAfter=function(e,t){return A(e)1?s-1:0),i=1;i2&&void 0!==arguments[2]?arguments[2]:m;t&&t(e,null);let r=n.length;for(;r--;){let t=n[r];if("string"==typeof t){const e=i(t);e!==t&&(s(n)||(n[r]=e),t=e)}e[t]=!0}return e}function E(e){for(let t=0;t/gm),F=o(/\${[\w\W]*}/gm),B=o(/^data-[\-\w.\u00B7-\uFFFF]/),q=o(/^aria-[\-\w]+$/),H=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=o(/^(?:\w+script|data):/i),W=o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),V=o(/^html$/i),Q=o(/^[a-z][.\w]*(-[.\w]+)+$/i);var J=Object.freeze({__proto__:null,MUSTACHE_EXPR:P,ERB_EXPR:U,TMPLIT_EXPR:F,DATA_ATTR:B,ARIA_ATTR:q,IS_ALLOWED_URI:H,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:W,DOCTYPE_NAME:V,CUSTOM_ELEMENT:Q});const K=function(){return"undefined"==typeof window?null:window},Y=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let s=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(s=t.getAttribute(n));const i="dompurify"+(s?"#"+s:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function X(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:K();const s=e=>X(e);if(s.version="3.0.11",s.removed=[],!t||!t.document||9!==t.document.nodeType)return s.isSupported=!1,s;let{document:n}=t;const i=n,o=i.currentScript,{DocumentFragment:c,HTMLTemplateElement:l,Node:S,Element:x,NodeFilter:E,NamedNodeMap:P=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:U,DOMParser:F,trustedTypes:B}=t,q=x.prototype,G=$(q,"cloneNode"),W=$(q,"nextSibling"),Q=$(q,"childNodes"),Z=$(q,"parentNode");if("function"==typeof l){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let ee,te="";const{implementation:se,createNodeIterator:ne,createDocumentFragment:ie,getElementsByTagName:re}=n,{importNode:oe}=i;let ae={};s.isSupported="function"==typeof e&&"function"==typeof Z&&se&&void 0!==se.createHTMLDocument;const{MUSTACHE_EXPR:ce,ERB_EXPR:le,TMPLIT_EXPR:de,DATA_ATTR:ue,ARIA_ATTR:he,IS_SCRIPT_OR_DATA:me,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:fe}=J;let{IS_ALLOWED_URI:pe}=J,ve=null;const ye=A({},[...j,...k,...T,...O,...M]);let be=null;const _e=A({},[...R,...D,...z,...L]);let we=Object.seal(a(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}})),Se=null,xe=null,Ae=!0,Ee=!0,Ce=!1,$e=!0,je=!1,ke=!1,Te=!1,Ie=!1,Oe=!1,Ne=!1,Me=!1,Re=!0,De=!1;const ze="user-content-";let Le=!0,Pe=!1,Ue={},Fe=null;const Be=A({},["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"]);let qe=null;const He=A({},["audio","video","img","source","image","track"]);let Ge=null;const We=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Qe="http://www.w3.org/2000/svg",Je="http://www.w3.org/1999/xhtml";let Ke=Je,Ye=!1,Xe=null;const Ze=A({},[Ve,Qe,Je],g);let et=null;const tt=["application/xhtml+xml","text/html"],st="text/html";let nt=null,it=null;const rt=n.createElement("form"),ot=function(e){return e instanceof RegExp||e instanceof Function},at=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!it||it!==e){if(e&&"object"==typeof e||(e={}),e=C(e),et=-1===tt.indexOf(e.PARSER_MEDIA_TYPE)?st:e.PARSER_MEDIA_TYPE,nt="application/xhtml+xml"===et?g:m,ve=b(e,"ALLOWED_TAGS")?A({},e.ALLOWED_TAGS,nt):ye,be=b(e,"ALLOWED_ATTR")?A({},e.ALLOWED_ATTR,nt):_e,Xe=b(e,"ALLOWED_NAMESPACES")?A({},e.ALLOWED_NAMESPACES,g):Ze,Ge=b(e,"ADD_URI_SAFE_ATTR")?A(C(We),e.ADD_URI_SAFE_ATTR,nt):We,qe=b(e,"ADD_DATA_URI_TAGS")?A(C(He),e.ADD_DATA_URI_TAGS,nt):He,Fe=b(e,"FORBID_CONTENTS")?A({},e.FORBID_CONTENTS,nt):Be,Se=b(e,"FORBID_TAGS")?A({},e.FORBID_TAGS,nt):{},xe=b(e,"FORBID_ATTR")?A({},e.FORBID_ATTR,nt):{},Ue=!!b(e,"USE_PROFILES")&&e.USE_PROFILES,Ae=!1!==e.ALLOW_ARIA_ATTR,Ee=!1!==e.ALLOW_DATA_ATTR,Ce=e.ALLOW_UNKNOWN_PROTOCOLS||!1,$e=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,je=e.SAFE_FOR_TEMPLATES||!1,ke=e.WHOLE_DOCUMENT||!1,Oe=e.RETURN_DOM||!1,Ne=e.RETURN_DOM_FRAGMENT||!1,Me=e.RETURN_TRUSTED_TYPE||!1,Ie=e.FORCE_BODY||!1,Re=!1!==e.SANITIZE_DOM,De=e.SANITIZE_NAMED_PROPS||!1,Le=!1!==e.KEEP_CONTENT,Pe=e.IN_PLACE||!1,pe=e.ALLOWED_URI_REGEXP||H,Ke=e.NAMESPACE||Je,we=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(we.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ot(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(we.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(we.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),je&&(Ee=!1),Ne&&(Oe=!0),Ue&&(ve=A({},M),be=[],!0===Ue.html&&(A(ve,j),A(be,R)),!0===Ue.svg&&(A(ve,k),A(be,D),A(be,L)),!0===Ue.svgFilters&&(A(ve,T),A(be,D),A(be,L)),!0===Ue.mathMl&&(A(ve,O),A(be,z),A(be,L))),e.ADD_TAGS&&(ve===ye&&(ve=C(ve)),A(ve,e.ADD_TAGS,nt)),e.ADD_ATTR&&(be===_e&&(be=C(be)),A(be,e.ADD_ATTR,nt)),e.ADD_URI_SAFE_ATTR&&A(Ge,e.ADD_URI_SAFE_ATTR,nt),e.FORBID_CONTENTS&&(Fe===Be&&(Fe=C(Fe)),A(Fe,e.FORBID_CONTENTS,nt)),Le&&(ve["#text"]=!0),ke&&A(ve,["html","head","body"]),ve.table&&(A(ve,["tbody"]),delete Se.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw w('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw w('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ee=e.TRUSTED_TYPES_POLICY,te=ee.createHTML("")}else void 0===ee&&(ee=Y(B,o)),null!==ee&&"string"==typeof te&&(te=ee.createHTML(""));r&&r(e),it=e}},ct=A({},["mi","mo","mn","ms","mtext"]),lt=A({},["foreignobject","desc","title","annotation-xml"]),dt=A({},["title","style","font","a","script"]),ut=A({},[...k,...T,...I]),ht=A({},[...O,...N]),mt=function(e){let t=Z(e);t&&t.tagName||(t={namespaceURI:Ke,tagName:"template"});const s=m(e.tagName),n=m(t.tagName);return!!Xe[e.namespaceURI]&&(e.namespaceURI===Qe?t.namespaceURI===Je?"svg"===s:t.namespaceURI===Ve?"svg"===s&&("annotation-xml"===n||ct[n]):Boolean(ut[s]):e.namespaceURI===Ve?t.namespaceURI===Je?"math"===s:t.namespaceURI===Qe?"math"===s&<[n]:Boolean(ht[s]):e.namespaceURI===Je?!(t.namespaceURI===Qe&&!lt[n])&&!(t.namespaceURI===Ve&&!ct[n])&&!ht[s]&&(dt[s]||!ut[s]):!("application/xhtml+xml"!==et||!Xe[e.namespaceURI]))},gt=function(e){h(s.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},ft=function(e,t){try{h(s.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){h(s.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!be[e])if(Oe||Ne)try{gt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},pt=function(e){let t=null,s=null;if(Ie)e=""+e;else{const t=f(e,/^[\r\n\t ]+/);s=t&&t[0]}"application/xhtml+xml"===et&&Ke===Je&&(e=''+e+"");const i=ee?ee.createHTML(e):e;if(Ke===Je)try{t=(new F).parseFromString(i,et)}catch(e){}if(!t||!t.documentElement){t=se.createDocument(Ke,"template",null);try{t.documentElement.innerHTML=Ye?te:i}catch(e){}}const r=t.body||t.documentElement;return e&&s&&r.insertBefore(n.createTextNode(s),r.childNodes[0]||null),Ke===Je?re.call(t,ke?"html":"body")[0]:ke?t.documentElement:r},vt=function(e){return ne.call(e.ownerDocument||e,e,E.SHOW_ELEMENT|E.SHOW_COMMENT|E.SHOW_TEXT|E.SHOW_PROCESSING_INSTRUCTION|E.SHOW_CDATA_SECTION,null)},yt=function(e){return e instanceof U&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof P)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},bt=function(e){return"function"==typeof S&&e instanceof S},_t=function(e,t,n){ae[e]&&d(ae[e],(e=>{e.call(s,t,n,it)}))},wt=function(e){let t=null;if(_t("beforeSanitizeElements",e,null),yt(e))return gt(e),!0;const n=nt(e.nodeName);if(_t("uponSanitizeElement",e,{tagName:n,allowedTags:ve}),e.hasChildNodes()&&!bt(e.firstElementChild)&&_(/<[/\w]/g,e.innerHTML)&&_(/<[/\w]/g,e.textContent))return gt(e),!0;if(7===e.nodeType)return gt(e),!0;if(!ve[n]||Se[n]){if(!Se[n]&&xt(n)){if(we.tagNameCheck instanceof RegExp&&_(we.tagNameCheck,n))return!1;if(we.tagNameCheck instanceof Function&&we.tagNameCheck(n))return!1}if(Le&&!Fe[n]){const t=Z(e)||e.parentNode,s=Q(e)||e.childNodes;if(s&&t)for(let n=s.length-1;n>=0;--n)t.insertBefore(G(s[n],!0),W(e))}return gt(e),!0}return e instanceof x&&!mt(e)?(gt(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!_(/<\/no(script|embed|frames)/i,e.innerHTML)?(je&&3===e.nodeType&&(t=e.textContent,d([ce,le,de],(e=>{t=p(t,e," ")})),e.textContent!==t&&(h(s.removed,{element:e.cloneNode()}),e.textContent=t)),_t("afterSanitizeElements",e,null),!1):(gt(e),!0)},St=function(e,t,s){if(Re&&("id"===t||"name"===t)&&(s in n||s in rt))return!1;if(Ee&&!xe[t]&&_(ue,t));else if(Ae&&_(he,t));else if(!be[t]||xe[t]){if(!(xt(e)&&(we.tagNameCheck instanceof RegExp&&_(we.tagNameCheck,e)||we.tagNameCheck instanceof Function&&we.tagNameCheck(e))&&(we.attributeNameCheck instanceof RegExp&&_(we.attributeNameCheck,t)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(t))||"is"===t&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&_(we.tagNameCheck,s)||we.tagNameCheck instanceof Function&&we.tagNameCheck(s))))return!1}else if(Ge[t]);else if(_(pe,p(s,ge,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(s,"data:")||!qe[e])if(Ce&&!_(me,p(s,ge,"")));else if(s)return!1;return!0},xt=function(e){return"annotation-xml"!==e&&f(e,fe)},At=function(e){_t("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be};let i=t.length;for(;i--;){const r=t[i],{name:o,namespaceURI:a,value:c}=r,l=nt(o);let h="value"===o?c:y(c);if(n.attrName=l,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,_t("uponSanitizeAttribute",e,n),h=n.attrValue,n.forceKeepAttr)continue;if(ft(o,e),!n.keepAttr)continue;if(!$e&&_(/\/>/i,h)){ft(o,e);continue}je&&d([ce,le,de],(e=>{h=p(h,e," ")}));const m=nt(e.nodeName);if(St(m,l,h)){if(!De||"id"!==l&&"name"!==l||(ft(o,e),h=ze+h),ee&&"object"==typeof B&&"function"==typeof B.getAttributeType)if(a);else switch(B.getAttributeType(m,l)){case"TrustedHTML":h=ee.createHTML(h);break;case"TrustedScriptURL":h=ee.createScriptURL(h)}try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),u(s.removed)}catch(e){}}}_t("afterSanitizeAttributes",e,null)},Et=function e(t){let s=null;const n=vt(t);for(_t("beforeSanitizeShadowDOM",t,null);s=n.nextNode();)_t("uponSanitizeShadowNode",s,null),wt(s)||(s.content instanceof c&&e(s.content),At(s));_t("afterSanitizeShadowDOM",t,null)};return s.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,o=null,a=null;if(Ye=!e,Ye&&(e="\x3c!--\x3e"),"string"!=typeof e&&!bt(e)){if("function"!=typeof e.toString)throw w("toString is not a function");if("string"!=typeof(e=e.toString()))throw w("dirty is not a string, aborting")}if(!s.isSupported)return e;if(Te||at(t),s.removed=[],"string"==typeof e&&(Pe=!1),Pe){if(e.nodeName){const t=nt(e.nodeName);if(!ve[t]||Se[t])throw w("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof S)n=pt("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!Oe&&!je&&!ke&&-1===e.indexOf("<"))return ee&&Me?ee.createHTML(e):e;if(n=pt(e),!n)return Oe?null:Me?te:""}n&&Ie&>(n.firstChild);const l=vt(Pe?e:n);for(;o=l.nextNode();)wt(o)||(o.content instanceof c&&Et(o.content),At(o));if(Pe)return e;if(Oe){if(Ne)for(a=ie.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return(be.shadowroot||be.shadowrootmode)&&(a=oe.call(i,a,!0)),a}let u=ke?n.outerHTML:n.innerHTML;return ke&&ve["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&_(V,n.ownerDocument.doctype.name)&&(u="\n"+u),je&&d([ce,le,de],(e=>{u=p(u,e," ")})),ee&&Me?ee.createHTML(u):u},s.setConfig=function(){at(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Te=!0},s.clearConfig=function(){it=null,Te=!1},s.isValidAttribute=function(e,t,s){it||at({});const n=nt(e),i=nt(t);return St(n,i,s)},s.addHook=function(e,t){"function"==typeof t&&(ae[e]=ae[e]||[],h(ae[e],t))},s.removeHook=function(e){if(ae[e])return u(ae[e])},s.removeHooks=function(e){ae[e]&&(ae[e]=[])},s.removeAllHooks=function(){ae={}},s}return X()}()},5838:(e,t)=>{var s,n;n=function(e){"use strict";e=e||{};var t,s,n,i,r,o,a,c,l,d,u,h,m,g,f={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1,element:null,dataUrl:!1,win:window};(h={}).ff="undefined"!=typeof InstallTrigger,h.chrome=!!window.chrome,h.opera=!!window.opera||navigator.userAgent.indexOf("Opera")>=0,h.ie=!1,h.safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,h.supported=h.chrome||h.ff||h.opera;var p=[];u=function(){},c=!1;var v={ready:function(){c=!0,v.reset(),u()},reset:function(){c&&(p=[],l=!1,d=!1,o.clearRect(0,0,i,n),o.drawImage(a,0,0,i,n),_.setIcon(r),window.clearTimeout(m),window.clearTimeout(void 0))},start:function(){if(c&&!d&&p.length>0){d=!0;var e=function(){["type","animation","bgColor","textColor","fontFamily","fontStyle"].forEach((function(e){e in p[0].options&&(t[e]=p[0].options[e])})),x.run(p[0].options,(function(){l=p[0],d=!1,p.length>0&&(p.shift(),v.start())}),!1)};l?x.run(l.options,(function(){e()}),!0):e()}}},y={},b=function(e){return e.n="number"==typeof e.n?Math.abs(0|e.n):e.n,e.x=i*e.x,e.y=n*e.y,e.w=i*e.w,e.h=n*e.h,e.len=(""+e.n).length,e};y.circle=function(e){var s=!1;2===(e=b(e)).len?(e.x=e.x-.4*e.w,e.w=1.4*e.w,s=!0):e.len>=3&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,s=!0),o.clearRect(0,0,i,n),o.drawImage(a,0,0,i,n),o.beginPath(),o.font=t.fontStyle+" "+Math.floor(e.h*(e.n>99?.85:1))+"px "+t.fontFamily,o.textAlign="center",s?(o.moveTo(e.x+e.w/2,e.y),o.lineTo(e.x+e.w-e.h/2,e.y),o.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w,e.y+e.h/2),o.lineTo(e.x+e.w,e.y+e.h-e.h/2),o.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w-e.h/2,e.y+e.h),o.lineTo(e.x+e.h/2,e.y+e.h),o.quadraticCurveTo(e.x,e.y+e.h,e.x,e.y+e.h-e.h/2),o.lineTo(e.x,e.y+e.h/2),o.quadraticCurveTo(e.x,e.y,e.x+e.h/2,e.y)):o.arc(e.x+e.w/2,e.y+e.h/2,e.h/2,0,2*Math.PI),o.fillStyle="rgba("+t.bgColor.r+","+t.bgColor.g+","+t.bgColor.b+","+e.o+")",o.fill(),o.closePath(),o.beginPath(),o.stroke(),o.fillStyle="rgba("+t.textColor.r+","+t.textColor.g+","+t.textColor.b+","+e.o+")","number"==typeof e.n&&e.n>999?o.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):o.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),o.closePath()},y.rectangle=function(e){2===(e=b(e)).len?(e.x=e.x-.4*e.w,e.w=1.4*e.w):e.len>=3&&(e.x=e.x-.65*e.w,e.w=1.65*e.w),o.clearRect(0,0,i,n),o.drawImage(a,0,0,i,n),o.beginPath(),o.font=t.fontStyle+" "+Math.floor(e.h*(e.n>99?.9:1))+"px "+t.fontFamily,o.textAlign="center",o.fillStyle="rgba("+t.bgColor.r+","+t.bgColor.g+","+t.bgColor.b+","+e.o+")",o.fillRect(e.x,e.y,e.w,e.h),o.fillStyle="rgba("+t.textColor.r+","+t.textColor.g+","+t.textColor.b+","+e.o+")","number"==typeof e.n&&e.n>999?o.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):o.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),o.closePath()};var _={};function w(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,s,n){return t+t+s+s+n+n}));var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return!!t&&{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function S(e,t){var s,n={};for(s in e)n[s]=e[s];for(s in t)n[s]=t[s];return n}_.getIcons=function(){var e=[];return t.element?e=[t.element]:t.elementId?(e=[g.getElementById(t.elementId)])[0].setAttribute("href",e[0].getAttribute("src")):0===(e=function(){for(var e=[],t=g.getElementsByTagName("head")[0].getElementsByTagName("link"),s=0;s=0?(y[t.type](S(e,o[i])),m=setTimeout((function(){n?i-=1:i+=1,x.run(e,s,n,i)}),x.duration),_.setIcon(r)):s()},function(){(t=S(f,e)).bgColor=w(t.bgColor),t.textColor=w(t.textColor),t.position=t.position.toLowerCase(),t.animation=x.types[""+t.animation]?t.animation:f.animation,g=t.win.document;var c=t.position.indexOf("up")>-1,l=t.position.indexOf("left")>-1;if(c||l)for(var d in x.types)for(var u=0;u0?a.height:32,i=a.width>0?a.width:32,r.height=n,r.width=i,o=r.getContext("2d"),v.ready()},a.setAttribute("src",m.getAttribute("href"))):(n=32,i=32,a.height=n,a.width=i,r.height=n,r.width=i,o=r.getContext("2d"),v.ready())}(),{badge:function(e,t){t=("string"==typeof t?{animation:t}:t)||{},u=function(){try{if("number"==typeof e?e>0:""!==e){var s={type:"badge",options:{n:e}};if("animation"in t&&x.types[""+t.animation]&&(s.options.animation=""+t.animation),"type"in t&&y[""+t.type]&&(s.options.type=""+t.type),["bgColor","textColor"].forEach((function(e){e in t&&(s.options[e]=w(t[e]))})),["fontStyle","fontFamily"].forEach((function(e){e in t&&(s.options[e]=t[e])})),p.push(s),p.length>100)throw new Error("Too many badges requests in queue.");v.start()}else v.reset()}catch(e){throw new Error("Error setting badge. Message: "+e.message)}},c&&u()},setOpt:function(e,s){var n=e;null==s&&"[object Object]"==Object.prototype.toString.call(e)||((n={})[e]=s);for(var i=Object.keys(n),r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deinterlace=void 0;t.deinterlace=function(e,t){for(var s=new Array(e.length),n=e.length/t,i=function(n,i){var r=e.slice(i*t,(i+1)*t);s.splice.apply(s,[n*t,t].concat(r))},r=[0,4,2,1],o=[8,8,4,2],a=0,c=0;c<4;c++)for(var l=r[c];l{"use strict";t.Ud=t.O5=void 0;var n,i=(n=s(4857))&&n.__esModule?n:{default:n},r=s(4088),o=s(3715),a=s(3077),c=s(7158);t.O5=function(e){var t=new Uint8Array(e);return(0,r.parse)((0,o.buildStream)(t),i.default)};var l=function(e,t,s){if(e.image){var n=e.image,i=n.descriptor.width*n.descriptor.height,r=(0,c.lzw)(n.data.minCodeSize,n.data.blocks,i);n.descriptor.lct.interlaced&&(r=(0,a.deinterlace)(r,n.descriptor.width));var o={pixels:r,dims:{top:e.image.descriptor.top,left:e.image.descriptor.left,width:e.image.descriptor.width,height:e.image.descriptor.height}};return n.descriptor.lct&&n.descriptor.lct.exists?o.colorTable=n.lct:o.colorTable=t,e.gce&&(o.delay=10*(e.gce.delay||10),o.disposalType=e.gce.extras.disposal,e.gce.extras.transparentColorGiven&&(o.transparentIndex=e.gce.transparentColorIndex)),s&&(o.patch=function(e){for(var t=e.pixels.length,s=new Uint8ClampedArray(4*t),n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lzw=void 0;t.lzw=function(e,t,s){var n,i,r,o,a,c,l,d,u,h,m,g,f,p,v,y,b=4096,_=s,w=new Array(s),S=new Array(b),x=new Array(b),A=new Array(4097);for(a=(i=1<<(h=e))+1,n=i+2,l=-1,r=(1<<(o=h+1))-1,d=0;d>=o,g-=o,d>n||d==a)break;if(d==i){r=(1<<(o=h+1))-1,n=i+2,l=-1;continue}if(-1==l){A[p++]=x[d],l=d,f=d;continue}for(c=d,d==n&&(A[p++]=f,d=l);d>i;)A[p++]=x[d],d=S[d];f=255&x[d],A[p++]=f,n{"use strict";var n,i,r=s.g.MutationObserver||s.g.WebKitMutationObserver;if(r){var o=0,a=new r(u),c=s.g.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=o=++o%2}}else if(s.g.setImmediate||void 0===s.g.MessageChannel)n="document"in s.g&&"onreadystatechange"in s.g.document.createElement("script")?function(){var e=s.g.document.createElement("script");e.onreadystatechange=function(){u(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},s.g.document.documentElement.appendChild(e)}:function(){setTimeout(u,0)};else{var l=new s.g.MessageChannel;l.port1.onmessage=u,n=function(){l.port2.postMessage(0)}}var d=[];function u(){var e,t;i=!0;for(var s=d.length;s;){for(t=d,d=[],e=-1;++eo.length?(this.options.missing_key_callback&&this.options.missing_key_callback(l,e),a=[s,n],!0===this.options.debug&&console.log(a[h(f)(i)]),a[h()(i)]):(a=o[c])||(a=[s,n])[h()(i)]}});var g,f,p=function(){function e(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function t(e,t){for(var s=[];t>0;s[--t]=e);return s.join("")}var s=function(){return s.cache.hasOwnProperty(arguments[0])||(s.cache[arguments[0]]=s.parse(arguments[0])),s.format.call(null,s.cache[arguments[0]],arguments)};return s.format=function(s,n){var i,r,o,a,c,l,d,u=1,h=s.length,m="",g=[];for(r=0;r=0?"+"+i:i,l=a[4]?"0"==a[4]?"0":a[4].charAt(1):" ",d=a[6]-String(i).length,c=a[6]?t(l,d):"",g.push(a[5]?i+c:c+i)}return g.join("")},s.cache={},s.parse=function(e){for(var t=e,s=[],n=[],i=0;t;){if(null!==(s=/^[^\x25]+/.exec(t)))n.push(s[0]);else if(null!==(s=/^\x25{2}/.exec(t)))n.push("%");else{if(null===(s=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(t)))throw"[sprintf] huh?";if(s[2]){i|=1;var r=[],o=s[2],a=[];if(null===(a=/^([a-z_][a-z_\d]*)/i.exec(o)))throw"[sprintf] huh?";for(r.push(a[1]);""!==(o=o.substring(a[0].length));)if(null!==(a=/^\.([a-z_][a-z_\d]*)/i.exec(o)))r.push(a[1]);else{if(null===(a=/^\[(\d+)\]/.exec(o)))throw"[sprintf] huh?";r.push(a[1])}s[2]=r}else i|=2;if(3===i)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";n.push(s)}t=t.substring(s[0].length)}return n},s}();u.parse_plural=function(e,t){return e=e.replace(/n/g,t),u.parse_expression(e)},u.sprintf=function(e,t){return"[object Array]"=={}.toString.call(t)?function(e,t){return t.unshift(e),p.apply(null,t)}(e,[].slice.call(t)):p.apply(this,[].slice.call(arguments))},u.prototype.sprintf=function(){return u.sprintf.apply(this,arguments)},(u.PF={}).parse=function(e){var t=u.PF.extractPluralExpr(e);return u.PF.parser.parse.call(u.PF.parser,t)},u.PF.compile=function(e){var t=u.PF.parse(e);return function(e){return!0===(s=u.PF.interpreter(t)(e))?1:s||0;var s}},u.PF.interpreter=function(e){return function(t){switch(e.type){case"GROUP":return u.PF.interpreter(e.expr)(t);case"TERNARY":return u.PF.interpreter(e.expr)(t)?u.PF.interpreter(e.truthy)(t):u.PF.interpreter(e.falsey)(t);case"OR":return u.PF.interpreter(e.left)(t)||u.PF.interpreter(e.right)(t);case"AND":return u.PF.interpreter(e.left)(t)&&u.PF.interpreter(e.right)(t);case"LT":return u.PF.interpreter(e.left)(t)u.PF.interpreter(e.right)(t);case"LTE":return u.PF.interpreter(e.left)(t)<=u.PF.interpreter(e.right)(t);case"GTE":return u.PF.interpreter(e.left)(t)>=u.PF.interpreter(e.right)(t);case"EQ":return u.PF.interpreter(e.left)(t)==u.PF.interpreter(e.right)(t);case"NEQ":return u.PF.interpreter(e.left)(t)!=u.PF.interpreter(e.right)(t);case"MOD":return u.PF.interpreter(e.left)(t)%u.PF.interpreter(e.right)(t);case"VAR":return t;case"NUM":return e.val;default:throw new Error("Invalid Token found.")}}},u.PF.extractPluralExpr=function(e){e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,""),/;\s*$/.test(e)||(e=e.concat(";"));var t,s=/nplurals\=(\d+);/,n=e.match(s);if(!(n.length>1))throw new Error("nplurals not found in plural_forms string: "+e);if(n[1],!((t=(e=e.replace(s,"")).match(/plural\=(.*);/))&&t.length>1))throw new Error("`plural` expression not found: "+e);return t[1]},u.PF.parser=(g={trace:function(){},yy:{},symbols_:{error:2,expressions:3,e:4,EOF:5,"?":6,":":7,"||":8,"&&":9,"<":10,"<=":11,">":12,">=":13,"!=":14,"==":15,"%":16,"(":17,")":18,n:19,NUMBER:20,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"?",7:":",8:"||",9:"&&",10:"<",11:"<=",12:">",13:">=",14:"!=",15:"==",16:"%",17:"(",18:")",19:"n",20:"NUMBER"},productions_:[0,[3,2],[4,5],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,1],[4,1]],performAction:function(e,t,s,n,i,r,o){var a=r.length-1;switch(i){case 1:return{type:"GROUP",expr:r[a-1]};case 2:this.$={type:"TERNARY",expr:r[a-4],truthy:r[a-2],falsey:r[a]};break;case 3:this.$={type:"OR",left:r[a-2],right:r[a]};break;case 4:this.$={type:"AND",left:r[a-2],right:r[a]};break;case 5:this.$={type:"LT",left:r[a-2],right:r[a]};break;case 6:this.$={type:"LTE",left:r[a-2],right:r[a]};break;case 7:this.$={type:"GT",left:r[a-2],right:r[a]};break;case 8:this.$={type:"GTE",left:r[a-2],right:r[a]};break;case 9:this.$={type:"NEQ",left:r[a-2],right:r[a]};break;case 10:this.$={type:"EQ",left:r[a-2],right:r[a]};break;case 11:this.$={type:"MOD",left:r[a-2],right:r[a]};break;case 12:this.$={type:"GROUP",expr:r[a-1]};break;case 13:this.$={type:"VAR"};break;case 14:this.$={type:"NUM",val:Number(e)}}},table:[{3:1,4:2,17:[1,3],19:[1,4],20:[1,5]},{1:[3]},{5:[1,6],6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{4:17,17:[1,3],19:[1,4],20:[1,5]},{5:[2,13],6:[2,13],7:[2,13],8:[2,13],9:[2,13],10:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13],15:[2,13],16:[2,13],18:[2,13]},{5:[2,14],6:[2,14],7:[2,14],8:[2,14],9:[2,14],10:[2,14],11:[2,14],12:[2,14],13:[2,14],14:[2,14],15:[2,14],16:[2,14],18:[2,14]},{1:[2,1]},{4:18,17:[1,3],19:[1,4],20:[1,5]},{4:19,17:[1,3],19:[1,4],20:[1,5]},{4:20,17:[1,3],19:[1,4],20:[1,5]},{4:21,17:[1,3],19:[1,4],20:[1,5]},{4:22,17:[1,3],19:[1,4],20:[1,5]},{4:23,17:[1,3],19:[1,4],20:[1,5]},{4:24,17:[1,3],19:[1,4],20:[1,5]},{4:25,17:[1,3],19:[1,4],20:[1,5]},{4:26,17:[1,3],19:[1,4],20:[1,5]},{4:27,17:[1,3],19:[1,4],20:[1,5]},{6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[1,28]},{6:[1,7],7:[1,29],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{5:[2,3],6:[2,3],7:[2,3],8:[2,3],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[2,4],9:[2,4],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[2,5],12:[2,5],13:[2,5],14:[2,5],15:[2,5],16:[1,16],18:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[2,6],12:[2,6],13:[2,6],14:[2,6],15:[2,6],16:[1,16],18:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[2,7],12:[2,7],13:[2,7],14:[2,7],15:[2,7],16:[1,16],18:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[1,16],18:[2,8]},{5:[2,9],6:[2,9],7:[2,9],8:[2,9],9:[2,9],10:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[1,16],18:[2,9]},{5:[2,10],6:[2,10],7:[2,10],8:[2,10],9:[2,10],10:[2,10],11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[2,10],16:[1,16],18:[2,10]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11],15:[2,11],16:[2,11],18:[2,11]},{5:[2,12],6:[2,12],7:[2,12],8:[2,12],9:[2,12],10:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12],15:[2,12],16:[2,12],18:[2,12]},{4:30,17:[1,3],19:[1,4],20:[1,5]},{5:[2,2],6:[1,7],7:[2,2],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,2]}],defaultActions:{6:[2,1]},parseError:function(e,t){throw new Error(e)},parse:function(e){var t=this,s=[0],n=[null],i=[],r=this.table,o="",a=0,c=0,l=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var d=this.lexer.yylloc;function u(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}i.push(d),"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var h,m,g,f,p,v,y,b,_,w,S={};;){if(g=s[s.length-1],this.defaultActions[g]?f=this.defaultActions[g]:(null==h&&(h=u()),f=r[g]&&r[g][h]),void 0===f||!f.length||!f[0]){if(!l){for(v in _=[],r[g])this.terminals_[v]&&v>2&&_.push("'"+this.terminals_[v]+"'");var x="";x=this.lexer.showPosition?"Parse error on line "+(a+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+_.join(", ")+", got '"+this.terminals_[h]+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==h?"end of input":"'"+(this.terminals_[h]||h)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[h]||h,line:this.lexer.yylineno,loc:d,expected:_})}if(3==l){if(1==h)throw new Error(x||"Parsing halted.");c=this.lexer.yyleng,o=this.lexer.yytext,a=this.lexer.yylineno,d=this.lexer.yylloc,h=u()}for(;!(2..toString()in r[g]);){if(0==g)throw new Error(x||"Parsing halted.");w=1,s.length=s.length-2*w,n.length=n.length-w,i.length=i.length-w,g=s[s.length-1]}m=h,h=2,f=r[g=s[s.length-1]]&&r[g][2],l=3}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+h);switch(f[0]){case 1:s.push(h),n.push(this.lexer.yytext),i.push(this.lexer.yylloc),s.push(f[1]),h=null,m?(h=m,m=null):(c=this.lexer.yyleng,o=this.lexer.yytext,a=this.lexer.yylineno,d=this.lexer.yylloc,l>0&&l--);break;case 2:if(y=this.productions_[f[1]][1],S.$=n[n.length-y],S._$={first_line:i[i.length-(y||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(y||1)].first_column,last_column:i[i.length-1].last_column},void 0!==(p=this.performAction.call(S,o,c,a,this.yy,f[1],n,i)))return p;y&&(s=s.slice(0,-1*y*2),n=n.slice(0,-1*y),i=i.slice(0,-1*y)),s.push(this.productions_[f[1]][0]),n.push(S.$),i.push(S._$),b=r[s[s.length-2]][s[s.length-1]],s.push(b);break;case 3:return!0}}return!0}},f=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parseError)throw new Error(e);this.yy.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.match+=e,this.matched+=e,e.match(/\n/)&&this.yylineno++,this._input=this._input.slice(1),e},unput:function(e){return this._input=e+this._input,this},more:function(){return this._more=!0,this},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;var e,t;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),n=0;n=/,/^/,/^!=/,/^==/,/^%/,/^\(/,/^\)/,/^$/,/^./],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],inclusive:!0}}};return e}(),g.lexer=f,g),e.exports&&(t=e.exports=u),t.Jed=u}()},4088:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.loop=t.conditional=t.parse=void 0;t.parse=function e(t,s){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(Array.isArray(s))s.forEach((function(s){return e(t,s,n,i)}));else if("function"==typeof s)s(t,n,i,e);else{var r=Object.keys(s)[0];Array.isArray(s[r])?(i[r]={},e(t,s[r],n,i[r])):i[r]=s[r](t,n,i,e)}return n};t.conditional=function(e,t){return function(s,n,i,r){t(s,n,i)&&r(s,e,n,i)}};t.loop=function(e,t){return function(s,n,i,r){for(var o=[],a=s.pos;t(s,n,i);){var c={};if(r(s,e,n,c),s.pos===a)break;a=s.pos,o.push(c)}return o}}},3715:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readBits=t.readArray=t.readUnsigned=t.readString=t.peekBytes=t.readBytes=t.peekByte=t.readByte=t.buildStream=void 0;t.buildStream=function(e){return{data:e,pos:0}};var s=function(){return function(e){return e.data[e.pos++]}};t.readByte=s;t.peekByte=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(t){return t.data[t.pos+e]}};var n=function(e){return function(t){return t.data.subarray(t.pos,t.pos+=e)}};t.readBytes=n;t.peekBytes=function(e){return function(t){return t.data.subarray(t.pos,t.pos+e)}};t.readString=function(e){return function(t){return Array.from(n(e)(t)).map((function(e){return String.fromCharCode(e)})).join("")}};t.readUnsigned=function(e){return function(t){var s=n(2)(t);return e?(s[1]<<8)+s[0]:(s[0]<<8)+s[1]}};t.readArray=function(e,t){return function(s,i,r){for(var o="function"==typeof t?t(s,i,r):t,a=n(e),c=new Array(o),l=0;l{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(4088),i=s(3715),r={blocks:function(e){for(var t=[],s=e.data.length,n=0,r=(0,i.readByte)()(e);0!==r&&r;r=(0,i.readByte)()(e)){if(e.pos+r>=s){var o=s-e.pos;t.push((0,i.readBytes)(o)(e)),n+=o;break}t.push((0,i.readBytes)(r)(e)),n+=r}for(var a=new Uint8Array(n),c=0,l=0;l{"use strict";var n=s(1066);function i(){}var r={},o=["REJECTED"],a=["FULFILLED"],c=["PENDING"];function l(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==i&&m(this,e)}function d(e,t,s){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof s&&(this.onRejected=s,this.callRejected=this.otherCallRejected)}function u(e,t,s){n((function(){var n;try{n=t(s)}catch(t){return r.reject(e,t)}n===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,n)}))}function h(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function m(e,t){var s=!1;function n(t){s||(s=!0,r.reject(e,t))}function i(t){s||(s=!0,r.resolve(e,t))}var o=g((function(){t(i,n)}));"error"===o.status&&n(o.value)}function g(e,t){var s={};try{s.value=e(t),s.status="success"}catch(e){s.status="error",s.value=e}return s}e.exports=l,l.prototype.catch=function(e){return this.then(null,e)},l.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var s=new this.constructor(i);this.state!==c?u(s,this.state===a?e:t,this.outcome):this.queue.push(new d(s,e,t));return s},d.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){r.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},r.resolve=function(e,t){var s=g(h,t);if("error"===s.status)return r.reject(e,s.value);var n=s.value;if(n)m(e,n);else{e.state=a,e.outcome=t;for(var i=-1,o=e.queue.length;++i{"use strict";"function"!=typeof s.g.Promise&&(s.g.Promise=s(5641))},8781:function(e,t){"undefined"!=typeof self&&self,function(e){"use strict";var t="localforage-driver-memory";function s(e){var t="function"==typeof Symbol&&e[Symbol.iterator],s=0;return t?t.call(e):{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}}}function n(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var s=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),n=0;n>4,i[o++]=(15&c)<<4|l>>2,i[o++]=(3&l)<<6|63&d}return n}function l(e){for(var t=new Uint8Array(e),s="",n=0;n>2],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&t[n])<<4|t[n+1]>>4],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&t[n+1])<<2|t[n+2]>>6],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t[n+2]];return t.length%3==2?s=s.substring(0,s.length-1)+"=":t.length%3==1&&(s=s.substring(0,s.length-2)+"=="),s}function d(e,t){var s="";if(e&&(s=a.call(e)),e&&("[object ArrayBuffer]"===s||e.buffer&&"[object ArrayBuffer]"===a.call(e.buffer))){var n=void 0,i="__lfsc__:";e instanceof ArrayBuffer?(n=e,i+="arbf"):(n=e.buffer,"[object Int8Array]"===s?i+="si08":"[object Uint8Array]"===s?i+="ui08":"[object Uint8ClampedArray]"===s?i+="uic8":"[object Int16Array]"===s?i+="si16":"[object Uint16Array]"===s?i+="ur16":"[object Int32Array]"===s?i+="si32":"[object Uint32Array]"===s?i+="ui32":"[object Float32Array]"===s?i+="fl32":"[object Float64Array]"===s?i+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(i+l(n))}else if("[object Blob]"===s){var r=new FileReader;r.onload=function(){var s="~~local_forage_type~"+e.type+"~"+l(this.result);t("__lfsc__:blob"+s)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(s){console.error("Couldn't convert value into a JSON string: ",e),t(null,s)}}function u(e){if("__lfsc__:"!==e.substring(0,r))return JSON.parse(e);var t,s=e.substring(o),a=e.substring(r,o);if("blob"===a&&i.test(s)){var l=s.match(i);t=l[1],s=s.substring(l[0].length)}var d=c(s);switch(a){case"arbf":return d;case"blob":return n([d],{type:t});case"si08":return new Int8Array(d);case"ui08":return new Uint8Array(d);case"uic8":return new Uint8ClampedArray(d);case"si16":return new Int16Array(d);case"ur16":return new Uint16Array(d);case"si32":return new Int32Array(d);case"ui32":return new Uint32Array(d);case"fl32":return new Float32Array(d);case"fl64":return new Float64Array(d);default:throw new Error("Unkown type: "+a)}}function h(e){var t,n;if(null===e||"object"!=typeof e||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var r=s(Object.keys(e)),o=r.next();!o.done;o=r.next()){var a=o.value;Object.prototype.hasOwnProperty.call(e,a)&&(e.isActiveClone=null,i[a]=h(e[a]),delete e.isActiveClone)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return i}function m(e,t){return(e.name||t.name)+"/"+(e.storeName||t.storeName)+"/"}function g(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function f(){for(var e=[],t=0;t{"use strict";var n=s(4602);Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var s=(0,a.getStorage)(),n=!(!s||!s[t]),c=n?s[t]:{clear:function(){},get:function(){},remove:function(){},set:function(){}},l=c.clear.bind(c),d=c.get.bind(c),u=c.remove.bind(c),h=c.set.bind(c);return{_driver:e,_support:n,_initStorage:function(){return Promise.resolve()},clear:function(e){return(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:l(),e&&e();case 2:case"end":return t.stop()}}),t)})))()},iterate:function(e,t){return(0,o.default)(i.default.mark((function s(){var n;return i.default.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,(0,a.usePromise)(d,null);case 2:n=s.sent,Object.keys(n).forEach((function(t,s){return e(n[t],t,s)})),t&&t();case 6:case"end":return s.stop()}}),s)})))()},getItem:function(e,t){return(0,o.default)(i.default.mark((function s(){var n;return i.default.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.prev=0,s.next=3,(0,a.usePromise)(d,e);case 3:return n=s.sent,n=void 0===(n="string"==typeof e?n[e]:n)?null:n,t&&t(null,n),s.abrupt("return",n);case 10:throw s.prev=10,s.t0=s.catch(0),t&&t(s.t0),s.t0;case 14:case"end":return s.stop()}}),s,null,[[0,10]])})))()},key:function(e,t){return(0,o.default)(i.default.mark((function s(){var n,r;return i.default.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,(0,a.usePromise)(d,null);case 2:return n=s.sent,r=Object.keys(n)[e],t&&t(r),s.abrupt("return",r);case 6:case"end":return s.stop()}}),s)})))()},keys:function(e){return(0,o.default)(i.default.mark((function t(){var s,n;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,a.usePromise)(d,null);case 2:return s=t.sent,n=Object.keys(s),e&&e(n),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t)})))()},length:function(e){return(0,o.default)(i.default.mark((function t(){var s,n,r;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,a.usePromise)(d,null);case 2:return s=t.sent,n=Object.keys(s),r=n.length,e&&e(r),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})))()},removeItem:function(e,t){return(0,o.default)(i.default.mark((function s(){return i.default.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,(0,a.usePromise)(u,e);case 2:t&&t();case 3:case"end":return s.stop()}}),s)})))()},setItem:function(e,t,s){return(0,o.default)(i.default.mark((function n(){return i.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,(0,a.usePromise)(h,(0,r.default)({},e,t));case 2:s&&s();case 3:case"end":return n.stop()}}),n)})))()}}};var i=n(s(460)),r=n(s(2485)),o=n(s(6597)),a=s(9513)},4103:(e,t,s)=>{"use strict";var n=s(4602);t.A=void 0;var i=(0,n(s(8372)).default)("webExtensionLocalStorage","local");t.A=i},6245:(e,t,s)=>{"use strict";var n=s(4602);t.A=void 0;var i=(0,n(s(8372)).default)("webExtensionSyncStorage","sync");t.A=i},9513:(e,t)=>{"use strict";function s(){return"undefined"!=typeof browser&&browser.storage||"undefined"!=typeof chrome&&chrome.storage}Object.defineProperty(t,"__esModule",{value:!0}),t.getStorage=s,t.usePromise=function(e,t){if(function(){var e=s();try{return e&&e.local.get&&e.local.get()&&"function"==typeof e.local.get().then}catch(e){return!1}}())return e(t);return new Promise((function(s){e(t,(function(){s.apply(void 0,arguments)}))}))}},9214:(e,t,s)=>{e.exports=function e(t,s,n){function i(o,a){if(!s[o]){if(!t[o]){if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=s[o]={exports:{}};t[o][0].call(l.exports,(function(e){var s=t[o][1][e];return i(s||e)}),l,l.exports,e,t,s,n)}return s[o].exports}for(var r=void 0,o=0;o=43)}})).catch((function(){return!1}))}function S(e){return"boolean"==typeof f?l.resolve(f):w(e).then((function(e){return f=e}))}function x(e){var t=p[e.name],s={};s.promise=new l((function(e,t){s.resolve=e,s.reject=t})),t.deferredOperations.push(s),t.dbReady?t.dbReady=t.dbReady.then((function(){return s.promise})):t.dbReady=s.promise}function A(e){var t=p[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function E(e,t){var s=p[e.name].deferredOperations.pop();if(s)return s.reject(t),s.promise}function C(e,t){return new l((function(s,n){if(p[e.name]=p[e.name]||D(),e.db){if(!t)return s(e.db);x(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var r=o.open.apply(o,i);t&&(r.onupgradeneeded=function(t){var s=r.result;try{s.createObjectStore(e.storeName),t.oldVersion<=1&&s.createObjectStore(g)}catch(s){if("ConstraintError"!==s.name)throw s;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),r.onerror=function(e){e.preventDefault(),n(r.error)},r.onsuccess=function(){var t=r.result;t.onversionchange=function(e){e.target.close()},s(t),A(e)}}))}function $(e){return C(e,!1)}function j(e){return C(e,!0)}function k(e,t){if(!e.db)return!0;var s=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(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||s){if(s){var r=e.db.version+1;r>e.version&&(e.version=r)}return!0}return!1}function T(e){return new l((function(t,s){var n=new FileReader;n.onerror=s,n.onloadend=function(s){var n=btoa(s.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},n.readAsBinaryString(e)}))}function I(e){return c([_(atob(e.data))],{type:e.type})}function O(e){return e&&e.__local_forage_encoded_blob}function N(e){var t=this,s=t._initReady().then((function(){var e=p[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return u(s,e,e),s}function M(e){x(e);for(var t=p[e.name],s=t.forages,n=0;n0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return l.resolve().then((function(){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),j(e)})).then((function(){return M(e).then((function(){R(e,t,s,n-1)}))})).catch(s);s(i)}}function D(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function z(e){var t=this,s={db:null};if(e)for(var n in e)s[n]=e[n];var i=p[s.name];i||(i=D(),p[s.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=N);var r=[];function o(){return l.resolve()}for(var a=0;a>4,d[c++]=(15&n)<<4|i>>2,d[c++]=(3&i)<<6|63&r;return l}function ge(e){var t,s=new Uint8Array(e),n="";for(t=0;t>2],n+=J[(3&s[t])<<4|s[t+1]>>4],n+=J[(15&s[t+1])<<2|s[t+2]>>6],n+=J[63&s[t+2]];return s.length%3==2?n=n.substring(0,n.length-1)+"=":s.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}function fe(e,t){var s="";if(e&&(s=he.call(e)),e&&("[object ArrayBuffer]"===s||e.buffer&&"[object ArrayBuffer]"===he.call(e.buffer))){var n,i=X;e instanceof ArrayBuffer?(n=e,i+=ee):(n=e.buffer,"[object Int8Array]"===s?i+=se:"[object Uint8Array]"===s?i+=ne:"[object Uint8ClampedArray]"===s?i+=ie:"[object Int16Array]"===s?i+=re:"[object Uint16Array]"===s?i+=ae:"[object Int32Array]"===s?i+=oe:"[object Uint32Array]"===s?i+=ce:"[object Float32Array]"===s?i+=le:"[object Float64Array]"===s?i+=de:t(new Error("Failed to get type for BinaryArray"))),t(i+ge(n))}else if("[object Blob]"===s){var r=new FileReader;r.onload=function(){var s=K+e.type+"~"+ge(this.result);t(X+te+s)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(s){console.error("Couldn't convert value into a JSON string: ",e),t(null,s)}}function pe(e){if(e.substring(0,Z)!==X)return JSON.parse(e);var t,s=e.substring(ue),n=e.substring(Z,ue);if(n===te&&Y.test(s)){var i=s.match(Y);t=i[1],s=s.substring(i[0].length)}var r=me(s);switch(n){case ee:return r;case te:return c([r],{type:t});case se:return new Int8Array(r);case ne:return new Uint8Array(r);case ie:return new Uint8ClampedArray(r);case re:return new Int16Array(r);case ae:return new Uint16Array(r);case oe:return new Int32Array(r);case ce:return new Uint32Array(r);case le:return new Float32Array(r);case de:return new Float64Array(r);default:throw new Error("Unkown type: "+n)}}var ve={serialize:fe,deserialize:pe,stringToBuffer:me,bufferToString:ge};function ye(e,t,s,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],s,n)}function be(e){var t=this,s={db:null};if(e)for(var n in e)s[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new l((function(e,n){try{s.db=openDatabase(s.name,String(s.version),s.description,s.size)}catch(e){return n(e)}s.db.transaction((function(i){ye(i,s,(function(){t._dbInfo=s,e()}),(function(e,t){n(t)}))}),n)}));return s.serializer=ve,i}function _e(e,t,s,n,i,r){e.executeSql(s,n,i,(function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?r(e,o):ye(e,t,(function(){e.executeSql(s,n,i,r)}),r)}),r):r(e,o)}),r)}function we(e,t){var s=this;e=h(e);var n=new l((function(t,n){s.ready().then((function(){var i=s._dbInfo;i.db.transaction((function(s){_e(s,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,s){var n=s.rows.length?s.rows.item(0).value:null;n&&(n=i.serializer.deserialize(n)),t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,t),n}function Se(e,t){var s=this,n=new l((function(t,n){s.ready().then((function(){var i=s._dbInfo;i.db.transaction((function(s){_e(s,i,"SELECT * FROM "+i.storeName,[],(function(s,n){for(var r=n.rows,o=r.length,a=0;a0)return void r(xe.apply(i,[e,a,s,n-1]));o(t)}}))}))})).catch(o)}));return d(r,s),r}function Ae(e,t,s){return xe.apply(this,[e,t,s,1])}function Ee(e,t){var s=this;e=h(e);var n=new l((function(t,n){s.ready().then((function(){var i=s._dbInfo;i.db.transaction((function(s){_e(s,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,t),n}function Ce(e){var t=this,s=new l((function(e,s){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){_e(t,n,"DELETE FROM "+n.storeName,[],(function(){e()}),(function(e,t){s(t)}))}))})).catch(s)}));return d(s,e),s}function $e(e){var t=this,s=new l((function(e,s){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){_e(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],(function(t,s){var n=s.rows.item(0).c;e(n)}),(function(e,t){s(t)}))}))})).catch(s)}));return d(s,e),s}function je(e,t){var s=this,n=new l((function(t,n){s.ready().then((function(){var i=s._dbInfo;i.db.transaction((function(s){_e(s,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,s){var n=s.rows.length?s.rows.item(0).key:null;t(n)}),(function(e,t){n(t)}))}))})).catch(n)}));return d(n,t),n}function ke(e){var t=this,s=new l((function(e,s){t.ready().then((function(){var n=t._dbInfo;n.db.transaction((function(t){_e(t,n,"SELECT key FROM "+n.storeName,[],(function(t,s){for(var n=[],i=0;i '__WebKitDatabaseInfoTable__'",[],(function(s,n){for(var i=[],r=0;r0}function ze(e){var t=this,s={};if(e)for(var n in e)s[n]=e[n];return s.keyPrefix=Me(e,t._defaultConfig),De()?(t._dbInfo=s,s.serializer=ve,l.resolve()):l.reject()}function Le(e){var t=this,s=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,s=localStorage.length-1;s>=0;s--){var n=localStorage.key(s);0===n.indexOf(e)&&localStorage.removeItem(n)}}));return d(s,e),s}function Pe(e,t){var s=this;e=h(e);var n=s.ready().then((function(){var t=s._dbInfo,n=localStorage.getItem(t.keyPrefix+e);return n&&(n=t.serializer.deserialize(n)),n}));return d(n,t),n}function Ue(e,t){var s=this,n=s.ready().then((function(){for(var t=s._dbInfo,n=t.keyPrefix,i=n.length,r=localStorage.length,o=1,a=0;a=0;t--){var s=localStorage.key(t);0===s.indexOf(e)&&localStorage.removeItem(s)}})):l.reject("Invalid arguments"),d(n,t),n}var Ve={_driver:"localStorageWrapper",_initStorage:ze,_support:Ne(),iterate:Ue,getItem:Pe,setItem:Ge,removeItem:He,clear:Le,length:qe,key:Fe,keys:Be,dropInstance:We},Qe=function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)},Je=function(e,t){for(var s=e.length,n=0;n{var n;!function(i){var r,o,a,c,l,d,u,h,m,g,f,p,v,y,b,_,w,S,x,A="sizzle"+1*new Date,E=i.document,C=0,$=0,j=he(),k=he(),T=he(),I=he(),O=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,M=[],R=M.pop,D=M.push,z=M.push,L=M.slice,P=function(e,t){for(var s=0,n=e.length;s+~]|"+F+")"+F+"*"),J=new RegExp(F+"|>"),K=new RegExp(H),Y=new RegExp("^"+B+"$"),X={ID:new RegExp("^#("+B+")"),CLASS:new RegExp("^\\.("+B+")"),TAG:new RegExp("^("+B+"|[*])"),ATTR:new RegExp("^"+q),PSEUDO:new RegExp("^"+H),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+F+"*(even|odd|(([+-]|)(\\d*)n|)"+F+"*(?:([+-]|)"+F+"*(\\d+)|))"+F+"*\\)|)","i"),bool:new RegExp("^(?:"+U+")$","i"),needsContext:new RegExp("^"+F+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+F+"*((?:-\\d)?\\d*)"+F+"*\\)|)(?=[^-]|$)","i")},Z=/HTML$/i,ee=/^(?:input|select|textarea|button)$/i,te=/^h\d$/i,se=/^[^{]+\{\s*\[native \w/,ne=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ie=/[+~]/,re=new RegExp("\\\\[\\da-fA-F]{1,6}"+F+"?|\\\\([^\\r\\n\\f])","g"),oe=function(e,t){var s="0x"+e.slice(1)-65536;return t||(s<0?String.fromCharCode(s+65536):String.fromCharCode(s>>10|55296,1023&s|56320))},ae=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ce=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},le=function(){p()},de=Ae((function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()}),{dir:"parentNode",next:"legend"});try{z.apply(M=L.call(E.childNodes),E.childNodes),M[E.childNodes.length].nodeType}catch(e){z={apply:M.length?function(e,t){D.apply(e,L.call(t))}:function(e,t){for(var s=e.length,n=0;e[s++]=t[n++];);e.length=s-1}}}function ue(e,t,s,n){var i,r,a,c,l,u,m,g=t&&t.ownerDocument,f=t?t.nodeType:9;if(s=s||[],"string"!=typeof e||!e||1!==f&&9!==f&&11!==f)return s;if(!n&&(p(t),t=t||v,b)){if(11!==f&&(l=ne.exec(e)))if(i=l[1]){if(9===f){if(!(a=t.getElementById(i)))return s;if(a.id===i)return s.push(a),s}else if(g&&(a=g.getElementById(i))&&x(t,a)&&a.id===i)return s.push(a),s}else{if(l[2])return z.apply(s,t.getElementsByTagName(e)),s;if((i=l[3])&&o.getElementsByClassName&&t.getElementsByClassName)return z.apply(s,t.getElementsByClassName(i)),s}if(o.qsa&&!I[e+" "]&&(!_||!_.test(e))&&(1!==f||"object"!==t.nodeName.toLowerCase())){if(m=e,g=t,1===f&&(J.test(e)||Q.test(e))){for((g=ie.test(e)&&we(t.parentNode)||t)===t&&o.scope||((c=t.getAttribute("id"))?c=c.replace(ae,ce):t.setAttribute("id",c=A)),r=(u=d(e)).length;r--;)u[r]=(c?"#"+c:":scope")+" "+xe(u[r]);m=u.join(",")}try{return z.apply(s,g.querySelectorAll(m)),s}catch(t){I(e,!0)}finally{c===A&&t.removeAttribute("id")}}}return h(e.replace(W,"$1"),t,s,n)}function he(){var e=[];return function t(s,n){return e.push(s+" ")>a.cacheLength&&delete t[e.shift()],t[s+" "]=n}}function me(e){return e[A]=!0,e}function ge(e){var t=v.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){for(var s=e.split("|"),n=s.length;n--;)a.attrHandle[s[n]]=t}function pe(e,t){var s=t&&e,n=s&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(n)return n;if(s)for(;s=s.nextSibling;)if(s===t)return-1;return e?1:-1}function ve(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function ye(e){return function(t){var s=t.nodeName.toLowerCase();return("input"===s||"button"===s)&&t.type===e}}function be(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&de(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function _e(e){return me((function(t){return t=+t,me((function(s,n){for(var i,r=e([],s.length,t),o=r.length;o--;)s[i=r[o]]&&(s[i]=!(n[i]=s[i]))}))}))}function we(e){return e&&void 0!==e.getElementsByTagName&&e}for(r in o=ue.support={},l=ue.isXML=function(e){var t=e&&e.namespaceURI,s=e&&(e.ownerDocument||e).documentElement;return!Z.test(t||s&&s.nodeName||"HTML")},p=ue.setDocument=function(e){var t,s,n=e?e.ownerDocument||e:E;return n!=v&&9===n.nodeType&&n.documentElement?(y=(v=n).documentElement,b=!l(v),E!=v&&(s=v.defaultView)&&s.top!==s&&(s.addEventListener?s.addEventListener("unload",le,!1):s.attachEvent&&s.attachEvent("onunload",le)),o.scope=ge((function(e){return y.appendChild(e).appendChild(v.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length})),o.cssHas=ge((function(){try{return v.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}})),o.attributes=ge((function(e){return e.className="i",!e.getAttribute("className")})),o.getElementsByTagName=ge((function(e){return e.appendChild(v.createComment("")),!e.getElementsByTagName("*").length})),o.getElementsByClassName=se.test(v.getElementsByClassName),o.getById=ge((function(e){return y.appendChild(e).id=A,!v.getElementsByName||!v.getElementsByName(A).length})),o.getById?(a.filter.ID=function(e){var t=e.replace(re,oe);return function(e){return e.getAttribute("id")===t}},a.find.ID=function(e,t){if(void 0!==t.getElementById&&b){var s=t.getElementById(e);return s?[s]:[]}}):(a.filter.ID=function(e){var t=e.replace(re,oe);return function(e){var s=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return s&&s.value===t}},a.find.ID=function(e,t){if(void 0!==t.getElementById&&b){var s,n,i,r=t.getElementById(e);if(r){if((s=r.getAttributeNode("id"))&&s.value===e)return[r];for(i=t.getElementsByName(e),n=0;r=i[n++];)if((s=r.getAttributeNode("id"))&&s.value===e)return[r]}return[]}}),a.find.TAG=o.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):o.qsa?t.querySelectorAll(e):void 0}:function(e,t){var s,n=[],i=0,r=t.getElementsByTagName(e);if("*"===e){for(;s=r[i++];)1===s.nodeType&&n.push(s);return n}return r},a.find.CLASS=o.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&b)return t.getElementsByClassName(e)},w=[],_=[],(o.qsa=se.test(v.querySelectorAll))&&(ge((function(e){var t;y.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&_.push("[*^$]="+F+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||_.push("\\["+F+"*(?:value|"+U+")"),e.querySelectorAll("[id~="+A+"-]").length||_.push("~="),(t=v.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||_.push("\\["+F+"*name"+F+"*="+F+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||_.push(":checked"),e.querySelectorAll("a#"+A+"+*").length||_.push(".#.+[+~]"),e.querySelectorAll("\\\f"),_.push("[\\r\\n\\f]")})),ge((function(e){e.innerHTML="";var t=v.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&_.push("name"+F+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&_.push(":enabled",":disabled"),y.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&_.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),_.push(",.*:")}))),(o.matchesSelector=se.test(S=y.matches||y.webkitMatchesSelector||y.mozMatchesSelector||y.oMatchesSelector||y.msMatchesSelector))&&ge((function(e){o.disconnectedMatch=S.call(e,"*"),S.call(e,"[s!='']:x"),w.push("!=",H)})),o.cssHas||_.push(":has"),_=_.length&&new RegExp(_.join("|")),w=w.length&&new RegExp(w.join("|")),t=se.test(y.compareDocumentPosition),x=t||se.test(y.contains)?function(e,t){var s=9===e.nodeType&&e.documentElement||e,n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(s.contains?s.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},O=t?function(e,t){if(e===t)return f=!0,0;var s=!e.compareDocumentPosition-!t.compareDocumentPosition;return s||(1&(s=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!o.sortDetached&&t.compareDocumentPosition(e)===s?e==v||e.ownerDocument==E&&x(E,e)?-1:t==v||t.ownerDocument==E&&x(E,t)?1:g?P(g,e)-P(g,t):0:4&s?-1:1)}:function(e,t){if(e===t)return f=!0,0;var s,n=0,i=e.parentNode,r=t.parentNode,o=[e],a=[t];if(!i||!r)return e==v?-1:t==v?1:i?-1:r?1:g?P(g,e)-P(g,t):0;if(i===r)return pe(e,t);for(s=e;s=s.parentNode;)o.unshift(s);for(s=t;s=s.parentNode;)a.unshift(s);for(;o[n]===a[n];)n++;return n?pe(o[n],a[n]):o[n]==E?-1:a[n]==E?1:0},v):v},ue.matches=function(e,t){return ue(e,null,null,t)},ue.matchesSelector=function(e,t){if(p(e),o.matchesSelector&&b&&!I[t+" "]&&(!w||!w.test(t))&&(!_||!_.test(t)))try{var s=S.call(e,t);if(s||o.disconnectedMatch||e.document&&11!==e.document.nodeType)return s}catch(e){I(t,!0)}return ue(t,v,null,[e]).length>0},ue.contains=function(e,t){return(e.ownerDocument||e)!=v&&p(e),x(e,t)},ue.attr=function(e,t){(e.ownerDocument||e)!=v&&p(e);var s=a.attrHandle[t.toLowerCase()],n=s&&N.call(a.attrHandle,t.toLowerCase())?s(e,t,!b):void 0;return void 0!==n?n:o.attributes||!b?e.getAttribute(t):(n=e.getAttributeNode(t))&&n.specified?n.value:null},ue.escape=function(e){return(e+"").replace(ae,ce)},ue.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ue.uniqueSort=function(e){var t,s=[],n=0,i=0;if(f=!o.detectDuplicates,g=!o.sortStable&&e.slice(0),e.sort(O),f){for(;t=e[i++];)t===e[i]&&(n=s.push(i));for(;n--;)e.splice(s[n],1)}return g=null,e},c=ue.getText=function(e){var t,s="",n=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)s+=c(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[n++];)s+=c(t);return s},a=ue.selectors={cacheLength:50,createPseudo:me,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(re,oe),e[3]=(e[3]||e[4]||e[5]||"").replace(re,oe),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ue.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ue.error(e[0]),e},PSEUDO:function(e){var t,s=!e[6]&&e[2];return X.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":s&&K.test(s)&&(t=d(s,!0))&&(t=s.indexOf(")",s.length-t)-s.length)&&(e[0]=e[0].slice(0,t),e[2]=s.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(re,oe).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=j[e+" "];return t||(t=new RegExp("(^|"+F+")"+e+"("+F+"|$)"))&&j(e,(function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,t,s){return function(n){var i=ue.attr(n,e);return null==i?"!="===t:!t||(i+="","="===t?i===s:"!="===t?i!==s:"^="===t?s&&0===i.indexOf(s):"*="===t?s&&i.indexOf(s)>-1:"$="===t?s&&i.slice(-s.length)===s:"~="===t?(" "+i.replace(G," ")+" ").indexOf(s)>-1:"|="===t&&(i===s||i.slice(0,s.length+1)===s+"-"))}},CHILD:function(e,t,s,n,i){var r="nth"!==e.slice(0,3),o="last"!==e.slice(-4),a="of-type"===t;return 1===n&&0===i?function(e){return!!e.parentNode}:function(t,s,c){var l,d,u,h,m,g,f=r!==o?"nextSibling":"previousSibling",p=t.parentNode,v=a&&t.nodeName.toLowerCase(),y=!c&&!a,b=!1;if(p){if(r){for(;f;){for(h=t;h=h[f];)if(a?h.nodeName.toLowerCase()===v:1===h.nodeType)return!1;g=f="only"===e&&!g&&"nextSibling"}return!0}if(g=[o?p.firstChild:p.lastChild],o&&y){for(b=(m=(l=(d=(u=(h=p)[A]||(h[A]={}))[h.uniqueID]||(u[h.uniqueID]={}))[e]||[])[0]===C&&l[1])&&l[2],h=m&&p.childNodes[m];h=++m&&h&&h[f]||(b=m=0)||g.pop();)if(1===h.nodeType&&++b&&h===t){d[e]=[C,m,b];break}}else if(y&&(b=m=(l=(d=(u=(h=t)[A]||(h[A]={}))[h.uniqueID]||(u[h.uniqueID]={}))[e]||[])[0]===C&&l[1]),!1===b)for(;(h=++m&&h&&h[f]||(b=m=0)||g.pop())&&((a?h.nodeName.toLowerCase()!==v:1!==h.nodeType)||!++b||(y&&((d=(u=h[A]||(h[A]={}))[h.uniqueID]||(u[h.uniqueID]={}))[e]=[C,b]),h!==t)););return(b-=i)===n||b%n==0&&b/n>=0}}},PSEUDO:function(e,t){var s,n=a.pseudos[e]||a.setFilters[e.toLowerCase()]||ue.error("unsupported pseudo: "+e);return n[A]?n(t):n.length>1?(s=[e,e,"",t],a.setFilters.hasOwnProperty(e.toLowerCase())?me((function(e,s){for(var i,r=n(e,t),o=r.length;o--;)e[i=P(e,r[o])]=!(s[i]=r[o])})):function(e){return n(e,0,s)}):n}},pseudos:{not:me((function(e){var t=[],s=[],n=u(e.replace(W,"$1"));return n[A]?me((function(e,t,s,i){for(var r,o=n(e,null,i,[]),a=e.length;a--;)(r=o[a])&&(e[a]=!(t[a]=r))})):function(e,i,r){return t[0]=e,n(t,null,r,s),t[0]=null,!s.pop()}})),has:me((function(e){return function(t){return ue(e,t).length>0}})),contains:me((function(e){return e=e.replace(re,oe),function(t){return(t.textContent||c(t)).indexOf(e)>-1}})),lang:me((function(e){return Y.test(e||"")||ue.error("unsupported lang: "+e),e=e.replace(re,oe).toLowerCase(),function(t){var s;do{if(s=b?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(s=s.toLowerCase())===e||0===s.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(e){var t=i.location&&i.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===y},focus:function(e){return e===v.activeElement&&(!v.hasFocus||v.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:be(!1),disabled:be(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!a.pseudos.empty(e)},header:function(e){return te.test(e.nodeName)},input:function(e){return ee.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:_e((function(){return[0]})),last:_e((function(e,t){return[t-1]})),eq:_e((function(e,t,s){return[s<0?s+t:s]})),even:_e((function(e,t){for(var s=0;st?t:s;--n>=0;)e.push(n);return e})),gt:_e((function(e,t,s){for(var n=s<0?s+t:s;++n1?function(t,s,n){for(var i=e.length;i--;)if(!e[i](t,s,n))return!1;return!0}:e[0]}function Ce(e,t,s,n,i){for(var r,o=[],a=0,c=e.length,l=null!=t;a-1&&(r[l]=!(o[l]=u))}}else v=Ce(v===o?v.splice(g,v.length):v),i?i(null,o,v,c):z.apply(o,v)}))}function je(e){for(var t,s,n,i=e.length,r=a.relative[e[0].type],o=r||a.relative[" "],c=r?1:0,l=Ae((function(e){return e===t}),o,!0),d=Ae((function(e){return P(t,e)>-1}),o,!0),u=[function(e,s,n){var i=!r&&(n||s!==m)||((t=s).nodeType?l(e,s,n):d(e,s,n));return t=null,i}];c1&&Ee(u),c>1&&xe(e.slice(0,c-1).concat({value:" "===e[c-2].type?"*":""})).replace(W,"$1"),s,c0,n=e.length>0,i=function(i,r,o,c,l){var d,u,h,g=0,f="0",y=i&&[],_=[],w=m,S=i||n&&a.find.TAG("*",l),x=C+=null==w?1:Math.random()||.1,A=S.length;for(l&&(m=r==v||r||l);f!==A&&null!=(d=S[f]);f++){if(n&&d){for(u=0,r||d.ownerDocument==v||(p(d),o=!b);h=e[u++];)if(h(d,r||v,o)){c.push(d);break}l&&(C=x)}s&&((d=!h&&d)&&g--,i&&y.push(d))}if(g+=f,s&&f!==g){for(u=0;h=t[u++];)h(y,_,r,o);if(i){if(g>0)for(;f--;)y[f]||_[f]||(_[f]=R.call(c));_=Ce(_)}z.apply(c,_),l&&!i&&_.length>0&&g+t.length>1&&ue.uniqueSort(c)}return l&&(C=x,m=w),y};return s?me(i):i}(i,n)),r.selector=e}return r},h=ue.select=function(e,t,s,n){var i,r,o,c,l,h="function"==typeof e&&e,m=!n&&d(e=h.selector||e);if(s=s||[],1===m.length){if((r=m[0]=m[0].slice(0)).length>2&&"ID"===(o=r[0]).type&&9===t.nodeType&&b&&a.relative[r[1].type]){if(!(t=(a.find.ID(o.matches[0].replace(re,oe),t)||[])[0]))return s;h&&(t=t.parentNode),e=e.slice(r.shift().value.length)}for(i=X.needsContext.test(e)?0:r.length;i--&&(o=r[i],!a.relative[c=o.type]);)if((l=a.find[c])&&(n=l(o.matches[0].replace(re,oe),ie.test(r[0].type)&&we(t.parentNode)||t))){if(r.splice(i,1),!(e=n.length&&xe(r)))return z.apply(s,n),s;break}}return(h||u(e,m))(n,t,!b,s,!t||ie.test(e)&&we(t.parentNode)||t),s},o.sortStable=A.split("").sort(O).join("")===A,o.detectDuplicates=!!f,p(),o.sortDetached=ge((function(e){return 1&e.compareDocumentPosition(v.createElement("fieldset"))})),ge((function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")}))||fe("type|href|height|width",(function(e,t,s){if(!s)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)})),o.attributes&&ge((function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")}))||fe("value",(function(e,t,s){if(!s&&"input"===e.nodeName.toLowerCase())return e.defaultValue})),ge((function(e){return null==e.getAttribute("disabled")}))||fe(U,(function(e,t,s){var n;if(!s)return!0===e[t]?t.toLowerCase():(n=e.getAttributeNode(t))&&n.specified?n.value:null}));var ke=i.Sizzle;ue.noConflict=function(){return i.Sizzle===ue&&(i.Sizzle=ke),ue},void 0===(n=function(){return ue}.call(t,s,t,e))||(e.exports=n)}(window)},5072:e=>{"use strict";var t=[];function s(e){for(var s=-1,n=0;n{"use strict";var t={};e.exports=function(e,s){var n=function(e){if(void 0===t[e]){var s=document.querySelector(e);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(e){s=null}t[e]=s}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(s)}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},5056:(e,t,s)=>{"use strict";e.exports=function(e){var t=s.nc;t&&e.setAttribute("nonce",t)}},7825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(s){!function(e,t,s){var n="";s.supports&&(n+="@supports (".concat(s.supports,") {")),s.media&&(n+="@media ".concat(s.media," {"));var i=void 0!==s.layer;i&&(n+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),n+=s.css,i&&(n+="}"),s.media&&(n+="}"),s.supports&&(n+="}");var r=s.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,s)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},1113:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},3883:(e,t,s)=>{var n={"./af/LC_MESSAGES/converse.po":[5544,4267],"./ar/LC_MESSAGES/converse.po":[788,5743],"./be/LC_MESSAGES/converse.po":[9174,1437],"./bg/LC_MESSAGES/converse.po":[9088,6179],"./ca/LC_MESSAGES/converse.po":[6929,962],"./cs/LC_MESSAGES/converse.po":[4359,8252],"./da/LC_MESSAGES/converse.po":[1712,6963],"./de/LC_MESSAGES/converse.po":[7532,6311],"./el/LC_MESSAGES/converse.po":[6202,345],"./eo/LC_MESSAGES/converse.po":[7653,7494],"./es/LC_MESSAGES/converse.po":[8209,4202],"./eu/LC_MESSAGES/converse.po":[4147,2168],"./fa/LC_MESSAGES/converse.po":[4750,453],"./fi/LC_MESSAGES/converse.po":[6742,3613],"./fr/LC_MESSAGES/converse.po":[2889,3698],"./gl/LC_MESSAGES/converse.po":[2504,2787],"./he/LC_MESSAGES/converse.po":[5424,8227],"./hi/LC_MESSAGES/converse.po":[7140,799],"./hu/LC_MESSAGES/converse.po":[1520,9139],"./id/LC_MESSAGES/converse.po":[4326,4749],"./it/LC_MESSAGES/converse.po":[8854,6109],"./ja/LC_MESSAGES/converse.po":[762,3881],"./lt/LC_MESSAGES/converse.po":[8261,1462],"./mr/LC_MESSAGES/converse.po":[4632,507],"./nb/LC_MESSAGES/converse.po":[6529,9562],"./nl/LC_MESSAGES/converse.po":[347,4336],"./nl_BE/LC_MESSAGES/converse.po":[2361,290],"./oc/LC_MESSAGES/converse.po":[107,7576],"./pl/LC_MESSAGES/converse.po":[2993,7370],"./pt/LC_MESSAGES/converse.po":[3385,2546],"./pt_BR/LC_MESSAGES/converse.po":[3096,4315],"./ro/LC_MESSAGES/converse.po":[9576,1963],"./ru/LC_MESSAGES/converse.po":[6166,6733],"./si/LC_MESSAGES/converse.po":[8553,8714],"./sq/LC_MESSAGES/converse.po":[8785,4146],"./sv/LC_MESSAGES/converse.po":[6850,6345],"./th/LC_MESSAGES/converse.po":[3161,3330],"./tr/LC_MESSAGES/converse.po":[9815,548],"./ug/LC_MESSAGES/converse.po":[1661,2894],"./uk/LC_MESSAGES/converse.po":[3689,8898],"./vi/LC_MESSAGES/converse.po":[358,221],"./zh_CN/LC_MESSAGES/converse.po":[5645,6550],"./zh_TW/LC_MESSAGES/converse.po":[5097,8986]};function i(e){if(!s.o(n,e))return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=n[e],i=t[0];return s.e(t[1]).then((()=>s.t(i,19)))}i.keys=()=>Object.keys(n),i.id=3883,e.exports=i},6597:e=>{function t(e,t,s,n,i,r,o){try{var a=e[r](o),c=a.value}catch(e){return void s(e)}a.done?t(c):Promise.resolve(c).then(n,i)}e.exports=function(e){return function(){var s=this,n=arguments;return new Promise((function(i,r){var o=e.apply(s,n);function a(e){t(o,i,r,a,c,"next",e)}function c(e){t(o,i,r,a,c,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},2485:(e,t,s)=>{var n=s(1344);e.exports=function(e,t,s){return(t=n(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e},e.exports.__esModule=!0,e.exports.default=e.exports},4602:e=>{e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},2081:(e,t,s)=>{var n=s(5410).default;function i(){"use strict";e.exports=i=function(){return s},e.exports.__esModule=!0,e.exports.default=e.exports;var t,s={},r=Object.prototype,o=r.hasOwnProperty,a=Object.defineProperty||function(e,t,s){e[t]=s.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",u=c.toStringTag||"@@toStringTag";function h(e,t,s){return Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,s){return e[t]=s}}function m(e,t,s,n){var i=t&&t.prototype instanceof _?t:_,r=Object.create(i.prototype),o=new N(n||[]);return a(r,"_invoke",{value:k(e,s,o)}),r}function g(e,t,s){try{return{type:"normal",arg:e.call(t,s)}}catch(e){return{type:"throw",arg:e}}}s.wrap=m;var f="suspendedStart",p="suspendedYield",v="executing",y="completed",b={};function _(){}function w(){}function S(){}var x={};h(x,l,(function(){return this}));var A=Object.getPrototypeOf,E=A&&A(A(M([])));E&&E!==r&&o.call(E,l)&&(x=E);var C=S.prototype=_.prototype=Object.create(x);function $(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function j(e,t){function s(i,r,a,c){var l=g(e[i],e,r);if("throw"!==l.type){var d=l.arg,u=d.value;return u&&"object"==n(u)&&o.call(u,"__await")?t.resolve(u.__await).then((function(e){s("next",e,a,c)}),(function(e){s("throw",e,a,c)})):t.resolve(u).then((function(e){d.value=e,a(d)}),(function(e){return s("throw",e,a,c)}))}c(l.arg)}var i;a(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,i){s(e,n,t,i)}))}return i=i?i.then(r,r):r()}})}function k(e,s,n){var i=f;return function(r,o){if(i===v)throw Error("Generator is already running");if(i===y){if("throw"===r)throw o;return{value:t,done:!0}}for(n.method=r,n.arg=o;;){var a=n.delegate;if(a){var c=T(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var l=g(e,s,n);if("normal"===l.type){if(i=n.done?y:p,l.arg===b)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=y,n.method="throw",n.arg=l.arg)}}}function T(e,s){var n=s.method,i=e.iterator[n];if(i===t)return s.delegate=null,"throw"===n&&e.iterator.return&&(s.method="return",s.arg=t,T(e,s),"throw"===s.method)||"return"!==n&&(s.method="throw",s.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var r=g(i,e.iterator,s.arg);if("throw"===r.type)return s.method="throw",s.arg=r.arg,s.delegate=null,b;var o=r.arg;return o?o.done?(s[e.resultName]=o.value,s.next=e.nextLoc,"return"!==s.method&&(s.method="next",s.arg=t),s.delegate=null,b):o:(s.method="throw",s.arg=new TypeError("iterator result is not an object"),s.delegate=null,b)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function M(e){if(e||""===e){var s=e[l];if(s)return s.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function s(){for(;++i=0;--i){var r=this.tryEntries[i],a=r.completion;if("root"===r.tryLoc)return n("end");if(r.tryLoc<=this.prev){var c=o.call(r,"catchLoc"),l=o.call(r,"finallyLoc");if(c&&l){if(this.prev=0;--s){var n=this.tryEntries[s];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--t){var s=this.tryEntries[t];if(s.finallyLoc===e)return this.complete(s.completion,s.afterLoc),O(s),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var s=this.tryEntries[t];if(s.tryLoc===e){var n=s.completion;if("throw"===n.type){var i=n.arg;O(s)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,s,n){return this.delegate={iterator:M(e),resultName:s,nextLoc:n},"next"===this.method&&(this.arg=t),b}},s}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},3517:(e,t,s)=>{var n=s(5410).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var i=s.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},1344:(e,t,s)=>{var n=s(5410).default,i=s(3517);e.exports=function(e){var t=i(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},5410:e=>{function t(s){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},460:(e,t,s)=>{var n=s(2081)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var s=r[e]={id:e,loaded:!1,exports:{}};return i[e].call(s.exports,s,s.exports,o),s.loaded=!0,s.exports}o.m=i,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(s,n){if(1&n&&(s=this(s)),8&n)return s;if("object"==typeof s&&s){if(4&n&&s.__esModule)return s;if(16&n&&"function"==typeof s.then)return s}var i=Object.create(null);o.r(i);var r={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&s;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>r[e]=()=>s[e]));return r.default=()=>s,o.d(i,r),i},o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,s)=>(o.f[s](e,t),t)),[])),o.u=e=>({7:"locales/dayjs/nb-js",131:"locales/dayjs/ar-sa-js",138:"locales/dayjs/tzm-latn-js",221:"locales/vi-LC_MESSAGES-converse-po",290:"locales/nl_BE-LC_MESSAGES-converse-po",345:"locales/el-LC_MESSAGES-converse-po",385:"locales/dayjs/et-js",422:"locales/dayjs/tk-js",453:"locales/fa-LC_MESSAGES-converse-po",507:"locales/mr-LC_MESSAGES-converse-po",548:"locales/tr-LC_MESSAGES-converse-po",561:"locales/dayjs/my-js",591:"locales/dayjs/es-mx-js",598:"locales/dayjs/fa-js",687:"locales/dayjs/ku-js",799:"locales/hi-LC_MESSAGES-converse-po",832:"locales/dayjs/ta-js",861:"locales/dayjs/ar-kw-js",933:"locales/dayjs/eu-js",948:"locales/dayjs/uz-js",962:"locales/ca-LC_MESSAGES-converse-po",1056:"locales/dayjs/mn-js",1072:"locales/dayjs/bg-js",1116:"locales/dayjs/bs-js",1275:"locales/dayjs/nn-js",1373:"locales/dayjs/lb-js",1388:"locales/dayjs/ur-js",1437:"locales/be-LC_MESSAGES-converse-po",1462:"locales/lt-LC_MESSAGES-converse-po",1464:"locales/dayjs/bo-js",1665:"locales/dayjs/en-ie-js",1696:"locales/dayjs/ar-ly-js",1712:"locales/dayjs/hu-js",1719:"locales/dayjs/oc-lnc-js",1827:"locales/dayjs/es-js",1938:"locales/dayjs/bi-js",1963:"locales/ro-LC_MESSAGES-converse-po",1982:"locales/dayjs/sv-js",2014:"locales/dayjs/pt-br-js",2091:"locales/dayjs/ms-js",2168:"locales/eu-LC_MESSAGES-converse-po",2241:"locales/dayjs/hr-js",2366:"locales/dayjs/be-js",2384:"locales/dayjs/he-js",2389:"locales/dayjs/sw-js",2546:"locales/pt-LC_MESSAGES-converse-po",2643:"locales/dayjs/br-js",2664:"locales/dayjs/pa-in-js",2766:"locales/dayjs/cv-js",2769:"locales/dayjs/ss-js",2787:"locales/gl-LC_MESSAGES-converse-po",2856:"locales/dayjs/es-pr-js",2894:"locales/ug-LC_MESSAGES-converse-po",2974:"emojis",2993:"locales/dayjs/dv-js",3014:"locales/dayjs/mt-js",3166:"locales/dayjs/fi-js",3287:"locales/dayjs/km-js",3330:"locales/th-LC_MESSAGES-converse-po",3341:"locales/dayjs/en-sg-js",3359:"locales/dayjs/is-js",3519:"locales/dayjs/rn-js",3613:"locales/fi-LC_MESSAGES-converse-po",3664:"locales/dayjs/sd-js",3683:"locales/dayjs/tzl-js",3698:"locales/fr-LC_MESSAGES-converse-po",3729:"locales/dayjs/mi-js",3731:"locales/dayjs/ug-cn-js",3741:"locales/dayjs/ar-dz-js",3774:"locales/dayjs/vi-js",3881:"locales/ja-LC_MESSAGES-converse-po",4034:"locales/dayjs/it-js",4094:"locales/dayjs/en-gb-js",4107:"locales/dayjs/uk-js",4146:"locales/sq-LC_MESSAGES-converse-po",4182:"locales/dayjs/es-us-js",4202:"locales/es-LC_MESSAGES-converse-po",4260:"locales/dayjs/mr-js",4267:"locales/af-LC_MESSAGES-converse-po",4315:"locales/pt_BR-LC_MESSAGES-converse-po",4333:"locales/dayjs/me-js",4336:"locales/nl-LC_MESSAGES-converse-po",4385:"locales/dayjs/zh-cn-js",4434:"locales/dayjs/ja-js",4497:"locales/dayjs/zh-js",4512:"locales/dayjs/ms-my-js",4523:"locales/dayjs/ka-js",4584:"locales/dayjs/ro-js",4636:"locales/dayjs/te-js",4718:"locales/dayjs/it-ch-js",4749:"locales/id-LC_MESSAGES-converse-po",4770:"locales/dayjs/id-js",4852:"locales/dayjs/hi-js",4858:"locales/dayjs/sr-js",4859:"locales/dayjs/lt-js",4974:"locales/dayjs/kn-js",5036:"locales/dayjs/de-js",5059:"locales/dayjs/mk-js",5284:"locales/dayjs/gd-js",5534:"locales/dayjs/de-at-js",5611:"locales/dayjs/en-ca-js",5628:"locales/dayjs/af-js",5724:"locales/dayjs/gl-js",5743:"locales/ar-LC_MESSAGES-converse-po",5790:"locales/dayjs/x-pseudo-js",5825:"locales/dayjs/cs-js",5946:"locales/dayjs/ne-js",5970:"locales/dayjs/uz-latn-js",5998:"locales/dayjs/ml-js",6007:"locales/dayjs/ht-js",6042:"locales/dayjs/lo-js",6064:"locales/dayjs/de-ch-js",6109:"locales/it-LC_MESSAGES-converse-po",6121:"locales/dayjs/en-au-js",6124:"locales/dayjs/bn-bd-js",6179:"locales/bg-LC_MESSAGES-converse-po",6191:"locales/dayjs/pt-js",6208:"locales/dayjs/da-js",6311:"locales/de-LC_MESSAGES-converse-po",6343:"locales/dayjs/pl-js",6345:"locales/sv-LC_MESSAGES-converse-po",6486:"locales/dayjs/bm-js",6537:"locales/dayjs/sk-js",6550:"locales/zh_CN-LC_MESSAGES-converse-po",6605:"locales/dayjs/ar-iq-js",6641:"locales/dayjs/kk-js",6655:"locales/dayjs/th-js",6660:"locales/dayjs/sv-fi-js",6733:"locales/ru-LC_MESSAGES-converse-po",6803:"locales/dayjs/yo-js",6824:"locales/dayjs/en-js",6963:"locales/da-LC_MESSAGES-converse-po",7003:"locales/dayjs/cy-js",7013:"locales/dayjs/zh-hk-js",7028:"locales/dayjs/en-in-js",7370:"locales/pl-LC_MESSAGES-converse-po",7385:"locales/dayjs/ar-ma-js",7491:"locales/dayjs/ky-js",7494:"locales/eo-LC_MESSAGES-converse-po",7497:"locales/dayjs/nl-js",7576:"locales/oc-LC_MESSAGES-converse-po",7596:"locales/dayjs/fo-js",7627:"locales/dayjs/en-tt-js",7743:"locales/dayjs/ga-js",7801:"locales/dayjs/ar-tn-js",7806:"locales/dayjs/ru-js",7962:"locales/dayjs/tg-js",7981:"locales/dayjs/zh-tw-js",8022:"locales/dayjs/tl-ph-js",8031:"locales/dayjs/eo-js",8176:"locales/dayjs/rw-js",8178:"locales/dayjs/en-il-js",8227:"locales/he-LC_MESSAGES-converse-po",8232:"locales/dayjs/sl-js",8252:"locales/cs-LC_MESSAGES-converse-po",8343:"locales/dayjs/en-nz-js",8431:"locales/dayjs/fr-js",8443:"locales/dayjs/gu-js",8489:"locales/dayjs/am-js",8592:"locales/dayjs/tet-js",8630:"locales/dayjs/gom-latn-js",8714:"locales/si-LC_MESSAGES-converse-po",8789:"locales/dayjs/ko-js",8880:"locales/dayjs/ar-js",8898:"locales/uk-LC_MESSAGES-converse-po",8945:"locales/dayjs/tlh-js",8986:"locales/zh_TW-LC_MESSAGES-converse-po",9007:"locales/dayjs/jv-js",9052:"locales/dayjs/tzm-js",9080:"locales/dayjs/az-js",9101:"locales/dayjs/fr-ch-js",9109:"locales/dayjs/nl-be-js",9139:"locales/hu-LC_MESSAGES-converse-po",9271:"locales/dayjs/es-do-js",9331:"locales/dayjs/sr-cyrl-js",9395:"locales/dayjs/ca-js",9411:"locales/dayjs/sq-js",9423:"locales/dayjs/bn-js",9547:"locales/dayjs/si-js",9557:"locales/dayjs/tr-js",9562:"locales/nb-LC_MESSAGES-converse-po",9589:"locales/dayjs/hy-am-js",9593:"locales/dayjs/lv-js",9710:"locales/dayjs/fy-js",9782:"locales/dayjs/el-js",9870:"locales/dayjs/fr-ca-js",9975:"locales/dayjs/se-js"}[e]+".js"),o.miniCssF=e=>{},o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},n="converse.js:",o.l=(e,t,i,r)=>{if(s[e])s[e].push(t);else{var a,c;if(void 0!==i)for(var l=document.getElementsByTagName("script"),d=0;d{a.onerror=a.onload=null,clearTimeout(m);var i=s[e];if(delete s[e],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((e=>e(n))),t)return t(n)},m=setTimeout(h.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=h.bind(null,a.onerror),a.onload=h.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),o.p="/dist/",(()=>{var e={50:0,6968:0};o.f.j=(t,s)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)s.push(n[2]);else{var i=new Promise(((s,i)=>n=e[t]=[s,i]));s.push(n[2]=i);var r=o.p+o.u(t),a=new Error;o.l(r,(s=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=s&&("load"===s.type?"missing":s.type),r=s&&s.target&&s.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+r+")",a.name="ChunkLoadError",a.type=i,a.request=r,n[1](a)}}),"chunk-"+t,t)}};var t=(t,s)=>{var n,i,[r,a,c]=s,l=0;if(r.some((t=>0!==e[t]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(c)c(o)}for(t&&t(s);l{"use strict";const e={},t={plugins:{add(t,s){if(void 0!==e[t])throw new TypeError(`Error: plugin with name "${t}" has already been registered!`);e[t]=s}},initialize:(e={})=>t.load(e).initialize(e),load:(s={})=>(s.assets_path&&(o.p=s.assets_path),o(3945),Object.keys(e).forEach((s=>t.plugins.add(s,e[s]))),t)};window.converse=t;const s=new CustomEvent("converse-loaded",{detail:{converse:t}});window.dispatchEvent(s)})()})(); //# sourceMappingURL=converse.min.js.map