Files
2025-07-31 16:05:55 +08:00

2 lines
595 KiB
JavaScript

(()=>{var e,t={42227:(e,t,i)=>{"use strict";var n,s,r,o,a,l;!function(e){e[e.LoggedOut=0]="LoggedOut",e[e.Locked=1]="Locked",e[e.Unlocked=2]="Unlocked"}(n||(n={})),function(e){e[e.None=0]="None",e[e.Password=1]="Password"}(s||(s={})),function(e){e[e.Login=1]="Login",e[e.SecureNote=2]="SecureNote",e[e.Card=3]="Card",e[e.Identity=4]="Identity"}(r||(r={}));class c{constructor(e){this.accountConstructor=e}create(e){return new this.accountConstructor(e)}}class d{constructor(e){this.globalStateConstructor=e}create(e){return new this.globalStateConstructor(e)}}class u{constructor(e,t){this.globalStateFactory=new d(e),this.accountFactory=new c(t)}createGlobal(e){return this.globalStateFactory.create(e)}createAccount(e){return this.accountFactory.create(e)}}!function(e){e[e.One=1]="One",e[e.Two=2]="Two",e[e.Three=3]="Three",e[e.Four=4]="Four",e[e.Five=5]="Five",e[e.Six=6]="Six",e[e.Latest=6]="Latest"}(o||(o={})),function(e){e.System="system",e.Light="light",e.Dark="dark",e.Nord="nord",e.SolarizedDark="solarizedDark"}(a||(a={}));class h{constructor(){this.base=null,this.api=null,this.identity=null,this.icons=null,this.notifications=null,this.events=null,this.webVault=null,this.keyConnector=null}static fromJSON(e){return Object.assign(new h,e)}}class p{}class y{constructor(){this.theme=a.System,this.window=new p,this.stateVersion=o.One,this.environmentUrls=new h}}!function(e){e[e.Android=0]="Android",e[e.iOS=1]="iOS",e[e.ChromeExtension=2]="ChromeExtension",e[e.FirefoxExtension=3]="FirefoxExtension",e[e.OperaExtension=4]="OperaExtension",e[e.EdgeExtension=5]="EdgeExtension",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.MacOsDesktop=7]="MacOsDesktop",e[e.LinuxDesktop=8]="LinuxDesktop",e[e.ChromeBrowser=9]="ChromeBrowser",e[e.FirefoxBrowser=10]="FirefoxBrowser",e[e.OperaBrowser=11]="OperaBrowser",e[e.EdgeBrowser=12]="EdgeBrowser",e[e.IEBrowser=13]="IEBrowser",e[e.UnknownBrowser=14]="UnknownBrowser",e[e.AndroidAmazon=15]="AndroidAmazon",e[e.UWP=16]="UWP",e[e.SafariBrowser=17]="SafariBrowser",e[e.VivaldiBrowser=18]="VivaldiBrowser",e[e.VivaldiExtension=19]="VivaldiExtension",e[e.SafariExtension=20]="SafariExtension"}(l||(l={}));var v=i(96905),g=i(71469);const m="undefined"==typeof window?i(50209):null;class f{static init(){f.inited||(f.inited=!0,f.isNode=void 0!==g&&null!=g.release&&"node"===g.release.name,f.isBrowser="undefined"!=typeof window,f.isMobileBrowser=f.isBrowser&&this.isMobile(window),f.isAppleMobileBrowser=f.isBrowser&&this.isAppleMobile(window),f.isNode?f.global=i.g:f.isBrowser?f.global=window:f.global=self)}static fromB64ToArray(e){if(f.isNode)return new Uint8Array(Buffer.from(e,"base64"));{const t=f.global.atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i}}static fromUrlB64ToArray(e){return f.fromB64ToArray(f.fromUrlB64ToB64(e))}static fromHexToArray(e){if(f.isNode)return new Uint8Array(Buffer.from(e,"hex"));{const t=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)t[i/2]=parseInt(e.substr(i,2),16);return t}}static fromUtf8ToArray(e){if(f.isNode)return new Uint8Array(Buffer.from(e,"utf8"));{const t=unescape(encodeURIComponent(e)),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i}}static fromByteStringToArray(e){if(null==e)return null;const t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}static fromBufferToB64(e){if(f.isNode)return Buffer.from(e).toString("base64");{let t="";const i=new Uint8Array(e);for(let e=0;e<i.byteLength;e++)t+=String.fromCharCode(i[e]);return f.global.btoa(t)}}static fromBufferToUrlB64(e){return f.fromB64toUrlB64(f.fromBufferToB64(e))}static fromB64toUrlB64(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}static fromBufferToUtf8(e){if(f.isNode)return Buffer.from(e).toString("utf8");{const t=new Uint8Array(e),i=String.fromCharCode.apply(null,t);return decodeURIComponent(escape(i))}}static fromBufferToByteString(e){return String.fromCharCode.apply(null,new Uint8Array(e))}static fromBufferToHex(e){if(f.isNode)return Buffer.from(e).toString("hex");{const t=new Uint8Array(e);return Array.prototype.map.call(t,(e=>("00"+e.toString(16)).slice(-2))).join("")}}static fromUrlB64ToB64(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}return t}static fromUrlB64ToUtf8(e){return f.fromB64ToUtf8(f.fromUrlB64ToB64(e))}static fromUtf8ToB64(e){return f.isNode?Buffer.from(e,"utf8").toString("base64"):decodeURIComponent(escape(f.global.btoa(e)))}static fromUtf8ToUrlB64(e){return f.fromBufferToUrlB64(f.fromUtf8ToArray(e))}static fromB64ToUtf8(e){return f.isNode?Buffer.from(e,"base64").toString("utf8"):decodeURIComponent(escape(f.global.atob(e)))}static newGuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}static isGuid(e){return RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,"i").test(e)}static getHostname(e){const t=f.getUrl(e);try{return null!=t&&""!==t.hostname?t.hostname:null}catch(e){return null}}static getHost(e){const t=f.getUrl(e);try{return null!=t&&""!==t.host?t.host:null}catch(e){return null}}static getDomain(e){if(null==e)return null;if(""===(e=e.trim()))return null;if(e.startsWith("data:"))return null;let t=e.startsWith("http://")||e.startsWith("https://");if(!t&&e.indexOf("://")<0&&f.tldEndingRegex.test(e)&&e.indexOf("@")<0&&(e="http://"+e,t=!0),t)try{const t=f.getUrlObject(e);if(!(null==(null==v?void 0:v.isValid)||v.isValid(t.hostname)))return null;if("localhost"===t.hostname||f.validIpAddress(t.hostname))return t.hostname;const i=null!=v&&null!=v.getDomain?v.getDomain(t.hostname):null;return null!=i?i:t.hostname}catch(e){}try{const t=null!=v&&null!=v.getDomain?v.getDomain(e):null;if(null!=t)return t}catch(e){return null}return null}static getQueryParams(e){const t=f.getUrl(e);if(null==t||null==t.search||""===t.search)return null;const i=new Map;return("?"===t.search[0]?t.search.substr(1):t.search).split("&").forEach((e=>{const t=e.split("=");t.length<1||i.set(decodeURIComponent(t[0]).toLowerCase(),null==t[1]?"":decodeURIComponent(t[1]))})),i}static getSortFunction(e,t){return(i,n)=>null==i[t]&&null!=n[t]?-1:null!=i[t]&&null==n[t]?1:null==i[t]&&null==n[t]?0:e.collator?e.collator.compare(i[t],n[t]):i[t].localeCompare(n[t])}static isNullOrWhitespace(e){return null==e||"string"!=typeof e||""===e.trim()}static isNullOrEmpty(e){return null==e||"string"!=typeof e||""==e}static nameOf(e){return e}static assign(e,t){return Object.assign(e,t)}static iterateEnum(e){return Object.keys(e).filter((e=>Number.isNaN(+e))).map((t=>e[t]))}static getUrl(e){if(null==e)return null;if(""===(e=e.trim()))return null;let t=f.getUrlObject(e);if(null==t){!(0===e.indexOf("http://")||0===e.indexOf("https://"))&&e.indexOf(".")>-1&&(t=f.getUrlObject("http://"+e))}return t}static camelToPascalCase(e){return e.charAt(0).toUpperCase()+e.slice(1)}static pickTextColorBasedOnBgColor(e,t=186,i=!1){const n="#"===e.charAt(0)?e.substring(1,7):e;return.299*parseInt(n.substring(0,2),16)+.587*parseInt(n.substring(2,4),16)+.114*parseInt(n.substring(4,6),16)>t?i?"black":"black !important":i?"white":"white !important"}static stringToColor(e){let t=0;for(let i=0;i<e.length;i++)t=e.charCodeAt(i)+((t<<5)-t);let i="#";for(let e=0;e<3;e++){i+=("00"+(t>>8*e&255).toString(16)).substr(-2)}return i}static getContainerService(){if(null==this.global.bitwardenContainerService)throw new Error("global bitwardenContainerService not initialized.");return this.global.bitwardenContainerService}static validIpAddress(e){return/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(e)}static isMobile(e){let t=!1;var i;return i=e.navigator.userAgent||e.navigator.vendor||e.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(i)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(i.substr(0,4)))&&(t=!0),t||null!=e.navigator.userAgent.match(/iPad/i)}static isAppleMobile(e){return null!=e.navigator.userAgent.match(/iPhone/i)||null!=e.navigator.userAgent.match(/iPad/i)}static getUrlObject(e){try{if(null!=m)return new m.URL(e);if("function"==typeof URL)return new URL(e);if("undefined"!=typeof window){const t=e.indexOf("://")>-1;if(!t&&e.indexOf(".")>-1)e="http://"+e;else if(!t)return null;const i=window.document.createElement("a");return i.href=e,i}}catch(e){}return null}}f.inited=!1,f.isNode=!1,f.isBrowser=!0,f.isMobileBrowser=!1,f.isAppleMobileBrowser=!1,f.global=null,f.tldEndingRegex=/.*\.(com|net|org|edu|uk|gov|ca|de|jp|fr|au|ru|ch|io|es|us|co|xyz|info|ly|mil)$/,f.regexpEmojiPresentation=/(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])/g,f.init();class b{constructor(e,t){this.type=t.getDevice(),this.name=t.getDeviceString(),this.identifier=e,this.pushToken=null}}class w{constructor(e,t){this.twoFactor=e,this.device=null!=t?t:null}alterIdentityTokenHeaders(e){}setTwoFactor(e){this.twoFactor=e}setPasswordlessAccessCode(e){this.passwordlessAuthRequest=e}toIdentityToken(e){const t={scope:"api offline_access",client_id:e};return this.device&&(t.deviceType=this.device.type,t.deviceIdentifier=this.device.identifier,t.deviceName=this.device.name),this.passwordlessAuthRequest&&(t.authRequest=this.passwordlessAuthRequest),this.twoFactor.token&&null!=this.twoFactor.provider&&(t.twoFactorToken=this.twoFactor.token,t.twoFactorProvider=this.twoFactor.provider,t.twoFactorRemember=this.twoFactor.remember?"1":"0"),t}}class S extends w{constructor(e,t,i,n){super(i,n),this.clientId=e,this.clientSecret=t,this.twoFactor=i}toIdentityToken(){const e=super.toIdentityToken(this.clientId);return e.scope=this.clientId.startsWith("organization")?"api.organization":"api",e.grant_type="client_credentials",e.client_secret=this.clientSecret,e}}class k{constructor(e=null,t=null,i=!1){this.provider=e,this.token=t,this.remember=i}}class O{constructor(e){this.response=e}getResponseProperty(e,t=null,i=!1){if(null==e||""===e)throw new Error("propertyName must not be null/empty.");if(null==t&&null!=this.response&&(t=this.response),null==t)return null;if(!i&&void 0===t[e]){let i=null;i=e.charAt(0)===e.charAt(0).toUpperCase()?e.charAt(0).toLowerCase():e.charAt(0).toUpperCase(),e.length>1&&(i+=e.slice(1)),void 0===t[e=i]&&(e=e.toLowerCase()),void 0===t[e]&&(e=e.toUpperCase())}return t[e]}}class P extends O{constructor(e){super(e),this.apiKey=this.getResponseProperty("ApiKey"),this.revisionDate=new Date(this.getResponseProperty("RevisionDate"))}}class A extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.url=this.getResponseProperty("Url"),this.fileName=this.getResponseProperty("FileName"),this.key=this.getResponseProperty("Key"),this.size=this.getResponseProperty("Size"),this.sizeName=this.getResponseProperty("SizeName")}}class C extends O{constructor(e=null){super(e),null!=e&&(this.cardholderName=this.getResponseProperty("CardholderName"),this.brand=this.getResponseProperty("Brand"),this.number=this.getResponseProperty("Number"),this.expMonth=this.getResponseProperty("ExpMonth"),this.expYear=this.getResponseProperty("ExpYear"),this.code=this.getResponseProperty("Code"))}}class D extends O{constructor(e=null){super(e),null!=e&&(this.type=this.getResponseProperty("Type"),this.name=this.getResponseProperty("Name"),this.value=this.getResponseProperty("Value"),this.linkedId=this.getResponseProperty("linkedId"))}}class x extends O{constructor(e=null){super(e),null!=e&&(this.title=this.getResponseProperty("Title"),this.firstName=this.getResponseProperty("FirstName"),this.middleName=this.getResponseProperty("MiddleName"),this.lastName=this.getResponseProperty("LastName"),this.address1=this.getResponseProperty("Address1"),this.address2=this.getResponseProperty("Address2"),this.address3=this.getResponseProperty("Address3"),this.city=this.getResponseProperty("City"),this.state=this.getResponseProperty("State"),this.postalCode=this.getResponseProperty("PostalCode"),this.country=this.getResponseProperty("Country"),this.company=this.getResponseProperty("Company"),this.email=this.getResponseProperty("Email"),this.phone=this.getResponseProperty("Phone"),this.ssn=this.getResponseProperty("SSN"),this.username=this.getResponseProperty("Username"),this.passportNumber=this.getResponseProperty("PassportNumber"),this.licenseNumber=this.getResponseProperty("LicenseNumber"))}}class T extends O{constructor(e=null){if(super(e),this.match=null,null==e)return;this.uri=this.getResponseProperty("Uri");const t=this.getResponseProperty("Match");this.match=null!=t?t:null}}class I extends O{constructor(e=null){if(super(e),null==e)return;this.username=this.getResponseProperty("Username"),this.password=this.getResponseProperty("Password"),this.passwordRevisionDate=this.getResponseProperty("PasswordRevisionDate"),this.totp=this.getResponseProperty("Totp"),this.autofillOnPageLoad=this.getResponseProperty("AutofillOnPageLoad");const t=this.getResponseProperty("Uris");null!=t&&(this.uris=t.map((e=>new T(e))))}}class R extends O{constructor(e=null){super(e),null!=e&&(this.type=this.getResponseProperty("Type"))}}class E extends O{constructor(e){super(e),this.password=this.getResponseProperty("Password"),this.lastUsedDate=this.getResponseProperty("LastUsedDate")}}class U extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.organizationId=this.getResponseProperty("OrganizationId"),this.folderId=this.getResponseProperty("FolderId")||null,this.type=this.getResponseProperty("Type"),this.name=this.getResponseProperty("Name"),this.notes=this.getResponseProperty("Notes"),this.favorite=this.getResponseProperty("Favorite")||!1,this.edit=!!this.getResponseProperty("Edit"),null==this.getResponseProperty("ViewPassword")?this.viewPassword=!0:this.viewPassword=this.getResponseProperty("ViewPassword"),this.organizationUseTotp=this.getResponseProperty("OrganizationUseTotp"),this.revisionDate=this.getResponseProperty("RevisionDate"),this.collectionIds=this.getResponseProperty("CollectionIds"),this.deletedDate=this.getResponseProperty("DeletedDate");const t=this.getResponseProperty("Login");null!=t&&(this.login=new I(t));const i=this.getResponseProperty("Card");null!=i&&(this.card=new C(i));const n=this.getResponseProperty("Identity");null!=n&&(this.identity=new x(n));const r=this.getResponseProperty("SecureNote");null!=r&&(this.secureNote=new R(r));const o=this.getResponseProperty("Fields");null!=o&&(this.fields=o.map((e=>new D(e))));const a=this.getResponseProperty("Attachments");null!=a&&(this.attachments=a.map((e=>new A(e))));const l=this.getResponseProperty("PasswordHistory");null!=l&&(this.passwordHistory=l.map((e=>new E(e)))),this.reprompt=this.getResponseProperty("Reprompt")||s.None}}class F extends O{constructor(e){super(e),this.url=null,this.attachmentId=this.getResponseProperty("AttachmentId"),this.fileUploadType=this.getResponseProperty("FileUploadType");const t=this.getResponseProperty("CipherResponse"),i=this.getResponseProperty("CipherMiniResponse");this.cipherResponse=null==t?null:new U(t),this.cipherMiniResponse=null==i?null:new U(i),this.url=this.getResponseProperty("Url")}}class N extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.publicKey=this.getResponseProperty("PublicKey"),this.requestDeviceType=this.getResponseProperty("RequestDeviceType"),this.requestIpAddress=this.getResponseProperty("RequestIpAddress"),this.key=this.getResponseProperty("Key"),this.masterPasswordHash=this.getResponseProperty("MasterPasswordHash"),this.creationDate=this.getResponseProperty("CreationDate"),this.requestApproved=this.getResponseProperty("RequestApproved")}}class z extends O{constructor(e){super(e),this.captchaBypassToken=this.getResponseProperty("CaptchaBypassToken")}}class M extends O{constructor(e){super(e),this.type=this.getResponseProperty("Type"),this.cardBrand=this.getResponseProperty("CardBrand"),this.description=this.getResponseProperty("Description"),this.needsVerification=this.getResponseProperty("NeedsVerification")}}class L extends O{constructor(e){super(e),this.url=this.getResponseProperty("Url"),this.pdfUrl=this.getResponseProperty("PdfUrl"),this.number=this.getResponseProperty("Number"),this.paid=this.getResponseProperty("Paid"),this.date=this.getResponseProperty("Date"),this.amount=this.getResponseProperty("Amount")}}class B extends O{constructor(e){super(e),this.createdDate=this.getResponseProperty("CreatedDate"),this.amount=this.getResponseProperty("Amount"),this.refunded=this.getResponseProperty("Refunded"),this.partiallyRefunded=this.getResponseProperty("PartiallyRefunded"),this.refundedAmount=this.getResponseProperty("RefundedAmount"),this.type=this.getResponseProperty("Type"),this.paymentMethodType=this.getResponseProperty("PaymentMethodType"),this.details=this.getResponseProperty("Details")}}class K extends O{constructor(e){super(e),this.invoices=[],this.transactions=[];const t=this.getResponseProperty("Transactions"),i=this.getResponseProperty("Invoices");null!=t&&(this.transactions=t.map((e=>new B(e)))),null!=i&&(this.invoices=i.map((e=>new L(e))))}get hasNoHistory(){return 0==this.invoices.length&&0==this.transactions.length}}class _ extends O{constructor(e){super(e),this.balance=this.getResponseProperty("Balance");const t=this.getResponseProperty("PaymentSource");this.paymentSource=null==t?null:new M(t)}}class j extends O{constructor(e){super(e),this.addedDate=this.getResponseProperty("AddedDate"),this.breachDate=this.getResponseProperty("BreachDate"),this.dataClasses=this.getResponseProperty("DataClasses"),this.description=this.getResponseProperty("Description"),this.domain=this.getResponseProperty("Domain"),this.isActive=this.getResponseProperty("IsActive"),this.isVerified=this.getResponseProperty("IsVerified"),this.logoPath=this.getResponseProperty("LogoPath"),this.modifiedDate=this.getResponseProperty("ModifiedDate"),this.name=this.getResponseProperty("Name"),this.pwnCount=this.getResponseProperty("PwnCount"),this.title=this.getResponseProperty("Title")}}class G extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.readOnly=this.getResponseProperty("ReadOnly"),this.hidePasswords=this.getResponseProperty("HidePasswords")}}class V extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.organizationId=this.getResponseProperty("OrganizationId"),this.name=this.getResponseProperty("Name"),this.externalId=this.getResponseProperty("ExternalId")}}class H extends V{constructor(e){super(e),this.readOnly=this.getResponseProperty("ReadOnly")||!1}}class q extends V{constructor(e){super(e),this.groups=[];const t=this.getResponseProperty("Groups");null!=t&&(this.groups=t.map((e=>new G(e))))}}class W extends O{constructor(e){super(e),this.isDeviceVerificationSectionEnabled=this.getResponseProperty("IsDeviceVerificationSectionEnabled"),this.unknownDeviceVerificationEnabled=this.getResponseProperty("UnknownDeviceVerificationEnabled")}}class J extends O{constructor(e){super(e),this.type=this.getResponseProperty("Type"),this.domains=this.getResponseProperty("Domains"),this.excluded=this.getResponseProperty("Excluded")}}class Y extends O{constructor(e){super(e),this.globalEquivalentDomains=[],this.equivalentDomains=this.getResponseProperty("EquivalentDomains");const t=this.getResponseProperty("GlobalEquivalentDomains");this.globalEquivalentDomains=null!=t?t.map((e=>new J(e))):[]}}class $ extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.granteeId=this.getResponseProperty("GranteeId"),this.name=this.getResponseProperty("Name"),this.email=this.getResponseProperty("Email"),this.type=this.getResponseProperty("Type"),this.status=this.getResponseProperty("Status"),this.waitTimeDays=this.getResponseProperty("WaitTimeDays"),this.creationDate=this.getResponseProperty("CreationDate")}}class Q extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.grantorId=this.getResponseProperty("GrantorId"),this.name=this.getResponseProperty("Name"),this.email=this.getResponseProperty("Email"),this.type=this.getResponseProperty("Type"),this.status=this.getResponseProperty("Status"),this.waitTimeDays=this.getResponseProperty("WaitTimeDays"),this.creationDate=this.getResponseProperty("CreationDate")}}class X extends O{constructor(e){super(e),this.keyEncrypted=this.getResponseProperty("KeyEncrypted"),this.kdf=this.getResponseProperty("Kdf"),this.kdfIterations=this.getResponseProperty("KdfIterations")}}class Z extends O{constructor(e){super(e),this.ciphers=[],this.keyEncrypted=this.getResponseProperty("KeyEncrypted");const t=this.getResponseProperty("Ciphers");null!=t&&(this.ciphers=t.map((e=>new U(e))))}}class ee extends O{constructor(e,t,i){var n,s;super(e);let r=null;if(null!=e){const t=this.getResponseProperty("ErrorModel");r=t&&i?t:e}429===t?this.message="Rate limit exceeded. Try again later.":r&&(this.message=this.getResponseProperty("Message",r),this.validationErrors=this.getResponseProperty("ValidationErrors",r),this.captchaSiteKey=null===(s=null===(n=this.validationErrors)||void 0===n?void 0:n.HCaptcha_SiteKey)||void 0===s?void 0:s[0],this.captchaRequired=!f.isNullOrWhitespace(this.captchaSiteKey)),this.statusCode=t}getSingleMessage(){if(null==this.validationErrors)return this.message;for(const e in this.validationErrors)if(this.validationErrors.hasOwnProperty(e)&&this.validationErrors[e].length)return this.validationErrors[e][0];return this.message}getAllMessages(){const e=[];if(null==this.validationErrors)return e;for(const t in this.validationErrors)this.validationErrors.hasOwnProperty(t)&&this.validationErrors[t].forEach((i=>{let n="";if(t.indexOf("[")>-1&&t.indexOf("]")>-1){const e=t.lastIndexOf(".");n=t.substr(0,e>-1?e:t.length)+": "}e.push(n+i)}));return e}}class te extends O{constructor(e){super(e),this.type=this.getResponseProperty("Type"),this.userId=this.getResponseProperty("UserId"),this.organizationId=this.getResponseProperty("OrganizationId"),this.providerId=this.getResponseProperty("ProviderId"),this.cipherId=this.getResponseProperty("CipherId"),this.collectionId=this.getResponseProperty("CollectionId"),this.groupId=this.getResponseProperty("GroupId"),this.policyId=this.getResponseProperty("PolicyId"),this.organizationUserId=this.getResponseProperty("OrganizationUserId"),this.providerUserId=this.getResponseProperty("ProviderUserId"),this.providerOrganizationId=this.getResponseProperty("ProviderOrganizationId"),this.actingUserId=this.getResponseProperty("ActingUserId"),this.date=this.getResponseProperty("Date"),this.deviceType=this.getResponseProperty("DeviceType"),this.ipAddress=this.getResponseProperty("IpAddress"),this.installationId=this.getResponseProperty("InstallationId")}}class ie extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.organizationId=this.getResponseProperty("OrganizationId"),this.name=this.getResponseProperty("Name"),this.accessAll=this.getResponseProperty("AccessAll"),this.externalId=this.getResponseProperty("ExternalId")}}class ne extends ie{constructor(e){super(e),this.collections=[];const t=this.getResponseProperty("Collections");null!=t&&(this.collections=t.map((e=>new G(e))))}}class se extends O{constructor(e){super(e),this.siteKey=this.getResponseProperty("HCaptcha_SiteKey")}}class re extends O{constructor(e){super(e),this.accessToken=e.access_token,this.expiresIn=e.expires_in,this.refreshToken=e.refresh_token,this.tokenType=e.token_type,this.resetMasterPassword=this.getResponseProperty("ResetMasterPassword"),this.privateKey=this.getResponseProperty("PrivateKey"),this.key=this.getResponseProperty("Key"),this.twoFactorToken=this.getResponseProperty("TwoFactorToken"),this.kdf=this.getResponseProperty("Kdf"),this.kdfIterations=this.getResponseProperty("KdfIterations"),this.forcePasswordReset=this.getResponseProperty("ForcePasswordReset"),this.apiUseKeyConnector=this.getResponseProperty("ApiUseKeyConnector"),this.keyConnectorUrl=this.getResponseProperty("KeyConnectorUrl")}}class oe extends O{constructor(e){super(e),this.twoFactorProviders2=new Map,this.captchaToken=this.getResponseProperty("CaptchaBypassToken"),this.twoFactorProviders=this.getResponseProperty("TwoFactorProviders");const t=this.getResponseProperty("TwoFactorProviders2");if(null!=t)for(const e in t)t.hasOwnProperty(e)&&this.twoFactorProviders2.set(parseInt(e,null),t[e])}}class ae extends O{constructor(e){super(e),this.key=this.getResponseProperty("Key")}}class le extends O{constructor(e,t){super(e);const i=this.getResponseProperty("Data");this.data=null==i?[]:i.map((e=>new t(e))),this.continuationToken=this.getResponseProperty("ContinuationToken")}}class ce extends O{constructor(e,t){super(e),this.id=this.getResponseProperty("Id"),this.type=this.getResponseProperty("Type"),this.organizationId=this.getResponseProperty("OrganizationId"),this.enabled=this.getResponseProperty("Enabled");const i=this.getResponseProperty("Config");this.config=null==i?null:new t(i)}}class de extends O{constructor(e){super(e),this.collections=this.getResponseProperty("Collections"),this.ciphers=this.getResponseProperty("Ciphers")}}class ue extends O{constructor(e){super(e);const t=this.getResponseProperty("LastSyncDate");t&&(this.lastSyncDate=new Date(t))}}class he extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.key=this.getResponseProperty("Key")}}class pe extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.error=this.getResponseProperty("Error")}}class ye extends O{constructor(e=null){if(super(e),null==e)return this;this.accessEventLogs=this.getResponseProperty("AccessEventLogs"),this.accessImportExport=this.getResponseProperty("AccessImportExport"),this.accessReports=this.getResponseProperty("AccessReports"),this.manageAllCollections=this.getResponseProperty("ManageAllCollections"),this.manageAssignedCollections=this.getResponseProperty("ManageAssignedCollections"),this.createNewCollections=this.getResponseProperty("CreateNewCollections"),this.editAnyCollection=this.getResponseProperty("EditAnyCollection"),this.deleteAnyCollection=this.getResponseProperty("DeleteAnyCollection"),this.editAssignedCollections=this.getResponseProperty("EditAssignedCollections"),this.deleteAssignedCollections=this.getResponseProperty("DeleteAssignedCollections"),this.manageCiphers=this.getResponseProperty("ManageCiphers"),this.manageGroups=this.getResponseProperty("ManageGroups"),this.manageSso=this.getResponseProperty("ManageSso"),this.managePolicies=this.getResponseProperty("ManagePolicies"),this.manageUsers=this.getResponseProperty("ManageUsers"),this.manageResetPassword=this.getResponseProperty("ManageResetPassword"),this.manageScim=this.getResponseProperty("ManageScim")}}class ve extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.type=this.getResponseProperty("Type"),this.status=this.getResponseProperty("Status"),this.permissions=new ye(this.getResponseProperty("Permissions")),this.accessAll=this.getResponseProperty("AccessAll"),this.resetPasswordEnrolled=this.getResponseProperty("ResetPasswordEnrolled")}}class ge extends ve{constructor(e){var t;super(e),this.name=this.getResponseProperty("Name"),this.email=this.getResponseProperty("Email"),this.twoFactorEnabled=this.getResponseProperty("TwoFactorEnabled"),this.usesKeyConnector=null!==(t=this.getResponseProperty("UsesKeyConnector"))&&void 0!==t&&t}}class me extends ve{constructor(e){super(e),this.collections=[];const t=this.getResponseProperty("Collections");null!=t&&(this.collections=t.map((e=>new G(e))))}}class fe extends O{constructor(e){super(e),this.kdf=this.getResponseProperty("Kdf"),this.kdfIterations=this.getResponseProperty("KdfIterations"),this.resetPasswordKey=this.getResponseProperty("ResetPasswordKey"),this.encryptedPrivateKey=this.getResponseProperty("EncryptedPrivateKey")}}class be extends O{constructor(e){var t,i,n;super(e),this.id=this.getResponseProperty("Id"),this.name=this.getResponseProperty("Name"),this.usePolicies=this.getResponseProperty("UsePolicies"),this.useGroups=this.getResponseProperty("UseGroups"),this.useDirectory=this.getResponseProperty("UseDirectory"),this.useEvents=this.getResponseProperty("UseEvents"),this.useTotp=this.getResponseProperty("UseTotp"),this.use2fa=this.getResponseProperty("Use2fa"),this.useApi=this.getResponseProperty("UseApi"),this.useSso=this.getResponseProperty("UseSso"),this.useKeyConnector=null!==(t=this.getResponseProperty("UseKeyConnector"))&&void 0!==t&&t,this.useScim=null!==(i=this.getResponseProperty("UseScim"))&&void 0!==i&&i,this.useResetPassword=this.getResponseProperty("UseResetPassword"),this.selfHost=this.getResponseProperty("SelfHost"),this.usersGetPremium=this.getResponseProperty("UsersGetPremium"),this.seats=this.getResponseProperty("Seats"),this.maxCollections=this.getResponseProperty("MaxCollections"),this.maxStorageGb=this.getResponseProperty("MaxStorageGb"),this.key=this.getResponseProperty("Key"),this.hasPublicAndPrivateKeys=this.getResponseProperty("HasPublicAndPrivateKeys"),this.status=this.getResponseProperty("Status"),this.type=this.getResponseProperty("Type"),this.enabled=this.getResponseProperty("Enabled"),this.ssoBound=this.getResponseProperty("SsoBound"),this.identifier=this.getResponseProperty("Identifier"),this.permissions=new ye(this.getResponseProperty("permissions")),this.resetPasswordEnrolled=this.getResponseProperty("ResetPasswordEnrolled"),this.userId=this.getResponseProperty("UserId"),this.providerId=this.getResponseProperty("ProviderId"),this.providerName=this.getResponseProperty("ProviderName"),this.familySponsorshipFriendlyName=this.getResponseProperty("FamilySponsorshipFriendlyName"),this.familySponsorshipAvailable=this.getResponseProperty("FamilySponsorshipAvailable"),this.planProductType=this.getResponseProperty("PlanProductType"),this.keyConnectorEnabled=null!==(n=this.getResponseProperty("KeyConnectorEnabled"))&&void 0!==n&&n,this.keyConnectorUrl=this.getResponseProperty("KeyConnectorUrl");const s=this.getResponseProperty("FamilySponsorshipLastSyncDate");s&&(this.familySponsorshipLastSyncDate=new Date(s));const r=this.getResponseProperty("FamilySponsorshipValidUntil");r&&(this.familySponsorshipValidUntil=new Date(r)),this.familySponsorshipToDelete=this.getResponseProperty("FamilySponsorshipToDelete")}}class we extends be{constructor(e){super(e),this.keyConnectorEnabled=!1}}class Se extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.name=this.getResponseProperty("Name"),this.key=this.getResponseProperty("Key"),this.status=this.getResponseProperty("Status"),this.type=this.getResponseProperty("Type"),this.enabled=this.getResponseProperty("Enabled"),this.permissions=new ye(this.getResponseProperty("permissions")),this.userId=this.getResponseProperty("UserId"),this.useEvents=this.getResponseProperty("UseEvents")}}class ke extends O{constructor(e){var t,i;super(e),this.organizations=[],this.providers=[],this.providerOrganizations=[],this.id=this.getResponseProperty("Id"),this.name=this.getResponseProperty("Name"),this.email=this.getResponseProperty("Email"),this.emailVerified=this.getResponseProperty("EmailVerified"),this.masterPasswordHint=this.getResponseProperty("MasterPasswordHint"),this.premiumPersonally=this.getResponseProperty("Premium"),this.premiumFromOrganization=this.getResponseProperty("PremiumFromOrganization"),this.culture=this.getResponseProperty("Culture"),this.twoFactorEnabled=this.getResponseProperty("TwoFactorEnabled"),this.key=this.getResponseProperty("Key"),this.privateKey=this.getResponseProperty("PrivateKey"),this.securityStamp=this.getResponseProperty("SecurityStamp"),this.forcePasswordReset=null!==(t=this.getResponseProperty("ForcePasswordReset"))&&void 0!==t&&t,this.usesKeyConnector=null!==(i=this.getResponseProperty("UsesKeyConnector"))&&void 0!==i&&i;const n=this.getResponseProperty("Organizations");null!=n&&(this.organizations=n.map((e=>new be(e))));const s=this.getResponseProperty("Providers");null!=s&&(this.providers=s.map((e=>new Se(e))));const r=this.getResponseProperty("ProviderOrganizations");null!=r&&(this.providerOrganizations=r.map((e=>new we(e))))}}class Oe extends O{constructor(e){super(e);const t=this.getResponseProperty("UserProfile");null!=t&&(this.userProfile=new ke(t)),this.paymentIntentClientSecret=this.getResponseProperty("PaymentIntentClientSecret"),this.success=this.getResponseProperty("Success")}}class Pe extends O{constructor(e){super(e),this.type=this.getResponseProperty("Type"),this.product=this.getResponseProperty("Product"),this.name=this.getResponseProperty("Name"),this.isAnnual=this.getResponseProperty("IsAnnual"),this.nameLocalizationKey=this.getResponseProperty("NameLocalizationKey"),this.descriptionLocalizationKey=this.getResponseProperty("DescriptionLocalizationKey"),this.canBeUsedByBusiness=this.getResponseProperty("CanBeUsedByBusiness"),this.baseSeats=this.getResponseProperty("BaseSeats"),this.baseStorageGb=this.getResponseProperty("BaseStorageGb"),this.maxCollections=this.getResponseProperty("MaxCollections"),this.maxUsers=this.getResponseProperty("MaxUsers"),this.hasAdditionalSeatsOption=this.getResponseProperty("HasAdditionalSeatsOption"),this.maxAdditionalSeats=this.getResponseProperty("MaxAdditionalSeats"),this.hasAdditionalStorageOption=this.getResponseProperty("HasAdditionalStorageOption"),this.maxAdditionalStorage=this.getResponseProperty("MaxAdditionalStorage"),this.hasPremiumAccessOption=this.getResponseProperty("HasPremiumAccessOption"),this.trialPeriodDays=this.getResponseProperty("TrialPeriodDays"),this.hasSelfHost=this.getResponseProperty("HasSelfHost"),this.hasPolicies=this.getResponseProperty("HasPolicies"),this.hasGroups=this.getResponseProperty("HasGroups"),this.hasDirectory=this.getResponseProperty("HasDirectory"),this.hasEvents=this.getResponseProperty("HasEvents"),this.hasTotp=this.getResponseProperty("HasTotp"),this.has2fa=this.getResponseProperty("Has2fa"),this.hasApi=this.getResponseProperty("HasApi"),this.hasSso=this.getResponseProperty("HasSso"),this.hasResetPassword=this.getResponseProperty("HasResetPassword"),this.usersGetPremium=this.getResponseProperty("UsersGetPremium"),this.upgradeSortOrder=this.getResponseProperty("UpgradeSortOrder"),this.displaySortOrder=this.getResponseProperty("SortOrder"),this.legacyYear=this.getResponseProperty("LegacyYear"),this.disabled=this.getResponseProperty("Disabled"),this.stripePlanId=this.getResponseProperty("StripePlanId"),this.stripeSeatPlanId=this.getResponseProperty("StripeSeatPlanId"),this.stripeStoragePlanId=this.getResponseProperty("StripeStoragePlanId"),this.stripePremiumAccessPlanId=this.getResponseProperty("StripePremiumAccessPlanId"),this.basePrice=this.getResponseProperty("BasePrice"),this.seatPrice=this.getResponseProperty("SeatPrice"),this.additionalStoragePricePerGb=this.getResponseProperty("AdditionalStoragePricePerGb"),this.premiumAccessOptionPrice=this.getResponseProperty("PremiumAccessOptionPrice")}}class Ae extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.organizationId=this.getResponseProperty("OrganizationId"),this.type=this.getResponseProperty("Type"),this.data=this.getResponseProperty("Data"),this.enabled=this.getResponseProperty("Enabled")}}class Ce extends O{constructor(e){super(e),this.kdf=this.getResponseProperty("Kdf"),this.kdfIterations=this.getResponseProperty("KdfIterations")}}class De extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.providerId=this.getResponseProperty("ProviderId"),this.organizationId=this.getResponseProperty("OrganizationId"),this.key=this.getResponseProperty("Key"),this.settings=this.getResponseProperty("Settings"),this.creationDate=this.getResponseProperty("CreationDate"),this.revisionDate=this.getResponseProperty("RevisionDate"),this.userCount=this.getResponseProperty("UserCount"),this.seats=this.getResponseProperty("Seats"),this.plan=this.getResponseProperty("Plan")}}class xe extends De{constructor(e){super(e),this.organizationName=this.getResponseProperty("OrganizationName")}}class Te extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.name=this.getResponseProperty("Name"),this.businessName=this.getResponseProperty("BusinessName"),this.billingEmail=this.getResponseProperty("BillingEmail")}}class Ie extends he{}class Re extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.error=this.getResponseProperty("Error")}}class Ee extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.type=this.getResponseProperty("Type"),this.status=this.getResponseProperty("Status"),this.permissions=new ye(this.getResponseProperty("Permissions"))}}class Ue extends Ee{constructor(e){super(e),this.name=this.getResponseProperty("Name"),this.email=this.getResponseProperty("Email")}}class Fe extends O{constructor(e=null){super(e),null!=e&&(this.id=this.getResponseProperty("Id"),this.fileName=this.getResponseProperty("FileName"),this.size=this.getResponseProperty("Size"),this.sizeName=this.getResponseProperty("SizeName"))}}class Ne extends O{constructor(e=null){super(e),null!=e&&(this.text=this.getResponseProperty("Text"),this.hidden=this.getResponseProperty("Hidden")||!1)}}class ze extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.type=this.getResponseProperty("Type"),this.name=this.getResponseProperty("Name");const t=this.getResponseProperty("Text");null!=t&&(this.text=new Ne(t));const i=this.getResponseProperty("File");null!=i&&(this.file=new Fe(i)),this.expirationDate=this.getResponseProperty("ExpirationDate"),this.creatorIdentifier=this.getResponseProperty("CreatorIdentifier")}}class Me extends O{constructor(e){super(e),this.id=null,this.url=null,this.id=this.getResponseProperty("Id"),this.url=this.getResponseProperty("Url")}}class Le extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.accessId=this.getResponseProperty("AccessId"),this.type=this.getResponseProperty("Type"),this.name=this.getResponseProperty("Name"),this.notes=this.getResponseProperty("Notes"),this.key=this.getResponseProperty("Key"),this.maxAccessCount=this.getResponseProperty("MaxAccessCount"),this.accessCount=this.getResponseProperty("AccessCount"),this.revisionDate=this.getResponseProperty("RevisionDate"),this.expirationDate=this.getResponseProperty("ExpirationDate"),this.deletionDate=this.getResponseProperty("DeletionDate"),this.password=this.getResponseProperty("Password"),this.disable=this.getResponseProperty("Disabled")||!1,this.hideEmail=this.getResponseProperty("HideEmail")||!1;const t=this.getResponseProperty("Text");null!=t&&(this.text=new Ne(t));const i=this.getResponseProperty("File");null!=i&&(this.file=new Fe(i))}}class Be extends O{constructor(e){super(e),this.url=null,this.fileUploadType=this.getResponseProperty("FileUploadType");const t=this.getResponseProperty("SendResponse");this.sendResponse=null==t?null:new Le(t),this.url=this.getResponseProperty("Url")}}class Ke extends O{constructor(e){super(e),this.token=this.getResponseProperty("Token")}}class _e extends O{constructor(e){super(e),this.storageName=this.getResponseProperty("StorageName"),this.storageGb=this.getResponseProperty("StorageGb"),this.maxStorageGb=this.getResponseProperty("MaxStorageGb"),this.license=this.getResponseProperty("License"),this.expiration=this.getResponseProperty("Expiration"),this.usingInAppPurchase=this.getResponseProperty("UsingInAppPurchase");const t=this.getResponseProperty("Subscription"),i=this.getResponseProperty("UpcomingInvoice");this.subscription=null==t?null:new je(t),this.upcomingInvoice=null==i?null:new Ve(i)}}class je extends O{constructor(e){super(e),this.items=[],this.trialEndDate=this.getResponseProperty("TrialStartDate"),this.trialEndDate=this.getResponseProperty("TrialEndDate"),this.periodStartDate=this.getResponseProperty("PeriodStartDate"),this.periodEndDate=this.getResponseProperty("PeriodEndDate"),this.cancelledDate=this.getResponseProperty("CancelledDate"),this.cancelAtEndDate=this.getResponseProperty("CancelAtEndDate"),this.status=this.getResponseProperty("Status"),this.cancelled=this.getResponseProperty("Cancelled");const t=this.getResponseProperty("Items");null!=t&&(this.items=t.map((e=>new Ge(e))))}}class Ge extends O{constructor(e){super(e),this.name=this.getResponseProperty("Name"),this.amount=this.getResponseProperty("Amount"),this.quantity=this.getResponseProperty("Quantity"),this.interval=this.getResponseProperty("Interval"),this.sponsoredSubscriptionItem=this.getResponseProperty("SponsoredSubscriptionItem")}}class Ve extends O{constructor(e){super(e),this.date=this.getResponseProperty("Date"),this.amount=this.getResponseProperty("Amount")}}class He extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.name=this.getResponseProperty("Name"),this.revisionDate=this.getResponseProperty("RevisionDate")}}class qe extends O{constructor(e){super(e),this.folders=[],this.collections=[],this.ciphers=[],this.policies=[],this.sends=[];const t=this.getResponseProperty("Profile");null!=t&&(this.profile=new ke(t));const i=this.getResponseProperty("Folders");null!=i&&(this.folders=i.map((e=>new He(e))));const n=this.getResponseProperty("Collections");null!=n&&(this.collections=n.map((e=>new H(e))));const s=this.getResponseProperty("Ciphers");null!=s&&(this.ciphers=s.map((e=>new U(e))));const r=this.getResponseProperty("Domains");null!=r&&(this.domains=new Y(r));const o=this.getResponseProperty("Policies");null!=o&&(this.policies=o.map((e=>new Ae(e))));const a=this.getResponseProperty("Sends");null!=a&&(this.sends=a.map((e=>new Le(e))))}}class We extends O{constructor(e){super(e),this.taxId=this.getResponseProperty("TaxIdNumber"),this.taxIdType=this.getResponseProperty("TaxIdType"),this.line1=this.getResponseProperty("Line1"),this.line2=this.getResponseProperty("Line2"),this.city=this.getResponseProperty("City"),this.state=this.getResponseProperty("State"),this.postalCode=this.getResponseProperty("PostalCode"),this.country=this.getResponseProperty("Country")}}class Je extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.country=this.getResponseProperty("Country"),this.state=this.getResponseProperty("State"),this.postalCode=this.getResponseProperty("PostalCode"),this.rate=this.getResponseProperty("Rate")}}class Ye extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled"),this.key=this.getResponseProperty("Key")}}class $e extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled"),this.host=this.getResponseProperty("Host"),this.secretKey=this.getResponseProperty("SecretKey"),this.integrationKey=this.getResponseProperty("IntegrationKey")}}class Qe extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled"),this.email=this.getResponseProperty("Email")}}class Xe extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled"),this.type=this.getResponseProperty("Type")}}class Ze extends O{constructor(e){super(e),this.code=this.getResponseProperty("Code")}}class et extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled");const t=this.getResponseProperty("Keys");this.keys=null==t?null:t.map((e=>new tt(e)))}}class tt extends O{constructor(e){super(e),this.name=this.getResponseProperty("Name"),this.id=this.getResponseProperty("Id"),this.migrated=this.getResponseProperty("Migrated")}}class it extends O{constructor(e){super(e),this.attestation=this.getResponseProperty("attestation"),this.authenticatorSelection=this.getResponseProperty("authenticatorSelection"),this.challenge=f.fromUrlB64ToArray(this.getResponseProperty("challenge")),this.excludeCredentials=this.getResponseProperty("excludeCredentials").map((e=>(e.id=f.fromUrlB64ToArray(e.id).buffer,e))),this.extensions=this.getResponseProperty("extensions"),this.pubKeyCredParams=this.getResponseProperty("pubKeyCredParams"),this.rp=this.getResponseProperty("rp"),this.timeout=this.getResponseProperty("timeout");const t=this.getResponseProperty("user");t.id=f.fromUrlB64ToArray(t.id),this.user=t}}class nt extends O{constructor(e){super(e),this.enabled=this.getResponseProperty("Enabled"),this.key1=this.getResponseProperty("Key1"),this.key2=this.getResponseProperty("Key2"),this.key3=this.getResponseProperty("Key3"),this.key4=this.getResponseProperty("Key4"),this.key5=this.getResponseProperty("Key5"),this.nfc=this.getResponseProperty("Nfc")}}class st extends O{constructor(e){super(e),this.userId=this.getResponseProperty("UserId"),this.publicKey=this.getResponseProperty("PublicKey")}}var rt,ot=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class at{constructor(e,t,i,n,s,r=null){this.tokenService=e,this.platformUtilsService=t,this.environmentService=i,this.appIdService=n,this.logoutCallback=s,this.customUserAgent=r,this.isWebClient=!1,this.isDesktopClient=!1,this.device=t.getDevice(),this.deviceType=this.device.toString(),this.isWebClient=this.device===l.IEBrowser||this.device===l.ChromeBrowser||this.device===l.EdgeBrowser||this.device===l.FirefoxBrowser||this.device===l.OperaBrowser||this.device===l.SafariBrowser||this.device===l.UnknownBrowser||this.device===l.VivaldiBrowser,this.isDesktopClient=this.device===l.WindowsDesktop||this.device===l.MacOsDesktop||this.device===l.LinuxDesktop}postIdentityToken(e){return ot(this,void 0,void 0,(function*(){const t=new Headers({"Content-Type":"application/x-www-form-urlencoded; charset=utf-8",Accept:"application/json","Device-Type":this.deviceType});null!=this.customUserAgent&&t.set("User-Agent",this.customUserAgent),e.alterIdentityTokenHeaders(t);const i=e instanceof S?e.toIdentityToken():e.toIdentityToken(this.platformUtilsService.getClientType()),n=yield this.fetch(new Request(this.environmentService.getIdentityUrl()+"/connect/token",{body:this.qsStringify(i),credentials:this.getCredentials(),cache:"no-store",headers:t,method:"POST"}));let s=null;if(this.isJsonResponse(n)&&(s=yield n.json()),null!=s){if(200===n.status)return new re(s);if(400===n.status&&s.TwoFactorProviders2&&Object.keys(s.TwoFactorProviders2).length)return yield this.tokenService.clearTwoFactorToken(),new oe(s);if(400===n.status&&s.HCaptcha_SiteKey&&Object.keys(s.HCaptcha_SiteKey).length)return new se(s)}return Promise.reject(new ee(s,n.status,!0))}))}refreshIdentityToken(){return ot(this,void 0,void 0,(function*(){try{yield this.doAuthRefresh()}catch(e){return Promise.reject(null)}}))}postAuthRequest(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/auth-requests/",e,!1,!0);return new N(t)}))}getAuthResponse(e,t){return ot(this,void 0,void 0,(function*(){const i=`/auth-requests/${e}/response?code=${t}`,n=yield this.send("GET",i,null,!1,!0);return new N(n)}))}getProfile(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/accounts/profile",null,!0,!0);return new ke(e)}))}getUserSubscription(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/accounts/subscription",null,!0,!0);return new _e(e)}))}getTaxInfo(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/accounts/tax",null,!0,!0);return new We(e)}))}putProfile(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/accounts/profile",e,!0,!0);return new ke(t)}))}putTaxInfo(e){return this.send("PUT","/accounts/tax",e,!0,!1)}postPrelogin(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/accounts/prelogin",e,!1,!0,this.platformUtilsService.isDev()?this.environmentService.getIdentityUrl():this.environmentService.getApiUrl());return new Ce(t)}))}postEmailToken(e){return this.send("POST","/accounts/email-token",e,!0,!1)}postEmail(e){return this.send("POST","/accounts/email",e,!0,!1)}postPassword(e){return this.send("POST","/accounts/password",e,!0,!1)}setPassword(e){return this.send("POST","/accounts/set-password",e,!0,!1)}postSetKeyConnectorKey(e){return this.send("POST","/accounts/set-key-connector-key",e,!0,!1)}postSecurityStamp(e){return this.send("POST","/accounts/security-stamp",e,!0,!1)}getAccountRevisionDate(){return ot(this,void 0,void 0,(function*(){return yield this.send("GET","/accounts/revision-date",null,!0,!0)}))}postPasswordHint(e){return this.send("POST","/accounts/password-hint",e,!1,!1)}postRegister(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/accounts/register",e,!1,!0,this.platformUtilsService.isDev()?this.environmentService.getIdentityUrl():this.environmentService.getApiUrl());return new z(t)}))}postPremium(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/accounts/premium",e,!0,!0);return new Oe(t)}))}postIapCheck(e){return ot(this,void 0,void 0,(function*(){return this.send("POST","/accounts/iap-check",e,!0,!1)}))}postReinstatePremium(){return this.send("POST","/accounts/reinstate-premium",null,!0,!1)}postCancelPremium(){return this.send("POST","/accounts/cancel-premium",null,!0,!1)}postAccountStorage(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/accounts/storage",e,!0,!0);return new Oe(t)}))}postAccountPayment(e){return this.send("POST","/accounts/payment",e,!0,!1)}postAccountLicense(e){return this.send("POST","/accounts/license",e,!0,!1)}postAccountKeys(e){return this.send("POST","/accounts/keys",e,!0,!1)}postAccountKey(e){return this.send("POST","/accounts/key",e,!0,!1)}postAccountVerifyEmail(){return this.send("POST","/accounts/verify-email",null,!0,!1)}postAccountVerifyEmailToken(e){return this.send("POST","/accounts/verify-email-token",e,!1,!1)}postAccountVerifyPassword(e){return this.send("POST","/accounts/verify-password",e,!0,!1)}postAccountRecoverDelete(e){return this.send("POST","/accounts/delete-recover",e,!1,!1)}postAccountRecoverDeleteToken(e){return this.send("POST","/accounts/delete-recover-token",e,!1,!1)}postAccountKdf(e){return this.send("POST","/accounts/kdf",e,!0,!1)}deleteSsoUser(e){return ot(this,void 0,void 0,(function*(){return this.send("DELETE","/accounts/sso/"+e,null,!0,!1)}))}getSsoUserIdentifier(){return ot(this,void 0,void 0,(function*(){return this.send("GET","/accounts/sso/user-identifier",null,!0,!0)}))}postUserApiKey(e,t){return ot(this,void 0,void 0,(function*(){const e=yield this.send("POST","/accounts/api-key",t,!0,!0);return new P(e)}))}postUserRotateApiKey(e,t){return ot(this,void 0,void 0,(function*(){const e=yield this.send("POST","/accounts/rotate-api-key",t,!0,!0);return new P(e)}))}putUpdateTempPassword(e){return this.send("PUT","/accounts/update-temp-password",e,!0,!1)}postConvertToKeyConnector(){return this.send("POST","/accounts/convert-to-key-connector",null,!0,!1)}getUserBillingHistory(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/accounts/billing/history",null,!0,!0);return new K(e)}))}getUserBillingPayment(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/accounts/billing/payment-method",null,!0,!0);return new _(e)}))}getSend(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/sends/"+e,null,!0,!0);return new Le(t)}))}postSendAccess(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("POST","/sends/access/"+e,t,!1,!0,i,(t=>{t.set("Send-Id",e)}));return new ze(n)}))}getSendFileDownloadData(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("POST","/sends/"+e.id+"/access/file/"+e.file.id,t,!1,!0,i,(t=>{t.set("Send-Id",e.id)}));return new Me(n)}))}getSends(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/sends",null,!0,!0);return new le(e,Le)}))}postSend(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/sends",e,!0,!0);return new Le(t)}))}postFileTypeSend(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/sends/file/v2",e,!0,!0);return new Be(t)}))}renewSendFileUploadUrl(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/sends/"+e+"/file/"+t,null,!0,!0);return new Be(i)}))}postSendFile(e,t,i){return this.send("POST","/sends/"+e+"/file/"+t,i,!0,!1)}postSendFileLegacy(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/sends/file",e,!0,!0);return new Le(t)}))}putSend(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/sends/"+e,t,!0,!0);return new Le(i)}))}putSendRemovePassword(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/sends/"+e+"/remove-password",null,!0,!0);return new Le(t)}))}deleteSend(e){return this.send("DELETE","/sends/"+e,null,!0,!1)}getCipher(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/ciphers/"+e,null,!0,!0);return new U(t)}))}getFullCipherDetails(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/ciphers/"+e+"/details",null,!0,!0);return new U(t)}))}getCipherAdmin(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/ciphers/"+e+"/admin",null,!0,!0);return new U(t)}))}getCiphersOrganization(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/ciphers/organization-details?organizationId="+e,null,!0,!0);return new le(t,U)}))}postCipher(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/ciphers",e,!0,!0);return new U(t)}))}postCipherCreate(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/ciphers/create",e,!0,!0);return new U(t)}))}postCipherAdmin(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/ciphers/admin",e,!0,!0);return new U(t)}))}putCipher(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/ciphers/"+e,t,!0,!0);return new U(i)}))}putCipherAdmin(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/ciphers/"+e+"/admin",t,!0,!0);return new U(i)}))}deleteCipher(e){return this.send("DELETE","/ciphers/"+e,null,!0,!1)}deleteCipherAdmin(e){return this.send("DELETE","/ciphers/"+e+"/admin",null,!0,!1)}deleteManyCiphers(e){return this.send("DELETE","/ciphers",e,!0,!1)}deleteManyCiphersAdmin(e){return this.send("DELETE","/ciphers/admin",e,!0,!1)}putMoveCiphers(e){return this.send("PUT","/ciphers/move",e,!0,!1)}putShareCipher(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/ciphers/"+e+"/share",t,!0,!0);return new U(i)}))}putShareCiphers(e){return this.send("PUT","/ciphers/share",e,!0,!1)}putCipherCollections(e,t){return this.send("PUT","/ciphers/"+e+"/collections",t,!0,!1)}putCipherCollectionsAdmin(e,t){return this.send("PUT","/ciphers/"+e+"/collections-admin",t,!0,!1)}postPurgeCiphers(e,t=null){let i="/ciphers/purge";return null!=t&&(i+="?organizationId="+t),this.send("POST",i,e,!0,!1)}postImportCiphers(e){return this.send("POST","/ciphers/import",e,!0,!1)}postImportOrganizationCiphers(e,t){return this.send("POST","/ciphers/import-organization?organizationId="+e,t,!0,!1)}putDeleteCipher(e){return this.send("PUT","/ciphers/"+e+"/delete",null,!0,!1)}putDeleteCipherAdmin(e){return this.send("PUT","/ciphers/"+e+"/delete-admin",null,!0,!1)}putDeleteManyCiphers(e){return this.send("PUT","/ciphers/delete",e,!0,!1)}putDeleteManyCiphersAdmin(e){return this.send("PUT","/ciphers/delete-admin",e,!0,!1)}putRestoreCipher(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/ciphers/"+e+"/restore",null,!0,!0);return new U(t)}))}putRestoreCipherAdmin(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/ciphers/"+e+"/restore-admin",null,!0,!0);return new U(t)}))}putRestoreManyCiphers(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/ciphers/restore",e,!0,!0);return new le(t,U)}))}getAttachmentData(e,t,i){return ot(this,void 0,void 0,(function*(){const n=(null!=i?"/emergency-access/"+i+"/":"/ciphers/")+e+"/attachment/"+t,s=yield this.send("GET",n,null,!0,!0);return new A(s)}))}postCipherAttachment(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/ciphers/"+e+"/attachment/v2",t,!0,!0);return new F(i)}))}postCipherAttachmentLegacy(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/ciphers/"+e+"/attachment",t,!0,!0);return new U(i)}))}postCipherAttachmentAdminLegacy(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/ciphers/"+e+"/attachment-admin",t,!0,!0);return new U(i)}))}deleteCipherAttachment(e,t){return this.send("DELETE","/ciphers/"+e+"/attachment/"+t,null,!0,!1)}deleteCipherAttachmentAdmin(e,t){return this.send("DELETE","/ciphers/"+e+"/attachment/"+t+"/admin",null,!0,!1)}postShareCipherAttachment(e,t,i,n){return this.send("POST","/ciphers/"+e+"/attachment/"+t+"/share?organizationId="+n,i,!0,!1)}renewAttachmentUploadUrl(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/ciphers/"+e+"/attachment/"+t+"/renew",null,!0,!0);return new F(i)}))}postAttachmentFile(e,t,i){return this.send("POST","/ciphers/"+e+"/attachment/"+t,i,!0,!1)}getCollectionDetails(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/organizations/"+e+"/collections/"+t+"/details",null,!0,!0);return new q(i)}))}getUserCollections(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/collections",null,!0,!0);return new le(e,V)}))}getCollections(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organizations/"+e+"/collections",null,!0,!0);return new le(t,V)}))}getCollectionUsers(e,t){return ot(this,void 0,void 0,(function*(){return(yield this.send("GET","/organizations/"+e+"/collections/"+t+"/users",null,!0,!0)).map((e=>new G(e)))}))}postCollection(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/collections",t,!0,!0);return new V(i)}))}putCollection(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("PUT","/organizations/"+e+"/collections/"+t,i,!0,!0);return new V(n)}))}putCollectionUsers(e,t,i){return ot(this,void 0,void 0,(function*(){yield this.send("PUT","/organizations/"+e+"/collections/"+t+"/users",i,!0,!1)}))}deleteCollection(e,t){return this.send("DELETE","/organizations/"+e+"/collections/"+t,null,!0,!1)}deleteCollectionUser(e,t,i){return this.send("DELETE","/organizations/"+e+"/collections/"+t+"/user/"+i,null,!0,!1)}getGroupDetails(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/organizations/"+e+"/groups/"+t+"/details",null,!0,!0);return new ne(i)}))}getGroups(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organizations/"+e+"/groups",null,!0,!0);return new le(t,ie)}))}getGroupUsers(e,t){return ot(this,void 0,void 0,(function*(){return yield this.send("GET","/organizations/"+e+"/groups/"+t+"/users",null,!0,!0)}))}postGroup(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/groups",t,!0,!0);return new ie(i)}))}putGroup(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("PUT","/organizations/"+e+"/groups/"+t,i,!0,!0);return new ie(n)}))}putGroupUsers(e,t,i){return ot(this,void 0,void 0,(function*(){yield this.send("PUT","/organizations/"+e+"/groups/"+t+"/users",i,!0,!1)}))}deleteGroup(e,t){return this.send("DELETE","/organizations/"+e+"/groups/"+t,null,!0,!1)}deleteGroupUser(e,t,i){return this.send("DELETE","/organizations/"+e+"/groups/"+t+"/user/"+i,null,!0,!1)}getOrganizationUser(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/organizations/"+e+"/users/"+t,null,!0,!0);return new me(i)}))}getOrganizationUserGroups(e,t){return ot(this,void 0,void 0,(function*(){return yield this.send("GET","/organizations/"+e+"/users/"+t+"/groups",null,!0,!0)}))}getOrganizationUsers(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organizations/"+e+"/users",null,!0,!0);return new le(t,ge)}))}getOrganizationUserResetPasswordDetails(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/organizations/"+e+"/users/"+t+"/reset-password-details",null,!0,!0);return new fe(i)}))}postOrganizationUserInvite(e,t){return this.send("POST","/organizations/"+e+"/users/invite",t,!0,!1)}postOrganizationUserReinvite(e,t){return this.send("POST","/organizations/"+e+"/users/"+t+"/reinvite",null,!0,!1)}postManyOrganizationUserReinvite(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/users/reinvite",t,!0,!0);return new le(i,pe)}))}postOrganizationUserAccept(e,t,i){return this.send("POST","/organizations/"+e+"/users/"+t+"/accept",i,!0,!1)}postOrganizationUserConfirm(e,t,i){return this.send("POST","/organizations/"+e+"/users/"+t+"/confirm",i,!0,!1)}postOrganizationUsersPublicKey(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/users/public-keys",t,!0,!0);return new le(i,he)}))}postOrganizationUserBulkConfirm(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/users/confirm",t,!0,!0);return new le(i,pe)}))}putOrganizationUser(e,t,i){return this.send("PUT","/organizations/"+e+"/users/"+t,i,!0,!1)}putOrganizationUserGroups(e,t,i){return this.send("PUT","/organizations/"+e+"/users/"+t+"/groups",i,!0,!1)}putOrganizationUserResetPasswordEnrollment(e,t,i){return this.send("PUT","/organizations/"+e+"/users/"+t+"/reset-password-enrollment",i,!0,!1)}putOrganizationUserResetPassword(e,t,i){return this.send("PUT","/organizations/"+e+"/users/"+t+"/reset-password",i,!0,!1)}deleteOrganizationUser(e,t){return this.send("DELETE","/organizations/"+e+"/users/"+t,null,!0,!1)}deleteManyOrganizationUsers(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("DELETE","/organizations/"+e+"/users",t,!0,!0);return new le(i,pe)}))}revokeOrganizationUser(e,t){return this.send("PUT","/organizations/"+e+"/users/"+t+"/revoke",null,!0,!1)}revokeManyOrganizationUsers(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/organizations/"+e+"/users/revoke",t,!0,!0);return new le(i,pe)}))}restoreOrganizationUser(e,t){return this.send("PUT","/organizations/"+e+"/users/"+t+"/restore",null,!0,!1)}restoreManyOrganizationUsers(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/organizations/"+e+"/users/restore",t,!0,!0);return new le(i,pe)}))}getPlans(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/plans/",null,!1,!0);return new le(e,Pe)}))}postPublicImportDirectory(e){return ot(this,void 0,void 0,(function*(){return this.send("POST","/public/organization/import",e,!0,!1)}))}getTaxRates(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/plans/sales-tax-rates/",null,!0,!0);return new le(e,Je)}))}getSettingsDomains(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/settings/domains",null,!0,!0);return new Y(e)}))}putSettingsDomains(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/settings/domains",e,!0,!0);return new Y(t)}))}getSync(){return ot(this,void 0,void 0,(function*(){const e=this.isDesktopClient||this.isWebClient?"/sync?excludeDomains=true":"/sync",t=yield this.send("GET",e,null,!0,!0);return new qe(t)}))}getTwoFactorProviders(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/two-factor",null,!0,!0);return new le(e,Xe)}))}getTwoFactorOrganizationProviders(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organizations/"+e+"/two-factor",null,!0,!0);return new le(t,Xe)}))}getTwoFactorAuthenticator(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-authenticator",e,!0,!0);return new Ye(t)}))}getTwoFactorEmail(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-email",e,!0,!0);return new Qe(t)}))}getTwoFactorDuo(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-duo",e,!0,!0);return new $e(t)}))}getTwoFactorOrganizationDuo(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/"+e+"/two-factor/get-duo",t,!0,!0);return new $e(i)}))}getTwoFactorYubiKey(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-yubikey",e,!0,!0);return new nt(t)}))}getTwoFactorWebAuthn(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-webauthn",e,!0,!0);return new et(t)}))}getTwoFactorWebAuthnChallenge(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-webauthn-challenge",e,!0,!0);return new it(t)}))}getTwoFactorRecover(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/two-factor/get-recover",e,!0,!0);return new Ze(t)}))}putTwoFactorAuthenticator(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/authenticator",e,!0,!0);return new Ye(t)}))}putTwoFactorEmail(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/email",e,!0,!0);return new Qe(t)}))}putTwoFactorDuo(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/duo",e,!0,!0);return new $e(t)}))}putTwoFactorOrganizationDuo(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/organizations/"+e+"/two-factor/duo",t,!0,!0);return new $e(i)}))}putTwoFactorYubiKey(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/yubikey",e,!0,!0);return new nt(t)}))}putTwoFactorWebAuthn(e){return ot(this,void 0,void 0,(function*(){const t=e.deviceResponse.response,i=Object.assign({},e);i.deviceResponse={id:e.deviceResponse.id,rawId:btoa(e.deviceResponse.id),type:e.deviceResponse.type,extensions:e.deviceResponse.getClientExtensionResults(),response:{AttestationObject:f.fromBufferToB64(t.attestationObject),clientDataJson:f.fromBufferToB64(t.clientDataJSON)}};const n=yield this.send("PUT","/two-factor/webauthn",i,!0,!0);return new et(n)}))}deleteTwoFactorWebAuthn(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("DELETE","/two-factor/webauthn",e,!0,!0);return new et(t)}))}putTwoFactorDisable(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/disable",e,!0,!0);return new Xe(t)}))}putTwoFactorOrganizationDisable(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/organizations/"+e+"/two-factor/disable",t,!0,!0);return new Xe(i)}))}postTwoFactorRecover(e){return this.send("POST","/two-factor/recover",e,!1,!1)}postTwoFactorEmailSetup(e){return this.send("POST","/two-factor/send-email",e,!0,!1)}postTwoFactorEmail(e){return this.send("POST","/two-factor/send-email-login",e,!1,!1)}getDeviceVerificationSettings(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/two-factor/get-device-verification-settings",null,!0,!0);return new W(e)}))}putDeviceVerificationSettings(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("PUT","/two-factor/device-verification-settings",e,!0,!0);return new W(t)}))}getEmergencyAccessTrusted(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/emergency-access/trusted",null,!0,!0);return new le(e,$)}))}getEmergencyAccessGranted(){return ot(this,void 0,void 0,(function*(){const e=yield this.send("GET","/emergency-access/granted",null,!0,!0);return new le(e,Q)}))}getEmergencyAccess(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/emergency-access/"+e,null,!0,!0);return new $(t)}))}getEmergencyGrantorPolicies(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/emergency-access/"+e+"/policies",null,!0,!0);return new le(t,Ae)}))}putEmergencyAccess(e,t){return this.send("PUT","/emergency-access/"+e,t,!0,!1)}deleteEmergencyAccess(e){return this.send("DELETE","/emergency-access/"+e,null,!0,!1)}postEmergencyAccessInvite(e){return this.send("POST","/emergency-access/invite",e,!0,!1)}postEmergencyAccessReinvite(e){return this.send("POST","/emergency-access/"+e+"/reinvite",null,!0,!1)}postEmergencyAccessAccept(e,t){return this.send("POST","/emergency-access/"+e+"/accept",t,!0,!1)}postEmergencyAccessConfirm(e,t){return this.send("POST","/emergency-access/"+e+"/confirm",t,!0,!1)}postEmergencyAccessInitiate(e){return this.send("POST","/emergency-access/"+e+"/initiate",null,!0,!1)}postEmergencyAccessApprove(e){return this.send("POST","/emergency-access/"+e+"/approve",null,!0,!1)}postEmergencyAccessReject(e){return this.send("POST","/emergency-access/"+e+"/reject",null,!0,!1)}postEmergencyAccessTakeover(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/emergency-access/"+e+"/takeover",null,!0,!0);return new X(t)}))}postEmergencyAccessPassword(e,t){return ot(this,void 0,void 0,(function*(){yield this.send("POST","/emergency-access/"+e+"/password",t,!0,!0)}))}postEmergencyAccessView(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("POST","/emergency-access/"+e+"/view",null,!0,!0);return new Z(t)}))}getCloudCommunicationsEnabled(){return ot(this,void 0,void 0,(function*(){return yield this.send("GET","/organizations/connections/enabled",null,!0,!0)}))}getOrganizationConnection(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("GET",`/organizations/connections/${e}/${t}`,null,!0,!0);return new ce(n,i)}))}createOrganizationConnection(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/organizations/connections/",e,!0,!0);return new ce(i,t)}))}updateOrganizationConnection(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("PUT","/organizations/connections/"+i,e,!0,!0);return new ce(n,t)}))}deleteOrganizationConnection(e){return ot(this,void 0,void 0,(function*(){return this.send("DELETE","/organizations/connections/"+e,null,!0,!1)}))}postProviderSetup(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/providers/"+e+"/setup",t,!0,!0);return new Te(i)}))}getProvider(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/providers/"+e,null,!0,!0);return new Te(t)}))}putProvider(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("PUT","/providers/"+e,t,!0,!0);return new Te(i)}))}getProviderUsers(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/providers/"+e+"/users",null,!0,!0);return new le(t,Ue)}))}getProviderUser(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("GET","/providers/"+e+"/users/"+t,null,!0,!0);return new Ee(i)}))}postProviderUserInvite(e,t){return this.send("POST","/providers/"+e+"/users/invite",t,!0,!1)}postProviderUserReinvite(e,t){return this.send("POST","/providers/"+e+"/users/"+t+"/reinvite",null,!0,!1)}postManyProviderUserReinvite(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/providers/"+e+"/users/reinvite",t,!0,!0);return new le(i,Re)}))}postProviderUserBulkConfirm(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/providers/"+e+"/users/confirm",t,!0,!0);return new le(i,Re)}))}deleteManyProviderUsers(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("DELETE","/providers/"+e+"/users",t,!0,!0);return new le(i,Re)}))}postProviderUserAccept(e,t,i){return this.send("POST","/providers/"+e+"/users/"+t+"/accept",i,!0,!1)}postProviderUserConfirm(e,t,i){return this.send("POST","/providers/"+e+"/users/"+t+"/confirm",i,!0,!1)}postProviderUsersPublicKey(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/providers/"+e+"/users/public-keys",t,!0,!0);return new le(i,Ie)}))}putProviderUser(e,t,i){return this.send("PUT","/providers/"+e+"/users/"+t,i,!0,!1)}deleteProviderUser(e,t){return this.send("DELETE","/providers/"+e+"/users/"+t,null,!0,!1)}getProviderClients(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/providers/"+e+"/organizations",null,!0,!0);return new le(t,xe)}))}postProviderAddOrganization(e,t){return this.send("POST","/providers/"+e+"/organizations/add",t,!0,!1)}postProviderCreateOrganization(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.send("POST","/providers/"+e+"/organizations",t,!0,!0);return new De(i)}))}deleteProviderOrganization(e,t){return this.send("DELETE","/providers/"+e+"/organizations/"+t,null,!0,!1)}getEvents(e,t,i){return ot(this,void 0,void 0,(function*(){const n=yield this.send("GET",this.addEventParameters("/events",e,t,i),null,!0,!0);return new le(n,te)}))}getEventsCipher(e,t,i,n){return ot(this,void 0,void 0,(function*(){const s=yield this.send("GET",this.addEventParameters("/ciphers/"+e+"/events",t,i,n),null,!0,!0);return new le(s,te)}))}getEventsOrganization(e,t,i,n){return ot(this,void 0,void 0,(function*(){const s=yield this.send("GET",this.addEventParameters("/organizations/"+e+"/events",t,i,n),null,!0,!0);return new le(s,te)}))}getEventsOrganizationUser(e,t,i,n,s){return ot(this,void 0,void 0,(function*(){const r=yield this.send("GET",this.addEventParameters("/organizations/"+e+"/users/"+t+"/events",i,n,s),null,!0,!0);return new le(r,te)}))}getEventsProvider(e,t,i,n){return ot(this,void 0,void 0,(function*(){const s=yield this.send("GET",this.addEventParameters("/providers/"+e+"/events",t,i,n),null,!0,!0);return new le(s,te)}))}getEventsProviderUser(e,t,i,n,s){return ot(this,void 0,void 0,(function*(){const r=yield this.send("GET",this.addEventParameters("/providers/"+e+"/users/"+t+"/events",i,n,s),null,!0,!0);return new le(r,te)}))}postEventsCollect(e){return ot(this,void 0,void 0,(function*(){const t=yield this.getActiveBearerToken(),i=new Headers({"Device-Type":this.deviceType,Authorization:"Bearer "+t,"Content-Type":"application/json; charset=utf-8"});null!=this.customUserAgent&&i.set("User-Agent",this.customUserAgent);if(200!==(yield this.fetch(new Request(this.environmentService.getEventsUrl()+"/collect",{cache:"no-store",credentials:this.getCredentials(),method:"POST",body:JSON.stringify(e),headers:i}))).status)return Promise.reject("Event post failed.")}))}getUserPublicKey(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/users/"+e+"/public-key",null,!0,!0);return new st(t)}))}getHibpBreach(e){return ot(this,void 0,void 0,(function*(){return(yield this.send("GET","/hibp/breach?username="+e,null,!0,!0)).map((e=>new j(e)))}))}postBitPayInvoice(e){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/bitpay-invoice",e,!0,!0)}))}postSetupPayment(){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/setup-payment",null,!0,!0)}))}getUserKeyFromKeyConnector(e){return ot(this,void 0,void 0,(function*(){const t=yield this.getActiveBearerToken(),i=yield this.fetch(new Request(e+"/user-keys",{cache:"no-store",method:"GET",headers:new Headers({Accept:"application/json",Authorization:"Bearer "+t})}));if(200!==i.status){const e=yield this.handleError(i,!1,!0);return Promise.reject(e)}return new ae(yield i.json())}))}postUserKeyToKeyConnector(e,t){return ot(this,void 0,void 0,(function*(){const i=yield this.getActiveBearerToken(),n=yield this.fetch(new Request(e+"/user-keys",{cache:"no-store",method:"POST",headers:new Headers({Accept:"application/json",Authorization:"Bearer "+i,"Content-Type":"application/json; charset=utf-8"}),body:JSON.stringify(t)}));if(200!==n.status){const e=yield this.handleError(n,!1,!0);return Promise.reject(e)}}))}getKeyConnectorAlive(e){return ot(this,void 0,void 0,(function*(){const t=yield this.fetch(new Request(e+"/alive",{cache:"no-store",method:"GET",headers:new Headers({Accept:"application/json","Content-Type":"application/json; charset=utf-8"})}));if(200!==t.status){const e=yield this.handleError(t,!1,!0);return Promise.reject(e)}}))}getOrganizationExport(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organizations/"+e+"/export",null,!0,!0);return new de(t)}))}getActiveBearerToken(){return ot(this,void 0,void 0,(function*(){let e=yield this.tokenService.getToken();return(yield this.tokenService.tokenNeedsRefresh())&&(yield this.doAuthRefresh(),e=yield this.tokenService.getToken()),e}))}fetch(e){return ot(this,void 0,void 0,(function*(){return"GET"===e.method&&(e.headers.set("Cache-Control","no-store"),e.headers.set("Pragma","no-cache")),e.headers.set("Bitwarden-Client-Name",this.platformUtilsService.getClientType()),e.headers.set("Bitwarden-Client-Version",yield this.platformUtilsService.getApplicationVersion()),this.nativeFetch(e)}))}nativeFetch(e){return fetch(e)}preValidateSso(e){return ot(this,void 0,void 0,(function*(){if(null==e||""===e)throw new Error("Organization Identifier was not provided.");const t=new Headers({Accept:"application/json","Device-Type":this.deviceType});null!=this.customUserAgent&&t.set("User-Agent",this.customUserAgent);const i=`/account/prevalidate?domainHint=${encodeURIComponent(e)}`,n=yield this.fetch(new Request(this.environmentService.getIdentityUrl()+i,{cache:"no-store",credentials:this.getCredentials(),headers:t,method:"GET"}));if(200===n.status){const e=yield n.json();return new Ke(e)}{const e=yield this.handleError(n,!1,!0);return Promise.reject(e)}}))}postCreateSponsorship(e,t){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/organization/sponsorship/"+(this.platformUtilsService.isSelfHost()?"self-hosted/":"")+e+"/families-for-enterprise",t,!0,!1)}))}getSponsorshipSyncStatus(e){return ot(this,void 0,void 0,(function*(){const t=yield this.send("GET","/organization/sponsorship/"+e+"/sync-status",null,!0,!0);return new ue(t)}))}deleteRevokeSponsorship(e){return ot(this,void 0,void 0,(function*(){return yield this.send("DELETE","/organization/sponsorship/"+(this.platformUtilsService.isSelfHost()?"self-hosted/":"")+e,null,!0,!1)}))}deleteRemoveSponsorship(e){return ot(this,void 0,void 0,(function*(){return yield this.send("DELETE","/organization/sponsorship/sponsored/"+e,null,!0,!1)}))}postPreValidateSponsorshipToken(e){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/organization/sponsorship/validate-token?sponsorshipToken="+encodeURIComponent(e),null,!0,!0)}))}postRedeemSponsorship(e,t){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/organization/sponsorship/redeem?sponsorshipToken="+encodeURIComponent(e),t,!0,!1)}))}postResendSponsorshipOffer(e){return ot(this,void 0,void 0,(function*(){return yield this.send("POST","/organization/sponsorship/"+e+"/families-for-enterprise/resend",null,!0,!1)}))}doAuthRefresh(){return ot(this,void 0,void 0,(function*(){const e=yield this.tokenService.getRefreshToken();if(null!=e&&""!==e)return this.doRefreshToken();const t=yield this.tokenService.getClientId(),i=yield this.tokenService.getClientSecret();if(!f.isNullOrWhitespace(t)&&!f.isNullOrWhitespace(i))return this.doApiTokenRefresh();throw new Error("Cannot refresh token, no refresh token or api keys are stored")}))}doRefreshToken(){return ot(this,void 0,void 0,(function*(){const e=yield this.tokenService.getRefreshToken();if(null==e||""===e)throw new Error;const t=new Headers({"Content-Type":"application/x-www-form-urlencoded; charset=utf-8",Accept:"application/json","Device-Type":this.deviceType});null!=this.customUserAgent&&t.set("User-Agent",this.customUserAgent);const i=yield this.tokenService.decodeToken(),n=yield this.fetch(new Request(this.environmentService.getIdentityUrl()+"/connect/token",{body:this.qsStringify({grant_type:"refresh_token",client_id:i.client_id,refresh_token:e}),cache:"no-store",credentials:this.getCredentials(),headers:t,method:"POST"}));if(200!==n.status){const e=yield this.handleError(n,!0,!0);return Promise.reject(e)}{const e=yield n.json(),t=new re(e);yield this.tokenService.setTokens(t.accessToken,t.refreshToken,null)}}))}doApiTokenRefresh(){return ot(this,void 0,void 0,(function*(){const e=yield this.tokenService.getClientId(),t=yield this.tokenService.getClientSecret(),i=yield this.appIdService.getAppId(),n=new b(i,this.platformUtilsService),s=new S(e,t,new k,n),r=yield this.postIdentityToken(s);if(!(r instanceof re))throw new Error("Invalid response received when refreshing api token");yield this.tokenService.setToken(r.accessToken)}))}send(e,t,i,n,s,r,o){return ot(this,void 0,void 0,(function*(){const a=(r=f.isNullOrWhitespace(r)?this.environmentService.getApiUrl():r)+t;if(new URL(a).href!==a)return Promise.reject("Invalid request url path.");const l=new Headers({"Device-Type":this.deviceType});null!=this.customUserAgent&&l.set("User-Agent",this.customUserAgent);const c={cache:"no-store",credentials:this.getCredentials(),method:e};if(n){const e=yield this.getActiveBearerToken();l.set("Authorization","Bearer "+e)}null!=i&&("string"==typeof i?(c.body=i,l.set("Content-Type","application/x-www-form-urlencoded; charset=utf-8")):"object"==typeof i&&(i instanceof FormData?c.body=i:(l.set("Content-Type","application/json; charset=utf-8"),c.body=JSON.stringify(i)))),s&&l.set("Accept","application/json"),null!=o&&o(l),c.headers=l;const d=yield this.fetch(new Request(a,c)),u=d.headers.get("content-type"),h=null!=u&&-1!==u.indexOf("application/json");if(s&&200===d.status&&h){return yield d.json()}if(200!==d.status){const e=yield this.handleError(d,!1,n);return Promise.reject(e)}}))}handleError(e,t,i){return ot(this,void 0,void 0,(function*(){if(i&&(t&&400===e.status||401===e.status||403===e.status))return yield this.logoutCallback(!0),null;let n=null;return this.isJsonResponse(e)?n=yield e.json():this.isTextResponse(e)&&(n={Message:yield e.text()}),new ee(n,e.status,t)}))}qsStringify(e){return Object.keys(e).map((t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&")}getCredentials(){if(!this.isWebClient||this.environmentService.hasBaseUrl())return"include"}addEventParameters(e,t,i,n){return null!=t&&(e+="?start="+t),null!=i&&(e+=e.indexOf("?")>-1?"&":"?",e+="end="+i),null!=n&&(e+=e.indexOf("?")>-1?"&":"?",e+="continuationToken="+n),e}isJsonResponse(e){const t=e.headers.get("content-type");return null!=t&&t.indexOf("application/json")>-1}isTextResponse(e){const t=e.headers.get("content-type");return null!=t&&t.indexOf("text")>-1}}!function(e){e.Local="local",e.Memory="memory",e.Session="session"}(rt||(rt={}));var lt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ct{constructor(e){this.storageService=e}getAppId(){return this.makeAndGetAppId("appId")}getAnonymousAppId(){return this.makeAndGetAppId("anonymousAppId")}makeAndGetAppId(e){return lt(this,void 0,void 0,(function*(){const t=yield this.storageService.get(e,{htmlStorageLocation:rt.Local});if(null!=t)return t;const i=f.newGuid();return yield this.storageService.save(e,i,{htmlStorageLocation:rt.Local}),i}))}}var dt=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},ut=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ht=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class pt{constructor(e,t){this.cryptoFunctionService=e,this.apiService=t}passwordLeaked(e){return ht(this,void 0,void 0,(function*(){const t=yield this.cryptoFunctionService.hash(e,"sha1"),i=f.fromBufferToHex(t).toUpperCase(),n=i.substr(0,5),s=i.substr(5),r=yield this.apiService.nativeFetch(new Request("https://api.pwnedpasswords.com/range/"+n)),o=(yield r.text()).split(/\r?\n/).find((e=>e.split(":")[0]===s));return null!=o?parseInt(o.split(":")[1],10):0}))}breachedAccounts(e){return ht(this,void 0,void 0,(function*(){try{return yield this.apiService.getHibpBreach(e)}catch(e){if(404===e.statusCode)return[];throw new Error}}))}}var yt,vt;dt([(yt=100,vt=()=>"passwordLeaked",(e,t,i)=>{const n=i.value,s=new Map;return{value:function(...e){const t=(e=>{let t=s.get(e);return null!=t||(t=new Map,s.set(e,t)),t})(this),i=vt(e);let r=t.get(i);return null==r&&(r=[],t.set(i,r)),new Promise(((o,a)=>{const l=()=>{const c=()=>{r.splice(r.indexOf(l),1),r.length>=yt?r[yt-1]():0===r.length&&(t.delete(i),0===t.size&&s.delete(this))};n.apply(this,e).then((e=>(c(),e))).catch((e=>{throw c(),e})).then(o,a)};r.push(l),r.length<=yt&&l()}))}}}),ut("design:type",Function),ut("design:paramtypes",[String]),ut("design:returntype",Promise)],pt.prototype,"passwordLeaked",null);var gt,mt,ft,bt,wt=i(99918);!function(e){e[e.Password=0]="Password",e[e.Sso=1]="Sso",e[e.Api=2]="Api",e[e.Passwordless=3]="Passwordless"}(gt||(gt={})),function(e){e.Auto="auto",e.Biometric="biometric"}(mt||(mt={})),function(e){e[e.Authenticator=0]="Authenticator",e[e.Email=1]="Email",e[e.Duo=2]="Duo",e[e.Yubikey=3]="Yubikey",e[e.U2f=4]="U2f",e[e.Remember=5]="Remember",e[e.OrganizationDuo=6]="OrganizationDuo",e[e.WebAuthn=7]="WebAuthn"}(ft||(ft={}));class St{constructor(e){this.version=null==e?void 0:e.version,this.gitHash=null==e?void 0:e.gitHash,this.server=(null==e?void 0:e.server)?new kt(e.server):null,this.utcDate=(new Date).toISOString(),this.environment=(null==e?void 0:e.environment)?new Ot(e.environment):null}static fromJSON(e){return Object.assign(new St({}),e,{server:(null==e?void 0:e.server)?kt.fromJSON(e.server):null,environment:(null==e?void 0:e.environment)?Ot.fromJSON(e.environment):null})}}class kt{constructor(e){this.name=e.name,this.url=e.url}static fromJSON(e){return Object.assign(new kt({}),e)}}class Ot{constructor(e){this.vault=e.vault,this.api=e.api,this.identity=e.identity,this.notifications=e.notifications,this.sso=e.sso}static fromJSON(e){return Object.assign(new Ot({}),e)}}!function(e){e[e.AesCbc256_B64=0]="AesCbc256_B64",e[e.AesCbc128_HmacSha256_B64=1]="AesCbc128_HmacSha256_B64",e[e.AesCbc256_HmacSha256_B64=2]="AesCbc256_HmacSha256_B64",e[e.Rsa2048_OaepSha256_B64=3]="Rsa2048_OaepSha256_B64",e[e.Rsa2048_OaepSha1_B64=4]="Rsa2048_OaepSha1_B64",e[e.Rsa2048_OaepSha256_HmacSha256_B64=5]="Rsa2048_OaepSha256_HmacSha256_B64",e[e.Rsa2048_OaepSha1_HmacSha256_B64=6]="Rsa2048_OaepSha1_HmacSha256_B64"}(bt||(bt={}));var Pt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class At{constructor(e,t,i,n){null!=t?this.initFromData(e,t,i,n):this.initFromEncryptedString(e)}get ivBytes(){return null==this.iv?null:f.fromB64ToArray(this.iv).buffer}get macBytes(){return null==this.mac?null:f.fromB64ToArray(this.mac).buffer}get dataBytes(){return null==this.data?null:f.fromB64ToArray(this.data).buffer}toJSON(){return this.encryptedString}static fromJSON(e){return new At(e)}initFromData(e,t,i,n){this.encryptedString=null!=i?e+"."+i+"|"+t:e+"."+t,null!=n&&(this.encryptedString+="|"+n),this.encryptionType=e,this.data=t,this.iv=i,this.mac=n}initFromEncryptedString(e){if(this.encryptedString=e,!this.encryptedString)return;const{encType:t,encPieces:i}=this.parseEncryptedString(this.encryptedString);switch(this.encryptionType=t,t){case bt.AesCbc128_HmacSha256_B64:case bt.AesCbc256_HmacSha256_B64:if(3!==i.length)return;this.iv=i[0],this.data=i[1],this.mac=i[2];break;case bt.AesCbc256_B64:if(2!==i.length)return;this.iv=i[0],this.data=i[1];break;case bt.Rsa2048_OaepSha256_B64:case bt.Rsa2048_OaepSha1_B64:if(1!==i.length)return;this.data=i[0];break;default:return}}parseEncryptedString(e){const t=e.split(".");let i,n=null;if(2===t.length)try{i=parseInt(t[0],null),n=t[1].split("|")}catch(e){return}else n=e.split("|"),i=3===n.length?bt.AesCbc128_HmacSha256_B64:bt.AesCbc256_B64;return{encType:i,encPieces:n}}decrypt(e,t=null){return Pt(this,void 0,void 0,(function*(){if(null!=this.decryptedValue)return this.decryptedValue;try{if(null==t&&(t=yield this.getKeyForDecryption(e)),null==t)throw new Error("No key to decrypt EncString with orgId "+e);const i=f.getContainerService().getEncryptService();this.decryptedValue=yield i.decryptToUtf8(this,t)}catch(e){this.decryptedValue="[error: cannot decrypt]"}return this.decryptedValue}))}getKeyForDecryption(e){return Pt(this,void 0,void 0,(function*(){const t=f.getContainerService().getCryptoService();return null!=e?yield t.getOrgKey(e):yield t.getKeyForUserEncryption()}))}}class Ct{constructor(e,t){if(null==e)throw new Error("Must provide key");if(null==t)if(32===e.byteLength)t=bt.AesCbc256_B64;else{if(64!==e.byteLength)throw new Error("Unable to determine encType.");t=bt.AesCbc256_HmacSha256_B64}if(this.key=e,this.encType=t,t===bt.AesCbc256_B64&&32===e.byteLength)this.encKey=e,this.macKey=null;else if(t===bt.AesCbc128_HmacSha256_B64&&32===e.byteLength)this.encKey=e.slice(0,16),this.macKey=e.slice(16,32);else{if(t!==bt.AesCbc256_HmacSha256_B64||64!==e.byteLength)throw new Error("Unsupported encType/key length.");this.encKey=e.slice(0,32),this.macKey=e.slice(32,64)}null!=this.key&&(this.keyB64=f.fromBufferToB64(this.key)),null!=this.encKey&&(this.encKeyB64=f.fromBufferToB64(this.encKey)),null!=this.macKey&&(this.macKeyB64=f.fromBufferToB64(this.macKey))}toJSON(){return{keyB64:this.keyB64}}static fromJSON(e){if(null==e)return null;const t=f.fromB64ToArray(e.keyB64).buffer;return new Ct(t)}}class Dt{toJSON(){return{encrypted:this.encrypted,decrypted:this.decrypted instanceof ArrayBuffer?f.fromBufferToByteString(this.decrypted):this.decrypted}}static fromJSON(e,t,i){if(null==e)return null;const n=new Dt;return null!=(null==e?void 0:e.encrypted)&&(n.encrypted=i?i(e.encrypted):e.encrypted),null!=(null==e?void 0:e.decrypted)&&(n.decrypted=t?t(e.decrypted):e.decrypted),n}}class xt{}class Tt{}class It{constructor(){this.ciphers=new xt,this.folders=new Tt,this.sends=new xt,this.collections=new xt,this.policies=new xt,this.passwordGenerationHistory=new Dt}}class Rt{constructor(){this.cryptoSymmetricKey=new Dt,this.organizationKeys=new Dt,this.providerKeys=new Dt,this.privateKey=new Dt}toJSON(){return Object.assign(this,{publicKey:f.fromBufferToByteString(this.publicKey)})}static fromJSON(e){var t;return null==e?null:Object.assign(new Rt,{cryptoMasterKey:Ct.fromJSON(null==e?void 0:e.cryptoMasterKey)},{cryptoSymmetricKey:Dt.fromJSON(null==e?void 0:e.cryptoSymmetricKey,Ct.fromJSON)},{organizationKeys:Rt.initRecordEncryptionPairsFromJSON(null==e?void 0:e.organizationKeys)},{providerKeys:Rt.initRecordEncryptionPairsFromJSON(null==e?void 0:e.providerKeys)},{privateKey:Dt.fromJSON(null==e?void 0:e.privateKey,(e=>f.fromByteStringToArray(e).buffer))},{publicKey:null===(t=f.fromByteStringToArray(null==e?void 0:e.publicKey))||void 0===t?void 0:t.buffer})}static initRecordEncryptionPairsFromJSON(e){return Dt.fromJSON(e,(t=>{if(null==e)return null;const i={};for(const e in t)i[e]=Ct.fromJSON(t[e]);return i}))}}class Et{static fromJSON(e){return null==e?null:Object.assign(new Et,e)}}class Ut{constructor(){this.environmentUrls=new h,this.pinProtected=new Dt,this.vaultTimeoutAction="lock"}static fromJSON(e){return null==e?null:Object.assign(new Ut,e,{environmentUrls:h.fromJSON(null==e?void 0:e.environmentUrls),pinProtected:Dt.fromJSON(null==e?void 0:e.pinProtected,At.fromJSON),serverConfig:St.fromJSON(null==e?void 0:e.serverConfig)})}}class Ft{static fromJSON(e){return null==e?null:Object.assign(new Ft,e)}}class Nt{constructor(e){this.data=new It,this.keys=new Rt,this.profile=new Et,this.settings=new Ut,this.tokens=new Ft,Object.assign(this,{data:Object.assign(Object.assign({},new It),null==e?void 0:e.data),keys:Object.assign(Object.assign({},new Rt),null==e?void 0:e.keys),profile:Object.assign(Object.assign({},new Et),null==e?void 0:e.profile),settings:Object.assign(Object.assign({},new Ut),null==e?void 0:e.settings),tokens:Object.assign(Object.assign({},new Ft),null==e?void 0:e.tokens)})}static fromJSON(e){return null==e?null:Object.assign(new Nt({}),e,{keys:Rt.fromJSON(null==e?void 0:e.keys),profile:Et.fromJSON(null==e?void 0:e.profile),settings:Ut.fromJSON(null==e?void 0:e.settings),tokens:Ft.fromJSON(null==e?void 0:e.tokens)})}}class zt{constructor(){this.captchaSiteKey="",this.resetMasterPassword=!1,this.forcePasswordReset=!1,this.twoFactorProviders=null}get requiresCaptcha(){return!f.isNullOrWhitespace(this.captchaSiteKey)}get requiresTwoFactor(){return null!=this.twoFactorProviders}}class Mt{constructor(e,t){this.publicKey=e,this.encryptedPrivateKey=t}}var Lt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Bt{constructor(e,t,i,n,s,r,o,a,l){this.cryptoService=e,this.apiService=t,this.tokenService=i,this.appIdService=n,this.platformUtilsService=s,this.messagingService=r,this.logService=o,this.stateService=a,this.twoFactorService=l,this.captchaBypassToken=null}logInTwoFactor(e,t=null){return Lt(this,void 0,void 0,(function*(){return this.tokenRequest.setTwoFactor(e),this.startLogIn()}))}startLogIn(){return Lt(this,void 0,void 0,(function*(){this.twoFactorService.clearSelectedProvider();const e=yield this.apiService.postIdentityToken(this.tokenRequest);if(e instanceof oe)return this.processTwoFactorResponse(e);if(e instanceof se)return this.processCaptchaResponse(e);if(e instanceof re)return this.processTokenResponse(e);throw new Error("Invalid response object.")}))}onSuccessfulLogin(e){return null}buildDeviceRequest(){return Lt(this,void 0,void 0,(function*(){const e=yield this.appIdService.getAppId();return new b(e,this.platformUtilsService)}))}buildTwoFactor(e){return Lt(this,void 0,void 0,(function*(){if(null!=e)return e;const t=yield this.tokenService.getTwoFactorToken();return null!=t?new k(ft.Remember,t,!1):new k}))}saveAccountInformation(e){return Lt(this,void 0,void 0,(function*(){const t=yield this.tokenService.decodeToken(e.accessToken);yield this.stateService.addAccount(new Nt({profile:Object.assign(Object.assign({},new Et),{userId:t.sub,email:t.email,hasPremiumPersonally:t.premium,kdfIterations:e.kdfIterations,kdfType:e.kdf}),tokens:Object.assign(Object.assign({},new Ft),{accessToken:e.accessToken,refreshToken:e.refreshToken})}))}))}processTokenResponse(e){var t;return Lt(this,void 0,void 0,(function*(){const i=new zt;i.resetMasterPassword=e.resetMasterPassword,i.forcePasswordReset=e.forcePasswordReset,yield this.saveAccountInformation(e),null!=e.twoFactorToken&&(yield this.tokenService.setTwoFactorToken(e));return null==e.key||(yield this.cryptoService.setEncKey(e.key),yield this.cryptoService.setEncPrivateKey(null!==(t=e.privateKey)&&void 0!==t?t:yield this.createKeyPairForOldAccount())),yield this.onSuccessfulLogin(e),this.messagingService.send("loggedIn"),i}))}processTwoFactorResponse(e){var t;return Lt(this,void 0,void 0,(function*(){const i=new zt;return i.twoFactorProviders=e.twoFactorProviders2,this.twoFactorService.setProviders(e),this.captchaBypassToken=null!==(t=e.captchaToken)&&void 0!==t?t:null,i}))}processCaptchaResponse(e){return Lt(this,void 0,void 0,(function*(){const t=new zt;return t.captchaSiteKey=e.siteKey,t}))}createKeyPairForOldAccount(){return Lt(this,void 0,void 0,(function*(){try{const[e,t]=yield this.cryptoService.makeKeyPair();return yield this.apiService.postAccountKeys(new Mt(e,t.encryptedString)),t.encryptedString}catch(e){this.logService.error(e)}}))}}var Kt,_t=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class jt extends Bt{constructor(e,t,i,n,s,r,o,a,l,c,d){super(e,t,i,n,s,r,o,a,l),this.environmentService=c,this.keyConnectorService=d}onSuccessfulLogin(e){return _t(this,void 0,void 0,(function*(){if(e.apiUseKeyConnector){const e=this.environmentService.getKeyConnectorUrl();yield this.keyConnectorService.getAndSetKey(e)}}))}logIn(e){return _t(this,void 0,void 0,(function*(){return this.tokenRequest=new S(e.clientId,e.clientSecret,yield this.buildTwoFactor(),yield this.buildDeviceRequest()),this.startLogIn()}))}saveAccountInformation(e){const t=Object.create(null,{saveAccountInformation:{get:()=>super.saveAccountInformation}});return _t(this,void 0,void 0,(function*(){yield t.saveAccountInformation.call(this,e),yield this.stateService.setApiKeyClientId(this.tokenRequest.clientId),yield this.stateService.setApiKeyClientSecret(this.tokenRequest.clientSecret)}))}}!function(e){e[e.ServerAuthorization=1]="ServerAuthorization",e[e.LocalAuthorization=2]="LocalAuthorization"}(Kt||(Kt={}));class Gt extends w{constructor(e,t,i,n,s){super(n,s),this.email=e,this.masterPasswordHash=t,this.captchaResponse=i,this.twoFactor=n}toIdentityToken(e){const t=super.toIdentityToken(e);return t.grant_type="password",t.username=this.email,t.password=this.masterPasswordHash,null!=this.captchaResponse&&(t.captchaResponse=this.captchaResponse),t}alterIdentityTokenHeaders(e){e.set("Auth-Email",f.fromUtf8ToUrlB64(this.email))}}var Vt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ht extends Bt{constructor(e,t,i,n,s,r,o,a,l,c){super(e,t,i,n,s,r,o,a,l),this.authService=c}get email(){return this.tokenRequest.email}get masterPasswordHash(){return this.tokenRequest.masterPasswordHash}onSuccessfulLogin(){return Vt(this,void 0,void 0,(function*(){yield this.cryptoService.setKey(this.key),yield this.cryptoService.setKeyHash(this.localHashedPassword)}))}logInTwoFactor(e,t){const i=Object.create(null,{logInTwoFactor:{get:()=>super.logInTwoFactor}});return Vt(this,void 0,void 0,(function*(){return this.tokenRequest.captchaResponse=null!=t?t:this.captchaBypassToken,i.logInTwoFactor.call(this,e)}))}logIn(e){return Vt(this,void 0,void 0,(function*(){const{email:t,masterPassword:i,captchaToken:n,twoFactor:s}=e;this.key=yield this.authService.makePreloginKey(i,t),this.localHashedPassword=yield this.cryptoService.hashPassword(i,this.key,Kt.LocalAuthorization);const r=yield this.cryptoService.hashPassword(i,this.key);return this.tokenRequest=new Gt(t,r,n,yield this.buildTwoFactor(s),yield this.buildDeviceRequest()),this.startLogIn()}))}}var qt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Wt extends Bt{constructor(e,t,i,n,s,r,o,a,l,c){super(e,t,i,n,s,r,o,a,l),this.authService=c}get email(){return this.tokenRequest.email}get masterPasswordHash(){return this.tokenRequest.masterPasswordHash}onSuccessfulLogin(){return qt(this,void 0,void 0,(function*(){yield this.cryptoService.setKey(this.key),yield this.cryptoService.setKeyHash(this.localHashedPassword)}))}logInTwoFactor(e,t){const i=Object.create(null,{logInTwoFactor:{get:()=>super.logInTwoFactor}});return qt(this,void 0,void 0,(function*(){return this.tokenRequest.captchaResponse=null!=t?t:this.captchaBypassToken,i.logInTwoFactor.call(this,e)}))}logIn(e){return qt(this,void 0,void 0,(function*(){return this.localHashedPassword=e.localPasswordHash,this.key=e.decKey,this.tokenRequest=new Gt(e.email,e.accessCode,null,yield this.buildTwoFactor(e.twoFactor),yield this.buildDeviceRequest()),this.tokenRequest.setPasswordlessAccessCode(e.authRequestId),this.startLogIn()}))}}class Jt extends w{constructor(e,t,i,n,s){super(n,s),this.code=e,this.codeVerifier=t,this.redirectUri=i,this.twoFactor=n}toIdentityToken(e){const t=super.toIdentityToken(e);return t.grant_type="authorization_code",t.code=this.code,t.code_verifier=this.codeVerifier,t.redirect_uri=this.redirectUri,t}}var Yt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class $t extends Bt{constructor(e,t,i,n,s,r,o,a,l,c){super(e,t,i,n,s,r,o,a,l),this.keyConnectorService=c}onSuccessfulLogin(e){return Yt(this,void 0,void 0,(function*(){const t=null==e.key;null!=e.keyConnectorUrl&&(t?yield this.keyConnectorService.convertNewSsoUserToKeyConnector(e,this.orgId):yield this.keyConnectorService.getAndSetKey(e.keyConnectorUrl))}))}logIn(e){return Yt(this,void 0,void 0,(function*(){return this.orgId=e.orgId,this.tokenRequest=new Jt(e.code,e.codeVerifier,e.redirectUrl,yield this.buildTwoFactor(e.twoFactor),yield this.buildDeviceRequest()),this.startLogIn()}))}}class Qt{constructor(e){this.email=e}}var Xt=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Zt{constructor(e,t,i,n,s,r,o,a,l,c,d,u){this.cryptoService=e,this.apiService=t,this.tokenService=i,this.appIdService=n,this.platformUtilsService=s,this.messagingService=r,this.logService=o,this.keyConnectorService=a,this.environmentService=l,this.stateService=c,this.twoFactorService=d,this.i18nService=u,this.pushNotificationSubject=new wt.x}get email(){return this.logInStrategy instanceof Ht?this.logInStrategy.email:null}get masterPasswordHash(){return this.logInStrategy instanceof Ht?this.logInStrategy.masterPasswordHash:null}logIn(e){return Xt(this,void 0,void 0,(function*(){let t;switch(this.clearState(),e.type){case gt.Password:t=new Ht(this.cryptoService,this.apiService,this.tokenService,this.appIdService,this.platformUtilsService,this.messagingService,this.logService,this.stateService,this.twoFactorService,this);break;case gt.Sso:t=new $t(this.cryptoService,this.apiService,this.tokenService,this.appIdService,this.platformUtilsService,this.messagingService,this.logService,this.stateService,this.twoFactorService,this.keyConnectorService);break;case gt.Api:t=new jt(this.cryptoService,this.apiService,this.tokenService,this.appIdService,this.platformUtilsService,this.messagingService,this.logService,this.stateService,this.twoFactorService,this.environmentService,this.keyConnectorService);break;case gt.Passwordless:t=new Wt(this.cryptoService,this.apiService,this.tokenService,this.appIdService,this.platformUtilsService,this.messagingService,this.logService,this.stateService,this.twoFactorService,this)}const i=yield t.logIn(e);return(null==i?void 0:i.requiresTwoFactor)&&this.saveState(t),i}))}logInTwoFactor(e,t){return Xt(this,void 0,void 0,(function*(){if(null==this.logInStrategy)throw new Error(this.i18nService.t("sessionTimeout"));try{const i=yield this.logInStrategy.logInTwoFactor(e,t);return i.requiresTwoFactor||i.requiresCaptcha||this.clearState(),i}catch(e){throw e instanceof ee||this.clearState(),e}}))}logOut(e){e(),this.messagingService.send("loggedOut")}authingWithApiKey(){return this.logInStrategy instanceof jt}authingWithSso(){return this.logInStrategy instanceof $t}authingWithPassword(){return this.logInStrategy instanceof Ht}getAuthStatus(e){return Xt(this,void 0,void 0,(function*(){if(!(yield this.stateService.getIsAuthenticated({userId:e})))return n.LoggedOut;(yield this.cryptoService.hasKeyStored(mt.Auto,e))&&!(yield this.stateService.getEverBeenUnlocked({userId:e}))&&(yield this.cryptoService.getKey(mt.Auto,e));return(yield this.cryptoService.hasKeyInMemory(e))?n.Unlocked:n.Locked}))}makePreloginKey(e,t){return Xt(this,void 0,void 0,(function*(){t=t.trim().toLowerCase();let i=null,n=null;try{const e=yield this.apiService.postPrelogin(new Qt(t));null!=e&&(i=e.kdf,n=e.kdfIterations)}catch(e){if(null==e||404!==e.statusCode)throw e}return this.cryptoService.makeKey(e,t,i,n)}))}authResponsePushNotifiction(e){return Xt(this,void 0,void 0,(function*(){this.pushNotificationSubject.next(e.id)}))}getPushNotifcationObs$(){return this.pushNotificationSubject.asObservable()}saveState(e){this.logInStrategy=e,this.startSessionTimeout()}clearState(){this.logInStrategy=null,this.clearSessionTimeout()}startSessionTimeout(){this.clearSessionTimeout(),this.sessionTimeout=setTimeout((()=>this.clearState()),12e4)}clearSessionTimeout(){null!=this.sessionTimeout&&clearTimeout(this.sessionTimeout)}}var ei,ti,ii=i(62858);function ni(e){return(t,i,n)=>{const s=n.value,r=new Map;return{value:function(...t){const i=(e=>{let t=r.get(e);return null!=t||(t=new Map,r.set(e,t)),t})(this),n=e(t);let o=i.get(n);if(null!=o)return o;const a=()=>{i.delete(n),0===i.size&&r.delete(this)};return o=s.apply(this,t).then((e=>(a(),e))).catch((e=>{throw a(),e})),i.set(n,o),o}}}}!function(e){e[e.Text=0]="Text",e[e.Hidden=1]="Hidden",e[e.Boolean=2]="Boolean",e[e.Linked=3]="Linked"}(ei||(ei={})),function(e){e[e.Domain=0]="Domain",e[e.Host=1]="Host",e[e.StartsWith=2]="StartsWith",e[e.Exact=3]="Exact",e[e.RegularExpression=4]="RegularExpression",e[e.Never=5]="Never"}(ti||(ti={}));class si{constructor(e){null!=e&&(this.id=e.id,this.url=e.url,this.fileName=e.fileName,this.key=e.key,this.size=e.size,this.sizeName=e.sizeName)}}class ri{constructor(e){null!=e&&(this.cardholderName=e.cardholderName,this.brand=e.brand,this.number=e.number,this.expMonth=e.expMonth,this.expYear=e.expYear,this.code=e.code)}}class oi{constructor(e){null!=e&&(this.type=e.type,this.name=e.name,this.value=e.value,this.linkedId=e.linkedId)}}class ai{constructor(e){null!=e&&(this.title=e.title,this.firstName=e.firstName,this.middleName=e.middleName,this.lastName=e.lastName,this.address1=e.address1,this.address2=e.address2,this.address3=e.address3,this.city=e.city,this.state=e.state,this.postalCode=e.postalCode,this.country=e.country,this.company=e.company,this.email=e.email,this.phone=e.phone,this.ssn=e.ssn,this.username=e.username,this.passportNumber=e.passportNumber,this.licenseNumber=e.licenseNumber)}}class li{constructor(e){this.match=null,null!=e&&(this.uri=e.uri,this.match=e.match)}}class ci{constructor(e){null!=e&&(this.username=e.username,this.password=e.password,this.passwordRevisionDate=e.passwordRevisionDate,this.totp=e.totp,this.autofillOnPageLoad=e.autofillOnPageLoad,e.uris&&(this.uris=e.uris.map((e=>new li(e)))))}}class di{constructor(e){null!=e&&(this.password=e.password,this.lastUsedDate=e.lastUsedDate)}}class ui{constructor(e){null!=e&&(this.type=e.type)}}class hi{constructor(e,t){if(null!=e){switch(this.id=e.id,this.organizationId=e.organizationId,this.folderId=e.folderId,this.edit=e.edit,this.viewPassword=e.viewPassword,this.organizationUseTotp=e.organizationUseTotp,this.favorite=e.favorite,this.revisionDate=e.revisionDate,this.type=e.type,this.name=e.name,this.notes=e.notes,this.collectionIds=null!=t?t:e.collectionIds,this.deletedDate=e.deletedDate,this.reprompt=e.reprompt,this.type){case r.Login:this.login=new ci(e.login);break;case r.SecureNote:this.secureNote=new ui(e.secureNote);break;case r.Card:this.card=new ri(e.card);break;case r.Identity:this.identity=new ai(e.identity)}null!=e.fields&&(this.fields=e.fields.map((e=>new oi(e)))),null!=e.attachments&&(this.attachments=e.attachments.map((e=>new si(e)))),null!=e.passwordHistory&&(this.passwordHistory=e.passwordHistory.map((e=>new di(e))))}}}class pi{constructor(e){this.id=null,this.url=null,this.size=null,this.sizeName=null,this.fileName=null,this.key=null,e&&(this.id=e.id,this.url=e.url,this.size=e.size,this.sizeName=e.sizeName)}get fileSize(){try{if(null!=this.size)return parseInt(this.size,null)}catch(e){}return 0}static fromJSON(e){const t=null==e.key?null:Ct.fromJSON(e.key);return Object.assign(new pi,e,{key:t})}}var yi=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class vi{buildDomainModel(e,t,i,n=[]){for(const s in i){if(!i.hasOwnProperty(s))continue;const r=t[i[s]||s];n.indexOf(s)>-1?e[s]=r||null:e[s]=r?new At(r):null}}buildDataModel(e,t,i,n=[]){for(const s in i){if(!i.hasOwnProperty(s))continue;const r=e[i[s]||s];n.indexOf(s)>-1?t[s]=null!=r?r:null:t[s]=null!=r?r.encryptedString:null}}decryptObj(e,t,i,n=null){return yi(this,void 0,void 0,(function*(){const s=[],r=this;for(const o in t)t.hasOwnProperty(o)&&function(o){const a=Promise.resolve().then((()=>{const e=t[o]||o;return r[e]?r[e].decrypt(i,n):null})).then((t=>{e[o]=t}));s.push(a)}(o);return yield Promise.all(s),e}))}}var gi,mi,fi,bi=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class wi extends vi{constructor(e){super(),null!=e&&(this.size=e.size,this.buildDomainModel(this,e,{id:null,url:null,sizeName:null,fileName:null,key:null},["id","url","sizeName"]))}decrypt(e,t){return bi(this,void 0,void 0,(function*(){const i=yield this.decryptObj(new pi(this),{fileName:null},e,t);return null!=this.key&&(i.key=yield this.decryptAttachmentKey(e,t)),i}))}decryptAttachmentKey(e,t){return bi(this,void 0,void 0,(function*(){try{null==t&&(t=yield this.getKeyForDecryption(e));const i=f.getContainerService().getEncryptService(),n=yield i.decryptToBytes(this.key,t);return new Ct(n)}catch(e){}}))}getKeyForDecryption(e){return bi(this,void 0,void 0,(function*(){const t=f.getContainerService().getCryptoService();return null!=e?yield t.getOrgKey(e):yield t.getKeyForUserEncryption()}))}toAttachmentData(){const e=new si;return e.size=this.size,this.buildDataModel(this,e,{id:null,url:null,sizeName:null,fileName:null,key:null},["id","url","sizeName"]),e}}!function(e){e[e.Username=100]="Username",e[e.Password=101]="Password"}(gi||(gi={})),function(e){e[e.CardholderName=300]="CardholderName",e[e.ExpMonth=301]="ExpMonth",e[e.ExpYear=302]="ExpYear",e[e.Code=303]="Code",e[e.Brand=304]="Brand",e[e.Number=305]="Number"}(mi||(mi={})),function(e){e[e.Title=400]="Title",e[e.MiddleName=401]="MiddleName",e[e.Address1=402]="Address1",e[e.Address2=403]="Address2",e[e.Address3=404]="Address3",e[e.City=405]="City",e[e.State=406]="State",e[e.PostalCode=407]="PostalCode",e[e.Country=408]="Country",e[e.Company=409]="Company",e[e.Email=410]="Email",e[e.Phone=411]="Phone",e[e.Ssn=412]="Ssn",e[e.Username=413]="Username",e[e.PassportNumber=414]="PassportNumber",e[e.LicenseNumber=415]="LicenseNumber",e[e.FirstName=416]="FirstName",e[e.LastName=417]="LastName",e[e.FullName=418]="FullName"}(fi||(fi={}));class Si{constructor(e,t){this.propertyKey=e,this._i18nKey=t}get i18nKey(){var e;return null!==(e=this._i18nKey)&&void 0!==e?e:this.propertyKey}}function ki(e,t){return(i,n)=>{null==i.linkedFieldOptions&&(i.linkedFieldOptions=new Map),i.linkedFieldOptions.set(e,new Si(n,t))}}class Oi{}var Pi=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},Ai=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};class Ci extends Oi{constructor(){super(...arguments),this.cardholderName=null,this.expMonth=null,this.expYear=null,this.code=null,this._brand=null,this._number=null,this._subTitle=null}get maskedCode(){return null!=this.code?"•".repeat(this.code.length):null}get maskedNumber(){return null!=this.number?"•".repeat(this.number.length):null}get brand(){return this._brand}set brand(e){this._brand=e,this._subTitle=null}get number(){return this._number}set number(e){this._number=e,this._subTitle=null}get subTitle(){if(null==this._subTitle&&(this._subTitle=this.brand,null!=this.number&&this.number.length>=4)){null!=this._subTitle&&""!==this._subTitle?this._subTitle+=", ":this._subTitle="";const e=this.number.length>=5&&null!=this.number.match(new RegExp("^3[47]"))?5:4;this._subTitle+="*"+this.number.substr(this.number.length-e)}return this._subTitle}get expiration(){if(!this.expMonth&&!this.expYear)return null;let e=null!=this.expMonth?("0"+this.expMonth).slice(-2):"__";return e+=" / "+(null!=this.expYear?this.formatYear(this.expYear):"____"),e}formatYear(e){return 2===e.length?"20"+e:e}static fromJSON(e){return Object.assign(new Ci,e)}}Pi([ki(mi.CardholderName),Ai("design:type",String)],Ci.prototype,"cardholderName",void 0),Pi([ki(mi.ExpMonth,"expirationMonth"),Ai("design:type",String)],Ci.prototype,"expMonth",void 0),Pi([ki(mi.ExpYear,"expirationYear"),Ai("design:type",String)],Ci.prototype,"expYear",void 0),Pi([ki(mi.Code,"securityCode"),Ai("design:type",String)],Ci.prototype,"code",void 0),Pi([ki(mi.Brand),Ai("design:type",String),Ai("design:paramtypes",[String])],Ci.prototype,"brand",null),Pi([ki(mi.Number),Ai("design:type",String),Ai("design:paramtypes",[String])],Ci.prototype,"number",null);class Di extends vi{constructor(e){super(),null!=e&&this.buildDomainModel(this,e,{cardholderName:null,brand:null,number:null,expMonth:null,expYear:null,code:null},[])}decrypt(e,t){return this.decryptObj(new Ci,{cardholderName:null,brand:null,number:null,expMonth:null,expYear:null,code:null},e,t)}toCardData(){const e=new ri;return this.buildDataModel(this,e,{cardholderName:null,brand:null,number:null,expMonth:null,expYear:null,code:null}),e}}class xi{constructor(e){this.name=null,this.value=null,this.type=null,this.newField=!1,this.showValue=!1,this.showCount=!1,this.linkedId=null,e&&(this.type=e.type,this.linkedId=e.linkedId)}get maskedValue(){return null!=this.value?"••••••••":null}static fromJSON(e){return Object.assign(new xi,e)}}var Ti=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},Ii=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};class Ri extends Oi{constructor(){super(),this.title=null,this.middleName=null,this.address1=null,this.address2=null,this.address3=null,this.city=null,this.state=null,this.postalCode=null,this.country=null,this.company=null,this.email=null,this.phone=null,this.ssn=null,this.username=null,this.passportNumber=null,this.licenseNumber=null,this._firstName=null,this._lastName=null,this._subTitle=null}get firstName(){return this._firstName}set firstName(e){this._firstName=e,this._subTitle=null}get lastName(){return this._lastName}set lastName(e){this._lastName=e,this._subTitle=null}get subTitle(){return null!=this._subTitle||null==this.firstName&&null==this.lastName||(this._subTitle="",null!=this.firstName&&(this._subTitle=this.firstName),null!=this.lastName&&(""!==this._subTitle&&(this._subTitle+=" "),this._subTitle+=this.lastName)),this._subTitle}get fullName(){if(null!=this.title||null!=this.firstName||null!=this.middleName||null!=this.lastName){let e="";return null!=this.title&&(e+=this.title+" "),null!=this.firstName&&(e+=this.firstName+" "),null!=this.middleName&&(e+=this.middleName+" "),null!=this.lastName&&(e+=this.lastName),e.trim()}return null}get fullAddress(){let e=this.address1;return f.isNullOrWhitespace(this.address2)||(f.isNullOrWhitespace(e)||(e+=", "),e+=this.address2),f.isNullOrWhitespace(this.address3)||(f.isNullOrWhitespace(e)||(e+=", "),e+=this.address3),e}get fullAddressPart2(){if(null==this.city&&null==this.state&&null==this.postalCode)return null;const e=this.city||"-",t=this.state,i=this.postalCode||"-";let n=e;return f.isNullOrWhitespace(t)||(n+=", "+t),n+=", "+i,n}static fromJSON(e){return Object.assign(new Ri,e)}}Ti([ki(fi.Title),Ii("design:type",String)],Ri.prototype,"title",void 0),Ti([ki(fi.MiddleName),Ii("design:type",String)],Ri.prototype,"middleName",void 0),Ti([ki(fi.Address1),Ii("design:type",String)],Ri.prototype,"address1",void 0),Ti([ki(fi.Address2),Ii("design:type",String)],Ri.prototype,"address2",void 0),Ti([ki(fi.Address3),Ii("design:type",String)],Ri.prototype,"address3",void 0),Ti([ki(fi.City,"cityTown"),Ii("design:type",String)],Ri.prototype,"city",void 0),Ti([ki(fi.State,"stateProvince"),Ii("design:type",String)],Ri.prototype,"state",void 0),Ti([ki(fi.PostalCode,"zipPostalCode"),Ii("design:type",String)],Ri.prototype,"postalCode",void 0),Ti([ki(fi.Country),Ii("design:type",String)],Ri.prototype,"country",void 0),Ti([ki(fi.Company),Ii("design:type",String)],Ri.prototype,"company",void 0),Ti([ki(fi.Email),Ii("design:type",String)],Ri.prototype,"email",void 0),Ti([ki(fi.Phone),Ii("design:type",String)],Ri.prototype,"phone",void 0),Ti([ki(fi.Ssn),Ii("design:type",String)],Ri.prototype,"ssn",void 0),Ti([ki(fi.Username),Ii("design:type",String)],Ri.prototype,"username",void 0),Ti([ki(fi.PassportNumber),Ii("design:type",String)],Ri.prototype,"passportNumber",void 0),Ti([ki(fi.LicenseNumber),Ii("design:type",String)],Ri.prototype,"licenseNumber",void 0),Ti([ki(fi.FirstName),Ii("design:type",String),Ii("design:paramtypes",[String])],Ri.prototype,"firstName",null),Ti([ki(fi.LastName),Ii("design:type",String),Ii("design:paramtypes",[String])],Ri.prototype,"lastName",null),Ti([ki(fi.FullName),Ii("design:type",String),Ii("design:paramtypes",[])],Ri.prototype,"fullName",null);const Ei=["https://","http://","ssh://","ftp://","sftp://","irc://","vnc://","rdp://","ms-rd:","chrome://","iosapp://","androidapp://"];class Ui{constructor(e){this.match=null,this._uri=null,this._domain=null,this._hostname=null,this._host=null,this._canLaunch=null,e&&(this.match=e.match)}get uri(){return this._uri}set uri(e){this._uri=e,this._domain=null,this._canLaunch=null}get domain(){return null==this._domain&&null!=this.uri&&(this._domain=f.getDomain(this.uri),""===this._domain&&(this._domain=null)),this._domain}get hostname(){return this.match===ti.RegularExpression?null:(null==this._hostname&&null!=this.uri&&(this._hostname=f.getHostname(this.uri),""===this._hostname&&(this._hostname=null)),this._hostname)}get host(){return this.match===ti.RegularExpression?null:(null==this._host&&null!=this.uri&&(this._host=f.getHost(this.uri),""===this._host&&(this._host=null)),this._host)}get hostnameOrUri(){return null!=this.hostname?this.hostname:this.uri}get hostOrUri(){return null!=this.host?this.host:this.uri}get isWebsite(){return null!=this.uri&&(0===this.uri.indexOf("http://")||0===this.uri.indexOf("https://")||this.uri.indexOf("://")<0&&f.tldEndingRegex.test(this.uri))}get canLaunch(){if(null!=this._canLaunch)return this._canLaunch;if(null!=this.uri&&this.match!==ti.RegularExpression){const e=this.launchUri;for(let t=0;t<Ei.length;t++)if(0===e.indexOf(Ei[t]))return this._canLaunch=!0,this._canLaunch}return this._canLaunch=!1,this._canLaunch}get launchUri(){return this.uri.indexOf("://")<0&&f.tldEndingRegex.test(this.uri)?"http://"+this.uri:this.uri}static fromJSON(e){return Object.assign(new Ui,e)}}var Fi=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},Ni=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};class zi extends Oi{constructor(e){super(),this.username=null,this.password=null,this.passwordRevisionDate=null,this.totp=null,this.uris=null,this.autofillOnPageLoad=null,e&&(this.passwordRevisionDate=e.passwordRevisionDate,this.autofillOnPageLoad=e.autofillOnPageLoad)}get uri(){return this.hasUris?this.uris[0].uri:null}get maskedPassword(){return null!=this.password?"••••••••":null}get subTitle(){return this.username}get canLaunch(){return this.hasUris&&this.uris.some((e=>e.canLaunch))}get hasTotp(){return!f.isNullOrWhitespace(this.totp)}get launchUri(){if(this.hasUris){const e=this.uris.find((e=>e.canLaunch));if(null!=e)return e.launchUri}return null}get hasUris(){return null!=this.uris&&this.uris.length>0}static fromJSON(e){var t;const i=null==e.passwordRevisionDate?null:new Date(e.passwordRevisionDate),n=null===(t=e.uris)||void 0===t?void 0:t.map((e=>Ui.fromJSON(e)));return Object.assign(new zi,e,{passwordRevisionDate:i,uris:n})}}Fi([ki(gi.Username),Ni("design:type",String)],zi.prototype,"username",void 0),Fi([ki(gi.Password),Ni("design:type",String)],zi.prototype,"password",void 0);class Mi{constructor(e){this.password=null,this.lastUsedDate=null,e&&(this.lastUsedDate=e.lastUsedDate)}static fromJSON(e){const t=null==e.lastUsedDate?null:new Date(e.lastUsedDate);return Object.assign(new Mi,e,{lastUsedDate:t})}}class Li extends Oi{constructor(e){super(),this.type=null,e&&(this.type=e.type)}get subTitle(){return null}static fromJSON(e){return Object.assign(new Li,e)}}class Bi{constructor(e){var t;this.id=null,this.organizationId=null,this.folderId=null,this.name=null,this.notes=null,this.type=null,this.favorite=!1,this.organizationUseTotp=!1,this.edit=!1,this.viewPassword=!0,this.login=new zi,this.identity=new Ri,this.card=new Ci,this.secureNote=new Li,this.attachments=null,this.fields=null,this.passwordHistory=null,this.collectionIds=null,this.revisionDate=null,this.deletedDate=null,this.reprompt=s.None,e&&(this.id=e.id,this.organizationId=e.organizationId,this.folderId=e.folderId,this.favorite=e.favorite,this.organizationUseTotp=e.organizationUseTotp,this.edit=e.edit,this.viewPassword=e.viewPassword,this.type=e.type,this.localData=e.localData,this.collectionIds=e.collectionIds,this.revisionDate=e.revisionDate,this.deletedDate=e.deletedDate,this.reprompt=null!==(t=e.reprompt)&&void 0!==t?t:s.None)}get item(){switch(this.type){case r.Login:return this.login;case r.SecureNote:return this.secureNote;case r.Card:return this.card;case r.Identity:return this.identity}return null}get subTitle(){return this.item.subTitle}get hasPasswordHistory(){return this.passwordHistory&&this.passwordHistory.length>0}get hasAttachments(){return this.attachments&&this.attachments.length>0}get hasOldAttachments(){if(this.hasAttachments)for(let e=0;e<this.attachments.length;e++)if(null==this.attachments[e].key)return!0;return!1}get hasFields(){return this.fields&&this.fields.length>0}get passwordRevisionDisplayDate(){return this.type!==r.Login||null==this.login||null==this.login.password||""===this.login.password?null:this.login.passwordRevisionDate}get isDeleted(){return null!=this.deletedDate}get linkedFieldOptions(){return this.item.linkedFieldOptions}linkedFieldValue(e){var t;const i=null===(t=this.linkedFieldOptions)||void 0===t?void 0:t.get(e);if(null==i)return null;this.item;return this.item[i.propertyKey]}linkedFieldI18nKey(e){var t;return null===(t=this.linkedFieldOptions.get(e))||void 0===t?void 0:t.i18nKey}static fromJSON(e){var t,i,n;const s=new Bi,o=null==e.revisionDate?null:new Date(e.revisionDate),a=null==e.deletedDate?null:new Date(e.deletedDate),l=null===(t=e.attachments)||void 0===t?void 0:t.map((e=>pi.fromJSON(e))),c=null===(i=e.fields)||void 0===i?void 0:i.map((e=>xi.fromJSON(e))),d=null===(n=e.passwordHistory)||void 0===n?void 0:n.map((e=>Mi.fromJSON(e)));switch(Object.assign(s,e,{revisionDate:o,deletedDate:a,attachments:l,fields:c,passwordHistory:d}),e.type){case r.Card:s.card=Ci.fromJSON(e.card);break;case r.Identity:s.identity=Ri.fromJSON(e.identity);break;case r.Login:s.login=zi.fromJSON(e.login);break;case r.SecureNote:s.secureNote=Li.fromJSON(e.secureNote)}return s}}class Ki extends vi{constructor(e){super(),null!=e&&(this.type=e.type,this.linkedId=e.linkedId,this.buildDomainModel(this,e,{name:null,value:null},[]))}decrypt(e,t){return this.decryptObj(new xi(this),{name:null,value:null},e,t)}toFieldData(){const e=new oi;return this.buildDataModel(this,e,{name:null,value:null,type:null,linkedId:null},["type","linkedId"]),e}}class _i extends vi{constructor(e){super(),null!=e&&this.buildDomainModel(this,e,{title:null,firstName:null,middleName:null,lastName:null,address1:null,address2:null,address3:null,city:null,state:null,postalCode:null,country:null,company:null,email:null,phone:null,ssn:null,username:null,passportNumber:null,licenseNumber:null},[])}decrypt(e,t){return this.decryptObj(new Ri,{title:null,firstName:null,middleName:null,lastName:null,address1:null,address2:null,address3:null,city:null,state:null,postalCode:null,country:null,company:null,email:null,phone:null,ssn:null,username:null,passportNumber:null,licenseNumber:null},e,t)}toIdentityData(){const e=new ai;return this.buildDataModel(this,e,{title:null,firstName:null,middleName:null,lastName:null,address1:null,address2:null,address3:null,city:null,state:null,postalCode:null,country:null,company:null,email:null,phone:null,ssn:null,username:null,passportNumber:null,licenseNumber:null}),e}}class ji extends vi{constructor(e){super(),null!=e&&(this.match=e.match,this.buildDomainModel(this,e,{uri:null},[]))}decrypt(e,t){return this.decryptObj(new Ui(this),{uri:null},e,t)}toLoginUriData(){const e=new li;return this.buildDataModel(this,e,{uri:null,match:null},["match"]),e}}var Gi=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Vi extends vi{constructor(e){super(),null!=e&&(this.passwordRevisionDate=null!=e.passwordRevisionDate?new Date(e.passwordRevisionDate):null,this.autofillOnPageLoad=e.autofillOnPageLoad,this.buildDomainModel(this,e,{username:null,password:null,totp:null},[]),e.uris&&(this.uris=[],e.uris.forEach((e=>{this.uris.push(new ji(e))}))))}decrypt(e,t){return Gi(this,void 0,void 0,(function*(){const i=yield this.decryptObj(new zi(this),{username:null,password:null,totp:null},e,t);if(null!=this.uris){i.uris=[];for(let n=0;n<this.uris.length;n++){const s=yield this.uris[n].decrypt(e,t);i.uris.push(s)}}return i}))}toLoginData(){const e=new ci;return e.passwordRevisionDate=null!=this.passwordRevisionDate?this.passwordRevisionDate.toISOString():null,e.autofillOnPageLoad=this.autofillOnPageLoad,this.buildDataModel(this,e,{username:null,password:null,totp:null}),null!=this.uris&&this.uris.length>0&&(e.uris=[],this.uris.forEach((t=>{e.uris.push(t.toLoginUriData())}))),e}}class Hi extends vi{constructor(e){super(),null!=e&&(this.buildDomainModel(this,e,{password:null}),this.lastUsedDate=new Date(e.lastUsedDate))}decrypt(e,t){return this.decryptObj(new Mi(this),{password:null},e,t)}toPasswordHistoryData(){const e=new di;return e.lastUsedDate=this.lastUsedDate.toISOString(),this.buildDataModel(this,e,{password:null}),e}}class qi extends vi{constructor(e){super(),null!=e&&(this.type=e.type)}decrypt(e,t){return Promise.resolve(new Li(this))}toSecureNoteData(){const e=new ui;return e.type=this.type,e}}var Wi=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ji extends vi{constructor(e,t=null){if(super(),null!=e){switch(this.buildDomainModel(this,e,{id:null,organizationId:null,folderId:null,name:null,notes:null},["id","organizationId","folderId"]),this.type=e.type,this.favorite=e.favorite,this.organizationUseTotp=e.organizationUseTotp,this.edit=e.edit,null!=e.viewPassword?this.viewPassword=e.viewPassword:this.viewPassword=!0,this.revisionDate=null!=e.revisionDate?new Date(e.revisionDate):null,this.collectionIds=e.collectionIds,this.localData=t,this.deletedDate=null!=e.deletedDate?new Date(e.deletedDate):null,this.reprompt=e.reprompt,this.type){case r.Login:this.login=new Vi(e.login);break;case r.SecureNote:this.secureNote=new qi(e.secureNote);break;case r.Card:this.card=new Di(e.card);break;case r.Identity:this.identity=new _i(e.identity)}null!=e.attachments?this.attachments=e.attachments.map((e=>new wi(e))):this.attachments=null,null!=e.fields?this.fields=e.fields.map((e=>new Ki(e))):this.fields=null,null!=e.passwordHistory?this.passwordHistory=e.passwordHistory.map((e=>new Hi(e))):this.passwordHistory=null}}decrypt(e){return Wi(this,void 0,void 0,(function*(){const t=new Bi(this);switch(yield this.decryptObj(t,{name:null,notes:null},this.organizationId,e),this.type){case r.Login:t.login=yield this.login.decrypt(this.organizationId,e);break;case r.SecureNote:t.secureNote=yield this.secureNote.decrypt(this.organizationId,e);break;case r.Card:t.card=yield this.card.decrypt(this.organizationId,e);break;case r.Identity:t.identity=yield this.identity.decrypt(this.organizationId,e)}const i=this.organizationId;if(null!=this.attachments&&this.attachments.length>0){const n=[];yield this.attachments.reduce(((t,s)=>t.then((()=>s.decrypt(i,e))).then((e=>{n.push(e)}))),Promise.resolve()),t.attachments=n}if(null!=this.fields&&this.fields.length>0){const n=[];yield this.fields.reduce(((t,s)=>t.then((()=>s.decrypt(i,e))).then((e=>{n.push(e)}))),Promise.resolve()),t.fields=n}if(null!=this.passwordHistory&&this.passwordHistory.length>0){const n=[];yield this.passwordHistory.reduce(((t,s)=>t.then((()=>s.decrypt(i,e))).then((e=>{n.push(e)}))),Promise.resolve()),t.passwordHistory=n}return t}))}toCipherData(){const e=new hi;switch(e.id=this.id,e.organizationId=this.organizationId,e.folderId=this.folderId,e.edit=this.edit,e.viewPassword=this.viewPassword,e.organizationUseTotp=this.organizationUseTotp,e.favorite=this.favorite,e.revisionDate=null!=this.revisionDate?this.revisionDate.toISOString():null,e.type=this.type,e.collectionIds=this.collectionIds,e.deletedDate=null!=this.deletedDate?this.deletedDate.toISOString():null,e.reprompt=this.reprompt,this.buildDataModel(this,e,{name:null,notes:null}),e.type){case r.Login:e.login=this.login.toLoginData();break;case r.SecureNote:e.secureNote=this.secureNote.toSecureNoteData();break;case r.Card:e.card=this.card.toCardData();break;case r.Identity:e.identity=this.identity.toIdentityData()}return null!=this.fields&&(e.fields=this.fields.map((e=>e.toFieldData()))),null!=this.attachments&&(e.attachments=this.attachments.map((e=>e.toAttachmentData()))),null!=this.passwordHistory&&(e.passwordHistory=this.passwordHistory.map((e=>e.toPasswordHistoryData()))),e}}var Yi=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class $i{constructor(e){this.buffer=e,this.encryptionType=null,this.dataBytes=null,this.ivBytes=null,this.macBytes=null;const t=new Uint8Array(e),i=t[0];switch(i){case bt.AesCbc128_HmacSha256_B64:case bt.AesCbc256_HmacSha256_B64:{const e=50;t.length<e&&this.throwDecryptionError(),this.ivBytes=t.slice(1,17).buffer,this.macBytes=t.slice(17,49).buffer,this.dataBytes=t.slice(49).buffer;break}case bt.AesCbc256_B64:{const e=18;t.length<e&&this.throwDecryptionError(),this.ivBytes=t.slice(1,17).buffer,this.dataBytes=t.slice(17).buffer;break}default:this.throwDecryptionError()}this.encryptionType=i}throwDecryptionError(){throw new Error("Error parsing encrypted ArrayBuffer: data is corrupted or has an invalid format.")}static fromResponse(e){return Yi(this,void 0,void 0,(function*(){const t=yield e.arrayBuffer();if(null==t)throw new Error("Cannot create EncArrayBuffer from Response - Response is empty");return new $i(t)}))}static fromB64(e){const t=f.fromB64ToArray(e).buffer;return new $i(t)}}class Qi{constructor(e){this.comparator=e,this.sortedCiphersByUrl=new Map,this.timeouts=new Map}isCached(e){return this.sortedCiphersByUrl.has(e)}addCiphers(e,t){t.sort(this.comparator),this.sortedCiphersByUrl.set(e,new Xi(t)),this.resetTimer(e)}getLastUsed(e){return this.resetTimer(e),this.isCached(e)?this.sortedCiphersByUrl.get(e).getLastUsed():null}getLastLaunched(e){return this.isCached(e)?this.sortedCiphersByUrl.get(e).getLastLaunched():null}getNext(e){return this.resetTimer(e),this.isCached(e)?this.sortedCiphersByUrl.get(e).getNext():null}updateLastUsedIndex(e){this.isCached(e)&&this.sortedCiphersByUrl.get(e).updateLastUsedIndex()}clear(){this.sortedCiphersByUrl.clear(),this.timeouts.clear()}resetTimer(e){clearTimeout(this.timeouts.get(e)),this.timeouts.set(e,setTimeout((()=>{this.sortedCiphersByUrl.delete(e),this.timeouts.delete(e)}),3e3))}}class Xi{constructor(e){this.ciphers=e,this.lastUsedIndex=-1}getLastUsed(){return this.lastUsedIndex=Math.max(this.lastUsedIndex,0),this.ciphers[this.lastUsedIndex]}getLastLaunched(){return this.ciphers.filter((e=>{var t;return null===(t=e.localData)||void 0===t?void 0:t.lastLaunched})).sort(((e,t)=>t.localData.lastLaunched.valueOf()-e.localData.lastLaunched.valueOf()))[0]}getNextIndex(){return(this.lastUsedIndex+1)%this.ciphers.length}getNext(){return this.ciphers[this.getNextIndex()]}updateLastUsedIndex(){this.lastUsedIndex=this.getNextIndex()}}class Zi{constructor(e,t){this.ids=null==e?[]:e,this.organizationId=t}}class en{constructor(e,t){this.ids=null==e?[]:e,this.folderId=t}}class tn{constructor(e){this.ids=null==e?[]:e}}class nn{}class sn{constructor(e){switch(this.type=e.type,this.folderId=e.folderId,this.organizationId=e.organizationId,this.name=e.name?e.name.encryptedString:null,this.notes=e.notes?e.notes.encryptedString:null,this.favorite=e.favorite,this.lastKnownRevisionDate=e.revisionDate,this.reprompt=e.reprompt,this.type){case r.Login:this.login=new I,this.login.uris=null,this.login.username=e.login.username?e.login.username.encryptedString:null,this.login.password=e.login.password?e.login.password.encryptedString:null,this.login.passwordRevisionDate=null!=e.login.passwordRevisionDate?e.login.passwordRevisionDate.toISOString():null,this.login.totp=e.login.totp?e.login.totp.encryptedString:null,this.login.autofillOnPageLoad=e.login.autofillOnPageLoad,null!=e.login.uris&&(this.login.uris=e.login.uris.map((e=>{const t=new T;return t.uri=null!=e.uri?e.uri.encryptedString:null,t.match=null!=e.match?e.match:null,t})));break;case r.SecureNote:this.secureNote=new R,this.secureNote.type=e.secureNote.type;break;case r.Card:this.card=new C,this.card.cardholderName=null!=e.card.cardholderName?e.card.cardholderName.encryptedString:null,this.card.brand=null!=e.card.brand?e.card.brand.encryptedString:null,this.card.number=null!=e.card.number?e.card.number.encryptedString:null,this.card.expMonth=null!=e.card.expMonth?e.card.expMonth.encryptedString:null,this.card.expYear=null!=e.card.expYear?e.card.expYear.encryptedString:null,this.card.code=null!=e.card.code?e.card.code.encryptedString:null;break;case r.Identity:this.identity=new x,this.identity.title=null!=e.identity.title?e.identity.title.encryptedString:null,this.identity.firstName=null!=e.identity.firstName?e.identity.firstName.encryptedString:null,this.identity.middleName=null!=e.identity.middleName?e.identity.middleName.encryptedString:null,this.identity.lastName=null!=e.identity.lastName?e.identity.lastName.encryptedString:null,this.identity.address1=null!=e.identity.address1?e.identity.address1.encryptedString:null,this.identity.address2=null!=e.identity.address2?e.identity.address2.encryptedString:null,this.identity.address3=null!=e.identity.address3?e.identity.address3.encryptedString:null,this.identity.city=null!=e.identity.city?e.identity.city.encryptedString:null,this.identity.state=null!=e.identity.state?e.identity.state.encryptedString:null,this.identity.postalCode=null!=e.identity.postalCode?e.identity.postalCode.encryptedString:null,this.identity.country=null!=e.identity.country?e.identity.country.encryptedString:null,this.identity.company=null!=e.identity.company?e.identity.company.encryptedString:null,this.identity.email=null!=e.identity.email?e.identity.email.encryptedString:null,this.identity.phone=null!=e.identity.phone?e.identity.phone.encryptedString:null,this.identity.ssn=null!=e.identity.ssn?e.identity.ssn.encryptedString:null,this.identity.username=null!=e.identity.username?e.identity.username.encryptedString:null,this.identity.passportNumber=null!=e.identity.passportNumber?e.identity.passportNumber.encryptedString:null,this.identity.licenseNumber=null!=e.identity.licenseNumber?e.identity.licenseNumber.encryptedString:null}null!=e.fields&&(this.fields=e.fields.map((e=>{const t=new D;return t.type=e.type,t.name=e.name?e.name.encryptedString:null,t.value=e.value?e.value.encryptedString:null,t.linkedId=e.linkedId,t}))),null!=e.passwordHistory&&(this.passwordHistory=[],e.passwordHistory.forEach((e=>{this.passwordHistory.push({lastUsedDate:e.lastUsedDate,password:e.password?e.password.encryptedString:null})}))),null!=e.attachments&&(this.attachments={},this.attachments2={},e.attachments.forEach((e=>{const t=e.fileName?e.fileName.encryptedString:null;this.attachments[e.id]=t;const i=new nn;i.fileName=t,null!=e.key&&(i.key=e.key.encryptedString),this.attachments2[e.id]=i})))}}class rn extends sn{constructor(e){super(e),this.id=e.id}}class on{constructor(e,t){null!=e&&(this.ciphers=[],e.forEach((e=>{this.ciphers.push(new rn(e))}))),this.collectionIds=t}}class an{constructor(e){this.collectionIds=null==e?[]:e}}class ln{constructor(e){this.cipher=new sn(e),this.collectionIds=e.collectionIds}}class cn{constructor(e){this.cipher=new sn(e),this.collectionIds=e.collectionIds}}var dn=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},un=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},hn=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const pn=new Map([["google.com",new Set(["script.google.com"])]]);class yn{constructor(e,t,i,n,s,r,o,a){this.cryptoService=e,this.settingsService=t,this.apiService=i,this.fileUploadService=n,this.i18nService=s,this.searchService=r,this.logService=o,this.stateService=a,this.sortedCiphersCache=new Qi(this.sortCiphersByLastUsed)}getDecryptedCipherCache(){return hn(this,void 0,void 0,(function*(){return yield this.stateService.getDecryptedCiphers()}))}setDecryptedCipherCache(e){return hn(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedCiphers(e),null!=this.searchService&&(null==e?this.searchService().clearIndex():this.searchService().indexCiphers())}))}clearCache(e){return hn(this,void 0,void 0,(function*(){yield this.clearDecryptedCiphersState(e)}))}encrypt(e,t,i=null){return hn(this,void 0,void 0,(function*(){if(null!=e.id){if(null==i&&(i=yield this.get(e.id)),null!=i){const t=yield i.decrypt();if(e.passwordHistory=t.passwordHistory||[],e.type===r.Login&&t.type===r.Login)if(null!=t.login.password&&""!==t.login.password&&t.login.password!==e.login.password){const i=new Mi;i.password=t.login.password,i.lastUsedDate=e.login.passwordRevisionDate=new Date,e.passwordHistory.splice(0,0,i)}else e.login.passwordRevisionDate=t.login.passwordRevisionDate;if(t.hasFields){const i=t.fields.filter((e=>e.type===ei.Hidden&&null!=e.name&&""!==e.name&&null!=e.value&&""!==e.value)),n=null==e.fields?[]:e.fields.filter((e=>e.type===ei.Hidden&&null!=e.name&&""!==e.name));i.forEach((t=>{const i=n.find((e=>e.name===t.name));if(null==i||i.value!==t.value){const i=new Mi;i.password=t.name+": "+t.value,i.lastUsedDate=new Date,e.passwordHistory.splice(0,0,i)}}))}}null!=e.passwordHistory&&0===e.passwordHistory.length?e.passwordHistory=null:null!=e.passwordHistory&&e.passwordHistory.length>5&&(e.passwordHistory=e.passwordHistory.slice(0,5))}const n=new Ji;if(n.id=e.id,n.folderId=e.folderId,n.favorite=e.favorite,n.organizationId=e.organizationId,n.type=e.type,n.collectionIds=e.collectionIds,n.revisionDate=e.revisionDate,n.reprompt=e.reprompt,null==t&&null!=n.organizationId&&null==(t=yield this.cryptoService.getOrgKey(n.organizationId)))throw new Error("Cannot encrypt cipher for organization. No key.");return yield Promise.all([this.encryptObjProperty(e,n,{name:null,notes:null},t),this.encryptCipherData(n,e,t),this.encryptFields(e.fields,t).then((e=>{n.fields=e})),this.encryptPasswordHistories(e.passwordHistory,t).then((e=>{n.passwordHistory=e})),this.encryptAttachments(e.attachments,t).then((e=>{n.attachments=e}))]),n}))}encryptAttachments(e,t){return hn(this,void 0,void 0,(function*(){if(null==e||0===e.length)return null;const i=[],n=[];return e.forEach((e=>hn(this,void 0,void 0,(function*(){const s=new wi;s.id=e.id,s.size=e.size,s.sizeName=e.sizeName,s.url=e.url;const r=this.encryptObjProperty(e,s,{fileName:null},t).then((()=>hn(this,void 0,void 0,(function*(){null!=e.key&&(s.key=yield this.cryptoService.encrypt(e.key.key,t)),n.push(s)}))));i.push(r)})))),yield Promise.all(i),n}))}encryptFields(e,t){return hn(this,void 0,void 0,(function*(){if(!e||!e.length)return null;const i=this,n=[];return yield e.reduce(((e,s)=>hn(this,void 0,void 0,(function*(){yield e;const r=yield i.encryptField(s,t);n.push(r)}))),Promise.resolve()),n}))}encryptField(e,t){return hn(this,void 0,void 0,(function*(){const i=new Ki;return i.type=e.type,i.linkedId=e.linkedId,e.type===ei.Boolean&&"true"!==e.value&&(e.value="false"),yield this.encryptObjProperty(e,i,{name:null,value:null},t),i}))}encryptPasswordHistories(e,t){return hn(this,void 0,void 0,(function*(){if(!e||!e.length)return null;const i=this,n=[];return yield e.reduce(((e,s)=>hn(this,void 0,void 0,(function*(){yield e;const r=yield i.encryptPasswordHistory(s,t);n.push(r)}))),Promise.resolve()),n}))}encryptPasswordHistory(e,t){return hn(this,void 0,void 0,(function*(){const i=new Hi;return i.lastUsedDate=e.lastUsedDate,yield this.encryptObjProperty(e,i,{password:null},t),i}))}get(e){return hn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCiphers();if(null==t||!t.hasOwnProperty(e))return null;const i=yield this.stateService.getLocalData();return new Ji(t[e],i?i[e]:null)}))}getAll(){return hn(this,void 0,void 0,(function*(){const e=yield this.stateService.getLocalData(),t=yield this.stateService.getEncryptedCiphers(),i=[];for(const n in t)t.hasOwnProperty(n)&&i.push(new Ji(t[n],e?e[n]:null));return i}))}getAllDecrypted(){var e;return hn(this,void 0,void 0,(function*(){const t=yield this.stateService.getUserId();if(null!=(yield this.getDecryptedCipherCache()))return null!=this.searchService&&(null!==(e=this.searchService().indexedEntityId)&&void 0!==e?e:t)!==t&&(yield this.searchService().indexCiphers(t,yield this.getDecryptedCipherCache())),yield this.getDecryptedCipherCache();const i=[];if(!(yield this.cryptoService.hasKey()))throw new Error("No key.");const n=[];return(yield this.getAll()).forEach((e=>hn(this,void 0,void 0,(function*(){n.push(e.decrypt().then((e=>i.push(e))))})))),yield Promise.all(n),i.sort(this.getLocaleSortingFunction()),yield this.setDecryptedCipherCache(i),i}))}getAllDecryptedForGrouping(e,t=!0){return hn(this,void 0,void 0,(function*(){return(yield this.getAllDecrypted()).filter((i=>!i.isDeleted&&(!(!t||i.folderId!==e)||!t&&null!=i.collectionIds&&i.collectionIds.indexOf(e)>-1)))}))}getAllDecryptedForUrl(e,t,i=null){return hn(this,void 0,void 0,(function*(){if(null==e&&null==t)return Promise.resolve([]);const n=f.getDomain(e),s=null==n?Promise.resolve([]):(0,ii.z)(this.settingsService.settings$).then((e=>{var t;let i=[];return null===(t=e.equivalentDomains)||void 0===t||t.forEach((e=>{e.length&&e.indexOf(n)>=0&&(i=i.concat(e))})),i.length||i.push(n),i})),o=yield Promise.all([s,this.getAllDecrypted()]),a=o[0],l=o[1];return null==i&&null==(i=yield this.stateService.getDefaultUriMatch())&&(i=ti.Domain),l.filter((s=>{if(null!=s.deletedDate)return!1;if(null!=t&&t.indexOf(s.type)>-1)return!0;if(null!=e&&s.type===r.Login&&null!=s.login.uris)for(let t=0;t<s.login.uris.length;t++){const r=s.login.uris[t];if(null==r.uri)continue;switch(null==r.match?i:r.match){case ti.Domain:if(null!=n&&null!=r.domain&&a.indexOf(r.domain)>-1){if(!pn.has(r.domain))return!0;{const t=f.getHost(e);if(!pn.get(r.domain).has(t))return!0}}break;case ti.Host:{const t=f.getHost(e);if(null!=t&&t===f.getHost(r.uri))return!0;break}case ti.Exact:if(e===r.uri)return!0;break;case ti.StartsWith:if(e.startsWith(r.uri))return!0;break;case ti.RegularExpression:try{if(new RegExp(r.uri,"i").test(e))return!0}catch(e){this.logService.error(e)}case ti.Never:}}return!1}))}))}getAllFromApiForOrganization(e){return hn(this,void 0,void 0,(function*(){const t=yield this.apiService.getCiphersOrganization(e);if(null!=t&&null!=t.data&&t.data.length){const e=[],i=[];return t.data.forEach((t=>{const n=new hi(t),s=new Ji(n);i.push(s.decrypt().then((t=>e.push(t))))})),yield Promise.all(i),e.sort(this.getLocaleSortingFunction()),e}return[]}))}getLastUsedForUrl(e,t=!1){return hn(this,void 0,void 0,(function*(){return this.getCipherForUrl(e,!0,!1,t)}))}getLastLaunchedForUrl(e,t=!1){return hn(this,void 0,void 0,(function*(){return this.getCipherForUrl(e,!1,!0,t)}))}getNextCipherForUrl(e){return hn(this,void 0,void 0,(function*(){return this.getCipherForUrl(e,!1,!1,!1)}))}updateLastUsedIndexForUrl(e){this.sortedCiphersCache.updateLastUsedIndex(e)}updateLastUsedDate(e){return hn(this,void 0,void 0,(function*(){let t=yield this.stateService.getLocalData();t||(t={}),t[e]?t[e].lastUsedDate=(new Date).getTime():t[e]={lastUsedDate:(new Date).getTime()},yield this.stateService.setLocalData(t);const i=yield this.stateService.getDecryptedCiphers();if(i){for(let n=0;n<i.length;n++){const s=i[n];if(s.id===e){s.localData=t[e];break}}yield this.stateService.setDecryptedCiphers(i)}}))}updateLastLaunchedDate(e){return hn(this,void 0,void 0,(function*(){let t=yield this.stateService.getLocalData();t||(t={}),t[e]?t[e].lastLaunched=(new Date).getTime():t[e]={lastUsedDate:(new Date).getTime()},yield this.stateService.setLocalData(t);const i=yield this.stateService.getDecryptedCiphers();if(i){for(let n=0;n<i.length;n++){const s=i[n];if(s.id===e){s.localData=t[e];break}}yield this.stateService.setDecryptedCiphers(i)}}))}saveNeverDomain(e){return hn(this,void 0,void 0,(function*(){if(null==e)return;let t=yield this.stateService.getNeverDomains();t||(t={}),t[e]=null,yield this.stateService.setNeverDomains(t)}))}saveWithServer(e){return hn(this,void 0,void 0,(function*(){let t;if(null==e.id){if(null!=e.collectionIds){const i=new ln(e);t=yield this.apiService.postCipherCreate(i)}else{const i=new sn(e);t=yield this.apiService.postCipher(i)}e.id=t.id}else{const i=new sn(e);t=yield this.apiService.putCipher(e.id,i)}const i=new hi(t,e.collectionIds);yield this.upsert(i)}))}shareWithServer(e,t,i){return hn(this,void 0,void 0,(function*(){const n=[];null!=e.attachments&&e.attachments.forEach((i=>{null==i.key&&n.push(this.shareAttachmentWithServer(i,e.id,t))})),yield Promise.all(n),e.organizationId=t,e.collectionIds=i;const s=yield this.encrypt(e),r=new cn(s),o=yield this.apiService.putShareCipher(e.id,r),a=new hi(o,i);yield this.upsert(a)}))}shareManyWithServer(e,t,i){return hn(this,void 0,void 0,(function*(){const n=[],s=[];for(const r of e)r.organizationId=t,r.collectionIds=i,n.push(this.encrypt(r).then((e=>{s.push(e)})));yield Promise.all(n);const r=new on(s,i);try{yield this.apiService.putShareCiphers(r)}catch(t){for(const t of e)t.organizationId=null,t.collectionIds=null;throw t}yield this.upsert(s.map((e=>e.toCipherData())))}))}saveAttachmentWithServer(e,t,i=!1){return new Promise(((n,s)=>{const r=new FileReader;r.readAsArrayBuffer(t),r.onload=r=>hn(this,void 0,void 0,(function*(){try{const s=yield this.saveAttachmentRawWithServer(e,t.name,r.target.result,i);n(s)}catch(e){s(e)}})),r.onerror=()=>{s("Error reading file.")}}))}saveAttachmentRawWithServer(e,t,i,n=!1){return hn(this,void 0,void 0,(function*(){const s=yield this.cryptoService.getOrgKey(e.organizationId),r=yield this.cryptoService.encrypt(t,s),o=yield this.cryptoService.makeEncKey(s),a=yield this.cryptoService.encryptToBytes(i,o[0]),l={key:o[1].encryptedString,fileName:r.encryptedString,fileSize:a.buffer.byteLength,adminRequest:n};let c;try{const t=yield this.apiService.postCipherAttachment(e.id,l);c=n?t.cipherMiniResponse:t.cipherResponse,yield this.fileUploadService.uploadCipherAttachment(n,t,r,a)}catch(t){if(!(t instanceof ee&&404===t.statusCode||405===t.statusCode))throw t instanceof ee?new Error(t.getSingleMessage()):t;c=yield this.legacyServerAttachmentFileUpload(n,e.id,r,a,o[1])}const d=new hi(c,e.collectionIds);return n||(yield this.upsert(d)),new Ji(d)}))}legacyServerAttachmentFileUpload(e,t,i,n,s){return hn(this,void 0,void 0,(function*(){const r=new FormData;try{const e=new Blob([n.buffer],{type:"application/octet-stream"});r.append("key",s.encryptedString),r.append("data",e,i.encryptedString)}catch(e){if(!f.isNode||f.isBrowser)throw e;r.append("key",s.encryptedString),r.append("data",Buffer.from(n.buffer),{filepath:i.encryptedString,contentType:"application/octet-stream"})}let o;try{o=e?yield this.apiService.postCipherAttachmentAdminLegacy(t,r):yield this.apiService.postCipherAttachmentLegacy(t,r)}catch(e){throw new Error(e.getSingleMessage())}return o}))}saveCollectionsWithServer(e){return hn(this,void 0,void 0,(function*(){const t=new an(e.collectionIds);yield this.apiService.putCipherCollections(e.id,t);const i=e.toCipherData();yield this.upsert(i)}))}upsert(e){return hn(this,void 0,void 0,(function*(){let t=yield this.stateService.getEncryptedCiphers();if(null==t&&(t={}),e instanceof hi){const i=e;t[i.id]=i}else e.forEach((e=>{t[e.id]=e}));yield this.replace(t)}))}replace(e){return hn(this,void 0,void 0,(function*(){yield this.clearDecryptedCiphersState(),yield this.stateService.setEncryptedCiphers(e)}))}clear(e){return hn(this,void 0,void 0,(function*(){yield this.clearEncryptedCiphersState(e),yield this.clearCache(e)}))}moveManyWithServer(e,t){return hn(this,void 0,void 0,(function*(){yield this.apiService.putMoveCiphers(new en(e,t));let i=yield this.stateService.getEncryptedCiphers();null==i&&(i={}),e.forEach((e=>{i.hasOwnProperty(e)&&(i[e].folderId=t)})),yield this.clearCache(),yield this.stateService.setEncryptedCiphers(i)}))}delete(e){return hn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCiphers();if(null!=t){if("string"==typeof e){if(null==t[e])return;delete t[e]}else e.forEach((e=>{delete t[e]}));yield this.clearCache(),yield this.stateService.setEncryptedCiphers(t)}}))}deleteWithServer(e){return hn(this,void 0,void 0,(function*(){yield this.apiService.deleteCipher(e),yield this.delete(e)}))}deleteManyWithServer(e){return hn(this,void 0,void 0,(function*(){yield this.apiService.deleteManyCiphers(new Zi(e)),yield this.delete(e)}))}deleteAttachment(e,t){return hn(this,void 0,void 0,(function*(){const i=yield this.stateService.getEncryptedCiphers();if(null!=i&&i.hasOwnProperty(e)&&null!=i[e].attachments){for(let n=0;n<i[e].attachments.length;n++)i[e].attachments[n].id===t&&i[e].attachments.splice(n,1);yield this.clearCache(),yield this.stateService.setEncryptedCiphers(i)}}))}deleteAttachmentWithServer(e,t){return hn(this,void 0,void 0,(function*(){try{yield this.apiService.deleteCipherAttachment(e,t)}catch(e){return Promise.reject(e.getSingleMessage())}yield this.deleteAttachment(e,t)}))}sortCiphersByLastUsed(e,t){const i=e.localData&&e.localData.lastUsedDate?e.localData.lastUsedDate:null,n=t.localData&&t.localData.lastUsedDate?t.localData.lastUsedDate:null,s=null!=i&&null!=n;return s&&i<n?1:null!=i&&null==n||s&&i>n?-1:null!=n&&null==i?1:0}sortCiphersByLastUsedThenName(e,t){const i=this.sortCiphersByLastUsed(e,t);return 0!==i?i:this.getLocaleSortingFunction()(e,t)}getLocaleSortingFunction(){return(e,t)=>{let i=e.name,n=t.name;if(null==i&&null!=n)return-1;if(null!=i&&null==n)return 1;if(null==i&&null==n)return 0;const s=this.i18nService.collator?this.i18nService.collator.compare(i,n):i.localeCompare(n);return 0!==s||e.type!==r.Login||t.type!==r.Login?s:(null!=e.login.username&&(i+=e.login.username),null!=t.login.username&&(n+=t.login.username),this.i18nService.collator?this.i18nService.collator.compare(i,n):i.localeCompare(n))}}softDelete(e){return hn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCiphers();if(null==t)return;const i=e=>{null!=t[e]&&(t[e].deletedDate=(new Date).toISOString())};"string"==typeof e?i(e):e.forEach(i),yield this.clearCache(),yield this.stateService.setEncryptedCiphers(t)}))}softDeleteWithServer(e){return hn(this,void 0,void 0,(function*(){yield this.apiService.putDeleteCipher(e),yield this.softDelete(e)}))}softDeleteManyWithServer(e){return hn(this,void 0,void 0,(function*(){yield this.apiService.putDeleteManyCiphers(new Zi(e)),yield this.softDelete(e)}))}restore(e){return hn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCiphers();if(null==t)return;const i=e=>{null!=t[e.id]&&(t[e.id].deletedDate=null,t[e.id].revisionDate=e.revisionDate)};e.constructor.name===Array.name?e.forEach(i):i(e),yield this.clearCache(),yield this.stateService.setEncryptedCiphers(t)}))}restoreWithServer(e){return hn(this,void 0,void 0,(function*(){const t=yield this.apiService.putRestoreCipher(e);yield this.restore({id:e,revisionDate:t.revisionDate})}))}restoreManyWithServer(e){return hn(this,void 0,void 0,(function*(){const t=yield this.apiService.putRestoreManyCiphers(new tn(e)),i=[];for(const e of t.data)i.push({id:e.id,revisionDate:e.revisionDate});yield this.restore(i)}))}shareAttachmentWithServer(e,t,i){return hn(this,void 0,void 0,(function*(){const n=yield this.apiService.nativeFetch(new Request(e.url,{cache:"no-store"}));if(200!==n.status)throw Error("Failed to download attachment: "+n.status.toString());const s=yield $i.fromResponse(n),r=yield this.cryptoService.decryptFromBytes(s,null),o=yield this.cryptoService.getOrgKey(i),a=yield this.cryptoService.encrypt(e.fileName,o),l=yield this.cryptoService.makeEncKey(o),c=yield this.cryptoService.encryptToBytes(r,l[0]),d=new FormData;try{const e=new Blob([c.buffer],{type:"application/octet-stream"});d.append("key",l[1].encryptedString),d.append("data",e,a.encryptedString)}catch(e){if(!f.isNode||f.isBrowser)throw e;d.append("key",l[1].encryptedString),d.append("data",Buffer.from(c.buffer),{filepath:a.encryptedString,contentType:"application/octet-stream"})}try{yield this.apiService.postShareCipherAttachment(t,e.id,d,i)}catch(e){throw new Error(e.getSingleMessage())}}))}encryptObjProperty(e,t,i,n){return hn(this,void 0,void 0,(function*(){const s=[],r=this;for(const o in i)i.hasOwnProperty(o)&&function(t,o){const a=Promise.resolve().then((()=>{const s=e[i[t]||t];return s&&""!==s?r.cryptoService.encrypt(s,n):null})).then((e=>{o[t]=e}));s.push(a)}(o,t);yield Promise.all(s)}))}encryptCipherData(e,t,i){return hn(this,void 0,void 0,(function*(){switch(e.type){case r.Login:if(e.login=new Vi,e.login.passwordRevisionDate=t.login.passwordRevisionDate,e.login.autofillOnPageLoad=t.login.autofillOnPageLoad,yield this.encryptObjProperty(t.login,e.login,{username:null,password:null,totp:null},i),null!=t.login.uris){e.login.uris=[];for(let n=0;n<t.login.uris.length;n++){const s=new ji;s.match=t.login.uris[n].match,yield this.encryptObjProperty(t.login.uris[n],s,{uri:null},i),e.login.uris.push(s)}}return;case r.SecureNote:return e.secureNote=new qi,void(e.secureNote.type=t.secureNote.type);case r.Card:return e.card=new Di,void(yield this.encryptObjProperty(t.card,e.card,{cardholderName:null,brand:null,number:null,expMonth:null,expYear:null,code:null},i));case r.Identity:return e.identity=new _i,void(yield this.encryptObjProperty(t.identity,e.identity,{title:null,firstName:null,middleName:null,lastName:null,address1:null,address2:null,address3:null,city:null,state:null,postalCode:null,country:null,company:null,email:null,phone:null,ssn:null,username:null,passportNumber:null,licenseNumber:null},i));default:throw new Error("Unknown cipher type.")}}))}getCipherForUrl(e,t,i,n){return hn(this,void 0,void 0,(function*(){const s=n?"autofillOnPageLoad-"+e:e;if(!this.sortedCiphersCache.isCached(s)){let t=yield this.getAllDecryptedForUrl(e);if(!t)return null;if(n){const e=yield this.stateService.getAutoFillOnPageLoadDefault();if(t=t.filter((t=>t.login.autofillOnPageLoad||null==t.login.autofillOnPageLoad&&!1!==e)),0===t.length)return null}this.sortedCiphersCache.addCiphers(s,t)}return i?this.sortedCiphersCache.getLastLaunched(s):t?this.sortedCiphersCache.getLastUsed(s):this.sortedCiphersCache.getNext(s)}))}clearEncryptedCiphersState(e){return hn(this,void 0,void 0,(function*(){yield this.stateService.setEncryptedCiphers(null,{userId:e})}))}clearDecryptedCiphersState(e){return hn(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedCiphers(null,{userId:e}),this.clearSortedCiphers()}))}clearSortedCiphers(){this.sortedCiphersCache.clear()}}dn([ni((()=>"getAllDecrypted")),un("design:type",Function),un("design:paramtypes",[]),un("design:returntype",Promise)],yn.prototype,"getAllDecrypted",null);class vn{constructor(e,t,i){this.children=[],this.parent=i,this.node=e,this.node.name=t}}class gn{static nestedTraverse(e,t,i,n,s,r){if(i.length<=t)return;const o=t===i.length-1,a=i[t];for(let l=0;l<e.length;l++)if(e[l].node.name===i[t])return o&&e[l].node.id!==n.id?void e.push(new vn(n,a,s)):void gn.nestedTraverse(e[l].children,t+1,i,n,e[l].node,r);if(0===e.filter((e=>e.node.name===a)).length){if(o)return void e.push(new vn(n,a,s));const l=i[t]+r+i[t+1];gn.nestedTraverse(e,0,[l,...i.slice(t+2)],n,s,r)}}static getTreeNodeObject(e,t){for(let i=0;i<e.length;i++){if(e[i].node.id===t)return e[i];if(null!=e[i].children){const n=gn.getTreeNodeObject(e[i].children,t);if(null!==n)return n}}return null}}class mn{constructor(e){this.id=e.id,this.organizationId=e.organizationId,this.name=e.name,this.externalId=e.externalId,this.readOnly=e.readOnly}}class fn{constructor(e){this.id=null,this.organizationId=null,this.name=null,this.externalId=null,this.readOnly=null,this.hidePasswords=null,e&&(this.id=e.id,this.organizationId=e.organizationId,this.externalId=e.externalId,e instanceof bn&&(this.readOnly=e.readOnly,this.hidePasswords=e.hidePasswords))}}class bn extends vi{constructor(e){super(),null!=e&&this.buildDomainModel(this,e,{id:null,organizationId:null,name:null,externalId:null,readOnly:null,hidePasswords:null},["id","organizationId","externalId","readOnly","hidePasswords"])}decrypt(){return this.decryptObj(new fn(this),{name:null},this.organizationId)}}var wn=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Sn{constructor(e,t,i){this.cryptoService=e,this.i18nService=t,this.stateService=i}clearCache(e){return wn(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedCollections(null,{userId:e})}))}encrypt(e){return wn(this,void 0,void 0,(function*(){if(null==e.organizationId)throw new Error("Collection has no organization id.");const t=yield this.cryptoService.getOrgKey(e.organizationId);if(null==t)throw new Error("No key for this collection's organization.");const i=new bn;return i.id=e.id,i.organizationId=e.organizationId,i.readOnly=e.readOnly,i.name=yield this.cryptoService.encrypt(e.name,t),i}))}decryptMany(e){return wn(this,void 0,void 0,(function*(){if(null==e)return[];const t=[],i=[];return e.forEach((e=>{i.push(e.decrypt().then((e=>t.push(e))))})),yield Promise.all(i),t.sort(f.getSortFunction(this.i18nService,"name"))}))}get(e){return wn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCollections();return null!=t&&t.hasOwnProperty(e)?new bn(t[e]):null}))}getAll(){return wn(this,void 0,void 0,(function*(){const e=yield this.stateService.getEncryptedCollections(),t=[];for(const i in e)e.hasOwnProperty(i)&&t.push(new bn(e[i]));return t}))}getAllDecrypted(){return wn(this,void 0,void 0,(function*(){let e=yield this.stateService.getDecryptedCollections();if(null!=e)return e;if(!(yield this.cryptoService.hasKey()))throw new Error("No key.");const t=yield this.getAll();return e=yield this.decryptMany(t),yield this.stateService.setDecryptedCollections(e),e}))}getAllNested(e=null){return wn(this,void 0,void 0,(function*(){null==e&&(e=yield this.getAllDecrypted());const t=[];return e.forEach((e=>{const i=new fn;i.id=e.id,i.organizationId=e.organizationId;const n=null!=e.name?e.name.replace(/^\/+|\/+$/g,"").split("/"):[];gn.nestedTraverse(t,0,n,i,null,"/")})),t}))}getNested(e){return wn(this,void 0,void 0,(function*(){const t=yield this.getAllNested();return gn.getTreeNodeObject(t,e)}))}upsert(e){return wn(this,void 0,void 0,(function*(){let t=yield this.stateService.getEncryptedCollections();if(null==t&&(t={}),e instanceof mn){const i=e;t[i.id]=i}else e.forEach((e=>{t[e.id]=e}));yield this.replace(t)}))}replace(e){return wn(this,void 0,void 0,(function*(){yield this.clearCache(),yield this.stateService.setEncryptedCollections(e)}))}clear(e){return wn(this,void 0,void 0,(function*(){yield this.clearCache(e),yield this.stateService.setEncryptedCollections(null,{userId:e})}))}delete(e){return wn(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedCollections();null!=t&&("string"==typeof e?delete t[e]:e.forEach((e=>{delete t[e]})),yield this.replace(t))}))}}var kn;!function(e){e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warning=2]="Warning",e[e.Error=3]="Error"}(kn||(kn={}));class On{constructor(e,t=null){this.isDev=e,this.filter=t,this.timersMap=new Map}debug(e){this.isDev&&this.write(kn.Debug,e)}info(e){this.write(kn.Info,e)}warning(e){this.write(kn.Warning,e)}error(e){this.write(kn.Error,e)}write(e,t){if(null==this.filter||!this.filter(e))switch(e){case kn.Debug:case kn.Info:console.log(t);break;case kn.Warning:console.warn(t);break;case kn.Error:console.error(t)}}}class Pn{constructor(e,t){this.cryptoService=e,this.encryptService=t}attachToGlobal(e){e.bitwardenContainerService||(e.bitwardenContainerService=this)}getCryptoService(){if(null==this.cryptoService)throw new Error("ContainerService.cryptoService not initialized.");return this.cryptoService}getEncryptService(){if(null==this.encryptService)throw new Error("ContainerService.encryptService not initialized.");return this.encryptService}}class An{}var Cn=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Dn{constructor(e,t,i){this.cryptoFunctionService=e,this.logService=t,this.logMacFailures=i}encrypt(e,t){return Cn(this,void 0,void 0,(function*(){if(null==t)throw new Error("No encryption key provided.");if(null==e)return Promise.resolve(null);let i;i="string"==typeof e?f.fromUtf8ToArray(e).buffer:e;const n=yield this.aesEncrypt(i,t),s=f.fromBufferToB64(n.iv),r=f.fromBufferToB64(n.data),o=null!=n.mac?f.fromBufferToB64(n.mac):null;return new At(n.key.encType,r,s,o)}))}encryptToBytes(e,t){return Cn(this,void 0,void 0,(function*(){if(null==t)throw new Error("No encryption key provided.");const i=yield this.aesEncrypt(e,t);let n=0;null!=i.mac&&(n=i.mac.byteLength);const s=new Uint8Array(1+i.iv.byteLength+n+i.data.byteLength);return s.set([i.key.encType]),s.set(new Uint8Array(i.iv),1),null!=i.mac&&s.set(new Uint8Array(i.mac),1+i.iv.byteLength),s.set(new Uint8Array(i.data),1+i.iv.byteLength+n),new $i(s.buffer)}))}decryptToUtf8(e,t){return Cn(this,void 0,void 0,(function*(){if(null==t)throw new Error("No key provided for decryption.");if(null!=(t=this.resolveLegacyKey(t,e)).macKey&&null==(null==e?void 0:e.mac))return this.logService.error("mac required."),null;if(t.encType!==e.encryptionType)return this.logService.error("encType unavailable."),null;const i=this.cryptoFunctionService.aesDecryptFastParameters(e.data,e.iv,e.mac,t);if(null!=i.macKey&&null!=i.mac){const e=yield this.cryptoFunctionService.hmacFast(i.macData,i.macKey,"sha256");if(!(yield this.cryptoFunctionService.compareFast(i.mac,e)))return this.logMacFailed("mac failed."),null}return yield this.cryptoFunctionService.aesDecryptFast(i)}))}decryptToBytes(e,t){return Cn(this,void 0,void 0,(function*(){if(null==t)throw new Error("No encryption key provided.");if(null==e)throw new Error("Nothing provided for decryption.");if(null!=(t=this.resolveLegacyKey(t,e)).macKey&&null==e.macBytes)return null;if(t.encType!==e.encryptionType)return null;if(null!=t.macKey&&null!=e.macBytes){const i=new Uint8Array(e.ivBytes.byteLength+e.dataBytes.byteLength);i.set(new Uint8Array(e.ivBytes),0),i.set(new Uint8Array(e.dataBytes),e.ivBytes.byteLength);const n=yield this.cryptoFunctionService.hmac(i.buffer,t.macKey,"sha256");if(null===n)return null;if(!(yield this.cryptoFunctionService.compare(e.macBytes,n)))return this.logMacFailed("mac failed."),null}const i=yield this.cryptoFunctionService.aesDecrypt(e.dataBytes,e.ivBytes,t.encKey);return null!=i?i:null}))}aesEncrypt(e,t){return Cn(this,void 0,void 0,(function*(){const i=new An;if(i.key=t,i.iv=yield this.cryptoFunctionService.randomBytes(16),i.data=yield this.cryptoFunctionService.aesEncrypt(e,i.iv,i.key.encKey),null!=i.key.macKey){const e=new Uint8Array(i.iv.byteLength+i.data.byteLength);e.set(new Uint8Array(i.iv),0),e.set(new Uint8Array(i.data),i.iv.byteLength),i.mac=yield this.cryptoFunctionService.hmac(e.buffer,i.key.macKey,"sha256")}return i}))}logMacFailed(e){this.logMacFailures&&this.logService.error(e)}resolveLegacyKey(e,t){return t.encryptionType===bt.AesCbc128_HmacSha256_B64&&e.encType===bt.AesCbc256_B64?new Ct(e.key,bt.AesCbc128_HmacSha256_B64):e}}class xn{}class Tn{}var In=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Rn{constructor(e,t,i,n,s){this.apiService=e,this.cipherService=t,this.stateService=i,this.logService=n,this.organizationService=s,this.inited=!1}init(e){this.inited||(this.inited=!0,e&&(this.uploadEvents(),setInterval((()=>this.uploadEvents()),6e4)))}collect(e,t=null,i=!1,n=null){return In(this,void 0,void 0,(function*(){if(!(yield this.stateService.getIsAuthenticated()))return;const s=yield this.organizationService.getAll();if(null==s)return;const r=new Set(s.filter((e=>e.useEvents)).map((e=>e.id)));if(0===r.size)return;if(null!=t){const e=yield this.cipherService.get(t);if(null==e||null==e.organizationId||!r.has(e.organizationId))return}if(null!=n&&!r.has(n))return;let o=yield this.stateService.getEventCollection();null==o&&(o=[]);const a=new xn;a.type=e,a.cipherId=t,a.date=(new Date).toISOString(),a.organizationId=n,o.push(a),yield this.stateService.setEventCollection(o),i&&(yield this.uploadEvents())}))}uploadEvents(e){return In(this,void 0,void 0,(function*(){if(!(yield this.stateService.getIsAuthenticated({userId:e})))return;const t=yield this.stateService.getEventCollection({userId:e});if(null==t||0===t.length)return;const i=t.map((e=>{const t=new Tn;return t.type=e.type,t.cipherId=e.cipherId,t.date=e.date,t.organizationId=e.organizationId,t}));try{yield this.apiService.postEventsCollect(i),this.clearEvents(e)}catch(e){this.logService.error(e)}}))}clearEvents(e){return In(this,void 0,void 0,(function*(){yield this.stateService.setEventCollection(null,{userId:e})}))}}var En,Un=i(890);!function(e){e[e.PBKDF2_SHA256=0]="PBKDF2_SHA256"}(En||(En={}));En.PBKDF2_SHA256;class Fn{constructor(e){var t,i,n,s,r,o;null!=e&&(e instanceof Ci?(this.cardholderName=e.cardholderName,this.brand=e.brand,this.number=e.number,this.expMonth=e.expMonth,this.expYear=e.expYear,this.code=e.code):(this.cardholderName=null===(t=e.cardholderName)||void 0===t?void 0:t.encryptedString,this.brand=null===(i=e.brand)||void 0===i?void 0:i.encryptedString,this.number=null===(n=e.number)||void 0===n?void 0:n.encryptedString,this.expMonth=null===(s=e.expMonth)||void 0===s?void 0:s.encryptedString,this.expYear=null===(r=e.expYear)||void 0===r?void 0:r.encryptedString,this.code=null===(o=e.code)||void 0===o?void 0:o.encryptedString))}static template(){const e=new Fn;return e.cardholderName="John Doe",e.brand="visa",e.number="4242424242424242",e.expMonth="04",e.expYear="2023",e.code="123",e}static toView(e,t=new Ci){return t.cardholderName=e.cardholderName,t.brand=e.brand,t.number=e.number,t.expMonth=e.expMonth,t.expYear=e.expYear,t.code=e.code,t}static toDomain(e,t=new Di){return t.cardholderName=null!=e.cardholderName?new At(e.cardholderName):null,t.brand=null!=e.brand?new At(e.brand):null,t.number=null!=e.number?new At(e.number):null,t.expMonth=null!=e.expMonth?new At(e.expMonth):null,t.expYear=null!=e.expYear?new At(e.expYear):null,t.code=null!=e.code?new At(e.code):null,t}}class Nn{constructor(e){var t,i;null!=e&&(e instanceof xi?(this.name=e.name,this.value=e.value):(this.name=null===(t=e.name)||void 0===t?void 0:t.encryptedString,this.value=null===(i=e.value)||void 0===i?void 0:i.encryptedString),this.type=e.type,this.linkedId=e.linkedId)}static template(){const e=new Nn;return e.name="Field name",e.value="Some value",e.type=ei.Text,e}static toView(e,t=new xi){return t.type=e.type,t.value=e.value,t.name=e.name,t.linkedId=e.linkedId,t}static toDomain(e,t=new Ki){return t.type=e.type,t.value=null!=e.value?new At(e.value):null,t.name=null!=e.name?new At(e.name):null,t.linkedId=e.linkedId,t}}class zn{constructor(e){var t,i,n,s,r,o,a,l,c,d,u,h,p,y,v,g,m,f;null!=e&&(e instanceof Ri?(this.title=e.title,this.firstName=e.firstName,this.middleName=e.middleName,this.lastName=e.lastName,this.address1=e.address1,this.address2=e.address2,this.address3=e.address3,this.city=e.city,this.state=e.state,this.postalCode=e.postalCode,this.country=e.country,this.company=e.company,this.email=e.email,this.phone=e.phone,this.ssn=e.ssn,this.username=e.username,this.passportNumber=e.passportNumber,this.licenseNumber=e.licenseNumber):(this.title=null===(t=e.title)||void 0===t?void 0:t.encryptedString,this.firstName=null===(i=e.firstName)||void 0===i?void 0:i.encryptedString,this.middleName=null===(n=e.middleName)||void 0===n?void 0:n.encryptedString,this.lastName=null===(s=e.lastName)||void 0===s?void 0:s.encryptedString,this.address1=null===(r=e.address1)||void 0===r?void 0:r.encryptedString,this.address2=null===(o=e.address2)||void 0===o?void 0:o.encryptedString,this.address3=null===(a=e.address3)||void 0===a?void 0:a.encryptedString,this.city=null===(l=e.city)||void 0===l?void 0:l.encryptedString,this.state=null===(c=e.state)||void 0===c?void 0:c.encryptedString,this.postalCode=null===(d=e.postalCode)||void 0===d?void 0:d.encryptedString,this.country=null===(u=e.country)||void 0===u?void 0:u.encryptedString,this.company=null===(h=e.company)||void 0===h?void 0:h.encryptedString,this.email=null===(p=e.email)||void 0===p?void 0:p.encryptedString,this.phone=null===(y=e.phone)||void 0===y?void 0:y.encryptedString,this.ssn=null===(v=e.ssn)||void 0===v?void 0:v.encryptedString,this.username=null===(g=e.username)||void 0===g?void 0:g.encryptedString,this.passportNumber=null===(m=e.passportNumber)||void 0===m?void 0:m.encryptedString,this.licenseNumber=null===(f=e.licenseNumber)||void 0===f?void 0:f.encryptedString))}static template(){const e=new zn;return e.title="Mr",e.firstName="John",e.middleName="William",e.lastName="Doe",e.address1="123 Any St",e.address2="Apt #123",e.address3=null,e.city="New York",e.state="NY",e.postalCode="10001",e.country="US",e.company="Acme Inc.",e.email="john@company.com",e.phone="5555551234",e.ssn="000-123-4567",e.username="jdoe",e.passportNumber="US-123456789",e.licenseNumber="D123-12-123-12333",e}static toView(e,t=new Ri){return t.title=e.title,t.firstName=e.firstName,t.middleName=e.middleName,t.lastName=e.lastName,t.address1=e.address1,t.address2=e.address2,t.address3=e.address3,t.city=e.city,t.state=e.state,t.postalCode=e.postalCode,t.country=e.country,t.company=e.company,t.email=e.email,t.phone=e.phone,t.ssn=e.ssn,t.username=e.username,t.passportNumber=e.passportNumber,t.licenseNumber=e.licenseNumber,t}static toDomain(e,t=new _i){return t.title=null!=e.title?new At(e.title):null,t.firstName=null!=e.firstName?new At(e.firstName):null,t.middleName=null!=e.middleName?new At(e.middleName):null,t.lastName=null!=e.lastName?new At(e.lastName):null,t.address1=null!=e.address1?new At(e.address1):null,t.address2=null!=e.address2?new At(e.address2):null,t.address3=null!=e.address3?new At(e.address3):null,t.city=null!=e.city?new At(e.city):null,t.state=null!=e.state?new At(e.state):null,t.postalCode=null!=e.postalCode?new At(e.postalCode):null,t.country=null!=e.country?new At(e.country):null,t.company=null!=e.company?new At(e.company):null,t.email=null!=e.email?new At(e.email):null,t.phone=null!=e.phone?new At(e.phone):null,t.ssn=null!=e.ssn?new At(e.ssn):null,t.username=null!=e.username?new At(e.username):null,t.passportNumber=null!=e.passportNumber?new At(e.passportNumber):null,t.licenseNumber=null!=e.licenseNumber?new At(e.licenseNumber):null,t}}class Mn{constructor(e){var t;this.match=null,null!=e&&(this.uri=e instanceof Ui?e.uri:null===(t=e.uri)||void 0===t?void 0:t.encryptedString,this.match=e.match)}static template(){const e=new Mn;return e.uri="https://google.com",e.match=null,e}static toView(e,t=new Ui){return t.uri=e.uri,t.match=e.match,t}static toDomain(e,t=new ji){return t.uri=null!=e.uri?new At(e.uri):null,t.match=e.match,t}}class Ln{constructor(e){var t,i,n;null!=e&&(null!=e.uris&&(this.uris=e.uris.map((e=>new Mn(e)))),e instanceof zi?(this.username=e.username,this.password=e.password,this.totp=e.totp):(this.username=null===(t=e.username)||void 0===t?void 0:t.encryptedString,this.password=null===(i=e.password)||void 0===i?void 0:i.encryptedString,this.totp=null===(n=e.totp)||void 0===n?void 0:n.encryptedString))}static template(){const e=new Ln;return e.uris=[],e.username="jdoe",e.password="myp@ssword123",e.totp="JBSWY3DPEHPK3PXP",e}static toView(e,t=new zi){return null!=e.uris&&(t.uris=e.uris.map((e=>Mn.toView(e)))),t.username=e.username,t.password=e.password,t.totp=e.totp,t}static toDomain(e,t=new Vi){return null!=e.uris&&(t.uris=e.uris.map((e=>Mn.toDomain(e)))),t.username=null!=e.username?new At(e.username):null,t.password=null!=e.password?new At(e.password):null,t.totp=null!=e.totp?new At(e.totp):null,t}}var Bn,Kn;!function(e){e[e.Generic=0]="Generic"}(Bn||(Bn={}));class _n{constructor(e){null!=e&&(this.type=e.type)}static template(){const e=new _n;return e.type=Bn.Generic,e}static toView(e,t=new Li){return t.type=e.type,t}static toDomain(e,t=new qi){return t.type=e.type,t}}class jn{static template(){const e=new jn;return e.organizationId=null,e.collectionIds=null,e.folderId=null,e.type=r.Login,e.name="Item name",e.notes="Some notes about this item.",e.favorite=!1,e.fields=[],e.login=null,e.secureNote=null,e.card=null,e.identity=null,e.reprompt=s.None,e}static toView(e,t=new Bi){var i,n,o;if(t.type=e.type,t.folderId=e.folderId,null==t.organizationId&&(t.organizationId=e.organizationId),t.collectionIds||e.collectionIds){const s=new Set((null!==(i=t.collectionIds)&&void 0!==i?i:[]).concat(null!==(n=e.collectionIds)&&void 0!==n?n:[]));t.collectionIds=Array.from(s.values())}switch(t.name=e.name,t.notes=e.notes,t.favorite=e.favorite,t.reprompt=null!==(o=e.reprompt)&&void 0!==o?o:s.None,null!=e.fields&&(t.fields=e.fields.map((e=>Nn.toView(e)))),e.type){case r.Login:t.login=Ln.toView(e.login);break;case r.SecureNote:t.secureNote=_n.toView(e.secureNote);break;case r.Card:t.card=Fn.toView(e.card);break;case r.Identity:t.identity=zn.toView(e.identity)}return t}static toDomain(e,t=new Ji){var i;switch(t.type=e.type,t.folderId=e.folderId,null==t.organizationId&&(t.organizationId=e.organizationId),t.name=null!=e.name?new At(e.name):null,t.notes=null!=e.notes?new At(e.notes):null,t.favorite=e.favorite,t.reprompt=null!==(i=e.reprompt)&&void 0!==i?i:s.None,null!=e.fields&&(t.fields=e.fields.map((e=>Nn.toDomain(e)))),e.type){case r.Login:t.login=Ln.toDomain(e.login);break;case r.SecureNote:t.secureNote=_n.toDomain(e.secureNote);break;case r.Card:t.card=Fn.toDomain(e.card);break;case r.Identity:t.identity=zn.toDomain(e.identity)}return t}build(e){var t,i;switch(this.organizationId=e.organizationId,this.folderId=e.folderId,this.type=e.type,this.reprompt=e.reprompt,e instanceof Bi?(this.name=e.name,this.notes=e.notes):(this.name=null===(t=e.name)||void 0===t?void 0:t.encryptedString,this.notes=null===(i=e.notes)||void 0===i?void 0:i.encryptedString),this.favorite=e.favorite,null!=e.fields&&(this.fields=e.fields.map((e=>new Nn(e)))),e.type){case r.Login:this.login=new Ln(e.login);break;case r.SecureNote:this.secureNote=new _n(e.secureNote);break;case r.Card:this.card=new Fn(e.card);break;case r.Identity:this.identity=new zn(e.identity)}}}class Gn extends jn{build(e){this.id=e.id,super.build(e),this.collectionIds=e.collectionIds}}class Vn{static template(){const e=new Vn;return e.organizationId="00000000-0000-0000-0000-000000000000",e.name="Collection name",e.externalId=null,e}static toView(e,t=new fn){return t.name=e.name,t.externalId=e.externalId,null==t.organizationId&&(t.organizationId=e.organizationId),t}static toDomain(e,t=new bn){return t.name=null!=e.name?new At(e.name):null,t.externalId=e.externalId,null==t.organizationId&&(t.organizationId=e.organizationId),t}build(e){var t;this.organizationId=e.organizationId,this.name=e instanceof fn?e.name:null===(t=e.name)||void 0===t?void 0:t.encryptedString,this.externalId=e.externalId}}class Hn extends Vn{build(e){this.id=e.id,super.build(e)}}!function(e){e[e.User_LoggedIn=1e3]="User_LoggedIn",e[e.User_ChangedPassword=1001]="User_ChangedPassword",e[e.User_Updated2fa=1002]="User_Updated2fa",e[e.User_Disabled2fa=1003]="User_Disabled2fa",e[e.User_Recovered2fa=1004]="User_Recovered2fa",e[e.User_FailedLogIn=1005]="User_FailedLogIn",e[e.User_FailedLogIn2fa=1006]="User_FailedLogIn2fa",e[e.User_ClientExportedVault=1007]="User_ClientExportedVault",e[e.User_UpdatedTempPassword=1008]="User_UpdatedTempPassword",e[e.User_MigratedKeyToKeyConnector=1009]="User_MigratedKeyToKeyConnector",e[e.Cipher_Created=1100]="Cipher_Created",e[e.Cipher_Updated=1101]="Cipher_Updated",e[e.Cipher_Deleted=1102]="Cipher_Deleted",e[e.Cipher_AttachmentCreated=1103]="Cipher_AttachmentCreated",e[e.Cipher_AttachmentDeleted=1104]="Cipher_AttachmentDeleted",e[e.Cipher_Shared=1105]="Cipher_Shared",e[e.Cipher_UpdatedCollections=1106]="Cipher_UpdatedCollections",e[e.Cipher_ClientViewed=1107]="Cipher_ClientViewed",e[e.Cipher_ClientToggledPasswordVisible=1108]="Cipher_ClientToggledPasswordVisible",e[e.Cipher_ClientToggledHiddenFieldVisible=1109]="Cipher_ClientToggledHiddenFieldVisible",e[e.Cipher_ClientToggledCardCodeVisible=1110]="Cipher_ClientToggledCardCodeVisible",e[e.Cipher_ClientCopiedPassword=1111]="Cipher_ClientCopiedPassword",e[e.Cipher_ClientCopiedHiddenField=1112]="Cipher_ClientCopiedHiddenField",e[e.Cipher_ClientCopiedCardCode=1113]="Cipher_ClientCopiedCardCode",e[e.Cipher_ClientAutofilled=1114]="Cipher_ClientAutofilled",e[e.Cipher_SoftDeleted=1115]="Cipher_SoftDeleted",e[e.Cipher_Restored=1116]="Cipher_Restored",e[e.Cipher_ClientToggledCardNumberVisible=1117]="Cipher_ClientToggledCardNumberVisible",e[e.Collection_Created=1300]="Collection_Created",e[e.Collection_Updated=1301]="Collection_Updated",e[e.Collection_Deleted=1302]="Collection_Deleted",e[e.Group_Created=1400]="Group_Created",e[e.Group_Updated=1401]="Group_Updated",e[e.Group_Deleted=1402]="Group_Deleted",e[e.OrganizationUser_Invited=1500]="OrganizationUser_Invited",e[e.OrganizationUser_Confirmed=1501]="OrganizationUser_Confirmed",e[e.OrganizationUser_Updated=1502]="OrganizationUser_Updated",e[e.OrganizationUser_Removed=1503]="OrganizationUser_Removed",e[e.OrganizationUser_UpdatedGroups=1504]="OrganizationUser_UpdatedGroups",e[e.OrganizationUser_UnlinkedSso=1505]="OrganizationUser_UnlinkedSso",e[e.OrganizationUser_ResetPassword_Enroll=1506]="OrganizationUser_ResetPassword_Enroll",e[e.OrganizationUser_ResetPassword_Withdraw=1507]="OrganizationUser_ResetPassword_Withdraw",e[e.OrganizationUser_AdminResetPassword=1508]="OrganizationUser_AdminResetPassword",e[e.OrganizationUser_ResetSsoLink=1509]="OrganizationUser_ResetSsoLink",e[e.OrganizationUser_FirstSsoLogin=1510]="OrganizationUser_FirstSsoLogin",e[e.OrganizationUser_Revoked=1511]="OrganizationUser_Revoked",e[e.OrganizationUser_Restored=1512]="OrganizationUser_Restored",e[e.Organization_Updated=1600]="Organization_Updated",e[e.Organization_PurgedVault=1601]="Organization_PurgedVault",e[e.Organization_ClientExportedVault=1602]="Organization_ClientExportedVault",e[e.Organization_VaultAccessed=1603]="Organization_VaultAccessed",e[e.Organization_EnabledSso=1604]="Organization_EnabledSso",e[e.Organization_DisabledSso=1605]="Organization_DisabledSso",e[e.Organization_EnabledKeyConnector=1606]="Organization_EnabledKeyConnector",e[e.Organization_DisabledKeyConnector=1607]="Organization_DisabledKeyConnector",e[e.Organization_SponsorshipsSynced=1608]="Organization_SponsorshipsSynced",e[e.Policy_Updated=1700]="Policy_Updated",e[e.ProviderUser_Invited=1800]="ProviderUser_Invited",e[e.ProviderUser_Confirmed=1801]="ProviderUser_Confirmed",e[e.ProviderUser_Updated=1802]="ProviderUser_Updated",e[e.ProviderUser_Removed=1803]="ProviderUser_Removed",e[e.ProviderOrganization_Created=1900]="ProviderOrganization_Created",e[e.ProviderOrganization_Added=1901]="ProviderOrganization_Added",e[e.ProviderOrganization_Removed=1902]="ProviderOrganization_Removed",e[e.ProviderOrganization_VaultAccessed=1903]="ProviderOrganization_VaultAccessed"}(Kn||(Kn={}));class qn{constructor(e){this.message=e.humanReadableMessage,this.appIcon=e.appIcon,this.appName=e.appName,this.userId=e.userId,this.userName=e.userName,this.userEmail=e.userEmail,this.date=e.date,this.ip=e.ip,this.type=Kn[e.type],this.installationId=e.installationId}}class Wn{constructor(e){this.id=null,this.name=null,this.revisionDate=null,e&&(this.id=e.id,this.revisionDate=e.revisionDate)}static fromJSON(e){const t=null==e.revisionDate?null:new Date(e.revisionDate);return Object.assign(new Wn,e,{revisionDate:t})}}class Jn extends vi{constructor(e){super(),null!=e&&(this.buildDomainModel(this,e,{id:null,name:null},["id"]),this.revisionDate=null!=e.revisionDate?new Date(e.revisionDate):null)}decrypt(){return this.decryptObj(new Wn(this),{name:null},null)}static fromJSON(e){const t=null==e.revisionDate?null:new Date(e.revisionDate);return Object.assign(new Jn,e,{name:At.fromJSON(e.name),revisionDate:t})}}class Yn{static template(){const e=new Yn;return e.name="Folder name",e}static toView(e,t=new Wn){return t.name=e.name,t}static toDomain(e,t=new Jn){return t.name=null!=e.name?new At(e.name):null,t}build(e){var t;this.name=e instanceof Wn?e.name:null===(t=e.name)||void 0===t?void 0:t.encryptedString}}class $n extends Yn{build(e){this.id=e.id,super.build(e)}}var Qn,Xn=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Zn{constructor(e,t,i,n,s){this.folderService=e,this.cipherService=t,this.apiService=i,this.cryptoService=n,this.cryptoFunctionService=s}getExport(e="csv",t){return Xn(this,void 0,void 0,(function*(){return t?yield this.getOrganizationExport(t,e):"encrypted_json"===e?this.getEncryptedExport():this.getDecryptedExport(e)}))}getPasswordProtectedExport(e,t){return Xn(this,void 0,void 0,(function*(){const i=t?yield this.getOrganizationExport(t,"json"):yield this.getExport("json"),n=f.fromBufferToB64(yield this.cryptoFunctionService.randomBytes(16)),s=1e5,r=yield this.cryptoService.makePinKey(e,n,En.PBKDF2_SHA256,s),o=yield this.cryptoService.encrypt(f.newGuid(),r),a=yield this.cryptoService.encrypt(i,r),l={encrypted:!0,passwordProtected:!0,salt:n,kdfIterations:s,kdfType:En.PBKDF2_SHA256,encKeyValidation_DO_NOT_EDIT:o.encryptedString,data:a.encryptedString};return JSON.stringify(l,null," ")}))}getOrganizationExport(e,t="csv"){return Xn(this,void 0,void 0,(function*(){return"encrypted_json"===t?this.getOrganizationEncryptedExport(e):this.getOrganizationDecryptedExport(e,t)}))}getEventExport(e){return Xn(this,void 0,void 0,(function*(){return Un.unparse(e.map((e=>new qn(e))))}))}getFileName(e=null,t="csv"){const i=new Date;return"bitwarden"+(e?"_"+e:"")+"_export_"+(i.getFullYear()+""+this.padNumber(i.getMonth()+1,2)+this.padNumber(i.getDate(),2)+this.padNumber(i.getHours(),2)+this.padNumber(i.getMinutes(),2)+this.padNumber(i.getSeconds(),2))+"."+t}getDecryptedExport(e){return Xn(this,void 0,void 0,(function*(){let t=[],i=[];const n=[];if(n.push((0,ii.z)(this.folderService.folderViews$).then((e=>{t=e}))),n.push(this.cipherService.getAllDecrypted().then((e=>{i=e.filter((e=>null==e.deletedDate))}))),yield Promise.all(n),"csv"===e){const e=new Map;t.forEach((t=>{null!=t.id&&e.set(t.id,t)}));const n=[];return i.forEach((t=>{if(t.type!==r.Login&&t.type!==r.SecureNote)return;if(null!=t.organizationId)return;const i={};i.folder=null!=t.folderId&&e.has(t.folderId)?e.get(t.folderId).name:null,i.favorite=t.favorite?1:null,this.buildCommonCipher(i,t),n.push(i)})),Un.unparse(n)}{const e={encrypted:!1,folders:[],items:[]};return t.forEach((t=>{if(null==t.id)return;const i=new $n;i.build(t),e.folders.push(i)})),i.forEach((t=>{if(null!=t.organizationId)return;const i=new Gn;i.build(t),i.collectionIds=null,e.items.push(i)})),JSON.stringify(e,null," ")}}))}getEncryptedExport(){return Xn(this,void 0,void 0,(function*(){let e=[],t=[];const i=[];i.push((0,ii.z)(this.folderService.folders$).then((t=>{e=t}))),i.push(this.cipherService.getAll().then((e=>{t=e.filter((e=>null==e.deletedDate))}))),yield Promise.all(i);const n={encrypted:!0,encKeyValidation_DO_NOT_EDIT:(yield this.cryptoService.encrypt(f.newGuid())).encryptedString,folders:[],items:[]};return e.forEach((e=>{if(null==e.id)return;const t=new $n;t.build(e),n.folders.push(t)})),t.forEach((e=>{if(null!=e.organizationId)return;const t=new Gn;t.build(e),t.collectionIds=null,n.items.push(t)})),JSON.stringify(n,null," ")}))}getOrganizationDecryptedExport(e,t){return Xn(this,void 0,void 0,(function*(){const i=[],n=[],s=[];if(s.push(this.apiService.getOrganizationExport(e).then((e=>{const t=[];return null!=e&&(null!=e.collections&&null!=e.collections.data&&e.collections.data.length>0&&e.collections.data.forEach((e=>{const n=new bn(new mn(e));t.push(n.decrypt().then((e=>{i.push(e)})))})),null!=e.ciphers&&null!=e.ciphers.data&&e.ciphers.data.length>0&&e.ciphers.data.filter((e=>null===e.deletedDate)).forEach((e=>{const i=new Ji(new hi(e));t.push(i.decrypt().then((e=>{n.push(e)})))}))),Promise.all(t)}))),yield Promise.all(s),"csv"===t){const e=new Map;i.forEach((t=>{e.set(t.id,t)}));const t=[];return n.forEach((i=>{if(i.type!==r.Login&&i.type!==r.SecureNote)return;const n={collections:[]};null!=i.collectionIds&&(n.collections=i.collectionIds.filter((t=>e.has(t))).map((t=>e.get(t).name))),this.buildCommonCipher(n,i),t.push(n)})),Un.unparse(t)}{const e={encrypted:!1,collections:[],items:[]};return i.forEach((t=>{const i=new Hn;i.build(t),e.collections.push(i)})),n.forEach((t=>{const i=new Gn;i.build(t),e.items.push(i)})),JSON.stringify(e,null," ")}}))}getOrganizationEncryptedExport(e){return Xn(this,void 0,void 0,(function*(){const t=[],i=[],n=[];n.push(this.apiService.getCollections(e).then((e=>(null!=e&&null!=e.data&&e.data.length>0&&e.data.forEach((e=>{const i=new bn(new mn(e));t.push(i)})),Promise.all([]))))),n.push(this.apiService.getCiphersOrganization(e).then((e=>(null!=e&&null!=e.data&&e.data.length>0&&e.data.filter((e=>null===e.deletedDate)).forEach((e=>{const t=new Ji(new hi(e));i.push(t)})),Promise.all([]))))),yield Promise.all(n);const s=yield this.cryptoService.getOrgKey(e),r={encrypted:!0,encKeyValidation_DO_NOT_EDIT:(yield this.cryptoService.encrypt(f.newGuid(),s)).encryptedString,collections:[],items:[]};return t.forEach((e=>{const t=new Hn;t.build(e),r.collections.push(t)})),i.forEach((e=>{const t=new Gn;t.build(e),r.items.push(t)})),JSON.stringify(r,null," ")}))}padNumber(e,t,i="0"){const n=e.toString();return n.length>=t?n:new Array(t-n.length+1).join(i)+n}buildCommonCipher(e,t){switch(e.type=null,e.name=t.name,e.notes=t.notes,e.fields=null,e.reprompt=t.reprompt,e.login_uri=null,e.login_username=null,e.login_password=null,e.login_totp=null,t.fields&&t.fields.forEach((t=>{e.fields?e.fields+="\n":e.fields="",e.fields+=(t.name||"")+": "+t.value})),t.type){case r.Login:e.type="login",e.login_username=t.login.username,e.login_password=t.login.password,e.login_totp=t.login.totp,t.login.uris&&(e.login_uri=[],t.login.uris.forEach((t=>{e.login_uri.push(t.uri)})));break;case r.SecureNote:e.type="note";break;default:return}return e}}!function(e){e[e.Direct=0]="Direct",e[e.Azure=1]="Azure"}(Qn||(Qn={}));var es=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ts{constructor(e){this.logService=e}upload(e,t,i){return es(this,void 0,void 0,(function*(){return t.buffer.byteLength<=268435456?yield this.azureUploadBlob(e,t):yield this.azureUploadBlocks(e,t,i)}))}azureUploadBlob(e,t){return es(this,void 0,void 0,(function*(){const i=f.getUrl(e),n=new Headers({"x-ms-date":(new Date).toUTCString(),"x-ms-version":i.searchParams.get("sv"),"Content-Length":t.buffer.byteLength.toString(),"x-ms-blob-type":"BlockBlob"}),s=new Request(e,{body:t.buffer,cache:"no-store",method:"PUT",headers:n}),r=yield fetch(s);if(201!==r.status)throw new Error(`Failed to create Azure blob: ${r.status}`)}))}azureUploadBlocks(e,t,i){return es(this,void 0,void 0,(function*(){const n=f.getUrl(e),s=this.getMaxBlockSize(n.searchParams.get("sv"));let r=0;const o=Math.ceil(t.buffer.byteLength/s),a=[];if(o>5e4)throw new Error("Cannot upload file, exceeds maximum size of "+5e4*s);try{for(;r<o;){e=yield this.renewUrlIfNecessary(e,i);const n=f.getUrl(e),o=this.encodedBlockId(r);n.searchParams.append("comp","block"),n.searchParams.append("blockid",o);const l=r*s,c=t.buffer.slice(l,l+s),d=new Headers({"x-ms-date":(new Date).toUTCString(),"x-ms-version":n.searchParams.get("sv"),"Content-Length":c.byteLength.toString()}),u=new Request(n.toString(),{body:c,cache:"no-store",method:"PUT",headers:d}),h=yield fetch(u);if(201!==h.status){const e=`Unsuccessful block PUT. Received status ${h.status}`;throw this.logService.error(e+"\n"+(yield h.json())),new Error(e)}a.push(o),r++}e=yield this.renewUrlIfNecessary(e,i);const n=f.getUrl(e),l=this.blockListXml(a);n.searchParams.append("comp","blocklist");const c=new Headers({"x-ms-date":(new Date).toUTCString(),"x-ms-version":n.searchParams.get("sv"),"Content-Length":l.length.toString()}),d=new Request(n.toString(),{body:l,cache:"no-store",method:"PUT",headers:c}),u=yield fetch(d);if(201!==u.status){const e=`Unsuccessful block list PUT. Received status ${u.status}`;throw this.logService.error(e+"\n"+(yield u.json())),new Error(e)}}catch(e){throw e}}))}renewUrlIfNecessary(e,t){var i;return es(this,void 0,void 0,(function*(){const n=f.getUrl(e),s=new Date(null!==(i=n.searchParams.get("se"))&&void 0!==i?i:"");return isNaN(s.getTime())&&s.setTime(Date.now()+36e5),s.getTime()<Date.now()+1e3?yield t():e}))}encodedBlockId(e){const t=("000000000000000000000000000000000000000000000000"+e.toString()).slice(-48);return f.fromUtf8ToB64(t)}blockListXml(e){let t='<?xml version="1.0" encoding="utf-8"?><BlockList>';return e.forEach((e=>{t+=`<Latest>${e}</Latest>`})),t+="</BlockList>",t}getMaxBlockSize(e){return is.compare(e,"2019-12-12")>=0?4194304e3:is.compare(e,"2016-05-31")>=0?104857600:4194304}}class is{constructor(e){this.year=0,this.month=0,this.day=0;try{const t=e.split("-").map((e=>Number.parseInt(e,10)));this.year=t[0],this.month=t[1],this.day=t[2]}catch(e){}}static compare(e,t){return"string"==typeof e&&(e=new is(e)),"string"==typeof t&&(t=new is(t)),e.year!==t.year?e.year-t.year:e.month!==t.month?e.month-t.month:e.day!==t.day?e.day-t.day:0}compare(e){return is.compare(this,e)}}var ns=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ss{upload(e,t,i){return ns(this,void 0,void 0,(function*(){const n=new FormData;try{const i=new Blob([t.buffer],{type:"application/octet-stream"});n.append("data",i,e)}catch(i){if(!f.isNode||f.isBrowser)throw i;n.append("data",Buffer.from(t.buffer),{filepath:e,contentType:"application/octet-stream"})}yield i(n)}))}}var rs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class os{constructor(e,t){this.logService=e,this.apiService=t,this.azureFileUploadService=new ts(e),this.bitwardenFileUploadService=new ss}uploadSendFile(e,t,i){return rs(this,void 0,void 0,(function*(){try{switch(e.fileUploadType){case Qn.Direct:yield this.bitwardenFileUploadService.upload(t.encryptedString,i,(t=>this.apiService.postSendFile(e.sendResponse.id,e.sendResponse.file.id,t)));break;case Qn.Azure:{const t=()=>rs(this,void 0,void 0,(function*(){return(yield this.apiService.renewSendFileUploadUrl(e.sendResponse.id,e.sendResponse.file.id)).url}));yield this.azureFileUploadService.upload(e.url,i,t);break}default:throw new Error("Unknown file upload type")}}catch(t){throw yield this.apiService.deleteSend(e.sendResponse.id),t}}))}uploadCipherAttachment(e,t,i,n){return rs(this,void 0,void 0,(function*(){const s=e?t.cipherMiniResponse:t.cipherResponse;try{switch(t.fileUploadType){case Qn.Direct:yield this.bitwardenFileUploadService.upload(i.encryptedString,n,(e=>this.apiService.postAttachmentFile(s.id,t.attachmentId,e)));break;case Qn.Azure:{const e=()=>rs(this,void 0,void 0,(function*(){return(yield this.apiService.renewAttachmentUploadUrl(s.id,t.attachmentId)).url}));yield this.azureFileUploadService.upload(t.url,n,e);break}default:throw new Error("Unknown file upload type.")}}catch(i){throw e?yield this.apiService.deleteCipherAttachmentAdmin(s.id,t.attachmentId):yield this.apiService.deleteCipherAttachment(s.id,t.attachmentId),i}}))}}class as{constructor(e){this.name=e.name,this.id=e.id,this.revisionDate=e.revisionDate}}class ls{constructor(e){this.name=e.name?e.name.encryptedString:null}}var cs,ds=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class us{constructor(e,t){this.folderService=e,this.apiService=t}save(e){return ds(this,void 0,void 0,(function*(){const t=new ls(e);let i;null==e.id?(i=yield this.postFolder(t),e.id=i.id):i=yield this.putFolder(e.id,t);const n=new as(i);yield this.folderService.upsert(n)}))}delete(e){return ds(this,void 0,void 0,(function*(){yield this.deleteFolder(e),yield this.folderService.delete(e)}))}get(e){return ds(this,void 0,void 0,(function*(){const t=yield this.apiService.send("GET","/folders/"+e,null,!0,!0);return new He(t)}))}postFolder(e){return ds(this,void 0,void 0,(function*(){const t=yield this.apiService.send("POST","/folders",e,!0,!0);return new He(t)}))}putFolder(e,t){return ds(this,void 0,void 0,(function*(){const i=yield this.apiService.send("PUT","/folders/"+e,t,!0,!0);return new He(i)}))}deleteFolder(e){return this.apiService.send("DELETE","/folders/"+e,null,!0,!1)}}!function(e){e[e.Owner=0]="Owner",e[e.Admin=1]="Admin",e[e.User=2]="User",e[e.Manager=3]="Manager",e[e.Custom=4]="Custom"}(cs||(cs={}));class hs{constructor(e,t,i,n,s){this.key=e,this.kdf=t,this.kdfIterations=i,this.orgIdentifier=n,this.keys=s}}class ps{constructor(e){this.key=e}}var ys=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class vs{constructor(e,t,i,n,s,r,o,a){this.stateService=e,this.cryptoService=t,this.apiService=i,this.tokenService=n,this.logService=s,this.organizationService=r,this.cryptoFunctionService=o,this.logoutCallback=a}setUsesKeyConnector(e){return this.stateService.setUsesKeyConnector(e)}getUsesKeyConnector(){return ys(this,void 0,void 0,(function*(){return yield this.stateService.getUsesKeyConnector()}))}userNeedsMigration(){return ys(this,void 0,void 0,(function*(){const e=yield this.tokenService.getIsExternal(),t=null!=(yield this.getManagingOrganization()),i=!(yield this.getUsesKeyConnector());return e&&t&&i}))}migrateUser(){return ys(this,void 0,void 0,(function*(){const e=yield this.getManagingOrganization(),t=yield this.cryptoService.getKey(),i=new ps(t.encKeyB64);try{yield this.apiService.postUserKeyToKeyConnector(e.keyConnectorUrl,i)}catch(e){this.handleKeyConnectorError(e)}yield this.apiService.postConvertToKeyConnector()}))}getAndSetKey(e){return ys(this,void 0,void 0,(function*(){try{const t=yield this.apiService.getUserKeyFromKeyConnector(e),i=f.fromB64ToArray(t.key),n=new Ct(i);yield this.cryptoService.setKey(n)}catch(e){this.handleKeyConnectorError(e)}}))}getManagingOrganization(){return ys(this,void 0,void 0,(function*(){return(yield this.organizationService.getAll()).find((e=>e.keyConnectorEnabled&&e.type!==cs.Admin&&e.type!==cs.Owner&&!e.isProviderUser))}))}convertNewSsoUserToKeyConnector(e,t){return ys(this,void 0,void 0,(function*(){const{kdf:i,kdfIterations:n,keyConnectorUrl:s}=e,r=yield this.cryptoFunctionService.randomBytes(64),o=yield this.cryptoService.makeKey(f.fromBufferToB64(r),yield this.tokenService.getEmail(),i,n),a=new ps(o.encKeyB64);yield this.cryptoService.setKey(o);const l=yield this.cryptoService.makeEncKey(o);yield this.cryptoService.setEncKey(l[1].encryptedString);const[c,d]=yield this.cryptoService.makeKeyPair();try{yield this.apiService.postUserKeyToKeyConnector(s,a)}catch(e){this.handleKeyConnectorError(e)}const u=new Mt(c,d.encryptedString),h=new hs(l[1].encryptedString,i,n,t,u);yield this.apiService.postSetKeyConnectorKey(h)}))}setConvertAccountRequired(e){return ys(this,void 0,void 0,(function*(){yield this.stateService.setConvertAccountToKeyConnector(e)}))}getConvertAccountRequired(){return ys(this,void 0,void 0,(function*(){return yield this.stateService.getConvertAccountToKeyConnector()}))}removeConvertAccountRequired(){return ys(this,void 0,void 0,(function*(){yield this.stateService.setConvertAccountToKeyConnector(null)}))}clear(){return ys(this,void 0,void 0,(function*(){yield this.removeConvertAccountRequired()}))}handleKeyConnectorError(e){throw this.logService.error(e),null!=this.logoutCallback&&this.logoutCallback(!1),new Error("Key Connector error")}}class gs{}class ms extends gs{}var fs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class bs extends gs{constructor(){super(...arguments),this.store=new Map}get(e){if(this.store.has(e)){const t=this.store.get(e);return Promise.resolve(t)}return Promise.resolve(null)}has(e){return fs(this,void 0,void 0,(function*(){return null!=this.get(e)}))}save(e,t){return null==t?this.remove(e):(this.store.set(e,t),Promise.resolve())}remove(e){return this.store.delete(e),Promise.resolve()}}var ws,Ss=i(50263),ks=i(5085),Os=i(35098);!function(e){e[e.SyncCipherUpdate=0]="SyncCipherUpdate",e[e.SyncCipherCreate=1]="SyncCipherCreate",e[e.SyncLoginDelete=2]="SyncLoginDelete",e[e.SyncFolderDelete=3]="SyncFolderDelete",e[e.SyncCiphers=4]="SyncCiphers",e[e.SyncVault=5]="SyncVault",e[e.SyncOrgKeys=6]="SyncOrgKeys",e[e.SyncFolderCreate=7]="SyncFolderCreate",e[e.SyncFolderUpdate=8]="SyncFolderUpdate",e[e.SyncCipherDelete=9]="SyncCipherDelete",e[e.SyncSettings=10]="SyncSettings",e[e.LogOut=11]="LogOut",e[e.SyncSendCreate=12]="SyncSendCreate",e[e.SyncSendUpdate=13]="SyncSendUpdate",e[e.SyncSendDelete=14]="SyncSendDelete",e[e.AuthRequest=15]="AuthRequest",e[e.AuthRequestResponse=16]="AuthRequestResponse"}(ws||(ws={}));class Ps extends O{constructor(e){super(e),this.contextId=this.getResponseProperty("ContextId"),this.type=this.getResponseProperty("Type");const t=this.getResponseProperty("Payload");switch(this.type){case ws.SyncCipherCreate:case ws.SyncCipherDelete:case ws.SyncCipherUpdate:case ws.SyncLoginDelete:this.payload=new As(t);break;case ws.SyncFolderCreate:case ws.SyncFolderDelete:case ws.SyncFolderUpdate:this.payload=new Cs(t);break;case ws.SyncVault:case ws.SyncCiphers:case ws.SyncOrgKeys:case ws.SyncSettings:case ws.LogOut:this.payload=new Ds(t);break;case ws.SyncSendCreate:case ws.SyncSendUpdate:case ws.SyncSendDelete:this.payload=new xs(t);break;case ws.AuthRequest:case ws.AuthRequestResponse:this.payload=new Ts(t)}}}class As extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.organizationId=this.getResponseProperty("OrganizationId"),this.collectionIds=this.getResponseProperty("CollectionIds"),this.revisionDate=new Date(this.getResponseProperty("RevisionDate"))}}class Cs extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.revisionDate=new Date(this.getResponseProperty("RevisionDate"))}}class Ds extends O{constructor(e){super(e),this.userId=this.getResponseProperty("UserId"),this.date=new Date(this.getResponseProperty("Date"))}}class xs extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId"),this.revisionDate=new Date(this.getResponseProperty("RevisionDate"))}}class Ts extends O{constructor(e){super(e),this.id=this.getResponseProperty("Id"),this.userId=this.getResponseProperty("UserId")}}var Is,Rs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Es{constructor(e,t,i,n,s,r,o,a){this.syncService=e,this.appIdService=t,this.apiService=i,this.environmentService=n,this.logoutCallback=s,this.logService=r,this.stateService=o,this.authService=a,this.connected=!1,this.inited=!1,this.inactive=!1,this.reconnectTimer=null,this.environmentService.urls.subscribe((()=>{this.inited&&this.init()}))}init(){return Rs(this,void 0,void 0,(function*(){this.inited=!1,this.url=this.environmentService.getNotificationsUrl(),"https://-"!==this.url&&(null!=this.signalrConnection&&(this.signalrConnection.off("ReceiveMessage"),this.signalrConnection.off("Heartbeat"),yield this.signalrConnection.stop(),this.connected=!1,this.signalrConnection=null),this.signalrConnection=(new Ss.s).withUrl(this.url+"/hub",{accessTokenFactory:()=>this.apiService.getActiveBearerToken(),skipNegotiation:!0,transport:ks.n.WebSockets}).withHubProtocol(new Os.e).build(),this.signalrConnection.on("ReceiveMessage",(e=>this.processNotification(new Ps(e)))),this.signalrConnection.on("Heartbeat",(e=>{})),this.signalrConnection.onclose((()=>{this.connected=!1,this.reconnect(!0)})),this.inited=!0,(yield this.isAuthedAndUnlocked())&&(yield this.reconnect(!1)))}))}updateConnection(e=!1){return Rs(this,void 0,void 0,(function*(){if(this.inited)try{(yield this.isAuthedAndUnlocked())?yield this.reconnect(e):yield this.signalrConnection.stop()}catch(e){this.logService.error(e.toString())}}))}reconnectFromActivity(){return Rs(this,void 0,void 0,(function*(){this.inactive=!1,this.inited&&!this.connected&&(yield this.reconnect(!0))}))}disconnectFromInactivity(){return Rs(this,void 0,void 0,(function*(){this.inactive=!0,this.inited&&this.connected&&(yield this.signalrConnection.stop())}))}processNotification(e){return Rs(this,void 0,void 0,(function*(){const t=yield this.appIdService.getAppId();if(null==e||e.contextId===t)return;const i=yield this.stateService.getIsAuthenticated(),n=e.payload.userId||e.payload.UserId,s=yield this.stateService.getUserId();if(!i||null==n||n===s)switch(e.type){case ws.SyncCipherCreate:case ws.SyncCipherUpdate:yield this.syncService.syncUpsertCipher(e.payload,e.type===ws.SyncCipherUpdate);break;case ws.SyncCipherDelete:case ws.SyncLoginDelete:yield this.syncService.syncDeleteCipher(e.payload);break;case ws.SyncFolderCreate:case ws.SyncFolderUpdate:yield this.syncService.syncUpsertFolder(e.payload,e.type===ws.SyncFolderUpdate);break;case ws.SyncFolderDelete:yield this.syncService.syncDeleteFolder(e.payload);break;case ws.SyncVault:case ws.SyncCiphers:case ws.SyncSettings:i&&(yield this.syncService.fullSync(!1));break;case ws.SyncOrgKeys:i&&(yield this.syncService.fullSync(!0),yield this.signalrConnection.stop());break;case ws.LogOut:i&&this.logoutCallback(!0);break;case ws.SyncSendCreate:case ws.SyncSendUpdate:yield this.syncService.syncUpsertSend(e.payload,e.type===ws.SyncSendUpdate);break;case ws.SyncSendDelete:yield this.syncService.syncDeleteSend(e.payload)}}))}reconnect(e){return Rs(this,void 0,void 0,(function*(){if(null!=this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.connected||!this.inited||this.inactive)return;if(yield this.isAuthedAndUnlocked()){try{yield this.signalrConnection.start(),this.connected=!0,e&&(yield this.syncService.fullSync(!1))}catch(e){this.logService.error(e)}this.connected||(this.reconnectTimer=setTimeout((()=>this.reconnect(e)),this.random(12e4,3e5)))}}))}isAuthedAndUnlocked(){return Rs(this,void 0,void 0,(function*(){return(yield this.authService.getAuthStatus())>=n.Unlocked}))}random(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}}!function(e){e[e.Invited=0]="Invited",e[e.Accepted=1]="Accepted",e[e.Confirmed=2]="Confirmed",e[e.Revoked=-1]="Revoked"}(Is||(Is={}));class Us{constructor(e){null!=e&&(this.id=e.id,this.name=e.name,this.status=e.status,this.type=e.type,this.enabled=e.enabled,this.usePolicies=e.usePolicies,this.useGroups=e.useGroups,this.useDirectory=e.useDirectory,this.useEvents=e.useEvents,this.useTotp=e.useTotp,this.use2fa=e.use2fa,this.useApi=e.useApi,this.useSso=e.useSso,this.useKeyConnector=e.useKeyConnector,this.useScim=e.useScim,this.useResetPassword=e.useResetPassword,this.selfHost=e.selfHost,this.usersGetPremium=e.usersGetPremium,this.seats=e.seats,this.maxCollections=e.maxCollections,this.maxStorageGb=e.maxStorageGb,this.ssoBound=e.ssoBound,this.identifier=e.identifier,this.permissions=e.permissions,this.resetPasswordEnrolled=e.resetPasswordEnrolled,this.userId=e.userId,this.hasPublicAndPrivateKeys=e.hasPublicAndPrivateKeys,this.providerId=e.providerId,this.providerName=e.providerName,this.isProviderUser=e.isProviderUser,this.familySponsorshipFriendlyName=e.familySponsorshipFriendlyName,this.familySponsorshipAvailable=e.familySponsorshipAvailable,this.planProductType=e.planProductType,this.keyConnectorEnabled=e.keyConnectorEnabled,this.keyConnectorUrl=e.keyConnectorUrl,this.familySponsorshipLastSyncDate=e.familySponsorshipLastSyncDate,this.familySponsorshipValidUntil=e.familySponsorshipValidUntil,this.familySponsorshipToDelete=e.familySponsorshipToDelete)}get canAccess(){return this.type===cs.Owner||this.enabled&&this.status===Is.Confirmed}get isManager(){return this.type===cs.Manager||this.type===cs.Owner||this.type===cs.Admin}get isAdmin(){return this.type===cs.Owner||this.type===cs.Admin}get isOwner(){return this.type===cs.Owner||this.isProviderUser}get canAccessEventLogs(){return(this.isAdmin||this.permissions.accessEventLogs)&&this.useEvents}get canAccessImportExport(){return this.isAdmin||this.permissions.accessImportExport}get canAccessReports(){return this.isAdmin||this.permissions.accessReports}get canCreateNewCollections(){var e;return this.isManager||(null!==(e=this.permissions.createNewCollections)&&void 0!==e?e:this.permissions.manageAllCollections)}get canEditAnyCollection(){var e;return this.isAdmin||(null!==(e=this.permissions.editAnyCollection)&&void 0!==e?e:this.permissions.manageAllCollections)}get canDeleteAnyCollection(){var e;return this.isAdmin||(null!==(e=this.permissions.deleteAnyCollection)&&void 0!==e?e:this.permissions.manageAllCollections)}get canViewAllCollections(){return this.canCreateNewCollections||this.canEditAnyCollection||this.canDeleteAnyCollection}get canEditAssignedCollections(){var e;return this.isManager||(null!==(e=this.permissions.editAssignedCollections)&&void 0!==e?e:this.permissions.manageAssignedCollections)}get canDeleteAssignedCollections(){var e;return this.isManager||(null!==(e=this.permissions.deleteAssignedCollections)&&void 0!==e?e:this.permissions.manageAssignedCollections)}get canViewAssignedCollections(){return this.canDeleteAssignedCollections||this.canEditAssignedCollections}get canManageGroups(){return(this.isAdmin||this.permissions.manageGroups)&&this.useGroups}get canManageSso(){return(this.isAdmin||this.permissions.manageSso)&&this.useSso}get canManageScim(){return(this.isAdmin||this.permissions.manageScim)&&this.useScim}get canManagePolicies(){return(this.isAdmin||this.permissions.managePolicies)&&this.usePolicies}get canManageUsers(){return this.isAdmin||this.permissions.manageUsers}get canManageUsersPassword(){return this.isAdmin||this.permissions.manageResetPassword}get isExemptFromPolicies(){return this.canManagePolicies}get canManageBilling(){return this.isOwner&&(this.isProviderUser||!this.hasProvider)}get hasProvider(){return null!=this.providerId||null!=this.providerName}}var Fs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ns{constructor(e){this.stateService=e}get(e){return Fs(this,void 0,void 0,(function*(){const t=yield this.stateService.getOrganizations();return null!=t&&t.hasOwnProperty(e)?new Us(t[e]):null}))}getByIdentifier(e){return Fs(this,void 0,void 0,(function*(){const t=yield this.getAll();return null==t||0===t.length?null:t.find((t=>t.identifier===e))}))}getAll(e){return Fs(this,void 0,void 0,(function*(){const t=yield this.stateService.getOrganizations({userId:e}),i=[];for(const e in t)t.hasOwnProperty(e)&&!t[e].isProviderUser&&i.push(new Us(t[e]));return i.sort(((e,t)=>e.name.localeCompare(t.name)))}))}save(e){return Fs(this,void 0,void 0,(function*(){return yield this.stateService.setOrganizations(e)}))}canManageSponsorships(){return Fs(this,void 0,void 0,(function*(){return(yield this.getAll()).some((e=>e.familySponsorshipAvailable||null!==e.familySponsorshipFriendlyName))}))}hasOrganizations(e){return Fs(this,void 0,void 0,(function*(){return(yield this.getAll(e)).length>0}))}}var zs,Ms=i(59029);!function(e){e[e.TwoFactorAuthentication=0]="TwoFactorAuthentication",e[e.MasterPassword=1]="MasterPassword",e[e.PasswordGenerator=2]="PasswordGenerator",e[e.SingleOrg=3]="SingleOrg",e[e.RequireSso=4]="RequireSso",e[e.PersonalOwnership=5]="PersonalOwnership",e[e.DisableSend=6]="DisableSend",e[e.SendOptions=7]="SendOptions",e[e.ResetPassword=8]="ResetPassword",e[e.MaximumVaultTimeout=9]="MaximumVaultTimeout",e[e.DisablePersonalVaultExport=10]="DisablePersonalVaultExport"}(zs||(zs={}));const Ls=["abacus","abdomen","abdominal","abide","abiding","ability","ablaze","able","abnormal","abrasion","abrasive","abreast","abridge","abroad","abruptly","absence","absentee","absently","absinthe","absolute","absolve","abstain","abstract","absurd","accent","acclaim","acclimate","accompany","account","accuracy","accurate","accustom","acetone","achiness","aching","acid","acorn","acquaint","acquire","acre","acrobat","acronym","acting","action","activate","activator","active","activism","activist","activity","actress","acts","acutely","acuteness","aeration","aerobics","aerosol","aerospace","afar","affair","affected","affecting","affection","affidavit","affiliate","affirm","affix","afflicted","affluent","afford","affront","aflame","afloat","aflutter","afoot","afraid","afterglow","afterlife","aftermath","aftermost","afternoon","aged","ageless","agency","agenda","agent","aggregate","aghast","agile","agility","aging","agnostic","agonize","agonizing","agony","agreeable","agreeably","agreed","agreeing","agreement","aground","ahead","ahoy","aide","aids","aim","ajar","alabaster","alarm","albatross","album","alfalfa","algebra","algorithm","alias","alibi","alienable","alienate","aliens","alike","alive","alkaline","alkalize","almanac","almighty","almost","aloe","aloft","aloha","alone","alongside","aloof","alphabet","alright","although","altitude","alto","aluminum","alumni","always","amaretto","amaze","amazingly","amber","ambiance","ambiguity","ambiguous","ambition","ambitious","ambulance","ambush","amendable","amendment","amends","amenity","amiable","amicably","amid","amigo","amino","amiss","ammonia","ammonium","amnesty","amniotic","among","amount","amperage","ample","amplifier","amplify","amply","amuck","amulet","amusable","amused","amusement","amuser","amusing","anaconda","anaerobic","anagram","anatomist","anatomy","anchor","anchovy","ancient","android","anemia","anemic","aneurism","anew","angelfish","angelic","anger","angled","angler","angles","angling","angrily","angriness","anguished","angular","animal","animate","animating","animation","animator","anime","animosity","ankle","annex","annotate","announcer","annoying","annually","annuity","anointer","another","answering","antacid","antarctic","anteater","antelope","antennae","anthem","anthill","anthology","antibody","antics","antidote","antihero","antiquely","antiques","antiquity","antirust","antitoxic","antitrust","antiviral","antivirus","antler","antonym","antsy","anvil","anybody","anyhow","anymore","anyone","anyplace","anything","anytime","anyway","anywhere","aorta","apache","apostle","appealing","appear","appease","appeasing","appendage","appendix","appetite","appetizer","applaud","applause","apple","appliance","applicant","applied","apply","appointee","appraisal","appraiser","apprehend","approach","approval","approve","apricot","april","apron","aptitude","aptly","aqua","aqueduct","arbitrary","arbitrate","ardently","area","arena","arguable","arguably","argue","arise","armadillo","armband","armchair","armed","armful","armhole","arming","armless","armoire","armored","armory","armrest","army","aroma","arose","around","arousal","arrange","array","arrest","arrival","arrive","arrogance","arrogant","arson","art","ascend","ascension","ascent","ascertain","ashamed","ashen","ashes","ashy","aside","askew","asleep","asparagus","aspect","aspirate","aspire","aspirin","astonish","astound","astride","astrology","astronaut","astronomy","astute","atlantic","atlas","atom","atonable","atop","atrium","atrocious","atrophy","attach","attain","attempt","attendant","attendee","attention","attentive","attest","attic","attire","attitude","attractor","attribute","atypical","auction","audacious","audacity","audible","audibly","audience","audio","audition","augmented","august","authentic","author","autism","autistic","autograph","automaker","automated","automatic","autopilot","available","avalanche","avatar","avenge","avenging","avenue","average","aversion","avert","aviation","aviator","avid","avoid","await","awaken","award","aware","awhile","awkward","awning","awoke","awry","axis","babble","babbling","babied","baboon","backache","backboard","backboned","backdrop","backed","backer","backfield","backfire","backhand","backing","backlands","backlash","backless","backlight","backlit","backlog","backpack","backpedal","backrest","backroom","backshift","backside","backslid","backspace","backspin","backstab","backstage","backtalk","backtrack","backup","backward","backwash","backwater","backyard","bacon","bacteria","bacterium","badass","badge","badland","badly","badness","baffle","baffling","bagel","bagful","baggage","bagged","baggie","bagginess","bagging","baggy","bagpipe","baguette","baked","bakery","bakeshop","baking","balance","balancing","balcony","balmy","balsamic","bamboo","banana","banish","banister","banjo","bankable","bankbook","banked","banker","banking","banknote","bankroll","banner","bannister","banshee","banter","barbecue","barbed","barbell","barber","barcode","barge","bargraph","barista","baritone","barley","barmaid","barman","barn","barometer","barrack","barracuda","barrel","barrette","barricade","barrier","barstool","bartender","barterer","bash","basically","basics","basil","basin","basis","basket","batboy","batch","bath","baton","bats","battalion","battered","battering","battery","batting","battle","bauble","bazooka","blabber","bladder","blade","blah","blame","blaming","blanching","blandness","blank","blaspheme","blasphemy","blast","blatancy","blatantly","blazer","blazing","bleach","bleak","bleep","blemish","blend","bless","blighted","blimp","bling","blinked","blinker","blinking","blinks","blip","blissful","blitz","blizzard","bloated","bloating","blob","blog","bloomers","blooming","blooper","blot","blouse","blubber","bluff","bluish","blunderer","blunt","blurb","blurred","blurry","blurt","blush","blustery","boaster","boastful","boasting","boat","bobbed","bobbing","bobble","bobcat","bobsled","bobtail","bodacious","body","bogged","boggle","bogus","boil","bok","bolster","bolt","bonanza","bonded","bonding","bondless","boned","bonehead","boneless","bonelike","boney","bonfire","bonnet","bonsai","bonus","bony","boogeyman","boogieman","book","boondocks","booted","booth","bootie","booting","bootlace","bootleg","boots","boozy","borax","boring","borough","borrower","borrowing","boss","botanical","botanist","botany","botch","both","bottle","bottling","bottom","bounce","bouncing","bouncy","bounding","boundless","bountiful","bovine","boxcar","boxer","boxing","boxlike","boxy","breach","breath","breeches","breeching","breeder","breeding","breeze","breezy","brethren","brewery","brewing","briar","bribe","brick","bride","bridged","brigade","bright","brilliant","brim","bring","brink","brisket","briskly","briskness","bristle","brittle","broadband","broadcast","broaden","broadly","broadness","broadside","broadways","broiler","broiling","broken","broker","bronchial","bronco","bronze","bronzing","brook","broom","brought","browbeat","brownnose","browse","browsing","bruising","brunch","brunette","brunt","brush","brussels","brute","brutishly","bubble","bubbling","bubbly","buccaneer","bucked","bucket","buckle","buckshot","buckskin","bucktooth","buckwheat","buddhism","buddhist","budding","buddy","budget","buffalo","buffed","buffer","buffing","buffoon","buggy","bulb","bulge","bulginess","bulgur","bulk","bulldog","bulldozer","bullfight","bullfrog","bullhorn","bullion","bullish","bullpen","bullring","bullseye","bullwhip","bully","bunch","bundle","bungee","bunion","bunkbed","bunkhouse","bunkmate","bunny","bunt","busboy","bush","busily","busload","bust","busybody","buzz","cabana","cabbage","cabbie","cabdriver","cable","caboose","cache","cackle","cacti","cactus","caddie","caddy","cadet","cadillac","cadmium","cage","cahoots","cake","calamari","calamity","calcium","calculate","calculus","caliber","calibrate","calm","caloric","calorie","calzone","camcorder","cameo","camera","camisole","camper","campfire","camping","campsite","campus","canal","canary","cancel","candied","candle","candy","cane","canine","canister","cannabis","canned","canning","cannon","cannot","canola","canon","canopener","canopy","canteen","canyon","capable","capably","capacity","cape","capillary","capital","capitol","capped","capricorn","capsize","capsule","caption","captivate","captive","captivity","capture","caramel","carat","caravan","carbon","cardboard","carded","cardiac","cardigan","cardinal","cardstock","carefully","caregiver","careless","caress","caretaker","cargo","caring","carless","carload","carmaker","carnage","carnation","carnival","carnivore","carol","carpenter","carpentry","carpool","carport","carried","carrot","carrousel","carry","cartel","cartload","carton","cartoon","cartridge","cartwheel","carve","carving","carwash","cascade","case","cash","casing","casino","casket","cassette","casually","casualty","catacomb","catalog","catalyst","catalyze","catapult","cataract","catatonic","catcall","catchable","catcher","catching","catchy","caterer","catering","catfight","catfish","cathedral","cathouse","catlike","catnap","catnip","catsup","cattail","cattishly","cattle","catty","catwalk","caucasian","caucus","causal","causation","cause","causing","cauterize","caution","cautious","cavalier","cavalry","caviar","cavity","cedar","celery","celestial","celibacy","celibate","celtic","cement","census","ceramics","ceremony","certainly","certainty","certified","certify","cesarean","cesspool","chafe","chaffing","chain","chair","chalice","challenge","chamber","chamomile","champion","chance","change","channel","chant","chaos","chaperone","chaplain","chapped","chaps","chapter","character","charbroil","charcoal","charger","charging","chariot","charity","charm","charred","charter","charting","chase","chasing","chaste","chastise","chastity","chatroom","chatter","chatting","chatty","cheating","cheddar","cheek","cheer","cheese","cheesy","chef","chemicals","chemist","chemo","cherisher","cherub","chess","chest","chevron","chevy","chewable","chewer","chewing","chewy","chief","chihuahua","childcare","childhood","childish","childless","childlike","chili","chill","chimp","chip","chirping","chirpy","chitchat","chivalry","chive","chloride","chlorine","choice","chokehold","choking","chomp","chooser","choosing","choosy","chop","chosen","chowder","chowtime","chrome","chubby","chuck","chug","chummy","chump","chunk","churn","chute","cider","cilantro","cinch","cinema","cinnamon","circle","circling","circular","circulate","circus","citable","citadel","citation","citizen","citric","citrus","city","civic","civil","clad","claim","clambake","clammy","clamor","clamp","clamshell","clang","clanking","clapped","clapper","clapping","clarify","clarinet","clarity","clash","clasp","class","clatter","clause","clavicle","claw","clay","clean","clear","cleat","cleaver","cleft","clench","clergyman","clerical","clerk","clever","clicker","client","climate","climatic","cling","clinic","clinking","clip","clique","cloak","clobber","clock","clone","cloning","closable","closure","clothes","clothing","cloud","clover","clubbed","clubbing","clubhouse","clump","clumsily","clumsy","clunky","clustered","clutch","clutter","coach","coagulant","coastal","coaster","coasting","coastland","coastline","coat","coauthor","cobalt","cobbler","cobweb","cocoa","coconut","cod","coeditor","coerce","coexist","coffee","cofounder","cognition","cognitive","cogwheel","coherence","coherent","cohesive","coil","coke","cola","cold","coleslaw","coliseum","collage","collapse","collar","collected","collector","collide","collie","collision","colonial","colonist","colonize","colony","colossal","colt","coma","come","comfort","comfy","comic","coming","comma","commence","commend","comment","commerce","commode","commodity","commodore","common","commotion","commute","commuting","compacted","compacter","compactly","compactor","companion","company","compare","compel","compile","comply","component","composed","composer","composite","compost","composure","compound","compress","comprised","computer","computing","comrade","concave","conceal","conceded","concept","concerned","concert","conch","concierge","concise","conclude","concrete","concur","condense","condiment","condition","condone","conducive","conductor","conduit","cone","confess","confetti","confidant","confident","confider","confiding","configure","confined","confining","confirm","conflict","conform","confound","confront","confused","confusing","confusion","congenial","congested","congrats","congress","conical","conjoined","conjure","conjuror","connected","connector","consensus","consent","console","consoling","consonant","constable","constant","constrain","constrict","construct","consult","consumer","consuming","contact","container","contempt","contend","contented","contently","contents","contest","context","contort","contour","contrite","control","contusion","convene","convent","copartner","cope","copied","copier","copilot","coping","copious","copper","copy","coral","cork","cornball","cornbread","corncob","cornea","corned","corner","cornfield","cornflake","cornhusk","cornmeal","cornstalk","corny","coronary","coroner","corporal","corporate","corral","correct","corridor","corrode","corroding","corrosive","corsage","corset","cortex","cosigner","cosmetics","cosmic","cosmos","cosponsor","cost","cottage","cotton","couch","cough","could","countable","countdown","counting","countless","country","county","courier","covenant","cover","coveted","coveting","coyness","cozily","coziness","cozy","crabbing","crabgrass","crablike","crabmeat","cradle","cradling","crafter","craftily","craftsman","craftwork","crafty","cramp","cranberry","crane","cranial","cranium","crank","crate","crave","craving","crawfish","crawlers","crawling","crayfish","crayon","crazed","crazily","craziness","crazy","creamed","creamer","creamlike","crease","creasing","creatable","create","creation","creative","creature","credible","credibly","credit","creed","creme","creole","crepe","crept","crescent","crested","cresting","crestless","crevice","crewless","crewman","crewmate","crib","cricket","cried","crier","crimp","crimson","cringe","cringing","crinkle","crinkly","crisped","crisping","crisply","crispness","crispy","criteria","critter","croak","crock","crook","croon","crop","cross","crouch","crouton","crowbar","crowd","crown","crucial","crudely","crudeness","cruelly","cruelness","cruelty","crumb","crummiest","crummy","crumpet","crumpled","cruncher","crunching","crunchy","crusader","crushable","crushed","crusher","crushing","crust","crux","crying","cryptic","crystal","cubbyhole","cube","cubical","cubicle","cucumber","cuddle","cuddly","cufflink","culinary","culminate","culpable","culprit","cultivate","cultural","culture","cupbearer","cupcake","cupid","cupped","cupping","curable","curator","curdle","cure","curfew","curing","curled","curler","curliness","curling","curly","curry","curse","cursive","cursor","curtain","curtly","curtsy","curvature","curve","curvy","cushy","cusp","cussed","custard","custodian","custody","customary","customer","customize","customs","cut","cycle","cyclic","cycling","cyclist","cylinder","cymbal","cytoplasm","cytoplast","dab","dad","daffodil","dagger","daily","daintily","dainty","dairy","daisy","dallying","dance","dancing","dandelion","dander","dandruff","dandy","danger","dangle","dangling","daredevil","dares","daringly","darkened","darkening","darkish","darkness","darkroom","darling","darn","dart","darwinism","dash","dastardly","data","datebook","dating","daughter","daunting","dawdler","dawn","daybed","daybreak","daycare","daydream","daylight","daylong","dayroom","daytime","dazzler","dazzling","deacon","deafening","deafness","dealer","dealing","dealmaker","dealt","dean","debatable","debate","debating","debit","debrief","debtless","debtor","debug","debunk","decade","decaf","decal","decathlon","decay","deceased","deceit","deceiver","deceiving","december","decency","decent","deception","deceptive","decibel","decidable","decimal","decimeter","decipher","deck","declared","decline","decode","decompose","decorated","decorator","decoy","decrease","decree","dedicate","dedicator","deduce","deduct","deed","deem","deepen","deeply","deepness","deface","defacing","defame","default","defeat","defection","defective","defendant","defender","defense","defensive","deferral","deferred","defiance","defiant","defile","defiling","define","definite","deflate","deflation","deflator","deflected","deflector","defog","deforest","defraud","defrost","deftly","defuse","defy","degraded","degrading","degrease","degree","dehydrate","deity","dejected","delay","delegate","delegator","delete","deletion","delicacy","delicate","delicious","delighted","delirious","delirium","deliverer","delivery","delouse","delta","deluge","delusion","deluxe","demanding","demeaning","demeanor","demise","democracy","democrat","demote","demotion","demystify","denatured","deniable","denial","denim","denote","dense","density","dental","dentist","denture","deny","deodorant","deodorize","departed","departure","depict","deplete","depletion","deplored","deploy","deport","depose","depraved","depravity","deprecate","depress","deprive","depth","deputize","deputy","derail","deranged","derby","derived","desecrate","deserve","deserving","designate","designed","designer","designing","deskbound","desktop","deskwork","desolate","despair","despise","despite","destiny","destitute","destruct","detached","detail","detection","detective","detector","detention","detergent","detest","detonate","detonator","detoxify","detract","deuce","devalue","deviancy","deviant","deviate","deviation","deviator","device","devious","devotedly","devotee","devotion","devourer","devouring","devoutly","dexterity","dexterous","diabetes","diabetic","diabolic","diagnoses","diagnosis","diagram","dial","diameter","diaper","diaphragm","diary","dice","dicing","dictate","dictation","dictator","difficult","diffused","diffuser","diffusion","diffusive","dig","dilation","diligence","diligent","dill","dilute","dime","diminish","dimly","dimmed","dimmer","dimness","dimple","diner","dingbat","dinghy","dinginess","dingo","dingy","dining","dinner","diocese","dioxide","diploma","dipped","dipper","dipping","directed","direction","directive","directly","directory","direness","dirtiness","disabled","disagree","disallow","disarm","disarray","disaster","disband","disbelief","disburse","discard","discern","discharge","disclose","discolor","discount","discourse","discover","discuss","disdain","disengage","disfigure","disgrace","dish","disinfect","disjoin","disk","dislike","disliking","dislocate","dislodge","disloyal","dismantle","dismay","dismiss","dismount","disobey","disorder","disown","disparate","disparity","dispatch","dispense","dispersal","dispersed","disperser","displace","display","displease","disposal","dispose","disprove","dispute","disregard","disrupt","dissuade","distance","distant","distaste","distill","distinct","distort","distract","distress","district","distrust","ditch","ditto","ditzy","dividable","divided","dividend","dividers","dividing","divinely","diving","divinity","divisible","divisibly","division","divisive","divorcee","dizziness","dizzy","doable","docile","dock","doctrine","document","dodge","dodgy","doily","doing","dole","dollar","dollhouse","dollop","dolly","dolphin","domain","domelike","domestic","dominion","dominoes","donated","donation","donator","donor","donut","doodle","doorbell","doorframe","doorknob","doorman","doormat","doornail","doorpost","doorstep","doorstop","doorway","doozy","dork","dormitory","dorsal","dosage","dose","dotted","doubling","douche","dove","down","dowry","doze","drab","dragging","dragonfly","dragonish","dragster","drainable","drainage","drained","drainer","drainpipe","dramatic","dramatize","drank","drapery","drastic","draw","dreaded","dreadful","dreadlock","dreamboat","dreamily","dreamland","dreamless","dreamlike","dreamt","dreamy","drearily","dreary","drench","dress","drew","dribble","dried","drier","drift","driller","drilling","drinkable","drinking","dripping","drippy","drivable","driven","driver","driveway","driving","drizzle","drizzly","drone","drool","droop","drop-down","dropbox","dropkick","droplet","dropout","dropper","drove","drown","drowsily","drudge","drum","dry","dubbed","dubiously","duchess","duckbill","ducking","duckling","ducktail","ducky","duct","dude","duffel","dugout","duh","duke","duller","dullness","duly","dumping","dumpling","dumpster","duo","dupe","duplex","duplicate","duplicity","durable","durably","duration","duress","during","dusk","dust","dutiful","duty","duvet","dwarf","dweeb","dwelled","dweller","dwelling","dwindle","dwindling","dynamic","dynamite","dynasty","dyslexia","dyslexic","each","eagle","earache","eardrum","earflap","earful","earlobe","early","earmark","earmuff","earphone","earpiece","earplugs","earring","earshot","earthen","earthlike","earthling","earthly","earthworm","earthy","earwig","easeful","easel","easiest","easily","easiness","easing","eastbound","eastcoast","easter","eastward","eatable","eaten","eatery","eating","eats","ebay","ebony","ebook","ecard","eccentric","echo","eclair","eclipse","ecologist","ecology","economic","economist","economy","ecosphere","ecosystem","edge","edginess","edging","edgy","edition","editor","educated","education","educator","eel","effective","effects","efficient","effort","eggbeater","egging","eggnog","eggplant","eggshell","egomaniac","egotism","egotistic","either","eject","elaborate","elastic","elated","elbow","eldercare","elderly","eldest","electable","election","elective","elephant","elevate","elevating","elevation","elevator","eleven","elf","eligible","eligibly","eliminate","elite","elitism","elixir","elk","ellipse","elliptic","elm","elongated","elope","eloquence","eloquent","elsewhere","elude","elusive","elves","email","embargo","embark","embassy","embattled","embellish","ember","embezzle","emblaze","emblem","embody","embolism","emboss","embroider","emcee","emerald","emergency","emission","emit","emote","emoticon","emotion","empathic","empathy","emperor","emphases","emphasis","emphasize","emphatic","empirical","employed","employee","employer","emporium","empower","emptier","emptiness","empty","emu","enable","enactment","enamel","enchanted","enchilada","encircle","enclose","enclosure","encode","encore","encounter","encourage","encroach","encrust","encrypt","endanger","endeared","endearing","ended","ending","endless","endnote","endocrine","endorphin","endorse","endowment","endpoint","endurable","endurance","enduring","energetic","energize","energy","enforced","enforcer","engaged","engaging","engine","engorge","engraved","engraver","engraving","engross","engulf","enhance","enigmatic","enjoyable","enjoyably","enjoyer","enjoying","enjoyment","enlarged","enlarging","enlighten","enlisted","enquirer","enrage","enrich","enroll","enslave","ensnare","ensure","entail","entangled","entering","entertain","enticing","entire","entitle","entity","entomb","entourage","entrap","entree","entrench","entrust","entryway","entwine","enunciate","envelope","enviable","enviably","envious","envision","envoy","envy","enzyme","epic","epidemic","epidermal","epidermis","epidural","epilepsy","epileptic","epilogue","epiphany","episode","equal","equate","equation","equator","equinox","equipment","equity","equivocal","eradicate","erasable","erased","eraser","erasure","ergonomic","errand","errant","erratic","error","erupt","escalate","escalator","escapable","escapade","escapist","escargot","eskimo","esophagus","espionage","espresso","esquire","essay","essence","essential","establish","estate","esteemed","estimate","estimator","estranged","estrogen","etching","eternal","eternity","ethanol","ether","ethically","ethics","euphemism","evacuate","evacuee","evade","evaluate","evaluator","evaporate","evasion","evasive","even","everglade","evergreen","everybody","everyday","everyone","evict","evidence","evident","evil","evoke","evolution","evolve","exact","exalted","example","excavate","excavator","exceeding","exception","excess","exchange","excitable","exciting","exclaim","exclude","excluding","exclusion","exclusive","excretion","excretory","excursion","excusable","excusably","excuse","exemplary","exemplify","exemption","exerciser","exert","exes","exfoliate","exhale","exhaust","exhume","exile","existing","exit","exodus","exonerate","exorcism","exorcist","expand","expanse","expansion","expansive","expectant","expedited","expediter","expel","expend","expenses","expensive","expert","expire","expiring","explain","expletive","explicit","explode","exploit","explore","exploring","exponent","exporter","exposable","expose","exposure","express","expulsion","exquisite","extended","extending","extent","extenuate","exterior","external","extinct","extortion","extradite","extras","extrovert","extrude","extruding","exuberant","fable","fabric","fabulous","facebook","facecloth","facedown","faceless","facelift","faceplate","faceted","facial","facility","facing","facsimile","faction","factoid","factor","factsheet","factual","faculty","fade","fading","failing","falcon","fall","false","falsify","fame","familiar","family","famine","famished","fanatic","fancied","fanciness","fancy","fanfare","fang","fanning","fantasize","fantastic","fantasy","fascism","fastball","faster","fasting","fastness","faucet","favorable","favorably","favored","favoring","favorite","fax","feast","federal","fedora","feeble","feed","feel","feisty","feline","felt-tip","feminine","feminism","feminist","feminize","femur","fence","fencing","fender","ferment","fernlike","ferocious","ferocity","ferret","ferris","ferry","fervor","fester","festival","festive","festivity","fetal","fetch","fever","fiber","fiction","fiddle","fiddling","fidelity","fidgeting","fidgety","fifteen","fifth","fiftieth","fifty","figment","figure","figurine","filing","filled","filler","filling","film","filter","filth","filtrate","finale","finalist","finalize","finally","finance","financial","finch","fineness","finer","finicky","finished","finisher","finishing","finite","finless","finlike","fiscally","fit","five","flaccid","flagman","flagpole","flagship","flagstick","flagstone","flail","flakily","flaky","flame","flammable","flanked","flanking","flannels","flap","flaring","flashback","flashbulb","flashcard","flashily","flashing","flashy","flask","flatbed","flatfoot","flatly","flatness","flatten","flattered","flatterer","flattery","flattop","flatware","flatworm","flavored","flavorful","flavoring","flaxseed","fled","fleshed","fleshy","flick","flier","flight","flinch","fling","flint","flip","flirt","float","flock","flogging","flop","floral","florist","floss","flounder","flyable","flyaway","flyer","flying","flyover","flypaper","foam","foe","fog","foil","folic","folk","follicle","follow","fondling","fondly","fondness","fondue","font","food","fool","footage","football","footbath","footboard","footer","footgear","foothill","foothold","footing","footless","footman","footnote","footpad","footpath","footprint","footrest","footsie","footsore","footwear","footwork","fossil","foster","founder","founding","fountain","fox","foyer","fraction","fracture","fragile","fragility","fragment","fragrance","fragrant","frail","frame","framing","frantic","fraternal","frayed","fraying","frays","freckled","freckles","freebase","freebee","freebie","freedom","freefall","freehand","freeing","freeload","freely","freemason","freeness","freestyle","freeware","freeway","freewill","freezable","freezing","freight","french","frenzied","frenzy","frequency","frequent","fresh","fretful","fretted","friction","friday","fridge","fried","friend","frighten","frightful","frigidity","frigidly","frill","fringe","frisbee","frisk","fritter","frivolous","frolic","from","front","frostbite","frosted","frostily","frosting","frostlike","frosty","froth","frown","frozen","fructose","frugality","frugally","fruit","frustrate","frying","gab","gaffe","gag","gainfully","gaining","gains","gala","gallantly","galleria","gallery","galley","gallon","gallows","gallstone","galore","galvanize","gambling","game","gaming","gamma","gander","gangly","gangrene","gangway","gap","garage","garbage","garden","gargle","garland","garlic","garment","garnet","garnish","garter","gas","gatherer","gathering","gating","gauging","gauntlet","gauze","gave","gawk","gazing","gear","gecko","geek","geiger","gem","gender","generic","generous","genetics","genre","gentile","gentleman","gently","gents","geography","geologic","geologist","geology","geometric","geometry","geranium","gerbil","geriatric","germicide","germinate","germless","germproof","gestate","gestation","gesture","getaway","getting","getup","giant","gibberish","giblet","giddily","giddiness","giddy","gift","gigabyte","gigahertz","gigantic","giggle","giggling","giggly","gigolo","gilled","gills","gimmick","girdle","giveaway","given","giver","giving","gizmo","gizzard","glacial","glacier","glade","gladiator","gladly","glamorous","glamour","glance","glancing","glandular","glare","glaring","glass","glaucoma","glazing","gleaming","gleeful","glider","gliding","glimmer","glimpse","glisten","glitch","glitter","glitzy","gloater","gloating","gloomily","gloomy","glorified","glorifier","glorify","glorious","glory","gloss","glove","glowing","glowworm","glucose","glue","gluten","glutinous","glutton","gnarly","gnat","goal","goatskin","goes","goggles","going","goldfish","goldmine","goldsmith","golf","goliath","gonad","gondola","gone","gong","good","gooey","goofball","goofiness","goofy","google","goon","gopher","gore","gorged","gorgeous","gory","gosling","gossip","gothic","gotten","gout","gown","grab","graceful","graceless","gracious","gradation","graded","grader","gradient","grading","gradually","graduate","graffiti","grafted","grafting","grain","granddad","grandkid","grandly","grandma","grandpa","grandson","granite","granny","granola","grant","granular","grape","graph","grapple","grappling","grasp","grass","gratified","gratify","grating","gratitude","gratuity","gravel","graveness","graves","graveyard","gravitate","gravity","gravy","gray","grazing","greasily","greedily","greedless","greedy","green","greeter","greeting","grew","greyhound","grid","grief","grievance","grieving","grievous","grill","grimace","grimacing","grime","griminess","grimy","grinch","grinning","grip","gristle","grit","groggily","groggy","groin","groom","groove","grooving","groovy","grope","ground","grouped","grout","grove","grower","growing","growl","grub","grudge","grudging","grueling","gruffly","grumble","grumbling","grumbly","grumpily","grunge","grunt","guacamole","guidable","guidance","guide","guiding","guileless","guise","gulf","gullible","gully","gulp","gumball","gumdrop","gumminess","gumming","gummy","gurgle","gurgling","guru","gush","gusto","gusty","gutless","guts","gutter","guy","guzzler","gyration","habitable","habitant","habitat","habitual","hacked","hacker","hacking","hacksaw","had","haggler","haiku","half","halogen","halt","halved","halves","hamburger","hamlet","hammock","hamper","hamster","hamstring","handbag","handball","handbook","handbrake","handcart","handclap","handclasp","handcraft","handcuff","handed","handful","handgrip","handgun","handheld","handiness","handiwork","handlebar","handled","handler","handling","handmade","handoff","handpick","handprint","handrail","handsaw","handset","handsfree","handshake","handstand","handwash","handwork","handwoven","handwrite","handyman","hangnail","hangout","hangover","hangup","hankering","hankie","hanky","haphazard","happening","happier","happiest","happily","happiness","happy","harbor","hardcopy","hardcore","hardcover","harddisk","hardened","hardener","hardening","hardhat","hardhead","hardiness","hardly","hardness","hardship","hardware","hardwired","hardwood","hardy","harmful","harmless","harmonica","harmonics","harmonize","harmony","harness","harpist","harsh","harvest","hash","hassle","haste","hastily","hastiness","hasty","hatbox","hatchback","hatchery","hatchet","hatching","hatchling","hate","hatless","hatred","haunt","haven","hazard","hazelnut","hazily","haziness","hazing","hazy","headache","headband","headboard","headcount","headdress","headed","header","headfirst","headgear","heading","headlamp","headless","headlock","headphone","headpiece","headrest","headroom","headscarf","headset","headsman","headstand","headstone","headway","headwear","heap","heat","heave","heavily","heaviness","heaving","hedge","hedging","heftiness","hefty","helium","helmet","helper","helpful","helping","helpless","helpline","hemlock","hemstitch","hence","henchman","henna","herald","herbal","herbicide","herbs","heritage","hermit","heroics","heroism","herring","herself","hertz","hesitancy","hesitant","hesitate","hexagon","hexagram","hubcap","huddle","huddling","huff","hug","hula","hulk","hull","human","humble","humbling","humbly","humid","humiliate","humility","humming","hummus","humongous","humorist","humorless","humorous","humpback","humped","humvee","hunchback","hundredth","hunger","hungrily","hungry","hunk","hunter","hunting","huntress","huntsman","hurdle","hurled","hurler","hurling","hurray","hurricane","hurried","hurry","hurt","husband","hush","husked","huskiness","hut","hybrid","hydrant","hydrated","hydration","hydrogen","hydroxide","hyperlink","hypertext","hyphen","hypnoses","hypnosis","hypnotic","hypnotism","hypnotist","hypnotize","hypocrisy","hypocrite","ibuprofen","ice","iciness","icing","icky","icon","icy","idealism","idealist","idealize","ideally","idealness","identical","identify","identity","ideology","idiocy","idiom","idly","igloo","ignition","ignore","iguana","illicitly","illusion","illusive","image","imaginary","imagines","imaging","imbecile","imitate","imitation","immature","immerse","immersion","imminent","immobile","immodest","immorally","immortal","immovable","immovably","immunity","immunize","impaired","impale","impart","impatient","impeach","impeding","impending","imperfect","imperial","impish","implant","implement","implicate","implicit","implode","implosion","implosive","imply","impolite","important","importer","impose","imposing","impotence","impotency","impotent","impound","imprecise","imprint","imprison","impromptu","improper","improve","improving","improvise","imprudent","impulse","impulsive","impure","impurity","iodine","iodize","ion","ipad","iphone","ipod","irate","irk","iron","irregular","irrigate","irritable","irritably","irritant","irritate","islamic","islamist","isolated","isolating","isolation","isotope","issue","issuing","italicize","italics","item","itinerary","itunes","ivory","ivy","jab","jackal","jacket","jackknife","jackpot","jailbird","jailbreak","jailer","jailhouse","jalapeno","jam","janitor","january","jargon","jarring","jasmine","jaundice","jaunt","java","jawed","jawless","jawline","jaws","jaybird","jaywalker","jazz","jeep","jeeringly","jellied","jelly","jersey","jester","jet","jiffy","jigsaw","jimmy","jingle","jingling","jinx","jitters","jittery","job","jockey","jockstrap","jogger","jogging","john","joining","jokester","jokingly","jolliness","jolly","jolt","jot","jovial","joyfully","joylessly","joyous","joyride","joystick","jubilance","jubilant","judge","judgingly","judicial","judiciary","judo","juggle","juggling","jugular","juice","juiciness","juicy","jujitsu","jukebox","july","jumble","jumbo","jump","junction","juncture","june","junior","juniper","junkie","junkman","junkyard","jurist","juror","jury","justice","justifier","justify","justly","justness","juvenile","kabob","kangaroo","karaoke","karate","karma","kebab","keenly","keenness","keep","keg","kelp","kennel","kept","kerchief","kerosene","kettle","kick","kiln","kilobyte","kilogram","kilometer","kilowatt","kilt","kimono","kindle","kindling","kindly","kindness","kindred","kinetic","kinfolk","king","kinship","kinsman","kinswoman","kissable","kisser","kissing","kitchen","kite","kitten","kitty","kiwi","kleenex","knapsack","knee","knelt","knickers","knoll","koala","kooky","kosher","krypton","kudos","kung","labored","laborer","laboring","laborious","labrador","ladder","ladies","ladle","ladybug","ladylike","lagged","lagging","lagoon","lair","lake","lance","landed","landfall","landfill","landing","landlady","landless","landline","landlord","landmark","landmass","landmine","landowner","landscape","landside","landslide","language","lankiness","lanky","lantern","lapdog","lapel","lapped","lapping","laptop","lard","large","lark","lash","lasso","last","latch","late","lather","latitude","latrine","latter","latticed","launch","launder","laundry","laurel","lavender","lavish","laxative","lazily","laziness","lazy","lecturer","left","legacy","legal","legend","legged","leggings","legible","legibly","legislate","lego","legroom","legume","legwarmer","legwork","lemon","lend","length","lens","lent","leotard","lesser","letdown","lethargic","lethargy","letter","lettuce","level","leverage","levers","levitate","levitator","liability","liable","liberty","librarian","library","licking","licorice","lid","life","lifter","lifting","liftoff","ligament","likely","likeness","likewise","liking","lilac","lilly","lily","limb","limeade","limelight","limes","limit","limping","limpness","line","lingo","linguini","linguist","lining","linked","linoleum","linseed","lint","lion","lip","liquefy","liqueur","liquid","lisp","list","litigate","litigator","litmus","litter","little","livable","lived","lively","liver","livestock","lividly","living","lizard","lubricant","lubricate","lucid","luckily","luckiness","luckless","lucrative","ludicrous","lugged","lukewarm","lullaby","lumber","luminance","luminous","lumpiness","lumping","lumpish","lunacy","lunar","lunchbox","luncheon","lunchroom","lunchtime","lung","lurch","lure","luridness","lurk","lushly","lushness","luster","lustfully","lustily","lustiness","lustrous","lusty","luxurious","luxury","lying","lyrically","lyricism","lyricist","lyrics","macarena","macaroni","macaw","mace","machine","machinist","magazine","magenta","maggot","magical","magician","magma","magnesium","magnetic","magnetism","magnetize","magnifier","magnify","magnitude","magnolia","mahogany","maimed","majestic","majesty","majorette","majority","makeover","maker","makeshift","making","malformed","malt","mama","mammal","mammary","mammogram","manager","managing","manatee","mandarin","mandate","mandatory","mandolin","manger","mangle","mango","mangy","manhandle","manhole","manhood","manhunt","manicotti","manicure","manifesto","manila","mankind","manlike","manliness","manly","manmade","manned","mannish","manor","manpower","mantis","mantra","manual","many","map","marathon","marauding","marbled","marbles","marbling","march","mardi","margarine","margarita","margin","marigold","marina","marine","marital","maritime","marlin","marmalade","maroon","married","marrow","marry","marshland","marshy","marsupial","marvelous","marxism","mascot","masculine","mashed","mashing","massager","masses","massive","mastiff","matador","matchbook","matchbox","matcher","matching","matchless","material","maternal","maternity","math","mating","matriarch","matrimony","matrix","matron","matted","matter","maturely","maturing","maturity","mauve","maverick","maximize","maximum","maybe","mayday","mayflower","moaner","moaning","mobile","mobility","mobilize","mobster","mocha","mocker","mockup","modified","modify","modular","modulator","module","moisten","moistness","moisture","molar","molasses","mold","molecular","molecule","molehill","mollusk","mom","monastery","monday","monetary","monetize","moneybags","moneyless","moneywise","mongoose","mongrel","monitor","monkhood","monogamy","monogram","monologue","monopoly","monorail","monotone","monotype","monoxide","monsieur","monsoon","monstrous","monthly","monument","moocher","moodiness","moody","mooing","moonbeam","mooned","moonlight","moonlike","moonlit","moonrise","moonscape","moonshine","moonstone","moonwalk","mop","morale","morality","morally","morbidity","morbidly","morphine","morphing","morse","mortality","mortally","mortician","mortified","mortify","mortuary","mosaic","mossy","most","mothball","mothproof","motion","motivate","motivator","motive","motocross","motor","motto","mountable","mountain","mounted","mounting","mourner","mournful","mouse","mousiness","moustache","mousy","mouth","movable","move","movie","moving","mower","mowing","much","muck","mud","mug","mulberry","mulch","mule","mulled","mullets","multiple","multiply","multitask","multitude","mumble","mumbling","mumbo","mummified","mummify","mummy","mumps","munchkin","mundane","municipal","muppet","mural","murkiness","murky","murmuring","muscular","museum","mushily","mushiness","mushroom","mushy","music","musket","muskiness","musky","mustang","mustard","muster","mustiness","musty","mutable","mutate","mutation","mute","mutilated","mutilator","mutiny","mutt","mutual","muzzle","myself","myspace","mystified","mystify","myth","nacho","nag","nail","name","naming","nanny","nanometer","nape","napkin","napped","napping","nappy","narrow","nastily","nastiness","national","native","nativity","natural","nature","naturist","nautical","navigate","navigator","navy","nearby","nearest","nearly","nearness","neatly","neatness","nebula","nebulizer","nectar","negate","negation","negative","neglector","negligee","negligent","negotiate","nemeses","nemesis","neon","nephew","nerd","nervous","nervy","nest","net","neurology","neuron","neurosis","neurotic","neuter","neutron","never","next","nibble","nickname","nicotine","niece","nifty","nimble","nimbly","nineteen","ninetieth","ninja","nintendo","ninth","nuclear","nuclei","nucleus","nugget","nullify","number","numbing","numbly","numbness","numeral","numerate","numerator","numeric","numerous","nuptials","nursery","nursing","nurture","nutcase","nutlike","nutmeg","nutrient","nutshell","nuttiness","nutty","nuzzle","nylon","oaf","oak","oasis","oat","obedience","obedient","obituary","object","obligate","obliged","oblivion","oblivious","oblong","obnoxious","oboe","obscure","obscurity","observant","observer","observing","obsessed","obsession","obsessive","obsolete","obstacle","obstinate","obstruct","obtain","obtrusive","obtuse","obvious","occultist","occupancy","occupant","occupier","occupy","ocean","ocelot","octagon","octane","october","octopus","ogle","oil","oink","ointment","okay","old","olive","olympics","omega","omen","ominous","omission","omit","omnivore","onboard","oncoming","ongoing","onion","online","onlooker","only","onscreen","onset","onshore","onslaught","onstage","onto","onward","onyx","oops","ooze","oozy","opacity","opal","open","operable","operate","operating","operation","operative","operator","opium","opossum","opponent","oppose","opposing","opposite","oppressed","oppressor","opt","opulently","osmosis","other","otter","ouch","ought","ounce","outage","outback","outbid","outboard","outbound","outbreak","outburst","outcast","outclass","outcome","outdated","outdoors","outer","outfield","outfit","outflank","outgoing","outgrow","outhouse","outing","outlast","outlet","outline","outlook","outlying","outmatch","outmost","outnumber","outplayed","outpost","outpour","output","outrage","outrank","outreach","outright","outscore","outsell","outshine","outshoot","outsider","outskirts","outsmart","outsource","outspoken","outtakes","outthink","outward","outweigh","outwit","oval","ovary","oven","overact","overall","overarch","overbid","overbill","overbite","overblown","overboard","overbook","overbuilt","overcast","overcoat","overcome","overcook","overcrowd","overdraft","overdrawn","overdress","overdrive","overdue","overeager","overeater","overexert","overfed","overfeed","overfill","overflow","overfull","overgrown","overhand","overhang","overhaul","overhead","overhear","overheat","overhung","overjoyed","overkill","overlabor","overlaid","overlap","overlay","overload","overlook","overlord","overlying","overnight","overpass","overpay","overplant","overplay","overpower","overprice","overrate","overreach","overreact","override","overripe","overrule","overrun","overshoot","overshot","oversight","oversized","oversleep","oversold","overspend","overstate","overstay","overstep","overstock","overstuff","oversweet","overtake","overthrow","overtime","overtly","overtone","overture","overturn","overuse","overvalue","overview","overwrite","owl","oxford","oxidant","oxidation","oxidize","oxidizing","oxygen","oxymoron","oyster","ozone","paced","pacemaker","pacific","pacifier","pacifism","pacifist","pacify","padded","padding","paddle","paddling","padlock","pagan","pager","paging","pajamas","palace","palatable","palm","palpable","palpitate","paltry","pampered","pamperer","pampers","pamphlet","panama","pancake","pancreas","panda","pandemic","pang","panhandle","panic","panning","panorama","panoramic","panther","pantomime","pantry","pants","pantyhose","paparazzi","papaya","paper","paprika","papyrus","parabola","parachute","parade","paradox","paragraph","parakeet","paralegal","paralyses","paralysis","paralyze","paramedic","parameter","paramount","parasail","parasite","parasitic","parcel","parched","parchment","pardon","parish","parka","parking","parkway","parlor","parmesan","parole","parrot","parsley","parsnip","partake","parted","parting","partition","partly","partner","partridge","party","passable","passably","passage","passcode","passenger","passerby","passing","passion","passive","passivism","passover","passport","password","pasta","pasted","pastel","pastime","pastor","pastrami","pasture","pasty","patchwork","patchy","paternal","paternity","path","patience","patient","patio","patriarch","patriot","patrol","patronage","patronize","pauper","pavement","paver","pavestone","pavilion","paving","pawing","payable","payback","paycheck","payday","payee","payer","paying","payment","payphone","payroll","pebble","pebbly","pecan","pectin","peculiar","peddling","pediatric","pedicure","pedigree","pedometer","pegboard","pelican","pellet","pelt","pelvis","penalize","penalty","pencil","pendant","pending","penholder","penknife","pennant","penniless","penny","penpal","pension","pentagon","pentagram","pep","perceive","percent","perch","percolate","perennial","perfected","perfectly","perfume","periscope","perish","perjurer","perjury","perkiness","perky","perm","peroxide","perpetual","perplexed","persecute","persevere","persuaded","persuader","pesky","peso","pessimism","pessimist","pester","pesticide","petal","petite","petition","petri","petroleum","petted","petticoat","pettiness","petty","petunia","phantom","phobia","phoenix","phonebook","phoney","phonics","phoniness","phony","phosphate","photo","phrase","phrasing","placard","placate","placidly","plank","planner","plant","plasma","plaster","plastic","plated","platform","plating","platinum","platonic","platter","platypus","plausible","plausibly","playable","playback","player","playful","playgroup","playhouse","playing","playlist","playmaker","playmate","playoff","playpen","playroom","playset","plaything","playtime","plaza","pleading","pleat","pledge","plentiful","plenty","plethora","plexiglas","pliable","plod","plop","plot","plow","ploy","pluck","plug","plunder","plunging","plural","plus","plutonium","plywood","poach","pod","poem","poet","pogo","pointed","pointer","pointing","pointless","pointy","poise","poison","poker","poking","polar","police","policy","polio","polish","politely","polka","polo","polyester","polygon","polygraph","polymer","poncho","pond","pony","popcorn","pope","poplar","popper","poppy","popsicle","populace","popular","populate","porcupine","pork","porous","porridge","portable","portal","portfolio","porthole","portion","portly","portside","poser","posh","posing","possible","possibly","possum","postage","postal","postbox","postcard","posted","poster","posting","postnasal","posture","postwar","pouch","pounce","pouncing","pound","pouring","pout","powdered","powdering","powdery","power","powwow","pox","praising","prance","prancing","pranker","prankish","prankster","prayer","praying","preacher","preaching","preachy","preamble","precinct","precise","precision","precook","precut","predator","predefine","predict","preface","prefix","preflight","preformed","pregame","pregnancy","pregnant","preheated","prelaunch","prelaw","prelude","premiere","premises","premium","prenatal","preoccupy","preorder","prepaid","prepay","preplan","preppy","preschool","prescribe","preseason","preset","preshow","president","presoak","press","presume","presuming","preteen","pretended","pretender","pretense","pretext","pretty","pretzel","prevail","prevalent","prevent","preview","previous","prewar","prewashed","prideful","pried","primal","primarily","primary","primate","primer","primp","princess","print","prior","prism","prison","prissy","pristine","privacy","private","privatize","prize","proactive","probable","probably","probation","probe","probing","probiotic","problem","procedure","process","proclaim","procreate","procurer","prodigal","prodigy","produce","product","profane","profanity","professed","professor","profile","profound","profusely","progeny","prognosis","program","progress","projector","prologue","prolonged","promenade","prominent","promoter","promotion","prompter","promptly","prone","prong","pronounce","pronto","proofing","proofread","proofs","propeller","properly","property","proponent","proposal","propose","props","prorate","protector","protegee","proton","prototype","protozoan","protract","protrude","proud","provable","proved","proven","provided","provider","providing","province","proving","provoke","provoking","provolone","prowess","prowler","prowling","proximity","proxy","prozac","prude","prudishly","prune","pruning","pry","psychic","public","publisher","pucker","pueblo","pug","pull","pulmonary","pulp","pulsate","pulse","pulverize","puma","pumice","pummel","punch","punctual","punctuate","punctured","pungent","punisher","punk","pupil","puppet","puppy","purchase","pureblood","purebred","purely","pureness","purgatory","purge","purging","purifier","purify","purist","puritan","purity","purple","purplish","purposely","purr","purse","pursuable","pursuant","pursuit","purveyor","pushcart","pushchair","pusher","pushiness","pushing","pushover","pushpin","pushup","pushy","putdown","putt","puzzle","puzzling","pyramid","pyromania","python","quack","quadrant","quail","quaintly","quake","quaking","qualified","qualifier","qualify","quality","qualm","quantum","quarrel","quarry","quartered","quarterly","quarters","quartet","quench","query","quicken","quickly","quickness","quicksand","quickstep","quiet","quill","quilt","quintet","quintuple","quirk","quit","quiver","quizzical","quotable","quotation","quote","rabid","race","racing","racism","rack","racoon","radar","radial","radiance","radiantly","radiated","radiation","radiator","radio","radish","raffle","raft","rage","ragged","raging","ragweed","raider","railcar","railing","railroad","railway","raisin","rake","raking","rally","ramble","rambling","ramp","ramrod","ranch","rancidity","random","ranged","ranger","ranging","ranked","ranking","ransack","ranting","rants","rare","rarity","rascal","rash","rasping","ravage","raven","ravine","raving","ravioli","ravishing","reabsorb","reach","reacquire","reaction","reactive","reactor","reaffirm","ream","reanalyze","reappear","reapply","reappoint","reapprove","rearrange","rearview","reason","reassign","reassure","reattach","reawake","rebalance","rebate","rebel","rebirth","reboot","reborn","rebound","rebuff","rebuild","rebuilt","reburial","rebuttal","recall","recant","recapture","recast","recede","recent","recess","recharger","recipient","recital","recite","reckless","reclaim","recliner","reclining","recluse","reclusive","recognize","recoil","recollect","recolor","reconcile","reconfirm","reconvene","recopy","record","recount","recoup","recovery","recreate","rectal","rectangle","rectified","rectify","recycled","recycler","recycling","reemerge","reenact","reenter","reentry","reexamine","referable","referee","reference","refill","refinance","refined","refinery","refining","refinish","reflected","reflector","reflex","reflux","refocus","refold","reforest","reformat","reformed","reformer","reformist","refract","refrain","refreeze","refresh","refried","refueling","refund","refurbish","refurnish","refusal","refuse","refusing","refutable","refute","regain","regalia","regally","reggae","regime","region","register","registrar","registry","regress","regretful","regroup","regular","regulate","regulator","rehab","reheat","rehire","rehydrate","reimburse","reissue","reiterate","rejoice","rejoicing","rejoin","rekindle","relapse","relapsing","relatable","related","relation","relative","relax","relay","relearn","release","relenting","reliable","reliably","reliance","reliant","relic","relieve","relieving","relight","relish","relive","reload","relocate","relock","reluctant","rely","remake","remark","remarry","rematch","remedial","remedy","remember","reminder","remindful","remission","remix","remnant","remodeler","remold","remorse","remote","removable","removal","removed","remover","removing","rename","renderer","rendering","rendition","renegade","renewable","renewably","renewal","renewed","renounce","renovate","renovator","rentable","rental","rented","renter","reoccupy","reoccur","reopen","reorder","repackage","repacking","repaint","repair","repave","repaying","repayment","repeal","repeated","repeater","repent","rephrase","replace","replay","replica","reply","reporter","repose","repossess","repost","repressed","reprimand","reprint","reprise","reproach","reprocess","reproduce","reprogram","reps","reptile","reptilian","repugnant","repulsion","repulsive","repurpose","reputable","reputably","request","require","requisite","reroute","rerun","resale","resample","rescuer","reseal","research","reselect","reseller","resemble","resend","resent","reset","reshape","reshoot","reshuffle","residence","residency","resident","residual","residue","resigned","resilient","resistant","resisting","resize","resolute","resolved","resonant","resonate","resort","resource","respect","resubmit","result","resume","resupply","resurface","resurrect","retail","retainer","retaining","retake","retaliate","retention","rethink","retinal","retired","retiree","retiring","retold","retool","retorted","retouch","retrace","retract","retrain","retread","retreat","retrial","retrieval","retriever","retry","return","retying","retype","reunion","reunite","reusable","reuse","reveal","reveler","revenge","revenue","reverb","revered","reverence","reverend","reversal","reverse","reversing","reversion","revert","revisable","revise","revision","revisit","revivable","revival","reviver","reviving","revocable","revoke","revolt","revolver","revolving","reward","rewash","rewind","rewire","reword","rework","rewrap","rewrite","rhyme","ribbon","ribcage","rice","riches","richly","richness","rickety","ricotta","riddance","ridden","ride","riding","rifling","rift","rigging","rigid","rigor","rimless","rimmed","rind","rink","rinse","rinsing","riot","ripcord","ripeness","ripening","ripping","ripple","rippling","riptide","rise","rising","risk","risotto","ritalin","ritzy","rival","riverbank","riverbed","riverboat","riverside","riveter","riveting","roamer","roaming","roast","robbing","robe","robin","robotics","robust","rockband","rocker","rocket","rockfish","rockiness","rocking","rocklike","rockslide","rockstar","rocky","rogue","roman","romp","rope","roping","roster","rosy","rotten","rotting","rotunda","roulette","rounding","roundish","roundness","roundup","roundworm","routine","routing","rover","roving","royal","rubbed","rubber","rubbing","rubble","rubdown","ruby","ruckus","rudder","rug","ruined","rule","rumble","rumbling","rummage","rumor","runaround","rundown","runner","running","runny","runt","runway","rupture","rural","ruse","rush","rust","rut","sabbath","sabotage","sacrament","sacred","sacrifice","sadden","saddlebag","saddled","saddling","sadly","sadness","safari","safeguard","safehouse","safely","safeness","saffron","saga","sage","sagging","saggy","said","saint","sake","salad","salami","salaried","salary","saline","salon","saloon","salsa","salt","salutary","salute","salvage","salvaging","salvation","same","sample","sampling","sanction","sanctity","sanctuary","sandal","sandbag","sandbank","sandbar","sandblast","sandbox","sanded","sandfish","sanding","sandlot","sandpaper","sandpit","sandstone","sandstorm","sandworm","sandy","sanitary","sanitizer","sank","santa","sapling","sappiness","sappy","sarcasm","sarcastic","sardine","sash","sasquatch","sassy","satchel","satiable","satin","satirical","satisfied","satisfy","saturate","saturday","sauciness","saucy","sauna","savage","savanna","saved","savings","savior","savor","saxophone","say","scabbed","scabby","scalded","scalding","scale","scaling","scallion","scallop","scalping","scam","scandal","scanner","scanning","scant","scapegoat","scarce","scarcity","scarecrow","scared","scarf","scarily","scariness","scarring","scary","scavenger","scenic","schedule","schematic","scheme","scheming","schilling","schnapps","scholar","science","scientist","scion","scoff","scolding","scone","scoop","scooter","scope","scorch","scorebook","scorecard","scored","scoreless","scorer","scoring","scorn","scorpion","scotch","scoundrel","scoured","scouring","scouting","scouts","scowling","scrabble","scraggly","scrambled","scrambler","scrap","scratch","scrawny","screen","scribble","scribe","scribing","scrimmage","script","scroll","scrooge","scrounger","scrubbed","scrubber","scruffy","scrunch","scrutiny","scuba","scuff","sculptor","sculpture","scurvy","scuttle","secluded","secluding","seclusion","second","secrecy","secret","sectional","sector","secular","securely","security","sedan","sedate","sedation","sedative","sediment","seduce","seducing","segment","seismic","seizing","seldom","selected","selection","selective","selector","self","seltzer","semantic","semester","semicolon","semifinal","seminar","semisoft","semisweet","senate","senator","send","senior","senorita","sensation","sensitive","sensitize","sensually","sensuous","sepia","september","septic","septum","sequel","sequence","sequester","series","sermon","serotonin","serpent","serrated","serve","service","serving","sesame","sessions","setback","setting","settle","settling","setup","sevenfold","seventeen","seventh","seventy","severity","shabby","shack","shaded","shadily","shadiness","shading","shadow","shady","shaft","shakable","shakily","shakiness","shaking","shaky","shale","shallot","shallow","shame","shampoo","shamrock","shank","shanty","shape","shaping","share","sharpener","sharper","sharpie","sharply","sharpness","shawl","sheath","shed","sheep","sheet","shelf","shell","shelter","shelve","shelving","sherry","shield","shifter","shifting","shiftless","shifty","shimmer","shimmy","shindig","shine","shingle","shininess","shining","shiny","ship","shirt","shivering","shock","shone","shoplift","shopper","shopping","shoptalk","shore","shortage","shortcake","shortcut","shorten","shorter","shorthand","shortlist","shortly","shortness","shorts","shortwave","shorty","shout","shove","showbiz","showcase","showdown","shower","showgirl","showing","showman","shown","showoff","showpiece","showplace","showroom","showy","shrank","shrapnel","shredder","shredding","shrewdly","shriek","shrill","shrimp","shrine","shrink","shrivel","shrouded","shrubbery","shrubs","shrug","shrunk","shucking","shudder","shuffle","shuffling","shun","shush","shut","shy","siamese","siberian","sibling","siding","sierra","siesta","sift","sighing","silenced","silencer","silent","silica","silicon","silk","silliness","silly","silo","silt","silver","similarly","simile","simmering","simple","simplify","simply","sincere","sincerity","singer","singing","single","singular","sinister","sinless","sinner","sinuous","sip","siren","sister","sitcom","sitter","sitting","situated","situation","sixfold","sixteen","sixth","sixties","sixtieth","sixtyfold","sizable","sizably","size","sizing","sizzle","sizzling","skater","skating","skedaddle","skeletal","skeleton","skeptic","sketch","skewed","skewer","skid","skied","skier","skies","skiing","skilled","skillet","skillful","skimmed","skimmer","skimming","skimpily","skincare","skinhead","skinless","skinning","skinny","skintight","skipper","skipping","skirmish","skirt","skittle","skydiver","skylight","skyline","skype","skyrocket","skyward","slab","slacked","slacker","slacking","slackness","slacks","slain","slam","slander","slang","slapping","slapstick","slashed","slashing","slate","slather","slaw","sled","sleek","sleep","sleet","sleeve","slept","sliceable","sliced","slicer","slicing","slick","slider","slideshow","sliding","slighted","slighting","slightly","slimness","slimy","slinging","slingshot","slinky","slip","slit","sliver","slobbery","slogan","sloped","sloping","sloppily","sloppy","slot","slouching","slouchy","sludge","slug","slum","slurp","slush","sly","small","smartly","smartness","smasher","smashing","smashup","smell","smelting","smile","smilingly","smirk","smite","smith","smitten","smock","smog","smoked","smokeless","smokiness","smoking","smoky","smolder","smooth","smother","smudge","smudgy","smuggler","smuggling","smugly","smugness","snack","snagged","snaking","snap","snare","snarl","snazzy","sneak","sneer","sneeze","sneezing","snide","sniff","snippet","snipping","snitch","snooper","snooze","snore","snoring","snorkel","snort","snout","snowbird","snowboard","snowbound","snowcap","snowdrift","snowdrop","snowfall","snowfield","snowflake","snowiness","snowless","snowman","snowplow","snowshoe","snowstorm","snowsuit","snowy","snub","snuff","snuggle","snugly","snugness","speak","spearfish","spearhead","spearman","spearmint","species","specimen","specked","speckled","specks","spectacle","spectator","spectrum","speculate","speech","speed","spellbind","speller","spelling","spendable","spender","spending","spent","spew","sphere","spherical","sphinx","spider","spied","spiffy","spill","spilt","spinach","spinal","spindle","spinner","spinning","spinout","spinster","spiny","spiral","spirited","spiritism","spirits","spiritual","splashed","splashing","splashy","splatter","spleen","splendid","splendor","splice","splicing","splinter","splotchy","splurge","spoilage","spoiled","spoiler","spoiling","spoils","spoken","spokesman","sponge","spongy","sponsor","spoof","spookily","spooky","spool","spoon","spore","sporting","sports","sporty","spotless","spotlight","spotted","spotter","spotting","spotty","spousal","spouse","spout","sprain","sprang","sprawl","spray","spree","sprig","spring","sprinkled","sprinkler","sprint","sprite","sprout","spruce","sprung","spry","spud","spur","sputter","spyglass","squabble","squad","squall","squander","squash","squatted","squatter","squatting","squeak","squealer","squealing","squeamish","squeegee","squeeze","squeezing","squid","squiggle","squiggly","squint","squire","squirt","squishier","squishy","stability","stabilize","stable","stack","stadium","staff","stage","staging","stagnant","stagnate","stainable","stained","staining","stainless","stalemate","staleness","stalling","stallion","stamina","stammer","stamp","stand","stank","staple","stapling","starboard","starch","stardom","stardust","starfish","stargazer","staring","stark","starless","starlet","starlight","starlit","starring","starry","starship","starter","starting","startle","startling","startup","starved","starving","stash","state","static","statistic","statue","stature","status","statute","statutory","staunch","stays","steadfast","steadier","steadily","steadying","steam","steed","steep","steerable","steering","steersman","stegosaur","stellar","stem","stench","stencil","step","stereo","sterile","sterility","sterilize","sterling","sternness","sternum","stew","stick","stiffen","stiffly","stiffness","stifle","stifling","stillness","stilt","stimulant","stimulate","stimuli","stimulus","stinger","stingily","stinging","stingray","stingy","stinking","stinky","stipend","stipulate","stir","stitch","stock","stoic","stoke","stole","stomp","stonewall","stoneware","stonework","stoning","stony","stood","stooge","stool","stoop","stoplight","stoppable","stoppage","stopped","stopper","stopping","stopwatch","storable","storage","storeroom","storewide","storm","stout","stove","stowaway","stowing","straddle","straggler","strained","strainer","straining","strangely","stranger","strangle","strategic","strategy","stratus","straw","stray","streak","stream","street","strength","strenuous","strep","stress","stretch","strewn","stricken","strict","stride","strife","strike","striking","strive","striving","strobe","strode","stroller","strongbox","strongly","strongman","struck","structure","strudel","struggle","strum","strung","strut","stubbed","stubble","stubbly","stubborn","stucco","stuck","student","studied","studio","study","stuffed","stuffing","stuffy","stumble","stumbling","stump","stung","stunned","stunner","stunning","stunt","stupor","sturdily","sturdy","styling","stylishly","stylist","stylized","stylus","suave","subarctic","subatomic","subdivide","subdued","subduing","subfloor","subgroup","subheader","subject","sublease","sublet","sublevel","sublime","submarine","submerge","submersed","submitter","subpanel","subpar","subplot","subprime","subscribe","subscript","subsector","subside","subsiding","subsidize","subsidy","subsoil","subsonic","substance","subsystem","subtext","subtitle","subtly","subtotal","subtract","subtype","suburb","subway","subwoofer","subzero","succulent","such","suction","sudden","sudoku","suds","sufferer","suffering","suffice","suffix","suffocate","suffrage","sugar","suggest","suing","suitable","suitably","suitcase","suitor","sulfate","sulfide","sulfite","sulfur","sulk","sullen","sulphate","sulphuric","sultry","superbowl","superglue","superhero","superior","superjet","superman","supermom","supernova","supervise","supper","supplier","supply","support","supremacy","supreme","surcharge","surely","sureness","surface","surfacing","surfboard","surfer","surgery","surgical","surging","surname","surpass","surplus","surprise","surreal","surrender","surrogate","surround","survey","survival","survive","surviving","survivor","sushi","suspect","suspend","suspense","sustained","sustainer","swab","swaddling","swagger","swampland","swan","swapping","swarm","sway","swear","sweat","sweep","swell","swept","swerve","swifter","swiftly","swiftness","swimmable","swimmer","swimming","swimsuit","swimwear","swinger","swinging","swipe","swirl","switch","swivel","swizzle","swooned","swoop","swoosh","swore","sworn","swung","sycamore","sympathy","symphonic","symphony","symptom","synapse","syndrome","synergy","synopses","synopsis","synthesis","synthetic","syrup","system","t-shirt","tabasco","tabby","tableful","tables","tablet","tableware","tabloid","tackiness","tacking","tackle","tackling","tacky","taco","tactful","tactical","tactics","tactile","tactless","tadpole","taekwondo","tag","tainted","take","taking","talcum","talisman","tall","talon","tamale","tameness","tamer","tamper","tank","tanned","tannery","tanning","tantrum","tapeless","tapered","tapering","tapestry","tapioca","tapping","taps","tarantula","target","tarmac","tarnish","tarot","tartar","tartly","tartness","task","tassel","taste","tastiness","tasting","tasty","tattered","tattle","tattling","tattoo","taunt","tavern","thank","that","thaw","theater","theatrics","thee","theft","theme","theology","theorize","thermal","thermos","thesaurus","these","thesis","thespian","thicken","thicket","thickness","thieving","thievish","thigh","thimble","thing","think","thinly","thinner","thinness","thinning","thirstily","thirsting","thirsty","thirteen","thirty","thong","thorn","those","thousand","thrash","thread","threaten","threefold","thrift","thrill","thrive","thriving","throat","throbbing","throng","throttle","throwaway","throwback","thrower","throwing","thud","thumb","thumping","thursday","thus","thwarting","thyself","tiara","tibia","tidal","tidbit","tidiness","tidings","tidy","tiger","tighten","tightly","tightness","tightrope","tightwad","tigress","tile","tiling","till","tilt","timid","timing","timothy","tinderbox","tinfoil","tingle","tingling","tingly","tinker","tinkling","tinsel","tinsmith","tint","tinwork","tiny","tipoff","tipped","tipper","tipping","tiptoeing","tiptop","tiring","tissue","trace","tracing","track","traction","tractor","trade","trading","tradition","traffic","tragedy","trailing","trailside","train","traitor","trance","tranquil","transfer","transform","translate","transpire","transport","transpose","trapdoor","trapeze","trapezoid","trapped","trapper","trapping","traps","trash","travel","traverse","travesty","tray","treachery","treading","treadmill","treason","treat","treble","tree","trekker","tremble","trembling","tremor","trench","trend","trespass","triage","trial","triangle","tribesman","tribunal","tribune","tributary","tribute","triceps","trickery","trickily","tricking","trickle","trickster","tricky","tricolor","tricycle","trident","tried","trifle","trifocals","trillion","trilogy","trimester","trimmer","trimming","trimness","trinity","trio","tripod","tripping","triumph","trivial","trodden","trolling","trombone","trophy","tropical","tropics","trouble","troubling","trough","trousers","trout","trowel","truce","truck","truffle","trump","trunks","trustable","trustee","trustful","trusting","trustless","truth","try","tubby","tubeless","tubular","tucking","tuesday","tug","tuition","tulip","tumble","tumbling","tummy","turban","turbine","turbofan","turbojet","turbulent","turf","turkey","turmoil","turret","turtle","tusk","tutor","tutu","tux","tweak","tweed","tweet","tweezers","twelve","twentieth","twenty","twerp","twice","twiddle","twiddling","twig","twilight","twine","twins","twirl","twistable","twisted","twister","twisting","twisty","twitch","twitter","tycoon","tying","tyke","udder","ultimate","ultimatum","ultra","umbilical","umbrella","umpire","unabashed","unable","unadorned","unadvised","unafraid","unaired","unaligned","unaltered","unarmored","unashamed","unaudited","unawake","unaware","unbaked","unbalance","unbeaten","unbend","unbent","unbiased","unbitten","unblended","unblessed","unblock","unbolted","unbounded","unboxed","unbraided","unbridle","unbroken","unbuckled","unbundle","unburned","unbutton","uncanny","uncapped","uncaring","uncertain","unchain","unchanged","uncharted","uncheck","uncivil","unclad","unclaimed","unclamped","unclasp","uncle","unclip","uncloak","unclog","unclothed","uncoated","uncoiled","uncolored","uncombed","uncommon","uncooked","uncork","uncorrupt","uncounted","uncouple","uncouth","uncover","uncross","uncrown","uncrushed","uncured","uncurious","uncurled","uncut","undamaged","undated","undaunted","undead","undecided","undefined","underage","underarm","undercoat","undercook","undercut","underdog","underdone","underfed","underfeed","underfoot","undergo","undergrad","underhand","underline","underling","undermine","undermost","underpaid","underpass","underpay","underrate","undertake","undertone","undertook","undertow","underuse","underwear","underwent","underwire","undesired","undiluted","undivided","undocked","undoing","undone","undrafted","undress","undrilled","undusted","undying","unearned","unearth","unease","uneasily","uneasy","uneatable","uneaten","unedited","unelected","unending","unengaged","unenvied","unequal","unethical","uneven","unexpired","unexposed","unfailing","unfair","unfasten","unfazed","unfeeling","unfiled","unfilled","unfitted","unfitting","unfixable","unfixed","unflawed","unfocused","unfold","unfounded","unframed","unfreeze","unfrosted","unfrozen","unfunded","unglazed","ungloved","unglue","ungodly","ungraded","ungreased","unguarded","unguided","unhappily","unhappy","unharmed","unhealthy","unheard","unhearing","unheated","unhelpful","unhidden","unhinge","unhitched","unholy","unhook","unicorn","unicycle","unified","unifier","uniformed","uniformly","unify","unimpeded","uninjured","uninstall","uninsured","uninvited","union","uniquely","unisexual","unison","unissued","unit","universal","universe","unjustly","unkempt","unkind","unknotted","unknowing","unknown","unlaced","unlatch","unlawful","unleaded","unlearned","unleash","unless","unleveled","unlighted","unlikable","unlimited","unlined","unlinked","unlisted","unlit","unlivable","unloaded","unloader","unlocked","unlocking","unlovable","unloved","unlovely","unloving","unluckily","unlucky","unmade","unmanaged","unmanned","unmapped","unmarked","unmasked","unmasking","unmatched","unmindful","unmixable","unmixed","unmolded","unmoral","unmovable","unmoved","unmoving","unnamable","unnamed","unnatural","unneeded","unnerve","unnerving","unnoticed","unopened","unopposed","unpack","unpadded","unpaid","unpainted","unpaired","unpaved","unpeeled","unpicked","unpiloted","unpinned","unplanned","unplanted","unpleased","unpledged","unplowed","unplug","unpopular","unproven","unquote","unranked","unrated","unraveled","unreached","unread","unreal","unreeling","unrefined","unrelated","unrented","unrest","unretired","unrevised","unrigged","unripe","unrivaled","unroasted","unrobed","unroll","unruffled","unruly","unrushed","unsaddle","unsafe","unsaid","unsalted","unsaved","unsavory","unscathed","unscented","unscrew","unsealed","unseated","unsecured","unseeing","unseemly","unseen","unselect","unselfish","unsent","unsettled","unshackle","unshaken","unshaved","unshaven","unsheathe","unshipped","unsightly","unsigned","unskilled","unsliced","unsmooth","unsnap","unsocial","unsoiled","unsold","unsolved","unsorted","unspoiled","unspoken","unstable","unstaffed","unstamped","unsteady","unsterile","unstirred","unstitch","unstopped","unstuck","unstuffed","unstylish","unsubtle","unsubtly","unsuited","unsure","unsworn","untagged","untainted","untaken","untamed","untangled","untapped","untaxed","unthawed","unthread","untidy","untie","until","untimed","untimely","untitled","untoasted","untold","untouched","untracked","untrained","untreated","untried","untrimmed","untrue","untruth","unturned","untwist","untying","unusable","unused","unusual","unvalued","unvaried","unvarying","unveiled","unveiling","unvented","unviable","unvisited","unvocal","unwanted","unwarlike","unwary","unwashed","unwatched","unweave","unwed","unwelcome","unwell","unwieldy","unwilling","unwind","unwired","unwitting","unwomanly","unworldly","unworn","unworried","unworthy","unwound","unwoven","unwrapped","unwritten","unzip","upbeat","upchuck","upcoming","upcountry","update","upfront","upgrade","upheaval","upheld","uphill","uphold","uplifted","uplifting","upload","upon","upper","upright","uprising","upriver","uproar","uproot","upscale","upside","upstage","upstairs","upstart","upstate","upstream","upstroke","upswing","uptake","uptight","uptown","upturned","upward","upwind","uranium","urban","urchin","urethane","urgency","urgent","urging","urologist","urology","usable","usage","useable","used","uselessly","user","usher","usual","utensil","utility","utilize","utmost","utopia","utter","vacancy","vacant","vacate","vacation","vagabond","vagrancy","vagrantly","vaguely","vagueness","valiant","valid","valium","valley","valuables","value","vanilla","vanish","vanity","vanquish","vantage","vaporizer","variable","variably","varied","variety","various","varmint","varnish","varsity","varying","vascular","vaseline","vastly","vastness","veal","vegan","veggie","vehicular","velcro","velocity","velvet","vendetta","vending","vendor","veneering","vengeful","venomous","ventricle","venture","venue","venus","verbalize","verbally","verbose","verdict","verify","verse","version","versus","vertebrae","vertical","vertigo","very","vessel","vest","veteran","veto","vexingly","viability","viable","vibes","vice","vicinity","victory","video","viewable","viewer","viewing","viewless","viewpoint","vigorous","village","villain","vindicate","vineyard","vintage","violate","violation","violator","violet","violin","viper","viral","virtual","virtuous","virus","visa","viscosity","viscous","viselike","visible","visibly","vision","visiting","visitor","visor","vista","vitality","vitalize","vitally","vitamins","vivacious","vividly","vividness","vixen","vocalist","vocalize","vocally","vocation","voice","voicing","void","volatile","volley","voltage","volumes","voter","voting","voucher","vowed","vowel","voyage","wackiness","wad","wafer","waffle","waged","wager","wages","waggle","wagon","wake","waking","walk","walmart","walnut","walrus","waltz","wand","wannabe","wanted","wanting","wasabi","washable","washbasin","washboard","washbowl","washcloth","washday","washed","washer","washhouse","washing","washout","washroom","washstand","washtub","wasp","wasting","watch","water","waviness","waving","wavy","whacking","whacky","wham","wharf","wheat","whenever","whiff","whimsical","whinny","whiny","whisking","whoever","whole","whomever","whoopee","whooping","whoops","why","wick","widely","widen","widget","widow","width","wieldable","wielder","wife","wifi","wikipedia","wildcard","wildcat","wilder","wildfire","wildfowl","wildland","wildlife","wildly","wildness","willed","willfully","willing","willow","willpower","wilt","wimp","wince","wincing","wind","wing","winking","winner","winnings","winter","wipe","wired","wireless","wiring","wiry","wisdom","wise","wish","wisplike","wispy","wistful","wizard","wobble","wobbling","wobbly","wok","wolf","wolverine","womanhood","womankind","womanless","womanlike","womanly","womb","woof","wooing","wool","woozy","word","work","worried","worrier","worrisome","worry","worsening","worshiper","worst","wound","woven","wow","wrangle","wrath","wreath","wreckage","wrecker","wrecking","wrench","wriggle","wriggly","wrinkle","wrinkly","wrist","writing","written","wrongdoer","wronged","wrongful","wrongly","wrongness","wrought","xbox","xerox","yahoo","yam","yanking","yapping","yard","yarn","yeah","yearbook","yearling","yearly","yearning","yeast","yelling","yelp","yen","yesterday","yiddish","yield","yin","yippee","yo-yo","yodel","yoga","yogurt","yonder","yoyo","yummy","zap","zealous","zebra","zen","zeppelin","zero","zestfully","zesty","zigzagged","zipfile","zipping","zippy","zips","zit","zodiac","zombie","zone","zoning","zookeeper","zoologist","zoology","zoom"];class Bs{constructor(e,t){this.password=e,this.date=t}}class Ks extends vi{constructor(){super(...arguments),this.defaultType="",this.minLength=0,this.useUppercase=!1,this.useLowercase=!1,this.useNumbers=!1,this.numberCount=0,this.useSpecial=!1,this.specialCount=0,this.minNumberWords=0,this.capitalize=!1,this.includeNumber=!1}inEffect(){return""!==this.defaultType||this.minLength>0||this.numberCount>0||this.specialCount>0||this.useUppercase||this.useLowercase||this.useNumbers||this.useSpecial||this.minNumberWords>0||this.capitalize||this.includeNumber}}var _s=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const js={length:14,ambiguous:!1,number:!0,minNumber:1,uppercase:!0,minUppercase:0,lowercase:!0,minLowercase:0,special:!1,minSpecial:1,type:"password",numWords:3,wordSeparator:"-",capitalize:!1,includeNumber:!1};class Gs{constructor(e,t,i){this.cryptoService=e,this.policyService=t,this.stateService=i}generatePassword(e){return _s(this,void 0,void 0,(function*(){const t=Object.assign({},js,e);if("passphrase"===t.type)return this.generatePassphrase(e);this.sanitizePasswordLength(t,!0);const i=t.minUppercase+t.minLowercase+t.minNumber+t.minSpecial;t.length<i&&(t.length=i);const n=[];if(t.lowercase&&t.minLowercase>0)for(let e=0;e<t.minLowercase;e++)n.push("l");if(t.uppercase&&t.minUppercase>0)for(let e=0;e<t.minUppercase;e++)n.push("u");if(t.number&&t.minNumber>0)for(let e=0;e<t.minNumber;e++)n.push("n");if(t.special&&t.minSpecial>0)for(let e=0;e<t.minSpecial;e++)n.push("s");for(;n.length<t.length;)n.push("a");yield this.shuffleArray(n);let s="",r="abcdefghijkmnopqrstuvwxyz";t.ambiguous&&(r+="l"),t.lowercase&&(s+=r);let o="ABCDEFGHJKLMNPQRSTUVWXYZ";t.ambiguous&&(o+="IO"),t.uppercase&&(s+=o);let a="23456789";t.ambiguous&&(a+="01"),t.number&&(s+=a);const l="!@#$%^&*";t.special&&(s+=l);let c="";for(let e=0;e<t.length;e++){let t;switch(n[e]){case"l":t=r;break;case"u":t=o;break;case"n":t=a;break;case"s":t=l;break;case"a":t=s}const i=yield this.cryptoService.randomNumber(0,t.length-1);c+=t.charAt(i)}return c}))}generatePassphrase(e){return _s(this,void 0,void 0,(function*(){const t=Object.assign({},js,e);(null==t.numWords||t.numWords<=2)&&(t.numWords=js.numWords),(null==t.wordSeparator||0===t.wordSeparator.length||t.wordSeparator.length>1)&&(t.wordSeparator=" "),null==t.capitalize&&(t.capitalize=!1),null==t.includeNumber&&(t.includeNumber=!1);const i=Ls.length-1,n=new Array(t.numWords);for(let e=0;e<t.numWords;e++){const s=yield this.cryptoService.randomNumber(0,i);t.capitalize?n[e]=this.capitalize(Ls[s]):n[e]=Ls[s]}return t.includeNumber&&(yield this.appendRandomNumberToRandomWord(n)),n.join(t.wordSeparator)}))}getOptions(){return _s(this,void 0,void 0,(function*(){let e=yield this.stateService.getPasswordGenerationOptions();e=null==e?Object.assign({},js):Object.assign({},js,e),yield this.stateService.setPasswordGenerationOptions(e);const t=yield this.enforcePasswordGeneratorPoliciesOnOptions(e);return e=t[0],[e,t[1]]}))}enforcePasswordGeneratorPoliciesOnOptions(e){return _s(this,void 0,void 0,(function*(){let t=yield this.getPasswordGeneratorPolicyOptions();return null!=t?(e.length<t.minLength&&(e.length=t.minLength),t.useUppercase&&(e.uppercase=!0),t.useLowercase&&(e.lowercase=!0),t.useNumbers&&(e.number=!0),e.minNumber<t.numberCount&&(e.minNumber=t.numberCount),t.useSpecial&&(e.special=!0),e.minSpecial<t.specialCount&&(e.minSpecial=t.specialCount),e.minSpecial+e.minNumber>e.length&&(e.minSpecial=e.length-e.minNumber),e.numWords<t.minNumberWords&&(e.numWords=t.minNumberWords),t.capitalize&&(e.capitalize=!0),t.includeNumber&&(e.includeNumber=!0),"password"!==t.defaultType&&"passphrase"!==t.defaultType||(e.type=t.defaultType)):t=new Ks,[e,t]}))}getPasswordGeneratorPolicyOptions(){return _s(this,void 0,void 0,(function*(){const e=null==this.policyService?null:yield this.policyService.getAll(zs.PasswordGenerator);let t=null;return null==e||0===e.length||e.forEach((e=>{e.enabled&&null!=e.data&&(null==t&&(t=new Ks),null!=e.data.defaultType&&"password"!==t.defaultType&&(t.defaultType=e.data.defaultType),null!=e.data.minLength&&e.data.minLength>t.minLength&&(t.minLength=e.data.minLength),e.data.useUpper&&(t.useUppercase=!0),e.data.useLower&&(t.useLowercase=!0),e.data.useNumbers&&(t.useNumbers=!0),null!=e.data.minNumbers&&e.data.minNumbers>t.numberCount&&(t.numberCount=e.data.minNumbers),e.data.useSpecial&&(t.useSpecial=!0),null!=e.data.minSpecial&&e.data.minSpecial>t.specialCount&&(t.specialCount=e.data.minSpecial),null!=e.data.minNumberWords&&e.data.minNumberWords>t.minNumberWords&&(t.minNumberWords=e.data.minNumberWords),e.data.capitalize&&(t.capitalize=!0),e.data.includeNumber&&(t.includeNumber=!0))})),t}))}saveOptions(e){return _s(this,void 0,void 0,(function*(){yield this.stateService.setPasswordGenerationOptions(e)}))}getHistory(){return _s(this,void 0,void 0,(function*(){if(!(yield this.cryptoService.hasKey()))return new Array;if(null==(yield this.stateService.getDecryptedPasswordGenerationHistory())){const e=yield this.stateService.getEncryptedPasswordGenerationHistory(),t=yield this.decryptHistory(e);yield this.stateService.setDecryptedPasswordGenerationHistory(t)}const e=yield this.stateService.getDecryptedPasswordGenerationHistory();return null!=e?e:new Array}))}addHistory(e){return _s(this,void 0,void 0,(function*(){if(!(yield this.cryptoService.hasKey()))return;const t=yield this.getHistory();if(this.matchesPrevious(e,t))return;t.unshift(new Bs(e,Date.now())),t.length>100&&t.pop();const i=yield this.encryptHistory(t);return yield this.stateService.setDecryptedPasswordGenerationHistory(t),yield this.stateService.setEncryptedPasswordGenerationHistory(i)}))}clear(e){return _s(this,void 0,void 0,(function*(){yield this.stateService.setEncryptedPasswordGenerationHistory(null,{userId:e}),yield this.stateService.setDecryptedPasswordGenerationHistory(null,{userId:e})}))}passwordStrength(e,t=null){if(null==e||0===e.length)return null;let i=["bitwarden","bit","warden"];null!=t&&t.length>0&&(i=i.concat(t));const n=Array.from(new Set(i));return Ms(e,n)}normalizeOptions(e,t){e.minLowercase=0,e.minUppercase=0,!e.length||e.length<5?e.length=5:e.length>128&&(e.length=128),e.length<t.minLength&&(e.length=t.minLength),e.minNumber?e.minNumber>e.length?e.minNumber=e.length:e.minNumber>9&&(e.minNumber=9):e.minNumber=0,e.minNumber<t.numberCount&&(e.minNumber=t.numberCount),e.minSpecial?e.minSpecial>e.length?e.minSpecial=e.length:e.minSpecial>9&&(e.minSpecial=9):e.minSpecial=0,e.minSpecial<t.specialCount&&(e.minSpecial=t.specialCount),e.minSpecial+e.minNumber>e.length&&(e.minSpecial=e.length-e.minNumber),null==e.numWords||e.length<3?e.numWords=3:e.numWords>20&&(e.numWords=20),e.numWords<t.minNumberWords&&(e.numWords=t.minNumberWords),null!=e.wordSeparator&&e.wordSeparator.length>1&&(e.wordSeparator=e.wordSeparator[0]),this.sanitizePasswordLength(e,!1)}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}appendRandomNumberToRandomWord(e){return _s(this,void 0,void 0,(function*(){if(null==e||e.length<=0)return;const t=yield this.cryptoService.randomNumber(0,e.length-1),i=yield this.cryptoService.randomNumber(0,9);e[t]=e[t]+i}))}encryptHistory(e){return _s(this,void 0,void 0,(function*(){if(null==e||0===e.length)return Promise.resolve([]);const t=e.map((e=>_s(this,void 0,void 0,(function*(){const t=yield this.cryptoService.encrypt(e.password);return new Bs(t.encryptedString,e.date)}))));return yield Promise.all(t)}))}decryptHistory(e){return _s(this,void 0,void 0,(function*(){if(null==e||0===e.length)return Promise.resolve([]);const t=e.map((e=>_s(this,void 0,void 0,(function*(){const t=yield this.cryptoService.decryptToUtf8(new At(e.password));return new Bs(t,e.date)}))));return yield Promise.all(t)}))}matchesPrevious(e,t){return null!=t&&0!==t.length&&t[t.length-1].password===e}shuffleArray(e){return _s(this,void 0,void 0,(function*(){for(let t=e.length-1;t>0;t--){const i=yield this.cryptoService.randomNumber(0,t);[e[t],e[i]]=[e[i],e[t]]}}))}sanitizePasswordLength(e,t){let i=0,n=0,s=e.minNumber,r=e.minSpecial;e.uppercase&&e.minUppercase<=0?i=1:e.uppercase||(i=0),e.lowercase&&e.minLowercase<=0?n=1:e.lowercase||(n=0),e.number&&e.minNumber<=0?s=1:e.number||(s=0),e.special&&e.minSpecial<=0?r=1:e.special||(r=0),(!e.length||e.length<1)&&(e.length=10);const o=i+n+s+r;e.length<o&&(e.length=o),t&&(e.minUppercase=i,e.minLowercase=n,e.minNumber=s,e.minSpecial=r)}}class Vs{constructor(e){this.id=e.id,this.organizationId=e.organizationId,this.type=e.type,this.data=e.data,this.enabled=e.enabled}}class Hs extends vi{constructor(e){super(),null!=e&&(this.id=e.id,this.organizationId=e.organizationId,this.type=e.type,this.data=e.data,this.enabled=e.enabled)}}var qs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ws{constructor(e,t,i,n){this.policyService=e,this.apiService=t,this.stateService=i,this.organizationService=n}getPolicy(e,t){return qs(this,void 0,void 0,(function*(){const i=yield this.apiService.send("GET","/organizations/"+e+"/policies/"+t,null,!0,!0);return new Ae(i)}))}getPolicies(e){return qs(this,void 0,void 0,(function*(){const t=yield this.apiService.send("GET","/organizations/"+e+"/policies",null,!0,!0);return new le(t,Ae)}))}getPoliciesByToken(e,t,i,n){return qs(this,void 0,void 0,(function*(){const s=yield this.apiService.send("GET","/organizations/"+e+"/policies/token?token="+encodeURIComponent(t)+"&email="+encodeURIComponent(i)+"&organizationUserId="+n,null,!1,!0);return new le(s,Ae)}))}getPoliciesByInvitedUser(e,t){return qs(this,void 0,void 0,(function*(){const i=yield this.apiService.send("GET","/organizations/"+e+"/policies/invited-user?userId="+t,null,!1,!0);return new le(i,Ae)}))}getPolicyForOrganization(e,t){return qs(this,void 0,void 0,(function*(){const i=yield this.organizationService.get(t);if(null==i?void 0:i.isProviderUser){const e=(yield this.getPolicies(t)).data.find((e=>e.organizationId===t));return null==e?null:new Hs(new Vs(e))}return(yield this.policyService.getAll(e)).find((e=>e.organizationId===t))}))}getMasterPasswordPoliciesForInvitedUsers(e){return qs(this,void 0,void 0,(function*(){const t=yield this.stateService.getUserId(),i=yield this.getPoliciesByInvitedUser(e,t),n=yield this.policyService.mapPoliciesFromToken(i);return this.policyService.getMasterPasswordPolicyOptions(n)}))}putPolicy(e,t,i){return qs(this,void 0,void 0,(function*(){const n=yield this.apiService.send("PUT","/organizations/"+e+"/policies/"+t,i,!0,!0),s=new Ae(n),r=new Vs(s);yield this.policyService.upsert(r)}))}}class Js extends vi{constructor(){super(...arguments),this.minComplexity=0,this.minLength=0,this.requireUpper=!1,this.requireLower=!1,this.requireNumbers=!1,this.requireSpecial=!1}}class Ys extends vi{constructor(){super(...arguments),this.autoEnrollEnabled=!1}}var $s,Qs,Xs=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Zs{constructor(e,t){this.stateService=e,this.organizationService=t}getAll(e,t){return Xs(this,void 0,void 0,(function*(){let i=[];const n=yield this.stateService.getDecryptedPolicies({userId:t});if(null!=n)i=n;else{const e=yield this.stateService.getEncryptedPolicies({userId:t});for(const t in e)e.hasOwnProperty(t)&&i.push(new Hs(e[t]));yield this.stateService.setDecryptedPolicies(i,{userId:t})}return null!=e?i.filter((t=>t.type===e)):i}))}getMasterPasswordPolicyOptions(e){return Xs(this,void 0,void 0,(function*(){let t=null;return null==(e=null==e?yield this.getAll(zs.MasterPassword):e.filter((e=>e.type===zs.MasterPassword)))||0===e.length||e.forEach((e=>{e.enabled&&null!=e.data&&(null==t&&(t=new Js),null!=e.data.minComplexity&&e.data.minComplexity>t.minComplexity&&(t.minComplexity=e.data.minComplexity),null!=e.data.minLength&&e.data.minLength>t.minLength&&(t.minLength=e.data.minLength),e.data.requireUpper&&(t.requireUpper=!0),e.data.requireLower&&(t.requireLower=!0),e.data.requireNumbers&&(t.requireNumbers=!0),e.data.requireSpecial&&(t.requireSpecial=!0))})),t}))}evaluateMasterPassword(e,t,i){return null==i||!(i.minComplexity>0&&i.minComplexity>e)&&(!(i.minLength>0&&i.minLength>t.length)&&((!i.requireUpper||t.toLocaleLowerCase()!==t)&&((!i.requireLower||t.toLocaleUpperCase()!==t)&&(!(i.requireNumbers&&!/[0-9]/.test(t))&&!(i.requireSpecial&&!/[!@#$%\^&*]/g.test(t))))))}getResetPasswordPolicyOptions(e,t){var i,n,s;const r=new Ys;if(null==e||null==t)return[r,!1];const o=e.find((e=>e.organizationId===t&&e.type===zs.ResetPassword&&e.enabled));return r.autoEnrollEnabled=null!==(n=null===(i=null==o?void 0:o.data)||void 0===i?void 0:i.autoEnrollEnabled)&&void 0!==n&&n,[r,null!==(s=null==o?void 0:o.enabled)&&void 0!==s&&s]}mapPoliciesFromToken(e){if(null==e||null==e.data)return null;return e.data.map((e=>new Vs(e))).map((e=>new Hs(e)))}policyAppliesToUser(e,t,i){return Xs(this,void 0,void 0,(function*(){const n=yield this.getAll(e,i),s=yield this.organizationService.getAll(i);let r;r=null!=t?n.filter((e=>e.enabled&&t(e))):n.filter((e=>e.enabled));const o=new Set(r.map((e=>e.organizationId)));return s.some((t=>t.enabled&&t.status>=Is.Accepted&&t.usePolicies&&!this.isExcemptFromPolicies(t,e)&&o.has(t.id)))}))}upsert(e){return Xs(this,void 0,void 0,(function*(){let t=yield this.stateService.getEncryptedPolicies();null==t&&(t={}),t[e.id]=e,yield this.stateService.setDecryptedPolicies(null),yield this.stateService.setEncryptedPolicies(t)}))}replace(e){return Xs(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedPolicies(null),yield this.stateService.setEncryptedPolicies(e)}))}clear(e){return Xs(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedPolicies(null,{userId:e}),yield this.stateService.setEncryptedPolicies(null,{userId:e})}))}isExcemptFromPolicies(e,t){return t===zs.MaximumVaultTimeout?e.type===cs.Owner:e.isExemptFromPolicies}}!function(e){e[e.Invited=0]="Invited",e[e.Accepted=1]="Accepted",e[e.Confirmed=2]="Confirmed",e[e.Revoked=-1]="Revoked"}($s||($s={})),function(e){e[e.ProviderAdmin=0]="ProviderAdmin",e[e.ServiceUser=1]="ServiceUser"}(Qs||(Qs={}));class er{constructor(e){null!=e&&(this.id=e.id,this.name=e.name,this.status=e.status,this.type=e.type,this.enabled=e.enabled,this.userId=e.userId,this.useEvents=e.useEvents)}get canAccess(){return!!this.isProviderAdmin||this.enabled&&this.status===$s.Confirmed}get canCreateOrganizations(){return this.enabled&&this.isProviderAdmin}get canManageUsers(){return this.isProviderAdmin}get canAccessEventLogs(){return this.isProviderAdmin}get isProviderAdmin(){return this.type===Qs.ProviderAdmin}}var tr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ir{constructor(e){this.stateService=e}get(e){return tr(this,void 0,void 0,(function*(){const t=yield this.stateService.getProviders();return null!=t&&t.hasOwnProperty(e)?new er(t[e]):null}))}getAll(){return tr(this,void 0,void 0,(function*(){const e=yield this.stateService.getProviders(),t=[];for(const i in e)e.hasOwnProperty(i)&&t.push(new er(e[i]));return t}))}save(e){return tr(this,void 0,void 0,(function*(){yield this.stateService.setProviders(e)}))}}var nr,sr=i(58626),rr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class or{constructor(e,t,i){this.cipherService=e,this.logService=t,this.i18nService=i,this.indexedEntityId=null,this.indexing=!1,this.index=null,this.immediateSearchLocales=["zh-CN","zh-TW","ja","ko","vi"],this.defaultSearchableMinLength=2,this.searchableMinLength=this.defaultSearchableMinLength,this.i18nService.locale$.subscribe((e=>{-1!==this.immediateSearchLocales.indexOf(e)?this.searchableMinLength=1:this.searchableMinLength=this.defaultSearchableMinLength})),or.registeredPipeline||(or.registeredPipeline=!0,sr.Pipeline.registerFunction(this.normalizeAccentsPipelineFunction,"normalizeAccents"))}clearIndex(){this.indexedEntityId=null,this.index=null}isSearchable(e){return!(null==(e=or.normalizeSearchQuery(e))||null==this.index&&e.length<this.searchableMinLength||null!=this.index&&e.length<this.searchableMinLength&&0!==e.indexOf(">"))}indexCiphers(e,t){return rr(this,void 0,void 0,(function*(){if(this.indexing)return;this.indexing=!0,this.indexedEntityId=e,this.index=null;const i=new sr.Builder;i.pipeline.add(this.normalizeAccentsPipelineFunction),i.ref("id"),i.field("shortid",{boost:100,extractor:e=>e.id.substr(0,8)}),i.field("name",{boost:10}),i.field("subtitle",{boost:5,extractor:e=>null!=e.subTitle&&e.type===r.Card?e.subTitle.replace(/\*/g,""):e.subTitle}),i.field("notes"),i.field("login.username",{extractor:e=>e.type===r.Login&&null!=e.login?e.login.username:null}),i.field("login.uris",{boost:2,extractor:e=>this.uriExtractor(e)}),i.field("fields",{extractor:e=>this.fieldExtractor(e,!1)}),i.field("fields_joined",{extractor:e=>this.fieldExtractor(e,!0)}),i.field("attachments",{extractor:e=>this.attachmentExtractor(e,!1)}),i.field("attachments_joined",{extractor:e=>this.attachmentExtractor(e,!0)}),i.field("organizationid",{extractor:e=>e.organizationId}),(t=t||(yield this.cipherService.getAllDecrypted())).forEach((e=>i.add(e))),this.index=i.build(),this.indexing=!1,this.logService.info("Finished search indexing")}))}searchCiphers(e,t=null,i=null){return rr(this,void 0,void 0,(function*(){const n=[];if(null!=e&&(e=or.normalizeSearchQuery(e.trim().toLowerCase())),""===e&&(e=null),null==i&&(i=yield this.cipherService.getAllDecrypted()),null!=t&&Array.isArray(t)&&t.length>0?i=i.filter((e=>t.every((t=>null==t||t(e))))):null!=t&&(i=i.filter(t)),!this.isSearchable(e))return i;this.indexing&&(yield new Promise((e=>setTimeout(e,250))),this.indexing&&(yield new Promise((e=>setTimeout(e,500)))));const s=this.getIndexForSearch();if(null==s)return this.searchCiphersBasic(i,e);const r=new Map;i.forEach((e=>r.set(e.id,e)));let o=null;if(null!=e&&e.length>1&&0===e.indexOf(">"))try{o=s.search(e.substr(1).trim())}catch(e){this.logService.error(e)}else{const t=sr.Query.wildcard.LEADING|sr.Query.wildcard.TRAILING;o=s.query((i=>{sr.tokenizer(e).forEach((e=>{const n=e.toString();i.term(n,{fields:["name"],wildcard:t}),i.term(n,{fields:["subtitle"],wildcard:t}),i.term(n,{fields:["login.uris"],wildcard:t}),i.term(n,{})}))}))}return null!=o&&o.forEach((e=>{r.has(e.ref)&&n.push(r.get(e.ref))})),n}))}searchCiphersBasic(e,t,i=!1){return t=or.normalizeSearchQuery(t.trim().toLowerCase()),e.filter((e=>i===e.isDeleted&&(null!=e.name&&e.name.toLowerCase().indexOf(t)>-1||(!!(t.length>=8&&e.id.startsWith(t))||(null!=e.subTitle&&e.subTitle.toLowerCase().indexOf(t)>-1||!!(e.login&&e.login.hasUris&&e.login.uris.some((e=>{var i;return(null===(i=null==e?void 0:e.uri)||void 0===i?void 0:i.toLowerCase().indexOf(t))>-1}))))))))}searchSends(e,t){if(null===(t=or.normalizeSearchQuery(t.trim().toLocaleLowerCase())))return e;const i=[],n=[];return e.forEach((e=>{var s,r,o;null!=e.name&&e.name.toLowerCase().indexOf(t)>-1?i.push(e):(t.length>=8&&(e.id.startsWith(t)||e.accessId.toLocaleLowerCase().startsWith(t)||null!=(null===(s=e.file)||void 0===s?void 0:s.id)&&e.file.id.startsWith(t))||null!=e.notes&&e.notes.toLowerCase().indexOf(t)>-1||null!=(null===(r=e.text)||void 0===r?void 0:r.text)&&e.text.text.toLowerCase().indexOf(t)>-1||null!=(null===(o=e.file)||void 0===o?void 0:o.fileName)&&e.file.fileName.toLowerCase().indexOf(t)>-1)&&n.push(e)})),i.concat(n)}getIndexForSearch(){return this.index}fieldExtractor(e,t){if(!e.hasFields)return null;let i=[];return e.fields.forEach((e=>{null!=e.name&&i.push(e.name),e.type===ei.Text&&null!=e.value&&i.push(e.value)})),i=i.filter((e=>""!==e.trim())),0===i.length?null:t?i.join(" "):i}attachmentExtractor(e,t){if(!e.hasAttachments)return null;let i=[];return e.attachments.forEach((e=>{null!=e&&null!=e.fileName&&(t&&e.fileName.indexOf(".")>-1?i.push(e.fileName.substr(0,e.fileName.lastIndexOf("."))):i.push(e.fileName))})),i=i.filter((e=>""!==e.trim())),0===i.length?null:t?i.join(" "):i}uriExtractor(e){if(e.type!==r.Login||null==e.login||!e.login.hasUris)return null;const t=[];return e.login.uris.forEach((e=>{if(null==e.uri||""===e.uri)return;if(null!=e.hostname)return void t.push(e.hostname);let i=e.uri;if(e.match!==ti.RegularExpression){const e=i.indexOf("://");e>-1&&(i=i.substr(e+3));const t=i.search(/\?|&|#/);t>-1&&(i=i.substring(0,t))}t.push(i)})),t.length>0?t:null}normalizeAccentsPipelineFunction(e){const t=["name","login.username","subtitle","notes"];return e.metadata.fields.every((e=>t.includes(e)))?or.normalizeSearchQuery(e.toString()):e}static normalizeSearchQuery(e){return null==e?void 0:e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}}or.registeredPipeline=!1,function(e){e[e.Text=0]="Text",e[e.File=1]="File"}(nr||(nr={}));class ar{constructor(e){null!=e&&(this.id=e.id,this.fileName=e.fileName,this.size=e.size,this.sizeName=e.sizeName)}}class lr{constructor(e){null!=e&&(this.text=e.text,this.hidden=e.hidden)}}class cr{constructor(e){if(null!=e)switch(this.id=e.id,this.accessId=e.accessId,this.type=e.type,this.name=e.name,this.notes=e.notes,this.key=e.key,this.maxAccessCount=e.maxAccessCount,this.accessCount=e.accessCount,this.revisionDate=e.revisionDate,this.expirationDate=e.expirationDate,this.deletionDate=e.deletionDate,this.password=e.password,this.disabled=e.disable,this.hideEmail=e.hideEmail,this.type){case nr.Text:this.text=new lr(e.text);break;case nr.File:this.file=new ar(e.file)}}}class dr{constructor(e){this.id=null,this.size=null,this.sizeName=null,this.fileName=null,e&&(this.id=e.id,this.size=e.size,this.sizeName=e.sizeName)}get fileSize(){try{if(null!=this.size)return parseInt(this.size,null)}catch(e){}return 0}}class ur{constructor(e){this.text=null,e&&(this.hidden=e.hidden)}get maskedText(){return null!=this.text?"••••••••":null}}class hr{constructor(e){this.id=null,this.accessId=null,this.name=null,this.notes=null,this.type=null,this.text=new ur,this.file=new dr,this.maxAccessCount=null,this.accessCount=0,this.revisionDate=null,this.deletionDate=null,this.expirationDate=null,this.password=null,this.disabled=!1,this.hideEmail=!1,e&&(this.id=e.id,this.accessId=e.accessId,this.type=e.type,this.maxAccessCount=e.maxAccessCount,this.accessCount=e.accessCount,this.revisionDate=e.revisionDate,this.deletionDate=e.deletionDate,this.expirationDate=e.expirationDate,this.disabled=e.disabled,this.password=e.password,this.hideEmail=e.hideEmail)}get urlB64Key(){return f.fromBufferToUrlB64(this.key)}get maxAccessCountReached(){return null!=this.maxAccessCount&&this.accessCount>=this.maxAccessCount}get expired(){return null!=this.expirationDate&&this.expirationDate<=new Date}get pendingDelete(){return this.deletionDate<=new Date}}var pr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class yr extends vi{constructor(e){super(),null!=e&&(this.size=e.size,this.buildDomainModel(this,e,{id:null,sizeName:null,fileName:null},["id","sizeName"]))}decrypt(e){return pr(this,void 0,void 0,(function*(){return yield this.decryptObj(new dr(this),{fileName:null},null,e)}))}}class vr extends vi{constructor(e){super(),null!=e&&(this.hidden=e.hidden,this.buildDomainModel(this,e,{text:null},[]))}decrypt(e){return this.decryptObj(new ur(this),{text:null},null,e)}}var gr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class mr extends vi{constructor(e){if(super(),null!=e)switch(this.buildDomainModel(this,e,{id:null,accessId:null,name:null,notes:null,key:null},["id","accessId"]),this.type=e.type,this.maxAccessCount=e.maxAccessCount,this.accessCount=e.accessCount,this.password=e.password,this.disabled=e.disabled,this.revisionDate=null!=e.revisionDate?new Date(e.revisionDate):null,this.deletionDate=null!=e.deletionDate?new Date(e.deletionDate):null,this.expirationDate=null!=e.expirationDate?new Date(e.expirationDate):null,this.hideEmail=e.hideEmail,this.type){case nr.Text:this.text=new vr(e.text);break;case nr.File:this.file=new yr(e.file)}}decrypt(){return gr(this,void 0,void 0,(function*(){const e=new hr(this),t=f.getContainerService().getCryptoService();try{e.key=yield t.decryptToBytes(this.key,null),e.cryptoKey=yield t.makeSendKey(e.key)}catch(e){}switch(yield this.decryptObj(e,{name:null,notes:null},null,e.cryptoKey),this.type){case nr.File:e.file=yield this.file.decrypt(e.cryptoKey);break;case nr.Text:e.text=yield this.text.decrypt(e.cryptoKey)}return e}))}}class fr{constructor(e,t){switch(this.type=e.type,this.fileLength=t,this.name=e.name?e.name.encryptedString:null,this.notes=e.notes?e.notes.encryptedString:null,this.maxAccessCount=e.maxAccessCount,this.expirationDate=null!=e.expirationDate?e.expirationDate.toISOString():null,this.deletionDate=null!=e.deletionDate?e.deletionDate.toISOString():null,this.key=null!=e.key?e.key.encryptedString:null,this.password=e.password,this.disabled=e.disabled,this.hideEmail=e.hideEmail,this.type){case nr.Text:this.text=new Ne,this.text.text=null!=e.text.text?e.text.text.encryptedString:null,this.text.hidden=e.text.hidden;break;case nr.File:this.file=new Fe,this.file.fileName=null!=e.file.fileName?e.file.fileName.encryptedString:null}}}var br=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class wr{constructor(e,t,i,n,s,r){this.cryptoService=e,this.apiService=t,this.fileUploadService=i,this.i18nService=n,this.cryptoFunctionService=s,this.stateService=r}clearCache(){return br(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedSends(null)}))}encrypt(e,t,i,n){return br(this,void 0,void 0,(function*(){let s=null;const r=new mr;if(r.id=e.id,r.type=e.type,r.disabled=e.disabled,r.hideEmail=e.hideEmail,r.maxAccessCount=e.maxAccessCount,null==e.key&&(e.key=yield this.cryptoFunctionService.randomBytes(16),e.cryptoKey=yield this.cryptoService.makeSendKey(e.key)),null!=i){const t=yield this.cryptoFunctionService.pbkdf2(i,e.key,"sha256",1e5);r.password=f.fromBufferToB64(t)}if(r.key=yield this.cryptoService.encrypt(e.key,n),r.name=yield this.cryptoService.encrypt(e.name,e.cryptoKey),r.notes=yield this.cryptoService.encrypt(e.notes,e.cryptoKey),r.type===nr.Text)r.text=new vr,r.text.text=yield this.cryptoService.encrypt(e.text.text,e.cryptoKey),r.text.hidden=e.text.hidden;else if(r.type===nr.File&&(r.file=new yr,null!=t))if(t instanceof ArrayBuffer){const[i,n]=yield this.encryptFileData(e.file.fileName,t,e.cryptoKey);r.file.fileName=i,s=n}else s=yield this.parseFile(r,t,e.cryptoKey);return[r,s]}))}get(e){return br(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedSends();return null!=t&&t.hasOwnProperty(e)?new mr(t[e]):null}))}getAll(){return br(this,void 0,void 0,(function*(){const e=yield this.stateService.getEncryptedSends(),t=[];for(const i in e)e.hasOwnProperty(i)&&t.push(new mr(e[i]));return t}))}getAllDecrypted(){return br(this,void 0,void 0,(function*(){let e=yield this.stateService.getDecryptedSends();if(null!=e)return e;e=[];if(!(yield this.cryptoService.hasKey()))throw new Error("No key.");const t=[];return(yield this.getAll()).forEach((i=>{t.push(i.decrypt().then((t=>e.push(t))))})),yield Promise.all(t),e.sort(f.getSortFunction(this.i18nService,"name")),yield this.stateService.setDecryptedSends(e),e}))}saveWithServer(e){var t;return br(this,void 0,void 0,(function*(){const i=new fr(e[0],null===(t=e[1])||void 0===t?void 0:t.buffer.byteLength);let n;if(null==e[0].id){if(e[0].type===nr.Text)n=yield this.apiService.postSend(i);else try{const t=yield this.apiService.postFileTypeSend(i);n=t.sendResponse,yield this.fileUploadService.uploadSendFile(t,e[0].file.fileName,e[1])}catch(t){if(!(t instanceof ee&&404===t.statusCode))throw t instanceof ee?new Error(t.getSingleMessage()):t;n=yield this.legacyServerSendFileUpload(e,i)}e[0].id=n.id,e[0].accessId=n.accessId}else n=yield this.apiService.putSend(e[0].id,i);const s=new cr(n);yield this.upsert(s)}))}legacyServerSendFileUpload(e,t){return br(this,void 0,void 0,(function*(){const i=new FormData;try{const n=new Blob([e[1].buffer],{type:"application/octet-stream"});i.append("model",JSON.stringify(t)),i.append("data",n,e[0].file.fileName.encryptedString)}catch(n){if(!f.isNode||f.isBrowser)throw n;i.append("model",JSON.stringify(t)),i.append("data",Buffer.from(e[1].buffer),{filepath:e[0].file.fileName.encryptedString,contentType:"application/octet-stream"})}return yield this.apiService.postSendFileLegacy(i)}))}upsert(e){return br(this,void 0,void 0,(function*(){let t=yield this.stateService.getEncryptedSends();if(null==t&&(t={}),e instanceof cr){const i=e;t[i.id]=i}else e.forEach((e=>{t[e.id]=e}));yield this.replace(t)}))}replace(e){return br(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedSends(null),yield this.stateService.setEncryptedSends(e)}))}clear(){return br(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedSends(null),yield this.stateService.setEncryptedSends(null)}))}delete(e){return br(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedSends();if(null!=t){if("string"==typeof e){if(null==t[e])return;delete t[e]}else e.forEach((e=>{delete t[e]}));yield this.replace(t)}}))}deleteWithServer(e){return br(this,void 0,void 0,(function*(){yield this.apiService.deleteSend(e),yield this.delete(e)}))}removePasswordWithServer(e){return br(this,void 0,void 0,(function*(){const t=yield this.apiService.putSendRemovePassword(e),i=new cr(t);yield this.upsert(i)}))}parseFile(e,t,i){return new Promise(((n,s)=>{const r=new FileReader;r.readAsArrayBuffer(t),r.onload=r=>br(this,void 0,void 0,(function*(){try{const[s,o]=yield this.encryptFileData(t.name,r.target.result,i);e.file.fileName=s,n(o)}catch(e){s(e)}})),r.onerror=()=>{s("Error reading file.")}}))}encryptFileData(e,t,i){return br(this,void 0,void 0,(function*(){return[yield this.cryptoService.encrypt(e,i),yield this.cryptoService.encryptToBytes(t,i)]}))}}var Sr=i(97123),kr=i(47456),Or=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Pr{constructor(e){this.stateService=e,this._settings=new Sr.X({}),this.settings$=this._settings.asObservable(),this.stateService.activeAccountUnlocked$.pipe((0,kr.b)((e=>Or(this,void 0,void 0,(function*(){if(null==f.global.bitwardenContainerService)return;if(!e)return void this._settings.next({});const t=yield this.stateService.getSettings();this._settings.next(t)}))))).subscribe()}setEquivalentDomains(e){var t;return Or(this,void 0,void 0,(function*(){const i=null!==(t=this._settings.getValue())&&void 0!==t?t:{};i.equivalentDomains=e,this._settings.next(i),yield this.stateService.setSettings(i)}))}clear(e){return Or(this,void 0,void 0,(function*(){null!=e&&e!=(yield this.stateService.getUserId())||this._settings.next({}),yield this.stateService.setSettings(null,{userId:e})}))}}var Ar=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Cr{constructor(e){this.stateService=e}static decodeToken(e){if(null==e)throw new Error("Token not provided.");const t=e.split(".");if(3!==t.length)throw new Error("JWT must have 3 parts");const i=f.fromUrlB64ToUtf8(t[1]);if(null==i)throw new Error("Cannot decode the token");return JSON.parse(i)}setTokens(e,t,i){return Ar(this,void 0,void 0,(function*(){yield this.setToken(e),yield this.setRefreshToken(t),null!=i&&(yield this.setClientId(i[0]),yield this.setClientSecret(i[1]))}))}setClientId(e){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.setApiKeyClientId(e)}))}getClientId(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.getApiKeyClientId()}))}setClientSecret(e){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.setApiKeyClientSecret(e)}))}getClientSecret(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.getApiKeyClientSecret()}))}setToken(e){return Ar(this,void 0,void 0,(function*(){yield this.stateService.setAccessToken(e)}))}getToken(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.getAccessToken()}))}setRefreshToken(e){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.setRefreshToken(e)}))}getRefreshToken(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.getRefreshToken()}))}setTwoFactorToken(e){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.setTwoFactorToken(e.twoFactorToken)}))}getTwoFactorToken(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.getTwoFactorToken()}))}clearTwoFactorToken(){return Ar(this,void 0,void 0,(function*(){return yield this.stateService.setTwoFactorToken(null)}))}clearToken(e){return Ar(this,void 0,void 0,(function*(){yield this.stateService.setAccessToken(null,{userId:e}),yield this.stateService.setRefreshToken(null,{userId:e}),yield this.stateService.setApiKeyClientId(null,{userId:e}),yield this.stateService.setApiKeyClientSecret(null,{userId:e})}))}decodeToken(e){return Ar(this,void 0,void 0,(function*(){if(null==(e=null!=e?e:yield this.stateService.getAccessToken()))throw new Error("Token not found.");return Cr.decodeToken(e)}))}getTokenExpirationDate(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();if(void 0===e.exp)return null;const t=new Date(0);return t.setUTCSeconds(e.exp),t}))}tokenSecondsRemaining(e=0){return Ar(this,void 0,void 0,(function*(){const t=yield this.getTokenExpirationDate();if(null==t)return 0;const i=t.valueOf()-((new Date).valueOf()+1e3*e);return Math.round(i/1e3)}))}tokenNeedsRefresh(e=5){return Ar(this,void 0,void 0,(function*(){return(yield this.tokenSecondsRemaining())<60*e}))}getUserId(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();if(void 0===e.sub)throw new Error("No user id found");return e.sub}))}getEmail(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();if(void 0===e.email)throw new Error("No email found");return e.email}))}getEmailVerified(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();if(void 0===e.email_verified)throw new Error("No email verification found");return e.email_verified}))}getName(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();return void 0===e.name?null:e.name}))}getIssuer(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();if(void 0===e.iss)throw new Error("No issuer found");return e.iss}))}getIsExternal(){return Ar(this,void 0,void 0,(function*(){const e=yield this.decodeToken();return Array.isArray(e.amr)&&e.amr.includes("external")}))}}var Dr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const xr={accessToken:"accessToken",alwaysShowDock:"alwaysShowDock",autoConfirmFingerprints:"autoConfirmFingerprints",autoFillOnPageLoadDefault:"autoFillOnPageLoadDefault",biometricAwaitingAcceptance:"biometricAwaitingAcceptance",biometricFingerprintValidated:"biometricFingerprintValidated",biometricText:"biometricText",biometricUnlock:"biometric",clearClipboard:"clearClipboardKey",clientId:"apikey_clientId",clientSecret:"apikey_clientSecret",collapsedGroupings:"collapsedGroupings",convertAccountToKeyConnector:"convertAccountToKeyConnector",defaultUriMatch:"defaultUriMatch",disableAddLoginNotification:"disableAddLoginNotification",disableAutoBiometricsPrompt:"noAutoPromptBiometrics",disableAutoTotpCopy:"disableAutoTotpCopy",disableBadgeCounter:"disableBadgeCounter",disableChangedPasswordNotification:"disableChangedPasswordNotification",disableContextMenuItem:"disableContextMenuItem",disableFavicon:"disableFavicon",disableGa:"disableGa",dontShowCardsCurrentTab:"dontShowCardsCurrentTab",dontShowIdentitiesCurrentTab:"dontShowIdentitiesCurrentTab",emailVerified:"emailVerified",enableAlwaysOnTop:"enableAlwaysOnTopKey",enableAutoFillOnPageLoad:"enableAutoFillOnPageLoad",enableBiometric:"enabledBiometric",enableBrowserIntegration:"enableBrowserIntegration",enableBrowserIntegrationFingerprint:"enableBrowserIntegrationFingerprint",enableCloseToTray:"enableCloseToTray",enableFullWidth:"enableFullWidth",enableGravatars:"enableGravatars",enableMinimizeToTray:"enableMinimizeToTray",enableStartToTray:"enableStartToTrayKey",enableTray:"enableTray",encKey:"encKey",encOrgKeys:"encOrgKeys",encPrivate:"encPrivateKey",encProviderKeys:"encProviderKeys",entityId:"entityId",entityType:"entityType",environmentUrls:"environmentUrls",equivalentDomains:"equivalentDomains",eventCollection:"eventCollection",forcePasswordReset:"forcePasswordReset",history:"generatedPasswordHistory",installedVersion:"installedVersion",kdf:"kdf",kdfIterations:"kdfIterations",key:"key",keyHash:"keyHash",lastActive:"lastActive",localData:"sitesLocalData",locale:"locale",mainWindowSize:"mainWindowSize",minimizeOnCopyToClipboard:"minimizeOnCopyToClipboardKey",neverDomains:"neverDomains",noAutoPromptBiometricsText:"noAutoPromptBiometricsText",openAtLogin:"openAtLogin",passwordGenerationOptions:"passwordGenerationOptions",pinProtected:"pinProtectedKey",protectedPin:"protectedPin",refreshToken:"refreshToken",ssoCodeVerifier:"ssoCodeVerifier",ssoIdentifier:"ssoOrgIdentifier",ssoState:"ssoState",stamp:"securityStamp",theme:"theme",userEmail:"userEmail",userId:"userId",usesConnector:"usesKeyConnector",vaultTimeoutAction:"vaultTimeoutAction",vaultTimeout:"lockOption",rememberedEmail:"rememberedEmail"},Tr={ciphers:"ciphers_",collections:"collections_",folders:"folders_",lastSync:"lastSync_",policies:"policies_",twoFactorToken:"twoFactorToken_",organizations:"organizations_",providers:"providers_",sends:"sends_",settings:"settings_"},Ir="global",Rr="authenticatedAccounts",Er="activeUserId",Ur="tempAccountSettings",Fr="accountActivity",Nr="_masterkey_auto",zr="_masterkey_biometric",Mr="_masterkey";class Lr{constructor(e,t,i){this.storageService=e,this.secureStorageService=t,this.stateFactory=i}needsMigration(){return Dr(this,void 0,void 0,(function*(){const e=yield this.getCurrentStateVersion();return null==e||e<o.Latest}))}migrate(){return Dr(this,void 0,void 0,(function*(){let e=yield this.getCurrentStateVersion();for(;e<o.Latest;){switch(e){case o.One:yield this.migrateStateFrom1To2();break;case o.Two:yield this.migrateStateFrom2To3();break;case o.Three:yield this.migrateStateFrom3To4();break;case o.Four:{const e=yield this.getAuthenticatedAccounts();for(const t of e){const e=yield this.migrateAccountFrom4To5(t);yield this.set(t.profile.userId,e)}yield this.setCurrentStateVersion(o.Five);break}case o.Five:{const e=yield this.getAuthenticatedAccounts();for(const t of e){const e=yield this.migrateAccountFrom5To6(t);yield this.set(t.profile.userId,e)}yield this.setCurrentStateVersion(o.Six);break}}e+=1}}))}migrateStateFrom1To2(){var e,t,i,n,s,r,a,l,c,d,u,h,p,y,v,g,m,f,b,w,S,k,O,P,A,C,D,x,T,I,R,E,U,F,N,z,M,L,B,K,_,j,G,V,H,q,W,J;return Dr(this,void 0,void 0,(function*(){const Y=e=>Dr(this,void 0,void 0,(function*(){for(const e in xr)null!=e&&(yield this.set(xr[e],null));if(null!=e)for(const e in Tr)null!=e&&(yield this.set(Tr[e]+Q,null))})),$=null!==(e=yield this.get(Ir))&&void 0!==e?e:this.stateFactory.createGlobal(null);$.stateVersion=o.Two,$.environmentUrls=null!==(t=yield this.get(xr.environmentUrls))&&void 0!==t?t:$.environmentUrls,$.locale=null!==(i=yield this.get(xr.locale))&&void 0!==i?i:$.locale,$.noAutoPromptBiometrics=null!==(n=yield this.get(xr.disableAutoBiometricsPrompt))&&void 0!==n?n:$.noAutoPromptBiometrics,$.noAutoPromptBiometricsText=null!==(s=yield this.get(xr.noAutoPromptBiometricsText))&&void 0!==s?s:$.noAutoPromptBiometricsText,$.ssoCodeVerifier=null!==(r=yield this.get(xr.ssoCodeVerifier))&&void 0!==r?r:$.ssoCodeVerifier,$.ssoOrganizationIdentifier=null!==(a=yield this.get(xr.ssoIdentifier))&&void 0!==a?a:$.ssoOrganizationIdentifier,$.ssoState=null!==(l=yield this.get(xr.ssoState))&&void 0!==l?l:$.ssoState,$.rememberedEmail=null!==(c=yield this.get(xr.rememberedEmail))&&void 0!==c?c:$.rememberedEmail,$.theme=null!==(d=yield this.get(xr.theme))&&void 0!==d?d:$.theme,$.vaultTimeout=null!==(u=yield this.get(xr.vaultTimeout))&&void 0!==u?u:$.vaultTimeout,$.vaultTimeoutAction=null!==(h=yield this.get(xr.vaultTimeoutAction))&&void 0!==h?h:$.vaultTimeoutAction,$.window=null!==(p=yield this.get(xr.mainWindowSize))&&void 0!==p?p:$.window,$.enableTray=null!==(y=yield this.get(xr.enableTray))&&void 0!==y?y:$.enableTray,$.enableMinimizeToTray=null!==(v=yield this.get(xr.enableMinimizeToTray))&&void 0!==v?v:$.enableMinimizeToTray,$.enableCloseToTray=null!==(g=yield this.get(xr.enableCloseToTray))&&void 0!==g?g:$.enableCloseToTray,$.enableStartToTray=null!==(m=yield this.get(xr.enableStartToTray))&&void 0!==m?m:$.enableStartToTray,$.openAtLogin=null!==(f=yield this.get(xr.openAtLogin))&&void 0!==f?f:$.openAtLogin,$.alwaysShowDock=null!==(b=yield this.get(xr.alwaysShowDock))&&void 0!==b?b:$.alwaysShowDock,$.enableBrowserIntegration=null!==(w=yield this.get(xr.enableBrowserIntegration))&&void 0!==w?w:$.enableBrowserIntegration,$.enableBrowserIntegrationFingerprint=null!==(S=yield this.get(xr.enableBrowserIntegrationFingerprint))&&void 0!==S?S:$.enableBrowserIntegrationFingerprint;const Q=null!==(k=yield this.get(xr.userId))&&void 0!==k?k:yield this.get(xr.entityId),X=this.stateFactory.createAccount(null),Z={autoConfirmFingerPrints:null!==(O=yield this.get(xr.autoConfirmFingerprints))&&void 0!==O?O:X.settings.autoConfirmFingerPrints,autoFillOnPageLoadDefault:null!==(P=yield this.get(xr.autoFillOnPageLoadDefault))&&void 0!==P?P:X.settings.autoFillOnPageLoadDefault,biometricUnlock:null!==(A=yield this.get(xr.biometricUnlock))&&void 0!==A?A:X.settings.biometricUnlock,clearClipboard:null!==(C=yield this.get(xr.clearClipboard))&&void 0!==C?C:X.settings.clearClipboard,defaultUriMatch:null!==(D=yield this.get(xr.defaultUriMatch))&&void 0!==D?D:X.settings.defaultUriMatch,disableAddLoginNotification:null!==(x=yield this.get(xr.disableAddLoginNotification))&&void 0!==x?x:X.settings.disableAddLoginNotification,disableAutoBiometricsPrompt:null!==(T=yield this.get(xr.disableAutoBiometricsPrompt))&&void 0!==T?T:X.settings.disableAutoBiometricsPrompt,disableAutoTotpCopy:null!==(I=yield this.get(xr.disableAutoTotpCopy))&&void 0!==I?I:X.settings.disableAutoTotpCopy,disableBadgeCounter:null!==(R=yield this.get(xr.disableBadgeCounter))&&void 0!==R?R:X.settings.disableBadgeCounter,disableChangedPasswordNotification:null!==(E=yield this.get(xr.disableChangedPasswordNotification))&&void 0!==E?E:X.settings.disableChangedPasswordNotification,disableContextMenuItem:null!==(U=yield this.get(xr.disableContextMenuItem))&&void 0!==U?U:X.settings.disableContextMenuItem,disableGa:null!==(F=yield this.get(xr.disableGa))&&void 0!==F?F:X.settings.disableGa,dontShowCardsCurrentTab:null!==(N=yield this.get(xr.dontShowCardsCurrentTab))&&void 0!==N?N:X.settings.dontShowCardsCurrentTab,dontShowIdentitiesCurrentTab:null!==(z=yield this.get(xr.dontShowIdentitiesCurrentTab))&&void 0!==z?z:X.settings.dontShowIdentitiesCurrentTab,enableAlwaysOnTop:null!==(M=yield this.get(xr.enableAlwaysOnTop))&&void 0!==M?M:X.settings.enableAlwaysOnTop,enableAutoFillOnPageLoad:null!==(L=yield this.get(xr.enableAutoFillOnPageLoad))&&void 0!==L?L:X.settings.enableAutoFillOnPageLoad,enableBiometric:null!==(B=yield this.get(xr.enableBiometric))&&void 0!==B?B:X.settings.enableBiometric,enableFullWidth:null!==(K=yield this.get(xr.enableFullWidth))&&void 0!==K?K:X.settings.enableFullWidth,enableGravitars:null!==(_=yield this.get(xr.enableGravatars))&&void 0!==_?_:X.settings.enableGravitars,environmentUrls:null!==(j=$.environmentUrls)&&void 0!==j?j:X.settings.environmentUrls,equivalentDomains:null!==(G=yield this.get(xr.equivalentDomains))&&void 0!==G?G:X.settings.equivalentDomains,minimizeOnCopyToClipboard:null!==(V=yield this.get(xr.minimizeOnCopyToClipboard))&&void 0!==V?V:X.settings.minimizeOnCopyToClipboard,neverDomains:null!==(H=yield this.get(xr.neverDomains))&&void 0!==H?H:X.settings.neverDomains,passwordGenerationOptions:null!==(q=yield this.get(xr.passwordGenerationOptions))&&void 0!==q?q:X.settings.passwordGenerationOptions,pinProtected:Object.assign(new Dt,{decrypted:null,encrypted:yield this.get(xr.pinProtected)}),protectedPin:yield this.get(xr.protectedPin),settings:null==Q?null:yield this.get(Tr.settings+Q),vaultTimeout:null!==(W=yield this.get(xr.vaultTimeout))&&void 0!==W?W:X.settings.vaultTimeout,vaultTimeoutAction:null!==(J=yield this.get(xr.vaultTimeoutAction))&&void 0!==J?J:X.settings.vaultTimeoutAction};if(null==Q)return yield this.set(Ur,Z),yield this.set(Ir,$),yield this.set(Rr,[]),yield this.set(Er,null),void(yield Y());$.twoFactorToken=yield this.get(Tr.twoFactorToken+Q),yield this.set(Ir,$),yield this.set(Q,{data:{addEditCipherInfo:null,ciphers:{decrypted:null,encrypted:yield this.get(Tr.ciphers+Q)},collapsedGroupings:null,collections:{decrypted:null,encrypted:yield this.get(Tr.collections+Q)},eventCollection:yield this.get(xr.eventCollection),folders:{decrypted:null,encrypted:yield this.get(Tr.folders+Q)},localData:null,organizations:yield this.get(Tr.organizations+Q),passwordGenerationHistory:{decrypted:null,encrypted:yield this.get(xr.history)},policies:{decrypted:null,encrypted:yield this.get(Tr.policies+Q)},providers:yield this.get(Tr.providers+Q),sends:{decrypted:null,encrypted:yield this.get(Tr.sends+Q)}},keys:{apiKeyClientSecret:yield this.get(xr.clientSecret),cryptoMasterKey:null,cryptoMasterKeyAuto:null,cryptoMasterKeyB64:null,cryptoMasterKeyBiometric:null,cryptoSymmetricKey:{encrypted:yield this.get(xr.encKey),decrypted:null},legacyEtmKey:null,organizationKeys:{decrypted:null,encrypted:yield this.get(xr.encOrgKeys)},privateKey:{decrypted:null,encrypted:yield this.get(xr.encPrivate)},providerKeys:{decrypted:null,encrypted:yield this.get(xr.encProviderKeys)},publicKey:null},profile:{apiKeyClientId:yield this.get(xr.clientId),authenticationStatus:null,convertAccountToKeyConnector:yield this.get(xr.convertAccountToKeyConnector),email:yield this.get(xr.userEmail),emailVerified:yield this.get(xr.emailVerified),entityId:null,entityType:null,everBeenUnlocked:null,forcePasswordReset:null,hasPremiumPersonally:null,kdfIterations:yield this.get(xr.kdfIterations),kdfType:yield this.get(xr.kdf),keyHash:yield this.get(xr.keyHash),lastSync:null,userId:Q,usesKeyConnector:null},settings:Z,tokens:{accessToken:yield this.get(xr.accessToken),decodedToken:null,refreshToken:yield this.get(xr.refreshToken),securityStamp:null}}),yield this.set(Rr,[Q]),yield this.set(Er,Q);const ee={[Q]:yield this.get(xr.lastActive)};ee[Q]=yield this.get(xr.lastActive),yield this.set(Fr,ee),yield Y(Q),(yield this.secureStorageService.has(xr.key,{keySuffix:"biometric"}))&&(yield this.secureStorageService.save(`${Q}${zr}`,yield this.secureStorageService.get(xr.key,{keySuffix:"biometric"}),{keySuffix:"biometric"}),yield this.secureStorageService.remove(xr.key,{keySuffix:"biometric"})),(yield this.secureStorageService.has(xr.key,{keySuffix:"auto"}))&&(yield this.secureStorageService.save(`${Q}${Nr}`,yield this.secureStorageService.get(xr.key,{keySuffix:"auto"}),{keySuffix:"auto"}),yield this.secureStorageService.remove(xr.key,{keySuffix:"auto"})),(yield this.secureStorageService.has(xr.key))&&(yield this.secureStorageService.save(`${Q}${Mr}`,yield this.secureStorageService.get(xr.key)),yield this.secureStorageService.remove(xr.key))}))}migrateStateFrom2To3(){return Dr(this,void 0,void 0,(function*(){const e=yield this.get(Rr);yield Promise.all(e.map((e=>Dr(this,void 0,void 0,(function*(){var t,i;const n=yield this.get(e);if(null===(null===(t=null==n?void 0:n.profile)||void 0===t?void 0:t.hasPremiumPersonally)&&null!=(null===(i=n.tokens)||void 0===i?void 0:i.accessToken)){const t=yield Cr.decodeToken(n.tokens.accessToken);n.profile.hasPremiumPersonally=t.premium,yield this.set(e,n)}})))));const t=yield this.getGlobals();t.stateVersion=o.Three,yield this.set(Ir,t)}))}migrateStateFrom3To4(){return Dr(this,void 0,void 0,(function*(){const e=yield this.get(Rr);yield Promise.all(e.map((e=>Dr(this,void 0,void 0,(function*(){var t;const i=yield this.get(e);if(null!=(null===(t=null==i?void 0:i.profile)||void 0===t?void 0:t.everBeenUnlocked))return delete i.profile.everBeenUnlocked,this.set(e,i)})))));const t=yield this.getGlobals();t.stateVersion=o.Four,yield this.set(Ir,t)}))}migrateAccountFrom4To5(e){var t,i;return Dr(this,void 0,void 0,(function*(){const n=null===(i=null===(t=e.keys)||void 0===t?void 0:t.organizationKeys)||void 0===i?void 0:i.encrypted;if(null!=n)for(const[e,t]of Object.entries(n))n[e]={type:"organization",key:t};return e}))}migrateAccountFrom5To6(e){var t;return Dr(this,void 0,void 0,(function*(){return null===(t=e.keys)||void 0===t||delete t.legacyEtmKey,e}))}get options(){return{htmlStorageLocation:rt.Local}}get(e){return this.storageService.get(e,this.options)}set(e,t){return null==t?this.storageService.remove(e,this.options):this.storageService.save(e,t,this.options)}getGlobals(){return Dr(this,void 0,void 0,(function*(){return yield this.get(Ir)}))}getCurrentStateVersion(){var e,t;return Dr(this,void 0,void 0,(function*(){return null!==(t=null===(e=yield this.getGlobals())||void 0===e?void 0:e.stateVersion)&&void 0!==t?t:o.One}))}setCurrentStateVersion(e){return Dr(this,void 0,void 0,(function*(){const t=yield this.getGlobals();t.stateVersion=e,yield this.set(Ir,t)}))}getAuthenticatedAccounts(){return Dr(this,void 0,void 0,(function*(){const e=yield this.get(Rr);return Promise.all(e.map((e=>this.get(e))))}))}}class Br{constructor(e){this.id=e.id,this.name=e.name,this.status=e.status,this.type=e.type,this.enabled=e.enabled,this.usePolicies=e.usePolicies,this.useGroups=e.useGroups,this.useDirectory=e.useDirectory,this.useEvents=e.useEvents,this.useTotp=e.useTotp,this.use2fa=e.use2fa,this.useApi=e.useApi,this.useSso=e.useSso,this.useKeyConnector=e.useKeyConnector,this.useScim=e.useScim,this.useResetPassword=e.useResetPassword,this.selfHost=e.selfHost,this.usersGetPremium=e.usersGetPremium,this.seats=e.seats,this.maxCollections=e.maxCollections,this.maxStorageGb=e.maxStorageGb,this.ssoBound=e.ssoBound,this.identifier=e.identifier,this.permissions=e.permissions,this.resetPasswordEnrolled=e.resetPasswordEnrolled,this.userId=e.userId,this.hasPublicAndPrivateKeys=e.hasPublicAndPrivateKeys,this.providerId=e.providerId,this.providerName=e.providerName,this.familySponsorshipFriendlyName=e.familySponsorshipFriendlyName,this.familySponsorshipAvailable=e.familySponsorshipAvailable,this.planProductType=e.planProductType,this.keyConnectorEnabled=e.keyConnectorEnabled,this.keyConnectorUrl=e.keyConnectorUrl,this.familySponsorshipLastSyncDate=e.familySponsorshipLastSyncDate,this.familySponsorshipValidUntil=e.familySponsorshipValidUntil,this.familySponsorshipToDelete=e.familySponsorshipToDelete}}class Kr{constructor(e){this.id=e.id,this.name=e.name,this.status=e.status,this.type=e.type,this.enabled=e.enabled,this.userId=e.userId,this.useEvents=e.useEvents}}var _r=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},jr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Gr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Vr{constructor(e,t,i,n,s,r,o,a,l,c,d,u,h,p,y,v){this.apiService=e,this.settingsService=t,this.folderService=i,this.cipherService=n,this.cryptoService=s,this.collectionService=r,this.messagingService=o,this.policyService=a,this.sendService=l,this.logService=c,this.keyConnectorService=d,this.stateService=u,this.organizationService=h,this.providerService=p,this.folderApiService=y,this.logoutCallback=v,this.syncInProgress=!1,this._sync=new wt.x,this.sync$=this._sync.asObservable()}getLastSync(){return Gr(this,void 0,void 0,(function*(){if(null==(yield this.stateService.getUserId()))return null;const e=yield this.stateService.getLastSync();return e?new Date(e):null}))}setLastSync(e,t){return Gr(this,void 0,void 0,(function*(){yield this.stateService.setLastSync(e.toJSON(),{userId:t})}))}fullSync(e,t=!1){return Gr(this,void 0,void 0,(function*(){this.syncStarted();if(!(yield this.stateService.getIsAuthenticated()))return this.syncCompleted(!1);const i=new Date;let n=!1;try{n=yield this.needsSyncing(e)}catch(e){if(t)throw e}if(!n)return yield this.setLastSync(i),this.syncCompleted(!1);try{yield this.apiService.refreshIdentityToken();const e=yield this.apiService.getSync();return yield this.syncProfile(e.profile),yield this.syncFolders(e.folders),yield this.syncCollections(e.collections),yield this.syncCiphers(e.ciphers),yield this.syncSends(e.sends),yield this.syncSettings(e.domains),yield this.syncPolicies(e.policies),yield this.setLastSync(i),this.syncCompleted(!0)}catch(e){if(t)throw e;return this.syncCompleted(!1)}}))}syncUpsertFolder(e,t){return Gr(this,void 0,void 0,(function*(){if(this.syncStarted(),yield this.stateService.getIsAuthenticated())try{const i=yield this.folderService.get(e.id);if(!t&&null==i||t&&null!=i&&i.revisionDate<e.revisionDate){const t=yield this.folderApiService.get(e.id);if(null!=t)return yield this.folderService.upsert(new as(t)),this.messagingService.send("syncedUpsertedFolder",{folderId:e.id}),this.syncCompleted(!0)}}catch(e){this.logService.error(e)}return this.syncCompleted(!1)}))}syncDeleteFolder(e){return Gr(this,void 0,void 0,(function*(){return this.syncStarted(),(yield this.stateService.getIsAuthenticated())?(yield this.folderService.delete(e.id),this.messagingService.send("syncedDeletedFolder",{folderId:e.id}),this.syncCompleted(!0),!0):this.syncCompleted(!1)}))}syncUpsertCipher(e,t){return Gr(this,void 0,void 0,(function*(){if(this.syncStarted(),yield this.stateService.getIsAuthenticated())try{let i=!0;const n=yield this.cipherService.get(e.id);null!=n&&n.revisionDate>=e.revisionDate&&(i=!1);let s=!1;if(i&&(t?(i=null!=n,s=!0):null==e.collectionIds||null==e.organizationId?i=null==n:(i=!1,s=!0)),!i&&s&&null!=e.organizationId&&null!=e.collectionIds&&e.collectionIds.length>0){const t=yield this.collectionService.getAll();if(null!=t)for(let n=0;n<t.length;n++)if(e.collectionIds.indexOf(t[n].id)>-1){i=!0;break}}if(i){const t=yield this.apiService.getFullCipherDetails(e.id);if(null!=t)return yield this.cipherService.upsert(new hi(t)),this.messagingService.send("syncedUpsertedCipher",{cipherId:e.id}),this.syncCompleted(!0)}}catch(i){if(null!=i&&404===i.statusCode&&t)return yield this.cipherService.delete(e.id),this.messagingService.send("syncedDeletedCipher",{cipherId:e.id}),this.syncCompleted(!0)}return this.syncCompleted(!1)}))}syncDeleteCipher(e){return Gr(this,void 0,void 0,(function*(){return this.syncStarted(),(yield this.stateService.getIsAuthenticated())?(yield this.cipherService.delete(e.id),this.messagingService.send("syncedDeletedCipher",{cipherId:e.id}),this.syncCompleted(!0)):this.syncCompleted(!1)}))}syncUpsertSend(e,t){return Gr(this,void 0,void 0,(function*(){if(this.syncStarted(),yield this.stateService.getIsAuthenticated())try{const i=yield this.sendService.get(e.id);if(!t&&null==i||t&&null!=i&&i.revisionDate<e.revisionDate){const t=yield this.apiService.getSend(e.id);if(null!=t)return yield this.sendService.upsert(new cr(t)),this.messagingService.send("syncedUpsertedSend",{sendId:e.id}),this.syncCompleted(!0)}}catch(e){this.logService.error(e)}return this.syncCompleted(!1)}))}syncDeleteSend(e){return Gr(this,void 0,void 0,(function*(){return this.syncStarted(),(yield this.stateService.getIsAuthenticated())?(yield this.sendService.delete(e.id),this.messagingService.send("syncedDeletedSend",{sendId:e.id}),this.syncCompleted(!0),!0):this.syncCompleted(!1)}))}syncStarted(){this.syncInProgress=!0,this.messagingService.send("syncStarted"),this._sync.next({status:"Started"})}syncCompleted(e){return this.syncInProgress=!1,this.messagingService.send("syncCompleted",{successfully:e}),this._sync.next({status:e?"SuccessfullyCompleted":"UnsuccessfullyCompleted"}),e}needsSyncing(e){return Gr(this,void 0,void 0,(function*(){if(e)return!0;const t=yield this.getLastSync();if(null==t||0===t.getTime())return!0;const i=yield this.apiService.getAccountRevisionDate();return!(new Date(i)<=t)}))}syncProfile(e){return Gr(this,void 0,void 0,(function*(){const t=yield this.stateService.getSecurityStamp();if(null!=t&&t!==e.securityStamp)throw null!=this.logoutCallback&&(yield this.logoutCallback(!0)),new Error("Stamp has changed");yield this.cryptoService.setEncKey(e.key),yield this.cryptoService.setEncPrivateKey(e.privateKey),yield this.cryptoService.setProviderKeys(e.providers),yield this.cryptoService.setOrgKeys(e.organizations,e.providerOrganizations),yield this.stateService.setSecurityStamp(e.securityStamp),yield this.stateService.setEmailVerified(e.emailVerified),yield this.stateService.setHasPremiumPersonally(e.premiumPersonally),yield this.stateService.setHasPremiumFromOrganization(e.premiumFromOrganization),yield this.stateService.setForcePasswordReset(e.forcePasswordReset),yield this.keyConnectorService.setUsesKeyConnector(e.usesKeyConnector);const i={};e.organizations.forEach((e=>{i[e.id]=new Br(e)}));const n={};e.providers.forEach((e=>{n[e.id]=new Kr(e)})),e.providerOrganizations.forEach((e=>{null==i[e.id]&&(i[e.id]=new Br(e),i[e.id].isProviderUser=!0)})),yield this.organizationService.save(i),yield this.providerService.save(n),(yield this.keyConnectorService.userNeedsMigration())?(yield this.keyConnectorService.setConvertAccountRequired(!0),this.messagingService.send("convertAccountToKeyConnector")):this.keyConnectorService.removeConvertAccountRequired()}))}syncFolders(e){return Gr(this,void 0,void 0,(function*(){const t={};return e.forEach((e=>{t[e.id]=new as(e)})),yield this.folderService.replace(t)}))}syncCollections(e){return Gr(this,void 0,void 0,(function*(){const t={};return e.forEach((e=>{t[e.id]=new mn(e)})),yield this.collectionService.replace(t)}))}syncCiphers(e){return Gr(this,void 0,void 0,(function*(){const t={};return e.forEach((e=>{t[e.id]=new hi(e)})),yield this.cipherService.replace(t)}))}syncSends(e){return Gr(this,void 0,void 0,(function*(){const t={};return e.forEach((e=>{t[e.id]=new cr(e)})),yield this.sendService.replace(t)}))}syncSettings(e){return Gr(this,void 0,void 0,(function*(){let t=[];return null!=e&&null!=e.equivalentDomains&&(t=t.concat(e.equivalentDomains)),null!=e&&null!=e.globalEquivalentDomains&&e.globalEquivalentDomains.forEach((e=>{e.domains.length>0&&t.push(e.domains)})),this.settingsService.setEquivalentDomains(t)}))}syncPolicies(e){return Gr(this,void 0,void 0,(function*(){const t={};return null!=e&&e.forEach((e=>{t[e.id]=new Vs(e)})),yield this.policyService.replace(t)}))}}_r([ni((()=>"fullSync")),jr("design:type",Function),jr("design:paramtypes",[Boolean,Object]),jr("design:returntype",Promise)],Vr.prototype,"fullSync",null);var Hr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class qr{constructor(e,t,i=null,n){this.messagingService=e,this.platformUtilsService=t,this.reloadCallback=i,this.stateService=n,this.reloadInterval=null,this.clearClipboardTimeout=null,this.clearClipboardTimeoutFunction=null}startProcessReload(e){return Hr(this,void 0,void 0,(function*(){const t=this.stateService.accounts.getValue();if(null!=t){const i=Object.keys(t);if(i.length>0)for(const t of i)if((yield e.getAuthStatus(t))===n.Unlocked)return}if(null!=this.reloadInterval)return;null==(yield this.stateService.getDecryptedPinProtected())&&(this.cancelProcessReload(),this.reloadInterval=setInterval((()=>Hr(this,void 0,void 0,(function*(){return yield this.executeProcessReload()}))),1e4))}))}inactiveMoreThanSeconds(e){return Hr(this,void 0,void 0,(function*(){const t=yield this.stateService.getLastActive();if(null!=t){return(new Date).getTime()-t>=1e3*e}return!0}))}executeProcessReload(){return Hr(this,void 0,void 0,(function*(){const e=this.stateService.accounts.getValue(),t=null==e||0==Object.keys(e).length||(yield this.inactiveMoreThanSeconds(5)),i=yield this.stateService.getBiometricFingerprintValidated();t&&!i&&(clearInterval(this.reloadInterval),this.reloadInterval=null,this.messagingService.send("reloadProcess"),null!=this.reloadCallback&&(yield this.reloadCallback()))}))}cancelProcessReload(){null!=this.reloadInterval&&(clearInterval(this.reloadInterval),this.reloadInterval=null)}clearClipboard(e,t=null){return Hr(this,void 0,void 0,(function*(){null!=this.clearClipboardTimeout&&(clearTimeout(this.clearClipboardTimeout),this.clearClipboardTimeout=null),f.isNullOrWhitespace(e)||(yield this.stateService.getClearClipboard().then((i=>{null!=i&&(null==t&&(t=1e3*i),this.clearClipboardTimeoutFunction=()=>Hr(this,void 0,void 0,(function*(){const t=yield this.platformUtilsService.readFromClipboard();e===t&&this.platformUtilsService.copyToClipboard("",{clearing:!0})})),this.clearClipboardTimeout=setTimeout((()=>Hr(this,void 0,void 0,(function*(){yield this.clearPendingClipboard()}))),t))})))}))}clearPendingClipboard(){return Hr(this,void 0,void 0,(function*(){null!=this.clearClipboardTimeoutFunction&&(yield this.clearClipboardTimeoutFunction(),this.clearClipboardTimeoutFunction=null)}))}}var Wr=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const Jr="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Yr="23456789BCDFGHJKMNPQRTVWXY";class $r{constructor(e,t){this.cryptoFunctionService=e,this.logService=t}getCode(e){return Wr(this,void 0,void 0,(function*(){if(null==e)return null;let t=30,i="sha1",n=6,s=e;const r=0===e.toLowerCase().indexOf("otpauth://"),o=!r&&0===e.toLowerCase().indexOf("steam://");if(r){const r=f.getQueryParams(e);if(r.has("digits")&&null!=r.get("digits"))try{const e=parseInt(r.get("digits").trim(),null);e>10?n=10:e>0&&(n=e)}catch(e){this.logService.error("Invalid digits param.")}if(r.has("period")&&null!=r.get("period"))try{const e=parseInt(r.get("period").trim(),null);e>0&&(t=e)}catch(e){this.logService.error("Invalid period param.")}if(r.has("secret")&&null!=r.get("secret")&&(s=r.get("secret")),r.has("algorithm")&&null!=r.get("algorithm")){const e=r.get("algorithm").toLowerCase();"sha1"!==e&&"sha256"!==e&&"sha512"!==e||(i=e)}}else o&&(s=e.substr("steam://".length),n=5);const a=Math.round((new Date).getTime()/1e3),l=this.leftPad(this.decToHex(Math.floor(a/t)),16,"0"),c=f.fromHexToArray(l),d=this.b32ToBytes(s);if(!d.length||!c.length)return null;const u=yield this.sign(d,c,i);if(0===u.length)return null;const h=15&u[u.length-1],p=(127&u[h])<<24|(255&u[h+1])<<16|(255&u[h+2])<<8|255&u[h+3];let y="";if(o){let e=2147483647&p;for(let t=0;t<n;t++)y+=Yr[e%Yr.length],e=Math.trunc(e/Yr.length)}else y=(p%Math.pow(10,n)).toString(),y=this.leftPad(y,n,"0");return y}))}getTimeInterval(e){let t=30;if(null!=e&&0===e.toLowerCase().indexOf("otpauth://")){const i=f.getQueryParams(e);if(i.has("period")&&null!=i.get("period"))try{t=parseInt(i.get("period").trim(),null)}catch(e){this.logService.error("Invalid period param.")}}return t}leftPad(e,t,i){return t+1>=e.length&&(e=Array(t+1-e.length).join(i)+e),e}decToHex(e){return(e<15.5?"0":"")+Math.round(e).toString(16)}b32ToHex(e){e=e.toUpperCase();let t="";for(let i=0;i<e.length;i++)Jr.indexOf(e[i])<0||(t+=e[i]);e=t;let i="",n="";for(let t=0;t<e.length;t++){const n=Jr.indexOf(e.charAt(t));n<0||(i+=this.leftPad(n.toString(2),5,"0"))}for(let e=0;e+4<=i.length;e+=4){const t=i.substr(e,4);n+=parseInt(t,2).toString(16)}return n}b32ToBytes(e){return f.fromHexToArray(this.b32ToHex(e))}sign(e,t,i){return Wr(this,void 0,void 0,(function*(){const n=yield this.cryptoFunctionService.hmac(t.buffer,e.buffer,i);return new Uint8Array(n)}))}}const Qr={[ft.Authenticator]:{type:ft.Authenticator,name:null,description:null,priority:1,sort:1,premium:!1},[ft.Yubikey]:{type:ft.Yubikey,name:null,description:null,priority:3,sort:2,premium:!0},[ft.Duo]:{type:ft.Duo,name:"Duo",description:null,priority:2,sort:3,premium:!0},[ft.OrganizationDuo]:{type:ft.OrganizationDuo,name:"Duo (Organization)",description:null,priority:10,sort:4,premium:!1},[ft.Email]:{type:ft.Email,name:null,description:null,priority:0,sort:6,premium:!1},[ft.WebAuthn]:{type:ft.WebAuthn,name:null,description:null,priority:4,sort:5,premium:!0}};class Xr{constructor(e,t){this.i18nService=e,this.platformUtilsService=t,this.selectedTwoFactorProviderType=null}init(){Qr[ft.Email].name=this.i18nService.t("emailTitle"),Qr[ft.Email].description=this.i18nService.t("emailDesc"),Qr[ft.Authenticator].name=this.i18nService.t("authenticatorAppTitle"),Qr[ft.Authenticator].description=this.i18nService.t("authenticatorAppDesc"),Qr[ft.Duo].description=this.i18nService.t("duoDesc"),Qr[ft.OrganizationDuo].name="Duo ("+this.i18nService.t("organization")+")",Qr[ft.OrganizationDuo].description=this.i18nService.t("duoOrganizationDesc"),Qr[ft.WebAuthn].name=this.i18nService.t("webAuthnTitle"),Qr[ft.WebAuthn].description=this.i18nService.t("webAuthnDesc"),Qr[ft.Yubikey].name=this.i18nService.t("yubiKeyTitle"),Qr[ft.Yubikey].description=this.i18nService.t("yubiKeyDesc")}getSupportedProviders(e){const t=[];return null==this.twoFactorProvidersData||(this.twoFactorProvidersData.has(ft.OrganizationDuo)&&this.platformUtilsService.supportsDuo()&&t.push(Qr[ft.OrganizationDuo]),this.twoFactorProvidersData.has(ft.Authenticator)&&t.push(Qr[ft.Authenticator]),this.twoFactorProvidersData.has(ft.Yubikey)&&t.push(Qr[ft.Yubikey]),this.twoFactorProvidersData.has(ft.Duo)&&this.platformUtilsService.supportsDuo()&&t.push(Qr[ft.Duo]),this.twoFactorProvidersData.has(ft.WebAuthn)&&this.platformUtilsService.supportsWebAuthn(e)&&t.push(Qr[ft.WebAuthn]),this.twoFactorProvidersData.has(ft.Email)&&t.push(Qr[ft.Email])),t}getDefaultProvider(e){if(null==this.twoFactorProvidersData)return null;if(null!=this.selectedTwoFactorProviderType&&this.twoFactorProvidersData.has(this.selectedTwoFactorProviderType))return this.selectedTwoFactorProviderType;let t=null,i=-1;return this.twoFactorProvidersData.forEach(((n,s)=>{const r=Qr[s];if(null!=r&&r.priority>i){if(s===ft.WebAuthn&&!e)return;t=s,i=r.priority}})),t}setSelectedProvider(e){this.selectedTwoFactorProviderType=e}clearSelectedProvider(){this.selectedTwoFactorProviderType=null}setProviders(e){this.twoFactorProvidersData=e.twoFactorProviders2}clearProviders(){this.twoFactorProvidersData=null}getProviders(){return this.twoFactorProvidersData}}var Zr,eo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class to{constructor(e){this.apiService=e}postAccountVerifyOTP(e){return this.apiService.send("POST","/accounts/verify-otp",e,!0,!1)}postAccountRequestOTP(){return eo(this,void 0,void 0,(function*(){return this.apiService.send("POST","/accounts/request-otp",null,!0,!1)}))}}!function(e){e[e.MasterPassword=0]="MasterPassword",e[e.OTP=1]="OTP"}(Zr||(Zr={}));class io{constructor(e){this.OTP=e}}class no{}var so=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ro{constructor(e,t,i){this.cryptoService=e,this.i18nService=t,this.userVerificationApiService=i}buildRequest(e,t,i){return so(this,void 0,void 0,(function*(){this.validateInput(e);const n=null!=t?new t:new no;return e.type===Zr.OTP?n.otp=e.secret:n.masterPasswordHash=i?e.secret:yield this.cryptoService.hashPassword(e.secret,null),n}))}verifyUser(e){return so(this,void 0,void 0,(function*(){if(this.validateInput(e),e.type===Zr.OTP){const t=new io(e.secret);try{yield this.userVerificationApiService.postAccountVerifyOTP(t)}catch(e){throw new Error(this.i18nService.t("invalidVerificationCode"))}}else{if(!(yield this.cryptoService.compareAndUpdateKeyHash(e.secret,null)))throw new Error(this.i18nService.t("invalidMasterPassword"))}return!0}))}requestOTP(){return so(this,void 0,void 0,(function*(){yield this.userVerificationApiService.postAccountRequestOTP()}))}validateInput(e){if(null==(null==e?void 0:e.secret)||""===e.secret)throw e.type===Zr.OTP?new Error(this.i18nService.t("verificationCodeRequired")):new Error(this.i18nService.t("masterPasswordRequired"))}}var oo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ao{generate(e,t){var i,n;return oo(this,void 0,void 0,(function*(){if(null==t.apiKey||""===t.apiKey)throw"Invalid AnonAddy API token.";if(null==(null===(i=t.anonaddy)||void 0===i?void 0:i.domain)||""===t.anonaddy.domain)throw"Invalid AnonAddy domain.";const s={redirect:"manual",cache:"no-store",method:"POST",headers:new Headers({Authorization:"Bearer "+t.apiKey,"Content-Type":"application/json"})};s.body=JSON.stringify({domain:t.anonaddy.domain,description:(null!=t.website?"Website: "+t.website+". ":"")+"Generated by Bitwarden."});const r=new Request("https://app.anonaddy.com/api/v1/aliases",s),o=yield e.nativeFetch(r);if(200===o.status||201===o.status){const e=yield o.json();return null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.email}if(401===o.status)throw"Invalid AnonAddy API token.";throw"Unknown AnonAddy error occurred."}))}}var lo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class co{generate(e,t){return lo(this,void 0,void 0,(function*(){if(null==t.apiKey||""===t.apiKey)throw"Invalid DuckDuckGo API token.";const i={redirect:"manual",cache:"no-store",method:"POST",headers:new Headers({Authorization:"Bearer "+t.apiKey,"Content-Type":"application/json"})},n=new Request("https://quack.duckduckgo.com/api/email/addresses",i),s=yield e.nativeFetch(n);if(200===s.status||201===s.status){const e=yield s.json();if(e.address)return`${e.address}@duck.com`}else if(401===s.status)throw"Invalid DuckDuckGo API token.";throw"Unknown DuckDuckGo error occurred."}))}}var uo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ho{generate(e,t){var i,n,s,r,o,a,l,c,d,u,h;return uo(this,void 0,void 0,(function*(){if(null==t.apiKey||""===t.apiKey)throw"Invalid Fastmail API token.";const p=yield this.getAccountId(e,t);if(null==p||""===p)throw"Unable to obtain Fastmail masked email account ID.";const y={redirect:"manual",cache:"no-store",method:"POST",headers:new Headers({Authorization:"Bearer "+t.apiKey,"Content-Type":"application/json"})};y.body=JSON.stringify({using:["https://www.fastmail.com/dev/maskedemail","urn:ietf:params:jmap:core"],methodCalls:[["MaskedEmail/set",{accountId:p,create:{"new-masked-email":{state:"enabled",description:"",url:t.website,emailPrefix:t.fastmail.prefix}}},"0"]]});const v=new Request("https://api.fastmail.com/jmap/api/",y),g=yield e.nativeFetch(v);if(200===g.status){const e=yield g.json();if(null!=e.methodResponses&&e.methodResponses.length>0&&e.methodResponses[0].length>0)if("MaskedEmail/set"===e.methodResponses[0][0]){if(null!=(null===(n=null===(i=e.methodResponses[0][1])||void 0===i?void 0:i.created)||void 0===n?void 0:n["new-masked-email"]))return null===(o=null===(r=null===(s=e.methodResponses[0][1])||void 0===s?void 0:s.created)||void 0===r?void 0:r["new-masked-email"])||void 0===o?void 0:o.email;if(null!=(null===(l=null===(a=e.methodResponses[0][1])||void 0===a?void 0:a.notCreated)||void 0===l?void 0:l["new-masked-email"]))throw"Fastmail error: "+(null===(u=null===(d=null===(c=e.methodResponses[0][1])||void 0===c?void 0:c.notCreated)||void 0===d?void 0:d["new-masked-email"])||void 0===u?void 0:u.description)}else if("error"===e.methodResponses[0][0])throw"Fastmail error: "+(null===(h=e.methodResponses[0][1])||void 0===h?void 0:h.description)}if(401===g.status||403===g.status)throw"Invalid Fastmail API token.";throw"Unknown Fastmail error occurred."}))}getAccountId(e,t){return uo(this,void 0,void 0,(function*(){const i={cache:"no-store",method:"GET",headers:new Headers({Authorization:"Bearer "+t.apiKey})},n=new Request("https://api.fastmail.com/.well-known/jmap",i),s=yield e.nativeFetch(n);if(200===s.status){const e=yield s.json();if(null!=e.primaryAccounts)return e.primaryAccounts["https://www.fastmail.com/dev/maskedemail"]}return null}))}}var po=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class yo{generate(e,t){return po(this,void 0,void 0,(function*(){if(null==t.apiKey||""===t.apiKey)throw"Invalid Firefox Relay API token.";const i={redirect:"manual",cache:"no-store",method:"POST",headers:new Headers({Authorization:"Token "+t.apiKey,"Content-Type":"application/json"})};i.body=JSON.stringify({enabled:!0,generated_for:t.website,description:(null!=t.website?t.website+" - ":"")+"Generated by Bitwarden."});const n=new Request("https://relay.firefox.com/api/v1/relayaddresses/",i),s=yield e.nativeFetch(n);if(200===s.status||201===s.status){const e=yield s.json();return null==e?void 0:e.full_address}if(401===s.status)throw"Invalid Firefox Relay API token.";throw"Unknown Firefox Relay error occurred."}))}}class vo{constructor(){this.fastmail=new go,this.anonaddy=new mo}}class go{}class mo{}var fo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class bo{generate(e,t){return fo(this,void 0,void 0,(function*(){if(null==t.apiKey||""===t.apiKey)throw"Invalid SimpleLogin API key.";const i={redirect:"manual",cache:"no-store",method:"POST",headers:new Headers({Authentication:t.apiKey,"Content-Type":"application/json"})};let n="https://app.simplelogin.io/api/alias/random/new";null!=t.website&&(n+="?hostname="+t.website),i.body=JSON.stringify({note:(null!=t.website?"Website: "+t.website+". ":"")+"Generated by Bitwarden."});const s=new Request(n,i),r=yield e.nativeFetch(s);if(200===r.status||201===r.status){return(yield r.json()).alias}if(401===r.status)throw"Invalid SimpleLogin API key.";try{const e=yield r.json();if(null!=(null==e?void 0:e.error))throw"SimpleLogin error:"+e.error}catch(e){}throw"Unknown SimpleLogin error occurred."}))}}var wo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const So={type:"word",wordCapitalize:!0,wordIncludeNumber:!0,subaddressType:"random",catchallType:"random",forwardedService:"simplelogin",forwardedAnonAddyDomain:"anonaddy.me"};class ko{constructor(e,t,i){this.cryptoService=e,this.stateService=t,this.apiService=i}generateUsername(e){return"catchall"===e.type?this.generateCatchall(e):"subaddress"===e.type?this.generateSubaddress(e):"forwarded"===e.type?this.generateForwarded(e):this.generateWord(e)}generateWord(e){return wo(this,void 0,void 0,(function*(){const t=Object.assign({},So,e);null==t.wordCapitalize&&(t.wordCapitalize=!0),null==t.wordIncludeNumber&&(t.wordIncludeNumber=!0);const i=yield this.cryptoService.randomNumber(0,Ls.length-1);let n=Ls[i];if(t.wordCapitalize&&(n=n.charAt(0).toUpperCase()+n.slice(1)),t.wordIncludeNumber){const e=yield this.cryptoService.randomNumber(1,9999);n+=this.zeroPad(e.toString(),4)}return n}))}generateSubaddress(e){return wo(this,void 0,void 0,(function*(){const t=Object.assign({},So,e),i=t.subaddressEmail;if(null==i||i.length<3)return t.subaddressEmail;const n=i.indexOf("@");if(n<1||n>=i.length-1)return i;null==t.subaddressType&&(t.subaddressType="random");const s=i.substr(0,n),r=i.substr(n+1,i.length);let o="";return"random"===t.subaddressType?o=yield this.randomString(8):"website-name"===t.subaddressType&&(o=t.website),s+"+"+o+"@"+r}))}generateCatchall(e){return wo(this,void 0,void 0,(function*(){const t=Object.assign({},So,e);if(null==t.catchallDomain||""===t.catchallDomain)return null;null==t.catchallType&&(t.catchallType="random");let i="";return"random"===t.catchallType?i=yield this.randomString(8):"website-name"===t.catchallType&&(i=t.website),i+"@"+t.catchallDomain}))}generateForwarded(e){return wo(this,void 0,void 0,(function*(){const t=Object.assign({},So,e);if(null==t.forwardedService)return null;let i=null;const n=new vo;return n.website=t.website,"simplelogin"===t.forwardedService?(i=new bo,n.apiKey=t.forwardedSimpleLoginApiKey):"anonaddy"===t.forwardedService?(i=new ao,n.apiKey=t.forwardedAnonAddyApiToken,n.anonaddy.domain=t.forwardedAnonAddyDomain):"firefoxrelay"===t.forwardedService?(i=new yo,n.apiKey=t.forwardedFirefoxApiToken):"fastmail"===t.forwardedService?(i=new ho,n.apiKey=t.forwardedFastmailApiToken):"duckduckgo"===t.forwardedService&&(i=new co,n.apiKey=t.forwardedDuckDuckGoToken),null==i?null:i.generate(this.apiService,n)}))}getOptions(){return wo(this,void 0,void 0,(function*(){let e=yield this.stateService.getUsernameGenerationOptions();return e=null==e?Object.assign({},So):Object.assign({},So,e),yield this.stateService.setUsernameGenerationOptions(e),e}))}saveOptions(e){return wo(this,void 0,void 0,(function*(){yield this.stateService.setUsernameGenerationOptions(e)}))}randomString(e){return wo(this,void 0,void 0,(function*(){let t="";const i="abcdefghijklmnopqrstuvwxyz1234567890";for(let n=0;n<e;n++){const e=yield this.cryptoService.randomNumber(0,i.length-1);t+=i.charAt(e)}return t}))}zeroPad(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e}}var Oo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Po{constructor(e,t,i,n){this.cryptoService=e,this.tokenService=t,this.policyService=i,this.stateService=n}setVaultTimeoutOptions(e,t){return Oo(this,void 0,void 0,(function*(){yield this.stateService.setVaultTimeout(e);const i=yield this.tokenService.getToken(),n=yield this.tokenService.getRefreshToken(),s=yield this.tokenService.getClientId(),r=yield this.tokenService.getClientSecret(),o=yield this.stateService.getVaultTimeoutAction();null==e&&0!==e||"logOut"!==t||t===o||(yield this.tokenService.clearToken()),yield this.stateService.setVaultTimeoutAction(t),yield this.tokenService.setToken(i),yield this.tokenService.setRefreshToken(n),yield this.tokenService.setClientId(s),yield this.tokenService.setClientSecret(r),yield this.cryptoService.toggleKey()}))}isPinLockSet(){return Oo(this,void 0,void 0,(function*(){return[null!=(yield this.stateService.getProtectedPin()),null!=(yield this.stateService.getEncryptedPinProtected())]}))}isBiometricLockSet(){return Oo(this,void 0,void 0,(function*(){return yield this.stateService.getBiometricUnlock()}))}getVaultTimeout(e){return Oo(this,void 0,void 0,(function*(){const t=yield this.stateService.getVaultTimeout({userId:e});if(yield this.policyService.policyAppliesToUser(zs.MaximumVaultTimeout,null,e)){const i=yield this.policyService.getAll(zs.MaximumVaultTimeout,e);let n=Math.min(t,i[0].data.minutes);return(null==t||n<0)&&(n=i[0].data.minutes),t!==n&&(yield this.stateService.setVaultTimeout(n,{userId:e})),n}return t}))}clear(e){return Oo(this,void 0,void 0,(function*(){yield this.stateService.setEverBeenUnlocked(!1,{userId:e}),yield this.stateService.setDecryptedPinProtected(null,{userId:e}),yield this.stateService.setProtectedPin(null,{userId:e})}))}}var Ao=i(57897);class Co{}var Do=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class xo{constructor(e){this.crypto=void 0!==e.crypto?e.crypto:null,this.subtle=this.crypto&&void 0!==e.crypto.subtle?e.crypto.subtle:null}pbkdf2(e,t,i,n){return Do(this,void 0,void 0,(function*(){const s="sha256"===i?256:512,r=this.toBuf(e),o={name:"PBKDF2",salt:this.toBuf(t),iterations:n,hash:{name:this.toWebCryptoAlgorithm(i)}},a=yield this.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]);return yield this.subtle.deriveBits(o,a,s)}))}hkdf(e,t,i,n,s){return Do(this,void 0,void 0,(function*(){const r={name:"HKDF",salt:this.toBuf(t),info:this.toBuf(i),hash:{name:this.toWebCryptoAlgorithm(s)}},o=yield this.subtle.importKey("raw",e,{name:"HKDF"},!1,["deriveBits"]);return yield this.subtle.deriveBits(r,o,8*n)}))}hkdfExpand(e,t,i,n){return Do(this,void 0,void 0,(function*(){const s="sha256"===n?32:64;if(i>255*s)throw new Error("outputByteSize is too large.");if(new Uint8Array(e).length<s)throw new Error("prk is too small.");const r=this.toBuf(t),o=new Uint8Array(r);let a=0,l=new Uint8Array(0);const c=Math.ceil(i/s),d=new Uint8Array(c*s);for(let t=0;t<c;t++){const s=new Uint8Array(l.length+o.length+1);if(s.set(l),s.set(o,l.length),s.set([t+1],s.length-1),l=new Uint8Array(yield this.hmac(s.buffer,e,n)),d.set(l,a),a+=l.length,a>=i)break}return d.slice(0,i).buffer}))}hash(e,t){return Do(this,void 0,void 0,(function*(){if("md5"===t){const i="md5"===t?Ao.md.md5.create():Ao.md.sha1.create(),n=this.toByteString(e);return i.update(n,"raw"),f.fromByteStringToArray(i.digest().data).buffer}const i=this.toBuf(e);return yield this.subtle.digest({name:this.toWebCryptoAlgorithm(t)},i)}))}hmac(e,t,i){return Do(this,void 0,void 0,(function*(){const n={name:"HMAC",hash:{name:this.toWebCryptoAlgorithm(i)}},s=yield this.subtle.importKey("raw",t,n,!1,["sign"]);return yield this.subtle.sign(n,s,e)}))}compare(e,t){return Do(this,void 0,void 0,(function*(){const i=yield this.randomBytes(32),n={name:"HMAC",hash:{name:"SHA-256"}},s=yield this.subtle.importKey("raw",i,n,!1,["sign"]),r=yield this.subtle.sign(n,s,e),o=yield this.subtle.sign(n,s,t);if(r.byteLength!==o.byteLength)return!1;const a=new Uint8Array(r),l=new Uint8Array(o);for(let e=0;e<l.length;e++)if(a[e]!==l[e])return!1;return!0}))}hmacFast(e,t,i){const n=Ao.hmac.create();n.start(i,t),n.update(e);const s=n.digest().getBytes();return Promise.resolve(s)}compareFast(e,t){return Do(this,void 0,void 0,(function*(){const i=yield this.randomBytes(32),n=new Uint32Array(i),s=Ao.util.createBuffer();for(let e=0;e<n.length;e++)s.putInt32(n[e]);const r=s.getBytes(),o=Ao.hmac.create();o.start("sha256",r),o.update(e);const a=o.digest().getBytes();o.start(null,null),o.update(t);return a===o.digest().getBytes()}))}aesEncrypt(e,t,i){return Do(this,void 0,void 0,(function*(){const n=yield this.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["encrypt"]);return yield this.subtle.encrypt({name:"AES-CBC",iv:t},n,e)}))}aesDecryptFastParameters(e,t,i,n){const s=new Co;return null!=n.meta&&(s.encKey=n.meta.encKeyByteString,s.macKey=n.meta.macKeyByteString),null==s.encKey&&(s.encKey=Ao.util.decode64(n.encKeyB64)),s.data=Ao.util.decode64(e),s.iv=Ao.util.decode64(t),s.macData=s.iv+s.data,null==s.macKey&&null!=n.macKeyB64&&(s.macKey=Ao.util.decode64(n.macKeyB64)),null!=i&&(s.mac=Ao.util.decode64(i)),null==n.meta&&(n.meta={}),null==n.meta.encKeyByteString&&(n.meta.encKeyByteString=s.encKey),null!=s.macKey&&null==n.meta.macKeyByteString&&(n.meta.macKeyByteString=s.macKey),s}aesDecryptFast(e){const t=Ao.util.createBuffer(e.data),i=Ao.cipher.createDecipher("AES-CBC",e.encKey);i.start({iv:e.iv}),i.update(t),i.finish();const n=i.output.toString();return Promise.resolve(n)}aesDecrypt(e,t,i){return Do(this,void 0,void 0,(function*(){const n=yield this.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["decrypt"]);return yield this.subtle.decrypt({name:"AES-CBC",iv:t},n,e)}))}rsaEncrypt(e,t,i){return Do(this,void 0,void 0,(function*(){const n={name:"RSA-OAEP",hash:{name:this.toWebCryptoAlgorithm(i)}},s=yield this.subtle.importKey("spki",t,n,!1,["encrypt"]);return yield this.subtle.encrypt(n,s,e)}))}rsaDecrypt(e,t,i){return Do(this,void 0,void 0,(function*(){const n={name:"RSA-OAEP",hash:{name:this.toWebCryptoAlgorithm(i)}},s=yield this.subtle.importKey("pkcs8",t,n,!1,["decrypt"]);return yield this.subtle.decrypt(n,s,e)}))}rsaExtractPublicKey(e){return Do(this,void 0,void 0,(function*(){const t={name:"RSA-OAEP",hash:{name:this.toWebCryptoAlgorithm("sha1")}},i=yield this.subtle.importKey("pkcs8",e,t,!0,["decrypt"]),n=yield this.subtle.exportKey("jwk",i),s={kty:"RSA",e:n.e,n:n.n,alg:"RSA-OAEP",ext:!0},r=yield this.subtle.importKey("jwk",s,t,!0,["encrypt"]);return yield this.subtle.exportKey("spki",r)}))}rsaGenerateKeyPair(e){return Do(this,void 0,void 0,(function*(){const t={name:"RSA-OAEP",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:this.toWebCryptoAlgorithm("sha1")}},i=yield this.subtle.generateKey(t,!0,["encrypt","decrypt"]);return[yield this.subtle.exportKey("spki",i.publicKey),yield this.subtle.exportKey("pkcs8",i.privateKey)]}))}randomBytes(e){const t=new Uint8Array(e);return this.crypto.getRandomValues(t),Promise.resolve(t.buffer)}toBuf(e){let t;return t="string"==typeof e?f.fromUtf8ToArray(e).buffer:e,t}toByteString(e){let t;return t="string"==typeof e?Ao.util.encodeUtf8(e):f.fromBufferToByteString(e),t}toWebCryptoAlgorithm(e){if("md5"===e)throw new Error("MD5 is not supported in WebCrypto.");return"sha1"===e?"SHA-1":"sha256"===e?"SHA-256":"SHA-512"}}var To=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Io{static getTabFromCurrentWindowId(){return To(this,void 0,void 0,(function*(){return yield Io.tabsQueryFirst({active:!0,windowId:chrome.windows.WINDOW_ID_CURRENT})}))}static getTabFromCurrentWindow(){return To(this,void 0,void 0,(function*(){return yield Io.tabsQueryFirst({active:!0,currentWindow:!0})}))}static getActiveTabs(){return To(this,void 0,void 0,(function*(){return yield Io.tabsQuery({active:!0})}))}static tabsQuery(e){return To(this,void 0,void 0,(function*(){return new Promise((t=>{chrome.tabs.query(e,(e=>{t(e)}))}))}))}static tabsQueryFirst(e){return To(this,void 0,void 0,(function*(){const t=yield Io.tabsQuery(e);return t.length>0?t[0]:null}))}static tabSendMessageData(e,t,i=null){const n={command:t};return null!=i&&(n.data=i),Io.tabSendMessage(e,n)}static tabSendMessage(e,t,i=null){return To(this,void 0,void 0,(function*(){if(e&&e.id)return new Promise((n=>{chrome.tabs.sendMessage(e.id,t,i,(()=>{chrome.runtime.lastError,n()}))}))}))}static getPrivateModeWindows(){return To(this,void 0,void 0,(function*(){return(yield browser.windows.getAll()).filter((e=>e.incognito))}))}static onWindowCreated(e){return To(this,void 0,void 0,(function*(){return chrome.windows.onCreated.addListener(e)}))}static getBackgroundPage(){return chrome.extension.getBackgroundPage()}static getApplicationVersion(){return chrome.runtime.getManifest().version}static isPopupOpen(){return To(this,void 0,void 0,(function*(){return Promise.resolve(chrome.extension.getViews({type:"popup"}).length>0)}))}static createNewTab(e,t=!1,i=!0){chrome.tabs.create({url:e,active:i})}static messageListener(e,t){chrome.runtime.onMessage.addListener(((e,i,n)=>{t(e,i,n)}))}static sendMessage(e,t={}){const i=Object.assign({},{command:e},t);return chrome.runtime.sendMessage(i)}static closeLoginTab(){return To(this,void 0,void 0,(function*(){const e=yield Io.tabsQuery({active:!0,title:"Bitwarden",windowType:"normal",currentWindow:!0});if(0===e.length)return;const t=e[e.length-1].id;chrome.tabs.remove(t)}))}static focusSpecifiedTab(e){return To(this,void 0,void 0,(function*(){chrome.tabs.update(e,{active:!0,highlighted:!0})}))}static closePopup(e){Io.isWebExtensionsApi&&Io.isFirefoxOnAndroid?browser.tabs.update({active:!0}).finally(e.close):e.close()}static gaFilter(){return!1}static getUILanguage(e){return chrome.i18n.getUILanguage()}static reloadExtension(e){return null!=e?e.location.reload(!0):chrome.runtime.reload()}static reloadOpenWindows(){chrome.extension.getViews().filter((e=>null!=e.location.href)).forEach((e=>{e.location.reload()}))}static connectNative(e){return Io.isWebExtensionsApi?browser.runtime.connectNative(e):Io.isChromeApi?chrome.runtime.connectNative(e):void 0}static requestPermission(e){return Io.isWebExtensionsApi?browser.permissions.request(e):new Promise(((t,i)=>{chrome.permissions.request(e,t)}))}static getPlatformInfo(){return Io.isWebExtensionsApi?browser.runtime.getPlatformInfo():new Promise((e=>{chrome.runtime.getPlatformInfo(e)}))}}Io.isWebExtensionsApi="undefined"!=typeof browser,Io.isSafariApi=-1!==navigator.userAgent.indexOf(" Safari/")&&-1===navigator.userAgent.indexOf(" Chrome/")&&-1===navigator.userAgent.indexOf(" Chromium/"),Io.isChromeApi=!Io.isSafariApi&&"undefined"!=typeof chrome,Io.isFirefoxOnAndroid=-1!==navigator.userAgent.indexOf("Firefox/")&&-1!==navigator.userAgent.indexOf("Android");class Ro{static sendMessageToApp(e,t=null,i=!1){return Io.isSafariApi?new Promise((i=>{const n=(new Date).getTime().toString()+"_"+Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);browser.runtime.sendNativeMessage("com.bitwarden.desktop",{id:n,command:e,data:t,responseData:null},(e=>{i(e)}))})):Promise.resolve(null)}}class Eo{}class Uo extends Eo{}class Fo extends Eo{}class No extends Ut{constructor(){super(...arguments),this.vaultTimeout=-1}}class zo extends Nt{constructor(e){var t,i,n,s;super(e),this.settings=new No,Object.assign(this.settings,Object.assign(Object.assign({},new No),this.settings)),this.groupings=null!==(t=null==e?void 0:e.groupings)&&void 0!==t?t:new Uo,this.send=null!==(i=null==e?void 0:e.send)&&void 0!==i?i:new Fo,this.ciphers=null!==(n=null==e?void 0:e.ciphers)&&void 0!==n?n:new Eo,this.sendType=null!==(s=null==e?void 0:e.sendType)&&void 0!==s?s:new Eo}}var Mo=i(78470);class Lo{constructor(e=!1){this.privateMode=e}inSidebar(e){return""!==e.location.search&&e.location.search.indexOf("uilocation=sidebar")>-1}inTab(e){return""!==e.location.search&&e.location.search.indexOf("uilocation=tab")>-1}inPopout(e){return""!==e.location.search&&e.location.search.indexOf("uilocation=popout")>-1}inPopup(e){return""===e.location.search||-1===e.location.search.indexOf("uilocation=")||e.location.search.indexOf("uilocation=popup")>-1}inPrivateMode(){return this.privateMode}getContentScrollY(e,t="main"){return e.document.getElementsByTagName(t)[0].scrollTop}setContentScrollY(e,t,i="main"){if(null!=t){e.document.getElementsByTagName(i)[0].scrollTop=t}}popOut(e,t=null){if(null===t&&(t=e.location.href),"undefined"!=typeof chrome&&chrome.windows&&chrome.windows.create){if(t.indexOf("?uilocation=")>-1)t=t.replace("uilocation=popup","uilocation=popout").replace("uilocation=tab","uilocation=popout").replace("uilocation=sidebar","uilocation=popout");else{const e=t.split("#");t=e[0]+"?uilocation=popout"+(e.length>0?"#"+e[1]:"")}const i=document.querySelector("body").getBoundingClientRect();chrome.windows.create({url:t,type:"popup",width:Math.round(i.width?i.width+60:375),height:Math.round(i.height||600)}),this.inPopup(e)&&Io.closePopup(e)}else"undefined"!=typeof chrome&&chrome.tabs&&chrome.tabs.create&&(t=t.replace("uilocation=popup","uilocation=tab").replace("uilocation=popout","uilocation=tab").replace("uilocation=sidebar","uilocation=tab"),chrome.tabs.create({url:t}))}}Lo.ɵfac=function(e){Mo.$Z()},Lo.ɵprov=Mo.Yz7({token:Lo,factory:Lo.ɵfac});class Bo{constructor(e){this.script=[],this.documentUUID={},this.properties={},this.options={},this.metadata={},this.autosubmit=null,this.documentUUID=e}}class Ko{}Ko.UsernameFieldNames=["username","user name","email","email address","e-mail","e-mail address","userid","user id","customer id","login id","benutzername","benutzer name","email adresse","e-mail adresse","benutzerid","benutzer id"],Ko.PasswordFieldIgnoreList=["onetimepassword","captcha","findanything","forgot"],Ko.ExcludedAutofillTypes=["radio","checkbox","hidden","file","button","image","reset","search"];class _o{}_o.CardAttributes=["autoCompleteType","data-stripe","htmlName","htmlID","label-tag","placeholder","label-left","label-top","data-recurly"],_o.CardAttributesExtended=[..._o.CardAttributes,"label-right"],_o.CardHolderFieldNames=["cc-name","card-name","cardholder-name","cardholder","name","nom"],_o.CardHolderFieldNameValues=["cc-name","card-name","cardholder-name","cardholder","tbName"],_o.CardNumberFieldNames=["cc-number","cc-num","card-number","card-num","number","cc","cc-no","card-no","credit-card","numero-carte","carte","carte-credit","num-carte","cb-num"],_o.CardNumberFieldNameValues=["cc-number","cc-num","card-number","card-num","cc-no","card-no","numero-carte","num-carte","cb-num"],_o.CardExpiryFieldNames=["cc-exp","card-exp","cc-expiration","card-expiration","cc-ex","card-ex","card-expire","card-expiry","validite","expiration","expiry","mm-yy","mm-yyyy","yy-mm","yyyy-mm","expiration-date","payment-card-expiration","payment-cc-date"],_o.CardExpiryFieldNameValues=["mm-yy","mm-yyyy","yy-mm","yyyy-mm","expiration-date","payment-card-expiration"],_o.ExpiryMonthFieldNames=["exp-month","cc-exp-month","cc-month","card-month","cc-mo","card-mo","exp-mo","card-exp-mo","cc-exp-mo","card-expiration-month","expiration-month","cc-mm","cc-m","card-mm","card-m","card-exp-mm","cc-exp-mm","exp-mm","exp-m","expire-month","expire-mo","expiry-month","expiry-mo","card-expire-month","card-expire-mo","card-expiry-month","card-expiry-mo","mois-validite","mois-expiration","m-validite","m-expiration","expiry-date-field-month","expiration-date-month","expiration-date-mm","exp-mon","validity-mo","exp-date-mo","cb-date-mois","date-m"],_o.ExpiryYearFieldNames=["exp-year","cc-exp-year","cc-year","card-year","cc-yr","card-yr","exp-yr","card-exp-yr","cc-exp-yr","card-expiration-year","expiration-year","cc-yy","cc-y","card-yy","card-y","card-exp-yy","cc-exp-yy","exp-yy","exp-y","cc-yyyy","card-yyyy","card-exp-yyyy","cc-exp-yyyy","expire-year","expire-yr","expiry-year","expiry-yr","card-expire-year","card-expire-yr","card-expiry-year","card-expiry-yr","an-validite","an-expiration","annee-validite","annee-expiration","expiry-date-field-year","expiration-date-year","cb-date-ann","expiration-date-yy","expiration-date-yyyy","validity-year","exp-date-year","date-y"],_o.CVVFieldNames=["cvv","cvc","cvv2","cc-csc","cc-cvv","card-csc","card-cvv","cvd","cid","cvc2","cnv","cvn2","cc-code","card-code","code-securite","security-code","crypto","card-verif","verification-code","csc","ccv"],_o.CardBrandFieldNames=["cc-type","card-type","card-brand","cc-brand","cb-type"],_o.MonthAbbr=["mm","mm","mm","mm","mm","mm"],_o.YearAbbrShort=["yy","åå","jj","aa","гг","rr"],_o.YearAbbrLong=["yyyy","åååå","jjjj","aa","гггг","rrrr"];class jo{}jo.IdentityAttributes=["autoCompleteType","data-stripe","htmlName","htmlID","label-tag","placeholder","label-left","label-top","data-recurly"],jo.FullNameFieldNames=["name","full-name","your-name"],jo.FullNameFieldNameValues=["full-name","your-name"],jo.TitleFieldNames=["honorific-prefix","prefix","title"],jo.FirstnameFieldNames=["f-name","first-name","given-name","first-n","vorname"],jo.MiddlenameFieldNames=["m-name","middle-name","additional-name","middle-initial","middle-n","middle-i"],jo.LastnameFieldNames=["l-name","last-name","s-name","surname","family-name","family-n","last-n","nachname","familienname"],jo.EmailFieldNames=["e-mail","email-address"],jo.AddressFieldNames=["address","street-address","addr","street","mailing-addr","billing-addr","mail-addr","bill-addr"],jo.AddressFieldNameValues=["mailing-addr","billing-addr","mail-addr","bill-addr"],jo.Address1FieldNames=["address-1","address-line-1","addr-1","street-1"],jo.Address2FieldNames=["address-2","address-line-2","addr-2","street-2"],jo.Address3FieldNames=["address-3","address-line-3","addr-3","street-3"],jo.PostalCodeFieldNames=["postal","zip","zip2","zip-code","postal-code","post-code","address-zip","address-postal","address-code","address-postal-code","address-zip-code"],jo.CityFieldNames=["city","town","address-level-2","address-city","address-town"],jo.StateFieldNames=["state","province","provence","address-level-1","address-state","address-province"],jo.CountryFieldNames=["country","country-code","country-name","address-country","address-country-name","address-country-code"],jo.PhoneFieldNames=["phone","mobile","mobile-phone","tel","telephone","phone-number"],jo.UserNameFieldNames=["user-name","user-id","screen-name"],jo.CompanyFieldNames=["company","company-name","organization","organization-name"],jo.IsoCountries={afghanistan:"AF","aland islands":"AX",albania:"AL",algeria:"DZ","american samoa":"AS",andorra:"AD",angola:"AO",anguilla:"AI",antarctica:"AQ","antigua and barbuda":"AG",argentina:"AR",armenia:"AM",aruba:"AW",australia:"AU",austria:"AT",azerbaijan:"AZ",bahamas:"BS",bahrain:"BH",bangladesh:"BD",barbados:"BB",belarus:"BY",belgium:"BE",belize:"BZ",benin:"BJ",bermuda:"BM",bhutan:"BT",bolivia:"BO","bosnia and herzegovina":"BA",botswana:"BW","bouvet island":"BV",brazil:"BR","british indian ocean territory":"IO","brunei darussalam":"BN",bulgaria:"BG","burkina faso":"BF",burundi:"BI",cambodia:"KH",cameroon:"CM",canada:"CA","cape verde":"CV","cayman islands":"KY","central african republic":"CF",chad:"TD",chile:"CL",china:"CN","christmas island":"CX","cocos (keeling) islands":"CC",colombia:"CO",comoros:"KM",congo:"CG","congo, democratic republic":"CD","cook islands":"CK","costa rica":"CR","cote d'ivoire":"CI",croatia:"HR",cuba:"CU",cyprus:"CY","czech republic":"CZ",denmark:"DK",djibouti:"DJ",dominica:"DM","dominican republic":"DO",ecuador:"EC",egypt:"EG","el salvador":"SV","equatorial guinea":"GQ",eritrea:"ER",estonia:"EE",ethiopia:"ET","falkland islands":"FK","faroe islands":"FO",fiji:"FJ",finland:"FI",france:"FR","french guiana":"GF","french polynesia":"PF","french southern territories":"TF",gabon:"GA",gambia:"GM",georgia:"GE",germany:"DE",ghana:"GH",gibraltar:"GI",greece:"GR",greenland:"GL",grenada:"GD",guadeloupe:"GP",guam:"GU",guatemala:"GT",guernsey:"GG",guinea:"GN","guinea-bissau":"GW",guyana:"GY",haiti:"HT","heard island & mcdonald islands":"HM","holy see (vatican city state)":"VA",honduras:"HN","hong kong":"HK",hungary:"HU",iceland:"IS",india:"IN",indonesia:"ID","iran, islamic republic of":"IR",iraq:"IQ",ireland:"IE","isle of man":"IM",israel:"IL",italy:"IT",jamaica:"JM",japan:"JP",jersey:"JE",jordan:"JO",kazakhstan:"KZ",kenya:"KE",kiribati:"KI","republic of korea":"KR","south korea":"KR","democratic people's republic of korea":"KP","north korea":"KP",kuwait:"KW",kyrgyzstan:"KG","lao people's democratic republic":"LA",latvia:"LV",lebanon:"LB",lesotho:"LS",liberia:"LR","libyan arab jamahiriya":"LY",liechtenstein:"LI",lithuania:"LT",luxembourg:"LU",macao:"MO",macedonia:"MK",madagascar:"MG",malawi:"MW",malaysia:"MY",maldives:"MV",mali:"ML",malta:"MT","marshall islands":"MH",martinique:"MQ",mauritania:"MR",mauritius:"MU",mayotte:"YT",mexico:"MX","micronesia, federated states of":"FM",moldova:"MD",monaco:"MC",mongolia:"MN",montenegro:"ME",montserrat:"MS",morocco:"MA",mozambique:"MZ",myanmar:"MM",namibia:"NA",nauru:"NR",nepal:"NP",netherlands:"NL","netherlands antilles":"AN","new caledonia":"NC","new zealand":"NZ",nicaragua:"NI",niger:"NE",nigeria:"NG",niue:"NU","norfolk island":"NF","northern mariana islands":"MP",norway:"NO",oman:"OM",pakistan:"PK",palau:"PW","palestinian territory, occupied":"PS",panama:"PA","papua new guinea":"PG",paraguay:"PY",peru:"PE",philippines:"PH",pitcairn:"PN",poland:"PL",portugal:"PT","puerto rico":"PR",qatar:"QA",reunion:"RE",romania:"RO","russian federation":"RU",rwanda:"RW","saint barthelemy":"BL","saint helena":"SH","saint kitts and nevis":"KN","saint lucia":"LC","saint martin":"MF","saint pierre and miquelon":"PM","saint vincent and grenadines":"VC",samoa:"WS","san marino":"SM","sao tome and principe":"ST","saudi arabia":"SA",senegal:"SN",serbia:"RS",seychelles:"SC","sierra leone":"SL",singapore:"SG",slovakia:"SK",slovenia:"SI","solomon islands":"SB",somalia:"SO","south africa":"ZA","south georgia and sandwich isl.":"GS",spain:"ES","sri lanka":"LK",sudan:"SD",suriname:"SR","svalbard and jan mayen":"SJ",swaziland:"SZ",sweden:"SE",switzerland:"CH","syrian arab republic":"SY",taiwan:"TW",tajikistan:"TJ",tanzania:"TZ",thailand:"TH","timor-leste":"TL",togo:"TG",tokelau:"TK",tonga:"TO","trinidad and tobago":"TT",tunisia:"TN",turkey:"TR",turkmenistan:"TM","turks and caicos islands":"TC",tuvalu:"TV",uganda:"UG",ukraine:"UA","united arab emirates":"AE","united kingdom":"GB","united states":"US","united states outlying islands":"UM",uruguay:"UY",uzbekistan:"UZ",vanuatu:"VU",venezuela:"VE",vietnam:"VN","virgin islands, british":"VG","virgin islands, u.s.":"VI","wallis and futuna":"WF","western sahara":"EH",yemen:"YE",zambia:"ZM",zimbabwe:"ZW"},jo.IsoStates={alabama:"AL",alaska:"AK","american samoa":"AS",arizona:"AZ",arkansas:"AR",california:"CA",colorado:"CO",connecticut:"CT",delaware:"DE","district of columbia":"DC","federated states of micronesia":"FM",florida:"FL",georgia:"GA",guam:"GU",hawaii:"HI",idaho:"ID",illinois:"IL",indiana:"IN",iowa:"IA",kansas:"KS",kentucky:"KY",louisiana:"LA",maine:"ME","marshall islands":"MH",maryland:"MD",massachusetts:"MA",michigan:"MI",minnesota:"MN",mississippi:"MS",missouri:"MO",montana:"MT",nebraska:"NE",nevada:"NV","new hampshire":"NH","new jersey":"NJ","new mexico":"NM","new york":"NY","north carolina":"NC","north dakota":"ND","northern mariana islands":"MP",ohio:"OH",oklahoma:"OK",oregon:"OR",palau:"PW",pennsylvania:"PA","puerto rico":"PR","rhode island":"RI","south carolina":"SC","south dakota":"SD",tennessee:"TN",texas:"TX",utah:"UT",vermont:"VT","virgin islands":"VI",virginia:"VA",washington:"WA","west virginia":"WV",wisconsin:"WI",wyoming:"WY"},jo.IsoProvinces={alberta:"AB","british columbia":"BC",manitoba:"MB","new brunswick":"NB","newfoundland and labrador":"NL","nova scotia":"NS",ontario:"ON","prince edward island":"PE",quebec:"QC",saskatchewan:"SK"};var Go=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Vo{constructor(e,t,i,n,s){this.cipherService=e,this.stateService=t,this.totpService=i,this.eventService=n,this.logService=s}getFormsWithPasswordFields(e){const t=[],i=Vo.loadPasswordFields(e,!0,!0,!1,!1);if(0===i.length)return t;for(const n in e.forms){if(!e.forms.hasOwnProperty(n))continue;const s=i.filter((e=>n===e.form));if(s.length>0){let i=this.findUsernameField(e,s[0],!1,!1,!1);null==i&&(i=this.findUsernameField(e,s[0],!0,!0,!1)),t.push({form:e.forms[n],password:s[0],username:i,passwords:s})}}return t}doAutoFill(e){return Go(this,void 0,void 0,(function*(){const t=e.tab;if(!(t&&e.cipher&&e.pageDetails&&e.pageDetails.length))throw new Error("Nothing to auto-fill.");let i=null;const n=yield this.stateService.getCanAccessPremium();let s=!1;if(e.pageDetails.forEach((o=>{if(o.tab.id!==t.id||o.tab.url!==t.url)return;const a=this.generateFillScript(o.details,{skipUsernameOnlyFill:e.skipUsernameOnlyFill||!1,onlyEmptyFields:e.onlyEmptyFields||!1,onlyVisibleFields:e.onlyVisibleFields||!1,fillNewPassword:e.fillNewPassword||!1,cipher:e.cipher});a&&a.script&&a.script.length&&(a.properties.delay_between_operations=20,s=!0,e.skipLastUsed||this.cipherService.updateLastUsedDate(e.cipher.id),Io.tabSendMessage(t,{command:"fillForm",fillScript:a,url:t.url},{frameId:o.frameId}),e.cipher.type===r.Login&&!i&&e.cipher.login.totp&&(n||e.cipher.organizationUseTotp)&&(i=this.stateService.getDisableAutoTotpCopy().then((t=>t?null:this.totpService.getCode(e.cipher.login.totp)))))})),s)return this.eventService.collect(Kn.Cipher_ClientAutofilled,e.cipher.id),null!=i?yield i:null;throw new Error("Did not auto-fill.")}))}doAutoFillOnTab(e,t,i){var n,r;return Go(this,void 0,void 0,(function*(){let o;if(i)o=yield this.cipherService.getNextCipherForUrl(t.url);else{const e=yield this.cipherService.getLastLaunchedForUrl(t.url,!0);if(o=e&&Date.now().valueOf()-(null===(r=null===(n=e.localData)||void 0===n?void 0:n.lastLaunched)||void 0===r?void 0:r.valueOf())<3e4?e:yield this.cipherService.getLastUsedForUrl(t.url,!0),null==o)return null}if(o.reprompt!==s.None)return;const a=yield this.doAutoFill({tab:t,cipher:o,pageDetails:e,skipLastUsed:!i,skipUsernameOnlyFill:!i,onlyEmptyFields:!i,onlyVisibleFields:!i,fillNewPassword:i});return i&&this.cipherService.updateLastUsedIndexForUrl(t.url),a}))}doAutoFillActiveTab(e,t){return Go(this,void 0,void 0,(function*(){const i=yield this.getActiveTab();if(i&&i.url)return yield this.doAutoFillOnTab(e,i,t)}))}getActiveTab(){return Go(this,void 0,void 0,(function*(){const e=yield Io.getTabFromCurrentWindow();if(!e)throw new Error("No tab found.");return e}))}generateFillScript(e,t){if(!e||!t.cipher)return null;let i=new Bo(e.documentUUID);const n={},s=t.cipher.fields;if(s&&s.length){const r=[];s.forEach((e=>{Vo.hasValue(e.name)&&r.push(e.name.toLowerCase())})),e.fields.forEach((e=>{if(n.hasOwnProperty(e.opid))return;if(!e.viewable&&"span"!==e.tagName)return;const o=this.findMatchingFieldIndex(e,r);if(o>-1){const r=s[o];let a;r.type===ei.Linked?a=t.cipher.linkedFieldValue(r.linkedId):(a=r.value,null==a&&r.type===ei.Boolean&&(a="false")),n[e.opid]=e,Vo.fillByOpid(i,e,a)}}))}switch(t.cipher.type){case r.Login:i=this.generateLoginFillScript(i,e,n,t);break;case r.Card:i=this.generateCardFillScript(i,e,n,t);break;case r.Identity:i=this.generateIdentityFillScript(i,e,n,t);break;default:return null}return i}generateLoginFillScript(e,t,i,n){if(!n.cipher.login)return null;const s=[],r=[];let o=null,a=null;const l=n.cipher.login;if(!l.password||""===l.password)return e=Vo.setFillScriptForFocus(i,e);let c=Vo.loadPasswordFields(t,!1,!1,n.onlyEmptyFields,n.fillNewPassword);c.length||n.onlyVisibleFields||(c=Vo.loadPasswordFields(t,!0,!0,n.onlyEmptyFields,n.fillNewPassword));for(const e in t.forms){if(!t.forms.hasOwnProperty(e))continue;const i=[];c.forEach((t=>{e===t.form&&i.push(t)})),c.forEach((e=>{o=e,s.push(o),l.username&&(a=this.findUsernameField(t,o,!1,!1,!1),a||n.onlyVisibleFields||(a=this.findUsernameField(t,o,!0,!0,!1)),a&&r.push(a))}))}return c.length&&!s.length&&(o=c[0],s.push(o),l.username&&o.elementNumber>0&&(a=this.findUsernameField(t,o,!1,!1,!0),a||n.onlyVisibleFields||(a=this.findUsernameField(t,o,!0,!0,!0)),a&&r.push(a))),c.length||n.skipUsernameOnlyFill||t.fields.forEach((e=>{e.viewable&&("text"===e.type||"email"===e.type||"tel"===e.type)&&Vo.fieldIsFuzzyMatch(e,Ko.UsernameFieldNames)&&r.push(e)})),r.forEach((t=>{i.hasOwnProperty(t.opid)||(i[t.opid]=t,Vo.fillByOpid(e,t,l.username))})),s.forEach((t=>{i.hasOwnProperty(t.opid)||(i[t.opid]=t,Vo.fillByOpid(e,t,l.password))})),e=Vo.setFillScriptForFocus(i,e)}generateCardFillScript(e,t,i,n){if(!n.cipher.card)return null;const s={};t.fields.forEach((e=>{if(!Vo.forCustomFieldsOnly(e)&&!this.isExcludedType(e.type,Ko.ExcludedAutofillTypes))for(let t=0;t<_o.CardAttributes.length;t++){const i=_o.CardAttributes[t];if(e.hasOwnProperty(i)&&e[i]&&e.viewable){if(!s.cardholderName&&Vo.isFieldMatch(e[i],_o.CardHolderFieldNames,_o.CardHolderFieldNameValues)){s.cardholderName=e;break}if(!s.number&&Vo.isFieldMatch(e[i],_o.CardNumberFieldNames,_o.CardNumberFieldNameValues)){s.number=e;break}if(!s.exp&&Vo.isFieldMatch(e[i],_o.CardExpiryFieldNames,_o.CardExpiryFieldNameValues)){s.exp=e;break}if(!s.expMonth&&Vo.isFieldMatch(e[i],_o.ExpiryMonthFieldNames)){s.expMonth=e;break}if(!s.expYear&&Vo.isFieldMatch(e[i],_o.ExpiryYearFieldNames)){s.expYear=e;break}if(!s.code&&Vo.isFieldMatch(e[i],_o.CVVFieldNames)){s.code=e;break}if(!s.brand&&Vo.isFieldMatch(e[i],_o.CardBrandFieldNames)){s.brand=e;break}}}}));const r=n.cipher.card;if(this.makeScriptAction(e,r,s,i,"cardholderName"),this.makeScriptAction(e,r,s,i,"number"),this.makeScriptAction(e,r,s,i,"code"),this.makeScriptAction(e,r,s,i,"brand"),s.expMonth&&Vo.hasValue(r.expMonth)){let t=r.expMonth;if(s.expMonth.selectInfo&&s.expMonth.selectInfo.options){let e=null;const i=s.expMonth.selectInfo.options;if(12===i.length?e=parseInt(r.expMonth,null)-1:13===i.length&&(e=null==i[0][0]||""===i[0][0]||null!=i[12][0]&&""!==i[12][0]?parseInt(r.expMonth,null):parseInt(r.expMonth,null)-1),null!=e){const n=i[e];n.length>1&&(t=n[1])}}else!this.fieldAttrsContain(s.expMonth,"mm")&&2!==s.expMonth.maxLength||1!==t.length||(t="0"+t);i[s.expMonth.opid]=s.expMonth,Vo.fillByOpid(e,s.expMonth,t)}if(s.expYear&&Vo.hasValue(r.expYear)){let t=r.expYear;if(s.expYear.selectInfo&&s.expYear.selectInfo.options)for(let e=0;e<s.expYear.selectInfo.options.length;e++){const i=s.expYear.selectInfo.options[e];if(i[0]===r.expYear||i[1]===r.expYear){t=i[1];break}if(2===i[1].length&&4===r.expYear.length&&i[1]===r.expYear.substring(2)){t=i[1];break}const n=i[1].indexOf(":");if(n>-1&&i[1].length>n+1){const e=i[1].substring(n+2);if(null!=e&&""!==e.trim()&&e===r.expYear){t=i[1];break}}}else this.fieldAttrsContain(s.expYear,"yyyy")||4===s.expYear.maxLength?2===t.length&&(t="20"+t):(this.fieldAttrsContain(s.expYear,"yy")||2===s.expYear.maxLength)&&4===t.length&&(t=t.substr(2));i[s.expYear.opid]=s.expYear,Vo.fillByOpid(e,s.expYear,t)}if(s.exp&&Vo.hasValue(r.expMonth)&&Vo.hasValue(r.expYear)){const t=("0"+r.expMonth).slice(-2);let n=r.expYear,o=null;2===n.length?(o=n,n="20"+n):4===n.length&&(o=n.substr(2,2));let a=null;for(let e=0;e<_o.MonthAbbr.length&&(this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+"/"+_o.YearAbbrShort[e])&&null!=o?a=t+"/"+o:this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+"/"+_o.YearAbbrLong[e])?a=t+"/"+n:this.fieldAttrsContain(s.exp,_o.YearAbbrShort[e]+"/"+_o.MonthAbbr[e])&&null!=o?a=o+"/"+t:this.fieldAttrsContain(s.exp,_o.YearAbbrLong[e]+"/"+_o.MonthAbbr[e])?a=n+"/"+t:this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+"-"+_o.YearAbbrShort[e])&&null!=o?a=t+"-"+o:this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+"-"+_o.YearAbbrLong[e])?a=t+"-"+n:this.fieldAttrsContain(s.exp,_o.YearAbbrShort[e]+"-"+_o.MonthAbbr[e])&&null!=o?a=o+"-"+t:this.fieldAttrsContain(s.exp,_o.YearAbbrLong[e]+"-"+_o.MonthAbbr[e])?a=n+"-"+t:this.fieldAttrsContain(s.exp,_o.YearAbbrShort[e]+_o.MonthAbbr[e])&&null!=o?a=o+t:this.fieldAttrsContain(s.exp,_o.YearAbbrLong[e]+_o.MonthAbbr[e])?a=n+t:this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+_o.YearAbbrShort[e])&&null!=o?a=t+o:this.fieldAttrsContain(s.exp,_o.MonthAbbr[e]+_o.YearAbbrLong[e])&&(a=t+n),null==a);e++);null==a&&(a=n+"-"+t),this.makeScriptActionWithValue(e,a,s.exp,i)}return e}fieldAttrsContain(e,t){if(!e)return!1;let i=!1;return _o.CardAttributesExtended.forEach((n=>{if(i||!e.hasOwnProperty(n)||!e[n])return;let s=e[n];s=s.replace(/ /g,"").toLowerCase(),i=s.indexOf(t)>-1})),i}generateIdentityFillScript(e,t,i,n){if(!n.cipher.identity)return null;const s={};t.fields.forEach((e=>{if(!Vo.forCustomFieldsOnly(e)&&!this.isExcludedType(e.type,Ko.ExcludedAutofillTypes))for(let t=0;t<jo.IdentityAttributes.length;t++){const i=jo.IdentityAttributes[t];if(e.hasOwnProperty(i)&&e[i]&&e.viewable){if(!s.name&&Vo.isFieldMatch(e[i],jo.FullNameFieldNames,jo.FullNameFieldNameValues)){s.name=e;break}if(!s.firstName&&Vo.isFieldMatch(e[i],jo.FirstnameFieldNames)){s.firstName=e;break}if(!s.middleName&&Vo.isFieldMatch(e[i],jo.MiddlenameFieldNames)){s.middleName=e;break}if(!s.lastName&&Vo.isFieldMatch(e[i],jo.LastnameFieldNames)){s.lastName=e;break}if(!s.title&&Vo.isFieldMatch(e[i],jo.TitleFieldNames)){s.title=e;break}if(!s.email&&Vo.isFieldMatch(e[i],jo.EmailFieldNames)){s.email=e;break}if(!s.address&&Vo.isFieldMatch(e[i],jo.AddressFieldNames,jo.AddressFieldNameValues)){s.address=e;break}if(!s.address1&&Vo.isFieldMatch(e[i],jo.Address1FieldNames)){s.address1=e;break}if(!s.address2&&Vo.isFieldMatch(e[i],jo.Address2FieldNames)){s.address2=e;break}if(!s.address3&&Vo.isFieldMatch(e[i],jo.Address3FieldNames)){s.address3=e;break}if(!s.postalCode&&Vo.isFieldMatch(e[i],jo.PostalCodeFieldNames)){s.postalCode=e;break}if(!s.city&&Vo.isFieldMatch(e[i],jo.CityFieldNames)){s.city=e;break}if(!s.state&&Vo.isFieldMatch(e[i],jo.StateFieldNames)){s.state=e;break}if(!s.country&&Vo.isFieldMatch(e[i],jo.CountryFieldNames)){s.country=e;break}if(!s.phone&&Vo.isFieldMatch(e[i],jo.PhoneFieldNames)){s.phone=e;break}if(!s.username&&Vo.isFieldMatch(e[i],jo.UserNameFieldNames)){s.username=e;break}if(!s.company&&Vo.isFieldMatch(e[i],jo.CompanyFieldNames)){s.company=e;break}}}}));const r=n.cipher.identity;this.makeScriptAction(e,r,s,i,"title"),this.makeScriptAction(e,r,s,i,"firstName"),this.makeScriptAction(e,r,s,i,"middleName"),this.makeScriptAction(e,r,s,i,"lastName"),this.makeScriptAction(e,r,s,i,"address1"),this.makeScriptAction(e,r,s,i,"address2"),this.makeScriptAction(e,r,s,i,"address3"),this.makeScriptAction(e,r,s,i,"city"),this.makeScriptAction(e,r,s,i,"postalCode"),this.makeScriptAction(e,r,s,i,"company"),this.makeScriptAction(e,r,s,i,"email"),this.makeScriptAction(e,r,s,i,"phone"),this.makeScriptAction(e,r,s,i,"username");let o=!1;if(s.state&&r.state&&r.state.length>2){const t=r.state.toLowerCase(),n=jo.IsoStates[t]||jo.IsoProvinces[t];n&&(o=!0,this.makeScriptActionWithValue(e,n,s.state,i))}o||this.makeScriptAction(e,r,s,i,"state");let a=!1;if(s.country&&r.country&&r.country.length>2){const t=r.country.toLowerCase(),n=jo.IsoCountries[t];n&&(a=!0,this.makeScriptActionWithValue(e,n,s.country,i))}if(a||this.makeScriptAction(e,r,s,i,"country"),s.name&&(r.firstName||r.lastName)){let t="";Vo.hasValue(r.firstName)&&(t=r.firstName),Vo.hasValue(r.middleName)&&(""!==t&&(t+=" "),t+=r.middleName),Vo.hasValue(r.lastName)&&(""!==t&&(t+=" "),t+=r.lastName),this.makeScriptActionWithValue(e,t,s.name,i)}if(s.address&&Vo.hasValue(r.address1)){let t="";Vo.hasValue(r.address1)&&(t=r.address1),Vo.hasValue(r.address2)&&(""!==t&&(t+=", "),t+=r.address2),Vo.hasValue(r.address3)&&(""!==t&&(t+=", "),t+=r.address3),this.makeScriptActionWithValue(e,t,s.address,i)}return e}isExcludedType(e,t){return t.indexOf(e)>-1}static isFieldMatch(e,t,i){e=e.trim().toLowerCase().replace(/[^a-zA-Z0-9]+/g,"");for(let n=0;n<t.length;n++){let s=t[n];const r=null==i||i.indexOf(s)>-1;if(s=s.toLowerCase().replace(/-/g,""),e===s||r&&e.indexOf(s)>-1)return!0}return!1}makeScriptAction(e,t,i,n,s,r){r=r||s,this.makeScriptActionWithValue(e,t[s],i[r],n)}makeScriptActionWithValue(e,t,i,n){let s=!1;if(Vo.hasValue(t)&&i)if("select-one"===i.type&&i.selectInfo&&i.selectInfo.options)for(let e=0;e<i.selectInfo.options.length;e++){const n=i.selectInfo.options[e];for(let e=0;e<n.length;e++)if(Vo.hasValue(n[e])&&n[e].toLowerCase()===t.toLowerCase()){s=!0,n.length>1&&(t=n[1]);break}if(s)break}else s=!0;s&&(n[i.opid]=i,Vo.fillByOpid(e,i,t))}static loadPasswordFields(e,t,i,n,s){const r=[];return e.fields.forEach((e=>{if(Vo.forCustomFieldsOnly(e))return;const o="password"===e.type,a=e=>{if(null==e)return!1;const t=e.toLowerCase().replace(/[\s_\-]/g,"");return!(t.indexOf("password")<0)&&!Ko.PasswordFieldIgnoreList.some((e=>t.indexOf(e)>-1))};e.disabled||!i&&e.readonly||!(o||"text"===e.type&&(a(e.htmlID)||a(e.htmlName)||a(e.placeholder)))||!t&&!e.viewable||n&&null!=e.value&&""!==e.value.trim()||!s&&"new-password"===e.autoCompleteType||r.push(e)})),r}findUsernameField(e,t,i,n,s){let r=null;for(let o=0;o<e.fields.length;o++){const a=e.fields[o];if(!Vo.forCustomFieldsOnly(a)){if(a.elementNumber>=t.elementNumber)break;if(!a.disabled&&(n||!a.readonly)&&(s||a.form===t.form)&&(i||a.viewable)&&("text"===a.type||"email"===a.type||"tel"===a.type)&&(r=a,this.findMatchingFieldIndex(a,Ko.UsernameFieldNames)>-1))break}}return r}findMatchingFieldIndex(e,t){for(let i=0;i<t.length;i++){if(t[i].indexOf("=")>-1){if(this.fieldPropertyIsPrefixMatch(e,"htmlID",t[i],"id"))return i;if(this.fieldPropertyIsPrefixMatch(e,"htmlName",t[i],"name"))return i;if(this.fieldPropertyIsPrefixMatch(e,"label-tag",t[i],"label"))return i;if(this.fieldPropertyIsPrefixMatch(e,"label-aria",t[i],"label"))return i;if(this.fieldPropertyIsPrefixMatch(e,"placeholder",t[i],"placeholder"))return i}if(this.fieldPropertyIsMatch(e,"htmlID",t[i]))return i;if(this.fieldPropertyIsMatch(e,"htmlName",t[i]))return i;if(this.fieldPropertyIsMatch(e,"label-tag",t[i]))return i;if(this.fieldPropertyIsMatch(e,"label-aria",t[i]))return i;if(this.fieldPropertyIsMatch(e,"placeholder",t[i]))return i}return-1}fieldPropertyIsPrefixMatch(e,t,i,n,s="="){if(0===i.indexOf(n+s)){const n=i.indexOf(s),r=i.substring(n+1);return null!=r&&this.fieldPropertyIsMatch(e,t,r)}return!1}fieldPropertyIsMatch(e,t,i){let n=e[t];if(!Vo.hasValue(n))return!1;if(n=n.trim().replace(/(?:\r\n|\r|\n)/g,""),i.startsWith("regex="))try{const e=i.split("=",2);if(2===e.length){return new RegExp(e[1],"i").test(n)}}catch(e){this.logService.error(e)}else if(i.startsWith("csv=")){const e=i.split("=",2);if(2===e.length){const t=e[1].split(",");for(let e=0;e<t.length;e++){const i=t[e];if(null!=i&&i.trim().toLowerCase()===n.toLowerCase())return!0}return!1}}return n.toLowerCase()===i}static fieldIsFuzzyMatch(e,t){return!(!Vo.hasValue(e.htmlID)||!this.fuzzyMatch(t,e.htmlID))||(!(!Vo.hasValue(e.htmlName)||!this.fuzzyMatch(t,e.htmlName))||(!(!Vo.hasValue(e["label-tag"])||!this.fuzzyMatch(t,e["label-tag"]))||(!(!Vo.hasValue(e.placeholder)||!this.fuzzyMatch(t,e.placeholder))||(!(!Vo.hasValue(e["label-left"])||!this.fuzzyMatch(t,e["label-left"]))||(!(!Vo.hasValue(e["label-top"])||!this.fuzzyMatch(t,e["label-top"]))||!(!Vo.hasValue(e["label-aria"])||!this.fuzzyMatch(t,e["label-aria"])))))))}static fuzzyMatch(e,t){if(null==e||0===e.length||null==t||""===t)return!1;t=t.replace(/(?:\r\n|\r|\n)/g,"").trim().toLowerCase();for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>-1)return!0;return!1}static hasValue(e){return e&&""!==e}static setFillScriptForFocus(e,t){let i=null,n=null;for(const t in e)e.hasOwnProperty(t)&&e[t].viewable&&(i=e[t],"password"===e[t].type&&(n=e[t]));return n?t.script.push(["focus_by_opid",n.opid]):i&&t.script.push(["focus_by_opid",i.opid]),t}static fillByOpid(e,t,i){t.maxLength&&i&&i.length>t.maxLength&&(i=i.substr(0,i.length)),"span"!==t.tagName&&(e.script.push(["click_on_opid",t.opid]),e.script.push(["focus_by_opid",t.opid])),e.script.push(["fill_by_opid",t.opid,i])}static forCustomFieldsOnly(e){return"span"===e.tagName}}var Ho=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var qo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Wo extends class{constructor(e){this.stateService=e,this.urlsSubject=new wt.x,this.urls=this.urlsSubject,this.scimUrl=null,this.stateService.activeAccount$.pipe((0,kr.b)((()=>Ho(this,void 0,void 0,(function*(){yield this.setUrlsFromStorage()}))))).subscribe()}hasBaseUrl(){return null!=this.baseUrl}getNotificationsUrl(){return null!=this.notificationsUrl?this.notificationsUrl:null!=this.baseUrl?this.baseUrl+"/notifications":"https://notifications.bitwarden.com"}getWebVaultUrl(){return null!=this.webVaultUrl?this.webVaultUrl:this.baseUrl?this.baseUrl:"https://vault.bitwarden.com"}getSendUrl(){return"https://vault.bitwarden.com"===this.getWebVaultUrl()?"https://send.bitwarden.com/#":this.getWebVaultUrl()+"/#/send/"}getIconsUrl(){return null!=this.iconsUrl?this.iconsUrl:this.baseUrl?this.baseUrl+"/icons":"https://icons.bitwarden.net"}getApiUrl(){return null!=this.apiUrl?this.apiUrl:this.baseUrl?this.baseUrl+"/api":"https://api.bitwarden.com"}getIdentityUrl(){return null!=this.identityUrl?this.identityUrl:this.baseUrl?this.baseUrl+"/identity":"https://identity.bitwarden.com"}getEventsUrl(){return null!=this.eventsUrl?this.eventsUrl:this.baseUrl?this.baseUrl+"/events":"https://events.bitwarden.com"}getKeyConnectorUrl(){return this.keyConnectorUrl}getScimUrl(){return null!=this.scimUrl?this.scimUrl+"/v2":"https://vault.bitwarden.com"===this.getWebVaultUrl()?"https://scim.bitwarden.com/v2":this.getWebVaultUrl()+"/scim/v2"}setUrlsFromStorage(){return Ho(this,void 0,void 0,(function*(){const e=yield this.stateService.getEnvironmentUrls(),t=new h;this.baseUrl=t.base=e.base,this.webVaultUrl=e.webVault,this.apiUrl=t.api=e.api,this.identityUrl=t.identity=e.identity,this.iconsUrl=e.icons,this.notificationsUrl=e.notifications,this.eventsUrl=t.events=e.events,this.keyConnectorUrl=e.keyConnector}))}setUrls(e){var t;return Ho(this,void 0,void 0,(function*(){return e.base=this.formatUrl(e.base),e.webVault=this.formatUrl(e.webVault),e.api=this.formatUrl(e.api),e.identity=this.formatUrl(e.identity),e.icons=this.formatUrl(e.icons),e.notifications=this.formatUrl(e.notifications),e.events=this.formatUrl(e.events),e.keyConnector=this.formatUrl(e.keyConnector),e.scim=null!==(t=this.formatUrl(e.scim))&&void 0!==t?t:this.scimUrl,yield this.stateService.setEnvironmentUrls({base:e.base,api:e.api,identity:e.identity,webVault:e.webVault,icons:e.icons,notifications:e.notifications,events:e.events,keyConnector:e.keyConnector}),this.baseUrl=e.base,this.webVaultUrl=e.webVault,this.apiUrl=e.api,this.identityUrl=e.identity,this.iconsUrl=e.icons,this.notificationsUrl=e.notifications,this.eventsUrl=e.events,this.keyConnectorUrl=e.keyConnector,this.scimUrl=e.scim,this.urlsSubject.next(e),e}))}getUrls(){return{base:this.baseUrl,webVault:this.webVaultUrl,api:this.apiUrl,identity:this.identityUrl,icons:this.iconsUrl,notifications:this.notificationsUrl,events:this.eventsUrl,keyConnector:this.keyConnectorUrl,scim:this.scimUrl}}formatUrl(e){return null==e||""===e?null:((e=e.replace(/\/+$/g,"")).startsWith("http://")||e.startsWith("https://")||(e="https://"+e),e.trim())}isCloud(){return["https://api.bitwarden.com","https://vault.bitwarden.com/api"].includes(this.getApiUrl())}}{constructor(e,t){super(e),this.logService=t}hasManagedEnvironment(){return qo(this,void 0,void 0,(function*(){try{return null!=(yield this.getManagedEnvironment())}catch(e){return this.logService.error(e),!1}}))}settingsHaveChanged(){return qo(this,void 0,void 0,(function*(){const e=yield this.getManagedEnvironment();return e.base!=this.baseUrl||e.webVault!=this.webVaultUrl||e.api!=this.webVaultUrl||e.identity!=this.identityUrl||e.icons!=this.iconsUrl||e.notifications!=this.notificationsUrl||e.events!=this.eventsUrl}))}getManagedEnvironment(){return new Promise(((e,t)=>{chrome.storage.managed.get("environment",(i=>{if(chrome.runtime.lastError)return t(chrome.runtime.lastError);e(i.environment)}))}))}setUrlsToManagedEnvironment(){return qo(this,void 0,void 0,(function*(){const e=yield this.getManagedEnvironment();yield this.setUrls({base:e.base,webVault:e.webVault,api:e.api,identity:e.identity,icons:e.icons,notifications:e.notifications,events:e.events})}))}}var Jo=i(79622),Yo=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class $o{static fromData(e){switch(e.type){case"organization":return new Qo(e.key);case"provider":return new Xo(e.key,e.providerId);default:return null}}}class Qo{constructor(e){this.key=e}decrypt(e){return Yo(this,void 0,void 0,(function*(){const t=yield e.rsaDecrypt(this.key);return new Ct(t)}))}toData(){return{type:"organization",key:this.key}}}class Xo{constructor(e,t){this.key=e,this.providerId=t}decrypt(e){return Yo(this,void 0,void 0,(function*(){const t=yield e.getProviderKey(this.providerId),i=yield e.decryptToBytes(new At(this.key),t);return new Ct(i)}))}toData(){return{type:"provider",key:this.key,providerId:this.providerId}}}var Zo=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},ea=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ta=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class ia{constructor(e,t,i,n,s){this.cryptoFunctionService=e,this.encryptService=t,this.platformUtilService=i,this.logService=n,this.stateService=s}setKey(e,t){return ta(this,void 0,void 0,(function*(){yield this.stateService.setCryptoMasterKey(e,{userId:t}),yield this.storeKey(e,t)}))}setKeyHash(e){return ta(this,void 0,void 0,(function*(){yield this.stateService.setKeyHash(e)}))}setEncKey(e){return ta(this,void 0,void 0,(function*(){null!=e&&(yield this.stateService.setDecryptedCryptoSymmetricKey(null),yield this.stateService.setEncryptedCryptoSymmetricKey(e))}))}setEncPrivateKey(e){return ta(this,void 0,void 0,(function*(){null!=e&&(yield this.stateService.setDecryptedPrivateKey(null),yield this.stateService.setEncryptedPrivateKey(e))}))}setOrgKeys(e=[],t=[]){return ta(this,void 0,void 0,(function*(){const i={};return e.forEach((e=>{i[e.id]={type:"organization",key:e.key}})),t.forEach((e=>{i[e.id]={type:"provider",providerId:e.providerId,key:e.key}})),yield this.stateService.setDecryptedOrganizationKeys(null),yield this.stateService.setEncryptedOrganizationKeys(i)}))}setProviderKeys(e){return ta(this,void 0,void 0,(function*(){const t={};return e.forEach((e=>{t[e.id]=e.key})),yield this.stateService.setDecryptedProviderKeys(null),yield this.stateService.setEncryptedProviderKeys(t)}))}getKey(e,t){return ta(this,void 0,void 0,(function*(){const i=yield this.stateService.getCryptoMasterKey({userId:t});if(null!=i)return i;e||(e=mt.Auto);const n=yield this.getKeyFromStorage(e,t);return null!=n&&this.setKey(n,t),n}))}getKeyFromStorage(e,t){return ta(this,void 0,void 0,(function*(){const i=yield this.retrieveKeyFromStorage(e,t);if(null!=i){const e=new Ct(f.fromB64ToArray(i).buffer);return(yield this.validateKey(e))?e:(this.logService.warning("Wrong key, throwing away stored key"),yield this.clearSecretKeyStore(t),null)}return null}))}getKeyHash(){return ta(this,void 0,void 0,(function*(){return yield this.stateService.getKeyHash()}))}compareAndUpdateKeyHash(e,t){return ta(this,void 0,void 0,(function*(){const i=yield this.getKeyHash();if(null!=e&&null!=i){const n=yield this.hashPassword(e,t,Kt.LocalAuthorization);if(null!=n&&i===n)return!0;const s=yield this.hashPassword(e,t,Kt.ServerAuthorization);if(null!=s&&i===s)return yield this.setKeyHash(n),!0}return!1}))}getEncKey(e=null){return this.getEncKeyHelper(e)}getPublicKey(){return ta(this,void 0,void 0,(function*(){const e=yield this.stateService.getPublicKey();if(null!=e)return e;const t=yield this.getPrivateKey();if(null==t)return null;const i=yield this.cryptoFunctionService.rsaExtractPublicKey(t);return yield this.stateService.setPublicKey(i),i}))}getPrivateKey(){return ta(this,void 0,void 0,(function*(){const e=yield this.stateService.getDecryptedPrivateKey();if(null!=e)return e;const t=yield this.stateService.getEncryptedPrivateKey();if(null==t)return null;const i=yield this.decryptToBytes(new At(t),null);return yield this.stateService.setDecryptedPrivateKey(i),i}))}getFingerprint(e,t){return ta(this,void 0,void 0,(function*(){if(null==t&&(t=yield this.getPublicKey()),null===t)throw new Error("No public key available.");const i=yield this.cryptoFunctionService.hash(t,"sha256"),n=yield this.cryptoFunctionService.hkdfExpand(i,e,32,"sha256");return this.hashPhrase(n)}))}getOrgKeys(){return ta(this,void 0,void 0,(function*(){const e=new Map,t=yield this.stateService.getDecryptedOrganizationKeys();if(null!=t&&t.size>0)return t;const i=yield this.stateService.getEncryptedOrganizationKeys();if(null==i)return null;let n=!1;for(const t of Object.keys(i)){if(e.has(t))continue;const s=$o.fromData(i[t]),r=yield s.decrypt(this);e.set(t,r),n=!0}return n&&(yield this.stateService.setDecryptedOrganizationKeys(e)),e}))}getOrgKey(e){return ta(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.getOrgKeys();return null!=t&&t.has(e)?t.get(e):null}))}getProviderKeys(){return ta(this,void 0,void 0,(function*(){const e=new Map,t=yield this.stateService.getDecryptedProviderKeys();if(null!=t&&t.size>0)return t;const i=yield this.stateService.getEncryptedProviderKeys();if(null==i)return null;let n=!1;for(const t in i){if(!i.hasOwnProperty(t))continue;const s=yield this.rsaDecrypt(i[t]);e.set(t,new Ct(s)),n=!0}return n&&(yield this.stateService.setDecryptedProviderKeys(e)),e}))}getProviderKey(e){return ta(this,void 0,void 0,(function*(){if(null==e)return null;const t=yield this.getProviderKeys();return null!=t&&t.has(e)?t.get(e):null}))}hasKey(){return ta(this,void 0,void 0,(function*(){return(yield this.hasKeyInMemory())||(yield this.hasKeyStored(mt.Auto))||(yield this.hasKeyStored(mt.Biometric))}))}hasKeyInMemory(e){return ta(this,void 0,void 0,(function*(){return null!=(yield this.stateService.getCryptoMasterKey({userId:e}))}))}hasKeyStored(e,t){return ta(this,void 0,void 0,(function*(){switch(e){case mt.Auto:return null!=(yield this.stateService.getCryptoMasterKeyAuto({userId:t}));case mt.Biometric:return!0===(yield this.stateService.hasCryptoMasterKeyBiometric({userId:t}));default:return!1}}))}hasEncKey(){return ta(this,void 0,void 0,(function*(){return null!=(yield this.stateService.getEncryptedCryptoSymmetricKey())}))}clearKey(e=!0,t){return ta(this,void 0,void 0,(function*(){yield this.stateService.setCryptoMasterKey(null,{userId:t}),e&&(yield this.clearSecretKeyStore(t))}))}clearStoredKey(e){return ta(this,void 0,void 0,(function*(){e===mt.Auto?yield this.stateService.setCryptoMasterKeyAuto(null):yield this.stateService.setCryptoMasterKeyBiometric(null)}))}clearKeyHash(e){return ta(this,void 0,void 0,(function*(){return yield this.stateService.setKeyHash(null,{userId:e})}))}clearEncKey(e,t){return ta(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedCryptoSymmetricKey(null,{userId:t}),e||(yield this.stateService.setEncryptedCryptoSymmetricKey(null,{userId:t}))}))}clearKeyPair(e,t){return ta(this,void 0,void 0,(function*(){const i=[this.stateService.setDecryptedPrivateKey(null,{userId:t}),this.stateService.setPublicKey(null,{userId:t})];return e||i.push(this.stateService.setEncryptedPrivateKey(null,{userId:t})),Promise.all(i)}))}clearOrgKeys(e,t){return ta(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedOrganizationKeys(null,{userId:t}),e||(yield this.stateService.setEncryptedOrganizationKeys(null,{userId:t}))}))}clearProviderKeys(e,t){return ta(this,void 0,void 0,(function*(){yield this.stateService.setDecryptedProviderKeys(null,{userId:t}),e||(yield this.stateService.setEncryptedProviderKeys(null,{userId:t}))}))}clearPinProtectedKey(e){return ta(this,void 0,void 0,(function*(){return yield this.stateService.setEncryptedPinProtected(null,{userId:e})}))}clearKeys(e){return ta(this,void 0,void 0,(function*(){yield this.clearKey(!0,e),yield this.clearKeyHash(e),yield this.clearOrgKeys(!1,e),yield this.clearProviderKeys(!1,e),yield this.clearEncKey(!1,e),yield this.clearKeyPair(!1,e),yield this.clearPinProtectedKey(e)}))}toggleKey(){return ta(this,void 0,void 0,(function*(){const e=yield this.getKey();yield this.setKey(e)}))}makeKey(e,t,i,n){return ta(this,void 0,void 0,(function*(){let s=null;if(null!=i&&i!==En.PBKDF2_SHA256)throw new Error("Unknown Kdf.");if(null==n)n=5e3;else if(n<5e3)throw new Error("PBKDF2 iteration minimum is 5000.");return s=yield this.cryptoFunctionService.pbkdf2(e,t,"sha256",n),new Ct(s)}))}makeKeyFromPin(e,t,i,n,s=null){return ta(this,void 0,void 0,(function*(){if(null==s){const e=yield this.stateService.getEncryptedPinProtected();if(null==e)throw new Error("No PIN protected key found.");s=new At(e)}const r=yield this.makePinKey(e,t,i,n),o=yield this.decryptToBytes(s,r);return new Ct(o)}))}makeShareKey(){return ta(this,void 0,void 0,(function*(){const e=yield this.cryptoFunctionService.randomBytes(64),t=yield this.getPublicKey();return[yield this.rsaEncrypt(e,t),new Ct(e)]}))}makeKeyPair(e){return ta(this,void 0,void 0,(function*(){const t=yield this.cryptoFunctionService.rsaGenerateKeyPair(2048);return[f.fromBufferToB64(t[0]),yield this.encrypt(t[1],e)]}))}makePinKey(e,t,i,n){return ta(this,void 0,void 0,(function*(){const s=yield this.makeKey(e,t,i,n);return yield this.stretchKey(s)}))}makeSendKey(e){return ta(this,void 0,void 0,(function*(){const t=yield this.cryptoFunctionService.hkdf(e,"bitwarden-send","send",64,"sha256");return new Ct(t)}))}hashPassword(e,t,i){return ta(this,void 0,void 0,(function*(){if(null==t&&(t=yield this.getKey()),null==e||null==t)throw new Error("Invalid parameters.");const n=i===Kt.LocalAuthorization?2:1,s=yield this.cryptoFunctionService.pbkdf2(t.key,e,"sha256",n);return f.fromBufferToB64(s)}))}makeEncKey(e){return ta(this,void 0,void 0,(function*(){const t=yield this.getKeyForUserEncryption(e),i=yield this.cryptoFunctionService.randomBytes(64);return this.buildEncKey(t,i)}))}remakeEncKey(e,t){return ta(this,void 0,void 0,(function*(){return null==t&&(t=yield this.getEncKey()),this.buildEncKey(e,t.key)}))}encrypt(e,t){return ta(this,void 0,void 0,(function*(){return t=yield this.getKeyForUserEncryption(t),yield this.encryptService.encrypt(e,t)}))}encryptToBytes(e,t){return ta(this,void 0,void 0,(function*(){return t=yield this.getKeyForUserEncryption(t),this.encryptService.encryptToBytes(e,t)}))}rsaEncrypt(e,t){return ta(this,void 0,void 0,(function*(){if(null==t&&(t=yield this.getPublicKey()),null==t)throw new Error("Public key unavailable.");const i=yield this.cryptoFunctionService.rsaEncrypt(e,t,"sha1");return new At(bt.Rsa2048_OaepSha1_B64,f.fromBufferToB64(i))}))}rsaDecrypt(e,t){return ta(this,void 0,void 0,(function*(){const i=e.split(".");let n,s=null;if(1===i.length)s=bt.Rsa2048_OaepSha256_B64,n=[i[0]];else if(2===i.length)try{s=parseInt(i[0],null),n=i[1].split("|")}catch(e){this.logService.error(e)}switch(s){case bt.Rsa2048_OaepSha256_B64:case bt.Rsa2048_OaepSha1_B64:case bt.Rsa2048_OaepSha256_HmacSha256_B64:case bt.Rsa2048_OaepSha1_HmacSha256_B64:break;default:throw new Error("encType unavailable.")}if(null==n||n.length<=0)throw new Error("encPieces unavailable.");const r=f.fromB64ToArray(n[0]).buffer,o=null!=t?t:yield this.getPrivateKey();if(null==o)throw new Error("No private key.");let a="sha1";switch(s){case bt.Rsa2048_OaepSha256_B64:case bt.Rsa2048_OaepSha256_HmacSha256_B64:a="sha256";break;case bt.Rsa2048_OaepSha1_B64:case bt.Rsa2048_OaepSha1_HmacSha256_B64:break;default:throw new Error("encType unavailable.")}return this.cryptoFunctionService.rsaDecrypt(r,o,a)}))}decryptToBytes(e,t){return ta(this,void 0,void 0,(function*(){const i=yield this.getKeyForUserEncryption(t);return this.encryptService.decryptToBytes(e,i)}))}decryptToUtf8(e,t){return ta(this,void 0,void 0,(function*(){return t=yield this.getKeyForUserEncryption(t),yield this.encryptService.decryptToUtf8(e,t)}))}decryptFromBytes(e,t){return ta(this,void 0,void 0,(function*(){if(null==e)throw new Error("No buffer provided for decryption.");return t=yield this.getKeyForUserEncryption(t),this.encryptService.decryptToBytes(e,t)}))}randomNumber(e,t){return ta(this,void 0,void 0,(function*(){let i=0;const n=t-e+1,s=Math.ceil(Math.log2(n));if(s>53)throw new Error("We cannot generate numbers larger than 53 bits.");const r=Math.ceil(s/8),o=Math.pow(2,s)-1,a=new Uint8Array(yield this.cryptoFunctionService.randomBytes(r));let l=8*(r-1);for(let e=0;e<r;e++)i+=a[e]*Math.pow(2,l),l-=8;return i&=o,i>=n?this.randomNumber(e,t):e+i}))}validateKey(e){return ta(this,void 0,void 0,(function*(){try{const t=yield this.stateService.getEncryptedPrivateKey(),i=yield this.getEncKeyHelper(e);if(null==t||null==i)return!1;const n=yield this.decryptToBytes(new At(t),i);yield this.cryptoFunctionService.rsaExtractPublicKey(n)}catch(e){return!1}return!0}))}storeKey(e,t){return ta(this,void 0,void 0,(function*(){(yield this.shouldStoreKey(mt.Auto,t))?yield this.stateService.setCryptoMasterKeyAuto(e.keyB64,{userId:t}):(yield this.shouldStoreKey(mt.Biometric,t))?yield this.stateService.setCryptoMasterKeyBiometric(e.keyB64,{userId:t}):(yield this.stateService.setCryptoMasterKeyAuto(null,{userId:t}),yield this.stateService.setCryptoMasterKeyBiometric(null,{userId:t}))}))}shouldStoreKey(e,t){return ta(this,void 0,void 0,(function*(){let i=!1;if(e===mt.Auto){i=null==(yield this.stateService.getVaultTimeout({userId:t}))}else if(e===mt.Biometric){i=(yield this.stateService.getBiometricUnlock({userId:t}))&&this.platformUtilService.supportsSecureStorage()}return i}))}retrieveKeyFromStorage(e,t){return ta(this,void 0,void 0,(function*(){return e===mt.Auto?yield this.stateService.getCryptoMasterKeyAuto({userId:t}):yield this.stateService.getCryptoMasterKeyBiometric({userId:t})}))}getKeyForUserEncryption(e){return ta(this,void 0,void 0,(function*(){if(null!=e)return e;const t=yield this.getEncKey();return null!=t?t:yield this.getKey()}))}stretchKey(e){return ta(this,void 0,void 0,(function*(){const t=new Uint8Array(64),i=yield this.cryptoFunctionService.hkdfExpand(e.key,"enc",32,"sha256"),n=yield this.cryptoFunctionService.hkdfExpand(e.key,"mac",32,"sha256");return t.set(new Uint8Array(i)),t.set(new Uint8Array(n),32),new Ct(t.buffer)}))}hashPhrase(e,t=64){return ta(this,void 0,void 0,(function*(){const i=Math.log(Ls.length)/Math.log(2);let n=Math.ceil(t/i);const s=Array.from(new Uint8Array(e));if(n*i>4*s.length)throw new Error("Output entropy of hash function is too small");const r=[];let o=Jo.fromArray(s,256);for(;n--;){const e=o.mod(Ls.length);o=o.divide(Ls.length),r.push(Ls[e])}return r}))}buildEncKey(e,t){return ta(this,void 0,void 0,(function*(){let i=null;if(32===e.key.byteLength){const n=yield this.stretchKey(e);i=yield this.encrypt(t,n)}else{if(64!==e.key.byteLength)throw new Error("Invalid key size.");i=yield this.encrypt(t,e)}return[new Ct(t),i]}))}clearSecretKeyStore(e){return ta(this,void 0,void 0,(function*(){yield this.stateService.setCryptoMasterKeyAuto(null,{userId:e}),yield this.stateService.setCryptoMasterKeyBiometric(null,{userId:e})}))}getEncKeyHelper(e=null){return ta(this,void 0,void 0,(function*(){const t=yield this.stateService.getDecryptedCryptoSymmetricKey();if(null!=t)return t;const i=yield this.stateService.getEncryptedCryptoSymmetricKey();if(null==i)return null;if(null==e&&(e=yield this.getKey()),null==e)return null;let n;const s=new At(i);if(s.encryptionType===bt.AesCbc256_B64)n=yield this.decryptToBytes(s,e);else{if(s.encryptionType!==bt.AesCbc256_HmacSha256_B64)throw new Error("Unsupported encKey type.");{const t=yield this.stretchKey(e);n=yield this.decryptToBytes(s,t)}}if(null==n)return null;const r=new Ct(n);return yield this.stateService.setDecryptedCryptoSymmetricKey(r),r}))}}Zo([ni((()=>"getEncKey")),ea("design:type",Function),ea("design:paramtypes",[Ct]),ea("design:returntype",Promise)],ia.prototype,"getEncKey",null),Zo([ni((()=>"getOrgKeys")),ea("design:type",Function),ea("design:paramtypes",[]),ea("design:returntype",Promise)],ia.prototype,"getOrgKeys",null),Zo([ni((()=>"getProviderKeys")),ea("design:type",Function),ea("design:paramtypes",[]),ea("design:returntype",Promise)],ia.prototype,"getProviderKeys",null);var na=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class sa extends ia{retrieveKeyFromStorage(e){const t=Object.create(null,{retrieveKeyFromStorage:{get:()=>super.retrieveKeyFromStorage}});var i;return na(this,void 0,void 0,(function*(){return"biometric"===e?(yield this.platformUtilService.authenticateBiometric(),null===(i=yield this.getKey())||void 0===i?void 0:i.keyB64):yield t.retrieveKeyFromStorage.call(this,e)}))}}var ra,oa=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class aa{get(e){return oa(this,void 0,void 0,(function*(){return new Promise((t=>{this.chromeStorageApi.get(e,(i=>{null==i||null==i[e]?t(null):t(i[e])}))}))}))}has(e){return oa(this,void 0,void 0,(function*(){return null!=(yield this.get(e))}))}save(e,t){return oa(this,void 0,void 0,(function*(){if(null==t)return new Promise((t=>{this.chromeStorageApi.remove(e,(()=>{t()}))}));t instanceof Set&&(t=Array.from(t));const i={[e]:t};return new Promise((e=>{this.chromeStorageApi.set(i,(()=>{e()}))}))}))}remove(e){return oa(this,void 0,void 0,(function*(){return new Promise((t=>{this.chromeStorageApi.remove(e,(()=>{t()}))}))}))}}class la extends aa{constructor(){super(...arguments),this.chromeStorageApi=chrome.storage.local}}class ca{send(e,t={}){return Io.sendMessage(e,t)}}class da{send(e,t={}){const i=Object.assign({},{command:e},t);window.bitwardenPopupMainMessageListener(i)}}!function(e){e.Web="web",e.Browser="browser",e.Desktop="desktop",e.Mobile="mobile",e.Cli="cli",e.DirectoryConnector="connector"}(ra||(ra={}));var ua=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const ha=6e5;class pa{constructor(e,t,i){this.messagingService=e,this.clipboardWriteCallback=t,this.biometricCallback=i,this.showDialogResolves=new Map,this.passwordDialogResolves=new Map,this.deviceCache=null}getDevice(){return this.deviceCache||(-1!==navigator.userAgent.indexOf(" Firefox/")||-1!==navigator.userAgent.indexOf(" Gecko/")?this.deviceCache=l.FirefoxExtension:window.opr&&opr.addons||window.opera||navigator.userAgent.indexOf(" OPR/")>=0?this.deviceCache=l.OperaExtension:-1!==navigator.userAgent.indexOf(" Edg/")?this.deviceCache=l.EdgeExtension:-1!==navigator.userAgent.indexOf(" Vivaldi/")?this.deviceCache=l.VivaldiExtension:window.chrome&&-1!==navigator.userAgent.indexOf(" Chrome/")?this.deviceCache=l.ChromeExtension:-1!==navigator.userAgent.indexOf(" Safari/")&&(this.deviceCache=l.SafariExtension)),this.deviceCache}getDeviceString(){return l[this.getDevice()].toLowerCase().replace("extension","")}getClientType(){return ra.Browser}isFirefox(){return this.getDevice()===l.FirefoxExtension}isChrome(){return this.getDevice()===l.ChromeExtension}isEdge(){return this.getDevice()===l.EdgeExtension}isOpera(){return this.getDevice()===l.OperaExtension}isVivaldi(){return this.getDevice()===l.VivaldiExtension}isSafari(){return this.getDevice()===l.SafariExtension}isIE(){return!1}isMacAppStore(){return!1}isViewOpen(){return ua(this,void 0,void 0,(function*(){if(yield Io.isPopupOpen())return!0;if(this.isSafari())return!1;const e=this.sidebarViewName();if(null!=e&&chrome.extension.getViews({type:e}).length>0)return!0;return chrome.extension.getViews({type:"tab"}).length>0}))}lockTimeout(){return null}launchUri(e,t){Io.createNewTab(e,t&&!0===t.extensionPage)}getApplicationVersion(){return Promise.resolve(Io.getApplicationVersion())}supportsWebAuthn(e){return"undefined"!=typeof PublicKeyCredential}supportsDuo(){return!0}showToast(e,t,i,n){this.messagingService.send("showToast",{text:i,title:t,type:e,options:n})}showDialog(e,t,i,n,s,r=!1){const o=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);return this.messagingService.send("showDialog",{text:r?null:e,html:r?e:null,title:t,confirmText:i,cancelText:n,type:s,dialogId:o}),new Promise((e=>{this.showDialogResolves.set(o,{resolve:e,date:new Date})}))}isDev(){return!1}isSelfHost(){return!1}copyToClipboard(e,t){let i=window,n=window.document;t&&(t.window||t.win)?(i=t.window||t.win,n=i.document):t&&t.doc&&(n=t.doc);const s=!!t&&!!t.clearing,r=t&&t.clearMs?t.clearMs:null;if(this.isSafari())Ro.sendMessageToApp("copyToClipboard",e).then((()=>{s||null==this.clipboardWriteCallback||this.clipboardWriteCallback(e,r)}));else if(this.isFirefox()&&i.navigator.clipboard&&i.navigator.clipboard.writeText)i.navigator.clipboard.writeText(e).then((()=>{s||null==this.clipboardWriteCallback||this.clipboardWriteCallback(e,r)}));else if(i.clipboardData&&i.clipboardData.setData)i.clipboardData.setData("Text",e),s||null==this.clipboardWriteCallback||this.clipboardWriteCallback(e,r);else if(n.queryCommandSupported&&n.queryCommandSupported("copy")){this.isChrome()&&""===e&&(e="\0");const t=n.createElement("textarea");t.textContent=null==e||""===e?" ":e,t.style.position="fixed",n.body.appendChild(t),t.select();try{n.execCommand("copy")&&!s&&null!=this.clipboardWriteCallback&&this.clipboardWriteCallback(e,r)}catch(e){console.warn("Copy to clipboard failed.",e)}finally{n.body.removeChild(t)}}}readFromClipboard(e){return ua(this,void 0,void 0,(function*(){let t=window,i=window.document;if(e&&(e.window||e.win)?(t=e.window||e.win,i=t.document):e&&e.doc&&(i=e.doc),this.isSafari())return yield Ro.sendMessageToApp("readFromClipboard");if(this.isFirefox()&&t.navigator.clipboard&&t.navigator.clipboard.readText)return yield t.navigator.clipboard.readText();if(i.queryCommandSupported&&i.queryCommandSupported("paste")){const e=i.createElement("textarea");e.style.position="fixed",i.body.appendChild(e),e.focus();try{if(i.execCommand("paste"))return e.value}catch(e){console.warn("Read from clipboard failed.",e)}finally{i.body.removeChild(e)}}return null}))}resolveDialogPromise(e,t){if(this.showDialogResolves.has(e)){this.showDialogResolves.get(e).resolve(t),this.showDialogResolves.delete(e)}this.showDialogResolves.forEach(((e,t)=>{(new Date).getTime()-e.date.getTime()>ha&&this.showDialogResolves.delete(t)}))}resolvePasswordDialogPromise(e,t,i){return ua(this,void 0,void 0,(function*(){let n=!1;if(this.passwordDialogResolves.has(e)){const s=this.passwordDialogResolves.get(e);(yield s.tryResolve(t,i))&&(this.passwordDialogResolves.delete(e),n=!0)}return this.passwordDialogResolves.forEach(((e,t)=>{(new Date).getTime()-e.date.getTime()>ha&&this.passwordDialogResolves.delete(t)})),n}))}supportsBiometric(){return ua(this,void 0,void 0,(function*(){return"android"!==(yield Io.getPlatformInfo()).os&&(!this.isFirefox()||parseInt((yield browser.runtime.getBrowserInfo()).version.split(".")[0],10)>=87)}))}authenticateBiometric(){return this.biometricCallback()}sidebarViewName(){return window.chrome.sidebarAction&&this.isFirefox()?"sidebar":this.isOpera()&&"undefined"!=typeof opr&&opr.sidebarAction?"sidebar_panel":null}supportsSecureStorage(){return!1}}var ya,va=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};!function(e){e.Both="both",e.Disk="disk",e.Memory="memory"}(ya||(ya={}));class ga{constructor(e){this.accounts={},this.authenticatedAccounts=[],this.accountActivity={},this.globals=e}static fromJSON(e){return null==e?null:Object.assign(new ga(null),e,{accounts:ga.buildAccountMapFromJSON(null==e?void 0:e.accounts)})}static buildAccountMapFromJSON(e){if(!e)return{};const t={};for(const i in e)t[i]=Nt.fromJSON(e[i]);return t}}var ma=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},fa=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ba=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const wa="state",Sa="global",ka="authenticatedAccounts",Oa="activeUserId",Pa="tempAccountSettings",Aa="accountActivity",Ca="_masterkey_auto",Da="_masterkey_biometric",xa="_masterkey",Ta="DuckDuckGoSharedKey";class Ia{constructor(e,t,i,n,s,r,o=!0){this.storageService=e,this.secureStorageService=t,this.memoryStorageService=i,this.logService=n,this.stateMigrationService=s,this.stateFactory=r,this.useAccountCache=o,this.accounts=new Sr.X({}),this.activeAccountSubject=new Sr.X(null),this.activeAccount$=this.activeAccountSubject.asObservable(),this.activeAccountUnlockedSubject=new Sr.X(!1),this.activeAccountUnlocked$=this.activeAccountUnlockedSubject.asObservable(),this.hasBeenInited=!1,this.isRecoveredSession=!1,this.accountDiskCache=new Map,this.activeAccountSubject.pipe((0,kr.b)((e=>ba(this,void 0,void 0,(function*(){null==e&&0==this.activeAccountUnlockedSubject.getValue()||(null==e&&this.activeAccountUnlockedSubject.next(!1),this.activeAccountUnlockedSubject.next(null!=(yield this.getCryptoMasterKey())))}))))).subscribe()}init(){return ba(this,void 0,void 0,(function*(){this.hasBeenInited||((yield this.stateMigrationService.needsMigration())&&(yield this.stateMigrationService.migrate()),yield this.state().then((e=>ba(this,void 0,void 0,(function*(){null==e?yield this.setState(new ga(this.createGlobals())):this.isRecoveredSession=!0})))),yield this.initAccountState(),this.hasBeenInited=!0)}))}initAccountState(){return ba(this,void 0,void 0,(function*(){this.isRecoveredSession||(yield this.updateState((e=>ba(this,void 0,void 0,(function*(){var t;e.authenticatedAccounts=null!==(t=yield this.storageService.get(ka))&&void 0!==t?t:[];for(const t in e.authenticatedAccounts)null!=t&&(yield this.syncAccountFromDisk(e.authenticatedAccounts[t]));const i=yield this.storageService.get(Oa);return null!=i&&(e.activeUserId=i),yield this.pushAccounts(),this.activeAccountSubject.next(e.activeUserId),e})))))}))}syncAccountFromDisk(e){return ba(this,void 0,void 0,(function*(){null!=e&&(yield this.updateState((t=>ba(this,void 0,void 0,(function*(){null==t.accounts&&(t.accounts={}),t.accounts[e]=this.createAccount();const i=yield this.getAccountFromDisk({userId:e});return t.accounts[e].profile=i.profile,t})))))}))}addAccount(e){return ba(this,void 0,void 0,(function*(){e=yield this.setAccountEnvironmentUrls(e),yield this.updateState((t=>ba(this,void 0,void 0,(function*(){return t.authenticatedAccounts.push(e.profile.userId),yield this.storageService.save(ka,t.authenticatedAccounts),t.accounts[e.profile.userId]=e,t})))),yield this.scaffoldNewAccountStorage(e),yield this.setLastActive((new Date).getTime(),{userId:e.profile.userId}),yield this.setActiveUser(e.profile.userId),this.activeAccountSubject.next(e.profile.userId)}))}setActiveUser(e){return ba(this,void 0,void 0,(function*(){this.clearDecryptedDataForActiveUser(),yield this.updateState((t=>ba(this,void 0,void 0,(function*(){return t.activeUserId=e,yield this.storageService.save(Oa,e),this.activeAccountSubject.next(t.activeUserId),t})))),yield this.pushAccounts()}))}clean(e){var t;return ba(this,void 0,void 0,(function*(){e=this.reconcileOptions(e,yield this.defaultInMemoryOptions()),yield this.deAuthenticateAccount(e.userId),e.userId===(null===(t=yield this.state())||void 0===t?void 0:t.activeUserId)&&(yield this.dynamicallySetActiveUser()),yield this.removeAccountFromDisk(null==e?void 0:e.userId),this.removeAccountFromMemory(null==e?void 0:e.userId),yield this.pushAccounts()}))}getAccessToken(e){var t,i;return ba(this,void 0,void 0,(function*(){return e=yield this.getTimeoutBasedStorageOptions(e),null===(i=null===(t=yield this.getAccount(e))||void 0===t?void 0:t.tokens)||void 0===i?void 0:i.accessToken}))}setAccessToken(e,t){return ba(this,void 0,void 0,(function*(){t=yield this.getTimeoutBasedStorageOptions(t);const i=yield this.getAccount(t);i.tokens.accessToken=e,yield this.saveAccount(i,t)}))}getAddEditCipherInfo(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.addEditCipherInfo}))}setAddEditCipherInfo(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.addEditCipherInfo=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getAlwaysShowDock(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.alwaysShowDock)&&void 0!==i&&i}))}setAlwaysShowDock(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.alwaysShowDock=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getApiKeyClientId(e){var t,i;return ba(this,void 0,void 0,(function*(){return e=yield this.getTimeoutBasedStorageOptions(e),null===(i=null===(t=yield this.getAccount(e))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.apiKeyClientId}))}setApiKeyClientId(e,t){return ba(this,void 0,void 0,(function*(){t=yield this.getTimeoutBasedStorageOptions(t);const i=yield this.getAccount(t);i.profile.apiKeyClientId=e,yield this.saveAccount(i,t)}))}getApiKeyClientSecret(e){var t,i;return ba(this,void 0,void 0,(function*(){return e=yield this.getTimeoutBasedStorageOptions(e),null===(i=null===(t=yield this.getAccount(e))||void 0===t?void 0:t.keys)||void 0===i?void 0:i.apiKeyClientSecret}))}setApiKeyClientSecret(e,t){return ba(this,void 0,void 0,(function*(){t=yield this.getTimeoutBasedStorageOptions(t);const i=yield this.getAccount(t);i.keys.apiKeyClientSecret=e,yield this.saveAccount(i,t)}))}getAutoConfirmFingerPrints(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.autoConfirmFingerPrints)&&void 0!==n&&n}))}setAutoConfirmFingerprints(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.autoConfirmFingerPrints=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getAutoFillOnPageLoadDefault(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.autoFillOnPageLoadDefault)||void 0===n||n}))}setAutoFillOnPageLoadDefault(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.autoFillOnPageLoadDefault=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getBiometricAwaitingAcceptance(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.biometricAwaitingAcceptance)&&void 0!==i&&i}))}setBiometricAwaitingAcceptance(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.biometricAwaitingAcceptance=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getBiometricFingerprintValidated(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.biometricFingerprintValidated)&&void 0!==i&&i}))}setBiometricFingerprintValidated(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.biometricFingerprintValidated=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getBiometricText(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.biometricText}))}setBiometricText(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.biometricText=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getBiometricUnlock(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.biometricUnlock)&&void 0!==n&&n}))}setBiometricUnlock(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.biometricUnlock=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getCanAccessPremium(e){return ba(this,void 0,void 0,(function*(){return!!(yield this.getIsAuthenticated(e))&&((yield this.getHasPremiumPersonally(e))||(yield this.getHasPremiumFromOrganization(e)))}))}getHasPremiumPersonally(e){var t;return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions()));return null===(t=null==i?void 0:i.profile)||void 0===t?void 0:t.hasPremiumPersonally}))}setHasPremiumPersonally(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.hasPremiumPersonally=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getHasPremiumFromOrganization(e){var t;return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions()));if(null===(t=i.profile)||void 0===t?void 0:t.hasPremiumFromOrganization)return!0;const n=yield this.getOrganizations(e);if(null==n)return!1;for(const e of Object.keys(n)){const t=n[e];if(t.enabled&&t.usersGetPremium&&!t.isProviderUser)return!0}return!1}))}setHasPremiumFromOrganization(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.hasPremiumFromOrganization=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getClearClipboard(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.clearClipboard)&&void 0!==n?n:null}))}setClearClipboard(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.clearClipboard=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getCollapsedGroupings(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.collapsedGroupings}))}setCollapsedGroupings(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.collapsedGroupings=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getConvertAccountToKeyConnector(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.convertAccountToKeyConnector}))}setConvertAccountToKeyConnector(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.convertAccountToKeyConnector=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getCryptoMasterKey(e){var t;return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions()));return null===(t=null==i?void 0:i.keys)||void 0===t?void 0:t.cryptoMasterKey}))}setCryptoMasterKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));if(i.keys.cryptoMasterKey=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions())),t.userId==this.activeAccountSubject.getValue()){const t=null!=e;this.activeAccountUnlockedSubject.getValue()!=t&&this.activeAccountUnlockedSubject.next(t)}}))}getCryptoMasterKeyAuto(e){return ba(this,void 0,void 0,(function*(){return null==(null==(e=this.reconcileOptions(this.reconcileOptions(e,{keySuffix:"auto"}),yield this.defaultSecureStorageOptions()))?void 0:e.userId)?null:yield this.secureStorageService.get(`${e.userId}${Ca}`,e)}))}setCryptoMasterKeyAuto(e,t){return ba(this,void 0,void 0,(function*(){null!=(null==(t=this.reconcileOptions(this.reconcileOptions(t,{keySuffix:"auto"}),yield this.defaultSecureStorageOptions()))?void 0:t.userId)&&(yield this.saveSecureStorageKey(Ca,e,t))}))}getCryptoMasterKeyB64(e){return ba(this,void 0,void 0,(function*(){return null==(null==(e=this.reconcileOptions(e,yield this.defaultSecureStorageOptions()))?void 0:e.userId)?null:yield this.secureStorageService.get(`${null==e?void 0:e.userId}${xa}`,e)}))}setCryptoMasterKeyB64(e,t){return ba(this,void 0,void 0,(function*(){null!=(null==(t=this.reconcileOptions(t,yield this.defaultSecureStorageOptions()))?void 0:t.userId)&&(yield this.saveSecureStorageKey(xa,e,t))}))}getCryptoMasterKeyBiometric(e){return ba(this,void 0,void 0,(function*(){return null==(null==(e=this.reconcileOptions(this.reconcileOptions(e,{keySuffix:"biometric"}),yield this.defaultSecureStorageOptions()))?void 0:e.userId)?null:yield this.secureStorageService.get(`${e.userId}${Da}`,e)}))}hasCryptoMasterKeyBiometric(e){return ba(this,void 0,void 0,(function*(){return null!=(null==(e=this.reconcileOptions(this.reconcileOptions(e,{keySuffix:"biometric"}),yield this.defaultSecureStorageOptions()))?void 0:e.userId)&&(yield this.secureStorageService.has(`${e.userId}${Da}`,e))}))}setCryptoMasterKeyBiometric(e,t){return ba(this,void 0,void 0,(function*(){null!=(null==(t=this.reconcileOptions(this.reconcileOptions(t,{keySuffix:"biometric"}),yield this.defaultSecureStorageOptions()))?void 0:t.userId)&&(yield this.saveSecureStorageKey(Da,e,t))}))}getDecryptedCiphers(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.ciphers)||void 0===n?void 0:n.decrypted}))}setDecryptedCiphers(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.ciphers.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedCollections(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.collections)||void 0===n?void 0:n.decrypted}))}setDecryptedCollections(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.collections.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedCryptoSymmetricKey(e){var t,i;return ba(this,void 0,void 0,(function*(){const n=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions()));return null===(i=null===(t=null==n?void 0:n.keys)||void 0===t?void 0:t.cryptoSymmetricKey)||void 0===i?void 0:i.decrypted}))}setDecryptedCryptoSymmetricKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.keys.cryptoSymmetricKey.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedOrganizationKeys(e){var t,i;return ba(this,void 0,void 0,(function*(){const n=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions()));return this.recordToMap(null===(i=null===(t=null==n?void 0:n.keys)||void 0===t?void 0:t.organizationKeys)||void 0===i?void 0:i.decrypted)}))}setDecryptedOrganizationKeys(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.keys.organizationKeys.decrypted=this.mapToRecord(e),yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedPasswordGenerationHistory(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.passwordGenerationHistory)||void 0===n?void 0:n.decrypted}))}setDecryptedPasswordGenerationHistory(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.passwordGenerationHistory.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedPinProtected(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.pinProtected)||void 0===n?void 0:n.decrypted}))}setDecryptedPinProtected(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.settings.pinProtected.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedPolicies(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.policies)||void 0===n?void 0:n.decrypted}))}setDecryptedPolicies(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.policies.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedPrivateKey(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.keys)||void 0===i?void 0:i.privateKey.decrypted}))}setDecryptedPrivateKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.keys.privateKey.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedProviderKeys(e){var t,i;return ba(this,void 0,void 0,(function*(){const n=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions()));return this.recordToMap(null===(i=null===(t=null==n?void 0:n.keys)||void 0===t?void 0:t.providerKeys)||void 0===i?void 0:i.decrypted)}))}setDecryptedProviderKeys(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.keys.providerKeys.decrypted=this.mapToRecord(e),yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDecryptedSends(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.sends)||void 0===n?void 0:n.decrypted}))}setDecryptedSends(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.data.sends.decrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getDefaultUriMatch(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.defaultUriMatch}))}setDefaultUriMatch(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.defaultUriMatch=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableAddLoginNotification(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableAddLoginNotification)&&void 0!==n&&n}))}setDisableAddLoginNotification(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableAddLoginNotification=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableAutoBiometricsPrompt(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableAutoBiometricsPrompt)&&void 0!==n&&n}))}setDisableAutoBiometricsPrompt(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableAutoBiometricsPrompt=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableAutoTotpCopy(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableAutoTotpCopy)&&void 0!==n&&n}))}setDisableAutoTotpCopy(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableAutoTotpCopy=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableBadgeCounter(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableBadgeCounter)&&void 0!==n&&n}))}setDisableBadgeCounter(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableBadgeCounter=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableChangedPasswordNotification(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableChangedPasswordNotification)&&void 0!==n&&n}))}setDisableChangedPasswordNotification(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableChangedPasswordNotification=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableContextMenuItem(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableContextMenuItem)&&void 0!==n&&n}))}setDisableContextMenuItem(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableContextMenuItem=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDisableFavicon(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.disableFavicon)&&void 0!==i&&i}))}setDisableFavicon(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.disableFavicon=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getDisableGa(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.disableGa)&&void 0!==n&&n}))}setDisableGa(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.disableGa=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDontShowCardsCurrentTab(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.dontShowCardsCurrentTab)&&void 0!==n&&n}))}setDontShowCardsCurrentTab(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.dontShowCardsCurrentTab=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDontShowIdentitiesCurrentTab(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.dontShowIdentitiesCurrentTab)&&void 0!==n&&n}))}setDontShowIdentitiesCurrentTab(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.dontShowIdentitiesCurrentTab=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getDuckDuckGoSharedKey(e){return ba(this,void 0,void 0,(function*(){return null==(null==(e=this.reconcileOptions(e,yield this.defaultSecureStorageOptions()))?void 0:e.userId)?null:yield this.secureStorageService.get(Ta,e)}))}setDuckDuckGoSharedKey(e,t){return ba(this,void 0,void 0,(function*(){null!=(null==(t=this.reconcileOptions(t,yield this.defaultSecureStorageOptions()))?void 0:t.userId)&&(null==e?yield this.secureStorageService.remove(Ta,t):yield this.secureStorageService.save(Ta,e,t))}))}getEmail(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.email}))}setEmail(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.profile.email=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getEmailVerified(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile.emailVerified)&&void 0!==i&&i}))}setEmailVerified(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.emailVerified=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableAlwaysOnTop(e){var t,i,n,s;return ba(this,void 0,void 0,(function*(){const r=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.enableAlwaysOnTop,o=null===(n=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===n?void 0:n.enableAlwaysOnTop;return null!==(s=null!=r?r:o)&&void 0!==s&&s}))}setEnableAlwaysOnTop(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.enableAlwaysOnTop=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()));const n=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));n.enableAlwaysOnTop=e,yield this.saveGlobals(n,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableAutoFillOnPageLoad(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.enableAutoFillOnPageLoad)&&void 0!==n&&n}))}setEnableAutoFillOnPageLoad(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.enableAutoFillOnPageLoad=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableBiometric(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableBiometrics)&&void 0!==i&&i}))}setEnableBiometric(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableBiometrics=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableBrowserIntegration(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableBrowserIntegration)&&void 0!==i&&i}))}setEnableBrowserIntegration(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableBrowserIntegration=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableBrowserIntegrationFingerprint(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableBrowserIntegrationFingerprint)&&void 0!==i&&i}))}setEnableBrowserIntegrationFingerprint(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableBrowserIntegrationFingerprint=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableCloseToTray(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableCloseToTray)&&void 0!==i&&i}))}setEnableCloseToTray(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableCloseToTray=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableDuckDuckGoBrowserIntegration(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableDuckDuckGoBrowserIntegration)&&void 0!==i&&i}))}setEnableDuckDuckGoBrowserIntegration(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableDuckDuckGoBrowserIntegration=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableFullWidth(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.enableFullWidth)&&void 0!==n&&n}))}setEnableFullWidth(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.enableFullWidth=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getEnableGravitars(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.enableGravitars)&&void 0!==n&&n}))}setEnableGravitars(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.enableGravitars=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getEnableMinimizeToTray(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableMinimizeToTray)&&void 0!==i&&i}))}setEnableMinimizeToTray(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableMinimizeToTray=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableStartToTray(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableStartToTray)&&void 0!==i&&i}))}setEnableStartToTray(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableStartToTray=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEnableTray(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.enableTray)&&void 0!==i&&i}))}setEnableTray(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.enableTray=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedCiphers(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.ciphers)||void 0===n?void 0:n.encrypted}))}setEncryptedCiphers(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.data.ciphers.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getEncryptedCollections(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.collections)||void 0===n?void 0:n.encrypted}))}setEncryptedCollections(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.data.collections.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getEncryptedCryptoSymmetricKey(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.keys.cryptoSymmetricKey.encrypted}))}setEncryptedCryptoSymmetricKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.keys.cryptoSymmetricKey.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedFolders(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.folders)||void 0===n?void 0:n.encrypted}))}setEncryptedFolders(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.data.folders.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getEncryptedOrganizationKeys(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.keys)||void 0===i?void 0:i.organizationKeys.encrypted}))}setEncryptedOrganizationKeys(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.keys.organizationKeys.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedPasswordGenerationHistory(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.passwordGenerationHistory)||void 0===n?void 0:n.encrypted}))}setEncryptedPasswordGenerationHistory(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.data.passwordGenerationHistory.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedPinProtected(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.pinProtected)||void 0===n?void 0:n.encrypted}))}setEncryptedPinProtected(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.pinProtected.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedPolicies(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.policies)||void 0===n?void 0:n.encrypted}))}setEncryptedPolicies(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.data.policies.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedPrivateKey(e){var t,i;return ba(this,void 0,void 0,(function*(){const n=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions()));return null===(i=null===(t=null==n?void 0:n.keys)||void 0===t?void 0:t.privateKey)||void 0===i?void 0:i.encrypted}))}setEncryptedPrivateKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.keys.privateKey.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedProviderKeys(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null===(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.keys)||void 0===i?void 0:i.providerKeys)||void 0===n?void 0:n.encrypted}))}setEncryptedProviderKeys(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.keys.providerKeys.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEncryptedSends(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.sends.encrypted}))}setEncryptedSends(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.data.sends.encrypted=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getEntityId(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.entityId}))}setEntityId(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.profile.entityId=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getEntityType(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.entityType}))}setEntityType(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.profile.entityType=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getEnvironmentUrls(e){var t,i,n,s;return ba(this,void 0,void 0,(function*(){return null==(null===(t=yield this.state())||void 0===t?void 0:t.activeUserId)?yield this.getGlobalEnvironmentUrls(e):(e=this.reconcileOptions(e,yield this.defaultOnDiskOptions()),null!==(s=null===(n=null===(i=yield this.getAccount(e))||void 0===i?void 0:i.settings)||void 0===n?void 0:n.environmentUrls)&&void 0!==s?s:new h)}))}setEnvironmentUrls(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.environmentUrls=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEquivalentDomains(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.equivalentDomains}))}setEquivalentDomains(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.equivalentDomains=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEventCollection(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.eventCollection}))}setEventCollection(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.data.eventCollection=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getEverBeenUnlocked(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.everBeenUnlocked)&&void 0!==n&&n}))}setEverBeenUnlocked(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.profile.everBeenUnlocked=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getForcePasswordReset(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.forcePasswordReset)&&void 0!==n&&n}))}setForcePasswordReset(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.profile.forcePasswordReset=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getInstalledVersion(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.installedVersion}))}setInstalledVersion(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.installedVersion=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getIsAuthenticated(e){return ba(this,void 0,void 0,(function*(){return null!=(yield this.getAccessToken(e))&&null!=(yield this.getUserId(e))}))}getKdfIterations(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.kdfIterations}))}setKdfIterations(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.kdfIterations=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getKdfType(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.kdfType}))}setKdfType(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.kdfType=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getKeyHash(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.keyHash}))}setKeyHash(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.keyHash=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getLastActive(e){return ba(this,void 0,void 0,(function*(){e=this.reconcileOptions(e,yield this.defaultOnDiskOptions());const t=yield this.storageService.get(Aa,e);return null==t||Object.keys(t).length<1?null:t[e.userId]}))}setLastActive(e,t){var i;return ba(this,void 0,void 0,(function*(){if(null==(t=this.reconcileOptions(t,yield this.defaultOnDiskOptions())).userId)return;const n=null!==(i=yield this.storageService.get(Aa,t))&&void 0!==i?i:{};n[t.userId]=e,yield this.storageService.save(Aa,n,t)}))}getLastSync(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.lastSync}))}setLastSync(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.profile.lastSync=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getLocalData(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.localData}))}setLocalData(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.data.localData=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getLocale(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.locale}))}setLocale(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.locale=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getMainWindowSize(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.mainWindowSize}))}setMainWindowSize(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.mainWindowSize=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getMinimizeOnCopyToClipboard(e){var t,i,n;return ba(this,void 0,void 0,(function*(){return null!==(n=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.minimizeOnCopyToClipboard)&&void 0!==n&&n}))}setMinimizeOnCopyToClipboard(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.minimizeOnCopyToClipboard=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getNeverDomains(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.neverDomains}))}setNeverDomains(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.neverDomains=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getNoAutoPromptBiometrics(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.noAutoPromptBiometrics)&&void 0!==i&&i}))}setNoAutoPromptBiometrics(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.noAutoPromptBiometrics=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getNoAutoPromptBiometricsText(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.noAutoPromptBiometricsText}))}setNoAutoPromptBiometricsText(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.noAutoPromptBiometricsText=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getOpenAtLogin(e){var t,i;return ba(this,void 0,void 0,(function*(){return null!==(i=null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.openAtLogin)&&void 0!==i&&i}))}setOpenAtLogin(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.openAtLogin=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getOrganizationInvitation(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.organizationInvitation}))}setOrganizationInvitation(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.organizationInvitation=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getOrganizations(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.organizations}))}setOrganizations(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.data.organizations=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getPasswordGenerationOptions(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.passwordGenerationOptions}))}setPasswordGenerationOptions(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.passwordGenerationOptions=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getUsernameGenerationOptions(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.usernameGenerationOptions}))}setUsernameGenerationOptions(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.usernameGenerationOptions=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getGeneratorOptions(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.generatorOptions}))}setGeneratorOptions(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.generatorOptions=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getProtectedPin(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.protectedPin}))}setProtectedPin(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.settings.protectedPin=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getProviders(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.data)||void 0===i?void 0:i.providers}))}setProviders(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.data.providers=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getPublicKey(e){var t;return ba(this,void 0,void 0,(function*(){const i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.keys;return null==i?void 0:i.publicKey}))}setPublicKey(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.keys.publicKey=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getRefreshToken(e){var t,i;return ba(this,void 0,void 0,(function*(){return e=yield this.getTimeoutBasedStorageOptions(e),null===(i=null===(t=yield this.getAccount(e))||void 0===t?void 0:t.tokens)||void 0===i?void 0:i.refreshToken}))}setRefreshToken(e,t){return ba(this,void 0,void 0,(function*(){t=yield this.getTimeoutBasedStorageOptions(t);const i=yield this.getAccount(t);i.tokens.refreshToken=e,yield this.saveAccount(i,t)}))}getRememberedEmail(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.rememberedEmail}))}setRememberedEmail(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.rememberedEmail=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getSecurityStamp(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.tokens)||void 0===i?void 0:i.securityStamp}))}setSecurityStamp(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.tokens.securityStamp=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getSettings(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskMemoryOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.settings}))}setSettings(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()));i.settings.settings=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskMemoryOptions()))}))}getSsoCodeVerifier(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.ssoCodeVerifier}))}setSsoCodeVerifier(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.ssoCodeVerifier=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getSsoOrgIdentifier(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.ssoOrganizationIdentifier}))}setSsoOrganizationIdentifier(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.ssoOrganizationIdentifier=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getSsoState(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.ssoState}))}setSsoState(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.ssoState=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getTheme(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.theme}))}setTheme(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.theme=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getTwoFactorToken(e){var t;return ba(this,void 0,void 0,(function*(){return null===(t=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.twoFactorToken}))}setTwoFactorToken(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.twoFactorToken=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getUserId(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.userId}))}getUsesKeyConnector(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskOptions())))||void 0===t?void 0:t.profile)||void 0===i?void 0:i.usesKeyConnector}))}setUsesKeyConnector(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));i.profile.usesKeyConnector=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}getVaultTimeout(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.vaultTimeout}))}setVaultTimeout(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.vaultTimeout=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getVaultTimeoutAction(e){var t,i,n;return ba(this,void 0,void 0,(function*(){const s=null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.vaultTimeoutAction,r=null===(n=yield this.getGlobals(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===n?void 0:n.vaultTimeoutAction;return null!=s?s:r}))}setVaultTimeoutAction(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));i.settings.vaultTimeoutAction=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getStateVersion(){var e;return ba(this,void 0,void 0,(function*(){return null!==(e=(yield this.getGlobals(yield this.defaultOnDiskLocalOptions())).stateVersion)&&void 0!==e?e:1}))}setStateVersion(e){return ba(this,void 0,void 0,(function*(){const t=yield this.getGlobals(yield this.defaultOnDiskOptions());t.stateVersion=e,yield this.saveGlobals(t,yield this.defaultOnDiskOptions())}))}getWindow(){return ba(this,void 0,void 0,(function*(){const e=yield this.getGlobals(yield this.defaultOnDiskOptions());return null!=(null==e?void 0:e.window)&&Object.keys(e.window).length>0?e.window:new p}))}setWindow(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getGlobals(this.reconcileOptions(t,yield this.defaultOnDiskOptions()));return i.window=e,yield this.saveGlobals(i,this.reconcileOptions(t,yield this.defaultOnDiskOptions()))}))}setServerConfig(e,t){return ba(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()));return i.settings.serverConfig=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultOnDiskLocalOptions()))}))}getServerConfig(e){var t,i;return ba(this,void 0,void 0,(function*(){return null===(i=null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultOnDiskLocalOptions())))||void 0===t?void 0:t.settings)||void 0===i?void 0:i.serverConfig}))}getGlobals(e){return ba(this,void 0,void 0,(function*(){let t;return this.useMemory(e.storageLocation)&&(t=yield this.getGlobalsFromMemory()),this.useDisk&&null==t&&(t=yield this.getGlobalsFromDisk(e)),null!=t?t:this.createGlobals()}))}saveGlobals(e,t){return ba(this,void 0,void 0,(function*(){return this.useMemory(t.storageLocation)?this.saveGlobalsToMemory(e):yield this.saveGlobalsToDisk(e,t)}))}getGlobalsFromMemory(){return ba(this,void 0,void 0,(function*(){return(yield this.state()).globals}))}getGlobalsFromDisk(e){return ba(this,void 0,void 0,(function*(){return yield this.storageService.get(Sa,e)}))}saveGlobalsToMemory(e){return ba(this,void 0,void 0,(function*(){yield this.updateState((t=>ba(this,void 0,void 0,(function*(){return t.globals=e,t}))))}))}saveGlobalsToDisk(e,t){return ba(this,void 0,void 0,(function*(){t.useSecureStorage?yield this.secureStorageService.save(Sa,e,t):yield this.storageService.save(Sa,e,t)}))}getAccount(e){return ba(this,void 0,void 0,(function*(){try{let t;return this.useMemory(e.storageLocation)&&(t=yield this.getAccountFromMemory(e)),this.useDisk(e.storageLocation)&&null==t&&(t=yield this.getAccountFromDisk(e)),t}catch(e){this.logService.error(e)}}))}getAccountFromMemory(e){return ba(this,void 0,void 0,(function*(){return yield this.state().then((t=>ba(this,void 0,void 0,(function*(){return null==t.accounts?null:t.accounts[yield this.getUserIdFromMemory(e)]}))))}))}getUserIdFromMemory(e){return ba(this,void 0,void 0,(function*(){return yield this.state().then((t=>{var i,n;return null!=(null==e?void 0:e.userId)?null===(n=null===(i=t.accounts[e.userId])||void 0===i?void 0:i.profile)||void 0===n?void 0:n.userId:t.activeUserId}))}))}getAccountFromDisk(e){var t,i;return ba(this,void 0,void 0,(function*(){if(null==(null==e?void 0:e.userId)&&null==(null===(t=yield this.state())||void 0===t?void 0:t.activeUserId))return null;if(this.useAccountCache){const t=this.accountDiskCache.get(e.userId);if(null!=t)return t}const n=(null==e?void 0:e.useSecureStorage)?null!==(i=yield this.secureStorageService.get(e.userId,e))&&void 0!==i?i:yield this.storageService.get(e.userId,this.reconcileOptions(e,{htmlStorageLocation:rt.Local})):yield this.storageService.get(e.userId,e);return this.useAccountCache&&this.accountDiskCache.set(e.userId,n),n}))}useMemory(e){return e===ya.Memory||e===ya.Both}useDisk(e){return e===ya.Disk||e===ya.Both}saveAccount(e,t={storageLocation:ya.Both,useSecureStorage:!1}){return ba(this,void 0,void 0,(function*(){return this.useMemory(t.storageLocation)?yield this.saveAccountToMemory(e):yield this.saveAccountToDisk(e,t)}))}saveAccountToDisk(e,t){return ba(this,void 0,void 0,(function*(){const i=t.useSecureStorage?this.secureStorageService:this.storageService;yield i.save(`${t.userId}`,e,t),this.useAccountCache&&this.accountDiskCache.delete(t.userId)}))}saveAccountToMemory(e){return ba(this,void 0,void 0,(function*(){null!==this.getAccountFromMemory({userId:e.profile.userId})&&(yield this.updateState((t=>new Promise((i=>{t.accounts[e.profile.userId]=e,i(t)}))))),yield this.pushAccounts()}))}scaffoldNewAccountStorage(e){return ba(this,void 0,void 0,(function*(){const t=JSON.parse(JSON.stringify(e));yield this.scaffoldNewAccountLocalStorage(t),yield this.scaffoldNewAccountSessionStorage(t),yield this.scaffoldNewAccountMemoryStorage(t)}))}scaffoldNewAccountLocalStorage(e){return ba(this,void 0,void 0,(function*(){const t=yield this.getAccount(this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskLocalOptions())),i=e.settings.environmentUrls;null!=(null==t?void 0:t.settings)?e.settings=t.settings:(yield this.storageService.has(Pa))&&(e.settings=yield this.storageService.get(Pa),yield this.storageService.remove(Pa)),e.settings.environmentUrls=i,"logOut"===e.settings.vaultTimeoutAction&&null!=e.settings.vaultTimeout&&(e.tokens.accessToken=null,e.tokens.refreshToken=null,e.profile.apiKeyClientId=null,e.keys.apiKeyClientSecret=null),yield this.saveAccount(e,this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskLocalOptions()))}))}scaffoldNewAccountMemoryStorage(e){return ba(this,void 0,void 0,(function*(){const t=yield this.getAccount(this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskMemoryOptions()));null!=(null==t?void 0:t.settings)&&(t.settings.environmentUrls=e.settings.environmentUrls,e.settings=t.settings),yield this.storageService.save(e.profile.userId,e,yield this.defaultOnDiskMemoryOptions()),yield this.saveAccount(e,this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskMemoryOptions()))}))}scaffoldNewAccountSessionStorage(e){return ba(this,void 0,void 0,(function*(){const t=yield this.getAccount(this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskOptions()));null!=(null==t?void 0:t.settings)&&(t.settings.environmentUrls=e.settings.environmentUrls,e.settings=t.settings),yield this.storageService.save(e.profile.userId,e,yield this.defaultOnDiskMemoryOptions()),yield this.saveAccount(e,this.reconcileOptions({userId:e.profile.userId},yield this.defaultOnDiskOptions()))}))}pushAccounts(){return ba(this,void 0,void 0,(function*(){yield this.pruneInMemoryAccounts(),yield this.state().then((e=>{null==e.accounts||Object.keys(e.accounts).length<1?this.accounts.next(null):this.accounts.next(e.accounts)}))}))}reconcileOptions(e,t){var i,n,s,r,o;return null==e?t:(e.userId=null!==(i=null==e?void 0:e.userId)&&void 0!==i?i:t.userId,e.storageLocation=null!==(n=null==e?void 0:e.storageLocation)&&void 0!==n?n:t.storageLocation,e.useSecureStorage=null!==(s=null==e?void 0:e.useSecureStorage)&&void 0!==s?s:t.useSecureStorage,e.htmlStorageLocation=null!==(r=null==e?void 0:e.htmlStorageLocation)&&void 0!==r?r:t.htmlStorageLocation,e.keySuffix=null!==(o=null==e?void 0:e.keySuffix)&&void 0!==o?o:t.keySuffix,e)}defaultInMemoryOptions(){return ba(this,void 0,void 0,(function*(){return{storageLocation:ya.Memory,userId:(yield this.state()).activeUserId}}))}defaultOnDiskOptions(){var e,t;return ba(this,void 0,void 0,(function*(){return{storageLocation:ya.Disk,htmlStorageLocation:rt.Session,userId:null!==(t=null===(e=yield this.state())||void 0===e?void 0:e.activeUserId)&&void 0!==t?t:yield this.getActiveUserIdFromStorage(),useSecureStorage:!1}}))}defaultOnDiskLocalOptions(){var e,t;return ba(this,void 0,void 0,(function*(){return{storageLocation:ya.Disk,htmlStorageLocation:rt.Local,userId:null!==(t=null===(e=yield this.state())||void 0===e?void 0:e.activeUserId)&&void 0!==t?t:yield this.getActiveUserIdFromStorage(),useSecureStorage:!1}}))}defaultOnDiskMemoryOptions(){var e,t;return ba(this,void 0,void 0,(function*(){return{storageLocation:ya.Disk,htmlStorageLocation:rt.Memory,userId:null!==(t=null===(e=yield this.state())||void 0===e?void 0:e.activeUserId)&&void 0!==t?t:yield this.getUserId(),useSecureStorage:!1}}))}defaultSecureStorageOptions(){var e,t;return ba(this,void 0,void 0,(function*(){return{storageLocation:ya.Disk,useSecureStorage:!0,userId:null!==(t=null===(e=yield this.state())||void 0===e?void 0:e.activeUserId)&&void 0!==t?t:yield this.getActiveUserIdFromStorage()}}))}getActiveUserIdFromStorage(){return ba(this,void 0,void 0,(function*(){return yield this.storageService.get(Oa)}))}removeAccountFromLocalStorage(e=null){var t;return ba(this,void 0,void 0,(function*(){e=null!=e?e:null===(t=yield this.state())||void 0===t?void 0:t.activeUserId;const i=yield this.getAccount(this.reconcileOptions({userId:e},yield this.defaultOnDiskLocalOptions()));yield this.saveAccount(this.resetAccount(i),this.reconcileOptions({userId:e},yield this.defaultOnDiskLocalOptions()))}))}removeAccountFromSessionStorage(e=null){var t;return ba(this,void 0,void 0,(function*(){e=null!=e?e:null===(t=yield this.state())||void 0===t?void 0:t.activeUserId;const i=yield this.getAccount(this.reconcileOptions({userId:e},yield this.defaultOnDiskOptions()));yield this.saveAccount(this.resetAccount(i),this.reconcileOptions({userId:e},yield this.defaultOnDiskOptions()))}))}removeAccountFromSecureStorage(e=null){var t;return ba(this,void 0,void 0,(function*(){e=null!=e?e:null===(t=yield this.state())||void 0===t?void 0:t.activeUserId,yield this.setCryptoMasterKeyAuto(null,{userId:e}),yield this.setCryptoMasterKeyBiometric(null,{userId:e}),yield this.setCryptoMasterKeyB64(null,{userId:e})}))}removeAccountFromMemory(e=null){return ba(this,void 0,void 0,(function*(){yield this.updateState((t=>ba(this,void 0,void 0,(function*(){return e=null!=e?e:t.activeUserId,delete t.accounts[e],this.useAccountCache&&this.accountDiskCache.delete(e),t}))))}))}pruneInMemoryAccounts(){var e;return ba(this,void 0,void 0,(function*(){for(const t in null===(e=yield this.state())||void 0===e?void 0:e.accounts)(yield this.getIsAuthenticated({userId:t}))||(yield this.removeAccountFromMemory(t))}))}resetAccount(e){const t={settings:e.settings};return Object.assign(this.createAccount(),t)}setAccountEnvironmentUrls(e){return ba(this,void 0,void 0,(function*(){return e.settings.environmentUrls=yield this.getGlobalEnvironmentUrls(),e}))}getGlobalEnvironmentUrls(e){var t;return ba(this,void 0,void 0,(function*(){return e=this.reconcileOptions(e,yield this.defaultOnDiskOptions()),null!==(t=(yield this.getGlobals(e)).environmentUrls)&&void 0!==t?t:new h}))}clearDecryptedDataForActiveUser(){return ba(this,void 0,void 0,(function*(){yield this.updateState((e=>ba(this,void 0,void 0,(function*(){var t;const i=null==e?void 0:e.activeUserId;return null!=i&&null!=(null===(t=null==e?void 0:e.accounts[i])||void 0===t?void 0:t.data)&&(e.accounts[i].data=new It),e}))))}))}createAccount(e=null){return this.stateFactory.createAccount(e)}createGlobals(e=null){return this.stateFactory.createGlobal(e)}deAuthenticateAccount(e){return ba(this,void 0,void 0,(function*(){yield this.setAccessToken(null,{userId:e}),yield this.setLastActive(null,{userId:e}),yield this.updateState((t=>ba(this,void 0,void 0,(function*(){return t.authenticatedAccounts=t.authenticatedAccounts.filter((t=>t!==e)),yield this.storageService.save(ka,t.authenticatedAccounts),t}))))}))}removeAccountFromDisk(e){return ba(this,void 0,void 0,(function*(){yield this.removeAccountFromSessionStorage(e),yield this.removeAccountFromLocalStorage(e),yield this.removeAccountFromSecureStorage(e)}))}dynamicallySetActiveUser(){var e;return ba(this,void 0,void 0,(function*(){const t=null===(e=yield this.state())||void 0===e?void 0:e.accounts;if(null==t||Object.keys(t).length<1)yield this.setActiveUser(null);else for(const e in t)if(null!=e){if(yield this.getIsAuthenticated({userId:e})){yield this.setActiveUser(e);break}yield this.setActiveUser(null)}}))}getTimeoutBasedStorageOptions(e){return ba(this,void 0,void 0,(function*(){const t=yield this.getVaultTimeoutAction({userId:null==e?void 0:e.userId}),i=yield this.getVaultTimeout({userId:null==e?void 0:e.userId}),n="logOut"===t&&null!=i?yield this.defaultInMemoryOptions():yield this.defaultOnDiskOptions();return this.reconcileOptions(e,n)}))}saveSecureStorageKey(e,t,i){return ba(this,void 0,void 0,(function*(){return null==t?yield this.secureStorageService.remove(`${i.userId}${e}`,i):yield this.secureStorageService.save(`${i.userId}${e}`,t,i)}))}state(){return ba(this,void 0,void 0,(function*(){return yield this.memoryStorageService.get(wa,{deserializer:e=>ga.fromJSON(e)})}))}setState(e){return ba(this,void 0,void 0,(function*(){yield this.memoryStorageService.save(wa,e)}))}updateState(e){return ba(this,void 0,void 0,(function*(){yield this.state().then((t=>ba(this,void 0,void 0,(function*(){const i=yield e(t);if(null==i)throw new Error("Attempted to update state to null value");yield this.setState(i)}))))}))}mapToRecord(e){return null==e?null:Object.fromEntries(e)}recordToMap(e){return null==e?null:new Map(Object.entries(e))}}function Ra(e,t=(e=>e)){return(i,n,s)=>{const r=s.value;return{value:function(...i){const s=r.apply(this,i);if(!(s instanceof Promise))throw new Error(`Error applying prototype to stored value -- result is not a promise for method ${String(n)}`);return s.then((i=>null==i||i.constructor.name===e.prototype.constructor.name?t(i):t(Object.create(e.prototype,Object.getOwnPropertyDescriptors(i)))))}}}}function Ea(e,t=(e=>e)){return(i,n,s)=>{const r=s.value;return{value:function(...i){const s=r.apply(this,i);if(!(s instanceof Promise))throw new Error(`Error applying prototype to stored value -- result is not a promise for method ${String(n)}`);return s.then((i=>{if(null==i)return null;if(i instanceof Array)return i.map((i=>null==i||i.constructor.name===e.prototype.constructor.name?t(i):t(Object.create(e.prototype,Object.getOwnPropertyDescriptors(i)))));throw new Error(`Attempted to retrieve non array type from state as an array for method ${String(n)}`)}))}}}}function Ua(e,t=(e=>e)){return(i,n,s)=>{const r=s.value;return{value:function(...i){const s=r.apply(this,i);if(!(s instanceof Promise))throw new Error(`Error applying prototype to stored value -- result is not a promise for method ${String(n)}`);return s.then((i=>{if(null==i)return null;for(const[n,s]of Object.entries(i))i[n]=null==s||s.constructor.name===e.prototype.constructor.name?t(s):t(Object.create(e.prototype,Object.getOwnPropertyDescriptors(s)));return i}))}}}}ma([Ea(Bi,Bi.fromJSON),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getDecryptedCiphers",null),ma([Ea(fn),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getDecryptedCollections",null),ma([Ea(Bs),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getDecryptedPasswordGenerationHistory",null),ma([Ea(Hs),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getDecryptedPolicies",null),ma([Ea(hr),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getDecryptedSends",null),ma([Ua(hi),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedCiphers",null),ma([Ua(mn),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedCollections",null),ma([Ua(as),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedFolders",null),ma([Ea(Bs),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedPasswordGenerationHistory",null),ma([Ua(Vs),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedPolicies",null),ma([Ua(cr),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEncryptedSends",null),ma([Ea(xn),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getEventCollection",null),ma([Ua(Kr),fa("design:type",Function),fa("design:paramtypes",[Object]),fa("design:returntype",Promise)],Ia.prototype,"getProviders",null);var Fa=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},Na=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},za=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ma extends Ia{getFromSessionMemory(e,t){return za(this,void 0,void 0,(function*(){return this.memoryStorageService instanceof ms?yield this.memoryStorageService.getBypassCache(e,{deserializer:t}):yield this.memoryStorageService.get(e)}))}setInSessionMemory(e,t){return za(this,void 0,void 0,(function*(){yield this.memoryStorageService.save(e,t)}))}addAccount(e){const t=Object.create(null,{addAccount:{get:()=>super.addAccount}});return za(this,void 0,void 0,(function*(){e=new zo(e),yield t.addAccount.call(this,e)}))}getIsAuthenticated(e){const t=Object.create(null,{getIsAuthenticated:{get:()=>super.getIsAuthenticated}});return za(this,void 0,void 0,(function*(){return(yield t.getIsAuthenticated.call(this,e))&&null!=(yield this.getAccount(yield this.defaultInMemoryOptions()))}))}getBrowserGroupingComponentState(e){var t;return za(this,void 0,void 0,(function*(){return null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.groupings}))}setBrowserGroupingComponentState(e,t){return za(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.groupings=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getBrowserCipherComponentState(e){var t;return za(this,void 0,void 0,(function*(){return null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.ciphers}))}setBrowserCipherComponentState(e,t){return za(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.ciphers=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getBrowserSendComponentState(e){var t;return za(this,void 0,void 0,(function*(){return null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.send}))}setBrowserSendComponentState(e,t){return za(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.send=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}getBrowserSendTypeComponentState(e){var t;return za(this,void 0,void 0,(function*(){return null===(t=yield this.getAccount(this.reconcileOptions(e,yield this.defaultInMemoryOptions())))||void 0===t?void 0:t.sendType}))}setBrowserSendTypeComponentState(e,t){return za(this,void 0,void 0,(function*(){const i=yield this.getAccount(this.reconcileOptions(t,yield this.defaultInMemoryOptions()));i.sendType=e,yield this.saveAccount(i,this.reconcileOptions(t,yield this.defaultInMemoryOptions()))}))}}Fa([Ra(Uo),Na("design:type",Function),Na("design:paramtypes",[Object]),Na("design:returntype",Promise)],Ma.prototype,"getBrowserGroupingComponentState",null),Fa([Ra(Eo),Na("design:type",Function),Na("design:paramtypes",[Object]),Na("design:returntype",Promise)],Ma.prototype,"getBrowserCipherComponentState",null),Fa([Ra(Fo),Na("design:type",Function),Na("design:paramtypes",[Object]),Na("design:returntype",Promise)],Ma.prototype,"getBrowserSendComponentState",null),Fa([Ra(Eo),Na("design:type",Function),Na("design:paramtypes",[Object]),Na("design:returntype",Promise)],Ma.prototype,"getBrowserSendTypeComponentState",null);var La=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ba{constructor(e,t,i){if(this.behaviorSubject=e,this.stateService=t,this.metaData=i,this.id=f.newGuid(),this.ignoreNextUpdate=!0,!(e instanceof Sr.X))throw new Error("behaviorSubject must be an instance of BehaviorSubject");if(null==i.ctor&&null==i.initializer)throw new Error("ctor or initializer must be provided")}init(){3==chrome.runtime.getManifest().manifest_version&&(this.observe(),this.listenForUpdates())}observe(){this.subscription=this.behaviorSubject.pipe((0,kr.b)((e=>La(this,void 0,void 0,(function*(){this.ignoreNextUpdate?this.ignoreNextUpdate=!1:yield this.updateSession(e)}))))).subscribe()}listenForUpdates(){Io.messageListener(this.updateMessageCommand,(e=>La(this,void 0,void 0,(function*(){return yield this.updateFromMessage(e)}))))}updateFromMessage(e){return La(this,void 0,void 0,(function*(){if(e.command!=this.updateMessageCommand||e.id===this.id)return;const t=class{static builder(e){const t=null!=e.initializer?e.initializer:t=>Object.assign(new e.ctor,t);return e.initializeAsArray?e=>e.map((e=>t(e))):e=>t(e)}}.builder(this.metaData),i=yield this.stateService.getFromSessionMemory(this.metaData.sessionKey,t);this.ignoreNextUpdate=!0,this.behaviorSubject.next(i)}))}updateSession(e){return La(this,void 0,void 0,(function*(){yield this.stateService.setInSessionMemory(this.metaData.sessionKey,e),yield Io.sendMessage(this.updateMessageCommand,{id:this.id})}))}get updateMessageCommand(){return`${this.metaData.sessionKey}_update`}}function Ka(e){return(t,i)=>{const n=t;null==n.__syncedItemMetadata&&(n.__syncedItemMetadata=[]),n.__syncedItemMetadata.push({propertyKey:i,sessionKey:`${t.constructor.name}_${i}`,ctor:e.ctor,initializer:e.initializer,initializeAsArray:e.initializeAsArray})}}var _a=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},ja=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Ga=class extends class{constructor(e,t,i,n){this.cryptoService=e,this.i18nService=t,this.cipherService=i,this.stateService=n,this._folders=new Sr.X([]),this._folderViews=new Sr.X([]),this.folders$=this._folders.asObservable(),this.folderViews$=this._folderViews.asObservable(),this.stateService.activeAccountUnlocked$.pipe((0,kr.b)((e=>va(this,void 0,void 0,(function*(){if(null==f.global.bitwardenContainerService)return;if(!e)return this._folders.next([]),void this._folderViews.next([]);const t=yield this.stateService.getEncryptedFolders();yield this.updateObservables(t)}))))).subscribe()}clearCache(){return va(this,void 0,void 0,(function*(){this._folderViews.next([])}))}encrypt(e,t){return va(this,void 0,void 0,(function*(){const i=new Jn;return i.id=e.id,i.name=yield this.cryptoService.encrypt(e.name,t),i}))}get(e){return va(this,void 0,void 0,(function*(){return this._folders.getValue().find((t=>t.id===e))}))}getAllDecryptedFromState(){return va(this,void 0,void 0,(function*(){const e=yield this.stateService.getEncryptedFolders(),t=Object.values(e||{}).map((e=>new Jn(e)));return this.decryptFolders(t)}))}upsert(e){return va(this,void 0,void 0,(function*(){let t=yield this.stateService.getEncryptedFolders();if(null==t&&(t={}),e instanceof as){const i=e;t[i.id]=i}else e.forEach((e=>{t[e.id]=e}));yield this.updateObservables(t),yield this.stateService.setEncryptedFolders(t)}))}replace(e){return va(this,void 0,void 0,(function*(){yield this.updateObservables(e),yield this.stateService.setEncryptedFolders(e)}))}clear(e){return va(this,void 0,void 0,(function*(){null!=e&&e!=(yield this.stateService.getUserId())||(this._folders.next([]),this._folderViews.next([])),yield this.stateService.setEncryptedFolders(null,{userId:e})}))}delete(e){return va(this,void 0,void 0,(function*(){const t=yield this.stateService.getEncryptedFolders();if(null==t)return;if("string"==typeof e){if(null==t[e])return;delete t[e]}else e.forEach((e=>{delete t[e]}));yield this.updateObservables(t),yield this.stateService.setEncryptedFolders(t);const i=yield this.stateService.getEncryptedCiphers();if(null!=i){const t=[];for(const n in i)i[n].folderId===e&&(i[n].folderId=null,t.push(i[n]));t.length>0&&this.cipherService.upsert(t)}}))}updateObservables(e){return va(this,void 0,void 0,(function*(){const t=Object.values(e||{}).map((e=>new Jn(e)));this._folders.next(t),(yield this.cryptoService.hasKey())&&this._folderViews.next(yield this.decryptFolders(t))}))}decryptFolders(e){return va(this,void 0,void 0,(function*(){const t=e.map((e=>e.decrypt())),i=yield Promise.all(t);i.sort(f.getSortFunction(this.i18nService,"name"));const n=new Wn;return n.name=this.i18nService.t("noneFolder"),i.push(n),i}))}}{};_a([Ka({initializer:Jn.fromJSON,initializeAsArray:!0}),ja("design:type",Sr.X)],Ga.prototype,"_folders",void 0),_a([Ka({initializer:Wn.fromJSON,initializeAsArray:!0}),ja("design:type",Sr.X)],Ga.prototype,"_folderViews",void 0),Ga=_a([function(e){return class extends e{constructor(...t){super(...t);const i=t.find((e=>e instanceof Ma));if(!i)throw new Error(`Cannot decorate ${e.name} with browserSession, Browser's StateService must be injected`);null!=this.__syncedItemMetadata&&this.__syncedItemMetadata instanceof Array&&(this.__sessionSyncers=this.__syncedItemMetadata.map((e=>this.buildSyncer(e,i))))}buildSyncer(e,t){const i=new Ba(this[e.propertyKey],t,e);return i.init(),i}}}],Ga);var Va=i(1607),Ha=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var qa=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Wa extends class{constructor(e,t,i){this.systemLanguage=e,this.localesDirectory=t,this.getLocalesJson=i,this._locale=new Va.t(1),this.locale$=this._locale.asObservable(),this.supportedTranslationLocales=["en"],this.localeNames=new Map([["af","Afrikaans"],["ar","العربية الفصحى"],["az","Azərbaycanca"],["be","Беларуская"],["bg","български"],["bn","বাংলা"],["bs","bosanski jezik"],["ca","català"],["cs","čeština"],["da","dansk"],["de","Deutsch"],["el","Ελληνικά"],["en","English"],["en-GB","English (British)"],["en-IN","English (India)"],["eo","Esperanto"],["es","español"],["et","eesti"],["eu","euskara"],["fa","فارسی"],["fi","suomi"],["fil","Wikang Filipino"],["fr","français"],["he","עברית"],["hi","हिन्दी"],["hr","hrvatski"],["hu","magyar"],["id","Bahasa Indonesia"],["it","italiano"],["ja","日本語"],["ka","ქართული"],["km","ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ"],["kn","ಕನ್ನಡ"],["ko","한국어"],["lt","lietuvių kalba"],["lv","Latvietis"],["me","црногорски"],["ml","മലയാളം"],["nb","norsk (bokmål)"],["nl","Nederlands"],["nn","Norsk Nynorsk"],["pl","polski"],["pt-BR","português do Brasil"],["pt-PT","português"],["ro","română"],["ru","русский"],["si","සිංහල"],["sk","slovenčina"],["sl","Slovenski jezik, Slovenščina"],["sr","Српски"],["sv","svenska"],["th","ไทย"],["tr","Türkçe"],["uk","українська"],["vi","Tiếng Việt"],["zh-CN","中文(中国大陆)"],["zh-TW","中文(台灣)"]]),this.defaultMessages={},this.localeMessages={},this.systemLanguage=e.replace("_","-")}init(e){return Ha(this,void 0,void 0,(function*(){if(this.inited)throw new Error("i18n already initialized.");if(null==this.supportedTranslationLocales||0===this.supportedTranslationLocales.length)throw new Error("supportedTranslationLocales not set.");this.inited=!0,this.translationLocale=null!=e?e:this.systemLanguage,this._locale.next(this.translationLocale);try{this.collator=new Intl.Collator(this.translationLocale,{numeric:!0,sensitivity:"base"})}catch(e){this.collator=null}-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.translationLocale.slice(0,2),-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.supportedTranslationLocales[0])),null!=this.localesDirectory&&(yield this.loadMessages(this.translationLocale,this.localeMessages),this.translationLocale!==this.supportedTranslationLocales[0]&&(yield this.loadMessages(this.supportedTranslationLocales[0],this.defaultMessages)))}))}t(e,t,i,n){return this.translate(e,t,i,n)}translate(e,t,i,n){let s;return s=this.localeMessages.hasOwnProperty(e)&&this.localeMessages[e]?this.localeMessages[e]:this.defaultMessages.hasOwnProperty(e)&&this.defaultMessages[e]?this.defaultMessages[e]:"",""!==s&&(null!=t&&(s=s.split("__$1__").join(t)),null!=i&&(s=s.split("__$2__").join(i)),null!=n&&(s=s.split("__$3__").join(n))),s}loadMessages(e,t){return Ha(this,void 0,void 0,(function*(){const i=e.replace("-","_"),n=yield this.getLocalesJson(i);for(const e in n)if(n.hasOwnProperty(e)&&(t[e]=n[e].message,n[e].placeholders))for(const i in n[e].placeholders){if(!n[e].placeholders.hasOwnProperty(i)||!n[e].placeholders[i].content)continue;const s="\\$"+i.toUpperCase()+"\\$";let r=n[e].placeholders[i].content;"$1"!==r&&"$2"!==r&&"$3"!==r||(r="__$"+r+"__"),t[e]=t[e].replace(new RegExp(s,"g"),r)}}))}}{constructor(e){super(e,null,(e=>qa(this,void 0,void 0,(function*(){const t=yield fetch(this.localesDirectory+e+"/messages.json");return yield t.json()})))),this.supportedTranslationLocales=["en","ar","az","be","bg","bn","bs","ca","cs","da","de","el","en-GB","en-IN","es","et","eu","fa","fi","fil","fr","he","hi","hr","hu","id","it","ja","ka","km","kn","ko","lt","lv","ml","nb","nl","nn","pl","pt-BR","pt-PT","ro","ru","si","sk","sl","sr","sv","th","tr","uk","vi","zh-CN","zh-TW"]}t(e,t,i,n){return this.translate(e,t,i,n)}translate(e,t,i,n){if(null==this.localesDirectory){const s=[];return null!=t&&s.push(t),null!=i&&s.push(i),null!=n&&s.push(n),s.length?chrome.i18n.getMessage(e,s):chrome.i18n.getMessage(e)}return super.translate(e,t,i,n)}}var Ja=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ya{constructor(e){this.cryptoFunctionService=e}makeEphemeralKey(e=16){return Ja(this,void 0,void 0,(function*(){const t=yield this.cryptoFunctionService.randomBytes(e),i=yield this.cryptoFunctionService.hkdf(t,"bitwarden-ephemeral","ephemeral",64,"sha256");return new Ct(i)}))}}class $a extends aa{constructor(){super(...arguments),this.chromeStorageApi=chrome.storage.session}}var Qa=function(e,t,i,n){var s,r=arguments.length,o=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(r<3?s(o):r>3?s(t,i,o):s(t,i))||o);return r>3&&o&&Object.defineProperty(t,i,o),o},Xa=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Za=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const el="localEncryptionKey",tl="session";class il extends ms{constructor(e,t){super(),this.encryptService=e,this.keyGenerationService=t,this.cache=new Map,this.localStorage=new la,this.sessionStorage=new $a}get(e,t){return Za(this,void 0,void 0,(function*(){return this.cache.has(e)?this.cache.get(e):yield this.getBypassCache(e,t)}))}getBypassCache(e,t){return Za(this,void 0,void 0,(function*(){const i=yield this.getLocalSession(yield this.getSessionEncKey());if(null==i||!Object.keys(i).includes(e))return null;let n=i[e];return null!=(null==t?void 0:t.deserializer)&&(n=t.deserializer(n)),this.cache.set(e,n),this.cache.get(e)}))}has(e){return Za(this,void 0,void 0,(function*(){return null!=(yield this.get(e))}))}save(e,t){var i;return Za(this,void 0,void 0,(function*(){null==t?this.cache.delete(e):this.cache.set(e,t);const n=yield this.getSessionEncKey(),s=null!==(i=yield this.getLocalSession(n))&&void 0!==i?i:{};s[e]=t,yield this.setLocalSession(s,n)}))}remove(e){return Za(this,void 0,void 0,(function*(){yield this.save(e,null)}))}getLocalSession(e){return Za(this,void 0,void 0,(function*(){const t=yield this.localStorage.get(tl);if(null==t)return null;const i=yield this.encryptService.decryptToUtf8(new At(t),e);return null==i?(yield this.setSessionEncKey(null),yield this.localStorage.remove(tl),null):JSON.parse(i)}))}setLocalSession(e,t){return Za(this,void 0,void 0,(function*(){yield this.setEncryptedLocalSession(e,t)}))}setDecryptedLocalSession(e){return Za(this,void 0,void 0,(function*(){const t=JSON.parse(JSON.stringify(e));null==e?yield this.localStorage.remove(tl):yield this.localStorage.save(tl,t)}))}setEncryptedLocalSession(e,t){return Za(this,void 0,void 0,(function*(){const i=JSON.stringify(e),n=yield this.encryptService.encrypt(i,t);if(null==n)return yield this.localStorage.remove(tl);yield this.localStorage.save(tl,n.encryptedString)}))}getSessionEncKey(){return Za(this,void 0,void 0,(function*(){let e=yield this.sessionStorage.get(el);return null!=e&&0!=Object.keys(e).length||(e=yield this.keyGenerationService.makeEphemeralKey(),yield this.setSessionEncKey(e)),Ct.fromJSON(e)}))}setSessionEncKey(e){return Za(this,void 0,void 0,(function*(){null==e?yield this.sessionStorage.remove(el):yield this.sessionStorage.save(el,e)}))}}Qa([function(e,t,i){i.value,i.value=function(...e){throw new Error("This method should not be called, it is protected by a disabled dev flag.")}},Xa("design:type",Function),Xa("design:paramtypes",[Object]),Xa("design:returntype",Promise)],il.prototype,"setDecryptedLocalSession",null);class nl{constructor(e){this.selectedCollection=!1,this.selectedFolder=!1,this.myVaultOnly=!1,this.refreshCollectionsAndFolders=!1,Object.assign(this,e)}resetFilter(){this.cipherType=null,this.status=null,this.selectedCollection=!1,this.selectedCollectionId=null,this.selectedFolder=!1,this.selectedFolderId=null}resetOrganization(){this.myVaultOnly=!1,this.selectedOrganizationId=null,this.resetFilter()}buildFilter(){return e=>{let t=!0;return"favorites"===this.status&&t&&(t=e.favorite),"trash"===this.status&&t&&(t=e.isDeleted),null!=this.cipherType&&t&&(t=e.type===this.cipherType),this.selectedFolder&&null==this.selectedFolderId&&t&&(t=null==e.folderId),this.selectedFolder&&null!=this.selectedFolderId&&t&&(t=e.folderId===this.selectedFolderId),this.selectedCollection&&null==this.selectedCollectionId&&t&&(t=null!=e.organizationId&&(null==e.collectionIds||0===e.collectionIds.length)),this.selectedCollection&&null!=this.selectedCollectionId&&t&&(t=null!=e.collectionIds&&e.collectionIds.includes(this.selectedCollectionId)),null!=this.selectedOrganizationId&&t&&(t=e.organizationId===this.selectedOrganizationId),this.myVaultOnly&&t&&(t=null===e.organizationId),t}}}var sl=i(47575),rl=i(80986);class ol{constructor(e){Object.assign(this,e)}hasId(e){return null!=this.fullList&&this.fullList.filter((t=>t.id===e)).length>0}}class al{}class ll{}class cl{}class dl{}class ul{}class hl{}var pl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class yl{constructor(e,t,i,n,s,r){this.stateService=e,this.organizationService=t,this.folderService=i,this.cipherService=n,this.collectionService=s,this.policyService=r}storeCollapsedFilterNodes(e){return pl(this,void 0,void 0,(function*(){yield this.stateService.setCollapsedGroupings(Array.from(e))}))}buildCollapsedFilterNodes(){return pl(this,void 0,void 0,(function*(){return new Set(yield this.stateService.getCollapsedGroupings())}))}buildOrganizations(){return pl(this,void 0,void 0,(function*(){return yield this.organizationService.getAll()}))}buildNestedFolders(e){const t=t=>pl(this,void 0,void 0,(function*(){let i;if(null!=e){const n=yield this.cipherService.getAllDecrypted(),s=n.filter((t=>t.organizationId==e));i=t.filter((e=>s.filter((t=>t.folderId==e.id)).length>0||n.filter((t=>t.folderId==e.id)).length<1))}else i=t;const n=yield this.getAllFoldersNested(i);return new ol({fullList:i,nestedList:n})}));return this.folderService.folderViews$.pipe((0,sl.z)((e=>(0,rl.D)(t(e)))))}buildCollections(e){return pl(this,void 0,void 0,(function*(){const t=yield this.collectionService.getAllDecrypted();let i;i=null!=e?t.filter((t=>t.organizationId===e)):t;const n=yield this.collectionService.getAllNested(i);return new ol({fullList:i,nestedList:n})}))}checkForSingleOrganizationPolicy(){return pl(this,void 0,void 0,(function*(){return yield this.policyService.policyAppliesToUser(zs.SingleOrg)}))}checkForPersonalOwnershipPolicy(){return pl(this,void 0,void 0,(function*(){return yield this.policyService.policyAppliesToUser(zs.PersonalOwnership)}))}getAllFoldersNested(e){return pl(this,void 0,void 0,(function*(){const t=[];return e.forEach((e=>{const i=new Wn;i.id=e.id,i.revisionDate=e.revisionDate;const n=null!=e.name?e.name.replace(/^\/+|\/+$/g,"").split("/"):[];gn.nestedTraverse(t,0,n,i,null,"/")})),t}))}getFolderNested(e){return pl(this,void 0,void 0,(function*(){const t=yield this.getAllFoldersNested(yield(0,ii.z)(this.folderService.folderViews$));return gn.getTreeNodeObject(t,e)}))}}yl.ɵfac=function(e){return new(e||yl)(Mo.LFG(al),Mo.LFG(ll),Mo.LFG(cl),Mo.LFG(dl),Mo.LFG(ul),Mo.LFG(hl))},yl.ɵprov=Mo.Yz7({token:yl,factory:yl.ɵfac});class vl extends yl{constructor(e,t,i,n,s,r){super(e,t,i,n,s,r),this.vaultFilter=new nl,this.allVaults="allVaults",this.myVault="myVault",this.vaultFilter.myVaultOnly=!1,this.vaultFilter.selectedOrganizationId=null}getVaultFilter(){return this.vaultFilter}setVaultFilter(e){e===this.allVaults?(this.vaultFilter.myVaultOnly=!1,this.vaultFilter.selectedOrganizationId=null):e===this.myVault?(this.vaultFilter.myVaultOnly=!0,this.vaultFilter.selectedOrganizationId=null):(this.vaultFilter.myVaultOnly=!1,this.vaultFilter.selectedOrganizationId=e)}clear(){this.setVaultFilter(this.allVaults)}filterCipherForSelectedVault(e){if(!this.vaultFilter.selectedOrganizationId&&!this.vaultFilter.myVaultOnly)return!1;if(this.vaultFilter.selectedOrganizationId){if(e.organizationId===this.vaultFilter.selectedOrganizationId)return!1}else if(this.vaultFilter.myVaultOnly&&!e.organizationId)return!1;return!0}}var gl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var ml=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class fl extends class{constructor(e,t,i,n,s,r,o,a,l,c,d,u=null,h=null){this.cipherService=e,this.folderService=t,this.collectionService=i,this.cryptoService=n,this.platformUtilsService=s,this.messagingService=r,this.searchService=o,this.keyConnectorService=a,this.stateService=l,this.authService=c,this.vaultTimeoutSettingsService=d,this.lockedCallback=u,this.loggedOutCallback=h,this.inited=!1}init(e){this.inited||(this.inited=!0,e&&this.startCheck())}startCheck(){this.checkVaultTimeout(),setInterval((()=>this.checkVaultTimeout()),1e4)}checkVaultTimeout(){return gl(this,void 0,void 0,(function*(){if(!(yield this.platformUtilsService.isViewOpen()))for(const e in this.stateService.accounts.getValue())null!=e&&(yield this.shouldLock(e))&&(yield this.executeTimeoutAction(e))}))}lock(e){return gl(this,void 0,void 0,(function*(){if(yield this.stateService.getIsAuthenticated({userId:e})){if(yield this.keyConnectorService.getUsesKeyConnector()){const t=yield this.vaultTimeoutSettingsService.isPinLockSet();t[0]&&null!=(yield this.stateService.getDecryptedPinProtected())||t[1]||(yield this.vaultTimeoutSettingsService.isBiometricLockSet())||(yield this.logOut(e))}null!=e&&e!==(yield this.stateService.getUserId())||(this.searchService.clearIndex(),yield this.folderService.clearCache()),yield this.stateService.setEverBeenUnlocked(!0,{userId:e}),yield this.stateService.setCryptoMasterKeyAuto(null,{userId:e}),yield this.cryptoService.clearKey(!1,e),yield this.cryptoService.clearOrgKeys(!0,e),yield this.cryptoService.clearKeyPair(!0,e),yield this.cryptoService.clearEncKey(!0,e),yield this.cipherService.clearCache(e),yield this.collectionService.clearCache(e),this.messagingService.send("locked",{userId:e}),null!=this.lockedCallback&&(yield this.lockedCallback(e))}}))}logOut(e){return gl(this,void 0,void 0,(function*(){null!=this.loggedOutCallback&&(yield this.loggedOutCallback(!1,e))}))}shouldLock(e){return gl(this,void 0,void 0,(function*(){const t=yield this.authService.getAuthStatus(e);if(t===n.Locked||t===n.LoggedOut)return!1;const i=yield this.vaultTimeoutSettingsService.getVaultTimeout(e);if(null==i||i<0)return!1;const s=yield this.stateService.getLastActive({userId:e});if(null==s)return!1;const r=60*i;return((new Date).getTime()-s)/1e3>=r}))}executeTimeoutAction(e){return gl(this,void 0,void 0,(function*(){"logOut"===(yield this.stateService.getVaultTimeoutAction({userId:e}))?yield this.logOut(e):yield this.lock(e)}))}}{startCheck(){this.checkVaultTimeout(),this.platformUtilsService.isSafari()?this.checkSafari():setInterval((()=>this.checkVaultTimeout()),1e4)}checkSafari(){return ml(this,void 0,void 0,(function*(){for(;;)try{yield Ro.sendMessageToApp("sleep"),this.checkVaultTimeout()}catch(e){console.log("Exception Safari VaultTimeout",e)}}))}}var bl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class wl{constructor(e,t,i,n,s){this.main=e,this.passwordGenerationService=t,this.platformUtilsService=i,this.vaultTimeoutService=n,this.authService=s,this.isSafari=this.platformUtilsService.isSafari(),this.isVivaldi=this.platformUtilsService.isVivaldi()}init(){return bl(this,void 0,void 0,(function*(){Io.messageListener("commands.background",((e,t,i)=>bl(this,void 0,void 0,(function*(){"unlockCompleted"===e.command&&"commands.background"===e.data.target&&(yield this.processCommand(e.data.commandToRetry.msg.command,e.data.commandToRetry.sender))})))),chrome&&chrome.commands&&chrome.commands.onCommand.addListener((e=>bl(this,void 0,void 0,(function*(){yield this.processCommand(e)}))))}))}processCommand(e,t){return bl(this,void 0,void 0,(function*(){switch(e){case"generate_password":yield this.generatePasswordToClipboard();break;case"autofill_login":yield this.autoFillLogin(t?t.tab:null);break;case"open_popup":yield this.openPopup();break;case"lock_vault":yield this.vaultTimeoutService.lock()}}))}generatePasswordToClipboard(){return bl(this,void 0,void 0,(function*(){const e=(yield this.passwordGenerationService.getOptions())[0],t=yield this.passwordGenerationService.generatePassword(e);this.platformUtilsService.copyToClipboard(t,{window}),this.passwordGenerationService.addHistory(t)}))}autoFillLogin(e){return bl(this,void 0,void 0,(function*(){if(e||(e=yield Io.getTabFromCurrentWindowId()),null!=e){if((yield this.authService.getAuthStatus())<n.Unlocked){const t={commandToRetry:{msg:{command:"autofill_login"},sender:{tab:e}},target:"commands.background"};return yield Io.tabSendMessageData(e,"addToLockedVaultPendingNotifications",t),void Io.tabSendMessageData(e,"promptForLogin")}yield this.main.collectPageDetailsForContentScript(e,"autofill_cmd")}}))}openPopup(){return bl(this,void 0,void 0,(function*(){this.isSafari&&this.main.openPopup()}))}}var Sl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class kl{constructor(e,t,i,n,s,r,o){this.main=e,this.cipherService=t,this.passwordGenerationService=i,this.platformUtilsService=n,this.authService=s,this.eventService=r,this.totpService=o,this.noopCommandSuffix="noop",this.contextMenus=chrome.contextMenus}init(){return Sl(this,void 0,void 0,(function*(){this.contextMenus&&(this.contextMenus.onClicked.addListener(((e,t)=>Sl(this,void 0,void 0,(function*(){"generate-password"===e.menuItemId?yield this.generatePasswordToClipboard():"copy-identifier"===e.menuItemId?yield this.getClickedElement(t,e.frameId):"autofill"!==e.parentMenuItemId&&"copy-username"!==e.parentMenuItemId&&"copy-password"!==e.parentMenuItemId&&"copy-totp"!==e.parentMenuItemId||(yield this.cipherAction(t,e))})))),Io.messageListener("contextmenus.background",((e,t,i)=>Sl(this,void 0,void 0,(function*(){"unlockCompleted"===e.command&&"contextmenus.background"===e.data.target&&(yield this.cipherAction(e.data.commandToRetry.sender.tab,e.data.commandToRetry.msg.data))})))))}))}generatePasswordToClipboard(){return Sl(this,void 0,void 0,(function*(){const e=(yield this.passwordGenerationService.getOptions())[0],t=yield this.passwordGenerationService.generatePassword(e);this.platformUtilsService.copyToClipboard(t,{window}),this.passwordGenerationService.addHistory(t)}))}getClickedElement(e,t){return Sl(this,void 0,void 0,(function*(){null!=e&&Io.tabSendMessage(e,{command:"getClickedElement"},{frameId:t})}))}cipherAction(e,t){return Sl(this,void 0,void 0,(function*(){if("string"!=typeof t.menuItemId)return;const i=t.menuItemId.split("_")[1];if((yield this.authService.getAuthStatus())<n.Unlocked){const i={commandToRetry:{msg:{command:this.noopCommandSuffix,data:t},sender:{tab:e}},target:"contextmenus.background"};return yield Io.tabSendMessageData(e,"addToLockedVaultPendingNotifications",i),void Io.tabSendMessageData(e,"promptForLogin")}let r;if(i===this.noopCommandSuffix){r=(yield this.cipherService.getAllDecryptedForUrl(e.url)).find((e=>e.reprompt===s.None))}else{r=(yield this.cipherService.getAllDecrypted()).find((e=>e.id===i))}if(null!=r)if("autofill"===t.parentMenuItemId)yield this.startAutofillPage(e,r);else if("copy-username"===t.parentMenuItemId)this.platformUtilsService.copyToClipboard(r.login.username,{window});else if("copy-password"===t.parentMenuItemId)this.platformUtilsService.copyToClipboard(r.login.password,{window}),this.eventService.collect(Kn.Cipher_ClientCopiedPassword,r.id);else if("copy-totp"===t.parentMenuItemId){const e=yield this.totpService.getCode(r.login.totp);this.platformUtilsService.copyToClipboard(e,{window})}}))}startAutofillPage(e,t){return Sl(this,void 0,void 0,(function*(){this.main.loginToAutoFill=t,null!=e&&Io.tabSendMessage(e,{command:"collectPageDetails",tab:e,sender:"contextMenu"})}))}}var Ol=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Pl{constructor(e,t,i){this.vaultTimeoutService=e,this.stateService=t,this.notificationsService=i,this.idleTimer=null,this.idleState="active",this.idle=chrome.idle||(null!=browser?browser.idle:null)}init(){return Ol(this,void 0,void 0,(function*(){if(!this.idle)return;const e=e=>{"active"===e?this.notificationsService.reconnectFromActivity():this.notificationsService.disconnectFromInactivity()};this.idle.onStateChanged&&this.idle.setDetectionInterval?(this.idle.setDetectionInterval(300),this.idle.onStateChanged.addListener(e)):this.pollIdle(e),this.idle.onStateChanged&&this.idle.onStateChanged.addListener((e=>Ol(this,void 0,void 0,(function*(){if("locked"===e){if(-2===(yield this.stateService.getVaultTimeout())){"logOut"===(yield this.stateService.getVaultTimeoutAction())?yield this.vaultTimeoutService.logOut():yield this.vaultTimeoutService.lock()}}}))))}))}pollIdle(e){null!=this.idleTimer&&(window.clearTimeout(this.idleTimer),this.idleTimer=null),this.idle.queryState(300,(t=>{t!==this.idleState&&(this.idleState=t,e(t)),this.idleTimer=window.setTimeout((()=>this.pollIdle(e)),5e3)}))}}var Al=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Cl{constructor(e,t,i,n,s,r,o,a,l,c){var d;this.cryptoService=e,this.cryptoFunctionService=t,this.runtimeBackground=i,this.i18nService=n,this.messagingService=s,this.appIdService=r,this.platformUtilsService=o,this.stateService=a,this.logService=l,this.authService=c,this.connected=!1,this.resolver=null,this.privateKey=null,this.publicKey=null,this.secureSetupResolve=null,this.stateService.setBiometricFingerprintValidated(!1),(null===(d=null===chrome||void 0===chrome?void 0:chrome.permissions)||void 0===d?void 0:d.onAdded)&&chrome.permissions.onAdded.addListener((e=>{Io.reloadExtension(null)}))}connect(){return Al(this,void 0,void 0,(function*(){return this.appId=yield this.appIdService.getAppId(),this.stateService.setBiometricFingerprintValidated(!1),new Promise(((e,t)=>{this.port=Io.connectNative("com.8bit.bitwarden"),this.connecting=!0;const i=()=>{this.connected=!0,this.connecting=!1,e()};this.platformUtilsService.isSafari()&&i(),this.port.onMessage.addListener((e=>Al(this,void 0,void 0,(function*(){switch(e.command){case"connected":i();break;case"disconnected":this.connecting&&t("startDesktop"),this.connected=!1,this.port.disconnect();break;case"setupEncryption":{if(e.appId!==this.appId)return;const t=f.fromB64ToArray(e.sharedSecret),i=yield this.cryptoFunctionService.rsaDecrypt(t.buffer,this.privateKey,"sha1");this.validatingFingerprint&&(this.validatingFingerprint=!1,this.stateService.setBiometricFingerprintValidated(!0)),this.sharedSecret=new Ct(i),this.secureSetupResolve();break}case"invalidateEncryption":if(e.appId!==this.appId)return;this.sharedSecret=null,this.privateKey=null,this.connected=!1,this.messagingService.send("showDialog",{text:this.i18nService.t("nativeMessagingInvalidEncryptionDesc"),title:this.i18nService.t("nativeMessagingInvalidEncryptionTitle"),confirmText:this.i18nService.t("ok"),type:"error"});break;case"verifyFingerprint":null==this.sharedSecret&&(this.validatingFingerprint=!0,this.showFingerprintDialog());break;case"wrongUserId":this.showWrongUserDialog();break;default:if(!this.platformUtilsService.isSafari()&&e.appId!==this.appId)return;this.onMessage(e.message)}})))),this.port.onDisconnect.addListener((e=>{let i;i=Io.isWebExtensionsApi?e.error.message:chrome.runtime.lastError.message,this.sharedSecret=null,this.privateKey=null,this.connected=!1;t(null!=i?"desktopIntegrationDisabled":null)}))}))}))}showWrongUserDialog(){this.messagingService.send("showDialog",{text:this.i18nService.t("nativeMessagingWrongUserDesc"),title:this.i18nService.t("nativeMessagingWrongUserTitle"),confirmText:this.i18nService.t("ok"),type:"error"})}send(e){return Al(this,void 0,void 0,(function*(){this.connected||(yield this.connect()),e.userId=yield this.stateService.getUserId(),e.timestamp=Date.now(),this.platformUtilsService.isSafari()?this.postMessage(e):this.postMessage({appId:this.appId,message:yield this.encryptMessage(e)})}))}encryptMessage(e){return Al(this,void 0,void 0,(function*(){return null==this.sharedSecret&&(yield this.secureCommunication()),yield this.cryptoService.encrypt(JSON.stringify(e),this.sharedSecret)}))}getResponse(){return new Promise(((e,t)=>{this.resolver=e}))}postMessage(e){try{const t=e;e.message instanceof At&&(t.message={encryptedString:e.message.encryptedString,encryptionType:e.message.encryptionType,data:e.message.data,iv:e.message.iv,mac:e.message.mac}),this.port.postMessage(t)}catch(e){this.logService.error("NativeMessaging port disconnected, disconnecting."),this.sharedSecret=null,this.privateKey=null,this.connected=!1,this.messagingService.send("showDialog",{text:this.i18nService.t("nativeMessagingInvalidEncryptionDesc"),title:this.i18nService.t("nativeMessagingInvalidEncryptionTitle"),confirmText:this.i18nService.t("ok"),type:"error"})}}onMessage(e){return Al(this,void 0,void 0,(function*(){let t=e;if(this.platformUtilsService.isSafari()||(t=JSON.parse(yield this.cryptoService.decryptToUtf8(e,this.sharedSecret))),Math.abs(t.timestamp-Date.now())>1e4)this.logService.error("NativeMessage is to old, ignoring.");else{switch(t.command){case"biometricUnlock":{if(yield this.stateService.setBiometricAwaitingAcceptance(null),"not enabled"===t.response){this.messagingService.send("showDialog",{text:this.i18nService.t("biometricsNotEnabledDesc"),title:this.i18nService.t("biometricsNotEnabledTitle"),confirmText:this.i18nService.t("ok"),type:"error"});break}if("not supported"===t.response){this.messagingService.send("showDialog",{text:this.i18nService.t("biometricsNotSupportedDesc"),title:this.i18nService.t("biometricsNotSupportedTitle"),confirmText:this.i18nService.t("ok"),type:"error"});break}const e=yield this.stateService.getBiometricUnlock();if(null===e||!1===e){"unlocked"===t.response&&(yield this.stateService.setBiometricUnlock(!0));break}if((yield this.authService.getAuthStatus())===n.Unlocked)break;if("unlocked"===t.response){yield this.cryptoService.setKey(new Ct(f.fromB64ToArray(t.keyB64).buffer));try{yield this.cryptoService.getFingerprint(yield this.stateService.getUserId())}catch(e){return this.logService.error("Unable to verify key: "+e),yield this.cryptoService.clearKey(),this.showWrongUserDialog(),void(this.resolver&&this.resolver(t))}this.runtimeBackground.processMessage({command:"unlocked"},null,null)}break}default:this.logService.error("NativeMessage, got unknown command: "+t.command)}this.resolver&&this.resolver(t)}}))}secureCommunication(){return Al(this,void 0,void 0,(function*(){const[e,t]=yield this.cryptoFunctionService.rsaGenerateKeyPair(2048);return this.publicKey=e,this.privateKey=t,this.sendUnencrypted({command:"setupEncryption",publicKey:f.fromBufferToB64(e),userId:yield this.stateService.getUserId()}),new Promise(((e,t)=>this.secureSetupResolve=e))}))}sendUnencrypted(e){return Al(this,void 0,void 0,(function*(){this.connected||(yield this.connect()),e.timestamp=Date.now(),this.postMessage({appId:this.appId,message:e})}))}showFingerprintDialog(){return Al(this,void 0,void 0,(function*(){const e=(yield this.cryptoService.getFingerprint(yield this.stateService.getUserId(),this.publicKey)).join(" ");this.messagingService.send("showDialog",{html:`${this.i18nService.t("desktopIntegrationVerificationText")}<br><br><strong>${e}</strong>`,title:this.i18nService.t("desktopSyncVerificationTitle"),confirmText:this.i18nService.t("ok"),type:"warning"})}))}}var Dl;!function(e){e[e.AddLogin=0]="AddLogin",e[e.ChangePassword=1]="ChangePassword"}(Dl||(Dl={}));var xl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Tl{constructor(e,t,i,n,s,r){this.autofillService=e,this.cipherService=t,this.authService=i,this.policyService=n,this.folderService=s,this.stateService=r,this.notificationQueue=[]}init(){return xl(this,void 0,void 0,(function*(){null!=chrome.runtime&&(Io.messageListener("notification.background",((e,t)=>xl(this,void 0,void 0,(function*(){yield this.processMessage(e,t)})))),this.cleanupNotificationQueue())}))}processMessage(e,t){return xl(this,void 0,void 0,(function*(){switch(e.command){case"unlockCompleted":if("notification.background"!==e.data.target)return;yield this.processMessage(e.data.commandToRetry.msg,e.data.commandToRetry.sender);break;case"bgGetDataForTab":yield this.getDataForTab(t.tab,e.responseCommand);break;case"bgCloseNotificationBar":yield Io.tabSendMessageData(t.tab,"closeNotificationBar");break;case"bgAdjustNotificationBar":yield Io.tabSendMessageData(t.tab,"adjustNotificationBar",e.data);break;case"bgAddLogin":yield this.addLogin(e.login,t.tab);break;case"bgChangedPassword":yield this.changedPassword(e.data,t.tab);break;case"bgAddClose":case"bgChangeClose":this.removeTabFromNotificationQueue(t.tab);break;case"bgAddSave":case"bgChangeSave":if((yield this.authService.getAuthStatus())<n.Unlocked){const i={commandToRetry:{msg:e,sender:t},target:"notification.background"};return yield Io.tabSendMessageData(t.tab,"addToLockedVaultPendingNotifications",i),void(yield Io.tabSendMessageData(t.tab,"promptForLogin"))}yield this.saveOrUpdateCredentials(t.tab,e.folder);break;case"bgNeverSave":yield this.saveNever(t.tab);break;case"collectPageDetailsResponse":switch(e.sender){case"notificationBar":{const t=this.autofillService.getFormsWithPasswordFields(e.details);yield Io.tabSendMessageData(e.tab,"notificationBarPageDetails",{details:e.details,forms:t});break}}}}))}checkNotificationQueue(e=null){return xl(this,void 0,void 0,(function*(){if(0===this.notificationQueue.length)return;if(null!=e)return void this.doNotificationQueueCheck(e);const t=yield Io.getTabFromCurrentWindow();null!=t&&this.doNotificationQueueCheck(t)}))}cleanupNotificationQueue(){for(let e=this.notificationQueue.length-1;e>=0;e--)this.notificationQueue[e].expires<new Date&&this.notificationQueue.splice(e,1);setTimeout((()=>this.cleanupNotificationQueue()),12e4)}doNotificationQueueCheck(e){if(null==e)return;const t=f.getDomain(e.url);if(null!=t)for(let i=0;i<this.notificationQueue.length;i++)if(this.notificationQueue[i].tabId===e.id&&this.notificationQueue[i].domain===t){this.notificationQueue[i].type===Dl.AddLogin?Io.tabSendMessageData(e,"openNotificationBar",{type:"add",typeData:{isVaultLocked:this.notificationQueue[i].wasVaultLocked}}):this.notificationQueue[i].type===Dl.ChangePassword&&Io.tabSendMessageData(e,"openNotificationBar",{type:"change",typeData:{isVaultLocked:this.notificationQueue[i].wasVaultLocked}});break}}removeTabFromNotificationQueue(e){for(let t=this.notificationQueue.length-1;t>=0;t--)this.notificationQueue[t].tabId===e.id&&this.notificationQueue.splice(t,1)}addLogin(e,t){return xl(this,void 0,void 0,(function*(){const i=yield this.authService.getAuthStatus();if(i===n.LoggedOut)return;const s=f.getDomain(e.url);if(null==s)return;let r=e.username;null!=r&&(r=r.toLowerCase());const o=yield this.stateService.getDisableAddLoginNotification();if(i===n.Locked){if(o)return;if(!(yield this.allowPersonalOwnership()))return;return void this.pushAddLoginToQueue(s,e,t,!0)}const a=(yield this.cipherService.getAllDecryptedForUrl(e.url)).filter((e=>null!=e.login.username&&e.login.username.toLowerCase()===r));if(0===a.length){if(o)return;if(!(yield this.allowPersonalOwnership()))return;this.pushAddLoginToQueue(s,e,t)}else if(1===a.length&&a[0].login.password!==e.password){if(yield this.stateService.getDisableChangedPasswordNotification())return;this.pushChangePasswordToQueue(a[0].id,s,e.password,t)}}))}pushAddLoginToQueue(e,t,i,n=!1){return xl(this,void 0,void 0,(function*(){this.removeTabFromNotificationQueue(i);const s={type:Dl.AddLogin,username:t.username,password:t.password,domain:e,uri:t.url,tabId:i.id,expires:new Date((new Date).getTime()+3e5),wasVaultLocked:n};this.notificationQueue.push(s),yield this.checkNotificationQueue(i)}))}changedPassword(e,t){return xl(this,void 0,void 0,(function*(){const i=f.getDomain(e.url);if(null==i)return;if((yield this.authService.getAuthStatus())<n.Unlocked)return void this.pushChangePasswordToQueue(null,i,e.newPassword,t,!0);let s=null;const r=yield this.cipherService.getAllDecryptedForUrl(e.url);if(null!=e.currentPassword){const t=r.filter((t=>t.login.password===e.currentPassword));1===t.length&&(s=t[0].id)}else 1===r.length&&(s=r[0].id);null!=s&&this.pushChangePasswordToQueue(s,i,e.newPassword,t)}))}pushChangePasswordToQueue(e,t,i,n,s=!1){return xl(this,void 0,void 0,(function*(){this.removeTabFromNotificationQueue(n);const r={type:Dl.ChangePassword,cipherId:e,newPassword:i,domain:t,tabId:n.id,expires:new Date((new Date).getTime()+3e5),wasVaultLocked:s};this.notificationQueue.push(r),yield this.checkNotificationQueue(n)}))}saveOrUpdateCredentials(e,t){return xl(this,void 0,void 0,(function*(){for(let i=this.notificationQueue.length-1;i>=0;i--){const n=this.notificationQueue[i];if(n.tabId!==e.id||n.type!==Dl.AddLogin&&n.type!==Dl.ChangePassword)continue;const s=f.getDomain(e.url);if(null==s||s===n.domain){if(this.notificationQueue.splice(i,1),Io.tabSendMessageData(e,"closeNotificationBar"),n.type===Dl.ChangePassword){const e=n,t=yield this.getDecryptedCipherById(e.cipherId);if(null==t)return;return void(yield this.updateCipher(t,e.newPassword))}if(n.type===Dl.AddLogin){if(!n.wasVaultLocked)return yield this.createNewCipher(n,t),void Io.tabSendMessageData(e,"addedCipher");const i=n,s=(yield this.cipherService.getAllDecryptedForUrl(i.uri)).filter((e=>null!=e.login.username&&e.login.username.toLowerCase()===i.username));if(s.length>=1)return void(yield this.updateCipher(s[0],i.password));yield this.createNewCipher(i,t),Io.tabSendMessageData(e,"addedCipher")}}}}))}createNewCipher(e,t){return xl(this,void 0,void 0,(function*(){const i=new zi,n=new Ui;n.uri=e.uri,i.uris=[n],i.username=e.username,i.password=e.password;const s=new Bi;if(s.name=f.getHostname(e.uri)||e.domain,s.name=s.name.replace(/^www\./,""),s.type=r.Login,s.login=i,!f.isNullOrWhitespace(t)){(yield(0,ii.z)(this.folderService.folderViews$)).some((e=>e.id===t))&&(s.folderId=t)}const o=yield this.cipherService.encrypt(s);yield this.cipherService.saveWithServer(o)}))}getDecryptedCipherById(e){return xl(this,void 0,void 0,(function*(){const t=yield this.cipherService.get(e);return null!=t&&t.type===r.Login?yield t.decrypt():null}))}updateCipher(e,t){return xl(this,void 0,void 0,(function*(){if(null!=e&&e.type===r.Login){e.login.password=t;const i=yield this.cipherService.encrypt(e);yield this.cipherService.saveWithServer(i)}}))}saveNever(e){return xl(this,void 0,void 0,(function*(){for(let t=this.notificationQueue.length-1;t>=0;t--){const i=this.notificationQueue[t];if(i.tabId!==e.id||i.type!==Dl.AddLogin)continue;const n=f.getDomain(e.url);if(null!=n&&n!==i.domain)continue;this.notificationQueue.splice(t,1),Io.tabSendMessageData(e,"closeNotificationBar");const s=f.getHostname(e.url);yield this.cipherService.saveNeverDomain(s)}}))}getDataForTab(e,t){return xl(this,void 0,void 0,(function*(){const i={};"notificationBarGetFoldersList"===t&&(i.folders=yield(0,ii.z)(this.folderService.folderViews$)),yield Io.tabSendMessageData(e,t,i)}))}allowPersonalOwnership(){return xl(this,void 0,void 0,(function*(){return!(yield this.policyService.policyAppliesToUser(zs.PersonalOwnership))}))}}var Il=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Rl{constructor(e,t,i,n,s,r,o,a,l){this.main=e,this.autofillService=t,this.platformUtilsService=i,this.i18nService=n,this.notificationsService=s,this.systemService=r,this.environmentService=o,this.messagingService=a,this.logService=l,this.pageDetailsToAutoFill=[],this.onInstalledReason=null,this.lockedVaultPendingNotifications=[],chrome.runtime.onInstalled.addListener((e=>{this.onInstalledReason=e.reason}))}init(){return Il(this,void 0,void 0,(function*(){if(!chrome.runtime)return;yield this.checkOnInstalled();const e=(e,t,i)=>Il(this,void 0,void 0,(function*(){yield this.processMessage(e,t,i)}));Io.messageListener("runtime.background",e),this.main.isPrivateMode&&(window.bitwardenBackgroundMessageListener=e)}))}processMessage(e,t,i){var n,s,r;return Il(this,void 0,void 0,(function*(){switch(e.command){case"loggedIn":case"unlocked":{let t;(null===(n=this.lockedVaultPendingNotifications)||void 0===n?void 0:n.length)>0&&(yield Io.closeLoginTab(),t=this.lockedVaultPendingNotifications.pop(),(null===(r=null===(s=t.commandToRetry.sender)||void 0===s?void 0:s.tab)||void 0===r?void 0:r.id)&&(yield Io.focusSpecifiedTab(t.commandToRetry.sender.tab.id))),yield this.main.setIcon(),yield this.main.refreshBadgeAndMenu(!1),this.notificationsService.updateConnection("unlocked"===e.command),this.systemService.cancelProcessReload(),t&&(yield Io.tabSendMessageData(t.commandToRetry.sender.tab,"unlockCompleted",t));break}case"addToLockedVaultPendingNotifications":this.lockedVaultPendingNotifications.push(e.data);break;case"logout":yield this.main.logout(e.expired,e.userId);break;case"syncCompleted":e.successfully&&setTimeout((()=>Il(this,void 0,void 0,(function*(){return yield this.main.refreshBadgeAndMenu()}))),2e3);break;case"openPopup":yield this.main.openPopup();break;case"promptForLogin":yield Io.createNewTab("popup/index.html?uilocation=popout",!0,!0);break;case"showDialogResolve":this.platformUtilsService.resolveDialogPromise(e.dialogId,e.confirmed);break;case"bgCollectPageDetails":yield this.main.collectPageDetailsForContentScript(t.tab,e.sender,t.frameId);break;case"bgUpdateContextMenu":case"editedCipher":case"addedCipher":case"deletedCipher":yield this.main.refreshBadgeAndMenu();break;case"bgReseedStorage":yield this.main.reseedStorage();break;case"collectPageDetailsResponse":switch(e.sender){case"autofiller":case"autofill_cmd":{const i=yield this.autofillService.doAutoFillActiveTab([{frameId:t.frameId,tab:e.tab,details:e.details}],"autofill_cmd"===e.sender);null!=i&&this.platformUtilsService.copyToClipboard(i,{window});break}case"contextMenu":clearTimeout(this.autofillTimeout),this.pageDetailsToAutoFill.push({frameId:t.frameId,tab:e.tab,details:e.details}),this.autofillTimeout=setTimeout((()=>Il(this,void 0,void 0,(function*(){return yield this.autofillPage(e.tab)}))),300)}break;case"authResult":{const t=this.environmentService.getWebVaultUrl();if(null==e.referrer||f.getHostname(t)!==e.referrer)return;try{Io.createNewTab("popup/index.html?uilocation=popout#/sso?code="+encodeURIComponent(e.code)+"&state="+encodeURIComponent(e.state))}catch(e){this.logService.error("Unable to open sso popout tab")}break}case"webAuthnResult":{const t=this.environmentService.getWebVaultUrl();if(null==e.referrer||f.getHostname(t)!==e.referrer)return;const i=`webAuthnResponse=${encodeURIComponent(e.data)};remember=${encodeURIComponent(e.remember)}`;Io.createNewTab(`popup/index.html?uilocation=popout#/2fa;${i}`,void 0,!1);break}case"reloadPopup":this.messagingService.send("reloadPopup");break;case"emailVerificationRequired":this.messagingService.send("showDialog",{dialogId:"emailVerificationRequired",title:this.i18nService.t("emailVerificationRequired"),text:this.i18nService.t("emailVerificationRequiredDesc"),confirmText:this.i18nService.t("ok"),type:"info"});break;case"getClickedElementResponse":this.platformUtilsService.copyToClipboard(e.identifier,{window})}}))}autofillPage(e){return Il(this,void 0,void 0,(function*(){const t=yield this.autofillService.doAutoFill({tab:e,cipher:this.main.loginToAutoFill,pageDetails:this.pageDetailsToAutoFill,fillNewPassword:!0});null!=t&&this.platformUtilsService.copyToClipboard(t,{window}),this.main.loginToAutoFill=null,this.pageDetailsToAutoFill=[]}))}checkOnInstalled(){return Il(this,void 0,void 0,(function*(){setTimeout((()=>Il(this,void 0,void 0,(function*(){null!=this.onInstalledReason&&("install"===this.onInstalledReason&&(Io.createNewTab("https://bitwarden.com/browser-start/"),(yield this.environmentService.hasManagedEnvironment())&&(yield this.environmentService.setUrlsToManagedEnvironment())),this.onInstalledReason=null)}))),100)}))}}var El=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ul{constructor(e,t){this.main=e,this.notificationBackground=t}init(){return El(this,void 0,void 0,(function*(){chrome.tabs&&chrome.windows&&(chrome.windows.onFocusChanged.addListener((e=>El(this,void 0,void 0,(function*(){null===e||e<0||(this.focusedWindowId=e,this.main.messagingService.send("windowChanged"))})))),chrome.tabs.onActivated.addListener((e=>El(this,void 0,void 0,(function*(){yield this.main.refreshBadgeAndMenu(),this.main.messagingService.send("tabChanged")})))),chrome.tabs.onReplaced.addListener(((e,t)=>El(this,void 0,void 0,(function*(){this.main.onReplacedRan||(this.main.onReplacedRan=!0,yield this.notificationBackground.checkNotificationQueue(),yield this.main.refreshBadgeAndMenu(),this.main.messagingService.send("tabChanged"))})))),chrome.tabs.onUpdated.addListener(((e,t,i)=>El(this,void 0,void 0,(function*(){this.focusedWindowId>0&&i.windowId!=this.focusedWindowId||i.active&&(this.main.onUpdatedRan||(this.main.onUpdatedRan=!0,yield this.notificationBackground.checkNotificationQueue(i),yield this.main.refreshBadgeAndMenu(),this.main.messagingService.send("tabChanged")))})))))}))}}var Fl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Nl{constructor(e,t,i){this.cipherService=t,this.authService=i,this.pendingAuthRequests=[];2===chrome.runtime.getManifest().manifest_version&&(this.webRequest=window.chrome.webRequest),this.isFirefox=e.isFirefox()}init(){return Fl(this,void 0,void 0,(function*(){this.webRequest&&this.webRequest.onAuthRequired&&(this.webRequest.onAuthRequired.addListener(((e,t)=>Fl(this,void 0,void 0,(function*(){if(e.url&&-1===this.pendingAuthRequests.indexOf(e.requestId)){if(this.pendingAuthRequests.push(e.requestId),this.isFirefox)return new Promise(((t,i)=>Fl(this,void 0,void 0,(function*(){yield this.resolveAuthCredentials(e.url,t,i)}))));yield this.resolveAuthCredentials(e.url,t,t)}else t&&t()}))),{urls:["http://*/*","https://*/*"]},[this.isFirefox?"blocking":"asyncBlocking"]),this.webRequest.onCompleted.addListener((e=>this.completeAuthRequest(e)),{urls:["http://*/*"]}),this.webRequest.onErrorOccurred.addListener((e=>this.completeAuthRequest(e)),{urls:["http://*/*"]}))}))}resolveAuthCredentials(e,t,i){return Fl(this,void 0,void 0,(function*(){if((yield this.authService.getAuthStatus())<n.Unlocked)i();else try{const n=yield this.cipherService.getAllDecryptedForUrl(e,null,ti.Host);if(null==n||1!==n.length)return void i();t({authCredentials:{username:n[0].login.username,password:n[0].login.password}})}catch(e){i()}}))}completeAuthRequest(e){const t=this.pendingAuthRequests.indexOf(e.requestId);t>-1&&this.pendingAuthRequests.splice(t,1)}}var zl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Ml{constructor(e=!1){this.isPrivateMode=e,this.backgroundWindow=window,this.loginToAutoFill=null,this.menuOptionsLoaded=[];const t=(e,t)=>zl(this,void 0,void 0,(function*(){return yield this.logout(e,t)}));this.messagingService=e?new da:new ca,this.logService=new On(!1),this.cryptoFunctionService=new xo(window),this.storageService=new la,this.secureStorageService=new la,this.memoryStorageService=3==chrome.runtime.getManifest().manifest_version?new il(new Dn(this.cryptoFunctionService,this.logService,!1),new Ya(this.cryptoFunctionService)):new bs,this.stateMigrationService=new Lr(this.storageService,this.secureStorageService,new u(y,zo)),this.stateService=new Ma(this.storageService,this.secureStorageService,this.memoryStorageService,this.logService,this.stateMigrationService,new u(y,zo)),this.platformUtilsService=new pa(this.messagingService,((e,t)=>{null!=this.systemService&&this.systemService.clearClipboard(e,t)}),(()=>zl(this,void 0,void 0,(function*(){if(null!=this.nativeMessagingBackground){const e=this.nativeMessagingBackground.getResponse();try{yield this.nativeMessagingBackground.send({command:"biometricUnlock"})}catch(e){return Promise.reject(e)}return e.then((e=>"unlocked"===e.response))}})))),this.i18nService=new Wa(Io.getUILanguage(window)),this.encryptService=new Dn(this.cryptoFunctionService,this.logService,!0),this.cryptoService=new sa(this.cryptoFunctionService,this.encryptService,this.platformUtilsService,this.logService,this.stateService),this.tokenService=new Cr(this.stateService),this.appIdService=new ct(this.storageService),this.environmentService=new Wo(this.stateService,this.logService),this.apiService=new at(this.tokenService,this.platformUtilsService,this.environmentService,this.appIdService,(e=>this.logout(e))),this.settingsService=new Pr(this.stateService),this.fileUploadService=new os(this.logService,this.apiService),this.cipherService=new yn(this.cryptoService,this.settingsService,this.apiService,this.fileUploadService,this.i18nService,(()=>this.searchService),this.logService,this.stateService),this.folderService=new Ga(this.cryptoService,this.i18nService,this.cipherService,this.stateService),this.folderApiService=new us(this.folderService,this.apiService),this.collectionService=new Sn(this.cryptoService,this.i18nService,this.stateService),this.searchService=new or(this.cipherService,this.logService,this.i18nService),this.sendService=new wr(this.cryptoService,this.apiService,this.fileUploadService,this.i18nService,this.cryptoFunctionService,this.stateService),this.organizationService=new Ns(this.stateService),this.policyService=new Zs(this.stateService,this.organizationService),this.policyApiService=new Ws(this.policyService,this.apiService,this.stateService,this.organizationService),this.keyConnectorService=new vs(this.stateService,this.cryptoService,this.apiService,this.tokenService,this.logService,this.organizationService,this.cryptoFunctionService,t),this.vaultFilterService=new vl(this.stateService,this.organizationService,this.folderService,this.cipherService,this.collectionService,this.policyService),this.twoFactorService=new Xr(this.i18nService,this.platformUtilsService);const i=this,n=new class extends class{}{constructor(){super(...arguments),this.send=(e,t={})=>{const n=Object.assign({},{command:e},t);i.runtimeBackground.processMessage(n,i,null)}}};this.authService=new Zt(this.cryptoService,this.apiService,this.tokenService,this.appIdService,this.platformUtilsService,n,this.logService,this.keyConnectorService,this.environmentService,this.stateService,this.twoFactorService,this.i18nService),this.vaultTimeoutSettingsService=new Po(this.cryptoService,this.tokenService,this.policyService,this.stateService),this.vaultTimeoutService=new fl(this.cipherService,this.folderService,this.collectionService,this.cryptoService,this.platformUtilsService,this.messagingService,this.searchService,this.keyConnectorService,this.stateService,this.authService,this.vaultTimeoutSettingsService,(e=>zl(this,void 0,void 0,(function*(){null!=this.notificationsService&&this.notificationsService.updateConnection(!1),yield this.setIcon(),yield this.refreshBadgeAndMenu(!0),null!=this.systemService&&(yield this.systemService.clearPendingClipboard(),yield this.systemService.startProcessReload(this.authService))}))),t),this.providerService=new ir(this.stateService),this.syncService=new Vr(this.apiService,this.settingsService,this.folderService,this.cipherService,this.cryptoService,this.collectionService,this.messagingService,this.policyService,this.sendService,this.logService,this.keyConnectorService,this.stateService,this.organizationService,this.providerService,this.folderApiService,t),this.eventService=new Rn(this.apiService,this.cipherService,this.stateService,this.logService,this.organizationService),this.passwordGenerationService=new Gs(this.cryptoService,this.policyService,this.stateService),this.totpService=new $r(this.cryptoFunctionService,this.logService),this.autofillService=new Vo(this.cipherService,this.stateService,this.totpService,this.eventService,this.logService),this.containerService=new Pn(this.cryptoService,this.encryptService),this.auditService=new pt(this.cryptoFunctionService,this.apiService),this.exportService=new Zn(this.folderService,this.cipherService,this.apiService,this.cryptoService,this.cryptoFunctionService),this.notificationsService=new Es(this.syncService,this.appIdService,this.apiService,this.environmentService,t,this.logService,this.stateService,this.authService),this.popupUtilsService=new Lo(e),this.userVerificationApiService=new to(this.apiService),this.userVerificationService=new ro(this.cryptoService,this.i18nService,this.userVerificationApiService);this.systemService=new qr(this.messagingService,this.platformUtilsService,(()=>{const e=this.platformUtilsService.isSafari()||this.platformUtilsService.isFirefox()||this.platformUtilsService.isOpera();return Io.reloadExtension(e?window:null),Promise.resolve()}),this.stateService),this.isSafari=this.platformUtilsService.isSafari(),this.sidebarAction=this.isSafari?null:"undefined"!=typeof opr&&opr.sidebarAction?opr.sidebarAction:window.chrome.sidebarAction,this.runtimeBackground=new Rl(this,this.autofillService,this.platformUtilsService,this.i18nService,this.notificationsService,this.systemService,this.environmentService,this.messagingService,this.logService),this.nativeMessagingBackground=new Cl(this.cryptoService,this.cryptoFunctionService,this.runtimeBackground,this.i18nService,this.messagingService,this.appIdService,this.platformUtilsService,this.stateService,this.logService,this.authService),this.commandsBackground=new wl(this,this.passwordGenerationService,this.platformUtilsService,this.vaultTimeoutService,this.authService),this.notificationBackground=new Tl(this.autofillService,this.cipherService,this.authService,this.policyService,this.folderService,this.stateService),this.tabsBackground=new Ul(this,this.notificationBackground),this.contextMenusBackground=new kl(this,this.cipherService,this.passwordGenerationService,this.platformUtilsService,this.authService,this.eventService,this.totpService),this.idleBackground=new Pl(this.vaultTimeoutService,this.stateService,this.notificationsService),this.webRequestBackground=new Nl(this.platformUtilsService,this.cipherService,this.authService),this.usernameGenerationService=new ko(this.cryptoService,this.stateService,this.apiService)}bootstrap(){return zl(this,void 0,void 0,(function*(){if(this.containerService.attachToGlobal(window),yield this.stateService.init(),yield this.vaultTimeoutService.init(!0),yield this.i18nService.init(),yield this.eventService.init(!0),yield this.runtimeBackground.init(),yield this.notificationBackground.init(),yield this.commandsBackground.init(),this.twoFactorService.init(),yield this.tabsBackground.init(),yield this.contextMenusBackground.init(),yield this.idleBackground.init(),yield this.webRequestBackground.init(),this.platformUtilsService.isFirefox()&&!this.isPrivateMode){(yield Io.getPrivateModeWindows()).forEach((e=>zl(this,void 0,void 0,(function*(){yield this.actionSetIcon(chrome.browserAction,"",e.id),yield this.actionSetIcon(this.sidebarAction,"",e.id)})))),Io.onWindowCreated((e=>zl(this,void 0,void 0,(function*(){e.incognito&&(yield this.actionSetIcon(chrome.browserAction,"",e.id),yield this.actionSetIcon(this.sidebarAction,"",e.id))}))))}return new Promise((e=>{setTimeout((()=>zl(this,void 0,void 0,(function*(){yield this.environmentService.setUrlsFromStorage(),yield this.setIcon(),this.fullSync(!0),setTimeout((()=>this.notificationsService.init()),2500),e()}))),500)}))}))}setIcon(){return zl(this,void 0,void 0,(function*(){if(!chrome.browserAction&&!this.sidebarAction||this.isPrivateMode)return;const e=yield this.authService.getAuthStatus();let t="";e===n.LoggedOut?t="_gray":e===n.Locked&&(t="_locked"),yield this.actionSetIcon(chrome.browserAction,t),yield this.actionSetIcon(this.sidebarAction,t)}))}refreshBadgeAndMenu(e=!1){return zl(this,void 0,void 0,(function*(){if(!chrome.windows||!chrome.contextMenus)return;const t=yield this.stateService.getDisableContextMenuItem();if(t?yield this.contextMenusRemoveAll():yield this.buildContextMenu(),e)return yield this.loadMenuAndUpdateBadgeForNoAccessState(!t),void(this.onUpdatedRan=this.onReplacedRan=!1);const i=yield Io.getTabFromCurrentWindow();i&&(yield this.contextMenuReady(i,!t))}))}logout(e,t){return zl(this,void 0,void 0,(function*(){yield this.eventService.uploadEvents(t),yield Promise.all([this.eventService.clearEvents(t),this.syncService.setLastSync(new Date(0),t),this.cryptoService.clearKeys(t),this.settingsService.clear(t),this.cipherService.clear(t),this.folderService.clear(t),this.collectionService.clear(t),this.policyService.clear(t),this.passwordGenerationService.clear(t),this.vaultTimeoutSettingsService.clear(t),this.keyConnectorService.clear(),this.vaultFilterService.clear()]),yield this.stateService.clean({userId:t}),null!=t&&t!==(yield this.stateService.getUserId())||(this.searchService.clearIndex(),this.messagingService.send("doneLoggingOut",{expired:e,userId:t})),yield this.setIcon(),yield this.refreshBadgeAndMenu(!0),yield this.reseedStorage(),this.notificationsService.updateConnection(!1),yield this.systemService.clearPendingClipboard(),yield this.systemService.startProcessReload(this.authService)}))}collectPageDetailsForContentScript(e,t,i=null){return zl(this,void 0,void 0,(function*(){if(null==e||!e.id)return;const n={};null!=i&&(n.frameId=i),Io.tabSendMessage(e,{command:"collectPageDetails",tab:e,sender:t},n)}))}openPopup(){return zl(this,void 0,void 0,(function*(){this.isSafari&&(yield Ro.sendMessageToApp("showPopover",null,!0))}))}reseedStorage(){return zl(this,void 0,void 0,(function*(){if(!this.platformUtilsService.isChrome()&&!this.platformUtilsService.isVivaldi()&&!this.platformUtilsService.isOpera())return;if(null==(yield this.stateService.getVaultTimeout()))return;const e=yield new Promise((e=>{chrome.storage.local.get(null,(t=>e(t)))}));yield new Promise((e=>{chrome.storage.local.clear((()=>e()))}));for(const t in e)e.hasOwnProperty(t)&&(yield this.storageService.save(t,e[t]))}))}buildContextMenu(){return zl(this,void 0,void 0,(function*(){chrome.contextMenus&&!this.buildingContextMenu&&(this.buildingContextMenu=!0,yield this.contextMenusRemoveAll(),yield this.contextMenusCreate({type:"normal",id:"root",contexts:["all"],title:"Bitwarden"}),yield this.contextMenusCreate({type:"normal",id:"autofill",parentId:"root",contexts:["all"],title:this.i18nService.t("autoFill")}),yield this.contextMenusCreate({type:"normal",id:"copy-username",parentId:"root",contexts:["all"],title:this.i18nService.t("copyUsername")}),yield this.contextMenusCreate({type:"normal",id:"copy-password",parentId:"root",contexts:["all"],title:this.i18nService.t("copyPassword")}),(yield this.stateService.getCanAccessPremium())&&(yield this.contextMenusCreate({type:"normal",id:"copy-totp",parentId:"root",contexts:["all"],title:this.i18nService.t("copyVerificationCode")})),yield this.contextMenusCreate({type:"separator",parentId:"root"}),yield this.contextMenusCreate({type:"normal",id:"generate-password",parentId:"root",contexts:["all"],title:this.i18nService.t("generatePasswordCopied")}),yield this.contextMenusCreate({type:"normal",id:"copy-identifier",parentId:"root",contexts:["all"],title:this.i18nService.t("copyElementIdentifier")}),this.buildingContextMenu=!1)}))}contextMenuReady(e,t){return zl(this,void 0,void 0,(function*(){yield this.loadMenuAndUpdateBadge(e.url,e.id,t),this.onUpdatedRan=this.onReplacedRan=!1}))}loadMenuAndUpdateBadge(e,t,i){return zl(this,void 0,void 0,(function*(){if(!e||!chrome.browserAction&&!this.sidebarAction)return;this.actionSetBadgeBackgroundColor(chrome.browserAction),this.actionSetBadgeBackgroundColor(this.sidebarAction),this.menuOptionsLoaded=[];if((yield this.authService.getAuthStatus())===n.Unlocked)try{const n=yield this.cipherService.getAllDecryptedForUrl(e);n.sort(((e,t)=>this.cipherService.sortCiphersByLastUsedThenName(e,t))),i&&n.forEach((e=>{this.loadLoginContextMenuOptions(e)}));const s=yield this.stateService.getDisableBadgeCounter();let r="";return s||(n.length>0&&n.length<=9?r=n.length.toString():n.length>0&&(r="9+")),i&&0===n.length&&(yield this.loadNoLoginsContextMenuOptions(this.i18nService.t("noMatchingLogins"))),this.sidebarActionSetBadgeText(r,t),void this.browserActionSetBadgeText(r,t)}catch(e){this.logService.error(e)}yield this.loadMenuAndUpdateBadgeForNoAccessState(i)}))}loadMenuAndUpdateBadgeForNoAccessState(e){return zl(this,void 0,void 0,(function*(){if(e){const e=yield this.stateService.getIsAuthenticated();yield this.loadNoLoginsContextMenuOptions(this.i18nService.t(e?"unlockVaultMenu":"loginToVaultMenu"))}const t=yield Io.getActiveTabs();null!=t&&t.forEach((e=>{null!=e.id&&(this.browserActionSetBadgeText("",e.id),this.sidebarActionSetBadgeText("",e.id))}))}))}loadLoginContextMenuOptions(e){return zl(this,void 0,void 0,(function*(){if(null==e||e.type!==r.Login||e.reprompt!==s.None)return;let t=e.name;e.login.username&&""!==e.login.username&&(t+=" ("+e.login.username+")"),yield this.loadContextMenuOptions(t,e.id,e)}))}loadNoLoginsContextMenuOptions(e){return zl(this,void 0,void 0,(function*(){yield this.loadContextMenuOptions(e,"noop",null)}))}loadContextMenuOptions(e,t,i){return zl(this,void 0,void 0,(function*(){if(!chrome.contextMenus||this.menuOptionsLoaded.indexOf(t)>-1||null!=i&&i.type!==r.Login)return;this.menuOptionsLoaded.push(t),(null==i||i.login.password&&""!==i.login.password)&&(yield this.contextMenusCreate({type:"normal",id:"autofill_"+t,parentId:"autofill",contexts:["all"],title:this.sanitizeContextMenuTitle(e)})),(null==i||i.login.username&&""!==i.login.username)&&(yield this.contextMenusCreate({type:"normal",id:"copy-username_"+t,parentId:"copy-username",contexts:["all"],title:this.sanitizeContextMenuTitle(e)})),(null==i||i.login.password&&""!==i.login.password&&i.viewPassword)&&(yield this.contextMenusCreate({type:"normal",id:"copy-password_"+t,parentId:"copy-password",contexts:["all"],title:this.sanitizeContextMenuTitle(e)}));(yield this.stateService.getCanAccessPremium())&&(null==i||i.login.totp&&""!==i.login.totp)&&(yield this.contextMenusCreate({type:"normal",id:"copy-totp_"+t,parentId:"copy-totp",contexts:["all"],title:this.sanitizeContextMenuTitle(e)}))}))}sanitizeContextMenuTitle(e){return e.replace(/&/g,"&&")}fullSync(e=!1){return zl(this,void 0,void 0,(function*(){const t=216e5,i=yield this.syncService.getLastSync();let n=21600001;null!=i&&(n=(new Date).getTime()-i.getTime()),e||n>=t?(yield this.syncService.fullSync(e),this.scheduleNextSync()):this.scheduleNextSync()}))}scheduleNextSync(){this.syncTimeout&&clearTimeout(this.syncTimeout),this.syncTimeout=setTimeout((()=>zl(this,void 0,void 0,(function*(){return yield this.fullSync()}))),3e5)}contextMenusRemoveAll(){return new Promise((e=>{chrome.contextMenus.removeAll((()=>{e(),chrome.runtime.lastError}))}))}contextMenusCreate(e){return new Promise((t=>{chrome.contextMenus.create(e,(()=>{t(),chrome.runtime.lastError}))}))}actionSetIcon(e,t,i){return zl(this,void 0,void 0,(function*(){if(!e||!e.setIcon)return;const n={path:{19:"images/icon19"+t+".png",38:"images/icon38"+t+".png"}};if(this.platformUtilsService.isFirefox())n.windowId=i,yield e.setIcon(n);else{if(!this.platformUtilsService.isSafari())return new Promise((t=>{e.setIcon(n,(()=>t()))}));e.setIcon(n)}}))}actionSetBadgeBackgroundColor(e){e&&e.setBadgeBackgroundColor&&e.setBadgeBackgroundColor({color:"#294e5f"})}browserActionSetBadgeText(e,t){chrome.browserAction&&chrome.browserAction.setBadgeText&&chrome.browserAction.setBadgeText({text:e,tabId:t})}sidebarActionSetBadgeText(e,t){if(this.sidebarAction)if(this.sidebarAction.setBadgeText)this.sidebarAction.setBadgeText({text:e,tabId:t});else if(this.sidebarAction.setTitle){let i="Bitwarden";e&&""!==e&&(i+=" ["+e+"]"),this.sidebarAction.setTitle({title:i,tabId:t})}}}class Ll{constructor(){if(3!==chrome.runtime.getManifest().manifest_version)throw new Error("You are not allowed to use this when not in manifest_version 3")}collect(e,t,i){return Promise.resolve()}uploadEvents(e){return Promise.resolve()}clearEvents(e){return Promise.resolve()}}var Bl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};class Kl{constructor(e){this.autofillService=e}doAutoFillActiveTabCommand(e){return Bl(this,void 0,void 0,(function*(){if(!e.id)throw new Error("Tab does not have an id, cannot complete autofill.");const t=yield this.collectPageDetails(e.id);yield this.autofillService.doAutoFillOnTab([{frameId:0,tab:e,details:t}],e,!0)}))}collectPageDetails(e){return Bl(this,void 0,void 0,(function*(){return new Promise(((t,i)=>{chrome.tabs.sendMessage(e,{command:"collectPageDetailsImmediately"},(e=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(e)}))}))}))}}var _l=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};const jl=(e,t)=>_l(void 0,void 0,void 0,(function*(){if("autofill_login"===e)yield Gl(t)})),Gl=e=>_l(void 0,void 0,void 0,(function*(){const t=new On(!1),i=new xo(self),s=new la,r=new la,o=new il(new Dn(i,t,!1),new Ya(i)),a=new u(y,zo),l=new Lr(s,r,a),c=new Ma(s,r,o,t,l,a);yield c.init();const d=new pa(null,null,null),h=new sa(i,null,d,t,c),p=new Pr(c),v=new Wa(chrome.i18n.getUILanguage());yield v.init();let g=null;const m=new yn(h,p,null,null,v,(()=>g),t,c);g=new or(m,t,v);const f=new Ll,b=new Vo(m,c,null,f,t),w=new Zt(h,null,null,null,d,null,t,null,null,c,null,v);if((yield w.getAuthStatus())<n.Unlocked)return void t.info("Currently not unlocked, MV3 does not support unlock on autofill currently.");const S=new Kl(b);yield S.doAutoFillActiveTabCommand(e)}));var Vl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};function Hl(e,t,i,n){return Vl(this,void 0,void 0,(function*(){let s=e[t];if(i.alwaysInitializeNewService||!s){const e=n();s=e instanceof Promise?yield e:e}return i.doNotStoreInitializedService||(e[t]=s),s}))}function ql(e,t){return Hl(e,"logService",t,(()=>new On(t.logServiceOptions.isDev,t.logServiceOptions.filter)))}function Wl(e,t){return Hl(e,"cryptoFunctionService",t,(()=>new xo(t.cryptoFunctionServiceOptions.win)))}var Jl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var Yl=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var $l=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};function Ql(e,t){return Hl(e,"diskStorageService",t,(()=>new la))}function Xl(e,t){return Hl(e,"secureStorageService",t,(()=>new la))}function Zl(e,t){return Hl(e,"memoryStorageService",t,(()=>$l(this,void 0,void 0,(function*(){return 3==chrome.runtime.getManifest().manifest_version?new il(yield function(e,t){return Hl(e,"encryptService",t,(()=>Jl(this,void 0,void 0,(function*(){return new Dn(yield Wl(e,t),yield ql(e,t),t.encryptServiceOptions.logMacFailures)}))))}(e,t),yield function(e,t){return Hl(e,"keyGenerationService",t,(()=>Yl(this,void 0,void 0,(function*(){return new Ya(yield Wl(e,t))}))))}(e,t)):new bs}))))}var ec=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var tc=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};function ic(e,t){return tc(this,void 0,void 0,(function*(){const i=yield Hl(e,"stateService",t,(()=>tc(this,void 0,void 0,(function*(){return yield new Ma(yield Ql(e,t),yield Xl(e,t),yield Zl(e,t),yield ql(e,t),yield function(e,t){return Hl(e,"stateMigrationService",t,(()=>ec(this,void 0,void 0,(function*(){return new Lr(yield Ql(e,t),yield Xl(e,t),t.stateMigrationServiceOptions.stateFactory)}))))}(e,t),t.stateServiceOptions.stateFactory,t.stateServiceOptions.useAccountCache)}))));return i.init(),i}))}var nc=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};var sc=function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))};if(3===chrome.runtime.getManifest().manifest_version)chrome.commands.onCommand.addListener(jl),chrome.runtime.onInstalled.addListener((function(e){return sc(this,void 0,void 0,(function*(){const t={encryptServiceOptions:{logMacFailures:!1},cryptoFunctionServiceOptions:{win:self},logServiceOptions:{isDev:!1},stateServiceOptions:{stateFactory:new u(y,zo)},stateMigrationServiceOptions:{stateFactory:new u(y,zo)}},i=yield function(e,t){return Hl(e,"environmentService",t,(()=>nc(this,void 0,void 0,(function*(){return new Wo(yield ic(e,t),yield ql(e,t))}))))}({},t);setTimeout((()=>sc(this,void 0,void 0,(function*(){null!=e.reason&&"install"===e.reason&&(Io.createNewTab("https://bitwarden.com/browser-start/"),(yield i.hasManagedEnvironment())&&(yield i.setUrlsToManagedEnvironment()))}))),100)}))}));else{(window.bitwardenMain=new Ml).bootstrap().then((()=>{}))}},95942:()=>{}},i={};function n(e){var s=i[e];if(void 0!==s)return s.exports;var r=i[e]={id:e,loaded:!1,exports:{}};return t[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,e=[],n.O=(t,i,s,r)=>{if(!i){var o=1/0;for(d=0;d<e.length;d++){for(var[i,s,r]=e[d],a=!0,l=0;l<i.length;l++)(!1&r||o>=r)&&Object.keys(n.O).every((e=>n.O[e](i[l])))?i.splice(l--,1):(a=!1,r<o&&(o=r));if(a){e.splice(d--,1);var c=s();void 0!==c&&(t=c)}}return t}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[i,s,r]},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={352:0};n.O.j=t=>0===e[t];var t=(t,i)=>{var s,r,[o,a,l]=i,c=0;if(o.some((t=>0!==e[t]))){for(s in a)n.o(a,s)&&(n.m[s]=a[s]);if(l)var d=l(n)}for(t&&t(i);c<o.length;c++)r=o[c],n.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return n.O(d)},i=self.webpackChunk_bitwarden_browser=self.webpackChunk_bitwarden_browser||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var s=n.O(void 0,[736],(()=>n(42227)));s=n.O(s)})();
//# sourceMappingURL=background.js.map