Skip to content
Snippets Groups Projects
Commit 40561be3 authored by Xavier Ferrer de la Penyita's avatar Xavier Ferrer de la Penyita
Browse files

fix scroll exception

parent 79c04acf
No related branches found
No related tags found
2 merge requests!64Fix scroll exception,!63Mentions, badges, moderation ghost separators
......@@ -474,7 +474,7 @@ const Fm=function(e){this.views={},this.keys=()=>Object.keys(this.views),this.ge
* @module converse-chatview
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/const{Strophe:Av,dayjs:Cv}=Yc.env,jv=Yc.env.utils,Tv=Bd.extend({length:200,className:"chatbox hidden",is_chatroom:!1,events:{"click .chatbox-navback":"showControlBox","click .new-msgs-indicator":"viewUnreadMessages","click .send-button":"onFormSubmitted","click .toggle-clear":"clearMessages","input .chat-textarea":"inputChanged","keydown .chat-textarea":"onKeyDown","keyup .chat-textarea":"onKeyUp","paste .chat-textarea":"onPaste"},async initialize(){this.initDebounced(),this.listenTo(this.model,"change:composing_spoiler",this.renderMessageForm),this.listenTo(this.model,"change:hidden",e=>e.get("hidden")?this.hide():this.show()),this.listenTo(this.model,"change:status",this.onStatusMessageChanged),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"show",this.show),this.listenTo(this.model,"vcard:change",this.renderHeading),this.model.contact&&this.listenTo(this.model.contact,"destroy",this.renderHeading),this.model.rosterContactAdded&&this.model.rosterContactAdded.then(()=>{this.listenTo(this.model.contact,"change:nickname",this.renderHeading),this.renderHeading()}),this.listenTo(this.model.presence,"change:show",this.onPresenceChanged),this.render(),this.listenTo(this.model.messages,"add",this.onMessageAdded),this.listenTo(this.model.messages,"remove",this.renderChatHistory),this.listenTo(this.model.messages,"rendered",this.maybeScrollDown),this.listenTo(this.model.messages,"reset",this.renderChatHistory),this.listenTo(this.model.notifications,"change",this.renderNotifications),this.listenTo(this.model,"change:show_help_messages",this.renderHelpMessages),await this.updateAfterMessagesFetched(),this.model.maybeShow(),qc.trigger("chatBoxViewInitialized",this)},initDebounced(){this.markScrolled=Tc(this._markScrolled,100),this.debouncedScrollDown=Tc(this.scrollDown,100),qc.settings.get("debounced_content_rendering")?(this.renderChatHistory=Tc(()=>this.renderChatContent(!1),100),this.renderNotifications=Tc(()=>this.renderChatContent(!0),100)):(this.renderChatHistory=()=>this.renderChatContent(!1),this.renderNotifications=()=>this.renderChatContent(!0))},render(){const e=Qm(Object.assign(this.model.toJSON(),{markScrolled:e=>this.markScrolled(e)}));return Wa(e,this.el),this.content=this.el.querySelector(".chat-content"),this.notifications=this.el.querySelector(".chat-content__notifications"),this.msgs_container=this.el.querySelector(".chat-content__messages"),this.help_container=this.el.querySelector(".chat-content__help"),this.renderChatContent(),this.renderMessageForm(),this.renderHeading(),this},onMessageAdded(e){this.renderChatHistory(),jv.isNewMessage(e)&&("me"===e.get("sender")?this.model.set("scrolled",!1):this.model.get("scrolled",!0)&&this.showNewMessagesIndicator())},getNotifications(){return this.model.notifications.get("chat_state")===Lc.COMPOSING?Ed("%1$s is typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Lc.PAUSED?Ed("%1$s has stopped typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Lc.GONE?Ed("%1$s has gone away",this.model.getDisplayName()):""},getHelpMessages:()=>["<strong>/clear</strong>: ".concat(Ed("Remove messages")),"<strong>/close</strong>: ".concat(Ed("Close this chat")),"<strong>/me</strong>: ".concat(Ed("Write in the third person")),"<strong>/help</strong>: ".concat(Ed("Show this menu"))],renderHelpMessages(){Wa(Ga(xv(),this.model,this.getHelpMessages(),!this.model.get("show_help_messages"),this.model.get("type")),this.help_container)},renderChatContent(e=!1){this.tpl_chat_content||(this.tpl_chat_content=e=>Ga(Sv(),this,e.messages,e.notifications));const t=this.model.messages.models,n=e?t:Array.from(t);Wa(this.tpl_chat_content({messages:n,notifications:this.getNotifications()}),this.msgs_container)},renderToolbar(){if(!qc.settings.get("show_toolbar"))return this;const e=Object.assign({model:this.model,chatview:this},this.model.toJSON(),this.getToolbarOptions());return Wa((e=>{const t=qc.settings.get("message_limit"),n=qc.settings.get("visible_toolbar_buttons").call,r=qc.settings.get("visible_toolbar_buttons").emoji,i=qc.settings.get("show_send_button"),s=qc.settings.get("visible_toolbar_buttons").spoiler,o=qc.settings.get("show_toolbar");return Ga(sv(),e.chatview,e.model,e.composing_spoiler,e.hidden_occupants,e.is_groupchat,n,r,e.show_occupants_toggle,i,s,o,t)})(e),this.el.querySelector(".chat-toolbar")),qc.trigger("renderToolbar",this),this},renderMessageForm(){var e,t;const n=this.el.querySelector(".message-form-container");var r;Wa((r=Object.assign(this.model.toJSON(),{hint_value:null===(e=this.el.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,label_message:this.model.get("composing_spoiler")?Ed("Hidden message"):Ed("Message"),label_spoiler_hint:Ed("Optional hint"),message_value:null===(t=this.el.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,show_send_button:qc.settings.get("show_send_button"),show_toolbar:qc.settings.get("show_toolbar"),unread_msgs:Ed("You have unread messages")}),Ga(iv(),r.unread_msgs,r.label_spoiler_hint||"",r.hint_value||"",r.composing_spoiler?"":"hidden",r.show_send_button?"chat-textarea-send-button":"",r.composing_spoile?"spoiler":"",r.label_message,r.message_value||"")),n),this.el.addEventListener("focusin",e=>this.emitFocused(e)),this.el.addEventListener("focusout",e=>this.emitBlurred(e)),this.renderToolbar()},showControlBox(){Lc.chatboxviews.get("controlbox").show(),this.hide()},showUserDetailsModal(e){e.preventDefault(),void 0===this.user_details_modal&&(this.user_details_modal=new Lc.UserDetailsModal({model:this.model})),this.user_details_modal.show(e)},onDragOver(e){e.preventDefault()},onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))},async renderHeading(){const e=await this.generateHeadingTemplate();Wa(e,this.el.querySelector(".chat-head-chatbox"))},async getHeadingStandaloneButton(e){const t=await e;return Ga(wv(),t.a_class,t.icon_class,t.handler,t.i18n_title)},async getHeadingDropdownItem(e){const t=await e;return Ga(yv(),t.a_class,t.handler,t.i18n_title,t.icon_class,t.i18n_text)},async generateHeadingTemplate(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{},r=await this.getHeadingButtons(),i=r.filter(e=>e.standalone),s=r.filter(e=>!e.standalone);return(e=>{const t={alt_text:Ed("The User's Profile Image"),extra_classes:"",height:40,width:40};return Ga(nv(),e.status?"":"chatbox-title--no-desc",e._converse.api.settings.get("singleton")?"":Ga(tv()),e.type!==e._converse.HEADLINES_TYPE?Ga(ev(),If(Object.assign({},e,t))):"",e.jid,e.url?Ga(Zm(),e.url,e.display_name):e.display_name,e.dropdown_btns.length?Ga(Km(),e.dropdown_btns):"",e.standalone_btns.length?(e=>e.standalone_btns.reverse().map(e=>bh(e,"")))(e):"",e.status?Ga(Ym(),e.status):"")})(Object.assign(n,this.model.toJSON(),{_converse:Lc,dropdown_btns:s.map(e=>this.getHeadingDropdownItem(e)),standalone_btns:i.map(e=>this.getHeadingStandaloneButton(e)),display_name:this.model.getDisplayName()}))},getHeadingButtons(){const e=[{a_class:"show-user-details-modal",handler:e=>this.showUserDetailsModal(e),i18n_text:Ed("Details"),i18n_title:Ed("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===qc.settings.get("view_mode")}];return qc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:Ed("Close"),i18n_title:Ed("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===qc.settings.get("view_mode")}),Lc.api.hook("getHeadingButtons",this,e)},getToolbarOptions:()=>({}),async updateAfterMessagesFetched(){await this.model.messages.fetched,this.renderChatContent(),this.insertIntoDOM(),this.scrollDown(),qc.trigger("afterMessagesFetched",this.model)},maybeScrollDown(e){!(!(null==e?void 0:e.get("is_archived"))&&"me"===(null==e?void 0:e.get("sender")))&&this.model.get("scrolled")||this.model.isHidden()||this.debouncedScrollDown()},scrollDown(e){var t,n;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.get("scrolled")&&jv.safeSave(this.model,{scrolled:!1,scrollTop:null}),this.msgs_container.scrollTo){const e=this.msgs_container.scrollTop?"smooth":"auto";this.msgs_container.scrollTo({top:this.msgs_container.scrollHeight,behavior:e})}else this.msgs_container.scrollTop=this.msgs_container.scrollHeight;this.onScrolledDown()},maintainScrollTop(){const e=this.model.get("scrollTop");e?this.msgs_container.scrollTop=e:this.scrollDown()},insertIntoDOM(){return Lc.chatboxviews.insertRowColumn(this.el),qc.trigger("chatBoxInsertedIntoDOM",this),this},addSpinner(e=!1){if(null===this.el.querySelector(".spinner")){const t=jv.getElementFromTemplateResult(qf());e?(this.content.insertAdjacentElement("beforeend",t),this.scrollDown()):this.content.insertAdjacentElement("afterbegin",t)}},clearSpinner(){this.content.querySelectorAll(".spinner").forEach(jv.removeElement)},onStatusMessageChanged(e){this.renderHeading(),qc.trigger("contactStatusMessageChanged",{contact:e.attributes,message:e.get("status")})},shouldShowOnTextMessage(){return!Lc.isUniView()&&!jv.isVisible(this.el)},markFollowups(e){const t=e.getAttribute("data-from"),n=e.previousElementSibling,r=Cv(e.getAttribute("data-isodate")),i=e.nextElementSibling;jv.hasClass("chat-msg--action",e)||jv.hasClass("chat-msg--action",n)||jv.hasClass("chat-info",e)||jv.hasClass("chat-info",n)||n.getAttribute("data-from")!==t||!r.isBefore(Cv(n.getAttribute("data-isodate")).add(10,"minutes"))||e.getAttribute("data-encrypted")!==n.getAttribute("data-encrypted")||jv.addClass("chat-msg--followup",e),i&&(!jv.hasClass("chat-msg--action",e)&&jv.hasClass("chat-info",e)&&i.getAttribute("data-from")===t&&Cv(i.getAttribute("data-isodate")).isBefore(r.add(10,"minutes"))&&e.getAttribute("data-encrypted")===i.getAttribute("data-encrypted")?jv.addClass("chat-msg--followup",i):jv.removeClass("chat-msg--followup",i))},parseMessageForCommands(e){const t=e.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(t){if("clear"===t[1])return this.clearMessages(),!0;if("close"===t[1])return this.close(),!0;if("help"===t[1])return this.model.set({show_help_messages:!0}),!0}},async onFormSubmitted(e){var t;e.preventDefault();const n=this.el.querySelector(".chat-textarea"),r=n.value.trim();if(qc.settings.get("message_limit")&&r.length>qc.settings.get("message_limit")||!r.replace(/\s/g,"").length)return;if(!Lc.connection.authenticated){const e=Ed("Sorry, the connection has been lost, and your message could not be sent");return qc.alert("error",Ed("Error"),e),void qc.connection.reconnect()}let i,s={};this.model.get("composing_spoiler")&&(s=this.el.querySelector("form.sendXMPPMessage input.spoiler-hint"),i=s.value),jv.addClass("disabled",n),n.setAttribute("disabled","disabled"),null===(t=this.el.querySelector("converse-emoji-dropdown"))||void 0===t||t.hideMenu();const o=this.parseMessageForCommands(r),a=o?null:await this.model.sendMessage(r,i);(o||a)&&(s.value="",n.value="",jv.removeClass("correcting",n),n.style.height="auto",this.updateCharCounter(n.value)),a&&qc.trigger("messageSend",a),"overlayed"===qc.settings.get("view_mode")&&(this.msgs_container.parentElement.style.display="none"),n.removeAttribute("disabled"),jv.removeClass("disabled",n),"overlayed"===qc.settings.get("view_mode")&&(this.msgs_container.parentElement.style.display=""),this.model.setChatState(Lc.ACTIVE,{silent:!0}),n.focus()},updateCharCounter(e){if(qc.settings.get("message_limit")){const t=this.el.querySelector(".message-limit"),n=qc.settings.get("message_limit")-e.length;t.textContent=n,n<1?jv.addClass("error",t):jv.removeClass("error",t)}},onPaste(e){if(0!==e.clipboardData.files.length)return e.preventDefault(),void this.model.sendFiles(Array.from(e.clipboardData.files));this.updateCharCounter(e.clipboardData.getData("text/plain"))},autocompleteInPicker(e,t){const n=this.el.querySelector("converse-emoji-dropdown"),r=this.el.querySelector("converse-emoji-picker");if(r&&n)return r.model.set({ac_position:e.selectionStart,autocompleting:t,query:t}),n.showMenu(),!0},onEmojiReceivedFromPicker(e){const t=this.el.querySelector("converse-emoji-picker").model,n=t.get("autocompleting"),r=t.get("ac_position");this.insertIntoTextArea(e,n,!1,r)},onKeyUp(e){this.updateCharCounter(e.target.value)},onKeyDown(e){if(!e.ctrlKey){if(!e.shiftKey&&!e.altKey&&!e.metaKey)if(e.keyCode===Yc.keycodes.TAB){const t=jv.getCurrentWord(e.target,null,/(:.*?:)/g);t.startsWith(":")&&this.autocompleteInPicker(e.target,t)&&(e.preventDefault(),e.stopPropagation())}else{if(e.keyCode===Yc.keycodes.FORWARD_SLASH)return;if(e.keyCode===Yc.keycodes.ESCAPE)return this.onEscapePressed(e);if(e.keyCode===Yc.keycodes.ENTER)return this.onEnterPressed(e);if(e.keyCode!==Yc.keycodes.UP_ARROW||e.target.selectionEnd){if(e.keyCode===Yc.keycodes.DOWN_ARROW&&e.target.selectionEnd===e.target.value.length&&jv.hasClass("correcting",this.el.querySelector(".chat-textarea")))return this.editLaterMessage()}else{const e=this.el.querySelector(".chat-textarea");if(!e.value||jv.hasClass("correcting",e))return this.editEarlierMessage()}}[Yc.keycodes.SHIFT,Yc.keycodes.META,Yc.keycodes.META_RIGHT,Yc.keycodes.ESCAPE,Yc.keycodes.ALT].includes(e.keyCode)||this.model.get("chat_state")!==Lc.COMPOSING&&this.model.setChatState(Lc.COMPOSING)}},getOwnMessages(){return this.model.messages.filter({sender:"me"})},onEnterPressed(e){return this.onFormSubmitted(e)},onEscapePressed(e){e.preventDefault();const t=this.model.messages.findLastIndex("correcting"),n=t>=0?this.model.messages.at(t):null;n&&n.save("correcting",!1),this.insertIntoTextArea("",!0,!1)},async onMessageRetractButtonClicked(e){if("me"!==e.get("sender"))return Pn.error("onMessageRetractButtonClicked called for someone else's message!");const t=Ed("Be aware that other XMPP/Jabber clients (and servers) may not yet support retractions and that this message may not be removed everywhere."),n=[Ed("Are you sure you want to retract this message?")];qc.settings.get("show_retraction_warning")&&(n[1]=t),await qc.confirm(Ed("Confirm"),n)&&this.model.retractOwnMessage(e)},onMessageEditButtonClicked(e){var t;const n=this.model.messages.findWhere("correcting"),r=null===(t=this.el.querySelector(".chat-textarea"))||void 0===t?void 0:t.value;(!r||n&&n.get("message")===r||confirm(Ed("You have an unsent message which will be lost if you continue. Are you sure?")))&&(n!==e?(null==n||n.save("correcting",!1),e.save("correcting",!0),this.insertIntoTextArea(jv.prefixMentions(e),!0,!0)):(e.save("correcting",!1),this.insertIntoTextArea("",!0,!1)))},editLaterMessage(){let e,t=this.model.messages.findLastIndex("correcting");if(t>=0)for(this.model.messages.at(t).save("correcting",!1);t<this.model.messages.length-1;){t+=1;const n=this.model.messages.at(t);if(n.get("editable")){e=n;break}}e?(this.insertIntoTextArea(jv.prefixMentions(e),!0,!0),e.save("correcting",!0)):this.insertIntoTextArea("",!0,!1)},editEarlierMessage(){let e,t=this.model.messages.findLastIndex("correcting");if(t>=0)for(this.model.messages.at(t).save("correcting",!1);t>0;){t-=1;const n=this.model.messages.at(t);if(n.get("editable")){e=n;break}}e=e||this.getOwnMessages().reverse().find(e=>e.get("editable")),e&&(this.insertIntoTextArea(jv.prefixMentions(e),!0,!0),e.save("correcting",!0))},inputChanged(e){const t=e.target.scrollHeight+"px";e.target.style.height!=t&&(e.target.style.height="auto",e.target.style.height=t)},async clearMessages(e){return e&&e.preventDefault&&e.preventDefault(),!0===confirm(Ed("Are you sure you want to clear the messages from this conversation?"))&&await this.model.clearMessages(),this},insertIntoTextArea(e,t=!1,n=!1,r){const i=this.el.querySelector(".chat-textarea");if(n?jv.addClass("correcting",i):jv.removeClass("correcting",i),t)i.value=r&&"string"==typeof t?i.value.replace(new RegExp(t,"g"),(n,i)=>i==r-t.length?e+" ":n):e;else{let t=i.value;t&&" "!==t[t.length-1]&&(t+=" "),i.value=t+e+" "}this.updateCharCounter(i.value),jv.placeCaretAtEnd(i)},onPresenceChanged(e){const t=e.get("show"),n=this.model.getDisplayName();let r;jv.isVisible(this.el)&&("offline"===t?r=Ed("%1$s has gone offline",n):"away"===t?r=Ed("%1$s has gone away",n):"dnd"===t?r=Ed("%1$s is busy",n):"online"===t&&(r=Ed("%1$s is online",n)),r&&this.model.createMessage({message:r,type:"info"}))},async close(e){return e&&e.preventDefault&&e.preventDefault(),Lc.router.history.getFragment()==="converse/chat?jid="+this.model.get("jid")&&Lc.router.navigate(""),qc.connection.connected()&&(this.model.setChatState(Lc.INACTIVE),this.model.sendChatState()),await this.model.close(),this.remove(),qc.trigger("chatBoxClosed",this),this},emitBlurred(e){this.el.contains(document.activeElement)||this.el.contains(e.relatedTarget)||qc.trigger("chatBoxBlurred",this,e)},emitFocused(e){this.el.contains(e.relatedTarget)||qc.trigger("chatBoxFocused",this,e)},focus(){const e=this.el.getElementsByClassName("chat-textarea")[0];return e&&document.activeElement!==e&&e.focus(),this},maybeFocus(){qc.settings.get("auto_focus")&&this.focus()},hide(){return this.el.classList.add("hidden"),this},afterShown(){this.model.clearUnreadMsgCounter(),this.model.setChatState(Lc.ACTIVE),this.scrollDown(),this.maybeFocus()},show(){jv.isVisible(this.el)?this.maybeFocus():(qc.trigger("beforeShowingChatView",this),qc.settings.get("animate")?jv.fadeIn(this.el,()=>this.afterShown()):(jv.showElement(this.el),this.afterShown()))},showNewMessagesIndicator(){jv.showElement(this.el.querySelector(".new-msgs-indicator"))},hideNewMessagesIndicator(){const e=this.el.querySelector(".new-msgs-indicator");null!==e&&e.classList.add("hidden")},_markScrolled:function(e){let t=!0,n=null;this.msgs_container.scrollTop+this.msgs_container.clientHeight>=this.msgs_container.scrollHeight-62?(t=!1,this.onScrolledDown()):0===this.msgs_container.scrollTop?qc.trigger("chatBoxScrolledUp",this):n=e.target.scrollTop,jv.safeSave(this.model,{scrolled:t,scrollTop:n})},viewUnreadMessages(){this.model.save({scrolled:!1,scrollTop:null}),this.scrollDown()},onScrolledDown(){if(this.hideNewMessagesIndicator(),!this.model.isHidden()){this.model.clearUnreadMsgCounter();const e=window.location.hash;e&&this.model.messages.get(e.slice(1))&&Lc.router.history.navigate()}qc.trigger("chatBoxScrolledDown",{chatbox:this.model})},onWindowStateChanged(e){"visible"===e?this.model.isHidden()||this.model.get("num_unread",0)&&this.model.clearUnreadMsgCounter():"hidden"===e&&(this.model.setChatState(Lc.INACTIVE,{silent:!0}),this.model.sendChatState())}});let Ov;Yc.plugins.add("converse-chatview",{dependencies:["converse-chatboxviews","converse-chat","converse-disco","converse-modal"],initialize(){qc.settings.extend({auto_focus:!0,debounced_content_rendering:!0,filter_url_query_params:null,image_urls_regex:null,message_limit:0,muc_hats:["xep317"],role_affiliation_hat_conversions:{},show_images_inline:!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}}),Lc.ChatBoxView=Tv,Lc.UserDetailsModal=dh.extend({id:"user-details-modal",events:{"click button.refresh-contact":"refreshContact","click .fingerprint-trust .btn input":"toggleDeviceTrust"},initialize(){dh.prototype.initialize.apply(this,arguments),this.model.rosterContactAdded.then(()=>this.registerContactEventHandlers()),this.listenTo(this.model,"change",this.render),this.registerContactEventHandlers(),qc.trigger("userDetailsModalInitialized",this.model)},toHTML(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{};return bv(Object.assign(this.model.toJSON(),n,{_converse:Lc,allow_contact_removal:qc.settings.get("allow_contact_removal"),display_name:this.model.getDisplayName(),is_roster_contact:void 0!==this.model.contact,removeContact:e=>this.removeContact(e),view:this,utils:jv}))},registerContactEventHandlers(){void 0!==this.model.contact&&(this.listenTo(this.model.contact,"change",this.render),this.listenTo(this.model.contact.vcard,"change",this.render),this.model.contact.on("destroy",()=>{delete this.model.contact,this.render()}))},async refreshContact(e){e&&e.preventDefault&&e.preventDefault();const t=this.el.querySelector(".fa-refresh");jv.addClass("fa-spin",t);try{await qc.vcard.update(this.model.contact.vcard,!0)}catch(e){Pn.fatal(e),this.alert(Ed("Sorry, something went wrong while trying to refresh"),"danger")}jv.removeClass("fa-spin",t)},removeContact(e){if(e&&e.preventDefault&&e.preventDefault(),!qc.settings.get("allow_contact_removal"))return;!0===confirm(Ed("Are you sure you want to remove this contact?"))&&(this.modal.hide(),setTimeout(()=>{this.model.contact.removeFromRoster(()=>this.model.contact.destroy(),e=>{Pn.error(e),qc.alert("error",Ed("Error"),[Ed("Sorry, there was an error while trying to remove %1$s as a contact.",this.model.contact.getDisplayName())])})},1))}}),qc.listen.on("chatBoxViewsInitialized",()=>{const e=Lc.chatboxviews;Lc.chatboxes.on("add",async t=>{e.get(t.get("id"))||t.get("type")!==Lc.PRIVATE_CHAT_TYPE||(await t.initialized,e.add(t.get("id"),new Lc.ChatBoxView({model:t})))})}),qc.listen.on("windowStateChanged",(function(e){Lc.chatboxviews&&Lc.chatboxviews.forEach(t=>{"controlbox"!==t.model.get("id")&&t.onWindowStateChanged(e.state)})})),qc.listen.on("connected",()=>qc.disco.own.features.add(Av.NS.SPOILER)),Object.assign(qc,{chatviews:{get:e=>void 0===e?Object.values(Lc.chatboxviews.getAll()):"string"==typeof e?Lc.chatboxviews.get(e):e.map(e=>Lc.chatboxviews.get(e))}})}});let kv=0;function Nv(e){Ov=e}function Iv(){Ov=null,kv=0}const Mv=Symbol("haunted.phase"),Rv=Symbol("haunted.hook"),Dv=Symbol("haunted.update"),Pv=Symbol("haunted.commit"),Lv=Symbol("haunted.effects"),zv=Symbol("haunted.layoutEffects");class Fv{constructor(e,t){this.update=e,this.host=t,this[Rv]=new Map,this[Lv]=[],this[zv]=[]}run(e){Nv(this);let t=e();return Iv(),t}_runEffects(e){let t=this[e];Nv(this);for(let e of t)e.call(this);Iv()}runEffects(){this._runEffects(Lv)}runLayoutEffects(){this._runEffects(zv)}teardown(){this[Rv].forEach(e=>{"function"==typeof e.teardown&&e.teardown()})}}const Bv=Promise.resolve().then.bind(Promise.resolve());function qv(){let e,t=[];function n(){e=null;let n=t;t=[];for(var r=0,i=n.length;r<i;r++)n[r]()}return function(r){t.push(r),null==e&&(e=Bv(n))}}const Hv=qv(),Uv=qv();class $v{constructor(e,t){this.renderer=e,this.host=t,this.state=new Fv(this.update.bind(this),t),this[Mv]=null,this._updateQueued=!1}update(){this._updateQueued||(Hv(()=>{let e=this.handlePhase(Dv);Uv(()=>{this.handlePhase(Pv,e),Uv(()=>{this.handlePhase(Lv)})}),this._updateQueued=!1}),this._updateQueued=!0)}handlePhase(e,t){switch(this[Mv]=e,e){case Pv:return this.commit(t),void this.runEffects(zv);case Dv:return this.render();case Lv:return this.runEffects(Lv)}this[Mv]=null}render(){return this.state.run(()=>this.renderer.call(this.host,this.host))}runEffects(e){this.state._runEffects(e)}teardown(){this.state.teardown()}}function Wv(e){class t extends $v{constructor(e,t,n){super(e,n||t),this.frag=t}commit(t){e(t,this.frag)}}return function(e,n,r){const i=(r||n||{}).baseElement||HTMLElement,{observedAttributes:s=[],useShadowDOM:o=!0,shadowRootInit:a={}}=r||n||{};class c extends i{constructor(){super(),!1===o?this._scheduler=new t(e,this):(this.attachShadow({mode:"open",...a}),this._scheduler=new t(e,this.shadowRoot,this))}static get observedAttributes(){return e.observedAttributes||s||[]}connectedCallback(){this._scheduler.update()}disconnectedCallback(){this._scheduler.teardown()}attributeChangedCallback(e,t,n){if(t===n)return;let r=""===n||n;Reflect.set(this,((e="")=>e.replace(/-+([a-z])?/g,(e,t)=>t?t.toUpperCase():""))(e),r)}}const l=new Proxy(i.prototype,{getPrototypeOf:e=>e,set(e,t,n,r){let i;if(t in e){if(i=Object.getOwnPropertyDescriptor(e,t),i&&i.set)return i.set.call(r,n),!0;Reflect.set(e,t,n)}return i="symbol"==typeof t||"_"===t[0]?{enumerable:!0,configurable:!0,writable:!0,value:n}:function(e){let t=e;return Object.freeze({enumerable:!0,configurable:!0,get:()=>t,set(e){t=e,this._scheduler.update()}})}(n),Object.defineProperty(r,t,i),i.set&&i.set.call(r,n),!0}});return Object.setPrototypeOf(c.prototype,l),c}}class Vv{constructor(e,t){this.id=e,this.state=t}}function Gv(e,...t){let n=kv++,r=Ov[Rv],i=r.get(n);return i||(i=new e(n,Ov,...t),r.set(n,i)),i.update(...t)}function Jv(e){return Gv.bind(null,e)}function Xv(e){return Jv(class extends Vv{constructor(t,n,r,i){super(t,n),e(n,this)}update(e,t){this.callback=e,this.lastValues=this.values,this.values=t}call(){this.values&&!this.hasChanged()||this.run()}run(){this.teardown(),this._teardown=this.callback.call(this.state)}teardown(){"function"==typeof this._teardown&&this._teardown()}hasChanged(){return!this.lastValues||this.values.some((e,t)=>this.lastValues[t]!==e)}})}function Qv(e,t){e[Lv].push(t)}Xv(Qv);const Yv=Jv(class extends Vv{constructor(e,t,n){super(e,t),this._updater=this._updater.bind(this),this._ranEffect=!1,this._unsubscribe=null,Qv(t,this)}update(e){if(this.state.virtual)throw new Error("can't be used with virtual components");return this.Context!==e&&(this._subscribe(e),this.Context=e),this.value}call(){this._ranEffect||(this._ranEffect=!0,this._unsubscribe&&this._unsubscribe(),this._subscribe(this.Context),this.state.update())}_updater(e){this.value=e,this.state.update()}_subscribe(e){const t={Context:e,callback:this._updater};this.state.host.dispatchEvent(new CustomEvent("haunted.context",{detail:t,bubbles:!0,cancelable:!0,composed:!0}));const{unsubscribe:n,value:r}=t;this.value=n?r:e.defaultValue,this._unsubscribe=n}teardown(){this._unsubscribe&&this._unsubscribe()}});Jv(class extends Vv{constructor(e,t,n,r){super(e,t),this.value=n(),this.values=r}update(e,t){return this.hasChanged(t)&&(this.values=t,this.value=e()),this.value}hasChanged(e=[]){return e.some((e,t)=>this.values[t]!==e)}});Xv((function(e,t){e[zv].push(t)})),Jv(class extends Vv{constructor(e,t,n){super(e,t),this.updater=this.updater.bind(this),"function"==typeof n&&(n=n()),this.makeArgs(n)}update(){return this.args}updater(e){if("function"==typeof e){const t=e,[n]=this.args;e=t(n)}this.makeArgs(e),this.state.update()}makeArgs(e){this.args=Object.freeze([e,this.updater])}}),Jv(class extends Vv{constructor(e,t,n,r,i){super(e,t),this.dispatch=this.dispatch.bind(this),this.currentState=void 0!==i?i(r):r}update(e){return this.reducer=e,[this.currentState,this.dispatch]}dispatch(e){this.currentState=this.reducer(this.currentState,e),this.state.update()}});const Kv=Array.prototype.includes;const{component:Zv,createContext:e_}=function({render:e}){const t=Wv(e),n=function(e){return t=>{const n={Provider:class extends HTMLElement{constructor(){super(),this.listeners=new Set,this.addEventListener("haunted.context",this)}disconnectedCallback(){this.removeEventListener("haunted.context",this)}handleEvent(e){const{detail:t}=e;t.Context===n&&(t.value=this.value,t.unsubscribe=this.unsubscribe.bind(this,t.callback),this.listeners.add(t.callback),e.stopPropagation())}unsubscribe(e){this.listeners.delete(e)}set value(e){this._value=e;for(let t of this.listeners)t(e)}get value(){return this._value}},Consumer:e((function({render:e}){return e(Yv(n))})),defaultValue:t};return n}}(t);return{component:t,createContext:n}}({render:Wa});!function(){const e=new WeakMap,t=new WeakMap;class n extends $v{constructor(e,t){super(e,t),this.state.virtual=!0}render(){return this.state.run(()=>this.renderer.apply(this.host,this.args))}commit(e){this.host.setValue(e),this.host.commit()}teardown(){super.teardown();let n=t.get(this);e.delete(n)}}}();function t_(){const e=i_(['\n <p class="brand-subtitle">','</p>\n <p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://conversejs.org">Open Source</a> XMPP chat client brought to you by <a target="_blank" rel="nofollow" href="https://opkode.com">Opkode</a> </p>\n <p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages">Translate</a> it into your own language</p>']);return t_=function(){return e},e}function n_(){const e=i_(['<p class="byline">messaging freedom</p>']);return n_=function(){return e},e}function r_(){const e=i_(['\n <a class="brand-heading" href="https://conversejs.org" target="_blank" rel="noopener">\n <span class="brand-name-wrapper ','">\n <svg class="converse-svg-logo"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n viewBox="0 0 364 364">\n <title>Converse</title>\n <g class="cls-1" id="g904">\n <g data-name="Layer 2">\n <g data-name="Layer 7">\n <path\n class="cls-3"\n d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" />\n <path\n class="cls-4"\n d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" />\n </g>\n </g>\n </g>\n </svg>\n <span class="brand-name">\n <span class="brand-name__text">converse<span class="subdued">.js</span></span>\n ',"\n </span>\n </span>\n </a>\n ","\n "]);return r_=function(){return e},e}function i_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function s_(){const e=a_(['<a class="chatbox-btn close-chatbox-button fa fa-times"></a>']);return s_=function(){return e},e}function o_(){const e=a_(['\n <div class="flyout box-flyout">\n <div class="chat-head controlbox-head">\n ','\n </div>\n <div class="controlbox-panes"></div>\n </div>']);return o_=function(){return e},e}function a_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}qc.elements.define("converse-brand-heading",Zv(e=>{const t="fullscreen"===qc.settings.get("view_mode");return Ga(r_(),t?"brand-name-wrapper--fullscreen":"",t?Ga(n_()):"",t?Ga(t_(),e.version_name):"")},{useShadowDOM:!1}));var c_=n(136),l_=n.n(c_);function u_(){const e=__(['\n <converse-brand-heading></converse-brand-heading>\n <form id="converse-login" class="converse-form" method="post">\n <div class="conn-feedback fade-in ','">\n <p class="feedback-subject">','</p>\n <p class="feedback-message ','">',"</p>\n </div>\n ","\n </form>\n"]);return u_=function(){return e},e}function d_(){const e=__(["<p>","</p>"]);return d_=function(){return e},e}function h_(){const e=__(['<input class="btn btn-primary login-anon" type="submit" value="','">']);return h_=function(){return e},e}function f_(){const e=__(["\n ","\n ","\n ","\n "]);return f_=function(){return e},e}function p_(){const e=__(['\n <div class="form-group">\n <label for="converse-login-jid">',':</label>\n <input id="converse-login-jid"\n ?autofocus=','\n required\n class="form-control"\n type="text"\n name="jid"\n placeholder="','"/>\n </div>\n ',"\n ",'\n <fieldset class="buttons">\n <input class="btn btn-primary" type="submit" value="','"/>\n </fieldset>\n ',"\n "]);return p_=function(){return e},e}function g_(){const e=__(['\n <fieldset class="switch-form">\n <p>','</p>\n <p><a class="register-account toggle-register-login" href="#converse/register">',"</a></p>\n </fieldset>\n "]);return g_=function(){return e},e}function m_(){const e=__(['\n <div class="form-group">\n <label for="converse-login-password">','</label>\n <input id="converse-login-password" class="form-control" required="required" type="password" name="password" placeholder="','"/>\n </div>\n ']);return m_=function(){return e},e}function v_(){const e=__(['\n <div class="form-group form-check login-trusted">\n <input id="converse-login-trusted" type="checkbox" class="form-check-input" name="trusted" ?checked=','>\n <label for="converse-login-trusted" class="form-check-label login-trusted__desc">','</label>\n <i class="fa fa-info-circle" data-toggle="popover"\n data-title="Trusted device?"\n data-content="','"></i>\n </div>\n ']);return v_=function(){return e},e}function __(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const b_=e=>{const t=Ed("Log in"),n=Ed("XMPP Address");return Ga(p_(),n,!!qc.settings.get("auto_focus"),e.placeholder_username,e.authentication!==e.EXTERNAL?(()=>{const e=Ed("Password");return Ga(m_(),e,e)})():"",e.show_trust_checkbox?(e=>{const t=Ed("To improve performance, we cache your data in this browser. Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. It's important that you explicitly log out, otherwise not all cached data might be deleted. Please note, when using an untrusted device, OMEMO encryption is NOT available."),n=Ed("This is a trusted device");return Ga(v_(),e._converse.config.get("trusted"),n,t)})(e):"",t,(e=>{const t=e._converse;return t.allow_registration&&!qc.settings.get("auto_login")&&t.pluggable.plugins["converse-register"].enabled(t)})(e)?(()=>{const e=Ed("Create an account"),t=Ed("Don't have a chat account?");return Ga(g_(),t,e)})():"")};var y_=e=>Ga(u_(),e.conn_feedback_subject?e.conn_feedback_class:"hidden",e.conn_feedback_subject,e.conn_feedback_message?"":"hidden",e.conn_feedback_message,"CONNECTING"===e._converse.CONNECTION_STATUS[e.connection_status]?qf({classes:"hor_centered"}):(e=>{const t=Ed("Disconnected"),n=Ed("Click here to log in anonymously");return Ga(f_(),e.authentication==e.LOGIN||e.authentication==e.EXTERNAL?b_(e):"",e.authentication==e.ANONYMOUS?Ga(h_(),n):"",e.authentication==e.PREBIND?Ga(d_(),t):"")})(e));function w_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S_(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}
*/const{Strophe:Av,dayjs:Cv}=Yc.env,jv=Yc.env.utils,Tv=Bd.extend({length:200,className:"chatbox hidden",is_chatroom:!1,events:{"click .chatbox-navback":"showControlBox","click .new-msgs-indicator":"viewUnreadMessages","click .send-button":"onFormSubmitted","click .toggle-clear":"clearMessages","input .chat-textarea":"inputChanged","keydown .chat-textarea":"onKeyDown","keyup .chat-textarea":"onKeyUp","paste .chat-textarea":"onPaste"},async initialize(){this.initDebounced(),this.listenTo(this.model,"change:composing_spoiler",this.renderMessageForm),this.listenTo(this.model,"change:hidden",e=>e.get("hidden")?this.hide():this.show()),this.listenTo(this.model,"change:status",this.onStatusMessageChanged),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"show",this.show),this.listenTo(this.model,"vcard:change",this.renderHeading),this.model.contact&&this.listenTo(this.model.contact,"destroy",this.renderHeading),this.model.rosterContactAdded&&this.model.rosterContactAdded.then(()=>{this.listenTo(this.model.contact,"change:nickname",this.renderHeading),this.renderHeading()}),this.listenTo(this.model.presence,"change:show",this.onPresenceChanged),this.render(),this.listenTo(this.model.messages,"add",this.onMessageAdded),this.listenTo(this.model.messages,"remove",this.renderChatHistory),this.listenTo(this.model.messages,"rendered",this.maybeScrollDown),this.listenTo(this.model.messages,"reset",this.renderChatHistory),this.listenTo(this.model.notifications,"change",this.renderNotifications),this.listenTo(this.model,"change:show_help_messages",this.renderHelpMessages),await this.updateAfterMessagesFetched(),this.model.maybeShow(),qc.trigger("chatBoxViewInitialized",this)},initDebounced(){this.markScrolled=Tc(this._markScrolled,100),this.debouncedScrollDown=Tc(this.scrollDown,100),qc.settings.get("debounced_content_rendering")?(this.renderChatHistory=Tc(()=>this.renderChatContent(!1),100),this.renderNotifications=Tc(()=>this.renderChatContent(!0),100)):(this.renderChatHistory=()=>this.renderChatContent(!1),this.renderNotifications=()=>this.renderChatContent(!0))},render(){const e=Qm(Object.assign(this.model.toJSON(),{markScrolled:e=>this.markScrolled(e)}));return Wa(e,this.el),this.content=this.el.querySelector(".chat-content"),this.notifications=this.el.querySelector(".chat-content__notifications"),this.msgs_container=this.el.querySelector(".chat-content__messages"),this.help_container=this.el.querySelector(".chat-content__help"),this.renderChatContent(),this.renderMessageForm(),this.renderHeading(),this},onMessageAdded(e){this.renderChatHistory(),jv.isNewMessage(e)&&("me"===e.get("sender")?this.model.set("scrolled",!1):this.model.get("scrolled",!0)&&this.showNewMessagesIndicator())},getNotifications(){return this.model.notifications.get("chat_state")===Lc.COMPOSING?Ed("%1$s is typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Lc.PAUSED?Ed("%1$s has stopped typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Lc.GONE?Ed("%1$s has gone away",this.model.getDisplayName()):""},getHelpMessages:()=>["<strong>/clear</strong>: ".concat(Ed("Remove messages")),"<strong>/close</strong>: ".concat(Ed("Close this chat")),"<strong>/me</strong>: ".concat(Ed("Write in the third person")),"<strong>/help</strong>: ".concat(Ed("Show this menu"))],renderHelpMessages(){Wa(Ga(xv(),this.model,this.getHelpMessages(),!this.model.get("show_help_messages"),this.model.get("type")),this.help_container)},renderChatContent(e=!1){this.tpl_chat_content||(this.tpl_chat_content=e=>Ga(Sv(),this,e.messages,e.notifications));const t=this.model.messages.models,n=e?t:Array.from(t);Wa(this.tpl_chat_content({messages:n,notifications:this.getNotifications()}),this.msgs_container)},renderToolbar(){if(!qc.settings.get("show_toolbar"))return this;const e=Object.assign({model:this.model,chatview:this},this.model.toJSON(),this.getToolbarOptions());return Wa((e=>{const t=qc.settings.get("message_limit"),n=qc.settings.get("visible_toolbar_buttons").call,r=qc.settings.get("visible_toolbar_buttons").emoji,i=qc.settings.get("show_send_button"),s=qc.settings.get("visible_toolbar_buttons").spoiler,o=qc.settings.get("show_toolbar");return Ga(sv(),e.chatview,e.model,e.composing_spoiler,e.hidden_occupants,e.is_groupchat,n,r,e.show_occupants_toggle,i,s,o,t)})(e),this.el.querySelector(".chat-toolbar")),qc.trigger("renderToolbar",this),this},renderMessageForm(){var e,t;const n=this.el.querySelector(".message-form-container");var r;Wa((r=Object.assign(this.model.toJSON(),{hint_value:null===(e=this.el.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,label_message:this.model.get("composing_spoiler")?Ed("Hidden message"):Ed("Message"),label_spoiler_hint:Ed("Optional hint"),message_value:null===(t=this.el.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,show_send_button:qc.settings.get("show_send_button"),show_toolbar:qc.settings.get("show_toolbar"),unread_msgs:Ed("You have unread messages")}),Ga(iv(),r.unread_msgs,r.label_spoiler_hint||"",r.hint_value||"",r.composing_spoiler?"":"hidden",r.show_send_button?"chat-textarea-send-button":"",r.composing_spoile?"spoiler":"",r.label_message,r.message_value||"")),n),this.el.addEventListener("focusin",e=>this.emitFocused(e)),this.el.addEventListener("focusout",e=>this.emitBlurred(e)),this.renderToolbar()},showControlBox(){Lc.chatboxviews.get("controlbox").show(),this.hide()},showUserDetailsModal(e){e.preventDefault(),void 0===this.user_details_modal&&(this.user_details_modal=new Lc.UserDetailsModal({model:this.model})),this.user_details_modal.show(e)},onDragOver(e){e.preventDefault()},onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))},async renderHeading(){const e=await this.generateHeadingTemplate();Wa(e,this.el.querySelector(".chat-head-chatbox"))},async getHeadingStandaloneButton(e){const t=await e;return Ga(wv(),t.a_class,t.icon_class,t.handler,t.i18n_title)},async getHeadingDropdownItem(e){const t=await e;return Ga(yv(),t.a_class,t.handler,t.i18n_title,t.icon_class,t.i18n_text)},async generateHeadingTemplate(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{},r=await this.getHeadingButtons(),i=r.filter(e=>e.standalone),s=r.filter(e=>!e.standalone);return(e=>{const t={alt_text:Ed("The User's Profile Image"),extra_classes:"",height:40,width:40};return Ga(nv(),e.status?"":"chatbox-title--no-desc",e._converse.api.settings.get("singleton")?"":Ga(tv()),e.type!==e._converse.HEADLINES_TYPE?Ga(ev(),If(Object.assign({},e,t))):"",e.jid,e.url?Ga(Zm(),e.url,e.display_name):e.display_name,e.dropdown_btns.length?Ga(Km(),e.dropdown_btns):"",e.standalone_btns.length?(e=>e.standalone_btns.reverse().map(e=>bh(e,"")))(e):"",e.status?Ga(Ym(),e.status):"")})(Object.assign(n,this.model.toJSON(),{_converse:Lc,dropdown_btns:s.map(e=>this.getHeadingDropdownItem(e)),standalone_btns:i.map(e=>this.getHeadingStandaloneButton(e)),display_name:this.model.getDisplayName()}))},getHeadingButtons(){const e=[{a_class:"show-user-details-modal",handler:e=>this.showUserDetailsModal(e),i18n_text:Ed("Details"),i18n_title:Ed("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===qc.settings.get("view_mode")}];return qc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:Ed("Close"),i18n_title:Ed("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===qc.settings.get("view_mode")}),Lc.api.hook("getHeadingButtons",this,e)},getToolbarOptions:()=>({}),async updateAfterMessagesFetched(){await this.model.messages.fetched,this.renderChatContent(),this.insertIntoDOM(),this.scrollDown(),qc.trigger("afterMessagesFetched",this.model)},maybeScrollDown(e){!(!(null==e?void 0:e.get("is_archived"))&&"me"===(null==e?void 0:e.get("sender")))&&this.model.get("scrolled")||this.model.isHidden()||this.debouncedScrollDown()},scrollDown(e){var t,n;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.get("scrolled")&&jv.safeSave(this.model,{scrolled:!1,scrollTop:null}),this.msgs_container.scrollTo){const e=this.msgs_container.scrollTop?"smooth":"auto";this.msgs_container.scrollTo({top:this.msgs_container.scrollHeight,behavior:e})}else this.msgs_container.scrollTop=this.msgs_container.scrollHeight;this.onScrolledDown()},maintainScrollTop(){const e=this.model.get("scrollTop");e?this.msgs_container.scrollTop=e:this.scrollDown()},insertIntoDOM(){return Lc.chatboxviews.insertRowColumn(this.el),qc.trigger("chatBoxInsertedIntoDOM",this),this},addSpinner(e=!1){if(null===this.el.querySelector(".spinner")){const t=jv.getElementFromTemplateResult(qf());e?(this.content.insertAdjacentElement("beforeend",t),this.scrollDown()):this.content.insertAdjacentElement("afterbegin",t)}},clearSpinner(){this.content.querySelectorAll(".spinner").forEach(jv.removeElement)},onStatusMessageChanged(e){this.renderHeading(),qc.trigger("contactStatusMessageChanged",{contact:e.attributes,message:e.get("status")})},shouldShowOnTextMessage(){return!Lc.isUniView()&&!jv.isVisible(this.el)},markFollowups(e){const t=e.getAttribute("data-from"),n=e.previousElementSibling,r=Cv(e.getAttribute("data-isodate")),i=e.nextElementSibling;jv.hasClass("chat-msg--action",e)||jv.hasClass("chat-msg--action",n)||jv.hasClass("chat-info",e)||jv.hasClass("chat-info",n)||n.getAttribute("data-from")!==t||!r.isBefore(Cv(n.getAttribute("data-isodate")).add(10,"minutes"))||e.getAttribute("data-encrypted")!==n.getAttribute("data-encrypted")||jv.addClass("chat-msg--followup",e),i&&(!jv.hasClass("chat-msg--action",e)&&jv.hasClass("chat-info",e)&&i.getAttribute("data-from")===t&&Cv(i.getAttribute("data-isodate")).isBefore(r.add(10,"minutes"))&&e.getAttribute("data-encrypted")===i.getAttribute("data-encrypted")?jv.addClass("chat-msg--followup",i):jv.removeClass("chat-msg--followup",i))},parseMessageForCommands(e){const t=e.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(t){if("clear"===t[1])return this.clearMessages(),!0;if("close"===t[1])return this.close(),!0;if("help"===t[1])return this.model.set({show_help_messages:!0}),!0}},async onFormSubmitted(e){var t;e.preventDefault();const n=this.el.querySelector(".chat-textarea"),r=n.value.trim();if(qc.settings.get("message_limit")&&r.length>qc.settings.get("message_limit")||!r.replace(/\s/g,"").length)return;if(!Lc.connection.authenticated){const e=Ed("Sorry, the connection has been lost, and your message could not be sent");return qc.alert("error",Ed("Error"),e),void qc.connection.reconnect()}let i,s={};this.model.get("composing_spoiler")&&(s=this.el.querySelector("form.sendXMPPMessage input.spoiler-hint"),i=s.value),jv.addClass("disabled",n),n.setAttribute("disabled","disabled"),null===(t=this.el.querySelector("converse-emoji-dropdown"))||void 0===t||t.hideMenu();const o=this.parseMessageForCommands(r),a=o?null:await this.model.sendMessage(r,i);(o||a)&&(s.value="",n.value="",jv.removeClass("correcting",n),n.style.height="auto",this.updateCharCounter(n.value)),a&&qc.trigger("messageSend",a),"overlayed"===qc.settings.get("view_mode")&&(this.msgs_container.parentElement.style.display="none"),n.removeAttribute("disabled"),jv.removeClass("disabled",n),"overlayed"===qc.settings.get("view_mode")&&(this.msgs_container.parentElement.style.display=""),this.model.setChatState(Lc.ACTIVE,{silent:!0}),n.focus()},updateCharCounter(e){if(qc.settings.get("message_limit")){const t=this.el.querySelector(".message-limit"),n=qc.settings.get("message_limit")-e.length;t.textContent=n,n<1?jv.addClass("error",t):jv.removeClass("error",t)}},onPaste(e){if(0!==e.clipboardData.files.length)return e.preventDefault(),void this.model.sendFiles(Array.from(e.clipboardData.files));this.updateCharCounter(e.clipboardData.getData("text/plain"))},autocompleteInPicker(e,t){const n=this.el.querySelector("converse-emoji-dropdown"),r=this.el.querySelector("converse-emoji-picker");if(r&&n)return r.model.set({ac_position:e.selectionStart,autocompleting:t,query:t}),n.showMenu(),!0},onEmojiReceivedFromPicker(e){const t=this.el.querySelector("converse-emoji-picker").model,n=t.get("autocompleting"),r=t.get("ac_position");this.insertIntoTextArea(e,n,!1,r)},onKeyUp(e){this.updateCharCounter(e.target.value)},onKeyDown(e){if(!e.ctrlKey){if(!e.shiftKey&&!e.altKey&&!e.metaKey)if(e.keyCode===Yc.keycodes.TAB){const t=jv.getCurrentWord(e.target,null,/(:.*?:)/g);t.startsWith(":")&&this.autocompleteInPicker(e.target,t)&&(e.preventDefault(),e.stopPropagation())}else{if(e.keyCode===Yc.keycodes.FORWARD_SLASH)return;if(e.keyCode===Yc.keycodes.ESCAPE)return this.onEscapePressed(e);if(e.keyCode===Yc.keycodes.ENTER)return this.onEnterPressed(e);if(e.keyCode!==Yc.keycodes.UP_ARROW||e.target.selectionEnd){if(e.keyCode===Yc.keycodes.DOWN_ARROW&&e.target.selectionEnd===e.target.value.length&&jv.hasClass("correcting",this.el.querySelector(".chat-textarea")))return this.editLaterMessage()}else{const e=this.el.querySelector(".chat-textarea");if(!e.value||jv.hasClass("correcting",e))return this.editEarlierMessage()}}[Yc.keycodes.SHIFT,Yc.keycodes.META,Yc.keycodes.META_RIGHT,Yc.keycodes.ESCAPE,Yc.keycodes.ALT].includes(e.keyCode)||this.model.get("chat_state")!==Lc.COMPOSING&&this.model.setChatState(Lc.COMPOSING)}},getOwnMessages(){return this.model.messages.filter({sender:"me"})},onEnterPressed(e){return this.onFormSubmitted(e)},onEscapePressed(e){e.preventDefault();const t=this.model.messages.findLastIndex("correcting"),n=t>=0?this.model.messages.at(t):null;n&&n.save("correcting",!1),this.insertIntoTextArea("",!0,!1)},async onMessageRetractButtonClicked(e){if("me"!==e.get("sender"))return Pn.error("onMessageRetractButtonClicked called for someone else's message!");const t=Ed("Be aware that other XMPP/Jabber clients (and servers) may not yet support retractions and that this message may not be removed everywhere."),n=[Ed("Are you sure you want to retract this message?")];qc.settings.get("show_retraction_warning")&&(n[1]=t),await qc.confirm(Ed("Confirm"),n)&&this.model.retractOwnMessage(e)},onMessageEditButtonClicked(e){var t;const n=this.model.messages.findWhere("correcting"),r=null===(t=this.el.querySelector(".chat-textarea"))||void 0===t?void 0:t.value;(!r||n&&n.get("message")===r||confirm(Ed("You have an unsent message which will be lost if you continue. Are you sure?")))&&(n!==e?(null==n||n.save("correcting",!1),e.save("correcting",!0),this.insertIntoTextArea(jv.prefixMentions(e),!0,!0)):(e.save("correcting",!1),this.insertIntoTextArea("",!0,!1)))},editLaterMessage(){let e,t=this.model.messages.findLastIndex("correcting");if(t>=0)for(this.model.messages.at(t).save("correcting",!1);t<this.model.messages.length-1;){t+=1;const n=this.model.messages.at(t);if(n.get("editable")){e=n;break}}e?(this.insertIntoTextArea(jv.prefixMentions(e),!0,!0),e.save("correcting",!0)):this.insertIntoTextArea("",!0,!1)},editEarlierMessage(){let e,t=this.model.messages.findLastIndex("correcting");if(t>=0)for(this.model.messages.at(t).save("correcting",!1);t>0;){t-=1;const n=this.model.messages.at(t);if(n.get("editable")){e=n;break}}e=e||this.getOwnMessages().reverse().find(e=>e.get("editable")),e&&(this.insertIntoTextArea(jv.prefixMentions(e),!0,!0),e.save("correcting",!0))},inputChanged(e){const t=e.target.scrollHeight+"px";e.target.style.height!=t&&(e.target.style.height="auto",e.target.style.height=t)},async clearMessages(e){return e&&e.preventDefault&&e.preventDefault(),!0===confirm(Ed("Are you sure you want to clear the messages from this conversation?"))&&await this.model.clearMessages(),this},insertIntoTextArea(e,t=!1,n=!1,r){const i=this.el.querySelector(".chat-textarea");if(n?jv.addClass("correcting",i):jv.removeClass("correcting",i),t)i.value=r&&"string"==typeof t?i.value.replace(new RegExp(t,"g"),(n,i)=>i==r-t.length?e+" ":n):e;else{let t=i.value;t&&" "!==t[t.length-1]&&(t+=" "),i.value=t+e+" "}this.updateCharCounter(i.value),jv.placeCaretAtEnd(i)},onPresenceChanged(e){const t=e.get("show"),n=this.model.getDisplayName();let r;jv.isVisible(this.el)&&("offline"===t?r=Ed("%1$s has gone offline",n):"away"===t?r=Ed("%1$s has gone away",n):"dnd"===t?r=Ed("%1$s is busy",n):"online"===t&&(r=Ed("%1$s is online",n)),r&&this.model.createMessage({message:r,type:"info"}))},async close(e){return e&&e.preventDefault&&e.preventDefault(),Lc.router.history.getFragment()==="converse/chat?jid="+this.model.get("jid")&&Lc.router.navigate(""),qc.connection.connected()&&(this.model.setChatState(Lc.INACTIVE),this.model.sendChatState()),await this.model.close(),this.remove(),qc.trigger("chatBoxClosed",this),this},emitBlurred(e){this.el.contains(document.activeElement)||this.el.contains(e.relatedTarget)||qc.trigger("chatBoxBlurred",this,e)},emitFocused(e){this.el.contains(e.relatedTarget)||qc.trigger("chatBoxFocused",this,e)},focus(){const e=this.el.getElementsByClassName("chat-textarea")[0];return e&&document.activeElement!==e&&e.focus(),this},maybeFocus(){qc.settings.get("auto_focus")&&this.focus()},hide(){return this.el.classList.add("hidden"),this},afterShown(){this.model.clearUnreadMsgCounter(),this.model.setChatState(Lc.ACTIVE),this.scrollDown(),this.maybeFocus()},show(){jv.isVisible(this.el)?this.maybeFocus():(qc.trigger("beforeShowingChatView",this),qc.settings.get("animate")?jv.fadeIn(this.el,()=>this.afterShown()):(jv.showElement(this.el),this.afterShown()))},showNewMessagesIndicator(){jv.showElement(this.el.querySelector(".new-msgs-indicator"))},hideNewMessagesIndicator(){const e=this.el.querySelector(".new-msgs-indicator");null!==e&&e.classList.add("hidden")},_markScrolled:function(e){let t=!0,n=null;this.msgs_container.scrollTop+this.msgs_container.clientHeight>=this.msgs_container.scrollHeight-62?(t=!1,this.onScrolledDown()):0===this.msgs_container.scrollTop?qc.trigger("chatBoxScrolledUp",this):n=e.target?e.target.scrollTop:null,jv.safeSave(this.model,{scrolled:t,scrollTop:n})},viewUnreadMessages(){this.model.save({scrolled:!1,scrollTop:null}),this.scrollDown()},onScrolledDown(){if(this.hideNewMessagesIndicator(),!this.model.isHidden()){this.model.clearUnreadMsgCounter();const e=window.location.hash;e&&this.model.messages.get(e.slice(1))&&Lc.router.history.navigate()}qc.trigger("chatBoxScrolledDown",{chatbox:this.model})},onWindowStateChanged(e){"visible"===e?this.model.isHidden()||this.model.get("num_unread",0)&&this.model.clearUnreadMsgCounter():"hidden"===e&&(this.model.setChatState(Lc.INACTIVE,{silent:!0}),this.model.sendChatState())}});let Ov;Yc.plugins.add("converse-chatview",{dependencies:["converse-chatboxviews","converse-chat","converse-disco","converse-modal"],initialize(){qc.settings.extend({auto_focus:!0,debounced_content_rendering:!0,filter_url_query_params:null,image_urls_regex:null,message_limit:0,muc_hats:["xep317"],role_affiliation_hat_conversions:{},show_images_inline:!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}}),Lc.ChatBoxView=Tv,Lc.UserDetailsModal=dh.extend({id:"user-details-modal",events:{"click button.refresh-contact":"refreshContact","click .fingerprint-trust .btn input":"toggleDeviceTrust"},initialize(){dh.prototype.initialize.apply(this,arguments),this.model.rosterContactAdded.then(()=>this.registerContactEventHandlers()),this.listenTo(this.model,"change",this.render),this.registerContactEventHandlers(),qc.trigger("userDetailsModalInitialized",this.model)},toHTML(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{};return bv(Object.assign(this.model.toJSON(),n,{_converse:Lc,allow_contact_removal:qc.settings.get("allow_contact_removal"),display_name:this.model.getDisplayName(),is_roster_contact:void 0!==this.model.contact,removeContact:e=>this.removeContact(e),view:this,utils:jv}))},registerContactEventHandlers(){void 0!==this.model.contact&&(this.listenTo(this.model.contact,"change",this.render),this.listenTo(this.model.contact.vcard,"change",this.render),this.model.contact.on("destroy",()=>{delete this.model.contact,this.render()}))},async refreshContact(e){e&&e.preventDefault&&e.preventDefault();const t=this.el.querySelector(".fa-refresh");jv.addClass("fa-spin",t);try{await qc.vcard.update(this.model.contact.vcard,!0)}catch(e){Pn.fatal(e),this.alert(Ed("Sorry, something went wrong while trying to refresh"),"danger")}jv.removeClass("fa-spin",t)},removeContact(e){if(e&&e.preventDefault&&e.preventDefault(),!qc.settings.get("allow_contact_removal"))return;!0===confirm(Ed("Are you sure you want to remove this contact?"))&&(this.modal.hide(),setTimeout(()=>{this.model.contact.removeFromRoster(()=>this.model.contact.destroy(),e=>{Pn.error(e),qc.alert("error",Ed("Error"),[Ed("Sorry, there was an error while trying to remove %1$s as a contact.",this.model.contact.getDisplayName())])})},1))}}),qc.listen.on("chatBoxViewsInitialized",()=>{const e=Lc.chatboxviews;Lc.chatboxes.on("add",async t=>{e.get(t.get("id"))||t.get("type")!==Lc.PRIVATE_CHAT_TYPE||(await t.initialized,e.add(t.get("id"),new Lc.ChatBoxView({model:t})))})}),qc.listen.on("windowStateChanged",(function(e){Lc.chatboxviews&&Lc.chatboxviews.forEach(t=>{"controlbox"!==t.model.get("id")&&t.onWindowStateChanged(e.state)})})),qc.listen.on("connected",()=>qc.disco.own.features.add(Av.NS.SPOILER)),Object.assign(qc,{chatviews:{get:e=>void 0===e?Object.values(Lc.chatboxviews.getAll()):"string"==typeof e?Lc.chatboxviews.get(e):e.map(e=>Lc.chatboxviews.get(e))}})}});let kv=0;function Nv(e){Ov=e}function Iv(){Ov=null,kv=0}const Mv=Symbol("haunted.phase"),Rv=Symbol("haunted.hook"),Dv=Symbol("haunted.update"),Pv=Symbol("haunted.commit"),Lv=Symbol("haunted.effects"),zv=Symbol("haunted.layoutEffects");class Fv{constructor(e,t){this.update=e,this.host=t,this[Rv]=new Map,this[Lv]=[],this[zv]=[]}run(e){Nv(this);let t=e();return Iv(),t}_runEffects(e){let t=this[e];Nv(this);for(let e of t)e.call(this);Iv()}runEffects(){this._runEffects(Lv)}runLayoutEffects(){this._runEffects(zv)}teardown(){this[Rv].forEach(e=>{"function"==typeof e.teardown&&e.teardown()})}}const Bv=Promise.resolve().then.bind(Promise.resolve());function qv(){let e,t=[];function n(){e=null;let n=t;t=[];for(var r=0,i=n.length;r<i;r++)n[r]()}return function(r){t.push(r),null==e&&(e=Bv(n))}}const Hv=qv(),Uv=qv();class $v{constructor(e,t){this.renderer=e,this.host=t,this.state=new Fv(this.update.bind(this),t),this[Mv]=null,this._updateQueued=!1}update(){this._updateQueued||(Hv(()=>{let e=this.handlePhase(Dv);Uv(()=>{this.handlePhase(Pv,e),Uv(()=>{this.handlePhase(Lv)})}),this._updateQueued=!1}),this._updateQueued=!0)}handlePhase(e,t){switch(this[Mv]=e,e){case Pv:return this.commit(t),void this.runEffects(zv);case Dv:return this.render();case Lv:return this.runEffects(Lv)}this[Mv]=null}render(){return this.state.run(()=>this.renderer.call(this.host,this.host))}runEffects(e){this.state._runEffects(e)}teardown(){this.state.teardown()}}function Wv(e){class t extends $v{constructor(e,t,n){super(e,n||t),this.frag=t}commit(t){e(t,this.frag)}}return function(e,n,r){const i=(r||n||{}).baseElement||HTMLElement,{observedAttributes:s=[],useShadowDOM:o=!0,shadowRootInit:a={}}=r||n||{};class c extends i{constructor(){super(),!1===o?this._scheduler=new t(e,this):(this.attachShadow({mode:"open",...a}),this._scheduler=new t(e,this.shadowRoot,this))}static get observedAttributes(){return e.observedAttributes||s||[]}connectedCallback(){this._scheduler.update()}disconnectedCallback(){this._scheduler.teardown()}attributeChangedCallback(e,t,n){if(t===n)return;let r=""===n||n;Reflect.set(this,((e="")=>e.replace(/-+([a-z])?/g,(e,t)=>t?t.toUpperCase():""))(e),r)}}const l=new Proxy(i.prototype,{getPrototypeOf:e=>e,set(e,t,n,r){let i;if(t in e){if(i=Object.getOwnPropertyDescriptor(e,t),i&&i.set)return i.set.call(r,n),!0;Reflect.set(e,t,n)}return i="symbol"==typeof t||"_"===t[0]?{enumerable:!0,configurable:!0,writable:!0,value:n}:function(e){let t=e;return Object.freeze({enumerable:!0,configurable:!0,get:()=>t,set(e){t=e,this._scheduler.update()}})}(n),Object.defineProperty(r,t,i),i.set&&i.set.call(r,n),!0}});return Object.setPrototypeOf(c.prototype,l),c}}class Vv{constructor(e,t){this.id=e,this.state=t}}function Gv(e,...t){let n=kv++,r=Ov[Rv],i=r.get(n);return i||(i=new e(n,Ov,...t),r.set(n,i)),i.update(...t)}function Jv(e){return Gv.bind(null,e)}function Xv(e){return Jv(class extends Vv{constructor(t,n,r,i){super(t,n),e(n,this)}update(e,t){this.callback=e,this.lastValues=this.values,this.values=t}call(){this.values&&!this.hasChanged()||this.run()}run(){this.teardown(),this._teardown=this.callback.call(this.state)}teardown(){"function"==typeof this._teardown&&this._teardown()}hasChanged(){return!this.lastValues||this.values.some((e,t)=>this.lastValues[t]!==e)}})}function Qv(e,t){e[Lv].push(t)}Xv(Qv);const Yv=Jv(class extends Vv{constructor(e,t,n){super(e,t),this._updater=this._updater.bind(this),this._ranEffect=!1,this._unsubscribe=null,Qv(t,this)}update(e){if(this.state.virtual)throw new Error("can't be used with virtual components");return this.Context!==e&&(this._subscribe(e),this.Context=e),this.value}call(){this._ranEffect||(this._ranEffect=!0,this._unsubscribe&&this._unsubscribe(),this._subscribe(this.Context),this.state.update())}_updater(e){this.value=e,this.state.update()}_subscribe(e){const t={Context:e,callback:this._updater};this.state.host.dispatchEvent(new CustomEvent("haunted.context",{detail:t,bubbles:!0,cancelable:!0,composed:!0}));const{unsubscribe:n,value:r}=t;this.value=n?r:e.defaultValue,this._unsubscribe=n}teardown(){this._unsubscribe&&this._unsubscribe()}});Jv(class extends Vv{constructor(e,t,n,r){super(e,t),this.value=n(),this.values=r}update(e,t){return this.hasChanged(t)&&(this.values=t,this.value=e()),this.value}hasChanged(e=[]){return e.some((e,t)=>this.values[t]!==e)}});Xv((function(e,t){e[zv].push(t)})),Jv(class extends Vv{constructor(e,t,n){super(e,t),this.updater=this.updater.bind(this),"function"==typeof n&&(n=n()),this.makeArgs(n)}update(){return this.args}updater(e){if("function"==typeof e){const t=e,[n]=this.args;e=t(n)}this.makeArgs(e),this.state.update()}makeArgs(e){this.args=Object.freeze([e,this.updater])}}),Jv(class extends Vv{constructor(e,t,n,r,i){super(e,t),this.dispatch=this.dispatch.bind(this),this.currentState=void 0!==i?i(r):r}update(e){return this.reducer=e,[this.currentState,this.dispatch]}dispatch(e){this.currentState=this.reducer(this.currentState,e),this.state.update()}});const Kv=Array.prototype.includes;const{component:Zv,createContext:e_}=function({render:e}){const t=Wv(e),n=function(e){return t=>{const n={Provider:class extends HTMLElement{constructor(){super(),this.listeners=new Set,this.addEventListener("haunted.context",this)}disconnectedCallback(){this.removeEventListener("haunted.context",this)}handleEvent(e){const{detail:t}=e;t.Context===n&&(t.value=this.value,t.unsubscribe=this.unsubscribe.bind(this,t.callback),this.listeners.add(t.callback),e.stopPropagation())}unsubscribe(e){this.listeners.delete(e)}set value(e){this._value=e;for(let t of this.listeners)t(e)}get value(){return this._value}},Consumer:e((function({render:e}){return e(Yv(n))})),defaultValue:t};return n}}(t);return{component:t,createContext:n}}({render:Wa});!function(){const e=new WeakMap,t=new WeakMap;class n extends $v{constructor(e,t){super(e,t),this.state.virtual=!0}render(){return this.state.run(()=>this.renderer.apply(this.host,this.args))}commit(e){this.host.setValue(e),this.host.commit()}teardown(){super.teardown();let n=t.get(this);e.delete(n)}}}();function t_(){const e=i_(['\n <p class="brand-subtitle">','</p>\n <p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://conversejs.org">Open Source</a> XMPP chat client brought to you by <a target="_blank" rel="nofollow" href="https://opkode.com">Opkode</a> </p>\n <p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages">Translate</a> it into your own language</p>']);return t_=function(){return e},e}function n_(){const e=i_(['<p class="byline">messaging freedom</p>']);return n_=function(){return e},e}function r_(){const e=i_(['\n <a class="brand-heading" href="https://conversejs.org" target="_blank" rel="noopener">\n <span class="brand-name-wrapper ','">\n <svg class="converse-svg-logo"\n xmlns:svg="http://www.w3.org/2000/svg"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n viewBox="0 0 364 364">\n <title>Converse</title>\n <g class="cls-1" id="g904">\n <g data-name="Layer 2">\n <g data-name="Layer 7">\n <path\n class="cls-3"\n d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" />\n <path\n class="cls-4"\n d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" />\n </g>\n </g>\n </g>\n </svg>\n <span class="brand-name">\n <span class="brand-name__text">converse<span class="subdued">.js</span></span>\n ',"\n </span>\n </span>\n </a>\n ","\n "]);return r_=function(){return e},e}function i_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function s_(){const e=a_(['<a class="chatbox-btn close-chatbox-button fa fa-times"></a>']);return s_=function(){return e},e}function o_(){const e=a_(['\n <div class="flyout box-flyout">\n <div class="chat-head controlbox-head">\n ','\n </div>\n <div class="controlbox-panes"></div>\n </div>']);return o_=function(){return e},e}function a_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}qc.elements.define("converse-brand-heading",Zv(e=>{const t="fullscreen"===qc.settings.get("view_mode");return Ga(r_(),t?"brand-name-wrapper--fullscreen":"",t?Ga(n_()):"",t?Ga(t_(),e.version_name):"")},{useShadowDOM:!1}));var c_=n(136),l_=n.n(c_);function u_(){const e=__(['\n <converse-brand-heading></converse-brand-heading>\n <form id="converse-login" class="converse-form" method="post">\n <div class="conn-feedback fade-in ','">\n <p class="feedback-subject">','</p>\n <p class="feedback-message ','">',"</p>\n </div>\n ","\n </form>\n"]);return u_=function(){return e},e}function d_(){const e=__(["<p>","</p>"]);return d_=function(){return e},e}function h_(){const e=__(['<input class="btn btn-primary login-anon" type="submit" value="','">']);return h_=function(){return e},e}function f_(){const e=__(["\n ","\n ","\n ","\n "]);return f_=function(){return e},e}function p_(){const e=__(['\n <div class="form-group">\n <label for="converse-login-jid">',':</label>\n <input id="converse-login-jid"\n ?autofocus=','\n required\n class="form-control"\n type="text"\n name="jid"\n placeholder="','"/>\n </div>\n ',"\n ",'\n <fieldset class="buttons">\n <input class="btn btn-primary" type="submit" value="','"/>\n </fieldset>\n ',"\n "]);return p_=function(){return e},e}function g_(){const e=__(['\n <fieldset class="switch-form">\n <p>','</p>\n <p><a class="register-account toggle-register-login" href="#converse/register">',"</a></p>\n </fieldset>\n "]);return g_=function(){return e},e}function m_(){const e=__(['\n <div class="form-group">\n <label for="converse-login-password">','</label>\n <input id="converse-login-password" class="form-control" required="required" type="password" name="password" placeholder="','"/>\n </div>\n ']);return m_=function(){return e},e}function v_(){const e=__(['\n <div class="form-group form-check login-trusted">\n <input id="converse-login-trusted" type="checkbox" class="form-check-input" name="trusted" ?checked=','>\n <label for="converse-login-trusted" class="form-check-label login-trusted__desc">','</label>\n <i class="fa fa-info-circle" data-toggle="popover"\n data-title="Trusted device?"\n data-content="','"></i>\n </div>\n ']);return v_=function(){return e},e}function __(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const b_=e=>{const t=Ed("Log in"),n=Ed("XMPP Address");return Ga(p_(),n,!!qc.settings.get("auto_focus"),e.placeholder_username,e.authentication!==e.EXTERNAL?(()=>{const e=Ed("Password");return Ga(m_(),e,e)})():"",e.show_trust_checkbox?(e=>{const t=Ed("To improve performance, we cache your data in this browser. Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. It's important that you explicitly log out, otherwise not all cached data might be deleted. Please note, when using an untrusted device, OMEMO encryption is NOT available."),n=Ed("This is a trusted device");return Ga(v_(),e._converse.config.get("trusted"),n,t)})(e):"",t,(e=>{const t=e._converse;return t.allow_registration&&!qc.settings.get("auto_login")&&t.pluggable.plugins["converse-register"].enabled(t)})(e)?(()=>{const e=Ed("Create an account"),t=Ed("Don't have a chat account?");return Ga(g_(),t,e)})():"")};var y_=e=>Ga(u_(),e.conn_feedback_subject?e.conn_feedback_class:"hidden",e.conn_feedback_subject,e.conn_feedback_message?"":"hidden",e.conn_feedback_message,"CONNECTING"===e._converse.CONNECTION_STATUS[e.connection_status]?qf({classes:"hor_centered"}):(e=>{const t=Ed("Disconnected"),n=Ed("Click here to log in anonymously");return Ga(f_(),e.authentication==e.LOGIN||e.authentication==e.EXTERNAL?b_(e):"",e.authentication==e.ANONYMOUS?Ga(h_(),n):"",e.authentication==e.PREBIND?Ga(d_(),t):"")})(e));function w_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S_(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}
/**
* @module converse-controlbox
* @copyright 2020, the Converse.js contributors
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment