From a02abec218191c10bd08510c30f97324576d4caa Mon Sep 17 00:00:00 2001 From: flarum-bot Date: Sat, 2 Jul 2022 15:40:39 +0000 Subject: [PATCH] Bundled output for commit aea79a03637827108d25cb0da7dad8a91705da5d Includes transpiled JS/TS. [skip ci] --- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/dist/forum.js b/js/dist/forum.js index e061db2..c2fcad2 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -(()=>{var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const a=flarum.core.compat["common/app"];e.n(a)().initializers.add("v17development/flarum-user-badges",(function(){}));const r=flarum.core.compat.extend,n=flarum.core.compat.Model;var s=e.n(n);const o=flarum.core.compat["models/User"];var i=e.n(o);const d=flarum.core.compat["components/UserPage"];var l=e.n(d);const u=flarum.core.compat["utils/UserControls"];var c=e.n(u);const p=flarum.core.compat["components/LinkButton"];var g=e.n(p);const b=flarum.core.compat["components/Button"];var f=e.n(b);function h(e,t){return h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},h(e,t)}function v(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}const y=flarum.core.compat["utils/mixin"];var B=e.n(y);const N=flarum.core.compat["components/Modal"];var _=e.n(N);const I=flarum.core.compat["helpers/fullTime"];var w=e.n(I);const C=flarum.core.compat["utils/ItemList"];var k=e.n(C);flarum.core.compat["components/Select"];const x=flarum.core.compat["utils/Stream"];var L=e.n(x),P=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.selectedBadge=this.attrs.badge?this.attrs.badge.badge():null,this.user=this.attrs.badge?this.attrs.badge.user():this.attrs.user,this.userHasBadge=!1,this.badge=this.attrs.badge?this.attrs.badge:app.store.createRecord("userBadges"),this.description=L()(this.badge.description()),this.categories={},this.uncategorizedBadges=[],this.loading=!1,this.attrs.badge||(this.loading=!0,app.store.find("badges",{include:"category"}).then((function(e){e.forEach((function(e){if(e.category()){var t=e.category();a.categories[t.id()]?a.categories[t.id()].badges.push(e):a.categories[t.id()]={category:t,badges:[e]}}else a.uncategorizedBadges.push(e)})),a.loading=!1,m.redraw()})))},a.className=function(){return"Modal--small BadgeModal"},a.title=function(){return app.translator.trans("v17development-flarum-badges.forum."+(this.badge.exists?"update":"give")+"_badge")},a.content=function(){return m("div",null,m("div",{className:"Modal-body"},m("div",{className:"Form"},this.fields().toArray())),m("div",{className:"Modal-footer"},m(f(),{className:"Button Button--primary",type:"submit",loading:this.loading,disabled:this.userHasBadge},app.translator.trans("core.forum.composer_edit.submit_button"))))},a.fields=function(){var e=this,t=new(k());return t.add("badge",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.badge"))),m("div",{className:"Select"},m("select",{value:this.selectedBadge?this.selectedBadge.id():"empty",disabled:!!this.attrs.badge,onchange:function(t){"empty"!==t.target.value&&(e.selectedBadge=app.store.getById("badges",t.target.value),e.checkUserHasBadge(e.selectedBadge))},className:"Select-input FormControl"},m("option",{value:"empty"},app.translator.trans("v17development-flarum-badges.forum.select_badge")),!this.attrs.badge&&Object.values(this.categories).map((function(e){var t=e.category,a=e.badges;return m("optgroup",{label:t.name()},a.map((function(e){return m("option",{value:e.id()},e.name())})))})),!this.attrs.badge&&this.uncategorizedBadges.length>=1&&m("optgroup",{label:app.translator.trans("v17development-flarum-badges.forum.uncategorized")},this.uncategorizedBadges.map((function(e){return m("option",{value:e.id()},e.name())}))),!!this.attrs.badge&&m("option",{value:this.selectedBadge.id()},this.selectedBadge.name())),m("i",{class:"icon fas fa-caret-down Select-caret"})),this.userHasBadge&&m("p",{className:"UserHasBadge"},app.translator.trans("v17development-flarum-badges.forum.user_has_badge"))),30),t.add("badge_description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.description"),":")),m("p",null,this.selectedBadge?this.selectedBadge.description():app.translator.trans("v17development-flarum-badges.forum.select_badge"))),30),t.add("description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"))),m("textarea",{className:"FormControl",placeholder:app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"),bidi:this.description})),30),t},a.checkUserHasBadge=function(e){var t=!1;this.user.userBadges().map((function(a){a.badge()==e&&(t=!0)})),this.userHasBadge=t,m.redraw()},a.onsubmit=function(e){var t=this;e.preventDefault(),this.loading=!0,this.badge.save({description:this.description(),relationships:this.attrs.badge?{}:{badge:this.selectedBadge,user:this.user}}).then((function(){t.attrs.badge?app.modal.show(M,{badge:t.attrs.badge.badge(),userBadgeData:t.attrs.badge}):t.hide(),m.redraw()}),(function(e){t.loading=!1,t.handleErrors(e)}))},t}(_()),M=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.loading=!1},a.className=function(){return"Modal--small"},a.title=function(){return app.translator.trans("v17development-flarum-badges.forum.badge_information")},a.content=function(){var e=this;return m("div",null,m("div",{className:"Modal-body"},this.data().toArray()),m("div",{className:"Modal-footer"},m(g(),{href:app.route("badges.item",{id:this.attrs.badge.id()}),className:"Button",style:{margin:"0 10px"}},app.translator.trans("v17development-flarum-badges.forum.badge.badge_details")),this.attrs.userBadgeData&&app.forum.attribute("canGiveBadge")&&m(f(),{className:"Button Button--primary",onclick:function(){confirm(app.translator.trans("v17development-flarum-badges.forum.moderation.remove_badge_confirm"))&&(e.loading=!0,e.attrs.userBadgeData.delete().then((function(){return e.hide()})))},loading:this.loading},app.translator.trans("v17development-flarum-badges.forum.moderation.remove_badge"))))},a.data=function(){var e=this,t=new(k());return t.add("name",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.name"),":")),m("p",null,this.attrs.badge.name()))),t.add("description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.description"),":")),m("p",null,this.attrs.badge.description()))),this.attrs.userBadgeData&&(this.attrs.userBadgeData.description()||app.forum.attribute("canGiveBadge"))&&t.add("earning_reason",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"),":")),m("p",null,this.attrs.userBadgeData.description()?this.attrs.userBadgeData.description():m("i",null,app.translator.trans("v17development-flarum-badges.forum.badge.no_earning_reason"))),m("p",null,app.forum.attribute("canGiveBadge")&&m("a",{href:"#",onclick:function(t){t.preventDefault(),app.modal.show(P,{badge:e.attrs.userBadgeData})}},app.translator.trans("v17development-flarum-badges.forum.badge.update_earning_reason"))))),this.attrs.userBadgeData&&t.add("earned_date",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_on"),":")),m("p",null,w()(this.attrs.userBadgeData.assignedAt())))),this.attrs.userBadgeData&&t.add("category",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.category"),":")),m("p",null,this.attrs.badge.category()&&this.attrs.badge.category().name(),!this.attrs.badge.category()&&app.translator.trans("v17development-flarum-badges.forum.uncategorized")))),this.attrs.badge&&this.attrs.badge.earnedAmount()&&t.add("earned_amount",m("div",{className:"BadgeModalListItem"},m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:this.attrs.badge.earnedAmount()})))),t},t}(_()),O=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/badges"+(this.exists?"/"+this.data.id:"")},t}(B()(s(),{name:s().attribute("name"),icon:s().attribute("icon"),order:s().attribute("order"),image:s().attribute("image"),description:s().attribute("description"),isVisible:s().attribute("isVisible"),createdAt:s().attribute("createdAt"),earnedAmount:s().attribute("earnedAmount"),category:s().hasOne("category"),backgroundColor:s().attribute("backgroundColor"),iconColor:s().attribute("iconColor"),labelColor:s().attribute("labelColor")})),U=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/badge_categories"+(this.exists?"/"+this.data.id:"")},t}(B()(s(),{name:s().attribute("name"),order:s().attribute("order"),description:s().attribute("description"),isEnabled:s().attribute("isEnabled"),createdAt:s().attribute("createdAt"),isTable:s().attribute("isTable"),users:s().hasMany("users"),badges:s().hasMany("badges")})),A=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/user_badges"+(this.exists?"/"+this.data.id:"")},t}(B()(s(),{user:s().hasOne("user"),badge:s().hasOne("badge"),description:s().attribute("description"),isPrimary:s().attribute("isPrimary"),assignedAt:s().attribute("assignedAt")}));const D=flarum.core.compat["components/LoadingIndicator"];var T=e.n(D);const S=flarum.core.compat["common/Component"];var z=e.n(S);const j=flarum.core.compat["common/components/Tooltip"];var E=e.n(j),V=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.tooltip=!1!==this.attrs.tooltip,this.forceVisibility=!0===this.attrs.forceVisibility},a.view=function(){return this.attrs.badge.isVisible()||this.forceVisibility?!1===this.tooltip?this.badge():m(E(),{text:""+(this.attrs.badge.description()?this.attrs.badge.description():"")},this.badge()):null},a.badge=function(){var e=this,t=!this.attrs.badge.isVisible()&&this.forceVisibility;return this.attrs.badge.image()?m("img",{src:this.attrs.badge.image(),className:"UserBadgeImage",onclick:function(){e.attrs.onclick&&e.attrs.onclick()},style:{opacity:t?.5:void 0}}):m("span",{className:"UserBadge UserBadge-"+this.attrs.badge.id(),onclick:function(){e.attrs.onclick&&e.attrs.onclick()},style:{backgroundColor:this.attrs.badge.backgroundColor(),color:this.attrs.badge.labelColor(),borderColor:this.attrs.badge.backgroundColor(),opacity:t?.5:void 0}},m("i",{className:this.attrs.badge.icon(),style:{color:this.attrs.badge.iconColor()}})," ",this.attrs.badge.name())},t}(z()),H=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){var e={},t=[];return this.attrs.user.userBadges().map((function(a){if(!a)return null;if(a.badge().category()){var r=a.badge().category();e[r.id()]?e[r.id()].badges.push(a):e[r.id()]={category:r,badges:[a]}}else t.push(a)})),m("div",{className:"UserBadges"},0===Object.keys(e).length&&m("div",{className:"Placeholder"},m("p",null,app.translator.trans("v17development-flarum-badges.forum.user_no_badges"))),Object.keys(e).length>=1&&Object.keys(e).sort((function(t,a){return e[t].category.order()-e[a].category.order()})).map((function(t){var a=e[t].category,r=e[t].badges;return a.isEnabled()?m("div",{className:"UserBadgesCategory"},m("h3",null,a.name()),a.description()&&m("p",null,a.description()),r.sort((function(e,t){return e.badge().order()-t.badge().order()})).map((function(e){return m(V,{badge:e.badge(),onclick:function(){return app.modal.show(M,{badge:e.badge(),userBadgeData:e})}})}))):null})),t.length>=1&&m("div",{className:"UserBadgesCategory"},m("h3",null,app.translator.trans("v17development-flarum-badges.forum.uncategorized")),t.sort((function(e,t){return e.badge().order()-t.badge().order()})).map((function(e){return m(V,{badge:e.badge(),onclick:function(){return app.modal.show(M,{badge:e.badge(),userBadgeData:e})}})}))))},t}(z()),G=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.user=null,this.loading=!0,this.loadUser(m.route.param("username"))},a.content=function(){return!this.user||this.loading?m(T(),{size:46}):H.component({user:this.user})},a.show=function(t){var a=this;e.prototype.show.call(this,t),this.user=t,app.store.find("users",t.id(),{include:"userBadges,userBadges.badge,userBadges.badge.category"}).then((function(){a.loading=!1,m.redraw()}))},t}(l());const R=flarum.core.compat["components/Page"];var F=e.n(R);const q=flarum.core.compat["components/IndexPage"];var J=e.n(q);const K=flarum.core.compat["common/helpers/listItems"];var Q=e.n(K);const W=flarum.core.compat["components/Link"];var X=e.n(W),Y=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){if(!this.attrs.badges)return null;var e=this.attrs.badges;return m("table",{width:"100%",className:"BadgeTable"},m("thead",null,m("tr",null,m("th",{scope:"col"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),m("th",{scope:"col"},app.translator.trans("v17development-flarum-badges.forum.badge.description")))),m("tbody",null,e.map((function(e){return m("tr",null,m("td",null,m(X(),{href:app.route("badges.item",{id:e.id()})},m(V,{badge:e,tooltip:!1}))),m("td",null,e.description(),m("div",{className:"BadgeTableRewarded"},app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:e.earnedAmount()}))))}))))},t}(z()),Z=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){if(!this.attrs.badges)return null;var e=this.attrs.badges;return m("ul",{className:"BadgeCategoryList"},e.map((function(e){return m("li",null,m(X(),{href:app.route("badges.item",{id:e.id()}),className:"BadgeContainer"},m("div",{className:"BadgeContainerInfo"},m(V,{badge:e,tooltip:!1}),m("p",{className:"BadgeDescription"},e.description()),m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:e.earnedAmount()})))))})))},t}(z()),$=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.bodyClass="App--index",this.loading=!0,app.history.push("badgeOverviewPage"),app.setTitle(app.translator.trans("v17development-flarum-badges.forum.badge.badges")),app.store.find("badge_categories").then((function(){a.loading=!1,m.redraw()}))},a.view=function(){var e=app.store.all("badgeCategories").sort((function(e,t){return e.order()-t.order()}));return m("div",{className:"IndexPage"},J().prototype.hero(),m("div",{className:"container"},m("div",{className:"sideNavContainer"},m("nav",{className:"IndexPage-nav sideNav"},m("ul",null,Q()(J().prototype.sidebarItems().toArray()))),m("div",{className:"IndexPage-results sideNavOffset"},m("h2",{className:"BadgeOverviewTitle"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),this.loading&&m(T(),{size:"large"}),!this.loading&&e.map((function(e){var t=e.badges().sort((function(e,t){return e.order()-t.order()}));return m("div",{className:"BadgeCategory"},m("h3",null,e.name()),e.description()&&m("p",null,e.description()),e.isTable()&&m(Y,{badges:t}),!e.isTable()&&m(Z,{badges:t}))}))))))},t}(F());const ee=flarum.core.compat["helpers/avatar"];var te=e.n(ee);const ae=flarum.core.compat["helpers/humanTime"];var re=e.n(ae),ne=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.attrs.state.refreshParams({filter:{badge:this.attrs.badgeId},sort:"-assignedAt"})},a.view=function(){var e=this.attrs.state,t=null;return e.isInitialLoading()||e.isLoadingNext()?t=T().component({size:"large"}):e.hasNext()&&(t=f().component({className:"Button",icon:"fas fa-chevron-down",onclick:e.loadNext.bind(e)},app.translator.trans("core.forum.discussion_list.load_more_button"))),e.isInitialLoading()&&e.isEmpty()?m(T(),null):e.isEmpty()?m("div",{className:"BadgeUserList-empty"},app.translator.trans("v17development-flarum-badges.forum.no_received")):m("div",null,m("ul",{className:"BadgeUserList"},e.getPages().map((function(e){return e.items.map((function(e){return m("li",null,m(X(),{href:app.route("user.badges",{username:e.user().username()}),className:"BadgeUserList-user"},te()(e.user()),m("div",{className:"BadgeUserList-userinfo"},m("h4",null,e.user().displayName()),m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.received_on",{date:re()(e.assignedAt())})))))}))}))),t&&m("div",{className:"SupportSearchList-loadMore"},t))},t}(z()),se=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.bodyClass="App--index";var r=app.store.getById("badges",m.route.param("id"));this.loading=!r,r?(app.history.push("badgeItemPage",r.name()),this.setTitle(r)):app.store.find("badges/"+m.route.param("id")).then((function(e){a.loading=!1,app.history.push("badgeItemPage",e.name()),a.setTitle(e),m.redraw()}))},a.setTitle=function(e){app.setTitle(e.name()+" - "+app.translator.trans("v17development-flarum-badges.forum.badge.badges"))},a.view=function(){var e=app.store.getById("badges",m.route.param("id"));return m("div",{className:"IndexPage"},J().prototype.hero(),m("div",{className:"container"},m("div",{className:"sideNavContainer"},m("nav",{className:"IndexPage-nav sideNav"},m("ul",null,Q()(J().prototype.sidebarItems().toArray()))),m("div",{className:"IndexPage-results sideNavOffset"},m(g(),{href:app.route("badges"),icon:"fas fa-chevron-left",className:"Button BadgesOverviewButton"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),this.loading&&m(T(),{size:"large"}),!this.loading&&m("div",{className:"BadgeUserListInfo"},m("i",{className:e.icon()}),m("div",{className:"BadgeUserListInfo-meta"},m("h3",null,e.name()),m("p",null,e.description()))),e&&m("h3",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_by_count",{count:e.earnedAmount()})),!this.loading&&app.forum.attribute("canViewDetailedBadgeUsers")&&m(ne,{state:app.userBadgeListState,badgeId:e.id()})))))},t}(F());function oe(){(0,r.extend)(J().prototype,"navItems",(function(e){return e.add("badges",m(g(),{icon:"fas fa-id-badge",href:app.route("badges")},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),15),e}))}function ie(e,t){for(var a=0;a{var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const a=flarum.core.compat["common/app"];e.n(a)().initializers.add("v17development/flarum-user-badges",(function(){}));const r=flarum.core.compat.extend,s=flarum.core.compat.Model;var n=e.n(s);const o=flarum.core.compat["models/User"];var i=e.n(o);const d=flarum.core.compat["components/UserPage"];var l=e.n(d);const u=flarum.core.compat["utils/UserControls"];var c=e.n(u);const p=flarum.core.compat["components/LinkButton"];var g=e.n(p);const f=flarum.core.compat["components/Button"];var b=e.n(f);function h(e,t){return h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},h(e,t)}function v(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}const y=flarum.core.compat["utils/mixin"];var B=e.n(y);const N=flarum.core.compat["components/Modal"];var _=e.n(N);const C=flarum.core.compat["helpers/fullTime"];var w=e.n(C);const I=flarum.core.compat["utils/ItemList"];var U=e.n(I);flarum.core.compat["components/Select"];const x=flarum.core.compat["utils/Stream"];var M=e.n(x),O=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.selectedBadge=this.attrs.badge?this.attrs.badge.badge():null,this.user=this.attrs.badge?this.attrs.badge.user():this.attrs.user,this.userHasBadge=!1,this.badge=this.attrs.badge?this.attrs.badge:app.store.createRecord("userBadges"),this.description=M()(this.badge.description()),this.categories={},this.uncategorizedBadges=[],this.loading=!1,this.attrs.badge||(this.loading=!0,app.store.find("badges",{include:"category"}).then((function(e){e.forEach((function(e){if(e.category()){var t=e.category();a.categories[t.id()]?a.categories[t.id()].badges.push(e):a.categories[t.id()]={category:t,badges:[e]}}else a.uncategorizedBadges.push(e)})),a.loading=!1,m.redraw()})))},a.className=function(){return"Modal--small BadgeModal"},a.title=function(){return app.translator.trans("v17development-flarum-badges.forum."+(this.badge.exists?"update":"give")+"_badge")},a.content=function(){return m("div",null,m("div",{className:"Modal-body"},m("div",{className:"Form"},this.fields().toArray())),m("div",{className:"Modal-footer"},m(b(),{className:"Button Button--primary",type:"submit",loading:this.loading,disabled:this.userHasBadge},app.translator.trans("core.forum.composer_edit.submit_button"))))},a.fields=function(){var e=this,t=new(U());return t.add("badge",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.badge"))),m("div",{className:"Select"},m("select",{value:this.selectedBadge?this.selectedBadge.id():"empty",disabled:!!this.attrs.badge,onchange:function(t){"empty"!==t.target.value&&(e.selectedBadge=app.store.getById("badges",t.target.value),e.checkUserHasBadge(e.selectedBadge))},className:"Select-input FormControl"},m("option",{value:"empty"},app.translator.trans("v17development-flarum-badges.forum.select_badge")),!this.attrs.badge&&Object.values(this.categories).map((function(e){var t=e.category,a=e.badges;return m("optgroup",{label:t.name()},a.map((function(e){return m("option",{value:e.id()},e.name())})))})),!this.attrs.badge&&this.uncategorizedBadges.length>=1&&m("optgroup",{label:app.translator.trans("v17development-flarum-badges.forum.uncategorized")},this.uncategorizedBadges.map((function(e){return m("option",{value:e.id()},e.name())}))),!!this.attrs.badge&&m("option",{value:this.selectedBadge.id()},this.selectedBadge.name())),m("i",{class:"icon fas fa-caret-down Select-caret"})),this.userHasBadge&&m("p",{className:"UserHasBadge"},app.translator.trans("v17development-flarum-badges.forum.user_has_badge"))),30),t.add("badge_description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.description"),":")),m("p",null,this.selectedBadge?this.selectedBadge.description():app.translator.trans("v17development-flarum-badges.forum.select_badge"))),30),t.add("description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"))),m("textarea",{className:"FormControl",placeholder:app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"),bidi:this.description})),30),t},a.checkUserHasBadge=function(e){var t=!1;this.user.userBadges().map((function(a){a.badge()==e&&(t=!0)})),this.userHasBadge=t,m.redraw()},a.onsubmit=function(e){var t=this;e.preventDefault(),this.loading=!0,this.badge.save({description:this.description(),relationships:this.attrs.badge?{}:{badge:this.selectedBadge,user:this.user}}).then((function(){t.attrs.badge?app.modal.show(k,{badge:t.attrs.badge.badge(),userBadgeData:t.attrs.badge}):t.hide(),m.redraw()}),(function(e){t.loading=!1,t.handleErrors(e)}))},t}(_()),k=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.loading=!1},a.className=function(){return"Modal--small"},a.title=function(){return app.translator.trans("v17development-flarum-badges.forum.badge_information")},a.content=function(){var e=this;return m("div",null,m("div",{className:"Modal-body"},this.data().toArray()),m("div",{className:"Modal-footer"},m(g(),{href:app.route("badges.item",{id:this.attrs.badge.id()}),className:"Button",style:{margin:"0 10px"}},app.translator.trans("v17development-flarum-badges.forum.badge.badge_details")),this.attrs.userBadgeData&&app.forum.attribute("canGiveBadge")&&m(b(),{className:"Button Button--primary",onclick:function(){confirm(app.translator.trans("v17development-flarum-badges.forum.moderation.remove_badge_confirm"))&&(e.loading=!0,e.attrs.userBadgeData.delete().then((function(){return e.hide()})))},loading:this.loading},app.translator.trans("v17development-flarum-badges.forum.moderation.remove_badge"))))},a.data=function(){var e=this,t=new(U());return t.add("name",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.name"),":")),m("p",null,this.attrs.badge.name()))),t.add("description",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.description"),":")),m("p",null,this.attrs.badge.description()))),this.attrs.userBadgeData&&(this.attrs.userBadgeData.description()||app.forum.attribute("canGiveBadge"))&&t.add("earning_reason",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earning_reason"),":")),m("p",null,this.attrs.userBadgeData.description()?this.attrs.userBadgeData.description():m("i",null,app.translator.trans("v17development-flarum-badges.forum.badge.no_earning_reason"))),m("p",null,app.forum.attribute("canGiveBadge")&&m("a",{href:"#",onclick:function(t){t.preventDefault(),app.modal.show(O,{badge:e.attrs.userBadgeData})}},app.translator.trans("v17development-flarum-badges.forum.badge.update_earning_reason"))))),this.attrs.userBadgeData&&t.add("earned_date",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_on"),":")),m("p",null,w()(this.attrs.userBadgeData.assignedAt())))),this.attrs.userBadgeData&&t.add("category",m("div",{className:"BadgeModalListItem"},m("p",null,m("b",null,app.translator.trans("v17development-flarum-badges.forum.badge.category"),":")),m("p",null,this.attrs.badge.category()&&this.attrs.badge.category().name(),!this.attrs.badge.category()&&app.translator.trans("v17development-flarum-badges.forum.uncategorized")))),this.attrs.badge&&this.attrs.badge.earnedAmount()&&t.add("earned_amount",m("div",{className:"BadgeModalListItem"},m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:this.attrs.badge.earnedAmount()})))),t},t}(_()),L=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/badges"+(this.exists?"/"+this.data.id:"")},t}(B()(n(),{name:n().attribute("name"),icon:n().attribute("icon"),order:n().attribute("order"),image:n().attribute("image"),description:n().attribute("description"),isVisible:n().attribute("isVisible"),createdAt:n().attribute("createdAt"),earnedAmount:n().attribute("earnedAmount"),category:n().hasOne("category"),backgroundColor:n().attribute("backgroundColor"),iconColor:n().attribute("iconColor"),labelColor:n().attribute("labelColor")})),P=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/badge_categories"+(this.exists?"/"+this.data.id:"")},t}(B()(n(),{name:n().attribute("name"),order:n().attribute("order"),description:n().attribute("description"),isEnabled:n().attribute("isEnabled"),createdAt:n().attribute("createdAt"),isTable:n().attribute("isTable"),users:n().hasMany("users"),badges:n().hasMany("badges")})),A=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.apiEndpoint=function(){return"/user_badges"+(this.exists?"/"+this.data.id:"")},t}(B()(n(),{user:n().hasOne("user"),badge:n().hasOne("badge"),description:n().attribute("description"),isPrimary:n().attribute("isPrimary"),assignedAt:n().attribute("assignedAt"),inUserCard:n().attribute("inUserCard")}));const D=flarum.core.compat["components/LoadingIndicator"];var T=e.n(D);const S=flarum.core.compat["common/Component"];var z=e.n(S);const j=flarum.core.compat["common/components/Tooltip"];var E=e.n(j),V=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.tooltip=!1!==this.attrs.tooltip,this.forceVisibility=!0===this.attrs.forceVisibility},a.view=function(){return this.attrs.badge.isVisible()||this.forceVisibility?!1===this.tooltip?this.badge():m(E(),{text:""+(this.attrs.badge.description()?this.attrs.badge.description():"")},this.badge()):null},a.badge=function(){var e=this,t=!this.attrs.badge.isVisible()&&this.forceVisibility;return this.attrs.badge.image()?m("img",{src:this.attrs.badge.image(),className:"UserBadgeImage",onclick:function(){e.attrs.onclick&&e.attrs.onclick()},style:{opacity:t?.5:void 0}}):m("span",{className:"UserBadge UserBadge-"+this.attrs.badge.id(),onclick:function(){e.attrs.onclick&&e.attrs.onclick()},style:{backgroundColor:this.attrs.badge.backgroundColor(),color:this.attrs.badge.labelColor(),borderColor:this.attrs.badge.backgroundColor(),opacity:t?.5:void 0}},m("i",{className:this.attrs.badge.icon(),style:{color:this.attrs.badge.iconColor()}})," ",this.attrs.badge.name())},t}(z());function H(e){var t={},a=[];e.userBadges().map((function(e){if(!e)return null;if(e.badge().category()){var r=e.badge().category();t[r.id()]?t[r.id()].badges.push(e):t[r.id()]={name:r.name(),category:r,badges:[e]}}else a.push(e)}));var r=Object.keys(t).sort((function(e,a){return t[e].category.order()-t[a].category.order()})).map((function(e){return t[e]}));return r.push({name:app.translator.trans("v17development-flarum-badges.forum.uncategorized"),category:null,badges:a}),r}var G=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){var e=H(this.attrs.user);return m("div",{className:"UserBadges"},0===e.length&&m("div",{className:"Placeholder"},m("p",null,app.translator.trans("v17development-flarum-badges.forum.user_no_badges"))),e.length>=1&&e.map((function(e){var t=e.name,a=e.category,r=e.badges;return a&&!a.isEnabled()?null:m("div",{className:"UserBadgesCategory"},m("h3",null,t),a&&a.description()&&m("p",null,a.description()),r.sort((function(e,t){return e.badge().order()-t.badge().order()})).map((function(e){return m(V,{badge:e.badge(),onclick:function(){return app.modal.show(k,{badge:e.badge(),userBadgeData:e})}})})))})))},t}(z()),R=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.user=null,this.loading=!0,this.loadUser(m.route.param("username"))},a.content=function(){return!this.user||this.loading?m(T(),{size:46}):G.component({user:this.user})},a.show=function(t){var a=this;e.prototype.show.call(this,t),this.user=t,app.store.find("users",t.id(),{include:"userBadges,userBadges.badge,userBadges.badge.category"}).then((function(){a.loading=!1,m.redraw()}))},t}(l());const F=flarum.core.compat["components/Page"];var q=e.n(F);const J=flarum.core.compat["components/IndexPage"];var K=e.n(J);const Q=flarum.core.compat["common/helpers/listItems"];var W=e.n(Q);const X=flarum.core.compat["components/Link"];var Y=e.n(X),Z=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){if(!this.attrs.badges)return null;var e=this.attrs.badges;return m("table",{width:"100%",className:"BadgeTable"},m("thead",null,m("tr",null,m("th",{scope:"col"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),m("th",{scope:"col"},app.translator.trans("v17development-flarum-badges.forum.badge.description")))),m("tbody",null,e.map((function(e){return m("tr",null,m("td",null,m(Y(),{href:app.route("badges.item",{id:e.id()})},m(V,{badge:e,tooltip:!1}))),m("td",null,e.description(),m("div",{className:"BadgeTableRewarded"},app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:e.earnedAmount()}))))}))))},t}(z()),$=function(e){function t(){return e.apply(this,arguments)||this}return v(t,e),t.prototype.view=function(){if(!this.attrs.badges)return null;var e=this.attrs.badges;return m("ul",{className:"BadgeCategoryList"},e.map((function(e){return m("li",null,m(Y(),{href:app.route("badges.item",{id:e.id()}),className:"BadgeContainer"},m("div",{className:"BadgeContainerInfo"},m(V,{badge:e,tooltip:!1}),m("p",{className:"BadgeDescription"},e.description()),m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_count",{count:e.earnedAmount()})))))})))},t}(z()),ee=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.bodyClass="App--index",this.loading=!0,app.history.push("badgeOverviewPage"),app.setTitle(app.translator.trans("v17development-flarum-badges.forum.badge.badges")),app.store.find("badge_categories").then((function(){a.loading=!1,m.redraw()}))},a.view=function(){var e=app.store.all("badgeCategories").sort((function(e,t){return e.order()-t.order()}));return m("div",{className:"IndexPage"},K().prototype.hero(),m("div",{className:"container"},m("div",{className:"sideNavContainer"},m("nav",{className:"IndexPage-nav sideNav"},m("ul",null,W()(K().prototype.sidebarItems().toArray()))),m("div",{className:"IndexPage-results sideNavOffset"},m("h2",{className:"BadgeOverviewTitle"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),this.loading&&m(T(),{size:"large"}),!this.loading&&e.map((function(e){var t=e.badges().sort((function(e,t){return e.order()-t.order()}));return m("div",{className:"BadgeCategory"},m("h3",null,e.name()),e.description()&&m("p",null,e.description()),e.isTable()&&m(Z,{badges:t}),!e.isTable()&&m($,{badges:t}))}))))))},t}(q());const te=flarum.core.compat["helpers/avatar"];var ae=e.n(te);const re=flarum.core.compat["helpers/humanTime"];var se=e.n(re),ne=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){e.prototype.oninit.call(this,t),this.attrs.state.refreshParams({filter:{badge:this.attrs.badgeId},sort:"-assignedAt"})},a.view=function(){var e=this.attrs.state,t=null;return e.isInitialLoading()||e.isLoadingNext()?t=T().component({size:"large"}):e.hasNext()&&(t=b().component({className:"Button",icon:"fas fa-chevron-down",onclick:e.loadNext.bind(e)},app.translator.trans("core.forum.discussion_list.load_more_button"))),e.isInitialLoading()&&e.isEmpty()?m(T(),null):e.isEmpty()?m("div",{className:"BadgeUserList-empty"},app.translator.trans("v17development-flarum-badges.forum.no_received")):m("div",null,m("ul",{className:"BadgeUserList"},e.getPages().map((function(e){return e.items.map((function(e){return m("li",null,m(Y(),{href:app.route("user.badges",{username:e.user().username()}),className:"BadgeUserList-user"},ae()(e.user()),m("div",{className:"BadgeUserList-userinfo"},m("h4",null,e.user().displayName()),m("p",null,app.translator.trans("v17development-flarum-badges.forum.badge.received_on",{date:se()(e.assignedAt())})))))}))}))),t&&m("div",{className:"SupportSearchList-loadMore"},t))},t}(z()),oe=function(e){function t(){return e.apply(this,arguments)||this}v(t,e);var a=t.prototype;return a.oninit=function(t){var a=this;e.prototype.oninit.call(this,t),this.bodyClass="App--index";var r=app.store.getById("badges",m.route.param("id"));this.loading=!r,r?(app.history.push("badgeItemPage",r.name()),this.setTitle(r)):app.store.find("badges/"+m.route.param("id")).then((function(e){a.loading=!1,app.history.push("badgeItemPage",e.name()),a.setTitle(e),m.redraw()}))},a.setTitle=function(e){app.setTitle(e.name()+" - "+app.translator.trans("v17development-flarum-badges.forum.badge.badges"))},a.view=function(){var e=app.store.getById("badges",m.route.param("id"));return m("div",{className:"IndexPage"},K().prototype.hero(),m("div",{className:"container"},m("div",{className:"sideNavContainer"},m("nav",{className:"IndexPage-nav sideNav"},m("ul",null,W()(K().prototype.sidebarItems().toArray()))),m("div",{className:"IndexPage-results sideNavOffset"},m(g(),{href:app.route("badges"),icon:"fas fa-chevron-left",className:"Button BadgesOverviewButton"},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),this.loading&&m(T(),{size:"large"}),!this.loading&&m("div",{className:"BadgeUserListInfo"},m("i",{className:e.icon()}),m("div",{className:"BadgeUserListInfo-meta"},m("h3",null,e.name()),m("p",null,e.description()))),e&&m("h3",null,app.translator.trans("v17development-flarum-badges.forum.badge.earned_by_count",{count:e.earnedAmount()})),!this.loading&&app.forum.attribute("canViewDetailedBadgeUsers")&&m(ne,{state:app.userBadgeListState,badgeId:e.id()})))))},t}(q());function ie(){(0,r.extend)(K().prototype,"navItems",(function(e){return e.add("badges",m(g(),{icon:"fas fa-id-badge",href:app.route("badges")},app.translator.trans("v17development-flarum-badges.forum.badge.badges")),15),e}))}function de(e,t){for(var a=0;a=e.limit&&-1===e.selectedBadges.indexOf(t.id());return m(E(),{text:a?app.translator.trans("v17development-flarum-badges.forum.badges_in_card.hit_limit",{limit:app.forum.attribute("numberOfBadgesOnUserCard")}):"",position:"bottom"},m("div",{className:"UserCardBadgesModalCategory-badge",onclick:function(){if(!a){var r=e.selectedBadges.indexOf(t.id());r>=0?e.selectedBadges.splice(r,1):e.selectedBadges.push(t.id())}}},m("div",{className:"UserCardBadgesModalCategory-badge-preview"},m(V,{badge:t.badge(),onclick:function(){}})),m("div",{className:"UserCardBadgesModalCategory-badge-switch"},Ce().component({state:e.selectedBadges.indexOf(t.id())>=0,disabled:a}))))}))))})),t},a.save=function(){var e=this;this.loading=!0,this.attrs.user.save({userCardBadges:this.selectedBadges}).then((function(){e.attrs.user.userBadges().map((function(t){t.pushAttributes({inUserCard:e.selectedBadges.indexOf(t.id())>=0})})),e.hide()})).catch((function(){})).then((function(){e.loading=!1,m.redraw()}))},t}(_());app.initializers.add("v17development-flarum-badges",(function(e){e.store.models.badges=L,e.store.models.badgeCategories=P,e.store.models.userBadges=A,i().prototype.userBadges=n().hasMany("userBadges"),i().prototype.userPrimaryBadge=n().hasOne("userPrimaryBadge"),e.routes["user.badges"]={path:"/u/:username/badges",component:R},e.routes.badges={path:"/badges",component:ee},e.routes["badges.item"]={path:"/badges/:id",component:oe},ie(),e.userBadgeListState=new ue({}),e.notificationComponents.badgeReceived=ce,(0,r.extend)(ge().prototype,"notificationTypes",(function(t){t.add("badgeReceived",{name:"badgeReceived",icon:"fas fa-user-tag",label:e.translator.trans("v17development-flarum-badges.forum.notification.settings")})})),(0,r.extend)(l().prototype,"navItems",(function(t){t.add("badges",g().component({href:e.route("user.badges",{username:this.user.username()}),name:"badges",icon:"fas fa-user-tag"},[e.translator.trans("v17development-flarum-badges.forum.badge.badges"),m("span",{className:"Button-badge"},this.user.userBadges().length)]),90)})),(0,r.extend)(c(),"moderationControls",(function(t,a){e.forum.attribute("canGiveBadge")&&t.add("test",m(b(),{icon:"fas fa-user-tag",onclick:function(){return e.modal.show(O,{user:a})}},e.translator.trans("v17development-flarum-badges.forum.give_badge")))})),(0,he.extend)(ye().prototype,"infoItems",(function(e){var t=this.attrs.user,a=t.userBadges();if(!(a.length<1)&&be().forum.attribute("showBadgesOnUserCard")){var r=be().forum.attribute("numberOfBadgesOnUserCard"),s=a.filter((function(e){return e.inUserCard()}));0===s.length&&(s=a.slice(0,r));var n=s.map((function(e){return m(V,{badge:e.badge(),onclick:function(){return be().modal.show(k,{badge:e.badge(),userBadgeData:e})}})}));if(n.length {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/app'];","import app from 'flarum/common/app';\n\napp.initializers.add('v17development/flarum-user-badges', () => {\n // console.log('[v17development/flarum-user-badges] Hello, forum and admin!')\n});\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['models/User'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/UserControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LinkButton'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/mixin'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/fullTime'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/ItemList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Select'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/Stream'];","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport ItemList from 'flarum/utils/ItemList';\nimport Select from 'flarum/components/Select';\nimport Stream from 'flarum/utils/Stream';\nimport BadgeModal from './BadgeModal';\n\nexport default class GiveBadgeModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Select image\n this.selectedBadge = this.attrs.badge ? this.attrs.badge.badge() : null;\n\n // Current user\n this.user = this.attrs.badge ? this.attrs.badge.user() : this.attrs.user;\n\n // User has badge\n this.userHasBadge = false;\n\n // Badge model\n this.badge = this.attrs.badge ? this.attrs.badge : app.store.createRecord('userBadges');\n\n // Earning reason\n this.description = Stream(this.badge.description());\n\n // List of available bagges\n this.categories = {};\n\n this.uncategorizedBadges = [];\n\n this.loading = false;\n\n // Load all available badges\n if (!this.attrs.badge) {\n this.loading = true;\n\n app.store\n .find('badges', {\n include: 'category',\n })\n .then((badges) => {\n badges.forEach((badge) => {\n // Categorized\n if (badge.category()) {\n const category = badge.category();\n\n if (!this.categories[category.id()]) {\n this.categories[category.id()] = {\n category,\n badges: [badge],\n };\n } else {\n this.categories[category.id()].badges.push(badge);\n }\n }\n // Uncategorized\n else {\n this.uncategorizedBadges.push(badge);\n }\n });\n\n this.loading = false;\n\n // Redraw\n m.redraw();\n });\n }\n }\n\n className() {\n return 'Modal--small BadgeModal';\n }\n\n title() {\n return app.translator.trans(`v17development-flarum-badges.forum.${this.badge.exists ? 'update' : 'give'}_badge`);\n }\n\n content() {\n return (\n
\n
\n
{this.fields().toArray()}
\n
\n\n
\n \n
\n
\n );\n }\n\n fields() {\n const items = new ItemList();\n\n // Badge selector\n items.add(\n 'badge',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.badge')}\n

\n\n
\n {\n if (e.target.value === 'empty') return;\n this.selectedBadge = app.store.getById('badges', e.target.value);\n\n // Check if the user already has this badge\n this.checkUserHasBadge(this.selectedBadge);\n }}\n className=\"Select-input FormControl\"\n >\n \n\n {/* When no badge is selected, show all available badges */}\n {!this.attrs.badge &&\n Object.values(this.categories).map(({ category, badges }) => (\n \n {badges.map((badge) => (\n \n ))}\n \n ))}\n\n {!this.attrs.badge && this.uncategorizedBadges.length >= 1 && (\n \n {this.uncategorizedBadges.map((badge) => (\n \n ))}\n \n )}\n\n {/* When a badge is already assigned */}\n {!!this.attrs.badge && }\n \n \n
\n\n {this.userHasBadge &&

{app.translator.trans('v17development-flarum-badges.forum.user_has_badge')}

}\n
,\n 30\n );\n\n // Badge description\n items.add(\n 'badge_description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.description')}:\n

\n

{this.selectedBadge ? this.selectedBadge.description() : app.translator.trans('v17development-flarum-badges.forum.select_badge')}

\n
,\n 30\n );\n\n // Badge earning reason\n items.add(\n 'description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earning_reason')}\n

\n \n
,\n 30\n );\n\n return items;\n }\n\n checkUserHasBadge(badge) {\n let foundBadge = false;\n\n this.user.userBadges().map((userBadge) => {\n if (userBadge.badge() == badge) {\n foundBadge = true;\n }\n });\n\n this.userHasBadge = foundBadge;\n\n m.redraw();\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n this.badge\n .save({\n description: this.description(),\n relationships: this.attrs.badge\n ? {}\n : {\n badge: this.selectedBadge,\n user: this.user,\n },\n })\n .then(\n () => {\n // Re-open badge modal\n if (this.attrs.badge) {\n app.modal.show(BadgeModal, {\n badge: this.attrs.badge.badge(),\n userBadgeData: this.attrs.badge,\n });\n } else {\n this.hide();\n }\n\n m.redraw();\n },\n (response) => {\n this.loading = false;\n this.handleErrors(response);\n }\n );\n }\n}\n","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport fullTime from 'flarum/helpers/fullTime';\nimport ItemList from 'flarum/utils/ItemList';\nimport LinkButton from 'flarum/components/LinkButton';\nimport GiveBadgeModal from './GiveBadgeModal';\n\nexport default class BadgeModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--small';\n }\n\n title() {\n return app.translator.trans('v17development-flarum-badges.forum.badge_information');\n }\n\n content() {\n return (\n
\n
{this.data().toArray()}
\n
\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badge_details')}\n \n\n {this.attrs.userBadgeData && app.forum.attribute('canGiveBadge') && (\n {\n if (confirm(app.translator.trans('v17development-flarum-badges.forum.moderation.remove_badge_confirm'))) {\n this.loading = true;\n this.attrs.userBadgeData.delete().then(() => this.hide());\n }\n }}\n loading={this.loading}\n >\n {app.translator.trans('v17development-flarum-badges.forum.moderation.remove_badge')}\n \n )}\n
\n
\n );\n }\n\n data() {\n const items = new ItemList();\n\n // Badge name\n items.add(\n 'name',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.name')}:\n

\n

{this.attrs.badge.name()}

\n
\n );\n\n // Badge description\n items.add(\n 'description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.description')}:\n

\n

{this.attrs.badge.description()}

\n
\n );\n\n // Badge earning reason\n if (this.attrs.userBadgeData && (this.attrs.userBadgeData.description() || app.forum.attribute('canGiveBadge'))) {\n items.add(\n 'earning_reason',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earning_reason')}:\n

\n\n

\n {this.attrs.userBadgeData.description() ? (\n this.attrs.userBadgeData.description()\n ) : (\n {app.translator.trans('v17development-flarum-badges.forum.badge.no_earning_reason')}\n )}\n

\n

\n {app.forum.attribute('canGiveBadge') && (\n {\n e.preventDefault();\n app.modal.show(GiveBadgeModal, {\n badge: this.attrs.userBadgeData,\n });\n }}\n >\n {app.translator.trans('v17development-flarum-badges.forum.badge.update_earning_reason')}\n \n )}\n

\n
\n );\n }\n\n // Badge earned on\n if (this.attrs.userBadgeData) {\n items.add(\n 'earned_date',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_on')}:\n

\n

{fullTime(this.attrs.userBadgeData.assignedAt())}

\n
\n );\n }\n\n // Badge category\n if (this.attrs.userBadgeData) {\n items.add(\n 'category',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.category')}:\n

