mirror of
https://github.com/flarum/framework.git
synced 2025-02-13 11:55:34 +08:00
3 lines
50 KiB
JavaScript
Generated
3 lines
50 KiB
JavaScript
Generated
/*! For license information please see forum.js.LICENSE.txt */
|
|
(()=>{var t={440:(t,u,e)=>{var n=e(75).default;function r(){"use strict";t.exports=r=function(){return u},t.exports.__esModule=!0,t.exports.default=t.exports;var u={},e=Object.prototype,o=e.hasOwnProperty,i=Object.defineProperty||function(t,u,e){t[u]=e.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",D=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function l(t,u,e){return Object.defineProperty(t,u,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[u]}try{l({},"")}catch(t){l=function(t,u,e){return t[u]=e}}function f(t,u,e,n){var r=u&&u.prototype instanceof d?u:d,o=Object.create(r.prototype),s=new M(n||[]);return i(o,"_invoke",{value:g(t,e,s)}),o}function m(t,u,e){try{return{type:"normal",arg:t.call(u,e)}}catch(t){return{type:"throw",arg:t}}}u.wrap=f;var p={};function d(){}function F(){}function h(){}var C={};l(C,a,(function(){return this}));var A=Object.getPrototypeOf,v=A&&A(A(P([])));v&&v!==e&&o.call(v,a)&&(C=v);var E=h.prototype=d.prototype=Object.create(C);function y(t){["next","throw","return"].forEach((function(u){l(t,u,(function(t){return this._invoke(u,t)}))}))}function B(t,u){function e(r,i,s,a){var D=m(t[r],t,i);if("throw"!==D.type){var c=D.arg,l=c.value;return l&&"object"==n(l)&&o.call(l,"__await")?u.resolve(l.__await).then((function(t){e("next",t,s,a)}),(function(t){e("throw",t,s,a)})):u.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return e("throw",t,s,a)}))}a(D.arg)}var r;i(this,"_invoke",{value:function(t,n){function o(){return new u((function(u,r){e(t,n,u,r)}))}return r=r?r.then(o,o):o()}})}function g(t,u,e){var n="suspendedStart";return function(r,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===r)throw o;return{value:void 0,done:!0}}for(e.method=r,e.arg=o;;){var i=e.delegate;if(i){var s=b(i,e);if(s){if(s===p)continue;return s}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var a=m(t,u,e);if("normal"===a.type){if(n=e.done?"completed":"suspendedYield",a.arg===p)continue;return{value:a.arg,done:e.done}}"throw"===a.type&&(n="completed",e.method="throw",e.arg=a.arg)}}}function b(t,u){var e=t.iterator[u.method];if(void 0===e){if(u.delegate=null,"throw"===u.method){if(t.iterator.return&&(u.method="return",u.arg=void 0,b(t,u),"throw"===u.method))return p;u.method="throw",u.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=m(e,t.iterator,u.arg);if("throw"===n.type)return u.method="throw",u.arg=n.arg,u.delegate=null,p;var r=n.arg;return r?r.done?(u[t.resultName]=r.value,u.next=t.nextLoc,"return"!==u.method&&(u.method="next",u.arg=void 0),u.delegate=null,p):r:(u.method="throw",u.arg=new TypeError("iterator result is not an object"),u.delegate=null,p)}function w(t){var u={tryLoc:t[0]};1 in t&&(u.catchLoc=t[1]),2 in t&&(u.finallyLoc=t[2],u.afterLoc=t[3]),this.tryEntries.push(u)}function x(t){var u=t.completion||{};u.type="normal",delete u.arg,t.completion=u}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(w,this),this.reset(!0)}function P(t){if(t){var u=t[a];if(u)return u.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function u(){for(;++e<t.length;)if(o.call(t,e))return u.value=t[e],u.done=!1,u;return u.value=void 0,u.done=!0,u};return n.next=n}}return{next:_}}function _(){return{value:void 0,done:!0}}return F.prototype=h,i(E,"constructor",{value:h,configurable:!0}),i(h,"constructor",{value:F,configurable:!0}),F.displayName=l(h,c,"GeneratorFunction"),u.isGeneratorFunction=function(t){var u="function"==typeof t&&t.constructor;return!!u&&(u===F||"GeneratorFunction"===(u.displayName||u.name))},u.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,l(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},u.awrap=function(t){return{__await:t}},y(B.prototype),l(B.prototype,D,(function(){return this})),u.AsyncIterator=B,u.async=function(t,e,n,r,o){void 0===o&&(o=Promise);var i=new B(f(t,e,n,r),o);return u.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},y(E),l(E,c,"Generator"),l(E,a,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),u.keys=function(t){var u=Object(t),e=[];for(var n in u)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in u)return t.value=n,t.done=!1,t}return t.done=!0,t}},u.values=P,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var u in this)"t"===u.charAt(0)&&o.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var u=this;function e(e,n){return i.type="throw",i.arg=t,u.next=e,n&&(u.method="next",u.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n],i=r.completion;if("root"===r.tryLoc)return e("end");if(r.tryLoc<=this.prev){var s=o.call(r,"catchLoc"),a=o.call(r,"finallyLoc");if(s&&a){if(this.prev<r.catchLoc)return e(r.catchLoc,!0);if(this.prev<r.finallyLoc)return e(r.finallyLoc)}else if(s){if(this.prev<r.catchLoc)return e(r.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return e(r.finallyLoc)}}}},abrupt:function(t,u){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var r=n;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=u&&u<=r.finallyLoc&&(r=null);var i=r?r.completion:{};return i.type=t,i.arg=u,r?(this.method="next",this.next=r.finallyLoc,p):this.complete(i)},complete:function(t,u){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&u&&(this.next=u),p},finish:function(t){for(var u=this.tryEntries.length-1;u>=0;--u){var e=this.tryEntries[u];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),x(e),p}},catch:function(t){for(var u=this.tryEntries.length-1;u>=0;--u){var e=this.tryEntries[u];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var r=n.arg;x(e)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,u,e){return this.delegate={iterator:P(t),resultName:u,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},u}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},75:t=>{function u(e){return t.exports=u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,u(e)}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports},507:(t,u,e)=>{var n=e(440)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},u={};function e(n){var r=u[n];if(void 0!==r)return r.exports;var o=u[n]={exports:{}};return t[n](o,o.exports,e),o.exports}e.n=t=>{var u=t&&t.__esModule?()=>t.default:()=>t;return e.d(u,{a:u}),u},e.d=(t,u)=>{for(var n in u)e.o(u,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:u[n]})},e.o=(t,u)=>Object.prototype.hasOwnProperty.call(t,u),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";e.r(n),e.d(n,{extend:()=>su,filterGroupMentions:()=>fu,filterPostMentions:()=>cu,filterTagMentions:()=>pu,filterUserMentions:()=>au,postFilterGroupMentions:()=>mu,postFilterPostMentions:()=>lu,postFilterTagMentions:()=>du,postFilterUserMentions:()=>Du});var t={};e.r(t),e.d(t,{default:()=>J,insertMention:()=>q});var u={};e.r(u),e.d(u,{filterGroupMentions:()=>fu,filterPostMentions:()=>cu,filterTagMentions:()=>pu,filterUserMentions:()=>au,postFilterGroupMentions:()=>mu,postFilterPostMentions:()=>lu,postFilterTagMentions:()=>du,postFilterUserMentions:()=>Du});const r=flarum.core.compat["common/extend"],o=flarum.core.compat["forum/app"];var i=e.n(o);const s=flarum.core.compat["forum/components/NotificationGrid"];var a=e.n(s);const D=flarum.core.compat["common/utils/string"],c=flarum.core.compat["common/helpers/textContrastClass"];var l=e.n(c);const f=flarum.core.compat["forum/components/Post"];var p=e.n(f);const d=flarum.core.compat["forum/components/CommentPost"];var F=e.n(d);const h=flarum.core.compat["forum/components/PostPreview"];var C=e.n(h);const A=flarum.core.compat["common/components/LoadingIndicator"];var v=e.n(A);const E=flarum.core.compat["common/components/Link"];var y=e.n(E);const B=flarum.core.compat["common/helpers/punctuateSeries"];var g=e.n(B);const b=flarum.core.compat["common/helpers/username"];var w=e.n(b);const x=flarum.core.compat["common/helpers/icon"];var M=e.n(x);const P=flarum.core.compat["common/components/Button"];var _=e.n(P);function T(t,u){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},T(t,u)}function S(t,u){t.prototype=Object.create(u.prototype),t.prototype.constructor=t,T(t,u)}const k=flarum.core.compat["common/components/Modal"];var L=e.n(k);function j(){return j=Object.assign?Object.assign.bind():function(t){for(var u=1;u<arguments.length;u++){var e=arguments[u];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},j.apply(this,arguments)}function N(t,u){for(var e=0;e<u.length;e++){var n=u[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}const O=flarum.core.compat["common/states/PaginatedListState"];var I=function(t){function u(u,e){return void 0===e&&(e=1),u.page=j({},u.page||{},{limit:10}),t.call(this,u,e,10)||this}var e,n;return S(u,t),e=u,(n=[{key:"type",get:function(){return"posts"}}])&&N(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),u}(e.n(O)()),R=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.oninit=function(u){t.prototype.oninit.call(this,u),this.state=new I({filter:{mentionedPost:this.attrs.post.id()},sort:"number"}),this.state.refresh()},e.className=function(){return"MentionedByModal"},e.title=function(){return i().translator.trans("flarum-mentions.forum.mentioned_by.title")},e.content=function(){var t=this;return m("[",null,m("div",{className:"Modal-body"},this.state.isInitialLoading()?m(v(),null):m("[",null,m("ul",{className:"MentionedByModal-list Dropdown-menu Dropdown-menu--inline Post-mentionedBy-preview"},this.state.getPages().map((function(t){return t.items.map((function(t){return m("li",{"data-number":t.number()},m(C(),{post:t,onclick:function(){return i().modal.close()}}))}))}))))),this.state.hasNext()&&m("div",{className:"Modal-footer"},m("div",{className:"Form Form--centered"},m("div",{className:"Form-group"},m(_(),{className:"Button Button--block",onclick:function(){return t.state.loadNext()},loading:this.state.isLoadingNext()},i().translator.trans("flarum-mentions.forum.mentioned_by.load_more_button"))))))},u}(L());const G=flarum.core.compat["forum/utils/DiscussionControls"];var U=e.n(G);const H=flarum.core.compat["forum/components/EditPostComposer"];var W=e.n(H);function q(t,u,e){return new Promise((function(n){var r=i().mentionFormats.mentionable("post").replacement(t)+" ";u.fields.content()||(u.body.attrs.originalContent=r);var o=u.editor.getSelectionRange()[0],s=u.fields.content().slice(0,o),a=0==s.length?0:3-s.match(/(\n{0,2})$/)[0].length;return u.editor.insertAtCursor(Array(a).join("\n")+(e?"> "+r+e.trim().replace(/\n/g,"\n> ")+"\n\n":r),!1),n(u)}))}function J(t,u){return i().composer.bodyMatches(W())&&i().composer.body.attrs.post.discussion()===t.discussion()?q(t,i().composer,u):U().replyAction.call(t.discussion()).then((function(e){return q(t,e,u)}))}const z=flarum.core.compat["common/Fragment"];var Y=e.n(z),Q=function(t){function u(u){var e;return(e=t.call(this)||this).post=u,e}S(u,t);var e=u.prototype;return e.view=function(){var t=this;return m("button",{class:"Button PostQuoteButton",onclick:function(){J(t.post,t.content)}},M()("fas fa-quote-left",{className:"Button-icon"}),i().translator.trans("flarum-mentions.forum.post.quote_button"))},e.show=function(t,u){var e=this.$().show(),n=e.offsetParent().offset();e.css("left",t-n.left).css("top",u-n.top),this.hideHandler=this.hide.bind(this),$(document).on("mouseup",this.hideHandler)},e.showStart=function(t,u){var e=this.$();this.show(t,$(window).scrollTop()+u-e.outerHeight()-5)},e.showEnd=function(t,u){var e=this.$();this.show(t-e.outerWidth(),$(window).scrollTop()+u+5)},e.hide=function(){this.$().hide(),$(document).off("mouseup",this.hideHandler)},u}(Y());function X(t){var u=window.getSelection();if(!u.isCollapsed){var e=u.getRangeAt(0),n=e.commonAncestorContainer;if(t[0]===n||$.contains(t[0],n)){var r=$("<div>").append(e.cloneContents());return r.find("img.emoji").replaceWith((function(){return this.alt})),r.find("img").replaceWith((function(){return"![]("+this.src+")"})),r.find("a").replaceWith((function(){return"["+this.innerText+"]("+this.href+")"})),r.text()}}return""}const K=flarum.core.compat["common/components/TextEditor"];var V=e.n(K);const Z=flarum.core.compat["common/components/TextEditorButton"];var tt=e.n(Z);const ut=flarum.core.compat["common/utils/KeyboardNavigatable"];var et=e.n(ut),nt=function(t){function u(){for(var u,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(u=t.call.apply(t,[this].concat(n))||this).items=[],u.active=!1,u.index=0,u.keyWasJustPressed=!1,u}S(u,t);var e=u.prototype;return e.view=function(){return m("ul",{className:"Dropdown-menu MentionsDropdown"},this.items.map((function(t){return m("li",null,t)})))},e.show=function(t,u){this.$().show().css({left:t+"px",top:u+"px"}),this.active=!0},e.hide=function(){this.$().hide(),this.active=!1},e.navigate=function(t){var u=this;this.keyWasJustPressed=!0,this.setIndex(this.index+t,!0),clearTimeout(this.keyWasJustPressedTimeout),this.keyWasJustPressedTimeout=setTimeout((function(){return u.keyWasJustPressed=!1}),500)},e.complete=function(){this.$("li").eq(this.index).find("button").click()},e.setIndex=function(t,u){if(!this.keyWasJustPressed||u){var e=this.$(),n=e.find("li"),r=t;r<0?r=n.length-1:r>=n.length&&(r=0),this.index=r;var o=n.removeClass("active").eq(r).addClass("active");if(u){var i,s=e.scrollTop(),a=e.offset().top,D=a+e.outerHeight(),c=o.offset().top,l=c+o.outerHeight();c<a?i=s-a+c-parseInt(e.css("padding-top"),10):l>D&&(i=s-D+l+parseInt(e.css("padding-bottom"),10)),void 0!==i&&e.stop(!0).animate({scrollTop:i},100)}}},u}(Y()),rt=function(){function t(){this.instances=void 0,this.mentionables=void 0,this.extendable=void 0}var u=t.prototype;return u.makeMentionables=function(){var t,u=this;return null!=(t=this.instances)?t:this.instances=this.mentionables.map((function(t){return new t(u)}))},u.getMentionable=function(t){var u;return null!=(u=this.makeMentionables().find((function(u){return u.type()===t})))?u:null},u.extend=function(t){if(!this.extendable)throw new Error("This mention format does not allow extending.");this.mentionables.push(t)},t}();function ot(t,u,e,n,r,o,i){try{var s=t[o](i),a=s.value}catch(t){return void e(t)}s.done?u(a):Promise.resolve(a).then(n,r)}function it(t){return function(){var u=this,e=arguments;return new Promise((function(n,r){var o=t.apply(u,e);function i(t){ot(o,n,r,i,s,"next",t)}function s(t){ot(o,n,r,i,s,"throw",t)}i(void 0)}))}}var st=e(507),at=e.n(st);const Dt=flarum.core.compat["common/helpers/avatar"];var ct=e.n(Dt);const lt=flarum.core.compat["common/helpers/highlight"];var ft=e.n(lt),mt=function(t){this.format=void 0,this.format=t};const pt=flarum.core.compat["common/utils/extractText"];var dt=e.n(pt),Ft=function(){return dt()(i().translator.trans("core.lib.username.deleted_text"))};function ht(t,u){return void 0===u&&(u=!0),t?((u?t.displayName():t.username())||Ft()).replace(/"#[a-z]{0,3}[0-9]+/,"_"):Ft().replace(/"#[a-z]{0,3}[0-9]+/,"_")}var Ct=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.type=function(){return"user"},e.initialResults=function(){return Array.from(i().store.all("users"))},e.replacement=function(t){if(i().forum.attribute("allowUsernameMentionFormat")){var u=ht(t,!1);return this.format.format(u)}var e=ht(t);return this.format.format(e,"",t.id())},e.suggestion=function(t,u){var e,n=w()(t);return u&&(n.children=[ft()(null!=(e=n.text)?e:"",u)],delete n.text),m("[",null,ct()(t),n)},e.matches=function(t,u){return!!u&&[t.username(),t.displayName()].some((function(t){return t.toLowerCase().substr(0,u.length)===u}))},e.maxStoreMatchedResults=function(){return null},e.search=function(){var t=it(at().mark((function t(u){return at().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i().store.find("users",{filter:{q:u},page:{limit:5}});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(u){return t.apply(this,arguments)}}(),e.enabled=function(){return!0},u}(mt);const At=flarum.core.compat["forum/components/ReplyComposer"];var vt=e.n(At),Et=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.type=function(){return"post"},e.initialResults=function(){if(!i().composer.bodyMatches(vt())&&!i().composer.bodyMatches(W()))return[];var t=i().composer.body.attrs,u=t.post;return(u&&u.discussion()||t.discussion).posts().filter((function(t){return t&&"comment"===t.contentType()&&(!u||t.number()<u.number())})).sort((function(t,u){return u.createdAt().getTime()-t.createdAt().getTime()}))},e.replacement=function(t){var u=ht(t.user());return this.format.format(u,"p",t.id())},e.suggestion=function(t,u){var e,n,r=t.user()||null,o=w()(r);return u&&(o.children=[ft()(null!=(n=o.text)?n:"",u)],delete o.text),m("[",null,ct()(r),o,[i().translator.trans("flarum-mentions.forum.composer.reply_to_post_text",{number:t.number()})," — ",(0,D.truncate)(null!=(e=t.contentPlain())?e:"",200)])},e.matches=function(t,u){var e=t.user(),n=i().mentionFormats.mentionable("user");return!u||e&&n.matches(e,u)},e.maxStoreMatchedResults=function(){return 5},e.search=function(t){return Promise.resolve([])},e.enabled=function(){return!0},u}(mt);const yt=flarum.core.compat["common/models/Group"];var Bt=e.n(yt);const gt=flarum.core.compat["common/components/Badge"];var bt=e.n(gt),wt=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.type=function(){return"group"},e.initialResults=function(){return Array.from(i().store.all("groups").filter((function(t){return t.id()!==Bt().GUEST_ID&&t.id()!==Bt().MEMBER_ID})))},e.replacement=function(t){return this.format.format(t.namePlural(),"g",t.id())},e.suggestion=function(t,u){var e=t.namePlural();return u&&(e=ft()(e,u)),m("[",null,m(bt(),{className:"Avatar Badge Badge--group--"+t.id()+" Badge-icon",color:t.color(),type:"group",icon:t.icon()}),m("span",{className:"username"},e))},e.matches=function(t,u){return!!u&&[t.namePlural().toLowerCase(),t.nameSingular().toLowerCase()].some((function(t){return t.toLowerCase().substr(0,u.length)===u}))},e.maxStoreMatchedResults=function(){return null},e.search=function(t){return Promise.resolve([])},e.enabled=function(){var t,u,e;return null!=(t=null==(u=i().session)||null==(e=u.user)?void 0:e.canMentionGroups())&&t},u}(mt),xt=function(t){function u(){for(var u,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(u=t.call.apply(t,[this].concat(n))||this).mentionables=[Ct,Et,wt],u.extendable=!0,u}S(u,t);var e=u.prototype;return e.trigger=function(){return"@"},e.queryFromTyped=function(t){var u=t.match(/^["“]?((?:(?!"#).)+)$/);return u?u[1]:null},e.format=function(t,u,e){return void 0===u&&(u=""),void 0===e&&(e=null),{simple:"@"+t,safe:'@"'+t+'"#'+u+e}[e?"safe":"simple"]},u}(rt),Mt=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.type=function(){return"tag"},e.initialResults=function(){return Array.from(i().store.all("tags"))},e.replacement=function(t){return this.format.format(t.slug())},e.matches=function(t,u){return!!u&&[t.name().toLowerCase()].some((function(t){return t.toLowerCase().substr(0,u.length)===u}))},e.maxStoreMatchedResults=function(){return null},e.search=function(){var t=it(at().mark((function t(u){return at().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i().store.find("tags",{filter:{q:u},page:{limit:5}});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(u){return t.apply(this,arguments)}}(),e.suggestion=function(t,u){var e=t.name();return u&&(e=ft()(e,u)),m("[",null,m(bt(),{className:"Avatar",icon:t.icon(),color:t.color(),type:"tag"}),m("span",{className:"username"},e))},e.enabled=function(){return"flarum-tags"in flarum.extensions},u}(mt),Pt=function(t){function u(){for(var u,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(u=t.call.apply(t,[this].concat(n))||this).mentionables=[Mt],u.extendable=!1,u}S(u,t);var e=u.prototype;return e.trigger=function(){return"#"},e.queryFromTyped=function(t){var u=t.match(/^(?:[\x2D0-9A-Z_a-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-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D68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\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B]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF])+$/gi);return u?u[0]:null},e.format=function(t){return"#"+t},u}(rt);function _t(t,u){(null==u||u>t.length)&&(u=t.length);for(var e=0,n=new Array(u);e<u;e++)n[e]=t[e];return n}var Tt=function(){function t(){this.formats=[new xt,new Pt]}var u=t.prototype;return u.get=function(t){var u;return null!=(u=this.formats.find((function(u){return u.trigger()===t})))?u:null},u.mentionable=function(t){for(var u,e=function(t,u){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,u){if(t){if("string"==typeof t)return _t(t,u);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_t(t,u):void 0}}(t))||u&&t&&"number"==typeof t.length){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.formats);!(u=e()).done;){var n=u.value.getMentionable(t);if(n)return n}return null},u.extend=function(t){this.formats.push(new t)},t}();function St(t,u){if(null==t)return{};var e,n,r={},o=Object.keys(t);for(n=0;n<o.length;n++)e=o[n],u.indexOf(e)>=0||(r[e]=t[e]);return r}const kt=flarum.core.compat["common/Component"];var $t=e.n(kt);const Lt=flarum.core.compat["common/utils/classList"];var jt=e.n(Lt),Nt=["mentionable"],Ot=function(t){function u(){return t.apply(this,arguments)||this}return S(u,t),u.prototype.view=function(t){var u=this.attrs,e=u.mentionable,n=St(u,Nt),r=jt()("MentionsDropdownItem","PostPreview","MentionsDropdown-"+e.type());return m("button",Object.assign({className:r},n),m("span",{className:"PostPreview-content"},t.children))},u}($t());const It=flarum.core.compat["common/utils/throttleDebounce"];var Rt=["onclick"];function Gt(t,u){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,u){if(t){if("string"==typeof t)return Ut(t,u);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ut(t,u):void 0}}(t))||u&&t&&"number"==typeof t.length){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ut(t,u){(null==u||u>t.length)&&(u=t.length);for(var e=0,n=new Array(u);e<u;e++)n[e]=t[e];return n}var Ht=function(){function t(t){var u=this;this.mentionables=void 0,this.results={},this.typed=null,this.searched=[],this.dropdownItemAttrs={},this.search=(0,It.throttle)(250,it(at().mark((function t(){var e,n,r,o,i,s,a;return at().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.typed&&!(u.typed.length<=1)){t.next=2;break}return t.abrupt("return");case 2:if(e=u.typed.toLowerCase(),!u.searched.includes(e)){t.next=5;break}return t.abrupt("return");case 5:n=Gt(u.mentionables);case 6:if((r=n()).done){t.next=20;break}return o=r.value,t.t0=Gt,t.next=11,o.search(e);case 11:t.t1=t.sent,i=(0,t.t0)(t.t1);case 13:if((s=i()).done){t.next=18;break}a=s.value,u.results[o.type()].has(a.id())||u.results[o.type()].set(a.id(),a);case 16:t.next=13;break;case 18:t.next=6;break;case 20:return u.searched.push(e),t.abrupt("return",Promise.resolve());case 22:case"end":return t.stop()}}),t)})))),this.dropdownItemAttrs=t}var u=t.prototype;return u.init=function(t){this.typed=null,this.mentionables=t;for(var u,e=Gt(this.mentionables);!(u=e()).done;){var n=u.value;this.results[n.type()]=new Map(n.initialResults().map((function(t){return[t.id(),t]})))}},u.matches=function(t,u){var e;return t.matches(u,(null==(e=this.typed)?void 0:e.toLowerCase())||"")},u.makeSuggestion=function(t,u){var e=t.suggestion(u,this.typed),n=t.replacement(u),r=this.dropdownItemAttrs,o=r.onclick,i=St(r,Rt);return m(Ot,Object.assign({mentionable:t,onclick:function(){return o(n)}},i),e)},u.buildSuggestions=function(){for(var t,u=this,e=[],n=function(){var n=t.value;if(!n.enabled())return"continue";var r=Array.from(u.results[n.type()].values()).filter((function(t){return u.matches(n,t)})),o=n.maxStoreMatchedResults();o&&(r=r.splice(0,o));for(var i,s=Gt(r);!(i=s()).done;){var a=i.value,D=u.makeSuggestion(n,a);e.push(D)}},r=Gt(this.mentionables);!(t=r()).done;)n();return e},t}();const Wt=flarum.core.compat["forum/components/Notification"];var qt=e.n(Wt),Jt=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.icon=function(){return"fas fa-reply"},e.href=function(){var t=this.attrs.notification,u=t.subject(),e=t.content();return i().route.discussion(u.discussion(),e&&e.replyNumber)},e.content=function(){var t=this.attrs.notification.fromUser();return i().translator.trans("flarum-mentions.forum.notifications.post_mentioned_text",{user:t,count:1})},e.excerpt=function(){return(0,D.truncate)(this.attrs.notification.subject().contentPlain()||"",200)},u}(qt()),zt=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.icon=function(){return"fas fa-at"},e.href=function(){var t=this.attrs.notification.subject();return i().route.discussion(t.discussion(),t.number())},e.content=function(){var t=this.attrs.notification.fromUser();return i().translator.trans("flarum-mentions.forum.notifications.user_mentioned_text",{user:t})},e.excerpt=function(){return(0,D.truncate)(this.attrs.notification.subject().contentPlain(),200)},u}(qt()),Yt=function(t){function u(){return t.apply(this,arguments)||this}S(u,t);var e=u.prototype;return e.icon=function(){return"fas fa-at"},e.href=function(){var t=this.attrs.notification.subject();return i().route.discussion(t.discussion(),t.number())},e.content=function(){var t=this.attrs.notification.fromUser();return i().translator.trans("flarum-mentions.forum.notifications.group_mentioned_text",{user:t})},e.excerpt=function(){return(0,D.truncate)(this.attrs.notification.subject().contentPlain(),200)},u}(qt());const Qt=flarum.core.compat["forum/components/UserPage"];var Xt=e.n(Qt);const Kt=flarum.core.compat["common/components/LinkButton"];var Vt=e.n(Kt);const Zt=flarum.core.compat["common/models/User"];var tu=e.n(Zt);flarum.core.compat["common/Model"];const uu=flarum.core.compat["common/extenders"];var eu=e.n(uu);const nu=flarum.core.compat["common/models/Post"];var ru=e.n(nu);const ou=flarum.core.compat["forum/components/PostsUserPage"];var iu=function(t){function u(){return t.apply(this,arguments)||this}return S(u,t),u.prototype.loadResults=function(t){return i().store.find("posts",{filter:{type:"comment",mentioned:this.user.id()},page:{offset:t,limit:this.loadLimit},sort:"-createdAt"})},u}(e.n(ou)());const su=[(new(eu().Routes)).add("user.mentions","/u/:username/mentions",iu),new(eu().Model)(ru()).hasMany("mentionedBy").attribute("mentionedByCount"),new(eu().Model)(tu()).attribute("canMentionGroups")];function au(t){var u;if(i().forum.attribute("allowUsernameMentionFormat")&&t.hasAttribute("username")?u=i().store.getBy("users","username",t.getAttribute("username")):t.hasAttribute("id")&&(u=i().store.getById("users",t.getAttribute("id"))),u)return t.setAttribute("id",u.id()),t.setAttribute("slug",u.slug()),t.setAttribute("displayname",dt()(w()(u))),!0;t.invalidate()}function Du(t){t.setAttribute("deleted",!1)}function cu(t){var u=i().store.getById("posts",t.getAttribute("id"));if(u)return t.setAttribute("discussionid",u.discussion().id()),t.setAttribute("number",u.number()),t.setAttribute("displayname",dt()(w()(u.user()))),!0}function lu(t){t.setAttribute("deleted",!1)}function fu(t){var u,e;if(null!=(u=i().session)&&null!=(e=u.user)&&e.canMentionGroups()){var n=i().store.getById("groups",t.getAttribute("id"));if(n)return t.setAttribute("groupname",dt()(n.namePlural())),!0}t.invalidate()}function mu(t){var u,e;if(null!=(u=i().session)&&null!=(e=u.user)&&e.canMentionGroups()){var n=i().store.getById("groups",t.getAttribute("id"));t.setAttribute("color",n.color()),t.setAttribute("icon",n.icon()),t.setAttribute("deleted",!1)}}function pu(t){if("flarum-tags"in flarum.extensions){var u=i().store.getBy("tags","slug",t.getAttribute("slug"));if(u)return t.setAttribute("id",u.id()),t.setAttribute("tagname",u.name()),!0}t.invalidate()}function du(t){if("flarum-tags"in flarum.extensions){var u=i().store.getBy("tags","slug",t.getAttribute("slug"));t.setAttribute("icon",u.icon()),t.setAttribute("color",u.color()),t.setAttribute("deleted",!1)}}function Fu(t,u){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,u){if(t){if("string"==typeof t)return hu(t,u);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?hu(t,u):void 0}}(t))||u&&t&&"number"==typeof t.length){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function hu(t,u){(null==u||u>t.length)&&(u=t.length);for(var e=0,n=new Array(u);e<u;e++)n[e]=t[e];return n}const Cu={"mentions/components/MentionsUserPage":iu,"mentions/components/PostMentionedNotification":Jt,"mentions/components/UserMentionedNotification":zt,"mentions/components/GroupMentionedNotification":Yt,"mentions/fragments/AutocompleteDropdown":nt,"mentions/fragments/PostQuoteButton":Q,"mentions/utils/getCleanDisplayName":ht,"mentions/utils/getMentionText":function(t,u,e){if(void 0!==t&&void 0===u)return i().mentionables.get("user").replacement(t);if(void 0!==t&&void 0!==u)return i().mentionables.get("post").replacement(i().store.getById("posts",u));if(void 0!==e)return i().mentionables.get("group").replacement(e);throw"No parameters were passed"},"mentions/utils/reply":t,"mentions/utils/selectedText":X,"mentions/utils/textFormatter":u,"mentions/mentionables/MentionableModel":mt,"mentions/mentionables/formats/MentionFormat":rt,"mentions/extenders/Mentionables":function(){function t(){this.formats=[],this.mentionables={}}var u=t.prototype;return u.format=function(t){return this.formats.push(t),this},u.mentionable=function(t,u){return this.mentionables[t]||(this.mentionables[t]=[]),this.mentionables[t].push(u),this},u.extend=function(t){for(var u,e=Fu(this.formats);!(u=e()).done;){var n=u.value;t.mentionFormats.extend(n)}for(var r in this.mentionables){var o=t.mentionFormats.get(r);if(o)for(var i,s=Fu(this.mentionables[r]);!(i=s()).done;){var a=i.value;o.extend(a)}}},t}()},Au=flarum.core;i().initializers.add("flarum-mentions",(function(){!function(){function t(){var t=this.attrs.post.contentHtml();if(t!==this.oldPostContentHtml&&!this.isEditing()){this.oldPostContentHtml=t;var u=this.attrs.post,e=this.$();this.$().on("click",".UserMention:not(.UserMention--deleted), .PostMention:not(.PostMention--deleted), .TagMention:not(.TagMention--deleted)",(function(t){m.route.set(this.getAttribute("href")),t.preventDefault()})),this.$(".PostMention:not(.PostMention--deleted)").each((function(){var t,n=$(this),r=n.data("id"),o=$('<ul class="Dropdown-menu PostMention-preview fade"/>');e.append(o);var i=function(){return $('.PostStream-item[data-id="'+r+'"]')},s=function(){var t=i(),s=!1;if(t.length){var a=t.offset().top,D=window.pageYOffset;a>D&&a+t.height()<D+$(window).height()&&(t.addClass("pulsate"),s=!0)}if(!s){var c=function(){var t=o.outerHeight(!0),u=0;n.offset().top-t<$(window).scrollTop()+$("#header").outerHeight()?u+=n.outerHeight(!0):u-=t,o.show().css("top",n.offset().top-e.offset().top+u).css("left",n.offsetParent().offset().left-e.offset().left).css("max-width",n.offsetParent().width())},l=function(t){var e=t.discussion();m.render(o[0],[e!==u.discussion()?m("li",null,m("span",{className:"PostMention-preview-discussion"},e.title())):"",m("li",null,C().component({post:t}))]),c()},f=app.store.getById("posts",r);f&&f.discussion()?l(f):(m.render(o[0],v().component()),app.store.find("posts",r).then(l),c()),setTimeout((function(){return o.off("transitionend").addClass("in")}))}},a=function(){i().removeClass("pulsate"),o.hasClass("in")&&o.removeClass("in").one("transitionend",(function(){return o.hide()}))};n.on("touchend",(function(t){t.cancelable&&t.preventDefault()})),n.add(o).hover((function(){clearTimeout(t),t=setTimeout(s,250)}),(function(){clearTimeout(t),i().removeClass("pulsate"),t=setTimeout(a,250)})).on("touchend",(function(t){s(),t.stopPropagation()})),$(document).on("touchend",a)}))}}(0,r.extend)(F().prototype,"oncreate",t),(0,r.extend)(F().prototype,"onupdate",t)}(),function(){function t(){this.$(".Post-mentionedBy-preview").removeClass("in").one("transitionend",(function(){$(this).hide()}))}(0,r.extend)(F().prototype,"oncreate",(function(){var u,e=this,n=this.attrs.post,r=n.mentionedBy();if(r&&r.length){var o=$('<ul class="Dropdown-menu Post-mentionedBy-preview fade"/>');this.$().append(o);var s=this.$(),a=this.$(".Post-mentionedBy"),D=function(){!o.hasClass("in")&&o.is(":visible")||(m.render(o[0],m("[",null,r.map((function(u){return m("li",{"data-number":u.number()},C().component({post:u,onclick:t.bind(e)}))})),r.length<n.mentionedByCount()?m("li",{className:"Post-mentionedBy-preview-more"},m(_(),{className:"PostPreview Button",onclick:function(){t.call(e),i().modal.show(R,{post:n})}},m("span",{className:"PostPreview-content"},m("span",{className:"PostPreview-badge Avatar"},M()("fas fa-reply-all")),m("span",null,i().translator.trans("flarum-mentions.forum.post.mentioned_by_more_text",{count:n.mentionedByCount()-r.length}))))):null)),o.show().css("top",a.offset().top-s.offset().top+a.outerHeight(!0)).css("left",a.offsetParent().offset().left-s.offset().left).css("max-width",s.width()),setTimeout((function(){return o.off("transitionend").addClass("in")})))};a.add(o).hover((function(){clearTimeout(u),u=setTimeout(D,250)}),(function(){clearTimeout(u),u=setTimeout(t,250)})),this.$().find(".Post-mentionedBy-summary a").hover((function(){o.find('[data-number="'+$(this).data("number")+'"]').addClass("active")}),(function(){o.find("[data-number]").removeClass("active")}))}})),(0,r.extend)(F().prototype,"footerItems",(function(u){var e=this,n=this.attrs.post.mentionedBy();if(n&&n.length){var r=[],o=n.sort((function(t){return t.user()===i().session.user?-1:0})).filter((function(t){var u=t.user();if(-1===r.indexOf(u))return r.push(u),!0})),s=o.length>4,a=o.slice(0,s?3:4).map((function(u){var n=u.user();return m(y(),{href:i().route.post(u),onclick:t.bind(e),"data-number":u.number()},i().session.user===n?i().translator.trans("flarum-mentions.forum.post.you_text"):w()(n))}));if(s){var D=o.length-a.length;a.push(i().translator.trans("flarum-mentions.forum.post.others_text",{count:D}))}u.add("replies",m("div",{className:"Post-mentionedBy"},m("span",{className:"Post-mentionedBy-summary"},M()("fas fa-reply"),i().translator.trans("flarum-mentions.forum.post.mentioned_by"+(o[0].user()===i().session.user?"_self":"")+"_text",{count:a.length,users:g()(a)}))))}}))}(),(0,r.extend)(F().prototype,"actionItems",(function(t){var u=this.attrs.post;u.isHidden()||i().session.user&&!u.discussion().canReply()||t.add("reply",m(_(),{className:"Button Button--link",onclick:function(){return J(u)}},i().translator.trans("flarum-mentions.forum.post.reply_link")))})),(0,r.extend)(F().prototype,"oncreate",(function(){var t=this.attrs.post;if(!(t.isHidden()||i().session.user&&!t.discussion().canReply())){var u=this.$(".Post-body"),e=$('<div class="Post-quoteButtonContainer"></div>'),n=new Q(t),r=function(t){setTimeout((function(){var r=X(u);if(r){n.content=r,m.render(e[0],n.render());var o=window.getSelection().getRangeAt(0).getClientRects(),i=o[0];if(t.clientY<i.bottom&&t.clientX-i.right<i.left-t.clientX)n.showStart(i.left,i.top);else{var s=o[o.length-1];n.showEnd(s.right,s.bottom)}}}),1)};this.$().after(e).on("mouseup",r),"ontouchstart"in window&&document.addEventListener("selectionchange",r,!1)}})),function(){i().mentionFormats=new Tt;var t=$('<div class="ComposerBody-mentionsDropdownContainer"></div>'),u=new nt;(0,r.extend)(V().prototype,"oncreate",(function(){var e=this.$(".TextEditor-editor").wrap('<div class="ComposerBody-mentionsWrapper"></div>');this.navigator=new(et()),this.navigator.when((function(){return u.active})).onUp((function(){return u.navigate(-1)})).onDown((function(){return u.navigate(1)})).onSelect(u.complete.bind(u)).onCancel(u.hide.bind(u)).bindTo(e),e.after(t)})),(0,r.extend)(V().prototype,"buildEditorParams",(function(e){var n,r,o,s=this,a=new Ht({onmouseenter:function(){u.setIndex($(this).parent().index())},onclick:function(t){s.attrs.composer.editor.replaceBeforeCursor(r-1,t+" "),u.hide()}});e.inputListeners.push((function(){var e=s.attrs.composer.editor.getSelectionRange(),D=e[0];if(!(e[1]-D>0)){var c=s.attrs.composer.editor.getLastNChars(30);r=0;for(var l=null,f=c.length-1;f>=0;f--){var p=c.substr(f,1);if((l=i().mentionFormats.get(p))&&(0===f||/\s/.test(c.substr(f-1,1)))){n=f+1,r=D-c.length+f+1,a.init(l.makeMentionables());break}}if(u.hide(),u.active=!1,r){var d,F=c.substring(n).toLowerCase();if(!(o=l.queryFromTyped(F)))return;a.typed=o;var h=function(){var e=a.buildSuggestions();if(e.length){u.items=e,m.render(t[0],u.render()),u.show();var n=s.attrs.composer.editor.getCaretCoordinates(r),o=u.$().outerWidth(),i=u.$().outerHeight(),D=u.$().offsetParent(),c=n.left,l=n.top+15;l+i>D.height()&&(l=n.top-i-15),c+o>D.width()&&(c=D.width()-o),l=Math.max(-(D.offset().top-$(document).scrollTop()),l),c=Math.max(-D.offset().left,c),u.show(c,l)}else u.active=!1,u.hide()};u.active=!0,h(),u.setIndex(0),u.$().scrollTop(0),null==(d=a.search())||d.then(h)}}}))})),(0,r.extend)(V().prototype,"toolbarItems",(function(t){var u=this;t.add("mention",m(tt(),{onclick:function(){return u.attrs.composer.editor.insertAtCursor(" @")},icon:"fas fa-at"},i().translator.trans("flarum-mentions.forum.composer.mention_tooltip")))}))}(),i().notificationComponents.postMentioned=Jt,i().notificationComponents.userMentioned=zt,i().notificationComponents.groupMentioned=Yt,(0,r.extend)(a().prototype,"notificationTypes",(function(t){t.add("postMentioned",{name:"postMentioned",icon:"fas fa-reply",label:i().translator.trans("flarum-mentions.forum.settings.notify_post_mentioned_label")}),t.add("userMentioned",{name:"userMentioned",icon:"fas fa-at",label:i().translator.trans("flarum-mentions.forum.settings.notify_user_mentioned_label")}),t.add("groupMentioned",{name:"groupMentioned",icon:"fas fa-at",label:i().translator.trans("flarum-mentions.forum.settings.notify_group_mentioned_label")})})),(0,r.extend)(Xt().prototype,"navItems",(function(t){var u=this.user;t.add("mentions",Vt().component({href:i().route("user.mentions",{username:u.slug()}),name:"mentions",icon:"fas fa-at"},i().translator.trans("flarum-mentions.forum.user.mentions_link")),80)})),D.getPlainContent.removeSelectors.push("a.PostMention"),(0,r.extend)(p().prototype,"oncreate",(function(){this.$(".GroupMention--colored, .TagMention--colored").each((function(){this.classList.add(l()(getComputedStyle(this).getPropertyValue("--color")))}))}))})),Object.assign(Au.compat,Cu)})(),module.exports=n})();
|
|
//# sourceMappingURL=forum.js.map
|