(()=>{var t={3:function(t){t.exports=function(){"use strict";var t,a,e=1e3,n=6e4,r=36e5,s=864e5,i=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,o=31536e6,l=2592e6,c=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,u={years:o,months:l,days:s,hours:r,minutes:n,seconds:e,milliseconds:1,weeks:6048e5},m=function(t){return t instanceof v},d=function(t,a,e){return new v(t,e,a.$l)},p=function(t){return a.p(t)+"s"},f=function(t){return t<0},g=function(t){return f(t)?Math.ceil(t):Math.floor(t)},h=function(t){return Math.abs(t)},k=function(t,a){return t?f(t)?{negative:!0,format:""+h(t)+a}:{negative:!1,format:""+t+a}:{negative:!1,format:""}},v=function(){function f(t,a,e){var n=this;if(this.$d={},this.$l=e,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),a)return d(t*u[p(a)],this);if("number"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if("object"==typeof t)return Object.keys(t).forEach((function(a){n.$d[p(a)]=t[a]})),this.calMilliseconds(),this;if("string"==typeof t){var r=t.match(c);if(r){var s=r.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=s[0],this.$d.months=s[1],this.$d.weeks=s[2],this.$d.days=s[3],this.$d.hours=s[4],this.$d.minutes=s[5],this.$d.seconds=s[6],this.calMilliseconds(),this}}return this}var h=f.prototype;return h.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(a,e){return a+(t.$d[e]||0)*u[e]}),0)},h.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=g(t/o),t%=o,this.$d.months=g(t/l),t%=l,this.$d.days=g(t/s),t%=s,this.$d.hours=g(t/r),t%=r,this.$d.minutes=g(t/n),t%=n,this.$d.seconds=g(t/e),t%=e,this.$d.milliseconds=t},h.toISOString=function(){var t=k(this.$d.years,"Y"),a=k(this.$d.months,"M"),e=+this.$d.days||0;this.$d.weeks&&(e+=7*this.$d.weeks);var n=k(e,"D"),r=k(this.$d.hours,"H"),s=k(this.$d.minutes,"M"),i=this.$d.seconds||0;this.$d.milliseconds&&(i+=this.$d.milliseconds/1e3);var o=k(i,"S"),l=t.negative||a.negative||n.negative||r.negative||s.negative||o.negative,c=r.format||s.format||o.format?"T":"",u=(l?"-":"")+"P"+t.format+a.format+n.format+c+r.format+s.format+o.format;return"P"===u||"-P"===u?"P0D":u},h.toJSON=function(){return this.toISOString()},h.format=function(t){var e=t||"YYYY-MM-DDTHH:mm:ss",n={Y:this.$d.years,YY:a.s(this.$d.years,2,"0"),YYYY:a.s(this.$d.years,4,"0"),M:this.$d.months,MM:a.s(this.$d.months,2,"0"),D:this.$d.days,DD:a.s(this.$d.days,2,"0"),H:this.$d.hours,HH:a.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:a.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:a.s(this.$d.seconds,2,"0"),SSS:a.s(this.$d.milliseconds,3,"0")};return e.replace(i,(function(t,a){return a||String(n[t])}))},h.as=function(t){return this.$ms/u[p(t)]},h.get=function(t){var a=this.$ms,e=p(t);return"milliseconds"===e?a%=1e3:a="weeks"===e?g(a/u[e]):this.$d[e],0===a?0:a},h.add=function(t,a,e){var n;return n=a?t*u[p(a)]:m(t)?t.$ms:d(t,this).$ms,d(this.$ms+n*(e?-1:1),this)},h.subtract=function(t,a){return this.add(t,a,!0)},h.locale=function(t){var a=this.clone();return a.$l=t,a},h.clone=function(){return d(this.$ms,this)},h.humanize=function(a){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!a)},h.milliseconds=function(){return this.get("milliseconds")},h.asMilliseconds=function(){return this.as("milliseconds")},h.seconds=function(){return this.get("seconds")},h.asSeconds=function(){return this.as("seconds")},h.minutes=function(){return this.get("minutes")},h.asMinutes=function(){return this.as("minutes")},h.hours=function(){return this.get("hours")},h.asHours=function(){return this.as("hours")},h.days=function(){return this.get("days")},h.asDays=function(){return this.as("days")},h.weeks=function(){return this.get("weeks")},h.asWeeks=function(){return this.as("weeks")},h.months=function(){return this.get("months")},h.asMonths=function(){return this.as("months")},h.years=function(){return this.get("years")},h.asYears=function(){return this.as("years")},f}();return function(e,n,r){t=r,a=r().$utils(),r.duration=function(t,a){var e=r.locale();return d(t,{$l:e},a)},r.isDuration=m;var s=n.prototype.add,i=n.prototype.subtract;n.prototype.add=function(t,a){return m(t)&&(t=t.asMilliseconds()),s.bind(this)(t,a)},n.prototype.subtract=function(t,a){return m(t)&&(t=t.asMilliseconds()),i.bind(this)(t,a)}}}()}},a={};function e(n){var r=a[n];if(void 0!==r)return r.exports;var s=a[n]={exports:{}};return t[n].call(s.exports,s,s.exports,e),s.exports}e.n=t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},e.d=(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},e.o=(t,a)=>Object.prototype.hasOwnProperty.call(t,a),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";e.r(n);const t=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/app"];var r=e.n(a);const s=flarum.core.compat["admin/components/ExtensionPage"];var i=e.n(s);const o=flarum.core.compat["common/components/Button"];var l=e.n(o);const c=flarum.core.compat["admin/components/LoadingModal"];var u=e.n(c);const d=flarum.core.compat["admin/utils/isExtensionEnabled"];var p=e.n(d);function f(t,a){return f=Object.setPrototypeOf||function(t,a){return t.__proto__=a,t},f(t,a)}function g(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,f(t,a)}function h(t,a){if(null==t)return{};var e,n,r={},s=Object.keys(t);for(n=0;n=0||(r[e]=t[e]);return r}const k=flarum.core.compat["common/Component"];var v=e.n(k);const y=flarum.core.compat["common/components/LoadingIndicator"];var b=e.n(y);const x=flarum.core.compat["common/components/Tooltip"];var w=e.n(x);const N=flarum.core.compat["common/helpers/icon"];var _=e.n(N);const M=flarum.core.compat["common/utils/ItemList"];var P=e.n(M);const U=flarum.core.compat["common/utils/extractText"];var j=e.n(U);const T=flarum.core.compat["common/utils/classList"];var q=e.n(T),B=["className","type"],S=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(t){var a=this.attrs,e=a.className,n=(a.type,h(a,B));return m("span",Object.assign({className:q()(["Label","Label--"+this.attrs.type,e])},n),t.children)},a}(v());const L=flarum.core.compat["common/components/Modal"];var O=e.n(L),A=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.className=function(){return"Modal--large QuickModal"},e.title=function(){return r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+this.attrs.task.operation())},e.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"TaskOutputModal-data"},m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.command")),m("div",{className:"FormControl TaskOutputModal-data-command"},m("code",null,"$ composer ",this.attrs.task.command()))),m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.output")),m("div",{className:"FormControl TaskOutputModal-data-output"},m("code",null,m("pre",null,this.attrs.task.output()))))))},a}(O()),C=e(3),E=e.n(C),I=function(t){function a(){return t.apply(this,arguments)||this}return g(a,t),a.prototype.view=function(){var t=this;return m("nav",{class:"Pagination UserListPage-gridPagination"},m(l(),{disabled:!this.attrs.list.hasPrev(),title:r().translator.trans("core.admin.users.pagination.back_button"),onclick:function(){return t.attrs.list.prev()},icon:"fas fa-chevron-left",className:"Button Button--icon UserListPage-backBtn"}),m("span",{class:"UserListPage-pageNumber"},r().translator.trans("core.admin.users.pagination.page_counter",{current:this.attrs.list.pageNumber()+1,total:this.attrs.list.getTotalPages()})),m(l(),{disabled:!this.attrs.list.hasNext(),title:r().translator.trans("core.admin.users.pagination.next_button"),onclick:function(){return t.attrs.list.next()},icon:"fas fa-chevron-right",className:"Button Button--icon UserListPage-nextBtn"}))},a}(v()),F=["label","content"],D=function(t){function a(){return t.apply(this,arguments)||this}g(a,t);var e=a.prototype;return e.oninit=function(a){t.prototype.oninit.call(this,a),r().packageManager.queue.load()},e.view=function(){return m("section",{id:"PackageManager-queueSection",className:"ExtensionPage-permissions PackageManager-queueSection"},m("div",{className:"ExtensionPage-permissions-header PackageManager-queueSection-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},r().translator.trans("flarum-package-manager.admin.sections.queue.title")),m(l(),{className:"Button Button--icon",icon:"fas fa-sync-alt",onclick:function(){return r().packageManager.queue.load()},"aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.refresh")}))),m("div",{className:"container"},this.queueTable()))},e.columns=function(){var t=this,a=new(P());return a.add("operation",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.operation")),content:function(a){return m("div",{className:"PackageManager-queueTable-operation"},m("span",{className:"PackageManager-queueTable-operation-icon"},t.operationIcon(a.operation())),m("span",{className:"PackageManager-queueTable-operation-name"},r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+a.operation())))}},80),a.add("package",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.package")),content:function(t){var a,e=r().data.extensions[null==(a=t.package())?void 0:a.replace(/(\/flarum-|\/flarum-ext-|\/)/g,"-")];return e?m("div",{className:"PackageManager-queueTable-package"},m("div",{className:"PackageManager-queueTable-package-icon ExtensionIcon",style:e.icon},e.icon?_()(e.icon.name):""),m("div",{className:"PackageManager-queueTable-package-details"},m("span",{className:"PackageManager-queueTable-package-title"},e.extra["flarum-extension"].title),m("span",{className:"PackageManager-queueTable-package-name"},t.package()))):t.package()}},75),a.add("status",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.status")),content:function(t){return m(S,{className:"PackageManager-queueTable-status",type:{running:"neutral",failure:"error",pending:"warning",success:"success"}[t.status()]},r().translator.trans("flarum-package-manager.admin.sections.queue.statuses."+t.status()))}},70),a.add("elapsedTime",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.elapsed_time")),content:function(t){return t.startedAt()?m(w(),{text:dayjs(t.startedAt()).format("LL LTS")+" "+dayjs(t.finishedAt()).format("LL LTS")},m("span",null,function(t,a){dayjs.extend(E());var e=dayjs(a).diff(t);return dayjs.duration(e).humanize()}(t.startedAt(),t.finishedAt()))):r().translator.trans("flarum-package-manager.admin.sections.queue.task_just_started")}},65),a.add("memoryUsed",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.peak_memory_used")),content:function(t){return m("span",null,t.peakMemoryUsed())}},60),a.add("details",{label:j()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details")),content:function(t){return m(l(),{className:"Button Button--icon Table-controls-item",icon:"fas fa-file-alt","aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details"),onclick:function(){return r().modal.show(A,{task:t})}})},className:"Table-controls"},55),a},e.queueTable=function(){var t=r().packageManager.queue.getItems();if(!t)return m(b(),null);if(t&&!t.length)return m("h3",{className:"ExtensionPage-subHeader"},r().translator.trans("flarum-package-manager.admin.sections.queue.none"));var a=this.columns();return m("[",null,m("table",{className:"Table PackageManager-queueTable"},m("thead",null,m("tr",null,a.toArray().map((function(t,a){return m("th",{key:a},t.label)})))),m("tbody",null,t.map((function(t,e){return m("tr",{key:e},a.toArray().map((function(a,e){a.label;var n=a.content,r=h(a,F);return m("td",Object.assign({key:e},r),n(t))})))})))),m(I,{list:r().packageManager.queue}))},e.operationIcon=function(t){return _()({update_check:"fas fa-sync-alt",update_major:"fas fa-play",update_minor:"fas fa-play",update_global:"fas fa-play",extension_install:"fas fa-download",extension_remove:"fas fa-times",extension_update:"fas fa-arrow-alt-circle-up",why_not:"fas fa-exclamation-circle"}[t])},a}(v());const Y=flarum.core.compat["common/components/Alert"];var H=e.n(Y);const R=flarum.core.compat["common/utils/Stream"];var W=e.n(R);function z(t){var a=t.response.errors[0];if(!["composer_command_failure","extension_already_installed","extension_not_installed"].includes(a.code))throw t;switch(a.code){case"composer_command_failure":a.guessed_cause?(r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.guessed_cause."+a.guessed_cause)),r().modal.close()):r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.composer_command_failure"));break;case"extension_already_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_already_installed")),r().modal.close();break;case"extension_not_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_not_installed")),r().modal.close()}}function G(){r().modal.close(),m.route.set(r().route("extension",{id:"flarum-package-manager"})),r().packageManager.queue.load(),setTimeout((function(){var t;null==(t=document.getElementById("PackageManager-queueSection"))||t.scrollIntoView({block:"nearest"})}),200)}window.jumpToQueue=G;var V=function(t){function a(){for(var a,e=arguments.length,n=new Array(e),r=0;r"+a.data.phpVersion+"",folder_perms_link:"https://docs.flarum.org/install#folder-ownership"}))),default:!1,type:"boolean",disabled:a.data["flarum-package-manager.using_sync_queue"]}).registerPage(lt),(0,t.extend)(i().prototype,"topItems",(function(t){var e=this;"flarum-package-manager"===this.extension.id||p()(this.extension.id)||t.add("remove",m(l(),{className:"Button Button--danger",icon:"fas fa-times",onclick:function(){a.modal.show(u()),a.request({url:a.forum.attribute("apiUrl")+"/package-manager/extensions/"+e.extension.id,method:"DELETE"}).then((function(t){null!=t&&t.processing?G():(a.alerts.show({type:"success"},a.translator.trans("flarum-package-manager.admin.extensions.successful_remove")),window.location=a.forum.attribute("adminUrl"))})).finally((function(){a.modal.close()}))}},"Remove"))}))}))})(),module.exports=n})(); //# sourceMappingURL=admin.js.map