text: !function(e){var t={};function i(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,i),a.l=!0,a.exports}i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)i.d(r,a,function(t){return e[t]}.bind(null,a));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){"use strict";i.r(t);var r=class{constructor(){$(".group-accounts.create").length&&$("select[name=group_id]").on("change",(function(){$("#user-group-descriptions li").hide(),$("#user-group-pwrules li").hide(),$("#user-group-"+$(this).val()).show(),$("#user-group-pw-"+$(this).val()).show()}))}};var a=class{constructor(){$(".group-accounts.edit").length&&this.initEmailManagement()}initEmailManagement(){$("#add-email-form a.submit").on("click",()=>(this.addEmail(),!1)),$("#add-email-form input[name=email]").on("keydown",e=>13!==e.which||(this.addEmail(),!1)),$("tr.existing-email td.actions a").on("click",e=>{let t=$(e.currentTarget),i=t.closest("tr").data("email");switch(t.data("action")){case"delete":this.deleteEmail(i);break;case"verify":this.verifyEmail(i);break;case"make-primary":this.makePrimaryEmail(i);break;default:console.log("no action")}return!1})}addEmail(){let e=$("#add-email-form input[name=email]").val(),t=$("#add-email-form input[name=is_primary]").is(":checked")?1:0,i=$("#add-email-form input[name=is_verified]").is(":checked")?1:0;$("#email-form input[name=action]").val("add"),$("#email-form input[name=email]").val(e),$("#email-form input[name=is_primary]").val(t),$("#email-form input[name=is_verified]").val(i),$("#email-form").submit()}deleteEmail(e){let t=$("<div>").text('Are you sure you want to delete "'+e+'"?').dialog({title:"Are you sure?",resizable:!1,draggable:!1,modal:!0,buttons:{OK:function(){$("#email-form input[name=action]").val("delete"),$("#email-form input[name=email]").val(e),$("#email-form").submit()},Cancel:function(){t.dialog("close")}}})}verifyEmail(e){$("#email-form input[name=action]").val("verify"),$("#email-form input[name=email]").val(e),$("#email-form").submit()}makePrimaryEmail(e){$("#email-form input[name=action]").val("makePrimary"),$("#email-form input[name=email]").val(e),$("#email-form").submit()}};var o=class{constructor(){$(".group-accounts.merge").length&&$("#merge-form").on("submit",()=>this.validate())}validate(){let e,t,i=!1,r=[],a=parseInt($("#user-id").val(),10),o=$("#merge-ids").val().split(","),s=[];for(e=0;e<o.length;e++)o[e]&&s.push(parseInt(o[e],10));for(isNaN(a)&&(i=!0,r.push("You must specify the user to keep.")),0===s.length&&(i=!0,r.push("You must specify at least one user to merge.")),e=0;e<s.length;e++)if(s[e]===a){i=!0,r.push("The user to merge into cannot be listed as a merge user.");break}for(e=0;e<s.length;e++)if(s[e]===window.NAILS.USER.ID){i=!0,r.push("You cannot specify yourself as a merge user.");break}if(!1===i)return!0;t="<p>The following errors occurred:</p>",t+="<ul>";for(let e in r)r.hasOwnProperty(e)&&(t+="<li>&rsaquo; "+r[e]+"</li>");t+="</ul>";let n=$("<div>").html(t).dialog({title:"An error occurred",resizable:!1,draggable:!1,modal:!0,dialogClass:"no-close",buttons:{OK:function(){n.dialog("close")}}}).show();return!1}};var s=class{constructor(){this.searchTimeout=null,this.searchDelay=150,$(".group-accounts.groups.edit").length&&(this.toggleSuperuser(),this.togglePermissions(),this.permissionSearch())}toggleSuperuser(){$(".field.boolean .toggle").on("toggle",(function(e,t){t?$("#adminPermissions").hide():$("#adminPermissions").show()}))}togglePermissions(){$(".permission-group tbody td.permission").on("click",(e,t)=>{$(t).closest("tr").find("input[type=checkbox]").click()}),$(".permission-group tbody td.enabled input").on("change",e=>{let t=$(e.currentTarget),i=t.closest("td");t.is(":checked")?(i.removeClass("error"),i.addClass("success")):(i.addClass("error"),i.removeClass("success"))}),$(".permission-group .toggleAll").on("click",e=>{let t=$(e.currentTarget),i=t.closest("table").find("tbody td.enabled input"),r=t.is(":checked");i.each((e,t)=>{let i=$(t);i.prop("checked",r);let a=i.closest("td");i.is(":checked")?(a.removeClass("error"),a.addClass("success")):(a.addClass("error"),a.removeClass("success"))})})}permissionSearch(){$("#permissionSearch input").on("keyup",e=>{let t=$(e.currentTarget),i=$.trim(t.val());clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{console.log("search"),this.doPermissionSearch(i)},this.searchDelay)})}doPermissionSearch(e){let t,i,r;if(""===e)return $(".permission-group").show(),void $(".permission-group tbody tr").show();t=new RegExp($.trim(e),"i"),$(".permission-group td.permission").each((e,a)=>{let o=$(a);i=$.trim(o.text()),r=t.test(i),r?o.closest("tr").show():o.closest("tr").hide()}),$(".permission-group legend").each((e,a)=>{let o=$(a);i=$.trim(o.text()),r=t.test(i),r&&o.parent().find("tbody tr").show()}),$(".permission-group").show(),$(".permission-group").each((e,t)=>{let i=$(t);i.find("td.permission:visible").length>0?i.show():i.hide()})}};var n=class{constructor(e){e.onRefreshUi(()=>{this.init()})}init(){let e=[{class:"user-search",placeholder:"Search for a user",minimumInputLength:3,apiUrl:window.SITE_URL+"api/auth/user",format:function(e){return"#"+e.id+" - "+e.first_name+" "+e.last_name+" ("+e.email+")"}}];for(let t in e)e.hasOwnProperty(t)&&this.setupSearcher(e[t])}setupSearcher(e){$("input."+e.class+":not(.processed)").each((t,i)=>{let r=$(i),a=r.data("multiple")||!1;r.parents(".js-admin-dynamic-table__template").length>0?console.log(r,r.parents(".js-admin-dynamic-table__template")):r.addClass("processed").select2({placeholder:e.placeholder,minimumInputLength:e.minimumInputLength,multiple:a,ajax:{url:e.apiUrl+"/search",dataType:"json",quietMillis:250,data:function(e){return{keywords:e}},results:function(t){let i,r={results:[]};for(let a in t.data)t.data.hasOwnProperty(a)&&(i="function"==typeof e.format?e.format(t.data[a]):t.data[a].label,r.results.push({id:t.data[a].id,text:i}));return r},cache:!0},initSelection:function(t,i){let r=$(t).val();""!==r&&(a?$.ajax({url:e.apiUrl+"/id?ids="+r,dataType:"json"}).done((function(t){let r=[],a="";for(let i=0;i<t.data.length;i++)a="function"==typeof e.format?e.format(t.data[i]):t.data[i].label,r.push({id:t.data[i].id,text:a});i(r)})):$.ajax({url:e.apiUrl+"/id?id="+r,dataType:"json"}).done((function(t){let r;r="function"==typeof e.format?e.format(t.data):t.data.label,i({id:t.data.id,text:r})})))}})})}};window.NAILS.ADMIN.registerPlugin("nails/module-auth","AccountCreate",new r),window.NAILS.ADMIN.registerPlugin("nails/module-auth","AccountEdit",new a),window.NAILS.ADMIN.registerPlugin("nails/module-auth","AccountMerge",new o),window.NAILS.ADMIN.registerPlugin("nails/module-auth","Groups",new s),window.NAILS.ADMIN.registerPlugin("nails/module-auth","SearchUser",new n(window.NAILS.ADMIN))}]);