diff --git a/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts b/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts index 303171287c..e5914ffe97 100644 --- a/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts +++ b/framework/core/js/dist-typings/forum/components/HeaderPrimary.d.ts @@ -1,16 +1,16 @@ +import Component from '../../common/Component'; +import ItemList from '../../common/utils/ItemList'; +import type Mithril from 'mithril'; /** * The `HeaderPrimary` component displays primary header controls. On the * default skin, these are shown just to the right of the forum title. */ -export default class HeaderPrimary extends Component { - constructor(); +export default class HeaderPrimary extends Component { view(): JSX.Element; /** * Build an item list for the controls. * * @return {ItemList} */ - items(): ItemList; + items(): ItemList; } -import Component from "../../common/Component"; -import ItemList from "../../common/utils/ItemList"; diff --git a/framework/core/js/dist/forum.js b/framework/core/js/dist/forum.js index 53f302c7b5..352e133926 100644 --- a/framework/core/js/dist/forum.js +++ b/framework/core/js/dist/forum.js @@ -1,3 +1,3 @@ /*! For license information please see forum.js.LICENSE.txt */ -(()=>{var t,e,r={6997:(t,e,r)=>{"use strict";r.d(e,{A:()=>L});var n=r(8805),s=r(5114),o=r(6064),i=r(7880),a=r(1344),l=r(4519),c=r(7088),u=r(7141),d=r(3984),h=r(3957),f=r(4586),p=r(117),g=r(8781),v=r(6987),b=r(1810),y=r(2361),A=r(76),w=r(4022),x=r(281),k=r(5223),C=r(7390),N=r(2288),S=r(4583),T=r(3945),E=r(4944),P=r(2217),M=r(8286),D=r(2891),I=r(1467),_=r(2188);class L{constructor(){(0,n.A)(this,"forum",void 0),(0,n.A)(this,"routes",{}),(0,n.A)(this,"initializers",new o.A),(0,n.A)(this,"session",void 0),(0,n.A)(this,"translator",new u.A),(0,n.A)(this,"store",new d.A({"access-tokens":I.A,forums:x.A,users:k.A,discussions:C.A,posts:N.A,groups:S.A,notifications:T.A})),(0,n.A)(this,"search",void 0),(0,n.A)(this,"cache",{}),(0,n.A)(this,"booted",!1),(0,n.A)(this,"current",new E.A(null)),(0,n.A)(this,"previous",new E.A(null)),(0,n.A)(this,"modal",new P.A),(0,n.A)(this,"alerts",new M.A),(0,n.A)(this,"drawer",void 0),(0,n.A)(this,"history",null),(0,n.A)(this,"pane",null),(0,n.A)(this,"data",void 0),(0,n.A)(this,"allowUserColorScheme",void 0),(0,n.A)(this,"refs",{fontawesome:"https://fontawesome.com/v6/icons?o=r&m=free"}),(0,n.A)(this,"_title",""),(0,n.A)(this,"_titleCount",0),(0,n.A)(this,"requestErrorAlert",null),(0,n.A)(this,"initialRoute",void 0)}set title(t){this._title=t}get title(){return this._title}set titleCount(t){this._titleCount=t}get titleCount(){return this._titleCount}load(t){this.data=t,this.translator.setLocale(t.locale)}initialize(){const t=[];return this.initializers.toArray().forEach((e=>{try{e(this)}catch(r){const n=e.itemName.includes("/")?e.itemName.replace(/(\/flarum-ext-)|(\/flarum-)/g,"-"):e.itemName;t.push((()=>(0,D.A)((0,p.A)(s.A.translator.trans("core.lib.error.extension_initialiation_failed_message",{extension:n})),"".concat(n," failed to initialize"),r)))}})),t}boot(){var t;const e=this.initialize();this.store.pushPayload({data:this.data.resources}),this.forum=this.store.getById("forums","1"),this.session=new h.A(null!=(t=this.store.getById("users",String(this.data.session.userId)))?t:null,this.data.session.csrfToken),this.beforeMount(),this.mount(),this.initialRoute=window.location.href,e.forEach((t=>t()))}beforeMount(){}bootExtensions(t){Object.keys(t).forEach((e=>{const r=t[e];if(!r.extend)return;const n=r.extend.flat(1/0);for(const t of n)t.extend(this,{name:e,exports:r})}))}mount(t){void 0===t&&(t=""),m.mount(document.getElementById("modal"),{view:()=>m(a.A,{state:this.modal})}),m.mount(document.getElementById("alerts"),{view:()=>m(l.A,{state:this.alerts})}),this.drawer=new g.A,m.route(document.getElementById("content"),t+"/",(0,v.A)(this.routes,t));const e=document.getElementById("app"),r=document.querySelector(".App-header"),n=new y.A((t=>{const n=e.getBoundingClientRect().top+document.body.scrollTop;e.classList.toggle("affix",t>=n),e.classList.toggle("scrolled",t>n),r.classList.toggle("navbar-fixed-top",t>=n)}));n.start(),n.update(),document.body.classList.add("ontouchstart"in window?"touch":"no-touch"),this.initColorScheme(),(0,A.A)()}initColorScheme(t){var e,r;void 0===t&&(t=null),null!=t||(t=null!=(e=s.A.forum.attribute("colorScheme"))?e:"auto"),this.allowUserColorScheme="auto"===t;const n=null==(r=this.session.user)||null==(r=r.preferences())?void 0:r.colorScheme;let o;this.allowUserColorScheme&&(o=n),o||(o=t),this.setColorScheme(o),this.allowUserColorScheme&&this.watchSystemColorSchemePreference((()=>{this.initColorScheme(t)}))}getSystemColorSchemePreference(){let t=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return window.matchMedia("(prefers-contrast: more)").matches&&(t+="-hc"),t}watchSystemColorSchemePreference(t){window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),window.matchMedia("(prefers-contrast: more)").addEventListener("change",t)}setColorScheme(t){t===_.z.Auto&&(t=this.getSystemColorSchemePreference()),document.documentElement.setAttribute("data-theme",t)}setColoredHeader(t){document.documentElement.setAttribute("data-colored-header",t?"true":"false")}preloadedApiDocument(){if(this.data.apiDocument&&window.location.href===this.initialRoute){const t=((0,d.J)(this.data.apiDocument),this.store.pushPayload(this.data.apiDocument));return this.data.apiDocument=null,t}return null}screen(){return getComputedStyle(document.documentElement).getPropertyValue("--flarum-screen")}setTitle(t){this.title=t,this.updateTitle()}setTitleCount(t){this.titleCount=t,this.updateTitle()}updateTitle(){const t=this.titleCount?"(".concat(this.titleCount,") "):"",e=m.route.get()===this.forum.attribute("basePath")+"/",r={pageTitle:this.title,forumName:this.forum.attribute("title"),pageNumber:1};let n=e||!this.title?(0,p.A)(s.A.translator.trans("core.lib.meta_titles.without_page_title",r)):(0,p.A)(s.A.translator.trans("core.lib.meta_titles.with_page_title",r));n=t+n;const o=new DOMParser;document.title=o.parseFromString(n,"text/html").body.innerText}transformRequestOptions(t){const{background:e,deserialize:r,modifyText:n,...o}={...t},i={background:null==e||e,deserialize:null!=r?r:t=>t,...o};if((0,w.X)(i,"config",((t,e)=>{e.setRequestHeader("X-CSRF-Token",this.session.csrfToken)})),i.method&&!["GET","POST"].includes(i.method)){const t=i.method;(0,w.X)(i,"config",((e,r)=>{r.setRequestHeader("X-HTTP-Method-Override",t)})),i.method="POST"}return i.extract=t=>{let e;e=n?n(t.responseText):t.responseText;const r=t.status;if(r<200||r>299)throw new b.A(r,"".concat(e),i,t);if(t.getResponseHeader){const e=t.getResponseHeader("X-CSRF-Token");e&&(s.A.session.csrfToken=e)}try{return""===e?null:JSON.parse(e)}catch(r){throw new b.A(500,"".concat(e),i,t)}},i}request(t){const e=this.transformRequestOptions(t);return this.requestErrorAlert&&this.alerts.dismiss(this.requestErrorAlert),m.request(e).catch((e=>this.requestErrorCatch(e,t.errorHandler)))}requestErrorCatch(t,e){var r,n,o,a;const l=null!=(r=null==(n=t.response)||null==(n=n.errors)?void 0:n.map((t=>{var e;return decodeURI(null!=(e=t.detail)?e:"")})))?r:[];let c;switch(t.status){case 422:c=l.map((t=>[t,m("br",null)])).flat().slice(0,-1);break;case 401:case 403:c=s.A.translator.trans("core.lib.error.permission_denied_message");break;case 404:case 410:c=s.A.translator.trans("core.lib.error.not_found_message");break;case 413:c=s.A.translator.trans("core.lib.error.payload_too_large_message");break;case 429:c=s.A.translator.trans("core.lib.error.rate_limit_exceeded_message");break;default:c="db_error"===(null==(o=t.response)||null==(o=o.errors)||null==(o=o[0])?void 0:o.code)&&null!=(a=s.A.session.user)&&a.isAdmin()?s.A.translator.trans("core.lib.error.db_error_message"):this.requestWasCrossOrigin(t)?s.A.translator.trans("core.lib.error.generic_cross_origin_message"):s.A.translator.trans("core.lib.error.generic_message")}const u=s.A.forum.attribute("debug");return t.alert={type:"error",content:c,controls:u&&[m(i.A,{className:"Button Button--link",onclick:this.showDebug.bind(this,t,l)},s.A.translator.trans("core.lib.debug_button"))]},e?e(t):this.requestErrorDefaultHandler(t,u,l),Promise.reject(t)}requestWasCrossOrigin(t){return new URL(t.options.url,document.baseURI).origin!==window.location.origin}requestErrorDefaultHandler(t,e,r){if(!(t instanceof b.A))throw t;if(e&&t.xhr){const{method:e,url:n}=t.options,{status:s=""}=t.xhr;console.group("".concat(e," ").concat(n," ").concat(s)),r.length?console.error(...r):console.error(t),console.groupEnd()}500===t.status&&e?s.A.modal.show(c.A,{error:t,formattedError:r}):t.alert&&(this.requestErrorAlert=this.alerts.show(t.alert,t.alert.content))}showDebug(t,e){null!==this.requestErrorAlert&&this.alerts.dismiss(this.requestErrorAlert),this.modal.show(c.A,{error:t,formattedError:e})}route(t,e){void 0===e&&(e={});const r=this.routes[t];if(!r)throw new Error("Route '".concat(t,"' does not exist"));const n=r.path.replace(/:([^\/]+)/g,((t,r)=>"".concat((0,f.A)(e,r))));for(const t in e)e.hasOwnProperty(t)&&!e[t]&&delete e[t];const s=m.buildQueryString(e);return(""===m.route.prefix?this.forum.attribute("basePath"):"")+n+(s?"?"+s:"")}}flarum.reg.add("core","common/Application",L)},5710:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});var n=r(8805);class s{constructor(){(0,n.A)(this,"element",void 0),(0,n.A)(this,"attrs",void 0),(0,n.A)(this,"state",void 0)}oninit(t){this.setAttrs(t.attrs)}oncreate(t){this.element=t.dom}onbeforeupdate(t){this.setAttrs(t.attrs)}onupdate(t){}onbeforeremove(t){}onremove(t){}$(t){const e=$(this.element);return t?e.find(t):e}static component(t,e){void 0===t&&(t={}),void 0===e&&(e=null);const r={...t};return m(this,r,e)}setAttrs(t){if(void 0===t&&(t={}),this.constructor.initAttrs(t),t){if("children"in t)throw new Error("[".concat(this.constructor.name,'] The "children" attribute of attrs should never be used. Either pass children in as the vnode children or rename the attribute'));if("tag"in t)throw new Error("[".concat(this.constructor.name,'] You cannot use the "tag" attribute name with Mithril 2.'))}this.attrs=t}static initAttrs(t){}}flarum.reg.add("core","common/Component",s)},5420:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(8805),s=r(5114);class o{constructor(t,e){void 0===t&&(t={}),void 0===e&&(e=s.A.store),(0,n.A)(this,"data",{}),(0,n.A)(this,"freshness",new Date),(0,n.A)(this,"exists",!1),(0,n.A)(this,"store",void 0),this.data=t,this.store=e}id(){return"id"in this.data?this.data.id:void 0}attribute(t){var e;return null==(e=this.data)||null==(e=e.attributes)?void 0:e[t]}pushData(t){if("id"in t&&(this.data.id=t.id),"type"in t&&(this.data.type=t.type),"attributes"in t){var e;(e=this.data).attributes||(e.attributes={});for(const e in t.attributes){const r=t.attributes[e];r&&r instanceof o&&delete t.attributes[e]}Object.assign(this.data.attributes,t.attributes)}if("relationships"in t){var r;const e=null!=(r=this.data.relationships)?r:{};for(const r in t.relationships){const n=t.relationships[r];if(null===n){delete e[r],delete t.relationships[r];continue}let s;s=n instanceof o?{data:o.getIdentifier(n)}:n instanceof Array?{data:n.map(o.getIdentifier)}:n,t.relationships[r]=s,e[r]=s}this.data.relationships=e}return this.freshness=new Date,this}pushAttributes(t){this.pushData({attributes:t})}save(t,e){void 0===e&&(e={});const r={type:this.data.type,attributes:t};if("id"in this.data&&(r.id=this.data.id),t.relationships){r.relationships={};for(const e in t.relationships){const n=t.relationships[e];null!==n&&(r.relationships[e]={data:n instanceof Array?n.map(o.getIdentifier):o.getIdentifier(n)})}delete t.relationships}const n=this.copyData();this.pushData(r);const i={data:r,meta:e.meta||void 0};return s.A.request({method:this.exists?"PATCH":"POST",url:s.A.forum.attribute("apiUrl")+this.apiEndpoint(),body:i,...e}).then((t=>this.store.pushPayload(t)),(t=>{throw this.pushData(n),m.redraw(),t}))}delete(t,e){return void 0===t&&(t={}),void 0===e&&(e={}),this.exists?s.A.request({method:"DELETE",url:s.A.forum.attribute("apiUrl")+this.apiEndpoint(),body:t,...e}).then((()=>{this.exists=!1,this.store.remove(this)})):Promise.resolve()}apiEndpoint(){return"/"+this.data.type+("id"in this.data?"/"+this.data.id:"")}copyData(){return JSON.parse(JSON.stringify(this.data))}rawRelationship(t){var e;return null==(e=this.data.relationships)||null==(e=e[t])?void 0:e.data}static attribute(t,e){return function(){return e?e(this.attribute(t)):this.attribute(t)}}static hasOne(t){return function(){var e;const r=null==(e=this.data.relationships)||null==(e=e[t])?void 0:e.data;if(r&&r instanceof Array)throw new Error("Relationship ".concat(t," on model ").concat(this.data.type," is plural, so the hasOne method cannot be used to access it."));return!!r&&this.store.getById(r.type,r.id)}}static hasMany(t){return function(){var e;const r=null==(e=this.data.relationships)||null==(e=e[t])?void 0:e.data;if(r&&!(r instanceof Array))throw new Error("Relationship ".concat(t," on model ").concat(this.data.type," is singular, so the hasMany method cannot be used to access it."));return!!r&&r.map((t=>this.store.getById(t.type,t.id)))}}static transformDate(t){return null!=t?new Date(t):t}static getIdentifier(t){return t&&t.data&&"id"in t.data?{type:t.data.type,id:t.data.id}:null}}flarum.reg.add("core","common/Model",o)},3920:(t,e,r)=>{"use strict";r.d(e,{A:()=>f});var n=r(8805),s=r(5114),o=r(8631);class i extends o.px{key(){return s.A.translator.trans("core.lib.gambits.discussions.author.key",{},!0)}hint(){return s.A.translator.trans("core.lib.gambits.discussions.author.hint",{},!0)}filterKey(){return"author"}}flarum.reg.add("core","common/query/discussions/AuthorGambit",i);class a extends o.px{key(){return s.A.translator.trans("core.lib.gambits.discussions.created.key",{},!0)}hint(){return s.A.translator.trans("core.lib.gambits.discussions.created.hint",{},!0)}valuePattern(){return"(\\d{4}\\-\\d\\d\\-\\d\\d(?:\\.\\.(\\d{4}\\-\\d\\d\\-\\d\\d))?)"}filterKey(){return"created"}}flarum.reg.add("core","common/query/discussions/CreatedGambit",a);class l extends o.pm{key(){return s.A.translator.trans("core.lib.gambits.discussions.hidden.key",{},!0)}filterKey(){return"hidden"}enabled(){return!!s.A.session.user}}flarum.reg.add("core","common/query/discussions/HiddenGambit",l);class c extends o.pm{key(){return s.A.translator.trans("core.lib.gambits.discussions.unread.key",{},!0)}filterKey(){return"unread"}enabled(){return!!s.A.session.user}}flarum.reg.add("core","common/query/discussions/UnreadGambit",c);class u extends o.px{key(){return s.A.translator.trans("core.lib.gambits.users.email.key",{},!0)}hint(){return s.A.translator.trans("core.lib.gambits.users.email.hint",{},!0)}filterKey(){return"email"}enabled(){return!(!s.A.session.user||!s.A.forum.attribute("canEditUserCredentials"))}}flarum.reg.add("core","common/query/users/EmailGambit",u);class d extends o.px{key(){return s.A.translator.trans("core.lib.gambits.users.group.key",{},!0)}hint(){return s.A.translator.trans("core.lib.gambits.users.group.hint",{},!0)}filterKey(){return"group"}}flarum.reg.add("core","common/query/users/GroupGambit",d);class h extends o.px{key(){return s.A.translator.trans("core.lib.gambits.posts.discussion.key",{},!0)}hint(){return s.A.translator.trans("core.lib.gambits.posts.discussion.hint",{},!0)}filterKey(){return"discussion"}}flarum.reg.add("core","common/query/discussions/DiscussionGambit",h);class m{constructor(){(0,n.A)(this,"gambits",{discussions:[i,a,l,c],posts:[i,h],users:[u,d]})}apply(t,e){return e.q=this.match(t,e.q,((t,r,n)=>{const s=t.toFilter(r,n);Object.keys(s).forEach((r=>{r in e&&t.predicates&&Array.isArray(s[r])?e[r]=e[r].concat(s[r]):e[r]=s[r]}))})),e}match(t,e,r){const n=this.for(t).filter((t=>t.enabled()));if(0===n.length)return e;const s=e.split(" ");for(const t of n)for(const n of s){const s=new RegExp("^(-?)".concat(t.pattern(),"$"),"i");let o=n.match(s);if(o){const s="-"===o[1];o.splice(1,1),r(t,o,s,n),e=e.replace(n,"")}}return e.trim().replace(/\s+/g," ")}from(t,e,r){const n=this.for(t);return 0===n.length||Object.keys(r).forEach((t=>{for(const s of n){const n="-"===t[0];n&&(t=t.substring(1)),s.filterKey()===t&&(e+=" ".concat(s.fromFilter(r[t],n)))}})),e}for(t){return(this.gambits[t]||[]).map((t=>new t))}}flarum.reg.add("core","common/GambitManager",m);class f{constructor(t){(0,n.A)(this,"state",void 0),(0,n.A)(this,"gambits",new m),this.state=t}}(0,n.A)(f,"MIN_SEARCH_LEN",3),flarum.reg.add("core","common/SearchManager",f)},3957:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(8805),s=r(5114);class o{constructor(t,e){(0,n.A)(this,"user",void 0),(0,n.A)(this,"csrfToken",void 0),this.user=t,this.csrfToken=e}login(t,e){return void 0===e&&(e={}),s.A.request({method:"POST",url:"".concat(s.A.forum.attribute("baseUrl"),"/login"),body:t,...e})}logout(){window.location.href="".concat(s.A.forum.attribute("baseUrl"),"/logout?token=").concat(this.csrfToken)}}flarum.reg.add("core","common/Session",o)},3984:(t,e,r)=>{"use strict";r.d(e,{A:()=>i,J:()=>o});var n=r(8805),s=r(5114);function o(t){return Array.isArray(t.data)}class i{constructor(t){(0,n.A)(this,"data",{}),(0,n.A)(this,"models",void 0),this.models=t}pushPayload(t){t.included&&t.included.map(this.pushObject.bind(this));const e=t.data instanceof Array?t.data.map((t=>this.pushObject(t))):this.pushObject(t.data);return e.payload=t,e}pushObject(t){if(!this.models[t.type])return setTimeout((()=>{throw new Error("Pushing object of type `".concat(t.type,"` not allowed, as type not yet registered in the store."))})),null;const e=this.data[t.type]=this.data[t.type]||{},r=e[t.id],n=r?r.pushData(t):this.createRecord(t.type,t);return e[t.id]=n,n.exists=!0,n}async find(t,e,r,n){var i;void 0===r&&(r={}),void 0===n&&(n={});let a=r,l=s.A.forum.attribute("apiUrl")+"/"+t;return e instanceof Array?l+="?filter[id]="+e.join(","):"object"==typeof e?a=e:e&&(l+="/"+e),"filter"in a&&null!=(i=a)&&null!=(i=i.filter)&&i.q&&(a.filter=s.A.search.gambits.apply(t,a.filter)),s.A.request({method:"GET",url:l,params:a,...n}).then((t=>(o(t),this.pushPayload(t))))}getById(t,e){var r;return null==(r=this.data)||null==(r=r[t])?void 0:r[e]}getBy(t,e,r){return this.all(t).filter((t=>t[e]()===r))[0]}all(t){const e=this.data[t];return e?Object.values(e):[]}remove(t){delete this.data[t.data.type][t.id()]}createRecord(t,e){return void 0===e&&(e={}),e.type=e.type||t,new this.models[t](e,this)}}flarum.reg.add("core","common/Store",i)},7141:(t,e,r)=>{"use strict";r.d(e,{A:()=>c});var n=r(8805),s=r(8687),o=r(4856),i=r(6445),a=r(4586),l=r(117);class c{constructor(){(0,n.A)(this,"translations",{}),(0,n.A)(this,"formatter",new s.A5(null,this.formatterTypeHandlers(),s.S))}setLocale(t){this.formatter.locale=t}getLocale(){return this.formatter.locale}addTranslations(t){Object.assign(this.translations,t)}formatterTypeHandlers(){return{plural:o.fL,select:o.Jb}}preprocessParameters(t){if("user"in t){const e=(0,a.A)(t,"user");t.username||(t.username=(0,i.A)(e))}return t}trans(t,e,r){void 0===e&&(e={}),void 0===r&&(r=!1);const n=this.translations[t];if(n){e=this.preprocessParameters(e);const t=this.formatter.rich(n,e);return r?(0,l.A)(t):t}return t}}flarum.reg.add("core","common/Translator",c)},5114:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});const n=window,s=new Proxy({},{get:(t,e)=>Reflect.get(n.app,e,n.app),set:(t,e,r)=>Reflect.set(n.app,e,r,n.app)}),o=s;flarum.reg.add("core","common/app",s)},9924:(t,e,r)=>{"use strict";r.d(e,{A:()=>u});var n=r(5710),s=r(7880),o=r(5673),i=r(4586),a=r(4268),l=r(5114),c=r(7479);class u extends n.A{view(t){const e=Object.assign({},this.attrs),r=(0,i.A)(e,"type");e.className=(0,a.A)("Alert","Alert--".concat(r),e.className);const n=(0,i.A)(e,"title"),u=(0,i.A)(e,"icon"),d=(0,i.A)(e,"content")||t.children,h=(0,i.A)(e,"controls")||[],f=(0,i.A)(e,"dismissible"),p=(0,i.A)(e,"ondismiss"),g=[];return(f||void 0===f)&&g.push(m(s.A,{"aria-label":l.A.translator.trans("core.lib.alert.dismiss_a11y_label"),icon:"fas fa-times",className:"Button Button--link Button--icon Alert-dismiss",onclick:p})),m("div",e,m("div",{className:(0,a.A)("Alert-container",e.containerClassName)},!!n&&m("div",{className:"Alert-title"},!!u&&m("span",{className:"Alert-title-icon"},m(c.A,{name:u})),m("span",{className:"Alert-title-text"},n)),m("span",{className:"Alert-body"},d),m("ul",{className:"Alert-controls"},(0,o.A)(h.concat(g)))))}}flarum.reg.add("core","common/components/Alert",u)},4519:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});var n=r(5710);class s extends n.A{oninit(t){super.oninit(t),this.state=this.attrs.state}view(){const t=this.state.getActiveAlerts();return m("div",{className:"AlertManager"},Object.keys(t).map(Number).map((e=>{const r=t[e],n="error"===r.attrs.type;return m("div",{className:"AlertManager-alert",role:"alert","aria-live":n?"assertive":"polite"},m(r.componentClass,Object.assign({},r.attrs,{ondismiss:this.state.dismiss.bind(this.state,e)}),r.children))})))}}flarum.reg.add("core","common/components/AlertManager",s)},7891:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(4268),s=r(5710);class o extends s.A{view(t){const{user:e,...r}=t.attrs;r.className=(0,n.A)("Avatar",r.className),null!=r.loading||(r.loading="lazy");let s="";const o="undefined"===r.title||r.title;if(o||delete r.title,e){const t=e.displayName()||"?",n=e.avatarUrl();if(o&&(r.title=r.title||t),n)return m("img",Object.assign({},r,{src:n,alt:""}));s=t.charAt(0).toUpperCase(),r.style=!window.testing&&{"--avatar-bg":e.color()}}return m("span",r,s)}}flarum.reg.add("core","common/components/Avatar",o)},367:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var n=r(4391),s=r(5710),o=r(4268),i=r(3288),a=r(7479);class l extends s.A{view(){const{type:t,icon:e,label:r,color:s,style:l={},...c}=this.attrs,u=(0,o.A)("Badge",[t&&"Badge--".concat(t)],c.className,(0,i.A)(s)),d=e?m(a.A,{name:e,className:"Badge-icon"}):m.trust(" "),h={...l};window.testing||(h["--badge-bg"]=s);const f={...c,className:u,style:h},p=m("div",f,d);return r?m(n.A,{text:r},p):p}}flarum.reg.add("core","common/components/Badge",l)},7880:(t,e,r)=>{"use strict";r.d(e,{A:()=>u});var n=r(5710),s=r(5114);function o(){s.A.forum.attribute("debug")&&console.warn(...arguments)}flarum.reg.add("core","common/helpers/fireDebugWarning",o);var i=r(4268),a=r(117),l=r(43),c=r(7479);class u extends n.A{view(t){let{type:e,"aria-label":r,icon:n,disabled:s,loading:o,className:l,class:c,...u}=this.attrs;e||(e="button"),"object"==typeof r&&(r=(0,a.A)(r)),(s||o)&&delete u.onclick,l=(0,i.A)(c,l,{hasIcon:n,disabled:s||o,loading:o});const d={disabled:s,className:l,type:e,"aria-label":r,...u};return m("button",d,this.getButtonContent(t.children))}oncreate(t){var e,r;super.oncreate(t);const{"aria-label":n}=this.attrs;this.view!==u.prototype.view||n||(0,a.A)(t.children)||null!=(e=this.element)&&null!=(r=e.getAttribute)&&r.call(e,"aria-label")||o('[Flarum Accessibility Warning] Button has no content and no accessible label. This means that screen-readers will not be able to interpret its meaning and just read "Button". Consider providing accessible text via the `aria-label` attribute. https://web.dev/button-name',this.element)}getButtonContent(t){const e=this.attrs.icon;return[e&&m(c.A,{name:e,className:"Button-icon"}),t&&m("span",{className:"Button-label"},t),this.attrs.loading&&m(l.A,{size:"small",display:"inline"})]}}flarum.reg.add("core","common/components/Button",u)},5215:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var n=r(5710),s=r(43),o=r(4268),i=r(9024),a=r(7479);class l extends n.A{view(t){const e=(0,o.A)(["Checkbox",this.attrs.state?"on":"off",this.attrs.className,this.attrs.loading&&"loading",this.attrs.disabled&&"disabled"]);return m("label",{className:e},m("input",{type:"checkbox",checked:this.attrs.state,disabled:this.attrs.disabled,onchange:(0,i.A)("checked",this.onchange.bind(this))}),m("div",{className:"Checkbox-display","aria-hidden":"true"},this.getDisplay()),t.children)}getDisplay(){return this.attrs.loading?m(s.A,{display:"unset",size:"small"}):m(a.A,{name:this.attrs.state?"fas fa-check":"fas fa-times"})}onchange(t){this.attrs.onchange&&this.attrs.onchange(t,this)}}flarum.reg.add("core","common/components/Checkbox",l)},4511:(t,e,r)=>{"use strict";r.d(e,{A:()=>u});var n=r(8805),s=r(5114),o=r(5710),i=r(5673),a=r(117),l=r(4391),c=r(7479);class u extends o.A{constructor(){super(...arguments),(0,n.A)(this,"showing",!1)}static initAttrs(t){t.className||(t.className=""),t.buttonClassName||(t.buttonClassName=""),t.menuClassName||(t.menuClassName=""),t.label||(t.label=""),null!=t.caretIcon||(t.caretIcon="fas fa-caret-down"),t.accessibleToggleLabel||(t.accessibleToggleLabel=(0,a.A)(s.A.translator.trans("core.lib.dropdown.toggle_dropdown_accessible_label")))}view(t){const e=t.children?(0,i.A)(t.children):[],r=!this.attrs.lazyDraw||this.showing;return m("div",{className:"ButtonGroup Dropdown dropdown "+this.attrs.className+" itemCount"+e.length+(this.showing?" open":"")},this.getButton(t.children),r&&this.getMenu(e))}oncreate(t){super.oncreate(t),this.$().on("shown.bs.dropdown",(()=>{var t,e,r,n,s,o,i,a,l,c,u;const{lazyDraw:d,onshow:h}=this.attrs;this.showing=!0,d&&m.redraw.sync(),"function"==typeof h&&h(),d||m.redraw();const f=this.$(".Dropdown-menu"),p=f.hasClass("Dropdown-menu--right"),g=null!=(t=null==(e=f.offset())?void 0:e.top)?t:0,v=null!=(r=f.height())?r:0,b=null!=(n=$(window).scrollTop())?n:0,y=null!=(s=$(window).height())?s:0;f.removeClass("Dropdown-menu--top Dropdown-menu--right"),f.toggleClass("Dropdown-menu--top",g+v>b+y),((null==(o=f.offset())?void 0:o.top)||0)<0&&f.removeClass("Dropdown-menu--top");const A=null!=(i=null==(a=f.offset())?void 0:a.left)?i:0,w=null!=(l=f.width())?l:0,x=null!=(c=$(window).scrollLeft())?c:0,k=null!=(u=$(window).width())?u:0;f.toggleClass("Dropdown-menu--right",p||A+w>x+k)})),this.$().on("hidden.bs.dropdown",(()=>{this.showing=!1,this.attrs.onhide&&this.attrs.onhide(),m.redraw()}))}getButton(t){let e=m("button",Object.assign({className:"Dropdown-toggle "+this.attrs.buttonClassName,"aria-haspopup":"menu","aria-label":this.attrs.accessibleToggleLabel,"data-toggle":"dropdown",onclick:this.attrs.onclick},this.attrs.buttonAttrs),this.getButtonContent(t));return this.attrs.tooltip&&(e=m(l.A,{text:this.attrs.tooltip,position:"bottom"},e)),e}getButtonContent(t){return[this.attrs.icon?m(c.A,{name:this.attrs.icon,className:"Button-icon"}):"",m("span",{className:"Button-label"},this.attrs.label),this.attrs.caretIcon?m(c.A,{name:this.attrs.caretIcon,className:"Button-caret"}):""]}getMenu(t){return m("ul",{className:"Dropdown-menu dropdown-menu "+this.attrs.menuClassName},t)}}flarum.reg.add("core","common/components/Dropdown",u)},592:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(5710),s=r(4268);class o extends n.A{view(t){return m("div",{className:(0,s.A)("FieldSet",this.attrs.className),role:"group","aria-label":this.attrs.label,"aria-disabled":!1},m("label",{className:"FieldSet-label","aria-hidden":"true"},this.attrs.label),this.attrs.description?m("div",{className:"FieldSet-description helpText"},this.attrs.description):null,m("div",{className:"FieldSet-items"},t.children))}}flarum.reg.add("core","common/components/FieldSet",o)},374:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(5710),s=r(4268);class o extends n.A{view(t){const{label:e,description:r,className:n,...o}=t.attrs;return m("div",Object.assign({className:(0,s.A)("Form",n)},o),(e||r)&&m("div",{className:"Form-header"},e&&m("label",null,e),r&&m("p",{className:"helpText"},r)),m("div",{className:"Form-body"},t.children))}}flarum.reg.add("core","common/components/Form",o)},2855:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});var n=r(2849);class s extends n.A{wrapper(t){return m("form",{onsubmit:this.onsubmit.bind(this)},t)}onsubmit(t){}onready(){this.$().find("input, select, textarea").first().trigger("focus").trigger("select")}onerror(t){var e;this.alertAttrs=t.alert,m.redraw(),422===t.status&&null!=(e=t.response)&&e.errors?this.$("form [name="+t.response.errors[0].source.pointer.replace("/data/attributes/","")+"]").trigger("select"):this.onready()}}flarum.reg.add("core","common/components/FormModal",s)},3550:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});var n=r(367);class s extends n.A{static initAttrs(t){super.initAttrs(t),t.group&&(t.icon=t.group.icon()||"",t.color=t.group.color()||"",t.label=void 0===t.label?t.group.nameSingular():t.label,t.type="group--"+t.group.id(),delete t.group)}}flarum.reg.add("core","common/components/GroupBadge",s)},7479:(t,e,r)=>{"use strict";r.d(e,{A:()=>o});var n=r(4268),s=r(5710);class o extends s.A{view(t){const{name:e,...r}=t.attrs;return r.className=(0,n.A)("icon",e,r.className),m("i",Object.assign({"aria-hidden":"true"},r))}}flarum.reg.add("core","common/components/Icon",o)},4164:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});var n=r(5710),s=r(7479),o=r(4268);class i extends n.A{view(t){const{icon:e,className:r,...n}=t.attrs;return m("div",Object.assign({className:(0,o.A)("InfoTile",r)},n),this.icon(),m("div",{className:"InfoTile-text"},t.children))}icon(){return this.attrs.iconElement?this.attrs.iconElement:this.attrs.icon?m(s.A,{name:(0,o.A)(this.attrs.icon,"InfoTile-icon")}):null}}flarum.reg.add("core","common/components/InfoTile",i)},7882:(t,e,r)=>{"use strict";r.d(e,{A:()=>c});var n=r(5114),s=r(5710),o=r(7479),i=r(43),a=r(4268),l=r(7880);class c extends s.A{oninit(t){super.oninit(t)}view(t){var e,r;const{className:s,...c}=this.attrs.inputAttrs||{},u=this.attrs.value||(null==(e=(r=this.attrs).stream)?void 0:e.call(r))||"";return m("div",{className:(0,a.A)("Input",this.attrs.className,{"Input--withPrefix":this.attrs.prefixIcon,"Input--withClear":this.attrs.clearable})},this.attrs.prefixIcon&&m(o.A,{name:(0,a.A)(this.attrs.prefixIcon,"Input-prefix-icon")}),this.input({inputClassName:s,value:u,inputAttrs:c}),this.attrs.loading&&m(i.A,{size:"small",display:"inline",containerClassName:"Button Button--icon Button--link"}),this.attrs.clearable&&u&&!this.attrs.loading&&m(l.A,{className:"Input-clear Button Button--icon Button--link",onclick:this.clear.bind(this),"aria-label":this.attrs.clearLabel||n.A.translator.trans("core.lib.input.clear_button"),type:"button",icon:"fas fa-times-circle"}))}input(t){let{inputClassName:e,value:r,inputAttrs:n}=t;const s={className:(0,a.A)("FormControl",e),type:this.attrs.type||"text",value:r,oninput:t=>{var e;return null==(e=this.onchange)?void 0:e.call(this,t.target.value)},"aria-label":this.attrs.ariaLabel,placeholder:this.attrs.placeholder,readonly:this.attrs.readonly||void 0,disabled:this.attrs.disabled||void 0,...n};return this.attrs.renderInput?this.attrs.renderInput(s):m("input",s)}onchange(t){var e,r;this.attrs.stream?this.attrs.stream(t):null==(e=(r=this.attrs).onchange)||e.call(r,t)}clear(){this.onchange("")}}flarum.reg.add("core","common/components/Input",c)},43:(t,e,r)=>{"use strict";r.d(e,{A:()=>i});var n=r(5114),s=r(5710),o=r(4268);class i extends s.A{view(){const{display:t="block",size:e="medium",containerClassName:r,className:s,...i}=this.attrs,a=(0,o.A)("LoadingIndicator",s),l=(0,o.A)("LoadingIndicator-container","unset"!==t&&"LoadingIndicator-container--".concat(t),e&&"LoadingIndicator-container--".concat(e),r);return m("div",Object.assign({"aria-label":n.A.translator.trans("core.lib.loading_indicator.accessible_label"),role:"status"},i.containerAttrs,{"data-size":e,className:l}),m("div",Object.assign({"aria-hidden":"true",className:a},i)))}}flarum.reg.add("core","common/components/LoadingIndicator",i)},2849:(t,e,r)=>{"use strict";r.d(e,{A:()=>c});var n=r(8805),s=r(5114),o=r(5710),i=r(9924),a=r(7880),l=r(4268);class c extends o.A{constructor(){super(...arguments),(0,n.A)(this,"loading",!1),(0,n.A)(this,"alertAttrs",null)}static get dismissibleOptions(){return{viaCloseButton:this.isDismissibleViaCloseButton,viaEscKey:this.isDismissibleViaEscKey,viaBackdropClick:this.isDismissibleViaBackdropClick}}oncreate(t){super.oncreate(t),this.attrs.animateShow((()=>this.onready()))}onbeforeremove(t){if(super.onbeforeremove(t),!this.attrs.state.modal)return new Promise((t=>setTimeout(t,300)))}view(){return this.alertAttrs&&(this.alertAttrs.dismissible=!1),m("div",{className:(0,l.A)("Modal modal-dialog fade",this.className())},m("div",{className:"Modal-content"},this.dismissibleOptions.viaCloseButton&&m("div",{className:"Modal-close App-backControl"},m(a.A,{icon:"fas fa-times",onclick:()=>this.hide(),className:"Button Button--icon Button--link","aria-label":s.A.translator.trans("core.lib.modal.close")})),this.wrapper(this.inner())))}wrapper(t){return m("[",null,t)}inner(){return m("[",null,m("div",{className:"Modal-header"},m("h3",{className:"App-titleControl App-titleControl--text"},this.title())),!!this.alertAttrs&&m("div",{className:"Modal-alert"},m(i.A,this.alertAttrs)),this.content())}onready(){}hide(){this.attrs.animateHide()}loaded(){this.loading=!1,m.redraw()}get dismissibleOptions(){return this.constructor.dismissibleOptions}}(0,n.A)(c,"isDismissibleViaCloseButton",!0),(0,n.A)(c,"isDismissibleViaEscKey",!0),(0,n.A)(c,"isDismissibleViaBackdropClick",!0),flarum.reg.add("core","common/components/Modal",c)},1344:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var n=r(8805),s=r(5710),o=r(8720),i=r(4945),a=r(43);class l extends s.A{constructor(){super(...arguments),(0,n.A)(this,"focusTrap",void 0),(0,n.A)(this,"lastSetFocusTrap",void 0),(0,n.A)(this,"modalClosing",!1),(0,n.A)(this,"keyUpListener",null)}view(t){return m("[",null,this.attrs.state.modalList.map(((t,e)=>{const r=null==t?void 0:t.componentClass;return m("div",{key:t.key,className:"ModalManager modal","data-modal-key":t.key,"data-modal-number":e,role:"dialog","aria-modal":"true",style:!window.testing&&{"--modal-number":e},"aria-hidden":this.attrs.state.modal!==t&&"true"},!!r&&[m(r,Object.assign({key:t.key},t.attrs,{animateShow:this.animateShow.bind(this),animateHide:this.animateHide.bind(this),state:this.attrs.state})),m("div",{key:t.key,className:"ModalManager-invisibleBackdrop",onclick:this.handlePossibleBackdropClick.bind(this)})])})),(this.attrs.state.backdropShown||this.attrs.state.loadingModal)&&m("div",{className:"Modal-backdrop backdrop",ontransitionend:this.onBackdropTransitionEnd.bind(this),"data-showing":!!this.attrs.state.modalList.length||this.attrs.state.loadingModal,style:!window.testing&&{"--modal-count":this.attrs.state.modalList.length+Number(this.attrs.state.loadingModal)}},this.attrs.state.loadingModal&&m(a.A,null)))}oncreate(t){super.oncreate(t),this.keyUpListener=this.handleEscPress.bind(this),document.body.addEventListener("keyup",this.keyUpListener)}onbeforeremove(t){super.onbeforeremove(t),this.keyUpListener&&document.body.removeEventListener("keyup",this.keyUpListener),this.keyUpListener=null}onupdate(t){super.onupdate(t),requestAnimationFrame((()=>{try{var t,e,r,n;if(!this.attrs.state.isModalOpen())return null==(e=document.getElementById("app"))||e.setAttribute("aria-hidden","false"),null==(r=(n=this.focusTrap).deactivate)||r.call(n),void(0,i.qY)();null==(t=document.getElementById("app"))||t.setAttribute("aria-hidden","true");const u=this.attrs.state.modal.key;var s,a,l,c;this.focusTrap&&this.lastSetFocusTrap!==u&&(null==(s=(a=this.focusTrap).deactivate)||s.call(a),(0,i.qY)()),this.activeDialogElement&&this.lastSetFocusTrap!==u&&(this.focusTrap=(0,o.K)(this.activeDialogElement,{allowOutsideClick:!0}),null==(l=(c=this.focusTrap).activate)||l.call(c),this.activeDialogManagerElement&&(0,i.mh)(this.activeDialogManagerElement,{reserveScrollBarGap:!0})),this.lastSetFocusTrap=u}catch{}}))}get activeDialogElement(){var t;return document.body.querySelector('.ModalManager[data-modal-key="'.concat(null==(t=this.attrs.state.modal)?void 0:t.key,'"] .Modal'))}get activeDialogManagerElement(){var t;return document.body.querySelector('.ModalManager[data-modal-key="'.concat(null==(t=this.attrs.state.modal)?void 0:t.key,'"]'))}animateShow(t){var e;void 0===t&&(t=()=>{}),this.attrs.state.modal&&(null==(e=this.activeDialogElement)||e.addEventListener("transitionend",(()=>{t()}),{once:!0}),requestAnimationFrame((()=>{var t;null==(t=this.activeDialogElement)||t.classList.add("in")})))}animateHide(t){var e,r,n;void 0===t&&(t=()=>{}),this.modalClosing||(this.modalClosing=!0,null==(e=this.activeDialogElement)||e.addEventListener("transitionend",(()=>{this.modalClosing=!1,this.attrs.state.close(),t()}),{once:!0}),null==(r=this.activeDialogElement)||r.classList.remove("in"),null==(n=this.activeDialogElement)||n.classList.add("out"))}handleEscPress(t){if(!this.attrs.state.modal)return;const e=this.attrs.state.modal.componentClass.dismissibleOptions;"Escape"===t.key&&e.viaEscKey&&(t.preventDefault(),this.animateHide())}handlePossibleBackdropClick(t){this.attrs.state.modal&&this.attrs.state.modal.componentClass.dismissibleOptions.viaBackdropClick&&this.animateHide()}onBackdropTransitionEnd(t){"opacity"===t.propertyName&&null===t.currentTarget.getAttribute("data-showing")&&(this.attrs.state.backdropShown=!1,m.redraw())}}flarum.reg.add("core","common/components/ModalManager",l)},2162:(t,e,r)=>{"use strict";r.d(e,{A:()=>l});var n=r(5114),s=r(5710),o=r(7880),i=r(6909),a=r(4268);class l extends s.A{view(){const{history:t,pane:e}=n.A;return m("div",{className:(0,a.A)("Navigation ButtonGroup",this.attrs.className),onmouseenter:e&&e.show.bind(e),onmouseleave:e&&e.onmouseleave.bind(e)},null!=t&&t.canGoBack()?[this.getBackButton(),this.getPaneButton()]:this.getDrawerButton())}getBackButton(){const{history:t}=n.A,e=null==t?void 0:t.getPrevious();return m(i.A,{className:"Button Navigation-back Button--icon",href:null==t?void 0:t.backUrl(),icon:"fas fa-chevron-left","aria-label":null==e?void 0:e.title,onclick:e=>{e.shiftKey||e.ctrlKey||e.metaKey||2===e.which||(e.preventDefault(),null==t||t.back())}})}getPaneButton(){const{pane:t}=n.A;return t&&t.active?m(o.A,{className:(0,a.A)("Button Button--icon Navigation-pin",{active:t.pinned}),onclick:t.togglePinned.bind(t),icon:"fas fa-thumbtack"}):null}getDrawerButton(){if(!this.attrs.drawer)return null;const{drawer:t}=n.A,e=n.A.session.user;return m(o.A,{className:(0,a.A)("Button Button--icon Navigation-drawer",{new:null==e?void 0:e.newNotificationCount()}),onclick:e=>{e.stopPropagation(),t.show()},icon:"fas fa-bars","aria-label":n.A.translator.trans("core.lib.nav.drawer_button")})}}flarum.reg.add("core","common/components/Navigation",l)},9377:(t,e,r)=>{"use strict";r.d(e,{A:()=>a});var n=r(8805),s=r(5114),o=r(5710),i=r(4944);class a extends o.A{constructor(){super(...arguments),(0,n.A)(this,"bodyClass",""),(0,n.A)(this,"scrollTopOnCreate",!0),(0,n.A)(this,"useBrowserScrollRestoration",!0)}oninit(t){super.oninit(t),s.A.previous=s.A.current,s.A.current=new i.A(this.constructor,{routeName:this.attrs.routeName}),s.A.drawer.hide(),s.A.modal.close()}oncreate(t){super.oncreate(t),this.bodyClass&&$("#app").addClass(this.bodyClass),this.scrollTopOnCreate&&$(window).scrollTop(0),"scrollRestoration"in history&&(history.scrollRestoration=this.useBrowserScrollRestoration?"auto":"manual")}onremove(t){super.onremove(t),this.bodyClass&&$("#app").removeClass(this.bodyClass)}}flarum.reg.add("core","common/components/Page",a)},7088:(t,e,r)=>{"use strict";r.d(e,{A:()=>s});var n=r(2849);class s extends n.A{className(){return"RequestErrorModal Modal--large"}title(){return!!this.attrs.error.xhr&&"".concat(this.attrs.error.xhr.status," ").concat(this.attrs.error.xhr.statusText)}content(){var t;const{error:e,formattedError:r}=this.attrs;let n;return n=r.length?r.join("\n\n"):e.response?JSON.stringify(e.response,null,2):e.responseText,null!=(t=n)&&t.includes("