(()=>{function e(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,i=function(){};return{s:i,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,f=!0,d=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return f=e.done,e},e:function(e){d=!0,o=e},f:function(){try{f||null==r.return||r.return()}finally{if(d)throw o}}}}function n(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}!function(n){var t=!1,r=null,a=n("#login"),i=a.find("#wpdef-2fa-form-"+webauthn.provider_slug);a.find("#wrap-nav #nav");function o(r,a){r.preventDefault(),!0!==t&&!1!==wpdefCheckBrowserSupportForWebauthn()&&(f(),n.ajax({url:webauthn.admin_url,type:"POST",data:{action:"defender_webauthn_get_option",username:webauthn.username,type:a,_def_nonce:webauthn.nonce},success:function(n){if(!1===n.success||void 0===n.data.challenge){return c("undefined"!==n.data.message&&"undefined"!==n.data.code&&0<n.data.code?n.data.message:webauthn.i18n.login_failed),void d()}var t=n.data;if(t.challenge=Uint8Array.from(window.atob(wpdefBase64Url2Base64(t.challenge)),(function(e){return e.charCodeAt(0)})),t.allowCredentials){var r,o=e(t.allowCredentials);try{for(o.s();!(r=o.n()).done;){var f=r.value;"cross-platform"===a?f.transports=["usb","nfc","ble"]:"platform"===a&&(f.transports=["internal"]),f.id=Uint8Array.from(window.atob(wpdefBase64Url2Base64(f.id)),(function(e){return e.charCodeAt(0)}))}}catch(e){o.e(e)}finally{o.f()}}var s=t.clientID;delete t.clientID,navigator.credentials.get({publicKey:t}).then((function(e){return{id:e.id,type:e.type,rawId:wpdefArrayToBase64String(new Uint8Array(e.rawId)),response:{authenticatorData:wpdefArrayToBase64String(new Uint8Array(e.response.authenticatorData)),clientDataJSON:wpdefArrayToBase64String(new Uint8Array(e.response.clientDataJSON)),signature:wpdefArrayToBase64String(new Uint8Array(e.response.signature)),userHandle:e.response.userHandle?wpdefArrayToBase64String(new Uint8Array(e.response.userHandle)):null}}})).then(JSON.stringify).then((function(e){i.find("#wpdef-2fa-biometric-data").val(window.btoa(e)),i.find("#wpdef-2fa-biometric-username").val(webauthn.username),i.find("#wpdef-2fa-biometric-client-id").val(s),i.find("#wpdef-2fa-biometric-nonce").val(webauthn.nonce),i.find("#wpdef-2fa-biometric-submit-btn").trigger("click")})).catch((function(e){c(webauthn.i18n.login_failed),d()}))},error:function(){c(webauthn.i18n.login_failed),d()}}))}function f(){t=!0,a.find("#login_error").remove(),i.find(".welcome-screen").hide(),i.find(".webauthn-"+r).show(),i.find(".wpdef-2fa-webauthn-control").hide(),i.find(".wpdef-2fa-biometric-process-desc").show()}function d(){t=!1,i.find(".wpdef-2fa-biometric-process-desc").hide(),i.find(".wpdef-2fa-webauthn-control").show()}function c(e){var n='<div id="login_error" class="notice notice-error">'+e+"</div>";a.find("h1").after(n)}n((function(){!1===wpdefCheckBrowserSupportForWebauthn()&&(e=webauthn.i18n.client_webauthn_notice,n='<div class="wpdef-notice warning webauthn-client-notice"><span class="dashicons dashicons-info"></span><span class="wpdef-notice-message">'+e+"</span></div>",i.append(n),i.find(".wpdef-2fa-biometric-process-desc").hide());var e,n})),i.find(".option-row").on("click",(function(e){o(e,r=n(this).attr("data-authType"))})),i.find("#wpdef-2fa-biometric-retry-btn").on("click",(function(e){null!==r&&o(e,r)})),i.find("#wpdef-2fa-webauthn-back-btn").on("click",(function(e){null!==r&&(a.find("#login_error").remove(),i.find(".welcome-screen").show(),i.find(".webauthn-"+r).hide(),i.find(".wpdef-2fa-webauthn-control").hide())}))}(jQuery)})();