(()=>{"use strict";function e(){const e=window.location.hostname||"";return[".bitwarden.com",".bitwarden.eu",".bitwarden.pw"].some(t=>e.endsWith(t))}function t(e){const t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}function n(e,t=!1){return t&&(e=e.replace(/ /g,"+")),decodeURIComponent(Array.prototype.map.call(atob(e),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}function r(e){document.location.replace(e)}function o(e){const n=`${e}-callback`;return"https"===(t("deeplinkScheme")||"").toLowerCase()?`https://${function(){const e=window.location.hostname||"";return e.endsWith("bitwarden.eu")?"bitwarden.eu":e.endsWith("bitwarden.pw")?"bitwarden.pw":"bitwarden.com"}()}/${n}`:`bitwarden://${n}`}function a(e){if(Array.isArray(e)&&(e=Uint8Array.from(e)),e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array){let t="";const n=e.byteLength;for(let r=0;ro("webauthn")),h=null!=g,i=e.data,d=e.headerText,s=e.btnText,u=e.btnReturnText}(),w||g?c=!0:R("No return target provided.")}function C(){if(m=!1,"credentials"in navigator){if(A(),d){document.getElementById("webauthn-header").innerText=decodeURI(d)}if(U(),i){try{y=function(e){const t=JSON.parse(e),n=t.challenge.replace(/-/g,"+").replace(/_/g,"/");return t.challenge=Uint8Array.from(atob(n),e=>e.charCodeAt(0)),t.allowCredentials.forEach(e=>{const t=e.id.replace(/\_/g,"/").replace(/\-/g,"+");e.id=Uint8Array.from(atob(t),e=>e.charCodeAt(0))}),t}(i)}catch(e){return void R("Cannot parse webauthn data.")}b=!1,h||-1!==navigator.userAgent.indexOf(" Safari/")&&-1===navigator.userAgent.indexOf("Chrome")||I()}else R("No data.")}else R("WebAuthn is not supported in this browser.")}function I(){b?U():(!function(){if(!l)return;const e=document.getElementById("webauthn-button");e.innerText=decodeURI(l),e.onclick=null,e.classList.remove(...x),e.classList.add(...v)}(),navigator.credentials.get({publicKey:y}).then(L).catch(R))}function R(e){if(g){const t=g+"?error="+encodeURIComponent(e);r(t),T(t)}else w&&(parent.postMessage("error|"+e,p),U())}function L(e){if(m)return;const t=function(e){const t=e.response,n=new Uint8Array(t.authenticatorData),r=new Uint8Array(t.clientDataJSON),o=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),c={id:e.id,rawId:a(o),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:a(n),clientDataJson:a(r),signature:a(i)}};return JSON.stringify(c)}(e);if(g){const e=g+"?data="+encodeURIComponent(t);r(e),T(e)}else w&&(parent.postMessage("success|"+t,p),m=!0)}function T(e){const t=document.getElementById("webauthn-button");t.innerText=decodeURI(u),t.onclick=()=>{r(e)}}document.addEventListener("DOMContentLoaded",()=>{var t;C(),window.addEventListener("message",t=>{const n=w&&w.startsWith("file:")||!e()?f:window.location.origin;(!n||t.origin&&""!==t.origin&&t.origin===n)&&("stop"===t.data?(U(),b=!0):"start"===t.data&&b&&C())},!1),t="ready",!h&&w&&parent.postMessage("info|"+t,p)})})(); //# sourceMappingURL=webauthn.ead2ec284156bb3fc911.js.map