(()=>{"use strict";var e={68674:(e,t,n)=>{n.r(t)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{function e(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 t(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){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;r<n;r++)t+=String.fromCharCode(e[r]);e=window.btoa(t)}if("string"!=typeof e)throw new Error("could not coerce to string");return e=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=*$/g,"")}n(68674);const o="bitwarden://webauthn-callback";let a,i=!1,c=null,d=null,l=null,u=null,s=null,p=!1,f=!1,g=!1,y=null;function b(){if(i)return;if(u=e("parent"),!u)return void w("No parent.");u=decodeURIComponent(u),s=new URL(u).origin;"1"===e("v")?function(){const n=e("data");if(!n)return void w("No data.");a=t(n),c=e("headerText"),d=e("btnText"),l=e("btnReturnText")}():function(){let n=null;try{n=JSON.parse(t(e("data")))}catch(r){return void w("Cannot parse data.")}p=null!=n.callbackUri||!0===n.mobile,a=n.data,c=n.headerText,d=n.btnText,l=n.btnReturnText}(),i=!0}function m(){if(g=!1,"credentials"in navigator)if(b(),a){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}(a)}catch(e){return void w("Cannot parse webauthn data.")}f=!1,p||-1!==navigator.userAgent.indexOf(" Safari/")&&-1===navigator.userAgent.indexOf("Chrome")||h()}else w("No data.");else w("WebAuthn is not supported in this browser.")}function h(){f||navigator.credentials.get({publicKey:y}).then(U).catch(w)}function w(e){p?(document.location.replace(o+"?error="+encodeURIComponent(e)),x(o+"?error="+encodeURIComponent(e))):parent.postMessage("error|"+e,u)}function U(e){if(g)return;const t=function(e){const t=e.response,n=new Uint8Array(t.authenticatorData),o=new Uint8Array(t.clientDataJSON),a=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),c={id:e.id,rawId:r(a),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:r(n),clientDataJson:r(o),signature:r(i)}};return JSON.stringify(c)}(e);p?(document.location.replace(o+"?data="+encodeURIComponent(t)),x(o+"?data="+encodeURIComponent(t))):(parent.postMessage("success|"+t,u),g=!0)}function x(e){const t=document.getElementById("webauthn-button");t.innerText=decodeURI(l),t.onclick=()=>{document.location.replace(e)}}document.addEventListener("DOMContentLoaded",(()=>{var e;if(m(),window.addEventListener("message",(e=>{e.origin&&""!==e.origin&&e.origin===s&&("stop"===e.data?f=!0:"start"===e.data&&f&&m())}),!1),e="ready",p||parent.postMessage("info|"+e,u),b(),c){document.getElementById("webauthn-header").innerText=decodeURI(c)}if(d){const e=document.getElementById("webauthn-button");e.innerText=decodeURI(d),e.onclick=h}}))})()})();
//# sourceMappingURL=webauthn.b50e3a9527b3e4de41eb.js.map