\n

\n {this.attrs.badge.category() && this.attrs.badge.category().name()}\n\n {/* Uncategorized */}\n {!this.attrs.badge.category() && app.translator.trans('v17development-flarum-badges.forum.uncategorized')}\n {/* \n {app.translator.trans(\n \"v17development-flarum-badges.forum.all_badges\"\n )}\n */}\n

\n
\n );\n }\n\n // Badge category\n if (this.attrs.badge && this.attrs.badge.earnedAmount()) {\n items.add(\n 'earned_amount',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: this.attrs.badge.earnedAmount(),\n })}\n

\n
\n );\n }\n\n return items;\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\nimport BadgeModal from '../../forum/components/BadgeModal';\n\nexport default class Badge extends mixin(Model, {\n name: Model.attribute('name'),\n icon: Model.attribute('icon'),\n order: Model.attribute('order'),\n image: Model.attribute('image'),\n description: Model.attribute('description'),\n isVisible: Model.attribute('isVisible'),\n createdAt: Model.attribute('createdAt'),\n earnedAmount: Model.attribute('earnedAmount'),\n category: Model.hasOne('category'),\n backgroundColor: Model.attribute('backgroundColor'),\n iconColor: Model.attribute('iconColor'),\n labelColor: Model.attribute('labelColor'),\n}) {\n apiEndpoint() {\n return '/badges' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class BadgeCategory extends mixin(Model, {\n name: Model.attribute('name'),\n order: Model.attribute('order'),\n description: Model.attribute('description'),\n isEnabled: Model.attribute('isEnabled'),\n createdAt: Model.attribute('createdAt'),\n isTable: Model.attribute('isTable'),\n users: Model.hasMany('users'),\n badges: Model.hasMany('badges'),\n}) {\n apiEndpoint() {\n return '/badge_categories' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class UserBadge extends mixin(Model, {\n user: Model.hasOne('user'),\n badge: Model.hasOne('badge'),\n description: Model.attribute('description'),\n isPrimary: Model.attribute('isPrimary'),\n assignedAt: Model.attribute('assignedAt'),\n}) {\n apiEndpoint() {\n return '/user_badges' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LoadingIndicator'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Tooltip'];","import Component from 'flarum/common/Component';\nimport Tooltip from 'flarum/common/components/Tooltip';\nimport BadgeModal from '../../forum/components/BadgeModal';\n\nexport default class UserBadge extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.tooltip = this.attrs.tooltip !== false;\n this.forceVisibility = this.attrs.forceVisibility === true;\n }\n\n view() {\n // Hide badge when not enabled\n if (!this.attrs.badge.isVisible() && !this.forceVisibility) {\n return null;\n }\n\n // Just show badge\n if (this.tooltip === false) return this.badge();\n\n return {this.badge()};\n }\n\n badge() {\n const isPartlyHidden = !this.attrs.badge.isVisible() && this.forceVisibility;\n\n // This badge is an image\n if (this.attrs.badge.image()) {\n return (\n {\n if (this.attrs.onclick) {\n this.attrs.onclick();\n }\n }}\n style={{\n opacity: isPartlyHidden ? 0.5 : undefined,\n }}\n />\n );\n }\n\n return (\n {\n if (this.attrs.onclick) {\n this.attrs.onclick();\n }\n }}\n style={{\n backgroundColor: this.attrs.badge.backgroundColor(),\n color: this.attrs.badge.labelColor(),\n borderColor: this.attrs.badge.backgroundColor(),\n opacity: isPartlyHidden ? 0.5 : undefined,\n }}\n >\n {this.attrs.badge.name()}\n \n );\n }\n}\n","import Component from 'flarum/common/Component';\nimport UserBadge from '../../common/components/UserBadge';\nimport BadgeModal from './BadgeModal';\n\nexport default class UserBadgeList extends Component {\n view() {\n const categories = {};\n const uncategorized = [];\n\n this.attrs.user.userBadges().map((userBadge) => {\n if (!userBadge) return null;\n\n // Categorized\n if (userBadge.badge().category()) {\n const category = userBadge.badge().category();\n\n if (!categories[category.id()]) {\n categories[category.id()] = {\n category,\n badges: [userBadge],\n };\n } else {\n categories[category.id()].badges.push(userBadge);\n }\n }\n // Uncategorized\n else {\n uncategorized.push(userBadge);\n }\n });\n\n return (\n
\n {Object.keys(categories).length === 0 && (\n
\n

{app.translator.trans('v17development-flarum-badges.forum.user_no_badges')}

\n
\n )}\n\n {Object.keys(categories).length >= 1 &&\n Object.keys(categories)\n .sort((a, b) => categories[a].category.order() - categories[b].category.order())\n .map((id) => {\n const category = categories[id].category;\n const badges = categories[id].badges;\n\n if (!category.isEnabled()) return null;\n\n return (\n
\n

{category.name()}

\n\n {category.description() &&

{category.description()}

}\n\n {badges\n .sort((a, b) => a.badge().order() - b.badge().order())\n .map((userBadge) => (\n \n app.modal.show(BadgeModal, {\n badge: userBadge.badge(),\n userBadgeData: userBadge,\n })\n }\n />\n ))}\n
\n );\n })}\n\n {/* Uncategorized badges */}\n {uncategorized.length >= 1 && (\n
\n

{app.translator.trans('v17development-flarum-badges.forum.uncategorized')}

\n\n {uncategorized\n .sort((a, b) => a.badge().order() - b.badge().order())\n .map((userBadge) => (\n \n app.modal.show(BadgeModal, {\n badge: userBadge.badge(),\n userBadgeData: userBadge,\n })\n }\n />\n ))}\n
\n )}\n
\n );\n }\n}\n","import UserPage from 'flarum/components/UserPage';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport UserBadgeList from './UserBadgeList';\n\nexport default class BadgesProfilePage extends UserPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.user = null;\n\n this.loading = true;\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n if (!this.user || this.loading) {\n return ;\n }\n\n return UserBadgeList.component({\n user: this.user,\n });\n }\n\n show(user) {\n super.show(user);\n this.user = user;\n\n app.store\n .find('users', user.id(), {\n include: 'userBadges,userBadges.badge,userBadges.badge.category',\n })\n .then(() => {\n this.loading = false;\n m.redraw();\n });\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Page'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Link'];","import Component from 'flarum/common/Component';\nimport Link from 'flarum/components/Link';\nimport UserBadge from '../../../common/components/UserBadge';\n\nexport default class TableView extends Component {\n view() {\n if (!this.attrs.badges) {\n return null;\n }\n\n const badges = this.attrs.badges;\n\n return (\n \n \n \n \n \n \n \n \n {badges.map((badge) => {\n return (\n \n \n \n \n );\n })}\n \n
{app.translator.trans('v17development-flarum-badges.forum.badge.badges')}{app.translator.trans('v17development-flarum-badges.forum.badge.description')}
\n \n \n \n \n {badge.description()}\n\n
\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: badge.earnedAmount(),\n })}\n
\n
\n );\n }\n}\n","import Component from 'flarum/common/Component';\nimport Link from 'flarum/components/Link';\nimport UserBadge from '../../../common/components/UserBadge';\n\nexport default class BlockListView extends Component {\n view() {\n if (!this.attrs.badges) {\n return null;\n }\n\n const badges = this.attrs.badges;\n\n return (\n
    \n {badges.map((badge) => {\n return (\n
  • \n \n
    \n \n\n

    {badge.description()}

    \n\n

    \n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: badge.earnedAmount(),\n })}\n

    \n
    \n \n
  • \n );\n })}\n
