<commit_before>/*!
 * at.js - 1.5.5 / ElkArte
 * Copyright (c) 2022 chord.luo <<EMAIL>>;
 * Homepage: https://ichord.github.com/At.js
 * License: MIT
 */
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t(require("jquery")):t(jQuery)}(function(a){var i,s;function t(t){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=a(t),this.setupRootElement(),this.listen()}s={ESC:27,TAB:9,ENTER:13,CTRL:17,A:65,P:80,N:78,LEFT:37,UP:38,RIGHT:39,DOWN:40,BACKSPACE:8,SPACE:32},i={beforeSave:function(t){return r.arrayToDefaultHash(t)},matcher:function(t,e,i,n){var r;return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i&&(t="(?:^|\\s)"+t),i=decodeURI("%C3%80"),r=decodeURI("%C3%BF"),(i=new RegExp(t+"([A-Za-z"+i+"-"+r+"0-9_"+(n?" ":"")+"'.+-]*)$|"+t+"([^\\x00-\\xff]*)$","gi").exec(e))?i[2]||i[1]:null},filter:function(t,e,i){for(var n,r=[],o=0,s=e.length;o<s;o++)n=e[o],~new String(n[i]).toLowerCase().indexOf(t.toLowerCase())&&r.push(n);return r},remoteFilter:null,sorter:function(t,e,i){var n,r,o,s;if(!t)return e;for(n=[],r=0,s=e.length;r<s;r++)(o=e[r]).atwho_order=new String(o[i]).toLowerCase().indexOf(t.toLowerCase()),-1<o.atwho_order&&n.push(o);return n.sort(function(t,e){return t.atwho_order-e.atwho_order})},tplEval:function(t,n){var e=t;try{return(e="string"!=typeof t?t(n):e).replace(/\$\{([^\}]*)\}/g,function(t,e,i){return n[e]})}catch(t){return""}},highlighter:function(t,e){return e?(e=new RegExp(">\\s*([^<]*?)("+e.replace("+","\\+")+")([^<]*)\\s*<","ig"),t.replace(e,function(t,e,i,n){return"> "+e+"<strong>"+i+"</strong>"+n+" <"})):t},beforeInsert:function(t,e,i){return t},beforeReposition:function(t){return t},afterMatchFailed:function(t,e){}},t.prototype.createContainer=function(t){var e;return null!=(e=this.$el)&&e.remove(),a(t.body).append(this.$el=a("<div class='atwho-container'></div>"))},t.prototype.setupRootElement=function(e,t){if(null==t&&(t=!1),e)this.window=e.contentWindow,this.document=e.contentDocument||this.window.document,this.iframe=e;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(t){if(e=t,this.iframe=null,a.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+e)}}return this.createContainer((this.iframeAsRoot=t)?this.document:document)},t.prototype.controller=function(t){var e,i,n,r;if(this.aliasMaps[t])i=this.controllers[this.aliasMaps[t]];else for(n in r=this.controllers)if(e=r[n],n===t){i=e;break}return i||this.controllers[this.currentFlag]},t.prototype.setContextFor=function(t){return this.currentFlag=t,this},t.prototype.reg=function(t,e){var i=(i=this.controllers)[t]||(i[t]=new(this.$inputor.is("[contentEditable]")?u:d)(this,t));return e.alias&&(this.aliasMaps[e.alias]=t),i.init(e),this},t.prototype.listen=function(){return this.$inputor.on("compositionstart",(a=this,function(t){var e;return null!=(e=a.controller())&&e.view.hide(),a.isComposing=!0,null})).on("compositionend",(s=this,function(t){return s.isComposing=!1,setTimeout(function(t){return s.dispatch(t)}),null})).on("keyup.atwhoInner",(o=this,function(t){return o.onKeyup(t)})).on("keydown.atwhoInner",(n=this,function(t){return n.onKeydown(t)})).on("blur.atwhoInner",(i=this,function(t){var e;if(e=i.controller())return e.expectedQueryCBId=null,e.view.hide(t,e.getOpt("displayTimeout"))})).on("click.atwhoInner",(e=this,function(t){return e.dispatch(t)})).on("scroll.atwhoInner",(r=this,function(){var n=r.$inputor.scrollTop();return function(t){var e,i=t.target.scrollTop;return n!==i&&null!=(e=r.controller())&&e.view.hide(t),n=i,!0}}()));var r,e,i,n,o,s,a},t.prototype.shutdown=function(){var t,e=this.controllers;for(t in e)e[t].destroy(),delete this.controllers[t];return this.$inputor.off(".atwhoInner"),this.$el.remove()},t.prototype.dispatch=function(t){var e,i,n,r;if(void 0!==t){for(e in r=[],n=this.controllers)i=n[e],r.push(i.lookUp(t));return r}},t.prototype.onKeyup=function(t){var e;switch(t.keyCode){case s.ESC:t.preventDefault(),null!=(e=this.controller())&&e.view.hide();break;case s.DOWN:case s.UP:case s.CTRL:case s.ENTER:a.noop();break;case s.P:case s.N:t.ctrlKey||this.dispatch(t);break;default:this.dispatch(t)}},t.prototype.onKeydown=function(t){var e,i=null!=(e=this.controller())?e.view:void 0;if(i&&i.visible())switch(t.keyCode){case s.ESC:t.preventDefault(),i.hide(t);break;case s.UP:t.preventDefault(),i.prev();break;case s.DOWN:t.preventDefault(),i.next();break;case s.P:if(!t.ctrlKey)return;t.preventDefault(),i.prev();break;case s.N:if(!t.ctrlKey)return;t.preventDefault(),i.next();break;case s.TAB:case s.ENTER:case s.SPACE:if(!i.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&t.keyCode===s.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&t.keyCode===s.TAB)return;i.highlighted()?(t.preventDefault(),i.choose(t)):i.hide(t);break;default:a.noop()}};var o=t,n=[].slice;function e(t,e){this.app=t,this.at=e,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.expectedQueryCBId=null,this.setting=null,this.query=null,this.pos=0,this.range=null,0===(this.$el=a("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=a("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new c(this),this.view=new p(this)}e.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},e.prototype.init=function(t){return this.setting=a.extend({},this.setting||a.fn.atwho.default,t),this.view.init(),this.model.reload(this.setting.data)},e.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},e.prototype.callDefault=function(){var e=arguments[0],t=2<=arguments.length?n.call(arguments,1):[];try{return i[e].apply(this,t)}catch(t){return a.error(t+" Or maybe At.js doesn't have function "+e)}},e.prototype.trigger=function(t,e){var i;return(e=null==e?[]:e).push(this),i=this.getOpt("alias"),this.$inputor.trigger(i?t+"-"+i+".atwho":t+".atwho",e)},e.prototype.callbacks=function(t){return this.getOpt("callbacks")[t]||i[t]},e.prototype.getOpt=function(t,e){try{return this.setting[t]}catch(t){return null}},e.prototype.insertContentFor=function(t){var e=this.getOpt("insertTpl"),t=a.extend({},t.data("item-data"),{"atwho-at":this.at});return this.callbacks("tplEval").call(this,e,t,"onInsert")},e.prototype.renderView=function(t){var e=this.getOpt("searchKey");return t=this.callbacks("sorter").call(this,this.query.text,t.slice(0,1001),e),this.view.render(t.slice(0,this.getOpt("limit")))},e.arrayToDefaultHash=function(t){var e,i,n,r;if(!a.isArray(t))return t;for(r=[],e=0,n=t.length;e<n;e++)i=t[e],a.isPlainObject(i)?r.push(i):r.push({name:i});return r},e.prototype.lookUp=function(t){var e;if((!t||"click"!==t.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(t=this.catchQuery(t))?(this.app.setContextFor(this.at),(e=this.getOpt("delay"))?this._delayLookUp(t,e):this._lookUp(t)):this.expectedQueryCBId=null,t},e.prototype._delayLookUp=function(t,e){var i,n,r=Date.now?Date.now():(new Date).getTime();return this.previousCallTime||(this.previousCallTime=r),0<(i=e-(r-this.previousCallTime))&&i<e?(this.previousCallTime=r,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout((n=this,function(){return n.previousCallTime=0,n.delayedCallTimeout=null,n._lookUp(t)}),e)):(this._stopDelayedCall(),this.previousCallTime!==r&&(this.previousCallTime=0),this._lookUp(t))},e.prototype._stopDelayedCall=function(){if(this.delayedCallTimeout)return clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null},e.prototype._generateQueryCBId=function(){return{}},e.prototype._lookUp=function(t){var e=function(t,e){if(t===this.expectedQueryCBId)return e&&0<e.length?this.renderView(this.constructor.arrayToDefaultHash(e)):this.view.hide()};return this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(t.text,a.proxy(e,this,this.expectedQueryCBId))};var r=e,l={}.hasOwnProperty;function h(){return h.__super__.constructor.apply(this,arguments)}(function(t,e){for(var i in e)l.call(e,i)&&(t[i]=e[i]);function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype})(h,r),h.prototype.catchQuery=function(){var t=this.$inputor.val(),e=this.$inputor.caret("pos",{iframe:this.app.iframe}),t=t.slice(0,e),t=this.callbacks("matcher").call(this,this.at,t,this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),i="string"==typeof t;if(!(i&&t.length<this.getOpt("minLen",0)))return i&&t.length<=this.getOpt("maxLen",20)?(e=(i=e-t.length)+t.length,this.pos=i,this.trigger("matched",[this.at,(t={text:t,headPos:i,endPos:e}).text])):(t=null,this.view.hide()),this.query=t},h.prototype.rect=function(){var t,e;if(t=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return this.app.iframe&&!this.app.iframeAsRoot&&(e=a(this.app.iframe).offset(),t.left+=e.left,t.top+=e.top),e=this.app.document.selection?0:2,{left:t.left,top:t.top,bottom:t.top+t.height+e}},h.prototype.insert=function(t,e){var i=this.$inputor,n=i.val(),r=n.slice(0,Math.max(this.query.headPos-this.at.length,0)),o=""===(o=this.getOpt("suffix"))?o:o||" ",o=""+r+(t+=o)+n.slice(this.query.endPos||0);return i.val(o),i.caret("pos",r.length+t.length,{iframe:this.app.iframe}),i.is(":focus")||i.focus(),i.change()};var u,c,p,f,d=h,l={}.hasOwnProperty;function g(){return g.__super__.constructor.apply(this,arguments)}function y(t){this.context=t,this.at=this.context.at,this.storage=this.context.$inputor}function v(t){this.context=t,this.$el=a("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.$elUl=this.$el.children(),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}(function(t,e){for(var i in e)l.call(e,i)&&(t[i]=e[i]);function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype})(g,r),g.prototype._getRange=function(){var t=this.app.window.getSelection();if(0<t.rangeCount)return t.getRangeAt(0)},g.prototype._setRange=function(t,e,i){if((i=null==i?this._getRange():i)&&e)return e=a(e)[0],"after"===t?(i.setEndAfter(e),i.setStartAfter(e)):(i.setEndBefore(e),i.setStartBefore(e)),i.collapse(!1),this._clearRange(i)},g.prototype._clearRange=function(t){var e;if(null==t&&(t=this._getRange()),e=this.app.window.getSelection(),null==this.ctrl_a_pressed)return e.removeAllRanges(),e.addRange(t)},g.prototype._movingEvent=function(t){return"click"===t.type||(t=t.which)===s.RIGHT||t===s.LEFT||t===s.UP||t===s.DOWN},g.prototype._unwrap=function(t){var e;return(e=(t=a(t).unwrap().get(0)).nextSibling)&&e.nodeValue&&(t.nodeValue+=e.nodeValue,a(e).remove()),t},g.prototype.catchQuery=function(t){var e,i,n,r,o;if((o=this._getRange())&&o.collapsed){if(t.which===s.ENTER)return(e=a(o.startContainer).closest(".atwho-query")).contents().unwrap(),e.is(":empty")&&e.remove(),(e=a(".atwho-query",this.app.document)).text(e.text()).contents().last().unwrap(),void this._clearRange();if(/firefox/i.test(navigator.userAgent)){if(a(o.startContainer).is(this.$inputor))return void this._clearRange();t.which===s.BACKSPACE&&o.startContainer.nodeType===document.ELEMENT_NODE&&0<=(r=o.startOffset-1)?((i=o.cloneRange()).setStart(o.startContainer,r),a(i.cloneContents()).contents().last().is(".atwho-inserted")&&(r=a(o.startContainer).contents().get(r),this._setRange("after",a(r).contents().last()))):t.which===s.LEFT&&o.startContainer.nodeType===document.TEXT_NODE&&(r=a(o.startContainer.previousSibling)).is(".atwho-inserted")&&0===o.startOffset&&this._setRange("after",r.contents().last())}if(a(o.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),0<(e=a(".atwho-query",this.app.document)).length&&e.is(":empty")&&0===e.text().length&&e.remove(),this._movingEvent(t)||e.removeClass("atwho-inserted"),0<e.length)switch(t.which){case s.LEFT:return this._setRange("before",e.get(0),o),void e.removeClass("atwho-query");case s.RIGHT:return this._setRange("after",e.get(0).nextSibling,o),void e.removeClass("atwho-query")}return 0<e.length&&(r=e.attr("data-atwho-at-query"))&&(e.empty().html(r).attr("data-atwho-at-query",null),this._setRange("after",e.get(0),o)),(i=o.cloneRange()).setStart(o.startContainer,0),i="string"==typeof(r=this.callbacks("matcher").call(this,this.at,i.toString(),this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar"))),0===e.length&&i&&0<=(n=o.startOffset-this.at.length-r.length)&&(o.setStart(o.startContainer,n),e=a("<span/>",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),o.surroundContents(e.get(0)),(n=e.contents().last().get(0))&&(/firefox/i.test(navigator.userAgent)?(o.setStart(n,n.length),o.setEnd(n,n.length),this._clearRange(o)):this._setRange("after",n,o))),i&&r.length<this.getOpt("minLen",0)?void 0:i&&r.length<=this.getOpt("maxLen",20)?(this.trigger("matched",[this.at,(n={text:r,el:e}).text]),this.query=n):(this.view.hide(),this.query={el:e},0<=e.text().indexOf(this.at)&&(this._movingEvent(t)&&e.hasClass("atwho-inserted")?e.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,e)&&this._setRange("after",this._unwrap(e.text(e.text()).contents().first()))),null)}},g.prototype.rect=function(){var t,e=this.query.el.offset();if(e&&this.query.el[0].getClientRects().length)return this.app.iframe&&!this.app.iframeAsRoot&&(t=a(this.app.iframe).offset(),e.left+=t.left-this.$inputor.scrollLeft(),e.top+=t.top-this.$inputor.scrollTop()),e.bottom=e.top+this.query.el.height(),e},g.prototype.insert=function(t,e){var i;return this.$inputor.is(":focus")||this.$inputor.focus(),(i=this.getOpt("functionOverrides")).insert?i.insert.call(this,t,e):(i=""===(i=this.getOpt("suffix"))?i:i||" ",e=e.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(t).attr("data-atwho-at-query",""+e["atwho-at"]+this.query.text).attr("contenteditable","false"),(t=this._getRange())&&(this.query.el.length&&t.setEndAfter(this.query.el[0]),t.collapse(!1),t.insertNode(e=this.app.document.createTextNode(""+i)),this._setRange("after",e,t)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change())},u=g,y.prototype.destroy=function(){return this.storage.data(this.at,null)},y.prototype.saved=function(){return 0<this.fetch()},y.prototype.query=function(t,e){var i=this.fetch(),n=this.context.getOpt("searchKey");return i=this.context.callbacks("filter").call(this.context,t,i,n)||[],n=this.context.callbacks("remoteFilter"),0<i.length||!n&&0===i.length?e(i):n.call(this.context,t,e)},y.prototype.fetch=function(){return this.storage.data(this.at)||[]},y.prototype.save=function(t){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,t||[]))},y.prototype.load=function(t){if(!this.saved()&&t)return this._load(t)},y.prototype.reload=function(t){return this._load(t)},y.prototype._load=function(t){return"string"==typeof t?a.ajax(t,{dataType:"json"}).done((e=this,function(t){return e.save(t)})):this.save(t);var e},c=y,v.prototype.init=function(){var t=this.context.getOpt("alias")||this.context.at.charCodeAt(0),e=this.context.getOpt("headerTpl");return e&&1===this.$el.children().length&&this.$el.prepend(e),this.$el.attr({id:"at-view-"+t})},v.prototype.destroy=function(){return this.$el.remove()},v.prototype.bindEvent=function(){var e,i=this.$el.find("ul"),n=0,r=0;return i.on("mousemove.atwho-view","li",function(t){if((n!==t.clientX||r!==t.clientY)&&(n=t.clientX,r=t.clientY,!(t=a(t.currentTarget)).hasClass("cur")))return i.find(".cur").removeClass("cur"),t.addClass("cur")}).on("click.atwho-view","li",(e=this,function(t){return i.find(".cur").removeClass("cur"),a(t.currentTarget).addClass("cur"),e.choose(t),t.preventDefault()}))},v.prototype.visible=function(){return a.expr.filters.visible(this.$el[0])},v.prototype.highlighted=function(){return 0<this.$el.find(".cur").length},v.prototype.choose=function(t){var e,i;if((e=this.$el.find(".cur")).length&&(i=this.context.insertContentFor(e),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,i,e,t),e),this.context.trigger("inserted",[e,t]),this.hide(t)),this.context.getOpt("hideWithoutSuffix"))return this.stopShowing=!0},v.prototype.reposition=function(t){var e=this.context.app.iframeAsRoot?this.context.app.window:window;return t.bottom+this.$el.height()-a(e).scrollTop()>a(e).height()&&(t.bottom=t.top-this.$el.height()),t.left>(e=a(e).width()-this.$el.width()-5)&&(t.left=e),e={left:t.left,top:t.bottom},null!=(t=this.context.callbacks("beforeReposition"))&&t.call(this.context,e),this.$el.offset(e),this.context.trigger("reposition",[e])},v.prototype.next=function(){var t=this.$el.find(".cur").removeClass("cur").next();return(t=t.length?t:this.$el.find("li:first")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))},v.prototype.prev=function(){var t=this.$el.find(".cur").removeClass("cur").prev();return(t=t.length?t:this.$el.find("li:last")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))},v.prototype.scrollTop=function(t){var e=this.context.getOpt("scrollDuration");return e?this.$elUl.animate({scrollTop:t},e):this.$elUl.scrollTop(t)},v.prototype.show=function(){var t;if(!this.stopShowing)return this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(t=this.context.rect())?this.reposition(t):void 0;this.stopShowing=!1},v.prototype.hide=function(t,e){var i;if(this.visible())return isNaN(e)?(this.$el.hide(),this.context.trigger("hidden",[t])):(i=this,t=function(){return i.hide()},clearTimeout(this.timeoutID),this.timeoutID=setTimeout(t,e))},v.prototype.render=function(t){var e,i,n,r,o,s;if(a.isArray(t)&&0<t.length){for(this.$el.find("ul").empty(),e=this.$el.find("ul"),s=this.context.getOpt("displayTpl"),i=0,r=t.length;i<r;i++)n=t[i],n=a.extend({},n,{"atwho-at":this.context.at}),o=this.context.callbacks("tplEval").call(this.context,s,n,"onDisplay"),(o=a(this.context.callbacks("highlighter").call(this.context,o,this.context.query.text))).data("item-data",n),e.append(o);return this.show(),this.context.getOpt("highlightFirst")?e.find("li:first").addClass("cur"):void 0}this.hide()},p=v,f={load:function(t,e){if(t=this.controller(t))return t.model.load(e)},isSelecting:function(){var t;return!(null==(t=this.controller())||!t.view.visible())},hide:function(){var t;return null!=(t=this.controller())?t.view.hide():void 0},reposition:function(){var t;if(t=this.controller())return t.view.reposition(t.rect())},setIframe:function(t,e){return this.setupRootElement(t,e),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},a.fn.atwho=function(i){var n=arguments,r=null;return this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var t,e;return(e=(t=a(this)).data("atwho"))||t.data("atwho",e=new o(this)),"object"!=typeof i&&i?f[i]&&e?r=f[i].apply(e,Array.prototype.slice.call(n,1)):a.error("Method "+i+" does not exist on jQuery.atwho"):e.reg(i.at,i)}),null!=r?r:this},a.fn.atwho.default={at:void 0,alias:void 0,data:null,displayTpl:"<li>${name}</li>",insertTpl:"${atwho-at}${name}",headerTpl:null,callbacks:i,functionOverrides:{},searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,acceptSpaceBar:!1,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},a.fn.atwho.debug=!1});<commit_msg>! The wrong min file was committed<commit_after>/*!
 * at.js - 1.5.5 / ElkArte
 * Copyright (c) 2022 chord.luo <<EMAIL>>;
 * Homepage: https://ichord.github.com/At.js
 * License: MIT
 */
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t(require("jquery")):t(jQuery)}(function(a){var i,s;function t(t){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=a(t),this.setupRootElement(),this.listen()}s={ESC:27,TAB:9,ENTER:13,CTRL:17,A:65,P:80,N:78,LEFT:37,UP:38,RIGHT:39,DOWN:40,BACKSPACE:8,SPACE:32},i={beforeSave:function(t){return n.arrayToDefaultHash(t)},matcher:function(t,e,i,r){var n;return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i&&(t="(?:^|\\s)"+t),i=decodeURI("%C3%80"),n=decodeURI("%C3%BF"),(i=new RegExp(t+"([A-Za-z"+i+"-"+n+"0-9_"+(r?" ":"")+"'.+-]*)$|"+t+"([^\\x00-\\xff]*)$","gi").exec(e))?i[2]||i[1]:null},filter:function(t,e,i){for(var r,n=[],o=0,s=e.length;o<s;o++)r=e[o],~new String(r[i]).toLowerCase().indexOf(t.toLowerCase())&&n.push(r);return n},remoteFilter:null,sorter:function(t,e,i){var r,n,o,s;if(!t)return e;for(r=[],n=0,s=e.length;n<s;n++)(o=e[n]).atwho_order=new String(o[i]).toLowerCase().indexOf(t.toLowerCase()),-1<o.atwho_order&&r.push(o);return r.sort(function(t,e){return t.atwho_order-e.atwho_order})},tplEval:function(t,r){var e=t;try{return(e="string"!=typeof t?t(r):e).replace(/\$\{([^\}]*)\}/g,function(t,e,i){return r[e]})}catch(t){return""}},highlighter:function(t,e){return e?(e=new RegExp(">\\s*([^<]*?)("+e.replace("+","\\+")+")([^<]*)\\s*<","ig"),t.replace(e,function(t,e,i,r){return"> "+e+"<strong>"+i+"</strong>"+r+" <"})):t},beforeInsert:function(t,e,i){return t},beforeReposition:function(t){return t},afterMatchFailed:function(t,e){}},t.prototype.createContainer=function(t){var e;return null!=(e=this.$el)&&e.remove(),a(t.body).append(this.$el=a("<div class='atwho-container'></div>"))},t.prototype.setupRootElement=function(e,t){if(null==t&&(t=!1),e)this.window=e.contentWindow,this.document=e.contentDocument||this.window.document,this.iframe=e;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(t){if(e=t,this.iframe=null,a.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+e)}}return this.createContainer((this.iframeAsRoot=t)?this.document:document)},t.prototype.controller=function(t){var e,i,r,n;if(this.aliasMaps[t])i=this.controllers[this.aliasMaps[t]];else for(r in n=this.controllers)if(e=n[r],r===t){i=e;break}return i||this.controllers[this.currentFlag]},t.prototype.setContextFor=function(t){return this.currentFlag=t,this},t.prototype.reg=function(t,e){var i=(i=this.controllers)[t]||(i[t]=new(this.$inputor.is("[contentEditable]")?u:d)(this,t));return e.alias&&(this.aliasMaps[e.alias]=t),i.init(e),this},t.prototype.listen=function(){return this.$inputor.on("compositionstart",(a=this,function(t){var e;return null!=(e=a.controller())&&e.view.hide(),a.isComposing=!0,null})).on("compositionend",(s=this,function(t){return s.isComposing=!1,setTimeout(function(){return s.dispatch(t)}),null})).on("keyup.atwhoInner",(o=this,function(t){return o.onKeyup(t)})).on("keydown.atwhoInner",(r=this,function(t){return r.onKeydown(t)})).on("blur.atwhoInner",(i=this,function(t){var e;if(e=i.controller())return e.expectedQueryCBId=null,e.view.hide(t,e.getOpt("displayTimeout"))})).on("click.atwhoInner",(e=this,function(t){return e.dispatch(t)})).on("scroll.atwhoInner",(n=this,function(){var r=n.$inputor.scrollTop();return function(t){var e,i=t.target.scrollTop;return r!==i&&null!=(e=n.controller())&&e.view.hide(t),r=i,!0}}()));var n,e,i,r,o,s,a},t.prototype.shutdown=function(){var t,e=this.controllers;for(t in e)e[t].destroy(),delete this.controllers[t];return this.$inputor.off(".atwhoInner"),this.$el.remove()},t.prototype.dispatch=function(t){var e,i,r,n;if(void 0!==t){for(e in n=[],r=this.controllers)i=r[e],n.push(i.lookUp(t));return n}},t.prototype.onKeyup=function(t){var e;switch(t.keyCode){case s.ESC:t.preventDefault(),null!=(e=this.controller())&&e.view.hide();break;case s.DOWN:case s.UP:case s.CTRL:a.noop();break;case s.P:case s.N:t.ctrlKey||this.dispatch(t);break;default:this.dispatch(t)}},t.prototype.onKeydown=function(t){var e,i=null!=(e=this.controller())?e.view:void 0;if(i&&i.visible())switch(t.keyCode){case s.ESC:t.preventDefault(),i.hide(t);break;case s.UP:t.preventDefault(),i.prev();break;case s.DOWN:t.preventDefault(),i.next();break;case s.P:if(!t.ctrlKey)return;t.preventDefault(),i.prev();break;case s.N:if(!t.ctrlKey)return;t.preventDefault(),i.next();break;case s.TAB:case s.ENTER:case s.SPACE:if(!i.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&t.keyCode===s.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&t.keyCode===s.TAB)return;i.highlighted()?(t.preventDefault(),i.choose(t)):i.hide(t);break;default:a.noop()}};var o=t,r=[].slice;function e(t,e){this.app=t,this.at=e,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.expectedQueryCBId=null,this.setting=null,this.query=null,this.pos=0,this.range=null,0===(this.$el=a("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=a("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new c(this),this.view=new p(this)}e.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},e.prototype.init=function(t){return this.setting=a.extend({},this.setting||a.fn.atwho.default,t),this.view.init(),this.model.reload(this.setting.data)},e.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},e.prototype.callDefault=function(){var e=arguments[0],t=2<=arguments.length?r.call(arguments,1):[];try{return i[e].apply(this,t)}catch(t){return a.error(t+" Or maybe At.js doesn't have function "+e)}},e.prototype.trigger=function(t,e){var i;return(e=null==e?[]:e).push(this),i=this.getOpt("alias"),this.$inputor.trigger(i?t+"-"+i+".atwho":t+".atwho",e)},e.prototype.callbacks=function(t){return this.getOpt("callbacks")[t]||i[t]},e.prototype.getOpt=function(t,e){try{return this.setting[t]}catch(t){return null}},e.prototype.insertContentFor=function(t){var e=this.getOpt("insertTpl"),t=a.extend({},t.data("item-data"),{"atwho-at":this.at});return this.callbacks("tplEval").call(this,e,t,"onInsert")},e.prototype.renderView=function(t){var e=this.getOpt("searchKey");return t=this.callbacks("sorter").call(this,this.query.text,t.slice(0,2001),e),this.view.render(t.slice(0,this.getOpt("limit")))},e.arrayToDefaultHash=function(t){var e,i,r,n;if(!a.isArray(t))return t;for(n=[],e=0,r=t.length;e<r;e++)i=t[e],a.isPlainObject(i)?n.push(i):n.push({name:i});return n},e.prototype.lookUp=function(t){var e;if((!t||"click"!==t.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(t=this.catchQuery(t))?(this.app.setContextFor(this.at),(e=this.getOpt("delay"))?this._delayLookUp(t,e):this._lookUp(t)):this.expectedQueryCBId=null,t},e.prototype._delayLookUp=function(t,e){var i,r,n=Date.now?Date.now():(new Date).getTime();return this.previousCallTime||(this.previousCallTime=n),0<(i=e-(n-this.previousCallTime))&&i<e?(this.previousCallTime=n,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout((r=this,function(){return r.previousCallTime=0,r.delayedCallTimeout=null,r._lookUp(t)}),e)):(this._stopDelayedCall(),this.previousCallTime!==n&&(this.previousCallTime=0),this._lookUp(t))},e.prototype._stopDelayedCall=function(){if(this.delayedCallTimeout)return clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null},e.prototype._generateQueryCBId=function(){return{}},e.prototype._lookUp=function(t){var e=function(t,e){if(t===this.expectedQueryCBId)return e&&0<e.length?this.renderView(this.constructor.arrayToDefaultHash(e)):this.view.hide()};return this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(t.text,a.proxy(e,this,this.expectedQueryCBId))};var n=e,h={}.hasOwnProperty;function l(){return l.__super__.constructor.apply(this,arguments)}(function(t,e){for(var i in e)h.call(e,i)&&(t[i]=e[i]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype})(l,n),l.prototype.catchQuery=function(){var t=this.$inputor.val(),e=this.$inputor.caret("pos",{iframe:this.app.iframe}),t=t.slice(0,e),t=this.callbacks("matcher").call(this,this.at,t,this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),i="string"==typeof t;if(!(i&&t.length<this.getOpt("minLen",0)))return i&&t.length<=this.getOpt("maxLen",20)?(e=(i=e-t.length)+t.length,this.pos=i,this.trigger("matched",[this.at,(t={text:t,headPos:i,endPos:e}).text])):(t=null,this.view.hide()),this.query=t},l.prototype.rect=function(){var t,e;if(t=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return this.app.iframe&&!this.app.iframeAsRoot&&(e=a(this.app.iframe).offset(),t.left+=e.left,t.top+=e.top),e=this.app.document.selection?0:2,{left:t.left,top:t.top,bottom:t.top+t.height+e}},l.prototype.insert=function(t,e){var i=this.$inputor,r=i.val(),n=r.slice(0,Math.max(this.query.headPos-this.at.length,0)),o=""===(o=this.getOpt("suffix"))?o:o||" ",o=""+n+(t+=o)+r.slice(this.query.endPos||0);return i.val(o),i.caret("pos",n.length+t.length,{iframe:this.app.iframe}),i.is(":focus")||i.focus(),i.change()};var u,c,p,f,d=l,h={}.hasOwnProperty;function g(){return g.__super__.constructor.apply(this,arguments)}function y(t){this.context=t,this.at=this.context.at,this.storage=this.context.$inputor}function v(t){this.context=t,this.$el=a("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.$elUl=this.$el.children(),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}(function(t,e){for(var i in e)h.call(e,i)&&(t[i]=e[i]);function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype})(g,n),g.prototype._getRange=function(){var t=this.app.window.getSelection();if(0<t.rangeCount)return t.getRangeAt(0)},g.prototype._setRange=function(t,e,i){if((i=null==i?this._getRange():i)&&e)return e=a(e)[0],"after"===t?(i.setEndAfter(e),i.setStartAfter(e)):(i.setEndBefore(e),i.setStartBefore(e)),i.collapse(!1),this._clearRange(i)},g.prototype._clearRange=function(t){var e;if(null==t&&(t=this._getRange()),e=this.app.window.getSelection(),null==this.ctrl_a_pressed)return e.removeAllRanges(),e.addRange(t)},g.prototype._movingEvent=function(t){return"click"===t.type||(t=t.which)===s.RIGHT||t===s.LEFT||t===s.UP||t===s.DOWN},g.prototype._unwrap=function(t){var e;return(e=(t=a(t).unwrap().get(0)).nextSibling)&&e.nodeValue&&(t.nodeValue+=e.nodeValue,a(e).remove()),t},g.prototype.catchQuery=function(t){var e,i,r,n,o;if((o=this._getRange())&&o.collapsed&&t){if(t.which===s.ENTER)return(e=a(o.startContainer).closest(".atwho-query")).contents().unwrap(),e.is(":empty")&&e.remove(),(e=a(".atwho-query",this.app.document)).text(e.text()).contents().last().unwrap(),void this._clearRange();if(/firefox/i.test(navigator.userAgent)){if(a(o.startContainer).is(this.$inputor))return void this._clearRange();t.which===s.BACKSPACE&&o.startContainer.nodeType===document.ELEMENT_NODE&&0<=(n=o.startOffset-1)?((i=o.cloneRange()).setStart(o.startContainer,n),a(i.cloneContents()).contents().last().is(".atwho-inserted")&&(n=a(o.startContainer).contents().get(n),this._setRange("after",a(n).contents().last()))):t.which===s.LEFT&&o.startContainer.nodeType===document.TEXT_NODE&&(n=a(o.startContainer.previousSibling)).is(".atwho-inserted")&&0===o.startOffset&&this._setRange("after",n.contents().last())}if(a(o.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),0<(e=a(".atwho-query",this.app.document)).length&&e.is(":empty")&&0===e.text().length&&e.remove(),this._movingEvent(t)||e.removeClass("atwho-inserted"),0<e.length)switch(t.which){case s.LEFT:return this._setRange("before",e.get(0),o),void e.removeClass("atwho-query");case s.RIGHT:return this._setRange("after",e.get(0).nextSibling,o),void e.removeClass("atwho-query")}return 0<e.length&&(n=e.attr("data-atwho-at-query"))&&(e.empty().html(n).attr("data-atwho-at-query",null),this._setRange("after",e.get(0),o)),(i=o.cloneRange()).setStart(o.startContainer,0),i="string"==typeof(n=this.callbacks("matcher").call(this,this.at,i.toString(),this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar"))),0===e.length&&i&&0<=(r=o.startOffset-this.at.length-n.length)&&(o.setStart(o.startContainer,r),e=a("<span/>",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),o.surroundContents(e.get(0)),(r=e.contents().last().get(0))&&(/firefox/i.test(navigator.userAgent)?(o.setStart(r,r.length),o.setEnd(r,r.length),this._clearRange(o)):this._setRange("after",r,o))),i&&n.length<this.getOpt("minLen",0)?void 0:i&&n.length<=this.getOpt("maxLen",20)?(this.trigger("matched",[this.at,(r={text:n,el:e}).text]),this.query=r):(this.view.hide(),this.query={el:e},0<=e.text().indexOf(this.at)&&(this._movingEvent(t)&&e.hasClass("atwho-inserted")?e.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,e)&&this._setRange("after",this._unwrap(e.text(e.text()).contents().first()))),null)}},g.prototype.rect=function(){var t,e=this.query.el.offset();if(e&&this.query.el[0].getClientRects().length)return this.app.iframe&&!this.app.iframeAsRoot&&(t=a(this.app.iframe).offset(),e.left+=t.left-this.$inputor.scrollLeft(),e.top+=t.top-this.$inputor.scrollTop()),e.bottom=e.top+this.query.el.height(),e},g.prototype.insert=function(t,e){var i;return this.$inputor.is(":focus")||this.$inputor.focus(),(i=this.getOpt("functionOverrides")).insert?i.insert.call(this,t,e):(i=""===(i=this.getOpt("suffix"))?i:i||" ",e=e.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(t).attr("data-atwho-at-query",""+e["atwho-at"]+this.query.text),(t=this._getRange())&&(this.query.el.length&&t.setEndAfter(this.query.el[0]),t.collapse(!1),t.insertNode(e=this.app.document.createTextNode("​"+i)),this._setRange("after",e,t)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change())},u=g,y.prototype.destroy=function(){return this.storage.data(this.at,null)},y.prototype.saved=function(){return 0<this.fetch()},y.prototype.query=function(t,e){var i=this.fetch(),r=this.context.getOpt("searchKey");return i=this.context.callbacks("filter").call(this.context,t,i,r)||[],r=this.context.callbacks("remoteFilter"),0<i.length||!r&&0===i.length?e(i):r.call(this.context,t,e)},y.prototype.fetch=function(){return this.storage.data(this.at)||[]},y.prototype.save=function(t){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,t||[]))},y.prototype.load=function(t){if(!this.saved()&&t)return this._load(t)},y.prototype.reload=function(t){return this._load(t)},y.prototype._load=function(t){return"string"==typeof t?a.ajax(t,{dataType:"json"}).done((e=this,function(t){return e.save(t)})):this.save(t);var e},c=y,v.prototype.init=function(){var t=this.context.getOpt("alias")||this.context.at.charCodeAt(0),e=this.context.getOpt("headerTpl");return e&&1===this.$el.children().length&&this.$el.prepend(e),this.$el.attr({id:"at-view-"+t})},v.prototype.destroy=function(){return this.$el.remove()},v.prototype.bindEvent=function(){var e,i=this.$el.find("ul"),r=0,n=0;return i.on("mousemove.atwho-view","li",function(t){if((r!==t.clientX||n!==t.clientY)&&(r=t.clientX,n=t.clientY,!(t=a(t.currentTarget)).hasClass("cur")))return i.find(".cur").removeClass("cur"),t.addClass("cur")}).on("click.atwho-view","li",(e=this,function(t){return i.find(".cur").removeClass("cur"),a(t.currentTarget).addClass("cur"),e.choose(t),t.preventDefault()}))},v.prototype.visible=function(){return a.expr.filters.visible(this.$el[0])},v.prototype.highlighted=function(){return 0<this.$el.find(".cur").length},v.prototype.choose=function(t){var e,i;if((e=this.$el.find(".cur")).length&&(i=this.context.insertContentFor(e),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,i,e,t),e),this.context.trigger("inserted",[e,t]),this.hide(t)),this.context.getOpt("hideWithoutSuffix"))return this.stopShowing=!0},v.prototype.reposition=function(t){var e=this.context.app.iframeAsRoot?this.context.app.window:window;return t.bottom+this.$el.height()-a(e).scrollTop()>a(e).height()&&(t.bottom=t.top-this.$el.height()),t.left>(e=a(e).width()-this.$el.width()-5)&&(t.left=e),e={left:t.left,top:t.bottom},null!=(t=this.context.callbacks("beforeReposition"))&&t.call(this.context,e),this.$el.offset(e),this.context.trigger("reposition",[e])},v.prototype.next=function(){var t=this.$el.find(".cur").removeClass("cur").next();return(t=t.length?t:this.$el.find("li:first")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))},v.prototype.prev=function(){var t=this.$el.find(".cur").removeClass("cur").prev();return(t=t.length?t:this.$el.find("li:last")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))},v.prototype.scrollTop=function(t){var e=this.context.getOpt("scrollDuration");return e?this.$elUl.animate({scrollTop:t},e):this.$elUl.scrollTop(t)},v.prototype.show=function(){var t;if(!this.stopShowing)return this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(t=this.context.rect())?this.reposition(t):void 0;this.stopShowing=!1},v.prototype.hide=function(t,e){var i;if(this.visible())return isNaN(e)?(this.$el.hide(),this.context.trigger("hidden",[t])):(i=this,t=function(){return i.hide()},clearTimeout(this.timeoutID),this.timeoutID=setTimeout(t,e))},v.prototype.render=function(t){var e,i,r,n,o,s;if(a.isArray(t)&&0<t.length){for(this.$el.find("ul").empty(),e=this.$el.find("ul"),s=this.context.getOpt("displayTpl"),i=0,n=t.length;i<n;i++)r=t[i],r=a.extend({},r,{"atwho-at":this.context.at}),o=this.context.callbacks("tplEval").call(this.context,s,r,"onDisplay"),(o=a(this.context.callbacks("highlighter").call(this.context,o,this.context.query.text))).data("item-data",r),e.append(o);return this.show(),this.context.getOpt("highlightFirst")?e.find("li:first").addClass("cur"):void 0}this.hide()},p=v,f={load:function(t,e){if(t=this.controller(t))return t.model.load(e)},isSelecting:function(){var t;return!(null==(t=this.controller())||!t.view.visible())},hide:function(){var t;return null!=(t=this.controller())?t.view.hide():void 0},reposition:function(){var t;if(t=this.controller())return t.view.reposition(t.rect())},setIframe:function(t,e){return this.setupRootElement(t,e),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},a.fn.atwho=function(i){var r=arguments,n=null;return this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var t,e;return(e=(t=a(this)).data("atwho"))||t.data("atwho",e=new o(this)),"object"!=typeof i&&i?f[i]&&e?n=f[i].apply(e,Array.prototype.slice.call(r,1)):a.error("Method "+i+" does not exist on jQuery.atwho"):e.reg(i.at,i)}),null!=n?n:this},a.fn.atwho.default={at:void 0,alias:void 0,data:null,displayTpl:"<li>${name}</li>",insertTpl:"${atwho-at}${name}",headerTpl:null,callbacks:i,functionOverrides:{},searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,acceptSpaceBar:!1,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},a.fn.atwho.debug=!1});
{'fraction_non_alphanumeric': 0.2672961502724693, 'fraction_numerical': 0.008387534215614877, 'mean_word_length': 12.703372333103923, 'pattern_counts': {'":': 18, '<': 89, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6529571', 'n_tokens_mistral': 15515, 'n_tokens_neox': 15401, 'n_words': 526}