!function(){var o=function(e,t){return $("#msg").attr("trspan",e),$("#msg").html(window.translate(e)),$("#color").removeClass("message-positive message-warning alert-success alert-warning alert-danger"),$("#color").addClass("message-"+t),"positive"===t&&(t="success"),$("#color").addClass("alert-"+t),$("#color").attr("role","status")},n=function(e,t,r){if(console.log("Error",r),(r=JSON.parse(e.responseText))&&r.error)return r=r.error.replace(/.* /,""),console.log("Returned error",r),r.match(/module/)?o("notAuthorized","warning"):"csrfToken"===r?(o(r,"danger"),setTimeout(function(){return window.location=window.location.href.split("?")[0]},2e3)):o(r,"warning")},e=function(t,r,e){return e=e||("UBK"===t?"yubikey":"TOTP"===t?"totp":"WebAuthn"===t?"webauthn":t.toLowerCase()),$.ajax({type:"POST",url:portal+`2fregisters/${e}/delete`,data:{epoch:r,csrf_token:datas.csrf_token},dataType:"json",error:n,success:function(e){return e.error?e.error.match(/notAuthorized/)?o("notAuthorized","warning"):o("unknownAction","warning"):e.result?($("#delete-"+r).hide(),e=jQuery.Event("mfaDeleted"),$(document).trigger(e,[{type:t,epoch:r}]),e.isDefaultPrevented()||o("yourKeyIsUnregistered","positive"),setTimeout(function(){return window.location=window.location.href.split("?")[0]},2e3)):void 0}})};$(document).ready(function(){return $("body").on("click",".remove2f",function(){return e($(this).attr("device"),$(this).attr("epoch"),$(this).attr("prefix"))}),$("#goback").attr("href",portal),$(".data-epoch").each(function(){var e=new Date(1e3*$(this).text());return $(this).text(e.toLocaleString())})})}.call(this);