\n );\n }\n}\n","import Page from 'flarum/components/Page';\nimport IndexPage from 'flarum/components/IndexPage';\nimport listItems from 'flarum/common/helpers/listItems';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport TableView from './BadgeCategoryList/TableView';\nimport BlockListView from './BadgeCategoryList/BlockListView';\n\nexport default class BadgesOverviewPage extends Page {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.bodyClass = 'App--index';\n\n this.loading = true;\n\n app.history.push('badgeOverviewPage');\n\n app.setTitle(app.translator.trans('v17development-flarum-badges.forum.badge.badges'));\n\n // Load badge categories\n app.store.find('badge_categories').then(() => {\n this.loading = false;\n\n m.redraw();\n });\n }\n\n view() {\n const categories = app.store.all('badgeCategories').sort((a, b) => a.order() - b.order());\n\n return (\n
\n {IndexPage.prototype.hero()}\n\n
\n
\n \n
\n

{app.translator.trans('v17development-flarum-badges.forum.badge.badges')}

\n\n {this.loading && }\n\n {!this.loading &&\n categories.map((category) => {\n const badges = category.badges().sort((a, b) => a.order() - b.order());\n\n return (\n
\n

{category.name()}

\n {category.description() &&

{category.description()}

}\n\n {category.isTable() && }\n\n {!category.isTable() && }\n
\n );\n })}\n
\n
\n
\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/avatar'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/humanTime'];","import Component from 'flarum/common/Component';\nimport Button from 'flarum/components/Button';\nimport Link from 'flarum/components/Link';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport avatar from 'flarum/helpers/avatar';\nimport humanTime from 'flarum/helpers/humanTime';\n\nexport default class BadgeUserList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Load articles\n this.attrs.state.refreshParams({\n filter: {\n badge: this.attrs.badgeId,\n },\n sort: '-assignedAt',\n });\n }\n\n view() {\n const state = this.attrs.state;\n\n let loading = null;\n\n if (state.isInitialLoading() || state.isLoadingNext()) {\n loading = LoadingIndicator.component({\n size: 'large',\n });\n } else if (state.hasNext()) {\n loading = Button.component(\n {\n className: 'Button',\n icon: 'fas fa-chevron-down',\n onclick: state.loadNext.bind(state),\n },\n app.translator.trans('core.forum.discussion_list.load_more_button')\n );\n }\n\n // No items\n if (state.isInitialLoading() && state.isEmpty()) {\n return ;\n }\n\n // No items\n if (state.isEmpty()) {\n return
{app.translator.trans('v17development-flarum-badges.forum.no_received')}
;\n }\n\n return (\n
\n
    \n {state.getPages().map((pg) => {\n return pg.items.map((userBadge) => {\n return (\n
  • \n \n {avatar(userBadge.user())}\n\n
    \n

    {userBadge.user().displayName()}

    \n\n

    \n {app.translator.trans('v17development-flarum-badges.forum.badge.received_on', {\n date: humanTime(userBadge.assignedAt()),\n })}\n

    \n
    \n \n
  • \n );\n });\n })}\n
\n\n {loading &&
{loading}
}\n
\n );\n }\n}\n","import Page from 'flarum/components/Page';\nimport IndexPage from 'flarum/components/IndexPage';\nimport listItems from 'flarum/common/helpers/listItems';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport LinkButton from 'flarum/components/LinkButton';\nimport BadgeUserList from './BadgeUserList';\n\nexport default class BadgeItemPage extends Page {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.bodyClass = 'App--index';\n\n const found = app.store.getById('badges', m.route.param('id'));\n\n this.loading = !found;\n\n if (!found) {\n // Load badge categories\n app.store.find(`badges/${m.route.param('id')}`).then((badge) => {\n this.loading = false;\n\n app.history.push('badgeItemPage', badge.name());\n\n this.setTitle(badge);\n\n m.redraw();\n });\n } else {\n app.history.push('badgeItemPage', found.name());\n\n this.setTitle(found);\n }\n }\n\n setTitle(badge) {\n app.setTitle(`${badge.name()} - ${app.translator.trans('v17development-flarum-badges.forum.badge.badges')}`);\n }\n\n view() {\n const badge = app.store.getById('badges', m.route.param('id'));\n\n return (\n
\n {IndexPage.prototype.hero()}\n\n
\n
\n \n
\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badges')}\n \n\n {this.loading && }\n\n {!this.loading && (\n
\n \n\n
\n

{badge.name()}

\n

{badge.description()}

\n
\n
\n )}\n\n {badge && (\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_by_count', {\n count: badge.earnedAmount(),\n })}\n

\n )}\n\n {!this.loading && app.forum.attribute('canViewDetailedBadgeUsers') && (\n \n )}\n
\n
\n
\n
\n );\n }\n}\n","import { extend } from 'flarum/extend';\nimport IndexPage from 'flarum/components/IndexPage';\nimport LinkButton from 'flarum/components/LinkButton';\n\nexport default function addSidebarNav() {\n extend(IndexPage.prototype, 'navItems', function (items) {\n items.add(\n 'badges',\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badges')}\n ,\n 15\n );\n\n return items;\n });\n}\n","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/states/PaginatedListState'];","import PaginatedListState from 'flarum/common/states/PaginatedListState';\n\nexport default class UserBadgeListState extends PaginatedListState {\n constructor(params, page = 1) {\n super(params, page, 18);\n }\n\n get type() {\n return 'user_badges';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/Notification'];","import Notification from 'flarum/forum/components/Notification';\n\nexport default class BadgeReceivedNotification extends Notification {\n icon() {\n return '';\n }\n\n href() {\n return app.route('user.badges', {\n username: app.session.user.username(),\n });\n }\n\n content() {\n return app.translator.trans('v17development-flarum-badges.forum.notification.title');\n }\n\n excerpt() {\n const subject = this.attrs.notification.subject();\n\n return (\n
\n \n\n {subject.badge().name()}\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/NotificationGrid'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserCard'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Link'];","import { extend } from 'flarum/extend';\nimport Model from 'flarum/Model';\nimport User from 'flarum/models/User';\nimport UserPage from 'flarum/components/UserPage';\nimport UserControls from 'flarum/utils/UserControls';\nimport LinkButton from 'flarum/components/LinkButton';\nimport Button from 'flarum/components/Button';\nimport Badge from '../common/models/Badge';\nimport BadgeCategory from '../common/models/BadgeCategory';\nimport UserBadge from '../common/models/UserBadge';\nimport BadgesProfilePage from './components/BadgesProfilePage';\nimport BadgesOverviewPage from './components/BadgesOverviewPage';\nimport BadgeItemPage from './components/BadgeItemPage';\nimport GiveBadgeModal from './components/GiveBadgeModal';\nimport addSidebarNav from './addSidebarNav';\nimport UserBadgeListState from './states/UserBadgeListState';\nimport BadgeReceivedNotification from './notification/BadgeReceivedNotification';\nimport NotificationGrid from 'flarum/forum/components/NotificationGrid';\nimport addBadgeListUserCard from './addBadgeListUserCard';\n\napp.initializers.add('v17development-flarum-badges', (app) => {\n app.store.models.badges = Badge;\n app.store.models.badgeCategories = BadgeCategory;\n app.store.models.userBadges = UserBadge;\n\n User.prototype.userBadges = Model.hasMany('userBadges');\n User.prototype.userPrimaryBadge = Model.hasOne('userPrimaryBadge');\n\n // Add user badges to the user profile\n app.routes['user.badges'] = {\n path: '/u/:username/badges',\n component: BadgesProfilePage,\n };\n\n // Badges overview page\n app.routes.badges = {\n path: '/badges',\n component: BadgesOverviewPage,\n };\n\n // Future\n // // Badges overview page\n // app.routes[\"badges.category\"] = {\n // path: \"/badges/category/:id\",\n // component: BadgesOverviewPage,\n // };\n\n // Badge item page\n app.routes['badges.item'] = {\n path: '/badges/:id',\n component: BadgeItemPage,\n };\n\n addSidebarNav();\n\n app.userBadgeListState = new UserBadgeListState({});\n\n // Badge received notification\n app.notificationComponents.badgeReceived = BadgeReceivedNotification;\n\n // Enable badge notifications?\n extend(NotificationGrid.prototype, 'notificationTypes', function (items) {\n items.add('badgeReceived', {\n name: 'badgeReceived',\n icon: 'fas fa-user-tag',\n label: app.translator.trans('v17development-flarum-badges.forum.notification.settings'),\n });\n });\n\n // Add uploads to user page menu items\n extend(UserPage.prototype, 'navItems', function (items) {\n items.add(\n 'badges',\n LinkButton.component(\n {\n href: app.route('user.badges', {\n username: this.user.username(),\n }),\n name: 'badges',\n icon: 'fas fa-user-tag',\n },\n [\n app.translator.trans('v17development-flarum-badges.forum.badge.badges'),\n {this.user.userBadges().length},\n ]\n ),\n 90\n );\n });\n\n extend(UserControls, 'moderationControls', function (items, user) {\n // User can give badges\n if (app.forum.attribute('canGiveBadge')) {\n items.add(\n 'test',\n \n app.modal.show(GiveBadgeModal, {\n user: user,\n })\n }\n >\n {app.translator.trans('v17development-flarum-badges.forum.give_badge')}\n \n );\n }\n });\n addBadgeListUserCard();\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport UserCard from 'flarum/forum/components/UserCard';\nimport Link from 'flarum/common/components/Link';\nimport UserBadge from '../common/components/UserBadge';\nimport BadgeModal from './components/BadgeModal';\n\nexport default function addBadgeListUserCard() {\n extend(UserCard.prototype, 'infoItems', function (items) {\n const user = this.attrs.user;\n const userBadges = user.userBadges();\n\n if (userBadges.length < 1 || !app.forum.attribute('showBadgesOnUserCard')) return;\n\n const limit = app.forum.attribute('numberOfBadgesOnUserCard');\n const badges = userBadges.slice(0, limit).map((userBadge) => (\n \n app.modal.show(BadgeModal, {\n badge: userBadge.badge(),\n userBadgeData: userBadge,\n })\n }\n />\n ));\n\n if (badges.length < userBadges.length) {\n const count = userBadges.length - badges.length;\n badges.push(\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.others_link', { count })}\n \n );\n }\n\n items.add('badges', badges);\n });\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","_setPrototypeOf","p","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","create","constructor","GiveBadgeModal","oninit","vnode","this","selectedBadge","attrs","badge","user","userHasBadge","store","createRecord","description","Stream","categories","uncategorizedBadges","loading","find","include","then","badges","forEach","category","id","push","m","redraw","className","title","translator","trans","exists","content","fields","toArray","type","disabled","items","ItemList","add","onchange","e","target","getById","checkUserHasBadge","values","map","label","name","length","class","placeholder","bidi","foundBadge","userBadges","userBadge","onsubmit","preventDefault","save","relationships","modal","show","BadgeModal","userBadgeData","hide","response","handleErrors","Modal","data","href","route","style","margin","forum","attribute","onclick","confirm","fullTime","assignedAt","earnedAmount","count","Badge","apiEndpoint","mixin","Model","icon","order","image","isVisible","createdAt","backgroundColor","iconColor","labelColor","BadgeCategory","isEnabled","isTable","users","UserBadge","isPrimary","tooltip","forceVisibility","view","text","isPartlyHidden","src","opacity","undefined","color","borderColor","Component","UserBadgeList","uncategorized","keys","sort","b","BadgesProfilePage","loadUser","param","size","component","UserPage","TableView","width","scope","BlockListView","BadgesOverviewPage","bodyClass","history","setTitle","all","IndexPage","listItems","Page","BadgeUserList","state","refreshParams","filter","badgeId","isInitialLoading","isLoadingNext","LoadingIndicator","hasNext","Button","loadNext","bind","isEmpty","getPages","pg","username","avatar","displayName","date","humanTime","BadgeItemPage","found","userBadgeListState","addSidebarNav","extend","_defineProperties","props","i","descriptor","configurable","writable","UserBadgeListState","params","page","Constructor","protoProps","PaginatedListState","BadgeReceivedNotification","session","excerpt","subject","notification","Notification","initializers","models","badgeCategories","User","routes","path","notificationComponents","badgeReceived","NotificationGrid","LinkButton","UserControls","UserCard","limit","slice"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,IACzBH,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,+BCLvD,MAAM,EAA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H,UAAU,yBAETpC,KAAAA,WAAAA,MAAqB,uDAAwD,CAAEyF,MAAAA,MAMlFxE,IAASjB,KAAAA,QAAAA,MACX6B,EAAOI,KACL,EAAC,IAAD,CAAS+E,KAAMhH,KAAAA,WAAAA,MAAqB,oEAClC,OACE8E,KAAM,IACN1C,UAAU,wBACVgD,QAAS,SAAClC,GACRA,EAAEgB,iBACFlE,KAAAA,MAAAA,KAAe4L,GAA2B,CAAE3K,KAAAA,MAG9C,OAAGmB,UAAW,uCAMtBU,EAAME,IAAI,SAAUnB,W","sources":["webpack://@v17development/flarum-user-badges/webpack/bootstrap","webpack://@v17development/flarum-user-badges/webpack/runtime/compat get default export","webpack://@v17development/flarum-user-badges/webpack/runtime/define property getters","webpack://@v17development/flarum-user-badges/webpack/runtime/hasOwnProperty shorthand","webpack://@v17development/flarum-user-badges/webpack/runtime/make namespace object","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/app']\"","webpack://@v17development/flarum-user-badges/./src/common/index.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['extend']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['Model']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['models/User']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/UserPage']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['utils/UserControls']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/LinkButton']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Button']\"","webpack://@v17development/flarum-user-badges/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@v17development/flarum-user-badges/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['utils/mixin']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Modal']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['helpers/fullTime']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['utils/ItemList']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Select']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['utils/Stream']\"","webpack://@v17development/flarum-user-badges/./src/forum/components/GiveBadgeModal.js","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgeModal.js","webpack://@v17development/flarum-user-badges/./src/common/models/Badge.js","webpack://@v17development/flarum-user-badges/./src/common/models/BadgeCategory.js","webpack://@v17development/flarum-user-badges/./src/common/models/UserBadge.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/LoadingIndicator']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/Component']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/components/Tooltip']\"","webpack://@v17development/flarum-user-badges/./src/common/components/UserBadge.js","webpack://@v17development/flarum-user-badges/./src/forum/utils/categorizeUserBadges.js","webpack://@v17development/flarum-user-badges/./src/forum/components/UserBadgeList.js","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgesProfilePage.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Page']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/IndexPage']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/helpers/listItems']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Link']\"","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgeCategoryList/TableView.js","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgeCategoryList/BlockListView.js","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgesOverviewPage.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['helpers/avatar']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['helpers/humanTime']\"","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgeUserList.js","webpack://@v17development/flarum-user-badges/./src/forum/components/BadgeItemPage.js","webpack://@v17development/flarum-user-badges/./src/forum/addSidebarNav.js","webpack://@v17development/flarum-user-badges/./node_modules/@babel/runtime/helpers/esm/createClass.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/states/PaginatedListState']\"","webpack://@v17development/flarum-user-badges/./src/forum/states/UserBadgeListState.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['forum/components/Notification']\"","webpack://@v17development/flarum-user-badges/./src/forum/notification/BadgeReceivedNotification.js","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['forum/components/NotificationGrid']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['forum/app']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/extend']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['forum/components/UserCard']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['common/components/Link']\"","webpack://@v17development/flarum-user-badges/external root \"flarum.core.compat['components/Switch']\"","webpack://@v17development/flarum-user-badges/./src/forum/components/SelectUserCardBadgesModal.js","webpack://@v17development/flarum-user-badges/./src/forum/index.js","webpack://@v17development/flarum-user-badges/./src/forum/addBadgeListUserCard.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/app'];","import app from 'flarum/common/app';\n\napp.initializers.add('v17development/flarum-user-badges', () => {\n // console.log('[v17development/flarum-user-badges] Hello, forum and admin!')\n});\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Model'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['models/User'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/UserControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LinkButton'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/mixin'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Modal'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/fullTime'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/ItemList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Select'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['utils/Stream'];","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport ItemList from 'flarum/utils/ItemList';\nimport Select from 'flarum/components/Select';\nimport Stream from 'flarum/utils/Stream';\nimport BadgeModal from './BadgeModal';\n\nexport default class GiveBadgeModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Select image\n this.selectedBadge = this.attrs.badge ? this.attrs.badge.badge() : null;\n\n // Current user\n this.user = this.attrs.badge ? this.attrs.badge.user() : this.attrs.user;\n\n // User has badge\n this.userHasBadge = false;\n\n // Badge model\n this.badge = this.attrs.badge ? this.attrs.badge : app.store.createRecord('userBadges');\n\n // Earning reason\n this.description = Stream(this.badge.description());\n\n // List of available bagges\n this.categories = {};\n\n this.uncategorizedBadges = [];\n\n this.loading = false;\n\n // Load all available badges\n if (!this.attrs.badge) {\n this.loading = true;\n\n app.store\n .find('badges', {\n include: 'category',\n })\n .then((badges) => {\n badges.forEach((badge) => {\n // Categorized\n if (badge.category()) {\n const category = badge.category();\n\n if (!this.categories[category.id()]) {\n this.categories[category.id()] = {\n category,\n badges: [badge],\n };\n } else {\n this.categories[category.id()].badges.push(badge);\n }\n }\n // Uncategorized\n else {\n this.uncategorizedBadges.push(badge);\n }\n });\n\n this.loading = false;\n\n // Redraw\n m.redraw();\n });\n }\n }\n\n className() {\n return 'Modal--small BadgeModal';\n }\n\n title() {\n return app.translator.trans(`v17development-flarum-badges.forum.${this.badge.exists ? 'update' : 'give'}_badge`);\n }\n\n content() {\n return (\n
\n
\n
{this.fields().toArray()}
\n
\n\n
\n \n
\n
\n );\n }\n\n fields() {\n const items = new ItemList();\n\n // Badge selector\n items.add(\n 'badge',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.badge')}\n

\n\n
\n {\n if (e.target.value === 'empty') return;\n this.selectedBadge = app.store.getById('badges', e.target.value);\n\n // Check if the user already has this badge\n this.checkUserHasBadge(this.selectedBadge);\n }}\n className=\"Select-input FormControl\"\n >\n \n\n {/* When no badge is selected, show all available badges */}\n {!this.attrs.badge &&\n Object.values(this.categories).map(({ category, badges }) => (\n \n {badges.map((badge) => (\n \n ))}\n \n ))}\n\n {!this.attrs.badge && this.uncategorizedBadges.length >= 1 && (\n \n {this.uncategorizedBadges.map((badge) => (\n \n ))}\n \n )}\n\n {/* When a badge is already assigned */}\n {!!this.attrs.badge && }\n \n \n
\n\n {this.userHasBadge &&

{app.translator.trans('v17development-flarum-badges.forum.user_has_badge')}

}\n
,\n 30\n );\n\n // Badge description\n items.add(\n 'badge_description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.description')}:\n

\n

{this.selectedBadge ? this.selectedBadge.description() : app.translator.trans('v17development-flarum-badges.forum.select_badge')}

\n
,\n 30\n );\n\n // Badge earning reason\n items.add(\n 'description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earning_reason')}\n

\n \n
,\n 30\n );\n\n return items;\n }\n\n checkUserHasBadge(badge) {\n let foundBadge = false;\n\n this.user.userBadges().map((userBadge) => {\n if (userBadge.badge() == badge) {\n foundBadge = true;\n }\n });\n\n this.userHasBadge = foundBadge;\n\n m.redraw();\n }\n\n onsubmit(e) {\n e.preventDefault();\n\n this.loading = true;\n\n this.badge\n .save({\n description: this.description(),\n relationships: this.attrs.badge\n ? {}\n : {\n badge: this.selectedBadge,\n user: this.user,\n },\n })\n .then(\n () => {\n // Re-open badge modal\n if (this.attrs.badge) {\n app.modal.show(BadgeModal, {\n badge: this.attrs.badge.badge(),\n userBadgeData: this.attrs.badge,\n });\n } else {\n this.hide();\n }\n\n m.redraw();\n },\n (response) => {\n this.loading = false;\n this.handleErrors(response);\n }\n );\n }\n}\n","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport fullTime from 'flarum/helpers/fullTime';\nimport ItemList from 'flarum/utils/ItemList';\nimport LinkButton from 'flarum/components/LinkButton';\nimport GiveBadgeModal from './GiveBadgeModal';\n\nexport default class BadgeModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = false;\n }\n\n className() {\n return 'Modal--small';\n }\n\n title() {\n return app.translator.trans('v17development-flarum-badges.forum.badge_information');\n }\n\n content() {\n return (\n
\n
{this.data().toArray()}
\n
\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badge_details')}\n \n\n {this.attrs.userBadgeData && app.forum.attribute('canGiveBadge') && (\n {\n if (confirm(app.translator.trans('v17development-flarum-badges.forum.moderation.remove_badge_confirm'))) {\n this.loading = true;\n this.attrs.userBadgeData.delete().then(() => this.hide());\n }\n }}\n loading={this.loading}\n >\n {app.translator.trans('v17development-flarum-badges.forum.moderation.remove_badge')}\n \n )}\n
\n
\n );\n }\n\n data() {\n const items = new ItemList();\n\n // Badge name\n items.add(\n 'name',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.name')}:\n

\n

{this.attrs.badge.name()}

\n
\n );\n\n // Badge description\n items.add(\n 'description',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.description')}:\n

\n

{this.attrs.badge.description()}

\n
\n );\n\n // Badge earning reason\n if (this.attrs.userBadgeData && (this.attrs.userBadgeData.description() || app.forum.attribute('canGiveBadge'))) {\n items.add(\n 'earning_reason',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earning_reason')}:\n

\n\n

\n {this.attrs.userBadgeData.description() ? (\n this.attrs.userBadgeData.description()\n ) : (\n {app.translator.trans('v17development-flarum-badges.forum.badge.no_earning_reason')}\n )}\n

\n

\n {app.forum.attribute('canGiveBadge') && (\n {\n e.preventDefault();\n app.modal.show(GiveBadgeModal, {\n badge: this.attrs.userBadgeData,\n });\n }}\n >\n {app.translator.trans('v17development-flarum-badges.forum.badge.update_earning_reason')}\n \n )}\n

\n
\n );\n }\n\n // Badge earned on\n if (this.attrs.userBadgeData) {\n items.add(\n 'earned_date',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_on')}:\n

\n

{fullTime(this.attrs.userBadgeData.assignedAt())}

\n
\n );\n }\n\n // Badge category\n if (this.attrs.userBadgeData) {\n items.add(\n 'category',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.category')}:\n

\n

\n {this.attrs.badge.category() && this.attrs.badge.category().name()}\n\n {/* Uncategorized */}\n {!this.attrs.badge.category() && app.translator.trans('v17development-flarum-badges.forum.uncategorized')}\n {/* \n {app.translator.trans(\n \"v17development-flarum-badges.forum.all_badges\"\n )}\n */}\n

\n
\n );\n }\n\n // Badge category\n if (this.attrs.badge && this.attrs.badge.earnedAmount()) {\n items.add(\n 'earned_amount',\n
\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: this.attrs.badge.earnedAmount(),\n })}\n

\n
\n );\n }\n\n return items;\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\nimport BadgeModal from '../../forum/components/BadgeModal';\n\nexport default class Badge extends mixin(Model, {\n name: Model.attribute('name'),\n icon: Model.attribute('icon'),\n order: Model.attribute('order'),\n image: Model.attribute('image'),\n description: Model.attribute('description'),\n isVisible: Model.attribute('isVisible'),\n createdAt: Model.attribute('createdAt'),\n earnedAmount: Model.attribute('earnedAmount'),\n category: Model.hasOne('category'),\n backgroundColor: Model.attribute('backgroundColor'),\n iconColor: Model.attribute('iconColor'),\n labelColor: Model.attribute('labelColor'),\n}) {\n apiEndpoint() {\n return '/badges' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class BadgeCategory extends mixin(Model, {\n name: Model.attribute('name'),\n order: Model.attribute('order'),\n description: Model.attribute('description'),\n isEnabled: Model.attribute('isEnabled'),\n createdAt: Model.attribute('createdAt'),\n isTable: Model.attribute('isTable'),\n users: Model.hasMany('users'),\n badges: Model.hasMany('badges'),\n}) {\n apiEndpoint() {\n return '/badge_categories' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class UserBadge extends mixin(Model, {\n user: Model.hasOne('user'),\n badge: Model.hasOne('badge'),\n description: Model.attribute('description'),\n isPrimary: Model.attribute('isPrimary'),\n assignedAt: Model.attribute('assignedAt'),\n inUserCard: Model.attribute('inUserCard'),\n}) {\n apiEndpoint() {\n return '/user_badges' + (this.exists ? '/' + this.data.id : '');\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LoadingIndicator'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Tooltip'];","import Component from 'flarum/common/Component';\nimport Tooltip from 'flarum/common/components/Tooltip';\nimport BadgeModal from '../../forum/components/BadgeModal';\n\nexport default class UserBadge extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.tooltip = this.attrs.tooltip !== false;\n this.forceVisibility = this.attrs.forceVisibility === true;\n }\n\n view() {\n // Hide badge when not enabled\n if (!this.attrs.badge.isVisible() && !this.forceVisibility) {\n return null;\n }\n\n // Just show badge\n if (this.tooltip === false) return this.badge();\n\n return {this.badge()};\n }\n\n badge() {\n const isPartlyHidden = !this.attrs.badge.isVisible() && this.forceVisibility;\n\n // This badge is an image\n if (this.attrs.badge.image()) {\n return (\n {\n if (this.attrs.onclick) {\n this.attrs.onclick();\n }\n }}\n style={{\n opacity: isPartlyHidden ? 0.5 : undefined,\n }}\n />\n );\n }\n\n return (\n {\n if (this.attrs.onclick) {\n this.attrs.onclick();\n }\n }}\n style={{\n backgroundColor: this.attrs.badge.backgroundColor(),\n color: this.attrs.badge.labelColor(),\n borderColor: this.attrs.badge.backgroundColor(),\n opacity: isPartlyHidden ? 0.5 : undefined,\n }}\n >\n {this.attrs.badge.name()}\n \n );\n }\n}\n","export default function categorizeUserBadges(user) {\n const categories = {};\n const uncategorized = [];\n\n user.userBadges().map((userBadge) => {\n if (!userBadge) return null;\n\n // Categorized\n if (userBadge.badge().category()) {\n const category = userBadge.badge().category();\n\n if (!categories[category.id()]) {\n categories[category.id()] = {\n name: category.name(),\n category,\n badges: [userBadge],\n };\n } else {\n categories[category.id()].badges.push(userBadge);\n }\n }\n // Uncategorized\n else {\n uncategorized.push(userBadge);\n }\n });\n\n // Sort categories and map them into an array\n let sortedCategories = Object.keys(categories)\n .sort((a, b) => categories[a].category.order() - categories[b].category.order())\n .map((category) => categories[category]);\n\n sortedCategories.push({\n name: app.translator.trans('v17development-flarum-badges.forum.uncategorized'),\n category: null,\n badges: uncategorized,\n });\n\n return sortedCategories;\n}\n","import Component from 'flarum/common/Component';\nimport UserBadge from '../../common/components/UserBadge';\nimport categorizeUserBadges from '../utils/categorizeUserBadges';\nimport BadgeModal from './BadgeModal';\n\nexport default class UserBadgeList extends Component {\n view() {\n const categories = categorizeUserBadges(this.attrs.user);\n\n return (\n
\n {categories.length === 0 && (\n
\n

{app.translator.trans('v17development-flarum-badges.forum.user_no_badges')}

\n
\n )}\n\n {categories.length >= 1 &&\n categories.map(({ name, category, badges }) => {\n if (category && !category.isEnabled()) return null;\n\n return (\n
\n

{name}

\n\n {category && category.description() &&

{category.description()}

}\n\n {badges\n .sort((a, b) => a.badge().order() - b.badge().order())\n .map((userBadge) => (\n \n app.modal.show(BadgeModal, {\n badge: userBadge.badge(),\n userBadgeData: userBadge,\n })\n }\n />\n ))}\n
\n );\n })}\n
\n );\n }\n}\n","import UserPage from 'flarum/components/UserPage';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport UserBadgeList from './UserBadgeList';\n\nexport default class BadgesProfilePage extends UserPage {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.user = null;\n\n this.loading = true;\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n if (!this.user || this.loading) {\n return ;\n }\n\n return UserBadgeList.component({\n user: this.user,\n });\n }\n\n show(user) {\n super.show(user);\n this.user = user;\n\n app.store\n .find('users', user.id(), {\n include: 'userBadges,userBadges.badge,userBadges.badge.category',\n })\n .then(() => {\n this.loading = false;\n m.redraw();\n });\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Page'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/IndexPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/helpers/listItems'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Link'];","import Component from 'flarum/common/Component';\nimport Link from 'flarum/components/Link';\nimport UserBadge from '../../../common/components/UserBadge';\n\nexport default class TableView extends Component {\n view() {\n if (!this.attrs.badges) {\n return null;\n }\n\n const badges = this.attrs.badges;\n\n return (\n \n \n \n \n \n \n \n \n {badges.map((badge) => {\n return (\n \n \n \n \n );\n })}\n \n
{app.translator.trans('v17development-flarum-badges.forum.badge.badges')}{app.translator.trans('v17development-flarum-badges.forum.badge.description')}
\n \n \n \n \n {badge.description()}\n\n
\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: badge.earnedAmount(),\n })}\n
\n
\n );\n }\n}\n","import Component from 'flarum/common/Component';\nimport Link from 'flarum/components/Link';\nimport UserBadge from '../../../common/components/UserBadge';\n\nexport default class BlockListView extends Component {\n view() {\n if (!this.attrs.badges) {\n return null;\n }\n\n const badges = this.attrs.badges;\n\n return (\n
    \n {badges.map((badge) => {\n return (\n
  • \n \n
    \n \n\n

    {badge.description()}

    \n\n

    \n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_count', {\n count: badge.earnedAmount(),\n })}\n

    \n
    \n \n
  • \n );\n })}\n
\n );\n }\n}\n","import Page from 'flarum/components/Page';\nimport IndexPage from 'flarum/components/IndexPage';\nimport listItems from 'flarum/common/helpers/listItems';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport TableView from './BadgeCategoryList/TableView';\nimport BlockListView from './BadgeCategoryList/BlockListView';\n\nexport default class BadgesOverviewPage extends Page {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.bodyClass = 'App--index';\n\n this.loading = true;\n\n app.history.push('badgeOverviewPage');\n\n app.setTitle(app.translator.trans('v17development-flarum-badges.forum.badge.badges'));\n\n // Load badge categories\n app.store.find('badge_categories').then(() => {\n this.loading = false;\n\n m.redraw();\n });\n }\n\n view() {\n const categories = app.store.all('badgeCategories').sort((a, b) => a.order() - b.order());\n\n return (\n
\n {IndexPage.prototype.hero()}\n\n
\n
\n \n
\n

{app.translator.trans('v17development-flarum-badges.forum.badge.badges')}

\n\n {this.loading && }\n\n {!this.loading &&\n categories.map((category) => {\n const badges = category.badges().sort((a, b) => a.order() - b.order());\n\n return (\n
\n

{category.name()}

\n {category.description() &&

{category.description()}

}\n\n {category.isTable() && }\n\n {!category.isTable() && }\n
\n );\n })}\n
\n
\n
\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/avatar'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/humanTime'];","import Component from 'flarum/common/Component';\nimport Button from 'flarum/components/Button';\nimport Link from 'flarum/components/Link';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport avatar from 'flarum/helpers/avatar';\nimport humanTime from 'flarum/helpers/humanTime';\n\nexport default class BadgeUserList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n\n // Load articles\n this.attrs.state.refreshParams({\n filter: {\n badge: this.attrs.badgeId,\n },\n sort: '-assignedAt',\n });\n }\n\n view() {\n const state = this.attrs.state;\n\n let loading = null;\n\n if (state.isInitialLoading() || state.isLoadingNext()) {\n loading = LoadingIndicator.component({\n size: 'large',\n });\n } else if (state.hasNext()) {\n loading = Button.component(\n {\n className: 'Button',\n icon: 'fas fa-chevron-down',\n onclick: state.loadNext.bind(state),\n },\n app.translator.trans('core.forum.discussion_list.load_more_button')\n );\n }\n\n // No items\n if (state.isInitialLoading() && state.isEmpty()) {\n return ;\n }\n\n // No items\n if (state.isEmpty()) {\n return
{app.translator.trans('v17development-flarum-badges.forum.no_received')}
;\n }\n\n return (\n
\n
    \n {state.getPages().map((pg) => {\n return pg.items.map((userBadge) => {\n return (\n
  • \n \n {avatar(userBadge.user())}\n\n
    \n

    {userBadge.user().displayName()}

    \n\n

    \n {app.translator.trans('v17development-flarum-badges.forum.badge.received_on', {\n date: humanTime(userBadge.assignedAt()),\n })}\n

    \n
    \n \n
  • \n );\n });\n })}\n
\n\n {loading &&
{loading}
}\n
\n );\n }\n}\n","import Page from 'flarum/components/Page';\nimport IndexPage from 'flarum/components/IndexPage';\nimport listItems from 'flarum/common/helpers/listItems';\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\nimport LinkButton from 'flarum/components/LinkButton';\nimport BadgeUserList from './BadgeUserList';\n\nexport default class BadgeItemPage extends Page {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.bodyClass = 'App--index';\n\n const found = app.store.getById('badges', m.route.param('id'));\n\n this.loading = !found;\n\n if (!found) {\n // Load badge categories\n app.store.find(`badges/${m.route.param('id')}`).then((badge) => {\n this.loading = false;\n\n app.history.push('badgeItemPage', badge.name());\n\n this.setTitle(badge);\n\n m.redraw();\n });\n } else {\n app.history.push('badgeItemPage', found.name());\n\n this.setTitle(found);\n }\n }\n\n setTitle(badge) {\n app.setTitle(`${badge.name()} - ${app.translator.trans('v17development-flarum-badges.forum.badge.badges')}`);\n }\n\n view() {\n const badge = app.store.getById('badges', m.route.param('id'));\n\n return (\n
\n {IndexPage.prototype.hero()}\n\n
\n
\n \n
\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badges')}\n \n\n {this.loading && }\n\n {!this.loading && (\n
\n \n\n
\n

{badge.name()}

\n

{badge.description()}

\n
\n
\n )}\n\n {badge && (\n

\n {app.translator.trans('v17development-flarum-badges.forum.badge.earned_by_count', {\n count: badge.earnedAmount(),\n })}\n

\n )}\n\n {!this.loading && app.forum.attribute('canViewDetailedBadgeUsers') && (\n \n )}\n
\n
\n
\n
\n );\n }\n}\n","import { extend } from 'flarum/extend';\nimport IndexPage from 'flarum/components/IndexPage';\nimport LinkButton from 'flarum/components/LinkButton';\n\nexport default function addSidebarNav() {\n extend(IndexPage.prototype, 'navItems', function (items) {\n items.add(\n 'badges',\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.badges')}\n ,\n 15\n );\n\n return items;\n });\n}\n","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/states/PaginatedListState'];","import PaginatedListState from 'flarum/common/states/PaginatedListState';\n\nexport default class UserBadgeListState extends PaginatedListState {\n constructor(params, page = 1) {\n super(params, page, 18);\n }\n\n get type() {\n return 'user_badges';\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/Notification'];","import Notification from 'flarum/forum/components/Notification';\n\nexport default class BadgeReceivedNotification extends Notification {\n icon() {\n return '';\n }\n\n href() {\n return app.route('user.badges', {\n username: app.session.user.username(),\n });\n }\n\n content() {\n return app.translator.trans('v17development-flarum-badges.forum.notification.title');\n }\n\n excerpt() {\n const subject = this.attrs.notification.subject();\n\n return (\n
\n \n\n {subject.badge().name()}\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/NotificationGrid'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserCard'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/Link'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Switch'];","import Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport ItemList from 'flarum/utils/ItemList';\nimport Switch from 'flarum/components/Switch';\nimport UserBadge from '../../common/components/UserBadge';\nimport categorizeUserBadges from '../utils/categorizeUserBadges';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default class SelectUserCardBadgesModal extends Modal {\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loading = false;\n\n this.limit = app.forum.attribute('numberOfBadgesOnUserCard');\n this.selectedBadges = this.attrs.user\n .userBadges()\n .filter((userBadge) => userBadge.inUserCard())\n .map((userBadge) => userBadge.id());\n }\n\n className() {\n return 'Modal--big UserCardBadgesModal';\n }\n\n title() {\n return app.translator.trans('v17development-flarum-badges.forum.badges_in_card.title');\n }\n\n content() {\n return (\n
\n
{this.data().toArray()}
\n
\n \n
\n
\n );\n }\n\n data() {\n const items = new ItemList();\n\n const categories = categorizeUserBadges(this.attrs.user);\n\n // Badge name\n items.add(\n 'info',\n
\n

{app.translator.trans('v17development-flarum-badges.forum.badges_in_card.description')}

\n

\n {app.translator.trans('v17development-flarum-badges.forum.badges_in_card.select_limit', {\n limit: app.forum.attribute('numberOfBadgesOnUserCard'),\n })}\n

\n
\n );\n\n // Loop through all badge categories\n categories.map(({ name, category, badges }) => {\n items.add(\n `badge_category_${category ? category.id() : 'uncategorized'}`,\n
\n
{name}
\n\n {/* Loop through the badges */}\n {badges\n .sort((a, b) => a.badge().order() - b.badge().order())\n .map((userBadge) => {\n const disabled = this.selectedBadges.length >= this.limit && this.selectedBadges.indexOf(userBadge.id()) === -1;\n\n return (\n \n {\n if (disabled) {\n return;\n }\n\n const currentIndex = this.selectedBadges.indexOf(userBadge.id());\n\n // Remove from selected list\n if (currentIndex >= 0) {\n this.selectedBadges.splice(currentIndex, 1);\n } else {\n // Add to list\n this.selectedBadges.push(userBadge.id());\n }\n }}\n >\n
\n {}} />\n
\n {/*
*/}\n
\n {Switch.component({\n state: this.selectedBadges.indexOf(userBadge.id()) >= 0,\n disabled,\n })}\n
\n
\n \n );\n })}\n \n );\n });\n\n return items;\n }\n\n save() {\n this.loading = true;\n\n this.attrs.user\n .save({ userCardBadges: this.selectedBadges })\n .then(() => {\n // Update current user badges store\n this.attrs.user.userBadges().map((userBadge) => {\n userBadge.pushAttributes({\n inUserCard: this.selectedBadges.indexOf(userBadge.id()) >= 0,\n });\n });\n\n this.hide();\n })\n .catch(() => {})\n .then(() => {\n this.loading = false;\n m.redraw();\n });\n }\n}\n","import { extend } from 'flarum/extend';\nimport Model from 'flarum/Model';\nimport User from 'flarum/models/User';\nimport UserPage from 'flarum/components/UserPage';\nimport UserControls from 'flarum/utils/UserControls';\nimport LinkButton from 'flarum/components/LinkButton';\nimport Button from 'flarum/components/Button';\nimport Badge from '../common/models/Badge';\nimport BadgeCategory from '../common/models/BadgeCategory';\nimport UserBadge from '../common/models/UserBadge';\nimport BadgesProfilePage from './components/BadgesProfilePage';\nimport BadgesOverviewPage from './components/BadgesOverviewPage';\nimport BadgeItemPage from './components/BadgeItemPage';\nimport GiveBadgeModal from './components/GiveBadgeModal';\nimport addSidebarNav from './addSidebarNav';\nimport UserBadgeListState from './states/UserBadgeListState';\nimport BadgeReceivedNotification from './notification/BadgeReceivedNotification';\nimport NotificationGrid from 'flarum/forum/components/NotificationGrid';\nimport addBadgeListUserCard from './addBadgeListUserCard';\n\napp.initializers.add('v17development-flarum-badges', (app) => {\n app.store.models.badges = Badge;\n app.store.models.badgeCategories = BadgeCategory;\n app.store.models.userBadges = UserBadge;\n\n User.prototype.userBadges = Model.hasMany('userBadges');\n User.prototype.userPrimaryBadge = Model.hasOne('userPrimaryBadge');\n\n // Add user badges to the user profile\n app.routes['user.badges'] = {\n path: '/u/:username/badges',\n component: BadgesProfilePage,\n };\n\n // Badges overview page\n app.routes.badges = {\n path: '/badges',\n component: BadgesOverviewPage,\n };\n\n // Future\n // // Badges overview page\n // app.routes[\"badges.category\"] = {\n // path: \"/badges/category/:id\",\n // component: BadgesOverviewPage,\n // };\n\n // Badge item page\n app.routes['badges.item'] = {\n path: '/badges/:id',\n component: BadgeItemPage,\n };\n\n addSidebarNav();\n\n app.userBadgeListState = new UserBadgeListState({});\n\n // Badge received notification\n app.notificationComponents.badgeReceived = BadgeReceivedNotification;\n\n // Enable badge notifications?\n extend(NotificationGrid.prototype, 'notificationTypes', function (items) {\n items.add('badgeReceived', {\n name: 'badgeReceived',\n icon: 'fas fa-user-tag',\n label: app.translator.trans('v17development-flarum-badges.forum.notification.settings'),\n });\n });\n\n // Add uploads to user page menu items\n extend(UserPage.prototype, 'navItems', function (items) {\n items.add(\n 'badges',\n LinkButton.component(\n {\n href: app.route('user.badges', {\n username: this.user.username(),\n }),\n name: 'badges',\n icon: 'fas fa-user-tag',\n },\n [\n app.translator.trans('v17development-flarum-badges.forum.badge.badges'),\n {this.user.userBadges().length},\n ]\n ),\n 90\n );\n });\n\n extend(UserControls, 'moderationControls', function (items, user) {\n // User can give badges\n if (app.forum.attribute('canGiveBadge')) {\n items.add(\n 'test',\n \n app.modal.show(GiveBadgeModal, {\n user: user,\n })\n }\n >\n {app.translator.trans('v17development-flarum-badges.forum.give_badge')}\n \n );\n }\n });\n addBadgeListUserCard();\n});\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport UserCard from 'flarum/forum/components/UserCard';\nimport Link from 'flarum/common/components/Link';\nimport UserBadge from '../common/components/UserBadge';\nimport BadgeModal from './components/BadgeModal';\nimport SelectUserCardBadgesModal from './components/SelectUserCardBadgesModal';\nimport Tooltip from 'flarum/common/components/Tooltip';\n\nexport default function addBadgeListUserCard() {\n extend(UserCard.prototype, 'infoItems', function (items) {\n const user = this.attrs.user;\n const userBadges = user.userBadges();\n\n if (userBadges.length < 1 || !app.forum.attribute('showBadgesOnUserCard')) return;\n\n const limit = app.forum.attribute('numberOfBadgesOnUserCard');\n\n // Check for all badges\n let visibleBadges = userBadges.filter((userBadge) => {\n return userBadge.inUserCard();\n });\n\n // No badges selected (yet). Just select a few\n if (visibleBadges.length === 0) {\n visibleBadges = userBadges.slice(0, limit);\n }\n\n const badges = visibleBadges.map((userBadge) => {\n return (\n \n app.modal.show(BadgeModal, {\n badge: userBadge.badge(),\n userBadgeData: userBadge,\n })\n }\n />\n );\n });\n\n if (badges.length < userBadges.length) {\n const count = userBadges.length - visibleBadges.length;\n badges.push(\n \n {app.translator.trans('v17development-flarum-badges.forum.badge.others_link', { count })}\n \n );\n }\n\n // Manage badges\n if (user === app.session.user) {\n badges.push(\n \n {\n e.preventDefault();\n app.modal.show(SelectUserCardBadgesModal, { user });\n }}\n >\n \n \n \n );\n }\n\n items.add('badges', badges);\n });\n}\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","_setPrototypeOf","p","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","create","constructor","GiveBadgeModal","oninit","vnode","this","selectedBadge","attrs","badge","user","userHasBadge","store","createRecord","description","Stream","categories","uncategorizedBadges","loading","find","include","then","badges","forEach","category","id","push","m","redraw","className","title","translator","trans","exists","content","fields","toArray","type","disabled","items","ItemList","add","onchange","e","target","getById","checkUserHasBadge","values","map","label","name","length","class","placeholder","bidi","foundBadge","userBadges","userBadge","onsubmit","preventDefault","save","relationships","modal","show","BadgeModal","userBadgeData","hide","response","handleErrors","Modal","data","href","route","style","margin","forum","attribute","onclick","confirm","fullTime","assignedAt","earnedAmount","count","Badge","apiEndpoint","mixin","Model","icon","order","image","isVisible","createdAt","backgroundColor","iconColor","labelColor","BadgeCategory","isEnabled","isTable","users","UserBadge","isPrimary","inUserCard","tooltip","forceVisibility","view","text","isPartlyHidden","src","opacity","undefined","color","borderColor","Component","categorizeUserBadges","uncategorized","sortedCategories","keys","sort","b","UserBadgeList","BadgesProfilePage","loadUser","param","size","component","UserPage","TableView","width","scope","BlockListView","BadgesOverviewPage","bodyClass","history","setTitle","all","IndexPage","listItems","Page","BadgeUserList","state","refreshParams","filter","badgeId","isInitialLoading","isLoadingNext","LoadingIndicator","hasNext","Button","loadNext","bind","isEmpty","getPages","pg","username","avatar","displayName","date","humanTime","BadgeItemPage","found","userBadgeListState","addSidebarNav","extend","_defineProperties","props","i","descriptor","configurable","writable","UserBadgeListState","params","page","Constructor","protoProps","PaginatedListState","BadgeReceivedNotification","session","excerpt","subject","notification","Notification","SelectUserCardBadgesModal","limit","selectedBadges","indexOf","position","currentIndex","splice","Switch","userCardBadges","pushAttributes","initializers","models","badgeCategories","User","routes","path","notificationComponents","badgeReceived","NotificationGrid","LinkButton","UserControls","UserCard","visibleBadges","slice"],"sourceRoot":""} \ No newline at end of file