/******/ (function() { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ 70526:
/***/ (function() {

(function(){/*

 Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
 This code may only be used under the BSD style license found at
 http://polymer.github.io/LICENSE.txt The complete set of authors may be found
 at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
 be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
 Google as part of the polymer project is also subject to an additional IP
 rights grant found at http://polymer.github.io/PATENTS.txt
*/'use strict';var n=window.Document.prototype.createElement,p=window.Document.prototype.createElementNS,aa=window.Document.prototype.importNode,ba=window.Document.prototype.prepend,ca=window.Document.prototype.append,da=window.DocumentFragment.prototype.prepend,ea=window.DocumentFragment.prototype.append,q=window.Node.prototype.cloneNode,r=window.Node.prototype.appendChild,t=window.Node.prototype.insertBefore,u=window.Node.prototype.removeChild,v=window.Node.prototype.replaceChild,w=Object.getOwnPropertyDescriptor(window.Node.prototype,"textContent"),y=window.Element.prototype.attachShadow,z=Object.getOwnPropertyDescriptor(window.Element.prototype,"innerHTML"),A=window.Element.prototype.getAttribute,B=window.Element.prototype.setAttribute,C=window.Element.prototype.removeAttribute,D=window.Element.prototype.toggleAttribute,E=window.Element.prototype.getAttributeNS,F=window.Element.prototype.setAttributeNS,G=window.Element.prototype.removeAttributeNS,H=window.Element.prototype.insertAdjacentElement,fa=window.Element.prototype.insertAdjacentHTML,ha=window.Element.prototype.prepend,ia=window.Element.prototype.append,ja=window.Element.prototype.before,ka=window.Element.prototype.after,la=window.Element.prototype.replaceWith,ma=window.Element.prototype.remove,na=window.HTMLElement,I=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,"innerHTML"),oa=window.HTMLElement.prototype.insertAdjacentElement,pa=window.HTMLElement.prototype.insertAdjacentHTML;var qa=new Set();"annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" ").forEach(function(a){return qa.add(a);});function ra(a){var b=qa.has(a);a=/^[a-z][.0-9_a-z]*-[-.0-9_a-z]*$/.test(a);return!b&&a;}var sa=document.contains?document.contains.bind(document):document.documentElement.contains.bind(document.documentElement);function J(a){var b=a.isConnected;if(void 0!==b)return b;if(sa(a))return!0;for(;a&&!(a.__CE_isImportDocument||a instanceof Document);)a=a.parentNode||(window.ShadowRoot&&a instanceof ShadowRoot?a.host:void 0);return!(!a||!(a.__CE_isImportDocument||a instanceof Document));}function K(a){var b=a.children;if(b)return Array.prototype.slice.call(b);b=[];for(a=a.firstChild;a;a=a.nextSibling)a.nodeType===Node.ELEMENT_NODE&&b.push(a);return b;}function L(a,b){for(;b&&b!==a&&!b.nextSibling;)b=b.parentNode;return b&&b!==a?b.nextSibling:null;}function M(a,b,d){for(var f=a;f;){if(f.nodeType===Node.ELEMENT_NODE){var c=f;b(c);var e=c.localName;if("link"===e&&"import"===c.getAttribute("rel")){f=c.import;void 0===d&&(d=new Set());if(f instanceof Node&&!d.has(f))for(d.add(f),f=f.firstChild;f;f=f.nextSibling)M(f,b,d);f=L(a,c);continue;}else if("template"===e){f=L(a,c);continue;}if(c=c.__CE_shadowRoot)for(c=c.firstChild;c;c=c.nextSibling)M(c,b,d);}f=f.firstChild?f.firstChild:L(a,f);}};function N(){var a=!(null===O||void 0===O||!O.noDocumentConstructionObserver),b=!(null===O||void 0===O||!O.shadyDomFastWalk);this.m=[];this.g=[];this.j=!1;this.shadyDomFastWalk=b;this.I=!a;}function P(a,b,d,f){var c=window.ShadyDOM;if(a.shadyDomFastWalk&&c&&c.inUse){if(b.nodeType===Node.ELEMENT_NODE&&d(b),b.querySelectorAll)for(a=c.nativeMethods.querySelectorAll.call(b,"*"),b=0;b<a.length;b++)d(a[b]);}else M(b,d,f);}function ta(a,b){a.j=!0;a.m.push(b);}function ua(a,b){a.j=!0;a.g.push(b);}function Q(a,b){a.j&&P(a,b,function(d){return R(a,d);});}function R(a,b){if(a.j&&!b.__CE_patched){b.__CE_patched=!0;for(var d=0;d<a.m.length;d++)a.m[d](b);for(d=0;d<a.g.length;d++)a.g[d](b);}}function S(a,b){var d=[];P(a,b,function(c){return d.push(c);});for(b=0;b<d.length;b++){var f=d[b];1===f.__CE_state?a.connectedCallback(f):T(a,f);}}function U(a,b){var d=[];P(a,b,function(c){return d.push(c);});for(b=0;b<d.length;b++){var f=d[b];1===f.__CE_state&&a.disconnectedCallback(f);}}function V(a,b,d){d=void 0===d?{}:d;var f=d.J,c=d.upgrade||function(g){return T(a,g);},e=[];P(a,b,function(g){a.j&&R(a,g);if("link"===g.localName&&"import"===g.getAttribute("rel")){var h=g.import;h instanceof Node&&(h.__CE_isImportDocument=!0,h.__CE_registry=document.__CE_registry);h&&"complete"===h.readyState?h.__CE_documentLoadHandled=!0:g.addEventListener("load",function(){var k=g.import;if(!k.__CE_documentLoadHandled){k.__CE_documentLoadHandled=!0;var l=new Set();f&&(f.forEach(function(m){return l.add(m);}),l.delete(k));V(a,k,{J:l,upgrade:c});}});}else e.push(g);},f);for(b=0;b<e.length;b++)c(e[b]);}function T(a,b){try{var d=b.ownerDocument,f=d.__CE_registry;var c=f&&(d.defaultView||d.__CE_isImportDocument)?W(f,b.localName):void 0;if(c&&void 0===b.__CE_state){c.constructionStack.push(b);try{try{if(new c.constructorFunction()!==b)throw Error("The custom element constructor did not produce the element being upgraded.");}finally{c.constructionStack.pop();}}catch(k){throw b.__CE_state=2,k;}b.__CE_state=1;b.__CE_definition=c;if(c.attributeChangedCallback&&b.hasAttributes()){var e=c.observedAttributes;for(c=0;c<e.length;c++){var g=e[c],h=b.getAttribute(g);null!==h&&a.attributeChangedCallback(b,g,null,h,null);}}J(b)&&a.connectedCallback(b);}}catch(k){X(k);}}N.prototype.connectedCallback=function(a){var b=a.__CE_definition;if(b.connectedCallback)try{b.connectedCallback.call(a);}catch(d){X(d);}};N.prototype.disconnectedCallback=function(a){var b=a.__CE_definition;if(b.disconnectedCallback)try{b.disconnectedCallback.call(a);}catch(d){X(d);}};N.prototype.attributeChangedCallback=function(a,b,d,f,c){var e=a.__CE_definition;if(e.attributeChangedCallback&&-1<e.observedAttributes.indexOf(b))try{e.attributeChangedCallback.call(a,b,d,f,c);}catch(g){X(g);}};function va(a,b,d,f){var c=b.__CE_registry;if(c&&(null===f||"http://www.w3.org/1999/xhtml"===f)&&(c=W(c,d)))try{var e=new c.constructorFunction();if(void 0===e.__CE_state||void 0===e.__CE_definition)throw Error("Failed to construct '"+d+"': The returned value was not constructed with the HTMLElement constructor.");if("http://www.w3.org/1999/xhtml"!==e.namespaceURI)throw Error("Failed to construct '"+d+"': The constructed element's namespace must be the HTML namespace.");if(e.hasAttributes())throw Error("Failed to construct '"+d+"': The constructed element must not have any attributes.");if(null!==e.firstChild)throw Error("Failed to construct '"+d+"': The constructed element must not have any children.");if(null!==e.parentNode)throw Error("Failed to construct '"+d+"': The constructed element must not have a parent node.");if(e.ownerDocument!==b)throw Error("Failed to construct '"+d+"': The constructed element's owner document is incorrect.");if(e.localName!==d)throw Error("Failed to construct '"+d+"': The constructed element's local name is incorrect.");return e;}catch(g){return X(g),b=null===f?n.call(b,d):p.call(b,f,d),Object.setPrototypeOf(b,HTMLUnknownElement.prototype),b.__CE_state=2,b.__CE_definition=void 0,R(a,b),b;}b=null===f?n.call(b,d):p.call(b,f,d);R(a,b);return b;}function X(a){var b="",d="",f=0,c=0;a instanceof Error?(b=a.message,d=a.sourceURL||a.fileName||"",f=a.line||a.lineNumber||0,c=a.column||a.columnNumber||0):b="Uncaught "+String(a);var e=void 0;void 0===ErrorEvent.prototype.initErrorEvent?e=new ErrorEvent("error",{cancelable:!0,message:b,filename:d,lineno:f,colno:c,error:a}):(e=document.createEvent("ErrorEvent"),e.initErrorEvent("error",!1,!0,b,d,f),e.preventDefault=function(){Object.defineProperty(this,"defaultPrevented",{configurable:!0,get:function(){return!0;}});});void 0===e.error&&Object.defineProperty(e,"error",{configurable:!0,enumerable:!0,get:function(){return a;}});window.dispatchEvent(e);e.defaultPrevented||console.error(a);};function wa(){var a=this;this.g=void 0;this.F=new Promise(function(b){a.l=b;});}wa.prototype.resolve=function(a){if(this.g)throw Error("Already resolved.");this.g=a;this.l(a);};function xa(a){var b=document;this.l=void 0;this.h=a;this.g=b;V(this.h,this.g);"loading"===this.g.readyState&&(this.l=new MutationObserver(this.G.bind(this)),this.l.observe(this.g,{childList:!0,subtree:!0}));}function ya(a){a.l&&a.l.disconnect();}xa.prototype.G=function(a){var b=this.g.readyState;"interactive"!==b&&"complete"!==b||ya(this);for(b=0;b<a.length;b++)for(var d=a[b].addedNodes,f=0;f<d.length;f++)V(this.h,d[f]);};function Y(a){this.s=new Map();this.u=new Map();this.C=new Map();this.A=!1;this.B=new Map();this.o=function(b){return b();};this.i=!1;this.v=[];this.h=a;this.D=a.I?new xa(a):void 0;}Y.prototype.H=function(a,b){var d=this;if(!(b instanceof Function))throw new TypeError("Custom element constructor getters must be functions.");za(this,a);this.s.set(a,b);this.v.push(a);this.i||(this.i=!0,this.o(function(){return Aa(d);}));};Y.prototype.define=function(a,b){var d=this;if(!(b instanceof Function))throw new TypeError("Custom element constructors must be functions.");za(this,a);Ba(this,a,b);this.v.push(a);this.i||(this.i=!0,this.o(function(){return Aa(d);}));};function za(a,b){if(!ra(b))throw new SyntaxError("The element name '"+b+"' is not valid.");if(W(a,b))throw Error("A custom element with name '"+(b+"' has already been defined."));if(a.A)throw Error("A custom element is already being defined.");}function Ba(a,b,d){a.A=!0;var f;try{var c=d.prototype;if(!(c instanceof Object))throw new TypeError("The custom element constructor's prototype is not an object.");var e=function(m){var x=c[m];if(void 0!==x&&!(x instanceof Function))throw Error("The '"+m+"' callback must be a function.");return x;};var g=e("connectedCallback");var h=e("disconnectedCallback");var k=e("adoptedCallback");var l=(f=e("attributeChangedCallback"))&&d.observedAttributes||[];}catch(m){throw m;}finally{a.A=!1;}d={localName:b,constructorFunction:d,connectedCallback:g,disconnectedCallback:h,adoptedCallback:k,attributeChangedCallback:f,observedAttributes:l,constructionStack:[]};a.u.set(b,d);a.C.set(d.constructorFunction,d);return d;}Y.prototype.upgrade=function(a){V(this.h,a);};function Aa(a){if(!1!==a.i){a.i=!1;for(var b=[],d=a.v,f=new Map(),c=0;c<d.length;c++)f.set(d[c],[]);V(a.h,document,{upgrade:function(k){if(void 0===k.__CE_state){var l=k.localName,m=f.get(l);m?m.push(k):a.u.has(l)&&b.push(k);}}});for(c=0;c<b.length;c++)T(a.h,b[c]);for(c=0;c<d.length;c++){for(var e=d[c],g=f.get(e),h=0;h<g.length;h++)T(a.h,g[h]);(e=a.B.get(e))&&e.resolve(void 0);}d.length=0;}}Y.prototype.get=function(a){if(a=W(this,a))return a.constructorFunction;};Y.prototype.whenDefined=function(a){if(!ra(a))return Promise.reject(new SyntaxError("'"+a+"' is not a valid custom element name."));var b=this.B.get(a);if(b)return b.F;b=new wa();this.B.set(a,b);var d=this.u.has(a)||this.s.has(a);a=-1===this.v.indexOf(a);d&&a&&b.resolve(void 0);return b.F;};Y.prototype.polyfillWrapFlushCallback=function(a){this.D&&ya(this.D);var b=this.o;this.o=function(d){return a(function(){return b(d);});};};function W(a,b){var d=a.u.get(b);if(d)return d;if(d=a.s.get(b)){a.s.delete(b);try{return Ba(a,b,d());}catch(f){X(f);}}}Y.prototype.define=Y.prototype.define;Y.prototype.upgrade=Y.prototype.upgrade;Y.prototype.get=Y.prototype.get;Y.prototype.whenDefined=Y.prototype.whenDefined;Y.prototype.polyfillDefineLazy=Y.prototype.H;Y.prototype.polyfillWrapFlushCallback=Y.prototype.polyfillWrapFlushCallback;function Z(a,b,d){function f(c){return function(e){for(var g=[],h=0;h<arguments.length;++h)g[h]=arguments[h];h=[];for(var k=[],l=0;l<g.length;l++){var m=g[l];m instanceof Element&&J(m)&&k.push(m);if(m instanceof DocumentFragment)for(m=m.firstChild;m;m=m.nextSibling)h.push(m);else h.push(m);}c.apply(this,g);for(g=0;g<k.length;g++)U(a,k[g]);if(J(this))for(g=0;g<h.length;g++)k=h[g],k instanceof Element&&S(a,k);};}void 0!==d.prepend&&(b.prepend=f(d.prepend));void 0!==d.append&&(b.append=f(d.append));};function Ca(a){Document.prototype.createElement=function(b){return va(a,this,b,null);};Document.prototype.importNode=function(b,d){b=aa.call(this,b,!!d);this.__CE_registry?V(a,b):Q(a,b);return b;};Document.prototype.createElementNS=function(b,d){return va(a,this,d,b);};Z(a,Document.prototype,{prepend:ba,append:ca});};function Da(a){function b(f){return function(c){for(var e=[],g=0;g<arguments.length;++g)e[g]=arguments[g];g=[];for(var h=[],k=0;k<e.length;k++){var l=e[k];l instanceof Element&&J(l)&&h.push(l);if(l instanceof DocumentFragment)for(l=l.firstChild;l;l=l.nextSibling)g.push(l);else g.push(l);}f.apply(this,e);for(e=0;e<h.length;e++)U(a,h[e]);if(J(this))for(e=0;e<g.length;e++)h=g[e],h instanceof Element&&S(a,h);};}var d=Element.prototype;void 0!==ja&&(d.before=b(ja));void 0!==ka&&(d.after=b(ka));void 0!==la&&(d.replaceWith=function(f){for(var c=[],e=0;e<arguments.length;++e)c[e]=arguments[e];e=[];for(var g=[],h=0;h<c.length;h++){var k=c[h];k instanceof Element&&J(k)&&g.push(k);if(k instanceof DocumentFragment)for(k=k.firstChild;k;k=k.nextSibling)e.push(k);else e.push(k);}h=J(this);la.apply(this,c);for(c=0;c<g.length;c++)U(a,g[c]);if(h)for(U(a,this),c=0;c<e.length;c++)g=e[c],g instanceof Element&&S(a,g);});void 0!==ma&&(d.remove=function(){var f=J(this);ma.call(this);f&&U(a,this);});};function Ea(a){function b(c,e){Object.defineProperty(c,"innerHTML",{enumerable:e.enumerable,configurable:!0,get:e.get,set:function(g){var h=this,k=void 0;J(this)&&(k=[],P(a,this,function(x){x!==h&&k.push(x);}));e.set.call(this,g);if(k)for(var l=0;l<k.length;l++){var m=k[l];1===m.__CE_state&&a.disconnectedCallback(m);}this.ownerDocument.__CE_registry?V(a,this):Q(a,this);return g;}});}function d(c,e){c.insertAdjacentElement=function(g,h){var k=J(h);g=e.call(this,g,h);k&&U(a,h);J(g)&&S(a,h);return g;};}function f(c,e){function g(h,k){for(var l=[];h!==k;h=h.nextSibling)l.push(h);for(k=0;k<l.length;k++)V(a,l[k]);}c.insertAdjacentHTML=function(h,k){h=h.toLowerCase();if("beforebegin"===h){var l=this.previousSibling;e.call(this,h,k);g(l||this.parentNode.firstChild,this);}else if("afterbegin"===h)l=this.firstChild,e.call(this,h,k),g(this.firstChild,l);else if("beforeend"===h)l=this.lastChild,e.call(this,h,k),g(l||this.firstChild,null);else if("afterend"===h)l=this.nextSibling,e.call(this,h,k),g(this.nextSibling,l);else throw new SyntaxError("The value provided ("+String(h)+") is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'.");};}y&&(Element.prototype.attachShadow=function(c){c=y.call(this,c);if(a.j&&!c.__CE_patched){c.__CE_patched=!0;for(var e=0;e<a.m.length;e++)a.m[e](c);}return this.__CE_shadowRoot=c;});z&&z.get?b(Element.prototype,z):I&&I.get?b(HTMLElement.prototype,I):ua(a,function(c){b(c,{enumerable:!0,configurable:!0,get:function(){return q.call(this,!0).innerHTML;},set:function(e){var g="template"===this.localName,h=g?this.content:this,k=p.call(document,this.namespaceURI,this.localName);for(k.innerHTML=e;0<h.childNodes.length;)u.call(h,h.childNodes[0]);for(e=g?k.content:k;0<e.childNodes.length;)r.call(h,e.childNodes[0]);}});});Element.prototype.setAttribute=function(c,e){if(1!==this.__CE_state)return B.call(this,c,e);var g=A.call(this,c);B.call(this,c,e);e=A.call(this,c);a.attributeChangedCallback(this,c,g,e,null);};Element.prototype.setAttributeNS=function(c,e,g){if(1!==this.__CE_state)return F.call(this,c,e,g);var h=E.call(this,c,e);F.call(this,c,e,g);g=E.call(this,c,e);a.attributeChangedCallback(this,e,h,g,c);};Element.prototype.removeAttribute=function(c){if(1!==this.__CE_state)return C.call(this,c);var e=A.call(this,c);C.call(this,c);null!==e&&a.attributeChangedCallback(this,c,e,null,null);};D&&(Element.prototype.toggleAttribute=function(c,e){if(1!==this.__CE_state)return D.call(this,c,e);var g=A.call(this,c),h=null!==g;e=D.call(this,c,e);h!==e&&a.attributeChangedCallback(this,c,g,e?"":null,null);return e;});Element.prototype.removeAttributeNS=function(c,e){if(1!==this.__CE_state)return G.call(this,c,e);var g=E.call(this,c,e);G.call(this,c,e);var h=E.call(this,c,e);g!==h&&a.attributeChangedCallback(this,e,g,h,c);};oa?d(HTMLElement.prototype,oa):H&&d(Element.prototype,H);pa?f(HTMLElement.prototype,pa):fa&&f(Element.prototype,fa);Z(a,Element.prototype,{prepend:ha,append:ia});Da(a);};var Fa={};function Ga(a){function b(){var d=this.constructor;var f=document.__CE_registry.C.get(d);if(!f)throw Error("Failed to construct a custom element: The constructor was not registered with `customElements`.");var c=f.constructionStack;if(0===c.length)return c=n.call(document,f.localName),Object.setPrototypeOf(c,d.prototype),c.__CE_state=1,c.__CE_definition=f,R(a,c),c;var e=c.length-1,g=c[e];if(g===Fa)throw Error("Failed to construct '"+f.localName+"': This element was already constructed.");c[e]=Fa;Object.setPrototypeOf(g,d.prototype);R(a,g);return g;}b.prototype=na.prototype;Object.defineProperty(HTMLElement.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:b});window.HTMLElement=b;};function Ha(a){function b(d,f){Object.defineProperty(d,"textContent",{enumerable:f.enumerable,configurable:!0,get:f.get,set:function(c){if(this.nodeType===Node.TEXT_NODE)f.set.call(this,c);else{var e=void 0;if(this.firstChild){var g=this.childNodes,h=g.length;if(0<h&&J(this)){e=Array(h);for(var k=0;k<h;k++)e[k]=g[k];}}f.set.call(this,c);if(e)for(c=0;c<e.length;c++)U(a,e[c]);}}});}Node.prototype.insertBefore=function(d,f){if(d instanceof DocumentFragment){var c=K(d);d=t.call(this,d,f);if(J(this))for(f=0;f<c.length;f++)S(a,c[f]);return d;}c=d instanceof Element&&J(d);f=t.call(this,d,f);c&&U(a,d);J(this)&&S(a,d);return f;};Node.prototype.appendChild=function(d){if(d instanceof DocumentFragment){var f=K(d);d=r.call(this,d);if(J(this))for(var c=0;c<f.length;c++)S(a,f[c]);return d;}f=d instanceof Element&&J(d);c=r.call(this,d);f&&U(a,d);J(this)&&S(a,d);return c;};Node.prototype.cloneNode=function(d){d=q.call(this,!!d);this.ownerDocument.__CE_registry?V(a,d):Q(a,d);return d;};Node.prototype.removeChild=function(d){var f=d instanceof Element&&J(d),c=u.call(this,d);f&&U(a,d);return c;};Node.prototype.replaceChild=function(d,f){if(d instanceof DocumentFragment){var c=K(d);d=v.call(this,d,f);if(J(this))for(U(a,f),f=0;f<c.length;f++)S(a,c[f]);return d;}c=d instanceof Element&&J(d);var e=v.call(this,d,f),g=J(this);g&&U(a,f);c&&U(a,d);g&&S(a,d);return e;};w&&w.get?b(Node.prototype,w):ta(a,function(d){b(d,{enumerable:!0,configurable:!0,get:function(){for(var f=[],c=this.firstChild;c;c=c.nextSibling)c.nodeType!==Node.COMMENT_NODE&&f.push(c.textContent);return f.join("");},set:function(f){for(;this.firstChild;)u.call(this,this.firstChild);null!=f&&""!==f&&r.call(this,document.createTextNode(f));}});});};var O=window.customElements;function Ia(){var a=new N();Ga(a);Ca(a);Z(a,DocumentFragment.prototype,{prepend:da,append:ea});Ha(a);Ea(a);window.CustomElementRegistry=Y;a=new Y(a);document.__CE_registry=a;Object.defineProperty(window,"customElements",{configurable:!0,enumerable:!0,value:a});}O&&!O.forcePolyfill&&"function"==typeof O.define&&"function"==typeof O.get||Ia();window.__CE_installPolyfill=Ia;}).call(self);

/***/ }),

/***/ 31506:
/***/ (function(__unused_webpack_module, exports) {

"use strict";
exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=='undefined'?Uint8Array:Array;var code='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i;}// Support decoding URL-safe base64 strings, as Node.js does.
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
revLookup['-'.charCodeAt(0)]=62;revLookup['_'.charCodeAt(0)]=63;function getLens(b64){var len=b64.length;if(len%4>0){throw new Error('Invalid string. Length must be a multiple of 4');}// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen=b64.indexOf('=');if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen];}// base64 is 4/3 + up to two characters of the original data
function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen;}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen;}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;// if there are placeholders, only get up to the last complete 4 chars
var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i<len;i+=4){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[curByte++]=tmp>>16&0xFF;arr[curByte++]=tmp>>8&0xFF;arr[curByte++]=tmp&0xFF;}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&0xFF;}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&0xFF;arr[curByte++]=tmp&0xFF;}return arr;}function tripletToBase64(num){return lookup[num>>18&0x3F]+lookup[num>>12&0x3F]+lookup[num>>6&0x3F]+lookup[num&0x3F];}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;i<end;i+=3){tmp=(uint8[i]<<16&0xFF0000)+(uint8[i+1]<<8&0xFF00)+(uint8[i+2]&0xFF);output.push(tripletToBase64(tmp));}return output.join('');}function fromByteArray(uint8){var tmp;var len=uint8.length;var extraBytes=len%3;// if we have 1 byte left, pad 2 bytes
var parts=[];var maxChunkLength=16383;// must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength));}// pad the end with zeros, but make sure to not forget the extra bytes
if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&0x3F]+'==');}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&0x3F]+lookup[tmp<<2&0x3F]+'=');}return parts.join('');}

/***/ }),

/***/ 97763:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
var __webpack_unused_export__;
/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 *//* eslint-disable no-proto */const base64=__webpack_require__(31506);const ieee754=__webpack_require__(94087);const customInspectSymbol=typeof Symbol==='function'&&typeof Symbol['for']==='function'// eslint-disable-line dot-notation
?Symbol['for']('nodejs.util.inspect.custom')// eslint-disable-line dot-notation
:null;exports.hp=Buffer;__webpack_unused_export__=SlowBuffer;exports.IS=50;const K_MAX_LENGTH=0x7fffffff;__webpack_unused_export__=K_MAX_LENGTH;/**
 * If `Buffer.TYPED_ARRAY_SUPPORT`:
 *   === true    Use Uint8Array implementation (fastest)
 *   === false   Print warning and recommend using `buffer` v4.x which has an Object
 *               implementation (most compatible, even IE6)
 *
 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
 * Opera 11.6+, iOS 4.2+.
 *
 * We report that the browser does not support typed arrays if the are not subclassable
 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
 * for __proto__ and has a buggy typed array implementation.
 */Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=='undefined'&&typeof console.error==='function'){console.error('This browser lacks typed array (Uint8Array) support which is required by '+'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.');}function typedArraySupport(){// Can typed array instances can be augmented?
try{const arr=new Uint8Array(1);const proto={foo:function(){return 42;}};Object.setPrototypeOf(proto,Uint8Array.prototype);Object.setPrototypeOf(arr,proto);return arr.foo()===42;}catch(e){return false;}}Object.defineProperty(Buffer.prototype,'parent',{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer;}});Object.defineProperty(Buffer.prototype,'offset',{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset;}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"');}// Return an augmented `Uint8Array` instance
const buf=new Uint8Array(length);Object.setPrototypeOf(buf,Buffer.prototype);return buf;}/**
 * The Buffer constructor returns instances of `Uint8Array` that have their
 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
 * returns a single octet.
 *
 * The `Uint8Array` prototype remains unmodified.
 */function Buffer(arg,encodingOrOffset,length){// Common case.
if(typeof arg==='number'){if(typeof encodingOrOffset==='string'){throw new TypeError('The "string" argument must be of type string. Received type number');}return allocUnsafe(arg);}return from(arg,encodingOrOffset,length);}Buffer.poolSize=8192;// not used by this implementation
function from(value,encodingOrOffset,length){if(typeof value==='string'){return fromString(value,encodingOrOffset);}if(ArrayBuffer.isView(value)){return fromArrayView(value);}if(value==null){throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, '+'or Array-like Object. Received type '+typeof value);}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length);}if(typeof SharedArrayBuffer!=='undefined'&&(isInstance(value,SharedArrayBuffer)||value&&isInstance(value.buffer,SharedArrayBuffer))){return fromArrayBuffer(value,encodingOrOffset,length);}if(typeof value==='number'){throw new TypeError('The "value" argument must not be of type number. Received type number');}const valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length);}const b=fromObject(value);if(b)return b;if(typeof Symbol!=='undefined'&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==='function'){return Buffer.from(value[Symbol.toPrimitive]('string'),encodingOrOffset,length);}throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, '+'or Array-like Object. Received type '+typeof value);}/**
 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
 * if value is a number.
 * Buffer.from(str[, encoding])
 * Buffer.from(array)
 * Buffer.from(buffer)
 * Buffer.from(arrayBuffer[, byteOffset[, length]])
 **/Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length);};// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
// https://github.com/feross/buffer/pull/148
Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype);Object.setPrototypeOf(Buffer,Uint8Array);function assertSize(size){if(typeof size!=='number'){throw new TypeError('"size" argument must be of type number');}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"');}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size);}if(fill!==undefined){// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpreted as a start offset.
return typeof encoding==='string'?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill);}return createBuffer(size);}/**
 * Creates a new filled Buffer instance.
 * alloc(size[, fill[, encoding]])
 **/Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding);};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0);}/**
 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
 * */Buffer.allocUnsafe=function(size){return allocUnsafe(size);};/**
 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
 */Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size);};function fromString(string,encoding){if(typeof encoding!=='string'||encoding===''){encoding='utf8';}if(!Buffer.isEncoding(encoding)){throw new TypeError('Unknown encoding: '+encoding);}const length=byteLength(string,encoding)|0;let buf=createBuffer(length);const actual=buf.write(string,encoding);if(actual!==length){// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf=buf.slice(0,actual);}return buf;}function fromArrayLike(array){const length=array.length<0?0:checked(array.length)|0;const buf=createBuffer(length);for(let i=0;i<length;i+=1){buf[i]=array[i]&255;}return buf;}function fromArrayView(arrayView){if(isInstance(arrayView,Uint8Array)){const copy=new Uint8Array(arrayView);return fromArrayBuffer(copy.buffer,copy.byteOffset,copy.byteLength);}return fromArrayLike(arrayView);}function fromArrayBuffer(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset){throw new RangeError('"offset" is outside of buffer bounds');}if(array.byteLength<byteOffset+(length||0)){throw new RangeError('"length" is outside of buffer bounds');}let buf;if(byteOffset===undefined&&length===undefined){buf=new Uint8Array(array);}else if(length===undefined){buf=new Uint8Array(array,byteOffset);}else{buf=new Uint8Array(array,byteOffset,length);}// Return an augmented `Uint8Array` instance
Object.setPrototypeOf(buf,Buffer.prototype);return buf;}function fromObject(obj){if(Buffer.isBuffer(obj)){const len=checked(obj.length)|0;const buf=createBuffer(len);if(buf.length===0){return buf;}obj.copy(buf,0,0,len);return buf;}if(obj.length!==undefined){if(typeof obj.length!=='number'||numberIsNaN(obj.length)){return createBuffer(0);}return fromArrayLike(obj);}if(obj.type==='Buffer'&&Array.isArray(obj.data)){return fromArrayLike(obj.data);}}function checked(length){// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if(length>=K_MAX_LENGTH){throw new RangeError('Attempt to allocate Buffer larger than maximum '+'size: 0x'+K_MAX_LENGTH.toString(16)+' bytes');}return length|0;}function SlowBuffer(length){if(+length!=length){// eslint-disable-line eqeqeq
length=0;}return Buffer.alloc(+length);}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype;// so Buffer.isBuffer(Buffer.prototype) will be false
};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');}if(a===b)return 0;let x=a.length;let y=b.length;for(let i=0,len=Math.min(x,y);i<len;++i){if(a[i]!==b[i]){x=a[i];y=b[i];break;}}if(x<y)return-1;if(y<x)return 1;return 0;};Buffer.isEncoding=function isEncoding(encoding){switch(String(encoding).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return true;default:return false;}};Buffer.concat=function concat(list,length){if(!Array.isArray(list)){throw new TypeError('"list" argument must be an Array of Buffers');}if(list.length===0){return Buffer.alloc(0);}let i;if(length===undefined){length=0;for(i=0;i<list.length;++i){length+=list[i].length;}}const buffer=Buffer.allocUnsafe(length);let pos=0;for(i=0;i<list.length;++i){let buf=list[i];if(isInstance(buf,Uint8Array)){if(pos+buf.length>buffer.length){if(!Buffer.isBuffer(buf))buf=Buffer.from(buf);buf.copy(buffer,pos);}else{Uint8Array.prototype.set.call(buffer,buf,pos);}}else if(!Buffer.isBuffer(buf)){throw new TypeError('"list" argument must be an Array of Buffers');}else{buf.copy(buffer,pos);}pos+=buf.length;}return buffer;};function byteLength(string,encoding){if(Buffer.isBuffer(string)){return string.length;}if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer)){return string.byteLength;}if(typeof string!=='string'){throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. '+'Received type '+typeof string);}const len=string.length;const mustMatch=arguments.length>2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;// Use a for loop to avoid recursion
let loweredCase=false;for(;;){switch(encoding){case'ascii':case'latin1':case'binary':return len;case'utf8':case'utf-8':return utf8ToBytes(string).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return len*2;case'hex':return len>>>1;case'base64':return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length;// assume utf8
}encoding=(''+encoding).toLowerCase();loweredCase=true;}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){let loweredCase=false;// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if(start===undefined||start<0){start=0;}// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if(start>this.length){return'';}if(end===undefined||end>this.length){end=this.length;}if(end<=0){return'';}// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
end>>>=0;start>>>=0;if(end<=start){return'';}if(!encoding)encoding='utf8';while(true){switch(encoding){case'hex':return hexSlice(this,start,end);case'utf8':case'utf-8':return utf8Slice(this,start,end);case'ascii':return asciiSlice(this,start,end);case'latin1':case'binary':return latin1Slice(this,start,end);case'base64':return base64Slice(this,start,end);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError('Unknown encoding: '+encoding);encoding=(encoding+'').toLowerCase();loweredCase=true;}}}// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
// reliably in a browserify context because there could be multiple different
// copies of the 'buffer' package in use. This method works even for Buffer
// instances that were created from another copy of the `buffer` package.
// See: https://github.com/feross/buffer/issues/154
Buffer.prototype._isBuffer=true;function swap(b,n,m){const i=b[n];b[n]=b[m];b[m]=i;}Buffer.prototype.swap16=function swap16(){const len=this.length;if(len%2!==0){throw new RangeError('Buffer size must be a multiple of 16-bits');}for(let i=0;i<len;i+=2){swap(this,i,i+1);}return this;};Buffer.prototype.swap32=function swap32(){const len=this.length;if(len%4!==0){throw new RangeError('Buffer size must be a multiple of 32-bits');}for(let i=0;i<len;i+=4){swap(this,i,i+3);swap(this,i+1,i+2);}return this;};Buffer.prototype.swap64=function swap64(){const len=this.length;if(len%8!==0){throw new RangeError('Buffer size must be a multiple of 64-bits');}for(let i=0;i<len;i+=8){swap(this,i,i+7);swap(this,i+1,i+6);swap(this,i+2,i+5);swap(this,i+3,i+4);}return this;};Buffer.prototype.toString=function toString(){const length=this.length;if(length===0)return'';if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments);};Buffer.prototype.toLocaleString=Buffer.prototype.toString;Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError('Argument must be a Buffer');if(this===b)return true;return Buffer.compare(this,b)===0;};Buffer.prototype.inspect=function inspect(){let str='';const max=exports.IS;str=this.toString('hex',0,max).replace(/(.{2})/g,'$1 ').trim();if(this.length>max)str+=' ... ';return'<Buffer '+str+'>';};if(customInspectSymbol){Buffer.prototype[customInspectSymbol]=Buffer.prototype.inspect;}Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength);}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+'Received type '+typeof target);}if(start===undefined){start=0;}if(end===undefined){end=target?target.length:0;}if(thisStart===undefined){thisStart=0;}if(thisEnd===undefined){thisEnd=this.length;}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError('out of range index');}if(thisStart>=thisEnd&&start>=end){return 0;}if(thisStart>=thisEnd){return-1;}if(start>=end){return 1;}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;let x=thisEnd-thisStart;let y=end-start;const len=Math.min(x,y);const thisCopy=this.slice(thisStart,thisEnd);const targetCopy=target.slice(start,end);for(let i=0;i<len;++i){if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i];y=targetCopy[i];break;}}if(x<y)return-1;if(y<x)return 1;return 0;};// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
//
// Arguments:
// - buffer - a Buffer to search
// - val - a string, Buffer, or number
// - byteOffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - dir - true for indexOf, false for lastIndexOf
function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){// Empty buffer means no match
if(buffer.length===0)return-1;// Normalize byteOffset
if(typeof byteOffset==='string'){encoding=byteOffset;byteOffset=0;}else if(byteOffset>0x7fffffff){byteOffset=0x7fffffff;}else if(byteOffset<-0x80000000){byteOffset=-0x80000000;}byteOffset=+byteOffset;// Coerce to Number.
if(numberIsNaN(byteOffset)){// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset=dir?0:buffer.length-1;}// Normalize byteOffset: negative offsets start from the end of the buffer
if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1;}else if(byteOffset<0){if(dir)byteOffset=0;else return-1;}// Normalize val
if(typeof val==='string'){val=Buffer.from(val,encoding);}// Finally, search either indexOf (if dir is true) or lastIndexOf
if(Buffer.isBuffer(val)){// Special case: looking for empty string/buffer always fails
if(val.length===0){return-1;}return arrayIndexOf(buffer,val,byteOffset,encoding,dir);}else if(typeof val==='number'){val=val&0xFF;// Search for a byte value [0-255]
if(typeof Uint8Array.prototype.indexOf==='function'){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset);}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset);}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir);}throw new TypeError('val must be string, number or Buffer');}function arrayIndexOf(arr,val,byteOffset,encoding,dir){let indexSize=1;let arrLength=arr.length;let valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==='ucs2'||encoding==='ucs-2'||encoding==='utf16le'||encoding==='utf-16le'){if(arr.length<2||val.length<2){return-1;}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2;}}function read(buf,i){if(indexSize===1){return buf[i];}else{return buf.readUInt16BE(i*indexSize);}}let i;if(dir){let foundIndex=-1;for(i=byteOffset;i<arrLength;i++){if(read(arr,i)===read(val,foundIndex===-1?0:i-foundIndex)){if(foundIndex===-1)foundIndex=i;if(i-foundIndex+1===valLength)return foundIndex*indexSize;}else{if(foundIndex!==-1)i-=i-foundIndex;foundIndex=-1;}}}else{if(byteOffset+valLength>arrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){let found=true;for(let j=0;j<valLength;j++){if(read(arr,i+j)!==read(val,j)){found=false;break;}}if(found)return i;}}return-1;}Buffer.prototype.includes=function includes(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1;};Buffer.prototype.indexOf=function indexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,true);};Buffer.prototype.lastIndexOf=function lastIndexOf(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,false);};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;const remaining=buf.length-offset;if(!length){length=remaining;}else{length=Number(length);if(length>remaining){length=remaining;}}const strLen=string.length;if(length>strLen/2){length=strLen/2;}let i;for(i=0;i<length;++i){const parsed=parseInt(string.substr(i*2,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed;}return i;}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);}function asciiWrite(buf,string,offset,length){return blitBuffer(asciiToBytes(string),buf,offset,length);}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length);}function ucs2Write(buf,string,offset,length){return blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length);}Buffer.prototype.write=function write(string,offset,length,encoding){// Buffer#write(string)
if(offset===undefined){encoding='utf8';length=this.length;offset=0;// Buffer#write(string, encoding)
}else if(length===undefined&&typeof offset==='string'){encoding=offset;length=this.length;offset=0;// Buffer#write(string, offset[, length][, encoding])
}else if(isFinite(offset)){offset=offset>>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding='utf8';}else{encoding=length;length=undefined;}}else{throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');}const remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError('Attempt to write outside buffer bounds');}if(!encoding)encoding='utf8';let loweredCase=false;for(;;){switch(encoding){case'hex':return hexWrite(this,string,offset,length);case'utf8':case'utf-8':return utf8Write(this,string,offset,length);case'ascii':case'latin1':case'binary':return asciiWrite(this,string,offset,length);case'base64':// Warning: maxLength not taken into account in base64Write
return base64Write(this,string,offset,length);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError('Unknown encoding: '+encoding);encoding=(''+encoding).toLowerCase();loweredCase=true;}}};Buffer.prototype.toJSON=function toJSON(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)};};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf);}else{return base64.fromByteArray(buf.slice(start,end));}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);const res=[];let i=start;while(i<end){const firstByte=buf[i];let codePoint=null;let bytesPerSequence=firstByte>0xEF?4:firstByte>0xDF?3:firstByte>0xBF?2:1;if(i+bytesPerSequence<=end){let secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<0x80){codePoint=firstByte;}break;case 2:secondByte=buf[i+1];if((secondByte&0xC0)===0x80){tempCodePoint=(firstByte&0x1F)<<0x6|secondByte&0x3F;if(tempCodePoint>0x7F){codePoint=tempCodePoint;}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&0xC0)===0x80&&(thirdByte&0xC0)===0x80){tempCodePoint=(firstByte&0xF)<<0xC|(secondByte&0x3F)<<0x6|thirdByte&0x3F;if(tempCodePoint>0x7FF&&(tempCodePoint<0xD800||tempCodePoint>0xDFFF)){codePoint=tempCodePoint;}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&0xC0)===0x80&&(thirdByte&0xC0)===0x80&&(fourthByte&0xC0)===0x80){tempCodePoint=(firstByte&0xF)<<0x12|(secondByte&0x3F)<<0xC|(thirdByte&0x3F)<<0x6|fourthByte&0x3F;if(tempCodePoint>0xFFFF&&tempCodePoint<0x110000){codePoint=tempCodePoint;}}}}if(codePoint===null){// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint=0xFFFD;bytesPerSequence=1;}else if(codePoint>0xFFFF){// encode to utf16 (surrogate pair dance)
codePoint-=0x10000;res.push(codePoint>>>10&0x3FF|0xD800);codePoint=0xDC00|codePoint&0x3FF;}res.push(codePoint);i+=bytesPerSequence;}return decodeCodePointsArray(res);}// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
const MAX_ARGUMENTS_LENGTH=0x1000;function decodeCodePointsArray(codePoints){const len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints);// avoid extra slice()
}// Decode in chunks to avoid "call stack size exceeded".
let res='';let i=0;while(i<len){res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));}return res;}function asciiSlice(buf,start,end){let ret='';end=Math.min(buf.length,end);for(let i=start;i<end;++i){ret+=String.fromCharCode(buf[i]&0x7F);}return ret;}function latin1Slice(buf,start,end){let ret='';end=Math.min(buf.length,end);for(let i=start;i<end;++i){ret+=String.fromCharCode(buf[i]);}return ret;}function hexSlice(buf,start,end){const len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;let out='';for(let i=start;i<end;++i){out+=hexSliceLookupTable[buf[i]];}return out;}function utf16leSlice(buf,start,end){const bytes=buf.slice(start,end);let res='';// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
for(let i=0;i<bytes.length-1;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256);}return res;}Buffer.prototype.slice=function slice(start,end){const len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0;}else if(start>len){start=len;}if(end<0){end+=len;if(end<0)end=0;}else if(end>len){end=len;}if(end<start)end=start;const newBuf=this.subarray(start,end);// Return an augmented `Uint8Array` instance
Object.setPrototypeOf(newBuf,Buffer.prototype);return newBuf;};/*
 * Need to make sure that buffer isn't trying to write out of bounds.
 */function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError('offset is not uint');if(offset+ext>length)throw new RangeError('Trying to access beyond buffer length');}Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);let val=this[offset];let mul=1;let i=0;while(++i<byteLength&&(mul*=0x100)){val+=this[offset+i]*mul;}return val;};Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function readUIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length);}let val=this[offset+--byteLength];let mul=1;while(byteLength>0&&(mul*=0x100)){val+=this[offset+--byteLength]*mul;}return val;};Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset];};Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8;};Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1];};Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*0x1000000;};Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*0x1000000+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3]);};Buffer.prototype.readBigUInt64LE=defineBigIntMethod(function readBigUInt64LE(offset){offset=offset>>>0;validateNumber(offset,'offset');const first=this[offset];const last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}const lo=first+this[++offset]*2**8+this[++offset]*2**16+this[++offset]*2**24;const hi=this[++offset]+this[++offset]*2**8+this[++offset]*2**16+last*2**24;return BigInt(lo)+(BigInt(hi)<<BigInt(32));});Buffer.prototype.readBigUInt64BE=defineBigIntMethod(function readBigUInt64BE(offset){offset=offset>>>0;validateNumber(offset,'offset');const first=this[offset];const last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}const hi=first*2**24+this[++offset]*2**16+this[++offset]*2**8+this[++offset];const lo=this[++offset]*2**24+this[++offset]*2**16+this[++offset]*2**8+last;return(BigInt(hi)<<BigInt(32))+BigInt(lo);});Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);let val=this[offset];let mul=1;let i=0;while(++i<byteLength&&(mul*=0x100)){val+=this[offset+i]*mul;}mul*=0x80;if(val>=mul)val-=Math.pow(2,8*byteLength);return val;};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);let i=byteLength;let mul=1;let val=this[offset+--i];while(i>0&&(mul*=0x100)){val+=this[offset+--i]*mul;}mul*=0x80;if(val>=mul)val-=Math.pow(2,8*byteLength);return val;};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&0x80))return this[offset];return(0xff-this[offset]+1)*-1;};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);const val=this[offset]|this[offset+1]<<8;return val&0x8000?val|0xFFFF0000:val;};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);const val=this[offset+1]|this[offset]<<8;return val&0x8000?val|0xFFFF0000:val;};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24;};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3];};Buffer.prototype.readBigInt64LE=defineBigIntMethod(function readBigInt64LE(offset){offset=offset>>>0;validateNumber(offset,'offset');const first=this[offset];const last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}const val=this[offset+4]+this[offset+5]*2**8+this[offset+6]*2**16+(last<<24);// Overflow
return(BigInt(val)<<BigInt(32))+BigInt(first+this[++offset]*2**8+this[++offset]*2**16+this[++offset]*2**24);});Buffer.prototype.readBigInt64BE=defineBigIntMethod(function readBigInt64BE(offset){offset=offset>>>0;validateNumber(offset,'offset');const first=this[offset];const last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}const val=(first<<24)+// Overflow
this[++offset]*2**16+this[++offset]*2**8+this[++offset];return(BigInt(val)<<BigInt(32))+BigInt(this[++offset]*2**24+this[++offset]*2**16+this[++offset]*2**8+last);});Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4);};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4);};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8);};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8);};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError('Index out of range');}Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){const maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0);}let mul=1;let i=0;this[offset]=value&0xFF;while(++i<byteLength&&(mul*=0x100)){this[offset+i]=value/mul&0xFF;}return offset+byteLength;};Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function writeUIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){const maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0);}let i=byteLength-1;let mul=1;this[offset+i]=value&0xFF;while(--i>=0&&(mul*=0x100)){this[offset+i]=value/mul&0xFF;}return offset+byteLength;};Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,0xff,0);this[offset]=value&0xff;return offset+1;};Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0xffff,0);this[offset]=value&0xff;this[offset+1]=value>>>8;return offset+2;};Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0xffff,0);this[offset]=value>>>8;this[offset+1]=value&0xff;return offset+2;};Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0xffffffff,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&0xff;return offset+4;};Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0xffffffff,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&0xff;return offset+4;};function wrtBigUInt64LE(buf,value,offset,min,max){checkIntBI(value,min,max,buf,offset,7);let lo=Number(value&BigInt(0xffffffff));buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;let hi=Number(value>>BigInt(32)&BigInt(0xffffffff));buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;return offset;}function wrtBigUInt64BE(buf,value,offset,min,max){checkIntBI(value,min,max,buf,offset,7);let lo=Number(value&BigInt(0xffffffff));buf[offset+7]=lo;lo=lo>>8;buf[offset+6]=lo;lo=lo>>8;buf[offset+5]=lo;lo=lo>>8;buf[offset+4]=lo;let hi=Number(value>>BigInt(32)&BigInt(0xffffffff));buf[offset+3]=hi;hi=hi>>8;buf[offset+2]=hi;hi=hi>>8;buf[offset+1]=hi;hi=hi>>8;buf[offset]=hi;return offset+8;}Buffer.prototype.writeBigUInt64LE=defineBigIntMethod(function writeBigUInt64LE(value,offset=0){return wrtBigUInt64LE(this,value,offset,BigInt(0),BigInt('0xffffffffffffffff'));});Buffer.prototype.writeBigUInt64BE=defineBigIntMethod(function writeBigUInt64BE(value,offset=0){return wrtBigUInt64BE(this,value,offset,BigInt(0),BigInt('0xffffffffffffffff'));});Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){const limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit);}let i=0;let mul=1;let sub=0;this[offset]=value&0xFF;while(++i<byteLength&&(mul*=0x100)){if(value<0&&sub===0&&this[offset+i-1]!==0){sub=1;}this[offset+i]=(value/mul>>0)-sub&0xFF;}return offset+byteLength;};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){const limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit);}let i=byteLength-1;let mul=1;let sub=0;this[offset+i]=value&0xFF;while(--i>=0&&(mul*=0x100)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1;}this[offset+i]=(value/mul>>0)-sub&0xFF;}return offset+byteLength;};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,0x7f,-0x80);if(value<0)value=0xff+value+1;this[offset]=value&0xff;return offset+1;};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0x7fff,-0x8000);this[offset]=value&0xff;this[offset+1]=value>>>8;return offset+2;};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0x7fff,-0x8000);this[offset]=value>>>8;this[offset+1]=value&0xff;return offset+2;};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0x7fffffff,-0x80000000);this[offset]=value&0xff;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4;};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0x7fffffff,-0x80000000);if(value<0)value=0xffffffff+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&0xff;return offset+4;};Buffer.prototype.writeBigInt64LE=defineBigIntMethod(function writeBigInt64LE(value,offset=0){return wrtBigUInt64LE(this,value,offset,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'));});Buffer.prototype.writeBigInt64BE=defineBigIntMethod(function writeBigInt64BE(value,offset=0){return wrtBigUInt64BE(this,value,offset,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'));});function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError('Index out of range');if(offset<0)throw new RangeError('Index out of range');}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e+38,-3.4028234663852886e+38);}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4;}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert);};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert);};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157E+308,-1.7976931348623157E+308);}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8;}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert);};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert);};// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError('argument should be a Buffer');if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end<start)end=start;// Copy 0 bytes; we're done
if(end===start)return 0;if(target.length===0||this.length===0)return 0;// Fatal error conditions
if(targetStart<0){throw new RangeError('targetStart out of bounds');}if(start<0||start>=this.length)throw new RangeError('Index out of range');if(end<0)throw new RangeError('sourceEnd out of bounds');// Are we oob?
if(end>this.length)end=this.length;if(target.length-targetStart<end-start){end=target.length-targetStart+start;}const len=end-start;if(this===target&&typeof Uint8Array.prototype.copyWithin==='function'){// Use built-in when available, missing from IE11
this.copyWithin(targetStart,start,end);}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart);}return len;};// Usage:
//    buffer.fill(number[, offset[, end]])
//    buffer.fill(buffer[, offset[, end]])
//    buffer.fill(string[, offset[, end]][, encoding])
Buffer.prototype.fill=function fill(val,start,end,encoding){// Handle string cases:
if(typeof val==='string'){if(typeof start==='string'){encoding=start;start=0;end=this.length;}else if(typeof end==='string'){encoding=end;end=this.length;}if(encoding!==undefined&&typeof encoding!=='string'){throw new TypeError('encoding must be a string');}if(typeof encoding==='string'&&!Buffer.isEncoding(encoding)){throw new TypeError('Unknown encoding: '+encoding);}if(val.length===1){const code=val.charCodeAt(0);if(encoding==='utf8'&&code<128||encoding==='latin1'){// Fast path: If `val` fits into a single byte, use that numeric value.
val=code;}}}else if(typeof val==='number'){val=val&255;}else if(typeof val==='boolean'){val=Number(val);}// Invalid ranges are not set to a default, so can range check early.
if(start<0||this.length<start||this.length<end){throw new RangeError('Out of range index');}if(end<=start){return this;}start=start>>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;let i;if(typeof val==='number'){for(i=start;i<end;++i){this[i]=val;}}else{const bytes=Buffer.isBuffer(val)?val:Buffer.from(val,encoding);const len=bytes.length;if(len===0){throw new TypeError('The value "'+val+'" is invalid for argument "value"');}for(i=0;i<end-start;++i){this[i+start]=bytes[i%len];}}return this;};// CUSTOM ERRORS
// =============
// Simplified versions from Node, changed for Buffer-only usage
const errors={};function E(sym,getMessage,Base){errors[sym]=class NodeError extends Base{constructor(){super();Object.defineProperty(this,'message',{value:getMessage.apply(this,arguments),writable:true,configurable:true});// Add the error code to the name to include it in the stack trace.
this.name=`${this.name} [${sym}]`;// Access the stack to generate the error message including the error code
// from the name.
this.stack;// eslint-disable-line no-unused-expressions
// Reset the name to the actual name.
delete this.name;}get code(){return sym;}set code(value){Object.defineProperty(this,'code',{configurable:true,enumerable:true,value,writable:true});}toString(){return`${this.name} [${sym}]: ${this.message}`;}};}E('ERR_BUFFER_OUT_OF_BOUNDS',function(name){if(name){return`${name} is outside of buffer bounds`;}return'Attempt to access memory outside buffer bounds';},RangeError);E('ERR_INVALID_ARG_TYPE',function(name,actual){return`The "${name}" argument must be of type number. Received type ${typeof actual}`;},TypeError);E('ERR_OUT_OF_RANGE',function(str,range,input){let msg=`The value of "${str}" is out of range.`;let received=input;if(Number.isInteger(input)&&Math.abs(input)>2**32){received=addNumericalSeparator(String(input));}else if(typeof input==='bigint'){received=String(input);if(input>BigInt(2)**BigInt(32)||input<-(BigInt(2)**BigInt(32))){received=addNumericalSeparator(received);}received+='n';}msg+=` It must be ${range}. Received ${received}`;return msg;},RangeError);function addNumericalSeparator(val){let res='';let i=val.length;const start=val[0]==='-'?1:0;for(;i>=start+4;i-=3){res=`_${val.slice(i-3,i)}${res}`;}return`${val.slice(0,i)}${res}`;}// CHECK FUNCTIONS
// ===============
function checkBounds(buf,offset,byteLength){validateNumber(offset,'offset');if(buf[offset]===undefined||buf[offset+byteLength]===undefined){boundsError(offset,buf.length-(byteLength+1));}}function checkIntBI(value,min,max,buf,offset,byteLength){if(value>max||value<min){const n=typeof min==='bigint'?'n':'';let range;if(byteLength>3){if(min===0||min===BigInt(0)){range=`>= 0${n} and < 2${n} ** ${(byteLength+1)*8}${n}`;}else{range=`>= -(2${n} ** ${(byteLength+1)*8-1}${n}) and < 2 ** `+`${(byteLength+1)*8-1}${n}`;}}else{range=`>= ${min}${n} and <= ${max}${n}`;}throw new errors.ERR_OUT_OF_RANGE('value',range,value);}checkBounds(buf,offset,byteLength);}function validateNumber(value,name){if(typeof value!=='number'){throw new errors.ERR_INVALID_ARG_TYPE(name,'number',value);}}function boundsError(value,length,type){if(Math.floor(value)!==value){validateNumber(value,type);throw new errors.ERR_OUT_OF_RANGE(type||'offset','an integer',value);}if(length<0){throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();}throw new errors.ERR_OUT_OF_RANGE(type||'offset',`>= ${type?1:0} and <= ${length}`,value);}// HELPER FUNCTIONS
// ================
const INVALID_BASE64_RE=/[^+/0-9A-Za-z-_]/g;function base64clean(str){// Node takes equal signs as end of the Base64 encoding
str=str.split('=')[0];// Node strips out invalid characters like \n and \t from the string, base64-js does not
str=str.trim().replace(INVALID_BASE64_RE,'');// Node converts strings with length < 2 to ''
if(str.length<2)return'';// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while(str.length%4!==0){str=str+'=';}return str;}function utf8ToBytes(string,units){units=units||Infinity;let codePoint;const length=string.length;let leadSurrogate=null;const bytes=[];for(let i=0;i<length;++i){codePoint=string.charCodeAt(i);// is surrogate component
if(codePoint>0xD7FF&&codePoint<0xE000){// last char was a lead
if(!leadSurrogate){// no lead yet
if(codePoint>0xDBFF){// unexpected trail
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);continue;}else if(i+1===length){// unpaired lead
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);continue;}// valid lead
leadSurrogate=codePoint;continue;}// 2 leads in a row
if(codePoint<0xDC00){if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);leadSurrogate=codePoint;continue;}// valid surrogate pair
codePoint=(leadSurrogate-0xD800<<10|codePoint-0xDC00)+0x10000;}else if(leadSurrogate){// valid bmp char, but last char was a lead
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);}leadSurrogate=null;// encode utf8
if(codePoint<0x80){if((units-=1)<0)break;bytes.push(codePoint);}else if(codePoint<0x800){if((units-=2)<0)break;bytes.push(codePoint>>0x6|0xC0,codePoint&0x3F|0x80);}else if(codePoint<0x10000){if((units-=3)<0)break;bytes.push(codePoint>>0xC|0xE0,codePoint>>0x6&0x3F|0x80,codePoint&0x3F|0x80);}else if(codePoint<0x110000){if((units-=4)<0)break;bytes.push(codePoint>>0x12|0xF0,codePoint>>0xC&0x3F|0x80,codePoint>>0x6&0x3F|0x80,codePoint&0x3F|0x80);}else{throw new Error('Invalid code point');}}return bytes;}function asciiToBytes(str){const byteArray=[];for(let i=0;i<str.length;++i){// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i)&0xFF);}return byteArray;}function utf16leToBytes(str,units){let c,hi,lo;const byteArray=[];for(let i=0;i<str.length;++i){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi);}return byteArray;}function base64ToBytes(str){return base64.toByteArray(base64clean(str));}function blitBuffer(src,dst,offset,length){let i;for(i=0;i<length;++i){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i];}return i;}// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
// the `instanceof` check but they should be treated as of that type.
// See: https://github.com/feross/buffer/issues/166
function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name;}function numberIsNaN(obj){// For IE11 support
return obj!==obj;// eslint-disable-line no-self-compare
}// Create lookup table for `toString('hex')`
// See: https://github.com/feross/buffer/issues/219
const hexSliceLookupTable=function(){const alphabet='0123456789abcdef';const table=new Array(256);for(let i=0;i<16;++i){const i16=i*16;for(let j=0;j<16;++j){table[i16+j]=alphabet[i]+alphabet[j];}}return table;}();// Return not function with Error if BigInt not supported
function defineBigIntMethod(fn){return typeof BigInt==='undefined'?BufferBigIntNotDefined:fn;}function BufferBigIntNotDefined(){throw new Error('BigInt not supported');}

/***/ }),

/***/ 76244:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var bind=__webpack_require__(10539);var $apply=__webpack_require__(84750);var $call=__webpack_require__(51008);var $reflectApply=__webpack_require__(84323);/** @type {import('./actualApply')} */module.exports=$reflectApply||bind.call($call,$apply);

/***/ }),

/***/ 84750:
/***/ (function(module) {

"use strict";
/** @type {import('./functionApply')} */module.exports=Function.prototype.apply;

/***/ }),

/***/ 51008:
/***/ (function(module) {

"use strict";
/** @type {import('./functionCall')} */module.exports=Function.prototype.call;

/***/ }),

/***/ 77434:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var bind=__webpack_require__(10539);var $TypeError=__webpack_require__(93767);var $call=__webpack_require__(51008);var $actualApply=__webpack_require__(76244);/** @type {(args: [Function, thisArg?: unknown, ...args: unknown[]]) => Function} TODO FIXME, find a way to use import('.') */module.exports=function callBindBasic(args){if(args.length<1||typeof args[0]!=='function'){throw new $TypeError('a function is required');}return $actualApply(bind,$call,args);};

/***/ }),

/***/ 84323:
/***/ (function(module) {

"use strict";
/** @type {import('./reflectApply')} */module.exports=typeof Reflect!=='undefined'&&Reflect&&Reflect.apply;

/***/ }),

/***/ 95736:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var GetIntrinsic=__webpack_require__(35049);var callBindBasic=__webpack_require__(77434);/** @type {(thisArg: string, searchString: string, position?: number) => number} */var $indexOf=callBindBasic([GetIntrinsic('%String.prototype.indexOf%')]);/** @type {import('.')} */module.exports=function callBoundIntrinsic(name,allowMissing){/* eslint no-extra-parens: 0 */var intrinsic=/** @type {(this: unknown, ...args: unknown[]) => unknown} */GetIntrinsic(name,!!allowMissing);if(typeof intrinsic==='function'&&$indexOf(name,'.prototype.')>-1){return callBindBasic(/** @type {const} */[intrinsic]);}return intrinsic;};

/***/ }),

/***/ 30708:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var callBind=__webpack_require__(77434);var gOPD=__webpack_require__(37391);var hasProtoAccessor;try{// eslint-disable-next-line no-extra-parens, no-proto
hasProtoAccessor=/** @type {{ __proto__?: typeof Array.prototype }} */[].__proto__===Array.prototype;}catch(e){if(!e||typeof e!=='object'||!('code'in e)||e.code!=='ERR_PROTO_ACCESS'){throw e;}}// eslint-disable-next-line no-extra-parens
var desc=!!hasProtoAccessor&&gOPD&&gOPD(Object.prototype,/** @type {keyof typeof Object.prototype} */'__proto__');var $Object=Object;var $getPrototypeOf=$Object.getPrototypeOf;/** @type {import('./get')} */module.exports=desc&&typeof desc.get==='function'?callBind([desc.get]):typeof $getPrototypeOf==='function'?/** @type {import('./get')} */function getDunder(value){// eslint-disable-next-line eqeqeq
return $getPrototypeOf(value==null?value:$Object(value));}:false;

/***/ }),

/***/ 85835:
/***/ (function(module) {

"use strict";
/** @type {import('.')} */var $defineProperty=Object.defineProperty||false;if($defineProperty){try{$defineProperty({},'a',{value:1});}catch(e){// IE 8 has a broken defineProperty
$defineProperty=false;}}module.exports=$defineProperty;

/***/ }),

/***/ 58809:
/***/ (function(module) {

"use strict";
/** @type {import('./eval')} */module.exports=EvalError;

/***/ }),

/***/ 94067:
/***/ (function(module) {

"use strict";
/** @type {import('.')} */module.exports=Error;

/***/ }),

/***/ 29382:
/***/ (function(module) {

"use strict";
/** @type {import('./range')} */module.exports=RangeError;

/***/ }),

/***/ 52166:
/***/ (function(module) {

"use strict";
/** @type {import('./ref')} */module.exports=ReferenceError;

/***/ }),

/***/ 30816:
/***/ (function(module) {

"use strict";
/** @type {import('./syntax')} */module.exports=SyntaxError;

/***/ }),

/***/ 93767:
/***/ (function(module) {

"use strict";
/** @type {import('./type')} */module.exports=TypeError;

/***/ }),

/***/ 32429:
/***/ (function(module) {

"use strict";
/** @type {import('./uri')} */module.exports=URIError;

/***/ }),

/***/ 85344:
/***/ (function(module) {

"use strict";
/** @type {import('.')} */module.exports=Object;

/***/ }),

/***/ 2301:
/***/ (function(module) {

"use strict";
/* eslint no-invalid-this: 1 */var ERROR_MESSAGE='Function.prototype.bind called on incompatible ';var toStr=Object.prototype.toString;var max=Math.max;var funcType='[object Function]';var concatty=function concatty(a,b){var arr=[];for(var i=0;i<a.length;i+=1){arr[i]=a[i];}for(var j=0;j<b.length;j+=1){arr[j+a.length]=b[j];}return arr;};var slicy=function slicy(arrLike,offset){var arr=[];for(var i=offset||0,j=0;i<arrLike.length;i+=1,j+=1){arr[j]=arrLike[i];}return arr;};var joiny=function(arr,joiner){var str='';for(var i=0;i<arr.length;i+=1){str+=arr[i];if(i+1<arr.length){str+=joiner;}}return str;};module.exports=function bind(that){var target=this;if(typeof target!=='function'||toStr.apply(target)!==funcType){throw new TypeError(ERROR_MESSAGE+target);}var args=slicy(arguments,1);var bound;var binder=function(){if(this instanceof bound){var result=target.apply(this,concatty(args,arguments));if(Object(result)===result){return result;}return this;}return target.apply(that,concatty(args,arguments));};var boundLength=max(0,target.length-args.length);var boundArgs=[];for(var i=0;i<boundLength;i++){boundArgs[i]='$'+i;}bound=Function('binder','return function ('+joiny(boundArgs,',')+'){ return binder.apply(this,arguments); }')(binder);if(target.prototype){var Empty=function Empty(){};Empty.prototype=target.prototype;bound.prototype=new Empty();Empty.prototype=null;}return bound;};

/***/ }),

/***/ 10539:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var implementation=__webpack_require__(2301);module.exports=Function.prototype.bind||implementation;

/***/ }),

/***/ 35049:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var undefined;var $Object=__webpack_require__(85344);var $Error=__webpack_require__(94067);var $EvalError=__webpack_require__(58809);var $RangeError=__webpack_require__(29382);var $ReferenceError=__webpack_require__(52166);var $SyntaxError=__webpack_require__(30816);var $TypeError=__webpack_require__(93767);var $URIError=__webpack_require__(32429);var abs=__webpack_require__(52126);var floor=__webpack_require__(5820);var max=__webpack_require__(73368);var min=__webpack_require__(60966);var pow=__webpack_require__(732);var round=__webpack_require__(10818);var sign=__webpack_require__(93425);var $Function=Function;// eslint-disable-next-line consistent-return
var getEvalledConstructor=function(expressionSyntax){try{return $Function('"use strict"; return ('+expressionSyntax+').constructor;')();}catch(e){}};var $gOPD=__webpack_require__(37391);var $defineProperty=__webpack_require__(85835);var throwTypeError=function(){throw new $TypeError();};var ThrowTypeError=$gOPD?function(){try{// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
arguments.callee;// IE 8 does not throw here
return throwTypeError;}catch(calleeThrows){try{// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
return $gOPD(arguments,'callee').get;}catch(gOPDthrows){return throwTypeError;}}}():throwTypeError;var hasSymbols=__webpack_require__(16019)();var getProto=__webpack_require__(33968);var $ObjectGPO=__webpack_require__(33556);var $ReflectGPO=__webpack_require__(22060);var $apply=__webpack_require__(84750);var $call=__webpack_require__(51008);var needsEval={};var TypedArray=typeof Uint8Array==='undefined'||!getProto?undefined:getProto(Uint8Array);var INTRINSICS={__proto__:null,'%AggregateError%':typeof AggregateError==='undefined'?undefined:AggregateError,'%Array%':Array,'%ArrayBuffer%':typeof ArrayBuffer==='undefined'?undefined:ArrayBuffer,'%ArrayIteratorPrototype%':hasSymbols&&getProto?getProto([][Symbol.iterator]()):undefined,'%AsyncFromSyncIteratorPrototype%':undefined,'%AsyncFunction%':needsEval,'%AsyncGenerator%':needsEval,'%AsyncGeneratorFunction%':needsEval,'%AsyncIteratorPrototype%':needsEval,'%Atomics%':typeof Atomics==='undefined'?undefined:Atomics,'%BigInt%':typeof BigInt==='undefined'?undefined:BigInt,'%BigInt64Array%':typeof BigInt64Array==='undefined'?undefined:BigInt64Array,'%BigUint64Array%':typeof BigUint64Array==='undefined'?undefined:BigUint64Array,'%Boolean%':Boolean,'%DataView%':typeof DataView==='undefined'?undefined:DataView,'%Date%':Date,'%decodeURI%':decodeURI,'%decodeURIComponent%':decodeURIComponent,'%encodeURI%':encodeURI,'%encodeURIComponent%':encodeURIComponent,'%Error%':$Error,'%eval%':eval,// eslint-disable-line no-eval
'%EvalError%':$EvalError,'%Float16Array%':typeof Float16Array==='undefined'?undefined:Float16Array,'%Float32Array%':typeof Float32Array==='undefined'?undefined:Float32Array,'%Float64Array%':typeof Float64Array==='undefined'?undefined:Float64Array,'%FinalizationRegistry%':typeof FinalizationRegistry==='undefined'?undefined:FinalizationRegistry,'%Function%':$Function,'%GeneratorFunction%':needsEval,'%Int8Array%':typeof Int8Array==='undefined'?undefined:Int8Array,'%Int16Array%':typeof Int16Array==='undefined'?undefined:Int16Array,'%Int32Array%':typeof Int32Array==='undefined'?undefined:Int32Array,'%isFinite%':isFinite,'%isNaN%':isNaN,'%IteratorPrototype%':hasSymbols&&getProto?getProto(getProto([][Symbol.iterator]())):undefined,'%JSON%':typeof JSON==='object'?JSON:undefined,'%Map%':typeof Map==='undefined'?undefined:Map,'%MapIteratorPrototype%':typeof Map==='undefined'||!hasSymbols||!getProto?undefined:getProto(new Map()[Symbol.iterator]()),'%Math%':Math,'%Number%':Number,'%Object%':$Object,'%Object.getOwnPropertyDescriptor%':$gOPD,'%parseFloat%':parseFloat,'%parseInt%':parseInt,'%Promise%':typeof Promise==='undefined'?undefined:Promise,'%Proxy%':typeof Proxy==='undefined'?undefined:Proxy,'%RangeError%':$RangeError,'%ReferenceError%':$ReferenceError,'%Reflect%':typeof Reflect==='undefined'?undefined:Reflect,'%RegExp%':RegExp,'%Set%':typeof Set==='undefined'?undefined:Set,'%SetIteratorPrototype%':typeof Set==='undefined'||!hasSymbols||!getProto?undefined:getProto(new Set()[Symbol.iterator]()),'%SharedArrayBuffer%':typeof SharedArrayBuffer==='undefined'?undefined:SharedArrayBuffer,'%String%':String,'%StringIteratorPrototype%':hasSymbols&&getProto?getProto(''[Symbol.iterator]()):undefined,'%Symbol%':hasSymbols?Symbol:undefined,'%SyntaxError%':$SyntaxError,'%ThrowTypeError%':ThrowTypeError,'%TypedArray%':TypedArray,'%TypeError%':$TypeError,'%Uint8Array%':typeof Uint8Array==='undefined'?undefined:Uint8Array,'%Uint8ClampedArray%':typeof Uint8ClampedArray==='undefined'?undefined:Uint8ClampedArray,'%Uint16Array%':typeof Uint16Array==='undefined'?undefined:Uint16Array,'%Uint32Array%':typeof Uint32Array==='undefined'?undefined:Uint32Array,'%URIError%':$URIError,'%WeakMap%':typeof WeakMap==='undefined'?undefined:WeakMap,'%WeakRef%':typeof WeakRef==='undefined'?undefined:WeakRef,'%WeakSet%':typeof WeakSet==='undefined'?undefined:WeakSet,'%Function.prototype.call%':$call,'%Function.prototype.apply%':$apply,'%Object.defineProperty%':$defineProperty,'%Object.getPrototypeOf%':$ObjectGPO,'%Math.abs%':abs,'%Math.floor%':floor,'%Math.max%':max,'%Math.min%':min,'%Math.pow%':pow,'%Math.round%':round,'%Math.sign%':sign,'%Reflect.getPrototypeOf%':$ReflectGPO};if(getProto){try{null.error;// eslint-disable-line no-unused-expressions
}catch(e){// https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
var errorProto=getProto(getProto(e));INTRINSICS['%Error.prototype%']=errorProto;}}var doEval=function doEval(name){var value;if(name==='%AsyncFunction%'){value=getEvalledConstructor('async function () {}');}else if(name==='%GeneratorFunction%'){value=getEvalledConstructor('function* () {}');}else if(name==='%AsyncGeneratorFunction%'){value=getEvalledConstructor('async function* () {}');}else if(name==='%AsyncGenerator%'){var fn=doEval('%AsyncGeneratorFunction%');if(fn){value=fn.prototype;}}else if(name==='%AsyncIteratorPrototype%'){var gen=doEval('%AsyncGenerator%');if(gen&&getProto){value=getProto(gen.prototype);}}INTRINSICS[name]=value;return value;};var LEGACY_ALIASES={__proto__:null,'%ArrayBufferPrototype%':['ArrayBuffer','prototype'],'%ArrayPrototype%':['Array','prototype'],'%ArrayProto_entries%':['Array','prototype','entries'],'%ArrayProto_forEach%':['Array','prototype','forEach'],'%ArrayProto_keys%':['Array','prototype','keys'],'%ArrayProto_values%':['Array','prototype','values'],'%AsyncFunctionPrototype%':['AsyncFunction','prototype'],'%AsyncGenerator%':['AsyncGeneratorFunction','prototype'],'%AsyncGeneratorPrototype%':['AsyncGeneratorFunction','prototype','prototype'],'%BooleanPrototype%':['Boolean','prototype'],'%DataViewPrototype%':['DataView','prototype'],'%DatePrototype%':['Date','prototype'],'%ErrorPrototype%':['Error','prototype'],'%EvalErrorPrototype%':['EvalError','prototype'],'%Float32ArrayPrototype%':['Float32Array','prototype'],'%Float64ArrayPrototype%':['Float64Array','prototype'],'%FunctionPrototype%':['Function','prototype'],'%Generator%':['GeneratorFunction','prototype'],'%GeneratorPrototype%':['GeneratorFunction','prototype','prototype'],'%Int8ArrayPrototype%':['Int8Array','prototype'],'%Int16ArrayPrototype%':['Int16Array','prototype'],'%Int32ArrayPrototype%':['Int32Array','prototype'],'%JSONParse%':['JSON','parse'],'%JSONStringify%':['JSON','stringify'],'%MapPrototype%':['Map','prototype'],'%NumberPrototype%':['Number','prototype'],'%ObjectPrototype%':['Object','prototype'],'%ObjProto_toString%':['Object','prototype','toString'],'%ObjProto_valueOf%':['Object','prototype','valueOf'],'%PromisePrototype%':['Promise','prototype'],'%PromiseProto_then%':['Promise','prototype','then'],'%Promise_all%':['Promise','all'],'%Promise_reject%':['Promise','reject'],'%Promise_resolve%':['Promise','resolve'],'%RangeErrorPrototype%':['RangeError','prototype'],'%ReferenceErrorPrototype%':['ReferenceError','prototype'],'%RegExpPrototype%':['RegExp','prototype'],'%SetPrototype%':['Set','prototype'],'%SharedArrayBufferPrototype%':['SharedArrayBuffer','prototype'],'%StringPrototype%':['String','prototype'],'%SymbolPrototype%':['Symbol','prototype'],'%SyntaxErrorPrototype%':['SyntaxError','prototype'],'%TypedArrayPrototype%':['TypedArray','prototype'],'%TypeErrorPrototype%':['TypeError','prototype'],'%Uint8ArrayPrototype%':['Uint8Array','prototype'],'%Uint8ClampedArrayPrototype%':['Uint8ClampedArray','prototype'],'%Uint16ArrayPrototype%':['Uint16Array','prototype'],'%Uint32ArrayPrototype%':['Uint32Array','prototype'],'%URIErrorPrototype%':['URIError','prototype'],'%WeakMapPrototype%':['WeakMap','prototype'],'%WeakSetPrototype%':['WeakSet','prototype']};var bind=__webpack_require__(10539);var hasOwn=__webpack_require__(1697);var $concat=bind.call($call,Array.prototype.concat);var $spliceApply=bind.call($apply,Array.prototype.splice);var $replace=bind.call($call,String.prototype.replace);var $strSlice=bind.call($call,String.prototype.slice);var $exec=bind.call($call,RegExp.prototype.exec);/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */var rePropName=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;var reEscapeChar=/\\(\\)?/g;/** Used to match backslashes in property paths. */var stringToPath=function stringToPath(string){var first=$strSlice(string,0,1);var last=$strSlice(string,-1);if(first==='%'&&last!=='%'){throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');}else if(last==='%'&&first!=='%'){throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');}var result=[];$replace(string,rePropName,function(match,number,quote,subString){result[result.length]=quote?$replace(subString,reEscapeChar,'$1'):number||match;});return result;};/* end adaptation */var getBaseIntrinsic=function getBaseIntrinsic(name,allowMissing){var intrinsicName=name;var alias;if(hasOwn(LEGACY_ALIASES,intrinsicName)){alias=LEGACY_ALIASES[intrinsicName];intrinsicName='%'+alias[0]+'%';}if(hasOwn(INTRINSICS,intrinsicName)){var value=INTRINSICS[intrinsicName];if(value===needsEval){value=doEval(intrinsicName);}if(typeof value==='undefined'&&!allowMissing){throw new $TypeError('intrinsic '+name+' exists, but is not available. Please file an issue!');}return{alias:alias,name:intrinsicName,value:value};}throw new $SyntaxError('intrinsic '+name+' does not exist!');};module.exports=function GetIntrinsic(name,allowMissing){if(typeof name!=='string'||name.length===0){throw new $TypeError('intrinsic name must be a non-empty string');}if(arguments.length>1&&typeof allowMissing!=='boolean'){throw new $TypeError('"allowMissing" argument must be a boolean');}if($exec(/^%?[^%]*%?$/,name)===null){throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');}var parts=stringToPath(name);var intrinsicBaseName=parts.length>0?parts[0]:'';var intrinsic=getBaseIntrinsic('%'+intrinsicBaseName+'%',allowMissing);var intrinsicRealName=intrinsic.name;var value=intrinsic.value;var skipFurtherCaching=false;var alias=intrinsic.alias;if(alias){intrinsicBaseName=alias[0];$spliceApply(parts,$concat([0,1],alias));}for(var i=1,isOwn=true;i<parts.length;i+=1){var part=parts[i];var first=$strSlice(part,0,1);var last=$strSlice(part,-1);if((first==='"'||first==="'"||first==='`'||last==='"'||last==="'"||last==='`')&&first!==last){throw new $SyntaxError('property names with quotes must have matching quotes');}if(part==='constructor'||!isOwn){skipFurtherCaching=true;}intrinsicBaseName+='.'+part;intrinsicRealName='%'+intrinsicBaseName+'%';if(hasOwn(INTRINSICS,intrinsicRealName)){value=INTRINSICS[intrinsicRealName];}else if(value!=null){if(!(part in value)){if(!allowMissing){throw new $TypeError('base intrinsic for '+name+' exists, but the property is not available.');}return void undefined;}if($gOPD&&i+1>=parts.length){var desc=$gOPD(value,part);isOwn=!!desc;// By convention, when a data property is converted to an accessor
// property to emulate a data property that does not suffer from
// the override mistake, that accessor's getter is marked with
// an `originalValue` property. Here, when we detect this, we
// uphold the illusion by pretending to see that original data
// property, i.e., returning the value rather than the getter
// itself.
if(isOwn&&'get'in desc&&!('originalValue'in desc.get)){value=desc.get;}else{value=value[part];}}else{isOwn=hasOwn(value,part);value=value[part];}if(isOwn&&!skipFurtherCaching){INTRINSICS[intrinsicRealName]=value;}}}return value;};

/***/ }),

/***/ 33556:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $Object=__webpack_require__(85344);/** @type {import('./Object.getPrototypeOf')} */module.exports=$Object.getPrototypeOf||null;

/***/ }),

/***/ 22060:
/***/ (function(module) {

"use strict";
/** @type {import('./Reflect.getPrototypeOf')} */module.exports=typeof Reflect!=='undefined'&&Reflect.getPrototypeOf||null;

/***/ }),

/***/ 33968:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var reflectGetProto=__webpack_require__(22060);var originalGetProto=__webpack_require__(33556);var getDunderProto=__webpack_require__(30708);/** @type {import('.')} */module.exports=reflectGetProto?function getProto(O){// @ts-expect-error TS can't narrow inside a closure, for some reason
return reflectGetProto(O);}:originalGetProto?function getProto(O){if(!O||typeof O!=='object'&&typeof O!=='function'){throw new TypeError('getProto: not an object');}// @ts-expect-error TS can't narrow inside a closure, for some reason
return originalGetProto(O);}:getDunderProto?function getProto(O){// @ts-expect-error TS can't narrow inside a closure, for some reason
return getDunderProto(O);}:null;

/***/ }),

/***/ 4089:
/***/ (function(module) {

"use strict";
/** @type {import('./gOPD')} */module.exports=Object.getOwnPropertyDescriptor;

/***/ }),

/***/ 37391:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
/** @type {import('.')} */var $gOPD=__webpack_require__(4089);if($gOPD){try{$gOPD([],'length');}catch(e){// IE 8 has a broken gOPD
$gOPD=null;}}module.exports=$gOPD;

/***/ }),

/***/ 16019:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var origSymbol=typeof Symbol!=='undefined'&&Symbol;var hasSymbolSham=__webpack_require__(75985);/** @type {import('.')} */module.exports=function hasNativeSymbols(){if(typeof origSymbol!=='function'){return false;}if(typeof Symbol!=='function'){return false;}if(typeof origSymbol('foo')!=='symbol'){return false;}if(typeof Symbol('bar')!=='symbol'){return false;}return hasSymbolSham();};

/***/ }),

/***/ 75985:
/***/ (function(module) {

"use strict";
/** @type {import('./shams')} *//* eslint complexity: [2, 18], max-statements: [2, 33] */module.exports=function hasSymbols(){if(typeof Symbol!=='function'||typeof Object.getOwnPropertySymbols!=='function'){return false;}if(typeof Symbol.iterator==='symbol'){return true;}/** @type {{ [k in symbol]?: unknown }} */var obj={};var sym=Symbol('test');var symObj=Object(sym);if(typeof sym==='string'){return false;}if(Object.prototype.toString.call(sym)!=='[object Symbol]'){return false;}if(Object.prototype.toString.call(symObj)!=='[object Symbol]'){return false;}// temp disabled per https://github.com/ljharb/object.assign/issues/17
// if (sym instanceof Symbol) { return false; }
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
// if (!(symObj instanceof Symbol)) { return false; }
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
var symVal=42;obj[sym]=symVal;for(var _ in obj){return false;}// eslint-disable-line no-restricted-syntax, no-unreachable-loop
if(typeof Object.keys==='function'&&Object.keys(obj).length!==0){return false;}if(typeof Object.getOwnPropertyNames==='function'&&Object.getOwnPropertyNames(obj).length!==0){return false;}var syms=Object.getOwnPropertySymbols(obj);if(syms.length!==1||syms[0]!==sym){return false;}if(!Object.prototype.propertyIsEnumerable.call(obj,sym)){return false;}if(typeof Object.getOwnPropertyDescriptor==='function'){// eslint-disable-next-line no-extra-parens
var descriptor=/** @type {PropertyDescriptor} */Object.getOwnPropertyDescriptor(obj,sym);if(descriptor.value!==symVal||descriptor.enumerable!==true){return false;}}return true;};

/***/ }),

/***/ 1697:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var call=Function.prototype.call;var $hasOwn=Object.prototype.hasOwnProperty;var bind=__webpack_require__(10539);/** @type {import('.')} */module.exports=bind.call(call,$hasOwn);

/***/ }),

/***/ 94087:
/***/ (function(__unused_webpack_module, exports) {

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias;}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity;}else{m=m+Math.pow(2,mLen);e=e-eBias;}return(s?-1:1)*m*Math.pow(2,e-mLen);};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<<eLen)-1;var eBias=eMax>>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax;}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2;}if(e+eBias>=1){value+=rt/c;}else{value+=rt*Math.pow(2,1-eBias);}if(value*c>=2){e++;c/=2;}if(e+eBias>=eMax){m=0;e=eMax;}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias;}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0;}}for(;mLen>=8;buffer[offset+i]=m&0xff,i+=d,m/=256,mLen-=8){}e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&0xff,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128;};

/***/ }),

/***/ 52126:
/***/ (function(module) {

"use strict";
/** @type {import('./abs')} */module.exports=Math.abs;

/***/ }),

/***/ 5820:
/***/ (function(module) {

"use strict";
/** @type {import('./floor')} */module.exports=Math.floor;

/***/ }),

/***/ 75519:
/***/ (function(module) {

"use strict";
/** @type {import('./isNaN')} */module.exports=Number.isNaN||function isNaN(a){return a!==a;};

/***/ }),

/***/ 73368:
/***/ (function(module) {

"use strict";
/** @type {import('./max')} */module.exports=Math.max;

/***/ }),

/***/ 60966:
/***/ (function(module) {

"use strict";
/** @type {import('./min')} */module.exports=Math.min;

/***/ }),

/***/ 732:
/***/ (function(module) {

"use strict";
/** @type {import('./pow')} */module.exports=Math.pow;

/***/ }),

/***/ 10818:
/***/ (function(module) {

"use strict";
/** @type {import('./round')} */module.exports=Math.round;

/***/ }),

/***/ 93425:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $isNaN=__webpack_require__(75519);/** @type {import('./sign')} */module.exports=function sign(number){if($isNaN(number)||number===0){return number;}return number<0?-1:+1;};

/***/ }),

/***/ 73271:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

var hasMap=typeof Map==='function'&&Map.prototype;var mapSizeDescriptor=Object.getOwnPropertyDescriptor&&hasMap?Object.getOwnPropertyDescriptor(Map.prototype,'size'):null;var mapSize=hasMap&&mapSizeDescriptor&&typeof mapSizeDescriptor.get==='function'?mapSizeDescriptor.get:null;var mapForEach=hasMap&&Map.prototype.forEach;var hasSet=typeof Set==='function'&&Set.prototype;var setSizeDescriptor=Object.getOwnPropertyDescriptor&&hasSet?Object.getOwnPropertyDescriptor(Set.prototype,'size'):null;var setSize=hasSet&&setSizeDescriptor&&typeof setSizeDescriptor.get==='function'?setSizeDescriptor.get:null;var setForEach=hasSet&&Set.prototype.forEach;var hasWeakMap=typeof WeakMap==='function'&&WeakMap.prototype;var weakMapHas=hasWeakMap?WeakMap.prototype.has:null;var hasWeakSet=typeof WeakSet==='function'&&WeakSet.prototype;var weakSetHas=hasWeakSet?WeakSet.prototype.has:null;var hasWeakRef=typeof WeakRef==='function'&&WeakRef.prototype;var weakRefDeref=hasWeakRef?WeakRef.prototype.deref:null;var booleanValueOf=Boolean.prototype.valueOf;var objectToString=Object.prototype.toString;var functionToString=Function.prototype.toString;var $match=String.prototype.match;var $slice=String.prototype.slice;var $replace=String.prototype.replace;var $toUpperCase=String.prototype.toUpperCase;var $toLowerCase=String.prototype.toLowerCase;var $test=RegExp.prototype.test;var $concat=Array.prototype.concat;var $join=Array.prototype.join;var $arrSlice=Array.prototype.slice;var $floor=Math.floor;var bigIntValueOf=typeof BigInt==='function'?BigInt.prototype.valueOf:null;var gOPS=Object.getOwnPropertySymbols;var symToString=typeof Symbol==='function'&&typeof Symbol.iterator==='symbol'?Symbol.prototype.toString:null;var hasShammedSymbols=typeof Symbol==='function'&&typeof Symbol.iterator==='object';// ie, `has-tostringtag/shams
var toStringTag=typeof Symbol==='function'&&Symbol.toStringTag&&(typeof Symbol.toStringTag===hasShammedSymbols?'object':'symbol')?Symbol.toStringTag:null;var isEnumerable=Object.prototype.propertyIsEnumerable;var gPO=(typeof Reflect==='function'?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype// eslint-disable-line no-proto
?function(O){return O.__proto__;// eslint-disable-line no-proto
}:null);function addNumericSeparator(num,str){if(num===Infinity||num===-Infinity||num!==num||num&&num>-1000&&num<1000||$test.call(/e/,str)){return str;}var sepRegex=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof num==='number'){var int=num<0?-$floor(-num):$floor(num);// trunc(num)
if(int!==num){var intStr=String(int);var dec=$slice.call(str,intStr.length+1);return $replace.call(intStr,sepRegex,'$&_')+'.'+$replace.call($replace.call(dec,/([0-9]{3})/g,'$&_'),/_$/,'');}}return $replace.call(str,sepRegex,'$&_');}var utilInspect=__webpack_require__(86973);var inspectCustom=utilInspect.custom;var inspectSymbol=isSymbol(inspectCustom)?inspectCustom:null;var quotes={__proto__:null,'double':'"',single:"'"};var quoteREs={__proto__:null,'double':/(["\\])/g,single:/(['\\])/g};module.exports=function inspect_(obj,options,depth,seen){var opts=options||{};if(has(opts,'quoteStyle')&&!has(quotes,opts.quoteStyle)){throw new TypeError('option "quoteStyle" must be "single" or "double"');}if(has(opts,'maxStringLength')&&(typeof opts.maxStringLength==='number'?opts.maxStringLength<0&&opts.maxStringLength!==Infinity:opts.maxStringLength!==null)){throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');}var customInspect=has(opts,'customInspect')?opts.customInspect:true;if(typeof customInspect!=='boolean'&&customInspect!=='symbol'){throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');}if(has(opts,'indent')&&opts.indent!==null&&opts.indent!=='\t'&&!(parseInt(opts.indent,10)===opts.indent&&opts.indent>0)){throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');}if(has(opts,'numericSeparator')&&typeof opts.numericSeparator!=='boolean'){throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');}var numericSeparator=opts.numericSeparator;if(typeof obj==='undefined'){return'undefined';}if(obj===null){return'null';}if(typeof obj==='boolean'){return obj?'true':'false';}if(typeof obj==='string'){return inspectString(obj,opts);}if(typeof obj==='number'){if(obj===0){return Infinity/obj>0?'0':'-0';}var str=String(obj);return numericSeparator?addNumericSeparator(obj,str):str;}if(typeof obj==='bigint'){var bigIntStr=String(obj)+'n';return numericSeparator?addNumericSeparator(obj,bigIntStr):bigIntStr;}var maxDepth=typeof opts.depth==='undefined'?5:opts.depth;if(typeof depth==='undefined'){depth=0;}if(depth>=maxDepth&&maxDepth>0&&typeof obj==='object'){return isArray(obj)?'[Array]':'[Object]';}var indent=getIndent(opts,depth);if(typeof seen==='undefined'){seen=[];}else if(indexOf(seen,obj)>=0){return'[Circular]';}function inspect(value,from,noIndent){if(from){seen=$arrSlice.call(seen);seen.push(from);}if(noIndent){var newOpts={depth:opts.depth};if(has(opts,'quoteStyle')){newOpts.quoteStyle=opts.quoteStyle;}return inspect_(value,newOpts,depth+1,seen);}return inspect_(value,opts,depth+1,seen);}if(typeof obj==='function'&&!isRegExp(obj)){// in older engines, regexes are callable
var name=nameOf(obj);var keys=arrObjKeys(obj,inspect);return'[Function'+(name?': '+name:' (anonymous)')+']'+(keys.length>0?' { '+$join.call(keys,', ')+' }':'');}if(isSymbol(obj)){var symString=hasShammedSymbols?$replace.call(String(obj),/^(Symbol\(.*\))_[^)]*$/,'$1'):symToString.call(obj);return typeof obj==='object'&&!hasShammedSymbols?markBoxed(symString):symString;}if(isElement(obj)){var s='<'+$toLowerCase.call(String(obj.nodeName));var attrs=obj.attributes||[];for(var i=0;i<attrs.length;i++){s+=' '+attrs[i].name+'='+wrapQuotes(quote(attrs[i].value),'double',opts);}s+='>';if(obj.childNodes&&obj.childNodes.length){s+='...';}s+='</'+$toLowerCase.call(String(obj.nodeName))+'>';return s;}if(isArray(obj)){if(obj.length===0){return'[]';}var xs=arrObjKeys(obj,inspect);if(indent&&!singleLineValues(xs)){return'['+indentedJoin(xs,indent)+']';}return'[ '+$join.call(xs,', ')+' ]';}if(isError(obj)){var parts=arrObjKeys(obj,inspect);if(!('cause'in Error.prototype)&&'cause'in obj&&!isEnumerable.call(obj,'cause')){return'{ ['+String(obj)+'] '+$join.call($concat.call('[cause]: '+inspect(obj.cause),parts),', ')+' }';}if(parts.length===0){return'['+String(obj)+']';}return'{ ['+String(obj)+'] '+$join.call(parts,', ')+' }';}if(typeof obj==='object'&&customInspect){if(inspectSymbol&&typeof obj[inspectSymbol]==='function'&&utilInspect){return utilInspect(obj,{depth:maxDepth-depth});}else if(customInspect!=='symbol'&&typeof obj.inspect==='function'){return obj.inspect();}}if(isMap(obj)){var mapParts=[];if(mapForEach){mapForEach.call(obj,function(value,key){mapParts.push(inspect(key,obj,true)+' => '+inspect(value,obj));});}return collectionOf('Map',mapSize.call(obj),mapParts,indent);}if(isSet(obj)){var setParts=[];if(setForEach){setForEach.call(obj,function(value){setParts.push(inspect(value,obj));});}return collectionOf('Set',setSize.call(obj),setParts,indent);}if(isWeakMap(obj)){return weakCollectionOf('WeakMap');}if(isWeakSet(obj)){return weakCollectionOf('WeakSet');}if(isWeakRef(obj)){return weakCollectionOf('WeakRef');}if(isNumber(obj)){return markBoxed(inspect(Number(obj)));}if(isBigInt(obj)){return markBoxed(inspect(bigIntValueOf.call(obj)));}if(isBoolean(obj)){return markBoxed(booleanValueOf.call(obj));}if(isString(obj)){return markBoxed(inspect(String(obj)));}// note: in IE 8, sometimes `global !== window` but both are the prototypes of each other
/* eslint-env browser */if(typeof window!=='undefined'&&obj===window){return'{ [object Window] }';}if(typeof globalThis!=='undefined'&&obj===globalThis||typeof __webpack_require__.g!=='undefined'&&obj===__webpack_require__.g){return'{ [object globalThis] }';}if(!isDate(obj)&&!isRegExp(obj)){var ys=arrObjKeys(obj,inspect);var isPlainObject=gPO?gPO(obj)===Object.prototype:obj instanceof Object||obj.constructor===Object;var protoTag=obj instanceof Object?'':'null prototype';var stringTag=!isPlainObject&&toStringTag&&Object(obj)===obj&&toStringTag in obj?$slice.call(toStr(obj),8,-1):protoTag?'Object':'';var constructorTag=isPlainObject||typeof obj.constructor!=='function'?'':obj.constructor.name?obj.constructor.name+' ':'';var tag=constructorTag+(stringTag||protoTag?'['+$join.call($concat.call([],stringTag||[],protoTag||[]),': ')+'] ':'');if(ys.length===0){return tag+'{}';}if(indent){return tag+'{'+indentedJoin(ys,indent)+'}';}return tag+'{ '+$join.call(ys,', ')+' }';}return String(obj);};function wrapQuotes(s,defaultStyle,opts){var style=opts.quoteStyle||defaultStyle;var quoteChar=quotes[style];return quoteChar+s+quoteChar;}function quote(s){return $replace.call(String(s),/"/g,'&quot;');}function canTrustToString(obj){return!toStringTag||!(typeof obj==='object'&&(toStringTag in obj||typeof obj[toStringTag]!=='undefined'));}function isArray(obj){return toStr(obj)==='[object Array]'&&canTrustToString(obj);}function isDate(obj){return toStr(obj)==='[object Date]'&&canTrustToString(obj);}function isRegExp(obj){return toStr(obj)==='[object RegExp]'&&canTrustToString(obj);}function isError(obj){return toStr(obj)==='[object Error]'&&canTrustToString(obj);}function isString(obj){return toStr(obj)==='[object String]'&&canTrustToString(obj);}function isNumber(obj){return toStr(obj)==='[object Number]'&&canTrustToString(obj);}function isBoolean(obj){return toStr(obj)==='[object Boolean]'&&canTrustToString(obj);}// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
function isSymbol(obj){if(hasShammedSymbols){return obj&&typeof obj==='object'&&obj instanceof Symbol;}if(typeof obj==='symbol'){return true;}if(!obj||typeof obj!=='object'||!symToString){return false;}try{symToString.call(obj);return true;}catch(e){}return false;}function isBigInt(obj){if(!obj||typeof obj!=='object'||!bigIntValueOf){return false;}try{bigIntValueOf.call(obj);return true;}catch(e){}return false;}var hasOwn=Object.prototype.hasOwnProperty||function(key){return key in this;};function has(obj,key){return hasOwn.call(obj,key);}function toStr(obj){return objectToString.call(obj);}function nameOf(f){if(f.name){return f.name;}var m=$match.call(functionToString.call(f),/^function\s*([\w$]+)/);if(m){return m[1];}return null;}function indexOf(xs,x){if(xs.indexOf){return xs.indexOf(x);}for(var i=0,l=xs.length;i<l;i++){if(xs[i]===x){return i;}}return-1;}function isMap(x){if(!mapSize||!x||typeof x!=='object'){return false;}try{mapSize.call(x);try{setSize.call(x);}catch(s){return true;}return x instanceof Map;// core-js workaround, pre-v2.5.0
}catch(e){}return false;}function isWeakMap(x){if(!weakMapHas||!x||typeof x!=='object'){return false;}try{weakMapHas.call(x,weakMapHas);try{weakSetHas.call(x,weakSetHas);}catch(s){return true;}return x instanceof WeakMap;// core-js workaround, pre-v2.5.0
}catch(e){}return false;}function isWeakRef(x){if(!weakRefDeref||!x||typeof x!=='object'){return false;}try{weakRefDeref.call(x);return true;}catch(e){}return false;}function isSet(x){if(!setSize||!x||typeof x!=='object'){return false;}try{setSize.call(x);try{mapSize.call(x);}catch(m){return true;}return x instanceof Set;// core-js workaround, pre-v2.5.0
}catch(e){}return false;}function isWeakSet(x){if(!weakSetHas||!x||typeof x!=='object'){return false;}try{weakSetHas.call(x,weakSetHas);try{weakMapHas.call(x,weakMapHas);}catch(s){return true;}return x instanceof WeakSet;// core-js workaround, pre-v2.5.0
}catch(e){}return false;}function isElement(x){if(!x||typeof x!=='object'){return false;}if(typeof HTMLElement!=='undefined'&&x instanceof HTMLElement){return true;}return typeof x.nodeName==='string'&&typeof x.getAttribute==='function';}function inspectString(str,opts){if(str.length>opts.maxStringLength){var remaining=str.length-opts.maxStringLength;var trailer='... '+remaining+' more character'+(remaining>1?'s':'');return inspectString($slice.call(str,0,opts.maxStringLength),opts)+trailer;}var quoteRE=quoteREs[opts.quoteStyle||'single'];quoteRE.lastIndex=0;// eslint-disable-next-line no-control-regex
var s=$replace.call($replace.call(str,quoteRE,'\\$1'),/[\x00-\x1f]/g,lowbyte);return wrapQuotes(s,'single',opts);}function lowbyte(c){var n=c.charCodeAt(0);var x={8:'b',9:'t',10:'n',12:'f',13:'r'}[n];if(x){return'\\'+x;}return'\\x'+(n<0x10?'0':'')+$toUpperCase.call(n.toString(16));}function markBoxed(str){return'Object('+str+')';}function weakCollectionOf(type){return type+' { ? }';}function collectionOf(type,size,entries,indent){var joinedEntries=indent?indentedJoin(entries,indent):$join.call(entries,', ');return type+' ('+size+') {'+joinedEntries+'}';}function singleLineValues(xs){for(var i=0;i<xs.length;i++){if(indexOf(xs[i],'\n')>=0){return false;}}return true;}function getIndent(opts,depth){var baseIndent;if(opts.indent==='\t'){baseIndent='\t';}else if(typeof opts.indent==='number'&&opts.indent>0){baseIndent=$join.call(Array(opts.indent+1),' ');}else{return null;}return{base:baseIndent,prev:$join.call(Array(depth+1),baseIndent)};}function indentedJoin(xs,indent){if(xs.length===0){return'';}var lineJoiner='\n'+indent.prev+indent.base;return lineJoiner+$join.call(xs,','+lineJoiner)+'\n'+indent.prev;}function arrObjKeys(obj,inspect){var isArr=isArray(obj);var xs=[];if(isArr){xs.length=obj.length;for(var i=0;i<obj.length;i++){xs[i]=has(obj,i)?inspect(obj[i],obj):'';}}var syms=typeof gOPS==='function'?gOPS(obj):[];var symMap;if(hasShammedSymbols){symMap={};for(var k=0;k<syms.length;k++){symMap['$'+syms[k]]=syms[k];}}for(var key in obj){// eslint-disable-line no-restricted-syntax
if(!has(obj,key)){continue;}// eslint-disable-line no-restricted-syntax, no-continue
if(isArr&&String(Number(key))===key&&key<obj.length){continue;}// eslint-disable-line no-restricted-syntax, no-continue
if(hasShammedSymbols&&symMap['$'+key]instanceof Symbol){// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
continue;// eslint-disable-line no-restricted-syntax, no-continue
}else if($test.call(/[^\w$]/,key)){xs.push(inspect(key,obj)+': '+inspect(obj[key],obj));}else{xs.push(key+': '+inspect(obj[key],obj));}}if(typeof gOPS==='function'){for(var j=0;j<syms.length;j++){if(isEnumerable.call(obj,syms[j])){xs.push('['+inspect(syms[j])+']: '+inspect(obj[syms[j]],obj));}}}return xs;}

/***/ }),

/***/ 98869:
/***/ (function(module, exports) {

var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/((e,t)=>{ true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (t),
		__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
		(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
		__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):0;})(this,function r(){var n="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n?n:{};var d,s=!n.document&&!!n.postMessage,a=n.IS_PAPA_WORKER||!1,o={},h=0,v={};function u(e){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},function(e){var t=b(e);t.chunkSize=parseInt(t.chunkSize),e.step||e.chunk||(t.chunkSize=null);this._handle=new i(t),(this._handle.streamer=this)._config=t;}.call(this,e),this.parseChunk=function(t,e){var i=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<i){let e=this._config.newline;e||(r=this._config.quoteChar||'"',e=this._handle.guessLineEndings(t,r)),t=[...t.split(e).slice(i)].join(e);}this.isFirstChunk&&U(this._config.beforeFirstChunk)&&void 0!==(r=this._config.beforeFirstChunk(t))&&(t=r),this.isFirstChunk=!1,this._halted=!1;var i=this._partialLine+t,r=(this._partialLine="",this._handle.parse(i,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){t=r.meta.cursor,i=(this._finished||(this._partialLine=i.substring(t-this._baseIndex),this._baseIndex=t),r&&r.data&&(this._rowCount+=r.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview);if(a)n.postMessage({results:r,workerId:v.WORKER_ID,finished:i});else if(U(this._config.chunk)&&!e){if(this._config.chunk(r,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=r=void 0;}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(r.data),this._completeResults.errors=this._completeResults.errors.concat(r.errors),this._completeResults.meta=r.meta),this._completed||!i||!U(this._config.complete)||r&&r.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),i||r&&r.meta.paused||this._nextChunk(),r;}this._halted=!0;},this._sendError=function(e){U(this._config.error)?this._config.error(e):a&&this._config.error&&n.postMessage({workerId:v.WORKER_ID,error:e,finished:!1});};}function f(e){var r;(e=e||{}).chunkSize||(e.chunkSize=v.RemoteChunkSize),u.call(this,e),this._nextChunk=s?function(){this._readChunk(),this._chunkLoaded();}:function(){this._readChunk();},this.stream=function(e){this._input=e,this._nextChunk();},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(r=new XMLHttpRequest(),this._config.withCredentials&&(r.withCredentials=this._config.withCredentials),s||(r.onload=y(this._chunkLoaded,this),r.onerror=y(this._chunkError,this)),r.open(this._config.downloadRequestBody?"POST":"GET",this._input,!s),this._config.downloadRequestHeaders){var e,t=this._config.downloadRequestHeaders;for(e in t)r.setRequestHeader(e,t[e]);}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,r.setRequestHeader("Range","bytes="+this._start+"-"+i));try{r.send(this._config.downloadRequestBody);}catch(e){this._chunkError(e.message);}s&&0===r.status&&this._chunkError();}},this._chunkLoaded=function(){4===r.readyState&&(r.status<200||400<=r.status?this._chunkError():(this._start+=this._config.chunkSize||r.responseText.length,this._finished=!this._config.chunkSize||this._start>=(e=>null!==(e=e.getResponseHeader("Content-Range"))?parseInt(e.substring(e.lastIndexOf("/")+1)):-1)(r),this.parseChunk(r.responseText)));},this._chunkError=function(e){e=r.statusText||e;this._sendError(new Error(e));};}function l(e){(e=e||{}).chunkSize||(e.chunkSize=v.LocalChunkSize),u.call(this,e);var i,r,n="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,r=e.slice||e.webkitSlice||e.mozSlice,n?((i=new FileReader()).onload=y(this._chunkLoaded,this),i.onerror=y(this._chunkError,this)):i=new FileReaderSync(),this._nextChunk();},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk();},this._readChunk=function(){var e=this._input,t=(this._config.chunkSize&&(t=Math.min(this._start+this._config.chunkSize,this._input.size),e=r.call(e,this._start,t)),i.readAsText(e,this._config.encoding));n||this._chunkLoaded({target:{result:t}});},this._chunkLoaded=function(e){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(e.target.result);},this._chunkError=function(){this._sendError(i.error);};}function c(e){var i;u.call(this,e=e||{}),this.stream=function(e){return i=e,this._nextChunk();},this._nextChunk=function(){var e,t;if(!this._finished)return e=this._config.chunkSize,i=e?(t=i.substring(0,e),i.substring(e)):(t=i,""),this._finished=!i,this.parseChunk(t);};}function p(e){u.call(this,e=e||{});var t=[],i=!0,r=!1;this.pause=function(){u.prototype.pause.apply(this,arguments),this._input.pause();},this.resume=function(){u.prototype.resume.apply(this,arguments),this._input.resume();},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError);},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0);},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):i=!0;},this._streamData=y(function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),i&&(i=!1,this._checkIsFinished(),this.parseChunk(t.shift()));}catch(e){this._streamError(e);}},this),this._streamError=y(function(e){this._streamCleanUp(),this._sendError(e);},this),this._streamEnd=y(function(){this._streamCleanUp(),r=!0,this._streamData("");},this),this._streamCleanUp=y(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError);},this);}function i(m){var n,s,a,t,o=Math.pow(2,53),h=-o,u=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,d=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,i=this,r=0,f=0,l=!1,e=!1,c=[],p={data:[],errors:[],meta:{}};function y(e){return"greedy"===m.skipEmptyLines?""===e.join("").trim():1===e.length&&0===e[0].length;}function g(){if(p&&a&&(k("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+v.DefaultDelimiter+"'"),a=!1),m.skipEmptyLines&&(p.data=p.data.filter(function(e){return!y(e);})),_()){if(p)if(Array.isArray(p.data[0])){for(var e=0;_()&&e<p.data.length;e++)p.data[e].forEach(t);p.data.splice(0,1);}else p.data.forEach(t);function t(e,t){U(m.transformHeader)&&(e=m.transformHeader(e,t)),c.push(e);}}function i(e,t){for(var i=m.header?{}:[],r=0;r<e.length;r++){var n=r,s=e[r],s=((e,t)=>(e=>(m.dynamicTypingFunction&&void 0===m.dynamicTyping[e]&&(m.dynamicTyping[e]=m.dynamicTypingFunction(e)),!0===(m.dynamicTyping[e]||m.dynamicTyping)))(e)?"true"===t||"TRUE"===t||"false"!==t&&"FALSE"!==t&&((e=>{if(u.test(e)){e=parseFloat(e);if(h<e&&e<o)return 1;}})(t)?parseFloat(t):d.test(t)?new Date(t):""===t?null:t):t)(n=m.header?r>=c.length?"__parsed_extra":c[r]:n,s=m.transform?m.transform(s,n):s);"__parsed_extra"===n?(i[n]=i[n]||[],i[n].push(s)):i[n]=s;}return m.header&&(r>c.length?k("FieldMismatch","TooManyFields","Too many fields: expected "+c.length+" fields but parsed "+r,f+t):r<c.length&&k("FieldMismatch","TooFewFields","Too few fields: expected "+c.length+" fields but parsed "+r,f+t)),i;}var r;p&&(m.header||m.dynamicTyping||m.transform)&&(r=1,!p.data.length||Array.isArray(p.data[0])?(p.data=p.data.map(i),r=p.data.length):p.data=i(p.data,0),m.header&&p.meta&&(p.meta.fields=c),f+=r);}function _(){return m.header&&0===c.length;}function k(e,t,i,r){e={type:e,code:t,message:i};void 0!==r&&(e.row=r),p.errors.push(e);}U(m.step)&&(t=m.step,m.step=function(e){p=e,_()?g():(g(),0!==p.data.length&&(r+=e.data.length,m.preview&&r>m.preview?s.abort():(p.data=p.data[0],t(p,i))));}),this.parse=function(e,t,i){var r=m.quoteChar||'"',r=(m.newline||(m.newline=this.guessLineEndings(e,r)),a=!1,m.delimiter?U(m.delimiter)&&(m.delimiter=m.delimiter(e),p.meta.delimiter=m.delimiter):((r=((e,t,i,r,n)=>{var s,a,o,h;n=n||[",","\t","|",";",v.RECORD_SEP,v.UNIT_SEP];for(var u=0;u<n.length;u++){for(var d,f=n[u],l=0,c=0,p=0,g=(o=void 0,new E({comments:r,delimiter:f,newline:t,preview:10}).parse(e)),_=0;_<g.data.length;_++)i&&y(g.data[_])?p++:(d=g.data[_].length,c+=d,void 0===o?o=d:0<d&&(l+=Math.abs(d-o),o=d));0<g.data.length&&(c/=g.data.length-p),(void 0===a||l<=a)&&(void 0===h||h<c)&&1.99<c&&(a=l,s=f,h=c);}return{successful:!!(m.delimiter=s),bestDelimiter:s};})(e,m.newline,m.skipEmptyLines,m.comments,m.delimitersToGuess)).successful?m.delimiter=r.bestDelimiter:(a=!0,m.delimiter=v.DefaultDelimiter),p.meta.delimiter=m.delimiter),b(m));return m.preview&&m.header&&r.preview++,n=e,s=new E(r),p=s.parse(n,t,i),g(),l?{meta:{paused:!0}}:p||{meta:{paused:!1}};},this.paused=function(){return l;},this.pause=function(){l=!0,s.abort(),n=U(m.chunk)?"":n.substring(s.getCharIndex());},this.resume=function(){i.streamer._halted?(l=!1,i.streamer.parseChunk(n,!0)):setTimeout(i.resume,3);},this.aborted=function(){return e;},this.abort=function(){e=!0,s.abort(),p.meta.aborted=!0,U(m.complete)&&m.complete(p),n="";},this.guessLineEndings=function(e,t){e=e.substring(0,1048576);var t=new RegExp(P(t)+"([^]*?)"+P(t),"gm"),i=(e=e.replace(t,"")).split("\r"),t=e.split("\n"),e=1<t.length&&t[0].length<i[0].length;if(1===i.length||e)return"\n";for(var r=0,n=0;n<i.length;n++)"\n"===i[n][0]&&r++;return r>=i.length/2?"\r\n":"\r";};}function P(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");}function E(C){var S=(C=C||{}).delimiter,O=C.newline,x=C.comments,I=C.step,A=C.preview,T=C.fastMode,D=null,L=!1,F=null==C.quoteChar?'"':C.quoteChar,j=F;if(void 0!==C.escapeChar&&(j=C.escapeChar),("string"!=typeof S||-1<v.BAD_DELIMITERS.indexOf(S))&&(S=","),x===S)throw new Error("Comment character same as delimiter");!0===x?x="#":("string"!=typeof x||-1<v.BAD_DELIMITERS.indexOf(x))&&(x=!1),"\n"!==O&&"\r"!==O&&"\r\n"!==O&&(O="\n");var z=0,M=!1;this.parse=function(i,t,r){if("string"!=typeof i)throw new Error("Input must be a string");var n=i.length,e=S.length,s=O.length,a=x.length,o=U(I),h=[],u=[],d=[],f=z=0;if(!i)return w();if(T||!1!==T&&-1===i.indexOf(F)){for(var l=i.split(O),c=0;c<l.length;c++){if(d=l[c],z+=d.length,c!==l.length-1)z+=O.length;else if(r)return w();if(!x||d.substring(0,a)!==x){if(o){if(h=[],k(d.split(S)),R(),M)return w();}else k(d.split(S));if(A&&A<=c)return h=h.slice(0,A),w(!0);}}return w();}for(var p=i.indexOf(S,z),g=i.indexOf(O,z),_=new RegExp(P(j)+P(F),"g"),m=i.indexOf(F,z);;)if(i[z]===F)for(m=z,z++;;){if(-1===(m=i.indexOf(F,m+1)))return r||u.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:h.length,index:z}),E();if(m===n-1)return E(i.substring(z,m).replace(_,F));if(F===j&&i[m+1]===j)m++;else if(F===j||0===m||i[m-1]!==j){-1!==p&&p<m+1&&(p=i.indexOf(S,m+1));var y=v(-1===(g=-1!==g&&g<m+1?i.indexOf(O,m+1):g)?p:Math.min(p,g));if(i.substr(m+1+y,e)===S){d.push(i.substring(z,m).replace(_,F)),i[z=m+1+y+e]!==F&&(m=i.indexOf(F,z)),p=i.indexOf(S,z),g=i.indexOf(O,z);break;}y=v(g);if(i.substring(m+1+y,m+1+y+s)===O){if(d.push(i.substring(z,m).replace(_,F)),b(m+1+y+s),p=i.indexOf(S,z),m=i.indexOf(F,z),o&&(R(),M))return w();if(A&&h.length>=A)return w(!0);break;}u.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:h.length,index:z}),m++;}}else if(x&&0===d.length&&i.substring(z,z+a)===x){if(-1===g)return w();z=g+s,g=i.indexOf(O,z),p=i.indexOf(S,z);}else if(-1!==p&&(p<g||-1===g))d.push(i.substring(z,p)),z=p+e,p=i.indexOf(S,z);else{if(-1===g)break;if(d.push(i.substring(z,g)),b(g+s),o&&(R(),M))return w();if(A&&h.length>=A)return w(!0);}return E();function k(e){h.push(e),f=z;}function v(e){var t=0;return t=-1!==e&&(e=i.substring(m+1,e))&&""===e.trim()?e.length:t;}function E(e){return r||(void 0===e&&(e=i.substring(z)),d.push(e),z=n,k(d),o&&R()),w();}function b(e){z=e,k(d),d=[],g=i.indexOf(O,z);}function w(e){if(C.header&&!t&&h.length&&!L){var s=h[0],a=Object.create(null),o=new Set(s);let n=!1;for(let r=0;r<s.length;r++){let i=s[r];if(a[i=U(C.transformHeader)?C.transformHeader(i,r):i]){let e,t=a[i];for(;e=i+"_"+t,t++,o.has(e););o.add(e),s[r]=e,a[i]++,n=!0,(D=null===D?{}:D)[e]=i;}else a[i]=1,s[r]=i;o.add(i);}n&&console.warn("Duplicate headers found and renamed."),L=!0;}return{data:h,errors:u,meta:{delimiter:S,linebreak:O,aborted:M,truncated:!!e,cursor:f+(t||0),renamedHeaders:D}};}function R(){I(w()),h=[],u=[];}},this.abort=function(){M=!0;},this.getCharIndex=function(){return z;};}function g(e){var t=e.data,i=o[t.workerId],r=!1;if(t.error)i.userError(t.error,t.file);else if(t.results&&t.results.data){var n={abort:function(){r=!0,_(t.workerId,{data:[],errors:[],meta:{aborted:!0}});},pause:m,resume:m};if(U(i.userStep)){for(var s=0;s<t.results.data.length&&(i.userStep({data:t.results.data[s],errors:t.results.errors,meta:t.results.meta},n),!r);s++);delete t.results;}else U(i.userChunk)&&(i.userChunk(t.results,n,t.file),delete t.results);}t.finished&&!r&&_(t.workerId,t.results);}function _(e,t){var i=o[e];U(i.userComplete)&&i.userComplete(t),i.terminate(),delete o[e];}function m(){throw new Error("Not implemented.");}function b(e){if("object"!=typeof e||null===e)return e;var t,i=Array.isArray(e)?[]:{};for(t in e)i[t]=b(e[t]);return i;}function y(e,t){return function(){e.apply(t,arguments);};}function U(e){return"function"==typeof e;}return v.parse=function(e,t){var i=(t=t||{}).dynamicTyping||!1;U(i)&&(t.dynamicTypingFunction=i,i={});if(t.dynamicTyping=i,t.transform=!!U(t.transform)&&t.transform,!t.worker||!v.WORKERS_SUPPORTED)return i=null,v.NODE_STREAM_INPUT,"string"==typeof e?(e=(e=>65279!==e.charCodeAt(0)?e:e.slice(1))(e),i=new(t.download?f:c)(t)):!0===e.readable&&U(e.read)&&U(e.on)?i=new p(t):(n.File&&e instanceof File||e instanceof Object)&&(i=new l(t)),i.stream(e);(i=(()=>{var e;return!!v.WORKERS_SUPPORTED&&(e=(()=>{var e=n.URL||n.webkitURL||null,t=r.toString();return v.BLOB_URL||(v.BLOB_URL=e.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",t,")();"],{type:"text/javascript"})));})(),(e=new n.Worker(e)).onmessage=g,e.id=h++,o[e.id]=e);})()).userStep=t.step,i.userChunk=t.chunk,i.userComplete=t.complete,i.userError=t.error,t.step=U(t.step),t.chunk=U(t.chunk),t.complete=U(t.complete),t.error=U(t.error),delete t.worker,i.postMessage({input:e,config:t,workerId:i.id});},v.unparse=function(e,t){var n=!1,_=!0,m=",",y="\r\n",s='"',a=s+s,i=!1,r=null,o=!1,h=((()=>{if("object"==typeof t){if("string"!=typeof t.delimiter||v.BAD_DELIMITERS.filter(function(e){return-1!==t.delimiter.indexOf(e);}).length||(m=t.delimiter),"boolean"!=typeof t.quotes&&"function"!=typeof t.quotes&&!Array.isArray(t.quotes)||(n=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(i=t.skipEmptyLines),"string"==typeof t.newline&&(y=t.newline),"string"==typeof t.quoteChar&&(s=t.quoteChar),"boolean"==typeof t.header&&(_=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");r=t.columns;}void 0!==t.escapeChar&&(a=t.escapeChar+s),t.escapeFormulae instanceof RegExp?o=t.escapeFormulae:"boolean"==typeof t.escapeFormulae&&t.escapeFormulae&&(o=/^[=+\-@\t\r].*$/);}})(),new RegExp(P(s),"g"));"string"==typeof e&&(e=JSON.parse(e));if(Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return u(null,e,i);if("object"==typeof e[0])return u(r||Object.keys(e[0]),e,i);}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||r),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),u(e.fields||[],e.data||[],i);throw new Error("Unable to serialize unrecognized input");function u(e,t,i){var r="",n=("string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t)),Array.isArray(e)&&0<e.length),s=!Array.isArray(t[0]);if(n&&_){for(var a=0;a<e.length;a++)0<a&&(r+=m),r+=k(e[a],a);0<t.length&&(r+=y);}for(var o=0;o<t.length;o++){var h=(n?e:t[o]).length,u=!1,d=n?0===Object.keys(t[o]).length:0===t[o].length;if(i&&!n&&(u="greedy"===i?""===t[o].join("").trim():1===t[o].length&&0===t[o][0].length),"greedy"===i&&n){for(var f=[],l=0;l<h;l++){var c=s?e[l]:l;f.push(t[o][c]);}u=""===f.join("").trim();}if(!u){for(var p=0;p<h;p++){0<p&&!d&&(r+=m);var g=n&&s?e[p]:p;r+=k(t[o][g],p);}o<t.length-1&&(!i||0<h&&!d)&&(r+=y);}}return r;}function k(e,t){var i,r;return null==e?"":e.constructor===Date?JSON.stringify(e).slice(1,25):(r=!1,o&&"string"==typeof e&&o.test(e)&&(e="'"+e,r=!0),i=e.toString().replace(h,a),(r=r||!0===n||"function"==typeof n&&n(e,t)||Array.isArray(n)&&n[t]||((e,t)=>{for(var i=0;i<t.length;i++)if(-1<e.indexOf(t[i]))return!0;return!1;})(i,v.BAD_DELIMITERS)||-1<i.indexOf(m)||" "===i.charAt(0)||" "===i.charAt(i.length-1))?s+i+s:i);}},v.RECORD_SEP=String.fromCharCode(30),v.UNIT_SEP=String.fromCharCode(31),v.BYTE_ORDER_MARK="\ufeff",v.BAD_DELIMITERS=["\r","\n",'"',v.BYTE_ORDER_MARK],v.WORKERS_SUPPORTED=!s&&!!n.Worker,v.NODE_STREAM_INPUT=1,v.LocalChunkSize=10485760,v.RemoteChunkSize=5242880,v.DefaultDelimiter=",",v.Parser=E,v.ParserHandle=i,v.NetworkStreamer=f,v.FileStreamer=l,v.StringStreamer=c,v.ReadableStreamStreamer=p,n.jQuery&&((d=n.jQuery).fn.parse=function(o){var i=o.config||{},h=[];return this.each(function(e){if(!("INPUT"===d(this).prop("tagName").toUpperCase()&&"file"===d(this).attr("type").toLowerCase()&&n.FileReader)||!this.files||0===this.files.length)return!0;for(var t=0;t<this.files.length;t++)h.push({file:this.files[t],inputElem:this,instanceConfig:d.extend({},i)});}),e(),this;function e(){if(0===h.length)U(o.complete)&&o.complete();else{var e,t,i,r,n=h[0];if(U(o.before)){var s=o.before(n.file,n.inputElem);if("object"==typeof s){if("abort"===s.action)return e="AbortError",t=n.file,i=n.inputElem,r=s.reason,void(U(o.error)&&o.error({name:e},t,i,r));if("skip"===s.action)return void u();"object"==typeof s.config&&(n.instanceConfig=d.extend(n.instanceConfig,s.config));}else if("skip"===s)return void u();}var a=n.instanceConfig.complete;n.instanceConfig.complete=function(e){U(a)&&a(e,n.file,n.inputElem),u();},v.parse(n.file,n.instanceConfig);}}function u(){h.splice(0,1),e();}}),a&&(n.onmessage=function(e){e=e.data;void 0===v.WORKER_ID&&e&&(v.WORKER_ID=e.workerId);"string"==typeof e.input?n.postMessage({workerId:v.WORKER_ID,results:v.parse(e.input,e.config),finished:!0}):(n.File&&e.input instanceof File||e.input instanceof Object)&&(e=v.parse(e.input,e.config))&&n.postMessage({workerId:v.WORKER_ID,results:e,finished:!0});}),(f.prototype=Object.create(u.prototype)).constructor=f,(l.prototype=Object.create(u.prototype)).constructor=l,(c.prototype=Object.create(c.prototype)).constructor=c,(p.prototype=Object.create(u.prototype)).constructor=p,v;});

/***/ }),

/***/ 58803:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
/* provided dependency */ var process = __webpack_require__(45202);
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
// transplited with Babel
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function assertPath(path){if(typeof path!=='string'){throw new TypeError('Path must be a string. Received '+JSON.stringify(path));}}// Resolves . and .. elements in a path with directory names
function normalizeStringPosix(path,allowAboveRoot){var res='';var lastSegmentLength=0;var lastSlash=-1;var dots=0;var code;for(var i=0;i<=path.length;++i){if(i<path.length)code=path.charCodeAt(i);else if(code===47/*/*/)break;else code=47/*/*/;if(code===47/*/*/){if(lastSlash===i-1||dots===1){// NOOP
}else if(lastSlash!==i-1&&dots===2){if(res.length<2||lastSegmentLength!==2||res.charCodeAt(res.length-1)!==46/*.*/||res.charCodeAt(res.length-2)!==46/*.*/){if(res.length>2){var lastSlashIndex=res.lastIndexOf('/');if(lastSlashIndex!==res.length-1){if(lastSlashIndex===-1){res='';lastSegmentLength=0;}else{res=res.slice(0,lastSlashIndex);lastSegmentLength=res.length-1-res.lastIndexOf('/');}lastSlash=i;dots=0;continue;}}else if(res.length===2||res.length===1){res='';lastSegmentLength=0;lastSlash=i;dots=0;continue;}}if(allowAboveRoot){if(res.length>0)res+='/..';else res='..';lastSegmentLength=2;}}else{if(res.length>0)res+='/'+path.slice(lastSlash+1,i);else res=path.slice(lastSlash+1,i);lastSegmentLength=i-lastSlash-1;}lastSlash=i;dots=0;}else if(code===46/*.*/&&dots!==-1){++dots;}else{dots=-1;}}return res;}function _format(sep,pathObject){var dir=pathObject.dir||pathObject.root;var base=pathObject.base||(pathObject.name||'')+(pathObject.ext||'');if(!dir){return base;}if(dir===pathObject.root){return dir+base;}return dir+sep+base;}var posix={// path.resolve([from ...], to)
resolve:function resolve(){var resolvedPath='';var resolvedAbsolute=false;var cwd;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path;if(i>=0)path=arguments[i];else{if(cwd===undefined)cwd=process.cwd();path=cwd;}assertPath(path);// Skip empty entries
if(path.length===0){continue;}resolvedPath=path+'/'+resolvedPath;resolvedAbsolute=path.charCodeAt(0)===47/*/*/;}// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath=normalizeStringPosix(resolvedPath,!resolvedAbsolute);if(resolvedAbsolute){if(resolvedPath.length>0)return'/'+resolvedPath;else return'/';}else if(resolvedPath.length>0){return resolvedPath;}else{return'.';}},normalize:function normalize(path){assertPath(path);if(path.length===0)return'.';var isAbsolute=path.charCodeAt(0)===47/*/*/;var trailingSeparator=path.charCodeAt(path.length-1)===47/*/*/;// Normalize the path
path=normalizeStringPosix(path,!isAbsolute);if(path.length===0&&!isAbsolute)path='.';if(path.length>0&&trailingSeparator)path+='/';if(isAbsolute)return'/'+path;return path;},isAbsolute:function isAbsolute(path){assertPath(path);return path.length>0&&path.charCodeAt(0)===47/*/*/;},join:function join(){if(arguments.length===0)return'.';var joined;for(var i=0;i<arguments.length;++i){var arg=arguments[i];assertPath(arg);if(arg.length>0){if(joined===undefined)joined=arg;else joined+='/'+arg;}}if(joined===undefined)return'.';return posix.normalize(joined);},relative:function relative(from,to){assertPath(from);assertPath(to);if(from===to)return'';from=posix.resolve(from);to=posix.resolve(to);if(from===to)return'';// Trim any leading backslashes
var fromStart=1;for(;fromStart<from.length;++fromStart){if(from.charCodeAt(fromStart)!==47/*/*/)break;}var fromEnd=from.length;var fromLen=fromEnd-fromStart;// Trim any leading backslashes
var toStart=1;for(;toStart<to.length;++toStart){if(to.charCodeAt(toStart)!==47/*/*/)break;}var toEnd=to.length;var toLen=toEnd-toStart;// Compare paths to find the longest common path from root
var length=fromLen<toLen?fromLen:toLen;var lastCommonSep=-1;var i=0;for(;i<=length;++i){if(i===length){if(toLen>length){if(to.charCodeAt(toStart+i)===47/*/*/){// We get here if `from` is the exact base path for `to`.
// For example: from='/foo/bar'; to='/foo/bar/baz'
return to.slice(toStart+i+1);}else if(i===0){// We get here if `from` is the root
// For example: from='/'; to='/foo'
return to.slice(toStart+i);}}else if(fromLen>length){if(from.charCodeAt(fromStart+i)===47/*/*/){// We get here if `to` is the exact base path for `from`.
// For example: from='/foo/bar/baz'; to='/foo/bar'
lastCommonSep=i;}else if(i===0){// We get here if `to` is the root.
// For example: from='/foo'; to='/'
lastCommonSep=0;}}break;}var fromCode=from.charCodeAt(fromStart+i);var toCode=to.charCodeAt(toStart+i);if(fromCode!==toCode)break;else if(fromCode===47/*/*/)lastCommonSep=i;}var out='';// Generate the relative path based on the path difference between `to`
// and `from`
for(i=fromStart+lastCommonSep+1;i<=fromEnd;++i){if(i===fromEnd||from.charCodeAt(i)===47/*/*/){if(out.length===0)out+='..';else out+='/..';}}// Lastly, append the rest of the destination (`to`) path that comes after
// the common path parts
if(out.length>0)return out+to.slice(toStart+lastCommonSep);else{toStart+=lastCommonSep;if(to.charCodeAt(toStart)===47/*/*/)++toStart;return to.slice(toStart);}},_makeLong:function _makeLong(path){return path;},dirname:function dirname(path){assertPath(path);if(path.length===0)return'.';var code=path.charCodeAt(0);var hasRoot=code===47/*/*/;var end=-1;var matchedSlash=true;for(var i=path.length-1;i>=1;--i){code=path.charCodeAt(i);if(code===47/*/*/){if(!matchedSlash){end=i;break;}}else{// We saw the first non-path separator
matchedSlash=false;}}if(end===-1)return hasRoot?'/':'.';if(hasRoot&&end===1)return'//';return path.slice(0,end);},basename:function basename(path,ext){if(ext!==undefined&&typeof ext!=='string')throw new TypeError('"ext" argument must be a string');assertPath(path);var start=0;var end=-1;var matchedSlash=true;var i;if(ext!==undefined&&ext.length>0&&ext.length<=path.length){if(ext.length===path.length&&ext===path)return'';var extIdx=ext.length-1;var firstNonSlashEnd=-1;for(i=path.length-1;i>=0;--i){var code=path.charCodeAt(i);if(code===47/*/*/){// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if(!matchedSlash){start=i+1;break;}}else{if(firstNonSlashEnd===-1){// We saw the first non-path separator, remember this index in case
// we need it if the extension ends up not matching
matchedSlash=false;firstNonSlashEnd=i+1;}if(extIdx>=0){// Try to match the explicit extension
if(code===ext.charCodeAt(extIdx)){if(--extIdx===-1){// We matched the extension, so mark this as the end of our path
// component
end=i;}}else{// Extension does not match, so our result is the entire path
// component
extIdx=-1;end=firstNonSlashEnd;}}}}if(start===end)end=firstNonSlashEnd;else if(end===-1)end=path.length;return path.slice(start,end);}else{for(i=path.length-1;i>=0;--i){if(path.charCodeAt(i)===47/*/*/){// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if(!matchedSlash){start=i+1;break;}}else if(end===-1){// We saw the first non-path separator, mark this as the end of our
// path component
matchedSlash=false;end=i+1;}}if(end===-1)return'';return path.slice(start,end);}},extname:function extname(path){assertPath(path);var startDot=-1;var startPart=0;var end=-1;var matchedSlash=true;// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
var preDotState=0;for(var i=path.length-1;i>=0;--i){var code=path.charCodeAt(i);if(code===47/*/*/){// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if(!matchedSlash){startPart=i+1;break;}continue;}if(end===-1){// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash=false;end=i+1;}if(code===46/*.*/){// If this is our first dot, mark it as the start of our extension
if(startDot===-1)startDot=i;else if(preDotState!==1)preDotState=1;}else if(startDot!==-1){// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState=-1;}}if(startDot===-1||end===-1||// We saw a non-dot character immediately before the dot
preDotState===0||// The (right-most) trimmed path component is exactly '..'
preDotState===1&&startDot===end-1&&startDot===startPart+1){return'';}return path.slice(startDot,end);},format:function format(pathObject){if(pathObject===null||typeof pathObject!=='object'){throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof pathObject);}return _format('/',pathObject);},parse:function parse(path){assertPath(path);var ret={root:'',dir:'',base:'',ext:'',name:''};if(path.length===0)return ret;var code=path.charCodeAt(0);var isAbsolute=code===47/*/*/;var start;if(isAbsolute){ret.root='/';start=1;}else{start=0;}var startDot=-1;var startPart=0;var end=-1;var matchedSlash=true;var i=path.length-1;// Track the state of characters (if any) we see before our first dot and
// after any path separator we find
var preDotState=0;// Get non-dir info
for(;i>=start;--i){code=path.charCodeAt(i);if(code===47/*/*/){// If we reached a path separator that was not part of a set of path
// separators at the end of the string, stop now
if(!matchedSlash){startPart=i+1;break;}continue;}if(end===-1){// We saw the first non-path separator, mark this as the end of our
// extension
matchedSlash=false;end=i+1;}if(code===46/*.*/){// If this is our first dot, mark it as the start of our extension
if(startDot===-1)startDot=i;else if(preDotState!==1)preDotState=1;}else if(startDot!==-1){// We saw a non-dot and non-path separator before our dot, so we should
// have a good chance at having a non-empty extension
preDotState=-1;}}if(startDot===-1||end===-1||// We saw a non-dot character immediately before the dot
preDotState===0||// The (right-most) trimmed path component is exactly '..'
preDotState===1&&startDot===end-1&&startDot===startPart+1){if(end!==-1){if(startPart===0&&isAbsolute)ret.base=ret.name=path.slice(1,end);else ret.base=ret.name=path.slice(startPart,end);}}else{if(startPart===0&&isAbsolute){ret.name=path.slice(1,startDot);ret.base=path.slice(1,end);}else{ret.name=path.slice(startPart,startDot);ret.base=path.slice(startPart,end);}ret.ext=path.slice(startDot,end);}if(startPart>0)ret.dir=path.slice(0,startPart-1);else if(isAbsolute)ret.dir='/';return ret;},sep:'/',delimiter:':',win32:null,posix:null};posix.posix=posix;module.exports=posix;

/***/ }),

/***/ 45202:
/***/ (function(module) {

// shim for using process in browser
var process=module.exports={};// cached from whatever global is present so that test runners that stub it
// don't break things.  But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals.  It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;var cachedClearTimeout;function defaultSetTimout(){throw new Error('setTimeout has not been defined');}function defaultClearTimeout(){throw new Error('clearTimeout has not been defined');}(function(){try{if(typeof setTimeout==='function'){cachedSetTimeout=setTimeout;}else{cachedSetTimeout=defaultSetTimout;}}catch(e){cachedSetTimeout=defaultSetTimout;}try{if(typeof clearTimeout==='function'){cachedClearTimeout=clearTimeout;}else{cachedClearTimeout=defaultClearTimeout;}}catch(e){cachedClearTimeout=defaultClearTimeout;}})();function runTimeout(fun){if(cachedSetTimeout===setTimeout){//normal enviroments in sane situations
return setTimeout(fun,0);}// if setTimeout wasn't available but was latter defined
if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout){cachedSetTimeout=setTimeout;return setTimeout(fun,0);}try{// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun,0);}catch(e){try{// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null,fun,0);}catch(e){// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this,fun,0);}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout){//normal enviroments in sane situations
return clearTimeout(marker);}// if clearTimeout wasn't available but was latter defined
if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout){cachedClearTimeout=clearTimeout;return clearTimeout(marker);}try{// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);}catch(e){try{// When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
return cachedClearTimeout.call(null,marker);}catch(e){// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this,marker);}}}var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return;}draining=false;if(currentQueue.length){queue=currentQueue.concat(queue);}else{queueIndex=-1;}if(queue.length){drainQueue();}}function drainQueue(){if(draining){return;}var timeout=runTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run();}}queueIndex=-1;len=queue.length;}currentQueue=null;draining=false;runClearTimeout(timeout);}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i];}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){runTimeout(drainQueue);}};// v8 likes predictible objects
function Item(fun,array){this.fun=fun;this.array=array;}Item.prototype.run=function(){this.fun.apply(null,this.array);};process.title='browser';process.browser=true;process.env={};process.argv=[];process.version='';// empty string to avoid regexp issues
process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.prependListener=noop;process.prependOnceListener=noop;process.listeners=function(name){return[];};process.binding=function(name){throw new Error('process.binding is not supported');};process.cwd=function(){return'/';};process.chdir=function(dir){throw new Error('process.chdir is not supported');};process.umask=function(){return 0;};

/***/ }),

/***/ 90791:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   decode: function() { return /* binding */ decode; },
/* harmony export */   encode: function() { return /* binding */ encode; },
/* harmony export */   toASCII: function() { return /* binding */ toASCII; },
/* harmony export */   toUnicode: function() { return /* binding */ toUnicode; },
/* harmony export */   ucs2decode: function() { return /* binding */ ucs2decode; },
/* harmony export */   ucs2encode: function() { return /* binding */ ucs2encode; }
/* harmony export */ });
/** Highest positive signed 32-bit float value */const maxInt=2147483647;// aka. 0x7FFFFFFF or 2^31-1
/** Bootstring parameters */const base=36;const tMin=1;const tMax=26;const skew=38;const damp=700;const initialBias=72;const initialN=128;// 0x80
const delimiter='-';// '\x2D'
/** Regular expressions */const regexPunycode=/^xn--/;const regexNonASCII=/[^\0-\x7F]/;// Note: U+007F DEL is excluded too.
const regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g;// RFC 3490 separators
/** Error messages */const errors={'overflow':'Overflow: input needs wider integers to process','not-basic':'Illegal input >= 0x80 (not a basic code point)','invalid-input':'Invalid input'};/** Convenience shortcuts */const baseMinusTMin=base-tMin;const floor=Math.floor;const stringFromCharCode=String.fromCharCode;/*--------------------------------------------------------------------------*//**
 * A generic error utility function.
 * @private
 * @param {String} type The error type.
 * @returns {Error} Throws a `RangeError` with the applicable error message.
 */function error(type){throw new RangeError(errors[type]);}/**
 * A generic `Array#map` utility function.
 * @private
 * @param {Array} array The array to iterate over.
 * @param {Function} callback The function that gets called for every array
 * item.
 * @returns {Array} A new array of values returned by the callback function.
 */function map(array,callback){const result=[];let length=array.length;while(length--){result[length]=callback(array[length]);}return result;}/**
 * A simple `Array#map`-like wrapper to work with domain name strings or email
 * addresses.
 * @private
 * @param {String} domain The domain name or email address.
 * @param {Function} callback The function that gets called for every
 * character.
 * @returns {String} A new string of characters returned by the callback
 * function.
 */function mapDomain(domain,callback){const parts=domain.split('@');let result='';if(parts.length>1){// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result=parts[0]+'@';domain=parts[1];}// Avoid `split(regex)` for IE8 compatibility. See #17.
domain=domain.replace(regexSeparators,'\x2E');const labels=domain.split('.');const encoded=map(labels,callback).join('.');return result+encoded;}/**
 * Creates an array containing the numeric code points of each Unicode
 * character in the string. While JavaScript uses UCS-2 internally,
 * this function will convert a pair of surrogate halves (each of which
 * UCS-2 exposes as separate characters) into a single code point,
 * matching UTF-16.
 * @see `punycode.ucs2.encode`
 * @see <https://mathiasbynens.be/notes/javascript-encoding>
 * @memberOf punycode.ucs2
 * @name decode
 * @param {String} string The Unicode input string (UCS-2).
 * @returns {Array} The new array of code points.
 */function ucs2decode(string){const output=[];let counter=0;const length=string.length;while(counter<length){const value=string.charCodeAt(counter++);if(value>=0xD800&&value<=0xDBFF&&counter<length){// It's a high surrogate, and there is a next character.
const extra=string.charCodeAt(counter++);if((extra&0xFC00)==0xDC00){// Low surrogate.
output.push(((value&0x3FF)<<10)+(extra&0x3FF)+0x10000);}else{// It's an unmatched surrogate; only append this code unit, in case the
// next code unit is the high surrogate of a surrogate pair.
output.push(value);counter--;}}else{output.push(value);}}return output;}/**
 * Creates a string based on an array of numeric code points.
 * @see `punycode.ucs2.decode`
 * @memberOf punycode.ucs2
 * @name encode
 * @param {Array} codePoints The array of numeric code points.
 * @returns {String} The new Unicode string (UCS-2).
 */const ucs2encode=codePoints=>String.fromCodePoint(...codePoints);/**
 * Converts a basic code point into a digit/integer.
 * @see `digitToBasic()`
 * @private
 * @param {Number} codePoint The basic numeric code point value.
 * @returns {Number} The numeric value of a basic code point (for use in
 * representing integers) in the range `0` to `base - 1`, or `base` if
 * the code point does not represent a value.
 */const basicToDigit=function(codePoint){if(codePoint>=0x30&&codePoint<0x3A){return 26+(codePoint-0x30);}if(codePoint>=0x41&&codePoint<0x5B){return codePoint-0x41;}if(codePoint>=0x61&&codePoint<0x7B){return codePoint-0x61;}return base;};/**
 * Converts a digit/integer into a basic code point.
 * @see `basicToDigit()`
 * @private
 * @param {Number} digit The numeric value of a basic code point.
 * @returns {Number} The basic code point whose value (when used for
 * representing integers) is `digit`, which needs to be in the range
 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
 * used; else, the lowercase form is used. The behavior is undefined
 * if `flag` is non-zero and `digit` has no uppercase form.
 */const digitToBasic=function(digit,flag){//  0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9
return digit+22+75*(digit<26)-((flag!=0)<<5);};/**
 * Bias adaptation function as per section 3.4 of RFC 3492.
 * https://tools.ietf.org/html/rfc3492#section-3.4
 * @private
 */const adapt=function(delta,numPoints,firstTime){let k=0;delta=firstTime?floor(delta/damp):delta>>1;delta+=floor(delta/numPoints);for/* no initialization */(;delta>baseMinusTMin*tMax>>1;k+=base){delta=floor(delta/baseMinusTMin);}return floor(k+(baseMinusTMin+1)*delta/(delta+skew));};/**
 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
 * symbols.
 * @memberOf punycode
 * @param {String} input The Punycode string of ASCII-only symbols.
 * @returns {String} The resulting string of Unicode symbols.
 */const decode=function(input){// Don't use UCS-2.
const output=[];const inputLength=input.length;let i=0;let n=initialN;let bias=initialBias;// Handle the basic code points: let `basic` be the number of input code
// points before the last delimiter, or `0` if there is none, then copy
// the first basic code points to the output.
let basic=input.lastIndexOf(delimiter);if(basic<0){basic=0;}for(let j=0;j<basic;++j){// if it's not a basic code point
if(input.charCodeAt(j)>=0x80){error('not-basic');}output.push(input.charCodeAt(j));}// Main decoding loop: start just after the last delimiter if any basic code
// points were copied; start at the beginning otherwise.
for/* no final expression */(let index=basic>0?basic+1:0;index<inputLength;){// `index` is the index of the next character to be consumed.
// Decode a generalized variable-length integer into `delta`,
// which gets added to `i`. The overflow checking is easier
// if we increase `i` as we go, then subtract off its starting
// value at the end to obtain `delta`.
const oldi=i;for/* no condition */(let w=1,k=base;;k+=base){if(index>=inputLength){error('invalid-input');}const digit=basicToDigit(input.charCodeAt(index++));if(digit>=base){error('invalid-input');}if(digit>floor((maxInt-i)/w)){error('overflow');}i+=digit*w;const t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(digit<t){break;}const baseMinusT=base-t;if(w>floor(maxInt/baseMinusT)){error('overflow');}w*=baseMinusT;}const out=output.length+1;bias=adapt(i-oldi,out,oldi==0);// `i` was supposed to wrap around from `out` to `0`,
// incrementing `n` each time, so we'll fix that now:
if(floor(i/out)>maxInt-n){error('overflow');}n+=floor(i/out);i%=out;// Insert `n` at position `i` of the output.
output.splice(i++,0,n);}return String.fromCodePoint(...output);};/**
 * Converts a string of Unicode symbols (e.g. a domain name label) to a
 * Punycode string of ASCII-only symbols.
 * @memberOf punycode
 * @param {String} input The string of Unicode symbols.
 * @returns {String} The resulting Punycode string of ASCII-only symbols.
 */const encode=function(input){const output=[];// Convert the input in UCS-2 to an array of Unicode code points.
input=ucs2decode(input);// Cache the length.
const inputLength=input.length;// Initialize the state.
let n=initialN;let delta=0;let bias=initialBias;// Handle the basic code points.
for(const currentValue of input){if(currentValue<0x80){output.push(stringFromCharCode(currentValue));}}const basicLength=output.length;let handledCPCount=basicLength;// `handledCPCount` is the number of code points that have been handled;
// `basicLength` is the number of basic code points.
// Finish the basic string with a delimiter unless it's empty.
if(basicLength){output.push(delimiter);}// Main encoding loop:
while(handledCPCount<inputLength){// All non-basic code points < n have been handled already. Find the next
// larger one:
let m=maxInt;for(const currentValue of input){if(currentValue>=n&&currentValue<m){m=currentValue;}}// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
// but guard against overflow.
const handledCPCountPlusOne=handledCPCount+1;if(m-n>floor((maxInt-delta)/handledCPCountPlusOne)){error('overflow');}delta+=(m-n)*handledCPCountPlusOne;n=m;for(const currentValue of input){if(currentValue<n&&++delta>maxInt){error('overflow');}if(currentValue===n){// Represent delta as a generalized variable-length integer.
let q=delta;for/* no condition */(let k=base;;k+=base){const t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q<t){break;}const qMinusT=q-t;const baseMinusT=base-t;output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0)));q=floor(qMinusT/baseMinusT);}output.push(stringFromCharCode(digitToBasic(q,0)));bias=adapt(delta,handledCPCountPlusOne,handledCPCount===basicLength);delta=0;++handledCPCount;}}++delta;++n;}return output.join('');};/**
 * Converts a Punycode string representing a domain name or an email address
 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
 * it doesn't matter if you call it on a string that has already been
 * converted to Unicode.
 * @memberOf punycode
 * @param {String} input The Punycoded domain name or email address to
 * convert to Unicode.
 * @returns {String} The Unicode representation of the given Punycode
 * string.
 */const toUnicode=function(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string;});};/**
 * Converts a Unicode string representing a domain name or an email address to
 * Punycode. Only the non-ASCII parts of the domain name will be converted,
 * i.e. it doesn't matter if you call it with a domain that's already in
 * ASCII.
 * @memberOf punycode
 * @param {String} input The domain name or email address to convert, as a
 * Unicode string.
 * @returns {String} The Punycode representation of the given domain name or
 * email address.
 */const toASCII=function(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?'xn--'+encode(string):string;});};/*--------------------------------------------------------------------------*//** Define the public API */const punycode={/**
	 * A string representing the current Punycode.js version number.
	 * @memberOf punycode
	 * @type String
	 */'version':'2.3.1',/**
	 * An object of methods to convert from JavaScript's internal character
	 * representation (UCS-2) to Unicode code points, and back.
	 * @see <https://mathiasbynens.be/notes/javascript-encoding>
	 * @memberOf punycode
	 * @type Object
	 */'ucs2':{'decode':ucs2decode,'encode':ucs2encode},'decode':decode,'encode':encode,'toASCII':toASCII,'toUnicode':toUnicode};/* harmony default export */ __webpack_exports__["default"] = (punycode);

/***/ }),

/***/ 10681:
/***/ (function(module) {

"use strict";
var replace=String.prototype.replace;var percentTwenties=/%20/g;var Format={RFC1738:'RFC1738',RFC3986:'RFC3986'};module.exports={'default':Format.RFC3986,formatters:{RFC1738:function(value){return replace.call(value,percentTwenties,'+');},RFC3986:function(value){return String(value);}},RFC1738:Format.RFC1738,RFC3986:Format.RFC3986};

/***/ }),

/***/ 641:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var stringify=__webpack_require__(62520);var parse=__webpack_require__(46998);var formats=__webpack_require__(10681);module.exports={formats:formats,parse:parse,stringify:stringify};

/***/ }),

/***/ 46998:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var utils=__webpack_require__(92972);var has=Object.prototype.hasOwnProperty;var isArray=Array.isArray;var defaults={allowDots:false,allowEmptyArrays:false,allowPrototypes:false,allowSparse:false,arrayLimit:20,charset:'utf-8',charsetSentinel:false,comma:false,decodeDotInKeys:false,decoder:utils.decode,delimiter:'&',depth:5,duplicates:'combine',ignoreQueryPrefix:false,interpretNumericEntities:false,parameterLimit:1000,parseArrays:true,plainObjects:false,strictDepth:false,strictMerge:true,strictNullHandling:false,throwOnLimitExceeded:false};var interpretNumericEntities=function(str){return str.replace(/&#(\d+);/g,function($0,numberStr){return String.fromCharCode(parseInt(numberStr,10));});};var parseArrayValue=function(val,options,currentArrayLength){if(val&&typeof val==='string'&&options.comma&&val.indexOf(',')>-1){return val.split(',');}if(options.throwOnLimitExceeded&&currentArrayLength>=options.arrayLimit){throw new RangeError('Array limit exceeded. Only '+options.arrayLimit+' element'+(options.arrayLimit===1?'':'s')+' allowed in an array.');}return val;};// This is what browsers will submit when the ✓ character occurs in an
// application/x-www-form-urlencoded body and the encoding of the page containing
// the form is iso-8859-1, or when the submitted form has an accept-charset
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
// the ✓ character, such as us-ascii.
var isoSentinel='utf8=%26%2310003%3B';// encodeURIComponent('&#10003;')
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
var charsetSentinel='utf8=%E2%9C%93';// encodeURIComponent('✓')
var parseValues=function parseQueryStringValues(str,options){var obj={__proto__:null};var cleanStr=options.ignoreQueryPrefix?str.replace(/^\?/,''):str;cleanStr=cleanStr.replace(/%5B/gi,'[').replace(/%5D/gi,']');var limit=options.parameterLimit===Infinity?void undefined:options.parameterLimit;var parts=cleanStr.split(options.delimiter,options.throwOnLimitExceeded&&typeof limit!=='undefined'?limit+1:limit);if(options.throwOnLimitExceeded&&typeof limit!=='undefined'&&parts.length>limit){throw new RangeError('Parameter limit exceeded. Only '+limit+' parameter'+(limit===1?'':'s')+' allowed.');}var skipIndex=-1;// Keep track of where the utf8 sentinel was found
var i;var charset=options.charset;if(options.charsetSentinel){for(i=0;i<parts.length;++i){if(parts[i].indexOf('utf8=')===0){if(parts[i]===charsetSentinel){charset='utf-8';}else if(parts[i]===isoSentinel){charset='iso-8859-1';}skipIndex=i;i=parts.length;// The eslint settings do not allow break;
}}}for(i=0;i<parts.length;++i){if(i===skipIndex){continue;}var part=parts[i];var bracketEqualsPos=part.indexOf(']=');var pos=bracketEqualsPos===-1?part.indexOf('='):bracketEqualsPos+1;var key;var val;if(pos===-1){key=options.decoder(part,defaults.decoder,charset,'key');val=options.strictNullHandling?null:'';}else{key=options.decoder(part.slice(0,pos),defaults.decoder,charset,'key');if(key!==null){val=utils.maybeMap(parseArrayValue(part.slice(pos+1),options,isArray(obj[key])?obj[key].length:0),function(encodedVal){return options.decoder(encodedVal,defaults.decoder,charset,'value');});}}if(val&&options.interpretNumericEntities&&charset==='iso-8859-1'){val=interpretNumericEntities(String(val));}if(part.indexOf('[]=')>-1){val=isArray(val)?[val]:val;}if(options.comma&&isArray(val)&&val.length>options.arrayLimit){if(options.throwOnLimitExceeded){throw new RangeError('Array limit exceeded. Only '+options.arrayLimit+' element'+(options.arrayLimit===1?'':'s')+' allowed in an array.');}val=utils.combine([],val,options.arrayLimit,options.plainObjects);}if(key!==null){var existing=has.call(obj,key);if(existing&&(options.duplicates==='combine'||part.indexOf('[]=')>-1)){obj[key]=utils.combine(obj[key],val,options.arrayLimit,options.plainObjects);}else if(!existing||options.duplicates==='last'){obj[key]=val;}}}return obj;};var parseObject=function(chain,val,options,valuesParsed){var currentArrayLength=0;if(chain.length>0&&chain[chain.length-1]==='[]'){var parentKey=chain.slice(0,-1).join('');currentArrayLength=Array.isArray(val)&&val[parentKey]?val[parentKey].length:0;}var leaf=valuesParsed?val:parseArrayValue(val,options,currentArrayLength);for(var i=chain.length-1;i>=0;--i){var obj;var root=chain[i];if(root==='[]'&&options.parseArrays){if(utils.isOverflow(leaf)){// leaf is already an overflow object, preserve it
obj=leaf;}else{obj=options.allowEmptyArrays&&(leaf===''||options.strictNullHandling&&leaf===null)?[]:utils.combine([],leaf,options.arrayLimit,options.plainObjects);}}else{obj=options.plainObjects?{__proto__:null}:{};var cleanRoot=root.charAt(0)==='['&&root.charAt(root.length-1)===']'?root.slice(1,-1):root;var decodedRoot=options.decodeDotInKeys?cleanRoot.replace(/%2E/g,'.'):cleanRoot;var index=parseInt(decodedRoot,10);var isValidArrayIndex=!isNaN(index)&&root!==decodedRoot&&String(index)===decodedRoot&&index>=0&&options.parseArrays;if(!options.parseArrays&&decodedRoot===''){obj={0:leaf};}else if(isValidArrayIndex&&index<options.arrayLimit){obj=[];obj[index]=leaf;}else if(isValidArrayIndex&&options.throwOnLimitExceeded){throw new RangeError('Array limit exceeded. Only '+options.arrayLimit+' element'+(options.arrayLimit===1?'':'s')+' allowed in an array.');}else if(isValidArrayIndex){obj[index]=leaf;utils.markOverflow(obj,index);}else if(decodedRoot!=='__proto__'){obj[decodedRoot]=leaf;}}leaf=obj;}return leaf;};var splitKeyIntoSegments=function splitKeyIntoSegments(givenKey,options){var key=options.allowDots?givenKey.replace(/\.([^.[]+)/g,'[$1]'):givenKey;if(options.depth<=0){if(!options.plainObjects&&has.call(Object.prototype,key)){if(!options.allowPrototypes){return;}}return[key];}var brackets=/(\[[^[\]]*])/;var child=/(\[[^[\]]*])/g;var segment=brackets.exec(key);var parent=segment?key.slice(0,segment.index):key;var keys=[];if(parent){if(!options.plainObjects&&has.call(Object.prototype,parent)){if(!options.allowPrototypes){return;}}keys[keys.length]=parent;}var i=0;while((segment=child.exec(key))!==null&&i<options.depth){i+=1;var segmentContent=segment[1].slice(1,-1);if(!options.plainObjects&&has.call(Object.prototype,segmentContent)){if(!options.allowPrototypes){return;}}keys[keys.length]=segment[1];}if(segment){if(options.strictDepth===true){throw new RangeError('Input depth exceeded depth option of '+options.depth+' and strictDepth is true');}keys[keys.length]='['+key.slice(segment.index)+']';}return keys;};var parseKeys=function parseQueryStringKeys(givenKey,val,options,valuesParsed){if(!givenKey){return;}var keys=splitKeyIntoSegments(givenKey,options);if(!keys){return;}return parseObject(keys,val,options,valuesParsed);};var normalizeParseOptions=function normalizeParseOptions(opts){if(!opts){return defaults;}if(typeof opts.allowEmptyArrays!=='undefined'&&typeof opts.allowEmptyArrays!=='boolean'){throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');}if(typeof opts.decodeDotInKeys!=='undefined'&&typeof opts.decodeDotInKeys!=='boolean'){throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided');}if(opts.decoder!==null&&typeof opts.decoder!=='undefined'&&typeof opts.decoder!=='function'){throw new TypeError('Decoder has to be a function.');}if(typeof opts.charset!=='undefined'&&opts.charset!=='utf-8'&&opts.charset!=='iso-8859-1'){throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');}if(typeof opts.throwOnLimitExceeded!=='undefined'&&typeof opts.throwOnLimitExceeded!=='boolean'){throw new TypeError('`throwOnLimitExceeded` option must be a boolean');}var charset=typeof opts.charset==='undefined'?defaults.charset:opts.charset;var duplicates=typeof opts.duplicates==='undefined'?defaults.duplicates:opts.duplicates;if(duplicates!=='combine'&&duplicates!=='first'&&duplicates!=='last'){throw new TypeError('The duplicates option must be either combine, first, or last');}var allowDots=typeof opts.allowDots==='undefined'?opts.decodeDotInKeys===true?true:defaults.allowDots:!!opts.allowDots;return{allowDots:allowDots,allowEmptyArrays:typeof opts.allowEmptyArrays==='boolean'?!!opts.allowEmptyArrays:defaults.allowEmptyArrays,allowPrototypes:typeof opts.allowPrototypes==='boolean'?opts.allowPrototypes:defaults.allowPrototypes,allowSparse:typeof opts.allowSparse==='boolean'?opts.allowSparse:defaults.allowSparse,arrayLimit:typeof opts.arrayLimit==='number'?opts.arrayLimit:defaults.arrayLimit,charset:charset,charsetSentinel:typeof opts.charsetSentinel==='boolean'?opts.charsetSentinel:defaults.charsetSentinel,comma:typeof opts.comma==='boolean'?opts.comma:defaults.comma,decodeDotInKeys:typeof opts.decodeDotInKeys==='boolean'?opts.decodeDotInKeys:defaults.decodeDotInKeys,decoder:typeof opts.decoder==='function'?opts.decoder:defaults.decoder,delimiter:typeof opts.delimiter==='string'||utils.isRegExp(opts.delimiter)?opts.delimiter:defaults.delimiter,// eslint-disable-next-line no-implicit-coercion, no-extra-parens
depth:typeof opts.depth==='number'||opts.depth===false?+opts.depth:defaults.depth,duplicates:duplicates,ignoreQueryPrefix:opts.ignoreQueryPrefix===true,interpretNumericEntities:typeof opts.interpretNumericEntities==='boolean'?opts.interpretNumericEntities:defaults.interpretNumericEntities,parameterLimit:typeof opts.parameterLimit==='number'?opts.parameterLimit:defaults.parameterLimit,parseArrays:opts.parseArrays!==false,plainObjects:typeof opts.plainObjects==='boolean'?opts.plainObjects:defaults.plainObjects,strictDepth:typeof opts.strictDepth==='boolean'?!!opts.strictDepth:defaults.strictDepth,strictMerge:typeof opts.strictMerge==='boolean'?!!opts.strictMerge:defaults.strictMerge,strictNullHandling:typeof opts.strictNullHandling==='boolean'?opts.strictNullHandling:defaults.strictNullHandling,throwOnLimitExceeded:typeof opts.throwOnLimitExceeded==='boolean'?opts.throwOnLimitExceeded:false};};module.exports=function(str,opts){var options=normalizeParseOptions(opts);if(str===''||str===null||typeof str==='undefined'){return options.plainObjects?{__proto__:null}:{};}var tempObj=typeof str==='string'?parseValues(str,options):str;var obj=options.plainObjects?{__proto__:null}:{};// Iterate over the keys and setup the new object
var keys=Object.keys(tempObj);for(var i=0;i<keys.length;++i){var key=keys[i];var newObj=parseKeys(key,tempObj[key],options,typeof str==='string');obj=utils.merge(obj,newObj,options);}if(options.allowSparse===true){return obj;}return utils.compact(obj);};

/***/ }),

/***/ 62520:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var getSideChannel=__webpack_require__(67124);var utils=__webpack_require__(92972);var formats=__webpack_require__(10681);var has=Object.prototype.hasOwnProperty;var arrayPrefixGenerators={brackets:function brackets(prefix){return prefix+'[]';},comma:'comma',indices:function indices(prefix,key){return prefix+'['+key+']';},repeat:function repeat(prefix){return prefix;}};var isArray=Array.isArray;var push=Array.prototype.push;var pushToArray=function(arr,valueOrArray){push.apply(arr,isArray(valueOrArray)?valueOrArray:[valueOrArray]);};var toISO=Date.prototype.toISOString;var defaultFormat=formats['default'];var defaults={addQueryPrefix:false,allowDots:false,allowEmptyArrays:false,arrayFormat:'indices',charset:'utf-8',charsetSentinel:false,commaRoundTrip:false,delimiter:'&',encode:true,encodeDotInKeys:false,encoder:utils.encode,encodeValuesOnly:false,filter:void undefined,format:defaultFormat,formatter:formats.formatters[defaultFormat],// deprecated
indices:false,serializeDate:function serializeDate(date){return toISO.call(date);},skipNulls:false,strictNullHandling:false};var isNonNullishPrimitive=function isNonNullishPrimitive(v){return typeof v==='string'||typeof v==='number'||typeof v==='boolean'||typeof v==='symbol'||typeof v==='bigint';};var sentinel={};var stringify=function stringify(object,prefix,generateArrayPrefix,commaRoundTrip,allowEmptyArrays,strictNullHandling,skipNulls,encodeDotInKeys,encoder,filter,sort,allowDots,serializeDate,format,formatter,encodeValuesOnly,charset,sideChannel){var obj=object;var tmpSc=sideChannel;var step=0;var findFlag=false;while((tmpSc=tmpSc.get(sentinel))!==void undefined&&!findFlag){// Where object last appeared in the ref tree
var pos=tmpSc.get(object);step+=1;if(typeof pos!=='undefined'){if(pos===step){throw new RangeError('Cyclic object value');}else{findFlag=true;// Break while
}}if(typeof tmpSc.get(sentinel)==='undefined'){step=0;}}if(typeof filter==='function'){obj=filter(prefix,obj);}else if(obj instanceof Date){obj=serializeDate(obj);}else if(generateArrayPrefix==='comma'&&isArray(obj)){obj=utils.maybeMap(obj,function(value){if(value instanceof Date){return serializeDate(value);}return value;});}if(obj===null){if(strictNullHandling){return encoder&&!encodeValuesOnly?encoder(prefix,defaults.encoder,charset,'key',format):prefix;}obj='';}if(isNonNullishPrimitive(obj)||utils.isBuffer(obj)){if(encoder){var keyValue=encodeValuesOnly?prefix:encoder(prefix,defaults.encoder,charset,'key',format);return[formatter(keyValue)+'='+formatter(encoder(obj,defaults.encoder,charset,'value',format))];}return[formatter(prefix)+'='+formatter(String(obj))];}var values=[];if(typeof obj==='undefined'){return values;}var objKeys;if(generateArrayPrefix==='comma'&&isArray(obj)){// we need to join elements in
if(encodeValuesOnly&&encoder){obj=utils.maybeMap(obj,encoder);}objKeys=[{value:obj.length>0?obj.join(',')||null:void undefined}];}else if(isArray(filter)){objKeys=filter;}else{var keys=Object.keys(obj);objKeys=sort?keys.sort(sort):keys;}var encodedPrefix=encodeDotInKeys?String(prefix).replace(/\./g,'%2E'):String(prefix);var adjustedPrefix=commaRoundTrip&&isArray(obj)&&obj.length===1?encodedPrefix+'[]':encodedPrefix;if(allowEmptyArrays&&isArray(obj)&&obj.length===0){return adjustedPrefix+'[]';}for(var j=0;j<objKeys.length;++j){var key=objKeys[j];var value=typeof key==='object'&&key&&typeof key.value!=='undefined'?key.value:obj[key];if(skipNulls&&value===null){continue;}var encodedKey=allowDots&&encodeDotInKeys?String(key).replace(/\./g,'%2E'):String(key);var keyPrefix=isArray(obj)?typeof generateArrayPrefix==='function'?generateArrayPrefix(adjustedPrefix,encodedKey):adjustedPrefix:adjustedPrefix+(allowDots?'.'+encodedKey:'['+encodedKey+']');sideChannel.set(object,step);var valueSideChannel=getSideChannel();valueSideChannel.set(sentinel,sideChannel);pushToArray(values,stringify(value,keyPrefix,generateArrayPrefix,commaRoundTrip,allowEmptyArrays,strictNullHandling,skipNulls,encodeDotInKeys,generateArrayPrefix==='comma'&&encodeValuesOnly&&isArray(obj)?null:encoder,filter,sort,allowDots,serializeDate,format,formatter,encodeValuesOnly,charset,valueSideChannel));}return values;};var normalizeStringifyOptions=function normalizeStringifyOptions(opts){if(!opts){return defaults;}if(typeof opts.allowEmptyArrays!=='undefined'&&typeof opts.allowEmptyArrays!=='boolean'){throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');}if(typeof opts.encodeDotInKeys!=='undefined'&&typeof opts.encodeDotInKeys!=='boolean'){throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');}if(opts.encoder!==null&&typeof opts.encoder!=='undefined'&&typeof opts.encoder!=='function'){throw new TypeError('Encoder has to be a function.');}var charset=opts.charset||defaults.charset;if(typeof opts.charset!=='undefined'&&opts.charset!=='utf-8'&&opts.charset!=='iso-8859-1'){throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');}var format=formats['default'];if(typeof opts.format!=='undefined'){if(!has.call(formats.formatters,opts.format)){throw new TypeError('Unknown format option provided.');}format=opts.format;}var formatter=formats.formatters[format];var filter=defaults.filter;if(typeof opts.filter==='function'||isArray(opts.filter)){filter=opts.filter;}var arrayFormat;if(opts.arrayFormat in arrayPrefixGenerators){arrayFormat=opts.arrayFormat;}else if('indices'in opts){arrayFormat=opts.indices?'indices':'repeat';}else{arrayFormat=defaults.arrayFormat;}if('commaRoundTrip'in opts&&typeof opts.commaRoundTrip!=='boolean'){throw new TypeError('`commaRoundTrip` must be a boolean, or absent');}var allowDots=typeof opts.allowDots==='undefined'?opts.encodeDotInKeys===true?true:defaults.allowDots:!!opts.allowDots;return{addQueryPrefix:typeof opts.addQueryPrefix==='boolean'?opts.addQueryPrefix:defaults.addQueryPrefix,allowDots:allowDots,allowEmptyArrays:typeof opts.allowEmptyArrays==='boolean'?!!opts.allowEmptyArrays:defaults.allowEmptyArrays,arrayFormat:arrayFormat,charset:charset,charsetSentinel:typeof opts.charsetSentinel==='boolean'?opts.charsetSentinel:defaults.charsetSentinel,commaRoundTrip:!!opts.commaRoundTrip,delimiter:typeof opts.delimiter==='undefined'?defaults.delimiter:opts.delimiter,encode:typeof opts.encode==='boolean'?opts.encode:defaults.encode,encodeDotInKeys:typeof opts.encodeDotInKeys==='boolean'?opts.encodeDotInKeys:defaults.encodeDotInKeys,encoder:typeof opts.encoder==='function'?opts.encoder:defaults.encoder,encodeValuesOnly:typeof opts.encodeValuesOnly==='boolean'?opts.encodeValuesOnly:defaults.encodeValuesOnly,filter:filter,format:format,formatter:formatter,serializeDate:typeof opts.serializeDate==='function'?opts.serializeDate:defaults.serializeDate,skipNulls:typeof opts.skipNulls==='boolean'?opts.skipNulls:defaults.skipNulls,sort:typeof opts.sort==='function'?opts.sort:null,strictNullHandling:typeof opts.strictNullHandling==='boolean'?opts.strictNullHandling:defaults.strictNullHandling};};module.exports=function(object,opts){var obj=object;var options=normalizeStringifyOptions(opts);var objKeys;var filter;if(typeof options.filter==='function'){filter=options.filter;obj=filter('',obj);}else if(isArray(options.filter)){filter=options.filter;objKeys=filter;}var keys=[];if(typeof obj!=='object'||obj===null){return'';}var generateArrayPrefix=arrayPrefixGenerators[options.arrayFormat];var commaRoundTrip=generateArrayPrefix==='comma'&&options.commaRoundTrip;if(!objKeys){objKeys=Object.keys(obj);}if(options.sort){objKeys.sort(options.sort);}var sideChannel=getSideChannel();for(var i=0;i<objKeys.length;++i){var key=objKeys[i];var value=obj[key];if(options.skipNulls&&value===null){continue;}pushToArray(keys,stringify(value,key,generateArrayPrefix,commaRoundTrip,options.allowEmptyArrays,options.strictNullHandling,options.skipNulls,options.encodeDotInKeys,options.encode?options.encoder:null,options.filter,options.sort,options.allowDots,options.serializeDate,options.format,options.formatter,options.encodeValuesOnly,options.charset,sideChannel));}var joined=keys.join(options.delimiter);var prefix=options.addQueryPrefix===true?'?':'';if(options.charsetSentinel){if(options.charset==='iso-8859-1'){// encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
prefix+='utf8=%26%2310003%3B&';}else{// encodeURIComponent('✓')
prefix+='utf8=%E2%9C%93&';}}return joined.length>0?prefix+joined:'';};

/***/ }),

/***/ 92972:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var formats=__webpack_require__(10681);var getSideChannel=__webpack_require__(67124);var has=Object.prototype.hasOwnProperty;var isArray=Array.isArray;// Track objects created from arrayLimit overflow using side-channel
// Stores the current max numeric index for O(1) lookup
var overflowChannel=getSideChannel();var markOverflow=function markOverflow(obj,maxIndex){overflowChannel.set(obj,maxIndex);return obj;};var isOverflow=function isOverflow(obj){return overflowChannel.has(obj);};var getMaxIndex=function getMaxIndex(obj){return overflowChannel.get(obj);};var setMaxIndex=function setMaxIndex(obj,maxIndex){overflowChannel.set(obj,maxIndex);};var hexTable=function(){var array=[];for(var i=0;i<256;++i){array[array.length]='%'+((i<16?'0':'')+i.toString(16)).toUpperCase();}return array;}();var compactQueue=function compactQueue(queue){while(queue.length>1){var item=queue.pop();var obj=item.obj[item.prop];if(isArray(obj)){var compacted=[];for(var j=0;j<obj.length;++j){if(typeof obj[j]!=='undefined'){compacted[compacted.length]=obj[j];}}item.obj[item.prop]=compacted;}}};var arrayToObject=function arrayToObject(source,options){var obj=options&&options.plainObjects?{__proto__:null}:{};for(var i=0;i<source.length;++i){if(typeof source[i]!=='undefined'){obj[i]=source[i];}}return obj;};var merge=function merge(target,source,options){/* eslint no-param-reassign: 0 */if(!source){return target;}if(typeof source!=='object'&&typeof source!=='function'){if(isArray(target)){var nextIndex=target.length;if(options&&typeof options.arrayLimit==='number'&&nextIndex>options.arrayLimit){return markOverflow(arrayToObject(target.concat(source),options),nextIndex);}target[nextIndex]=source;}else if(target&&typeof target==='object'){if(isOverflow(target)){// Add at next numeric index for overflow objects
var newIndex=getMaxIndex(target)+1;target[newIndex]=source;setMaxIndex(target,newIndex);}else if(options&&options.strictMerge){return[target,source];}else if(options&&(options.plainObjects||options.allowPrototypes)||!has.call(Object.prototype,source)){target[source]=true;}}else{return[target,source];}return target;}if(!target||typeof target!=='object'){if(isOverflow(source)){// Create new object with target at 0, source values shifted by 1
var sourceKeys=Object.keys(source);var result=options&&options.plainObjects?{__proto__:null,0:target}:{0:target};for(var m=0;m<sourceKeys.length;m++){var oldKey=parseInt(sourceKeys[m],10);result[oldKey+1]=source[sourceKeys[m]];}return markOverflow(result,getMaxIndex(source)+1);}var combined=[target].concat(source);if(options&&typeof options.arrayLimit==='number'&&combined.length>options.arrayLimit){return markOverflow(arrayToObject(combined,options),combined.length-1);}return combined;}var mergeTarget=target;if(isArray(target)&&!isArray(source)){mergeTarget=arrayToObject(target,options);}if(isArray(target)&&isArray(source)){source.forEach(function(item,i){if(has.call(target,i)){var targetItem=target[i];if(targetItem&&typeof targetItem==='object'&&item&&typeof item==='object'){target[i]=merge(targetItem,item,options);}else{target[target.length]=item;}}else{target[i]=item;}});return target;}return Object.keys(source).reduce(function(acc,key){var value=source[key];if(has.call(acc,key)){acc[key]=merge(acc[key],value,options);}else{acc[key]=value;}if(isOverflow(source)&&!isOverflow(acc)){markOverflow(acc,getMaxIndex(source));}if(isOverflow(acc)){var keyNum=parseInt(key,10);if(String(keyNum)===key&&keyNum>=0&&keyNum>getMaxIndex(acc)){setMaxIndex(acc,keyNum);}}return acc;},mergeTarget);};var assign=function assignSingleSource(target,source){return Object.keys(source).reduce(function(acc,key){acc[key]=source[key];return acc;},target);};var decode=function(str,defaultDecoder,charset){var strWithoutPlus=str.replace(/\+/g,' ');if(charset==='iso-8859-1'){// unescape never throws, no try...catch needed:
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi,unescape);}// utf-8
try{return decodeURIComponent(strWithoutPlus);}catch(e){return strWithoutPlus;}};var limit=1024;/* eslint operator-linebreak: [2, "before"] */var encode=function encode(str,defaultEncoder,charset,kind,format){// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if(str.length===0){return str;}var string=str;if(typeof str==='symbol'){string=Symbol.prototype.toString.call(str);}else if(typeof str!=='string'){string=String(str);}if(charset==='iso-8859-1'){return escape(string).replace(/%u[0-9a-f]{4}/gi,function($0){return'%26%23'+parseInt($0.slice(2),16)+'%3B';});}var out='';for(var j=0;j<string.length;j+=limit){var segment=string.length>=limit?string.slice(j,j+limit):string;var arr=[];for(var i=0;i<segment.length;++i){var c=segment.charCodeAt(i);if(c===0x2D// -
||c===0x2E// .
||c===0x5F// _
||c===0x7E// ~
||c>=0x30&&c<=0x39// 0-9
||c>=0x41&&c<=0x5A// a-z
||c>=0x61&&c<=0x7A// A-Z
||format===formats.RFC1738&&(c===0x28||c===0x29)// ( )
){arr[arr.length]=segment.charAt(i);continue;}if(c<0x80){arr[arr.length]=hexTable[c];continue;}if(c<0x800){arr[arr.length]=hexTable[0xC0|c>>6]+hexTable[0x80|c&0x3F];continue;}if(c<0xD800||c>=0xE000){arr[arr.length]=hexTable[0xE0|c>>12]+hexTable[0x80|c>>6&0x3F]+hexTable[0x80|c&0x3F];continue;}i+=1;c=0x10000+((c&0x3FF)<<10|segment.charCodeAt(i)&0x3FF);arr[arr.length]=hexTable[0xF0|c>>18]+hexTable[0x80|c>>12&0x3F]+hexTable[0x80|c>>6&0x3F]+hexTable[0x80|c&0x3F];}out+=arr.join('');}return out;};var compact=function compact(value){var queue=[{obj:{o:value},prop:'o'}];var refs=[];for(var i=0;i<queue.length;++i){var item=queue[i];var obj=item.obj[item.prop];var keys=Object.keys(obj);for(var j=0;j<keys.length;++j){var key=keys[j];var val=obj[key];if(typeof val==='object'&&val!==null&&refs.indexOf(val)===-1){queue[queue.length]={obj:obj,prop:key};refs[refs.length]=val;}}}compactQueue(queue);return value;};var isRegExp=function isRegExp(obj){return Object.prototype.toString.call(obj)==='[object RegExp]';};var isBuffer=function isBuffer(obj){if(!obj||typeof obj!=='object'){return false;}return!!(obj.constructor&&obj.constructor.isBuffer&&obj.constructor.isBuffer(obj));};var combine=function combine(a,b,arrayLimit,plainObjects){// If 'a' is already an overflow object, add to it
if(isOverflow(a)){var newIndex=getMaxIndex(a)+1;a[newIndex]=b;setMaxIndex(a,newIndex);return a;}var result=[].concat(a,b);if(result.length>arrayLimit){return markOverflow(arrayToObject(result,{plainObjects:plainObjects}),result.length-1);}return result;};var maybeMap=function maybeMap(val,fn){if(isArray(val)){var mapped=[];for(var i=0;i<val.length;i+=1){mapped[mapped.length]=fn(val[i]);}return mapped;}return fn(val);};module.exports={arrayToObject:arrayToObject,assign:assign,combine:combine,compact:compact,decode:decode,encode:encode,isBuffer:isBuffer,isOverflow:isOverflow,isRegExp:isRegExp,markOverflow:markOverflow,maybeMap:maybeMap,merge:merge};

/***/ }),

/***/ 60271:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var inspect=__webpack_require__(73271);var $TypeError=__webpack_require__(93767);/*
* This function traverses the list returning the node corresponding to the given key.
*
* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list.
* By doing so, all the recently used nodes can be accessed relatively quickly.
*//** @type {import('./list.d.ts').listGetNode} */// eslint-disable-next-line consistent-return
var listGetNode=function(list,key,isDelete){/** @type {typeof list | NonNullable<(typeof list)['next']>} */var prev=list;/** @type {(typeof list)['next']} */var curr;// eslint-disable-next-line eqeqeq
for(;(curr=prev.next)!=null;prev=curr){if(curr.key===key){prev.next=curr.next;if(!isDelete){// eslint-disable-next-line no-extra-parens
curr.next=/** @type {NonNullable<typeof list.next>} */list.next;list.next=curr;// eslint-disable-line no-param-reassign
}return curr;}}};/** @type {import('./list.d.ts').listGet} */var listGet=function(objects,key){if(!objects){return void undefined;}var node=listGetNode(objects,key);return node&&node.value;};/** @type {import('./list.d.ts').listSet} */var listSet=function(objects,key,value){var node=listGetNode(objects,key);if(node){node.value=value;}else{// Prepend the new node to the beginning of the list
objects.next=/** @type {import('./list.d.ts').ListNode<typeof value, typeof key>} */{// eslint-disable-line no-param-reassign, no-extra-parens
key:key,next:objects.next,value:value};}};/** @type {import('./list.d.ts').listHas} */var listHas=function(objects,key){if(!objects){return false;}return!!listGetNode(objects,key);};/** @type {import('./list.d.ts').listDelete} */// eslint-disable-next-line consistent-return
var listDelete=function(objects,key){if(objects){return listGetNode(objects,key,true);}};/** @type {import('.')} */module.exports=function getSideChannelList(){/** @typedef {ReturnType<typeof getSideChannelList>} Channel *//** @typedef {Parameters<Channel['get']>[0]} K *//** @typedef {Parameters<Channel['set']>[1]} V *//** @type {import('./list.d.ts').RootNode<V, K> | undefined} */var $o;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){var deletedNode=listDelete($o,key);if(deletedNode&&$o&&!$o.next){$o=void undefined;}return!!deletedNode;},get:function(key){return listGet($o,key);},has:function(key){return listHas($o,key);},set:function(key,value){if(!$o){// Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head
$o={next:void undefined};}// eslint-disable-next-line no-extra-parens
listSet(/** @type {NonNullable<typeof $o>} */$o,key,value);}};return channel;};

/***/ }),

/***/ 12263:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var GetIntrinsic=__webpack_require__(35049);var callBound=__webpack_require__(95736);var inspect=__webpack_require__(73271);var $TypeError=__webpack_require__(93767);var $Map=GetIntrinsic('%Map%',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => V} */var $mapGet=callBound('Map.prototype.get',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K, value: V) => void} */var $mapSet=callBound('Map.prototype.set',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapHas=callBound('Map.prototype.has',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapDelete=callBound('Map.prototype.delete',true);/** @type {<K, V>(thisArg: Map<K, V>) => number} */var $mapSize=callBound('Map.prototype.size',true);/** @type {import('.')} */module.exports=!!$Map&&/** @type {Exclude<import('.'), false>} */function getSideChannelMap(){/** @typedef {ReturnType<typeof getSideChannelMap>} Channel *//** @typedef {Parameters<Channel['get']>[0]} K *//** @typedef {Parameters<Channel['set']>[1]} V *//** @type {Map<K, V> | undefined} */var $m;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){if($m){var result=$mapDelete($m,key);if($mapSize($m)===0){$m=void undefined;}return result;}return false;},get:function(key){// eslint-disable-line consistent-return
if($m){return $mapGet($m,key);}},has:function(key){if($m){return $mapHas($m,key);}return false;},set:function(key,value){if(!$m){// @ts-expect-error TS can't handle narrowing a variable inside a closure
$m=new $Map();}$mapSet($m,key,value);}};// @ts-expect-error TODO: figure out why TS is erroring here
return channel;};

/***/ }),

/***/ 29499:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var GetIntrinsic=__webpack_require__(35049);var callBound=__webpack_require__(95736);var inspect=__webpack_require__(73271);var getSideChannelMap=__webpack_require__(12263);var $TypeError=__webpack_require__(93767);var $WeakMap=GetIntrinsic('%WeakMap%',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */var $weakMapGet=callBound('WeakMap.prototype.get',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K, value: V) => void} */var $weakMapSet=callBound('WeakMap.prototype.set',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapHas=callBound('WeakMap.prototype.has',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapDelete=callBound('WeakMap.prototype.delete',true);/** @type {import('.')} */module.exports=$WeakMap?/** @type {Exclude<import('.'), false>} */function getSideChannelWeakMap(){/** @typedef {ReturnType<typeof getSideChannelWeakMap>} Channel *//** @typedef {Parameters<Channel['get']>[0]} K *//** @typedef {Parameters<Channel['set']>[1]} V *//** @type {WeakMap<K & object, V> | undefined} */var $wm;/** @type {Channel | undefined} */var $m;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapDelete($wm,key);}}else if(getSideChannelMap){if($m){return $m['delete'](key);}}return false;},get:function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapGet($wm,key);}}return $m&&$m.get(key);},has:function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapHas($wm,key);}}return!!$m&&$m.has(key);},set:function(key,value){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if(!$wm){$wm=new $WeakMap();}$weakMapSet($wm,key,value);}else if(getSideChannelMap){if(!$m){$m=getSideChannelMap();}// eslint-disable-next-line no-extra-parens
/** @type {NonNullable<typeof $m>} */$m.set(key,value);}}};// @ts-expect-error TODO: figure out why this is erroring
return channel;}:getSideChannelMap;

/***/ }),

/***/ 67124:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $TypeError=__webpack_require__(93767);var inspect=__webpack_require__(73271);var getSideChannelList=__webpack_require__(60271);var getSideChannelMap=__webpack_require__(12263);var getSideChannelWeakMap=__webpack_require__(29499);var makeChannel=getSideChannelWeakMap||getSideChannelMap||getSideChannelList;/** @type {import('.')} */module.exports=function getSideChannel(){/** @typedef {ReturnType<typeof getSideChannel>} Channel *//** @type {Channel | undefined} */var $channelData;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){return!!$channelData&&$channelData['delete'](key);},get:function(key){return $channelData&&$channelData.get(key);},has:function(key){return!!$channelData&&$channelData.has(key);},set:function(key,value){if(!$channelData){$channelData=makeChannel();}$channelData.set(key,value);}};// @ts-expect-error TODO: figure out why this is erroring
return channel;};

/***/ }),

/***/ 10967:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
/*
 * Copyright Joyent, Inc. and other Node contributors.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to permit
 * persons to whom the Software is furnished to do so, subject to the
 * following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 */var punycode=__webpack_require__(90791);function Url(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null;}// Reference: RFC 3986, RFC 1808, RFC 2396
/*
 * define these here so at least they only have to be
 * compiled once on the first module load.
 */var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,// Special case for a simple path URL
simplePathPattern=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,/*
   * RFC 2396: characters reserved for delimiting URLs.
   * We actually just auto-escape these.
   */delims=['<','>','"','`',' ','\r','\n','\t'],// RFC 2396: characters not allowed for various reasons.
unwise=['{','}','|','\\','^','`'].concat(delims),// Allowed by RFCs, but cause of XSS attacks.  Always escape these.
autoEscape=['\''].concat(unwise),/*
   * Characters that are never ever allowed in a hostname.
   * Note that any invalid chars are also handled, but these
   * are the ones that are *expected* to be seen, so we fast-path
   * them.
   */nonHostChars=['%','/','?',';','#'].concat(autoEscape),hostEndingChars=['/','?','#'],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,// protocols that can allow "unsafe" and "unwise" chars.
unsafeProtocol={javascript:true,'javascript:':true},// protocols that never have a hostname.
hostlessProtocol={javascript:true,'javascript:':true},// protocols that always contain a // bit.
slashedProtocol={http:true,https:true,ftp:true,gopher:true,file:true,'http:':true,'https:':true,'ftp:':true,'gopher:':true,'file:':true},querystring=__webpack_require__(641);function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&typeof url==='object'&&url instanceof Url){return url;}var u=new Url();u.parse(url,parseQueryString,slashesDenoteHost);return u;}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(typeof url!=='string'){throw new TypeError("Parameter 'url' must be a string, not "+typeof url);}/*
   * Copy chrome, IE, opera backslash-handling behavior.
   * Back slashes before the query string get converted to forward slashes
   * See: https://code.google.com/p/chromium/issues/detail?id=25916
   */var queryIndex=url.indexOf('?'),splitter=queryIndex!==-1&&queryIndex<url.indexOf('#')?'?':'#',uSplit=url.split(splitter),slashRegex=/\\/g;uSplit[0]=uSplit[0].replace(slashRegex,'/');url=uSplit.join(splitter);var rest=url;/*
   * trim before proceeding.
   * This is to support parse stuff like "  http://foo.com  \n"
   */rest=rest.trim();if(!slashesDenoteHost&&url.split('#').length===1){// Try fast path regexp
var simplePath=simplePathPattern.exec(rest);if(simplePath){this.path=rest;this.href=rest;this.pathname=simplePath[1];if(simplePath[2]){this.search=simplePath[2];if(parseQueryString){this.query=querystring.parse(this.search.substr(1));}else{this.query=this.search.substr(1);}}else if(parseQueryString){this.search='';this.query={};}return this;}}var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto;rest=rest.substr(proto.length);}/*
   * figure out if it's got a host
   * user@server is *always* interpreted as a hostname, and url
   * resolution will treat //foo/bar as host=foo,path=bar because that's
   * how the browser resolves relative URLs.
   */if(slashesDenoteHost||proto||rest.match(/^\/\/[^@/]+@[^@/]+/)){var slashes=rest.substr(0,2)==='//';if(slashes&&!(proto&&hostlessProtocol[proto])){rest=rest.substr(2);this.slashes=true;}}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){/*
     * there's a hostname.
     * the first instance of /, ?, ;, or # ends the host.
     *
     * If there is an @ in the hostname, then non-host chars *are* allowed
     * to the left of the last @ sign, unless some host-ending character
     * comes *before* the @-sign.
     * URLs are obnoxious.
     *
     * ex:
     * http://a@b@c/ => user:a@b host:c
     * http://a@b?@c => user:a host:c path:/?@c
     *//*
     * v0.12 TODO(isaacs): This is not quite how Chrome does things.
     * Review our test case against browsers more comprehensively.
     */// find the first instance of any hostEndingChars
var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd)){hostEnd=hec;}}/*
     * at this point, either we have an explicit point where the
     * auth portion cannot go past, or the last @ char is the decider.
     */var auth,atSign;if(hostEnd===-1){// atSign can be anywhere.
atSign=rest.lastIndexOf('@');}else{/*
       * atSign must be in auth portion.
       * http://a@b/c@d => host:b auth:a path:/c@d
       */atSign=rest.lastIndexOf('@',hostEnd);}/*
     * Now we have a portion which is definitely the auth.
     * Pull that off.
     */if(atSign!==-1){auth=rest.slice(0,atSign);rest=rest.slice(atSign+1);this.auth=decodeURIComponent(auth);}// the host is the remaining to the left of the first non-host char
hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd)){hostEnd=hec;}}// if we still have not hit it, then the entire thing is a host.
if(hostEnd===-1){hostEnd=rest.length;}this.host=rest.slice(0,hostEnd);rest=rest.slice(hostEnd);// pull out port.
this.parseHost();/*
     * we've indicated that there is a hostname,
     * so even if it's empty, it has to be present.
     */this.hostname=this.hostname||'';/*
     * if hostname begins with [ and ends with ]
     * assume that it's an IPv6 address.
     */var ipv6Hostname=this.hostname[0]==='['&&this.hostname[this.hostname.length-1]===']';// validate a little.
if(!ipv6Hostname){var hostparts=this.hostname.split(/\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part){continue;}if(!part.match(hostnamePartPattern)){var newpart='';for(var j=0,k=part.length;j<k;j++){if(part.charCodeAt(j)>127){/*
               * we replace non-ASCII char with a temporary placeholder
               * we need this to make sure size of hostname is not
               * broken by replacing non-ASCII by nothing
               */newpart+='x';}else{newpart+=part[j];}}// we test again with ASCII char only
if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i);var notHost=hostparts.slice(i+1);var bit=part.match(hostnamePartStart);if(bit){validParts.push(bit[1]);notHost.unshift(bit[2]);}if(notHost.length){rest='/'+notHost.join('.')+rest;}this.hostname=validParts.join('.');break;}}}}if(this.hostname.length>hostnameMaxLen){this.hostname='';}else{// hostnames are always lower case.
this.hostname=this.hostname.toLowerCase();}if(!ipv6Hostname){/*
       * IDNA Support: Returns a punycoded representation of "domain".
       * It only converts parts of the domain name that
       * have non-ASCII characters, i.e. it doesn't matter if
       * you call it with a domain that already is ASCII-only.
       */this.hostname=punycode.toASCII(this.hostname);}var p=this.port?':'+this.port:'';var h=this.hostname||'';this.host=h+p;this.href+=this.host;/*
     * strip [ and ] from the hostname
     * the host field still retains them, though
     */if(ipv6Hostname){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(rest[0]!=='/'){rest='/'+rest;}}}/*
   * now rest is set to the post-host stuff.
   * chop off any delim chars.
   */if(!unsafeProtocol[lowerProto]){/*
     * First, make 100% sure that any "autoEscape" chars get
     * escaped, even if encodeURIComponent doesn't think they
     * need to be.
     */for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];if(rest.indexOf(ae)===-1){continue;}var esc=encodeURIComponent(ae);if(esc===ae){esc=escape(ae);}rest=rest.split(ae).join(esc);}}// chop off from the tail first.
var hash=rest.indexOf('#');if(hash!==-1){// got a fragment string.
this.hash=rest.substr(hash);rest=rest.slice(0,hash);}var qm=rest.indexOf('?');if(qm!==-1){this.search=rest.substr(qm);this.query=rest.substr(qm+1);if(parseQueryString){this.query=querystring.parse(this.query);}rest=rest.slice(0,qm);}else if(parseQueryString){// no query string, but parseQueryString still requested
this.search='';this.query={};}if(rest){this.pathname=rest;}if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname){this.pathname='/';}// to support http.request
if(this.pathname||this.search){var p=this.pathname||'';var s=this.search||'';this.path=p+s;}// finally, reconstruct the href based on what has been validated.
this.href=this.format();return this;};// format a parsed object into a url string
function urlFormat(obj){/*
   * ensure it's an object, and not a string url.
   * If it's an obj, this is a no-op.
   * this way, you can call url_format() on strings
   * to clean up potentially wonky urls.
   */if(typeof obj==='string'){obj=urlParse(obj);}if(!(obj instanceof Url)){return Url.prototype.format.call(obj);}return obj.format();}Url.prototype.format=function(){var auth=this.auth||'';if(auth){auth=encodeURIComponent(auth);auth=auth.replace(/%3A/i,':');auth+='@';}var protocol=this.protocol||'',pathname=this.pathname||'',hash=this.hash||'',host=false,query='';if(this.host){host=auth+this.host;}else if(this.hostname){host=auth+(this.hostname.indexOf(':')===-1?this.hostname:'['+this.hostname+']');if(this.port){host+=':'+this.port;}}if(this.query&&typeof this.query==='object'&&Object.keys(this.query).length){query=querystring.stringify(this.query,{arrayFormat:'repeat',addQueryPrefix:false});}var search=this.search||query&&'?'+query||'';if(protocol&&protocol.substr(-1)!==':'){protocol+=':';}/*
   * only the slashedProtocols get the //.  Not mailto:, xmpp:, etc.
   * unless they had them to begin with.
   */if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==false){host='//'+(host||'');if(pathname&&pathname.charAt(0)!=='/'){pathname='/'+pathname;}}else if(!host){host='';}if(hash&&hash.charAt(0)!=='#'){hash='#'+hash;}if(search&&search.charAt(0)!=='?'){search='?'+search;}pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match);});search=search.replace('#','%23');return protocol+host+pathname+search+hash;};function urlResolve(source,relative){return urlParse(source,false,true).resolve(relative);}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,false,true)).format();};function urlResolveObject(source,relative){if(!source){return relative;}return urlParse(source,false,true).resolveObject(relative);}Url.prototype.resolveObject=function(relative){if(typeof relative==='string'){var rel=new Url();rel.parse(relative,false,true);relative=rel;}var result=new Url();var tkeys=Object.keys(this);for(var tk=0;tk<tkeys.length;tk++){var tkey=tkeys[tk];result[tkey]=this[tkey];}/*
   * hash is always overridden, no matter what.
   * even href="" will remove it.
   */result.hash=relative.hash;// if the relative url is empty, then there's nothing left to do here.
if(relative.href===''){result.href=result.format();return result;}// hrefs like //foo/bar always cut to the protocol.
if(relative.slashes&&!relative.protocol){// take everything except the protocol from relative
var rkeys=Object.keys(relative);for(var rk=0;rk<rkeys.length;rk++){var rkey=rkeys[rk];if(rkey!=='protocol'){result[rkey]=relative[rkey];}}// urlParse appends trailing / to urls like http://www.example.com
if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname){result.pathname='/';result.path=result.pathname;}result.href=result.format();return result;}if(relative.protocol&&relative.protocol!==result.protocol){/*
     * if it's a known url protocol, then changing
     * the protocol does weird things
     * first, if it's not file:, then we MUST have a host,
     * and if there was a path
     * to begin with, then we MUST have a path.
     * if it is file:, then the host is dropped,
     * because that's known to be hostless.
     * anything else is assumed to be absolute.
     */if(!slashedProtocol[relative.protocol]){var keys=Object.keys(relative);for(var v=0;v<keys.length;v++){var k=keys[v];result[k]=relative[k];}result.href=result.format();return result;}result.protocol=relative.protocol;if(!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||'').split('/');while(relPath.length&&!(relative.host=relPath.shift())){}if(!relative.host){relative.host='';}if(!relative.hostname){relative.hostname='';}if(relPath[0]!==''){relPath.unshift('');}if(relPath.length<2){relPath.unshift('');}result.pathname=relPath.join('/');}else{result.pathname=relative.pathname;}result.search=relative.search;result.query=relative.query;result.host=relative.host||'';result.auth=relative.auth;result.hostname=relative.hostname||relative.host;result.port=relative.port;// to support http.request
if(result.pathname||result.search){var p=result.pathname||'';var s=result.search||'';result.path=p+s;}result.slashes=result.slashes||relative.slashes;result.href=result.format();return result;}var isSourceAbs=result.pathname&&result.pathname.charAt(0)==='/',isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)==='/',mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split('/')||[],relPath=relative.pathname&&relative.pathname.split('/')||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];/*
   * if the url is a non-slashed url, then relative
   * links like ../.. should be able
   * to crawl up to the hostname, as well.  This is strange.
   * result.protocol has already been set by now.
   * Later on, put the first path part into the host field.
   */if(psychotic){result.hostname='';result.port=null;if(result.host){if(srcPath[0]===''){srcPath[0]=result.host;}else{srcPath.unshift(result.host);}}result.host='';if(relative.protocol){relative.hostname=null;relative.port=null;if(relative.host){if(relPath[0]===''){relPath[0]=relative.host;}else{relPath.unshift(relative.host);}}relative.host=null;}mustEndAbs=mustEndAbs&&(relPath[0]===''||srcPath[0]==='');}if(isRelAbs){// it's absolute.
result.host=relative.host||relative.host===''?relative.host:result.host;result.hostname=relative.hostname||relative.hostname===''?relative.hostname:result.hostname;result.search=relative.search;result.query=relative.query;srcPath=relPath;// fall through to the dot-handling below.
}else if(relPath.length){/*
     * it's relative
     * throw away the existing file, and take the new path instead.
     */if(!srcPath){srcPath=[];}srcPath.pop();srcPath=srcPath.concat(relPath);result.search=relative.search;result.query=relative.query;}else if(relative.search!=null){/*
     * just pull out the search.
     * like href='?foo'.
     * Put this after the other two cases because it simplifies the booleans
     */if(psychotic){result.host=srcPath.shift();result.hostname=result.host;/*
       * occationaly the auth can get stuck only in host
       * this especially happens in cases like
       * url.resolveObject('mailto:local1@domain1', 'local2@domain2')
       */var authInHost=result.host&&result.host.indexOf('@')>0?result.host.split('@'):false;if(authInHost){result.auth=authInHost.shift();result.hostname=authInHost.shift();result.host=result.hostname;}}result.search=relative.search;result.query=relative.query;// to support http.request
if(result.pathname!==null||result.search!==null){result.path=(result.pathname?result.pathname:'')+(result.search?result.search:'');}result.href=result.format();return result;}if(!srcPath.length){/*
     * no path at all.  easy.
     * we've already handled the other stuff above.
     */result.pathname=null;// to support http.request
if(result.search){result.path='/'+result.search;}else{result.path=null;}result.href=result.format();return result;}/*
   * if a url ENDs in . or .., then it must get a trailing slash.
   * however, if it ends in anything else non-slashy,
   * then it must NOT get a trailing slash.
   */var last=srcPath.slice(-1)[0];var hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last==='.'||last==='..')||last==='';/*
   * strip single dots, resolve double dots to parent dir
   * if the path tries to go above the root, `up` ends up > 0
   */var up=0;for(var i=srcPath.length;i>=0;i--){last=srcPath[i];if(last==='.'){srcPath.splice(i,1);}else if(last==='..'){srcPath.splice(i,1);up++;}else if(up){srcPath.splice(i,1);up--;}}// if the path is allowed to go above the root, restore leading ..s
if(!mustEndAbs&&!removeAllDots){for(;up--;up){srcPath.unshift('..');}}if(mustEndAbs&&srcPath[0]!==''&&(!srcPath[0]||srcPath[0].charAt(0)!=='/')){srcPath.unshift('');}if(hasTrailingSlash&&srcPath.join('/').substr(-1)!=='/'){srcPath.push('');}var isAbsolute=srcPath[0]===''||srcPath[0]&&srcPath[0].charAt(0)==='/';// put the host back
if(psychotic){result.hostname=isAbsolute?'':srcPath.length?srcPath.shift():'';result.host=result.hostname;/*
     * occationaly the auth can get stuck only in host
     * this especially happens in cases like
     * url.resolveObject('mailto:local1@domain1', 'local2@domain2')
     */var authInHost=result.host&&result.host.indexOf('@')>0?result.host.split('@'):false;if(authInHost){result.auth=authInHost.shift();result.hostname=authInHost.shift();result.host=result.hostname;}}mustEndAbs=mustEndAbs||result.host&&srcPath.length;if(mustEndAbs&&!isAbsolute){srcPath.unshift('');}if(srcPath.length>0){result.pathname=srcPath.join('/');}else{result.pathname=null;result.path=null;}// to support request.http
if(result.pathname!==null||result.search!==null){result.path=(result.pathname?result.pathname:'')+(result.search?result.search:'');}result.auth=relative.auth||result.auth;result.slashes=result.slashes||relative.slashes;result.href=result.format();return result;};Url.prototype.parseHost=function(){var host=this.host;var port=portPattern.exec(host);if(port){port=port[0];if(port!==':'){this.port=port.substr(1);}host=host.substr(0,host.length-port.length);}if(host){this.hostname=host;}};exports.parse=urlParse;exports.resolve=urlResolve;exports.resolveObject=urlResolveObject;exports.format=urlFormat;exports.Url=Url;

/***/ }),

/***/ 86973:
/***/ (function() {

/* (ignored) */

/***/ }),

/***/ 27762:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isCallable=__webpack_require__(83869);var tryToString=__webpack_require__(90799);var $TypeError=TypeError;// `Assert: IsCallable(argument) is true`
module.exports=function(argument){if(isCallable(argument))return argument;throw new $TypeError(tryToString(argument)+' is not a function');};

/***/ }),

/***/ 56127:
/***/ (function(module) {

"use strict";
var $TypeError=TypeError;module.exports=function(argument){if(typeof argument=='string')return argument;throw new $TypeError('Argument is not a string');};

/***/ }),

/***/ 71436:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isObject=__webpack_require__(98970);var $String=String;var $TypeError=TypeError;module.exports=function(argument){if(argument===undefined||isObject(argument))return argument;throw new $TypeError($String(argument)+' is not an object or undefined');};

/***/ }),

/***/ 16127:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isObject=__webpack_require__(98970);var $String=String;var $TypeError=TypeError;// `Assert: Type(argument) is Object`
module.exports=function(argument){if(isObject(argument))return argument;throw new $TypeError($String(argument)+' is not an object');};

/***/ }),

/***/ 72514:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var classof=__webpack_require__(90803);var $TypeError=TypeError;// Perform ? RequireInternalSlot(argument, [[TypedArrayName]])
// If argument.[[TypedArrayName]] is not "Uint8Array", throw a TypeError exception
module.exports=function(argument){if(classof(argument)==='Uint8Array')return argument;throw new $TypeError('Argument is not an Uint8Array');};

/***/ }),

/***/ 34523:
/***/ (function(module) {

"use strict";
// eslint-disable-next-line es/no-typed-arrays -- safe
module.exports=typeof ArrayBuffer!='undefined'&&typeof DataView!='undefined';

/***/ }),

/***/ 39453:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var uncurryThisAccessor=__webpack_require__(29338);var classof=__webpack_require__(39400);var ArrayBuffer=globalThis.ArrayBuffer;var TypeError=globalThis.TypeError;// Includes
// - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
// - If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
module.exports=ArrayBuffer&&uncurryThisAccessor(ArrayBuffer.prototype,'byteLength','get')||function(O){if(classof(O)!=='ArrayBuffer')throw new TypeError('ArrayBuffer expected');return O.byteLength;};

/***/ }),

/***/ 91086:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var NATIVE_ARRAY_BUFFER=__webpack_require__(34523);var arrayBufferByteLength=__webpack_require__(39453);var DataView=globalThis.DataView;module.exports=function(O){if(!NATIVE_ARRAY_BUFFER||arrayBufferByteLength(O)!==0)return false;try{// eslint-disable-next-line no-new -- thrower
new DataView(O);return false;}catch(error){return true;}};

/***/ }),

/***/ 26121:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isDetached=__webpack_require__(91086);var $TypeError=TypeError;module.exports=function(it){if(isDetached(it))throw new $TypeError('ArrayBuffer is detached');return it;};

/***/ }),

/***/ 74866:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var lengthOfArrayLike=__webpack_require__(51918);module.exports=function(Constructor,list,$length){var index=0;var length=arguments.length>2?$length:lengthOfArrayLike(list);var result=new Constructor(length);while(length>index)result[index]=list[index++];return result;};

/***/ }),

/***/ 71545:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var toIndexedObject=__webpack_require__(2349);var toAbsoluteIndex=__webpack_require__(38258);var lengthOfArrayLike=__webpack_require__(51918);// `Array.prototype.{ indexOf, includes }` methods implementation
var createMethod=function(IS_INCLUDES){return function($this,el,fromIndex){var O=toIndexedObject($this);var length=lengthOfArrayLike(O);if(length===0)return!IS_INCLUDES&&-1;var index=toAbsoluteIndex(fromIndex,length);var value;// Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare -- NaN check
if(IS_INCLUDES&&el!==el)while(length>index){value=O[index++];// eslint-disable-next-line no-self-compare -- NaN check
if(value!==value)return true;// Array#indexOf ignores holes, Array#includes - not
}else for(;length>index;index++){if((IS_INCLUDES||index in O)&&O[index]===el)return IS_INCLUDES||index||0;}return!IS_INCLUDES&&-1;};};module.exports={// `Array.prototype.includes` method
// https://tc39.es/ecma262/#sec-array.prototype.includes
includes:createMethod(true),// `Array.prototype.indexOf` method
// https://tc39.es/ecma262/#sec-array.prototype.indexof
indexOf:createMethod(false)};

/***/ }),

/***/ 76428:
/***/ (function(module) {

"use strict";
var commonAlphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';var base64Alphabet=commonAlphabet+'+/';var base64UrlAlphabet=commonAlphabet+'-_';var inverse=function(characters){// TODO: use `Object.create(null)` in `core-js@4`
var result={};var index=0;for(;index<64;index++)result[characters.charAt(index)]=index;return result;};module.exports={i2c:base64Alphabet,c2i:inverse(base64Alphabet),i2cUrl:base64UrlAlphabet,c2iUrl:inverse(base64UrlAlphabet)};

/***/ }),

/***/ 39400:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var toString=uncurryThis({}.toString);var stringSlice=uncurryThis(''.slice);module.exports=function(it){return stringSlice(toString(it),8,-1);};

/***/ }),

/***/ 90803:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var TO_STRING_TAG_SUPPORT=__webpack_require__(64244);var isCallable=__webpack_require__(83869);var classofRaw=__webpack_require__(39400);var wellKnownSymbol=__webpack_require__(51275);var TO_STRING_TAG=wellKnownSymbol('toStringTag');var $Object=Object;// ES3 wrong here
var CORRECT_ARGUMENTS=classofRaw(function(){return arguments;}())==='Arguments';// fallback for IE11 Script Access Denied error
var tryGet=function(it,key){try{return it[key];}catch(error){/* empty */}};// getting tag from ES6+ `Object.prototype.toString`
module.exports=TO_STRING_TAG_SUPPORT?classofRaw:function(it){var O,tag,result;return it===undefined?'Undefined':it===null?'Null'// @@toStringTag case
:typeof(tag=tryGet(O=$Object(it),TO_STRING_TAG))=='string'?tag// builtinTag case
:CORRECT_ARGUMENTS?classofRaw(O)// ES3 arguments fallback
:(result=classofRaw(O))==='Object'&&isCallable(O.callee)?'Arguments':result;};

/***/ }),

/***/ 82836:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var hasOwn=__webpack_require__(22233);var ownKeys=__webpack_require__(4687);var getOwnPropertyDescriptorModule=__webpack_require__(2443);var definePropertyModule=__webpack_require__(27705);module.exports=function(target,source,exceptions){var keys=ownKeys(source);var defineProperty=definePropertyModule.f;var getOwnPropertyDescriptor=getOwnPropertyDescriptorModule.f;for(var i=0;i<keys.length;i++){var key=keys[i];if(!hasOwn(target,key)&&!(exceptions&&hasOwn(exceptions,key))){defineProperty(target,key,getOwnPropertyDescriptor(source,key));}}};

/***/ }),

/***/ 95427:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var definePropertyModule=__webpack_require__(27705);var createPropertyDescriptor=__webpack_require__(59948);module.exports=DESCRIPTORS?function(object,key,value){return definePropertyModule.f(object,key,createPropertyDescriptor(1,value));}:function(object,key,value){object[key]=value;return object;};

/***/ }),

/***/ 59948:
/***/ (function(module) {

"use strict";
module.exports=function(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value};};

/***/ }),

/***/ 36256:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isCallable=__webpack_require__(83869);var definePropertyModule=__webpack_require__(27705);var makeBuiltIn=__webpack_require__(78211);var defineGlobalProperty=__webpack_require__(5249);module.exports=function(O,key,value,options){if(!options)options={};var simple=options.enumerable;var name=options.name!==undefined?options.name:key;if(isCallable(value))makeBuiltIn(value,name,options);if(options.global){if(simple)O[key]=value;else defineGlobalProperty(key,value);}else{try{if(!options.unsafe)delete O[key];else if(O[key])simple=true;}catch(error){/* empty */}if(simple)O[key]=value;else definePropertyModule.f(O,key,{value:value,enumerable:false,configurable:!options.nonConfigurable,writable:!options.nonWritable});}return O;};

/***/ }),

/***/ 5249:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);// eslint-disable-next-line es/no-object-defineproperty -- safe
var defineProperty=Object.defineProperty;module.exports=function(key,value){try{defineProperty(globalThis,key,{value:value,configurable:true,writable:true});}catch(error){globalThis[key]=value;}return value;};

/***/ }),

/***/ 44164:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var fails=__webpack_require__(6615);// Detect IE8's incomplete defineProperty implementation
module.exports=!fails(function(){// eslint-disable-next-line es/no-object-defineproperty -- required for testing
return Object.defineProperty({},1,{get:function(){return 7;}})[1]!==7;});

/***/ }),

/***/ 62607:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var isObject=__webpack_require__(98970);var document=globalThis.document;// typeof document.createElement is 'object' in old IE
var EXISTS=isObject(document)&&isObject(document.createElement);module.exports=function(it){return EXISTS?document.createElement(it):{};};

/***/ }),

/***/ 43663:
/***/ (function(module) {

"use strict";
// IE8- don't enum bug keys
module.exports=['constructor','hasOwnProperty','isPrototypeOf','propertyIsEnumerable','toLocaleString','toString','valueOf'];

/***/ }),

/***/ 4591:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var navigator=globalThis.navigator;var userAgent=navigator&&navigator.userAgent;module.exports=userAgent?String(userAgent):'';

/***/ }),

/***/ 40583:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var userAgent=__webpack_require__(4591);var process=globalThis.process;var Deno=globalThis.Deno;var versions=process&&process.versions||Deno&&Deno.version;var v8=versions&&versions.v8;var match,version;if(v8){match=v8.split('.');// in old Chrome, versions of V8 isn't V8 = Chrome / 10
// but their correct versions are not interesting for us
version=match[0]>0&&match[0]<4?1:+(match[0]+match[1]);}// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
// so check `userAgent` even if `.v8` exists, but 0
if(!version&&userAgent){match=userAgent.match(/Edge\/(\d+)/);if(!match||match[1]>=74){match=userAgent.match(/Chrome\/(\d+)/);if(match)version=+match[1];}}module.exports=version;

/***/ }),

/***/ 48094:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var getOwnPropertyDescriptor=(__webpack_require__(2443).f);var createNonEnumerableProperty=__webpack_require__(95427);var defineBuiltIn=__webpack_require__(36256);var defineGlobalProperty=__webpack_require__(5249);var copyConstructorProperties=__webpack_require__(82836);var isForced=__webpack_require__(81444);/*
  options.target         - name of the target object
  options.global         - target is the global object
  options.stat           - export as static methods of target
  options.proto          - export as prototype methods of target
  options.real           - real prototype method for the `pure` version
  options.forced         - export even if the native feature is available
  options.bind           - bind methods to the target, required for the `pure` version
  options.wrap           - wrap constructors to preventing global pollution, required for the `pure` version
  options.unsafe         - use the simple assignment of property instead of delete + defineProperty
  options.sham           - add a flag to not completely full polyfills
  options.enumerable     - export as enumerable property
  options.dontCallGetSet - prevent calling a getter on target
  options.name           - the .name of the function if it does not match the key
*/module.exports=function(options,source){var TARGET=options.target;var GLOBAL=options.global;var STATIC=options.stat;var FORCED,target,key,targetProperty,sourceProperty,descriptor;if(GLOBAL){target=globalThis;}else if(STATIC){target=globalThis[TARGET]||defineGlobalProperty(TARGET,{});}else{target=globalThis[TARGET]&&globalThis[TARGET].prototype;}if(target)for(key in source){sourceProperty=source[key];if(options.dontCallGetSet){descriptor=getOwnPropertyDescriptor(target,key);targetProperty=descriptor&&descriptor.value;}else targetProperty=target[key];FORCED=isForced(GLOBAL?key:TARGET+(STATIC?'.':'#')+key,options.forced);// contained in target
if(!FORCED&&targetProperty!==undefined){if(typeof sourceProperty==typeof targetProperty)continue;copyConstructorProperties(sourceProperty,targetProperty);}// add a flag to not completely full polyfills
if(options.sham||targetProperty&&targetProperty.sham){createNonEnumerableProperty(sourceProperty,'sham',true);}defineBuiltIn(target,key,sourceProperty,options);}};

/***/ }),

/***/ 6615:
/***/ (function(module) {

"use strict";
module.exports=function(exec){try{return!!exec();}catch(error){return true;}};

/***/ }),

/***/ 62416:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var fails=__webpack_require__(6615);module.exports=!fails(function(){// eslint-disable-next-line es/no-function-prototype-bind -- safe
var test=function(){/* empty */}.bind();// eslint-disable-next-line no-prototype-builtins -- safe
return typeof test!='function'||test.hasOwnProperty('prototype');});

/***/ }),

/***/ 10149:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var NATIVE_BIND=__webpack_require__(62416);var call=Function.prototype.call;// eslint-disable-next-line es/no-function-prototype-bind -- safe
module.exports=NATIVE_BIND?call.bind(call):function(){return call.apply(call,arguments);};

/***/ }),

/***/ 45878:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var hasOwn=__webpack_require__(22233);var FunctionPrototype=Function.prototype;// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var getDescriptor=DESCRIPTORS&&Object.getOwnPropertyDescriptor;var EXISTS=hasOwn(FunctionPrototype,'name');// additional protection from minified / mangled / dropped function names
var PROPER=EXISTS&&function something(){/* empty */}.name==='something';var CONFIGURABLE=EXISTS&&(!DESCRIPTORS||DESCRIPTORS&&getDescriptor(FunctionPrototype,'name').configurable);module.exports={EXISTS:EXISTS,PROPER:PROPER,CONFIGURABLE:CONFIGURABLE};

/***/ }),

/***/ 29338:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var aCallable=__webpack_require__(27762);module.exports=function(object,key,method){try{// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object,key)[method]));}catch(error){/* empty */}};

/***/ }),

/***/ 61512:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var NATIVE_BIND=__webpack_require__(62416);var FunctionPrototype=Function.prototype;var call=FunctionPrototype.call;// eslint-disable-next-line es/no-function-prototype-bind -- safe
var uncurryThisWithBind=NATIVE_BIND&&FunctionPrototype.bind.bind(call,call);module.exports=NATIVE_BIND?uncurryThisWithBind:function(fn){return function(){return call.apply(fn,arguments);};};

/***/ }),

/***/ 85256:
/***/ (function(module) {

"use strict";
var $TypeError=TypeError;module.exports=function(options){var alphabet=options&&options.alphabet;if(alphabet===undefined||alphabet==='base64'||alphabet==='base64url')return alphabet||'base64';throw new $TypeError('Incorrect `alphabet` option');};

/***/ }),

/***/ 4095:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var isCallable=__webpack_require__(83869);var aFunction=function(argument){return isCallable(argument)?argument:undefined;};module.exports=function(namespace,method){return arguments.length<2?aFunction(globalThis[namespace]):globalThis[namespace]&&globalThis[namespace][method];};

/***/ }),

/***/ 90022:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var aCallable=__webpack_require__(27762);var isNullOrUndefined=__webpack_require__(12237);// `GetMethod` abstract operation
// https://tc39.es/ecma262/#sec-getmethod
module.exports=function(V,P){var func=V[P];return isNullOrUndefined(func)?undefined:aCallable(func);};

/***/ }),

/***/ 75864:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var check=function(it){return it&&it.Math===Math&&it;};// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
module.exports=// eslint-disable-next-line es/no-global-this -- safe
check(typeof globalThis=='object'&&globalThis)||check(typeof window=='object'&&window)||// eslint-disable-next-line no-restricted-globals -- safe
check(typeof self=='object'&&self)||check(typeof __webpack_require__.g=='object'&&__webpack_require__.g)||check(typeof this=='object'&&this)||// eslint-disable-next-line no-new-func -- fallback
function(){return this;}()||Function('return this')();

/***/ }),

/***/ 22233:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var toObject=__webpack_require__(39533);var hasOwnProperty=uncurryThis({}.hasOwnProperty);// `HasOwnProperty` abstract operation
// https://tc39.es/ecma262/#sec-hasownproperty
// eslint-disable-next-line es/no-object-hasown -- safe
module.exports=Object.hasOwn||function hasOwn(it,key){return hasOwnProperty(toObject(it),key);};

/***/ }),

/***/ 40269:
/***/ (function(module) {

"use strict";
module.exports={};

/***/ }),

/***/ 45269:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var fails=__webpack_require__(6615);var createElement=__webpack_require__(62607);// Thanks to IE8 for its funny defineProperty
module.exports=!DESCRIPTORS&&!fails(function(){// eslint-disable-next-line es/no-object-defineproperty -- required for testing
return Object.defineProperty(createElement('div'),'a',{get:function(){return 7;}}).a!==7;});

/***/ }),

/***/ 63383:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var fails=__webpack_require__(6615);var classof=__webpack_require__(39400);var $Object=Object;var split=uncurryThis(''.split);// fallback for non-array-like ES3 and non-enumerable old V8 strings
module.exports=fails(function(){// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
// eslint-disable-next-line no-prototype-builtins -- safe
return!$Object('z').propertyIsEnumerable(0);})?function(it){return classof(it)==='String'?split(it,''):$Object(it);}:$Object;

/***/ }),

/***/ 85042:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var isCallable=__webpack_require__(83869);var store=__webpack_require__(47221);var functionToString=uncurryThis(Function.toString);// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
if(!isCallable(store.inspectSource)){store.inspectSource=function(it){return functionToString(it);};}module.exports=store.inspectSource;

/***/ }),

/***/ 24965:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var NATIVE_WEAK_MAP=__webpack_require__(29110);var globalThis=__webpack_require__(75864);var isObject=__webpack_require__(98970);var createNonEnumerableProperty=__webpack_require__(95427);var hasOwn=__webpack_require__(22233);var shared=__webpack_require__(47221);var sharedKey=__webpack_require__(73327);var hiddenKeys=__webpack_require__(40269);var OBJECT_ALREADY_INITIALIZED='Object already initialized';var TypeError=globalThis.TypeError;var WeakMap=globalThis.WeakMap;var set,get,has;var enforce=function(it){return has(it)?get(it):set(it,{});};var getterFor=function(TYPE){return function(it){var state;if(!isObject(it)||(state=get(it)).type!==TYPE){throw new TypeError('Incompatible receiver, '+TYPE+' required');}return state;};};if(NATIVE_WEAK_MAP||shared.state){var store=shared.state||(shared.state=new WeakMap());/* eslint-disable no-self-assign -- prototype methods protection */store.get=store.get;store.has=store.has;store.set=store.set;/* eslint-enable no-self-assign -- prototype methods protection */set=function(it,metadata){if(store.has(it))throw new TypeError(OBJECT_ALREADY_INITIALIZED);metadata.facade=it;store.set(it,metadata);return metadata;};get=function(it){return store.get(it)||{};};has=function(it){return store.has(it);};}else{var STATE=sharedKey('state');hiddenKeys[STATE]=true;set=function(it,metadata){if(hasOwn(it,STATE))throw new TypeError(OBJECT_ALREADY_INITIALIZED);metadata.facade=it;createNonEnumerableProperty(it,STATE,metadata);return metadata;};get=function(it){return hasOwn(it,STATE)?it[STATE]:{};};has=function(it){return hasOwn(it,STATE);};}module.exports={set:set,get:get,has:has,enforce:enforce,getterFor:getterFor};

/***/ }),

/***/ 83869:
/***/ (function(module) {

"use strict";
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
var documentAll=typeof document=='object'&&document.all;// `IsCallable` abstract operation
// https://tc39.es/ecma262/#sec-iscallable
// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
module.exports=typeof documentAll=='undefined'&&documentAll!==undefined?function(argument){return typeof argument=='function'||argument===documentAll;}:function(argument){return typeof argument=='function';};

/***/ }),

/***/ 81444:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var fails=__webpack_require__(6615);var isCallable=__webpack_require__(83869);var replacement=/#|\.prototype\./;var isForced=function(feature,detection){var value=data[normalize(feature)];return value===POLYFILL?true:value===NATIVE?false:isCallable(detection)?fails(detection):!!detection;};var normalize=isForced.normalize=function(string){return String(string).replace(replacement,'.').toLowerCase();};var data=isForced.data={};var NATIVE=isForced.NATIVE='N';var POLYFILL=isForced.POLYFILL='P';module.exports=isForced;

/***/ }),

/***/ 12237:
/***/ (function(module) {

"use strict";
// we can't use just `it == null` since of `document.all` special case
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
module.exports=function(it){return it===null||it===undefined;};

/***/ }),

/***/ 98970:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isCallable=__webpack_require__(83869);module.exports=function(it){return typeof it=='object'?it!==null:isCallable(it);};

/***/ }),

/***/ 11523:
/***/ (function(module) {

"use strict";
module.exports=false;

/***/ }),

/***/ 84829:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var getBuiltIn=__webpack_require__(4095);var isCallable=__webpack_require__(83869);var isPrototypeOf=__webpack_require__(81185);var USE_SYMBOL_AS_UID=__webpack_require__(33464);var $Object=Object;module.exports=USE_SYMBOL_AS_UID?function(it){return typeof it=='symbol';}:function(it){var $Symbol=getBuiltIn('Symbol');return isCallable($Symbol)&&isPrototypeOf($Symbol.prototype,$Object(it));};

/***/ }),

/***/ 51918:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var toLength=__webpack_require__(21926);// `LengthOfArrayLike` abstract operation
// https://tc39.es/ecma262/#sec-lengthofarraylike
module.exports=function(obj){return toLength(obj.length);};

/***/ }),

/***/ 78211:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var fails=__webpack_require__(6615);var isCallable=__webpack_require__(83869);var hasOwn=__webpack_require__(22233);var DESCRIPTORS=__webpack_require__(44164);var CONFIGURABLE_FUNCTION_NAME=(__webpack_require__(45878).CONFIGURABLE);var inspectSource=__webpack_require__(85042);var InternalStateModule=__webpack_require__(24965);var enforceInternalState=InternalStateModule.enforce;var getInternalState=InternalStateModule.get;var $String=String;// eslint-disable-next-line es/no-object-defineproperty -- safe
var defineProperty=Object.defineProperty;var stringSlice=uncurryThis(''.slice);var replace=uncurryThis(''.replace);var join=uncurryThis([].join);var CONFIGURABLE_LENGTH=DESCRIPTORS&&!fails(function(){return defineProperty(function(){/* empty */},'length',{value:8}).length!==8;});var TEMPLATE=String(String).split('String');var makeBuiltIn=module.exports=function(value,name,options){if(stringSlice($String(name),0,7)==='Symbol('){name='['+replace($String(name),/^Symbol\(([^)]*)\).*$/,'$1')+']';}if(options&&options.getter)name='get '+name;if(options&&options.setter)name='set '+name;if(!hasOwn(value,'name')||CONFIGURABLE_FUNCTION_NAME&&value.name!==name){if(DESCRIPTORS)defineProperty(value,'name',{value:name,configurable:true});else value.name=name;}if(CONFIGURABLE_LENGTH&&options&&hasOwn(options,'arity')&&value.length!==options.arity){defineProperty(value,'length',{value:options.arity});}try{if(options&&hasOwn(options,'constructor')&&options.constructor){if(DESCRIPTORS)defineProperty(value,'prototype',{writable:false});// in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
}else if(value.prototype)value.prototype=undefined;}catch(error){/* empty */}var state=enforceInternalState(value);if(!hasOwn(state,'source')){state.source=join(TEMPLATE,typeof name=='string'?name:'');}return value;};// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
// eslint-disable-next-line no-extend-native -- required
Function.prototype.toString=makeBuiltIn(function toString(){return isCallable(this)&&getInternalState(this).source||inspectSource(this);},'toString');

/***/ }),

/***/ 27533:
/***/ (function(module) {

"use strict";
var ceil=Math.ceil;var floor=Math.floor;// `Math.trunc` method
// https://tc39.es/ecma262/#sec-math.trunc
// eslint-disable-next-line es/no-math-trunc -- safe
module.exports=Math.trunc||function trunc(x){var n=+x;return(n>0?floor:ceil)(n);};

/***/ }),

/***/ 27705:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var IE8_DOM_DEFINE=__webpack_require__(45269);var V8_PROTOTYPE_DEFINE_BUG=__webpack_require__(24054);var anObject=__webpack_require__(16127);var toPropertyKey=__webpack_require__(20753);var $TypeError=TypeError;// eslint-disable-next-line es/no-object-defineproperty -- safe
var $defineProperty=Object.defineProperty;// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var $getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;var ENUMERABLE='enumerable';var CONFIGURABLE='configurable';var WRITABLE='writable';// `Object.defineProperty` method
// https://tc39.es/ecma262/#sec-object.defineproperty
exports.f=DESCRIPTORS?V8_PROTOTYPE_DEFINE_BUG?function defineProperty(O,P,Attributes){anObject(O);P=toPropertyKey(P);anObject(Attributes);if(typeof O==='function'&&P==='prototype'&&'value'in Attributes&&WRITABLE in Attributes&&!Attributes[WRITABLE]){var current=$getOwnPropertyDescriptor(O,P);if(current&&current[WRITABLE]){O[P]=Attributes.value;Attributes={configurable:CONFIGURABLE in Attributes?Attributes[CONFIGURABLE]:current[CONFIGURABLE],enumerable:ENUMERABLE in Attributes?Attributes[ENUMERABLE]:current[ENUMERABLE],writable:false};}}return $defineProperty(O,P,Attributes);}:$defineProperty:function defineProperty(O,P,Attributes){anObject(O);P=toPropertyKey(P);anObject(Attributes);if(IE8_DOM_DEFINE)try{return $defineProperty(O,P,Attributes);}catch(error){/* empty */}if('get'in Attributes||'set'in Attributes)throw new $TypeError('Accessors not supported');if('value'in Attributes)O[P]=Attributes.value;return O;};

/***/ }),

/***/ 2443:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var call=__webpack_require__(10149);var propertyIsEnumerableModule=__webpack_require__(77453);var createPropertyDescriptor=__webpack_require__(59948);var toIndexedObject=__webpack_require__(2349);var toPropertyKey=__webpack_require__(20753);var hasOwn=__webpack_require__(22233);var IE8_DOM_DEFINE=__webpack_require__(45269);// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var $getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;// `Object.getOwnPropertyDescriptor` method
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
exports.f=DESCRIPTORS?$getOwnPropertyDescriptor:function getOwnPropertyDescriptor(O,P){O=toIndexedObject(O);P=toPropertyKey(P);if(IE8_DOM_DEFINE)try{return $getOwnPropertyDescriptor(O,P);}catch(error){/* empty */}if(hasOwn(O,P))return createPropertyDescriptor(!call(propertyIsEnumerableModule.f,O,P),O[P]);};

/***/ }),

/***/ 2408:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
var internalObjectKeys=__webpack_require__(94956);var enumBugKeys=__webpack_require__(43663);var hiddenKeys=enumBugKeys.concat('length','prototype');// `Object.getOwnPropertyNames` method
// https://tc39.es/ecma262/#sec-object.getownpropertynames
// eslint-disable-next-line es/no-object-getownpropertynames -- safe
exports.f=Object.getOwnPropertyNames||function getOwnPropertyNames(O){return internalObjectKeys(O,hiddenKeys);};

/***/ }),

/***/ 90605:
/***/ (function(__unused_webpack_module, exports) {

"use strict";
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
exports.f=Object.getOwnPropertySymbols;

/***/ }),

/***/ 81185:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);module.exports=uncurryThis({}.isPrototypeOf);

/***/ }),

/***/ 94956:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var hasOwn=__webpack_require__(22233);var toIndexedObject=__webpack_require__(2349);var indexOf=(__webpack_require__(71545).indexOf);var hiddenKeys=__webpack_require__(40269);var push=uncurryThis([].push);module.exports=function(object,names){var O=toIndexedObject(object);var i=0;var result=[];var key;for(key in O)!hasOwn(hiddenKeys,key)&&hasOwn(O,key)&&push(result,key);// Don't enum bug & hidden keys
while(names.length>i)if(hasOwn(O,key=names[i++])){~indexOf(result,key)||push(result,key);}return result;};

/***/ }),

/***/ 77453:
/***/ (function(__unused_webpack_module, exports) {

"use strict";
var $propertyIsEnumerable={}.propertyIsEnumerable;// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
var getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;// Nashorn ~ JDK8 bug
var NASHORN_BUG=getOwnPropertyDescriptor&&!$propertyIsEnumerable.call({1:2},1);// `Object.prototype.propertyIsEnumerable` method implementation
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
exports.f=NASHORN_BUG?function propertyIsEnumerable(V){var descriptor=getOwnPropertyDescriptor(this,V);return!!descriptor&&descriptor.enumerable;}:$propertyIsEnumerable;

/***/ }),

/***/ 29654:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var call=__webpack_require__(10149);var isCallable=__webpack_require__(83869);var isObject=__webpack_require__(98970);var $TypeError=TypeError;// `OrdinaryToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
module.exports=function(input,pref){var fn,val;if(pref==='string'&&isCallable(fn=input.toString)&&!isObject(val=call(fn,input)))return val;if(isCallable(fn=input.valueOf)&&!isObject(val=call(fn,input)))return val;if(pref!=='string'&&isCallable(fn=input.toString)&&!isObject(val=call(fn,input)))return val;throw new $TypeError("Can't convert object to primitive value");};

/***/ }),

/***/ 4687:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var getBuiltIn=__webpack_require__(4095);var uncurryThis=__webpack_require__(61512);var getOwnPropertyNamesModule=__webpack_require__(2408);var getOwnPropertySymbolsModule=__webpack_require__(90605);var anObject=__webpack_require__(16127);var concat=uncurryThis([].concat);// all object keys, includes non-enumerable and symbols
module.exports=getBuiltIn('Reflect','ownKeys')||function ownKeys(it){var keys=getOwnPropertyNamesModule.f(anObject(it));var getOwnPropertySymbols=getOwnPropertySymbolsModule.f;return getOwnPropertySymbols?concat(keys,getOwnPropertySymbols(it)):keys;};

/***/ }),

/***/ 96238:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var isNullOrUndefined=__webpack_require__(12237);var $TypeError=TypeError;// `RequireObjectCoercible` abstract operation
// https://tc39.es/ecma262/#sec-requireobjectcoercible
module.exports=function(it){if(isNullOrUndefined(it))throw new $TypeError("Can't call method on "+it);return it;};

/***/ }),

/***/ 73327:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var shared=__webpack_require__(50601);var uid=__webpack_require__(18392);var keys=shared('keys');module.exports=function(key){return keys[key]||(keys[key]=uid(key));};

/***/ }),

/***/ 47221:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var IS_PURE=__webpack_require__(11523);var globalThis=__webpack_require__(75864);var defineGlobalProperty=__webpack_require__(5249);var SHARED='__core-js_shared__';var store=module.exports=globalThis[SHARED]||defineGlobalProperty(SHARED,{});(store.versions||(store.versions=[])).push({version:'3.49.0',mode:IS_PURE?'pure':'global',copyright:'© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.',license:'https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE',source:'https://github.com/zloirock/core-js'});

/***/ }),

/***/ 50601:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var store=__webpack_require__(47221);module.exports=function(key,value){return store[key]||(store[key]=value||{});};

/***/ }),

/***/ 49591:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
/* eslint-disable es/no-symbol -- required for testing */var V8_VERSION=__webpack_require__(40583);var fails=__webpack_require__(6615);var globalThis=__webpack_require__(75864);var $String=globalThis.String;// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
module.exports=!!Object.getOwnPropertySymbols&&!fails(function(){var symbol=Symbol('symbol detection');// Chrome 38 Symbol has incorrect toString conversion
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
// nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
// of course, fail.
return!$String(symbol)||!(Object(symbol)instanceof Symbol)||// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
!Symbol.sham&&V8_VERSION&&V8_VERSION<41;});

/***/ }),

/***/ 38258:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var toIntegerOrInfinity=__webpack_require__(67635);var max=Math.max;var min=Math.min;// Helper for a popular repeating case of the spec:
// Let integer be ? ToInteger(index).
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
module.exports=function(index,length){var integer=toIntegerOrInfinity(index);return integer<0?max(integer+length,0):min(integer,length);};

/***/ }),

/***/ 2349:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// toObject with fallback for non-array-like ES3 strings
var IndexedObject=__webpack_require__(63383);var requireObjectCoercible=__webpack_require__(96238);module.exports=function(it){return IndexedObject(requireObjectCoercible(it));};

/***/ }),

/***/ 67635:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var trunc=__webpack_require__(27533);// `ToIntegerOrInfinity` abstract operation
// https://tc39.es/ecma262/#sec-tointegerorinfinity
module.exports=function(argument){var number=+argument;// eslint-disable-next-line no-self-compare -- NaN check
return number!==number||number===0?0:trunc(number);};

/***/ }),

/***/ 21926:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var toIntegerOrInfinity=__webpack_require__(67635);var min=Math.min;// `ToLength` abstract operation
// https://tc39.es/ecma262/#sec-tolength
module.exports=function(argument){var len=toIntegerOrInfinity(argument);return len>0?min(len,0x1FFFFFFFFFFFFF):0;// 2 ** 53 - 1 == 9007199254740991
};

/***/ }),

/***/ 39533:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var requireObjectCoercible=__webpack_require__(96238);var $Object=Object;// `ToObject` abstract operation
// https://tc39.es/ecma262/#sec-toobject
module.exports=function(argument){return $Object(requireObjectCoercible(argument));};

/***/ }),

/***/ 19729:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var call=__webpack_require__(10149);var isObject=__webpack_require__(98970);var isSymbol=__webpack_require__(84829);var getMethod=__webpack_require__(90022);var ordinaryToPrimitive=__webpack_require__(29654);var wellKnownSymbol=__webpack_require__(51275);var $TypeError=TypeError;var TO_PRIMITIVE=wellKnownSymbol('toPrimitive');// `ToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-toprimitive
module.exports=function(input,pref){if(!isObject(input)||isSymbol(input))return input;var exoticToPrim=getMethod(input,TO_PRIMITIVE);var result;if(exoticToPrim){if(pref===undefined)pref='default';result=call(exoticToPrim,input,pref);if(!isObject(result)||isSymbol(result))return result;throw new $TypeError("Can't convert object to primitive value");}if(pref===undefined)pref='number';return ordinaryToPrimitive(input,pref);};

/***/ }),

/***/ 20753:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var toPrimitive=__webpack_require__(19729);var isSymbol=__webpack_require__(84829);// `ToPropertyKey` abstract operation
// https://tc39.es/ecma262/#sec-topropertykey
module.exports=function(argument){var key=toPrimitive(argument,'string');return isSymbol(key)?key:key+'';};

/***/ }),

/***/ 64244:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var wellKnownSymbol=__webpack_require__(51275);var TO_STRING_TAG=wellKnownSymbol('toStringTag');var test={};// eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
test[TO_STRING_TAG]='z';module.exports=String(test)==='[object z]';

/***/ }),

/***/ 90799:
/***/ (function(module) {

"use strict";
var $String=String;module.exports=function(argument){try{return $String(argument);}catch(error){return'Object';}};

/***/ }),

/***/ 18392:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var uncurryThis=__webpack_require__(61512);var id=0;var postfix=Math.random();var toString=uncurryThis(1.1.toString);module.exports=function(key){return'Symbol('+(key===undefined?'':key)+')_'+toString(++id+postfix,36);};

/***/ }),

/***/ 59663:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var uncurryThis=__webpack_require__(61512);var anObjectOrUndefined=__webpack_require__(71436);var aString=__webpack_require__(56127);var hasOwn=__webpack_require__(22233);var base64Map=__webpack_require__(76428);var getAlphabetOption=__webpack_require__(85256);var notDetached=__webpack_require__(26121);var base64Alphabet=base64Map.c2i;var base64UrlAlphabet=base64Map.c2iUrl;var SyntaxError=globalThis.SyntaxError;var TypeError=globalThis.TypeError;var at=uncurryThis(''.charAt);var skipAsciiWhitespace=function(string,index){var length=string.length;for(;index<length;index++){var chr=at(string,index);if(chr!==' '&&chr!=='\t'&&chr!=='\n'&&chr!=='\f'&&chr!=='\r')break;}return index;};var decodeBase64Chunk=function(chunk,alphabet,throwOnExtraBits){var chunkLength=chunk.length;if(chunkLength<4){chunk+=chunkLength===2?'AA':'A';}var triplet=(alphabet[at(chunk,0)]<<18)+(alphabet[at(chunk,1)]<<12)+(alphabet[at(chunk,2)]<<6)+alphabet[at(chunk,3)];var chunkBytes=[triplet>>16&255,triplet>>8&255,triplet&255];if(chunkLength===2){if(throwOnExtraBits&&chunkBytes[1]!==0){throw new SyntaxError('Extra bits');}return[chunkBytes[0]];}if(chunkLength===3){if(throwOnExtraBits&&chunkBytes[2]!==0){throw new SyntaxError('Extra bits');}return[chunkBytes[0],chunkBytes[1]];}return chunkBytes;};var writeBytes=function(bytes,elements,written){var elementsLength=elements.length;for(var index=0;index<elementsLength;index++){bytes[written+index]=elements[index];}return written+elementsLength;};/* eslint-disable max-statements, max-depth -- TODO */module.exports=function(string,options,into,maxLength){aString(string);anObjectOrUndefined(options);var alphabet=getAlphabetOption(options)==='base64'?base64Alphabet:base64UrlAlphabet;var lastChunkHandling=options?options.lastChunkHandling:undefined;if(lastChunkHandling===undefined)lastChunkHandling='loose';if(lastChunkHandling!=='loose'&&lastChunkHandling!=='strict'&&lastChunkHandling!=='stop-before-partial'){throw new TypeError('Incorrect `lastChunkHandling` option');}if(into)notDetached(into.buffer);var stringLength=string.length;var bytes=into||[];var written=0;var read=0;var chunk='';var index=0;if(maxLength)while(true){index=skipAsciiWhitespace(string,index);if(index===stringLength){if(chunk.length>0){if(lastChunkHandling==='stop-before-partial'){break;}if(lastChunkHandling==='loose'){if(chunk.length===1){throw new SyntaxError('Malformed padding: exactly one additional character');}written=writeBytes(bytes,decodeBase64Chunk(chunk,alphabet,false),written);}else{throw new SyntaxError('Missing padding');}}read=stringLength;break;}var chr=at(string,index);++index;if(chr==='='){if(chunk.length<2){throw new SyntaxError('Padding is too early');}index=skipAsciiWhitespace(string,index);if(chunk.length===2){if(index===stringLength){if(lastChunkHandling==='stop-before-partial'){break;}throw new SyntaxError('Malformed padding: only one =');}if(at(string,index)==='='){++index;index=skipAsciiWhitespace(string,index);}}if(index<stringLength){throw new SyntaxError('Unexpected character after padding');}written=writeBytes(bytes,decodeBase64Chunk(chunk,alphabet,lastChunkHandling==='strict'),written);read=stringLength;break;}if(!hasOwn(alphabet,chr)){throw new SyntaxError('Unexpected character');}var remainingBytes=maxLength-written;if(remainingBytes===1&&chunk.length===2||remainingBytes===2&&chunk.length===3){// special case: we can fit exactly the number of bytes currently represented by chunk, so we were just checking for `=`
break;}chunk+=chr;if(chunk.length===4){written=writeBytes(bytes,decodeBase64Chunk(chunk,alphabet,false),written);chunk='';read=index;if(written===maxLength){break;}}}return{bytes:bytes,read:read,written:written};};

/***/ }),

/***/ 97687:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var uncurryThis=__webpack_require__(61512);var Uint8Array=globalThis.Uint8Array;var SyntaxError=globalThis.SyntaxError;var min=Math.min;var stringMatch=uncurryThis(''.match);module.exports=function(string,into){var stringLength=string.length;if(stringLength%2!==0)throw new SyntaxError('String should be an even number of characters');var maxLength=into?min(into.length,stringLength/2):stringLength/2;var bytes=into||new Uint8Array(maxLength);var segments=stringMatch(string,/.{2}/g);var written=0;for(;written<maxLength;written++){var result=+('0x'+segments[written]+'0');// eslint-disable-next-line no-self-compare -- NaN check
if(result!==result){throw new SyntaxError('String should only contain hex characters');}bytes[written]=result>>4;}return{bytes:bytes,read:written<<1};};

/***/ }),

/***/ 33464:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
/* eslint-disable es/no-symbol -- required for testing */var NATIVE_SYMBOL=__webpack_require__(49591);module.exports=NATIVE_SYMBOL&&!Symbol.sham&&typeof Symbol.iterator=='symbol';

/***/ }),

/***/ 24054:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var DESCRIPTORS=__webpack_require__(44164);var fails=__webpack_require__(6615);// V8 ~ Chrome 36-
// https://bugs.chromium.org/p/v8/issues/detail?id=3334
module.exports=DESCRIPTORS&&fails(function(){// eslint-disable-next-line es/no-object-defineproperty -- required for testing
return Object.defineProperty(function(){/* empty */},'prototype',{value:42,writable:false}).prototype!==42;});

/***/ }),

/***/ 29110:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var isCallable=__webpack_require__(83869);var WeakMap=globalThis.WeakMap;module.exports=isCallable(WeakMap)&&/native code/.test(String(WeakMap));

/***/ }),

/***/ 51275:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var globalThis=__webpack_require__(75864);var shared=__webpack_require__(50601);var hasOwn=__webpack_require__(22233);var uid=__webpack_require__(18392);var NATIVE_SYMBOL=__webpack_require__(49591);var USE_SYMBOL_AS_UID=__webpack_require__(33464);var Symbol=globalThis.Symbol;var WellKnownSymbolsStore=shared('wks');var createWellKnownSymbol=USE_SYMBOL_AS_UID?Symbol['for']||Symbol:Symbol&&Symbol.withoutSetter||uid;module.exports=function(name){if(!hasOwn(WellKnownSymbolsStore,name)){WellKnownSymbolsStore[name]=NATIVE_SYMBOL&&hasOwn(Symbol,name)?Symbol[name]:createWellKnownSymbol('Symbol.'+name);}return WellKnownSymbolsStore[name];};

/***/ }),

/***/ 25909:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var arrayFromConstructorAndList=__webpack_require__(74866);var $fromBase64=__webpack_require__(59663);var Uint8Array=globalThis.Uint8Array;var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS=!Uint8Array||!Uint8Array.fromBase64||!function(){// Webkit not throw an error on odd length string
try{Uint8Array.fromBase64('a');return;}catch(error){/* empty */}try{Uint8Array.fromBase64('',null);}catch(error){return true;}}();// `Uint8Array.fromBase64` method
// https://tc39.es/ecma262/#sec-uint8array.frombase64
if(Uint8Array)$({target:'Uint8Array',stat:true,forced:INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS},{fromBase64:function fromBase64(string/* , options */){var result=$fromBase64(string,arguments.length>1?arguments[1]:undefined,null,0x1FFFFFFFFFFFFF);return arrayFromConstructorAndList(Uint8Array,result.bytes);}});

/***/ }),

/***/ 42781:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var aString=__webpack_require__(56127);var $fromHex=__webpack_require__(97687);// `Uint8Array.fromHex` method
// https://tc39.es/ecma262/#sec-uint8array.fromhex
if(globalThis.Uint8Array)$({target:'Uint8Array',stat:true},{fromHex:function fromHex(string){return $fromHex(aString(string)).bytes;}});

/***/ }),

/***/ 62720:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var $fromBase64=__webpack_require__(59663);var anUint8Array=__webpack_require__(72514);var Uint8Array=globalThis.Uint8Array;var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS=!Uint8Array||!Uint8Array.prototype.setFromBase64||!function(){var target=new Uint8Array([255,255,255,255,255]);try{target.setFromBase64('',null);return;}catch(error){/* empty */}// Webkit not throw an error on odd length string
try{target.setFromBase64('a');return;}catch(error){/* empty */}try{target.setFromBase64('MjYyZg===');}catch(error){return target[0]===50&&target[1]===54&&target[2]===50&&target[3]===255&&target[4]===255;}}();// `Uint8Array.prototype.setFromBase64` method
// https://tc39.es/ecma262/#sec-uint8array.prototype.setfrombase64
if(Uint8Array)$({target:'Uint8Array',proto:true,forced:INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS},{setFromBase64:function setFromBase64(string/* , options */){anUint8Array(this);var result=$fromBase64(string,arguments.length>1?arguments[1]:undefined,this,this.length);return{read:result.read,written:result.written};}});

/***/ }),

/***/ 60330:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var aString=__webpack_require__(56127);var anUint8Array=__webpack_require__(72514);var notDetached=__webpack_require__(26121);var $fromHex=__webpack_require__(97687);// Should not throw an error on length-tracking views over ResizableArrayBuffer
// https://issues.chromium.org/issues/454630441
function throwsOnLengthTrackingView(){try{// eslint-disable-next-line es/no-resizable-and-growable-arraybuffers -- required for testing
var rab=new ArrayBuffer(16,{maxByteLength:1024});// eslint-disable-next-line es/no-uint8array-prototype-setfromhex, es/no-typed-arrays -- required for testing
new Uint8Array(rab).setFromHex('cafed00d');}catch(error){return true;}}// `Uint8Array.prototype.setFromHex` method
// https://tc39.es/ecma262/#sec-uint8array.prototype.setfromhex
if(globalThis.Uint8Array)$({target:'Uint8Array',proto:true,forced:throwsOnLengthTrackingView()},{setFromHex:function setFromHex(string){anUint8Array(this);aString(string);notDetached(this.buffer);var read=$fromHex(string,this).read;return{read:read,written:read/2};}});

/***/ }),

/***/ 98870:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var uncurryThis=__webpack_require__(61512);var anObjectOrUndefined=__webpack_require__(71436);var anUint8Array=__webpack_require__(72514);var notDetached=__webpack_require__(26121);var base64Map=__webpack_require__(76428);var getAlphabetOption=__webpack_require__(85256);var base64Alphabet=base64Map.i2c;var base64UrlAlphabet=base64Map.i2cUrl;var charAt=uncurryThis(''.charAt);var Uint8Array=globalThis.Uint8Array;var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS=!Uint8Array||!Uint8Array.prototype.toBase64||!function(){try{var target=new Uint8Array();target.toBase64(null);}catch(error){return true;}}();// `Uint8Array.prototype.toBase64` method
// https://tc39.es/ecma262/#sec-uint8array.prototype.tobase64
if(Uint8Array)$({target:'Uint8Array',proto:true,forced:INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS},{toBase64:function toBase64(/* options */){var array=anUint8Array(this);var options=arguments.length?anObjectOrUndefined(arguments[0]):undefined;var alphabet=getAlphabetOption(options)==='base64'?base64Alphabet:base64UrlAlphabet;var omitPadding=!!options&&!!options.omitPadding;notDetached(this.buffer);var result='';var i=0;var length=array.length;var triplet;var at=function(shift){return charAt(alphabet,triplet>>6*shift&63);};for(;i+2<length;i+=3){triplet=(array[i]<<16)+(array[i+1]<<8)+array[i+2];result+=at(3)+at(2)+at(1)+at(0);}if(i+2===length){triplet=(array[i]<<16)+(array[i+1]<<8);result+=at(3)+at(2)+at(1)+(omitPadding?'':'=');}else if(i+1===length){triplet=array[i]<<16;result+=at(3)+at(2)+(omitPadding?'':'==');}return result;}});

/***/ }),

/***/ 40384:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
var $=__webpack_require__(48094);var globalThis=__webpack_require__(75864);var uncurryThis=__webpack_require__(61512);var anUint8Array=__webpack_require__(72514);var notDetached=__webpack_require__(26121);var numberToString=uncurryThis(1.1.toString);var join=uncurryThis([].join);var $Array=Array;var Uint8Array=globalThis.Uint8Array;var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS=!Uint8Array||!Uint8Array.prototype.toHex||!function(){try{var target=new Uint8Array([255,255,255,255,255,255,255,255]);return target.toHex()==='ffffffffffffffff';}catch(error){return false;}}();// `Uint8Array.prototype.toHex` method
// https://tc39.es/ecma262/#sec-uint8array.prototype.tohex
if(Uint8Array)$({target:'Uint8Array',proto:true,forced:INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS},{toHex:function toHex(){anUint8Array(this);notDetached(this.buffer);var result=$Array(this.length);for(var i=0,length=this.length;i<length;i++){var hex=numberToString(this[i],16);result[i]=hex.length===1?'0'+hex:hex;}return join(result,'');}});

/***/ }),

/***/ 68576:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(25909);

/***/ }),

/***/ 39562:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(42781);

/***/ }),

/***/ 10677:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(62720);

/***/ }),

/***/ 47389:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(60330);

/***/ }),

/***/ 96167:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(98870);

/***/ }),

/***/ 91967:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// TODO: Remove from `core-js@4`
__webpack_require__(40384);

/***/ }),

/***/ 14049:
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {

"use strict";
// https://github.com/tc39/proposal-arraybuffer-base64
__webpack_require__(68576);__webpack_require__(39562);__webpack_require__(10677);__webpack_require__(47389);__webpack_require__(96167);__webpack_require__(91967);

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/global */
/******/ 	!function() {
/******/ 		__webpack_require__.g = (function() {
/******/ 			if (typeof globalThis === 'object') return globalThis;
/******/ 			try {
/******/ 				return this || new Function('return this')();
/******/ 			} catch (e) {
/******/ 				if (typeof window === 'object') return window;
/******/ 			}
/******/ 		})();
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
!function() {
"use strict";

;// ./src/autofill/enums/autofill-overlay.enum.ts
const AutofillOverlayElement = {
    Button: "autofill-inline-menu-button",
    List: "autofill-inline-menu-list",
};
const AutofillOverlayPort = {
    Button: "autofill-inline-menu-button-port",
    ButtonMessageConnector: "autofill-inline-menu-button-message-connector",
    List: "autofill-inline-menu-list-port",
    ListMessageConnector: "autofill-inline-menu-list-message-connector",
};
const RedirectFocusDirection = {
    Current: "current",
    Previous: "previous",
    Next: "next",
};
const InlineMenuFillTypes = {
    AccountCreationUsername: 5,
    PasswordGeneration: 6,
    CurrentPasswordUpdate: 7,
};
const InlineMenuAccountCreationFieldType = {
    Text: "text",
    Email: "email",
    Password: "password",
    Totp: "totp",
};
const MAX_SUB_FRAME_DEPTH = 8;

;// ../../libs/common/src/autofill/constants/match-patterns.ts
const CardExpiryDateDelimiters = ["/", "-", ".", " "];
// `CardExpiryDateDelimiters` is not intended solely for regex consumption,
// so we need to format it here
const ExpiryDateDelimitersPattern = "\\" +
    CardExpiryDateDelimiters.join("\\")
        // replace space character with the regex whitespace character class
        .replace(" ", "s");
const MonthPattern = "(([1]{1}[0-2]{1})|(0?[1-9]{1}))";
// Because we're dealing with expiry dates, we assume the year will be in current or next century (as of 2024)
const ExpiryFullYearPattern = "2[0-1]{1}\\d{2}";
const DelimiterPatternExpression = new RegExp(`[${ExpiryDateDelimitersPattern}]`, "g");
const IrrelevantExpiryCharactersPatternExpression = new RegExp(
// "nor digits" to ensure numbers are removed from guidance pattern, which aren't covered by ^\w
`[^\\d${ExpiryDateDelimitersPattern}]`, "g");
const MonthPatternExpression = new RegExp(`^${MonthPattern}$`);
const ExpiryFullYearPatternExpression = new RegExp(`^${ExpiryFullYearPattern}$`);

;// ../../libs/common/src/autofill/constants/index.ts
const TYPE_CHECK = {
    FUNCTION: "function",
    NUMBER: "number",
    STRING: "string",
};
const EVENTS = {
    CHANGE: "change",
    INPUT: "input",
    KEYDOWN: "keydown",
    KEYPRESS: "keypress",
    KEYUP: "keyup",
    BLUR: "blur",
    CLICK: "click",
    FOCUS: "focus",
    FOCUSIN: "focusin",
    FOCUSOUT: "focusout",
    SCROLL: "scroll",
    RESIZE: "resize",
    DOMCONTENTLOADED: "DOMContentLoaded",
    LOAD: "load",
    MESSAGE: "message",
    VISIBILITYCHANGE: "visibilitychange",
    MOUSEENTER: "mouseenter",
    MOUSELEAVE: "mouseleave",
    MOUSEUP: "mouseup",
    MOUSEOUT: "mouseout",
    SUBMIT: "submit",
};
/**
 * HTML attributes observed by the MutationObserver for autofill form/field tracking.
 * If you need to observe a new attribute, add it here.
 */
const AUTOFILL_ATTRIBUTES = {
    ACTION: "action",
    ARIA_DESCRIBEDBY: "aria-describedby",
    ARIA_DISABLED: "aria-disabled",
    ARIA_HASPOPUP: "aria-haspopup",
    ARIA_HIDDEN: "aria-hidden",
    ARIA_LABEL: "aria-label",
    ARIA_LABELLEDBY: "aria-labelledby",
    AUTOCOMPLETE: "autocomplete",
    AUTOCOMPLETE_TYPE: "autocompletetype",
    X_AUTOCOMPLETE_TYPE: "x-autocompletetype",
    CHECKED: "checked",
    // CLASS intentionally omitted because it can cause a callback storm on dynamic pages.
    DATA_LABEL: "data-label",
    DATA_STRIPE: "data-stripe",
    DISABLED: "disabled",
    ID: "id",
    MAXLENGTH: "maxlength",
    METHOD: "method",
    NAME: "name",
    PLACEHOLDER: "placeholder",
    POPOVER: "popover",
    POPOVERTARGET: "popovertarget",
    POPOVERTARGETACTION: "popovertargetaction",
    READONLY: "readonly",
    REL: "rel",
    TABINDEX: "tabindex",
    TITLE: "title",
    TYPE: "type",
};
const ClearClipboardDelay = {
    Never: "never",
    TenSeconds: "tenSeconds",
    TwentySeconds: "twentySeconds",
    ThirtySeconds: "thirtySeconds",
    OneMinute: "oneMinute",
    TwoMinutes: "twoMinutes",
    FiveMinutes: "fiveMinutes",
};
/* Ids for context menu items and messaging events */
const AUTOFILL_CARD_ID = "autofill-card";
const AUTOFILL_ID = "autofill";
const SHOW_AUTOFILL_BUTTON = "show-autofill-button";
const AUTOFILL_IDENTITY_ID = "autofill-identity";
const AUTOFILL_TRIAGE_ID = "autofill-triage";
const COPY_IDENTIFIER_ID = "copy-identifier";
const COPY_PASSWORD_ID = "copy-password";
const COPY_USERNAME_ID = "copy-username";
const COPY_VERIFICATION_CODE_ID = "copy-totp";
const CREATE_CARD_ID = "create-card";
const CREATE_IDENTITY_ID = "create-identity";
const CREATE_LOGIN_ID = "create-login";
const GENERATE_PASSWORD_ID = "generate-password";
const NOOP_COMMAND_SUFFIX = "noop";
const ROOT_ID = "root";
const SEPARATOR_ID = "separator";
const UPDATE_PASSWORD = "update-password";
const NOTIFICATION_BAR_LIFESPAN_MS = 150000; // 150 seconds
const AUTOFILL_OVERLAY_HANDLE_REPOSITION = "autofill-overlay-handle-reposition-event";
const AUTOFILL_OVERLAY_HANDLE_SCROLL = "autofill-overlay-handle-scroll-event";
const UPDATE_PASSKEYS_HEADINGS_ON_SCROLL = "update-passkeys-headings-on-scroll";
const AUTOFILL_TRIGGER_FORM_FIELD_SUBMIT = "autofill-trigger-form-field-submit";
const AutofillOverlayVisibility = {
    Off: 0,
    OnButtonClick: 1,
    OnFieldFocus: 2,
};
const BrowserClientVendors = {
    Chrome: "Chrome",
    Firefox: "Firefox",
    Opera: "Opera",
    Edge: "Edge",
    Vivaldi: "Vivaldi",
    Unknown: "Unknown",
};
const BrowserShortcutsUris = {
    Chrome: "chrome://extensions/shortcuts",
    Firefox: "https://bitwarden.com/help/keyboard-shortcuts",
    Opera: "opera://extensions/shortcuts",
    Edge: "edge://extensions/shortcuts",
    Vivaldi: "vivaldi://extensions/shortcuts",
    Unknown: "https://bitwarden.com/help/keyboard-shortcuts",
};
const DisablePasswordManagerUris = {
    Chrome: "chrome://password-manager/settings",
    Firefox: "https://bitwarden.com/help/disable-browser-autofill/",
    Opera: "opera://settings/autofill",
    Edge: "edge://settings/autofill/passwords/settings",
    Vivaldi: "vivaldi://settings/autofill",
    Unknown: "https://bitwarden.com/help/disable-browser-autofill/",
};
const ExtensionCommand = {
    AutofillCommand: "autofill_cmd",
    AutofillCard: "autofill_card",
    AutofillIdentity: "autofill_identity",
    AutofillLogin: "autofill_login",
    OpenAutofillOverlay: "open_autofill_overlay",
    GeneratePassword: "generate_password",
    OpenPopup: "open_popup",
    LockVault: "lock_vault",
    NoopCommand: "noop",
};
const CLEAR_NOTIFICATION_LOGIN_DATA_DURATION = (/* unused pure expression or super */ null && (60 * 1000)); // 1 minute
const MAX_DEEP_QUERY_RECURSION_DEPTH = 4;
const DEEP_QUERY_SELECTOR_COMBINATOR = ">>>";
// this list is derived from the `attachShadow` candidate elements list
// https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow
const SHADOW_ROOT_CANDIDATE_NODE_NAMES = Object.freeze(new Set([
    "ARTICLE",
    "ASIDE",
    "BLOCKQUOTE",
    "BODY",
    "DIV",
    "FOOTER",
    "H1",
    "H2",
    "H3",
    "H4",
    "H5",
    "H6",
    "HEADER",
    "MAIN",
    "NAV",
    "P",
    "SECTION",
    "SPAN",
]));
/**
 * Field keys for targeting rules. These MUST match the `fieldKey` enum in
 * the Forms Map schema.
 */
const AutofillTargetingRuleTypes = {
    // Authentication
    username: "username",
    password: "password",
    newPassword: "newPassword",
    oneTimeCode: "oneTimeCode",
    // Name
    fullName: "fullName",
    honorificPrefix: "honorificPrefix",
    firstName: "firstName",
    middleName: "middleName",
    lastName: "lastName",
    honorificSuffix: "honorificSuffix",
    // Contact
    email: "email",
    phone: "phone",
    phoneCountryCode: "phoneCountryCode",
    phoneAreaCode: "phoneAreaCode",
    phoneLocal: "phoneLocal",
    phoneExtension: "phoneExtension",
    organization: "organization",
    // Address
    streetAddress: "streetAddress",
    addressLine1: "addressLine1",
    addressLine2: "addressLine2",
    addressLine3: "addressLine3",
    addressLevel1: "addressLevel1",
    addressLevel2: "addressLevel2",
    addressLevel3: "addressLevel3",
    addressLevel4: "addressLevel4",
    postalCode: "postalCode",
    country: "country",
    // Birthdate
    birthdate: "birthdate",
    birthdateDay: "birthdateDay",
    birthdateMonth: "birthdateMonth",
    birthdateYear: "birthdateYear",
    // Payment card
    cardholderName: "cardholderName",
    cardNumber: "cardNumber",
    cardExpirationDate: "cardExpirationDate",
    cardExpirationMonth: "cardExpirationMonth",
    cardExpirationYear: "cardExpirationYear",
    cardCvv: "cardCvv",
    cardType: "cardType",
    // Consent
    consentTerms: "consentTerms",
    consentPrivacy: "consentPrivacy",
    consentUser: "consentUser",
    // Search
    searchTerm: "searchTerm",
};
const FormPurposeCategories = {
    AccountCreation: "account-creation",
    AccountLogin: "account-login",
    AccountRecovery: "account-recovery",
    AccountUpdate: "account-update",
    Address: "address",
    Identity: "identity",
    PaymentCard: "payment-card",
    Search: "search",
    Signup: "signup",
};


;// ./src/autofill/enums/autofill-port.enum.ts
const AutofillPort = {
    InjectedScript: "autofill-injected-script-port",
};


;// ./src/autofill/utils/index.ts
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


/**
 * Generates a random string of characters.
 *
 * @param length - The length of the random string to generate.
 */
function generateRandomChars(length) {
    const chars = "abcdefghijklmnopqrstuvwxyz";
    const randomChars = [];
    const randomBytes = new Uint8Array(length);
    globalThis.crypto.getRandomValues(randomBytes);
    for (let byteIndex = 0; byteIndex < randomBytes.length; byteIndex++) {
        const byte = randomBytes[byteIndex];
        randomChars.push(chars[byte % chars.length]);
    }
    return randomChars.join("");
}
/**
 * Polyfills the requestIdleCallback API with a setTimeout fallback.
 *
 * @param callback - The callback function to run when the browser is idle.
 * @param options - The options to pass to the requestIdleCallback function.
 */
function requestIdleCallbackPolyfill(callback, options) {
    if ("requestIdleCallback" in globalThis) {
        return globalThis.requestIdleCallback(() => callback(), options);
    }
    return globalThis.setTimeout(() => callback(), 1);
}
/**
 * Polyfills the cancelIdleCallback API with a clearTimeout fallback.
 *
 * @param id - The ID of the idle callback to cancel.
 */
function cancelIdleCallbackPolyfill(id) {
    if ("cancelIdleCallback" in globalThis) {
        return globalThis.cancelIdleCallback(id);
    }
    return globalThis.clearTimeout(id);
}
/**
 * Generates a random string of characters that formatted as a custom element name.
 */
function generateRandomCustomElementName() {
    const length = Math.floor(Math.random() * 5) + 8; // Between 8 and 12 characters
    const numHyphens = Math.min(Math.max(Math.floor(Math.random() * 4), 1), length - 1); // At least 1, maximum of 3 hyphens
    const hyphenIndices = [];
    while (hyphenIndices.length < numHyphens) {
        const index = Math.floor(Math.random() * (length - 1)) + 1;
        if (!hyphenIndices.includes(index)) {
            hyphenIndices.push(index);
        }
    }
    hyphenIndices.sort((a, b) => a - b);
    let randomString = "";
    let prevIndex = 0;
    for (let index = 0; index < hyphenIndices.length; index++) {
        const hyphenIndex = hyphenIndices[index];
        randomString = randomString + generateRandomChars(hyphenIndex - prevIndex) + "-";
        prevIndex = hyphenIndex;
    }
    randomString += generateRandomChars(length - prevIndex);
    return randomString;
}
/**
 * Builds a DOM element from an SVG string.
 *
 * @param svgString - The SVG string to build the DOM element from.
 * @param ariaHidden - Determines whether the SVG should be hidden from screen readers.
 */
function buildSvgDomElement(svgString, ariaHidden = true) {
    const domParser = new DOMParser();
    const svgDom = domParser.parseFromString(svgString, "image/svg+xml");
    const domElement = svgDom.documentElement;
    domElement.setAttribute("aria-hidden", `${ariaHidden}`);
    return domElement;
}
/**
 * Sends a message to the extension.
 *
 * @param command - The command to send.
 * @param options - The options to send with the command.
 */
function sendExtensionMessage(command_1) {
    return __awaiter(this, arguments, void 0, function* (command, options = {}) {
        if (typeof browser !== "undefined" &&
            typeof browser.runtime !== "undefined" &&
            typeof browser.runtime.sendMessage !== "undefined") {
            return browser.runtime.sendMessage(Object.assign({ command }, options));
        }
        return new Promise((resolve) => chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => {
            if (chrome.runtime.lastError) {
                resolve(null);
            }
            resolve(response);
        }));
    });
}
/**
 * Sets CSS styles on an element.
 *
 * @param element - The element to set the styles on.
 * @param styles - The styles to set on the element.
 * @param priority - Determines whether the styles should be set as important.
 */
function setElementStyles(element, styles, priority) {
    if (!element || !styles || !Object.keys(styles).length) {
        return;
    }
    for (const styleProperty in styles) {
        const styleValue = styles[styleProperty];
        if (styleValue !== undefined) {
            element.style.setProperty(styleProperty.replace(/([a-z])([A-Z])/g, "$1-$2"), // Convert camelCase to kebab-case
            styleValue, priority ? "important" : undefined);
        }
    }
}
/**
 * Sets up a long-lived connection with the extension background
 * and triggers an onDisconnect event if the extension context
 * is invalidated.
 *
 * @param callback - Callback export function to run when the extension disconnects
 */
function setupExtensionDisconnectAction(callback) {
    const port = chrome.runtime.connect({ name: AutofillPort.InjectedScript });
    const onDisconnectCallback = (disconnectedPort) => {
        callback(disconnectedPort);
        port.onDisconnect.removeListener(onDisconnectCallback);
    };
    port.onDisconnect.addListener(onDisconnectCallback);
}
/**
 * Handles setup of the extension disconnect action for the autofill init class
 * in both instances where the overlay might or might not be initialized.
 *
 * @param windowContext - The global window context
 */
function setupAutofillInitDisconnectAction(windowContext) {
    const bitwardenAutofillInit = windowContext.bitwardenAutofillInit;
    if (!bitwardenAutofillInit) {
        return;
    }
    const onDisconnectCallback = () => {
        bitwardenAutofillInit.destroy();
        delete windowContext.bitwardenAutofillInit;
    };
    setupExtensionDisconnectAction(onDisconnectCallback);
}
/**
 * Identifies whether an element is a fillable form field.
 * This is determined by whether the element is a form field and not a span.
 *
 * @param formFieldElement - The form field element to check.
 */
function elementIsFillableFormField(formFieldElement) {
    return !elementIsSpanElement(formFieldElement);
}
/**
 * Identifies whether an element is an instance of a specific tag name.
 *
 * @param element - The element to check.
 * @param tagName -  The tag name to check against.
 */
function elementIsInstanceOf(element, tagName) {
    return nodeIsElement(element) && element.tagName.toLowerCase() === tagName;
}
/**
 * Identifies whether an element is a span element.
 *
 * @param element - The element to check.
 */
function elementIsSpanElement(element) {
    return elementIsInstanceOf(element, "span");
}
/**
 * Identifies whether an element is an input field.
 *
 * @param element - The element to check.
 */
function elementIsInputElement(element) {
    return elementIsInstanceOf(element, "input");
}
/**
 * Identifies whether an element is a select field.
 *
 * @param element - The element to check.
 */
function elementIsSelectElement(element) {
    return elementIsInstanceOf(element, "select");
}
/**
 * Identifies whether an element is a textarea field.
 *
 * @param element - The element to check.
 */
function elementIsTextAreaElement(element) {
    return elementIsInstanceOf(element, "textarea");
}
/**
 * Identifies whether an element is a form element.
 *
 * @param element - The element to check.
 */
function elementIsFormElement(element) {
    return elementIsInstanceOf(element, "form");
}
/**
 * Identifies whether an element is a label element.
 *
 * @param element - The element to check.
 */
function elementIsLabelElement(element) {
    return elementIsInstanceOf(element, "label");
}
/**
 * Identifies whether an element is a description details `dd` element.
 *
 * @param element - The element to check.
 */
function elementIsDescriptionDetailsElement(element) {
    return elementIsInstanceOf(element, "dd");
}
/**
 * Identifies whether an element is a description term `dt` element.
 *
 * @param element - The element to check.
 */
function elementIsDescriptionTermElement(element) {
    return elementIsInstanceOf(element, "dt");
}
/**
 * Identifies whether a node is an HTML element.
 *
 * @param node - The node to check.
 */
function nodeIsElement(node) {
    if (!node) {
        return false;
    }
    return (node === null || node === void 0 ? void 0 : node.nodeType) === Node.ELEMENT_NODE;
}
/**
 * Identifies whether a node is an input element.
 *
 * @param node - The node to check.
 */
function nodeIsInputElement(node) {
    return nodeIsElement(node) && elementIsInputElement(node);
}
/**
 * Identifies whether a node is a form element.
 *
 * @param node - The node to check.
 */
function nodeIsFormElement(node) {
    return nodeIsElement(node) && elementIsFormElement(node);
}
function nodeIsTypeSubmitElement(node) {
    return nodeIsElement(node) && getPropertyOrAttribute(node, "type") === "submit";
}
function nodeIsButtonElement(node) {
    return (nodeIsElement(node) &&
        (elementIsInstanceOf(node, "button") ||
            getPropertyOrAttribute(node, "type") === "button"));
}
function nodeIsAnchorElement(node) {
    return nodeIsElement(node) && elementIsInstanceOf(node, "a");
}
/**
 * Returns a boolean representing the attribute value of an element.
 *
 * @param element
 * @param attributeName
 * @param checkString
 */
function getAttributeBoolean(element, attributeName, checkString = false) {
    if (checkString) {
        return getPropertyOrAttribute(element, attributeName) === "true";
    }
    return Boolean(getPropertyOrAttribute(element, attributeName));
}
/**
 * Checks if a form field element is currently readonly or disabled.
 *
 * @param formFieldElement - The form field element to evaluate.
 * @param autofillFieldData - Optional cached autofill metadata for readonly or disabled state.
 */
function isReadonlyOrDisabledFormFieldElement(formFieldElement, autofillFieldData) {
    const readOnlyByProperty = (elementIsInputElement(formFieldElement) || elementIsTextAreaElement(formFieldElement)) &&
        formFieldElement.readOnly;
    return (getAttributeBoolean(formFieldElement, AUTOFILL_ATTRIBUTES.DISABLED) ||
        readOnlyByProperty ||
        getAttributeBoolean(formFieldElement, "aria-readonly", true) ||
        (autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.readonly) === true ||
        (autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.disabled) === true);
}
/**
 * Get the value of a property or attribute from a FormFieldElement.
 *
 * @param element
 * @param attributeName
 */
function getPropertyOrAttribute(element, attributeName) {
    var _a;
    if (attributeName in element) {
        return (_a = element[attributeName]) !== null && _a !== void 0 ? _a : null;
    }
    return element.getAttribute(attributeName);
}
/**
 * Throttles a callback function to run at most once every `limit` milliseconds.
 *
 * @param callback - The callback function to throttle (must return void).
 * @param limit - The time in milliseconds to throttle the callback.
 */
function throttle(callback, limit) {
    let waitingDelay = false;
    return function (...args) {
        if (waitingDelay) {
            return;
        }
        callback.apply(this, args);
        waitingDelay = true;
        globalThis.setTimeout(() => (waitingDelay = false), limit);
    };
}
/**
 * Debounces a callback function to run after a delay of `delay` milliseconds.
 *
 * @param callback - The callback function to debounce.
 * @param delay - The time in milliseconds to debounce the callback.
 * @param immediate - Determines whether the callback should run immediately.
 */
function debounce(callback, delay, immediate) {
    let timeout = null;
    return function (...args) {
        const callImmediately = !!immediate && !timeout;
        if (timeout) {
            globalThis.clearTimeout(timeout);
        }
        timeout = globalThis.setTimeout(() => {
            timeout = null;
            if (!callImmediately) {
                callback.apply(this, args);
            }
        }, delay);
        if (callImmediately) {
            callback.apply(this, args);
        }
    };
}
/**
 * Generates the origin and subdomain match patterns for the URL.
 *
 * @param url - The URL of the tab
 */
function generateDomainMatchPatterns(url) {
    try {
        const extensionUrlPattern = /^(chrome|chrome-extension|moz-extension|safari-web-extension):\/\/\/?/;
        if (extensionUrlPattern.test(url)) {
            return [];
        }
        // Add protocol to URL if it is missing to allow for parsing the hostname correctly
        const urlPattern = /^(https?|file):\/\/\/?/;
        if (!urlPattern.test(url)) {
            url = `https://${url}`;
        }
        let protocolGlob = "*://";
        if (url.startsWith("file:///")) {
            protocolGlob = "*:///"; // File URLs require three slashes to be a valid match pattern
        }
        const parsedUrl = new URL(url);
        const originMatchPattern = `${protocolGlob}${parsedUrl.hostname}/*`;
        const splitHost = parsedUrl.hostname.split(".");
        const domain = splitHost.slice(-2).join(".");
        const subDomainMatchPattern = `${protocolGlob}*.${domain}/*`;
        return [originMatchPattern, subDomainMatchPattern];
    }
    catch (_a) {
        return [];
    }
}
/**
 * Determines if the status code of the web response is invalid. An invalid status code is
 * any status code that is not in the 200-299 range.
 *
 * @param statusCode - The status code of the web response
 */
function isInvalidResponseStatusCode(statusCode) {
    return statusCode < 200 || statusCode >= 300;
}
/**
 * Determines if the current context is within a sandboxed iframe.
 */
function currentlyInSandboxedIframe() {
    var _a, _b;
    if (String(self.origin).toLowerCase() === "null" || globalThis.location.hostname === "") {
        return true;
    }
    const sandbox = (_b = (_a = globalThis.frameElement) === null || _a === void 0 ? void 0 : _a.getAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, "sandbox");
    // No frameElement or sandbox attribute means not sandboxed
    if (sandbox === null || sandbox === undefined) {
        return false;
    }
    // An empty string means fully sandboxed
    if (sandbox === "") {
        return true;
    }
    const tokens = new Set(sandbox.toLowerCase().split(" "));
    return !["allow-scripts", "allow-same-origin"].every((token) => tokens.has(token));
}
/**
 * This object allows us to map a special character to a key name. The key name is used
 * in gathering the i18n translation of the written version of the special character.
 */
const specialCharacterToKeyMap = {
    " ": "spaceCharacterDescriptor",
    "~": "tildeCharacterDescriptor",
    "`": "backtickCharacterDescriptor",
    "!": "exclamationCharacterDescriptor",
    "@": "atSignCharacterDescriptor",
    "#": "hashSignCharacterDescriptor",
    $: "dollarSignCharacterDescriptor",
    "%": "percentSignCharacterDescriptor",
    "^": "caretCharacterDescriptor",
    "&": "ampersandCharacterDescriptor",
    "*": "asteriskCharacterDescriptor",
    "(": "parenLeftCharacterDescriptor",
    ")": "parenRightCharacterDescriptor",
    "-": "hyphenCharacterDescriptor",
    _: "underscoreCharacterDescriptor",
    "+": "plusCharacterDescriptor",
    "=": "equalsCharacterDescriptor",
    "{": "braceLeftCharacterDescriptor",
    "}": "braceRightCharacterDescriptor",
    "[": "bracketLeftCharacterDescriptor",
    "]": "bracketRightCharacterDescriptor",
    "|": "pipeCharacterDescriptor",
    "\\": "backSlashCharacterDescriptor",
    ":": "colonCharacterDescriptor",
    ";": "semicolonCharacterDescriptor",
    '"': "doubleQuoteCharacterDescriptor",
    "'": "singleQuoteCharacterDescriptor",
    "<": "lessThanCharacterDescriptor",
    ">": "greaterThanCharacterDescriptor",
    ",": "commaCharacterDescriptor",
    ".": "periodCharacterDescriptor",
    "?": "questionCharacterDescriptor",
    "/": "forwardSlashCharacterDescriptor",
};
/**
 * Determines if the current rect values are not all 0.
 */
function rectHasSize(rect) {
    if (rect.right > 0 && rect.left > 0 && rect.top > 0 && rect.bottom > 0) {
        return true;
    }
    return false;
}
/**
 * Checks if all the values corresponding to the specified keys in an object are null.
 * If no keys are specified, checks all keys in the object.
 *
 * @param obj - The object to check.
 * @param keys - An optional array of keys to check in the object. Defaults to all keys.
 * @returns Returns true if all values for the specified keys (or all keys if none are provided) are null; otherwise, false.
 */
function areKeyValuesNull(obj, keys) {
    const keysToCheck = keys && keys.length > 0 ? keys : Object.keys(obj);
    return keysToCheck.every((key) => obj[key] == null);
}
/**
 * Validates the shape of `subFrameData` and rejects any payload that carries a
 * `url`. This is the *receive*-side counterpart to the *send*-side
 * `SubFrameOffsetWindowMessageData` type: that type stops our own code from
 * constructing a leaky payload at compile time, but any frame can post arbitrary
 * data, so inbound messages must be validated at runtime before they are trusted.
 *
 * @param value - The untrusted `data` property of the window message event.
 */
function isSubFramePositioningMessageData(value) {
    if (typeof value !== "object" || value === null || !("subFrameData" in value)) {
        return false;
    }
    const { subFrameData } = value;
    if (typeof subFrameData !== "object" || subFrameData === null || "url" in subFrameData) {
        return false;
    }
    // Number.isFinite (not `typeof === "number"`) so NaN/Infinity are rejected: a
    // non-finite subFrameDepth would defeat the MAX_SUB_FRAME_DEPTH relay guard.
    const candidate = subFrameData;
    return (Number.isFinite(candidate.top) &&
        Number.isFinite(candidate.left) &&
        Number.isFinite(candidate.subFrameDepth) &&
        (candidate.frameId === undefined || Number.isFinite(candidate.frameId)) &&
        (candidate.parentFrameIds === undefined ||
            (Array.isArray(candidate.parentFrameIds) &&
                candidate.parentFrameIds.every((id) => Number.isFinite(id)))));
}

;// ../../libs/common/src/platform/enums/encryption-type.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var EncryptionType;
(function (EncryptionType) {
    // Symmetric encryption types
    EncryptionType[EncryptionType["AesCbc256_B64"] = 0] = "AesCbc256_B64";
    // Type 1 was the unused and removed AesCbc128_HmacSha256_B64
    EncryptionType[EncryptionType["AesCbc256_HmacSha256_B64"] = 2] = "AesCbc256_HmacSha256_B64";
    // Cose is the encoding for the key used, but contained can be:
    // - XChaCha20Poly1305
    EncryptionType[EncryptionType["CoseEncrypt0"] = 7] = "CoseEncrypt0";
    // Asymmetric encryption types. These never occur in the same places that the symmetric ones would
    // and can be split out into a separate enum.
    EncryptionType[EncryptionType["Rsa2048_OaepSha256_B64"] = 3] = "Rsa2048_OaepSha256_B64";
    EncryptionType[EncryptionType["Rsa2048_OaepSha1_B64"] = 4] = "Rsa2048_OaepSha1_B64";
    EncryptionType[EncryptionType["Rsa2048_OaepSha256_HmacSha256_B64"] = 5] = "Rsa2048_OaepSha256_HmacSha256_B64";
    EncryptionType[EncryptionType["Rsa2048_OaepSha1_HmacSha256_B64"] = 6] = "Rsa2048_OaepSha1_HmacSha256_B64";
})(EncryptionType || (EncryptionType = {}));
function encryptionTypeToString(encryptionType) {
    if (encryptionType in EncryptionType) {
        return EncryptionType[encryptionType];
    }
    else {
        return "Unknown encryption type " + encryptionType;
    }
}
/** The expected number of parts to a serialized EncString of the given encryption type.
 * For example, an EncString of type AesCbc256_B64 will have 2 parts
 *
 * Example of annotated serialized EncStrings:
 * 0.iv|data
 * 2.iv|data|mac
 * 3.data
 * 4.data
 *
 * @see EncString
 * @see EncryptionType
 * @see EncString.parseEncryptedString
 */
const EXPECTED_NUM_PARTS_BY_ENCRYPTION_TYPE = {
    [EncryptionType.AesCbc256_B64]: 2,
    [EncryptionType.AesCbc256_HmacSha256_B64]: 3,
    [EncryptionType.Rsa2048_OaepSha256_B64]: 1,
    [EncryptionType.Rsa2048_OaepSha1_B64]: 1,
    [EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64]: 2,
    [EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64]: 2,
    [EncryptionType.CoseEncrypt0]: 1,
};

;// ../../libs/common/src/platform/enums/file-upload-type.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var FileUploadType;
(function (FileUploadType) {
    FileUploadType[FileUploadType["Direct"] = 0] = "Direct";
    FileUploadType[FileUploadType["Azure"] = 1] = "Azure";
})(FileUploadType || (FileUploadType = {}));

;// ../../libs/storage-core/src/html-storage-location.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var HtmlStorageLocation;
(function (HtmlStorageLocation) {
    HtmlStorageLocation["Local"] = "local";
    HtmlStorageLocation["Memory"] = "memory";
    HtmlStorageLocation["Session"] = "session";
})(HtmlStorageLocation || (HtmlStorageLocation = {}));

;// ../../node_modules/tslib/tslib.es6.mjs
/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** *//* global Reflect, Promise, SuppressedError, Symbol, Iterator */var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b;}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p];};return extendStatics(d,b);};function __extends(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d;}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __());}var __assign=function(){__assign=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p))t[p]=s[p];}return t;};return __assign.apply(this,arguments);};function __rest(s,e){var t={};for(var p in s)if(Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0)t[p]=s[p];if(s!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++){if(e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i]))t[p[i]]=s[p[i]];}return t;}function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r;}function __param(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex);};}function __esDecorate(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!=="function")throw new TypeError("Function expected");return f;}var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value";var target=!descriptorIn&&ctor?contextIn["static"]?ctor:ctor.prototype:null;var descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{});var _,done=false;for(var i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null));};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!=="object")throw new TypeError("Object expected");if(_=accept(result.get))descriptor.get=_;if(_=accept(result.set))descriptor.set=_;if(_=accept(result.init))initializers.unshift(_);}else if(_=accept(result)){if(kind==="field")initializers.unshift(_);else descriptor[key]=_;}}if(target)Object.defineProperty(target,contextIn.name,descriptor);done=true;};function __runInitializers(thisArg,initializers,value){var useValue=arguments.length>2;for(var i=0;i<initializers.length;i++){value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);}return useValue?value:void 0;};function __propKey(x){return typeof x==="symbol"?x:"".concat(x);};function __setFunctionName(f,name,prefix){if(typeof name==="symbol")name=name.description?"[".concat(name.description,"]"):"";return Object.defineProperty(f,"name",{configurable:true,value:prefix?"".concat(prefix," ",name):name});};function __metadata(metadataKey,metadataValue){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(metadataKey,metadataValue);}function tslib_es6_awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}}function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);}step((generator=generator.apply(thisArg,_arguments||[])).next());});}function __generator(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1];},trys:[],ops:[]},f,y,t,g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this;}),g;function verb(n){return function(v){return step([n,v]);};}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue;}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break;}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break;}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break;}if(t[2])_.ops.pop();_.trys.pop();continue;}op=body.call(thisArg,_);}catch(e){op=[6,e];y=0;}finally{f=t=0;}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true};}}var __createBinding=Object.create?function(o,m,k,k2){if(k2===undefined)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k];}};}Object.defineProperty(o,k2,desc);}:function(o,m,k,k2){if(k2===undefined)k2=k;o[k2]=m[k];};function __exportStar(m,o){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(o,p))__createBinding(o,m,p);}function __values(o){var s=typeof Symbol==="function"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length==="number")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o};}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.");}function __read(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m)return o;var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-->0)&&!(r=i.next()).done)ar.push(r.value);}catch(error){e={error:error};}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i);}finally{if(e)throw e.error;}}return ar;}/** @deprecated */function __spread(){for(var ar=[],i=0;i<arguments.length;i++)ar=ar.concat(__read(arguments[i]));return ar;}/** @deprecated */function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;for(var r=Array(s),k=0,i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r;}function __spreadArray(to,from,pack){if(pack||arguments.length===2)for(var i=0,l=from.length,ar;i<l;i++){if(ar||!(i in from)){if(!ar)ar=Array.prototype.slice.call(from,0,i);ar[i]=from[i];}}return to.concat(ar||Array.prototype.slice.call(from));}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v);}function __asyncGenerator(thisArg,_arguments,generator){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g=generator.apply(thisArg,_arguments||[]),i,q=[];return i=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),verb("next"),verb("throw"),verb("return",awaitReturn),i[Symbol.asyncIterator]=function(){return this;},i;function awaitReturn(f){return function(v){return Promise.resolve(v).then(f,reject);};}function verb(n,f){if(g[n]){i[n]=function(v){return new Promise(function(a,b){q.push([n,v,a,b])>1||resume(n,v);});};if(f)i[n]=f(i[n]);}}function resume(n,v){try{step(g[n](v));}catch(e){settle(q[0][3],e);}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r);}function fulfill(value){resume("next",value);}function reject(value){resume("throw",value);}function settle(f,v){if(f(v),q.shift(),q.length)resume(q[0][0],q[0][1]);}}function __asyncDelegator(o){var i,p;return i={},verb("next"),verb("throw",function(e){throw e;}),verb("return"),i[Symbol.iterator]=function(){return this;},i;function verb(n,f){i[n]=o[n]?function(v){return(p=!p)?{value:__await(o[n](v)),done:false}:f?f(v):v;}:f;}}function __asyncValues(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var m=o[Symbol.asyncIterator],i;return m?m.call(o):(o=typeof __values==="function"?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this;},i);function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value);});};}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d});},reject);}}function __makeTemplateObject(cooked,raw){if(Object.defineProperty){Object.defineProperty(cooked,"raw",{value:raw});}else{cooked.raw=raw;}return cooked;};var __setModuleDefault=Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:true,value:v});}:function(o,v){o["default"]=v;};var ownKeys=function(o){ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)if(Object.prototype.hasOwnProperty.call(o,k))ar[ar.length]=k;return ar;};return ownKeys(o);};function __importStar(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i]);__setModuleDefault(result,mod);return result;}function __importDefault(mod){return mod&&mod.__esModule?mod:{default:mod};}function __classPrivateFieldGet(receiver,state,kind,f){if(kind==="a"&&!f)throw new TypeError("Private accessor was defined without a getter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return kind==="m"?f:kind==="a"?f.call(receiver):f?f.value:state.get(receiver);}function __classPrivateFieldSet(receiver,state,value,kind,f){if(kind==="m")throw new TypeError("Private method is not writable");if(kind==="a"&&!f)throw new TypeError("Private accessor was defined without a setter");if(typeof state==="function"?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return kind==="a"?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value;}function __classPrivateFieldIn(state,receiver){if(receiver===null||typeof receiver!=="object"&&typeof receiver!=="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof state==="function"?receiver===state:state.has(receiver);}function __addDisposableResource(env,value,async){if(value!==null&&value!==void 0){if(typeof value!=="object"&&typeof value!=="function")throw new TypeError("Object expected.");var dispose,inner;if(async){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");dispose=value[Symbol.asyncDispose];}if(dispose===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");dispose=value[Symbol.dispose];if(async)inner=dispose;}if(typeof dispose!=="function")throw new TypeError("Object not disposable.");if(inner)dispose=function(){try{inner.call(this);}catch(e){return Promise.reject(e);}};env.stack.push({value:value,dispose:dispose,async:async});}else if(async){env.stack.push({async:true});}return value;}var _SuppressedError=typeof SuppressedError==="function"?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e;};function __disposeResources(env){function fail(e){env.error=env.hasError?new _SuppressedError(e,env.error,"An error was suppressed during disposal."):e;env.hasError=true;}var r,s=0;function next(){while(r=env.stack.pop()){try{if(!r.async&&s===1)return s=0,env.stack.push(r),Promise.resolve().then(next);if(r.dispose){var result=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(result).then(next,function(e){fail(e);return next();});}else s|=1;}catch(e){fail(e);}}if(s===1)return env.hasError?Promise.reject(env.error):Promise.resolve();if(env.hasError)throw env.error;}return next();}function __rewriteRelativeImportExtension(path,preserveJsx){if(typeof path==="string"&&/^\.\.?\//.test(path)){return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js";});}return path;}/* harmony default export */ var tslib_es6 = ({__extends,__assign,__rest,__decorate,__param,__esDecorate,__runInitializers,__propKey,__setFunctionName,__metadata,__awaiter: tslib_es6_awaiter,__generator,__createBinding,__exportStar,__values,__read,__spread,__spreadArrays,__spreadArray,__await,__asyncGenerator,__asyncDelegator,__asyncValues,__makeTemplateObject,__importStar,__importDefault,__classPrivateFieldGet,__classPrivateFieldSet,__classPrivateFieldIn,__addDisposableResource,__disposeResources,__rewriteRelativeImportExtension});
;// ../../node_modules/rxjs/dist/esm5/internal/util/isFunction.js
function isFunction(value){return typeof value==='function';}
;// ../../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js
function createErrorClass(createImpl){var _super=function(instance){Error.call(instance);instance.stack=new Error().stack;};var ctorFunc=createImpl(_super);ctorFunc.prototype=Object.create(Error.prototype);ctorFunc.prototype.constructor=ctorFunc;return ctorFunc;}
;// ../../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js
var UnsubscriptionError=createErrorClass(function(_super){return function UnsubscriptionErrorImpl(errors){_super(this);this.message=errors?errors.length+" errors occurred during unsubscription:\n"+errors.map(function(err,i){return i+1+") "+err.toString();}).join('\n  '):'';this.name='UnsubscriptionError';this.errors=errors;};});
;// ../../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js
function arrRemove(arr,item){if(arr){var index=arr.indexOf(item);0<=index&&arr.splice(index,1);}}
;// ../../node_modules/rxjs/dist/esm5/internal/Subscription.js
var Subscription=function(){function Subscription(initialTeardown){this.initialTeardown=initialTeardown;this.closed=false;this._parentage=null;this._finalizers=null;}Subscription.prototype.unsubscribe=function(){var e_1,_a,e_2,_b;var errors;if(!this.closed){this.closed=true;var _parentage=this._parentage;if(_parentage){this._parentage=null;if(Array.isArray(_parentage)){try{for(var _parentage_1=__values(_parentage),_parentage_1_1=_parentage_1.next();!_parentage_1_1.done;_parentage_1_1=_parentage_1.next()){var parent_1=_parentage_1_1.value;parent_1.remove(this);}}catch(e_1_1){e_1={error:e_1_1};}finally{try{if(_parentage_1_1&&!_parentage_1_1.done&&(_a=_parentage_1.return))_a.call(_parentage_1);}finally{if(e_1)throw e_1.error;}}}else{_parentage.remove(this);}}var initialFinalizer=this.initialTeardown;if(isFunction(initialFinalizer)){try{initialFinalizer();}catch(e){errors=e instanceof UnsubscriptionError?e.errors:[e];}}var _finalizers=this._finalizers;if(_finalizers){this._finalizers=null;try{for(var _finalizers_1=__values(_finalizers),_finalizers_1_1=_finalizers_1.next();!_finalizers_1_1.done;_finalizers_1_1=_finalizers_1.next()){var finalizer=_finalizers_1_1.value;try{execFinalizer(finalizer);}catch(err){errors=errors!==null&&errors!==void 0?errors:[];if(err instanceof UnsubscriptionError){errors=__spreadArray(__spreadArray([],__read(errors)),__read(err.errors));}else{errors.push(err);}}}}catch(e_2_1){e_2={error:e_2_1};}finally{try{if(_finalizers_1_1&&!_finalizers_1_1.done&&(_b=_finalizers_1.return))_b.call(_finalizers_1);}finally{if(e_2)throw e_2.error;}}}if(errors){throw new UnsubscriptionError(errors);}}};Subscription.prototype.add=function(teardown){var _a;if(teardown&&teardown!==this){if(this.closed){execFinalizer(teardown);}else{if(teardown instanceof Subscription){if(teardown.closed||teardown._hasParent(this)){return;}teardown._addParent(this);}(this._finalizers=(_a=this._finalizers)!==null&&_a!==void 0?_a:[]).push(teardown);}}};Subscription.prototype._hasParent=function(parent){var _parentage=this._parentage;return _parentage===parent||Array.isArray(_parentage)&&_parentage.includes(parent);};Subscription.prototype._addParent=function(parent){var _parentage=this._parentage;this._parentage=Array.isArray(_parentage)?(_parentage.push(parent),_parentage):_parentage?[_parentage,parent]:parent;};Subscription.prototype._removeParent=function(parent){var _parentage=this._parentage;if(_parentage===parent){this._parentage=null;}else if(Array.isArray(_parentage)){arrRemove(_parentage,parent);}};Subscription.prototype.remove=function(teardown){var _finalizers=this._finalizers;_finalizers&&arrRemove(_finalizers,teardown);if(teardown instanceof Subscription){teardown._removeParent(this);}};Subscription.EMPTY=function(){var empty=new Subscription();empty.closed=true;return empty;}();return Subscription;}();var EMPTY_SUBSCRIPTION=Subscription.EMPTY;function isSubscription(value){return value instanceof Subscription||value&&'closed'in value&&isFunction(value.remove)&&isFunction(value.add)&&isFunction(value.unsubscribe);}function execFinalizer(finalizer){if(isFunction(finalizer)){finalizer();}else{finalizer.unsubscribe();}}
;// ../../node_modules/rxjs/dist/esm5/internal/config.js
var config={onUnhandledError:null,onStoppedNotification:null,Promise:undefined,useDeprecatedSynchronousErrorHandling:false,useDeprecatedNextContext:false};
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js
var timeoutProvider={setTimeout:function(handler,timeout){var args=[];for(var _i=2;_i<arguments.length;_i++){args[_i-2]=arguments[_i];}var delegate=timeoutProvider.delegate;if(delegate===null||delegate===void 0?void 0:delegate.setTimeout){return delegate.setTimeout.apply(delegate,__spreadArray([handler,timeout],__read(args)));}return setTimeout.apply(void 0,__spreadArray([handler,timeout],__read(args)));},clearTimeout:function(handle){var delegate=timeoutProvider.delegate;return((delegate===null||delegate===void 0?void 0:delegate.clearTimeout)||clearTimeout)(handle);},delegate:undefined};
;// ../../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js
function reportUnhandledError(err){timeoutProvider.setTimeout(function(){var onUnhandledError=config.onUnhandledError;if(onUnhandledError){onUnhandledError(err);}else{throw err;}});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/noop.js
function noop(){}
;// ../../node_modules/rxjs/dist/esm5/internal/NotificationFactories.js
var COMPLETE_NOTIFICATION=function(){return createNotification('C',undefined,undefined);}();function errorNotification(error){return createNotification('E',undefined,error);}function nextNotification(value){return createNotification('N',value,undefined);}function createNotification(kind,value,error){return{kind:kind,value:value,error:error};}
;// ../../node_modules/rxjs/dist/esm5/internal/util/errorContext.js
var context=null;function errorContext(cb){if(config.useDeprecatedSynchronousErrorHandling){var isRoot=!context;if(isRoot){context={errorThrown:false,error:null};}cb();if(isRoot){var _a=context,errorThrown=_a.errorThrown,error=_a.error;context=null;if(errorThrown){throw error;}}}else{cb();}}function captureError(err){if(config.useDeprecatedSynchronousErrorHandling&&context){context.errorThrown=true;context.error=err;}}
;// ../../node_modules/rxjs/dist/esm5/internal/Subscriber.js
var Subscriber=function(_super){__extends(Subscriber,_super);function Subscriber(destination){var _this=_super.call(this)||this;_this.isStopped=false;if(destination){_this.destination=destination;if(isSubscription(destination)){destination.add(_this);}}else{_this.destination=EMPTY_OBSERVER;}return _this;}Subscriber.create=function(next,error,complete){return new SafeSubscriber(next,error,complete);};Subscriber.prototype.next=function(value){if(this.isStopped){handleStoppedNotification(nextNotification(value),this);}else{this._next(value);}};Subscriber.prototype.error=function(err){if(this.isStopped){handleStoppedNotification(errorNotification(err),this);}else{this.isStopped=true;this._error(err);}};Subscriber.prototype.complete=function(){if(this.isStopped){handleStoppedNotification(COMPLETE_NOTIFICATION,this);}else{this.isStopped=true;this._complete();}};Subscriber.prototype.unsubscribe=function(){if(!this.closed){this.isStopped=true;_super.prototype.unsubscribe.call(this);this.destination=null;}};Subscriber.prototype._next=function(value){this.destination.next(value);};Subscriber.prototype._error=function(err){try{this.destination.error(err);}finally{this.unsubscribe();}};Subscriber.prototype._complete=function(){try{this.destination.complete();}finally{this.unsubscribe();}};return Subscriber;}(Subscription);var _bind=Function.prototype.bind;function bind(fn,thisArg){return _bind.call(fn,thisArg);}var ConsumerObserver=function(){function ConsumerObserver(partialObserver){this.partialObserver=partialObserver;}ConsumerObserver.prototype.next=function(value){var partialObserver=this.partialObserver;if(partialObserver.next){try{partialObserver.next(value);}catch(error){handleUnhandledError(error);}}};ConsumerObserver.prototype.error=function(err){var partialObserver=this.partialObserver;if(partialObserver.error){try{partialObserver.error(err);}catch(error){handleUnhandledError(error);}}else{handleUnhandledError(err);}};ConsumerObserver.prototype.complete=function(){var partialObserver=this.partialObserver;if(partialObserver.complete){try{partialObserver.complete();}catch(error){handleUnhandledError(error);}}};return ConsumerObserver;}();var SafeSubscriber=function(_super){__extends(SafeSubscriber,_super);function SafeSubscriber(observerOrNext,error,complete){var _this=_super.call(this)||this;var partialObserver;if(isFunction(observerOrNext)||!observerOrNext){partialObserver={next:observerOrNext!==null&&observerOrNext!==void 0?observerOrNext:undefined,error:error!==null&&error!==void 0?error:undefined,complete:complete!==null&&complete!==void 0?complete:undefined};}else{var context_1;if(_this&&config.useDeprecatedNextContext){context_1=Object.create(observerOrNext);context_1.unsubscribe=function(){return _this.unsubscribe();};partialObserver={next:observerOrNext.next&&bind(observerOrNext.next,context_1),error:observerOrNext.error&&bind(observerOrNext.error,context_1),complete:observerOrNext.complete&&bind(observerOrNext.complete,context_1)};}else{partialObserver=observerOrNext;}}_this.destination=new ConsumerObserver(partialObserver);return _this;}return SafeSubscriber;}(Subscriber);function handleUnhandledError(error){if(config.useDeprecatedSynchronousErrorHandling){captureError(error);}else{reportUnhandledError(error);}}function defaultErrorHandler(err){throw err;}function handleStoppedNotification(notification,subscriber){var onStoppedNotification=config.onStoppedNotification;onStoppedNotification&&timeoutProvider.setTimeout(function(){return onStoppedNotification(notification,subscriber);});}var EMPTY_OBSERVER={closed:true,next:noop,error:defaultErrorHandler,complete:noop};
;// ../../node_modules/rxjs/dist/esm5/internal/symbol/observable.js
var observable=function(){return typeof Symbol==='function'&&Symbol.observable||'@@observable';}();
;// ../../node_modules/rxjs/dist/esm5/internal/util/identity.js
function identity(x){return x;}
;// ../../node_modules/rxjs/dist/esm5/internal/util/pipe.js
function pipe(){var fns=[];for(var _i=0;_i<arguments.length;_i++){fns[_i]=arguments[_i];}return pipeFromArray(fns);}function pipeFromArray(fns){if(fns.length===0){return identity;}if(fns.length===1){return fns[0];}return function piped(input){return fns.reduce(function(prev,fn){return fn(prev);},input);};}
;// ../../node_modules/rxjs/dist/esm5/internal/Observable.js
var Observable=function(){function Observable(subscribe){if(subscribe){this._subscribe=subscribe;}}Observable.prototype.lift=function(operator){var observable=new Observable();observable.source=this;observable.operator=operator;return observable;};Observable.prototype.subscribe=function(observerOrNext,error,complete){var _this=this;var subscriber=isSubscriber(observerOrNext)?observerOrNext:new SafeSubscriber(observerOrNext,error,complete);errorContext(function(){var _a=_this,operator=_a.operator,source=_a.source;subscriber.add(operator?operator.call(subscriber,source):source?_this._subscribe(subscriber):_this._trySubscribe(subscriber));});return subscriber;};Observable.prototype._trySubscribe=function(sink){try{return this._subscribe(sink);}catch(err){sink.error(err);}};Observable.prototype.forEach=function(next,promiseCtor){var _this=this;promiseCtor=getPromiseCtor(promiseCtor);return new promiseCtor(function(resolve,reject){var subscriber=new SafeSubscriber({next:function(value){try{next(value);}catch(err){reject(err);subscriber.unsubscribe();}},error:reject,complete:resolve});_this.subscribe(subscriber);});};Observable.prototype._subscribe=function(subscriber){var _a;return(_a=this.source)===null||_a===void 0?void 0:_a.subscribe(subscriber);};Observable.prototype[observable]=function(){return this;};Observable.prototype.pipe=function(){var operations=[];for(var _i=0;_i<arguments.length;_i++){operations[_i]=arguments[_i];}return pipeFromArray(operations)(this);};Observable.prototype.toPromise=function(promiseCtor){var _this=this;promiseCtor=getPromiseCtor(promiseCtor);return new promiseCtor(function(resolve,reject){var value;_this.subscribe(function(x){return value=x;},function(err){return reject(err);},function(){return resolve(value);});});};Observable.create=function(subscribe){return new Observable(subscribe);};return Observable;}();function getPromiseCtor(promiseCtor){var _a;return(_a=promiseCtor!==null&&promiseCtor!==void 0?promiseCtor:config.Promise)!==null&&_a!==void 0?_a:Promise;}function isObserver(value){return value&&isFunction(value.next)&&isFunction(value.error)&&isFunction(value.complete);}function isSubscriber(value){return value&&value instanceof Subscriber||isObserver(value)&&isSubscription(value);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js
var ObjectUnsubscribedError=createErrorClass(function(_super){return function ObjectUnsubscribedErrorImpl(){_super(this);this.name='ObjectUnsubscribedError';this.message='object unsubscribed';};});
;// ../../node_modules/rxjs/dist/esm5/internal/Subject.js
var Subject=function(_super){__extends(Subject,_super);function Subject(){var _this=_super.call(this)||this;_this.closed=false;_this.currentObservers=null;_this.observers=[];_this.isStopped=false;_this.hasError=false;_this.thrownError=null;return _this;}Subject.prototype.lift=function(operator){var subject=new AnonymousSubject(this,this);subject.operator=operator;return subject;};Subject.prototype._throwIfClosed=function(){if(this.closed){throw new ObjectUnsubscribedError();}};Subject.prototype.next=function(value){var _this=this;errorContext(function(){var e_1,_a;_this._throwIfClosed();if(!_this.isStopped){if(!_this.currentObservers){_this.currentObservers=Array.from(_this.observers);}try{for(var _b=__values(_this.currentObservers),_c=_b.next();!_c.done;_c=_b.next()){var observer=_c.value;observer.next(value);}}catch(e_1_1){e_1={error:e_1_1};}finally{try{if(_c&&!_c.done&&(_a=_b.return))_a.call(_b);}finally{if(e_1)throw e_1.error;}}}});};Subject.prototype.error=function(err){var _this=this;errorContext(function(){_this._throwIfClosed();if(!_this.isStopped){_this.hasError=_this.isStopped=true;_this.thrownError=err;var observers=_this.observers;while(observers.length){observers.shift().error(err);}}});};Subject.prototype.complete=function(){var _this=this;errorContext(function(){_this._throwIfClosed();if(!_this.isStopped){_this.isStopped=true;var observers=_this.observers;while(observers.length){observers.shift().complete();}}});};Subject.prototype.unsubscribe=function(){this.isStopped=this.closed=true;this.observers=this.currentObservers=null;};Object.defineProperty(Subject.prototype,"observed",{get:function(){var _a;return((_a=this.observers)===null||_a===void 0?void 0:_a.length)>0;},enumerable:false,configurable:true});Subject.prototype._trySubscribe=function(subscriber){this._throwIfClosed();return _super.prototype._trySubscribe.call(this,subscriber);};Subject.prototype._subscribe=function(subscriber){this._throwIfClosed();this._checkFinalizedStatuses(subscriber);return this._innerSubscribe(subscriber);};Subject.prototype._innerSubscribe=function(subscriber){var _this=this;var _a=this,hasError=_a.hasError,isStopped=_a.isStopped,observers=_a.observers;if(hasError||isStopped){return EMPTY_SUBSCRIPTION;}this.currentObservers=null;observers.push(subscriber);return new Subscription(function(){_this.currentObservers=null;arrRemove(observers,subscriber);});};Subject.prototype._checkFinalizedStatuses=function(subscriber){var _a=this,hasError=_a.hasError,thrownError=_a.thrownError,isStopped=_a.isStopped;if(hasError){subscriber.error(thrownError);}else if(isStopped){subscriber.complete();}};Subject.prototype.asObservable=function(){var observable=new Observable();observable.source=this;return observable;};Subject.create=function(destination,source){return new AnonymousSubject(destination,source);};return Subject;}(Observable);var AnonymousSubject=function(_super){__extends(AnonymousSubject,_super);function AnonymousSubject(destination,source){var _this=_super.call(this)||this;_this.destination=destination;_this.source=source;return _this;}AnonymousSubject.prototype.next=function(value){var _a,_b;(_b=(_a=this.destination)===null||_a===void 0?void 0:_a.next)===null||_b===void 0?void 0:_b.call(_a,value);};AnonymousSubject.prototype.error=function(err){var _a,_b;(_b=(_a=this.destination)===null||_a===void 0?void 0:_a.error)===null||_b===void 0?void 0:_b.call(_a,err);};AnonymousSubject.prototype.complete=function(){var _a,_b;(_b=(_a=this.destination)===null||_a===void 0?void 0:_a.complete)===null||_b===void 0?void 0:_b.call(_a);};AnonymousSubject.prototype._subscribe=function(subscriber){var _a,_b;return(_b=(_a=this.source)===null||_a===void 0?void 0:_a.subscribe(subscriber))!==null&&_b!==void 0?_b:EMPTY_SUBSCRIPTION;};return AnonymousSubject;}(Subject);
;// ../../libs/storage-core/src/storage.service.ts
class StorageService {
}

;// ../../libs/storage-core/src/memory-storage.service.ts
var memory_storage_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


class MemoryStorageService extends StorageService {
    constructor() {
        super(...arguments);
        this.store = new Map();
        this.updatesSubject = new Subject();
    }
    get valuesRequireDeserialization() {
        return false;
    }
    get updates$() {
        return this.updatesSubject.asObservable();
    }
    get(key) {
        if (this.store.has(key)) {
            const obj = this.store.get(key);
            return Promise.resolve(obj);
        }
        return Promise.resolve(null);
    }
    has(key) {
        return memory_storage_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.get(key)) != null;
        });
    }
    save(key, obj) {
        if (obj == null) {
            return this.remove(key);
        }
        // TODO: Remove once foreground/background contexts are separated in browser
        // Needed to ensure ownership of all memory by the context running the storage service
        const toStore = structuredClone(obj);
        this.store.set(key, toStore);
        this.updatesSubject.next({ key, updateType: "save" });
        return Promise.resolve();
    }
    remove(key) {
        this.store.delete(key);
        this.updatesSubject.next({ key, updateType: "remove" });
        return Promise.resolve();
    }
}

;// ../../libs/storage-core/src/serialized-memory-storage.service.ts
var serialized_memory_storage_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


class SerializedMemoryStorageService extends StorageService {
    constructor() {
        super(...arguments);
        this.store = {};
        this.updatesSubject = new Subject();
    }
    get valuesRequireDeserialization() {
        return true;
    }
    get updates$() {
        return this.updatesSubject.asObservable();
    }
    get(key) {
        const json = this.store[key];
        if (json) {
            const obj = JSON.parse(json);
            return Promise.resolve(obj);
        }
        return Promise.resolve(null);
    }
    has(key) {
        return serialized_memory_storage_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.get(key)) != null;
        });
    }
    save(key, obj) {
        if (obj == null) {
            return this.remove(key);
        }
        // TODO: Remove once foreground/background contexts are separated in browser
        // Needed to ensure ownership of all memory by the context running the storage service
        this.store[key] = JSON.stringify(obj);
        this.updatesSubject.next({ key, updateType: "save" });
        return Promise.resolve();
    }
    remove(key) {
        delete this.store[key];
        this.updatesSubject.next({ key, updateType: "remove" });
        return Promise.resolve();
    }
}

;// ../../libs/storage-core/src/storage-location.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var StorageLocationEnum;
(function (StorageLocationEnum) {
    StorageLocationEnum["Both"] = "both";
    StorageLocationEnum["Disk"] = "disk";
    StorageLocationEnum["Memory"] = "memory";
})(StorageLocationEnum || (StorageLocationEnum = {}));

;// ../../libs/storage-core/src/index.ts








// Renamed to just "StorageService", to be removed when references are updated



;// ../../libs/common/src/platform/enums/html-storage-location.enum.ts


;// ../../libs/common/src/platform/enums/key-suffix-options.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var KeySuffixOptions;
(function (KeySuffixOptions) {
    KeySuffixOptions["Auto"] = "auto";
    KeySuffixOptions["Pin"] = "pin";
})(KeySuffixOptions || (KeySuffixOptions = {}));

;// ../../libs/logging/src/log-level.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var LogLevel;
(function (LogLevel) {
    LogLevel[LogLevel["Debug"] = 0] = "Debug";
    LogLevel[LogLevel["Info"] = 1] = "Info";
    LogLevel[LogLevel["Warning"] = 2] = "Warning";
    LogLevel[LogLevel["Error"] = 3] = "Error";
})(LogLevel || (LogLevel = {}));

;// ../../libs/logging/src/console-log.service.ts

class ConsoleLogService {
    constructor(isDev, filter = null) {
        this.isDev = isDev;
        this.filter = filter;
        this.timersMap = new Map();
    }
    debug(message, ...optionalParams) {
        if (!this.isDev) {
            return;
        }
        this.write(LogLevel.Debug, message, ...optionalParams);
    }
    info(message, ...optionalParams) {
        this.write(LogLevel.Info, message, ...optionalParams);
    }
    warning(message, ...optionalParams) {
        this.write(LogLevel.Warning, message, ...optionalParams);
    }
    error(message, ...optionalParams) {
        this.write(LogLevel.Error, message, ...optionalParams);
    }
    write(level, message, ...optionalParams) {
        if (this.filter != null && this.filter(level)) {
            return;
        }
        switch (level) {
            case LogLevel.Debug:
                // eslint-disable-next-line
                console.log(message, ...optionalParams);
                break;
            case LogLevel.Info:
                // eslint-disable-next-line
                console.log(message, ...optionalParams);
                break;
            case LogLevel.Warning:
                // eslint-disable-next-line
                console.warn(message, ...optionalParams);
                break;
            case LogLevel.Error:
                // eslint-disable-next-line
                console.error(message, ...optionalParams);
                break;
            default:
                break;
        }
    }
    measure(start, trackGroup, track, name, properties) {
        const measureName = `[${track}]: ${name}`;
        const measure = performance.measure(measureName, {
            start: start,
            detail: {
                devtools: {
                    dataType: "track-entry",
                    track,
                    trackGroup,
                    properties,
                },
            },
        });
        this.info(`${measureName} took ${measure.duration}`, properties);
        return measure;
    }
    mark(name) {
        const mark = performance.mark(name, {
            detail: {
                devtools: {
                    dataType: "marker",
                },
            },
        });
        this.info(mark.name, new Date().toISOString());
        return mark;
    }
}

;// ../../libs/logging/src/flight-recorder.ts
/* unused harmony import specifier */ var FlightRecorderClient;
var flight_recorder_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

/**
 * Framework-agnostic wrapper around the SDK's {@link FlightRecorderClient}.
 *
 * The underlying WASM must be loaded before the client can be used. Callers
 * provide a `sdkReady` promise (typically `SdkLoadService.Ready`) that resolves
 * once the SDK is initialized. The client is lazily created on first access.
 */
class FlightRecorder {
    /**
     * @param sdkReady - A promise that resolves when the SDK WASM has been loaded
     *   and initialized. Pass `SdkLoadService.Ready` in DI-enabled contexts.
     */
    constructor(sdkReady) {
        this.sdkReady = sdkReady;
    }
    /**
     * Read all events currently in the flight recorder buffer.
     */
    read() {
        return flight_recorder_awaiter(this, void 0, void 0, function* () {
            const client = yield this.getClient();
            return client.read();
        });
    }
    /**
     * Get the current event count without reading event contents.
     */
    count() {
        return flight_recorder_awaiter(this, void 0, void 0, function* () {
            const client = yield this.getClient();
            return client.count();
        });
    }
    getClient() {
        if (this.clientPromise == null) {
            this.clientPromise = this.sdkReady.then(() => new FlightRecorderClient());
        }
        return this.clientPromise;
    }
}

// EXTERNAL MODULE: ../../node_modules/papaparse/papaparse.min.js
var papaparse_min = __webpack_require__(98869);
;// ../../libs/logging/src/flight-recorder-export.ts
/* unused harmony import specifier */ var papa;

const CSV_COLUMNS = (/* unused pure expression or super */ null && (["timestamp", "level", "target", "message", "fields"]));
/**
 * Build a CSV download payload for {@link FlightRecorderEvent}s.
 *
 * Returns a `fileName` of the form `Bitwarden-diagnostic-report-YYYY-MM-DD.csv`
 * and a CSV-encoded `blobData` ready to pass to `FileDownloadService.download`.
 *
 * @param events The events to encode.
 * @param date The date used for the filename. Defaults to `new Date()`.
 */
function buildFlightRecorderCsvExport(events, date = new Date()) {
    const rows = events.map((e) => ({
        timestamp: new Date(e.timestamp).toISOString(),
        level: e.level,
        target: e.target,
        message: e.message,
        fields: JSON.stringify(e.fields),
    }));
    const blobData = papa.unparse(rows, {
        columns: [...CSV_COLUMNS],
        header: true,
    });
    const datePart = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
    const fileName = `Bitwarden-diagnostic-report-${datePart}.csv`;
    return { fileName, blobData };
}

;// ../../libs/logging/src/index.ts






;// ../../libs/common/src/platform/enums/log-level-type.enum.ts


;// ../../libs/common/src/platform/enums/storage-location.enum.ts


;// ../../libs/common/src/platform/enums/theme-type.enum.ts
/**
 * @deprecated prefer the `ThemeTypes` constants and `Theme` type over unsafe enum types
 **/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var ThemeType;
(function (ThemeType) {
    ThemeType["System"] = "system";
    ThemeType["Light"] = "light";
    ThemeType["Dark"] = "dark";
})(ThemeType || (ThemeType = {}));
const ThemeTypes = {
    System: "system",
    Light: "light",
    Dark: "dark",
};

;// ../../libs/common/src/platform/enums/index.ts








;// ../../libs/client-type/src/index.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var ClientType;
(function (ClientType) {
    ClientType["Web"] = "web";
    ClientType["Browser"] = "browser";
    ClientType["Desktop"] = "desktop";
    // Mobile = "mobile",
    ClientType["Cli"] = "cli";
    // DirectoryConnector = "connector",
})(ClientType || (ClientType = {}));

;// ../../libs/common/src/enums/client-type.enum.ts


;// ../../libs/common/src/enums/device-type.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var DeviceType;
(function (DeviceType) {
    DeviceType[DeviceType["Android"] = 0] = "Android";
    DeviceType[DeviceType["iOS"] = 1] = "iOS";
    DeviceType[DeviceType["ChromeExtension"] = 2] = "ChromeExtension";
    DeviceType[DeviceType["FirefoxExtension"] = 3] = "FirefoxExtension";
    DeviceType[DeviceType["OperaExtension"] = 4] = "OperaExtension";
    DeviceType[DeviceType["EdgeExtension"] = 5] = "EdgeExtension";
    DeviceType[DeviceType["WindowsDesktop"] = 6] = "WindowsDesktop";
    DeviceType[DeviceType["MacOsDesktop"] = 7] = "MacOsDesktop";
    DeviceType[DeviceType["LinuxDesktop"] = 8] = "LinuxDesktop";
    DeviceType[DeviceType["ChromeBrowser"] = 9] = "ChromeBrowser";
    DeviceType[DeviceType["FirefoxBrowser"] = 10] = "FirefoxBrowser";
    DeviceType[DeviceType["OperaBrowser"] = 11] = "OperaBrowser";
    DeviceType[DeviceType["EdgeBrowser"] = 12] = "EdgeBrowser";
    DeviceType[DeviceType["IEBrowser"] = 13] = "IEBrowser";
    DeviceType[DeviceType["UnknownBrowser"] = 14] = "UnknownBrowser";
    DeviceType[DeviceType["AndroidAmazon"] = 15] = "AndroidAmazon";
    DeviceType[DeviceType["UWP"] = 16] = "UWP";
    DeviceType[DeviceType["SafariBrowser"] = 17] = "SafariBrowser";
    DeviceType[DeviceType["VivaldiBrowser"] = 18] = "VivaldiBrowser";
    DeviceType[DeviceType["VivaldiExtension"] = 19] = "VivaldiExtension";
    DeviceType[DeviceType["SafariExtension"] = 20] = "SafariExtension";
    DeviceType[DeviceType["SDK"] = 21] = "SDK";
    DeviceType[DeviceType["Server"] = 22] = "Server";
    DeviceType[DeviceType["WindowsCLI"] = 23] = "WindowsCLI";
    DeviceType[DeviceType["MacOsCLI"] = 24] = "MacOsCLI";
    DeviceType[DeviceType["LinuxCLI"] = 25] = "LinuxCLI";
    DeviceType[DeviceType["DuckDuckGoBrowser"] = 26] = "DuckDuckGoBrowser";
})(DeviceType || (DeviceType = {}));
const DeviceTypeMetadata = {
    [DeviceType.Android]: { category: "mobile", platform: "Android" },
    [DeviceType.iOS]: { category: "mobile", platform: "iOS" },
    [DeviceType.AndroidAmazon]: { category: "mobile", platform: "Amazon" },
    [DeviceType.ChromeExtension]: { category: "extension", platform: "Chrome" },
    [DeviceType.FirefoxExtension]: { category: "extension", platform: "Firefox" },
    [DeviceType.OperaExtension]: { category: "extension", platform: "Opera" },
    [DeviceType.EdgeExtension]: { category: "extension", platform: "Edge" },
    [DeviceType.VivaldiExtension]: { category: "extension", platform: "Vivaldi" },
    [DeviceType.SafariExtension]: { category: "extension", platform: "Safari" },
    [DeviceType.ChromeBrowser]: { category: "webApp", platform: "Chrome" },
    [DeviceType.FirefoxBrowser]: { category: "webApp", platform: "Firefox" },
    [DeviceType.OperaBrowser]: { category: "webApp", platform: "Opera" },
    [DeviceType.EdgeBrowser]: { category: "webApp", platform: "Edge" },
    [DeviceType.IEBrowser]: { category: "webApp", platform: "IE" },
    [DeviceType.SafariBrowser]: { category: "webApp", platform: "Safari" },
    [DeviceType.VivaldiBrowser]: { category: "webApp", platform: "Vivaldi" },
    [DeviceType.DuckDuckGoBrowser]: { category: "webApp", platform: "DuckDuckGo" },
    [DeviceType.UnknownBrowser]: { category: "webApp", platform: "Unknown" },
    [DeviceType.WindowsDesktop]: { category: "desktop", platform: "Windows" },
    [DeviceType.MacOsDesktop]: { category: "desktop", platform: "macOS" },
    [DeviceType.LinuxDesktop]: { category: "desktop", platform: "Linux" },
    [DeviceType.UWP]: { category: "desktop", platform: "Windows UWP" },
    [DeviceType.WindowsCLI]: { category: "cli", platform: "Windows" },
    [DeviceType.MacOsCLI]: { category: "cli", platform: "macOS" },
    [DeviceType.LinuxCLI]: { category: "cli", platform: "Linux" },
    [DeviceType.SDK]: { category: "sdk", platform: "" },
    [DeviceType.Server]: { category: "server", platform: "" },
};

;// ../../libs/common/src/enums/http-status-code.enum.ts
/**
 * Hypertext Transfer Protocol (HTTP) response status codes.
 *
 * @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
 * src: https://gist.github.com/RWOverdijk/6cef816cfdf5722228e01cc05fd4b094
 */
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var HttpStatusCode;
(function (HttpStatusCode) {
    /**
     * The server has received the request headers and the client should proceed to send the request body
     * (in the case of a request for which a body needs to be sent; for example, a POST request).
     * Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient.
     * To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request
     * and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.
     */
    HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
    /**
     * The requester has asked the server to switch protocols and the server has agreed to do so.
     */
    HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
    /**
     * A WebDAV request may contain many sub-requests involving file operations, requiring a long time to complete the request.
     * This code indicates that the server has received and is processing the request, but no response is available yet.
     * This prevents the client from timing out and assuming the request was lost.
     */
    HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
    // **********************************************************************************************************
    // 200s - SUCCESS
    // **********************************************************************************************************
    /**
     * Standard response for successful HTTP requests.
     * The actual response will depend on the request method used.
     * In a GET request, the response will contain an entity corresponding to the requested resource.
     * In a POST request, the response will contain an entity describing or containing the result of the action.
     */
    HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
    /**
     * The request has been fulfilled, resulting in the creation of a new resource.
     */
    HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
    /**
     * The request has been accepted for processing, but the processing has not been completed.
     * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
     */
    HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
    /**
     * SINCE HTTP/1.1
     * The server is a transforming proxy that received a 200 OK from its origin,
     * but is returning a modified version of the origin's response.
     */
    HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
    /**
     * The server successfully processed the request and is not returning any content.
     */
    HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
    /**
     * The server successfully processed the request, but is not returning any content.
     * Unlike a 204 response, this response requires that the requester reset the document view.
     */
    HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
    /**
     * The server is delivering only part of the resource (byte serving) due to a range header sent by the client.
     * The range header is used by HTTP clients to enable resuming of interrupted downloads,
     * or split a download into multiple simultaneous streams.
     */
    HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
    /**
     * The message body that follows is an XML message and can contain a number of separate response codes,
     * depending on how many sub-requests were made.
     */
    HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
    /**
     * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response,
     * and are not being included again.
     */
    HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
    /**
     * The server has fulfilled a request for the resource,
     * and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
     */
    HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
    // **********************************************************************************************************
    // 300s - Redirections
    // **********************************************************************************************************
    /**
     * Indicates multiple options for the resource from which the client may choose (via agent-driven content negotiation).
     * For example, this code could be used to present multiple video format options,
     * to list files with different filename extensions, or to suggest word-sense disambiguation.
     */
    HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
    /**
     * This and all future requests should be directed to the given URI.
     */
    HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
    /**
     * This is an example of industry practice contradicting the standard.
     * The HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect
     * (the original describing phrase was "Moved Temporarily"), but popular browsers implemented 302
     * with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307
     * to distinguish between the two behaviours. However, some Web applications and frameworks
     * use the 302 status code as if it were the 303.
     */
    HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
    /**
     * SINCE HTTP/1.1
     * The response to the request can be found under another URI using a GET method.
     * When received in response to a POST (or PUT/DELETE), the client should presume that
     * the server has received the data and should issue a redirect with a separate GET message.
     */
    HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
    /**
     * Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.
     * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
     */
    HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
    /**
     * SINCE HTTP/1.1
     * The requested resource is available only through a proxy, the address for which is provided in the response.
     * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
     */
    HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
    /**
     * No longer used. Originally meant "Subsequent requests should use the specified proxy."
     */
    HttpStatusCode[HttpStatusCode["SwitchProxy"] = 306] = "SwitchProxy";
    /**
     * SINCE HTTP/1.1
     * In this case, the request should be repeated with another URI; however, future requests should still use the original URI.
     * In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request.
     * For example, a POST request should be repeated using another POST request.
     */
    HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
    /**
     * The request and all future requests should be repeated using another URI.
     * 307 and 308 parallel the behaviors of 302 and 301, but do not allow the HTTP method to change.
     * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
     */
    HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
    // **********************************************************************************************************
    // 400s - Client / User messed up
    // **********************************************************************************************************
    /**
     * The server cannot or will not process the request due to an apparent client error
     * (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing).
     */
    HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
    /**
     * Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet
     * been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the
     * requested resource. See Basic access authentication and Digest access authentication. 401 semantically means
     * "unauthenticated",i.e. the user does not have the necessary credentials.
     */
    HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
    /**
     * Reserved for future use. The original intention was that this code might be used as part of some form of digital
     * cash or micro payment scheme, but that has not happened, and this code is not usually used.
     * Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.
     */
    HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
    /**
     * The request was valid, but the server is refusing action.
     * The user might not have the necessary permissions for a resource.
     */
    HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
    /**
     * The requested resource could not be found but may be available in the future.
     * Subsequent requests by the client are permissible.
     */
    HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
    /**
     * A request method is not supported for the requested resource;
     * for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
     */
    HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
    /**
     * The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.
     */
    HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
    /**
     * The client must first authenticate itself with the proxy.
     */
    HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
    /**
     * The server timed out waiting for the request.
     * According to HTTP specifications:
     * "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time."
     */
    HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
    /**
     * Indicates that the request could not be processed because of conflict in the request,
     * such as an edit conflict between multiple simultaneous updates.
     */
    HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
    /**
     * Indicates that the resource requested is no longer available and will not be available again.
     * This should be used when a resource has been intentionally removed and the resource should be purged.
     * Upon receiving a 410 status code, the client should not request the resource in the future.
     * Clients such as search engines should remove the resource from their indices.
     * Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
     */
    HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
    /**
     * The request did not specify the length of its content, which is required by the requested resource.
     */
    HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
    /**
     * The server does not meet one of the preconditions that the requester put on the request.
     */
    HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
    /**
     * The request is larger than the server is willing or able to process. Previously called "Request Entity Too Large".
     */
    HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
    /**
     * The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request,
     * in which case it should be converted to a POST request.
     * Called "Request-URI Too Long" previously.
     */
    HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
    /**
     * The request entity has a media type which the server or resource does not support.
     * For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.
     */
    HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
    /**
     * The client has asked for a portion of the file (byte serving), but the server cannot supply that portion.
     * For example, if the client asked for a part of the file that lies beyond the end of the file.
     * Called "Requested Range Not Satisfiable" previously.
     */
    HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
    /**
     * The server cannot meet the requirements of the Expect request-header field.
     */
    HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
    /**
     * This code was defined in 1998 as one of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol,
     * and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by
     * teapots requested to brew coffee. This HTTP status is used as an Easter egg in some websites, including Google.com.
     */
    HttpStatusCode[HttpStatusCode["IAmATeapot"] = 418] = "IAmATeapot";
    /**
     * The request was directed at a server that is not able to produce a response (for example because a connection reuse).
     */
    HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
    /**
     * The request was well-formed but was unable to be followed due to semantic errors.
     */
    HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
    /**
     * The resource that is being accessed is locked.
     */
    HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
    /**
     * The request failed due to failure of a previous request (e.g., a PROPPATCH).
     */
    HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
    /**
     * The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.
     */
    HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
    /**
     * The origin server requires the request to be conditional.
     * Intended to prevent "the 'lost update' problem, where a client
     * GETs a resource's state, modifies it, and PUTs it back to the server,
     * when meanwhile a third party has modified the state on the server, leading to a conflict."
     */
    HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
    /**
     * The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.
     */
    HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
    /**
     * The server is unwilling to process the request because either an individual header field,
     * or all the header fields collectively, are too large.
     */
    HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
    /**
     * A server operator has received a legal demand to deny access to a resource or to a set of resources
     * that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.
     */
    HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
    // **********************************************************************************************************
    // 500s - Server messed up
    // **********************************************************************************************************
    /**
     * A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.
     */
    HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
    /**
     * The server either does not recognize the request method, or it lacks the ability to fulfill the request.
     * Usually this implies future availability (e.g., a new feature of a web-service API).
     */
    HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
    /**
     * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
     */
    HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
    /**
     * The server is currently unavailable (because it is overloaded or down for maintenance).
     * Generally, this is a temporary state.
     */
    HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
    /**
     * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
     */
    HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
    /**
     * The server does not support the HTTP protocol version used in the request
     */
    HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
    /**
     * Transparent content negotiation for the request results in a circular reference.
     */
    HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
    /**
     * The server is unable to store the representation needed to complete the request.
     */
    HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
    /**
     * The server detected an infinite loop while processing the request.
     */
    HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
    /**
     * Further extensions to the request are required for the server to fulfill it.
     */
    HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
    /**
     * The client needs to authenticate to gain network access.
     * Intended for use by intercepting proxies used to control access to the network (e.g., "captive portals" used
     * to require agreement to Terms of Service before granting full Internet access via a Wi-Fi hotspot).
     */
    HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
})(HttpStatusCode || (HttpStatusCode = {}));

;// ../../libs/common/src/enums/integration-type.enum.ts
const IntegrationType = Object.freeze({
    Integration: "integration",
    SDK: "sdk",
    SSO: "sso",
    SCIM: "scim",
    BWDC: "bwdc",
    EVENT: "event",
    DEVICE: "device",
});

;// ../../libs/common/src/enums/native-messaging-version.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var NativeMessagingVersion;
(function (NativeMessagingVersion) {
    NativeMessagingVersion[NativeMessagingVersion["One"] = 1] = "One";
    NativeMessagingVersion[NativeMessagingVersion["Latest"] = 1] = "Latest";
})(NativeMessagingVersion || (NativeMessagingVersion = {}));

;// ../../libs/common/src/enums/notification-type.enum.ts
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var NotificationType;
(function (NotificationType) {
    NotificationType[NotificationType["SyncCipherUpdate"] = 0] = "SyncCipherUpdate";
    NotificationType[NotificationType["SyncCipherCreate"] = 1] = "SyncCipherCreate";
    NotificationType[NotificationType["SyncLoginDelete"] = 2] = "SyncLoginDelete";
    NotificationType[NotificationType["SyncFolderDelete"] = 3] = "SyncFolderDelete";
    NotificationType[NotificationType["SyncCiphers"] = 4] = "SyncCiphers";
    NotificationType[NotificationType["SyncVault"] = 5] = "SyncVault";
    NotificationType[NotificationType["SyncOrgKeys"] = 6] = "SyncOrgKeys";
    NotificationType[NotificationType["SyncFolderCreate"] = 7] = "SyncFolderCreate";
    NotificationType[NotificationType["SyncFolderUpdate"] = 8] = "SyncFolderUpdate";
    NotificationType[NotificationType["SyncCipherDelete"] = 9] = "SyncCipherDelete";
    NotificationType[NotificationType["SyncSettings"] = 10] = "SyncSettings";
    NotificationType[NotificationType["LogOut"] = 11] = "LogOut";
    NotificationType[NotificationType["SyncSendCreate"] = 12] = "SyncSendCreate";
    NotificationType[NotificationType["SyncSendUpdate"] = 13] = "SyncSendUpdate";
    NotificationType[NotificationType["SyncSendDelete"] = 14] = "SyncSendDelete";
    NotificationType[NotificationType["AuthRequest"] = 15] = "AuthRequest";
    NotificationType[NotificationType["AuthRequestResponse"] = 16] = "AuthRequestResponse";
    NotificationType[NotificationType["SyncOrganizations"] = 17] = "SyncOrganizations";
    NotificationType[NotificationType["SyncOrganizationStatusChanged"] = 18] = "SyncOrganizationStatusChanged";
    NotificationType[NotificationType["SyncOrganizationCollectionSettingChanged"] = 19] = "SyncOrganizationCollectionSettingChanged";
    NotificationType[NotificationType["Notification"] = 20] = "Notification";
    NotificationType[NotificationType["NotificationStatus"] = 21] = "NotificationStatus";
    NotificationType[NotificationType["RefreshSecurityTasks"] = 22] = "RefreshSecurityTasks";
    NotificationType[NotificationType["OrganizationBankAccountVerified"] = 23] = "OrganizationBankAccountVerified";
    NotificationType[NotificationType["ProviderBankAccountVerified"] = 24] = "ProviderBankAccountVerified";
    NotificationType[NotificationType["SyncPolicy"] = 25] = "SyncPolicy";
    NotificationType[NotificationType["AutoConfirmMember"] = 26] = "AutoConfirmMember";
    NotificationType[NotificationType["PremiumStatusChanged"] = 27] = "PremiumStatusChanged";
})(NotificationType || (NotificationType = {}));

;// ../../libs/common/src/enums/push-notification-logout-reason.enum.ts
const PushNotificationLogOutReasonType = Object.freeze({
    KdfChange: 0,
    KeyRotation: 1,
});

;// ../../libs/common/src/enums/index.ts








;// ../../libs/platform/src/services/browser-service.ts
function isBrowserSafariApi() {
    return (navigator.userAgent.indexOf(" Safari/") !== -1 &&
        navigator.userAgent.indexOf(" Chrome/") === -1 &&
        navigator.userAgent.indexOf(" Chromium/") === -1);
}

;// ../../libs/scheduling/src/scheduled-task-name.enum.ts
const ScheduledTaskNames = {
    generatePasswordClearClipboardTimeout: "generatePasswordClearClipboardTimeout",
    systemClearClipboardTimeout: "systemClearClipboardTimeout",
    loginStrategySessionTimeout: "loginStrategySessionTimeout",
    notificationsReconnectTimeout: "notificationsReconnectTimeout",
    fido2ClientAbortTimeout: "fido2ClientAbortTimeout",
    scheduleNextSyncInterval: "scheduleNextSyncInterval",
    eventUploadsInterval: "eventUploadsInterval",
    vaultTimeoutCheckInterval: "vaultTimeoutCheckInterval",
    clearPopupViewCache: "clearPopupViewCache",
    targetingRulesUpdate: "targetingRulesUpdate",
    phishingDomainUpdate: "phishingDomainUpdate",
};

;// ../../libs/scheduling/src/task-scheduler.service.ts
/* unused harmony import specifier */ var asyncScheduler;
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore

/**
 * Creates a RXJS scheduler based on a {@link TaskSchedulerService}.
 *
 * @description This API defers to `TaskSchedulerService` to schedule a task to be ran
 * in the future but the task that is ran is NOT the remainder of your RXJS pipeline. The
 * task you want ran must instead be registered in a location reachable on a service worker
 * startup (on browser). An example of an acceptable location is the constructor of a service
 * you know is created in `MainBackground`. Uses of this API in other clients _can_ have the
 * `registerTaskHandler` call in more places, but in order to have it work across clients
 * it is recommended to register it according to the rules of browser.
 *
 * @link https://rxjs.dev/guide/scheduler#using-schedulers
 *
 * @example
 * ```ts
 * class MyService {
 *   constructor(messageListener: MessageListener, taskScheduler: TaskSchedulerService) {
 *    // VERY IMPORTANT!
 *    this.taskSchedulerService.registerTaskHandler(SchedulerTaskNames.myTaskName, async () => {
 *      await this.runEvent();
 *    });
 *
 *     messageListener.messages$(MY_MESSAGE).pipe(
 *        debounceTime(
 *          10 * 1000,
 *          toScheduler(taskScheduler, ShedulerTaskNames.myTaskName),
 *        ),
 *        switchMap(() => this.runEvent()),
 *     )
 *   }
 * }
 * ```
 *
 * @param taskScheduler The task scheduler service to use to schedule RXJS work.
 * @param taskName The name of the task that the handler should be registered and scheduled based on.
 * @returns A SchedulerLike object that can be passed in to RXJS operators like `delay` and `timeout`.
 */
function toScheduler(taskScheduler, taskName) {
    return new TaskSchedulerSheduler(taskScheduler, taskName);
}
class TaskSchedulerSheduler {
    constructor(taskSchedulerService, taskName) {
        this.taskSchedulerService = taskSchedulerService;
        this.taskName = taskName;
    }
    schedule(work, delay, state) {
        return this.taskSchedulerService.setTimeout(this.taskName, delay !== null && delay !== void 0 ? delay : 0);
    }
    now() {
        return asyncScheduler.now();
    }
}
class TaskSchedulerService {
}

;// ../../libs/scheduling/src/default-task-scheduler.service.ts
var default_task_scheduler_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


class DefaultTaskSchedulerService extends TaskSchedulerService {
    constructor(logService) {
        super();
        this.logService = logService;
        this.taskHandlers = new Map();
    }
    /**
     * Sets a timeout and returns the timeout id.
     *
     * @param taskName - The name of the task. Unused in the base implementation.
     * @param delayInMs - The delay in milliseconds.
     */
    setTimeout(taskName, delayInMs) {
        this.validateRegisteredTask(taskName);
        const timeoutHandle = globalThis.setTimeout(() => this.triggerTask(taskName), delayInMs);
        return new Subscription(() => globalThis.clearTimeout(timeoutHandle));
    }
    /**
     * Sets an interval and returns the interval id.
     *
     * @param taskName - The name of the task. Unused in the base implementation.
     * @param intervalInMs - The interval in milliseconds.
     * @param _initialDelayInMs - The initial delay in milliseconds. Unused in the base implementation.
     */
    setInterval(taskName, intervalInMs, _initialDelayInMs) {
        this.validateRegisteredTask(taskName);
        const intervalHandle = globalThis.setInterval(() => this.triggerTask(taskName), intervalInMs);
        return new Subscription(() => globalThis.clearInterval(intervalHandle));
    }
    /**
     * Registers a task handler.
     *
     * @param taskName - The name of the task.
     * @param handler - The task handler.
     */
    registerTaskHandler(taskName, handler) {
        const existingHandler = this.taskHandlers.get(taskName);
        if (existingHandler) {
            this.logService.warning(`Task handler for ${taskName} already exists. Overwriting.`);
            this.unregisterTaskHandler(taskName);
        }
        this.taskHandlers.set(taskName, handler);
    }
    /**
     * Unregisters a task handler.
     *
     * @param taskName - The name of the task.
     */
    unregisterTaskHandler(taskName) {
        this.taskHandlers.delete(taskName);
    }
    /**
     * Triggers a task.
     *
     * @param taskName - The name of the task.
     * @param _periodInMinutes - The period in minutes. Unused in the base implementation.
     */
    triggerTask(taskName, _periodInMinutes) {
        return default_task_scheduler_service_awaiter(this, void 0, void 0, function* () {
            const handler = this.taskHandlers.get(taskName);
            if (handler) {
                handler();
            }
        });
    }
    /**
     * Validates that a task handler is registered.
     *
     * @param taskName - The name of the task.
     */
    validateRegisteredTask(taskName) {
        if (!this.taskHandlers.has(taskName)) {
            throw new Error(`Task handler for ${taskName} not registered. Unable to schedule task.`);
        }
    }
}

;// ../../libs/scheduling/src/index.ts




;// ../../libs/common/src/platform/scheduling/index.ts


;// ../../libs/platform/src/background-sync/background-sync.service.ts
/* unused harmony import specifier */ var background_sync_service_ScheduledTaskNames;

/**
 * The default interval between background syncs.
 * 300,000ms = 5 minutes
 */
const DEFAULT_SYNC_INTERVAL_MS = 300000;
/**
 * Service responsible for registering and managing background synchronization for the browser extension.
 * Handles scheduling of periodic sync operations using the task scheduler infrastructure.
 */
class BackgroundSyncService {
    /**
     * Creates a new instance of BackgroundSyncService.
     * @param taskSchedulerService - Service that handles scheduling and execution of periodic tasks
     */
    constructor(taskSchedulerService) {
        this.taskSchedulerService = taskSchedulerService;
    }
    /**
     * Registers a callback function to be executed when the sync interval task is triggered.
     * This associates the sync task name with the provided callback in the task scheduler.
     *
     * @param syncCallback - The function to execute when the sync task is triggered
     */
    register(syncCallback) {
        this.taskSchedulerService.registerTaskHandler(background_sync_service_ScheduledTaskNames.scheduleNextSyncInterval, syncCallback);
    }
    /**
     * Initializes the background sync service by scheduling the sync interval task.
     * This sets up a recurring timer that triggers the registered sync callback at regular intervals.
     *
     * @param intervalMs - The interval in milliseconds between sync operations (defaults to 300000ms/5 minutes)
     */
    init(intervalMs = DEFAULT_SYNC_INTERVAL_MS) {
        intervalMs = intervalMs < 1 ? DEFAULT_SYNC_INTERVAL_MS : intervalMs;
        this.taskSchedulerService.setInterval(background_sync_service_ScheduledTaskNames.scheduleNextSyncInterval, intervalMs);
    }
}

;// ../../libs/platform/src/background-sync/index.ts


;// ../../libs/platform/src/util.ts
function toURL(input) {
    if (input instanceof URL) {
        return input;
    }
    try {
        return new URL(input);
    }
    catch (_a) {
        return null;
    }
}
function effectiveOrigin(url) {
    // The URL spec returns "null" for .origin on non-special schemes
    // (e.g. chrome-extension://) so we build the origin from protocol + host instead.
    // An empty host means no meaningful origin can be compared (file:, data:, etc.).
    if (!url.host) {
        return null;
    }
    return `${url.protocol}//${url.host}`;
}
/**
 * Compares two URLs to determine whether the suspect URL originates from the
 * same host as the canonical URL.
 *
 * Both arguments accept either a string or an existing {@link URL} object.
 *
 * Returns `false` when:
 * - Either argument cannot be parsed as a valid URL
 * - Either URL has no host (e.g. `file:`, `data:` schemes), since URLs without
 *   a meaningful host cannot be distinguished by origin
 *
 * @param canonical - The reference URL whose origin acts as the baseline.
 * @param suspect - The URL being tested against the canonical origin.
 * @returns `true` if both URLs share the same scheme, host, and port; `false` otherwise.
 */
function urlOriginsMatch(canonical, suspect) {
    const canonicalUrl = toURL(canonical);
    const suspectUrl = toURL(suspect);
    if (!canonicalUrl || !suspectUrl) {
        return false;
    }
    const canonicalOrigin = effectiveOrigin(canonicalUrl);
    const suspectOrigin = effectiveOrigin(suspectUrl);
    // Safari sends the extension GUID in uppercase while the canonical URL is lowercase,
    // Normalize both to lowercase and trim trailing slashes to avoid browser specific issues.
    const normalizedCanonicalOrigin = canonicalOrigin === null || canonicalOrigin === void 0 ? void 0 : canonicalOrigin.replace(/\/$/, "").toLowerCase();
    const normalizedSuspectOrigin = suspectOrigin === null || suspectOrigin === void 0 ? void 0 : suspectOrigin.replace(/\/$/, "").toLowerCase();
    if (!normalizedCanonicalOrigin || !normalizedSuspectOrigin) {
        return false;
    }
    return normalizedCanonicalOrigin === normalizedSuspectOrigin;
}

;// ../../libs/platform/src/index.ts




;// ./src/browser/safariApp.ts

class SafariApp {
    static sendMessageToApp(command, data = null, resolveNow = false) {
        if (!BrowserApi.isSafariApi) {
            return Promise.resolve(null);
        }
        return new Promise((resolve) => {
            const now = new Date();
            const messageId = now.getTime().toString() + "_" + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
            browser.runtime.sendNativeMessage("com.bitwarden.desktop", {
                id: messageId,
                command: command,
                data: data,
                responseData: null,
            }, (response) => {
                resolve(response);
            });
        });
    }
}

;// ../../libs/common/src/platform/services/console-log.service.ts


;// ./src/platform/services/browser-clipboard.service.ts
var browser_clipboard_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class BrowserClipboardService {
    /**
     * Copies the given text to the user's clipboard.
     *
     * @param globalContext - The global window context.
     * @param text - The text to copy.
     */
    static copy(globalContext, text) {
        return browser_clipboard_service_awaiter(this, void 0, void 0, function* () {
            if (!BrowserClipboardService.isClipboardApiSupported(globalContext, "writeText")) {
                this.useLegacyCopyMethod(globalContext, text);
                return;
            }
            try {
                yield globalContext.navigator.clipboard.writeText(text);
            }
            catch (error) {
                BrowserClipboardService.consoleLogService.debug(`Error copying to clipboard using the clipboard API, attempting legacy method: ${error}`);
                this.useLegacyCopyMethod(globalContext, text);
            }
        });
    }
    /**
     * Reads the user's clipboard and returns the text.
     *
     * @param globalContext - The global window context.
     */
    static read(globalContext) {
        return browser_clipboard_service_awaiter(this, void 0, void 0, function* () {
            if (!BrowserClipboardService.isClipboardApiSupported(globalContext, "readText")) {
                return this.useLegacyReadMethod(globalContext);
            }
            try {
                return yield globalContext.navigator.clipboard.readText();
            }
            catch (error) {
                BrowserClipboardService.consoleLogService.debug(`Error reading from clipboard using the clipboard API, attempting legacy method: ${error}`);
                return this.useLegacyReadMethod(globalContext);
            }
        });
    }
    /**
     * Copies the given text to the user's clipboard using the legacy `execCommand` method. This
     * method is used as a fallback when the clipboard API is not supported or fails.
     *
     * @param globalContext - The global window context.
     * @param text - The text to copy.
     */
    static useLegacyCopyMethod(globalContext, text) {
        if (!BrowserClipboardService.isLegacyClipboardMethodSupported(globalContext, "copy")) {
            BrowserClipboardService.consoleLogService.warning("Legacy copy method not supported");
            return;
        }
        const textareaElement = globalContext.document.createElement("textarea");
        textareaElement.textContent = !text ? " " : text;
        textareaElement.style.position = "fixed";
        globalContext.document.body.appendChild(textareaElement);
        textareaElement.select();
        try {
            const success = globalContext.document.execCommand("copy");
            if (!success) {
                BrowserClipboardService.consoleLogService.warning("execCommand('copy') returned false");
            }
        }
        catch (error) {
            BrowserClipboardService.consoleLogService.warning(`Error writing to clipboard: ${error}`);
        }
        finally {
            globalContext.document.body.removeChild(textareaElement);
        }
    }
    /**
     * Reads the user's clipboard using the legacy `execCommand` method. This method is used as a
     * fallback when the clipboard API is not supported or fails.
     *
     * @param globalContext - The global window context.
     */
    static useLegacyReadMethod(globalContext) {
        if (!BrowserClipboardService.isLegacyClipboardMethodSupported(globalContext, "paste")) {
            BrowserClipboardService.consoleLogService.warning("Legacy paste method not supported");
            return "";
        }
        const textareaElement = globalContext.document.createElement("textarea");
        textareaElement.style.position = "fixed";
        globalContext.document.body.appendChild(textareaElement);
        textareaElement.focus();
        try {
            return globalContext.document.execCommand("paste") ? textareaElement.value : "";
        }
        catch (error) {
            BrowserClipboardService.consoleLogService.warning(`Error reading from clipboard: ${error}`);
        }
        finally {
            globalContext.document.body.removeChild(textareaElement);
        }
        return "";
    }
    /**
     * Checks if the clipboard API is supported in the current environment.
     *
     * @param globalContext - The global window context.
     * @param method - The clipboard API method to check for support.
     */
    static isClipboardApiSupported(globalContext, method) {
        return "clipboard" in globalContext.navigator && method in globalContext.navigator.clipboard;
    }
    /**
     * Checks if the legacy clipboard method is supported in the current environment.
     *
     * @param globalContext - The global window context.
     * @param method - The legacy clipboard method to check for support.
     */
    static isLegacyClipboardMethodSupported(globalContext, method) {
        return ("queryCommandSupported" in globalContext.document &&
            globalContext.document.queryCommandSupported(method));
    }
}
BrowserClipboardService.consoleLogService = new ConsoleLogService(false);
/* harmony default export */ var browser_clipboard_service = (BrowserClipboardService);

;// ./src/platform/services/platform-utils/browser-platform-utils.service.ts
var browser_platform_utils_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore





class BrowserPlatformUtilsService {
    constructor(clipboardWriteCallback, globalContext, offscreenDocumentService) {
        this.clipboardWriteCallback = clipboardWriteCallback;
        this.globalContext = globalContext;
        this.offscreenDocumentService = offscreenDocumentService;
    }
    static getDevice(globalContext) {
        if (this.deviceCache) {
            return this.deviceCache;
        }
        // ORDERING MATTERS HERE
        // Ordered from most specific to least specific. We try to discern the greatest detail
        // for the type of extension the user is on by checking specific cases first and as we go down
        // the list we hope to catch all by the most generic clients they could be on.
        if (BrowserPlatformUtilsService.isFirefox()) {
            this.deviceCache = DeviceType.FirefoxExtension;
        }
        else if (BrowserPlatformUtilsService.isOpera(globalContext)) {
            this.deviceCache = DeviceType.OperaExtension;
        }
        else if (BrowserPlatformUtilsService.isEdge()) {
            this.deviceCache = DeviceType.EdgeExtension;
        }
        else if (BrowserPlatformUtilsService.isVivaldi()) {
            this.deviceCache = DeviceType.VivaldiExtension;
        }
        else if (BrowserPlatformUtilsService.isChrome(globalContext)) {
            this.deviceCache = DeviceType.ChromeExtension;
        }
        else if (BrowserPlatformUtilsService.isSafari(globalContext)) {
            this.deviceCache = DeviceType.SafariExtension;
        }
        return this.deviceCache;
    }
    getDevice() {
        return BrowserPlatformUtilsService.getDevice(this.globalContext);
    }
    getDeviceString() {
        const device = DeviceType[this.getDevice()].toLowerCase();
        return device.replace("extension", "");
    }
    getClientType() {
        return ClientType.Browser;
    }
    static isFirefox() {
        return (navigator.userAgent.indexOf(" Firefox/") !== -1 ||
            navigator.userAgent.indexOf(" Gecko/") !== -1);
    }
    isFirefox() {
        return this.getDevice() === DeviceType.FirefoxExtension;
    }
    static isChrome(globalContext) {
        return globalContext.chrome && navigator.userAgent.indexOf(" Chrome/") !== -1;
    }
    isChrome() {
        return this.getDevice() === DeviceType.ChromeExtension;
    }
    static isEdge() {
        return navigator.userAgent.indexOf(" Edg/") !== -1;
    }
    isEdge() {
        return this.getDevice() === DeviceType.EdgeExtension;
    }
    static isOpera(globalContext) {
        var _a;
        return (!!((_a = globalContext.opr) === null || _a === void 0 ? void 0 : _a.addons) ||
            !!globalContext.opera ||
            navigator.userAgent.indexOf(" OPR/") >= 0);
    }
    isOpera() {
        return this.getDevice() === DeviceType.OperaExtension;
    }
    static isVivaldi() {
        return navigator.userAgent.indexOf(" Vivaldi/") !== -1;
    }
    isVivaldi() {
        return this.getDevice() === DeviceType.VivaldiExtension;
    }
    static isSafari(globalContext) {
        // Opera masquerades as Safari, so make sure we're not there first
        return (!BrowserPlatformUtilsService.isOpera(globalContext) &&
            navigator.userAgent.indexOf(" Safari/") !== -1);
    }
    static safariVersion() {
        var _a;
        return (_a = navigator.userAgent.match("Version/([0-9.]*)")) === null || _a === void 0 ? void 0 : _a[1];
    }
    isSafari() {
        return this.getDevice() === DeviceType.SafariExtension;
    }
    isChromium() {
        return this.isChrome() || this.isEdge() || this.isOpera() || this.isVivaldi();
    }
    /**
     * Safari previous to version 16.1 had a bug which caused artifacts on hover in large extension popups.
     * https://bugs.webkit.org/show_bug.cgi?id=218704
     */
    static shouldApplySafariHeightFix(globalContext) {
        var _a;
        if (BrowserPlatformUtilsService.getDevice(globalContext) !== DeviceType.SafariExtension) {
            return false;
        }
        const version = BrowserPlatformUtilsService.safariVersion();
        const parts = (_a = version === null || version === void 0 ? void 0 : version.split(".")) === null || _a === void 0 ? void 0 : _a.map((v) => Number(v));
        return (parts === null || parts === void 0 ? void 0 : parts[0]) < 16 || ((parts === null || parts === void 0 ? void 0 : parts[0]) === 16 && (parts === null || parts === void 0 ? void 0 : parts[1]) === 0);
    }
    isIE() {
        return false;
    }
    isMacAppStore() {
        return false;
    }
    isPopupOpen() {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            return BrowserApi.isPopupOpen();
        });
    }
    isAnyViewFocused() {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            return BrowserApi.isAnyViewFocused();
        });
    }
    lockTimeout() {
        return null;
    }
    launchUri(uri, options) {
        // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
        // eslint-disable-next-line @typescript-eslint/no-floating-promises
        BrowserApi.createNewTab(uri, options && options.extensionPage === true);
    }
    getApplicationVersion() {
        var _a;
        const manifest = chrome.runtime.getManifest();
        return Promise.resolve((_a = manifest.version_name) !== null && _a !== void 0 ? _a : manifest.version);
    }
    getApplicationVersionNumber() {
        const manifest = chrome.runtime.getManifest();
        return Promise.resolve(manifest.version.split(RegExp("[+|-]"))[0].trim());
    }
    supportsWebAuthn(win) {
        return typeof PublicKeyCredential !== "undefined";
    }
    supportsDuo() {
        return true;
    }
    supportsAutofill() {
        return true;
    }
    supportsFileDownloads() {
        return false;
    }
    isDev() {
        return "production" === "development";
    }
    isSelfHost() {
        return false;
    }
    /**
     * Copies the passed text to the clipboard. For Safari, this will use
     * the native messaging API to send the text to the Bitwarden app. If
     * the extension is using manifest v3 and the calling context does not
     * have direct DOM access (e.g. a service worker), the offscreen document
     * API will be used to copy the text to the clipboard. Otherwise, the
     * browser's clipboard API will be used directly, which requires a focused
     * document with a user gesture (e.g. the popup).
     *
     * @param text - The text to copy to the clipboard.
     * @param options - Options for the clipboard operation.
     */
    copyToClipboard(text, options) {
        const windowContext = (options === null || options === void 0 ? void 0 : options.window) || this.globalContext;
        const clearing = Boolean(options === null || options === void 0 ? void 0 : options.clearing);
        const clearMs = (options === null || options === void 0 ? void 0 : options.clearMs) || null;
        const handleClipboardWriteCallback = () => {
            if (!clearing && this.clipboardWriteCallback != null) {
                this.clipboardWriteCallback(text, clearMs);
            }
        };
        if (this.isSafari()) {
            void SafariApp.sendMessageToApp("copyToClipboard", text).then(handleClipboardWriteCallback);
            return;
        }
        if (this.isChrome() && text === "") {
            text = "\u0000";
        }
        if (BrowserApi.isManifestVersion(3) &&
            this.offscreenDocumentService.offscreenApiSupported() &&
            typeof windowContext.document === "undefined") {
            void this.triggerOffscreenCopyToClipboard(text).then(handleClipboardWriteCallback);
            return;
        }
        void browser_clipboard_service.copy(windowContext, text).then(handleClipboardWriteCallback);
    }
    /**
     * Reads the text from the clipboard. For Safari, this will use the
     * native messaging API to request the text from the Bitwarden app. If
     * the extension is using manifest v3 and the calling context does not
     * have direct DOM access (e.g. a service worker), the offscreen document
     * API will be used to read the text from the clipboard. Otherwise, the
     * browser's clipboard API will be used directly.
     *
     * @param options - Options for the clipboard operation.
     */
    readFromClipboard(options) {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            const windowContext = (options === null || options === void 0 ? void 0 : options.window) || this.globalContext;
            if (this.isSafari()) {
                return yield SafariApp.sendMessageToApp("readFromClipboard");
            }
            if (BrowserApi.isManifestVersion(3) &&
                this.offscreenDocumentService.offscreenApiSupported() &&
                typeof windowContext.document === "undefined") {
                return yield this.triggerOffscreenReadFromClipboard();
            }
            return yield browser_clipboard_service.read(windowContext);
        });
    }
    supportsSecureStorage() {
        return false;
    }
    getAutofillKeyboardShortcut() {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            let autofillCommand;
            // You can not change the command in Safari or obtain it programmatically
            if (this.isSafari()) {
                autofillCommand = "Cmd+Shift+L";
            }
            else if (this.isFirefox()) {
                autofillCommand = (yield browser.commands.getAll()).find((c) => c.name === ExtensionCommand.AutofillLogin).shortcut;
                // Firefox is returning Ctrl instead of Cmd for the modifier key on macOS if
                // the command is the default one set on installation.
                if ((yield browser.runtime.getPlatformInfo()).os === "mac" &&
                    autofillCommand === "Ctrl+Shift+L") {
                    autofillCommand = "Cmd+Shift+L";
                }
            }
            else {
                yield new Promise((resolve) => chrome.commands.getAll((c) => resolve((autofillCommand = c.find((c) => c.name === ExtensionCommand.AutofillLogin).shortcut))));
            }
            return autofillCommand;
        });
    }
    packageType() {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            switch (this.getDevice()) {
                case DeviceType.ChromeExtension:
                    return "Chrome Extension";
                case DeviceType.FirefoxExtension:
                    return "Firefox Extension";
                case DeviceType.OperaExtension:
                    return "Opera Extension";
                case DeviceType.EdgeExtension:
                    return "Edge Extension";
                case DeviceType.VivaldiExtension:
                    return "Vivaldi Extension";
                case DeviceType.SafariExtension:
                    return "Safari Extension";
                default:
                    return "Unknown Browser Extension";
            }
        });
    }
    /**
     * Triggers the offscreen document API to copy the text to the clipboard.
     */
    triggerOffscreenCopyToClipboard(text) {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            yield this.offscreenDocumentService.withDocument([chrome.offscreen.Reason.CLIPBOARD], "Write text to the clipboard.", () => browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
                yield BrowserApi.sendMessageWithResponse("offscreenCopyToClipboard", { text });
            }));
        });
    }
    /**
     * Triggers the offscreen document API to read the text from the clipboard.
     */
    triggerOffscreenReadFromClipboard() {
        return browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
            const response = yield this.offscreenDocumentService.withDocument([chrome.offscreen.Reason.CLIPBOARD], "Read text from the clipboard.", () => browser_platform_utils_service_awaiter(this, void 0, void 0, function* () {
                return yield BrowserApi.sendMessageWithResponse("offscreenReadFromClipboard");
            }));
            if (typeof response === "string") {
                return response;
            }
            return "";
        });
    }
}
BrowserPlatformUtilsService.deviceCache = null;

;// ./src/platform/browser/browser-api.register-content-scripts-polyfill.ts
var browser_api_register_content_scripts_polyfill_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
/**
 * MIT License
 *
 * Copyright (c) Federico Brigante <me@fregante.com> (https://fregante.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * @see https://github.com/fregante/content-scripts-register-polyfill
 * @version 4.0.2
 */


let registerContentScripts;
function registerContentScriptsPolyfill(contentScriptOptions, callback) {
    return browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
        if (!registerContentScripts) {
            registerContentScripts = buildRegisterContentScriptsPolyfill();
        }
        return registerContentScripts(contentScriptOptions, callback);
    });
}
function buildRegisterContentScriptsPolyfill() {
    var _a, _b;
    const logService = new ConsoleLogService(false);
    const chromeProxy = globalThis.chrome && NestedProxy(globalThis.chrome);
    const patternValidationRegex = /^(https?|wss?|file|ftp|\*):\/\/(\*|\*\.[^*/]+|[^*/]+)\/.*$|^file:\/\/\/.*$|^resource:\/\/(\*|\*\.[^*/]+|[^*/]+)\/.*$|^about:/;
    const isFirefox = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent.includes("Firefox/");
    const gotScripting = Boolean((_b = globalThis.chrome) === null || _b === void 0 ? void 0 : _b.scripting);
    const gotNavigation = typeof chrome === "object" && "webNavigation" in chrome;
    function NestedProxy(target) {
        return new Proxy(target, {
            get(target, prop) {
                if (!target[prop]) {
                    return;
                }
                if (typeof target[prop] !== "function") {
                    return NestedProxy(target[prop]);
                }
                return (...arguments_) => new Promise((resolve, reject) => {
                    target[prop](...arguments_, (result) => {
                        if (chrome.runtime.lastError) {
                            reject(new Error(chrome.runtime.lastError.message));
                        }
                        else {
                            resolve(result);
                        }
                    });
                });
            },
        });
    }
    function assertValidPattern(matchPattern) {
        if (!isValidPattern(matchPattern)) {
            throw new Error(`${matchPattern} is an invalid pattern, it must match ${String(patternValidationRegex)}`);
        }
    }
    function isValidPattern(matchPattern) {
        return matchPattern === "<all_urls>" || patternValidationRegex.test(matchPattern);
    }
    function getRawPatternRegex(matchPattern) {
        assertValidPattern(matchPattern);
        let [, protocol, host = "", pathname] = matchPattern.split(/(^[^:]+:[/][/])([^/]+)?/);
        protocol = protocol
            .replace("*", isFirefox ? "(https?|wss?)" : "https?")
            .replaceAll(/[/]/g, "[/]");
        if (host === "*") {
            host = "[^/]+";
        }
        else if (host) {
            host = host
                .replace(/^[*][.]/, "([^/]+.)*")
                .replaceAll(/[.]/g, "[.]")
                .replace(/[*]$/, "[^.]+");
        }
        pathname = pathname
            .replaceAll(/[/]/g, "[/]")
            .replaceAll(/[.]/g, "[.]")
            .replaceAll(/[*]/g, ".*");
        return "^" + protocol + host + "(" + pathname + ")?$";
    }
    function patternToRegex(...matchPatterns) {
        if (matchPatterns.length === 0) {
            return /$./;
        }
        if (matchPatterns.includes("<all_urls>")) {
            // <all_urls> regex
            return /^(https?|file|ftp):[/]+/;
        }
        if (matchPatterns.includes("*://*/*")) {
            // all stars regex
            return isFirefox ? /^(https?|wss?):[/][/][^/]+([/].*)?$/ : /^https?:[/][/][^/]+([/].*)?$/;
        }
        return new RegExp(matchPatterns.map((x) => getRawPatternRegex(x)).join("|"));
    }
    function castAllFramesTarget(target) {
        if (typeof target === "object") {
            return Object.assign(Object.assign({}, target), { allFrames: false });
        }
        return {
            tabId: target,
            frameId: undefined,
            allFrames: true,
        };
    }
    function castArray(possibleArray) {
        if (Array.isArray(possibleArray)) {
            return possibleArray;
        }
        return [possibleArray];
    }
    function createTarget(tabId, frameId, allFrames) {
        if (frameId === undefined) {
            return {
                tabId,
                frameIds: undefined,
                allFrames: allFrames,
            };
        }
        else {
            return {
                tabId,
                frameIds: [frameId],
                allFrames: undefined,
            };
        }
    }
    function insertCSS(_a) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, arguments, void 0, function* ({ tabId, frameId, files, allFrames, matchAboutBlank, runAt, }, { ignoreTargetErrors } = {}) {
            const everyInsertion = Promise.all(files.map((content) => browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
                if (typeof content === "string") {
                    content = { file: content };
                }
                if (gotScripting) {
                    if ("file" in content) {
                        return chrome.scripting.insertCSS({
                            target: createTarget(tabId, frameId, allFrames),
                            files: [content.file],
                        });
                    }
                    else {
                        return chrome.scripting.insertCSS({
                            target: createTarget(tabId, frameId, allFrames),
                            css: content.code,
                        });
                    }
                }
                return chromeProxy.tabs.insertCSS(tabId, Object.assign(Object.assign({}, content), { matchAboutBlank,
                    allFrames,
                    frameId, runAt: runAt !== null && runAt !== void 0 ? runAt : "document_start" }));
            })));
            if (ignoreTargetErrors) {
                yield catchTargetInjectionErrors(everyInsertion);
            }
            else {
                yield everyInsertion;
            }
        });
    }
    function assertNoCode(files) {
        if (files.some((content) => "code" in content)) {
            throw new Error("chrome.scripting does not support injecting strings of `code`");
        }
    }
    function executeScript(_a) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, arguments, void 0, function* ({ tabId, frameId, files, allFrames, matchAboutBlank, runAt, }, { ignoreTargetErrors } = {}) {
            const normalizedFiles = files.map((file) => (typeof file === "string" ? { file } : file));
            if (gotScripting) {
                assertNoCode(normalizedFiles);
                const injection = chrome.scripting.executeScript({
                    target: createTarget(tabId, frameId, allFrames),
                    files: normalizedFiles.map(({ file }) => file),
                });
                if (ignoreTargetErrors) {
                    yield catchTargetInjectionErrors(injection);
                }
                else {
                    yield injection;
                }
                return;
            }
            const executions = [];
            for (const content of normalizedFiles) {
                if ("code" in content) {
                    yield executions.at(-1);
                }
                executions.push(chromeProxy.tabs.executeScript(tabId, Object.assign(Object.assign({}, content), { matchAboutBlank,
                    allFrames,
                    frameId,
                    runAt })));
            }
            if (ignoreTargetErrors) {
                yield catchTargetInjectionErrors(Promise.all(executions));
            }
            else {
                yield Promise.all(executions);
            }
        });
    }
    function injectContentScript(where_1, scripts_1) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, arguments, void 0, function* (where, scripts, options = {}) {
            const targets = castArray(where);
            yield Promise.all(targets.map((target) => browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () { return injectContentScriptInSpecificTarget(castAllFramesTarget(target), scripts, options); })));
        });
    }
    function injectContentScriptInSpecificTarget(_a, scripts_1) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, arguments, void 0, function* ({ frameId, tabId, allFrames }, scripts, options = {}) {
            const injections = castArray(scripts).flatMap((script) => {
                var _a, _b, _c, _d, _e, _f;
                return [
                    insertCSS({
                        tabId,
                        frameId,
                        allFrames,
                        files: (_a = script.css) !== null && _a !== void 0 ? _a : [],
                        matchAboutBlank: (_b = script.matchAboutBlank) !== null && _b !== void 0 ? _b : script.match_about_blank,
                        runAt: (_c = script.runAt) !== null && _c !== void 0 ? _c : script.run_at,
                    }, options),
                    executeScript({
                        tabId,
                        frameId,
                        allFrames,
                        files: (_d = script.js) !== null && _d !== void 0 ? _d : [],
                        matchAboutBlank: (_e = script.matchAboutBlank) !== null && _e !== void 0 ? _e : script.match_about_blank,
                        runAt: (_f = script.runAt) !== null && _f !== void 0 ? _f : script.run_at,
                    }, options),
                ];
            });
            yield Promise.all(injections);
        });
    }
    function catchTargetInjectionErrors(promise) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
            try {
                yield promise;
            }
            catch (error) {
                const targetErrors = /^No frame with id \d+ in tab \d+.$|^No tab with id: \d+.$|^The tab was closed.$|^The frame was removed.$/;
                if (!targetErrors.test(error === null || error === void 0 ? void 0 : error.message)) {
                    throw error;
                }
            }
        });
    }
    function isOriginPermitted(url) {
        return browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
            return chromeProxy.permissions.contains({
                origins: [new URL(url).origin + "/*"],
            });
        });
    }
    return (contentScriptOptions, callback) => browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
        const { js = [], css = [], matchAboutBlank, matches = [], excludeMatches, runAt, } = contentScriptOptions;
        let { allFrames } = contentScriptOptions;
        if (gotNavigation) {
            allFrames = false;
        }
        else if (allFrames) {
            logService.warning("`allFrames: true` requires the `webNavigation` permission to work correctly: https://github.com/fregante/content-scripts-register-polyfill#permissions");
        }
        if (matches.length === 0) {
            throw new Error("Type error for parameter contentScriptOptions (Error processing matches: Array requires at least 1 items; you have 0) for contentScripts.register.");
        }
        yield Promise.all(matches.map((pattern) => browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
            if (!(yield chromeProxy.permissions.contains({ origins: [pattern] }))) {
                throw new Error(`Permission denied to register a content script for ${pattern}`);
            }
        })));
        const matchesRegex = patternToRegex(...matches);
        const excludeMatchesRegex = patternToRegex(...(excludeMatches !== null && excludeMatches !== void 0 ? excludeMatches : []));
        const inject = (url_1, tabId_1, ...args_1) => browser_api_register_content_scripts_polyfill_awaiter(this, [url_1, tabId_1, ...args_1], void 0, function* (url, tabId, frameId = 0) {
            if (!matchesRegex.test(url) ||
                excludeMatchesRegex.test(url) ||
                !(yield isOriginPermitted(url))) {
                return;
            }
            yield injectContentScript({ tabId, frameId }, { css, js, matchAboutBlank, runAt }, { ignoreTargetErrors: true });
        });
        const tabListener = (tabId_1, _a, _b) => browser_api_register_content_scripts_polyfill_awaiter(this, [tabId_1, _a, _b], void 0, function* (tabId, { status }, { url }) {
            if (status === "loading" && url) {
                void inject(url, tabId);
            }
        });
        const navListener = (_a) => browser_api_register_content_scripts_polyfill_awaiter(this, [_a], void 0, function* ({ tabId, frameId, url, }) {
            void inject(url, tabId, frameId);
        });
        if (gotNavigation) {
            BrowserApi.addListener(chrome.webNavigation.onCommitted, navListener);
        }
        else {
            BrowserApi.addListener(chrome.tabs.onUpdated, tabListener);
        }
        const registeredContentScript = {
            unregister() {
                return browser_api_register_content_scripts_polyfill_awaiter(this, void 0, void 0, function* () {
                    if (gotNavigation) {
                        chrome.webNavigation.onCommitted.removeListener(navListener);
                    }
                    else {
                        chrome.tabs.onUpdated.removeListener(tabListener);
                    }
                });
            },
        };
        if (typeof callback === "function") {
            callback(registeredContentScript);
        }
        return registeredContentScript;
    });
}

;// ./src/platform/browser/extension-install-type.ts
const ExtensionInstallType = Object.freeze({
    Admin: "admin",
    Development: "development",
    Normal: "normal",
    Sideload: "sideload",
    Other: "other",
    Unknown: "unknown",
});

;// ./src/platform/browser/browser-api.ts
var browser_api_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore







class BrowserApi {
    static get manifestVersion() {
        return chrome.runtime.getManifest().manifest_version;
    }
    /**
     * Determines if the extension manifest version is the given version.
     *
     * @param expectedVersion - The expected manifest version to check against.
     */
    static isManifestVersion(expectedVersion) {
        return BrowserApi.manifestVersion === expectedVersion;
    }
    /**
     * Returns how this extension was installed on the current browser. Use
     * {@link ExtensionInstallType.Admin} to detect enterprise-policy installs and
     * {@link ExtensionInstallType.Sideload} to detect extensions installed by other software
     * on the machine.
     *
     * `management.getSelf()` is the only `chrome.management` method that does
     * not require the "management" manifest permission.
     */
    static getInstallType() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            var _a, _b;
            try {
                if (BrowserApi.isWebExtensionsApi) {
                    const info = yield browser.management.getSelf();
                    return (_a = info === null || info === void 0 ? void 0 : info.installType) !== null && _a !== void 0 ? _a : ExtensionInstallType.Unknown;
                }
                else if (BrowserApi.isChromeApi) {
                    const info = yield chrome.management.getSelf();
                    return (_b = info === null || info === void 0 ? void 0 : info.installType) !== null && _b !== void 0 ? _b : ExtensionInstallType.Unknown;
                }
            }
            catch (_c) {
                // management API not available on this browser (e.g. older Safari)
            }
            return ExtensionInstallType.Unknown;
        });
    }
    /**
     * Returns `true` if the message sender appears to originate from within this extension.
     *
     * Returns `false` when:
     * - `sender` is absent or has no `origin` property
     * - The extension's own URL cannot be determined at runtime
     * - The sender's origin does not match the extension's origin (compared by scheme, host, and port;
     *   senders without a host such as `file:` or `data:` URLs are always rejected)
     * - The message comes from a sub-frame rather than the top-level frame
     *
     * Note: this is a best-effort check that relies on the browser correctly populating `sender.origin`.
     *
     * @param sender - The message sender to validate. `undefined` or a sender without `origin` returns `false`.
     * @param logger - Optional logger; rejections are reported at `warning` level, acceptance at `info`.
     * @returns `true` if the sender appears to be internal to the extension; `false` otherwise.
     */
    static senderIsInternal(sender, logger) {
        var _a;
        if (!(sender === null || sender === void 0 ? void 0 : sender.origin)) {
            logger === null || logger === void 0 ? void 0 : logger.warning("[BrowserApi] Message sender has no origin");
            return false;
        }
        // Empty path yields the extension's base URL; coalesce to empty string so the guard below fires on a missing runtime.
        const extensionUrl = (_a = BrowserApi.getRuntimeURL("")) !== null && _a !== void 0 ? _a : "";
        if (!extensionUrl) {
            logger === null || logger === void 0 ? void 0 : logger.warning("[BrowserApi] Unable to determine extension URL");
            return false;
        }
        if (!urlOriginsMatch(extensionUrl, sender.origin)) {
            logger === null || logger === void 0 ? void 0 : logger.warning(`[BrowserApi] Message sender origin (${sender.origin}) does not match extension URL (${extensionUrl})`);
            return false;
        }
        // frameId is absent for popups, so use an 'in' check rather than direct comparison.
        if ("frameId" in sender && sender.frameId !== 0) {
            logger === null || logger === void 0 ? void 0 : logger.warning("[BrowserApi] Message sender is not from the top-level frame");
            return false;
        }
        logger === null || logger === void 0 ? void 0 : logger.info("[BrowserApi] Message sender appears to be internal");
        return true;
    }
    /**
     * Gets all open browser windows, including their tabs.
     *
     * @returns A promise that resolves to an array of browser windows.
     */
    static getWindows() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.windows.getAll({ populate: true }, resolve));
        });
    }
    /**
     * Gets the current window or the window with the given id.
     *
     * @param windowId - The id of the window to get. If not provided, the current window is returned.
     */
    static getWindow(windowId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (!windowId) {
                return BrowserApi.getCurrentWindow();
            }
            return yield BrowserApi.getWindowById(windowId);
        });
    }
    /**
     * Gets the currently active browser window.
     */
    static getCurrentWindow() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.windows.getCurrent({ populate: true }, resolve));
        });
    }
    /**
     * Gets the window with the given id.
     *
     * @param windowId - The id of the window to get.
     */
    static getWindowById(windowId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.windows.get(windowId, { populate: true }, resolve));
        });
    }
    static createWindow(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => {
                chrome.windows.create(options, (newWindow) => browser_api_awaiter(this, void 0, void 0, function* () {
                    if (!BrowserApi.isSafariApi) {
                        return resolve(newWindow);
                    }
                    // Safari doesn't close the default extension popup when a new window is created so we need to
                    // manually trigger the close by focusing the main window after the new window is created
                    const allWindows = yield new Promise((resolve) => {
                        chrome.windows.getAll({ windowTypes: ["normal"] }, (windows) => resolve(windows));
                    });
                    const mainWindow = allWindows.find((window) => window.id !== newWindow.id);
                    // No main window found, resolve the new window
                    if (mainWindow == null || !mainWindow.id) {
                        return resolve(newWindow);
                    }
                    // Focus the main window to close the extension popup
                    chrome.windows.update(mainWindow.id, { focused: true }, () => {
                        // Refocus the newly created window
                        chrome.windows.update(newWindow.id, { focused: true }, () => {
                            resolve(newWindow);
                        });
                    });
                }));
            });
        });
    }
    /**
     * Removes the window with the given id.
     *
     * @param windowId - The id of the window to remove.
     */
    static removeWindow(windowId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.windows.remove(windowId, () => resolve()));
        });
    }
    /**
     * Updates the properties of the window with the given id.
     *
     * @param windowId - The id of the window to update.
     * @param options - The window properties to update.
     */
    static updateWindowProperties(windowId, options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.windows.update(windowId, options, () => {
                resolve();
            }));
        });
    }
    /**
     * Focuses the window with the given id.
     *
     * @param windowId - The id of the window to focus.
     */
    static focusWindow(windowId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            yield BrowserApi.updateWindowProperties(windowId, { focused: true });
        });
    }
    static getTabFromCurrentWindowId() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return yield BrowserApi.tabsQueryFirstCurrentWindowForSafari({
                active: true,
                windowId: chrome.windows.WINDOW_ID_CURRENT,
            });
        });
    }
    static getBrowserClientVendor(clientWindow) {
        const device = BrowserPlatformUtilsService.getDevice(clientWindow);
        switch (device) {
            case DeviceType.ChromeExtension:
            case DeviceType.ChromeBrowser:
                return BrowserClientVendors.Chrome;
            case DeviceType.OperaExtension:
            case DeviceType.OperaBrowser:
                return BrowserClientVendors.Opera;
            case DeviceType.EdgeExtension:
            case DeviceType.EdgeBrowser:
                return BrowserClientVendors.Edge;
            case DeviceType.VivaldiExtension:
            case DeviceType.VivaldiBrowser:
                return BrowserClientVendors.Vivaldi;
            case DeviceType.FirefoxExtension:
            case DeviceType.FirefoxBrowser:
                return BrowserClientVendors.Firefox;
            default:
                return BrowserClientVendors.Unknown;
        }
    }
    /**
     * Gets the tab with the given id.
     *
     * @param tabId - The id of the tab to get.
     */
    static getTab(tabId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (!tabId) {
                return null;
            }
            if (BrowserApi.isManifestVersion(3)) {
                return yield chrome.tabs.get(tabId);
            }
            return new Promise((resolve) => chrome.tabs.get(tabId, (tab) => {
                resolve(tab);
            }));
        });
    }
    static getTabFromCurrentWindow() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return yield BrowserApi.tabsQueryFirstCurrentWindowForSafari({
                active: true,
                currentWindow: true,
            });
        });
    }
    static getActiveTabs() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return yield BrowserApi.tabsQuery({
                active: true,
            });
        });
    }
    /**
     * Fetch the currently open browser tab
     */
    static getCurrentTab() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (BrowserApi.isManifestVersion(3)) {
                return yield chrome.tabs.getCurrent();
            }
            return new Promise((resolve) => chrome.tabs.getCurrent((tab) => {
                resolve(tab);
            }));
        });
    }
    /**
     * Closes a browser tab with the given id
     *
     * @param tabId The id of the tab to close
     */
    static closeTab(tabId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (tabId) {
                if (BrowserApi.isWebExtensionsApi) {
                    yield browser.tabs.remove(tabId).catch((error) => {
                        throw new Error("[BrowserApi] Failed to remove current tab: " + error.message);
                    });
                }
                else if (BrowserApi.isChromeApi) {
                    yield chrome.tabs.remove(tabId).catch((error) => {
                        throw new Error("[BrowserApi] Failed to remove current tab: " + error.message);
                    });
                }
            }
        });
    }
    /**
     * Navigates a browser tab to the given URL
     *
     * @param tabId The id of the tab to navigate
     * @param url The URL to navigate to
     */
    static navigateTabToUrl(tabId, url) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (tabId) {
                if (BrowserApi.isWebExtensionsApi) {
                    yield browser.tabs.update(tabId, { url: url.href }).catch((error) => {
                        throw new Error("Failed to navigate tab to URL: " + error.message);
                    });
                }
                else if (BrowserApi.isChromeApi) {
                    chrome.tabs.update(tabId, { url: url.href }, () => {
                        if (chrome.runtime.lastError) {
                            throw new Error("Failed to navigate tab to URL: " + chrome.runtime.lastError.message);
                        }
                    });
                }
            }
        });
    }
    static tabsQuery(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => {
                chrome.tabs.query(options, (tabs) => {
                    resolve(tabs);
                });
            });
        });
    }
    static tabsQueryFirst(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            const tabs = yield BrowserApi.tabsQuery(options);
            if (tabs.length > 0) {
                return tabs[0];
            }
            return null;
        });
    }
    /**
     * Drop-in replacement for {@link BrowserApi.tabsQueryFirst}.
     *
     * Safari sometimes returns >1 tabs unexpectedly even when
     * specifying a `windowId` or `currentWindow: true` query option.
     *
     * For all of these calls,
     * ```
     * await chrome.tabs.query({active: true, currentWindow: true})
     * await chrome.tabs.query({active: true, windowId: chrome.windows.WINDOW_ID_CURRENT})
     * await chrome.tabs.query({active: true, windowId: 10})
     * ```
     *
     * Safari could return:
     * ```
     * [
     *   {windowId: 2, pinned: true, title: "Incorrect tab in another window", …},
     *   {windowId: 10, title: "Correct tab in foreground", …},
     * ]
     * ```
     *
     * This function captures the current window ID manually before running the query,
     * then finds and returns the tab with the matching window ID.
     *
     * See the `SafariTabsQuery` tests in `browser-api.spec.ts`.
     *
     * This workaround can be removed when Safari fixes this bug.
     */
    static tabsQueryFirstCurrentWindowForSafari(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (!BrowserApi.isSafariApi) {
                return yield BrowserApi.tabsQueryFirst(options);
            }
            const currentWindowId = (yield BrowserApi.getCurrentWindow()).id;
            const tabs = yield BrowserApi.tabsQuery(options);
            if (tabs.length <= 1 || currentWindowId == null) {
                return tabs[0];
            }
            return (_a = tabs.find((t) => t.windowId === currentWindowId)) !== null && _a !== void 0 ? _a : tabs[0];
        });
    }
    static tabSendMessageData(tab, command, data = null) {
        const obj = {
            command: command,
        };
        if (data != null) {
            obj.data = data;
        }
        return BrowserApi.tabSendMessage(tab, obj);
    }
    static tabSendMessage(tab_1, obj_1) {
        return browser_api_awaiter(this, arguments, void 0, function* (tab, obj, options = null, rejectOnError = false) {
            if (!tab || !tab.id) {
                return;
            }
            return new Promise((resolve, reject) => {
                chrome.tabs.sendMessage(tab.id, obj, options, (response) => {
                    if (chrome.runtime.lastError && rejectOnError) {
                        // Some error happened
                        reject();
                    }
                    resolve(response);
                });
            });
        });
    }
    static sendTabsMessage(tabId, message, options, responseCallback) {
        chrome.tabs.sendMessage(tabId, message, options, responseCallback);
    }
    static getRuntimeURL(path) {
        if (BrowserApi.isWebExtensionsApi) {
            return browser.runtime.getURL(path);
        }
        else if (BrowserApi.isChromeApi) {
            return chrome.runtime.getURL(path);
        }
    }
    static onWindowCreated(callback) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            // FIXME: Make sure that is does not cause a memory leak in Safari or use BrowserApi.AddListener
            // and test that it doesn't break.
            // eslint-disable-next-line no-restricted-syntax
            return chrome.windows.onCreated.addListener(callback);
        });
    }
    /**
     * Gets the background page for the extension. This method is
     * not valid within manifest v3 background service workers. As
     * a result, it will return null when called from that context.
     */
    static getBackgroundPage() {
        if (typeof chrome.extension.getBackgroundPage === "undefined") {
            return null;
        }
        return chrome.extension.getBackgroundPage();
    }
    /**
     * Accepts a window object and determines if it is
     * associated with the background page of the extension.
     *
     * @param window - The window to check.
     */
    static isBackgroundPage(window) {
        return typeof window !== "undefined" && window === BrowserApi.getBackgroundPage();
    }
    /**
     * Gets the extension views that match the given properties. This method is not
     * available within background service worker. As a result, it will return an
     * empty array when called from that context.
     *
     * @param fetchProperties - The properties used to filter extension views.
     */
    static getExtensionViews(fetchProperties) {
        if (typeof chrome.extension.getViews === "undefined") {
            return [];
        }
        return chrome.extension.getViews(fetchProperties);
    }
    /**
     * Returns true if the vault popup is currently open.
     *
     * Uses `chrome.runtime.getContexts()` on MV3 (Chrome/Edge),
     * and falls back to `chrome.extension.getViews()` for MV2 (Firefox) and Safari.
     */
    static isPopupOpen() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (typeof chrome.runtime.getContexts === "function" &&
                BrowserApi.isManifestVersion(3)) {
                const contexts = yield chrome.runtime.getContexts({});
                return contexts.some((context) => context.contextType === "POPUP");
            }
            // MV2/Safari — background page can use getExtensionViews
            return BrowserApi.getExtensionViews({ type: "popup" }).length > 0;
        });
    }
    /**
     * Returns true if the toolbar popup or any popout window is currently open.
     *
     * Used to gate `chrome.runtime.reload()` so it doesn't fire while a popout is mid-teardown.
     * Popouts are classified as `TAB` contexts (not `POPUP`) by `chrome.runtime.getContexts`,
     * so they're identified by `uilocation=popout` in their documentUrl.
     */
    static isAnyPopupOrPopoutOpen() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (typeof chrome.runtime.getContexts === "function" &&
                BrowserApi.isManifestVersion(3)) {
                const contexts = yield chrome.runtime.getContexts({});
                return contexts.some((context) => {
                    var _a;
                    return context.contextType === "POPUP" ||
                        (context.contextType === "TAB" && ((_a = context.documentUrl) === null || _a === void 0 ? void 0 : _a.includes("uilocation=popout")));
                });
            }
            // MV2/Safari — background page can use getExtensionViews
            if (BrowserApi.getExtensionViews({ type: "popup" }).length > 0) {
                return true;
            }
            return BrowserApi.getExtensionViews({ type: "tab" }).some((v) => v.location.href.includes("uilocation=popout"));
        });
    }
    /**
     * Returns true if any extension view is currently active/focused.
     *
     * - Main popup: always considered focused (auto-closes on blur).
     * - Sidebar: always considered focused (always visible).
     * - Popout windows: only focused if the window is currently focused.
     *
     * Uses `chrome.runtime.getContexts()` on MV3 (Chrome/Edge),
     * and falls back to `chrome.extension.getViews()` for MV2 (Firefox) and Safari.
     *
     * NOTE: The `getContexts` path is restricted to MV3. Firefox MV2's persistent
     * background page is classified as a "POPUP" context by `runtime.getContexts()`,
     * which would cause `isAnyViewFocused` to permanently return true and block vault
     * timeout. The `getExtensionViews` path only returns actually-visible views.
     */
    static isAnyViewFocused() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (typeof chrome.runtime.getContexts === "function" &&
                BrowserApi.isManifestVersion(3)) {
                const contexts = yield chrome.runtime.getContexts({});
                if (contexts.some((c) => c.contextType === "POPUP" || c.contextType === "SIDE_PANEL")) {
                    return true;
                }
                const tabs = contexts.filter((c) => { var _a; return c.contextType === "TAB" && ((_a = c.documentUrl) === null || _a === void 0 ? void 0 : _a.includes("uilocation=popout")); });
                for (const context of tabs) {
                    const win = yield BrowserApi.getWindowById(context.windowId);
                    if (win === null || win === void 0 ? void 0 : win.focused) {
                        return true;
                    }
                }
                return false;
            }
            // MV2/Safari — background page can use getExtensionViews
            if (BrowserApi.getExtensionViews({ type: "popup" }).length > 0) {
                return true;
            }
            return BrowserApi.getExtensionViews({ type: "tab" }).some((v) => v.location.href.includes("uilocation=sidebar") ||
                (v.location.href.includes("uilocation=popout") && v.document.hasFocus()));
        });
    }
    static createNewTab(url, active = true) {
        return new Promise((resolve) => chrome.tabs.create({ url: url, active: active }, (tab) => resolve(tab)));
    }
    /**
     * Gathers the details for a specified sub-frame of a tab.
     *
     * @param details - The details of the frame to get.
     */
    static getFrameDetails(details) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.webNavigation.getFrame(details, resolve));
        });
    }
    /**
     * Gets all frames associated with a tab.
     *
     * @param tabId - The id of the tab to get the frames for.
     */
    static getAllFrameDetails(tabId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.webNavigation.getAllFrames({ tabId }, resolve));
        });
    }
    static messageListener(name, callback) {
        BrowserApi.addListener(chrome.runtime.onMessage, callback);
    }
    static messageListener$() {
        return new Observable((subscriber) => {
            const handler = (message) => {
                subscriber.next(message);
            };
            BrowserApi.addListener(chrome.runtime.onMessage, handler);
            return () => BrowserApi.removeListener(chrome.runtime.onMessage, handler);
        });
    }
    static storageChangeListener(callback) {
        BrowserApi.addListener(chrome.storage.onChanged, callback);
    }
    /**
     * Adds a callback to the given chrome event in a cross-browser platform manner.
     *
     * **Important:** All event listeners in the browser extension popup context must
     * use this instead of the native APIs to handle unsubscribing from Safari properly.
     *
     * @param event - The event in which to add the listener to.
     * @param callback - The callback you want registered onto the event.
     */
    static addListener(event, callback) {
        event.addListener(callback);
        if (BrowserApi.isSafariApi && !BrowserApi.isBackgroundPage(self)) {
            BrowserApi.trackedChromeEventListeners.push([event, callback]);
            BrowserApi.setupUnloadListeners();
        }
    }
    /**
     * Removes a callback from the given chrome event in a cross-browser platform manner.
     * @param event - The event in which to remove the listener from.
     * @param callback - The callback you want removed from the event.
     */
    // Chrome's Event.removeListener expects callback args as `any[]` to align with its internal event typings.
    static removeListener(event, callback) {
        event.removeListener(callback);
        if (BrowserApi.isSafariApi && !BrowserApi.isBackgroundPage(self)) {
            const index = BrowserApi.trackedChromeEventListeners.findIndex(([_event, eventListener]) => {
                return eventListener == callback;
            });
            if (index !== -1) {
                BrowserApi.trackedChromeEventListeners.splice(index, 1);
            }
        }
    }
    // Setup the event to destroy all the listeners when the popup gets unloaded in Safari, otherwise we get a memory leak
    static setupUnloadListeners() {
        // The MDN recommend using 'visibilitychange' but that event is fired any time the popup window is obscured as well
        // 'pagehide' works just like 'unload' but is compatible with the back/forward cache, so we prefer using that one
        self.addEventListener("pagehide", () => {
            for (const [event, callback] of BrowserApi.trackedChromeEventListeners) {
                event.removeListener(callback);
            }
        });
    }
    /**
     * Whether the Chrome Side Panel API is available (Chrome 114+).
     */
    static get isSidePanelApiSupported() {
        return typeof chrome !== "undefined" && typeof chrome.sidePanel !== "undefined";
    }
    /**
     * Opens the extension's side panel for a specific tab.
     * Must be called in response to a user gesture (context menu click qualifies).
     */
    static openSidePanel(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (!BrowserApi.isSidePanelApiSupported) {
                return;
            }
            yield chrome.sidePanel.open({ tabId: options.tabId });
        });
    }
    /**
     * Sets the side panel options (path, enabled state), optionally scoped to a tab.
     */
    static setSidePanelOptions(options) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (!BrowserApi.isSidePanelApiSupported) {
                return;
            }
            yield chrome.sidePanel.setOptions(options);
        });
    }
    static sendMessage(subscriber, arg = {}) {
        const message = Object.assign({}, { command: subscriber }, arg);
        return chrome.runtime.sendMessage(message);
    }
    static sendMessageWithResponse(subscriber, arg = {}) {
        const message = Object.assign({}, { command: subscriber }, arg);
        return new Promise((resolve) => chrome.runtime.sendMessage(message, resolve));
    }
    static focusTab(tabId) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            chrome.tabs.update(tabId, { active: true, highlighted: true });
        });
    }
    static closePopup(win) {
        if (BrowserApi.isWebExtensionsApi && BrowserApi.isFirefoxOnAndroid) {
            // Reactivating the active tab dismisses the popup tab. The promise final
            // condition is only called if the popup wasn't already dismissed (future proofing).
            // ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1433604
            // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            browser.tabs.update({ active: true }).finally(win.close);
        }
        else {
            win.close();
        }
    }
    static gaFilter() {
        return "production" !== "production";
    }
    static getUILanguage() {
        return chrome.i18n.getUILanguage();
    }
    /**
     * Handles reloading the extension using the underlying functionality exposed by the browser API.
     */
    static reloadExtension() {
        // If we do `chrome.runtime.reload` on safari they will send an onInstalled reason of install
        // and that prompts us to show a new tab, this apparently doesn't happen on sideloaded
        // extensions and only shows itself production scenarios. See: https://bitwarden.atlassian.net/browse/PM-12298
        if (this.isSafariApi) {
            return self.location.reload();
        }
        return chrome.runtime.reload();
    }
    /**
     * Reloads all open extension views, except the background page. Will also
     * skip reloading the current window location if exemptCurrentHref is true.
     *
     * @param exemptCurrentHref - Whether to exempt the current window location from the reload.
     */
    static reloadOpenWindows(exemptCurrentHref = false) {
        const views = BrowserApi.getExtensionViews();
        if (!views.length) {
            return;
        }
        const currentHref = self.location.href;
        views
            .filter((w) => w.location.href != null && !w.location.href.includes("background.html"))
            .filter((w) => !exemptCurrentHref || w.location.href !== currentHref)
            .forEach((w) => w.location.reload());
    }
    static connectNative(application) {
        if (BrowserApi.isWebExtensionsApi) {
            return browser.runtime.connectNative(application);
        }
        else if (BrowserApi.isChromeApi) {
            return chrome.runtime.connectNative(application);
        }
    }
    static requestPermission(permission) {
        if (BrowserApi.isWebExtensionsApi) {
            return browser.permissions.request(permission);
        }
        return new Promise((resolve) => {
            chrome.permissions.request(permission, resolve);
        });
    }
    /**
     * Checks if the user has provided the given permissions to the extension.
     *
     * @param permissions - The permissions to check.
     */
    static permissionsGranted(permissions) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve) => chrome.permissions.contains({ permissions }, (result) => resolve(result)));
        });
    }
    static getPlatformInfo() {
        if (BrowserApi.isWebExtensionsApi) {
            return browser.runtime.getPlatformInfo();
        }
        return new Promise((resolve) => {
            chrome.runtime.getPlatformInfo(resolve);
        });
    }
    /**
     * Returns the supported BrowserAction API based on the manifest version.
     */
    static getBrowserAction() {
        return BrowserApi.isManifestVersion(3) ? chrome.action : chrome.browserAction;
    }
    static getSidebarAction(win) {
        var _a;
        const deviceType = BrowserPlatformUtilsService.getDevice(win);
        if (deviceType === DeviceType.FirefoxExtension) {
            return browser.sidebarAction;
        }
        if (deviceType === DeviceType.OperaExtension) {
            return (_a = win.opr) === null || _a === void 0 ? void 0 : _a.sidebarAction;
        }
        return null;
    }
    static captureVisibleTab() {
        return new Promise((resolve) => {
            chrome.tabs.captureVisibleTab(null, { format: "png" }, resolve);
        });
    }
    /**
     * Extension API helper method used to execute a script in a tab.
     *
     * @see https://developer.chrome.com/docs/extensions/reference/tabs/#method-executeScript
     * @param tabId - The id of the tab to execute the script in.
     * @param details {@link "InjectDetails" https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/extensionTypes/InjectDetails}
     * @param scriptingApiDetails {@link "ExecutionWorld" https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld}
     */
    static executeScriptInTab(tabId, details, scriptingApiDetails) {
        if (BrowserApi.isManifestVersion(3)) {
            let target;
            if (typeof details.frameId === "number") {
                target = { tabId, frameIds: [details.frameId] };
            }
            else if (details.allFrames) {
                target = { tabId, allFrames: true };
            }
            else {
                target = { tabId };
            }
            return chrome.scripting.executeScript({
                target,
                files: details.file ? [details.file] : null,
                injectImmediately: details.runAt === "document_start",
                world: (scriptingApiDetails === null || scriptingApiDetails === void 0 ? void 0 : scriptingApiDetails.world) || chrome.scripting.ExecutionWorld.ISOLATED,
            });
        }
        return new Promise((resolve) => {
            chrome.tabs.executeScript(tabId, details, (result) => {
                resolve(result);
            });
        });
    }
    /**
     * Executes a self-contained function in the given tab and returns its result from the top frame.
     * The function is serialized for injection, so it must not close over outer-scope variables.
     *
     * @param tabId - The id of the tab to execute the function in.
     * @param func - The function to inject.
     */
    static executeFunctionInTab(tabId, func) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (BrowserApi.isManifestVersion(3)) {
                const results = yield chrome.scripting.executeScript({
                    target: { tabId },
                    func,
                });
                return (_a = results === null || results === void 0 ? void 0 : results[0]) === null || _a === void 0 ? void 0 : _a.result;
            }
            // MV2 has no `func` parameter, so serialize the function source and inject it as code.
            return new Promise((resolve) => {
                chrome.tabs.executeScript(tabId, { code: `(${func.toString()})()` }, (results) => resolve(results === null || results === void 0 ? void 0 : results[0]));
            });
        });
    }
    /**
     * Identifies if the browser autofill settings are overridden by the extension.
     */
    static browserAutofillSettingsOverridden() {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            if (!(yield BrowserApi.permissionsGranted(["privacy"]))) {
                return false;
            }
            const checkOverrideStatus = (details) => details.levelOfControl === "controlled_by_this_extension" && !details.value;
            const passwordSavingOverridden = yield new Promise((resolve) => chrome.privacy.services.passwordSavingEnabled.get({}, (details) => resolve(checkOverrideStatus(details))));
            if (BrowserApi.isFirefox) {
                return passwordSavingOverridden;
            }
            const autofillAddressOverridden = yield new Promise((resolve) => chrome.privacy.services.autofillAddressEnabled.get({}, (details) => resolve(checkOverrideStatus(details))));
            const autofillCreditCardOverridden = yield new Promise((resolve) => chrome.privacy.services.autofillCreditCardEnabled.get({}, (details) => resolve(checkOverrideStatus(details))));
            return autofillAddressOverridden && autofillCreditCardOverridden && passwordSavingOverridden;
        });
    }
    /**
     * Updates the browser autofill settings to the given value.
     *
     * @param value - Determines whether to enable or disable the autofill settings.
     */
    static updateDefaultBrowserAutofillSettings(value) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c;
            if (BrowserApi.isFirefox) {
                if (BrowserApi.isWebExtensionsApi) {
                    yield ((_c = (_b = (_a = browser.privacy) === null || _a === void 0 ? void 0 : _a.services) === null || _b === void 0 ? void 0 : _b.passwordSavingEnabled) === null || _c === void 0 ? void 0 : _c.set({ value }));
                }
                else {
                    yield chrome.privacy.services.passwordSavingEnabled.set({ value });
                }
                return;
            }
            yield chrome.privacy.services.autofillAddressEnabled.set({ value });
            yield chrome.privacy.services.autofillCreditCardEnabled.set({ value });
            yield chrome.privacy.services.passwordSavingEnabled.set({ value });
        });
    }
    /**
     * Handles registration of static content scripts within manifest v2.
     *
     * @param contentScriptOptions - Details of the registered content scripts
     */
    static registerContentScriptsMv2(contentScriptOptions) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (typeof browser !== "undefined" && !!((_a = browser.contentScripts) === null || _a === void 0 ? void 0 : _a.register)) {
                return yield browser.contentScripts.register(contentScriptOptions);
            }
            return yield registerContentScriptsPolyfill(contentScriptOptions);
        });
    }
    /**
     * Handles registration of static content scripts within manifest v3.
     *
     * @param scripts - Details of the registered content scripts
     */
    static registerContentScriptsMv3(scripts) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            yield chrome.scripting.registerContentScripts(scripts);
        });
    }
    /**
     * Handles unregistering of static content scripts within manifest v3.
     *
     * @param filter - Optional filter to unregister content scripts. Passing an empty object will unregister all content scripts.
     */
    static unregisterContentScriptsMv3(filter) {
        return browser_api_awaiter(this, void 0, void 0, function* () {
            yield chrome.scripting.unregisterContentScripts(filter);
        });
    }
}
BrowserApi.isWebExtensionsApi = typeof browser !== "undefined";
BrowserApi.isSafariApi = isBrowserSafariApi();
BrowserApi.isChromeApi = !BrowserApi.isSafariApi && typeof chrome !== "undefined";
BrowserApi.isFirefoxOnAndroid = navigator.userAgent.indexOf("Firefox/") !== -1 && navigator.userAgent.indexOf("Android") !== -1;
BrowserApi.isFirefox = navigator.userAgent.indexOf("Firefox/") !== -1;
// Keep track of all the events registered in a Safari popup so we can remove
// them when the popup gets unloaded, otherwise we cause a memory leak
BrowserApi.trackedChromeEventListeners = [];

;// ./src/autofill/overlay/inline-menu/iframe-content/autofill-inline-menu-iframe.service.ts
var autofill_inline_menu_iframe_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};




class AutofillInlineMenuIframeService {
    constructor(shadow, portName, initStyles, iframeTitle, ariaAlert) {
        var _a;
        this.shadow = shadow;
        this.portName = portName;
        this.initStyles = initStyles;
        this.iframeTitle = iframeTitle;
        this.ariaAlert = ariaAlert;
        this.setElementStyles = setElementStyles;
        this.sendExtensionMessage = sendExtensionMessage;
        this.port = null;
        this.ariaAlertTimeout = null;
        this.delayedCloseTimeout = null;
        this.fadeInTimeout = null;
        this.showAnimations = true;
        this.fadeInOpacityTransition = "opacity 125ms ease-out 0s";
        this.fadeOutOpacityTransition = "opacity 65ms ease-out 0s";
        this.iframeStyles = {
            all: "initial",
            position: "fixed",
            display: "block",
            zIndex: "2147483647",
            lineHeight: "0",
            overflow: "hidden",
            transition: this.fadeInOpacityTransition,
            visibility: "visible",
            clipPath: "none",
            pointerEvents: "auto",
            margin: "0",
            padding: "0",
            colorScheme: "normal",
            opacity: "0",
        };
        this.defaultIframeAttributes = {
            src: "",
            title: "",
            credentialless: "",
            allowtransparency: "true",
            tabIndex: "-1",
            scrolling: "no",
        };
        this.foreignMutationsCount = 0;
        this.mutationObserverIterations = 0;
        this.mutationObserverIterationsResetTimeout = null;
        this.backgroundPortMessageHandlers = {
            initAutofillInlineMenuButton: ({ message }) => this.initAutofillInlineMenu(message),
            initAutofillInlineMenuList: ({ message }) => this.initAutofillInlineMenu(message),
            updateAutofillInlineMenuPosition: ({ message }) => this.updateIframePosition(message.styles),
            toggleAutofillInlineMenuHidden: ({ message }) => this.updateElementStyles(this.iframe, message.styles),
            updateAutofillInlineMenuColorScheme: () => this.updateAutofillInlineMenuColorScheme(),
            triggerDelayedAutofillInlineMenuClosure: () => this.handleDelayedAutofillInlineMenuClosure(),
            fadeInAutofillInlineMenuIframe: () => this.handleFadeInInlineMenuIframe(),
            updateAutofillInlineMenuGeneratedPassword: ({ message }) => this.handleUpdateGeneratedPassword(message),
        };
        /**
         * Sets up the port message listener to the extension background script. This
         * listener is used to communicate between the iframe and the background script.
         * This also facilitates announcing to screen readers when the iframe is loaded.
         */
        this.setupPortMessageListener = () => {
            this.port = chrome.runtime.connect({ name: this.portName });
            this.port.onDisconnect.addListener(this.handlePortDisconnect);
            this.port.onMessage.addListener(this.handlePortMessage);
            if (this.ariaAlert) {
                this.announceAriaAlert(this.ariaAlert, 2000);
            }
        };
        /**
         * Handles disconnecting the port message listener from the extension background
         * script. This also removes the listener that facilitates announcing to screen
         * readers when the iframe is loaded.
         *
         * @param port - The port that is disconnected
         */
        this.handlePortDisconnect = (port) => {
            var _a, _b, _c;
            if (port.name !== this.portName) {
                return;
            }
            this.updateElementStyles(this.iframe, { opacity: "0", height: "0px" });
            this.unobserveIframe();
            this.clearAriaAlert();
            (_a = this.port) === null || _a === void 0 ? void 0 : _a.onMessage.removeListener(this.handlePortMessage);
            (_b = this.port) === null || _b === void 0 ? void 0 : _b.onDisconnect.removeListener(this.handlePortDisconnect);
            (_c = this.port) === null || _c === void 0 ? void 0 : _c.disconnect();
            this.port = null;
        };
        /**
         * Handles messages sent from the extension background script to the iframe.
         * Triggers behavior within the iframe as well as on the custom element that
         * contains the iframe element.
         *
         * @param message
         * @param port
         */
        this.handlePortMessage = (message, port) => {
            if (port.name !== this.portName) {
                return;
            }
            if (this.backgroundPortMessageHandlers[message.command]) {
                this.backgroundPortMessageHandlers[message.command]({ message, port });
                return;
            }
            this.postMessageToIFrame(message);
        };
        /**
         * Handles updating the generated password in the inline menu iframe. Triggers
         * an aria alert if the user initiated the password regeneration.
         *
         * @param message - The message sent from the iframe
         */
        this.handleUpdateGeneratedPassword = (message) => {
            this.postMessageToIFrame(message);
            if (message.refreshPassword) {
                this.clearAriaAlert();
                this.createAriaAlertElement(true);
                this.announceAriaAlert(chrome.i18n.getMessage("passwordRegenerated"), 500, true);
            }
        };
        /**
         * Handles mutations to the iframe element. The ensures that the iframe
         * element's styles are not modified by a third party source.
         *
         * @param mutations - The mutations to the iframe element
         */
        this.handleMutations = (mutations) => {
            if (this.isTriggeringExcessiveMutationObserverIterations()) {
                return;
            }
            for (let index = 0; index < mutations.length; index++) {
                const mutation = mutations[index];
                if (mutation.type !== "attributes") {
                    continue;
                }
                const element = mutation.target;
                if (mutation.attributeName !== "style") {
                    this.handleElementAttributeMutation(element);
                    continue;
                }
                this.iframe.removeAttribute("style");
                this.updateElementStyles(this.iframe, this.iframeStyles);
            }
        };
        this.extensionOrigin = (_a = BrowserApi.getRuntimeURL("")) === null || _a === void 0 ? void 0 : _a.slice(0, -1);
        this.iframeMutationObserver = new MutationObserver(this.handleMutations);
    }
    /**
     * Handles initialization of the iframe which includes applying initial styles
     * to the iframe, setting the source, and adding listener that connects the
     * iframe to the background script each time it loads. Can conditionally
     * create an aria alert element to announce to screen readers when the iframe
     * is loaded. The end result is append to the shadowDOM of the custom element
     * that is declared.
     */
    initMenuIframe() {
        this.defaultIframeAttributes.src = BrowserApi.getRuntimeURL("overlay/menu.html");
        this.defaultIframeAttributes.title = this.iframeTitle;
        this.iframe = globalThis.document.createElement("iframe");
        for (const [attribute, value] of Object.entries(this.defaultIframeAttributes)) {
            this.iframe.setAttribute(attribute, value);
        }
        this.iframeStyles = Object.assign(Object.assign({}, this.iframeStyles), this.initStyles);
        this.setElementStyles(this.iframe, this.iframeStyles, true);
        this.iframe.addEventListener(EVENTS.LOAD, this.setupPortMessageListener);
        if (this.ariaAlert) {
            this.createAriaAlertElement();
        }
        this.shadow.appendChild(this.iframe);
        this.observeIframe();
    }
    /**
     * Creates an aria alert element that is used to announce to screen readers
     * when the iframe is loaded.
     */
    createAriaAlertElement(assertive = false) {
        this.ariaAlertElement = globalThis.document.createElement("div");
        this.ariaAlertElement.setAttribute("role", "alert");
        this.ariaAlertElement.setAttribute("aria-live", assertive ? "assertive" : "polite");
        this.ariaAlertElement.setAttribute("aria-atomic", "true");
        this.updateElementStyles(this.ariaAlertElement, {
            position: "absolute",
            top: "-9999px",
            left: "-9999px",
            width: "1px",
            height: "1px",
            overflow: "hidden",
            opacity: "0",
            pointerEvents: "none",
        });
    }
    /**
     * Announces the aria alert element to screen readers when the iframe is loaded.
     *
     * @param textContent - The text content to announce
     * @param delay - The delay before announcing the text content
     * @param triggeredByUser - Identifies whether we should present the alert regardless of field focus
     */
    announceAriaAlert(textContent, delay, triggeredByUser = false) {
        if (!this.ariaAlertElement || !textContent) {
            return;
        }
        this.ariaAlertElement.remove();
        this.ariaAlertElement.textContent = textContent;
        this.clearAriaAlert();
        this.ariaAlertTimeout = globalThis.setTimeout(() => autofill_inline_menu_iframe_service_awaiter(this, void 0, void 0, function* () {
            const isFieldFocused = yield this.sendExtensionMessage("checkIsFieldCurrentlyFocused");
            if ((isFieldFocused || triggeredByUser) && this.ariaAlertElement) {
                this.shadow.appendChild(this.ariaAlertElement);
            }
            this.ariaAlertTimeout = null;
        }), delay);
    }
    /**
     * Clears any existing aria alert that could be announced.
     */
    clearAriaAlert() {
        if (this.ariaAlertTimeout) {
            clearTimeout(this.ariaAlertTimeout);
            this.ariaAlertTimeout = null;
        }
    }
    /**
     * Handles the initialization of the autofill inline menu. This includes setting
     * the port key and sending a message to the iframe to initialize the inline menu.
     *
     * @param message
     * @private
     */
    initAutofillInlineMenu(message) {
        var _a;
        this.portKey = message.portKey;
        this.showAnimations = (_a = message.showAnimations) !== null && _a !== void 0 ? _a : true;
        if (message.command === "initAutofillInlineMenuList") {
            this.initAutofillInlineMenuList(message);
            return;
        }
        this.postMessageToIFrame(message);
    }
    /**
     * Handles initialization of the autofill inline menu list. This includes setting
     * the theme and sending a message to the iframe to initialize the inline menu.
     *
     * @param message - The message sent from the iframe
     */
    initAutofillInlineMenuList(message) {
        const { theme } = message;
        let borderColor;
        let verifiedTheme = theme;
        if (verifiedTheme === ThemeTypes.System) {
            verifiedTheme = globalThis.matchMedia("(prefers-color-scheme: dark)").matches
                ? ThemeTypes.Dark
                : ThemeTypes.Light;
        }
        if (verifiedTheme === ThemeTypes.Dark) {
            borderColor = "#4c525f";
        }
        if (borderColor) {
            this.updateElementStyles(this.iframe, { borderColor });
        }
        message.theme = verifiedTheme;
        this.postMessageToIFrame(message);
    }
    postMessageToIFrame(message) {
        var _a;
        (_a = this.iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(Object.assign({ portKey: this.portKey }, message), this.extensionOrigin);
    }
    /**
     * Updates the position of the iframe element. Will also announce
     * to screen readers that the iframe is open.
     *
     * @param position - The position styles to apply to the iframe
     */
    updateIframePosition(position) {
        if (!position || !globalThis.document.hasFocus()) {
            return;
        }
        const styles = this.fadeInTimeout ? Object.assign(position, { opacity: "0" }) : position;
        this.updateElementStyles(this.iframe, styles);
        const elementHeightCompletelyInViewport = this.isElementCompletelyWithinViewport(this.iframe.getBoundingClientRect());
        if (!elementHeightCompletelyInViewport) {
            this.forceCloseInlineMenu();
            return;
        }
        if (this.fadeInTimeout) {
            this.handleFadeInInlineMenuIframe();
        }
        if (this.ariaAlert) {
            this.announceAriaAlert(this.ariaAlert, 2000);
        }
    }
    /**
     * Check if element is completely within the browser viewport.
     */
    isElementCompletelyWithinViewport(elementPosition) {
        // An element that lacks size should be considered within the viewport
        if (!elementPosition.height || !elementPosition.width) {
            return true;
        }
        const [viewportHeight, viewportWidth] = this.getViewportSize();
        const rightSideIsWithinViewport = (elementPosition.right || 0) <= viewportWidth;
        const leftSideIsWithinViewport = (elementPosition.left || 0) >= 0;
        const topSideIsWithinViewport = (elementPosition.top || 0) >= 0;
        const bottomSideIsWithinViewport = (elementPosition.bottom || 0) <= viewportHeight;
        return (rightSideIsWithinViewport &&
            leftSideIsWithinViewport &&
            topSideIsWithinViewport &&
            bottomSideIsWithinViewport);
    }
    /** Use Visual Viewport API if available (better for mobile/zoom) */
    getViewportSize() {
        if ("visualViewport" in globalThis.window && globalThis.window.visualViewport) {
            return [globalThis.window.visualViewport.height, globalThis.window.visualViewport.width];
        }
        return [globalThis.window.innerHeight, globalThis.window.innerWidth];
    }
    /**
     * Gets the page color scheme meta tag and sends a message to the iframe
     * to update its color scheme. Will default to "normal" if the meta tag
     * does not exist.
     */
    updateAutofillInlineMenuColorScheme() {
        var _a;
        const colorSchemeValue = (_a = globalThis.document
            .querySelector("meta[name='color-scheme']")) === null || _a === void 0 ? void 0 : _a.getAttribute("content");
        this.postMessageToIFrame({
            command: "updateAutofillInlineMenuColorScheme",
            colorScheme: colorSchemeValue || "normal",
        });
    }
    /**
     * Accepts an element and updates the styles for that element. This method
     * will also unobserve the element if it is the iframe element. This is
     * done to ensure that we do not trigger the mutation observer when we
     * update the styles for the iframe.
     *
     * @param customElement - The element to update the styles for
     * @param styles - The styles to apply to the element
     */
    updateElementStyles(customElement, styles) {
        if (!customElement || !styles) {
            return;
        }
        this.unobserveIframe();
        this.setElementStyles(customElement, styles, true);
        if (customElement === this.iframe) {
            this.iframeStyles = Object.assign(Object.assign({}, this.iframeStyles), styles);
        }
        this.observeIframe();
    }
    /**
     * Triggers a forced closure of the autofill inline menu. This is used when the
     * mutation observer is triggered excessively.
     */
    forceCloseInlineMenu() {
        void this.sendExtensionMessage("closeAutofillInlineMenu", { forceCloseInlineMenu: true });
    }
    /**
     * Triggers a fade in effect for the inline menu iframe. Initialized by the background context.
     */
    handleFadeInInlineMenuIframe() {
        this.clearFadeInTimeout();
        if (!this.showAnimations) {
            this.updateElementStyles(this.iframe, {
                display: "block",
                opacity: "1",
                transition: "none",
            });
            return;
        }
        this.fadeInTimeout = globalThis.setTimeout(() => {
            this.updateElementStyles(this.iframe, { display: "block", opacity: "1" });
            this.clearFadeInTimeout();
        }, 10);
    }
    /**
     * Clears the fade in timeout for the inline menu iframe.
     */
    clearFadeInTimeout() {
        if (this.fadeInTimeout) {
            clearTimeout(this.fadeInTimeout);
            this.fadeInTimeout = null;
        }
    }
    /**
     * Triggers a delayed closure of the inline menu to ensure that click events are
     * caught if focus is programmatically redirected away from the inline menu.
     */
    handleDelayedAutofillInlineMenuClosure() {
        var _a;
        if (this.delayedCloseTimeout) {
            clearTimeout(this.delayedCloseTimeout);
        }
        if (!this.showAnimations) {
            (_a = this.port) === null || _a === void 0 ? void 0 : _a.disconnect();
            this.port = null;
            this.forceCloseInlineMenu();
            return;
        }
        this.updateElementStyles(this.iframe, {
            transition: this.fadeOutOpacityTransition,
            opacity: "0",
        });
        this.delayedCloseTimeout = globalThis.setTimeout(() => {
            var _a;
            this.updateElementStyles(this.iframe, { transition: this.fadeInOpacityTransition });
            (_a = this.port) === null || _a === void 0 ? void 0 : _a.disconnect();
            this.port = null;
            this.forceCloseInlineMenu();
        }, 100);
    }
    /**
     * Handles mutations to the iframe element's attributes. This ensures that
     * the iframe element's attributes are not modified by a third party source.
     *
     * @param element - The element to handle attribute mutations for
     */
    handleElementAttributeMutation(element) {
        const attributes = Array.from(element.attributes);
        for (let attributeIndex = 0; attributeIndex < attributes.length; attributeIndex++) {
            const attribute = attributes[attributeIndex];
            if (attribute.name === "style") {
                continue;
            }
            if (this.foreignMutationsCount >= 10) {
                this.forceCloseInlineMenu();
                break;
            }
            const defaultIframeAttribute = this.defaultIframeAttributes[attribute.name];
            if (!defaultIframeAttribute) {
                this.iframe.removeAttribute(attribute.name);
                this.foreignMutationsCount++;
                continue;
            }
            if (attribute.value === defaultIframeAttribute) {
                continue;
            }
            this.iframe.setAttribute(attribute.name, defaultIframeAttribute);
            this.foreignMutationsCount++;
        }
    }
    /**
     * Observes the iframe element for mutations to its style attribute.
     */
    observeIframe() {
        this.iframeMutationObserver.observe(this.iframe, { attributes: true });
    }
    /**
     * Unobserves the iframe element for mutations to its style attribute.
     */
    unobserveIframe() {
        var _a;
        (_a = this.iframeMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    }
    /**
     * Identifies if the mutation observer is triggering excessive iterations.
     * Will remove the autofill inline menu if any set mutation observer is
     * triggering excessive iterations.
     */
    isTriggeringExcessiveMutationObserverIterations() {
        const resetCounters = () => {
            this.mutationObserverIterations = 0;
            this.foreignMutationsCount = 0;
        };
        if (this.mutationObserverIterationsResetTimeout) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
        }
        this.mutationObserverIterations++;
        this.mutationObserverIterationsResetTimeout = globalThis.setTimeout(() => resetCounters(), 2000);
        if (this.mutationObserverIterations > 20) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
            resetCounters();
            this.forceCloseInlineMenu();
            return true;
        }
        return false;
    }
    /**
     * Cleans up all event listeners, timeouts, and observers to prevent memory leaks.
     */
    destroy() {
        var _a, _b, _c, _d;
        (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.removeEventListener(EVENTS.LOAD, this.setupPortMessageListener);
        this.clearAriaAlert();
        this.clearFadeInTimeout();
        if (this.delayedCloseTimeout) {
            clearTimeout(this.delayedCloseTimeout);
            this.delayedCloseTimeout = null;
        }
        if (this.mutationObserverIterationsResetTimeout) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
            this.mutationObserverIterationsResetTimeout = null;
        }
        this.unobserveIframe();
        (_b = this.port) === null || _b === void 0 ? void 0 : _b.onMessage.removeListener(this.handlePortMessage);
        (_c = this.port) === null || _c === void 0 ? void 0 : _c.onDisconnect.removeListener(this.handlePortDisconnect);
        (_d = this.port) === null || _d === void 0 ? void 0 : _d.disconnect();
        this.port = null;
    }
}

;// ./src/autofill/overlay/inline-menu/iframe-content/autofill-inline-menu-iframe-element.ts

class AutofillInlineMenuIframeElement {
    constructor(element, portName, initStyles, iframeTitle, ariaAlert) {
        const style = this.createInternalStyleNode();
        const shadow = element.attachShadow({ mode: "closed" });
        shadow.prepend(style);
        this.autofillInlineMenuIframeService = new AutofillInlineMenuIframeService(shadow, portName, initStyles, iframeTitle, ariaAlert);
        this.autofillInlineMenuIframeService.initMenuIframe();
    }
    /**
     * Builds and prepends an internal stylesheet to the container node with rules
     * to prevent targeting by the host's global styling rules. This should only be
     * used for pseudo elements such as `::backdrop` or `::before`. All other
     * styles should be applied inline upon the parent container itself for improved
     * specificity priority.
     */
    createInternalStyleNode() {
        const css = document.createTextNode(`
      :host::backdrop,
      :host::before,
      :host::after {
        all: initial !important;
        backdrop-filter: none !important;
        filter: none !important;
        inset: auto !important;
        touch-action: auto !important;
        user-select: text !important;
        display: none !important;
        position: relative !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        transform-origin: 50% 50% !important;
        opacity: 1 !important;
        mix-blend-mode: normal !important;
        isolation: isolate !important;
        z-index: 0 !important;
        background: none !important;
        background-color: transparent !important;
        background-image: none !important;
        width: 0 !important;
        height: 0 !important;
        content: "" !important;
        pointer-events: all !important;
      }
    `);
        const style = globalThis.document.createElement("style");
        style.setAttribute("type", "text/css");
        style.appendChild(css);
        return style;
    }
    /**
     * Cleans up the iframe service to prevent memory leaks.
     */
    destroy() {
        var _a;
        (_a = this.autofillInlineMenuIframeService) === null || _a === void 0 ? void 0 : _a.destroy();
    }
}

;// ./src/autofill/overlay/inline-menu/iframe-content/autofill-inline-menu-button-iframe.ts


class AutofillInlineMenuButtonIframe extends AutofillInlineMenuIframeElement {
    constructor(element) {
        super(element, AutofillOverlayPort.Button, {
            background: "transparent",
            border: "none",
        }, chrome.i18n.getMessage("bitwardenOverlayButton"), chrome.i18n.getMessage("bitwardenOverlayMenuAvailable"));
    }
}

;// ./src/autofill/overlay/inline-menu/iframe-content/autofill-inline-menu-list-iframe.ts


class AutofillInlineMenuListIframe extends AutofillInlineMenuIframeElement {
    constructor(element) {
        super(element, AutofillOverlayPort.List, {
            height: "0px",
            minWidth: "260px",
            maxHeight: "180px",
            boxShadow: "rgba(0, 0, 0, 0.1) 2px 4px 6px 0px",
            borderRadius: "4px",
            borderWidth: "1px",
            borderStyle: "solid",
            borderColor: "rgb(206, 212, 220)",
        }, chrome.i18n.getMessage("bitwardenVault"));
    }
}

;// ./src/autofill/overlay/inline-menu/content/autofill-inline-menu-content.service.ts
var autofill_inline_menu_content_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};




const experienceValidationBackoffThresholds = {
    topLayer: {
        countLimit: 5,
        timeSpanLimit: 5000,
    },
    popoverAttribute: {
        countLimit: 10,
        timeSpanLimit: 5000,
    },
};
class AutofillInlineMenuContentService {
    constructor() {
        this.sendExtensionMessage = sendExtensionMessage;
        this.generateRandomCustomElementName = generateRandomCustomElementName;
        this.setElementStyles = setElementStyles;
        this.isFirefoxBrowser = globalThis.navigator.userAgent.indexOf(" Firefox/") !== -1 ||
            globalThis.navigator.userAgent.indexOf(" Gecko/") !== -1;
        this.refreshCountWithinTimeThreshold = {
            topLayer: 0,
            popoverAttribute: 0,
        };
        this.lastTrackedTimestamp = {
            topLayer: Date.now(),
            popoverAttribute: Date.now(),
        };
        /**
         * Distinct from preventing inline menu script injection, this is for cases
         * where the page is subsequently determined to be risky.
         */
        this.inlineMenuEnabled = true;
        this.mutationObserverIterations = 0;
        this.mutationObserverIterationsResetTimeout = null;
        this.handlePersistentLastChildOverrideTimeout = null;
        this.lastElementOverrides = new WeakMap();
        this.customElementDefaultStyles = {
            all: "initial",
            position: "fixed",
            display: "block",
            zIndex: "2147483647",
        };
        this.extensionMessageHandlers = {
            closeAutofillInlineMenu: ({ message }) => this.closeInlineMenu(message),
            appendAutofillInlineMenuToDom: ({ message }) => this.appendInlineMenuElements(message),
        };
        this.isMonitoring = false;
        /**
         * Removes the autofill inline menu from the page. This will initially
         * unobserve the menu container to ensure the mutation observer no
         * longer triggers.
         */
        this.closeInlineMenu = (message) => {
            if ((message === null || message === void 0 ? void 0 : message.overlayElement) === AutofillOverlayElement.Button) {
                this.closeInlineMenuButton();
                return;
            }
            if ((message === null || message === void 0 ? void 0 : message.overlayElement) === AutofillOverlayElement.List) {
                this.closeInlineMenuList();
                return;
            }
            this.unobserveContainerElement();
            this.closeInlineMenuButton();
            this.closeInlineMenuList();
        };
        /**
         * Handles the mutation observer update for the inline menu elements. This method will
         * remove any attributes or styles that might be added to the inline menu elements by
         * a separate process within the website where this script is injected.
         *
         * @param mutationRecord - The mutation record that triggered the update.
         */
        this.handleInlineMenuElementMutationObserverUpdate = (mutationRecord) => {
            if (this.isTriggeringExcessiveMutationObserverIterations()) {
                return;
            }
            for (let recordIndex = 0; recordIndex < mutationRecord.length; recordIndex++) {
                const record = mutationRecord[recordIndex];
                if (record.type !== "attributes") {
                    continue;
                }
                const element = record.target;
                if (record.attributeName === "popover" && this.inlineMenuEnabled) {
                    const attributeValue = element.getAttribute(record.attributeName);
                    if (attributeValue !== "manual") {
                        this.refreshPopoverAttribute(element);
                    }
                    continue;
                }
                if (record.attributeName === "style") {
                    element.removeAttribute("style");
                    this.updateCustomElementDefaultStyles(element);
                    continue;
                }
                this.removeModifiedElementAttributes(element);
            }
        };
        /**
         * Handles the mutation observer update for the element that contains the inline menu.
         * This method will ensure that the inline menu elements are always present at the
         * bottom of the container.
         */
        this.handleContainerElementMutationObserverUpdate = (mutations) => {
            if ((!this.buttonElement && !this.listElement) ||
                this.isTriggeringExcessiveMutationObserverIterations()) {
                return;
            }
            const containerElement = mutations[0].target;
            requestIdleCallbackPolyfill(() => this.processContainerElementMutation(containerElement), {
                timeout: 500,
            });
        };
        this.checkPageRisks = () => autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            const pageIsOpaque = yield this.getPageIsOpaque();
            const risksFound = !pageIsOpaque || !this.inlineMenuEnabled;
            if (risksFound) {
                this.closeInlineMenu();
            }
            return risksFound;
        });
        /*
         * Checks for known risks at the page level
         */
        this.handlePageMutations = (mutations) => autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            if (mutations.some(({ type }) => type === "attributes")) {
                yield this.checkPageRisks();
            }
        });
        /**
         * Returns the name of the generated container tags for usage internally to avoid
         * unintentional targeting of the owned experience.
         */
        this.getOwnedTagNames = () => {
            var _a, _b;
            return [
                ...(((_a = this.buttonElement) === null || _a === void 0 ? void 0 : _a.tagName) ? [this.buttonElement.tagName] : []),
                ...(((_b = this.listElement) === null || _b === void 0 ? void 0 : _b.tagName) ? [this.listElement.tagName] : []),
            ];
        };
        /**
         * Queries and return elements (excluding those of the inline menu) that exist in the
         * top-layer via popover or dialog
         * @param {boolean} [includeCandidates=false] indicate whether top-layer candidate (which
         * may or may not be active) should be included in the query
         */
        this.getUnownedTopLayerItems = (includeCandidates = false) => {
            var _a, _b;
            const inlineMenuTagExclusions = [
                ...(((_a = this.buttonElement) === null || _a === void 0 ? void 0 : _a.tagName) ? [`:not(${this.buttonElement.tagName})`] : []),
                ...(((_b = this.listElement) === null || _b === void 0 ? void 0 : _b.tagName) ? [`:not(${this.listElement.tagName})`] : []),
                ":popover-open",
            ].join("");
            const selector = [
                ":modal",
                inlineMenuTagExclusions,
                ...(includeCandidates ? ["[popover], dialog"] : []),
            ].join(",");
            const otherTopLayeritems = globalThis.document.querySelectorAll(selector);
            return otherTopLayeritems;
        };
        /**
         * Internally track owned injected experience refreshes as a side-effect
         * of host page interference.
         */
        this.checkAndUpdateRefreshCount = (countType) => {
            if (!this.inlineMenuEnabled) {
                return;
            }
            const { countLimit, timeSpanLimit } = experienceValidationBackoffThresholds[countType];
            const now = Date.now();
            const timeSinceLastTrackedRefresh = now - this.lastTrackedTimestamp[countType];
            const currentlyWithinTimeThreshold = timeSinceLastTrackedRefresh <= timeSpanLimit;
            const withinCountThreshold = this.refreshCountWithinTimeThreshold[countType] <= countLimit;
            if (currentlyWithinTimeThreshold) {
                if (withinCountThreshold) {
                    this.refreshCountWithinTimeThreshold[countType]++;
                }
                else {
                    // Set inline menu to be off; page is aggressively trying to take top position of top layer
                    this.inlineMenuEnabled = false;
                    void this.checkPageRisks();
                    const warningMessage = chrome.i18n.getMessage("topLayerHijackWarning");
                    globalThis.window.alert(warningMessage);
                }
            }
            else {
                this.lastTrackedTimestamp[countType] = now;
                this.refreshCountWithinTimeThreshold[countType] = 0;
            }
        };
        this.refreshPopoverAttribute = (element) => {
            this.checkAndUpdateRefreshCount("popoverAttribute");
            element.setAttribute("popover", "manual");
            element.showPopover();
        };
        this.refreshTopLayerPosition = () => {
            if (!this.inlineMenuEnabled) {
                return;
            }
            const otherTopLayerItems = this.getUnownedTopLayerItems();
            // No need to refresh if there are no other top-layer items
            if (!otherTopLayerItems.length) {
                return;
            }
            const buttonInDocument = this.buttonElement &&
                globalThis.document.getElementsByTagName(this.buttonElement.tagName)[0];
            const listInDocument = this.listElement &&
                globalThis.document.getElementsByTagName(this.listElement.tagName)[0];
            if (buttonInDocument) {
                buttonInDocument.hidePopover();
                buttonInDocument.showPopover();
            }
            if (listInDocument) {
                listInDocument.hidePopover();
                listInDocument.showPopover();
            }
            if (buttonInDocument || listInDocument) {
                this.checkAndUpdateRefreshCount("topLayer");
            }
        };
        /**
         * Checks the opacity of the page body and body parent, since the inline menu experience
         * will inherit the opacity, despite being otherwise encapsulated from styling changes
         * of parents below the body. Assumes the target element will be a direct child of the page
         * `body` (enforced elsewhere).
         */
        this.getPageIsOpaque = () => {
            // @TODO for definitive checks, traverse up the node tree from the inline menu container;
            // nodes can exist between `html` and `body`
            /**
             * `querySelectorAll` for (non-standard) cases where the page has additional copies of
             * page nodes that should be unique
             */
            const pageElements = globalThis.document.querySelectorAll("html, body");
            if (!pageElements.length) {
                return false;
            }
            return [...pageElements].every((element) => {
                var _a;
                // These are computed style values, so we don't need to worry about non-float values
                // for `opacity`, here
                const elementOpacity = ((_a = globalThis.window.getComputedStyle(element)) === null || _a === void 0 ? void 0 : _a.opacity) || "0";
                // Any value above this is considered "opaque" for our purposes
                const opacityThreshold = 0.6;
                return parseFloat(elementOpacity) > opacityThreshold;
            });
        };
        /**
         * Processes the mutation of the element that contains the inline menu. Will trigger when an
         * idle moment in the execution of the main thread is detected.
         */
        this.processContainerElementMutation = (containerElement) => autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            // If the page contains risks, tear down and prevent building the inline menu experience.
            const pageRisksFound = yield this.checkPageRisks();
            if (pageRisksFound) {
                return;
            }
            if (!this.buttonElement) {
                return;
            }
            const lastChild = containerElement.lastElementChild;
            const secondToLastChild = lastChild === null || lastChild === void 0 ? void 0 : lastChild.previousElementSibling;
            const lastChildIsInlineMenuList = lastChild === this.listElement;
            const lastChildIsInlineMenuButton = lastChild === this.buttonElement;
            const secondToLastChildIsInlineMenuButton = secondToLastChild === this.buttonElement;
            if (!lastChild) {
                return;
            }
            const lastChildEncounterCount = this.lastElementOverrides.get(lastChild) || 0;
            if (!lastChildIsInlineMenuList && !lastChildIsInlineMenuButton && lastChildEncounterCount < 3) {
                this.lastElementOverrides.set(lastChild, lastChildEncounterCount + 1);
            }
            const lastChildEncounterCountAfterUpdate = this.lastElementOverrides.get(lastChild) || 0;
            if (lastChildEncounterCountAfterUpdate >= 3) {
                this.handlePersistentLastChildOverride(lastChild);
                return;
            }
            const isInlineMenuListVisible = yield this.isInlineMenuListVisible();
            if (!lastChild ||
                (lastChildIsInlineMenuList && secondToLastChildIsInlineMenuButton) ||
                (lastChildIsInlineMenuButton && !isInlineMenuListVisible)) {
                return;
            }
            if ((lastChildIsInlineMenuList && !secondToLastChildIsInlineMenuButton) ||
                (lastChildIsInlineMenuButton && isInlineMenuListVisible)) {
                if (!this.listElement) {
                    return;
                }
                containerElement.insertBefore(this.buttonElement, this.listElement);
                return;
            }
            containerElement.insertBefore(lastChild, this.buttonElement);
        });
        /**
         * Verifies if the last child of the menu container is overlaying the inline menu elements.
         * This is triggered when the last child of the menu container is being forced by some
         * script to be an element other than the inline menu elements.
         *
         * @param lastChild - The last child of the menu container.
         */
        this.verifyInlineMenuIsNotObscured = (lastChild) => autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            const inlineMenuPosition = yield this.sendExtensionMessage("getAutofillInlineMenuPosition");
            const { button, list } = inlineMenuPosition;
            if (!!button && this.elementAtCenterOfInlineMenuPosition(button) === lastChild) {
                this.closeInlineMenu();
                return;
            }
            if (!!list && this.elementAtCenterOfInlineMenuPosition(list) === lastChild) {
                this.closeInlineMenu();
            }
        });
        /**
         * Sets up mutation observers for the inline menu elements, the menu container, and
         * the document element. The mutation observers are used to remove any styles that
         * are added to the inline menu elements by the website. They are also used to ensure
         * that the inline menu elements are always present at the bottom of the menu container.
         */
        this.htmlMutationObserver = new MutationObserver(this.handlePageMutations);
        this.bodyMutationObserver = new MutationObserver(this.handlePageMutations);
        this.inlineMenuElementsMutationObserver = new MutationObserver(this.handleInlineMenuElementMutationObserverUpdate);
        this.containerElementMutationObserver = new MutationObserver(this.handleContainerElementMutationObserverUpdate);
    }
    /**
     * Attaches the page-attribute mutation observers that guard the inline menu
     * against website style interference. Idempotent.
     */
    startMonitoring() {
        if (this.isMonitoring) {
            return;
        }
        this.isMonitoring = true;
        this.observePageAttributes();
    }
    /**
     * Detaches the page-attribute observers, clears monitoring-scoped
     * iteration counters, and removes the inline-menu UI from the DOM so
     * a logged-out user does not see an orphaned iframe. The iframes
     * themselves are torn down in `destroy()`. Idempotent.
     */
    stopMonitoring() {
        this.isMonitoring = false;
        this.closeInlineMenu();
        this.unobservePageAttributes();
        this.unobserveCustomElements();
        this.unobserveContainerElement();
        this.clearPersistentLastChildOverrideTimeout();
        if (this.mutationObserverIterationsResetTimeout) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
            this.mutationObserverIterationsResetTimeout = null;
        }
        this.mutationObserverIterations = 0;
        this.refreshCountWithinTimeThreshold.topLayer = 0;
        this.refreshCountWithinTimeThreshold.popoverAttribute = 0;
    }
    /**
     * Returns the message handlers for the autofill inline menu content service.
     */
    get messageHandlers() {
        return this.extensionMessageHandlers;
    }
    /**
     * Identifies if the passed element corresponds to the inline menu button or list.
     *
     * @param element  - The element being checked
     */
    isElementInlineMenu(element) {
        return element === this.buttonElement || element === this.listElement;
    }
    /**
     * Checks if the inline menu button is visible at the top frame.
     */
    isInlineMenuButtonVisible() {
        return autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            return (!!this.buttonElement &&
                (yield this.sendExtensionMessage("checkIsAutofillInlineMenuButtonVisible")) === true);
        });
    }
    /**
     * Checks if the inline menu list if visible at the top frame.
     */
    isInlineMenuListVisible() {
        return autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            return (!!this.listElement &&
                (yield this.sendExtensionMessage("checkIsAutofillInlineMenuListVisible")) === true);
        });
    }
    /**
     * Removes the inline menu button from the DOM if it is currently present. Will
     * also remove the inline menu reposition event listeners.
     */
    closeInlineMenuButton() {
        if (this.buttonElement) {
            this.buttonElement.remove();
            void this.sendExtensionMessage("autofillOverlayElementClosed", {
                overlayElement: AutofillOverlayElement.Button,
            });
        }
    }
    /**
     * Removes the inline menu list from the DOM if it is currently present.
     */
    closeInlineMenuList() {
        if (this.listElement) {
            this.listElement.remove();
            void this.sendExtensionMessage("autofillOverlayElementClosed", {
                overlayElement: AutofillOverlayElement.List,
            });
        }
    }
    /**
     * Updates the position of both the inline menu button and inline menu list.
     */
    appendInlineMenuElements(_a) {
        return autofill_inline_menu_content_service_awaiter(this, arguments, void 0, function* ({ overlayElement }) {
            if (!this.inlineMenuEnabled) {
                return;
            }
            if (overlayElement === AutofillOverlayElement.Button) {
                return this.appendButtonElement();
            }
            return this.appendListElement();
        });
    }
    /**
     * Updates the position of the inline menu button.
     */
    appendButtonElement() {
        return autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            if (!this.buttonElement) {
                this.buttonElement = this.createButtonElement();
                this.updateCustomElementDefaultStyles(this.buttonElement);
            }
            if (!(yield this.isInlineMenuButtonVisible())) {
                this.appendInlineMenuElementToDom(this.buttonElement);
                this.updateInlineMenuElementIsVisibleStatus(AutofillOverlayElement.Button, true);
                this.buttonElement.showPopover();
            }
        });
    }
    /**
     * Updates the position of the inline menu list.
     */
    appendListElement() {
        return autofill_inline_menu_content_service_awaiter(this, void 0, void 0, function* () {
            if (!this.listElement) {
                this.listElement = this.createListElement();
                this.updateCustomElementDefaultStyles(this.listElement);
            }
            if (!(yield this.isInlineMenuListVisible())) {
                this.appendInlineMenuElementToDom(this.listElement);
                this.updateInlineMenuElementIsVisibleStatus(AutofillOverlayElement.List, true);
                this.listElement.showPopover();
            }
        });
    }
    /**
     * Updates the visibility status of the inline menu element within the background script.
     *
     * @param overlayElement - The inline menu element to update the visibility status for.
     * @param isVisible - The visibility status to update the inline menu element to.
     */
    updateInlineMenuElementIsVisibleStatus(overlayElement, isVisible) {
        void this.sendExtensionMessage("updateAutofillInlineMenuElementIsVisibleStatus", {
            overlayElement,
            isVisible,
        });
    }
    /**
     * Appends the inline menu element to the menu container. This method will also
     * observe the menu container to ensure that the inline menu element is not
     * interfered with by any DOM changes.
     *
     * @param element - The inline menu element to append to the menu container.
     */
    appendInlineMenuElementToDom(element) {
        var _a;
        const parentDialogElement = (_a = globalThis.document.activeElement) === null || _a === void 0 ? void 0 : _a.closest("dialog");
        if ((parentDialogElement === null || parentDialogElement === void 0 ? void 0 : parentDialogElement.open) && parentDialogElement.matches(":modal")) {
            this.observeContainerElement(parentDialogElement);
            parentDialogElement.appendChild(element);
            return;
        }
        this.observeContainerElement(globalThis.document.body);
        globalThis.document.body.appendChild(element);
    }
    /**
     * Creates the autofill inline menu button element. Will not attempt
     * to create the element if it already exists in the DOM.
     */
    createButtonElement() {
        var _a;
        if (this.isFirefoxBrowser) {
            this.buttonElement = globalThis.document.createElement("div");
            this.buttonElement.setAttribute("popover", "manual");
            this.buttonIframe = new AutofillInlineMenuButtonIframe(this.buttonElement);
            return this.buttonElement;
        }
        const customElementName = this.generateRandomCustomElementName();
        const self = this;
        (_a = globalThis.customElements) === null || _a === void 0 ? void 0 : _a.define(customElementName, class extends HTMLElement {
            constructor() {
                super();
                self.buttonIframe = new AutofillInlineMenuButtonIframe(this);
            }
        });
        this.buttonElement = globalThis.document.createElement(customElementName);
        this.buttonElement.setAttribute("popover", "manual");
        return this.buttonElement;
    }
    /**
     * Creates the autofill inline menu list element. Will not attempt
     * to create the element if it already exists in the DOM.
     */
    createListElement() {
        var _a;
        if (this.isFirefoxBrowser) {
            this.listElement = globalThis.document.createElement("div");
            this.listElement.setAttribute("popover", "manual");
            this.listIframe = new AutofillInlineMenuListIframe(this.listElement);
            return this.listElement;
        }
        const customElementName = this.generateRandomCustomElementName();
        const self = this;
        (_a = globalThis.customElements) === null || _a === void 0 ? void 0 : _a.define(customElementName, class extends HTMLElement {
            constructor() {
                super();
                self.listIframe = new AutofillInlineMenuListIframe(this);
            }
        });
        this.listElement = globalThis.document.createElement(customElementName);
        this.listElement.setAttribute("popover", "manual");
        return this.listElement;
    }
    /**
     * Updates the default styles for the custom element. This method will
     * remove any styles that are added to the custom element by other methods.
     *
     * @param element - The custom element to update the default styles for.
     */
    updateCustomElementDefaultStyles(element) {
        this.unobserveCustomElements();
        this.setElementStyles(element, this.customElementDefaultStyles, true);
        this.observeCustomElements();
    }
    /**
     * Sets up mutation observers to verify that the inline menu
     * elements are not modified by the website.
     */
    observeCustomElements() {
        var _a, _b;
        if (this.buttonElement) {
            (_a = this.inlineMenuElementsMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.buttonElement, {
                attributes: true,
            });
        }
        if (this.listElement) {
            (_b = this.inlineMenuElementsMutationObserver) === null || _b === void 0 ? void 0 : _b.observe(this.listElement, { attributes: true });
        }
    }
    /**
     * Sets up mutation observers to verify that the page `html` and `body` attributes
     * are not altered in a way that would impact safe display of the inline menu.
     *
     * Only attributes that directly affect the computed opacity/visibility of the inline
     * menu container are observed. This minimizes calls to `getComputedStyle` (indirectly
     * via `checkPageRisks`), which blocks layout and freezes the browser.
     */
    observePageAttributes() {
        var _a, _b;
        // FIXME: find a more efficient means to monitor attribute changes so that indirect
        // uses of attributes can be monitored without impacting the layout hot path.
        const attributeFilter = ["style", "hidden", "popover", "width", "height"];
        if (document.documentElement) {
            (_a = this.htmlMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(document.documentElement, {
                attributes: true,
                attributeFilter,
            });
        }
        if (document.body) {
            (_b = this.bodyMutationObserver) === null || _b === void 0 ? void 0 : _b.observe(document.body, {
                attributes: true,
                attributeFilter,
            });
        }
    }
    unobservePageAttributes() {
        var _a, _b;
        (_a = this.htmlMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
        (_b = this.bodyMutationObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
    }
    /**
     * Disconnects the mutation observers that are used to verify that the inline menu
     * elements are not modified by the website.
     */
    unobserveCustomElements() {
        var _a;
        (_a = this.inlineMenuElementsMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    }
    /**
     * Sets up a mutation observer for the element which contains the inline menu.
     */
    observeContainerElement(element) {
        var _a;
        (_a = this.containerElementMutationObserver) === null || _a === void 0 ? void 0 : _a.observe(element, { childList: true });
    }
    /**
     * Disconnects the mutation observer for the element which contains the inline menu.
     */
    unobserveContainerElement() {
        var _a;
        (_a = this.containerElementMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    }
    /**
     * Removes all elements from a passed inline menu
     * element except for the style attribute.
     *
     * @param element - The element to remove the attributes from.
     */
    removeModifiedElementAttributes(element) {
        const attributes = Array.from(element.attributes);
        for (let attributeIndex = 0; attributeIndex < attributes.length; attributeIndex++) {
            const attribute = attributes[attributeIndex];
            if (attribute.name === "style" || attribute.name === "popover") {
                continue;
            }
            element.removeAttribute(attribute.name);
        }
    }
    /**
     * Handles the behavior of a persistent child element that is forcing itself to
     * the bottom of the menu container. This method will ensure that the inline menu
     * elements are not obscured by the persistent child element.
     *
     * @param lastChild - The last child of the menu container.
     */
    handlePersistentLastChildOverride(lastChild) {
        const lastChildZIndex = parseInt(lastChild.style.zIndex);
        if (lastChildZIndex >= 2147483647) {
            lastChild.style.zIndex = "2147483646";
        }
        this.clearPersistentLastChildOverrideTimeout();
        this.handlePersistentLastChildOverrideTimeout = globalThis.setTimeout(() => this.verifyInlineMenuIsNotObscured(lastChild), 500);
    }
    /**
     * Returns the element present at the center of the inline menu position.
     *
     * @param position - The position of the inline menu element.
     */
    elementAtCenterOfInlineMenuPosition(position) {
        return globalThis.document.elementFromPoint(position.left + position.width / 2, position.top + position.height / 2);
    }
    /**
     * Clears the timeout that is used to verify that the last child of the menu container
     * is not overlaying the inline menu elements.
     */
    clearPersistentLastChildOverrideTimeout() {
        if (this.handlePersistentLastChildOverrideTimeout) {
            globalThis.clearTimeout(this.handlePersistentLastChildOverrideTimeout);
        }
    }
    /**
     * Identifies if the mutation observer is triggering excessive iterations.
     * Will trigger a blur of the most recently focused field and remove the
     * autofill inline menu if any set mutation observer is triggering
     * excessive iterations.
     */
    isTriggeringExcessiveMutationObserverIterations() {
        if (this.mutationObserverIterationsResetTimeout) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
        }
        this.mutationObserverIterations++;
        this.mutationObserverIterationsResetTimeout = setTimeout(() => (this.mutationObserverIterations = 0), 2000);
        if (this.mutationObserverIterations > 100) {
            clearTimeout(this.mutationObserverIterationsResetTimeout);
            this.mutationObserverIterations = 0;
            this.closeInlineMenu();
            return true;
        }
        return false;
    }
    /**
     * Stops monitoring (which closes the inline menu UI) and then tears
     * down the iframe wrappers for terminal disposal.
     */
    destroy() {
        var _a, _b;
        this.stopMonitoring();
        (_a = this.buttonIframe) === null || _a === void 0 ? void 0 : _a.destroy();
        (_b = this.listIframe) === null || _b === void 0 ? void 0 : _b.destroy();
    }
}

;// ./src/autofill/notification/abstractions/notification-bar.ts
const NotificationTypes = {
    /** represents scenarios handling saving new ciphers after form submit */
    Add: "add",
    /** represents scenarios handling saving updated ciphers after form submit */
    Change: "change",
    /** represents scenarios where user has interacted with an unlock action prompt or action otherwise requiring unlock as a prerequisite */
    Unlock: "unlock",
    /** represents scenarios where the user has security tasks after updating ciphers */
    AtRiskPassword: "at-risk-password",
};


;// ./src/autofill/overlay/notifications/content/overlay-notifications-content.service.ts
var overlay_notifications_content_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var overlay_notifications_content_service_rest = (undefined && undefined.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};




class OverlayNotificationsContentService {
    constructor() {
        var _a;
        this.notificationBarRootElement = null;
        this.notificationBarElement = null;
        this.notificationBarIframeElement = null;
        this.notificationBarShadowRoot = null;
        this.currentNotificationBarType = null;
        this.showAnimations = true;
        this.notificationBarContainerStyles = {
            height: "400px",
            width: "430px",
            maxWidth: "calc(100% - 20px)",
            minHeight: "initial",
            top: "10px",
            right: "0px",
            padding: "0",
            position: "fixed",
            zIndex: "2147483647",
            visibility: "visible",
            borderRadius: "4px",
            border: "none",
            backgroundColor: "transparent",
            overflow: "hidden",
            transition: "box-shadow 0.15s ease",
            transitionDelay: "0.15s",
        };
        this.notificationBarIframeElementStyles = {
            width: "100%",
            height: "100%",
            border: "0",
            display: "block",
            position: "relative",
            transition: "transform 0.15s ease-out, opacity 0.15s ease",
            borderRadius: "4px",
            colorScheme: "auto",
        };
        this.extensionMessageHandlers = {
            openNotificationBar: ({ message }) => this.handleOpenNotificationBarMessage(message),
            closeNotificationBar: ({ message }) => this.handleCloseNotificationBarMessage(message),
            adjustNotificationBar: ({ message }) => this.handleAdjustNotificationBarHeightMessage(message),
            saveCipherAttemptCompleted: ({ message }) => this.handleSaveCipherAttemptCompletedMessage(message),
        };
        /**
         * Handles the load event for the notification bar iframe.
         * This will animate the notification bar into view.
         */
        this.handleNotificationBarIframeOnLoad = () => {
            var _a;
            if (this.notificationBarIframeElement) {
                setElementStyles(this.notificationBarIframeElement, { transform: "translateX(0)", opacity: "1" }, true);
            }
            (_a = this.notificationBarIframeElement) === null || _a === void 0 ? void 0 : _a.removeEventListener(EVENTS.LOAD, this.handleNotificationBarIframeOnLoad);
        };
        this.extensionOrigin = (_a = BrowserApi.getRuntimeURL("")) === null || _a === void 0 ? void 0 : _a.slice(0, -1);
        void sendExtensionMessage("checkNotificationQueue");
    }
    /**
     * Returns the message handlers for the content script.
     */
    get messageHandlers() {
        return this.extensionMessageHandlers;
    }
    /**
     * Opens the notification bar with the provided init data. Will trigger a closure
     * of the notification bar if the type of the notification bar changes.
     *
     * @param message - The message containing the initialization data for the notification bar.
     */
    handleOpenNotificationBarMessage(message) {
        return overlay_notifications_content_service_awaiter(this, void 0, void 0, function* () {
            if (!message.data) {
                return;
            }
            const { type, typeData, params, isConfirmation, confirmationData } = message.data;
            if (!typeData) {
                return;
            }
            if (this.currentNotificationBarType && type !== this.currentNotificationBarType) {
                this.closeNotificationBar();
            }
            const initData = {
                type: type,
                isVaultLocked: typeData.isVaultLocked,
                theme: typeData.theme,
                removeIndividualVault: typeData.removeIndividualVault,
                importType: typeData.importType,
                launchTimestamp: typeData.launchTimestamp,
                showAnimations: typeData.showAnimations,
                params,
                isConfirmation,
                confirmationData,
            };
            if (globalThis.document.readyState === "loading") {
                document.addEventListener("DOMContentLoaded", () => this.openNotificationBar(initData));
                return;
            }
            this.openNotificationBar(initData);
        });
    }
    /**
     * Closes the notification bar. If the message contains a flag to fade out the notification,
     * the notification bar will fade out before being removed from the DOM.
     *
     * @param message - The message containing the data for closing the notification bar.
     */
    handleCloseNotificationBarMessage(message) {
        var _a, _b;
        const closedByUser = typeof ((_a = message.data) === null || _a === void 0 ? void 0 : _a.closedByUser) === "boolean" ? message.data.closedByUser : true;
        // FIXME (PM-33879): `fadeOutNotification` is hardcoded to true;
        // we should remove it in favor of `showAnimations`
        if (((_b = message.data) === null || _b === void 0 ? void 0 : _b.fadeOutNotification) && this.showAnimations) {
            if (this.notificationBarIframeElement) {
                setElementStyles(this.notificationBarIframeElement, { opacity: "0" }, true);
            }
            globalThis.setTimeout(() => this.closeNotificationBar(closedByUser), 150);
            return;
        }
        this.closeNotificationBar(closedByUser);
    }
    /**
     * Adjusts the height of the notification bar.
     *
     * @param message - The message containing the height of the notification bar.
     */
    handleAdjustNotificationBarHeightMessage(message) {
        var _a;
        if (this.notificationBarElement && ((_a = message.data) === null || _a === void 0 ? void 0 : _a.height)) {
            this.notificationBarElement.style.height = `${message.data.height}px`;
        }
    }
    /**
     * Handles the message for when a save cipher attempt has completed. This triggers an update
     * to the presentation of the notification bar, facilitating a visual indication of the save
     * attempt's success or failure.
     *
     * @param message
     * @private
     */
    handleSaveCipherAttemptCompletedMessage(message) {
        // destructure error out of data
        const _a = (message === null || message === void 0 ? void 0 : message.data) || {}, { error } = _a, otherData = overlay_notifications_content_service_rest(_a, ["error"]);
        this.sendMessageToNotificationBarIframe({
            command: "saveCipherAttemptCompleted",
            data: Object.keys(otherData).length ? otherData : undefined,
            error,
        });
    }
    /**
     * Opens the notification bar with the given initialization data.
     *
     * @param initData
     * @private
     */
    openNotificationBar(initData) {
        var _a, _b;
        this.showAnimations = (_a = initData.showAnimations) !== null && _a !== void 0 ? _a : true;
        if (!this.notificationBarRootElement && !this.notificationBarIframeElement) {
            this.createNotificationBarIframeElement(initData);
            this.createNotificationBarElement();
            this.setupInitNotificationBarMessageListener(initData);
            if (this.notificationBarRootElement) {
                globalThis.document.body.appendChild(this.notificationBarRootElement);
            }
            return;
        }
        this.currentNotificationBarType = (_b = initData.type) !== null && _b !== void 0 ? _b : null;
        this.sendMessageToNotificationBarIframe({
            command: "initNotificationBar",
            initData,
            parentOrigin: globalThis.location.origin,
        });
    }
    /**
     * Creates the iframe element for the notification bar.
     *
     * @param initData - The initialization data for the notification bar.
     */
    createNotificationBarIframeElement(initData) {
        var _a;
        const isNotificationFresh = initData.launchTimestamp && Date.now() - initData.launchTimestamp < 250;
        this.currentNotificationBarType = (_a = initData.type) !== null && _a !== void 0 ? _a : null;
        this.notificationBarIframeElement = globalThis.document.createElement("iframe");
        this.notificationBarIframeElement.id = "bit-notification-bar-iframe";
        const parentOrigin = globalThis.location.origin;
        const iframeUrl = new URL(BrowserApi.getRuntimeURL("notification/bar.html"));
        iframeUrl.searchParams.set("parentOrigin", parentOrigin);
        this.notificationBarIframeElement.src = iframeUrl.toString();
        this.notificationBarIframeElement.setAttribute("credentialless", "");
        const skipAnimation = !this.showAnimations;
        setElementStyles(this.notificationBarIframeElement, Object.assign(Object.assign(Object.assign({}, this.notificationBarIframeElementStyles), (skipAnimation ? { transition: "none" } : {})), { transform: isNotificationFresh && !skipAnimation ? "translateX(100%)" : "translateX(0)", opacity: skipAnimation ? "1" : isNotificationFresh ? "1" : "0" }), true);
        this.notificationBarIframeElement.addEventListener(EVENTS.LOAD, this.handleNotificationBarIframeOnLoad);
    }
    /**
     * Creates the container for the notification bar iframe with shadow DOM.
     */
    createNotificationBarElement() {
        if (this.notificationBarIframeElement) {
            this.notificationBarRootElement = globalThis.document.createElement("bit-notification-bar-root");
            this.notificationBarShadowRoot = this.notificationBarRootElement.attachShadow({
                mode: "closed",
                delegatesFocus: true,
            });
            this.notificationBarElement = globalThis.document.createElement("div");
            this.notificationBarElement.id = "bit-notification-bar";
            const containerStyles = Object.assign({}, this.notificationBarContainerStyles);
            if (!this.showAnimations) {
                delete containerStyles.transition;
                delete containerStyles.transitionDelay;
            }
            setElementStyles(this.notificationBarElement, containerStyles, true);
            this.notificationBarShadowRoot.appendChild(this.notificationBarElement);
            this.notificationBarElement.appendChild(this.notificationBarIframeElement);
        }
    }
    /**
     * Sets up the message listener for the initialization of the notification bar.
     * This will send the initialization data to the notification bar iframe.
     *
     * @param initData - The initialization data for the notification bar.
     */
    setupInitNotificationBarMessageListener(initData) {
        const handleInitNotificationBarMessage = (event) => {
            var _a;
            const { source, data } = event;
            if (!((_a = this.notificationBarIframeElement) === null || _a === void 0 ? void 0 : _a.contentWindow) ||
                source !== this.notificationBarIframeElement.contentWindow ||
                (data === null || data === void 0 ? void 0 : data.command) !== "initNotificationBar") {
                return;
            }
            this.sendMessageToNotificationBarIframe({
                command: "initNotificationBar",
                initData,
                parentOrigin: globalThis.location.origin,
            });
            globalThis.removeEventListener("message", handleInitNotificationBarMessage);
        };
        if (this.notificationBarIframeElement) {
            globalThis.addEventListener("message", handleInitNotificationBarMessage);
        }
    }
    /**
     * Closes the notification bar. Will trigger a removal of the notification bar
     * from the background queue if the notification bar was closed by the user.
     *
     * @param closedByUserAction - Whether the notification bar was closed by the user.
     */
    closeNotificationBar(closedByUserAction = false) {
        var _a, _b, _c;
        if (!this.notificationBarRootElement && !this.notificationBarIframeElement) {
            return;
        }
        (_a = this.notificationBarIframeElement) === null || _a === void 0 ? void 0 : _a.remove();
        this.notificationBarIframeElement = null;
        (_b = this.notificationBarElement) === null || _b === void 0 ? void 0 : _b.remove();
        this.notificationBarElement = null;
        this.notificationBarShadowRoot = null;
        (_c = this.notificationBarRootElement) === null || _c === void 0 ? void 0 : _c.remove();
        this.notificationBarRootElement = null;
        const removableNotificationTypes = new Set([
            NotificationTypes.Add,
            NotificationTypes.Change,
            NotificationTypes.AtRiskPassword,
        ]);
        if (closedByUserAction &&
            this.currentNotificationBarType &&
            removableNotificationTypes.has(this.currentNotificationBarType)) {
            void sendExtensionMessage("bgRemoveTabFromNotificationQueue");
        }
        this.currentNotificationBarType = null;
    }
    /**
     * Sends a message to the notification bar iframe.
     *
     * @param message - The message to send to the notification bar iframe.
     */
    sendMessageToNotificationBarIframe(message) {
        var _a;
        if ((_a = this.notificationBarIframeElement) === null || _a === void 0 ? void 0 : _a.contentWindow) {
            this.notificationBarIframeElement.contentWindow.postMessage(message, this.extensionOrigin);
        }
    }
    /**
     * Destroys the notification bar.
     */
    destroy() {
        this.closeNotificationBar(true);
    }
}

// EXTERNAL MODULE: ../../node_modules/@webcomponents/custom-elements/custom-elements.min.js
var custom_elements_min = __webpack_require__(70526);
;// ../../node_modules/lit/polyfill-support.js
!function(i){"function"==typeof define&&define.amd?define(i):i();}(function(){"use strict";/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */var i,n,o="__scoped";null!==(i=globalThis.reactiveElementPolyfillSupport)&&void 0!==i||(globalThis.reactiveElementPolyfillSupport=function(i){var n=i.ReactiveElement;if(void 0!==window.ShadyCSS&&(!window.ShadyCSS.nativeShadow||window.ShadyCSS.ApplyShim)){var t=n.prototype;window.ShadyDOM&&window.ShadyDOM.inUse&&!0===window.ShadyDOM.noPatch&&window.ShadyDOM.patchElementProto(t);var d=t.createRenderRoot;t.createRenderRoot=function(){var i,n,t,w=this.localName;if(window.ShadyCSS.nativeShadow)return d.call(this);if(!this.constructor.hasOwnProperty(o)){this.constructor[o]=!0;var v=this.constructor.elementStyles.map(function(i){return i instanceof CSSStyleSheet?Array.from(i.cssRules).reduce(function(i,n){return i+n.cssText;},""):i.cssText;});null===(n=null===(i=window.ShadyCSS)||void 0===i?void 0:i.ScopingShim)||void 0===n||n.prepareAdoptedCssText(v,w),void 0===this.constructor._$AJ&&window.ShadyCSS.prepareTemplateStyles(document.createElement("template"),w);}return null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);};var w=t.connectedCallback;t.connectedCallback=function(){w.call(this),this.hasUpdated&&window.ShadyCSS.styleElement(this);};var v=t._$AE;t._$AE=function(i){this.hasUpdated||window.ShadyCSS.styleElement(this),v.call(this,i);};}});var t,d=new Set(),w=new Map();null!==(n=globalThis.litHtmlPolyfillSupport)&&void 0!==n||(globalThis.litHtmlPolyfillSupport=function(i,n){if(void 0!==window.ShadyCSS&&(!window.ShadyCSS.nativeShadow||window.ShadyCSS.ApplyShim)){var o=function(i){return void 0!==i&&!d.has(i);},t=function(i){var n=w.get(i);return void 0===n&&w.set(i,n=[]),n;},v=new Map(),l=i.createElement;i.createElement=function(n,d){var w=l.call(i,n,d),v=null==d?void 0:d.scope;if(void 0!==v&&(window.ShadyCSS.nativeShadow||window.ShadyCSS.prepareTemplateDom(w,v),o(v))){var r=t(v),u=w.content.querySelectorAll("style");r.push.apply(r,Array.from(u).map(function(i){var n;return null===(n=i.parentNode)||void 0===n||n.removeChild(i),i.textContent;}));}return w;};var r=document.createDocumentFragment(),u=document.createComment(""),s=n.prototype,e=s._$AI;s._$AI=function(i,n){var v,l;void 0===n&&(n=this);var s=this._$AA.parentNode,a=null===(v=this.options)||void 0===v?void 0:v.scope;if(s instanceof ShadowRoot&&o(a)){var h=this._$AA,f=this._$AB;r.appendChild(u),this._$AA=u,this._$AB=null,e.call(this,i,n);var c=(null==i?void 0:i._$litType$)?this._$AH._$AD.el:document.createElement("template");if(function(i,n){var o,v=t(i),l=0!==v.length;l&&((o=document.createElement("style")).textContent=v.join("\n"),n.content.appendChild(o)),d.add(i),w.delete(i),window.ShadyCSS.prepareTemplateStyles(n,i),l&&window.ShadyCSS.nativeShadow&&null!==(o=n.content.querySelector("style"))&&n.content.appendChild(o);}(a,c),r.removeChild(u),null===(l=window.ShadyCSS)||void 0===l?void 0:l.nativeShadow){var y=c.content.querySelector("style");null!==y&&r.appendChild(y.cloneNode(!0));}s.insertBefore(r,f),this._$AA=h,this._$AB=f;}else e.call(this,i,n);},s._$AC=function(n){var o,t=null===(o=this.options)||void 0===o?void 0:o.scope,d=v.get(t);void 0===d&&v.set(t,d=new Map());var w=d.get(n.strings);return void 0===w&&d.set(n.strings,w=new i(n,this.options)),w;};}}),null!==(t=globalThis.litElementPolyfillSupport)&&void 0!==t||(globalThis.litElementPolyfillSupport=function(i){var n=i.LitElement;if(void 0!==window.ShadyCSS&&(!window.ShadyCSS.nativeShadow||window.ShadyCSS.ApplyShim)){n._$AJ=!0;var o=n.prototype,t=o.createRenderRoot;o.createRenderRoot=function(){return this.renderOptions.scope=this.localName,t.call(this);};}});});
;// ../../node_modules/tabbable/dist/index.esm.js
/*!
* tabbable 6.4.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/// NOTE: separate `:not()` selectors has broader browser support than the newer
//  `:not([inert], [inert] *)` (Feb 2023)
var candidateSelectors=['input:not([inert]):not([inert] *)','select:not([inert]):not([inert] *)','textarea:not([inert]):not([inert] *)','a[href]:not([inert]):not([inert] *)','button:not([inert]):not([inert] *)','[tabindex]:not(slot):not([inert]):not([inert] *)','audio[controls]:not([inert]):not([inert] *)','video[controls]:not([inert]):not([inert] *)','[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)','details>summary:first-of-type:not([inert]):not([inert] *)','details:not([inert]):not([inert] *)'];var candidateSelector=/* #__PURE__ */candidateSelectors.join(',');var NoElement=typeof Element==='undefined';var matches=NoElement?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;var getRootNode=!NoElement&&Element.prototype.getRootNode?function(element){var _element$getRootNode;return element===null||element===void 0?void 0:(_element$getRootNode=element.getRootNode)===null||_element$getRootNode===void 0?void 0:_element$getRootNode.call(element);}:function(element){return element===null||element===void 0?void 0:element.ownerDocument;};/**
 * Determines if a node is inert or in an inert ancestor.
 * @param {Node} [node]
 * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
 *  see if any of them are inert. If false, only `node` itself is considered.
 * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
 *  False if `node` is falsy.
 */var _isInert=function isInert(node,lookUp){var _node$getAttribute;if(lookUp===void 0){lookUp=true;}// CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
//  JS API property; we have to check the attribute, which can either be empty or 'true';
//  if it's `null` (not specified) or 'false', it's an active element
var inertAtt=node===null||node===void 0?void 0:(_node$getAttribute=node.getAttribute)===null||_node$getAttribute===void 0?void 0:_node$getAttribute.call(node,'inert');var inert=inertAtt===''||inertAtt==='true';// NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
//  if it weren't for `matches()` not being a function on shadow roots; the following
//  code works for any kind of node
var result=inert||lookUp&&node&&(// closest does not exist on shadow roots, so we fall back to a manual
// lookup upward, in case it is not defined.
typeof node.closest==='function'?node.closest('[inert]'):_isInert(node.parentNode));return result;};/**
 * Determines if a node's content is editable.
 * @param {Element} [node]
 * @returns True if it's content-editable; false if it's not or `node` is falsy.
 */var isContentEditable=function isContentEditable(node){var _node$getAttribute2;// CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
//  to use the attribute directly to check for this, which can either be empty or 'true';
//  if it's `null` (not specified) or 'false', it's a non-editable element
var attValue=node===null||node===void 0?void 0:(_node$getAttribute2=node.getAttribute)===null||_node$getAttribute2===void 0?void 0:_node$getAttribute2.call(node,'contenteditable');return attValue===''||attValue==='true';};/**
 * @param {Element} el container to check in
 * @param {boolean} includeContainer add container to check
 * @param {(node: Element) => boolean} filter filter candidates
 * @returns {Element[]}
 */var getCandidates=function getCandidates(el,includeContainer,filter){// even if `includeContainer=false`, we still have to check it for inertness because
//  if it's inert (either by itself or via its parent), then all its children are inert
if(_isInert(el)){return[];}var candidates=Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));if(includeContainer&&matches.call(el,candidateSelector)){candidates.unshift(el);}candidates=candidates.filter(filter);return candidates;};/**
 * @callback GetShadowRoot
 * @param {Element} element to check for shadow root
 * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
 *//**
 * @callback ShadowRootFilter
 * @param {Element} shadowHostNode the element which contains shadow content
 * @returns {boolean} true if a shadow root could potentially contain valid candidates.
 *//**
 * @typedef {Object} CandidateScope
 * @property {Element} scopeParent contains inner candidates
 * @property {Element[]} candidates list of candidates found in the scope parent
 *//**
 * @typedef {Object} IterativeOptions
 * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
 *  if a function, implies shadow support is enabled and either returns the shadow root of an element
 *  or a boolean stating if it has an undisclosed shadow root
 * @property {(node: Element) => boolean} filter filter candidates
 * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
 * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
 *//**
 * @param {Element[]} elements list of element containers to match candidates from
 * @param {boolean} includeContainer add container list to check
 * @param {IterativeOptions} options
 * @returns {Array.<Element|CandidateScope>}
 */var _getCandidatesIteratively=function getCandidatesIteratively(elements,includeContainer,options){var candidates=[];var elementsToCheck=Array.from(elements);while(elementsToCheck.length){var element=elementsToCheck.shift();if(_isInert(element,false)){// no need to look up since we're drilling down
// anything inside this container will also be inert
continue;}if(element.tagName==='SLOT'){// add shadow dom slot scope (slot itself cannot be focusable)
var assigned=element.assignedElements();var content=assigned.length?assigned:element.children;var nestedCandidates=_getCandidatesIteratively(content,true,options);if(options.flatten){candidates.push.apply(candidates,nestedCandidates);}else{candidates.push({scopeParent:element,candidates:nestedCandidates});}}else{// check candidate element
var validCandidate=matches.call(element,candidateSelector);if(validCandidate&&options.filter(element)&&(includeContainer||!elements.includes(element))){candidates.push(element);}// iterate over shadow content if possible
var shadowRoot=element.shadowRoot||// check for an undisclosed shadow
typeof options.getShadowRoot==='function'&&options.getShadowRoot(element);// no inert look up because we're already drilling down and checking for inertness
//  on the way down, so all containers to this root node should have already been
//  vetted as non-inert
var validShadowRoot=!_isInert(shadowRoot,false)&&(!options.shadowRootFilter||options.shadowRootFilter(element));if(shadowRoot&&validShadowRoot){// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
//  shadow exists, so look at light dom children as fallback BUT create a scope for any
//  child candidates found because they're likely slotted elements (elements that are
//  children of the web component element (which has the shadow), in the light dom, but
//  slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
//  _after_ we return from this recursive call
var _nestedCandidates=_getCandidatesIteratively(shadowRoot===true?element.children:shadowRoot.children,true,options);if(options.flatten){candidates.push.apply(candidates,_nestedCandidates);}else{candidates.push({scopeParent:element,candidates:_nestedCandidates});}}else{// there's not shadow so just dig into the element's (light dom) children
//  __without__ giving the element special scope treatment
elementsToCheck.unshift.apply(elementsToCheck,element.children);}}}return candidates;};/**
 * @private
 * Determines if the node has an explicitly specified `tabindex` attribute.
 * @param {HTMLElement} node
 * @returns {boolean} True if so; false if not.
 */var hasTabIndex=function hasTabIndex(node){return!isNaN(parseInt(node.getAttribute('tabindex'),10));};/**
 * Determine the tab index of a given node.
 * @param {HTMLElement} node
 * @returns {number} Tab order (negative, 0, or positive number).
 * @throws {Error} If `node` is falsy.
 */var getTabIndex=function getTabIndex(node){if(!node){throw new Error('No node provided');}if(node.tabIndex<0){// in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
// `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
// yet they are still part of the regular tab order; in FF, they get a default
// `tabIndex` of 0; since Chrome still puts those elements in the regular tab
// order, consider their tab index to be 0.
// Also browsers do not return `tabIndex` correctly for contentEditable nodes;
// so if they don't have a tabindex attribute specifically set, assume it's 0.
if((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName)||isContentEditable(node))&&!hasTabIndex(node)){return 0;}}return node.tabIndex;};/**
 * Determine the tab index of a given node __for sort order purposes__.
 * @param {HTMLElement} node
 * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
 *  has tabIndex -1, but needs to be sorted by document order in order for its content to be
 *  inserted into the correct sort position.
 * @returns {number} Tab order (negative, 0, or positive number).
 */var getSortOrderTabIndex=function getSortOrderTabIndex(node,isScope){var tabIndex=getTabIndex(node);if(tabIndex<0&&isScope&&!hasTabIndex(node)){return 0;}return tabIndex;};var sortOrderedTabbables=function sortOrderedTabbables(a,b){return a.tabIndex===b.tabIndex?a.documentOrder-b.documentOrder:a.tabIndex-b.tabIndex;};var isInput=function isInput(node){return node.tagName==='INPUT';};var isHiddenInput=function isHiddenInput(node){return isInput(node)&&node.type==='hidden';};var isDetailsWithSummary=function isDetailsWithSummary(node){var r=node.tagName==='DETAILS'&&Array.prototype.slice.apply(node.children).some(function(child){return child.tagName==='SUMMARY';});return r;};var getCheckedRadio=function getCheckedRadio(nodes,form){for(var i=0;i<nodes.length;i++){if(nodes[i].checked&&nodes[i].form===form){return nodes[i];}}};var isTabbableRadio=function isTabbableRadio(node){if(!node.name){return true;}var radioScope=node.form||getRootNode(node);var queryRadios=function queryRadios(name){return radioScope.querySelectorAll('input[type="radio"][name="'+name+'"]');};var radioSet;if(typeof window!=='undefined'&&typeof window.CSS!=='undefined'&&typeof window.CSS.escape==='function'){radioSet=queryRadios(window.CSS.escape(node.name));}else{try{radioSet=queryRadios(node.name);}catch(err){// eslint-disable-next-line no-console
console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s',err.message);return false;}}var checked=getCheckedRadio(radioSet,node.form);return!checked||checked===node;};var isRadio=function isRadio(node){return isInput(node)&&node.type==='radio';};var isNonTabbableRadio=function isNonTabbableRadio(node){return isRadio(node)&&!isTabbableRadio(node);};// determines if a node is ultimately attached to the window's document
var isNodeAttached=function isNodeAttached(node){var _nodeRoot;// The root node is the shadow root if the node is in a shadow DOM; some document otherwise
//  (but NOT _the_ document; see second 'If' comment below for more).
// If rootNode is shadow root, it'll have a host, which is the element to which the shadow
//  is attached, and the one we need to check if it's in the document or not (because the
//  shadow, and all nodes it contains, is never considered in the document since shadows
//  behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
//  is hidden, or is not in the document itself but is detached, it will affect the shadow's
//  visibility, including all the nodes it contains). The host could be any normal node,
//  or a custom element (i.e. web component). Either way, that's the one that is considered
//  part of the document, not the shadow root, nor any of its children (i.e. the node being
//  tested).
// To further complicate things, we have to look all the way up until we find a shadow HOST
//  that is attached (or find none) because the node might be in nested shadows...
// If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
//  document (per the docs) and while it's a Document-type object, that document does not
//  appear to be the same as the node's `ownerDocument` for some reason, so it's safer
//  to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
//  using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
//  node is actually detached.
// NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
//  if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
//  from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
//  `ownerDocument` will be `null`, hence the optional chaining on it.
var nodeRoot=node&&getRootNode(node);var nodeRootHost=(_nodeRoot=nodeRoot)===null||_nodeRoot===void 0?void 0:_nodeRoot.host;// in some cases, a detached node will return itself as the root instead of a document or
//  shadow root object, in which case, we shouldn't try to look further up the host chain
var attached=false;if(nodeRoot&&nodeRoot!==node){var _nodeRootHost,_nodeRootHost$ownerDo,_node$ownerDocument;attached=!!((_nodeRootHost=nodeRootHost)!==null&&_nodeRootHost!==void 0&&(_nodeRootHost$ownerDo=_nodeRootHost.ownerDocument)!==null&&_nodeRootHost$ownerDo!==void 0&&_nodeRootHost$ownerDo.contains(nodeRootHost)||node!==null&&node!==void 0&&(_node$ownerDocument=node.ownerDocument)!==null&&_node$ownerDocument!==void 0&&_node$ownerDocument.contains(node));while(!attached&&nodeRootHost){var _nodeRoot2,_nodeRootHost2,_nodeRootHost2$ownerD;// since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
//  which means we need to get the host's host and check if that parent host is contained
//  in (i.e. attached to) the document
nodeRoot=getRootNode(nodeRootHost);nodeRootHost=(_nodeRoot2=nodeRoot)===null||_nodeRoot2===void 0?void 0:_nodeRoot2.host;attached=!!((_nodeRootHost2=nodeRootHost)!==null&&_nodeRootHost2!==void 0&&(_nodeRootHost2$ownerD=_nodeRootHost2.ownerDocument)!==null&&_nodeRootHost2$ownerD!==void 0&&_nodeRootHost2$ownerD.contains(nodeRootHost));}}return attached;};var isZeroArea=function isZeroArea(node){var _node$getBoundingClie=node.getBoundingClientRect(),width=_node$getBoundingClie.width,height=_node$getBoundingClie.height;return width===0&&height===0;};var isHidden=function isHidden(node,_ref){var displayCheck=_ref.displayCheck,getShadowRoot=_ref.getShadowRoot;if(displayCheck==='full-native'){if('checkVisibility'in node){// Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
// @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
var visible=node.checkVisibility({// Checking opacity might be desirable for some use cases, but natively,
// opacity zero elements _are_ focusable and tabbable.
checkOpacity:false,opacityProperty:false,contentVisibilityAuto:true,visibilityProperty:true,// This is an alias for `visibilityProperty`. Contemporary browsers
// support both. However, this alias has wider browser support (Chrome
// >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
// we include it anyway.
checkVisibilityCSS:true});return!visible;}// Fall through to manual visibility checks
}// NOTE: visibility will be `undefined` if node is detached from the document
//  (see notes about this further down), which means we will consider it visible
//  (this is legacy behavior from a very long way back)
// NOTE: we check this regardless of `displayCheck="none"` because this is a
//  _visibility_ check, not a _display_ check
if(getComputedStyle(node).visibility==='hidden'){return true;}var isDirectSummary=matches.call(node,'details>summary:first-of-type');var nodeUnderDetails=isDirectSummary?node.parentElement:node;if(matches.call(nodeUnderDetails,'details:not([open]) *')){return true;}if(!displayCheck||displayCheck==='full'||// full-native can run this branch when it falls through in case
// Element#checkVisibility is unsupported
displayCheck==='full-native'||displayCheck==='legacy-full'){if(typeof getShadowRoot==='function'){// figure out if we should consider the node to be in an undisclosed shadow and use the
//  'non-zero-area' fallback
var originalNode=node;while(node){var parentElement=node.parentElement;var rootNode=getRootNode(node);if(parentElement&&!parentElement.shadowRoot&&getShadowRoot(parentElement)===true// check if there's an undisclosed shadow
){// node has an undisclosed shadow which means we can only treat it as a black box, so we
//  fall back to a non-zero-area test
return isZeroArea(node);}else if(node.assignedSlot){// iterate up slot
node=node.assignedSlot;}else if(!parentElement&&rootNode!==node.ownerDocument){// cross shadow boundary
node=rootNode.host;}else{// iterate up normal dom
node=parentElement;}}node=originalNode;}// else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
//  (i.e. it does not also presume that all nodes might have undisclosed shadows); or
//  it might be a falsy value, which means shadow DOM support is disabled
// Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
//  now we can just test to see if it would normally be visible or not, provided it's
//  attached to the main document.
// NOTE: We must consider case where node is inside a shadow DOM and given directly to
//  `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
if(isNodeAttached(node)){// this works wherever the node is: if there's at least one client rect, it's
//  somehow displayed; it also covers the CSS 'display: contents' case where the
//  node itself is hidden in place of its contents; and there's no need to search
//  up the hierarchy either
return!node.getClientRects().length;}// Else, the node isn't attached to the document, which means the `getClientRects()`
//  API will __always__ return zero rects (this can happen, for example, if React
//  is used to render nodes onto a detached tree, as confirmed in this thread:
//  https://github.com/facebook/react/issues/9117#issuecomment-284228870)
//
// It also means that even window.getComputedStyle(node).display will return `undefined`
//  because styles are only computed for nodes that are in the document.
//
// NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
//  somehow. Though it was never stated officially, anyone who has ever used tabbable
//  APIs on nodes in detached containers has actually implicitly used tabbable in what
//  was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
//  considering __everything__ to be visible because of the innability to determine styles.
//
// v6.0.0: As of this major release, the default 'full' option __no longer treats detached
//  nodes as visible with the 'none' fallback.__
if(displayCheck!=='legacy-full'){return true;// hidden
}// else, fallback to 'none' mode and consider the node visible
}else if(displayCheck==='non-zero-area'){// NOTE: Even though this tests that the node's client rect is non-zero to determine
//  whether it's displayed, and that a detached node will __always__ have a zero-area
//  client rect, we don't special-case for whether the node is attached or not. In
//  this mode, we do want to consider nodes that have a zero area to be hidden at all
//  times, and that includes attached or not.
return isZeroArea(node);}// visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
//  it's visible
return false;};// form fields (nested) inside a disabled fieldset are not focusable/tabbable
//  unless they are in the _first_ <legend> element of the top-most disabled
//  fieldset
var isDisabledFromFieldset=function isDisabledFromFieldset(node){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)){var parentNode=node.parentElement;// check if `node` is contained in a disabled <fieldset>
while(parentNode){if(parentNode.tagName==='FIELDSET'&&parentNode.disabled){// look for the first <legend> among the children of the disabled <fieldset>
for(var i=0;i<parentNode.children.length;i++){var child=parentNode.children.item(i);// when the first <legend> (in document order) is found
if(child.tagName==='LEGEND'){// if its parent <fieldset> is not nested in another disabled <fieldset>,
// return whether `node` is a descendant of its first <legend>
return matches.call(parentNode,'fieldset[disabled] *')?true:!child.contains(node);}}// the disabled <fieldset> containing `node` has no <legend>
return true;}parentNode=parentNode.parentElement;}}// else, node's tabbable/focusable state should not be affected by a fieldset's
//  enabled/disabled state
return false;};var isNodeMatchingSelectorFocusable=function isNodeMatchingSelectorFocusable(options,node){if(node.disabled||isHiddenInput(node)||isHidden(node,options)||// For a details element with a summary, the summary element gets the focus
isDetailsWithSummary(node)||isDisabledFromFieldset(node)){return false;}return true;};var isNodeMatchingSelectorTabbable=function isNodeMatchingSelectorTabbable(options,node){if(isNonTabbableRadio(node)||getTabIndex(node)<0||!isNodeMatchingSelectorFocusable(options,node)){return false;}return true;};var isShadowRootTabbable=function isShadowRootTabbable(shadowHostNode){var tabIndex=parseInt(shadowHostNode.getAttribute('tabindex'),10);if(isNaN(tabIndex)||tabIndex>=0){return true;}// If a custom element has an explicit negative tabindex,
// browsers will not allow tab targeting said element's children.
return false;};/**
 * @param {Array.<Element|CandidateScope>} candidates
 * @returns Element[]
 */var _sortByOrder=function sortByOrder(candidates){var regularTabbables=[];var orderedTabbables=[];candidates.forEach(function(item,i){var isScope=!!item.scopeParent;var element=isScope?item.scopeParent:item;var candidateTabindex=getSortOrderTabIndex(element,isScope);var elements=isScope?_sortByOrder(item.candidates):element;if(candidateTabindex===0){isScope?regularTabbables.push.apply(regularTabbables,elements):regularTabbables.push(element);}else{orderedTabbables.push({documentOrder:i,tabIndex:candidateTabindex,item:item,isScope:isScope,content:elements});}});return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc,sortable){sortable.isScope?acc.push.apply(acc,sortable.content):acc.push(sortable.content);return acc;},[]).concat(regularTabbables);};var tabbable=function tabbable(container,options){options=options||{};var candidates;if(options.getShadowRoot){candidates=_getCandidatesIteratively([container],options.includeContainer,{filter:isNodeMatchingSelectorTabbable.bind(null,options),flatten:false,getShadowRoot:options.getShadowRoot,shadowRootFilter:isShadowRootTabbable});}else{candidates=getCandidates(container,options.includeContainer,isNodeMatchingSelectorTabbable.bind(null,options));}return _sortByOrder(candidates);};var focusable=function focusable(container,options){options=options||{};var candidates;if(options.getShadowRoot){candidates=_getCandidatesIteratively([container],options.includeContainer,{filter:isNodeMatchingSelectorFocusable.bind(null,options),flatten:true,getShadowRoot:options.getShadowRoot});}else{candidates=getCandidates(container,options.includeContainer,isNodeMatchingSelectorFocusable.bind(null,options));}return candidates;};var isTabbable=function isTabbable(node,options){options=options||{};if(!node){throw new Error('No node provided');}if(matches.call(node,candidateSelector)===false){return false;}return isNodeMatchingSelectorTabbable(options,node);};var focusableCandidateSelector=/* #__PURE__ */(/* unused pure expression or super */ null && (candidateSelectors.concat('iframe:not([inert]):not([inert] *)').join(',')));var isFocusable=function isFocusable(node,options){options=options||{};if(!node){throw new Error('No node provided');}if(matches.call(node,focusableCandidateSelector)===false){return false;}return isNodeMatchingSelectorFocusable(options,node);};
;// ../../libs/common/src/vault/enums/bank-account-type.ts
const _BankAccountType = Object.freeze({
    Checking: "checking",
    Savings: "savings",
    CertificateOfDeposit: "certificateOfDeposit",
    LineOfCredit: "lineOfCredit",
    InvestmentBrokerage: "investmentBrokerage",
    MoneyMarket: "moneyMarket",
    Other: "other",
});
const BankAccountType = (/* unused pure expression or super */ null && (_BankAccountType));
const BankAccountTypeI18nKeys = {
    checking: "bankAccountTypeChecking",
    savings: "bankAccountTypeSavings",
    certificateOfDeposit: "bankAccountTypeCertificateOfDeposit",
    lineOfCredit: "bankAccountTypeLineOfCredit",
    investmentBrokerage: "bankAccountTypeInvestmentBrokerage",
    moneyMarket: "bankAccountTypeMoneyMarket",
    other: "bankAccountTypeOther",
};

;// ../../libs/common/src/vault/enums/cipher-reprompt-type.ts
const CipherRepromptType = {
    None: 0,
    Password: 1,
};
/**
 * Normalizes a CipherRepromptType value to ensure compatibility with the SDK.
 * @param value - The cipher reprompt type from user data
 * @returns Valid CipherRepromptType, defaults to CipherRepromptType.None if unrecognized
 */
function normalizeCipherRepromptTypeForSdk(value) {
    switch (value) {
        case CipherRepromptType.None:
        case CipherRepromptType.Password:
            return value;
        default:
            return CipherRepromptType.None;
    }
}

;// ../../libs/common/src/vault/enums/cipher-type.ts
const _CipherType = Object.freeze({
    Login: 1,
    SecureNote: 2,
    Card: 3,
    Identity: 4,
    SshKey: 5,
    BankAccount: 6,
    DriversLicense: 7,
    Passport: 8,
});
// FIXME: Update typing of `CipherType` to be `Record<keyof _CipherType, CipherType>` which is ADR-0025 compliant when the TypeScript version is at least 5.8.
const CipherType = _CipherType;
/**
 * Reverse mapping of Cipher Types to their associated names.
 * Prefer using {@link toCipherTypeName} rather than accessing this object directly.
 *
 * When represented as an enum in TypeScript, this mapping was provided
 * by default. Now using a constant object it needs to be defined manually.
 */
const cipherTypeNames = Object.freeze(Object.fromEntries(Object.entries(CipherType).map(([key, value]) => [value, key])));
/**
 * Returns the associated name for the cipher type, will throw when the name is not found.
 */
function toCipherTypeName(type) {
    const name = cipherTypeNames[type];
    return name;
}
/**
 * @returns `true` if the value is a valid `CipherType`, `false` otherwise.
 */
const isCipherType = (value) => {
    return Object.values(CipherType).includes(value);
};
/**
 * Converts a value to a `CipherType` if it is valid, otherwise returns `null`.
 */
const toCipherType = (value) => {
    if (isCipherType(value)) {
        return value;
    }
    if (typeof value === "string") {
        const valueAsInt = parseInt(value, 10);
        if (isCipherType(valueAsInt)) {
            return valueAsInt;
        }
    }
    return undefined;
};

;// ../../libs/common/src/vault/enums/field-type.enum.ts
const _FieldType = Object.freeze({
    Text: 0,
    Hidden: 1,
    Boolean: 2,
    Linked: 3,
});
const FieldType = _FieldType;
/**
 * Normalizes a FieldType value to ensure compatibility with the SDK.
 * @param value - The field type from user data
 * @returns Valid FieldType, defaults to FieldType.Text if unrecognized
 */
function normalizeFieldTypeForSdk(value) {
    switch (value) {
        case FieldType.Text:
        case FieldType.Hidden:
        case FieldType.Boolean:
        case FieldType.Linked:
            return value;
        default:
            return FieldType.Text;
    }
}

;// ../../libs/common/src/vault/enums/linked-id-type.enum.ts
// LoginView
const LoginLinkedId = {
    Username: 100,
    Password: 101,
};
// CardView
const CardLinkedId = {
    CardholderName: 300,
    ExpMonth: 301,
    ExpYear: 302,
    Code: 303,
    Brand: 304,
    Number: 305,
};
// IdentityView
const IdentityLinkedId = {
    Title: 400,
    MiddleName: 401,
    Address1: 402,
    Address2: 403,
    Address3: 404,
    City: 405,
    State: 406,
    PostalCode: 407,
    Country: 408,
    Company: 409,
    Email: 410,
    Phone: 411,
    Ssn: 412,
    Username: 413,
    PassportNumber: 414,
    LicenseNumber: 415,
    FirstName: 416,
    LastName: 417,
    FullName: 418,
};
/**
 * Normalizes a LinkedIdType value to ensure compatibility with the SDK.
 * @param value - The linked ID type from user data
 * @returns Valid LinkedIdType or undefined if unrecognized
 */
function normalizeLinkedIdTypeForSdk(value) {
    if (value == null) {
        return undefined;
    }
    // Check all valid LinkedId numeric values (100-418)
    const allValidValues = [
        ...Object.values(LoginLinkedId),
        ...Object.values(CardLinkedId),
        ...Object.values(IdentityLinkedId),
    ];
    return allValidValues.includes(value) ? value : undefined;
}

;// ../../libs/common/src/vault/enums/secure-note-type.enum.ts
const SecureNoteType = {
    Generic: 0,
};
/**
 * Normalizes a SecureNoteType value to ensure compatibility with the SDK.
 * @param value - The secure note type from user data
 * @returns Valid SecureNoteType, defaults to SecureNoteType.Generic if unrecognized
 */
function normalizeSecureNoteTypeForSdk(value) {
    return SecureNoteType.Generic;
}

;// ../../libs/common/src/vault/enums/extension-page-urls.enum.ts
/**
 * Available pages within the extension by their URL.
 * Useful when opening a specific page within the popup.
 */
const ExtensionPageUrls = {
    Index: "popup/index.html#/",
    AtRiskPasswords: "popup/index.html#/at-risk-passwords",
};

;// ../../libs/common/src/vault/enums/index.ts








;// ./src/autofill/enums/autofill-field.enums.ts
const AutofillFieldQualifier = {
    password: "password",
    newPassword: "newPassword",
    username: "username",
    cardholderName: "cardholderName",
    cardNumber: "cardNumber",
    cardExpirationMonth: "cardExpirationMonth",
    cardExpirationYear: "cardExpirationYear",
    cardExpirationDate: "cardExpirationDate",
    cardCvv: "cardCvv",
    identityTitle: "identityTitle",
    identityFirstName: "identityFirstName",
    identityMiddleName: "identityMiddleName",
    identityLastName: "identityLastName",
    identityFullName: "identityFullName",
    identityAddress1: "identityAddress1",
    identityAddress2: "identityAddress2",
    identityAddress3: "identityAddress3",
    identityCity: "identityCity",
    identityState: "identityState",
    identityPostalCode: "identityPostalCode",
    identityCountry: "identityCountry",
    identityCompany: "identityCompany",
    identityPhone: "identityPhone",
    identityEmail: "identityEmail",
    identityUsername: "identityUsername",
};

;// ./src/autofill/utils/event-security.ts
/**
 * Event security utilities for validating trusted events
 */
class EventSecurity {
    /**
     * Validates that an event is trusted (originated from user agent)
     * @param event - The event to validate
     * @returns true if the event is trusted, false otherwise
     */
    static isEventTrusted(event) {
        return event.isTrusted;
    }
}

;// ./src/autofill/utils/url-variations.ts
/**
 * Returns the set of URL variations that should match a given sub-frame URL.
 *
 * Frame URLs reported by different sources can diverge in normalization:
 * trailing slashes, omitted protocol or hostname, search/hash components, etc.
 * This helper enumerates the variations that a caller may want to compare
 * against (e.g. via Set membership) so a strict equality check is not the
 * only way to identify a matching frame.
 *
 * Returns `null` if the input cannot be parsed as a URL.
 *
 * @param subFrameUrl - The URL of the sub frame. May be relative when
 *   `baseUrl` is provided.
 * @param baseUrl - Base URL used to resolve relative `subFrameUrl` values.
 *   Defaults to the current global location when available, mirroring the
 *   behavior used by content-script callers.
 */
function getSubFrameUrlVariations(subFrameUrl, baseUrl) {
    var _a;
    if (baseUrl === void 0) { baseUrl = typeof globalThis !== "undefined"
        ? (_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.href
        : undefined; }
    let url;
    try {
        url = baseUrl ? new URL(subFrameUrl, baseUrl) : new URL(subFrameUrl);
    }
    catch (_b) {
        return null;
    }
    const pathAndHash = url.pathname + url.hash;
    const pathAndSearch = url.pathname + url.search;
    const pathSearchAndHash = pathAndSearch + url.hash;
    const pathNameWithoutTrailingSlash = url.pathname.replace(/\/$/, "");
    const pathWithoutTrailingSlashAndHash = pathNameWithoutTrailingSlash + url.hash;
    const pathWithoutTrailingSlashAndSearch = pathNameWithoutTrailingSlash + url.search;
    const pathWithoutTrailingSlashSearchAndHash = pathWithoutTrailingSlashAndSearch + url.hash;
    return new Set([
        url.href,
        url.href.replace(/\/$/, ""),
        url.pathname,
        pathAndHash,
        pathAndSearch,
        pathSearchAndHash,
        pathNameWithoutTrailingSlash,
        pathWithoutTrailingSlashAndHash,
        pathWithoutTrailingSlashAndSearch,
        pathWithoutTrailingSlashSearchAndHash,
        url.hostname + url.pathname,
        url.hostname + pathAndHash,
        url.hostname + pathAndSearch,
        url.hostname + pathSearchAndHash,
        url.hostname + pathNameWithoutTrailingSlash,
        url.hostname + pathWithoutTrailingSlashAndHash,
        url.hostname + pathWithoutTrailingSlashAndSearch,
        url.hostname + pathWithoutTrailingSlashSearchAndHash,
        url.origin + url.pathname,
        url.origin + pathAndHash,
        url.origin + pathAndSearch,
        url.origin + pathSearchAndHash,
        url.origin + pathNameWithoutTrailingSlash,
        url.origin + pathWithoutTrailingSlashAndHash,
        url.origin + pathWithoutTrailingSlashAndSearch,
        url.origin + pathWithoutTrailingSlashSearchAndHash,
    ]);
}

;// ./src/autofill/services/autofill-constants.ts


/**
 * Authoritative cipher-type mapping for targeting-rule form categories whose
 * fields all belong to a single cipher type.
 */
const targetedFormCategoryFillTypes = {
    [FormPurposeCategories.AccountLogin]: CipherType.Login,
    [FormPurposeCategories.PaymentCard]: CipherType.Card,
    [FormPurposeCategories.Identity]: CipherType.Identity,
    [FormPurposeCategories.Address]: CipherType.Identity,
};
const loginQualifiers = [
    AutofillTargetingRuleTypes.username,
    AutofillTargetingRuleTypes.password,
    AutofillTargetingRuleTypes.newPassword,
];
const cardQualifiers = [
    AutofillTargetingRuleTypes.cardholderName,
    AutofillTargetingRuleTypes.cardNumber,
    AutofillTargetingRuleTypes.cardExpirationMonth,
    AutofillTargetingRuleTypes.cardExpirationYear,
    AutofillTargetingRuleTypes.cardExpirationDate,
    AutofillTargetingRuleTypes.cardCvv,
    AutofillTargetingRuleTypes.cardType,
];
const identityQualifiers = [
    AutofillTargetingRuleTypes.fullName,
    AutofillTargetingRuleTypes.honorificPrefix,
    AutofillTargetingRuleTypes.firstName,
    AutofillTargetingRuleTypes.middleName,
    AutofillTargetingRuleTypes.lastName,
    AutofillTargetingRuleTypes.honorificSuffix,
    AutofillTargetingRuleTypes.email,
    AutofillTargetingRuleTypes.phone,
    AutofillTargetingRuleTypes.phoneCountryCode,
    AutofillTargetingRuleTypes.phoneAreaCode,
    AutofillTargetingRuleTypes.phoneLocal,
    AutofillTargetingRuleTypes.phoneExtension,
    AutofillTargetingRuleTypes.organization,
    AutofillTargetingRuleTypes.streetAddress,
    AutofillTargetingRuleTypes.addressLine1,
    AutofillTargetingRuleTypes.addressLine2,
    AutofillTargetingRuleTypes.addressLine3,
    AutofillTargetingRuleTypes.addressLevel1,
    AutofillTargetingRuleTypes.addressLevel2,
    AutofillTargetingRuleTypes.addressLevel3,
    AutofillTargetingRuleTypes.addressLevel4,
    AutofillTargetingRuleTypes.postalCode,
    AutofillTargetingRuleTypes.country,
    AutofillTargetingRuleTypes.birthdate,
    AutofillTargetingRuleTypes.birthdateDay,
    AutofillTargetingRuleTypes.birthdateMonth,
    AutofillTargetingRuleTypes.birthdateYear,
];
class AutoFillConstants {
}
AutoFillConstants.EmailFieldNames = [
    // English
    "email",
    "email address",
    "e-mail",
    "e-mail address",
    // German
    "email adresse",
    "e-mail adresse",
];
AutoFillConstants.UsernameFieldNames = [
    // English
    "username",
    "user name",
    "userid",
    "user id",
    "customer id",
    "login id",
    "login",
    // German
    "benutzername",
    "benutzer name",
    "benutzerid",
    "benutzer id",
    ...AutoFillConstants.EmailFieldNames,
];
AutoFillConstants.TotpFieldNames = [
    "2facode",
    "approvals_code",
    "mfacode",
    "onetimecode",
    "onetimepassword",
    "otc-code",
    "otp-code",
    "otpcode",
    "second-factor",
    "security_code",
    "security code",
    "totp",
    "totpcode",
    "twofa",
    "twofactor",
    "twofactorcode",
    "verificationcode",
    "verification code",
    "otc-confirmation",
];
AutoFillConstants.RecoveryCodeFieldNames = ["backup", "recovery"];
AutoFillConstants.AmbiguousTotpFieldNames = ["code", "pin", "otc", "otp", "2fa", "mfa"];
AutoFillConstants.SearchFieldNames = ["search", "query", "find", "go"];
AutoFillConstants.NewEmailFieldKeywords = [
    "new-email",
    "newemail",
    "new email",
    "neue e-mail",
];
AutoFillConstants.RegistrationKeywords = [
    "register",
    "signup",
    "sign-up",
    "join",
    "create",
];
/**
 * Field-level keywords indicating account creation or registration context.
 * Broader than {@link RegistrationKeywords}, which is used at the form level.
 */
AutoFillConstants.AccountCreationFieldKeywords = [
    "register",
    "registration",
    "create password",
    "create a password",
    "create an account",
    "create account password",
    "create user password",
    "confirm password",
    "confirm account password",
    "confirm user password",
    "new user",
    "new email",
    "new e-mail",
    "new password",
    "new-password",
    "neuer benutzer",
    "neues passwort",
    "neue e-mail",
    "pwdcheck",
];
/**
 * Field-level keywords indicating a password update or change context, as distinguished
 * from a new account creation or initial login context.
 */
AutoFillConstants.UpdatePasswordFieldKeywords = [
    "update password",
    "change password",
    "current password",
    "kennwort ändern",
];
/**
 * Non-login keywords with high enough confidence to disqualify a form for login on their own.
 * Included by default in {@link ComprehensiveNonLoginKeywords}.
 */
AutoFillConstants.StrongNonLoginKeywords = ["newsletter"];
/** Full lexicon of non-login keywords. */
AutoFillConstants.ComprehensiveNonLoginKeywords = [
    ...AutoFillConstants.StrongNonLoginKeywords,
    "mailing list",
    "subscribe",
    "subscription",
    "unsubscribe",
];
/** Login-positive heading text used to short-circuit ambiguous-case disqualification. */
AutoFillConstants.StrongLoginHeadingKeywords = [
    "sign in",
    "signin",
    "log in",
    "login",
    "log on",
    "logon",
];
AutoFillConstants.FieldIgnoreList = ["captcha", "findanything", "forgot"];
AutoFillConstants.PasswordFieldExcludeList = [
    "hint",
    ...AutoFillConstants.FieldIgnoreList,
    ...AutoFillConstants.TotpFieldNames,
];
AutoFillConstants.ExcludedAutofillLoginTypes = [
    "hidden",
    "file",
    "button",
    "image",
    "reset",
    "search",
];
AutoFillConstants.ExcludedAutofillTypes = [
    "radio",
    "checkbox",
    ...AutoFillConstants.ExcludedAutofillLoginTypes,
];
AutoFillConstants.ExcludedInlineMenuTypes = [
    "textarea",
    ...AutoFillConstants.ExcludedAutofillTypes,
];
/** HTML elements for form fields */
AutoFillConstants.FieldElements = ["input", "select", "textarea"];
AutoFillConstants.AutocompleteCurrentPassword = "current-password";
AutoFillConstants.AutocompleteNewPassword = "new-password";
AutoFillConstants.ExcludedIdentityAutocompleteTypes = new Set([
    AutoFillConstants.AutocompleteCurrentPassword,
    AutoFillConstants.AutocompleteNewPassword,
]);
class CreditCardAutoFillConstants {
}
CreditCardAutoFillConstants.CardAttributes = [
    "autoCompleteType",
    "data-stripe",
    "htmlName",
    "htmlID",
    "title",
    "label-tag",
    "placeholder",
    "label-left",
    "label-top",
    "data-recurly",
];
CreditCardAutoFillConstants.CardAttributesExtended = [
    ...CreditCardAutoFillConstants.CardAttributes,
    "label-right",
];
CreditCardAutoFillConstants.CardHolderFieldNames = [
    "accountholdername",
    "cc-name",
    "card-name",
    "cardholder-name",
    "cardholder",
    "name",
    "nom",
];
CreditCardAutoFillConstants.CardHolderFieldNameValues = [
    "accountholdername",
    "cc-name",
    "card-name",
    "cardholder-name",
    "cardholder",
    "tbName",
];
CreditCardAutoFillConstants.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",
    "card-pan",
];
CreditCardAutoFillConstants.CardNumberFieldNameValues = [
    "cc-number",
    "cc-num",
    "card-number",
    "card-num",
    "cc-no",
    "card-no",
    "numero-carte",
    "num-carte",
    "cb-num",
];
CreditCardAutoFillConstants.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",
];
CreditCardAutoFillConstants.CardExpiryFieldNameValues = [
    "mm-yy",
    "mm-yyyy",
    "yy-mm",
    "yyyy-mm",
    "expiration-date",
    "payment-card-expiration",
];
CreditCardAutoFillConstants.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",
];
CreditCardAutoFillConstants.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",
];
CreditCardAutoFillConstants.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",
];
CreditCardAutoFillConstants.CardBrandFieldNames = [
    "cc-type",
    "card-type",
    "card-brand",
    "cc-brand",
    "cb-type",
];
// Note, these are expressions of user-guidance for the expected expiry date format to be used
CreditCardAutoFillConstants.CardExpiryDateFormats = [
    // English
    {
        Month: "mm",
        MonthShort: "m",
        Year: "yyyy",
        YearShort: "yy",
    },
    // Danish
    {
        Month: "mm",
        MonthShort: "m",
        Year: "åååå",
        YearShort: "åå",
    },
    // German/Dutch
    {
        Month: "mm",
        MonthShort: "m",
        Year: "jjjj",
        YearShort: "jj",
    },
    // French/Spanish/Italian
    {
        Month: "mm",
        MonthShort: "m",
        Year: "aa",
        YearShort: "aa",
    },
    // Russian
    {
        Month: "мм",
        MonthShort: "м",
        Year: "гггг",
        YearShort: "гг",
    },
    // Portuguese
    {
        Month: "mm",
        MonthShort: "m",
        Year: "rrrr",
        YearShort: "rr",
    },
];
// Each index represents a language. These three arrays should all be the same length.
// 0: English, 1: Danish, 2: German/Dutch, 3: French/Spanish/Italian, 4: Russian, 5: Portuguese
CreditCardAutoFillConstants.MonthAbbr = ["mm", "mm", "mm", "mm", "мм", "mm"];
CreditCardAutoFillConstants.YearAbbrShort = ["yy", "åå", "jj", "aa", "гг", "rr"];
CreditCardAutoFillConstants.YearAbbrLong = ["yyyy", "åååå", "jjjj", "aa", "гггг", "rrrr"];
class IdentityAutoFillConstants {
}
IdentityAutoFillConstants.IdentityAttributes = [
    "autoCompleteType",
    "data-stripe",
    "htmlName",
    "htmlID",
    "label-tag",
    "placeholder",
    "label-left",
    "label-top",
    "data-recurly",
    "accountCreationFieldType",
    "type",
];
IdentityAutoFillConstants.FullNameFieldNames = ["name", "full-name", "your-name"];
IdentityAutoFillConstants.FullNameFieldNameValues = ["full-name", "your-name"];
IdentityAutoFillConstants.TitleFieldNames = [
    "honorific-prefix",
    "prefix",
    "title",
    // German
    "anrede",
];
IdentityAutoFillConstants.FirstnameFieldNames = [
    // English
    "f-name",
    "first-name",
    "given-name",
    "first-n",
    // German
    "vorname",
];
IdentityAutoFillConstants.MiddlenameFieldNames = [
    "m-name",
    "middle-name",
    "additional-name",
    "middle-initial",
    "middle-n",
    "middle-i",
];
IdentityAutoFillConstants.LastnameFieldNames = [
    // English
    "l-name",
    "last-name",
    "s-name",
    "surname",
    "family-name",
    "family-n",
    "last-n",
    // German
    "nachname",
    "familienname",
];
IdentityAutoFillConstants.EmailFieldNames = ["e-mail", "email-address"];
IdentityAutoFillConstants.AddressFieldNames = [
    "address",
    "street-address",
    "addr",
    "street",
    "mailing-addr",
    "billing-addr",
    "mail-addr",
    "bill-addr",
    // German
    "strasse",
    "adresse",
];
IdentityAutoFillConstants.AddressFieldNameValues = [
    "mailing-addr",
    "billing-addr",
    "mail-addr",
    "bill-addr",
];
IdentityAutoFillConstants.Address1FieldNames = [
    "address-1",
    "address-line-1",
    "addr-1",
    "street-1",
];
IdentityAutoFillConstants.Address2FieldNames = [
    "address-2",
    "address-line-2",
    "addr-2",
    "street-2",
    "address-ext",
];
IdentityAutoFillConstants.Address3FieldNames = [
    "address-3",
    "address-line-3",
    "addr-3",
    "street-3",
];
IdentityAutoFillConstants.PostalCodeFieldNames = [
    "postal",
    "zip",
    "zip2",
    "zip-code",
    "postal-code",
    "post-code",
    "postcode",
    "address-zip",
    "address-postal",
    "address-code",
    "address-postal-code",
    "address-zip-code",
    // German
    "plz",
    "postleitzahl",
];
IdentityAutoFillConstants.CityFieldNames = [
    "city",
    "town",
    "address-level-2",
    "address-city",
    "address-town",
    // German
    "ort",
    "stadt",
    "wohnort",
];
IdentityAutoFillConstants.StateFieldNames = [
    "state",
    "province",
    "provence",
    "address-level-1",
    "address-state",
    "address-province",
    // German
    "bundesland",
];
IdentityAutoFillConstants.CountryFieldNames = [
    "country",
    "country-code",
    "country-name",
    "address-country",
    "address-country-name",
    "address-country-code",
    // German
    "land",
];
IdentityAutoFillConstants.PhoneFieldNames = [
    "phone",
    "mobile",
    "mobile-phone",
    "tel",
    "telephone",
    "phone-number",
    // German
    "telefon",
    "telefonnummer",
    "mobil",
    "handy",
];
IdentityAutoFillConstants.UserNameFieldNames = ["user-name", "user-id", "screen-name"];
IdentityAutoFillConstants.CompanyFieldNames = [
    "company",
    "company-name",
    "organization",
    "organization-name",
    // German
    "firma",
];
IdentityAutoFillConstants.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",
};
IdentityAutoFillConstants.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",
};
IdentityAutoFillConstants.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",
};
const SubmitLoginButtonNames = [
    "login",
    "signin",
    "submit",
    "continue",
    "next",
    "verify",
];
const SubmitChangePasswordButtonNames = [
    "change",
    "save",
    "savepassword",
    "updatepassword",
    "changepassword",
    "resetpassword",
];

;// ./src/autofill/services/autofill-overlay-content.service.ts
var autofill_overlay_content_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};











class AutofillOverlayContentService {
    constructor(domQueryService, domElementVisibilityService, inlineMenuFieldQualificationService, inlineMenuContentService) {
        this.domQueryService = domQueryService;
        this.domElementVisibilityService = domElementVisibilityService;
        this.inlineMenuFieldQualificationService = inlineMenuFieldQualificationService;
        this.inlineMenuContentService = inlineMenuContentService;
        this.pageDetailsUpdateRequired = false;
        this.showInlineMenuIdentities = false;
        this.showInlineMenuCards = false;
        this.findTabs = tabbable;
        this.sendExtensionMessage = sendExtensionMessage;
        this.formFieldElements = new Map();
        this.hiddenFormFieldElements = new WeakMap();
        this.formElements = new Set();
        this.submitElements = new Set();
        this.fieldsWithSubmitElements = new WeakMap();
        this.ignoredFieldTypes = new Set(AutoFillConstants.ExcludedInlineMenuTypes);
        this.userFilledFields = {};
        this.focusableElements = [];
        this.mostRecentlyFocusedField = null;
        this.focusedFieldData = null;
        this.closeInlineMenuOnRedirectTimeout = null;
        this.focusInlineMenuListTimeout = null;
        this.eventHandlersMemo = {};
        this.extensionMessageHandlers = {
            addNewVaultItemFromOverlay: ({ message }) => this.addNewVaultItem(message),
            focusMostRecentlyFocusedField: () => this.focusMostRecentlyFocusedField(),
            blurMostRecentlyFocusedField: () => this.blurMostRecentlyFocusedField(),
            unsetMostRecentlyFocusedField: () => this.unsetMostRecentlyFocusedField(),
            checkIsMostRecentlyFocusedFieldWithinViewport: () => this.checkIsMostRecentlyFocusedFieldWithinViewport(),
            bgVaultItemRepromptPopoutOpened: () => this.blurMostRecentlyFocusedField(true),
            bgUnlockPopoutOpened: () => this.blurMostRecentlyFocusedField(true),
            redirectAutofillInlineMenuFocusOut: ({ message }) => { var _a; return this.redirectInlineMenuFocusOut((_a = message === null || message === void 0 ? void 0 : message.data) === null || _a === void 0 ? void 0 : _a.direction); },
            getSubFrameOffsets: ({ message }) => this.getSubFrameOffsets(message),
            getSubFrameOffsetsFromWindowMessage: ({ message }) => this.getSubFrameOffsetsFromWindowMessage(message),
            checkMostRecentlyFocusedFieldHasValue: () => this.mostRecentlyFocusedFieldHasValue(),
            setupRebuildSubFrameOffsetsListeners: () => this.setupRebuildSubFrameOffsetsListeners(),
            destroyAutofillInlineMenuListeners: () => this.destroy(),
            getInlineMenuFormFieldData: ({ message }) => this.handleGetInlineMenuFormFieldDataMessage(message),
            generatedPasswordModifyLogin: () => this.sendGeneratedPasswordModifyLogin(),
        };
        this.loginFieldQualifiers = {
            [AutofillFieldQualifier.username]: this.inlineMenuFieldQualificationService.isUsernameField,
            [AutofillFieldQualifier.password]: this.inlineMenuFieldQualificationService.isCurrentPasswordField,
        };
        this.accountCreationFieldQualifiers = {
            [AutofillFieldQualifier.username]: this.inlineMenuFieldQualificationService.isUsernameField,
            [AutofillFieldQualifier.newPassword]: this.inlineMenuFieldQualificationService.isNewPasswordField,
        };
        this.cardFieldQualifiers = {
            [AutofillFieldQualifier.cardholderName]: this.inlineMenuFieldQualificationService.isFieldForCardholderName,
            [AutofillFieldQualifier.cardNumber]: this.inlineMenuFieldQualificationService.isFieldForCardNumber,
            [AutofillFieldQualifier.cardExpirationMonth]: this.inlineMenuFieldQualificationService.isFieldForCardExpirationMonth,
            [AutofillFieldQualifier.cardExpirationYear]: this.inlineMenuFieldQualificationService.isFieldForCardExpirationYear,
            [AutofillFieldQualifier.cardExpirationDate]: this.inlineMenuFieldQualificationService.isFieldForCardExpirationDate,
            [AutofillFieldQualifier.cardCvv]: this.inlineMenuFieldQualificationService.isFieldForCardCvv,
        };
        this.identityFieldQualifiers = {
            [AutofillFieldQualifier.identityTitle]: this.inlineMenuFieldQualificationService.isFieldForIdentityTitle,
            [AutofillFieldQualifier.identityFirstName]: this.inlineMenuFieldQualificationService.isFieldForIdentityFirstName,
            [AutofillFieldQualifier.identityMiddleName]: this.inlineMenuFieldQualificationService.isFieldForIdentityMiddleName,
            [AutofillFieldQualifier.identityLastName]: this.inlineMenuFieldQualificationService.isFieldForIdentityLastName,
            [AutofillFieldQualifier.identityFullName]: this.inlineMenuFieldQualificationService.isFieldForIdentityFullName,
            [AutofillFieldQualifier.identityAddress1]: this.inlineMenuFieldQualificationService.isFieldForIdentityAddress1,
            [AutofillFieldQualifier.identityAddress2]: this.inlineMenuFieldQualificationService.isFieldForIdentityAddress2,
            [AutofillFieldQualifier.identityAddress3]: this.inlineMenuFieldQualificationService.isFieldForIdentityAddress3,
            [AutofillFieldQualifier.identityCity]: this.inlineMenuFieldQualificationService.isFieldForIdentityCity,
            [AutofillFieldQualifier.identityState]: this.inlineMenuFieldQualificationService.isFieldForIdentityState,
            [AutofillFieldQualifier.identityPostalCode]: this.inlineMenuFieldQualificationService.isFieldForIdentityPostalCode,
            [AutofillFieldQualifier.identityCountry]: this.inlineMenuFieldQualificationService.isFieldForIdentityCountry,
            [AutofillFieldQualifier.identityCompany]: this.inlineMenuFieldQualificationService.isFieldForIdentityCompany,
            [AutofillFieldQualifier.identityPhone]: this.inlineMenuFieldQualificationService.isFieldForIdentityPhone,
            [AutofillFieldQualifier.identityEmail]: this.inlineMenuFieldQualificationService.isFieldForIdentityEmail,
            [AutofillFieldQualifier.identityUsername]: this.inlineMenuFieldQualificationService.isFieldForIdentityUsername,
        };
        this.isMonitoring = false;
        this.refreshMenuLayerPosition = () => { var _a; return (_a = this.inlineMenuContentService) === null || _a === void 0 ? void 0 : _a.refreshTopLayerPosition(); };
        this.getOwnedInlineMenuTagNames = () => { var _a; return ((_a = this.inlineMenuContentService) === null || _a === void 0 ? void 0 : _a.getOwnedTagNames()) || []; };
        this.isElementInlineMenu = (element) => { var _a, _b; return (_b = (_a = this.inlineMenuContentService) === null || _a === void 0 ? void 0 : _a.isElementInlineMenu(element)) !== null && _b !== void 0 ? _b : false; };
        this.getUnownedTopLayerItems = (includeCandidates) => { var _a; return (_a = this.inlineMenuContentService) === null || _a === void 0 ? void 0 : _a.getUnownedTopLayerItems(includeCandidates); };
        /**
         * On password generation, send form field data i.e. modified login data
         */
        this.sendGeneratedPasswordModifyLogin = () => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            yield this.sendExtensionMessage("generatedPasswordFilled", this.getFormFieldData());
        });
        /**
         * Sets up the event listeners that trigger an indication that a form has been submitted.
         *
         * @param submitButton - The submit button element to set up the event listeners for.
         */
        this.setupSubmitButtonEventListeners = (submitButton) => {
            if (!submitButton || this.submitElements.has(submitButton)) {
                return;
            }
            this.submitElements.add(submitButton);
            const handler = this.useEventHandlersMemo(throttle(this.handleSubmitButtonInteraction, 150), AUTOFILL_TRIGGER_FORM_FIELD_SUBMIT);
            submitButton.addEventListener(EVENTS.KEYUP, handler);
            globalThis.document.addEventListener(EVENTS.CLICK, handler);
            globalThis.document.addEventListener(EVENTS.MOUSEUP, handler);
        };
        /**
         * Handles click and keyup events that trigger behavior for a submit button element.
         *
         * @param event - The event that triggered the submit button interaction.
         */
        this.handleSubmitButtonInteraction = (event) => {
            if (
            /**
             * Reject synthetic events (not originating from the user agent)
             */
            !EventSecurity.isEventTrusted(event) ||
                !this.submitElements.has(event.target) ||
                (event.type === "keyup" &&
                    !["Enter", "Space"].includes(event.code))) {
                return;
            }
            this.handleFormFieldSubmitEvent();
        };
        /**
         * Handles the repositioning of the autofill overlay when the form is submitted.
         */
        this.handleFormFieldSubmitEvent = () => {
            void this.sendExtensionMessage("formFieldSubmitted", this.getFormFieldData());
        };
        /**
         * Handles capturing the form field data for a notification message. Will not trigger this behavior
         * in the case where the user is still typing in the field unless the focus is ignored.
         */
        this.handleGetInlineMenuFormFieldDataMessage = (_a) => autofill_overlay_content_service_awaiter(this, [_a], void 0, function* ({ ignoreFieldFocus, }) {
            if (!ignoreFieldFocus && (yield this.isFieldCurrentlyFocused())) {
                return;
            }
            return this.getFormFieldData();
        });
        /**
         * Returns the form field data used for add login and change password notifications.
         */
        this.getFormFieldData = () => {
            var _a, _b, _c, _d, _e, _f;
            return {
                uri: globalThis.document.URL,
                username: ((_b = (_a = this.userFilledFields) === null || _a === void 0 ? void 0 : _a["username"]) === null || _b === void 0 ? void 0 : _b.value) || "",
                password: ((_d = (_c = this.userFilledFields) === null || _c === void 0 ? void 0 : _c["password"]) === null || _d === void 0 ? void 0 : _d.value) || "",
                newPassword: ((_f = (_e = this.userFilledFields) === null || _e === void 0 ? void 0 : _e["newPassword"]) === null || _f === void 0 ? void 0 : _f.value) || "",
            };
        };
        /**
         * Helper method that facilitates registration of an event handler to a form field element.
         *
         * @param eventHandler - The event handler to memoize.
         * @param memoIndex - The memo index to use for the event handler.
         */
        this.useEventHandlersMemo = (eventHandler, memoIndex) => {
            return this.eventHandlersMemo[memoIndex] || (this.eventHandlersMemo[memoIndex] = eventHandler);
        };
        /**
         * Form Field blur event handler. Updates the value identifying whether
         * the field is focused and sends a message to check if the inline menu itself
         * is currently focused.
         */
        this.handleFormFieldBlurEvent = () => {
            void this.updateIsFieldCurrentlyFocused(false);
            void this.sendExtensionMessage("checkAutofillInlineMenuFocused");
        };
        this.handleFormFieldKeyupEventAsListener = (e) => {
            void this.handleFormFieldKeyupEvent(e);
        };
        /**
         * Form field keyup event handler. Facilitates the ability to remove the
         * autofill inline menu using the escape key, focusing the inline menu list using
         * the ArrowDown key, and ensuring that the inline menu is repositioned when
         * the form is submitted using the Enter key.
         *
         * @param event - The keyup event.
         */
        this.handleFormFieldKeyupEvent = (event) => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            /**
             * Reject synthetic events (not originating from the user agent)
             */
            if (!EventSecurity.isEventTrusted(event)) {
                return;
            }
            const eventCode = event.code;
            if (eventCode === "Escape") {
                void this.sendExtensionMessage("closeAutofillInlineMenu", {
                    forceCloseInlineMenu: true,
                });
                return;
            }
            if (eventCode === "Enter" && !(yield this.isFieldCurrentlyFilling())) {
                void this.handleOverlayRepositionEvent();
                return;
            }
            if (eventCode === "ArrowDown") {
                event.preventDefault();
                event.stopPropagation();
                void this.focusInlineMenuList();
            }
        });
        /**
         * Sets up and memoizes the form field input event handler.
         *
         * @param formFieldElement - The form field element that triggered the input event.
         */
        this.handleFormFieldInputEvent = (formFieldElement) => {
            return this.useEventHandlersMemo(debounce(() => this.triggerFormFieldInput(formFieldElement), 100, true), this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.INPUT));
        };
        /**
         * Handles qualification of the user filled field based on the field qualifiers provided.
         *
         * @param autofillFieldData - Autofill field data captured from the form field element.
         * @param qualifiers - The field qualifiers to use when qualifying the user filled field.
         */
        this.qualifyUserFilledField = (autofillFieldData, qualifiers) => {
            for (const [fieldQualifier, fieldQualifierFunction] of Object.entries(qualifiers)) {
                if (fieldQualifierFunction(autofillFieldData)) {
                    autofillFieldData.fieldQualifier = fieldQualifier;
                    return;
                }
            }
        };
        /**
         * Sets up and memoizes the form field click event handler.
         *
         * @param formFieldElement - The form field element that triggered the click event.
         */
        this.handleFormFieldClickEvent = (formFieldElement) => {
            return this.useEventHandlersMemo(() => this.triggerFormFieldClickedAction(formFieldElement), this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.CLICK));
        };
        /**
         * Sets up and memoizes the form field focus event handler.
         *
         * @param formFieldElement - The form field element that triggered the focus event.
         */
        this.handleFormFieldFocusEvent = (formFieldElement) => {
            return this.useEventHandlersMemo(() => this.triggerFormFieldFocusedAction(formFieldElement), this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.FOCUS));
        };
        /**
         * Triggers an update in the background script focused status of the form field element.
         *
         * @param isFieldCurrentlyFocused - The focused status of the form field element.
         */
        this.updateIsFieldCurrentlyFocused = (isFieldCurrentlyFocused) => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            yield this.sendExtensionMessage("updateIsFieldCurrentlyFocused", { isFieldCurrentlyFocused });
        });
        this.handleHiddenFieldFocusEventAsListener = (e) => this.handleHiddenFieldFocusEvent(e);
        /**
         * Handles the focus event on a hidden field. When
         * triggered, the inline menu is set up on the field.
         *
         * @param event - The focus event.
         */
        this.handleHiddenFieldFocusEvent = (event) => {
            const formFieldElement = event.target;
            if (!(formFieldElement instanceof Element)) {
                return;
            }
            this.handleHiddenElementFallbackEvent(formFieldElement);
        };
        this.handleHiddenFieldInputEventAsListener = (e) => {
            void this.handleHiddenFieldInputEvent(e);
        };
        /**
         * Handles an input event on a hidden field. When triggered, the inline menu is set up on the
         * field. We also capture the input value for the field to facilitate presentation of the value
         * for the field in the notification bar.
         *
         * @param event - The input event.
         */
        this.handleHiddenFieldInputEvent = (event) => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const formFieldElement = event.target;
            if (!(formFieldElement instanceof Element)) {
                return;
            }
            this.handleHiddenElementFallbackEvent(formFieldElement);
            yield this.triggerFormFieldInput(formFieldElement);
        });
        /**
         * Handles updating the hidden element when a fallback event is triggered.
         *
         * @param formFieldElement - The form field element that triggered the focus event.
         */
        this.handleHiddenElementFallbackEvent = (formFieldElement) => {
            const autofillFieldData = this.hiddenFormFieldElements.get(formFieldElement);
            if (autofillFieldData) {
                autofillFieldData.readonly =
                    Boolean(formFieldElement.readOnly) ||
                        getAttributeBoolean(formFieldElement, "aria-readonly", true);
                autofillFieldData.disabled = getAttributeBoolean(formFieldElement, "disabled");
                autofillFieldData.viewable = true;
                void this.setupOverlayListenersOnQualifiedField(formFieldElement, autofillFieldData);
            }
            this.removeHiddenFieldFallbackListener(formFieldElement);
        };
        /**
         * Calculates the sub frame positioning for the current frame
         * through all parent frames until the top frame is reached.
         *
         * @param event - The message event.
         */
        this.calculateSubFramePositioning = (event) => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (!isSubFramePositioningMessageData(event.data)) {
                return;
            }
            const { subFrameData } = event.data;
            subFrameData.subFrameDepth++;
            if (subFrameData.subFrameDepth >= MAX_SUB_FRAME_DEPTH) {
                void this.sendExtensionMessage("destroyAutofillInlineMenuListeners", { subFrameData });
                return;
            }
            let subFrameOffsets;
            const iframes = globalThis.document.querySelectorAll("iframe");
            for (let i = 0; i < iframes.length; i++) {
                if (iframes[i].contentWindow === event.source) {
                    const iframeElement = iframes[i];
                    subFrameOffsets = this.calculateSubFrameOffsets(iframeElement, undefined, subFrameData.frameId);
                    if (!subFrameOffsets) {
                        return;
                    }
                    subFrameData.top += subFrameOffsets.top;
                    subFrameData.left += subFrameOffsets.left;
                    const parentFrameId = yield this.sendExtensionMessage("getCurrentTabFrameId");
                    if (typeof parentFrameId !== "undefined") {
                        (_a = subFrameData.parentFrameIds) === null || _a === void 0 ? void 0 : _a.push(parentFrameId);
                    }
                    break;
                }
            }
            if (globalThis.window.self !== globalThis.window.top) {
                globalThis.parent.postMessage({ command: "calculateSubFramePositioning", subFrameData }, "*");
                return;
            }
            void this.sendExtensionMessage("updateSubFrameData", { subFrameData });
        });
        /**
         * Sets up global event listeners and the mutation
         * observer to facilitate required changes to the
         * overlay elements.
         */
        this.setupGlobalEventListeners = () => {
            globalThis.addEventListener(EVENTS.MESSAGE, this.handleWindowMessageEvent);
            globalThis.document.addEventListener(EVENTS.VISIBILITYCHANGE, this.handleVisibilityChangeEvent);
            globalThis.addEventListener(EVENTS.FOCUSOUT, this.handleWindowFocusOutEvent);
            this.setOverlayRepositionEventListeners();
        };
        /**
         * Handles window messages that are sent to the current frame. Will trigger a
         * calculation of the sub frame offsets through the parent frame.
         *
         * @param event - The message event.
         */
        this.handleWindowMessageEvent = (event) => {
            var _a;
            if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.command) === "calculateSubFramePositioning") {
                void this.calculateSubFramePositioning(event);
            }
        };
        /**
         * Handles the window focus out event, triggering a focus check on the
         * inline menu if the document has focus and a closure of the inline
         * menu if it does not have focus.
         */
        this.handleWindowFocusOutEvent = () => {
            if (document.hasFocus()) {
                this.handleFormFieldBlurEvent();
                return;
            }
            void this.sendExtensionMessage("closeAutofillInlineMenu", {
                forceCloseInlineMenu: true,
            });
        };
        /**
         * Handles the visibility change event. This method will remove the
         * autofill overlay if the document is not visible.
         */
        this.handleVisibilityChangeEvent = () => {
            if (globalThis.document.visibilityState === "hidden") {
                void this.sendExtensionMessage("closeAutofillInlineMenu", {
                    forceCloseInlineMenu: true,
                });
            }
            if (this.mostRecentlyFocusedField) {
                this.unsetMostRecentlyFocusedField();
            }
        };
        /**
         * Handles the resize or scroll events that enact
         * repositioning of existing overlay elements.
         */
        this.handleOverlayRepositionEvent = () => autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            yield this.sendExtensionMessage("triggerAutofillOverlayReposition");
        });
        /**
         * Sets up listeners that facilitate a rebuild of the sub frame offsets
         * when a user interacts or focuses an element within the frame.
         */
        this.setupRebuildSubFrameOffsetsListeners = () => {
            if (globalThis.window.top === globalThis.window || this.formFieldElements.size < 1) {
                return;
            }
            this.removeSubFrameFocusOutListeners();
            globalThis.addEventListener(EVENTS.FOCUS, this.handleSubFrameFocusInEvent);
            globalThis.document.body.addEventListener(EVENTS.MOUSEENTER, this.handleSubFrameFocusInEvent);
        };
        /**
         * Removes the listeners that facilitate a rebuild of the sub frame offsets.
         */
        this.removeRebuildSubFrameOffsetsListeners = () => {
            globalThis.removeEventListener(EVENTS.FOCUS, this.handleSubFrameFocusInEvent);
            globalThis.document.body.removeEventListener(EVENTS.MOUSEENTER, this.handleSubFrameFocusInEvent);
        };
        /**
         * Re-establishes listeners that handle the sub frame offsets rebuild of the frame
         * based on user interaction with the sub frame.
         */
        this.setupSubFrameFocusOutListeners = () => {
            globalThis.addEventListener(EVENTS.BLUR, this.setupRebuildSubFrameOffsetsListeners);
            globalThis.document.body.addEventListener(EVENTS.MOUSELEAVE, this.setupRebuildSubFrameOffsetsListeners);
        };
        /**
         * Removes the listeners that trigger when a user focuses away from the sub frame.
         */
        this.removeSubFrameFocusOutListeners = () => {
            globalThis.removeEventListener(EVENTS.BLUR, this.setupRebuildSubFrameOffsetsListeners);
            globalThis.document.body.removeEventListener(EVENTS.MOUSELEAVE, this.setupRebuildSubFrameOffsetsListeners);
        };
        /**
         * Sends a message to the background script to trigger a rebuild of the sub frame
         * offsets. Will deregister the listeners to ensure that other focus and mouse
         * events do not unnecessarily re-trigger a sub frame rebuild.
         */
        this.handleSubFrameFocusInEvent = () => {
            void this.sendExtensionMessage("triggerSubFrameFocusInRebuild");
            this.removeRebuildSubFrameOffsetsListeners();
            this.setupSubFrameFocusOutListeners();
        };
    }
    /**
     * Attaches the global event listeners that drive inline menu placement and
     * focus tracking. Defers attachment until DOMContentLoaded when the page
     * is still loading. Idempotent.
     */
    startMonitoring() {
        if (this.isMonitoring) {
            return;
        }
        this.isMonitoring = true;
        void this.getInlineMenuCardsVisibility();
        void this.getInlineMenuIdentitiesVisibility();
        if (globalThis.document.readyState === "loading") {
            globalThis.document.addEventListener(EVENTS.DOMCONTENTLOADED, this.setupGlobalEventListeners);
            return;
        }
        this.setupGlobalEventListeners();
    }
    /**
     * Detaches global and per-field event listeners, clears monitoring-scoped
     * timers and caches, and resets focus tracking so a future
     * `startMonitoring()` begins fresh. Idempotent.
     */
    stopMonitoring() {
        this.isMonitoring = false;
        globalThis.document.removeEventListener(EVENTS.DOMCONTENTLOADED, this.setupGlobalEventListeners);
        globalThis.removeEventListener(EVENTS.MESSAGE, this.handleWindowMessageEvent);
        globalThis.document.removeEventListener(EVENTS.VISIBILITYCHANGE, this.handleVisibilityChangeEvent);
        globalThis.removeEventListener(EVENTS.FOCUSOUT, this.handleWindowFocusOutEvent);
        this.removeOverlayRepositionEventListeners();
        this.removeRebuildSubFrameOffsetsListeners();
        this.removeSubFrameFocusOutListeners();
        this.formFieldElements.forEach((_autofillField, formFieldElement) => {
            this.removeCachedFormFieldEventListeners(formFieldElement);
            formFieldElement.removeEventListener(EVENTS.BLUR, this.handleFormFieldBlurEvent);
            formFieldElement.removeEventListener(EVENTS.KEYUP, this.handleFormFieldKeyupEventAsListener);
        });
        this.clearFocusInlineMenuListTimeout();
        this.clearCloseInlineMenuOnRedirectTimeout();
        // Clear caches so that message handlers that arrive while monitoring is stopped
        // short-circuit on empty state instead of walking stale data.
        this.formFieldElements.clear();
        this.formElements.clear();
        this.submitElements.clear();
        this.focusableElements = [];
        this.clearUserFilledFields();
        this.mostRecentlyFocusedField = null;
        this.focusedFieldData = null;
        this.pageDetailsUpdateRequired = false;
    }
    /**
     * Getter used to access the extension message handlers associated
     * with the autofill overlay content service.
     */
    get messageHandlers() {
        return this.extensionMessageHandlers;
    }
    /**
     * Sets up the autofill inline menu listener on the form field element. This method is called
     * during the page details collection process.
     *
     * @param formFieldElement - Form field elements identified during the page details collection process.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     * @param pageDetails - The collected page details from the tab.
     */
    setupOverlayListeners(formFieldElement, autofillFieldData, pageDetails) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (currentlyInSandboxedIframe() ||
                this.formFieldElements.has(formFieldElement) ||
                this.isIgnoredField(autofillFieldData, pageDetails)) {
                return;
            }
            if (this.isHiddenField(formFieldElement, autofillFieldData)) {
                return;
            }
            if (isReadonlyOrDisabledFormFieldElement(formFieldElement, autofillFieldData)) {
                return;
            }
            yield this.setupOverlayListenersOnQualifiedField(formFieldElement, autofillFieldData);
        });
    }
    /**
     * Removes focus from the most recently focused field element.
     */
    blurMostRecentlyFocusedField() {
        return autofill_overlay_content_service_awaiter(this, arguments, void 0, function* (isClosingInlineMenu = false) {
            var _a;
            (_a = this.mostRecentlyFocusedField) === null || _a === void 0 ? void 0 : _a.blur();
            if (isClosingInlineMenu) {
                yield this.sendExtensionMessage("closeAutofillInlineMenu", { forceCloseInlineMenu: true });
            }
        });
    }
    /**
     * Clears all cached user filled fields.
     */
    clearUserFilledFields() {
        if (!this.userFilledFields) {
            return;
        }
        this.userFilledFields = {};
    }
    /**
     * Formats any found user filled fields for a login cipher and sends a message
     * to the background script to add a new cipher.
     */
    addNewVaultItem(_a) {
        return autofill_overlay_content_service_awaiter(this, arguments, void 0, function* ({ addNewCipherType }) {
            var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
            const command = "autofillOverlayAddNewVaultItem";
            const password = ((_c = (_b = this.userFilledFields) === null || _b === void 0 ? void 0 : _b["newPassword"]) === null || _c === void 0 ? void 0 : _c.value) || ((_e = (_d = this.userFilledFields) === null || _d === void 0 ? void 0 : _d["password"]) === null || _e === void 0 ? void 0 : _e.value);
            if (addNewCipherType === CipherType.Login) {
                const login = {
                    username: ((_g = (_f = this.userFilledFields) === null || _f === void 0 ? void 0 : _f["username"]) === null || _g === void 0 ? void 0 : _g.value) || "",
                    password: password || "",
                    uri: globalThis.document.URL,
                    hostname: globalThis.document.location.hostname,
                };
                yield this.sendExtensionMessage(command, { addNewCipherType, login });
                return;
            }
            if (addNewCipherType === CipherType.Card) {
                const card = {
                    cardholderName: ((_j = (_h = this.userFilledFields) === null || _h === void 0 ? void 0 : _h["cardholderName"]) === null || _j === void 0 ? void 0 : _j.value) || "",
                    number: ((_l = (_k = this.userFilledFields) === null || _k === void 0 ? void 0 : _k["cardNumber"]) === null || _l === void 0 ? void 0 : _l.value) || "",
                    expirationMonth: ((_o = (_m = this.userFilledFields) === null || _m === void 0 ? void 0 : _m["cardExpirationMonth"]) === null || _o === void 0 ? void 0 : _o.value) || "",
                    expirationYear: ((_q = (_p = this.userFilledFields) === null || _p === void 0 ? void 0 : _p["cardExpirationYear"]) === null || _q === void 0 ? void 0 : _q.value) || "",
                    expirationDate: ((_s = (_r = this.userFilledFields) === null || _r === void 0 ? void 0 : _r["cardExpirationDate"]) === null || _s === void 0 ? void 0 : _s.value) || "",
                    cvv: ((_u = (_t = this.userFilledFields) === null || _t === void 0 ? void 0 : _t["cardCvv"]) === null || _u === void 0 ? void 0 : _u.value) || "",
                };
                yield this.sendExtensionMessage(command, { addNewCipherType, card });
                return;
            }
            if (addNewCipherType === CipherType.Identity) {
                const identity = {
                    title: ((_w = (_v = this.userFilledFields) === null || _v === void 0 ? void 0 : _v["identityTitle"]) === null || _w === void 0 ? void 0 : _w.value) || "",
                    firstName: ((_y = (_x = this.userFilledFields) === null || _x === void 0 ? void 0 : _x["identityFirstName"]) === null || _y === void 0 ? void 0 : _y.value) || "",
                    middleName: ((_0 = (_z = this.userFilledFields) === null || _z === void 0 ? void 0 : _z["identityMiddleName"]) === null || _0 === void 0 ? void 0 : _0.value) || "",
                    lastName: ((_2 = (_1 = this.userFilledFields) === null || _1 === void 0 ? void 0 : _1["identityLastName"]) === null || _2 === void 0 ? void 0 : _2.value) || "",
                    fullName: ((_4 = (_3 = this.userFilledFields) === null || _3 === void 0 ? void 0 : _3["identityFullName"]) === null || _4 === void 0 ? void 0 : _4.value) || "",
                    address1: ((_6 = (_5 = this.userFilledFields) === null || _5 === void 0 ? void 0 : _5["identityAddress1"]) === null || _6 === void 0 ? void 0 : _6.value) || "",
                    address2: ((_8 = (_7 = this.userFilledFields) === null || _7 === void 0 ? void 0 : _7["identityAddress2"]) === null || _8 === void 0 ? void 0 : _8.value) || "",
                    address3: ((_10 = (_9 = this.userFilledFields) === null || _9 === void 0 ? void 0 : _9["identityAddress3"]) === null || _10 === void 0 ? void 0 : _10.value) || "",
                    city: ((_12 = (_11 = this.userFilledFields) === null || _11 === void 0 ? void 0 : _11["identityCity"]) === null || _12 === void 0 ? void 0 : _12.value) || "",
                    state: ((_14 = (_13 = this.userFilledFields) === null || _13 === void 0 ? void 0 : _13["identityState"]) === null || _14 === void 0 ? void 0 : _14.value) || "",
                    postalCode: ((_16 = (_15 = this.userFilledFields) === null || _15 === void 0 ? void 0 : _15["identityPostalCode"]) === null || _16 === void 0 ? void 0 : _16.value) || "",
                    country: ((_18 = (_17 = this.userFilledFields) === null || _17 === void 0 ? void 0 : _17["identityCountry"]) === null || _18 === void 0 ? void 0 : _18.value) || "",
                    company: ((_20 = (_19 = this.userFilledFields) === null || _19 === void 0 ? void 0 : _19["identityCompany"]) === null || _20 === void 0 ? void 0 : _20.value) || "",
                    phone: ((_22 = (_21 = this.userFilledFields) === null || _21 === void 0 ? void 0 : _21["identityPhone"]) === null || _22 === void 0 ? void 0 : _22.value) || "",
                    email: ((_24 = (_23 = this.userFilledFields) === null || _23 === void 0 ? void 0 : _23["identityEmail"]) === null || _24 === void 0 ? void 0 : _24.value) || "",
                    username: ((_26 = (_25 = this.userFilledFields) === null || _25 === void 0 ? void 0 : _25["identityUsername"]) === null || _26 === void 0 ? void 0 : _26.value) || "",
                };
                yield this.sendExtensionMessage(command, { addNewCipherType, identity });
            }
        });
    }
    /**
     * Focuses the most recently focused field element.
     */
    focusMostRecentlyFocusedField() {
        var _a;
        (_a = this.mostRecentlyFocusedField) === null || _a === void 0 ? void 0 : _a.focus();
    }
    /**
     * Sets the most recently focused field within the current frame to a `null` value.
     */
    unsetMostRecentlyFocusedField() {
        this.mostRecentlyFocusedField = null;
    }
    /**
     * Redirects the keyboard focus out of the inline menu, selecting the element that is
     * either previous or next in the tab order. If the direction is current, the most
     * recently focused field will be focused.
     *
     * @param direction - The direction to redirect the focus out.
     */
    redirectInlineMenuFocusOut(direction) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (!direction || !this.mostRecentlyFocusedField || !(yield this.isInlineMenuListVisible())) {
                return;
            }
            if (direction === RedirectFocusDirection.Current) {
                this.focusMostRecentlyFocusedField();
                this.closeInlineMenuOnRedirectTimeout = globalThis.setTimeout(() => void this.sendExtensionMessage("closeAutofillInlineMenu"), 100);
                return;
            }
            if (!this.focusableElements.length) {
                this.focusableElements = this.findTabs(globalThis.document.body, { getShadowRoot: true });
            }
            const focusedElementIndex = this.focusableElements.findIndex((element) => element === this.mostRecentlyFocusedField);
            const indexOffset = direction === RedirectFocusDirection.Previous ? -1 : 1;
            const redirectFocusElement = this.focusableElements[focusedElementIndex + indexOffset];
            if (redirectFocusElement) {
                redirectFocusElement.focus();
                return;
            }
            this.focusMostRecentlyFocusedField();
        });
    }
    /**
     * Sets up the event listeners that facilitate interaction with the form field elements.
     * Will clear any cached form field element handlers that are encountered when setting
     * up a form field element.
     *
     * @param formFieldElement - The form field element to set up the event listeners for.
     */
    setupFormFieldElementEventListeners(formFieldElement) {
        this.removeCachedFormFieldEventListeners(formFieldElement);
        formFieldElement.addEventListener(EVENTS.INPUT, this.handleFormFieldInputEvent(formFieldElement));
        formFieldElement.addEventListener(EVENTS.FOCUS, this.handleFormFieldFocusEvent(formFieldElement));
        if (elementIsSelectElement(formFieldElement)) {
            return;
        }
        formFieldElement.addEventListener(EVENTS.BLUR, this.handleFormFieldBlurEvent);
        formFieldElement.addEventListener(EVENTS.KEYUP, this.handleFormFieldKeyupEventAsListener);
        formFieldElement.addEventListener(EVENTS.CLICK, this.handleFormFieldClickEvent(formFieldElement));
    }
    /**
     * Removes any cached form field element handlers that are encountered
     * when setting up a form field element to present the inline menu.
     *
     * @param formFieldElement - The form field element to remove the cached handlers for.
     */
    removeCachedFormFieldEventListeners(formFieldElement) {
        const handlers = [EVENTS.INPUT, EVENTS.CLICK, EVENTS.FOCUS];
        for (let index = 0; index < handlers.length; index++) {
            const event = handlers[index];
            const memoIndex = this.getFormFieldHandlerMemoIndex(formFieldElement, event);
            const existingHandler = this.eventHandlersMemo[memoIndex];
            if (!existingHandler) {
                return;
            }
            formFieldElement.removeEventListener(event, existingHandler);
            delete this.eventHandlersMemo[memoIndex];
        }
    }
    /**
     * Sets up listeners on the submit button that triggers a submission of the field's form.
     *
     * @param formFieldElement - The form field element to set up the submit button listeners for.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    setupFormSubmissionEventListeners(formFieldElement, autofillFieldData) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (!elementIsFillableFormField(formFieldElement) ||
                autofillFieldData.inlineMenuFillType === CipherType.Card) {
                return;
            }
            if (autofillFieldData.form) {
                yield this.setupSubmitListenerOnFieldWithForms(formFieldElement);
                return;
            }
            yield this.setupSubmitListenerOnFormlessField(formFieldElement);
            return;
        });
    }
    /**
     * Sets up the submit listener on the form field element that contains a form element.
     * Will establish on submit event listeners on the form element and click listeners on
     * the submit button element that triggers the submission of the form.
     *
     * @param formFieldElement - The form field element to set up the submit listener for.
     */
    setupSubmitListenerOnFieldWithForms(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const formElement = formFieldElement.form;
            if (formElement && !this.formElements.has(formElement)) {
                this.formElements.add(formElement);
                formElement.addEventListener(EVENTS.SUBMIT, this.handleFormFieldSubmitEvent);
                const closestSubmitButton = yield this.findSubmitButton(formElement);
                // If we cannot find a submit button within the form, check for a submit button outside the form.
                if (!closestSubmitButton) {
                    yield this.setupSubmitListenerOnFormlessField(formFieldElement);
                    return;
                }
                this.setupSubmitButtonEventListeners(closestSubmitButton);
                return;
            }
        });
    }
    /**
     * Sets up the submit listener on the form field element that does not contain a form element.
     * Will establish a submit button event listener on the closest formless submit button element.
     *
     * @param formFieldElement - The form field element to set up the submit listener for.
     */
    setupSubmitListenerOnFormlessField(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (formFieldElement && !this.fieldsWithSubmitElements.has(formFieldElement)) {
                const closestSubmitButton = yield this.findClosestFormlessSubmitButton(formFieldElement);
                if (closestSubmitButton) {
                    this.setupSubmitButtonEventListeners(closestSubmitButton);
                }
            }
            return;
        });
    }
    /**
     * Finds the closest formless submit button element to the form field element.
     *
     * @param formFieldElement - The form field element to find the closest formless submit button for.
     */
    findClosestFormlessSubmitButton(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            let currentElement = formFieldElement;
            while (currentElement && currentElement.tagName !== "HTML") {
                const element = currentElement;
                const submitButton = yield this.findSubmitButton(element);
                if (submitButton) {
                    this.formFieldElements.forEach((_, fieldElement) => {
                        if (element.contains(fieldElement)) {
                            this.fieldsWithSubmitElements.set(fieldElement, submitButton);
                        }
                    });
                    return submitButton;
                }
                if (!element.parentElement && element.getRootNode() instanceof ShadowRoot) {
                    currentElement = element.getRootNode().host;
                    continue;
                }
                currentElement = element.parentElement;
            }
            return null;
        });
    }
    /**
     * Finds the submit button element within the provided element. Will attempt to find a generic
     * submit element before attempting to find a button or button-like element.
     *
     * @param element - The element to find the submit button within.
     */
    findSubmitButton(element) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const genericSubmitElement = yield this.querySubmitButtonElement(element, "[type='submit']", (node) => nodeIsTypeSubmitElement(node));
            if (genericSubmitElement) {
                return genericSubmitElement;
            }
            const submitButtonElement = yield this.querySubmitButtonElement(element, "button, [type='button']", (node) => nodeIsButtonElement(node));
            if (submitButtonElement) {
                return submitButtonElement;
            }
            // If the submit button is not a traditional button element, check for an anchor element that contains submission keywords.
            const submitAnchorElement = yield this.querySubmitButtonElement(element, "a", (node) => nodeIsAnchorElement(node));
            if (submitAnchorElement) {
                return submitAnchorElement;
            }
            return null;
        });
    }
    /**
     * Queries the provided element for a submit button element using the provided selector.
     *
     * @param element - The element to query for a submit button.
     * @param selector - The selector to use to query the element for a submit button.
     * @param treeWalkerFilter - The tree walker filter to use when querying the element.
     */
    querySubmitButtonElement(element, selector, treeWalkerFilter) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const submitButtonElements = this.domQueryService.query(element, selector, treeWalkerFilter);
            for (let index = 0; index < submitButtonElements.length; index++) {
                const submitElement = submitButtonElements[index];
                if (this.isElementSubmitButton(submitElement) &&
                    (yield this.domElementVisibilityService.isElementViewable(submitElement))) {
                    return submitElement;
                }
            }
        });
    }
    /**
     * Determines if the provided element is a submit button element.
     *
     * @param element - The element to determine if it is a submit button.
     */
    isElementSubmitButton(element) {
        return (this.inlineMenuFieldQualificationService.isElementLoginSubmitButton(element) ||
            this.inlineMenuFieldQualificationService.isElementChangePasswordSubmitButton(element));
    }
    /**
     * Formats the memoIndex for the form field event handler.
     *
     * @param formFieldElement - The form field element to format the memo index for.
     * @param event - The event to format the memo index for.
     */
    getFormFieldHandlerMemoIndex(formFieldElement, event) {
        return `${formFieldElement.opid}-${formFieldElement.id}-${event}-handler`;
    }
    /**
     * Triggers a focus of the inline menu list, if it is visible. If the list is not visible,
     * the inline menu will be opened and the list will be focused after a short delay. Ensures
     * that the inline menu list is focused when the user presses the down arrow key.
     */
    focusInlineMenuList() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (this.mostRecentlyFocusedField && !(yield this.isInlineMenuListVisible())) {
                if (isReadonlyOrDisabledFormFieldElement(this.mostRecentlyFocusedField)) {
                    return;
                }
                this.clearFocusInlineMenuListTimeout();
                yield this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
                yield this.sendExtensionMessage("openAutofillInlineMenu", { isOpeningFullInlineMenu: true });
                this.focusInlineMenuListTimeout = globalThis.setTimeout(() => this.sendExtensionMessage("focusAutofillInlineMenuList"), 125);
                return;
            }
            void this.sendExtensionMessage("focusAutofillInlineMenuList");
        });
    }
    /**
     * Triggers when the form field element receives an input event. This method will
     * store the modified form element data for use when the user attempts to add a new
     * vault item. It also acts to remove the inline menu list while the user is typing.
     *
     * @param formFieldElement - The form field element that triggered the input event.
     */
    triggerFormFieldInput(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (!elementIsFillableFormField(formFieldElement)) {
                return;
            }
            if (isReadonlyOrDisabledFormFieldElement(formFieldElement)) {
                return;
            }
            this.storeModifiedFormElement(formFieldElement);
            if (elementIsSelectElement(formFieldElement)) {
                return;
            }
            yield this.sendExtensionMessage("closeAutofillInlineMenu", {
                overlayElement: AutofillOverlayElement.List,
                forceCloseInlineMenu: true,
            });
            if (!(formFieldElement === null || formFieldElement === void 0 ? void 0 : formFieldElement.value)) {
                yield this.sendExtensionMessage("openAutofillInlineMenu");
            }
        });
    }
    /**
     * Stores the modified form element data for use when the user attempts to add a new
     * vault item. This method will also store the most recently focused field, if it is
     * not already stored.
     *
     * @param formFieldElement
     * @private
     */
    storeModifiedFormElement(formFieldElement) {
        if (formFieldElement !== this.mostRecentlyFocusedField) {
            void this.updateMostRecentlyFocusedField(formFieldElement);
        }
        const autofillFieldData = this.formFieldElements.get(formFieldElement);
        if (!autofillFieldData) {
            return;
        }
        if (!autofillFieldData.fieldQualifier) {
            switch (autofillFieldData.inlineMenuFillType) {
                case CipherType.Login:
                case InlineMenuFillTypes.CurrentPasswordUpdate:
                    this.qualifyUserFilledField(autofillFieldData, this.loginFieldQualifiers);
                    break;
                case InlineMenuFillTypes.AccountCreationUsername:
                case InlineMenuFillTypes.PasswordGeneration:
                    this.qualifyUserFilledField(autofillFieldData, this.accountCreationFieldQualifiers);
                    break;
                case CipherType.Card:
                    this.qualifyUserFilledField(autofillFieldData, this.cardFieldQualifiers);
                    break;
                case CipherType.Identity:
                    this.qualifyUserFilledField(autofillFieldData, this.identityFieldQualifiers);
                    break;
            }
        }
        this.storeQualifiedUserFilledField(formFieldElement, autofillFieldData);
    }
    /**
     * Stores the qualified user filled filed to allow for referencing its value when adding a new vault item.
     *
     * @param formFieldElement - The form field element that triggered the input event.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    storeQualifiedUserFilledField(formFieldElement, autofillFieldData) {
        if (!autofillFieldData.fieldQualifier) {
            return;
        }
        const clonedNode = formFieldElement.cloneNode(true);
        // Identifier fields that double as the login username when saving a login.
        // Heuristic (identity) and targeting-rule (email/phone) qualifiers both flow
        // through here, so both namespaces are listed; targeting `username` already
        // stores directly under the username key below.
        const identityLoginFields = [
            AutofillFieldQualifier.identityUsername,
            AutofillFieldQualifier.identityEmail,
            AutofillFieldQualifier.identityPhone,
            AutofillTargetingRuleTypes.email,
            AutofillTargetingRuleTypes.phone,
        ];
        if (!this.userFilledFields) {
            return;
        }
        if (identityLoginFields.includes(autofillFieldData.fieldQualifier)) {
            this.userFilledFields[AutofillFieldQualifier.username] = clonedNode;
        }
        this.userFilledFields[autofillFieldData.fieldQualifier] = clonedNode;
    }
    /**
     * Triggers when the form field element receives a click event. This method will
     * trigger the focused action for the form field element if the inline menu is not visible.
     *
     * @param formFieldElement - The form field element that triggered the click event.
     */
    triggerFormFieldClickedAction(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (isReadonlyOrDisabledFormFieldElement(formFieldElement)) {
                return;
            }
            if ((yield this.isInlineMenuButtonVisible()) || (yield this.isInlineMenuListVisible())) {
                return;
            }
            yield this.triggerFormFieldFocusedAction(formFieldElement);
        });
    }
    /**
     * Triggers when the form field element receives a focus event. This method will
     * update the most recently focused field and open the autofill inline menu if the
     * autofill process is not currently active.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     */
    triggerFormFieldFocusedAction(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (yield this.isFieldCurrentlyFilling()) {
                return;
            }
            if (isReadonlyOrDisabledFormFieldElement(formFieldElement)) {
                return;
            }
            if (this.pageDetailsUpdateRequired) {
                yield this.sendExtensionMessage("bgCollectPageDetails", {
                    sender: "autofillOverlayContentService",
                });
                this.pageDetailsUpdateRequired = false;
            }
            if (elementIsSelectElement(formFieldElement)) {
                yield this.sendExtensionMessage("closeAutofillInlineMenu", {
                    forceCloseInlineMenu: true,
                });
                return;
            }
            yield this.updateIsFieldCurrentlyFocused(true);
            yield this.updateMostRecentlyFocusedField(formFieldElement);
            yield this.sendExtensionMessage("openAutofillInlineMenu");
        });
    }
    /**
     * Updates the data used to position the inline menu elements in relation
     * to the most recently focused form field.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     */
    updateMostRecentlyFocusedField(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (!formFieldElement ||
                !elementIsFillableFormField(formFieldElement) ||
                elementIsSelectElement(formFieldElement)) {
                return;
            }
            this.mostRecentlyFocusedField = formFieldElement;
            const { paddingRight, paddingLeft } = globalThis.getComputedStyle(formFieldElement);
            const { width, height, top, left } = yield this.getMostRecentlyFocusedFieldRects(formFieldElement);
            const autofillFieldData = this.formFieldElements.get(formFieldElement);
            this.focusedFieldData = {
                focusedFieldStyles: { paddingRight, paddingLeft },
                focusedFieldRects: { width, height, top, left },
                inlineMenuFillType: autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.inlineMenuFillType,
                showPasskeys: !!(autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.showPasskeys),
                accountCreationFieldType: autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.accountCreationFieldType,
                focusedFieldForm: (_a = autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.form) !== null && _a !== void 0 ? _a : undefined,
                focusedFieldOpid: autofillFieldData === null || autofillFieldData === void 0 ? void 0 : autofillFieldData.opid,
            };
            const allFields = this.formFieldElements;
            const allFieldsRect = [];
            for (const key of allFields.keys()) {
                const rect = yield this.getMostRecentlyFocusedFieldRects(key);
                allFieldsRect.push(Object.assign(Object.assign({}, allFields.get(key)), { rect })); // Add the combined result to the array
            }
            yield this.sendExtensionMessage("updateFocusedFieldData", {
                focusedFieldData: this.focusedFieldData,
                allFieldsRect,
            });
        });
    }
    /**
     * Gets the bounding client rects for the most recently focused field. This method will
     * attempt to use an intersection observer to get the most recently focused field's
     * bounding client rects. If the intersection observer is not supported, or the
     * intersection observer does not return a valid bounding client rect, the form
     * field element's bounding client rect will be used.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     */
    getMostRecentlyFocusedFieldRects(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const focusedFieldRects = yield this.getBoundingClientRectFromIntersectionObserver(formFieldElement);
            if (focusedFieldRects) {
                return focusedFieldRects;
            }
            return formFieldElement.getBoundingClientRect();
        });
    }
    /**
     * Gets the bounds of the form field element from the IntersectionObserver API.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     */
    getBoundingClientRectFromIntersectionObserver(formFieldElement) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            if (!("IntersectionObserver" in globalThis) && !("IntersectionObserverEntry" in globalThis)) {
                return null;
            }
            return new Promise((resolve) => {
                const intersectionObserver = new IntersectionObserver((entries) => {
                    var _a, _b;
                    let fieldBoundingClientRects = (_b = (_a = entries[0]) === null || _a === void 0 ? void 0 : _a.boundingClientRect) !== null && _b !== void 0 ? _b : null;
                    if (fieldBoundingClientRects &&
                        (!fieldBoundingClientRects.width || !fieldBoundingClientRects.height)) {
                        fieldBoundingClientRects = null;
                    }
                    intersectionObserver.disconnect();
                    resolve(fieldBoundingClientRects);
                }, {
                    root: globalThis.document.body,
                    rootMargin: "0px",
                    threshold: 0.9999, // Safari doesn't seem to function properly with a threshold of 1
                });
                intersectionObserver.observe(formFieldElement);
            });
        });
    }
    /**
     * Identifies if the field should have the autofill inline menu setup on it. Currently, this is mainly
     * determined by whether the field correlates with a login cipher. This method will need to be
     * updated in the future to support other types of forms.
     *
     * @param autofillFieldData - Autofill field data captured from the form field element.
     * @param pageDetails - The collected page details from the tab.
     */
    isIgnoredField(autofillFieldData, pageDetails) {
        /**
         * This check comes first because a targeting rule is an
         * authoritative override for subsequent checks
         */
        if (autofillFieldData.targeted) {
            this.setTargetedFieldFillType(autofillFieldData);
            return false;
        }
        if (autofillFieldData.type != null && this.ignoredFieldTypes.has(autofillFieldData.type)) {
            return true;
        }
        if (this.inlineMenuFieldQualificationService.isFieldForLoginForm(autofillFieldData, pageDetails)) {
            void this.setQualifiedLoginFillType(autofillFieldData);
            return false;
        }
        if (this.showInlineMenuCards &&
            this.inlineMenuFieldQualificationService.isFieldForCreditCardForm(autofillFieldData, pageDetails)) {
            autofillFieldData.inlineMenuFillType = CipherType.Card;
            return false;
        }
        if (this.inlineMenuFieldQualificationService.isFieldForAccountCreationForm(autofillFieldData, pageDetails)) {
            this.setQualifiedAccountCreationFillType(autofillFieldData);
            return false;
        }
        if (this.showInlineMenuIdentities &&
            this.inlineMenuFieldQualificationService.isFieldForIdentityForm(autofillFieldData, pageDetails)) {
            autofillFieldData.inlineMenuFillType = CipherType.Identity;
            return false;
        }
        return true;
    }
    /**
     * Maps a targeted field's qualifier to the correct inline menu fill type,
     * bypassing heuristic qualification.
     */
    setTargetedFieldFillType(autofillFieldData) {
        // Targeted fields use AutofillTargetingRuleType values in fieldQualifier,
        // which are distinct from the heuristic AutofillFieldQualifierType values.
        const qualifier = autofillFieldData.fieldQualifier;
        if (qualifier === AutofillTargetingRuleTypes.newPassword) {
            autofillFieldData.inlineMenuFillType = InlineMenuFillTypes.PasswordGeneration;
            return;
        }
        // The form category is authoritative for single-cipher-type forms, so it
        // takes precedence over inferring the cipher type from the individual field
        // qualifier. This is what routes an account-login form's email/phone field
        // to Login rather than Identity. Categories needing qualifier-level fill
        // sub-types fall through to the qualifier checks below.
        const categoryFillType = autofillFieldData.formCategory != null
            ? targetedFormCategoryFillTypes[autofillFieldData.formCategory]
            : undefined;
        if (categoryFillType != null) {
            autofillFieldData.inlineMenuFillType = categoryFillType;
            return;
        }
        if (loginQualifiers.includes(qualifier)) {
            autofillFieldData.inlineMenuFillType = CipherType.Login;
            return;
        }
        if (cardQualifiers.includes(qualifier)) {
            autofillFieldData.inlineMenuFillType = CipherType.Card;
            return;
        }
        if (identityQualifiers.includes(qualifier)) {
            autofillFieldData.inlineMenuFillType = CipherType.Identity;
            return;
        }
        // Fallback: default to Login to avoid inline menu re-render churn that
        // occurs when `inlineMenuFillType` is left undefined.
        autofillFieldData.inlineMenuFillType = CipherType.Login;
    }
    /**
     * Sets the autofill field data that indicates this field is part of a login form
     *
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    setQualifiedLoginFillType(autofillFieldData) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            // Check if this is a current password field in a password change form
            if (this.inlineMenuFieldQualificationService.isUpdateCurrentPasswordField(autofillFieldData)) {
                autofillFieldData.inlineMenuFillType = InlineMenuFillTypes.CurrentPasswordUpdate;
                return;
            }
            autofillFieldData.inlineMenuFillType = CipherType.Login;
            autofillFieldData.showPasskeys = (autofillFieldData.autoCompleteType || []).includes("webauthn");
            if (this.inlineMenuFieldQualificationService.hasCurrentPasswordAutocomplete(autofillFieldData)) {
                return;
            }
            this.qualifyAccountCreationFieldType(autofillFieldData);
        });
    }
    /**
     * Sets the autofill field data that indicates this field is part of an account creation or update form.
     *
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    setQualifiedAccountCreationFillType(autofillFieldData) {
        if (this.inlineMenuFieldQualificationService.isNewPasswordField(autofillFieldData)) {
            autofillFieldData.inlineMenuFillType = InlineMenuFillTypes.PasswordGeneration;
            this.qualifyAccountCreationFieldType(autofillFieldData);
            return;
        }
        if (this.inlineMenuFieldQualificationService.isUpdateCurrentPasswordField(autofillFieldData)) {
            autofillFieldData.inlineMenuFillType = InlineMenuFillTypes.CurrentPasswordUpdate;
            return;
        }
        if (this.inlineMenuFieldQualificationService.isUsernameField(autofillFieldData)) {
            autofillFieldData.inlineMenuFillType = InlineMenuFillTypes.AccountCreationUsername;
            this.qualifyAccountCreationFieldType(autofillFieldData);
        }
    }
    /**
     * Sets the account creation field type for the autofill field data based on the field's attributes.
     *
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    qualifyAccountCreationFieldType(autofillFieldData) {
        if (this.inlineMenuFieldQualificationService.isTotpField(autofillFieldData)) {
            autofillFieldData.accountCreationFieldType = InlineMenuAccountCreationFieldType.Totp;
            return;
        }
        if (!this.inlineMenuFieldQualificationService.isUsernameField(autofillFieldData)) {
            autofillFieldData.accountCreationFieldType = InlineMenuAccountCreationFieldType.Password;
            return;
        }
        if (!this.showInlineMenuIdentities) {
            return;
        }
        if (this.inlineMenuFieldQualificationService.isEmailField(autofillFieldData)) {
            autofillFieldData.accountCreationFieldType = InlineMenuAccountCreationFieldType.Email;
            return;
        }
        autofillFieldData.accountCreationFieldType = InlineMenuAccountCreationFieldType.Text;
    }
    /**
     * Validates whether a field is considered to be "hidden" based on the field's attributes.
     * If the field is hidden, a fallback listener will be set up to ensure that the
     * field will have the inline menu set up on it when it becomes visible.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    isHiddenField(formFieldElement, autofillFieldData) {
        if (!autofillFieldData.readonly && !autofillFieldData.disabled && autofillFieldData.viewable) {
            this.removeHiddenFieldFallbackListener(formFieldElement);
            return false;
        }
        this.setupHiddenFieldFallbackListener(formFieldElement, autofillFieldData);
        return true;
    }
    /**
     * Sets up a fallback listener that will facilitate setting up the
     * inline menu on the field when it becomes visible and focused.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    setupHiddenFieldFallbackListener(formFieldElement, autofillFieldData) {
        this.hiddenFormFieldElements.set(formFieldElement, autofillFieldData);
        formFieldElement.addEventListener(EVENTS.FOCUS, this.handleHiddenFieldFocusEventAsListener);
        formFieldElement.addEventListener(EVENTS.INPUT, this.handleHiddenFieldInputEventAsListener);
    }
    /**
     * Removes the fallback listener that facilitates setting up the inline
     *  menu on the field when it becomes visible and focused.
     *
     * @param formFieldElement - The form field element that triggered the focus event.
     */
    removeHiddenFieldFallbackListener(formFieldElement) {
        formFieldElement.removeEventListener(EVENTS.FOCUS, this.handleHiddenFieldFocusEventAsListener);
        formFieldElement.removeEventListener(EVENTS.INPUT, this.handleHiddenFieldInputEventAsListener);
        this.hiddenFormFieldElements.delete(formFieldElement);
    }
    /**
     * Sets up the inline menu on a qualified form field element.
     *
     * @param formFieldElement - The form field element to set up the inline menu on.
     * @param autofillFieldData - Autofill field data captured from the form field element.
     */
    setupOverlayListenersOnQualifiedField(formFieldElement, autofillFieldData) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            this.formFieldElements.set(formFieldElement, autofillFieldData);
            if (elementIsFillableFormField(formFieldElement) && !!formFieldElement.value) {
                this.storeModifiedFormElement(formFieldElement);
            }
            this.setupFormFieldElementEventListeners(formFieldElement);
            yield this.setupFormSubmissionEventListeners(formFieldElement, autofillFieldData);
            if (globalThis.document.hasFocus() &&
                this.getRootNodeActiveElement(formFieldElement) === formFieldElement) {
                yield this.triggerFormFieldFocusedAction(formFieldElement);
            }
        });
    }
    /**
     * Queries the background script for the autofill inline menu's Cards visibility setting.
     * If the setting is not found, a default value of true will be used
     * @private
     */
    getInlineMenuCardsVisibility() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const inlineMenuCardsVisibility = yield this.sendExtensionMessage("getInlineMenuCardsVisibility");
            this.showInlineMenuCards = inlineMenuCardsVisibility !== null && inlineMenuCardsVisibility !== void 0 ? inlineMenuCardsVisibility : true;
        });
    }
    /**
     * Queries the background script for the autofill inline menu's Identities visibility setting.
     * If the setting is not found, a default value of true will be used
     * @private
     */
    getInlineMenuIdentitiesVisibility() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const inlineMenuIdentitiesVisibility = yield this.sendExtensionMessage("getInlineMenuIdentitiesVisibility");
            this.showInlineMenuIdentities = inlineMenuIdentitiesVisibility !== null && inlineMenuIdentitiesVisibility !== void 0 ? inlineMenuIdentitiesVisibility : true;
        });
    }
    /**
     * Indicates whether the most recently focused field has a value.
     */
    mostRecentlyFocusedFieldHasValue() {
        var _a;
        return Boolean((_a = this.mostRecentlyFocusedField) === null || _a === void 0 ? void 0 : _a.value);
    }
    /**
     * Checks if a field is currently filling within an frame in the tab.
     */
    isFieldCurrentlyFilling() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.sendExtensionMessage("checkIsFieldCurrentlyFilling")) === true;
        });
    }
    /**
     * Checks if the inline menu button is visible at the top frame.
     */
    isInlineMenuButtonVisible() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.sendExtensionMessage("checkIsAutofillInlineMenuButtonVisible")) === true;
        });
    }
    /**
     * Checks if the inline menu list if visible at the top frame.
     */
    isInlineMenuListVisible() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.sendExtensionMessage("checkIsAutofillInlineMenuListVisible")) === true;
        });
    }
    /**
     * Checks if the field is currently focused within the top frame.
     */
    isFieldCurrentlyFocused() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            return (yield this.sendExtensionMessage("checkIsFieldCurrentlyFocused")) === true;
        });
    }
    /**
     * Gets the root node of the passed element and returns the active element within that root node.
     *
     * @param element - The element to get the root node active element for.
     */
    getRootNodeActiveElement(element) {
        if (!element) {
            return null;
        }
        const documentRoot = element.getRootNode();
        return documentRoot === null || documentRoot === void 0 ? void 0 : documentRoot.activeElement;
    }
    /**
     * Queries all iframe elements within the document and returns the
     * sub frame offsets for each iframe element.
     *
     * @param message - The message object from the extension.
     */
    getSubFrameOffsets(message) {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            const { subFrameUrl } = message;
            const subFrameUrlVariations = subFrameUrl && getSubFrameUrlVariations(subFrameUrl);
            if (!subFrameUrlVariations) {
                return null;
            }
            let iframeElement = null;
            const iframeElements = globalThis.document.getElementsByTagName("iframe");
            for (let iframeIndex = 0; iframeIndex < iframeElements.length; iframeIndex++) {
                const iframe = iframeElements[iframeIndex];
                if (!subFrameUrlVariations.has(iframe.src)) {
                    continue;
                }
                if (iframeElement) {
                    return null;
                }
                iframeElement = iframe;
            }
            if (!iframeElement) {
                return null;
            }
            return this.calculateSubFrameOffsets(iframeElement, subFrameUrl);
        });
    }
    /**
     * Posts a message to the parent frame to calculate the sub frame offset of the current frame.
     *
     * @param message - The message object from the extension.
     */
    getSubFrameOffsetsFromWindowMessage(message) {
        // `postMessage` accepts `any` message, which disables typechecking, so typecheck it early
        const subFrameData = {
            frameId: message.subFrameId,
            left: 0,
            top: 0,
            parentFrameIds: [0],
            subFrameDepth: 0,
        };
        globalThis.parent.postMessage({
            command: "calculateSubFramePositioning",
            subFrameData,
        }, "*");
    }
    /**
     * Calculates the bounding rect for the queried frame and returns the
     * offset data for the sub frame.
     *
     * @param iframeElement - The iframe element to calculate the sub frame offsets for.
     * @param subFrameUrl - The URL of the sub frame.
     * @param frameId - The frame ID of the sub frame.
     */
    calculateSubFrameOffsets(iframeElement, subFrameUrl, frameId) {
        const iframeRect = iframeElement.getBoundingClientRect();
        const iframeRectHasSize = iframeRect.width > 0 && iframeRect.height > 0;
        const iframeStyles = globalThis.getComputedStyle(iframeElement);
        const paddingLeft = parseInt(iframeStyles.getPropertyValue("padding-left")) || 0;
        const paddingTop = parseInt(iframeStyles.getPropertyValue("padding-top")) || 0;
        const borderWidthLeft = parseInt(iframeStyles.getPropertyValue("border-left-width")) || 0;
        const borderWidthTop = parseInt(iframeStyles.getPropertyValue("border-top-width")) || 0;
        if (!iframeRect || !iframeRectHasSize || !iframeElement.isConnected) {
            return null;
        }
        return {
            url: subFrameUrl,
            frameId,
            top: iframeRect.top + paddingTop + borderWidthTop,
            left: iframeRect.left + paddingLeft + borderWidthLeft,
        };
    }
    /**
     * Sets up event listeners that facilitate repositioning
     * the overlay elements on scroll or resize.
     */
    setOverlayRepositionEventListeners() {
        let currentScrollY = globalThis.scrollY;
        let currentScrollX = globalThis.scrollX;
        let mostRecentTargetScrollY = 0;
        const repositionHandler = this.useEventHandlersMemo(throttle(this.handleOverlayRepositionEvent, 250), AUTOFILL_OVERLAY_HANDLE_REPOSITION);
        const eventTargetContainsFocusedField = (eventTarget) => {
            if (typeof eventTarget.contains !== "function") {
                return false;
            }
            const targetScrollY = eventTarget.scrollTop;
            if (targetScrollY === mostRecentTargetScrollY) {
                return false;
            }
            if (eventTarget === this.mostRecentlyFocusedField ||
                eventTarget.contains(this.mostRecentlyFocusedField)) {
                mostRecentTargetScrollY = targetScrollY;
                return true;
            }
            return false;
        };
        const onScroll = (...args) => {
            const event = args[0];
            const scrollY = globalThis.scrollY;
            const scrollX = globalThis.scrollX;
            if (currentScrollY !== scrollY ||
                currentScrollX !== scrollX ||
                (event instanceof Event &&
                    event.target instanceof Element &&
                    eventTargetContainsFocusedField(event.target))) {
                repositionHandler(event);
            }
            currentScrollY = scrollY;
            currentScrollX = scrollX;
        };
        const scrollHandler = this.useEventHandlersMemo(throttle(onScroll, 50), AUTOFILL_OVERLAY_HANDLE_SCROLL);
        globalThis.addEventListener(EVENTS.SCROLL, scrollHandler, {
            capture: true,
            passive: true,
        });
        globalThis.addEventListener(EVENTS.RESIZE, repositionHandler);
    }
    /**
     * Removes the listeners that facilitate repositioning
     * the overlay elements on scroll or resize.
     */
    removeOverlayRepositionEventListeners() {
        globalThis.removeEventListener(EVENTS.SCROLL, this.eventHandlersMemo[AUTOFILL_OVERLAY_HANDLE_SCROLL], {
            capture: true,
        });
        globalThis.removeEventListener(EVENTS.RESIZE, this.eventHandlersMemo[AUTOFILL_OVERLAY_HANDLE_REPOSITION]);
        delete this.eventHandlersMemo[AUTOFILL_OVERLAY_HANDLE_SCROLL];
        delete this.eventHandlersMemo[AUTOFILL_OVERLAY_HANDLE_REPOSITION];
    }
    /**
     * Triggers an update in the most recently focused field's data and returns
     * whether the field is within the viewport bounds. If not within the bounds
     * of the viewport, the inline menu will be closed.
     */
    checkIsMostRecentlyFocusedFieldWithinViewport() {
        return autofill_overlay_content_service_awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d;
            yield this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
            const focusedFieldRectsTop = (_b = (_a = this.focusedFieldData) === null || _a === void 0 ? void 0 : _a.focusedFieldRects) === null || _b === void 0 ? void 0 : _b.top;
            const focusedFieldRectsHeight = (_d = (_c = this.focusedFieldData) === null || _c === void 0 ? void 0 : _c.focusedFieldRects) === null || _d === void 0 ? void 0 : _d.height;
            if (focusedFieldRectsTop == null || focusedFieldRectsHeight == null) {
                return false;
            }
            const focusedFieldRectsBottom = focusedFieldRectsTop + focusedFieldRectsHeight;
            const viewportHeight = globalThis.innerHeight + globalThis.scrollY;
            return (!globalThis.isNaN(focusedFieldRectsTop) &&
                focusedFieldRectsTop >= 0 &&
                focusedFieldRectsTop < viewportHeight &&
                focusedFieldRectsBottom <= viewportHeight);
        });
    }
    /**
     * Clears the timeout that triggers a debounced focus of the inline menu list.
     */
    clearFocusInlineMenuListTimeout() {
        if (this.focusInlineMenuListTimeout) {
            globalThis.clearTimeout(this.focusInlineMenuListTimeout);
        }
    }
    /**
     * Clears the timeout that triggers the closing of the inline menu on a focus redirection.
     */
    clearCloseInlineMenuOnRedirectTimeout() {
        if (this.closeInlineMenuOnRedirectTimeout) {
            globalThis.clearTimeout(this.closeInlineMenuOnRedirectTimeout);
        }
    }
    /**
     * Stops monitoring (detaching listeners, clearing caches) and releases
     * the userFilledFields reference for terminal disposal.
     */
    destroy() {
        this.stopMonitoring();
        this.userFilledFields = null;
    }
}

;// ./src/autofill/services/dom-element-visibility.service.ts
var dom_element_visibility_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
class DomElementVisibilityService {
    constructor(inlineMenuContentService) {
        this.inlineMenuContentService = inlineMenuContentService;
        this.cachedComputedStyle = null;
    }
    /**
     * Checks if an element is viewable. This is done by checking if the element is within the
     * viewport bounds, not hidden by CSS, and not hidden behind another element.
     * @param element
     */
    isElementViewable(element) {
        return dom_element_visibility_service_awaiter(this, void 0, void 0, function* () {
            const elementBoundingClientRect = element.getBoundingClientRect();
            if (this.isElementOutsideViewportBounds(element, elementBoundingClientRect) ||
                this.isElementHiddenByCss(element)) {
                return false;
            }
            return this.formFieldIsNotHiddenBehindAnotherElement(element, elementBoundingClientRect);
        });
    }
    /**
     * Check if the target element is hidden using CSS. This is done by checking the opacity, display,
     * visibility, and clip-path CSS properties of the element. We also check the opacity of all
     * parent elements to ensure that the target element is not hidden by a parent element.
     * @param {HTMLElement} element
     * @returns {boolean}
     * @public
     */
    isElementHiddenByCss(element) {
        this.cachedComputedStyle = null;
        if (this.isElementInvisible(element) ||
            this.isElementNotDisplayed(element) ||
            this.isElementNotVisible(element) ||
            this.isElementClipped(element)) {
            return true;
        }
        let parentElement = element.parentElement;
        while (parentElement && parentElement !== element.ownerDocument.documentElement) {
            this.cachedComputedStyle = null;
            if (this.isElementInvisible(parentElement)) {
                return true;
            }
            parentElement = parentElement.parentElement;
        }
        return false;
    }
    /**
     * Gets the computed style of a given element, will only calculate the computed
     * style if the element's style has not been previously cached.
     * @param {HTMLElement} element
     * @param {string} styleProperty
     * @returns {string}
     * @private
     */
    getElementStyle(element, styleProperty) {
        if (!this.cachedComputedStyle) {
            this.cachedComputedStyle = (element.ownerDocument.defaultView || globalThis).getComputedStyle(element);
        }
        return this.cachedComputedStyle.getPropertyValue(styleProperty);
    }
    /**
     * Checks if the opacity of the target element is less than 0.1.
     * @param {HTMLElement} element
     * @returns {boolean}
     * @private
     */
    isElementInvisible(element) {
        return parseFloat(this.getElementStyle(element, "opacity")) < 0.1;
    }
    /**
     * Checks if the target element has a display property of none.
     * @param {HTMLElement} element
     * @returns {boolean}
     * @private
     */
    isElementNotDisplayed(element) {
        return this.getElementStyle(element, "display") === "none";
    }
    /**
     * Checks if the target element has a visibility property of hidden or collapse.
     * @param {HTMLElement} element
     * @returns {boolean}
     * @private
     */
    isElementNotVisible(element) {
        return new Set(["hidden", "collapse"]).has(this.getElementStyle(element, "visibility"));
    }
    /**
     * Checks if the target element has a clip-path property that hides the element.
     * @param {HTMLElement} element
     * @returns {boolean}
     * @private
     */
    isElementClipped(element) {
        return new Set([
            "inset(50%)",
            "inset(100%)",
            "circle(0)",
            "circle(0px)",
            "circle(0px at 50% 50%)",
            "polygon(0 0, 0 0, 0 0, 0 0)",
            "polygon(0px 0px, 0px 0px, 0px 0px, 0px 0px)",
        ]).has(this.getElementStyle(element, "clipPath"));
    }
    /**
     * Checks if the target element is outside the viewport bounds. This is done by checking if the
     * element is too small or is overflowing the viewport bounds.
     * @param {HTMLElement} targetElement
     * @param {DOMRectReadOnly | null} targetElementBoundingClientRect
     * @returns {boolean}
     * @private
     */
    isElementOutsideViewportBounds(targetElement, targetElementBoundingClientRect = null) {
        const documentElement = targetElement.ownerDocument.documentElement;
        const documentElementWidth = documentElement.scrollWidth;
        const documentElementHeight = documentElement.scrollHeight;
        const elementBoundingClientRect = targetElementBoundingClientRect || targetElement.getBoundingClientRect();
        const elementTopOffset = elementBoundingClientRect.top - documentElement.clientTop;
        const elementLeftOffset = elementBoundingClientRect.left - documentElement.clientLeft;
        const isElementSizeInsufficient = elementBoundingClientRect.width < 10 || elementBoundingClientRect.height < 10;
        const isElementOverflowingLeftViewport = elementLeftOffset < 0;
        const isElementOverflowingRightViewport = elementLeftOffset + elementBoundingClientRect.width > documentElementWidth;
        const isElementOverflowingTopViewport = elementTopOffset < 0;
        const isElementOverflowingBottomViewport = elementTopOffset + elementBoundingClientRect.height > documentElementHeight;
        return (isElementSizeInsufficient ||
            isElementOverflowingLeftViewport ||
            isElementOverflowingRightViewport ||
            isElementOverflowingTopViewport ||
            isElementOverflowingBottomViewport);
    }
    /**
     * Checks if a passed FormField is not hidden behind another element. This is done by
     * checking if the element at the center point of the FormField is the FormField itself
     * or one of its labels.
     * @param {FormFieldElement} targetElement
     * @param {DOMRectReadOnly | null} targetElementBoundingClientRect
     * @returns {boolean}
     * @private
     */
    formFieldIsNotHiddenBehindAnotherElement(targetElement, targetElementBoundingClientRect = null) {
        var _a, _b;
        const elementBoundingClientRect = targetElementBoundingClientRect || targetElement.getBoundingClientRect();
        const elementRootNode = targetElement.getRootNode();
        const rootElement = elementRootNode instanceof ShadowRoot ? elementRootNode : targetElement.ownerDocument;
        const elementAtCenterPoint = rootElement.elementFromPoint(elementBoundingClientRect.left + elementBoundingClientRect.width / 2, elementBoundingClientRect.top + elementBoundingClientRect.height / 2);
        if (elementAtCenterPoint === targetElement) {
            return true;
        }
        if ((_a = this.inlineMenuContentService) === null || _a === void 0 ? void 0 : _a.isElementInlineMenu(elementAtCenterPoint)) {
            return true;
        }
        const targetElementLabelsSet = new Set(targetElement.labels);
        if (targetElementLabelsSet.has(elementAtCenterPoint)) {
            return true;
        }
        const closestParentLabel = (_b = elementAtCenterPoint === null || elementAtCenterPoint === void 0 ? void 0 : elementAtCenterPoint.parentElement) === null || _b === void 0 ? void 0 : _b.closest("label");
        return closestParentLabel ? targetElementLabelsSet.has(closestParentLabel) : false;
    }
}
/* harmony default export */ var dom_element_visibility_service = (DomElementVisibilityService);

;// ./src/autofill/content/performance.ts
// Hot-path instrumentation for autofill content scripts.
// See performance.md for usage and performance.design.md for design rationale.
const enabled = false;
const WATCH_BITS = enabled ? 10 : 0;
const WATCH_SIZE = 1 << WATCH_BITS;
const WATCH_MASK = WATCH_SIZE - 1;
const DEFAULT_METER_BITS = 8;
const namesCache = {};
let namesCacheSize = 0;
const NAMES_CACHE_WARN_THRESHOLD = 64;
const NAMES_SUFFIX = "autofill:bw";
function formatMark(name, mark) {
    return `${name}:${mark}:${NAMES_SUFFIX}`;
}
function resolveNames(name) {
    let names = namesCache[name];
    if (!names) {
        names = {
            measure: `${name}:${NAMES_SUFFIX}`,
            start: formatMark(name, "start"),
            end: formatMark(name, "end"),
            poison: formatMark(name, "poison"),
        };
        namesCache[name] = names;
        namesCacheSize++;
        if (namesCacheSize === NAMES_CACHE_WARN_THRESHOLD) {
            // eslint-disable-next-line no-console -- this is running in a content-script; `LogService` is unavailable
            console.warn(`[perf] ${NAMES_CACHE_WARN_THRESHOLD} unique measurement names registered. ` +
                "This cache is not bounded — ensure names are static, not dynamically generated.");
        }
    }
    return names;
}
const watchBuffer = new Array(WATCH_SIZE);
for (let i = 0; i < WATCH_SIZE; i++) {
    watchBuffer[i] = { name: "", start: 0, end: 0 };
}
let watchWriteHead = 0;
let watchReadHead = 0;
const meters = [];
let pendingFlush = false;
function scheduleFlush() {
    globalThis.setTimeout(flushBuffer, 0);
}
function recordWatch(name, start, end) {
    const slot = watchBuffer[watchWriteHead & WATCH_MASK];
    slot.name = name;
    slot.start = start;
    slot.end = end;
    watchWriteHead++;
    if (!pendingFlush) {
        pendingFlush = true;
        scheduleFlush();
    }
}
function flushBuffer() {
    let rescheduleNeeded = false;
    const watchWriteHeadAtStart = watchWriteHead;
    if (watchWriteHeadAtStart - watchReadHead > WATCH_SIZE) {
        watchReadHead = watchWriteHeadAtStart - WATCH_SIZE;
    }
    while (watchReadHead < watchWriteHeadAtStart) {
        const slot = watchBuffer[watchReadHead & WATCH_MASK];
        const names = resolveNames(slot.name);
        performance.mark(names.start, { startTime: slot.start });
        performance.mark(names.end, { startTime: slot.end });
        performance.measure(names.measure, names.start, names.end);
        watchReadHead++;
    }
    for (let i = 0; i < meters.length; i++) {
        const m = meters[i];
        const meterWriteHeadAtStart = m.getWriteHead();
        let meterReadHead = m.getReadHead();
        const meterSize = m.mask + 1;
        if (meterWriteHeadAtStart - meterReadHead > meterSize) {
            meterReadHead = meterWriteHeadAtStart - meterSize;
        }
        const markName = `${m.name}:meter:${NAMES_SUFFIX}`;
        const arity = m.keys.length;
        while (meterReadHead < meterWriteHeadAtStart) {
            const row = m.buffer[meterReadHead & m.mask];
            const at = row[0];
            if (arity === 0) {
                performance.mark(markName, { startTime: at });
            }
            else {
                const detail = {};
                for (let k = 0; k < arity; k++) {
                    detail[m.keys[k]] = row[k + 1];
                }
                performance.mark(markName, { startTime: at, detail });
            }
            meterReadHead++;
        }
        m.setReadHead(meterReadHead);
        if (m.getWriteHead() > meterWriteHeadAtStart) {
            rescheduleNeeded = true;
        }
    }
    pendingFlush = false;
    if (watchWriteHead > watchWriteHeadAtStart || rescheduleNeeded) {
        pendingFlush = true;
        scheduleFlush();
    }
}
/**
 * Wraps a function with timing instrumentation. The wrapper preserves the
 * function's return value, arguments, and `this` context. When disabled at
 * build time, the wrapper delegates directly to `fn` with no timestamps or
 * buffer writes.
 *
 * **Warning:** Only measures synchronous execution. If `fn` returns a Promise,
 * the recorded duration is the time to create the promise, not to resolve it.
 *
 * @param name - Label for the resulting performance measure entries.
 * @param fn - The function to instrument.
 * @returns A wrapper that instruments `fn` when enabled, or delegates directly when disabled.
 */
function stopwatch(name, fn) {
    return function (...args) {
        if (!enabled) {
            return fn.apply(this, args);
        }
        const start = performance.now();
        const result = fn.apply(this, args);
        recordWatch(name, start, performance.now());
        return result;
        // Best-effort type preservation: the wrapper's call signature matches T,
        // but any non-callable properties on T (e.g. a .cancel() method) are lost.
    };
}
/**
 * Executes `fn` and records its duration. Use for inline code blocks that don't
 * sit at a function boundary. When disabled, calls `fn()` directly with no overhead.
 *
 * **Warning:** Only measures synchronous execution. If `fn` returns a Promise,
 * the recorded duration is the time to create the promise, not to resolve it.
 *
 * @param name - Label for the resulting performance measure entry.
 * @param fn - The block to time.
 * @returns The return value of `fn`.
 */
function measure(name, fn) {
    if (!enabled) {
        return fn();
    }
    const start = performance.now();
    const result = fn();
    recordWatch(name, start, performance.now());
    return result;
}
const NOOP = () => { };
/**
 * Registers a meter and returns a function that records one point-in-time event
 * per call. Each call records `performance.now()` and zero or more positional
 * values typed `string | number | boolean`. The declared field names become the
 * keys of the `detail` object on the resulting `${name}:meter:autofill:bw` mark.
 *
 * When disabled at build time, returns a shared no-op and allocates no buffer.
 *
 * @param config - The meter name as a string, or `{ name, bits }` to override
 *   the per-meter buffer size. Buffer size is `1 << bits`. Defaults to 8.
 * @param keys - Field names; their order determines the positional argument order.
 * @returns A function that records one meter entry per call.
 */
function createMeter(config, ...keys) {
    var _a;
    if (!enabled) {
        return NOOP;
    }
    const name = typeof config === "string" ? config : config.name;
    const bits = typeof config === "string" ? DEFAULT_METER_BITS : ((_a = config.bits) !== null && _a !== void 0 ? _a : DEFAULT_METER_BITS);
    const size = 1 << bits;
    const mask = size - 1;
    const rowLength = 1 + keys.length;
    const buffer = new Array(size);
    for (let i = 0; i < size; i++) {
        buffer[i] = new Array(rowLength);
    }
    let writeHead = 0;
    let readHead = 0;
    meters.push({
        name,
        keys,
        buffer,
        mask,
        getWriteHead: () => writeHead,
        getReadHead: () => readHead,
        setReadHead: (v) => {
            readHead = v;
        },
    });
    return ((...values) => {
        const slot = buffer[writeHead & mask];
        slot[0] = performance.now();
        for (let i = 0; i < values.length; i++) {
            slot[i + 1] = values[i];
        }
        writeHead++;
        if (!pendingFlush) {
            pendingFlush = true;
            scheduleFlush();
        }
    });
}
/**
 * Marks a span measurement as poisoned by writing a `${name}:poison:autofill:bw`
 * mark to the Performance Timeline. Use when an unexpected error or external
 * factor has compromised the timing data. Consumers should check for poison
 * marks before trusting extracted measures.
 *
 * Applies only to spans (`stopwatch`/`measure`). Meter entries cannot be poisoned.
 *
 * When disabled at build time, this is a no-op.
 *
 * @param name - The span measurement name to poison.
 */
function poison(name) {
    if (!enabled) {
        return;
    }
    const names = resolveNames(name);
    performance.mark(names.poison);
}

;// ./src/autofill/services/dom-query.service.ts
var dom_query_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



class DomQueryService {
    constructor() {
        // Stale entries (roots whose hosts left the DOM) are harmless — querying them
        // returns an empty NodeList. Cleared on `resetObservedShadowRoots` (navigation).
        this.knownShadowRoots = new Set();
        this.isOwnedShadowHost = () => false;
        this.ignoredTreeWalkerNodes = new Set([
            "svg",
            "script",
            "noscript",
            "head",
            "style",
            "link",
            "meta",
            "title",
            "base",
            "img",
            "picture",
            "video",
            "audio",
            "object",
            "source",
            "track",
            "param",
            "map",
            "area",
        ]);
        /**
         * Queries the page for shadow DOM elements and updates the cached state.
         * Use this when you need to refresh the shadow DOM detection state.
         *
         * @returns True if the page contains any shadow DOM elements
         */
        this.updatePageContainsShadowDom = () => {
            this.pageContainsShadowDom = this.queryShadowRoots(globalThis.document.body, true).length > 0;
            return this.pageContainsShadowDom;
        };
        /**
         * Checks if any of the provided mutations occurred within shadow roots.
         * This is a lightweight check that doesn't query the DOM.
         * @param mutations - The mutation records to check
         * @returns True if any mutation occurred within a shadow root
         */
        this.checkMutationsInShadowRoots = (mutations) => {
            // Latch is a one-way ratchet (see `markShadowDomPresent`); false here means no
            // shadow root has been observed yet, so no mutation target can be inside one.
            if (!this.pageContainsShadowDom) {
                return false;
            }
            return mutations.some((mutation) => {
                const root = mutation.target.getRootNode();
                // Ignore our own injected shadow hosts — observing them churns on the menu's own styling.
                return root instanceof ShadowRoot && !this.isOwnedShadowHost(root.host);
            });
        };
        /** Identity predicate for the extension's own injected shadow hosts, excluded from scanning/observation. */
        this.setOwnedShadowHostPredicate = (predicate) => {
            this.isOwnedShadowHost = predicate;
        };
        /** @returns true if an unobserved root is reachable; flips the latch on first post-init() find. */
        this.checkForNewShadowRoots = (addedElements) => {
            const verdict = this.classifyShadowRootScan(addedElements);
            if (verdict.foundNewRoot && !this.pageContainsShadowDom) {
                this.markShadowDomPresent();
            }
            return verdict.foundNewRoot;
        };
        this.classifyShadowRootScan = (addedElements) => {
            const hasAddedElements = !!addedElements && addedElements.length > 0;
            // Batch present: scan even with latch false (shadow DOM may attach post-init).
            if (!this.pageContainsShadowDom && !hasAddedElements) {
                return { branch: "shortCircuit", foundNewRoot: false };
            }
            return hasAddedElements
                ? this.findNewShadowRootInBatch(addedElements)
                : this.findNewShadowRootInDocument();
        };
        this.findNewShadowRootInBatch = (elements) => {
            // Drop descendants of other batch elements — same subtree, re-walked.
            const roots = this.suppressDescendantsInBatch(elements);
            for (const el of roots) {
                if (this.scanForNewShadowRootInSubtree(el, 0)) {
                    return { branch: "narrow", foundNewRoot: true };
                }
            }
            return { branch: "narrow", foundNewRoot: false };
        };
        /** O(N²) over the batch — N is bounded upstream by `pendingMutationAddedElementsCap`. */
        this.suppressDescendantsInBatch = (elements) => {
            if (elements.length < 2) {
                return elements;
            }
            const roots = [];
            for (const candidate of elements) {
                let coveredByAnotherElement = false;
                for (const other of elements) {
                    if (other !== candidate && other.contains(candidate)) {
                        coveredByAnotherElement = true;
                        break;
                    }
                }
                if (!coveredByAnotherElement) {
                    roots.push(candidate);
                }
            }
            return roots;
        };
        this.findNewShadowRootInDocument = () => {
            let roots;
            try {
                roots = this.recursivelyQueryShadowRoots(globalThis.document.body);
            }
            catch (_a) {
                roots = this.queryShadowRoots(globalThis.document.body);
            }
            return {
                branch: "fullScan",
                foundNewRoot: roots.some((r) => !this.knownShadowRoots.has(r)),
            };
        };
        this.markShadowDomPresent = () => {
            this.pageContainsShadowDom = true;
        };
        /**
         * Resets the observed shadow roots tracking. This should be called when the mutation
         * observer is recreated or on significant lifecycle events (like navigation).
         */
        this.resetObservedShadowRoots = () => {
            this.knownShadowRoots.clear();
        };
        // `ShadowRoot.host` is non-nullable per spec; persists after host removal from document.
        this.purgeDetachedShadowRoots = () => {
            for (const root of this.knownShadowRoots) {
                if (!root.host.isConnected) {
                    this.knownShadowRoots.delete(root);
                }
            }
        };
        // No cycle guard — `attachShadow` throws on re-attach, `ShadowRoot.host` is
        // read-only. See https://dom.spec.whatwg.org/#dom-element-attachshadow.
        this.scanForNewShadowRootInSubtree = (subtree, depth) => {
            if (depth >= MAX_DEEP_QUERY_RECURSION_DEPTH) {
                return false;
            }
            // Host check — `querySelectorAll("*")` excludes the scope element.
            if (subtree instanceof Element) {
                const root = this.getShadowRoot(subtree);
                if (root) {
                    if (!this.knownShadowRoots.has(root)) {
                        return true;
                    }
                    if (this.scanForNewShadowRootInSubtree(root, depth + 1)) {
                        return true;
                    }
                }
            }
            // querySelectorAll doesn't pierce shadow boundaries — recurse per boundary.
            for (const child of subtree.querySelectorAll("*")) {
                const childRoot = this.getShadowRoot(child);
                if (childRoot) {
                    if (!this.knownShadowRoots.has(childRoot)) {
                        return true;
                    }
                    if (this.scanForNewShadowRootInSubtree(childRoot, depth + 1)) {
                        return true;
                    }
                }
            }
            return false;
        };
        this.getShadowRoot = stopwatch("getShadowRoot", this.getShadowRoot);
        void this.init();
    }
    /**
     * Sets up a query that will trigger a deepQuery of the DOM, querying all elements that match the given query string.
     * If the deepQuery fails or reaches a max recursion depth, it will fall back to a treeWalker query.
     *
     * @param root - The root element to start the query from
     * @param queryString - The query string to match elements against
     * @param treeWalkerFilter - The filter callback to use for the treeWalker query
     * @param mutationObserver - The MutationObserver to use for observing shadow roots
     * @param forceDeepQueryAttempt - Whether to force a deep query attempt
     * @param ignoredTreeWalkerNodesOverride - An optional set of node names to ignore when using the treeWalker strategy
     */
    query(root, queryString, treeWalkerFilter, mutationObserver, forceDeepQueryAttempt, ignoredTreeWalkerNodesOverride) {
        const ignoredTreeWalkerNodes = ignoredTreeWalkerNodesOverride || this.ignoredTreeWalkerNodes;
        if (!forceDeepQueryAttempt) {
            return this.queryAllTreeWalkerNodes(root, treeWalkerFilter, ignoredTreeWalkerNodes, mutationObserver);
        }
        try {
            return this.deepQueryElements(root, queryString, mutationObserver);
        }
        catch (_a) {
            return this.queryAllTreeWalkerNodes(root, treeWalkerFilter, ignoredTreeWalkerNodes, mutationObserver);
        }
    }
    /**
     * Queries the DOM for elements based on the given selector string.
     * Supports the special `>>>` combinator to traverse iframe and shadow DOM
     * boundaries; each segment separated by `>>>` is queried within the context
     * produced by the previous segment. Boundary type is determined exclusively
     * by the resolved element type — iframe elements always use iframe traversal,
     * all other elements always use shadow DOM traversal, with no fallback between
     * the two. This enforces the contract expressed in the targeting rule.
     *
     * @param selector selector string, supports boundary-piercing with `>>>`
     * @returns The first matching element, or null if no match is found
     */
    queryDeepSelector(selector) {
        if (!selector) {
            return null;
        }
        const segments = selector.split(DEEP_QUERY_SELECTOR_COMBINATOR);
        let context = globalThis.document;
        for (let i = 0; i < segments.length; i++) {
            const segment = (segments[i] || "").trim();
            if (segment.length < 1) {
                return null;
            }
            const element = context.querySelector(segment);
            if (!element) {
                return null;
            }
            if (i < segments.length - 1) {
                // FIXME: When a targeting rule specifies `iframe#foo`, we should fail
                // authoritatively if `#foo` does not resolve to an iframe (rather than
                // falling back to shadow traversal). The current test-and-fallback can
                // mask stale or inaccurate selectors.
                const next = element instanceof HTMLIFrameElement
                    ? element.contentDocument
                    : this.traverseShadowRootBoundary(element);
                if (!next) {
                    return null;
                }
                context = next;
            }
            else {
                return element;
            }
        }
        return null;
    }
    /**
     * Walks a selector and returns the first iframe boundary encountered along
     * with the remaining selector to apply inside that iframe.  Shadow DOM
     * boundaries before the iframe are traversed normally. Returns null if no
     * iframe boundary exists in the selector (pure shadow DOM or direct element).
     *
     * @param selector - Selector string using `>>>` as the boundary combinator
     */
    findIframeCrossing(selector) {
        const segments = selector.split(DEEP_QUERY_SELECTOR_COMBINATOR);
        if (segments.length < 2) {
            return null;
        }
        let context = globalThis.document;
        for (let i = 0; i < segments.length - 1; i++) {
            const segment = (segments[i] || "").trim();
            if (!segment) {
                return null;
            }
            const element = context.querySelector(segment);
            if (!element) {
                return null;
            }
            if (element instanceof HTMLIFrameElement) {
                return {
                    iframeElement: element,
                    innerSelector: segments.slice(i + 1).join(DEEP_QUERY_SELECTOR_COMBINATOR),
                };
            }
            const shadow = this.getShadowRoot(element);
            if (!shadow) {
                return null;
            }
            context = shadow;
        }
        return null;
    }
    /**
     * Returns the shadow root of an element, or null if no shadow root exists.
     * Explicitly refuses to traverse iframe elements — callers must read
     * `contentDocument` directly for those.
     */
    traverseShadowRootBoundary(element) {
        if (element instanceof HTMLIFrameElement) {
            return null;
        }
        return this.getShadowRoot(element);
    }
    /**
     * Initializes the DomQueryService, checking for the presence of shadow DOM elements on the page.
     */
    init() {
        return dom_query_service_awaiter(this, void 0, void 0, function* () {
            if (globalThis.document.readyState === "complete") {
                this.updatePageContainsShadowDom();
                return;
            }
            globalThis.addEventListener(EVENTS.LOAD, this.updatePageContainsShadowDom);
        });
    }
    /**
     * Queries all elements in the DOM that match the given query string.
     * Also, recursively queries all shadow roots for the element.
     *
     * @param root - The root element to start the query from
     * @param queryString - The query string to match elements against
     * @param mutationObserver - The MutationObserver to use for observing shadow roots
     */
    deepQueryElements(root, queryString, mutationObserver) {
        let elements = this.queryElements(root, queryString);
        if (!this.pageContainsShadowDom) {
            return elements;
        }
        // Re-use the already-discovered shadow roots when possible to avoid the
        // expensive querySelectorAll("*") + tag-name scan on every call.
        // FIXME: shadow roots added to the main document after initialization are not
        // included in this set until `resetObservedShadowRoots()` is called. (i.e.
        // when the mutation observer is rebuilt)
        const shadowRoots = this.knownShadowRoots.size > 0
            ? Array.from(this.knownShadowRoots)
            : this.recursivelyQueryShadowRoots(root);
        for (let index = 0; index < shadowRoots.length; index++) {
            const shadowRoot = shadowRoots[index];
            elements = elements.concat(this.queryElements(shadowRoot, queryString));
            if (mutationObserver) {
                mutationObserver.observe(shadowRoot, {
                    attributes: true,
                    childList: true,
                    subtree: true,
                });
            }
            this.knownShadowRoots.add(shadowRoot);
        }
        return elements;
    }
    /**
     * Queries the DOM for elements based on the given query string.
     *
     * @param root - The root element to start the query from
     * @param queryString - The query string to match elements against
     */
    queryElements(root, queryString) {
        // Avoid a redundant pre-check querySelector — querySelectorAll already
        // returns an empty NodeList when nothing matches, at no extra cost.
        return Array.from(root.querySelectorAll(queryString));
    }
    /**
     * Recursively queries all shadow roots found within the given root element.
     * Will also set up a mutation observer on the shadow root if the
     * `isObservingShadowRoot` parameter is set to true.
     *
     * @param root - The root element to start the query from
     * @param depth - The depth of the recursion
     */
    recursivelyQueryShadowRoots(root, depth = 0) {
        if (depth >= MAX_DEEP_QUERY_RECURSION_DEPTH) {
            throw new Error("Max recursion depth reached");
        }
        let shadowRoots = this.queryShadowRoots(root);
        for (let index = 0; index < shadowRoots.length; index++) {
            const shadowRoot = shadowRoots[index];
            shadowRoots = shadowRoots.concat(this.recursivelyQueryShadowRoots(shadowRoot, depth + 1));
        }
        return shadowRoots;
    }
    /**
     * Queries any immediate shadow roots found within the given root element.
     *
     * @param root - The root element to start the query from
     * @param returnSingleShadowRoot - Whether to return a single shadow root or an array of shadow roots
     */
    queryShadowRoots(root, returnSingleShadowRoot = false) {
        if (!root) {
            return [];
        }
        const shadowRoots = [];
        for (const potentialShadowRoot of root.querySelectorAll("*")) {
            const shadowRoot = this.getShadowRoot(potentialShadowRoot);
            if (shadowRoot) {
                shadowRoots.push(shadowRoot);
            }
            if (returnSingleShadowRoot && shadowRoots.length) {
                break;
            }
        }
        return shadowRoots;
    }
    /**
     * Attempts to get the ShadowRoot of the passed node. If support for the
     * extension based openOrClosedShadowRoot API is available, it will be used.
     * Will return null if the node is not an HTMLElement or if the node has
     * child nodes.
     *
     * @param {Node} node
     */
    getShadowRoot(node) {
        var _a;
        if (!nodeIsElement(node)) {
            return null;
        }
        if (this.isOwnedShadowHost(node)) {
            return null;
        }
        // Fast path first: element.shadowRoot is cheap and works on any element with
        // an open root.
        if (node.shadowRoot) {
            return node.shadowRoot;
        }
        // skip nodes that cannot contain shadow roots
        const isCandidate = SHADOW_ROOT_CANDIDATE_NODE_NAMES.has(node.nodeName) || node.nodeName.includes("-");
        if (!isCandidate) {
            return null;
        }
        // Fall back to chrome.dom.openOrClosedShadowRoot for closed
        // roots — the expensive cross-boundary call — on any host element, since
        // closed roots can be (and are) attached to plain HTML hosts in the wild.
        if ((_a = chrome.dom) === null || _a === void 0 ? void 0 : _a.openOrClosedShadowRoot) {
            try {
                return chrome.dom.openOrClosedShadowRoot(node);
            }
            catch (_b) {
                return null;
            }
        }
        // Firefox-specific equivalent of `openOrClosedShadowRoot`
        return node.openOrClosedShadowRoot;
    }
    /**
     * Queries the DOM for all the nodes that match the given filter callback
     * and returns a collection of nodes.
     * @param rootNode
     * @param filterCallback
     * @param ignoredTreeWalkerNodes
     * @param mutationObserver
     */
    queryAllTreeWalkerNodes(rootNode, filterCallback, ignoredTreeWalkerNodes, mutationObserver) {
        const treeWalkerQueryResults = [];
        this.buildTreeWalkerNodesQueryResults(rootNode, treeWalkerQueryResults, filterCallback, ignoredTreeWalkerNodes, mutationObserver);
        return treeWalkerQueryResults;
    }
    /**
     * Recursively builds a collection of nodes that match the given filter callback.
     * If a node has a ShadowRoot, it will be observed for mutations.
     *
     * @param rootNode
     * @param treeWalkerQueryResults
     * @param filterCallback
     * @param ignoredTreeWalkerNodes
     * @param mutationObserver
     */
    buildTreeWalkerNodesQueryResults(rootNode, treeWalkerQueryResults, filterCallback, ignoredTreeWalkerNodes, mutationObserver) {
        const treeWalker = document === null || document === void 0 ? void 0 : document.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT, (node) => {
            var _a;
            return ignoredTreeWalkerNodes.has((_a = node.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase())
                ? NodeFilter.FILTER_REJECT
                : NodeFilter.FILTER_ACCEPT;
        });
        let currentNode = treeWalker === null || treeWalker === void 0 ? void 0 : treeWalker.currentNode;
        while (currentNode) {
            if (filterCallback(currentNode)) {
                treeWalkerQueryResults.push(currentNode);
            }
            // Only probe for a shadow root when the page is known to have shadow DOM.
            // Fast path: element.shadowRoot for open roots, free on any element type.
            // Fall back to the extension API (chrome.dom.openOrClosedShadowRoot) for
            // closed roots on any host element.
            if (this.pageContainsShadowDom && nodeIsElement(currentNode)) {
                const el = currentNode;
                let nodeShadowRoot = el.shadowRoot;
                if (!nodeShadowRoot) {
                    nodeShadowRoot = this.getShadowRoot(currentNode);
                }
                if (nodeShadowRoot) {
                    if (mutationObserver) {
                        mutationObserver.observe(nodeShadowRoot, {
                            attributes: true,
                            childList: true,
                            subtree: true,
                        });
                    }
                    this.knownShadowRoots.add(nodeShadowRoot);
                    this.buildTreeWalkerNodesQueryResults(nodeShadowRoot, treeWalkerQueryResults, filterCallback, ignoredTreeWalkerNodes, mutationObserver);
                }
            }
            currentNode = treeWalker === null || treeWalker === void 0 ? void 0 : treeWalker.nextNode();
        }
    }
}

;// ./src/autofill/utils/qualification.ts

const KeywordMatchMode = Object.freeze({
    AppearsWithin: "appearsWithin",
    MatchesToken: "matchesToken",
});
// Module-level cache
const autofillFieldKeywordsCache = new WeakMap();
const autofillFormKeywordsCache = new WeakMap();
/**
 * Normalizes and tokenizes a single attribute value string into a set of keyword tokens.
 * Produces the full lowercased value, tokens split on non-alphanumeric characters (after
 * hyphen removal), and tokens split after additional space removal (e.g. "user id" → "userid").
 */
function tokenizeValue(value) {
    const keywordsSet = new Set();
    let keywordEl = value.toLowerCase();
    keywordsSet.add(keywordEl);
    keywordEl = keywordEl.replace(/-/g, "");
    keywordEl.split(/[^\p{L}\d]+/gu).forEach((k) => {
        if (k) {
            keywordsSet.add(k);
        }
    });
    keywordEl
        .replace(/\s/g, "")
        .split(/[^\p{L}\d]+/gu)
        .forEach((k) => {
        if (k) {
            keywordsSet.add(k);
        }
    });
    return keywordsSet;
}
/**
 * Collects and tokenizes all qualifying attribute values from a field into a unified
 * keyword set and a comma-joined string value. Results are cached per field reference
 * in {@link autofillFieldKeywordsCache} to avoid redundant computation across repeated calls.
 */
function buildAutofillFieldKeywords(field) {
    if (autofillFieldKeywordsCache.has(field)) {
        return autofillFieldKeywordsCache.get(field);
    }
    const attributeValues = [
        field.htmlID,
        field.htmlName,
        field.htmlClass,
        field.type,
        field.title,
        field.placeholder,
        field.autoCompleteType,
        field.dataSetValues,
        field["label-data"],
        field["label-aria"],
        field["label-left"],
        field["label-right"],
        field["label-tag"],
        field["label-top"],
        field["aria-describedby"],
    ];
    const keywordsSet = new Set();
    for (const attributeValue of attributeValues) {
        if (!attributeValue || typeof attributeValue !== "string") {
            continue;
        }
        tokenizeValue(attributeValue).forEach((k) => keywordsSet.add(k));
    }
    const result = { keywordsSet, stringValue: Array.from(keywordsSet).join(",") };
    autofillFieldKeywordsCache.set(field, result);
    return result;
}
/**
 * True if any keyword matches a token from the field. With `appearsWithin` (default), the
 * keyword may appear as a substring of any token; `matchesToken` requires an exact token.
 * Hyphens are stripped from keywords before matching.
 */
function fieldContainsKeyword(field, keywords, mode = KeywordMatchMode.AppearsWithin) {
    const parsedKeywords = keywords.map((k) => k.replace(/-/g, ""));
    const { keywordsSet, stringValue } = buildAutofillFieldKeywords(field);
    if (mode === KeywordMatchMode.AppearsWithin) {
        return parsedKeywords.some((k) => stringValue.indexOf(k) > -1);
    }
    return parsedKeywords.some((k) => keywordsSet.has(k));
}
/**
 * True if any keyword matches a token from the form. With `appearsWithin` (default), the
 * keyword may appear as a substring of any token; `matchesToken` requires an exact token.
 * Hyphens are stripped from keywords before matching.
 */
function formContainsKeyword(form, keywords, mode = KeywordMatchMode.AppearsWithin) {
    const parsedKeywords = keywords.map((k) => k.replace(/-/g, ""));
    const { keywordsSet, stringValue } = buildAutofillFormKeywords(form);
    if (mode === KeywordMatchMode.AppearsWithin) {
        return parsedKeywords.some((k) => stringValue.indexOf(k) > -1);
    }
    return parsedKeywords.some((k) => keywordsSet.has(k));
}
/**
 * Tokenizes form attrs only — heading text is handled by classifyHeadings.
 */
function buildAutofillFormKeywords(form) {
    if (autofillFormKeywordsCache.has(form)) {
        return autofillFormKeywordsCache.get(form);
    }
    const stringAttributes = [form.htmlID, form.htmlName, form.htmlAction, form.htmlClass];
    const keywordsSet = new Set();
    for (const attributeValue of stringAttributes) {
        if (!attributeValue || typeof attributeValue !== "string") {
            continue;
        }
        tokenizeValue(attributeValue).forEach((k) => keywordsSet.add(k));
    }
    const result = { keywordsSet, stringValue: Array.from(keywordsSet).join(",") };
    autofillFormKeywordsCache.set(form, result);
    return result;
}
/**
 * Walks headings closest-first; first match against the login or identity keyword
 * lists wins, silent headings skipped. Returns a context signal, not a verdict.
 */
function classifyHeadings(headings, loginKeywords, identityKeywords) {
    if (!(headings === null || headings === void 0 ? void 0 : headings.length)) {
        return "ambiguous";
    }
    const loginTokens = loginKeywords.map((k) => k.replace(/-/g, "").toLowerCase());
    const identityTokens = identityKeywords.map((k) => k.replace(/-/g, "").toLowerCase());
    for (const heading of headings) {
        if (!heading) {
            continue;
        }
        const stringValue = Array.from(tokenizeValue(heading)).join(",");
        if (loginTokens.some((k) => stringValue.indexOf(k) > -1)) {
            return "login";
        }
        if (identityTokens.some((k) => stringValue.indexOf(k) > -1)) {
            return "identity";
        }
    }
    return "ambiguous";
}
/**
 * Gathers and normalizes keywords from a potential submit button element. Used
 * to verify if the element submits a login or change password form.
 *
 * @param element - The element to gather keywords from.
 */
function getSubmitButtonKeywordsSet(element) {
    const keywords = [
        element.textContent,
        element.getAttribute("type"),
        element.getAttribute("value"),
        element.getAttribute("aria-label"),
        element.getAttribute("aria-labelledby"),
        element.getAttribute("aria-describedby"),
        element.getAttribute("title"),
        element.getAttribute("id"),
        element.getAttribute("name"),
        element.getAttribute("class"),
    ];
    const keywordsSet = new Set();
    for (const keyword of keywords) {
        if (typeof keyword === "string") {
            // Iterate over all keywords metadata and split them by non-letter characters.
            // This ensures we check against individual words and not the entire string.
            keyword
                .toLowerCase()
                .replace(/[-\s]/g, "")
                .split(/[^\p{L}]+/gu)
                .forEach((splitKeyword) => {
                if (splitKeyword) {
                    keywordsSet.add(splitKeyword);
                }
            });
        }
    }
    return keywordsSet;
}
/**
 * True if the field's parent form carries a non-login signal, scanned against
 * {@link AutoFillConstants.StrongNonLoginKeywords}.
 */
function isNonLoginFormContext(field, pageDetails) {
    var _a;
    const fieldForm = field.form;
    if (!fieldForm) {
        return false;
    }
    const parentForm = (_a = pageDetails.forms) === null || _a === void 0 ? void 0 : _a[fieldForm];
    if (!parentForm) {
        return false;
    }
    return formContainsKeyword(parentForm, AutoFillConstants.StrongNonLoginKeywords);
}
/**
 * True if the field or any same-form sibling matches a keyword.
 * Returns false when the field has no form to scope siblings against.
 */
function anyFieldInFormMatches(field, pageDetails, keywords) {
    if (fieldContainsKeyword(field, keywords)) {
        return true;
    }
    if (!field.form) {
        return false;
    }
    return pageDetails.fields.some((sibling) => sibling !== field && sibling.form === field.form && fieldContainsKeyword(sibling, keywords));
}
/**
 * Checks form context plus field/siblings for non-login keywords. Headings are
 * deferred to isAmbiguousFieldNonLogin pending a confidence-weighting system.
 */
function isNonLoginUsernameField(field, pageDetails) {
    if (isNonLoginFormContext(field, pageDetails)) {
        return true;
    }
    return anyFieldInFormMatches(field, pageDetails, AutoFillConstants.StrongNonLoginKeywords);
}
/**
 * Tie-break for an ambiguously structured login input (lone username, no password).
 * Headings go through classifyHeadings; a closer login signal short-circuits.
 */
function isAmbiguousFieldNonLogin(field, pageDetails) {
    var _a;
    const keywords = AutoFillConstants.ComprehensiveNonLoginKeywords;
    const parentForm = field.form ? (_a = pageDetails.forms) === null || _a === void 0 ? void 0 : _a[field.form] : undefined;
    if (parentForm) {
        const headingClassification = classifyHeadings(parentForm.htmlAncestorHeadings, AutoFillConstants.StrongLoginHeadingKeywords, keywords);
        if (headingClassification === "login") {
            return false;
        }
        if (headingClassification === "identity") {
            return true;
        }
        if (formContainsKeyword(parentForm, keywords)) {
            return true;
        }
    }
    return anyFieldInFormMatches(field, pageDetails, keywords);
}

;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js
var dateTimestampProvider={now:function(){return(dateTimestampProvider.delegate||Date).now();},delegate:undefined};
;// ../../node_modules/rxjs/dist/esm5/internal/ReplaySubject.js
var ReplaySubject=function(_super){__extends(ReplaySubject,_super);function ReplaySubject(_bufferSize,_windowTime,_timestampProvider){if(_bufferSize===void 0){_bufferSize=Infinity;}if(_windowTime===void 0){_windowTime=Infinity;}if(_timestampProvider===void 0){_timestampProvider=dateTimestampProvider;}var _this=_super.call(this)||this;_this._bufferSize=_bufferSize;_this._windowTime=_windowTime;_this._timestampProvider=_timestampProvider;_this._buffer=[];_this._infiniteTimeWindow=true;_this._infiniteTimeWindow=_windowTime===Infinity;_this._bufferSize=Math.max(1,_bufferSize);_this._windowTime=Math.max(1,_windowTime);return _this;}ReplaySubject.prototype.next=function(value){var _a=this,isStopped=_a.isStopped,_buffer=_a._buffer,_infiniteTimeWindow=_a._infiniteTimeWindow,_timestampProvider=_a._timestampProvider,_windowTime=_a._windowTime;if(!isStopped){_buffer.push(value);!_infiniteTimeWindow&&_buffer.push(_timestampProvider.now()+_windowTime);}this._trimBuffer();_super.prototype.next.call(this,value);};ReplaySubject.prototype._subscribe=function(subscriber){this._throwIfClosed();this._trimBuffer();var subscription=this._innerSubscribe(subscriber);var _a=this,_infiniteTimeWindow=_a._infiniteTimeWindow,_buffer=_a._buffer;var copy=_buffer.slice();for(var i=0;i<copy.length&&!subscriber.closed;i+=_infiniteTimeWindow?1:2){subscriber.next(copy[i]);}this._checkFinalizedStatuses(subscriber);return subscription;};ReplaySubject.prototype._trimBuffer=function(){var _a=this,_bufferSize=_a._bufferSize,_timestampProvider=_a._timestampProvider,_buffer=_a._buffer,_infiniteTimeWindow=_a._infiniteTimeWindow;var adjustedBufferSize=(_infiniteTimeWindow?1:2)*_bufferSize;_bufferSize<Infinity&&adjustedBufferSize<_buffer.length&&_buffer.splice(0,_buffer.length-adjustedBufferSize);if(!_infiniteTimeWindow){var now=_timestampProvider.now();var last=0;for(var i=1;i<_buffer.length&&_buffer[i]<=now;i+=2){last=i;}last&&_buffer.splice(0,last+1);}};return ReplaySubject;}(Subject);
;// ../../node_modules/rxjs/dist/esm5/internal/util/lift.js
function hasLift(source){return isFunction(source===null||source===void 0?void 0:source.lift);}function operate(init){return function(source){if(hasLift(source)){return source.lift(function(liftedSource){try{return init(liftedSource,this);}catch(err){this.error(err);}});}throw new TypeError('Unable to lift unknown Observable type');};}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
function createOperatorSubscriber(destination,onNext,onComplete,onError,onFinalize){return new OperatorSubscriber(destination,onNext,onComplete,onError,onFinalize);}var OperatorSubscriber=function(_super){__extends(OperatorSubscriber,_super);function OperatorSubscriber(destination,onNext,onComplete,onError,onFinalize,shouldUnsubscribe){var _this=_super.call(this,destination)||this;_this.onFinalize=onFinalize;_this.shouldUnsubscribe=shouldUnsubscribe;_this._next=onNext?function(value){try{onNext(value);}catch(err){destination.error(err);}}:_super.prototype._next;_this._error=onError?function(err){try{onError(err);}catch(err){destination.error(err);}finally{this.unsubscribe();}}:_super.prototype._error;_this._complete=onComplete?function(){try{onComplete();}catch(err){destination.error(err);}finally{this.unsubscribe();}}:_super.prototype._complete;return _this;}OperatorSubscriber.prototype.unsubscribe=function(){var _a;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var closed_1=this.closed;_super.prototype.unsubscribe.call(this);!closed_1&&((_a=this.onFinalize)===null||_a===void 0?void 0:_a.call(this));}};return OperatorSubscriber;}(Subscriber);
;// ../../node_modules/rxjs/dist/esm5/internal/operators/filter.js
function filter(predicate,thisArg){return operate(function(source,subscriber){var index=0;source.subscribe(createOperatorSubscriber(subscriber,function(value){return predicate.call(thisArg,value,index++)&&subscriber.next(value);}));});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js
function scanInternals(accumulator,seed,hasSeed,emitOnNext,emitBeforeComplete){return function(source,subscriber){var hasState=hasSeed;var state=seed;var index=0;source.subscribe(createOperatorSubscriber(subscriber,function(value){var i=index++;state=hasState?accumulator(state,value,i):(hasState=true,value);emitOnNext&&subscriber.next(state);},emitBeforeComplete&&function(){hasState&&subscriber.next(state);subscriber.complete();}));};}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/scan.js
function scan(accumulator,seed){return operate(scanInternals(accumulator,seed,arguments.length>=2,true));}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/Action.js
var Action=function(_super){__extends(Action,_super);function Action(scheduler,work){return _super.call(this)||this;}Action.prototype.schedule=function(state,delay){if(delay===void 0){delay=0;}return this;};return Action;}(Subscription);
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
var intervalProvider={setInterval:function(handler,timeout){var args=[];for(var _i=2;_i<arguments.length;_i++){args[_i-2]=arguments[_i];}var delegate=intervalProvider.delegate;if(delegate===null||delegate===void 0?void 0:delegate.setInterval){return delegate.setInterval.apply(delegate,__spreadArray([handler,timeout],__read(args)));}return setInterval.apply(void 0,__spreadArray([handler,timeout],__read(args)));},clearInterval:function(handle){var delegate=intervalProvider.delegate;return((delegate===null||delegate===void 0?void 0:delegate.clearInterval)||clearInterval)(handle);},delegate:undefined};
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js
var AsyncAction=function(_super){__extends(AsyncAction,_super);function AsyncAction(scheduler,work){var _this=_super.call(this,scheduler,work)||this;_this.scheduler=scheduler;_this.work=work;_this.pending=false;return _this;}AsyncAction.prototype.schedule=function(state,delay){var _a;if(delay===void 0){delay=0;}if(this.closed){return this;}this.state=state;var id=this.id;var scheduler=this.scheduler;if(id!=null){this.id=this.recycleAsyncId(scheduler,id,delay);}this.pending=true;this.delay=delay;this.id=(_a=this.id)!==null&&_a!==void 0?_a:this.requestAsyncId(scheduler,this.id,delay);return this;};AsyncAction.prototype.requestAsyncId=function(scheduler,_id,delay){if(delay===void 0){delay=0;}return intervalProvider.setInterval(scheduler.flush.bind(scheduler,this),delay);};AsyncAction.prototype.recycleAsyncId=function(_scheduler,id,delay){if(delay===void 0){delay=0;}if(delay!=null&&this.delay===delay&&this.pending===false){return id;}if(id!=null){intervalProvider.clearInterval(id);}return undefined;};AsyncAction.prototype.execute=function(state,delay){if(this.closed){return new Error('executing a cancelled action');}this.pending=false;var error=this._execute(state,delay);if(error){return error;}else if(this.pending===false&&this.id!=null){this.id=this.recycleAsyncId(this.scheduler,this.id,null);}};AsyncAction.prototype._execute=function(state,_delay){var errored=false;var errorValue;try{this.work(state);}catch(e){errored=true;errorValue=e?e:new Error('Scheduled action threw falsy error');}if(errored){this.unsubscribe();return errorValue;}};AsyncAction.prototype.unsubscribe=function(){if(!this.closed){var _a=this,id=_a.id,scheduler=_a.scheduler;var actions=scheduler.actions;this.work=this.state=this.scheduler=null;this.pending=false;arrRemove(actions,this);if(id!=null){this.id=this.recycleAsyncId(scheduler,id,null);}this.delay=null;_super.prototype.unsubscribe.call(this);}};return AsyncAction;}(Action);
;// ../../node_modules/rxjs/dist/esm5/internal/Scheduler.js
var Scheduler=function(){function Scheduler(schedulerActionCtor,now){if(now===void 0){now=Scheduler.now;}this.schedulerActionCtor=schedulerActionCtor;this.now=now;}Scheduler.prototype.schedule=function(work,delay,state){if(delay===void 0){delay=0;}return new this.schedulerActionCtor(this,work).schedule(state,delay);};Scheduler.now=dateTimestampProvider.now;return Scheduler;}();
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js
var AsyncScheduler=function(_super){__extends(AsyncScheduler,_super);function AsyncScheduler(SchedulerAction,now){if(now===void 0){now=Scheduler.now;}var _this=_super.call(this,SchedulerAction,now)||this;_this.actions=[];_this._active=false;return _this;}AsyncScheduler.prototype.flush=function(action){var actions=this.actions;if(this._active){actions.push(action);return;}var error;this._active=true;do{if(error=action.execute(action.state,action.delay)){break;}}while(action=actions.shift());this._active=false;if(error){while(action=actions.shift()){action.unsubscribe();}throw error;}};return AsyncScheduler;}(Scheduler);
;// ../../node_modules/rxjs/dist/esm5/internal/scheduler/async.js
var async_asyncScheduler=new AsyncScheduler(AsyncAction);var async_async=async_asyncScheduler;
;// ../../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
function isScheduler(value){return value&&isFunction(value.schedule);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/isDate.js
function isValidDate(value){return value instanceof Date&&!isNaN(value);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/timer.js
function timer(dueTime,intervalOrScheduler,scheduler){if(dueTime===void 0){dueTime=0;}if(scheduler===void 0){scheduler=async_async;}var intervalDuration=-1;if(intervalOrScheduler!=null){if(isScheduler(intervalOrScheduler)){scheduler=intervalOrScheduler;}else{intervalDuration=intervalOrScheduler;}}return new Observable(function(subscriber){var due=isValidDate(dueTime)?+dueTime-scheduler.now():dueTime;if(due<0){due=0;}var n=0;return scheduler.schedule(function(){if(!subscriber.closed){subscriber.next(n++);if(0<=intervalDuration){this.schedule(undefined,intervalDuration);}else{subscriber.complete();}}},due);});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/map.js
function map(project,thisArg){return operate(function(source,subscriber){var index=0;source.subscribe(createOperatorSubscriber(subscriber,function(value){subscriber.next(project.call(thisArg,value,index++));}));});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
var isArrayLike=function(x){return x&&typeof x.length==='number'&&typeof x!=='function';};
;// ../../node_modules/rxjs/dist/esm5/internal/util/isPromise.js
function isPromise(value){return isFunction(value===null||value===void 0?void 0:value.then);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
function isInteropObservable(input){return isFunction(input[observable]);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
function isAsyncIterable(obj){return Symbol.asyncIterator&&isFunction(obj===null||obj===void 0?void 0:obj[Symbol.asyncIterator]);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
function createInvalidObservableTypeError(input){return new TypeError("You provided "+(input!==null&&typeof input==='object'?'an invalid object':"'"+input+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");}
;// ../../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
function getSymbolIterator(){if(typeof Symbol!=='function'||!Symbol.iterator){return'@@iterator';}return Symbol.iterator;}var iterator_iterator=getSymbolIterator();
;// ../../node_modules/rxjs/dist/esm5/internal/util/isIterable.js
function isIterable(input){return isFunction(input===null||input===void 0?void 0:input[iterator_iterator]);}
;// ../../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
function readableStreamLikeToAsyncGenerator(readableStream){return __asyncGenerator(this,arguments,function readableStreamLikeToAsyncGenerator_1(){var reader,_a,value,done;return __generator(this,function(_b){switch(_b.label){case 0:reader=readableStream.getReader();_b.label=1;case 1:_b.trys.push([1,,9,10]);_b.label=2;case 2:if(false)// removed by dead control flow
{}return[4,__await(reader.read())];case 3:_a=_b.sent(),value=_a.value,done=_a.done;if(!done)return[3,5];return[4,__await(void 0)];case 4:return[2,_b.sent()];case 5:return[4,__await(value)];case 6:return[4,_b.sent()];case 7:_b.sent();return[3,2];case 8:return[3,10];case 9:reader.releaseLock();return[7];case 10:return[2];}});});}function isReadableStreamLike(obj){return isFunction(obj===null||obj===void 0?void 0:obj.getReader);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
function innerFrom(input){if(input instanceof Observable){return input;}if(input!=null){if(isInteropObservable(input)){return fromInteropObservable(input);}if(isArrayLike(input)){return fromArrayLike(input);}if(isPromise(input)){return fromPromise(input);}if(isAsyncIterable(input)){return fromAsyncIterable(input);}if(isIterable(input)){return fromIterable(input);}if(isReadableStreamLike(input)){return fromReadableStreamLike(input);}}throw createInvalidObservableTypeError(input);}function fromInteropObservable(obj){return new Observable(function(subscriber){var obs=obj[observable]();if(isFunction(obs.subscribe)){return obs.subscribe(subscriber);}throw new TypeError('Provided object does not correctly implement Symbol.observable');});}function fromArrayLike(array){return new Observable(function(subscriber){for(var i=0;i<array.length&&!subscriber.closed;i++){subscriber.next(array[i]);}subscriber.complete();});}function fromPromise(promise){return new Observable(function(subscriber){promise.then(function(value){if(!subscriber.closed){subscriber.next(value);subscriber.complete();}},function(err){return subscriber.error(err);}).then(null,reportUnhandledError);});}function fromIterable(iterable){return new Observable(function(subscriber){var e_1,_a;try{for(var iterable_1=__values(iterable),iterable_1_1=iterable_1.next();!iterable_1_1.done;iterable_1_1=iterable_1.next()){var value=iterable_1_1.value;subscriber.next(value);if(subscriber.closed){return;}}}catch(e_1_1){e_1={error:e_1_1};}finally{try{if(iterable_1_1&&!iterable_1_1.done&&(_a=iterable_1.return))_a.call(iterable_1);}finally{if(e_1)throw e_1.error;}}subscriber.complete();});}function fromAsyncIterable(asyncIterable){return new Observable(function(subscriber){process(asyncIterable,subscriber).catch(function(err){return subscriber.error(err);});});}function fromReadableStreamLike(readableStream){return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));}function process(asyncIterable,subscriber){var asyncIterable_1,asyncIterable_1_1;var e_2,_a;return tslib_es6_awaiter(this,void 0,void 0,function(){var value,e_2_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,5,6,11]);asyncIterable_1=__asyncValues(asyncIterable);_b.label=1;case 1:return[4,asyncIterable_1.next()];case 2:if(!(asyncIterable_1_1=_b.sent(),!asyncIterable_1_1.done))return[3,4];value=asyncIterable_1_1.value;subscriber.next(value);if(subscriber.closed){return[2];}_b.label=3;case 3:return[3,1];case 4:return[3,11];case 5:e_2_1=_b.sent();e_2={error:e_2_1};return[3,11];case 6:_b.trys.push([6,,9,10]);if(!(asyncIterable_1_1&&!asyncIterable_1_1.done&&(_a=asyncIterable_1.return)))return[3,8];return[4,_a.call(asyncIterable_1)];case 7:_b.sent();_b.label=8;case 8:return[3,10];case 9:if(e_2)throw e_2.error;return[7];case 10:return[7];case 11:subscriber.complete();return[2];}});});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
function executeSchedule(parentSubscription,scheduler,work,delay,repeat){if(delay===void 0){delay=0;}if(repeat===void 0){repeat=false;}var scheduleSubscription=scheduler.schedule(function(){work();if(repeat){parentSubscription.add(this.schedule(null,delay));}else{this.unsubscribe();}},delay);parentSubscription.add(scheduleSubscription);if(!repeat){return scheduleSubscription;}}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
function mergeInternals(source,subscriber,project,concurrent,onBeforeNext,expand,innerSubScheduler,additionalFinalizer){var buffer=[];var active=0;var index=0;var isComplete=false;var checkComplete=function(){if(isComplete&&!buffer.length&&!active){subscriber.complete();}};var outerNext=function(value){return active<concurrent?doInnerSub(value):buffer.push(value);};var doInnerSub=function(value){expand&&subscriber.next(value);active++;var innerComplete=false;innerFrom(project(value,index++)).subscribe(createOperatorSubscriber(subscriber,function(innerValue){onBeforeNext===null||onBeforeNext===void 0?void 0:onBeforeNext(innerValue);if(expand){outerNext(innerValue);}else{subscriber.next(innerValue);}},function(){innerComplete=true;},undefined,function(){if(innerComplete){try{active--;var _loop_1=function(){var bufferedValue=buffer.shift();if(innerSubScheduler){executeSchedule(subscriber,innerSubScheduler,function(){return doInnerSub(bufferedValue);});}else{doInnerSub(bufferedValue);}};while(buffer.length&&active<concurrent){_loop_1();}checkComplete();}catch(err){subscriber.error(err);}}}));};source.subscribe(createOperatorSubscriber(subscriber,outerNext,function(){isComplete=true;checkComplete();}));return function(){additionalFinalizer===null||additionalFinalizer===void 0?void 0:additionalFinalizer();};}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
function mergeMap(project,resultSelector,concurrent){if(concurrent===void 0){concurrent=Infinity;}if(isFunction(resultSelector)){return mergeMap(function(a,i){return map(function(b,ii){return resultSelector(a,b,i,ii);})(innerFrom(project(a,i)));},concurrent);}else if(typeof resultSelector==='number'){concurrent=resultSelector;}return operate(function(source,subscriber){return mergeInternals(source,subscriber,project,concurrent);});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
function mergeAll(concurrent){if(concurrent===void 0){concurrent=Infinity;}return mergeMap(identity,concurrent);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/empty.js
/* unused harmony import specifier */ var empty_Observable;
var EMPTY=new Observable(function(subscriber){return subscriber.complete();});function empty(scheduler){return scheduler?emptyScheduled(scheduler):EMPTY;}function emptyScheduled(scheduler){return new empty_Observable(function(subscriber){return scheduler.schedule(function(){return subscriber.complete();});});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/args.js
function last(arr){return arr[arr.length-1];}function popResultSelector(args){return isFunction(last(args))?args.pop():undefined;}function popScheduler(args){return isScheduler(last(args))?args.pop():undefined;}function popNumber(args,defaultValue){return typeof last(args)==='number'?args.pop():defaultValue;}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
function observeOn(scheduler,delay){if(delay===void 0){delay=0;}return operate(function(source,subscriber){source.subscribe(createOperatorSubscriber(subscriber,function(value){return executeSchedule(subscriber,scheduler,function(){return subscriber.next(value);},delay);},function(){return executeSchedule(subscriber,scheduler,function(){return subscriber.complete();},delay);},function(err){return executeSchedule(subscriber,scheduler,function(){return subscriber.error(err);},delay);}));});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
function subscribeOn(scheduler,delay){if(delay===void 0){delay=0;}return operate(function(source,subscriber){subscriber.add(scheduler.schedule(function(){return source.subscribe(subscriber);},delay));});}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
function scheduleObservable(input,scheduler){return innerFrom(input).pipe(subscribeOn(scheduler),observeOn(scheduler));}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
function schedulePromise(input,scheduler){return innerFrom(input).pipe(subscribeOn(scheduler),observeOn(scheduler));}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
function scheduleArray(input,scheduler){return new Observable(function(subscriber){var i=0;return scheduler.schedule(function(){if(i===input.length){subscriber.complete();}else{subscriber.next(input[i++]);if(!subscriber.closed){this.schedule();}}});});}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
function scheduleIterable(input,scheduler){return new Observable(function(subscriber){var iterator;executeSchedule(subscriber,scheduler,function(){iterator=input[iterator_iterator]();executeSchedule(subscriber,scheduler,function(){var _a;var value;var done;try{_a=iterator.next(),value=_a.value,done=_a.done;}catch(err){subscriber.error(err);return;}if(done){subscriber.complete();}else{subscriber.next(value);}},0,true);});return function(){return isFunction(iterator===null||iterator===void 0?void 0:iterator.return)&&iterator.return();};});}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
function scheduleAsyncIterable(input,scheduler){if(!input){throw new Error('Iterable cannot be null');}return new Observable(function(subscriber){executeSchedule(subscriber,scheduler,function(){var iterator=input[Symbol.asyncIterator]();executeSchedule(subscriber,scheduler,function(){iterator.next().then(function(result){if(result.done){subscriber.complete();}else{subscriber.next(result.value);}});},0,true);});});}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
function scheduleReadableStreamLike(input,scheduler){return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input),scheduler);}
;// ../../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
function scheduled(input,scheduler){if(input!=null){if(isInteropObservable(input)){return scheduleObservable(input,scheduler);}if(isArrayLike(input)){return scheduleArray(input,scheduler);}if(isPromise(input)){return schedulePromise(input,scheduler);}if(isAsyncIterable(input)){return scheduleAsyncIterable(input,scheduler);}if(isIterable(input)){return scheduleIterable(input,scheduler);}if(isReadableStreamLike(input)){return scheduleReadableStreamLike(input,scheduler);}}throw createInvalidObservableTypeError(input);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/from.js
function from(input,scheduler){return scheduler?scheduled(input,scheduler):innerFrom(input);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/merge.js
function merge(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i];}var scheduler=popScheduler(args);var concurrent=popNumber(args,Infinity);var sources=args;return!sources.length?EMPTY:sources.length===1?innerFrom(sources[0]):mergeAll(concurrent)(from(sources,scheduler));}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js
function concatAll(){return mergeAll(1);}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/concat.js
function concat(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i];}return concatAll()(from(args,popScheduler(args)));}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/startWith.js
function startWith(){var values=[];for(var _i=0;_i<arguments.length;_i++){values[_i]=arguments[_i];}var scheduler=popScheduler(values);return operate(function(source,subscriber){(scheduler?concat(values,source,scheduler):concat(values,source)).subscribe(subscriber);});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
var EmptyError=createErrorClass(function(_super){return function EmptyErrorImpl(){_super(this);this.name='EmptyError';this.message='no elements in sequence';};});
;// ../../node_modules/rxjs/dist/esm5/internal/firstValueFrom.js
function firstValueFrom(source,config){var hasConfig=typeof config==='object';return new Promise(function(resolve,reject){var subscriber=new SafeSubscriber({next:function(value){resolve(value);subscriber.unsubscribe();},error:reject,complete:function(){if(hasConfig){resolve(config.defaultValue);}else{reject(new EmptyError());}}});source.subscribe(subscriber);});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/share.js
function share(options){if(options===void 0){options={};}var _a=options.connector,connector=_a===void 0?function(){return new Subject();}:_a,_b=options.resetOnError,resetOnError=_b===void 0?true:_b,_c=options.resetOnComplete,resetOnComplete=_c===void 0?true:_c,_d=options.resetOnRefCountZero,resetOnRefCountZero=_d===void 0?true:_d;return function(wrapperSource){var connection;var resetConnection;var subject;var refCount=0;var hasCompleted=false;var hasErrored=false;var cancelReset=function(){resetConnection===null||resetConnection===void 0?void 0:resetConnection.unsubscribe();resetConnection=undefined;};var reset=function(){cancelReset();connection=subject=undefined;hasCompleted=hasErrored=false;};var resetAndUnsubscribe=function(){var conn=connection;reset();conn===null||conn===void 0?void 0:conn.unsubscribe();};return operate(function(source,subscriber){refCount++;if(!hasErrored&&!hasCompleted){cancelReset();}var dest=subject=subject!==null&&subject!==void 0?subject:connector();subscriber.add(function(){refCount--;if(refCount===0&&!hasErrored&&!hasCompleted){resetConnection=handleReset(resetAndUnsubscribe,resetOnRefCountZero);}});dest.subscribe(subscriber);if(!connection&&refCount>0){connection=new SafeSubscriber({next:function(value){return dest.next(value);},error:function(err){hasErrored=true;cancelReset();resetConnection=handleReset(reset,resetOnError,err);dest.error(err);},complete:function(){hasCompleted=true;cancelReset();resetConnection=handleReset(reset,resetOnComplete);dest.complete();}});innerFrom(source).subscribe(connection);}})(wrapperSource);};}function handleReset(reset,on){var args=[];for(var _i=2;_i<arguments.length;_i++){args[_i-2]=arguments[_i];}if(on===true){reset();return;}if(on===false){return;}var onSubscriber=new SafeSubscriber({next:function(){onSubscriber.unsubscribe();reset();}});return innerFrom(on.apply(void 0,__spreadArray([],__read(args)))).subscribe(onSubscriber);}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js
function takeUntil(notifier){return operate(function(source,subscriber){innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber,function(){return subscriber.complete();},noop));!subscriber.closed&&source.subscribe(subscriber);});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/pairwise.js
function pairwise(){return operate(function(source,subscriber){var prev;var hasPrev=false;source.subscribe(createOperatorSubscriber(subscriber,function(value){var p=prev;prev=value;hasPrev&&subscriber.next([p,value]);hasPrev=true;}));});}
;// ../../libs/common/src/auth/enums/authentication-status.ts
/**
 * The authentication status of the user
 *
 * See `AuthService.authStatusFor$` for details on how we determine the user's `AuthenticationStatus`
 */
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var AuthenticationStatus;
(function (AuthenticationStatus) {
    /**
     * User is not authenticated
     *  - The user does not have an active account userId and/or an access token in state
     */
    AuthenticationStatus[AuthenticationStatus["LoggedOut"] = 0] = "LoggedOut";
    /**
     * User is authenticated but not decrypted
     *  - The user has an access token, but no user key in state
     *  - Vault data cannot be decrypted (because there is no user key)
     */
    AuthenticationStatus[AuthenticationStatus["Locked"] = 1] = "Locked";
    /**
     * User is authenticated and decrypted
     *  - The user has an access token and a user key in state
     *  - Vault data can be decrypted (via user key)
     */
    AuthenticationStatus[AuthenticationStatus["Unlocked"] = 2] = "Unlocked";
})(AuthenticationStatus || (AuthenticationStatus = {}));

// EXTERNAL MODULE: ../../node_modules/path-browserify/index.js
var path_browserify = __webpack_require__(58803);
// EXTERNAL MODULE: ../../node_modules/buffer/index.js
var node_modules_buffer = __webpack_require__(97763);
;// ../../node_modules/rxjs/dist/esm5/internal/observable/of.js
function of(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i];}var scheduler=popScheduler(args);return from(args,scheduler);}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js
function switchMap(project,resultSelector){return operate(function(source,subscriber){var innerSubscriber=null;var index=0;var isComplete=false;var checkComplete=function(){return isComplete&&!innerSubscriber&&subscriber.complete();};source.subscribe(createOperatorSubscriber(subscriber,function(value){innerSubscriber===null||innerSubscriber===void 0?void 0:innerSubscriber.unsubscribe();var innerIndex=0;var outerIndex=index++;innerFrom(project(value,outerIndex)).subscribe(innerSubscriber=createOperatorSubscriber(subscriber,function(innerValue){return subscriber.next(resultSelector?resultSelector(value,innerValue,outerIndex,innerIndex++):innerValue);},function(){innerSubscriber=null;checkComplete();}));},function(){isComplete=true;checkComplete();}));});}
;// ../../node_modules/tldts-core/dist/es6/src/domain.js
/**
 * Check if `vhost` is a valid suffix of `hostname` (top-domain)
 *
 * It means that `vhost` needs to be a suffix of `hostname` and we then need to
 * make sure that: either they are equal, or the character preceding `vhost` in
 * `hostname` is a '.' (it should not be a partial label).
 *
 * * hostname = 'not.evil.com' and vhost = 'vil.com'      => not ok
 * * hostname = 'not.evil.com' and vhost = 'evil.com'     => ok
 * * hostname = 'not.evil.com' and vhost = 'not.evil.com' => ok
 */function shareSameDomainSuffix(hostname,vhost){if(hostname.endsWith(vhost)){return hostname.length===vhost.length||hostname[hostname.length-vhost.length-1]==='.';}return false;}/**
 * Given a hostname and its public suffix, extract the general domain.
 */function extractDomainWithSuffix(hostname,publicSuffix){// Locate the index of the last '.' in the part of the `hostname` preceding
// the public suffix.
//
// examples:
//   1. not.evil.co.uk  => evil.co.uk
//         ^    ^
//         |    | start of public suffix
//         | index of the last dot
//
//   2. example.co.uk   => example.co.uk
//     ^       ^
//     |       | start of public suffix
//     |
//     | (-1) no dot found before the public suffix
const publicSuffixIndex=hostname.length-publicSuffix.length-2;const lastDotBeforeSuffixIndex=hostname.lastIndexOf('.',publicSuffixIndex);// No '.' found, then `hostname` is the general domain (no sub-domain)
if(lastDotBeforeSuffixIndex===-1){return hostname;}// Extract the part between the last '.'
return hostname.slice(lastDotBeforeSuffixIndex+1);}/**
 * Detects the domain based on rules and upon and a host string
 */function getDomain(suffix,hostname,options){// Check if `hostname` ends with a member of `validHosts`.
if(options.validHosts!==null){const validHosts=options.validHosts;for(const vhost of validHosts){if(/*@__INLINE__*/shareSameDomainSuffix(hostname,vhost)){return vhost;}}}let numberOfLeadingDots=0;if(hostname.startsWith('.')){while(numberOfLeadingDots<hostname.length&&hostname[numberOfLeadingDots]==='.'){numberOfLeadingDots+=1;}}// If `hostname` is a valid public suffix, then there is no domain to return.
// Since we already know that `getPublicSuffix` returns a suffix of `hostname`
// there is no need to perform a string comparison and we only compare the
// size.
if(suffix.length===hostname.length-numberOfLeadingDots){return null;}// To extract the general domain, we start by identifying the public suffix
// (if any), then consider the domain to be the public suffix with one added
// level of depth. (e.g.: if hostname is `not.evil.co.uk` and public suffix:
// `co.uk`, then we take one more level: `evil`, giving the final result:
// `evil.co.uk`).
return/*@__INLINE__*/extractDomainWithSuffix(hostname,suffix);}
;// ../../node_modules/tldts-core/dist/es6/src/domain-without-suffix.js
/**
 * Return the part of domain without suffix.
 *
 * Example: for domain 'foo.com', the result would be 'foo'.
 */function getDomainWithoutSuffix(domain,suffix){// Note: here `domain` and `suffix` cannot have the same length because in
// this case we set `domain` to `null` instead. It is thus safe to assume
// that `suffix` is shorter than `domain`.
return domain.slice(0,-suffix.length-1);}
;// ../../node_modules/tldts-core/dist/es6/src/extract-hostname.js
/**
 * Matches an ASCII tab (U+0009) or newline (U+000A / U+000D). The WHATWG URL
 * parser strips these before parsing; we only allocate a cleaned copy (and
 * re-parse) on the rare input that actually contains one.
 */const CONTROL_CHARS=/[\t\n\r]/g;// Set by `extractHostname` (a module-scope flag, read synchronously by
// `parseImpl` right after the call — same pattern as the reused RESULT object).
// `true` ONLY when extraction validated the returned host inline (a confirmed-
// valid, "simple" authority) so `parseImpl` can skip the separate
// `isValidHostname` pass. `false` in every other case (validation disabled, a
// complex authority — userinfo/port/brackets/trailing-dot/control — an invalid
// host, or a non-main return path); `parseImpl` then validates as usual. The
// fast path can only ever SKIP a redundant scan for hosts already known valid,
// never accept an invalid one.
let extractedHostnameValidated=false;/**
 * True if char `code` is a valid hostname character. This is the per-char half
 * of `is-valid.ts`'s `isValidAscii` (a-z, 0-9, > U+007F) PLUS three additions:
 * A-Z (the host is lowercased before validation, so uppercase ≡ a valid
 * lowercase letter) and '-' / '_' (valid inside a label). KEEP IN SYNC with
 * `is-valid.ts`: these rules are deliberately duplicated to validate during
 * extraction, so any change to the accepted character set there must be
 * mirrored here (and vice-versa).
 */function isValidHostnameChar(code){return code>=97&&code<=122||// a-z
code>=48&&code<=57||// 0-9
code>127||// non-ASCII (accepted, not punycode-checked)
code>=65&&code<=90||// A-Z (becomes valid once lowercased)
code===45||// '-'
code===95// '_'
;}/**
 * Classify scheme `url.slice(schemeStart, colonIndex)` as a WHATWG special
 * scheme without allocating a substring (case-insensitive via `| 32`).
 * Special schemes: ftp, file, http, https, ws, wss
 * (https://url.spec.whatwg.org/#special-scheme).
 *
 * @returns 0 = not special, 1 = special, 2 = file (its host sits only between
 *          "//" and the next slash).
 */function getSpecialScheme(url,schemeStart,colonIndex){const length=colonIndex-schemeStart;const c0=url.charCodeAt(schemeStart)|32;if(length===2){return c0===119&&(url.charCodeAt(schemeStart+1)|32)===115?1:0;// ws
}else if(length===3){const c1=url.charCodeAt(schemeStart+1)|32;const c2=url.charCodeAt(schemeStart+2)|32;if(c0===119&&c1===115&&c2===115)return 1;// wss
if(c0===102&&c1===116&&c2===112)return 1;// ftp
return 0;}else if(length===4){const c1=url.charCodeAt(schemeStart+1)|32;const c2=url.charCodeAt(schemeStart+2)|32;const c3=url.charCodeAt(schemeStart+3)|32;if(c0===104&&c1===116&&c2===116&&c3===112)return 1;// http
if(c0===102&&c1===105&&c2===108&&c3===101)return 2;// file
return 0;}else if(length===5){return c0===104&&(url.charCodeAt(schemeStart+1)|32)===116&&(url.charCodeAt(schemeStart+2)|32)===116&&(url.charCodeAt(schemeStart+3)|32)===112&&(url.charCodeAt(schemeStart+4)|32)===115?1:0;// https
}return 0;}/**
 * Extract a hostname from `url`, matching a WHATWG URL parser's host-boundary
 * behaviour (https://url.spec.whatwg.org/#concept-basic-url-parser) for tldts'
 * scope. It deliberately does NOT normalise the host (no IDNA/punycode or IPv4
 * canonicalisation; IPv6 brackets are stripped, not compressed), strips trailing
 * dots, and stays lenient where a strict parser rejects (bare host:port,
 * out-of-range port, user@host) — all documented deviations.
 *
 * @param urlIsValidHostname - when true, `url` is already a valid hostname and is
 *   returned by the same reference (factory.ts skips re-validation on that
 *   identity), keeping the common path allocation-free.
 * @param validate - when true, validate the host inline during the authority
 *   scan and publish the verdict via `extractedHostnameValidated` so `parseImpl`
 *   can skip the redundant `isValidHostname` pass for simple authorities.
 */function extractHostname(url,urlIsValidHostname,validate=false){let start=0;let end=url.length;let hasUpper=false;let isSpecial=false;extractedHostnameValidated=false;if(!urlIsValidHostname){// Data URLs never carry a host (and may be huge — short-circuit them).
if(url.startsWith('data:')){return null;}// WHATWG step 1: trim leading/trailing C0 control or space (<= U+0020).
// Tab/newline elsewhere are handled lazily below.
while(start<url.length&&url.charCodeAt(start)<=32){start+=1;}while(end>start+1&&url.charCodeAt(end-1)<=32){end-=1;}if(url.charCodeAt(start)===47/* '/' */&&url.charCodeAt(start+1)===47/* '/' */){// Scheme-relative reference ("//host/path").
start+=2;}else{const indexOfProtocol=url.indexOf(':/',start);if(indexOfProtocol!==-1){// "scheme://…". Classify the scheme, then position `start` at the host.
const special=getSpecialScheme(url,start,indexOfProtocol);if(special===1){// Special scheme: skip the run of '/' and '\' after it
// (special-authority-(ignore-)slashes states; '\' acts as '/').
isSpecial=true;start=indexOfProtocol+2;while(url.charCodeAt(start)===47/* '/' */||url.charCodeAt(start)===92/* '\' */){start+=1;}}else if(special===2){// file: the host is only what sits between "//" and the next slash, so
// "file://h/x" => "h" but "file:///x" / "file:/x" => no host.
isSpecial=true;start=indexOfProtocol+1;let slashes=0;while((url.charCodeAt(start)===47||url.charCodeAt(start)===92)&&slashes<2){start+=1;slashes+=1;}if(slashes<2){return null;}}else{// Unknown scheme: validate the WHATWG scheme grammar [A-Za-z0-9+.-];
// a control char means it was split by a tab/newline (strip + re-parse).
for(let i=start;i<indexOfProtocol;i+=1){const code=url.charCodeAt(i)|32;if(!(code>=97&&code<=122||// [a, z]
code>=48&&code<=57||// [0, 9]
code===46||// '.'
code===45||// '-'
code===43// '+'
)){const raw=url.charCodeAt(i);if(raw===9||raw===10||raw===13){return extractHostname(url.replace(CONTROL_CHARS,''),urlIsValidHostname,validate);}return null;}}// A non-special scheme has an authority only after "//" (else it is an
// opaque path with no host). `indexOf(':/')` already gave the first '/'.
if(url.charCodeAt(indexOfProtocol+2)===47/* '/' */){start=indexOfProtocol+3;}else{return null;}}}else if(url.charCodeAt(start)!==91/* '[' */){// Cold path: no scheme "://", and not a bare IPv6 literal (whose first
// ':' would otherwise look like a scheme separator; "[…]" falls through
// to the ipv6 handling below). May be a bare host, a host:port, a
// user@host, a slash-less special scheme ("https:host"), or an opaque
// URI ("mailto:", "tel:", "urn:…").
let indexOfColon=-1;for(let i=start;i<end;i+=1){const code=url.charCodeAt(i);if(code===9||code===10||code===13){return extractHostname(url.replace(CONTROL_CHARS,''),urlIsValidHostname,validate);}if(code===58/* ':' */){indexOfColon=i;break;}if(code===47||code===92||code===63||code===35){break;}}if(indexOfColon!==-1){// An '@' before the next delimiter => the ':' is userinfo, not a
// scheme ("user:pass@host", "mailto:a@b"): keep the whole authority.
let hasIdentifier=false;for(let i=indexOfColon+1;i<end;i+=1){const code=url.charCodeAt(i);if(code===47||code===92||code===63||code===35){break;}if(code===64/* '@' */){hasIdentifier=true;break;}}if(!hasIdentifier){// All-digits after ':' => a bare "host:port" (tldts accepts
// hostnames too); keep `start` and let the port handling trim it.
let allDigits=true;let i=indexOfColon+1;for(;i<end;i+=1){const code=url.charCodeAt(i);if(code===47||code===92||code===63||code===35){break;}if(code<48/* '0' */||code>57/* '9' */){allDigits=false;break;}}if(i===indexOfColon+1){allDigits=false;// nothing after ':' => not a port
}if(!allDigits){const special=getSpecialScheme(url,start,indexOfColon);if(special===0){// No "://" anywhere on the cold path and not a special scheme.
// A second ':' before the host's end marks a bare, unbracketed
// IPv6 literal ("2a01:e35::1"): fall through and let the host
// loop + isIp classify it. Without one this is an opaque path
// with no host ("mailto:x", "foo:bar").
let isBareIpv6=false;for(let j=indexOfColon+1;j<end;j+=1){const code=url.charCodeAt(j);if(code===47||code===92||code===63||code===35){break;}if(code===58/* ':' */){isBareIpv6=true;break;}}if(!isBareIpv6){return null;}}else{isSpecial=true;start=indexOfColon+1;if(special===2){// file (e.g. "file:\\host"): host only between "//" and next slash.
let slashes=0;while((url.charCodeAt(start)===47||url.charCodeAt(start)===92)&&slashes<2){start+=1;slashes+=1;}if(slashes<2){return null;}}else{while(url.charCodeAt(start)===47||url.charCodeAt(start)===92){start+=1;}}}}}}}}// Find the host's end: first '/', '?' or '#' (and '\' for special URLs,
// which WHATWG treats like '/'). Track the last '@', ']' and ':' for
// userinfo, ipv6 and port, plus the first ':' of the host (reset at each
// '@') to tell a bare IPv6 (>= 2 colons) from a host:port (exactly one);
// flag uppercase and a stray tab/newline. The loop is split on `code < 64`
// so common host characters take fewer comparisons.
//
// When `validate`, also accumulate `is-valid.ts`'s checks over the scanned
// run so a simple authority's host can be validated in this single pass.
// `vValid` only stays meaningful for a "simple" authority (no userinfo, port,
// brackets, control or trailing dot); those cases clear it / are rejected by
// the guard below, falling back to `isValidHostname`.
let indexOfIdentifier=-1;let indexOfClosingBracket=-1;let indexOfPort=-1;let indexOfFirstColon=-1;let hasControl=false;let vValid=validate;// seeded true when validating; cleared on the first invalid char
let vLastDot=start-1;// mirrors is-valid.ts `lastDotIndex = -1` at host start
let vLastCode=-1;if(validate&&start<end){// First-char rule: must be a valid host char, '.', or '_' (NOT '-').
const c0=url.charCodeAt(start);if(!(/*@__INLINE__*/isValidHostnameChar(c0)||c0===46/* '.' */||c0===95/* '_' */)||c0===45/* '-' (isValidHostnameChar allows it mid-label, not first) */){vValid=false;}}for(let i=start;i<end;i+=1){const code=url.charCodeAt(i);if(code<64){if(code===47||code===35||code===63){end=i;break;}else if(code===58/* ':' */){if(indexOfFirstColon===-1){indexOfFirstColon=i;}indexOfPort=i;}else if(code===9||code===10||code===13){hasControl=true;}else if(validate){if(code===46/* '.' */){if(i-vLastDot>64||vLastCode===46||vLastCode===45){vValid=false;}vLastDot=i;}else if(code<48||code>57){// < 64 and not a delimiter/dot/digit => only '-' (45) is a valid
// host char here; everything else (space, %, !, etc.) is invalid.
// A '-' must also not START a label (the byte right after a '.') —
// mirrors is-valid.ts; the first label is covered by the first-char
// rule above. (RFC 1034 §3.5 / RFC 1035 §2.3.1 LDH.)
if(code!==45||vLastCode===46/* label-leading '-' */){vValid=false;}}}}else if(isSpecial&&code===92/* '\' */){end=i;break;}else if(code===64/* '@' */){indexOfIdentifier=i;indexOfFirstColon=-1;// colons before '@' are userinfo, not the host
}else if(code===93/* ']' */){indexOfClosingBracket=i;}else if(code>=65&&code<=90){hasUpper=true;}else if(validate&&!(/*@__INLINE__*/isValidHostnameChar(code))){// >= 64, not '@'/']'/upper: valid only if a-z, '_', or non-ASCII.
vValid=false;}if(validate){vLastCode=code;}}// A tab/newline inside the authority: strip everything and re-parse (rare).
if(hasControl){return extractHostname(url.replace(CONTROL_CHARS,''),urlIsValidHostname,validate);}// Skip userinfo. '>= start' so an empty userinfo ("http://@host") works too.
if(indexOfIdentifier!==-1&&indexOfIdentifier>=start&&indexOfIdentifier<end){start=indexOfIdentifier+1;}if(url.charCodeAt(start)===91/* '[' */){// ipv6 address: return what is between the brackets, or null if unclosed.
if(indexOfClosingBracket!==-1){return url.slice(start+1,indexOfClosingBracket).toLowerCase();}return null;}else if(indexOfPort!==-1&&indexOfPort>start&&indexOfPort<end&&// A host:port has exactly one ':' in the host (so its first ':' is its
// last); a bare, unbracketed IPv6 literal ("2a01:e35::1") has >= 2, so
// its first ':' precedes the last. Only the former has a ':port' to trim.
indexOfFirstColon===indexOfPort){end=indexOfPort;// trim ':port'
}// Empty authority ("http://", "file:///path", "//"); only reachable here via
// extraction — a bare valid hostname never lands here.
if(start>=end){return null;}// Publish the inline-validation verdict — but only for a "simple" authority,
// where the scanned run equals the final host: no userinfo skip, no port
// trim, no brackets, no trailing dot (trimmed below), and length within RFC
// limits. Anything else leaves it `false` so `parseImpl` re-validates.
//
// Every clause below is load-bearing for CORRECTNESS, not just speed: the
// loop accumulates `vValid` over the whole scanned run (it does not stop at
// ':' or '@', so any port/userinfo bytes are included), so the verdict is
// only sound when that run equals the final host. Do not drop a clause as
// "redundant" — e.g. without `indexOfPort === -1`, `host:8080` would be
// wrongly accepted.
if(validate&&vValid&&indexOfIdentifier===-1&&indexOfPort===-1&&indexOfClosingBracket===-1&&url.charCodeAt(end-1)!==46/* no trailing dot */&&end-start<=255&&// total length
end-vLastDot-1<=63&&// last label length
vLastCode!==45/* last char not '-' */){extractedHostnameValidated=true;}}// Trim trailing dots
while(end>start+1&&url.charCodeAt(end-1)===46/* '.' */){end-=1;}const hostname=start!==0||end!==url.length?url.slice(start,end):url;if(hasUpper){return hostname.toLowerCase();}return hostname;}
;// ../../node_modules/tldts-core/dist/es6/src/is-ip.js
/**
 * Check if a hostname is an IP. You should be aware that this only works
 * because `hostname` is already garanteed to be a valid hostname!
 */function isProbablyIpv4(hostname){// Cannot be shorted than 1.1.1.1
if(hostname.length<7){return false;}// Cannot be longer than: 255.255.255.255
if(hostname.length>15){return false;}let numberOfDots=0;for(let i=0;i<hostname.length;i+=1){const code=hostname.charCodeAt(i);if(code===46/* '.' */){numberOfDots+=1;}else if(code<48/* '0' */||code>57/* '9' */){return false;}}return numberOfDots===3&&hostname.charCodeAt(0)!==46/* '.' */&&hostname.charCodeAt(hostname.length-1)!==46/* '.' */;}/**
 * Similar to isProbablyIpv4.
 */function isProbablyIpv6(hostname){if(hostname.length<3){return false;}let start=hostname.startsWith('[')?1:0;let end=hostname.length;if(hostname[end-1]===']'){end-=1;}// We only consider the maximum size of a normal IPV6. Note that this will
// fail on so-called "IPv4 mapped IPv6 addresses" but this is a corner-case
// and a proper validation library should be used for these.
if(end-start>39){return false;}let hasColon=false;for(;start<end;start+=1){const code=hostname.charCodeAt(start);if(code===58/* ':' */){hasColon=true;}else if(!(code>=48&&code<=57||// 0-9
code>=97&&code<=102||// a-f
code>=65&&code<=70// A-F (RFC 4291 §2.2: an IPv6 hextet is hex digits only)
)){return false;}}return hasColon;}/**
 * Check if `hostname` is *probably* a valid ip addr (either ipv6 or ipv4).
 * This *will not* work on any string. We need `hostname` to be a valid
 * hostname.
 */function isIp(hostname){return isProbablyIpv6(hostname)||isProbablyIpv4(hostname);}
;// ../../node_modules/tldts-core/dist/es6/src/is-special-use.js
/**
 * Special-use domain names from the IANA "Special-Use Domain Names" registry:
 * the authoritative list, created by RFC 6761 and maintained as new RFCs add to
 * it: https://www.iana.org/assignments/special-use-domain-names/
 * Snapshot: 2026-05-24. (RFC 6761 is not obsoleted; draft-hoffman-rfc6761bis
 * proposes to retire its prose but keep this registry, so the registry is the
 * source of truth; re-sync this list against it.)
 *
 * These names never correspond to a public registration, yet neither
 * `isIcann` nor `isPrivate` marks one as special-use: most are absent from the
 * Public Suffix List (so `a.test` looks like a registrable domain), and the
 * few that are listed (`onion`, `home.arpa`) appear there as ordinary ICANN
 * suffixes. `isSpecialUse` is the single signal that covers them all.
 *
 * Per the registry and RFC 6761 ("and any names falling within these domains"),
 * the designation covers each listed name AND all of its sub-domains. DNS labels
 * are case-insensitive (RFC 4343); `hostname` is expected to be already
 * lower-cased and trailing-dot-stripped, as produced by `extractHostname`, the
 * same normalization the Public-Suffix-List lookup relies on.
 *
 * Two groups of registry entries are intentionally excluded: the numeric
 * reverse-DNS delegation zones (`10.in-addr.arpa`, the `*.ip6.arpa` ranges, …),
 * which are reverse-DNS PTR zones rather than hostnames and whose parents
 * (`in-addr.arpa`/`ip6.arpa`) are already in the Public Suffix List; and the
 * deprecated `eap-noob.arpa` entry.
 */const SPECIAL_USE_DOMAINS=['test',// RFC 6761
'localhost',// RFC 6761
'invalid',// RFC 6761
'example',// RFC 6761
'example.com',// RFC 6761
'example.net',// RFC 6761
'example.org',// RFC 6761
'local',// RFC 6762 (mDNS)
'onion',// RFC 7686 (Tor)
'alt',// RFC 9476
'home.arpa',// RFC 8375
'ipv4only.arpa',// RFC 8880
'resolver.arpa',// RFC 9462
'service.arpa',// RFC 9665
'6tisch.arpa',// RFC 9031
'eap.arpa'// RFC 9965
];/**
 * Return `true` if `hostname` is, or is a sub-domain of, a special-use domain
 * (see the registry note above). Expects an already-normalized `hostname`.
 */function isSpecialUse(hostname){for(const name of SPECIAL_USE_DOMAINS){// Match on a label boundary: `hostname` is either exactly `name` or ends
// with `.name` (so `latest` is not matched by `test`, nor `myexample.com`
// by `example.com`).
if(hostname.endsWith(name)&&(hostname.length===name.length||hostname.charCodeAt(hostname.length-name.length-1)===46)/* '.' */){return true;}}return false;}
;// ../../node_modules/tldts-core/dist/es6/src/is-valid.js
Object.defineProperty(is_valid, "name", { value: "default", configurable: true });
/**
 * Implements fast shallow verification of hostnames. This does not perform a
 * struct check on the content of labels (classes of Unicode characters, etc.)
 * but instead check that the structure is valid (number of labels, length of
 * labels, etc.).
 *
 * If you need stricter validation, consider using an external library.
 */// KEEP IN SYNC with `extract-hostname.ts` `isValidHostnameChar` + its inline
// scan/verdict, which duplicate these structural rules to validate during
// extraction (a perf fusion). That copy additionally accepts A-Z (the host is
// not yet lowercased there) and folds in '-' / '_'. Any change to the accepted
// character set or the label/length rules here must be mirrored there.
function isValidAscii(code){return code>=97&&code<=122||code>=48&&code<=57||code>127;}/**
 * Check if a hostname string is valid. It's usually a preliminary check before
 * trying to use getDomain or anything else.
 *
 * Beware: it does not check if the TLD exists.
 *//* harmony default export */ function is_valid(hostname){if(hostname.length>255){return false;}if(hostname.length===0){return false;}if(/*@__INLINE__*/!isValidAscii(hostname.charCodeAt(0))&&hostname.charCodeAt(0)!==46&&// '.' (dot)
hostname.charCodeAt(0)!==95// '_' (underscore)
){return false;}// Validate hostname according to RFC
let lastDotIndex=-1;let lastCharCode=-1;const len=hostname.length;for(let i=0;i<len;i+=1){const code=hostname.charCodeAt(i);if(code===46/* '.' */){if(// Check that previous label is < 63 bytes long (64 = 63 + '.')
i-lastDotIndex>64||// Check that previous character was not already a '.'
lastCharCode===46||// Check that the previous label does not end with '-' (RFC 1035 §2.3.1 LDH).
// '_' is intentionally NOT restricted: DNS allows any octet (RFC 2181 §11) and
// WHATWG URL does not treat '_' as a forbidden host code point.
lastCharCode===45){return false;}lastDotIndex=i;}else if(// A forbidden character in the label...
!(/*@__INLINE__*/isValidAscii(code)||code===45||code===95)||// ...or a '-' starting a label (the byte right after a '.'). A label must
// not begin with a hyphen (RFC 1034 §3.5 / RFC 1035 §2.3.1 LDH, as amended
// by RFC 1123 §2.1; cf. UTS #46 CheckHyphens). The first label is covered by
// the leading-character guard above; mirrors the trailing-'-' rule below.
code===45&&lastCharCode===46){return false;}lastCharCode=code;}return(// Check that last label is shorter than 63 chars
len-lastDotIndex-1<=63&&// Check that the last character is an allowed trailing label character.
// Since we already checked that the char is a valid hostname character,
// we only need to check that it's different from '-'.
lastCharCode!==45);}
;// ../../node_modules/tldts-core/dist/es6/src/options.js
function setDefaultsImpl({allowIcannDomains=true,allowPrivateDomains=false,detectIp=true,detectSpecialUse=false,extractHostname=true,mixedInputs=true,validHosts=null,validateHostname=true}){return{allowIcannDomains,allowPrivateDomains,detectIp,detectSpecialUse,extractHostname,mixedInputs,validHosts,validateHostname};}const DEFAULT_OPTIONS=/*@__INLINE__*/setDefaultsImpl({});function setDefaults(options){if(options===undefined){return DEFAULT_OPTIONS;}return/*@__INLINE__*/setDefaultsImpl(options);}
;// ../../node_modules/tldts-core/dist/es6/src/subdomain.js
/**
 * Returns the subdomain of a hostname string
 */function getSubdomain(hostname,domain){// If `hostname` and `domain` are the same, then there is no sub-domain
if(domain.length===hostname.length){return'';}return hostname.slice(0,-domain.length-1);}
;// ../../node_modules/tldts-core/dist/es6/src/factory.js
/**
 * Implement a factory allowing to plug different implementations of suffix
 * lookup (e.g.: using a trie or the packed hashes datastructures). This is used
 * and exposed in `tldts.ts` and `tldts-experimental.ts` bundle entrypoints.
 */function getEmptyResult(){return{domain:null,domainWithoutSuffix:null,hostname:null,isIcann:null,isIp:null,isPrivate:null,isSpecialUse:null,publicSuffix:null,subdomain:null};}function resetResult(result){result.domain=null;result.domainWithoutSuffix=null;result.hostname=null;result.isIcann=null;result.isIp=null;result.isPrivate=null;result.isSpecialUse=null;result.publicSuffix=null;result.subdomain=null;}function parseImpl(url,step,suffixLookup,partialOptions,result){const options=/*@__INLINE__*/setDefaults(partialOptions);// Very fast approximate check to make sure `url` is a string. This is needed
// because the library will not necessarily be used in a typed setup and
// values of arbitrary types might be given as argument.
if(typeof url!=='string'){return result;}// Extract hostname from `url` only if needed. This can be made optional
// using `options.extractHostname`. This option will typically be used
// whenever we are sure the inputs to `parse` are already hostnames and not
// arbitrary URLs.
//
// `mixedInput` allows to specify if we expect a mix of URLs and hostnames
// as input. If only hostnames are expected then `extractHostname` can be
// set to `false` to speed-up parsing. If only URLs are expected then
// `mixedInputs` can be set to `false`. The `mixedInputs` is only a hint
// and will not change the behavior of the library.
// Whether `url` itself was already a valid hostname (only computed on the
// mixedInputs path). Lets us skip the post-extraction validation below when
// extractHostname returned `url` unchanged (same reference).
let urlIsValid=false;if(!options.extractHostname){result.hostname=url;}else if(options.mixedInputs){urlIsValid=is_valid(url);result.hostname=extractHostname(url,urlIsValid,options.validateHostname);}else{result.hostname=extractHostname(url,false,options.validateHostname);}// Check if `hostname` is a valid ip address
if(options.detectIp&&result.hostname!==null){result.isIp=isIp(result.hostname);if(result.isIp){return result;}}// Perform hostname validation if enabled. If hostname is not valid, no need to
// go further as there will be no valid domain or sub-domain. This validation
// is applied before any early returns to ensure consistent behavior across
// all API methods including getHostname().
if(options.validateHostname&&options.extractHostname&&result.hostname!==null&&// Skip the re-scan when `url` was already validated and extractHostname
// returned it unchanged (same reference => identical string, still valid).
!(urlIsValid&&result.hostname===url)&&// Skip the re-scan when extractHostname already validated the host inline
// (a confirmed-valid simple authority — see extract-hostname.ts).
!extractedHostnameValidated&&!is_valid(result.hostname)){result.hostname=null;return result;}if(step===0/* FLAG.HOSTNAME */||result.hostname===null){return result;}// Flag special-use domains, only when opted in (`detectSpecialUse`) and only
// for the full `parse()` result (FLAG.ALL). Computed here, before the
// public-suffix/domain early-returns below, so single-label names like
// `localhost` (which have no registrable domain) are still flagged.
if(step===5/* FLAG.ALL */&&options.detectSpecialUse){result.isSpecialUse=isSpecialUse(result.hostname);}// Extract public suffix
suffixLookup(result.hostname,options,result);if(step===2/* FLAG.PUBLIC_SUFFIX */||result.publicSuffix===null){return result;}// Extract domain
result.domain=getDomain(result.publicSuffix,result.hostname,options);if(step===3/* FLAG.DOMAIN */||result.domain===null){return result;}// Extract subdomain
result.subdomain=getSubdomain(result.hostname,result.domain);if(step===4/* FLAG.SUB_DOMAIN */){return result;}// Extract domain without suffix
result.domainWithoutSuffix=getDomainWithoutSuffix(result.domain,result.publicSuffix);return result;}
;// ../../node_modules/tldts-core/dist/es6/src/lookup/fast-path.js
Object.defineProperty(fast_path, "name", { value: "default", configurable: true });
/* harmony default export */ function fast_path(hostname,options,out){// Fast path for very popular suffixes; this allows to by-pass lookup
// completely as well as any extra allocation or string manipulation.
if(!options.allowPrivateDomains&&hostname.length>3){const last=hostname.length-1;const c3=hostname.charCodeAt(last);const c2=hostname.charCodeAt(last-1);const c1=hostname.charCodeAt(last-2);const c0=hostname.charCodeAt(last-3);if(c3===109/* 'm' */&&c2===111/* 'o' */&&c1===99/* 'c' */&&c0===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='com';return true;}else if(c3===103/* 'g' */&&c2===114/* 'r' */&&c1===111/* 'o' */&&c0===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='org';return true;}else if(c3===117/* 'u' */&&c2===100/* 'd' */&&c1===101/* 'e' */&&c0===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='edu';return true;}else if(c3===118/* 'v' */&&c2===111/* 'o' */&&c1===103/* 'g' */&&c0===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='gov';return true;}else if(c3===116/* 't' */&&c2===101/* 'e' */&&c1===110/* 'n' */&&c0===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='net';return true;}else if(c3===101/* 'e' */&&c2===100/* 'd' */&&c1===46/* '.' */){out.isIcann=true;out.isPrivate=false;out.publicSuffix='de';return true;}}return false;}
;// ../../node_modules/tldts-core/dist/es6/index.js

;// ../../node_modules/tldts/dist/es6/src/data/trie.js
// Auto-generated flat public-suffix trie. Do not edit.
const nodeFlags=/*#__PURE__*/new Uint8Array([1,2,1,1,1,1,1,1,1,1,1,1,0,2,2,2,0,2,2,0,2,0,0,1,0,0,2,1,1,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,0,0,0,0,0,0,1,1,1,0,2,0,0,0,0,0,0,0,2,0,2,2,0,0,2,2,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,2,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,2,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,1,0,2,2,0,0,0,2,0,1,1,0,2,0,2,2,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,0,1,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,2,2,0,2,2,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,2,0,2,2,2,2,0,0,0,0,2,0,0,0,0,0,0,2,2,0,0,0,2,2,1,1,1,1,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,2,2,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,2,2,1,2,1,1,1,2,1,1,1,1,1,0,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,0,0]);const edgeStart=/*#__PURE__*/new Uint16Array([0,0,0,9,10,17,105,110,116,123,129,135,144,145,146,147,148,149,150,152,153,154,156,158,224,237,239,240,241,256,263,264,267,268,269,272,274,294,295,297,306,311,312,330,331,334,336,337,339,373,374,376,379,380,384,386,390,393,425,428,441,442,450,452,462,476,477,478,487,524,529,545,565,571,612,613,640,667,668,816,822,825,826,827,832,837,846,868,869,870,871,872,873,874,892,894,895,898,900,901,903,905,920,935,940,941,943,944,945,946,947,949,952,957,958,959,961,962,965,968,969,970,983,985,997,1008,1016,1018,1057,1060,1064,1065,1067,1070,1081,1083,1093,1095,1101,1103,1104,1106,1109,1110,1111,1163,1165,1167,1187,1188,1189,1190,1192,1203,1234,1245,1257,1266,1273,1278,1291,1302,1315,1316,1327,1361,1362,1363,1378,1393,1465,1466,1468,1469,1503,1504,1505,1508,1512,1514,1543,1544,1552,1553,1554,1556,1558,1559,1561,1562,1563,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1590,1591,1592,1594,2049,2052,2053,2055,2062,2069,2077,2081,2092,2093,2094,2106,2107,2109,2111,2112,2119,2120,2122,2123,2125,2126,2127,2128,2129,2197,2199,2220,2221,2222,2224,2250,2251,2302,2303,2305,2312,2318,2328,2338,2391,2392,2393,2403,2417,2418,2421,2428,2429,2437,2438,2439,2440,2441,2451,2452,2453,2455,2456,2457,2459,2469,2481,2487,2519,2523,2525,2526,2528,2529,2536,2537,2539,2547,2554,2560,2565,2566,2572,2575,2581,2588,2589,2596,2604,2605,2606,2644,2650,2665,2666,2671,2689,2720,2738,2740,2743,2751,2753,2760,2808,2832,2833,2834,2835,2836,2837,2838,2839,2846,2847,2848,2849,2850,2851,2853,2854,2858,2942,2955,2956,3391,3395,3409,3461,3489,3511,3569,3591,3606,3669,3720,3758,3794,3819,3961,4007,4058,4077,4111,4126,4146,4176,4207,4230,4261,4291,4323,4350,4425,4447,4485,4495,4529,4548,4574,4616,4666,4692,4761,4762,4764,4787,4810,4846,4877,4894,4951,4964,4988,5017,5019,5053,5069,5097,5402,5411,5420,5427,5444,5448,5454,5493,5495,5502,5509,5518,5525,5526,5537,5540,5555,5556,5565,5566,5575,5584,5590,5592,5593,5594,5629,5630,5632,5640,5647,5660,5664,5666,5667,5673,5680,5694,5704,5709,5717,5725,5731,5732,5736,5738,5739,5751,5752,5753,5754,5756,5757,5760,5762,5765,5769,5770,5776,5777,5778,5780,5782,5784,5785,5786,5789,5791,5794,5795,5797,5994,6001,6002,6012,6017,6034,6048,6057,6058,6059,6063,6064,6066,6068,6074,6075,6078,6079,6081,6082,6083,6974,6978,6996,7005,7008,7014,7015,7017,7018,7019,7021,7073,7074,7077,7078,7196,7197,7208,7219,7226,7229,7238,7239,7240,7255,7310,7501,7503,7504,7506,7511,7524,7539,7546,7555,7558,7561,7568,7576,7580,7581,7582,7596,7600,7609,7610,7611,7615,7650,7651,7668,7675,7683,7684,7688,7696,7740,7741,7747,7750,7761,7766,7767,7770,7801,7802,7808,7815,7816,7824,7833,7848,7852,7904,7905,7910,7912,7915,7917,7918,7919,7928,7943,7951,7965,7977,7978,7980,7982,8004,8015,8021,8022,8034,8046,8133,8145,8147,8156,8159,8165,8190,8193,8194,8195,8197,8200,8203,8214,8216,8218,8246,8320,8327,8331,8332,8341,8363,8364,8369,8370,8449,8451,8452,8461,8465,8471,8477,8483,8493,8498,8499,8517,8528,8533,8538,8548,8554,8558,8564,8570,10178,10179,10180,10187,10189]);const edgeLength=/*#__PURE__*/new Uint8Array([3,3,3,3,3,3,3,5,8,8,2,2,3,3,3,3,3,8,5,5,5,5,5,3,3,5,5,9,12,19,8,19,8,11,9,9,8,7,7,6,8,9,16,10,7,7,11,8,6,6,9,7,11,7,14,4,4,4,4,4,4,10,7,6,6,6,6,10,10,6,10,10,22,11,9,10,10,10,9,10,8,7,7,7,8,21,13,11,11,9,10,9,13,10,8,8,9,12,9,7,10,7,7,13,7,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,8,6,3,3,3,3,3,3,2,5,3,3,3,7,2,2,2,2,2,2,3,3,3,1,1,7,8,5,2,2,7,2,2,1,4,1,11,9,9,5,5,8,5,5,5,5,5,5,5,3,3,3,3,3,11,9,9,13,7,14,7,6,6,6,7,6,6,6,6,6,10,7,11,9,4,4,4,4,4,4,6,6,6,6,6,8,7,10,9,9,9,8,9,8,10,6,9,9,8,10,10,7,8,1,9,10,12,12,12,10,9,9,10,10,9,9,1,1,5,3,3,3,3,3,3,3,3,3,3,3,3,6,6,6,4,3,3,3,7,4,4,4,3,3,6,7,3,4,1,2,2,2,6,1,2,2,2,2,2,12,5,3,3,8,9,13,4,4,4,13,9,9,11,3,12,9,2,2,2,3,3,3,3,3,8,2,2,3,3,3,3,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,3,7,10,15,7,15,15,20,15,9,10,10,12,14,14,14,12,12,12,12,12,14,14,10,10,10,10,14,9,9,9,10,14,14,14,13,13,9,9,9,9,9,9,7,8,6,8,8,6,8,13,8,8,6,13,8,11,13,8,6,13,8,6,9,10,10,12,14,14,14,12,12,12,12,14,14,10,10,10,10,9,9,9,10,14,14,11,13,13,9,9,9,9,9,9,2,6,9,2,2,3,3,3,3,3,3,3,3,3,4,4,4,2,3,3,3,3,3,3,7,2,3,2,2,5,3,3,3,3,3,3,4,2,2,2,2,2,2,3,3,3,3,3,3,3,4,5,7,2,2,12,8,10,8,10,7,18,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,2,2,3,3,3,5,5,3,8,8,6,8,6,6,4,6,7,7,7,10,11,2,5,5,3,3,3,3,3,3,5,5,6,11,10,7,7,7,4,4,4,2,3,3,3,3,3,2,7,5,5,3,3,3,3,3,3,3,3,7,7,7,11,7,6,9,6,6,8,10,8,6,8,13,4,4,4,4,4,10,8,11,8,8,8,10,10,7,10,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,5,5,5,5,5,5,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,10,13,7,8,7,11,8,8,6,9,8,8,6,6,6,8,8,6,6,6,6,6,9,7,6,4,4,4,4,4,4,4,6,6,6,9,7,8,10,8,8,2,3,3,3,3,3,2,8,9,9,2,2,2,3,3,3,2,3,3,3,9,2,2,3,3,3,3,3,3,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,12,5,5,3,5,4,2,3,2,4,3,9,2,2,2,2,2,5,5,3,8,8,13,6,10,9,4,7,9,11,2,3,7,3,3,4,1,3,4,2,9,3,3,12,5,3,7,10,10,7,4,4,6,14,7,9,7,13,2,2,2,2,2,2,3,3,3,3,3,8,15,4,4,2,3,3,3,7,4,9,9,2,3,3,3,5,3,2,2,7,2,7,6,6,7,2,4,2,2,2,2,2,2,8,8,8,9,5,2,3,3,3,3,3,3,10,7,4,4,4,4,3,4,2,3,3,3,3,3,10,7,4,4,4,4,2,3,3,3,3,10,7,4,4,4,4,3,9,6,6,6,9,13,9,2,2,2,8,7,9,5,3,3,3,5,5,12,9,10,7,8,7,6,8,6,11,12,7,9,10,4,4,7,8,11,6,7,9,8,7,10,8,9,15,8,5,4,7,2,3,3,3,2,14,10,2,14,10,2,14,3,9,13,13,10,14,16,17,11,2,14,2,14,3,9,13,10,14,16,17,11,14,10,14,2,7,3,10,7,14,10,2,14,10,9,9,17,6,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,10,10,10,12,9,4,10,11,8,8,8,7,9,5,3,3,3,3,3,3,3,3,5,8,4,4,4,4,4,4,6,16,3,3,14,3,14,2,14,9,13,10,10,14,16,17,11,6,9,10,10,12,14,14,14,12,12,12,12,14,14,10,10,10,10,14,9,9,9,10,14,14,14,9,9,9,9,9,9,2,14,9,13,10,10,14,16,17,11,6,2,14,9,17,13,10,10,14,16,17,11,6,2,14,9,13,10,14,16,17,11,2,14,9,13,10,16,11,2,14,10,19,7,2,14,9,13,10,19,10,7,14,16,17,11,6,2,14,9,13,10,19,7,14,16,17,11,2,14,9,13,17,13,10,10,14,16,17,11,6,3,2,14,9,13,10,10,14,16,17,11,6,9,10,12,14,14,14,12,12,12,12,12,14,14,14,10,10,10,14,9,9,9,9,14,14,14,13,13,14,9,9,9,9,9,9,4,11,2,14,9,13,17,13,10,19,10,7,14,16,17,11,6,2,14,9,13,17,13,10,19,10,7,14,16,17,11,6,2,9,10,10,7,17,3,3,12,12,16,15,15,12,14,14,14,20,20,13,12,12,12,12,12,12,20,25,14,14,12,12,10,10,10,10,9,9,9,25,4,9,17,10,7,14,16,21,13,13,14,20,14,13,17,24,9,12,13,25,13,21,20,17,9,9,9,9,9,9,12,17,4,4,9,9,9,10,10,12,14,14,14,12,12,12,12,12,14,14,10,10,10,10,14,9,9,9,10,14,14,14,13,13,9,9,9,9,9,9,1,8,7,11,11,1,3,3,3,4,8,9,10,14,14,12,12,12,12,14,14,10,10,10,10,14,9,9,9,10,14,14,14,13,13,9,9,9,9,9,7,4,4,4,4,4,4,4,4,4,4,9,12,6,14,4,12,7,2,2,1,2,7,6,4,4,4,6,8,8,7,4,5,6,3,3,3,3,4,16,8,3,5,4,3,3,3,5,2,2,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,11,12,7,7,13,9,10,12,8,9,7,8,5,12,10,13,14,5,5,5,13,5,5,5,3,3,3,5,16,5,5,5,5,5,7,12,14,8,12,8,10,12,9,11,7,9,7,10,7,13,9,7,12,8,17,7,7,16,10,13,13,8,10,10,14,17,7,16,16,15,8,10,10,12,17,7,17,14,7,10,17,8,7,7,7,8,15,15,7,14,10,10,10,11,11,7,7,13,8,10,7,16,7,8,7,14,17,12,10,11,21,8,9,7,13,9,8,13,6,12,7,6,13,10,10,10,8,18,9,17,13,10,12,6,13,6,11,8,13,10,13,18,13,11,13,8,16,7,10,8,16,12,10,8,8,6,14,11,8,15,8,8,7,7,12,7,8,9,14,15,8,9,10,9,15,7,8,8,12,13,9,10,15,15,13,7,10,10,20,7,6,9,6,6,14,11,14,11,12,9,10,16,16,12,7,11,28,8,11,10,7,21,8,7,9,4,4,4,17,7,8,6,9,6,6,13,6,6,6,6,18,20,14,8,11,12,9,10,13,15,19,8,9,12,7,10,16,12,9,9,9,14,12,11,9,12,11,18,9,9,9,10,7,7,16,8,9,7,13,12,10,18,7,8,11,7,7,8,8,13,7,7,7,11,15,13,11,7,8,15,11,7,8,18,14,13,18,15,10,12,12,9,7,11,11,8,7,10,8,14,12,10,18,7,10,9,7,8,13,10,14,9,10,8,8,23,7,7,11,12,12,17,7,7,11,11,17,16,16,7,8,11,14,14,8,10,7,7,16,16,13,9,11,9,15,15,11,11,7,7,14,7,9,7,7,16,10,13,10,11,14,7,11,10,11,7,11,10,11,15,11,15,10,12,17,10,14,13,11,11,12,13,10,7,13,10,16,12,21,9,10,10,7,11,14,17,7,7,8,11,12,8,15,14,14,8,17,12,10,10,7,9,11,7,10,7,11,18,7,11,7,12,11,8,8,14,12,7,8,15,3,7,7,5,2,9,2,2,2,2,2,2,2,3,3,3,3,3,3,3,2,3,3,3,3,3,4,4,3,3,3,3,3,3,5,11,6,4,7,10,7,7,11,1,10,2,2,3,3,3,3,3,3,3,3,5,7,3,5,6,3,3,5,2,2,5,3,4,13,11,3,3,6,3,5,14,2,2,3,8,2,2,12,18,5,3,3,3,16,5,5,5,10,7,13,12,13,9,12,14,19,9,21,9,9,10,6,9,6,15,10,6,12,8,6,10,15,4,4,6,9,9,12,16,14,23,7,7,14,9,7,7,11,14,10,10,10,10,12,11,10,13,11,15,11,7,12,10,3,7,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,4,3,7,2,5,5,3,3,5,5,5,5,7,6,6,6,4,4,4,4,4,4,6,6,6,6,6,7,10,2,2,2,5,5,5,5,3,3,3,3,3,5,5,10,9,11,8,7,12,8,9,7,6,13,11,6,13,7,9,9,4,4,4,4,4,4,6,10,7,8,13,8,8,9,14,8,10,7,7,7,9,6,9,7,2,12,5,3,3,13,4,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,4,5,5,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,8,4,4,4,4,4,4,4,4,4,4,4,4,9,3,3,3,3,3,3,3,3,3,3,4,2,2,2,5,3,3,3,3,3,3,3,3,4,4,1,7,6,4,12,3,3,3,3,3,8,7,3,3,3,3,3,3,4,4,11,14,2,8,3,5,5,8,10,8,6,4,7,17,4,5,2,6,5,2,4,4,2,12,5,5,3,15,13,10,8,11,2,2,3,3,3,3,3,3,3,3,4,4,5,3,3,3,3,4,18,2,12,5,3,3,3,3,3,5,16,8,8,9,6,6,4,4,4,4,31,6,6,10,11,21,10,9,7,10,7,7,2,4,4,4,4,6,5,3,3,4,3,3,3,3,3,3,6,6,2,2,2,5,3,3,3,7,7,4,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,8,2,3,3,3,3,3,5,9,11,3,3,3,3,4,4,3,3,3,3,3,5,10,9,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,11,10,10,10,10,10,11,10,11,10,11,10,9,9,11,3,3,3,3,3,3,5,3,7,8,8,7,6,6,11,4,4,4,7,8,9,9,2,3,7,4,4,2,5,5,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,2,2,5,5,5,5,5,3,3,5,5,5,7,7,6,6,6,4,4,4,4,4,4,4,4,4,4,6,6,8,8,1,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,6,9,12,3,7,10,7,2,2,3,3,3,3,3,4,3,3,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,8,8,6,8,7,4,4,4,4,4,6,7,5,5,20,19,8,10,9,7,10,6,8,11,6,6,6,6,13,12,8,6,7,14,11,9,2,5,3,3,6,2,3,2,2,2,2,2,2,2,5,4,3,7,6,4,7,4,3,6,4,7,2,7,7,7,5,5,5,5,3,3,3,3,3,3,3,3,3,3,5,9,10,10,8,11,7,8,20,7,8,9,8,12,6,6,6,8,9,8,12,6,6,8,13,10,12,6,6,7,7,8,9,6,4,4,4,4,4,4,4,10,6,6,6,7,14,11,10,7,8,10,8,11,14,11,11,9,7,9,8,11,9,17,10,9,2,2,2,9,3,3,3,3,15,14,9,5,5,2,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,15,12,22,19,17,18,18,19,21,7,16,16,5,5,5,5,5,5,5,5,5,5,5,7,5,5,5,5,5,5,5,5,5,5,5,9,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,7,16,11,11,7,7,7,7,17,7,8,12,15,9,19,7,19,8,16,21,11,12,19,14,22,7,7,7,7,7,7,7,7,7,7,7,16,16,19,24,12,7,14,7,12,7,8,10,10,13,7,12,12,7,7,10,18,15,12,16,7,14,12,17,10,16,17,12,17,25,7,7,7,13,6,9,6,9,18,6,6,11,20,10,6,6,6,6,6,6,6,17,6,6,6,15,6,6,6,6,6,8,14,11,12,15,13,19,17,21,7,18,8,13,13,8,12,8,6,6,13,6,15,15,16,6,6,16,6,6,6,14,6,18,6,6,6,17,18,9,13,15,8,19,8,15,15,18,14,16,4,4,4,4,4,4,4,4,4,4,4,4,6,11,10,11,6,21,23,12,17,12,11,14,13,22,15,15,11,12,14,12,7,12,8,14,12,18,10,8,16,19,17,12,14,15,8,9,19,17,12,13,13,15,18,13,23,24,23,21,17,24,8,21,8,14,14,16,14,8,8,15,20,8,19,21,9,8,13,12,13,15,11,8,11,9,9,8,11,8,21,14,21,15,15,13,7,19,7,7,7,7,7,16,12,17,18,7,7,11,11,7,9,9,2,2,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,4,5,5,5,5,5,5,5,5,3,3,10,10,7,9,7,7,7,6,8,6,6,6,6,6,6,6,7,6,8,6,6,9,7,7,7,4,4,4,4,4,4,4,4,8,9,8,7,8,7,8,10,7,5,5,5,5,5,5,3,9,7,7,8,6,6,6,6,6,6,6,6,9,6,6,9,11,13,7,8,9,9,5,5,5,7,8,6,6,6,6,6,6,6,7,8,9,7,10,9,10,7,8,5,5,5,5,5,5,7,7,9,8,7,7,6,6,6,6,6,6,10,6,6,6,6,6,6,6,6,6,6,6,9,10,4,4,4,4,8,7,7,10,10,9,8,8,15,9,8,8,8,8,8,9,10,9,10,7,8,13,5,5,5,5,5,3,3,7,7,8,6,6,6,4,4,11,9,7,8,9,10,7,5,5,5,5,5,3,3,7,6,6,13,7,9,8,7,5,5,5,5,5,5,5,5,3,3,3,3,7,8,7,8,13,6,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,6,6,6,6,7,6,7,6,6,9,7,4,4,4,4,4,4,4,7,8,7,8,9,8,8,8,7,10,7,8,5,5,5,5,5,5,5,5,3,7,7,7,7,9,7,10,9,6,6,6,6,6,8,8,6,6,6,7,6,6,6,9,9,4,4,13,7,10,9,9,12,7,8,8,10,8,8,8,8,8,8,5,5,5,5,3,7,7,11,7,9,8,8,6,6,10,6,8,8,8,6,7,6,6,12,4,4,4,4,4,4,4,4,4,9,8,8,16,8,9,8,7,5,5,5,5,5,3,3,7,7,7,10,15,8,9,8,9,9,6,6,6,6,6,6,7,4,8,7,8,8,7,8,11,8,5,5,5,5,5,3,7,7,6,11,16,7,6,4,4,4,4,9,9,8,8,8,13,12,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,11,7,8,8,9,13,7,7,7,9,8,8,9,12,7,12,7,12,8,7,10,12,9,9,6,6,8,8,6,6,6,6,6,6,6,9,8,9,11,8,6,6,6,6,6,12,7,6,6,6,9,7,7,6,6,6,6,6,11,9,6,6,6,6,6,7,9,4,4,4,4,4,4,4,4,9,9,9,9,7,7,7,7,7,11,7,7,8,8,8,8,8,8,9,8,9,9,7,7,11,11,7,12,8,8,8,8,8,7,8,8,8,8,8,13,12,8,8,8,8,7,7,7,9,5,5,5,5,5,5,5,3,3,7,7,11,7,8,8,8,6,6,6,6,6,6,6,6,6,6,6,10,11,6,7,9,4,4,4,4,4,4,9,9,8,9,8,8,8,7,7,5,5,5,5,5,5,5,5,5,5,3,3,11,7,7,7,9,6,6,11,8,10,6,6,6,12,8,8,7,6,6,8,7,4,4,4,4,4,4,4,4,9,10,9,9,8,10,9,11,8,5,5,5,7,6,6,8,7,4,4,4,4,8,7,7,8,7,8,8,5,5,5,5,7,7,8,8,8,6,6,6,6,6,10,8,9,13,6,7,6,6,8,7,8,4,4,4,4,11,8,8,8,10,5,5,8,7,8,13,8,7,6,8,6,9,7,8,7,5,5,5,5,5,5,3,3,7,8,9,6,4,8,10,10,8,12,9,13,2,7,5,5,5,5,5,7,7,10,6,6,6,6,6,6,6,8,4,4,9,8,8,8,14,8,8,8,9,8,5,5,5,5,5,3,3,9,6,6,6,6,10,12,6,6,6,6,6,6,6,4,4,4,4,11,8,7,8,8,8,5,5,3,3,3,3,7,7,6,8,6,8,11,7,6,6,6,7,4,8,11,9,10,5,5,5,3,3,3,7,7,8,9,8,15,9,6,6,6,6,6,6,11,11,4,4,4,4,4,7,9,9,10,8,7,5,5,5,5,5,5,3,3,8,6,6,6,6,6,6,6,6,6,9,7,4,4,4,4,4,9,9,8,8,10,13,5,5,5,3,17,7,7,7,7,7,8,6,8,13,6,6,6,6,6,6,6,6,4,4,4,9,10,8,8,8,5,5,5,5,3,7,7,7,8,8,6,6,6,8,8,8,9,10,8,4,8,10,9,8,8,8,9,13,10,5,5,5,5,5,5,5,5,5,5,3,3,7,8,9,9,7,7,7,10,9,9,8,9,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,6,8,12,6,6,6,6,6,6,6,6,6,12,4,4,4,4,4,4,4,4,4,4,4,11,8,8,9,9,10,8,9,7,7,5,5,5,5,5,5,3,7,8,7,6,6,8,6,6,10,4,7,8,9,12,8,7,7,5,5,5,5,5,5,3,3,7,14,7,9,8,8,6,6,8,12,12,6,6,7,7,10,4,4,4,4,4,9,9,14,9,13,8,7,5,5,5,6,6,6,7,4,8,7,5,5,5,5,5,5,5,5,3,3,7,7,7,8,6,6,6,6,6,6,12,6,6,6,6,4,4,9,9,8,8,11,7,7,7,5,5,5,3,9,8,6,6,7,4,4,4,4,4,4,8,8,11,5,5,5,7,7,7,9,6,6,6,6,6,6,9,8,4,4,4,4,7,12,9,8,8,8,7,10,10,5,5,5,5,5,5,5,3,11,14,8,7,8,8,6,6,6,6,6,8,7,6,6,6,7,6,8,9,4,4,4,7,8,9,7,9,7,7,9,8,5,5,5,5,5,5,5,5,5,11,3,9,7,7,12,14,8,6,6,12,11,8,6,6,6,6,6,6,6,6,6,15,7,4,4,4,16,9,9,9,8,9,9,9,9,9,8,8,8,13,11,8,5,5,5,5,3,7,6,6,8,8,8,6,6,7,10,7,4,4,4,4,9,7,8,7,7,7,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,7,7,7,9,6,6,6,6,6,8,8,7,7,9,6,6,6,7,6,6,6,6,6,15,4,4,4,4,4,8,8,7,8,12,9,8,8,8,8,8,9,8,8,10,8,8,8,8,16,9,10,2,5,5,5,5,5,5,5,9,7,6,8,9,4,4,4,4,4,7,8,8,8,9,8,11,10,5,5,5,5,3,7,8,6,6,6,6,6,8,6,6,6,6,4,12,10,12,7,7,7,7,7,7,7,5,5,5,5,3,3,7,7,10,8,9,7,6,10,7,6,6,4,4,8,9,7,9,9,9,9,8,8,8,8,10,5,5,5,5,5,5,8,7,6,6,6,10,6,7,10,7,4,4,4,4,4,4,4,12,9,10,7,7,10,8,10,5,12,9,6,6,6,6,6,7,6,4,4,4,10,9,9,8,7,7,5,5,5,5,5,5,3,3,13,7,7,9,7,7,7,8,9,9,7,8,6,6,6,6,6,6,6,6,6,6,6,6,6,7,13,9,15,15,4,4,4,4,4,10,10,9,8,9,8,8,9,7,8,7,8,5,5,7,6,6,6,4,4,4,7,8,11,8,5,5,5,5,5,5,5,7,6,6,6,6,6,6,9,11,10,7,4,4,4,9,8,8,5,5,5,5,5,9,9,6,6,6,6,6,6,6,9,9,4,4,4,4,8,8,8,9,9,8,8,8,13,2,4,2,7,5,5,5,5,5,5,9,9,6,6,6,6,10,8,8,8,6,6,6,4,4,9,8,10,8,9,8,8,8,9,8,8,5,3,3,3,11,6,6,6,7,6,6,6,4,4,9,8,5,5,5,5,5,3,11,8,6,6,6,6,6,9,7,4,4,14,10,9,8,12,8,8,8,11,15,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,11,11,11,10,10,7,7,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,5,5,3,3,3,7,11,7,7,11,11,7,8,9,10,7,7,9,9,9,9,7,7,10,8,13,8,8,8,8,11,10,6,6,8,10,11,14,14,6,6,6,6,6,6,9,11,7,7,6,8,12,11,11,6,6,10,6,6,6,6,6,10,7,7,6,6,11,6,6,6,11,8,9,7,6,10,11,9,10,11,7,11,8,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8,6,6,8,9,10,9,6,6,6,10,6,6,6,6,11,10,11,10,9,8,7,7,7,7,11,14,8,10,9,9,8,8,7,11,8,8,8,11,11,10,10,9,10,8,11,10,8,11,9,12,8,10,8,11,8,9,9,11,11,10,11,13,8,7,8,8,9,7,8,8,8,8,7,8,2,2,2,2,2,2,2,4,4,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,4,2,3,3,3,3,3,3,3,3,8,6,4,4,4,11,7,11,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,5,5,5,3,3,3,3,8,7,7,8,8,4,8,7,7,7,9,7,8,9,8,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,6,3,3,3,3,3,3,3,3,4,2,2,3,3,3,3,3,4,5,5,3,8,8,6,9,4,4,10,7,3,3,3,2,5,3,3,3,3,3,3,3,3,3,3,3,3,4,3,2,2,2,3,3,3,3,3,4,10,2,3,3,3,3,3,3,3,4,2,3,3,3,3,3,3,3,3,2,2,3,3,3,5,2,4,2,6,2,2,9,5,5,3,3,3,3,3,3,3,5,5,5,9,8,7,6,6,11,4,4,4,4,4,4,4,6,6,7,7,11,8,8,6,5,11,2,3,3,3,3,3,3,3,3,3,3,3,3,3,4,2,2,3,3,3,3,3,3,6,4,4,4,4,3,3,3,3,5,7,2,3,3,3,3,3,8,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,6,4,4,4,4,2,2,3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,3,3,3,3,3,4,2,2,3,3,3,3,3,3,2,3,3,3,3,3,6,3,3,8,10,3,4,4,1,1,1,1,1,1,1,8,9,10,7,7,1,1,3,8,7,7,8,8,8,1,6,1,1,6,3,3,4,7,3,5,5,4,4,4,4,4,2,7,7,8,12,3,4,5,1,3,4,4,10,4,3,3,3,8,7,7,2,2,2,2,2,2,2,2,2,12,9,20,7,5,5,9,13,5,5,5,5,5,3,3,3,16,5,5,5,13,7,8,8,11,8,7,9,7,11,12,9,9,8,8,11,10,14,7,12,10,11,13,7,9,11,17,17,14,13,7,8,7,10,10,7,16,13,7,8,17,12,9,8,6,7,10,6,6,12,6,8,10,8,8,8,6,8,6,14,6,6,6,13,6,10,6,6,7,14,8,6,6,10,11,10,9,9,7,7,6,6,6,9,9,7,9,10,9,13,12,4,4,4,4,4,4,4,4,4,6,6,6,8,8,6,8,9,10,9,7,10,10,8,7,8,7,10,12,9,8,15,8,7,8,8,7,7,15,13,7,10,9,14,18,16,7,24,7,8,10,11,16,8,14,7,9,9,9,11,13,19,14,15,14,11,7,13,9,10,7,13,9,10,11,12,8,9,2,3,5,8,7,4,4,10,5,3,3,3,3,3,5,4,4,4,2,2,2,2,2,1,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,2,2,2,3,3,3,3,3,3,3,3,3,3,4,2,12,5,3,8,10,15,6,7,2,3,2,5,5,12,2,5,5,5,5,2,2,5,5,12,9,5,2,2,9,5,5,12,12,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,12,5,8,8,9,5,5,5,8,19,7,16,15,14,9,9,9,9,7,11,11,11,14,10,10,5,5,5,5,5,5,5,5,5,15,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,9,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,14,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,15,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,12,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,9,12,9,9,12,12,12,15,7,11,7,11,18,13,8,18,15,18,12,14,12,8,8,8,8,9,9,9,12,7,10,10,8,8,12,12,12,7,12,12,9,7,7,7,7,7,8,15,12,9,10,10,7,10,10,13,11,10,9,22,11,9,8,8,8,8,8,13,18,13,9,15,19,9,7,7,10,7,7,7,11,8,13,17,7,7,10,10,10,7,20,16,7,7,7,7,11,21,12,12,13,11,14,16,8,8,13,11,9,7,7,13,7,7,14,15,15,6,6,6,6,6,6,6,6,6,6,13,10,18,6,6,6,6,6,6,6,6,6,11,8,8,12,12,11,11,8,12,9,9,9,13,13,9,9,9,9,9,9,10,12,6,6,6,6,17,11,7,7,7,7,14,14,12,6,7,7,6,6,15,10,13,10,6,8,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,13,9,9,15,13,6,12,12,6,19,11,10,7,7,16,8,19,17,9,9,9,9,9,6,6,6,10,8,16,8,6,6,9,6,6,6,6,6,6,6,6,8,8,8,6,7,6,6,6,6,6,6,6,6,6,6,6,14,6,6,6,6,20,6,9,6,9,9,9,6,9,8,8,12,9,8,8,8,7,8,12,7,8,8,8,6,8,6,6,6,6,6,6,6,9,8,8,6,6,13,9,12,13,12,14,13,12,11,11,6,8,8,8,6,13,12,11,11,12,6,11,12,11,13,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,15,6,6,6,6,6,6,6,13,6,6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,8,6,18,6,12,13,13,13,9,10,15,9,12,6,6,6,6,6,6,6,6,9,15,10,9,10,13,9,19,8,18,17,10,10,8,8,6,6,6,6,6,6,10,14,8,16,16,9,8,15,8,8,10,12,14,7,7,8,8,7,7,7,7,8,13,13,11,9,9,9,12,10,17,8,11,9,7,7,14,8,14,14,7,7,7,7,7,7,14,7,7,7,7,7,10,10,8,14,7,7,7,7,8,8,8,8,8,17,9,15,7,8,12,7,9,14,7,7,7,9,13,8,14,7,16,18,13,15,14,12,13,10,15,9,7,7,7,10,13,15,15,9,9,9,9,19,11,11,11,13,8,8,8,8,7,12,19,17,9,9,13,7,7,7,9,7,7,7,12,13,15,10,8,8,14,15,12,13,13,8,12,14,7,11,7,14,15,13,12,8,8,8,8,11,13,15,15,8,13,12,8,8,8,13,10,16,14,11,8,8,12,12,9,15,15,12,12,13,8,8,9,12,13,9,8,8,8,8,8,8,8,8,8,8,8,11,12,11,14,7,13,13,13,12,18,16,7,12,11,10,10,15,9,9,9,21,7,7,7,11,16,8,8,11,11,7,7,7,7,7,19,7,7,7,7,7,7,7,7,7,12,8,9,12,14,11,9,9,9,22,12,8,8,15,4,2,2,5,5,3,3,3,3,3,3,6,6,4,4,4,12,7,10,2,3,3,3,3,3,3,3,6,7,3,7,5,14,4,4,8,10,4,1,3,3,6,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,4,2,2,5,3,4,2,2,2,2,2,2,11,5,5,5,11,5,5,3,5,5,5,5,11,14,13,9,11,9,12,8,11,11,8,11,16,9,9,7,10,9,12,8,15,6,7,6,6,13,10,8,11,8,6,6,6,12,16,6,11,7,8,9,18,6,6,9,4,4,6,13,6,6,6,6,8,8,9,16,8,7,7,14,7,8,8,8,7,7,7,7,7,7,15,13,7,10,7,7,10,12,16,15,7,9,9,14,11,11,10,9,10,8,12,7,8,7,7,10,12,7,12,8,7,2,3,3,3,3,3,3,3,3,3,3,5,3,3,5,5,5,10,4,8,7,10,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,7,4,5,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,5,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,6,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,9,8,2,2,2,8,12,7,7,5,5,5,5,5,5,5,5,5,5,5,5,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,7,11,9,8,8,8,7,8,9,7,7,9,7,7,7,10,7,7,10,9,10,6,6,6,6,6,6,15,7,8,9,9,8,6,6,10,9,6,8,13,9,7,6,6,6,6,6,6,12,6,6,7,6,7,6,6,6,10,10,7,6,6,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,6,14,6,6,7,7,9,6,6,6,6,9,9,8,9,10,9,8,9,12,7,7,7,8,7,10,12,11,9,10,7,7,7,9,10,10,8,12,9,7,7,9,8,8,8,10,7,7,8,9,9,7,7,7,8,2,4,6,3,4,2,3,3,3,3,2,3,3,3,3,3,3,3,3,4,4,4,4,5,5,3,3,3,3,3,3,3,3,5,8,6,4,7,3,3,3,3,3,3,3,12,3,3,3,3,3,3,4,4,2,3,5,3,4,7,3,3,3,3,3,3,4,3,3,3,3,3,3,3,4,3,3,6,4,3,4,2,2,2,5,3,3,3,3,3,5,4,4,4,4,7,6,8,9,2,2,2,2,3,3,3,5,7,2,3,3,8,7,7,2,2,8,5,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,8,8,7,7,6,10,6,9,7,11,4,6,8,8,7,8,4,5,5,5,3,3,11,8,9,6,6,8,7,4,4,7,8,7,2,2,3,3,3,3,4,3,3,3,3,3,3,3,3,7,2,2,3,3,2,3,3,3,3,3,3,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,12,5,5,3,3,3,5,10,12,6,15,4,6,6,7,14,9,3,3,3,3,3,8,2,2,3,5,3,3,3,3,3,3,8,8,8,7,5,8,4,6,11,2,2,6,7,2,9,8,5,5,3,3,5,7,6,6,10,6,6,8,9,7,4,4,4,4,7,6,6,7,7,10,9,8,11,8,3,3,3,3,3,4,4,2,3,3,3,3,3,7,6,2,5,6,7,6,4,9,11,2,2,3,3,3,3,3,3,3,2,2,5,3,3,3,3,3,9,9,6,4,8,7,7,5,9,8,6,8,7,8,5,5,5,5,5,3,3,3,16,8,7,7,7,8,7,7,7,7,9,6,9,6,10,7,7,7,6,10,8,9,11,11,8,4,4,10,8,8,6,9,6,11,8,8,8,15,7,8,9,5,3,3,3,3,3,5,11,2,2,3,8,9,10,3,2,2,2,2,2,2,3,6,4,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,2,3,3,3,3,3,3,3,11,5,3,3,3,3,3,3,3,3,6,7,4,4,2,3,3,3,3,3,3,3,3,12,7,4,12,4,6,5,4,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,2,3,3,3,3,3,3,3,3,4,4,11,10,6,4,6,10,8,3,3,3,3,3,3,3,3,5,4,4,4,2,2,2,2,2,2,2,2,5,3,4,4,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,5,5,5,5,5,5,3,3,3,3,3,3,3,3,7,8,8,7,13,12,10,10,8,8,7,7,9,12,11,6,6,8,8,9,7,7,7,10,15,10,4,4,4,4,4,11,8,8,9,7,9,14,14,12,2,2,2,2,2,2,2,3,3,3,3,3,2,2,12,5,5,5,8,11,10,7,9,3,8,7,3,15,13,11,4,4,2,2,2,19,7,5,5,3,3,3,3,3,3,3,5,22,18,6,14,17,4,4,19,16,18,2,3,3,2,3,2,3,3,6,4,2,3,3,2,5,3,3,3,3,3,3,3,9,9,2,3,2,2,2,3,3,3,5,7,14,7,7,12,9,13,6,11,6,10,9,7,7,8,12,12,8,8,8,10,7,7,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,5,8,10,7,8,11,8,12,9,4,7,7,9,13,2,3,3,3,3,3,3,2,3,3,3,1,2,2,3,3,3,3,3,3,5,2,2,5,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,8,4,4,4,3,2,3,3,3,3,5,2,2,2,2,5,5,5,5,3,3,3,3,3,3,3,3,3,7,7,7,7,7,8,8,8,8,8,12,9,8,8,9,8,6,17,6,6,6,8,8,6,6,6,6,6,6,6,6,6,6,6,7,4,4,8,8,9,9,9,7,7,7,7,7,7,7,9,9,9,7,8,8,8,10,7,13,10,8,9,3,3,13,3,3,3,3,3,7,7,6,6,10,13,11,11,8,8,9,8,9,9,10,10,10,11,10,10,13,13,16,15,11,12,9,9,10,9,11,10,9,9,14,7,8,3,10,7,7,3,2,2,2,5,3,3,3,3,3,3,3,3,3,3,3,3,6,7,2,2,3,3,3,3,3,3,3,3,4,11,6,7,4,6,2,2,3,3,3,1,3,3,3,3,3,3,6,4,4,2,2,2,3,3,3,3,4,4,6,6,6,6,5,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,9,11,6,10,9,12,7,7,11,14,9,7,12,3,3,7,12,11,12,7,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,11,5,5,5,5,5,5,5,5,11,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,3,3,3,5,5,5,5,5,5,5,5,5,5,5,3,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,5,5,5,5,5,5,5,5,5,5,5,5,5,3,10,3,3,3,11,3,5,9,11,8,12,14,9,7,8,7,7,11,11,7,7,10,9,8,10,9,7,7,7,7,7,7,8,8,7,11,8,8,8,7,7,10,8,7,13,12,7,17,10,8,8,11,7,11,11,14,7,11,7,8,6,9,20,8,7,9,16,7,10,6,11,10,8,9,7,16,11,11,9,8,9,8,8,8,11,8,15,8,8,9,7,8,8,11,10,7,5,7,10,10,15,7,7,7,8,7,8,8,10,11,10,10,10,11,11,7,8,6,8,8,8,10,6,8,6,6,7,8,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,16,6,15,6,7,11,11,7,9,10,11,13,10,6,16,8,10,12,11,6,6,6,6,6,6,6,10,6,10,7,7,7,7,11,7,11,6,6,6,6,6,6,17,7,7,6,6,12,22,6,6,6,6,6,8,6,6,6,6,7,6,6,5,6,6,8,11,6,9,14,11,9,11,7,7,8,6,6,6,8,10,9,6,6,6,6,9,7,6,6,6,6,6,15,6,4,4,4,6,4,17,8,11,6,6,9,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,6,6,6,6,10,6,10,6,6,6,6,12,8,6,6,6,6,6,6,6,6,6,9,6,6,6,6,18,6,6,6,8,9,10,7,8,9,10,11,7,13,6,8,8,6,6,14,7,7,7,7,10,7,14,9,6,6,9,15,9,7,14,6,11,14,13,7,12,8,7,7,7,7,7,12,7,10,9,16,6,8,6,5,17,6,8,10,4,6,4,10,15,17,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8,4,4,11,7,4,4,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,19,17,6,10,11,6,6,6,6,18,6,6,11,4,4,4,5,6,6,6,9,5,6,4,6,6,4,6,6,6,6,10,6,6,4,6,6,10,6,10,6,6,6,6,11,6,6,10,6,6,8,6,6,6,8,6,11,4,11,9,10,9,11,4,8,4,11,12,7,9,8,6,7,7,8,12,12,11,13,10,11,7,7,7,9,7,11,10,7,7,7,16,11,10,11,17,9,9,8,8,7,7,7,9,7,7,7,14,7,13,9,11,10,14,10,10,12,11,10,7,10,5,14,8,8,8,9,7,8,7,7,9,8,7,8,7,7,7,7,7,7,7,11,8,10,8,7,8,14,11,8,9,9,9,8,24,10,10,12,7,7,15,11,8,8,12,11,8,9,9,7,8,9,10,11,10,11,7,12,7,7,11,9,8,14,13,12,8,11,10,8,8,7,7,14,9,10,8,9,11,7,14,8,8,13,8,8,12,7,10,14,14,11,9,10,9,9,7,7,11,11,13,9,13,5,5,5,7,9,5,11,12,14,8,7,7,11,10,9,7,8,8,7,10,11,11,5,5,7,5,5,5,7,7,15,7,7,8,7,15,12,12,10,7,8,7,11,7,7,7,23,11,8,8,11,10,7,8,11,7,19,7,7,6,9,9,9,11,3,4,7,8,6,6,4,10,8,2,2]);const edgeChild=/*#__PURE__*/new Uint16Array([0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,12,1,1,1,1,1,17,1,1,1,12,1,12,1,12,13,1,1,1,1,12,1,12,1,1,1,1,1,14,21,1,1,1,1,1,1,19,12,1,1,1,1,1,1,1,20,1,1,1,16,1,18,1,1,15,1,1,1,1,12,1,1,1,1,1,1,22,1,1,1,12,1,1,1,1,1,1,1,1,1,12,12,12,12,12,12,12,12,12,12,12,12,1,24,25,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,12,12,12,12,1,32,0,0,0,1,1,1,1,1,35,34,1,1,1,1,1,1,33,1,1,1,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,38,0,0,0,0,39,40,0,0,0,41,0,12,1,1,12,1,1,1,1,44,45,45,45,44,45,44,44,46,45,44,45,44,44,44,44,44,44,46,44,44,44,44,44,44,45,47,47,45,44,44,44,44,44,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,50,52,50,50,50,52,50,51,50,53,50,51,51,50,50,50,51,53,51,53,50,51,51,12,55,55,54,56,51,53,50,50,48,49,57,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,60,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,66,1,12,1,1,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0,0,0,0,0,0,0,0,0,0,0,0,74,77,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,12,1,1,1,1,87,1,89,1,1,1,1,1,1,1,1,92,1,1,1,1,1,1,1,1,1,1,1,1,0,1,95,95,1,1,12,1,98,1,1,1,1,1,1,1,96,1,97,1,99,1,1,1,1,1,100,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,108,109,1,1,1,1,1,1,111,111,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,119,120,1,1,1,1,1,1,1,1,1,1,1,1,1,120,1,1,1,1,1,1,1,1,1,1,120,1,1,1,1,1,1,1,1,1,124,121,123,118,1,122,1,1,112,1,1,1,1,115,1,125,1,1,1,1,1,117,1,106,1,107,1,12,126,104,1,110,1,1,1,1,1,105,113,1,12,12,12,116,114,1,1,1,1,1,0,0,0,0,1,12,12,1,1,1,1,1,12,132,1,1,1,1,1,1,1,1,1,1,1,12,134,1,1,1,1,1,1,1,1,135,136,12,12,133,131,45,45,138,50,50,137,140,139,1,1,0,0,0,0,0,0,0,0,0,0,0,0,143,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,141,0,0,0,0,1,0,142,130,1,0,1,12,12,1,1,1,1,1,0,0,0,0,0,0,0,1,146,145,20,1,1,12,12,1,20,12,12,1,1,1,1,1,132,1,1,150,1,1,1,1,151,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,1,1,134,1,1,150,1,1,1,1,151,1,1,132,1,1,1,150,1,1,1,1,151,1,1,132,1,1,1,1,1,1,1,1,132,1,1,1,1,1,1,1,1,1,1,1,158,1,1,1,150,1,1,1,1,1,151,1,1,158,1,1,1,1,1,1,1,1,1,1,132,1,1,1,1,150,1,1,1,1,151,1,1,1,132,1,1,150,1,1,1,1,162,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,1,165,1,1,158,1,1,1,1,1,150,1,1,1,1,1,151,1,1,158,1,1,1,1,1,150,1,1,1,1,1,151,1,152,156,156,12,1,12,164,1,1,1,1,1,156,156,156,152,1,1,1,155,156,159,163,1,1,1,1,155,155,1,1,154,152,152,155,168,154,168,1,1,166,1,154,153,155,1,1,1,1,155,1,157,1,1,1,12,1,160,1,160,1,1,1,160,159,161,167,154,152,1,1,1,1,1,1,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,171,170,171,170,170,170,170,172,172,170,171,170,171,170,170,12,12,12,12,12,1,12,12,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,191,1,1,1,1,12,197,198,199,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,149,1,1,1,1,1,1,1,1,1,1,1,194,1,1,1,182,1,208,1,1,1,206,1,1,203,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,1,1,1,1,12,1,1,1,1,1,1,1,1,188,1,1,1,184,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,180,1,1,1,1,1,1,1,189,1,1,1,1,193,1,1,1,1,169,1,1,187,1,1,1,190,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,178,1,12,1,1,12,1,1,1,1,181,1,1,1,186,1,201,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,1,207,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,192,1,1,1,1,1,12,1,1,1,1,1,1,1,1,174,12,1,1,1,176,12,1,1,1,1,1,1,1,196,1,1,1,1,1,1,1,1,1,1,175,1,1,1,1,1,1,202,1,1,1,179,1,1,1,185,1,12,1,1,12,1,1,1,1,1,1,1,1,1,1,189,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,173,1,1,1,1,1,1,1,1,1,1,183,1,1,1,1,1,1,1,1,1,1,1,204,1,1,1,1,1,1,1,1,1,1,1,1,1,205,1,1,12,1,1,1,1,177,1,1,1,183,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,1,1,195,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,12,1,1,1,1,1,1,1,1,1,200,1,1,12,1,1,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,218,0,0,0,0,0,219,0,0,0,0,0,0,1,12,1,1,1,223,1,1,1,0,224,221,222,1,1,1,1,1,1,229,1,231,1,1,1,1,1,1,1,1,1,1,227,1,1,1,1,1,233,1,1,12,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,232,1,1,12,1,1,1,1,228,1,1,226,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,230,1,1,1,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,239,13,1,1,1,12,12,236,237,1,1,1,1,238,1,1,12,1,1,1,1,1,1,1,240,1,1,12,16,1,1,1,1,1,1,1,241,1,1,1,12,12,1,1,1,1,1,241,12,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,250,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,254,254,1,0,0,0,0,0,1,12,0,0,0,0,0,0,0,0,170,259,260,1,12,1,1,1,1,12,262,1,1,261,1,264,1,1,1,1,1,1,1,1,0,1,1,1,268,269,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,12,1,0,1,0,0,0,0,1,0,1,0,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,1,1,12,0,280,0,0,281,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,12,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,60,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,305,0,0,0,0,0,0,0,0,0,307,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,12,1,1,1,1,1,1,1,1,1,12,1,1,1,1,1,324,324,325,324,0,183,1,1,13,320,1,318,0,0,0,0,1,0,0,0,321,1,1,326,1,203,1,1,1,1,1,319,1,316,1,322,1,314,1,323,1,315,1,1,1,1,1,1,1,12,1,1,1,12,1,12,317,317,1,1,1,313,182,1,1,12,1,1,1,1,1,1,1,1,1,1,12,1,1,1,1,12,1,1,1,1,312,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,329,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,264,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,369,369,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,361,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,337,348,1,1,336,371,1,342,1,1,334,366,1,1,352,333,338,1,1,1,345,376,354,1,1,1,1,1,1,355,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,364,368,0,0,77,1,1,0,362,339,375,340,343,350,1,365,0,1,0,77,359,357,1,0,0,1,1,1,0,0,0,0,378,1,1,349,1,77,1,0,1,1,1,381,1,0,0,77,356,0,1,335,1,1,1,0,1,1,358,1,0,1,1,1,0,1,383,346,1,1,0,1,0,0,374,0,1,1,1,77,367,1,1,363,360,1,1,1,1,1,1,1,1,1,1,1,341,1,1,1,1,1,1,1,1,1,1,1,373,0,77,1,1,1,1,0,1,1,1,1,1,1,0,0,1,1,377,1,1,1,0,0,380,0,0,0,1,353,1,0,77,379,1,0,0,0,0,382,1,1,0,0,1,0,1,0,351,0,347,0,1,1,1,0,1,1,0,370,344,372,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,1,1,397,397,1,1,12,12,1,397,1,1,12,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,409,1,0,1,1,1,1,203,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,427,427,1,1,0,0,314,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,439,1,438,1,1,1,1,1,1,1,1,442,1,12,12,1,1,1,1,1,12,1,1,1,1,450,1,1,1,452,1,1,1,1,1,1,1,1,1,1,449,1,444,1,1,1,432,1,1,1,1,1,1,1,1,445,12,1,1,1,1,451,1,1,1,446,441,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,314,1,430,1,1,12,448,1,1,314,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,434,1,1,1,1,1,1,1,1,1,1,1,451,1,1,1,1,314,1,447,1,1,1,436,1,1,1,1,1,437,1,453,440,1,1,1,1,1,435,1,1,1,1,1,1,1,1,1,431,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,443,1,1,1,1,1,1,1,12,1,1,1,1,1,433,1,1,1,1,1,1,1,218,454,1,1,1,1,1,12,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,0,0,459,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,12,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,463,0,463,463,463,463,463,463,463,0,463,463,463,463,463,1,463,463,463,0,463,463,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,468,467,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,472,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,465,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,466,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,474,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,463,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,471,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,464,0,0,475,470,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,469,0,0,0,0,0,0,0,0,0,0,0,0,0,463,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,464,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,463,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,473,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,12,1,1,1,1,1,1,1,1,1,1,1,484,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,196,196,1,488,1,1,1,487,1,1,1,1,483,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,485,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,489,1,1,486,1,1,1,1,1,1,1,1,1,369,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,490,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,501,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,12,1,503,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,12,12,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,1,1,1,0,0,0,1,0,0,0,1,60,1,1,12,12,12,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,522,1,1,1,1,1,1,1,523,1,1,1,1,1,1,1,521,1,1,12,1,525,237,1,1,12,12,1,1,12,1,12,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,529,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,535,1,1,1,1,1,1,1,1,1,1,1,1,1,1,130,1,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,105,1,1,12,1,1,1,12,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,544,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,142,1,1,1,226,1,1,12,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,568,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,573,1,218,1,325,1,1,1,1,1,1,1,1,1,0,0,574,1,1,1,1,0,576,0,77,0,575,0,1,1,1,0,1,1,1,1,1,1,12,0,0,0,0,1,0,0,0,0,0,0,582,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,578,578,0,581,579,578,578,578,578,578,583,578,578,587,578,578,578,578,578,578,578,578,578,578,584,581,578,578,581,578,578,578,578,578,578,578,578,578,578,578,578,578,579,578,578,578,578,578,585,578,578,578,578,578,578,0,0,0,1,586,1,1,1,1,580,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,12,591,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,12,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,12,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,12,1,1,12,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,94,64,277,303,408,531,0,4,67,234,252,279,304,331,385,410,0,495,515,532,593,9,0,61,86,395,406,426,571,0,493,514,528,608,0,30,6,0,458,496,598,556,68,0,7,282,253,386,460,413,534,77,594,0,572,306,415,462,9,103,285,502,6,30,0,308,77,388,77,479,10,6,129,246,272,0,609,505,0,559,0,63,6,6,249,93,2,429,396,407,592,0,6,0,6,283,101,6,557,497,536,0,461,387,270,284,8,69,102,595,539,389,309,297,416,144,72,287,542,506,597,560,332,327,476,6,73,147,11,0,247,518,543,561,510,547,566,607,36,6,258,292,330,301,216,30,524,549,216,42,214,263,293,302,403,420,477,271,0,71,558,0,400,414,296,77,245,77,0,577,541,500,289,418,77,390,384,0,0,0,9,551,567,215,0,421,404,527,512,569,611,83,216,43,294,393,422,565,0,507,290,273,77,213,78,28,387,30,6,391,328,300,600,588,520,546,509,0,256,79,30,402,419,0,30,423,0,217,589,513,9,405,424,216,246,84,220,590,570,553,478,425,394,248,225,85,59,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,616,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,0,0,0,0,0,0,0,0,80,0,127,0,0,82,545,0,0,0,0,0,0,0,27,0,548,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,0,0,0,0,499,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,291,0,0,0,0,0,0,0,613,0,0,0,0,0,612,0,0,0,0,0,0,0,0,0,0,0,0,0,0,392,0,0,0,480,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,491,0,0,0,0,0,0,401,0,0,0,0,0,0,0,0,0,0,0,0,0,209,0,0,0,0,0,0,0,0,0,0,511,0,0,0,0,0,0,0,0,0,0,0,0,492,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,278,0,0,0,0,0,526,274,0,0,0,0,0,0,0,0,0,0,0,0,0,508,0,0,0,0,0,0,0,0,0,0,0,455,0,0,0,311,0,0,0,0,0,0,251,0,0,0,0,0,0,23,0,0,0,0,564,0,0,0,0,596,517,0,0,0,0,242,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,265,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,0,0,0,0,0,276,606,0,70,0,0,0,0,0,0,0,0,0,615,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,148,0,275,0,0,0,0,0,0,563,0,0,0,0,0,0,519,0,0,0,0,0,0,0,0,0,562,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,211,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,0,498,0,0,0,0,0,550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,81,0,0,0,0,0,0,0,0,0,0,0,0,482,0,481,0,0,0,0,0,0,0,0,0,0,257,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,456,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,533,0,0,0,0,0,0,0,0,295,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,235,0,0,0,0,0,0,0,0,0,0,82,0,602,0,0,0,0,0,0,0,0,0,0,0,0,243,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,605,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,516,0,0,0,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,494,0,610,0,0,428,0,0,0,0,0,0,0,0,0,0,0,0,399,0,0,0,540,0,91,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,29,90,0,0,0,0,0,0,0,0,0,0,0,0,288,0,0,0,212,0,0,0,0,0,0,554,0,267,0,0,128,0,0,0,0,0,555,0,0,0,0,0,0,0,411,417,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,310,0,0,0,0,0,5,0,0,0,0,0,0,0,298,0,0,0,0,0,0,0,0,0,0,0,0,0,530,0,0,0,412,0,0,398,0,0,0,0,0,0,599,0,0,0,537,0,0,88,0,538,0,0,0,0,0,0,0,0,0,0,504,457,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,266,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,411,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,604,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,603,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,614,0,0,0,0,0,552,0,0,0,0,0,0,0,0,0,0,299,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,601,0,0,210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,619,619,619,619,619,619,619,618,620]);const labelText="orgmilcomnetedugovdrrformsfeedbackofficialaccoorgmilschnetgovmagazinemediaunioncargopilotgroupcaarespressworksaerodromeworkinggroupair-traffic-controlaircraftaccident-preventioneducatormarketplaceambulanceinsurancecateringairportrepbodyenginesoftwaremodellingair-surveillanceconsultingchartertrainermaintenanceservicesdesignflightskydivingfreightassociationstudentgroundhandlingdgcafuelclubtaxicrewshowballooningexpresstraderbrokerauthoragentsairtrafficjournalistsafetyconsultantmicrolightaccident-investigationparachutingequipmentproductionfederationrecreationscientistnavigationengineertradingglidingleasingresearchpassenger-associationentertainmentparaglidinghangglidingaerobaticrotorcraftemergencycertificationgovernmentaeroclubexchangelogisticschampionshiphomebuiltcouncilconferencecontrolairlinecivilaviationjournalorgcomnetedugovcoorgcomnomnetobjofforgcomnetuwukiloappsframerorgmilcomnetedugovcoradioorgcomnetcommuneedogpbcoitgvorgedugov*spreviewfrontendrelayononstagingupid*mtls*privatelinktypedreamdeveloperbravemochawindsurfaivenmirenupsunwnextbegetngrokclerkwale2bwebcsbrunflutterflowspawnbaseshiptodaymagicpatternsnetlifyondigitaloceanrailwayhostedclaudehasurabotdashvercelgithubluyanigadgetreplitcloudflaretelebitedgecomputeevervaultdetaexponyatnoopencrpplxzeaburwasmerframerzeropsconvexmedusajsspritesonherculeseasypanelstreamlitsnowflakemesserliloginlinehackclubnorthflankbase44corespeedadaptableleapcellngrok-freeclerkstagelovableon-fleek*us-west-3ap-south-2us-central-2us-central-1eu-central-1ap-south-1us-west-2us-east-2eu-north-1ap-north-1us-west-1us-east-1*rcloudintsegorgmilcomgobbetnetintedugovturmusicasenasamutualcoopip6uriurnin-addre164homeirisgovdixdaemoncloudnssthwien*inexexkunden4accogvormymyspreadshop4lima2ixbizortsinfofuturecmsfuturehostinginfo12hpprivfuturemailinglima-cityfunkfeuer123webseitemelmyspreadshopcloudletswasantqldvicactnswtascatholicwasaqldvictasvpsidwasantozqldorgcomvicasnactnetedugovnswtasconfhrsncomairflowlambda-urltransfer-webappairflowtransfer-webapptransfer-webapptransfer-webapp-fipstransfer-webappeu-west-3ap-south-2eu-south-2eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3eu-central-1mx-central-1me-central-1ca-central-1il-central-1ap-northeast-1ap-southeast-1me-south-1af-south-1eu-south-1ap-south-1ap-southeast-7us-west-2eu-west-2us-east-2eu-north-1ap-southeast-2ap-northeast-2ap-southeast-5us-gov-west-1us-gov-east-1ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1privatenotebookstudiolabelingnotebookstudionotebooknotebook-fipslabelingnotebookstudionotebook-fipsnotebookstudio-fipsnotebook-fipsnotebookstudionotebook-fipsnotebookstudioeu-west-3ap-south-2eu-south-2eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3eu-central-1me-central-1ca-central-1il-central-1ap-northeast-1ap-southeast-1me-south-1af-south-1eu-south-1ap-south-1us-west-2eu-west-2us-east-2eu-north-1ap-southeast-2ap-northeast-2experimentsus-gov-west-1us-gov-east-1ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1onrepostsagemakercopporgmilcompronetintedugovbiznameinfoshoprsorgmilcomnetedugovbrendlynzauscotvstoreorgcomnetedugovbizinfoidacaicoittvorgmilcomschnetedugovinfocloudezproxyacmymyspreadshopkuleuvenwebhostingtransurl123websitecloudnsinterhostsolutions5476103298edgfacbmlonihkjutwvqpsryxzbarsycoororgcomedumyftpno-iporxcloud-ipfor-somemmafanfor-morewebhopselfipjozidyndnscloudnsdscloudfor-thefor-betteractivetrailcoeconorestooteorgcomeconeteduassurmoneyafricaarchitectesrestaurantloisirstourismavocatsinfoagrounivcoorgcomnetedugovtvdeportesaludtksatorgmilcomwebgobnetinteducienciaboliviarevistacooperativaempresanombreindustriamusicapatriamedicinademocraciapoliticapuebloindigenaplurinacionalarteblogwikiinfoagrotransportenoticiasprofesionalacademiaeconomiaecologiamovimientotecnologianaturalsimplesitecepesebamapadfmgalampbacscpirngorotomtrjspaprrprrsesmscepesebamapadfmgalampbacscpirngorotomtrjspaprrprrsesms*biaamfmtcmptvfeirasampajampanatalbelemananiradiog12medindfndbmdtrdthepoaggfjdfdefinfenflegsegongengcngorgzlgslglogppgmillelqslcimcomnomadmjabimbbibbsbabcrectecsjcetcpscpvhudieticriapipsiecnbiorioecogeoteoodoproatoartfstmatvetdetbetnetcntnotfotgrueduajuespappreptmpemparqsrvadvdevgovntrturagrjorfarjusmusdesvixxyzcozfozslzbhzmaringasantamariacampinagrandegoianiasorocabafloripasaobernardocuritibaboavistarecifeaparecidasaogoncasalvadorcuiabamorenamacapalondrinacontagemsocialfortalmaceioleilaoosascoriobranconiteroi9guacutcheblogflogvlogwikitaxicoopmanauspalmascaxiasjoinvillebaruericampinassantoandreribeiraoriopretoweorgcomnetedugovv0windsurfshiptodaycloudsitecoaccoorgnetgovofmilcomgovmediatechzacoorgcomnetedugsjgovmydnspenfnlabnbmbgcbcqconcontnuyksknsmyspreadshopno-ipawdevboxbarsyonidatemfuinabusavinstanceseceuguukussryzespawncsxcloud-ipmyphotosfantasyleaguetwmailcleverappsscrappingccwucloudnsftpaccessgame-serverccgovobjectsrmalpgcust*svcalp1aeappenginermalpgmyspreadshop4lima2ixsquare7cloudscale123websitefirenet12hpflowgotdnslinkyard-cloudcloudnslima-citydnskingobjectstorageedaccogoorusorgcomnetinteduaéroportxn--aroport-byaassogouvcomilgobgovcloudnses-1eu-west-1us-east-1euvipit1eurarubait1s3lbwebsites3websiteru-spbru-mskelasticcsrunstnukukcaukusnl-ams-1fr-par-1fr-par-2functionsnodess3ddlwhmrdbfnck8sifrs3-websitecockpitscblmgdbdtwhkafkpubprivs3ddlwhmrdbk8sifrs3-websitecockpitscblmgdbdtwhkafks3ddlrdbk8sifrs3-websitecockpitscblmgdbdtwhkafkk8sscalebookpl-wawfr-parnl-amsbaremetalsmartlabelinginstancesdechk2kuleuvenlaravelvoorloperurownoxazapscwhstgrvaporobservablehqelementorantagonistreclaimjoteluluencowaydiademjelasticmatlabmagentositetrendhostingaxarnetperspectajenv-arubajelejoteravendbemergenttrafficplexconvexkeliwebserveboltbegetcdnstaticson-rancherprimetelonstackitunison-serviceslinkyardbarsyjelecloudnscocomnetgovmycn-northwest-1cn-north-1s3s3-accesspoints3-websites3s3-accesspointrdsdualstacks3-deprecatedemrappui-prods3-websiteemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apis3s3-accesspoints3s3-accesspointrdsdualstackemrappui-prods3-websiteemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicn-northwest-1cn-north-1cn-northwest-1ebcomputeelbcn-north-1airflowcn-northwest-1cn-north-1oncn-northwest-1cn-north-1amazonawssagemakeramazonwebservicesdirectasgdsdhehahljlnmhbacscahqhshhihnlnynsnmofjbjzjxjtjhkcqtwgsjssxnxjxgxxzgz網絡网络公司orgmilcomnetedugovxn--55qx5dcanva-appsxn--io0a7iquickconnectcanvasitekhsjxn--od0algmyqnapcloudsrvrlessclustersrealtimestorageleadpagescarrdcrdorgmilcomnomnetedugovhidnssupabaserdpareplmypiumsoxmitotaplpagesfirewalledreplitowodevwebview-assetsvfswebview-assetss3s3-accesspointdualstackemrappui-prods3-websiteaws-cloud9emrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9eu-west-3ap-south-2eu-south-2eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3eu-central-1me-central-1ca-central-1il-central-1ap-northeast-1ap-southeast-1me-south-1af-south-1eu-south-1ap-south-1ap-southeast-7us-west-2eu-west-2us-east-2eu-north-1ap-southeast-2ap-northeast-2ap-southeast-5ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1s3s3-accesspointdualstackemrappui-prods3-websiteaws-cloud9emrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9s3s3-accesspointdualstackanalytics-gatewayemrappui-prods3-websiteaws-cloud9emrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9s3s3-accesspointdualstackemrappui-prods3-websiteemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apis3s3-accesspointdualstacks3-deprecateds3-websites3-object-lambdaexecute-apis3s3-accesspoints3-websites3-accesspoint-fipss3-fipss3s3-accesspointdualstackemrappui-prods3-websites3-accesspoint-fipsaws-cloud9s3-fipsemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9s3s3-accesspointdualstackemrappui-prods3-websites3-accesspoint-fipss3-fipsemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apis3s3-accesspointdualstacks3-deprecatedanalytics-gatewayemrappui-prods3-websiteaws-cloud9emrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9vfss3s3-accesspointdualstackemrappui-prods3-websiteaws-cloud9emrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9eu-west-3ap-south-2eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3eu-central-1mx-central-1me-central-1ca-central-1il-central-1ap-northeast-1us-northeast-1ap-southeast-1me-south-1af-south-1ap-south-1ap-southeast-7us-west-2eu-west-2ap-east-2us-east-2ap-southeast-2ap-northeast-2ap-southeast-5us-gov-west-1us-gov-east-1ap-southeast-6ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1mrapaccesspoints3s3-accesspointdualstacks3-deprecatedanalytics-gatewayemrappui-prods3-websites3-accesspoint-fipsaws-cloud9s3-fipsemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9s3s3-accesspointdualstacks3-deprecatedanalytics-gatewayemrappui-prods3-websites3-accesspoint-fipsaws-cloud9s3-fipsemrstudio-prods3-object-lambdaemrnotebooks-prodexecute-apicloud9s3eu-west-3ap-south-2eu-south-2computes3-ap-northeast-2elbrdss3-ap-east-1s3-sa-east-1s3-us-gov-west-1s3-eu-central-1s3-ca-central-1eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3s3-website-us-west-2s3-website-eu-west-1s3-external-1eu-central-1me-central-1ca-central-1il-central-1s3-us-west-1s3-eu-west-1s3-website-sa-east-1s3-website-ap-southeast-2ap-northeast-1ap-southeast-1s3-us-west-2s3-eu-west-2me-south-1af-south-1eu-south-1ap-south-1us-west-2eu-west-2us-east-2s3-website-ap-southeast-1s3-1s3-globals3-ap-northeast-3eu-north-1airflowap-southeast-2s3-us-gov-east-1s3-fips-us-gov-east-1s3-me-south-1s3-ap-south-1ap-northeast-2s3-website-us-west-1ap-southeast-5s3-eu-north-1s3-ap-southeast-1s3-website-us-gov-west-1compute-1s3-eu-west-3us-gov-west-1s3-website-ap-northeast-1us-gov-east-1s3-fips-us-gov-west-1s3-website-us-east-1s3-ap-southeast-2ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1s3-us-east-2s3-ap-northeast-1authauthauth-fipsauth-fipseu-west-3ap-south-2eu-south-2eu-central-2ap-southeast-3ap-southeast-4ap-northeast-3eu-central-1mx-central-1me-central-1ca-central-1il-central-1ap-northeast-1ap-southeast-1me-south-1af-south-1eu-south-1ap-south-1ap-southeast-7us-west-2eu-west-2us-east-2eu-north-1ap-southeast-2ap-northeast-2ap-southeast-5us-gov-west-1us-gov-east-1ca-west-1us-west-1eu-west-1us-east-1ap-east-1sa-east-1rservicesbuilderstg-builderdev-builder* ünstigliefernbwcloud-os-instancemy-routerxn--gnstigliefern-wobin-butterl-o-g-i-nisteingeekin-dslin-berlinin-brbfuettertdasnetzleitungsenin-vpnlcube-serverdyn-ip24logoipdyn-berlinruhr-uni-bochum12hpgoipfruskygit-repossvn-reposinternet-dnsgünstigbestellenhome-webserverxn--gnstigbestellen-zvbbplacedcosidnswebspaceconfiglima-citydyndns1istmeinvirtualuserschulplattformmy-gatewaylebtimnetztest-iservmein-iservvirtual-useriservschuletaifun-dnstraeumtgeradeschulserverdynamisches-dns123webseitednshomehs-heilbronndnsupdaterbssgraphicdwadpdwdaepeweaawapaafpfwfabwbpbacwcpcciwebuserapiobjectsidsiskospockkimodorikerbonesteamsparisjanewaypicardglobaltarpitreedpikekiraworfsulukirkarchertuckerhackercanarywesleystagingprereleaset3r2lpbravepanelngrokiservstglclcrmerpflypagesbarsyvivenushoplocalcertlocalplayerbearbloggatewaydeno-stagingis-not-ais-a-goodbotdashvercelmocha-sandboxplatter-appreplitgithubpreviewworkersinbrowserevervaultdetais-ahrsndenoxmitmodxmyaddrstorageapipayloadgrebedocruncontainersstgstagelclstageloginlineis-a-fullstackleapcellngrok-freeis-coolstoragewebharemediatechlibp2pdiscourseimaginecomyspreadshopstoreregbiz123hjemmesidefirmcoorgcomnetedugovsldorgmilcomwebgobartnetedugovtmorgpolcomsocartnetedugovassoagrondiscoodontk12medcuegyecpaabgengorgmilgalsaltulcomadmesmgobpubdocmonfindgnriouioproartlatvetnetfotedulojgovntrturibrbarxxxofficialbasechefprofmktgpsictechinfoarqtcontdentrrpppsiqgit-pagesritmedfieorgcomlibprieduaipgovriikmeactvsportorgmilcomscieunnetedugovnameinfopintouchtawktotawkmyspreadshoporgcomnomgobedu123miwebcomputeorgcomnetedugovbiznameinfocognito-idpeusc-de-east-1onjelasticnxaspdnsbarsydirectwpdeuxfleurstransurldogadoprvwcloudnsamazonwebservicesuserpartycokoobinstorjfidemopaasdymyspreadshopalandkapsiikixn--hkkinen-5wacloudplatformdatacenterhäkkinen123kotisivuidacorgmilcompronetedugovbiznameinforadioorgcomneteduuserexperts-comptablestmmyspreadshopgretaprdcomnomynhccifbxoshuissier-justicenotairesaeroportfreeboxoson-webavocatassoportgouvkdnschirurgiens-dentistes-en-franceavouesfbx-os123sitewebveterinairechirurgiens-dentistespharmacienchambagrimedecinfreebox-osdediboxgoupilemszicpyicpvicppleysheezypagesedugovcnpyorgcompvtnetedugovschooldaemond6atcopanelorgnetplybotdashstackitkaasorgmilcomnetedugovbizmodltdorgcomedugovcoorgcomneteduappwriteacorgcomnetedugovcloudtranslateusercontentorgcomnetedumobiassoorgcomnetedugovbarsysimplesitediscourseindorgmilcomgobneteduorgcomwebnetedugovguaminfonxhra教育敎育網絡网絡组織組織网络網络组织組织公司政府個人个人箇人ltdorgcomincneteduidvgovxn--uc0ay4axn--55qx5dxn--mk0axixn--io0a7ixn--uc0atvxn--zf0avxxn--lcvr32dxn--od0algxn--wcvs22dxn--gmqw5axn--od0aq3bxn--mxtq1mxn--ciqpnxn--tn0agxn--gmq050iorgmilcomgobneteduiservwp2tempurlmircloudfreesitewpmudevmyfastgadgetcloudaccessjelehalfboltfastvpsemergenteasypanelopencraftizcombrendlynamefromrtpersoadultmedorgpolrelcomproartnetedufirminfoassoshopcoopgouvtmcomediahotelforumvideosportorgsexagrargameslakaseroticaerotikatozsdereklamcasino2000filmsuliinfoboltshopprivnewsszexcityutazasjogaszkonyveloingatlaneacaicogoormyᬩᬮᬶmilwebschnetkopbizzonedesaponpesxn--9tfkymyspreadshopgovmytabittabitorderravpageaccok12idforgnetgovmuniltdplcaccotttvorgcomnetmeca6g5gpgamacaicniocoukuptverdruscsdelhiindorgmilcomwebnicfingenpronetintedugovresbizbiharbarsyinternetbusinesstravelsupabasegujaratfirminfopostbankcoopindevscloudnsno-ipbarsybarrell-of-knowledgebarrel-of-knowledgensupdategroks-thisdnsupdatefor-ourknowsitalldvrcammittwalddynamic-dnsv-infowebhopselfipdyndnshere-for-moreilovecollegemayfirstforumzcloudnsmittwaldservertypo3servergroks-theeusekd1uk0cdndyndnsidrawsainaueuapjpusstagemocksysdevicesclientcustreservdcustdevdisrecprodtestingcobeebyteutwenteboxfusebravepstmndedynngrokorgmilcomnomhzcnetedugovqcxqzzbarsythingdustmo-siemensrb-hostingprotonetfh-muenstergitbookbluebitecloudbeesusercontentnodeartkiloappsforgerockdarklangresinstagingapigeebubbleb-datascryptedhypernodedappnodepantheonsitegitlabgithubkeeneticvirtualservercleverappshostyhostingon-rioedugitticketstelebiton-acornwixstudioon-k3sicp0icp12038jeleqotobigvlairbubbleappsmyaddrstolosmyrdbxwebflowdrive-platformbeagleboardhasura-applolipopdefinimavaporcloudmusicianwebflowtestazurecontainerresindevicereadthedocsloginlineeditorxmoonscalesandcatsbasicserverwebthingsbrowsersafetymarkbeebyteappbitbucketidaccovistablogorgschnetgovxn--mgba3a4f16axn--mgba3a4fraarvanedgeايرانایرانjclaspeziapdudcefegelemeperetevebacanatavaparasabgagfgogrgpgalclblimfmrmcbmbvbfclcmcvcrcpcchlimifibicivipirisimncnbnanenrnpntnnolomobocoaogorosopotoptvtatctbtmtltotpulunutpspapaqsvpvvvtvavvrtrsrprgrfrcrbrarorkrvstsssbscsmsispzczbzbozen-suedtirolmyspreadshopxn--bulsan-sdtirol-nsbxn--valledaoste-ebbtrentinoaltoadigetrentin-sued-tirolxn--forlcesena-c8axn--forl-cesena-fcbxn--bozen-sdtirol-2obtriestetrentinsuedtiroltrentino-s-tirollecceudineaostesienaparmaluccapaviagenoapaduaaostamonzaabruzzoternirietiturinmilanbozenlaziofermoleccocuneonuoropratola-speziavdataaligfvgpugmolcalcamlomumbsicpmnvenvaoedugovabrsarmaremrbastoslazibxosfirenzetrentinosüdtirolval-d-aostavalle-aostamessinacremonaravennatoscanatrentin-suedtirolbolognacalabriaurbinopesarofriuli-v-giuliaogliastraxn--valle-aoste-ebblaquilaandriatranibarlettasyncloudtrentinosudtirolxn--valle-d-aoste-ehbaostavalleyvalled-aostatrentino-alto-adigevallee-d-aostexn--balsan-sdtirol-nsbpistoiasicilialucaniacataniaiserniaperugiabresciaveneziagorizialiguriaimperiabulsan-suedtirolbalsan-suedtirolbarlettatraniandriaxn--trentino-sdtirol-szbforlì-cesenatuscanyvallée-d-aostemantovavallée-aostecasertapiemontevalleaostaval-daostafriulivgiuliatrevisoforli-cesenavalléedaosteferrarapescaravald-aostatrentino-altoadigefriuli-vegiuliavallee-aostecarboniaiglesiastarantomediocampidanovalleedaostetrentinosud-tirolcampobassotrentinsüd-tiroltrentinosüd-tirolmonzabrianzatrentino-südtirolxn--trentino-sd-tirol-c3bpotenzacosenzavicenzaemiliaromagnavenicefrosinonemarchepordenonetrentinosued-tirolvaresemolisevalléeaostefriuli-veneziagiuliabasilicatalatinaanconasavonaveronamodenaaquilabiellabolzano-altoadigepugliafoggiaumbriatrentino-stirolgenovapadovamateranovararagusapiacenzatrentinostirolvalleeaostetempio-olbiatrentinsudtirolmassa-carrarafriuliveneziagiuliatrentinosuedtirolandria-barletta-tranitrapanixn--cesenaforl-i8amaceratacaltanissettaascoli-picenobrindisicarraramassacagliaririmininapolivibo-valentiachietibulsan-sudtirolbalsan-sudtiroltrentino-a-adigebulsanbalsaniglesiascarboniamilanotorinoteramodell-ogliastraarezzotrentinoalto-adigerovigotrentovenetoiglesias-carboniatrentino-sud-tirolaltoadigereggio-emiliareggio-calabriasardegnatranibarlettaandriapiedmontxn--sdtirol-n2amedio-campidanotrentino-süd-tirolfriuli-vgiuliafriuli-ve-giuliaromeennaromapisa32-b16-b64-blodiastibarineencomonaplesforlicesenailiadboxosalessandriasicilytrani-barletta-andriaxn--trentin-sdtirol-7vbpesarourbinotrentinsued-tirolcesena-forliforlìcesenaemilia-romagnamonzaebrianzaxn--trentinsdtirol-nsbtrentinos-tiroltrentinsüdtirolvalledaostaolbia-tempiocampidanomediovibovalentiasassarivalle-daostalombardyfriulivegiuliareggioemiliamonzaedellabrianzaalto-adigevercellitrentin-sudtiroltraniandriabarlettatrentino-sudtirolascolipicenobozen-südtirolfriulive-giuliaflorencevaldaostaxn--cesena-forl-mcbcarbonia-iglesiasaosta-valleycarrara-massadellogliastratrentinoa-adigexn--valleaoste-e7apesaro-urbinoxn--trentinosdtirol-7vbxn--trentin-sd-tirol-rzbxn--trentinsd-tirol-6vbtrani-andria-barlettatrentin-süd-tirolxn--trentinosd-tirol-rzbgrossetomonza-e-della-brianzasüdtirolreggiocalabriatrentinoaadigetrentin-südtirolfriuliv-giuliaverbaniacampaniatrentino-aadigefriulivenezia-giuliasardiniaandriabarlettatranibarletta-trani-andriacatanzarooristanourbino-pesarocesena-forlìvalle-d-aostacampidano-medio123homepagesiracusatempioolbiasuedtirollombardiaavellinocesenaforlìtrentinofriuli-venezia-giuliabozen-sudtirolandria-trani-barlettabulsan-südtirolbalsan-sü 長野京都岐阜大阪三重群馬千葉滋賀佐賀奈良adednelgaccogogror秋田愛知高知埼玉沖縄栃木熊本岩手青森山梨新潟島根鳥取長崎香川宮城石川大分宮崎茨城山口兵庫山形徳島広島福島福岡岡山富山静岡愛媛福井東京xn--4it168dhatenadiaryxn--vgu402ckawaiishophatenablogcocottenamaste北海道penneehimeiwateversestabachibashigagonnagunmapermahaccaakitaosakauh-ohblushkochiaichifukuikuroncapooitigohyogotokyokyotopunyuthickcheap0t00g00j0mie2-ddaapyawjg0amfemsubxiiboomoobutchueekpgwrgrherskrboyrdyupperunderflierchipsmydnsheavyangryhippygirlyrulez神奈川鹿児島和歌山 ålerxn--vler-qoaossandeheroysandeherøybøboheroyherøyxn--hery-iraxn--b-5gavalerbøboxn--b-5gasandesandexn--hery-iraxn--vler-qoavålerhåålaahavaofsfvfhlolnlalrlhmfmtmahcostntbuåstrmreigersundmyspreadshopgálsáeidsvolltingvollgildeskalflorøvadsøvardøvanylvenxn--bhccavuotna-k7astrandaxn--kvnangen-k0axn--sknland-fxaxn--mosjen-eyarakkestadhyllestadnannestadvevelstadvaapstenordre-landsondre-landsøndre-landxn--vrggt-xqadsør-aurdalsor-aurdalheradstordmoldefordeførdeseljefedjeryggehemnexn--krehamn-dxasognegranesøgnebrynetjomevallebykletokkegiskedovretjømehobølvoldasaudatolgasømnaviknadønnasomnadonnatranafrananesnaraumasmolatrænafrænalesjasmølaørstaorstahitrafloraaukraloppafrøyarissasnasahalsagalsaromsaraisaráisafroyasnåsagronghobolfjelltydalårdalardalaskimharamkraanghkekråanghkesorumbarumhurumbærumsørummodumsálátbálátfrognbjugnvåganvagangulenskienløtenlotenstrynvefsnxn--merker-kuaskaunsveiobømlobomloskjåkvardoflorovadsosalatbalatsálatklæbuklabuselbubarduulvikskjakklepprisørxn--nttery-byaeflåeidflahofmilgolholsellomskifetvikdepvgsfhsaskerrisorhamarasnesåsnesrørosrorosxn--slat-5namasoynaroyvaroyluroydyroyaskoyradoyandoyrodoymeloyradøyandøyrødøymeløyaskøylurøydyrøymåsøyværøynærøyhoylandethøylandetdivtasvuodnalørenskoglorenskognesoddtangenxn--tjme-hraxn--smla-hraxn--stjrdal-s1aunjargalillehammerunjárgadavvenjargaxn--bearalvhki-y4a123hjemmesidegjerdrumxn--brnnysund-m8acxn--tnsberg-q1axn--mlatvuopmi-s4axn--snsa-roaxn--skierv-utaxn--brum-voatysfjordkvafjordeidfjordkvæfjordsongdalenmjondalenmjøndalenxn--gls-elackragerogáŋgaviikagangaviikasørreisasorreisasør-varangersor-varangerxn--risr-iraskiervaxn--frna-woaxn--trna-woakvinesdalleksvikleirvikrøyrvikroyrviksvelvikvenneslaevje-og-hornnessandnessjøenmarnardalvindafjordsandefjordenebakksnillfjordullensvangxn--trany-yuabrønnøysundnamsskoganaustevollxn--stjrdalshalsen-sqbnord-aurdalnord-frontrøgstadtrogstadgrimstadflakstadgjerstadxn--sandy-yuaxn--leagaviika-52bnore-og-uvdalvegarsheixn--rlingen-mxaxn--ggaviika-8ya47hvegårsheikarlsoykvitsoymasfjordenhamaroyinderoyosteroydavvenjárgasauheradguovdageaidnuxn--vre-eiker-k8abronnoysiellakkrødsheradkrodsheradkvinnheradbrønnøyxn--mtta-vrjjat-k7afxn--lrenskog-54akvitsøyvárggátosterøyinderøybronnoysundxn--aurskog-hland-jnbbahccavuotnabáhccavuotnagiehtavuoatnastor-elvdalmidtre-gauldalxn--gildeskl-g0akarasjokevenassixn--bievt-0qaxn--yer-znaaudnedalnlebesbynessebyxn--hbmer-xqamalselvmålselvxn--unjrga-rtamøre-og-romsdalmore-og-romsdalhareidmelandørlandorlandstrandålgårdsolundalgardafjordåfjorddielddanuorrikautokeinoxn--stre-toten-zcbskodjeaejriestangeliernebamblestokkefauskesnåasesnaasekongsvingerlangevagberlevagxn--flor-jrahattfjelldalostre-totenøstre-totenvestfoldxn--mely-iraálaheadjualaheadjunordreisaxn--troms-zuaxn--lgrd-poacporsangerflatangerstavangerleikangerbremangersamnangerkarasjohkaxn--rdy-0nabfrostautsirasnoasatromsaxn--sr-aurdal-l8aflekkefjordjølsterjolsteraremarkhedmarknååmesjevuemienaamesjevuemiexn--vard-jrarollagmeråkermerakerorskogørskogxn--bdddj-mrabdákŋoluoktaxn--osyro-wuaaknoluoktatrysilskjervøymandaljondalbindalrindalmeldalsuldalorkdalsigdalalvdallærdalhurdalsirdalverdallerdallardaloppdalåseralaseralhadselkragerødivttasvuotnaoverhallasteinkjerxn--hnefoss-q1askedsmokorsettromsøxn--dyry-iravestre-totenmuseumxn--sandnessjen-ogbrahkkeravjufylkesbiblbájddarbajddarxn--laheadju-7yarennesøyxn--koluokta-7ya57hxn--hgebostad-g3aleirfjordstorfjordbalsfjordbåtsfjordbatsfjordmuosátbievátloabátkárášjohkanøtterøyxn--mjndalen-64anordkappláhppilahppialstahaugsiljanverranrøykenroykenhaldenlyngenbergenhortenhønefosshonefosstroandinbeiarnvarggatosoyroosøyrotromsoidrettmuosatbievatruovatloabatvoagattynsetnessetxn--indery-fyaskánitskanitraholtråholtxn--ystre-slidre-ujbandebusarpsborgbearduhordalandjorpelandjørpelanddeatnuringsakersør-odalsor-odalxn--slt-elabringerikenittedalnissedalhemsedalslattumsurnadalxn--blt-elabelverumstjørdalnaustdalhjartdalgjøvikfyresdalhasviknarviklarvikgjovikmalvikgamviklenvikporsgrunnstjordalengerdaldrobakdrøbakxn--msy-ula0hvestvagoyxn--vgan-qoaxn--ryken-vuaxn--lten-graxn--stfold-9xaxn--hpmir-xqaxn--lury-iramálatvuopmimalatvuopmitysværkirkenesbirkenesmoskenesbáidárxn--fjord-lraxn--rdal-poabahcavuotnabáhcavuotnaxn--frde-gralindåsbearalvahkixn--hobl-iraráhkkerávjuxn--loabt-0qavågåáltábodøsundlundraderådeetnetimeholeauregrueoddavagavegaranatanaarnasolasulaaltalekafusavangbergkvamåmliamlifreibokntinnroangranosenoslobodorøstroststatåmotamotivguprivøyeroyerliermossvossxn--nvuotna-hwalusterlunnermarkerhábmerhabmerhvalerfjalerxn--rholt-mratysvarbaidarfitjargaularhápmirhapmirmelhusfosnesøksnesoksnestysneshemnesevenesflesbergeidsbergtonsbergtønsberglindasxn--sndre-land-0cbnamsosxn--srum-graøystre-slidreoystre-slidrevestre-slidretrondheimbalestrandxn--langevg-jxaaustrheimxn--skjk-soavagsoyaveroysandoykarmoyfinnoytranoyvestbytranbysykkylvenxn--hyanger-q1aspjelkavikandasuoloxn--fl-ziaxn--drbak-wuastathellexn--sr-varanger-ggbtelemarkxn--bhcavuotna-s4axn--porsgu-sta26fčáhcesuolocahcesuoloakrehamnåkrehamnsandøykarmøyfinnøytranøyvågsøyaverøynamdalseidxn--lesund-huabadaddjaxn--vegrshei-c0axn--btsfjord-9zagildeskålporsanguxn--trgstad-r1anávuotnanavuotnahammerfestxn--sgne-graxn--brnny-wuacibestadharstadnarviikaevenáššivestnesgjemnessandnesagdenesrennesoyxn--avery-yuaxn--tysvr-vrabearalváhkikongsbergspydebergrandabergxn--andy-iradavvesiidaxn--krdsherad-m8aporsáŋgufredrikstadbjerkreimringeburennebuaurskog-holandnotteroyxn--vgsy-qoa0jxn--rmskog-byaskierváivelandbyglandfrolandaurlandforsandxn--bjddar-ptamidsundålesundalesundfetsundfarsundovre-eikerøvre-eikerakershusxn--moreke-juasørfoldøstfoldostfoldsorfoldhøyangerhoyangerlevangerorkangertanangerxn--vestvgy-ixa6olillesandxn--rennesy-v1agranvinskjervoyxn--klbu-woalavagisxn--h-2faxn--ryrvik-byakafjordkåfjordseljordfolkebiblxn--gjvik-wuajevnakerxn--kfjord-iuabudejjuxn--kranghke-b0axn--davvenjrga-y4axn--rland-uuaxn--ldingen-q1axn--mlselv-iuaxn--rady-iraxn--linds-prabrumunddalxn--ygarden-p1amo-i-ranaeidskogrømskogromskoghjelmelandxn--finny-yuaxn--sr-odal-q1axn--skjervy-v1aballangenkvanangenkvænangengratangenxn--hmmrfeasta-s4acvossevangenxn--rde-ulaxn--mli-tlaxn--ksnes-uuanordlandskanlandskånlandsortlandfuoiskuxn--rros-graxn--hcesuolo-7ya35bxn--eveni-0qa01gagaivuotnagáivuotnaxn--seral-lradrammenmodalenmosjoenjan-mayentorskensteigengloppenxn--snes-poamatta-varjjatxn--sr-fron-q1aomasvuotnajessheimbådåddjåxn--krager-gyaxn--kvfjord-nxaxn--asky-iraxn--snase-nraxn--bidr-5nacholtålenxn--vads-jraxn--jlster-byamosjøenxn--rst-0nastavernxn--ostery-fyaxn--oppegrd-ixaxn--sknit-yqaxn--risa-5naoppegårdskiptvetrendalenholtalenxn--mot-tlaxn--lhppi-xqaxn--holtlen-hxaxn--srreisa-q1akopervikxn--muost-0qaxn--bmlo-grahokksundkvalsundegersundxn--karmy-yuaullensakerxn--hylandet-54axn--kvitsy-fyaxn--bod-2nalangevågberlevågkristiansandxn--rsta-frahornindalstjørdalshalsenstjordalshalsensandnessjoenhámmárfeastaxn--lrdal-srasør-fronsor-fronnord-odalkristiansundmátta-várjjatvestvågøynesoddennotoddenbuskerudøygardenoygardensalangenlavangenralingenrælingenlodingenlødingenleaŋgaviikalaakesvuemieleangaviikaxn--srfold-byaaskvollxn--rskog-uuaxn--nry-yla5gxn--vry-yla5ghammarfeastaxn--rhkkervju-01afxn--givuotna-8yakommunekrokstadelvanedre-eikerhagebostadhægebostadxn--berlevg-jxakviteseidxn--s-1faxn--l-1faxn--nmesjevuemie-tcbafuosskomoårekemoarekexn--lt-liacxn--jrpeland-54asvalbardoppegardholmestrandtvedestrandsogndalsokndalarendalsunndalfolldalxn--krjohka-hwab49jlyngdaletnedalnorddalsaltdalgausdalskedsmovaksdalgjesdalstordalxn--frya-hraaarbortedrangedalxn--smna-graaurskog-hølandxn--vg-yiabtjeldsundhaugesundlindesnesxn--mre-og-romsdal-qqbxn--dnna-gramerseineshacknetenterprisecloudmineaccomaorimā яспборгкоммскбизмирсамаракрымсочиакодпроргобрупрצהלממשלישובאקדמיהองค์กรธุรกิจรัฐบาลศึกษาทหารเน็ต教育網絡組織公司政府個人닷넷한국澳门新闻澳門联通家電嘉里招聘通販닷컴삼성コムგეбгрфеюadcdbdgdidmdsdtdaebedeeegeiejekemenepereseveyegabacalamanauavapaqasazacfbfafgfnfpfwftfbgcgagggegkgngmgsgpgvgtgugilmlnlalclglplsltlhmimjmkmmmomambmcmdmfmgmzmpmsmtmgbbblbsbecccacnclcmcvctcscmhkhghchbhthphshlinikifigiaibicivisikninhnmncnbngnsnpnvntnjoionomobocoaofodorosotoptstttytatbtetgtithtmtltrusuvuaucueuguhulumunufjdjbjtjsjlkmkhkfkdkcktkukskpkgpmpnpkpjpgqaqmqiqsvtvcvbvmvlvrwpwtwzwbwcwawgwkwmwtrsrprgrfrercrbrarnrmrlrkrirhrwsusrssspsgsesbsaslsmsissxmxaxcxuypysylymykygybycyuztzsznzmzkzdzczbzazελευ世界台灣购物公益点看臺灣网络書籍在线网站手机机构大拿游戏信息台湾谷歌慈善商标香港中国餐厅网址中國商城食品微博政务移动集团公司八卦商店健康网店政府时尚佛山中信娱乐广东企业homedepotengineeringاماراتrepublicankuokgroupversicherungchannelcitadelxn--pgbs0dhxn--b4w605ferdstatebankwebsitexn--mgb9awbf亚马逊淡马锡alibabaxn--ngbc5azdxn--mgbbh1axn--45br5cyltoshibabuildworldcloudtradeguideplacespacedancemoviephoneprimesmilebiblestyleappleazurestoreskypegripexn--l1accdrivelottehorsehouseleasechasereisestadahondaomegaaetnaamicaninjanokiamediadeltavodkaedekaosakapizzaslingemailgmailtirolshelltmallfinallegaltotalhotelamfamforumrehabmusicciticricohcoachwatchboschearthfaithirishmiamiarchidubaiguccipraxiみんなストアセールcanonsalononionnikonepsonkoelngreensevencrownikanoradioaudioweiboglobopromogalloyahoociscorodeovideomangobingotokyovolvolottokyotophotosmartsportquesttrusthyattjetztadultcymrubaidutushuxn--kprw13dubankclickblackmerckgroupsharpcheapnowtvxn--h2brj9cקוםհայоргсрбмонкомбелмкдқазрусукрمصرقطرعربكومdadcfdmedwedredphdthdbidpidkrdmsdltdiceonewmeglemoerwecfageacbanbambaaaammakianraspacpaaxawtfbcgaegongingaigvigorgdogdhlmilrilonlaolloluoljllcalgalnflafltelsrlfrllplkimibmcamcombommomifmabbjcbscbcabnabtabmlbpubabcbbcnecincpncllcstcwtcpwcnyckfhbzhovhmoiskiobisbitcifyituipinvinwinxincbnbcnmanfangdnmenrenkpnmtnyunrunfununobiojioriohbogmofooboooooacoecoceongoproartistottnttbbtcateatlatvetpetbetnethktmitfitintjothotgotdotbotprueduicujnjyouinknhktdkappsapgapmapdnptopgopllpjmpzipvipripesqtrvdtvitvdevmovgovhivnrwlawsewnewbmwwownowhowdvrftrmtrsfrbarcartvscrseusawsupsubssbsadsddsldssasbmsmlsxxxboxfoxgmxtjxsextaxbuyflydiysoyjoyskypaydaygayxyzanzbizwebersenerpokerlameractortatarsolarລາວคอมไทยtourslocusnexuslexusgiftsbeatsboatspartspressglassswissकॉमनेटtiresgivescodeshomesgamestunesshoescardswalesloansvegastoolsdealsautosparisファッションworkssucksrocksxeroxforexfedexpartylillymoneystudyrugbytoraytoday中文网xn--unup4y天主教飞利浦新加坡enterprises我爱你嘉里大酒店christmasxn--fct429kholdingsxn--8y0a063axn--mgbx4cd0ablifestyleabogadoallstatenetbankكاثوليكxn--s9brj9cxn--gk3at1ebestbuycharityxn--55qx5dmicrosoftpropertybasketballhomegoodscorsicajewelrygallerygrocerysurgerycountrybrusselsverisignferreroxn--czr694bhdfcbankcommbanksoftbankپاكستانپاکستانnextdirectالسعوديهالعليانxn--h2brj9c8cxn--80adxhksshikshaxn--mgbai9azgqp6jcuisinellabarclayscatholicxn--kpry57dcompanyxn--xhq521bblackfridayxn--mgba3a3ejtsandvikxn--d1acj3bacademydownloadمليسياxn--j1amhxn--w4r85el8fhu5dnraipirangaathletaxn--fhbeixn--mgbqly7cvafrzuerichxn--c2br7gஇலங்கைcontractorsxn--io0a7igraphicsinsurancetemasekxn--xkc2al3hye2amotorcyclesphotographydirectoryplumbingxn--vhquvclothingtrainingcleaningwilliamhilllightingxn--mgba3a4f16ashoppingcateringeducationokinawapicturesventuresproductionsxn--9et52uwalmartഭാരതംsupportrealestatecapitalonexn--nqv7fs00emaauspostfloristdentistxn--qxamgodaddybradescobargainsmitsubishikerryhotelsxn--9dbq2axn--3pxu8kimmobilienxn--fjq720axn--mgbtx2bholidaymckinseymadridbusinessbuildershelsinkixn--4gbrimмоскваالسعودیةcoffeedegreelacaixapartnersalsaceofficeabbvievoyageorangegeorgeonlinechromemobilekindlegoogleoraclecircleschulesecureinsurexn--mgba7c0bbn0aestatexn--mgbc0a9azcgcruisehangoutxn--vuq861bxn--42c2d9arexrothfirestoneuniversityxn--nnx388alifeinsuranceextraspaceонлайнvermögensberatersoftwarexn--fiqs8sxn--mgbab2bdxn--w4rs40ltiendaभारतम्africatoyotaotsukasakuracameracreditcardnagoyaconsultingnetworkjunipertheatermonsterprogressivepioneerxn--55qw42gracingdatingvotingvikinglivinggivingxn--bck1b9a5dre4cbrotherweatherjoburgفلسطينlplfinancialxn--clchc0ea0b2g2a9gcdfutbolschoolsocialglobaldentalwoodsidechanelairtelmatteltravelrealtorwebcamstreamభారత్unicomalstomxn--nodexn--6frz82gmuseumfurniturexn--rvc1e0am3exn--mix891faccenturexn--11b4c3dismailineustardiscountquebeccomsecclinicservicesxn--y9a3aqxn--c1avgswatchchurchsearchالاردنmarketingcontacthealthmonashshoujisanofitaipeiamericanexpresssuzukiアマゾンクラウドポイントbhartiグーグルxn--mgberp4a5d4armemorialxn--1qqw23alondonmormoninstitutevisionbostonnortoncouponmaisonamazonvirginberlindesigndurbanolayannissananquanxihuanhitachikaufengardenreisenbayerntechnologydatsunxn--90a3aclatinocasinostudiophysioxn--ngbe9e0apharmacytattootaobaoaramcoexpertreportabbottdirectselectimamatfairwindspictettargetmarketintuittravelersinsurancecreditdupontryukyusuppliesxn--tckwebnpparibasschmidtmerckmsdyodobashirestaurantbridgestonecricketxn--fpcrj9c3dbostikbroadwayattorneylefrakemerckxn--fiq228c5hscareersfarmerswinnersflowersxn--wgbh1cguitarsxn--54b7fta0ccxn--p1acfmakeupgalluplandroverxn--kcrx77d1x4agoldpointbauhausxn--mgbayh7gpahiphopplaystationxn--mgba3a4fraxn--eckvdtc9dhyundaixn--gckr3f0fistanbulticketsmarketsflightschintaireviewsxn--3e0b707ewindowsxn--fiqz9sfinancialxn--fzys8d69uvgmابوظبيdiscoverreviewবাংলাxn--5su34j936bgsgmoscowobserverapartmentsдетиارامكوсайтeurovisionxn--i1b6b1a6a2exn--xkc2dl3a5ee0hتونسموقعبارتڀارتشبكةعمانبيتكعراقreadkredbondlandbandfundfoodprodgoldfordtubecafesafelifeggeeieeefreefagepagegugezonewinememenamegamesaleablebikenikelikecarecbreherefiresaveloveliveblueartedatesitevotecaseluxebofamodaltdaasdatiaayogasinavanashiaasiajavabbvatevavivadatazaraarpacasavisasncfprofmaifsurfgolfdvagsongbingpingwangkpmggoogblogpohlfailcooldellcalldeallidlsarlfilmteamroomfarmimdbarabclubhdfcicbchsbcgmbhrichtechfishdishcashminiernikddiaudiwikimobitaxicitikiwidesiqponskinloanakdnwienopenporncerntownimmolimoolloinfonicofidolegosaxozeroaerovivoautovotomotofastbestresthostpostnextlgbtchatseatgiftmeetdietreitmintrentgentspotscotguruitausohumenucyoubanklinkpinkdclktalksilkbookseekworkrsvpaarpjeepshopcoophelpcamppccwshowbeerstarruhrflirweirhaircarsparsjprshausplusnewstipstoysjobskidsfanspicsdocsxboxamexsexynavycitysonyarmyallybabyplaydeliverybuzzgbizlamborghiniphilipsලංකාಭಾರತfitnessexpresslanxesspfizercenterwalterlawyersoccercareerkosherbrokerlockerdealerdoctorauthorxn--mgbqly7c0a67fbcvermögensberatungjaguarxn--pssy2uxn--hxt814eflickrrepairrogersairbusxn--mgbai9a5eva00beventsyachtsxn--t60b56aভাৰতভারতभारतभारोतviajeshermeshughesxn--j1aefसंगठनvillasଭାରତclaimshotelsભારતzapposphotosjuegoscondostatamotorsgratistennisਭਾਰਤtkmaxxtjmaxxschaeffleryandexxn--80aswgrealtysafetybeautyluxuryxn--3ds443gsupplyfamilyxn--o3cw4hhockeysydneyxn--90aenissayalipayenergycomputeragencyxn--rovu88b電訊盈科xn--gecrj9cstatefarmaccountantaquarelleolayangroup香格里拉xn--p1ai组织机构xn--1ck2e1bxn--mgbt3dhdschwarzموريتانياabudhabinowruzkomatsufujitsuhospitalxn--80asehdbxn--mgbtf8flxn--j6w193gxn--yfro4i67oprudentialxn--flw351ecruisescoursesrecipesxn--e1a4cferrarixn--ses554gxn--wgbl6awatchesstaplessinglesxn--mgbcpq6gpa1axn--otu796dpropertiescreditunionxn--mgbah1a3hjkrdstockholmhisamitsuالسعوديةstcgroupdomainsoriginscouponsbloombergclubmedfroganslimitedxn--80aqecdr1aexposedinternationalequipmentbarclaycardxn--q7ce6axn--mgbi4ecexpprotectionassociatesconstructionxn--cck2b3bxn--45q11candroidfoundationישראלxn--mgbca7dzdocliniqueboutiqueengineerxn--qxa6asystemsfirmdalefashionauctionxn--nqv7finfinitirentalsreliancetradingweddingfishinghostinggentingbookingcookingxn--3hcrj9cgraingerxn--czrs0tdemocratsamsungyokohamaxn--h2breg3evexn--nyqy26alundbeckmelbournevacationssolutionsfrontierxn--vermgensberatung-pwbmanagementxn--cg4bkixn--mgb2ddeslincolnhamburgsandvikcoromantblockbusterairforcebarefootxn--4dbrk0ceinvestmentsfeedbackcommunityxn--ngbrxالبحرينdiamondsamsterdamhealthcareredumbrellaxn--mxtq1mxn--2scrj9cagakhanxn--mgbpl2fhкатоликcaravanசிங்கப்பூர்richardlimortgageamericanfamilyxn--fzc2c9e2cscholarshipssaarlandxn--imr513nvlaanderensamsclubgoodyearkitchenஇந்தியாweatherchannelallfinanzxn--kput3iالسعودیۃxn--90aisxn--efvy88hالجزائرxn--mgbaam7a8hexchangejpmorganxn--tiq49xqyjfidelitysecurityxn--mk1bu44cwanggouxn--fiq64bxn--6qq986b3xlxn--mgbbh1a71exn--80ao21amarshallsxn--5tzm5gtravelerspanasoniclatrobeyoutubeaccountantsxn--rhqv96gxn--cckwcxetdanalyticsxn--ygbi2ammxبازاربھارتسوريةorganicfreseniusسورياxn--9krt00axn--qcka1pmcxn--jlq480n2rgdeloittesciencefinancexn--jvr189mxn--30rr7yhomesensehotmailbaseballfootballleclercboehringerxn--q9jyb4cxn--mix082fاليمنهمراهpolitieسودانايرانایرانnetflixyamaxunxn--lgbbat1ad8jcollegestoragecapetowncolognekerrypropertiesxn--mgbgu82axn--ogbpf8flxn--czru2dwhoswhociprianilasallexn--g2xx48cforsalebanamexaudiblexn--vermgensberater-ctbxn--zfr164bericssonvanguardxn--45brj9cindustriestheatremarriottxn--3bst00mcomparexn--mgberp4a5d4a87gcapitaldigitalالمغربbarcelonashangrilaxn--d1alfcalvinkleinwwwcitysapporokawasakinagoyasendaikobekitakyushuyokohamackjp";const rulesRoot=617;const exceptionsRoot=621;
;// ../../node_modules/tldts/dist/es6/src/suffix-trie.js
// NOTE: kept (intentionally) near-identical to packages/tldts-icann/src/suffix-trie.ts.
// They are separate copies rather than a shared helper because the lookup is
// only fast when the typed arrays are module-scope monomorphic globals —
// closing over them (a shared factory) measured ~20% slower. The ICANN build
// also specializes (constant mask, no isIcann/isPrivate). Keep the two in sync.
// `edgeOffset` (where each label starts in `labelText`), `edgeHash` (djb2 of
// each label) and `wildcardEdge` (each node's '*' edge, or -1) are derived once
// at load instead of being shipped: the bundle then carries only the
// compressible `labelText` + structure, while the lookup binary-searches
// integer hashes. The cost is a single ~1ms pass at first import — cheaper than
// the object trie it replaces. Kept at module scope (not captured in a closure)
// so V8 treats the typed arrays as fast monomorphic globals.
const numberOfNodes=nodeFlags.length;const numberOfEdges=edgeLength.length;const edgeOffset=new Uint32Array(numberOfEdges);const edgeHash=new Uint32Array(numberOfEdges);const wildcardEdge=new Int32Array(numberOfNodes).fill(-1);for(let node=0,offset=0;node<numberOfNodes;node+=1){for(let edge=edgeStart[node];edge<edgeStart[node+1];edge+=1){edgeOffset[edge]=offset;const end=offset+edgeLength[edge];let hash=5381;for(let i=end-1;i>=offset;i-=1){hash=hash*33^labelText.charCodeAt(i);}edgeHash[edge]=hash>>>0;if(edgeLength[edge]===1&&labelText.charCodeAt(offset)===42/* '*' */){wildcardEdge[node]=edge;}offset=end;}}// Result of the last `walk`, kept in module scope to avoid allocating a match
// object. Safe because lookups are synchronous and read right after `walk`.
let matchNode=-1;let matchStart=0;let matchEnd=0;/**
 * True if edge `edge`'s label equals `hostname[start, start + length)`.
 */function labelEquals(edge,hostname,start,length){if(edgeLength[edge]!==length){return false;}const offset=edgeOffset[edge];for(let i=0;i<length;i+=1){if(labelText.charCodeAt(offset+i)!==hostname.charCodeAt(start+i)){return false;}}return true;}/**
 * Find the child edge of `node` whose label is `hostname[start, start + length)`.
 * Edges are sorted by hash, so binary-search the hash then verify the label
 * (scanning the rare run of equal hashes). Returns the edge index or -1.
 */function findEdge(node,hash,hostname,start,length){let lo=edgeStart[node];let hi=edgeStart[node+1];while(lo<hi){const mid=lo+hi>>>1;const value=edgeHash[mid];if(value<hash){lo=mid+1;}else if(value>hash){hi=mid;}else{for(let e=mid;e>=lo&&edgeHash[e]===hash;e-=1){if(labelEquals(e,hostname,start,length))return e;}for(let e=mid+1;e<hi&&edgeHash[e]===hash;e+=1){if(labelEquals(e,hostname,start,length))return e;}return-1;}}return-1;}/**
 * Walk `hostname`'s labels right-to-left from `root`, recording the deepest
 * node whose flag passes `allowedMask` (with the label boundaries of that match
 * in `matchStart`/`matchEnd`). Returns whether any match was found.
 */function walk(hostname,root,allowedMask){let node=root;let end=hostname.length;let hash=5381;matchNode=-1;for(let i=hostname.length-1;i>=0;i-=1){const code=hostname.charCodeAt(i);if(code===46/* '.' */){const start=i+1;let edge=findEdge(node,hash>>>0,hostname,start,end-start);if(edge===-1){edge=wildcardEdge[node];}if(edge===-1){return matchNode!==-1;}node=edgeChild[edge];if((nodeFlags[node]&allowedMask)!==0){matchNode=node;matchStart=start;matchEnd=end;}end=i;hash=5381;}else{hash=hash*33^code;}}// Left-most label: hostname[0, end). Same find/descend/record as the loop —
// duplicated rather than folded into the loop (via `i >= -1`) because that
// extra per-character branch measured slightly slower on the hot path.
let edge=findEdge(node,hash>>>0,hostname,0,end);if(edge===-1){edge=wildcardEdge[node];}if(edge!==-1){node=edgeChild[edge];if((nodeFlags[node]&allowedMask)!==0){matchNode=node;matchStart=0;matchEnd=end;}}return matchNode!==-1;}/**
 * Check if `hostname` has a valid public suffix in the trie.
 */function suffixLookup(hostname,options,out){if(fast_path(hostname,options,out)){return;}const allowedMask=(options.allowPrivateDomains?2/* RULE_TYPE.PRIVATE */:0)|(options.allowIcannDomains?1/* RULE_TYPE.ICANN */:0);// Exceptions have priority and strip their own left-most label (e.g. the
// rule '!www.ck' makes the suffix of 'www.ck' be 'ck').
if(walk(hostname,exceptionsRoot,allowedMask)){out.isIcann=(nodeFlags[matchNode]&1/* RULE_TYPE.ICANN */)!==0;out.isPrivate=(nodeFlags[matchNode]&2/* RULE_TYPE.PRIVATE */)!==0;out.publicSuffix=hostname.slice(matchEnd+1);return;}if(walk(hostname,rulesRoot,allowedMask)){out.isIcann=(nodeFlags[matchNode]&1/* RULE_TYPE.ICANN */)!==0;out.isPrivate=(nodeFlags[matchNode]&2/* RULE_TYPE.PRIVATE */)!==0;out.publicSuffix=hostname.slice(matchStart);return;}// No match: the prevailing '*' rule makes the right-most label the suffix.
out.isIcann=false;out.isPrivate=false;const lastDot=hostname.lastIndexOf('.');out.publicSuffix=lastDot===-1?hostname:hostname.slice(lastDot+1);}
;// ../../node_modules/tldts/dist/es6/index.js
/* unused harmony import specifier */ var es6_resetResult;
/* unused harmony import specifier */ var es6_parseImpl;
/* unused harmony import specifier */ var es6_suffixLookup;
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT=getEmptyResult();function parse(url,options){return parseImpl(url,5/* FLAG.ALL */,suffixLookup,options,getEmptyResult());}function getHostname(url,options){/*@__INLINE__*/resetResult(RESULT);return parseImpl(url,0/* FLAG.HOSTNAME */,suffixLookup,options,RESULT).hostname;}function getPublicSuffix(url,options){/*@__INLINE__*/es6_resetResult(RESULT);return es6_parseImpl(url,2/* FLAG.PUBLIC_SUFFIX */,es6_suffixLookup,options,RESULT).publicSuffix;}function es6_getDomain(url,options){/*@__INLINE__*/es6_resetResult(RESULT);return es6_parseImpl(url,3/* FLAG.DOMAIN */,es6_suffixLookup,options,RESULT).domain;}function getFullDomain(url,options){/*@__INLINE__*/es6_resetResult(RESULT);const result=es6_parseImpl(url,3/* FLAG.DOMAIN */,es6_suffixLookup,options,RESULT);// The hostname *is* the full domain (subdomain + domain) whenever a
// registrable domain exists; gate on `domain` so non-registrable inputs
// (IPs, suffix-less or invalid hostnames) return `null` like `getDomain`.
return result.domain===null?null:result.hostname;}function es6_getSubdomain(url,options){/*@__INLINE__*/es6_resetResult(RESULT);return es6_parseImpl(url,4/* FLAG.SUB_DOMAIN */,es6_suffixLookup,options,RESULT).subdomain;}function es6_getDomainWithoutSuffix(url,options){/*@__INLINE__*/es6_resetResult(RESULT);return es6_parseImpl(url,5/* FLAG.ALL */,es6_suffixLookup,options,RESULT).domainWithoutSuffix;}
// EXTERNAL MODULE: ../../node_modules/core-js/proposals/array-buffer-base64.js
var array_buffer_base64 = __webpack_require__(14049);
;// ../../libs/common/src/platform/misc/utils.ts
/* provided dependency */ var utils_process = __webpack_require__(45202);
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
/* eslint-disable no-useless-escape */





// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-require-imports
const nodeURL = typeof self === "undefined" ? __webpack_require__(10967) : null;
// Checked against the result of decodeURIComponent(url). Literal entries catch
// single-encoded input (%2e%2e → ".." after decode). Percent-encoded entries catch
// double-encoded input (%252e → "%2e" after one decode, matched literally here).
const pathTraversalPatterns = [
    "..", // Double dot
    "%2e", // Double-encoded single dot (%252e → "%2e")
    "\\", // Backslash
    "%5c", // Double-encoded backslash (%255c → "%5c")
    "\t", // TAB (stripped by WHATWG URL parser)
    "%09", // Double-encoded TAB (%2509 → "%09")
    "\n", // Line feed (stripped by WHATWG URL parser)
    "%0a", // Double-encoded line feed (%250a → "%0a")
    "\r", // Carriage return (stripped by WHATWG URL parser)
    "%0d", // Double-encoded carriage return (%250d → "%0d")
    "\0", // Null byte
    "%00", // Double-encoded null byte (%2500 → "%00")
];
// Query-string-specific patterns, also checked after decodeURIComponent.
const queryDangerousPatterns = [
    "/", // Path separator (Dangerous in a query parameter)
    "%2f", // Double-encoded path separator (%252f → "%2f")
    "#", // Fragment delimiter (Truncates strings)
    "%23", // Double-encoded fragment delimiter (%2523 → "%23")
];
class Utils {
    static init() {
        if (Utils.inited) {
            return;
        }
        Utils.inited = true;
        Utils.isNode =
            typeof utils_process !== "undefined" &&
                utils_process.release != null &&
                utils_process.release.name === "node";
        Utils.isBrowser = typeof window !== "undefined";
        Utils.isMobileBrowser = Utils.isBrowser && this.isMobile(window);
        Utils.isAppleMobileBrowser = Utils.isBrowser && this.isAppleMobile(window);
        if (Utils.isNode) {
            Utils.global = __webpack_require__.g;
        }
        else if (Utils.isBrowser) {
            Utils.global = window;
        }
        else {
            // If it's not browser or node then it must be a service worker
            Utils.global = self;
        }
    }
    static fromB64ToArray(str) {
        if (str == null) {
            return null;
        }
        if (Utils.isNode) {
            return new Uint8Array(Buffer.from(str, "base64"));
        }
        else {
            const binaryString = Utils.global.atob(str);
            const bytes = new Uint8Array(binaryString.length);
            for (let i = 0; i < binaryString.length; i++) {
                bytes[i] = binaryString.charCodeAt(i);
            }
            return bytes;
        }
    }
    static fromUrlB64ToArray(str) {
        return Utils.fromB64ToArray(Utils.fromUrlB64ToB64(str));
    }
    static fromHexToArray(str) {
        if (Utils.isNode) {
            return new Uint8Array(Buffer.from(str, "hex"));
        }
        else {
            const bytes = new Uint8Array(str.length / 2);
            for (let i = 0; i < str.length; i += 2) {
                bytes[i / 2] = parseInt(str.substr(i, 2), 16);
            }
            return bytes;
        }
    }
    static fromUtf8ToArray(str) {
        if (Utils.isNode) {
            return new Uint8Array(Buffer.from(str, "utf8"));
        }
        else {
            const strUtf8 = unescape(encodeURIComponent(str));
            const arr = new Uint8Array(strUtf8.length);
            for (let i = 0; i < strUtf8.length; i++) {
                arr[i] = strUtf8.charCodeAt(i);
            }
            return arr;
        }
    }
    static fromByteStringToArray(str) {
        if (str == null) {
            return null;
        }
        const arr = new Uint8Array(str.length);
        for (let i = 0; i < str.length; i++) {
            arr[i] = str.charCodeAt(i);
        }
        return arr;
    }
    /**
     * Converts a Uint8Array to a hexadecimal string.
     * @param arr - The Uint8Array to convert.
     * @returns The hexadecimal string representation, or null if the input is null.
     */
    static fromArrayToHex(arr) {
        if (arr == null) {
            return null;
        }
        // @ts-expect-error - polyfilled by core-js
        return arr.toHex();
    }
    /**
     * Converts a Uint8Array to a Base64 encoded string.
     * @param arr - The Uint8Array to convert.
     * @returns The Base64 encoded string, or null if the input is null.
     */
    static fromArrayToB64(arr) {
        if (arr == null) {
            return null;
        }
        // @ts-expect-error - polyfilled by core-js
        return arr.toBase64({ alphabet: "base64" });
    }
    static fromArrayToUrlB64(arr) {
        if (arr == null) {
            return null;
        }
        // @ts-expect-error - polyfilled by core-js
        return arr.toBase64({ alphabet: "base64url", omitPadding: true });
    }
    /**
     * Converts a Uint8Array to a byte string (each byte as a character).
     * @param arr - The Uint8Array to convert.
     * @returns The byte string representation, or null if the input is null.
     */
    static fromArrayToByteString(arr) {
        if (arr == null) {
            return null;
        }
        let byteString = "";
        for (let i = 0; i < arr.length; i++) {
            byteString += String.fromCharCode(arr[i]);
        }
        return byteString;
    }
    /**
     * Converts a Uint8Array to a UTF-8 decoded string.
     * @param arr - The Uint8Array containing UTF-8 encoded bytes.
     * @returns The decoded UTF-8 string, or null if the input is null.
     */
    static fromArrayToUtf8(arr) {
        if (arr == null) {
            return null;
        }
        return node_modules_buffer/* Buffer */.hp.from(arr).toString("utf8");
    }
    static fromBufferToB64(buffer) {
        // Handle null / undefined input
        if (buffer == null) {
            return null;
        }
        const bytes = Utils.normalizeToUint8Array(buffer);
        // Handle empty input
        if (bytes.length === 0) {
            return "";
        }
        if (Utils.isNode) {
            return Buffer.from(bytes).toString("base64");
        }
        else {
            let binary = "";
            for (let i = 0; i < bytes.byteLength; i++) {
                binary += String.fromCharCode(bytes[i]);
            }
            return Utils.global.btoa(binary);
        }
    }
    /**
     * Normalizes input into a Uint8Array so we always have a uniform,
     * byte-level view of the data. This avoids dealing with differences
     * between ArrayBuffer (raw memory with no indexing) and other typed
     * views (which may have element sizes, offsets, and lengths).
     * @param buffer ArrayBuffer or ArrayBufferView (e.g. Uint8Array, DataView, etc.)
     */
    static normalizeToUint8Array(buffer) {
        /**
         * 1) Uint8Array: already bytes → use directly.
         * 2) ArrayBuffer: wrap whole buffer.
         * 3) Other ArrayBufferView (e.g., DataView, Int32Array):
         *    wrap the view’s window (byteOffset..byteOffset+byteLength).
         */
        if (buffer instanceof Uint8Array) {
            return buffer;
        }
        else if (buffer instanceof ArrayBuffer) {
            return new Uint8Array(buffer);
        }
        else {
            const view = buffer;
            return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
        }
    }
    static fromBufferToUrlB64(buffer) {
        return Utils.fromB64toUrlB64(Utils.fromBufferToB64(buffer));
    }
    static fromB64toUrlB64(b64Str) {
        return b64Str.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
    }
    static fromBufferToUtf8(buffer) {
        return node_modules_buffer/* Buffer */.hp.from(buffer).toString("utf8");
    }
    static fromBufferToByteString(buffer) {
        return String.fromCharCode.apply(null, new Uint8Array(buffer));
    }
    // ref: https://stackoverflow.com/a/40031979/1090359
    static fromBufferToHex(buffer) {
        if (Utils.isNode) {
            return Buffer.from(buffer).toString("hex");
        }
        else {
            const bytes = new Uint8Array(buffer);
            return Array.prototype.map
                .call(bytes, (x) => ("00" + x.toString(16)).slice(-2))
                .join("");
        }
    }
    /**
     * Converts a hex string to an ArrayBuffer.
     * Note: this doesn't need any Node specific code as parseInt() / ArrayBuffer / Uint8Array
     * work the same in Node and the browser.
     * @param {string} hexString - A string of hexadecimal characters.
     * @returns {ArrayBuffer} The ArrayBuffer representation of the hex string.
     */
    static hexStringToArrayBuffer(hexString) {
        // Check if the hexString has an even length, as each hex digit represents half a byte (4 bits),
        // and it takes two hex digits to represent a full byte (8 bits).
        if (hexString.length % 2 !== 0) {
            throw "HexString has to be an even length";
        }
        // Create an ArrayBuffer with a length that is half the length of the hex string,
        // because each pair of hex digits will become a single byte.
        const arrayBuffer = new ArrayBuffer(hexString.length / 2);
        // Create a Uint8Array view on top of the ArrayBuffer (each position represents a byte)
        // as ArrayBuffers cannot be edited directly.
        const uint8Array = new Uint8Array(arrayBuffer);
        // Loop through the bytes
        for (let i = 0; i < uint8Array.length; i++) {
            // Extract two hex characters (1 byte)
            const hexByte = hexString.substr(i * 2, 2);
            // Convert hexByte into a decimal value from base 16. (ex: ff --> 255)
            const byteValue = parseInt(hexByte, 16);
            // Place the byte value into the uint8Array
            uint8Array[i] = byteValue;
        }
        return arrayBuffer;
    }
    static fromUrlB64ToB64(urlB64Str) {
        let output = urlB64Str.replace(/-/g, "+").replace(/_/g, "/");
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += "==";
                break;
            case 3:
                output += "=";
                break;
            default:
                throw new Error("Illegal base64url string!");
        }
        return output;
    }
    static fromUrlB64ToUtf8(urlB64Str) {
        return Utils.fromB64ToUtf8(Utils.fromUrlB64ToB64(urlB64Str));
    }
    static fromUtf8ToB64(utfStr) {
        if (Utils.isNode) {
            return Buffer.from(utfStr, "utf8").toString("base64");
        }
        else {
            return node_modules_buffer/* Buffer */.hp.from(utfStr, "utf8").toString("base64");
        }
    }
    static fromUtf8ToUrlB64(utfStr) {
        return Utils.fromArrayToUrlB64(Utils.fromUtf8ToArray(utfStr));
    }
    static fromB64ToUtf8(b64Str) {
        if (Utils.isNode) {
            return Buffer.from(b64Str, "base64").toString("utf8");
        }
        else {
            return node_modules_buffer/* Buffer */.hp.from(b64Str, "base64").toString("utf8");
        }
    }
    // ref: http://stackoverflow.com/a/2117523/1090359
    /** @deprecated Use newGuid from @bitwarden/guid instead */
    static newGuid() {
        return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
            const r = (Math.random() * 16) | 0;
            const v = c === "x" ? r : (r & 0x3) | 0x8;
            return v.toString(16);
        });
    }
    /** @deprecated Use isGuid from @bitwarden/guid instead */
    static isGuid(id) {
        return RegExp(Utils.guidRegex, "i").test(id);
    }
    static getHostname(uriString) {
        if (Utils.isNullOrWhitespace(uriString)) {
            return null;
        }
        uriString = uriString.trim();
        if (uriString.startsWith("data:")) {
            return null;
        }
        if (uriString.startsWith("about:")) {
            return null;
        }
        if (uriString.startsWith("file:")) {
            return null;
        }
        try {
            const hostname = getHostname(uriString, { validHosts: this.validHosts });
            if (hostname != null) {
                return hostname;
            }
        }
        catch (_a) {
            return null;
        }
        return null;
    }
    static getHost(uriString) {
        const url = Utils.getUrl(uriString);
        try {
            return url != null && url.host !== "" ? url.host : null;
        }
        catch (_a) {
            return null;
        }
    }
    static getDomain(uriString) {
        if (Utils.isNullOrWhitespace(uriString)) {
            return null;
        }
        uriString = uriString.trim();
        if (uriString.startsWith("data:")) {
            return null;
        }
        if (uriString.startsWith("about:")) {
            return null;
        }
        try {
            const parseResult = parse(uriString, {
                validHosts: this.validHosts,
                allowPrivateDomains: true,
            });
            if (parseResult != null && parseResult.hostname != null) {
                if (parseResult.hostname === "localhost" || parseResult.isIp) {
                    return parseResult.hostname;
                }
                if (parseResult.domain != null) {
                    return parseResult.domain;
                }
                return null;
            }
        }
        catch (_a) {
            return null;
        }
        return null;
    }
    static getQueryParams(uriString) {
        const url = Utils.getUrl(uriString);
        if (url == null || url.search == null || url.search === "") {
            return null;
        }
        const map = new Map();
        const pairs = (url.search[0] === "?" ? url.search.substr(1) : url.search).split("&");
        pairs.forEach((pair) => {
            const parts = pair.split("=");
            if (parts.length < 1) {
                return;
            }
            map.set(decodeURIComponent(parts[0]).toLowerCase(), parts[1] == null ? "" : decodeURIComponent(parts[1]));
        });
        return map;
    }
    static getSortFunction(i18nService, prop) {
        return (a, b) => {
            if (a[prop] == null && b[prop] != null) {
                return -1;
            }
            if (a[prop] != null && b[prop] == null) {
                return 1;
            }
            if (a[prop] == null && b[prop] == null) {
                return 0;
            }
            // The `as unknown as string` here is unfortunate because typescript doesn't property understand that the return of T[prop] will be a string
            return i18nService.collator
                ? i18nService.collator.compare(a[prop], b[prop])
                : a[prop].localeCompare(b[prop]);
        };
    }
    static isNullOrWhitespace(str) {
        return str == null || typeof str !== "string" || str.trim() === "";
    }
    static isNullOrEmpty(str) {
        return str == null || typeof str !== "string" || str == "";
    }
    static isPromise(obj) {
        return (obj != undefined && typeof obj["then"] === "function" && typeof obj["catch"] === "function");
    }
    static nameOf(name) {
        return name;
    }
    static assign(target, source) {
        return Object.assign(target, source);
    }
    static iterateEnum(obj) {
        return Object.keys(obj).filter((k) => Number.isNaN(+k)).map((k) => obj[k]);
    }
    static getUrl(uriString) {
        if (this.isNullOrWhitespace(uriString)) {
            return null;
        }
        uriString = uriString.trim();
        return Utils.getUrlObject(uriString);
    }
    static camelToPascalCase(s) {
        return s.charAt(0).toUpperCase() + s.slice(1);
    }
    /**
     * There are a few ways to calculate text color for contrast, this one seems to fit accessibility guidelines best.
     * https://stackoverflow.com/a/3943023/6869691
     *
     * @param {string} bgColor
     * @param {number} [threshold] see stackoverflow link above
     * @param {boolean} [svgTextFill]
     * Indicates if this method is performed on an SVG <text> 'fill' attribute (e.g. <text fill="black"></text>).
     * This check is necessary because the '!important' tag cannot be used in a 'fill' attribute.
     */
    static pickTextColorBasedOnBgColor(bgColor, threshold = 186, svgTextFill = false) {
        const bgColorHexNums = bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor;
        const r = parseInt(bgColorHexNums.substring(0, 2), 16); // hexToR
        const g = parseInt(bgColorHexNums.substring(2, 4), 16); // hexToG
        const b = parseInt(bgColorHexNums.substring(4, 6), 16); // hexToB
        const blackColor = svgTextFill ? "black" : "black !important";
        const whiteColor = svgTextFill ? "white" : "white !important";
        return r * 0.299 + g * 0.587 + b * 0.114 > threshold ? blackColor : whiteColor;
    }
    static stringToColor(str) {
        let hash = 0;
        for (let i = 0; i < str.length; i++) {
            hash = str.charCodeAt(i) + ((hash << 5) - hash);
        }
        let color = "#";
        for (let i = 0; i < 3; i++) {
            const value = (hash >> (i * 8)) & 0xff;
            color += ("00" + value.toString(16)).substr(-2);
        }
        return color;
    }
    /**
     * @throws Will throw an error if the ContainerService has not been attached to the window object
     */
    static getContainerService() {
        if (this.global.bitwardenContainerService == null) {
            throw new Error("global bitwardenContainerService not initialized.");
        }
        return this.global.bitwardenContainerService;
    }
    static validateHexColor(color) {
        return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
    }
    /**
     * Converts map to a Record<string, V> with the same data. Inverse of recordToMap
     * Useful in toJSON methods, since Maps are not serializable
     * @param map
     * @returns
     */
    static mapToRecord(map) {
        if (map == null) {
            return null;
        }
        if (!(map instanceof Map)) {
            return map;
        }
        return Object.fromEntries(map);
    }
    /**
     * Converts record to a Map<string, V> with the same data. Inverse of mapToRecord
     * Useful in fromJSON methods, since Maps are not serializable
     *
     * Warning: If the record has string keys that are numbers, they will be converted to numbers in the map
     * @param record
     * @returns
     */
    static recordToMap(record) {
        if (record == null) {
            return null;
        }
        else if (record instanceof Map) {
            return record;
        }
        const entries = Object.entries(record);
        if (entries.length === 0) {
            return new Map();
        }
        if (isNaN(Number(entries[0][0]))) {
            return new Map(entries);
        }
        else {
            return new Map(entries.map((e) => [Number(e[0]), e[1]]));
        }
    }
    /** Applies Object.assign, but converts the type nicely using Type-Fest Merge<Destination, Source> */
    static merge(destination, source) {
        return Object.assign(destination, source);
    }
    /**
     * encodeURIComponent escapes all characters except the following:
     * alphabetic, decimal digits, - _ . ! ~ * ' ( )
     * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
     */
    static encodeRFC3986URIComponent(str) {
        return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
    }
    /**
     * Normalizes a path for defense against attacks like traversals
     * @param denormalizedPath
     * @returns
     */
    static normalizePath(denormalizedPath) {
        return path_browserify.normalize(decodeURIComponent(denormalizedPath)).replace(/^(\.\.(\/|\\|$))+/, "");
    }
    /**
     * Checks whether a URL string contains common path traversal indicators.
     *
     * This is a **supplementary heuristic**, not a security boundary.
     *
     * Primary defense against untrusted input in URL paths is
     * validation at the input boundary (component level).
     * Companion sanitizer: {@link normalizePath}.
     *
     * Known limitations:
     * - This is a denylist, NOT a substitute for boundary validation.
     * - WHATWG URL normalization may alter byte sequences beyond the checked set.
     *
     * @param url - The full URL string to inspect (path + optional query string).
     * @returns `true` if traversal indicators are found; `false` otherwise.
     */
    static containsTraversalIndicators(url) {
        let decodedUrl;
        try {
            decodedUrl = decodeURIComponent(url.toLowerCase());
        }
        catch (_a) {
            // Malformed URI sequences (e.g., overlong UTF-8) are treated as suspicious.
            return true;
        }
        if (pathTraversalPatterns.some((p) => decodedUrl.includes(p))) {
            return true;
        }
        if (decodedUrl.includes("?")) {
            return this.containsDangerousQueryPatterns(decodedUrl);
        }
        return false;
    }
    /**
     * Checks whether query parameters contain characters that could indicate
     * path injection within a query string context.
     *
     * Note: When called from {@link containsTraversalIndicators}, the URL has
     * already been decoded via `decodeURIComponent`. The encoded forms (`%2f`,
     * `%23`) in the pattern list are therefore redundant in that context — the
     * literal `/` and `#` entries handle matching. The encoded forms are retained
     * for clarity and in case this method is called on non-decoded input.
     *
     * @param url - A URL string containing a query string (after `?`).
     * @returns `true` if dangerous patterns are found in the query string; `false` otherwise.
     */
    static containsDangerousQueryPatterns(url) {
        const queryString = url.split("?")[1];
        if (!queryString) {
            return false;
        }
        return queryDangerousPatterns.some((p) => queryString.includes(p));
    }
    static isMobile(win) {
        let mobile = false;
        ((a) => {
            if (/(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(a) ||
                /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(a.substr(0, 4))) {
                mobile = true;
            }
        })(win.navigator.userAgent || win.navigator.vendor || win.opera);
        return mobile || win.navigator.userAgent.match(/iPad/i) != null;
    }
    static delay(ms) {
        return new Promise((resolve) => setTimeout(resolve, ms));
    }
    /**
     * Generate an observable from a function that returns a promise.
     * Similar to the rxjs function {@link from} with one big exception:
     * {@link from} will not re-execute the function when observers resubscribe.
     * {@link Util.asyncToObservable} will execute `generator` for every
     * subscribe, making it ideal if the value ever needs to be refreshed.
     * */
    static asyncToObservable(generator) {
        return of(undefined).pipe(switchMap(() => generator()));
    }
    /**
     * Return the number of days remaining before a target date arrives.
     * Returns 0 if the day has already passed.
     */
    static daysRemaining(targetDate) {
        const diffTime = targetDate.getTime() - Date.now();
        const msPerDay = 86400000;
        return Math.max(0, Math.floor(diffTime / msPerDay));
    }
    static isAppleMobile(win) {
        return (win.navigator.userAgent.match(/iPhone/i) != null ||
            win.navigator.userAgent.match(/iPad/i) != null);
    }
    static getUrlObject(uriString) {
        // All the methods below require a protocol to properly parse a URL string
        // Assume http if no other protocol is present
        const hasProtocol = uriString.indexOf("://") > -1;
        if (!hasProtocol && uriString.indexOf(".") > -1) {
            uriString = "http://" + uriString;
        }
        else if (!hasProtocol) {
            return null;
        }
        try {
            if (nodeURL != null) {
                return new nodeURL.URL(uriString);
            }
            return new URL(uriString);
            // FIXME: Remove when updating file. Eslint update
            // eslint-disable-next-line @typescript-eslint/no-unused-vars
        }
        catch (e) {
            // Ignore error
        }
        return null;
    }
}
Utils.inited = false;
Utils.isNode = false;
Utils.isBrowser = true;
Utils.isMobileBrowser = false;
Utils.isAppleMobileBrowser = false;
Utils.global = null;
// Transpiled version of /\p{Emoji_Presentation}/gu using https://mothereff.in/regexpu. Used for compatibility in older browsers.
Utils.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;
Utils.validHosts = ["localhost"];
Utils.originalMinimumPasswordLength = 8;
Utils.minimumPasswordLength = 12;
Utils.maximumPasswordLength = 128;
Utils.DomainMatchBlacklist = new Map([
    ["google.com", new Set(["script.google.com"])],
]);
/** @deprecated Use guidRegex from @bitwarden/guid instead */
Utils.guidRegex = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/;
Utils.init();

;// ../../libs/serialization/src/deserialization-helpers.ts
/**
 *
 * @param elementDeserializer
 * @returns
 */
function array(elementDeserializer) {
    return (array) => {
        if (array == null) {
            return null;
        }
        return array.map((element) => elementDeserializer(element));
    };
}
/**
 *
 * @param valueDeserializer
 */
function record(valueDeserializer) {
    return (jsonValue) => {
        if (jsonValue == null) {
            return null;
        }
        const output = {};
        Object.entries(jsonValue).forEach(([key, value]) => {
            output[key] = valueDeserializer(value);
        });
        return output;
    };
}

;// ../../libs/state/src/core/key-definition.ts

/**
 * KeyDefinitions describe the precise location to store data for a given piece of state.
 * The StateDefinition is used to describe the domain of the state, and the KeyDefinition
 * sub-divides that domain into specific keys.
 */
class KeyDefinition {
    /**
     * Creates a new instance of a KeyDefinition
     * @param stateDefinition The state definition for which this key belongs to.
     * @param key The name of the key, this should be unique per domain.
     * @param options A set of options to customize the behavior of {@link KeyDefinition}. All options are required.
     * @param options.deserializer A function to use to safely convert your type from json to your expected type.
     *   Your data may be serialized/deserialized at any time and this needs callback needs to be able to faithfully re-initialize
     *   from the JSON object representation of your type.
     */
    constructor(stateDefinition, key, options) {
        var _a;
        this.stateDefinition = stateDefinition;
        this.key = key;
        this.options = options;
        if (options.deserializer == null) {
            throw new Error(`'deserializer' is a required property on key ${this.errorKeyName}`);
        }
        if (options.cleanupDelayMs < 0) {
            throw new Error(`'cleanupDelayMs' must be greater than or equal to 0. Value of ${options.cleanupDelayMs} passed to key ${this.errorKeyName} `);
        }
        // Normalize optional debug options
        const { enableUpdateLogging = false, enableRetrievalLogging = false } = (_a = options.debug) !== null && _a !== void 0 ? _a : {};
        this.debug = {
            enableUpdateLogging,
            enableRetrievalLogging,
        };
    }
    /**
     * Gets the deserializer configured for this {@link KeyDefinition}
     */
    get deserializer() {
        return this.options.deserializer;
    }
    /**
     * Gets the number of milliseconds to wait before cleaning up the state after the last subscriber has unsubscribed.
     */
    get cleanupDelayMs() {
        var _a;
        return this.options.cleanupDelayMs < 0 ? 0 : ((_a = this.options.cleanupDelayMs) !== null && _a !== void 0 ? _a : 1000);
    }
    /**
     * Creates a {@link KeyDefinition} for state that is an array.
     * @param stateDefinition The state definition to be added to the KeyDefinition
     * @param key The key to be added to the KeyDefinition
     * @param options The options to customize the final {@link KeyDefinition}.
     * @returns A {@link KeyDefinition} initialized for arrays, the options run
     * the deserializer on the provided options for each element of an array.
     *
     * @example
     * ```typescript
     * const MY_KEY = KeyDefinition.array<MyArrayElement>(MY_STATE, "key", {
     *   deserializer: (myJsonElement) => convertToElement(myJsonElement),
     * });
     * ```
     */
    static array(stateDefinition, key, 
    // We have them provide options for the element of the array, depending on future options we add, this could get a little weird.
    options) {
        return new KeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: array((e) => options.deserializer(e)) }));
    }
    /**
     * Creates a {@link KeyDefinition} for state that is a record.
     * @param stateDefinition The state definition to be added to the KeyDefinition
     * @param key The key to be added to the KeyDefinition
     * @param options The options to customize the final {@link KeyDefinition}.
     * @returns A {@link KeyDefinition} that contains a serializer that will run the provided deserializer for each
     * value in a record and returns every key as a string.
     *
     * @example
     * ```typescript
     * const MY_KEY = KeyDefinition.record<MyRecordValue>(MY_STATE, "key", {
     *   deserializer: (myJsonValue) => convertToValue(myJsonValue),
     * });
     * ```
     */
    static record(stateDefinition, key, 
    // We have them provide options for the value of the record, depending on future options we add, this could get a little weird.
    options) {
        return new KeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: record((v) => options.deserializer(v)) }));
    }
    get fullName() {
        return `${this.stateDefinition.name}_${this.key}`;
    }
    get errorKeyName() {
        return `${this.stateDefinition.name} > ${this.key}`;
    }
}

;// ../../libs/guid/src/index.ts
const guidRegex = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
function newGuid() {
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
        const r = (Math.random() * 16) | 0;
        const v = c === "x" ? r : (r & 0x3) | 0x8;
        return v.toString(16);
    });
}
function isGuid(id) {
    return guidRegex.test(id);
}

;// ../../libs/state/src/core/user-key-definition.ts
var _a;
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


const USER_KEY_DEFINITION_MARKER = Symbol("UserKeyDefinition");
class UserKeyDefinition {
    constructor(stateDefinition, key, options) {
        var _b;
        this.stateDefinition = stateDefinition;
        this.key = key;
        this.options = options;
        this[_a] = true;
        if (options.deserializer == null) {
            throw new Error(`'deserializer' is a required property on key ${this.errorKeyName}`);
        }
        if (options.cleanupDelayMs < 0) {
            throw new Error(`'cleanupDelayMs' must be greater than or equal to 0. Value of ${options.cleanupDelayMs} passed to key ${this.errorKeyName} `);
        }
        // Filter out repeat values
        this.clearOn = Array.from(new Set(options.clearOn));
        // Normalize optional debug options
        const { enableUpdateLogging = false, enableRetrievalLogging = false } = (_b = options.debug) !== null && _b !== void 0 ? _b : {};
        this.debug = {
            enableUpdateLogging,
            enableRetrievalLogging,
        };
    }
    /**
     * Gets the deserializer configured for this {@link KeyDefinition}
     */
    get deserializer() {
        return this.options.deserializer;
    }
    /**
     * Gets the number of milliseconds to wait before cleaning up the state after the last subscriber has unsubscribed.
     */
    get cleanupDelayMs() {
        var _b;
        return this.options.cleanupDelayMs < 0 ? 0 : ((_b = this.options.cleanupDelayMs) !== null && _b !== void 0 ? _b : 1000);
    }
    /**
     * Creates a {@link UserKeyDefinition} for state that is an array.
     * @param stateDefinition The state definition to be added to the UserKeyDefinition
     * @param key The key to be added to the KeyDefinition
     * @param options The options to customize the final {@link UserKeyDefinition}.
     * @returns A {@link UserKeyDefinition} initialized for arrays, the options run
     * the deserializer on the provided options for each element of an array
     * **unless that array is null, in which case it will return an empty list.**
     *
     * @example
     * ```typescript
     * const MY_KEY = UserKeyDefinition.array<MyArrayElement>(MY_STATE, "key", {
     *   deserializer: (myJsonElement) => convertToElement(myJsonElement),
     * });
     * ```
     */
    static array(stateDefinition, key, 
    // We have them provide options for the element of the array, depending on future options we add, this could get a little weird.
    options) {
        return new UserKeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: array((e) => options.deserializer(e)) }));
    }
    /**
     * Creates a {@link UserKeyDefinition} for state that is a record.
     * @param stateDefinition The state definition to be added to the UserKeyDefinition
     * @param key The key to be added to the KeyDefinition
     * @param options The options to customize the final {@link UserKeyDefinition}.
     * @returns A {@link UserKeyDefinition} that contains a serializer that will run the provided deserializer for each
     * value in a record and returns every key as a string **unless that record is null, in which case it will return an record.**
     *
     * @example
     * ```typescript
     * const MY_KEY = UserKeyDefinition.record<MyRecordValue>(MY_STATE, "key", {
     *   deserializer: (myJsonValue) => convertToValue(myJsonValue),
     * });
     * ```
     */
    static record(stateDefinition, key, 
    // We have them provide options for the value of the record, depending on future options we add, this could get a little weird.
    options) {
        return new UserKeyDefinition(stateDefinition, key, Object.assign(Object.assign({}, options), { deserializer: record((v) => options.deserializer(v)) }));
    }
    get fullName() {
        return `${this.stateDefinition.name}_${this.key}`;
    }
    buildKey(userId) {
        if (!isGuid(userId)) {
            throw new Error(`You cannot build a user key without a valid UserId, building for key ${this.fullName}`);
        }
        return `user_${userId}_${this.stateDefinition.name}_${this.key}`;
    }
    get errorKeyName() {
        return `${this.stateDefinition.name} > ${this.key}`;
    }
}
_a = USER_KEY_DEFINITION_MARKER;

;// ../../libs/state/src/core/user-state.ts
const activeMarker = Symbol("active");

;// ../../libs/state/src/core/state-definition.ts
/**
 * Defines the base location and instruction of where this state is expected to be located.
 */
class StateDefinition {
    /**
     * Creates a new instance of {@link StateDefinition}, the creation of which is owned by the platform team.
     * @param name The name of the state, this needs to be unique from all other {@link StateDefinition}'s.
     * @param defaultStorageLocation The location of where this state should be stored.
     */
    constructor(name, defaultStorageLocation, storageLocationOverrides) {
        this.name = name;
        this.defaultStorageLocation = defaultStorageLocation;
        this.storageLocationOverrides = storageLocationOverrides !== null && storageLocationOverrides !== void 0 ? storageLocationOverrides : {};
    }
}

;// ../../libs/state/src/core/state-definitions.ts

/**
 * `StateDefinition`s comes with some rules, to facilitate a quick review from
 * platform of this file, ensure you follow these rules, the ones marked with (tested)
 * have unit tests that you can run locally.
 *
 * 1. (tested) Names should not be null or undefined
 * 2. (tested) Name and storage location should be unique
 * 3. (tested) Name and storage location can't differ from another export by only casing
 * 4. (tested) Name should be longer than 3 characters. It should be descriptive, but brief.
 * 5. (tested) Name should not contain spaces or underscores
 * 6. Name should be human readable
 * 7. Name should be in camelCase format (unit tests ensure the first character is lowercase)
 * 8. Teams should only use state definitions they have created
 * 9. StateDefinitions should only be used for keys relating to the state name they chose
 *
 */
// Admin Console
const ORGANIZATIONS_DISK = new StateDefinition("organizations", "disk");
const POLICIES_DISK = new StateDefinition("policies", "disk");
const PROVIDERS_DISK = new StateDefinition("providers", "disk");
const ORGANIZATION_MANAGEMENT_PREFERENCES_DISK = new StateDefinition("organizationManagementPreferences", "disk", {
    web: "disk-local",
});
const DELETE_MANAGED_USER_WARNING = new StateDefinition("showDeleteManagedUserWarning", "disk", {
    web: "disk-local",
});
const AUTO_CONFIRM = new StateDefinition("autoConfirm", "disk", { web: "disk-local" });
const ORGANIZATION_INVITE_LINK_DISK = new StateDefinition("organizationInviteLink", "disk");
const SCIM_BANNER = new StateDefinition("scimBanner", "disk", {
    web: "disk-local",
});
// Billing
const BILLING_DISK = new StateDefinition("billing", "disk");
const BILLING_DISK_LOCAL = new StateDefinition("billingLocal", "disk", {
    web: "disk-local",
});
const BILLING_MEMORY = new StateDefinition("billing", "memory");
// Auth
const ACCOUNT_DISK = new StateDefinition("account", "disk");
const ACCOUNT_MEMORY = new StateDefinition("account", "memory");
const AUTH_REQUEST_DISK_LOCAL = new StateDefinition("authRequestLocal", "disk", {
    web: "disk-local",
});
const AVATAR_DISK = new StateDefinition("avatar", "disk", { web: "disk-local" });
const DEVICE_TRUST_DISK_LOCAL = new StateDefinition("deviceTrust", "disk", {
    web: "disk-local",
    browser: "disk-backup-local-storage",
});
const LOGIN_EMAIL_DISK = new StateDefinition("loginEmail", "disk", {
    web: "disk-local",
});
const LOGIN_EMAIL_MEMORY = new StateDefinition("loginEmail", "memory");
const LOGIN_STRATEGY_MEMORY = new StateDefinition("loginStrategy", "memory");
const MASTER_PASSWORD_DISK = new StateDefinition("masterPassword", "disk");
const MASTER_PASSWORD_MEMORY = new StateDefinition("masterPassword", "memory");
const MASTER_PASSWORD_UNLOCK_DISK = new StateDefinition("masterPasswordUnlock", "disk");
const ROUTER_DISK = new StateDefinition("router", "disk");
const SSO_DISK = new StateDefinition("ssoLogin", "disk");
const SSO_DISK_LOCAL = new StateDefinition("ssoLoginLocal", "disk", { web: "disk-local" });
const TOKEN_DISK = new StateDefinition("token", "disk");
const TOKEN_DISK_LOCAL = new StateDefinition("tokenDiskLocal", "disk", {
    web: "disk-local",
});
const TOKEN_MEMORY = new StateDefinition("token", "memory");
const SEND_ACCESS_DISK = new StateDefinition("sendAccess", "disk");
const TWO_FACTOR_MEMORY = new StateDefinition("twoFactor", "memory");
const USER_DECRYPTION_OPTIONS_DISK = new StateDefinition("userDecryptionOptions", "disk");
const ORGANIZATION_INVITE_DISK = new StateDefinition("organizationInvite", "disk");
const VAULT_TIMEOUT_SETTINGS_DISK_LOCAL = new StateDefinition("vaultTimeoutSettings", "disk", {
    web: "disk-local",
});
const VAULT_TIMEOUT_SETTINGS_MEMORY = new StateDefinition("vaultTimeoutSettings", "memory");
// Autofill
const BADGE_SETTINGS_DISK = new StateDefinition("badgeSettings", "disk");
const USER_NOTIFICATION_SETTINGS_DISK = new StateDefinition("userNotificationSettings", "disk");
const DOMAIN_SETTINGS_DISK = new StateDefinition("domainSettings", "disk");
const AUTOFILL_SETTINGS_DISK = new StateDefinition("autofillSettings", "disk");
const AUTOFILL_SETTINGS_DISK_LOCAL = new StateDefinition("autofillSettingsLocal", "disk", {
    web: "disk-local",
});
const AUTOTYPE_SETTINGS_DISK = new StateDefinition("autotypeSettings", "disk");
// Components
const NEW_WEB_LAYOUT_BANNER_DISK = new StateDefinition("newWebLayoutBanner", "disk", {
    web: "disk-local",
});
const BIT_SIDE_NAV_DISK = new StateDefinition("bitSideNav", "disk");
// DIRT
const PHISHING_DETECTION_DISK = new StateDefinition("phishingDetection", "disk");
// Platform
const APPLICATION_ID_DISK = new StateDefinition("applicationId", "disk", {
    web: "disk-local",
});
const CLEAR_EVENT_DISK = new StateDefinition("clearEvent", "disk");
const CONFIG_DISK = new StateDefinition("config", "disk", {
    web: "disk-local",
});
const DESKTOP_SETTINGS_DISK = new StateDefinition("desktopSettings", "disk");
const ENVIRONMENT_DISK = new StateDefinition("environment", "disk");
const ENVIRONMENT_MEMORY = new StateDefinition("environment", "memory");
const IPC_MEMORY = new StateDefinition("interProcessCommunication", "memory");
const POPUP_VIEW_MEMORY = new StateDefinition("popupView", "memory", {
    browser: "memory-large-object",
});
const SYNC_DISK = new StateDefinition("sync", "disk", { web: "memory" });
const THEMING_DISK = new StateDefinition("theming", "disk", { web: "disk-local" });
const TRANSLATION_DISK = new StateDefinition("translation", "disk", { web: "disk-local" });
const ANIMATION_DISK = new StateDefinition("animation", "disk");
const TASK_SCHEDULER_DISK = new StateDefinition("taskScheduler", "disk");
const EXTENSION_INITIAL_INSTALL_DISK = new StateDefinition("extensionInitialInstall", "disk");
const WEB_PUSH_SUBSCRIPTION = new StateDefinition("webPushSubscription", "disk", {
    web: "disk-local",
});
const SERVER_COMMUNICATION_CONFIG_DISK = new StateDefinition("serverCommunicationConfig", "disk");
// Design System
const POPUP_STYLE_DISK = new StateDefinition("popupStyle", "disk");
// Secrets Manager
const SM_ONBOARDING_DISK = new StateDefinition("smOnboarding", "disk", {
    web: "disk-local",
});
// Tools
const EXTENSION_DISK = new StateDefinition("extension", "disk");
const GENERATOR_DISK = new StateDefinition("generator", "disk");
const GENERATOR_MEMORY = new StateDefinition("generator", "memory");
const BROWSER_SEND_MEMORY = new StateDefinition("sendBrowser", "memory");
const EVENT_COLLECTION_DISK = new StateDefinition("eventCollection", "disk");
const SEND_DISK = new StateDefinition("encryptedSend", "disk", {
    web: "memory",
});
const SEND_MEMORY = new StateDefinition("decryptedSend", "memory", {
    browser: "memory-large-object",
});
const SEND_ACCESS_AUTH_MEMORY = new StateDefinition("sendAccessAuth", "memory");
// Vault
const COLLECTION_DISK = new StateDefinition("collection", "disk", {
    web: "memory",
});
const COLLECTION_MEMORY = new StateDefinition("decryptedCollections", "memory", {
    browser: "memory-large-object",
});
const FOLDER_DISK = new StateDefinition("folder", "disk", { web: "memory" });
const FOLDER_MEMORY = new StateDefinition("decryptedFolders", "memory", {
    browser: "memory-large-object",
});
const VAULT_FILTER_DISK = new StateDefinition("vaultFilter", "disk", {
    web: "disk-local",
});
const VAULT_ONBOARDING = new StateDefinition("vaultOnboarding", "disk", {
    web: "disk-local",
});
const VAULT_SETTINGS_DISK = new StateDefinition("vaultSettings", "disk", {
    web: "disk-local",
});
const VAULT_BROWSER_MEMORY = new StateDefinition("vaultBrowser", "memory", {
    browser: "memory-large-object",
});
const VAULT_SEARCH_MEMORY = new StateDefinition("vaultSearch", "memory", {
    browser: "memory-large-object",
});
const CIPHERS_DISK = new StateDefinition("ciphers", "disk", { web: "memory" });
const CIPHERS_DISK_LOCAL = new StateDefinition("ciphersLocal", "disk", {
    web: "disk-local",
});
const CIPHERS_MEMORY = new StateDefinition("ciphersMemory", "memory", {
    browser: "memory-large-object",
});
const BANNERS_DISMISSED_DISK = new StateDefinition("bannersDismissed", "disk");
const VAULT_APPEARANCE = new StateDefinition("vaultAppearance", "disk");
const SECURITY_TASKS_DISK = new StateDefinition("securityTasks", "disk");
const AT_RISK_PASSWORDS_PAGE_DISK = new StateDefinition("atRiskPasswordsPage", "disk");
const NOTIFICATION_DISK = new StateDefinition("notifications", "disk");
const NUDGES_DISK = new StateDefinition("nudges", "disk", { web: "disk-local" });
const SETUP_EXTENSION_DISMISSED_DISK = new StateDefinition("setupExtensionDismissed", "disk", {
    web: "disk-local",
});
const VAULT_WELCOME_DIALOG_DISK = new StateDefinition("vaultWelcomeDialog", "disk", {
    web: "disk-local",
});
const VAULT_BROWSER_INTRO_CAROUSEL = new StateDefinition("vaultBrowserIntroCarousel", "disk");
const VAULT_BROWSER_DEFAULT_PASSWORD_MANAGER_PROMPT = new StateDefinition("vaultBrowserDefaultPasswordManagerPrompt", "disk");
const VAULT_AUTOFILL_SIMPLIFIED_ICON = new StateDefinition("vaultAutofillSimplifiedIcon", "disk");
const VAULT_AT_RISK_PASSWORDS_MEMORY = new StateDefinition("vaultAtRiskPasswords", "memory");
const VAULT_ORG_USER_NOTIFICATION_DISK_LOCAL = new StateDefinition("vaultOrgUserNotification", "disk", { web: "disk-local" });
const WELCOME_EXTENSION_DIALOG_DISK = new StateDefinition("vaultWelcomeExtensionDialogDismissed", "disk", {
    web: "disk-local",
});
const ACCESS_INTELLIGENCE_WELCOME_DIALOG_DISK = new StateDefinition("accessIntelligenceWelcomeDialog", "disk", {
    web: "disk-local",
});
// KM
const BIOMETRIC_SETTINGS_DISK = new StateDefinition("biometricSettings", "disk");
const ENCRYPTED_MIGRATION_DISK = new StateDefinition("encryptedMigration", "disk");
const PIN_DISK = new StateDefinition("pinUnlock", "disk");
const PIN_MEMORY = new StateDefinition("pinUnlock", "memory");
const CRYPTO_DISK = new StateDefinition("crypto", "disk");
const CRYPTO_MEMORY = new StateDefinition("crypto", "memory");
const KDF_CONFIG_DISK = new StateDefinition("kdfConfig", "disk");
const KEY_CONNECTOR_DISK = new StateDefinition("keyConnector", "disk");
const SHARED_UNLOCK_SETTINGS_DISK = new StateDefinition("sharedUnlockSettings", "disk");

;// ../../libs/state/src/core/index.ts













;// ../../libs/state/src/state-migrations/migration-builder.ts
var migration_builder_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
class MigrationBuilder {
    /** Create a new MigrationBuilder with an empty buffer of migrations to perform.
     *
     * Add migrations to the buffer with {@link with} and {@link rollback}.
     * @returns A new MigrationBuilder.
     */
    static create() {
        return new MigrationBuilder([]);
    }
    constructor(migrations) {
        this.migrations = migrations;
    }
    /** Add a migrator to the MigrationBuilder. Types are updated such that the chained MigrationBuilder must currently be
     * at state version equal to the from version of the migrator. Return as MigrationBuilder<TTo> where TTo is the to
     * version of the migrator, so that the next migrator can be chained.
     *
     * @param migrate A migrator class or a tuple of a migrator class, the from version, and the to version. A tuple is
     * required to instantiate version numbers unless a default constructor is defined.
     * @returns A new MigrationBuilder with the to version of the migrator as the current version.
     */
    with(...migrate) {
        return this.addMigrator(migrate, "up");
    }
    /** Add a migrator to rollback on the MigrationBuilder's list of migrations. As with {@link with}, types of
     * MigrationBuilder and Migrator must align. However, this time the migration is reversed so TCurrent of the
     * MigrationBuilder must be equal to the to version of the migrator. Return as MigrationBuilder<TFrom> where TFrom
     * is the from version of the migrator, so that the next migrator can be chained.
     *
     * @param migrate A migrator class or a tuple of a migrator class, the from version, and the to version. A tuple is
     * required to instantiate version numbers unless a default constructor is defined.
     * @returns A new MigrationBuilder with the from version of the migrator as the current version.
     */
    rollback(...migrate) {
        if (migrate.length === 3) {
            migrate = [migrate[0], migrate[2], migrate[1]];
        }
        return this.addMigrator(migrate, "down");
    }
    /** Execute the migrations as defined in the MigrationBuilder's migrator buffer */
    migrate(helper) {
        return this.migrations.reduce((promise, migrator) => promise.then(() => migration_builder_awaiter(this, void 0, void 0, function* () {
            yield this.runMigrator(migrator.migrator, helper, migrator.direction);
        })), Promise.resolve());
    }
    addMigrator(migrate, direction = "up") {
        const newMigration = migrate.length === 1
            ? { migrator: new migrate[0](), direction }
            : { migrator: new migrate[0](migrate[1], migrate[2]), direction };
        return new MigrationBuilder([...this.migrations, newMigration]);
    }
    runMigrator(migrator, helper, direction) {
        return migration_builder_awaiter(this, void 0, void 0, function* () {
            const shouldMigrate = yield migrator.shouldMigrate(helper, direction);
            helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) should migrate: ${shouldMigrate} - ${direction}`);
            if (shouldMigrate) {
                const method = direction === "up" ? migrator.migrate : migrator.rollback;
                yield method.bind(migrator)(helper);
                helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) migrated - ${direction}`);
                yield migrator.updateVersion(helper, direction);
                helper.info(`Migrator ${migrator.constructor.name} (to version ${migrator.toVersion}) updated version - ${direction}`);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrator.ts
var migrator_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
const IRREVERSIBLE = new Error("Irreversible migration");
class Migrator {
    constructor(fromVersion, toVersion) {
        this.fromVersion = fromVersion;
        this.toVersion = toVersion;
        if (fromVersion == null || toVersion == null) {
            throw new Error("Invalid migration");
        }
        if (fromVersion > toVersion) {
            throw new Error("Invalid migration");
        }
    }
    shouldMigrate(helper, direction) {
        const startVersion = direction === "up" ? this.fromVersion : this.toVersion;
        return Promise.resolve(helper.currentVersion === startVersion);
    }
    updateVersion(helper, direction) {
        return migrator_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            yield helper.set("stateVersion", endVersion);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/10-move-ever-had-user-key-to-state-providers.ts
/* unused harmony import specifier */ var _10_move_ever_had_user_key_to_state_providers_Migrator;
var _10_move_ever_had_user_key_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_EVER_HAD_USER_KEY = {
    key: "everHadUserKey",
    stateDefinition: {
        name: "crypto",
    },
};
class EverHadUserKeyMigrator extends (/* unused pure expression or super */ null && (_10_move_ever_had_user_key_to_state_providers_Migrator)) {
    migrate(helper) {
        return _10_move_ever_had_user_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _10_move_ever_had_user_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.everHadUserKey;
                    yield helper.setToUser(userId, USER_EVER_HAD_USER_KEY, value !== null && value !== void 0 ? value : false);
                    if (value != null) {
                        delete account.profile.everHadUserKey;
                    }
                    yield helper.set(userId, account);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _10_move_ever_had_user_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _10_move_ever_had_user_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_EVER_HAD_USER_KEY);
                    if (account) {
                        account.profile = Object.assign((_a = account.profile) !== null && _a !== void 0 ? _a : {}, {
                            everHadUserKey: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_EVER_HAD_USER_KEY, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/11-move-org-keys-to-state-providers.ts
/* unused harmony import specifier */ var _11_move_org_keys_to_state_providers_Migrator;
var _11_move_org_keys_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENCRYPTED_ORGANIZATION_KEYS = {
    key: "organizationKeys",
    stateDefinition: {
        name: "crypto",
    },
};
class OrganizationKeyMigrator extends (/* unused pure expression or super */ null && (_11_move_org_keys_to_state_providers_Migrator)) {
    migrate(helper) {
        return _11_move_org_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _11_move_org_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.organizationKeys) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ENCRYPTED_ORGANIZATION_KEYS, value);
                        delete account.keys.organizationKeys;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _11_move_org_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _11_move_org_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ENCRYPTED_ORGANIZATION_KEYS);
                    if (account && value) {
                        account.keys = Object.assign((_a = account.keys) !== null && _a !== void 0 ? _a : {}, {
                            organizationKeys: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ENCRYPTED_ORGANIZATION_KEYS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/12-move-environment-state-to-providers.ts
/* unused harmony import specifier */ var _12_move_environment_state_to_providers_Migrator;
var _12_move_environment_state_to_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const ENVIRONMENT_STATE = { name: "environment" };
const REGION_KEY = { key: "region", stateDefinition: ENVIRONMENT_STATE };
const URLS_KEY = { key: "urls", stateDefinition: ENVIRONMENT_STATE };
class MoveEnvironmentStateToProviders extends (/* unused pure expression or super */ null && (_12_move_environment_state_to_providers_Migrator)) {
    migrate(helper) {
        return _12_move_environment_state_to_providers_awaiter(this, void 0, void 0, function* () {
            const legacyGlobal = yield helper.get("global");
            // Move global data
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.region) != null) {
                yield helper.setToGlobal(REGION_KEY, legacyGlobal.region);
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.environmentUrls) != null) {
                yield helper.setToGlobal(URLS_KEY, legacyGlobal.environmentUrls);
            }
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _12_move_environment_state_to_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c, _d, _e;
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.region) != null) {
                    yield helper.setToUser(userId, REGION_KEY, account.settings.region);
                }
                if (((_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? void 0 : _c.environmentUrls) != null) {
                    yield helper.setToUser(userId, URLS_KEY, account.settings.environmentUrls);
                }
                // Delete old account data
                (_d = account === null || account === void 0 ? void 0 : account.settings) === null || _d === void 0 ? true : delete _d.region;
                (_e = account === null || account === void 0 ? void 0 : account.settings) === null || _e === void 0 ? true : delete _e.environmentUrls;
                yield helper.set(userId, account);
            })));
            // Delete legacy global data
            legacyGlobal === null || legacyGlobal === void 0 ? true : delete legacyGlobal.region;
            legacyGlobal === null || legacyGlobal === void 0 ? true : delete legacyGlobal.environmentUrls;
            yield helper.set("global", legacyGlobal);
        });
    }
    rollback(helper) {
        return _12_move_environment_state_to_providers_awaiter(this, void 0, void 0, function* () {
            let legacyGlobal = yield helper.get("global");
            let updatedLegacyGlobal = false;
            const globalRegion = yield helper.getFromGlobal(REGION_KEY);
            if (globalRegion) {
                if (!legacyGlobal) {
                    legacyGlobal = {};
                }
                updatedLegacyGlobal = true;
                legacyGlobal.region = globalRegion;
                yield helper.setToGlobal(REGION_KEY, null);
            }
            const globalUrls = yield helper.getFromGlobal(URLS_KEY);
            if (globalUrls) {
                if (!legacyGlobal) {
                    legacyGlobal = {};
                }
                updatedLegacyGlobal = true;
                legacyGlobal.environmentUrls = globalUrls;
                yield helper.setToGlobal(URLS_KEY, null);
            }
            if (updatedLegacyGlobal) {
                yield helper.set("global", legacyGlobal);
            }
            function rollbackUser(userId, account) {
                return _12_move_environment_state_to_providers_awaiter(this, void 0, void 0, function* () {
                    let updatedAccount = false;
                    const userRegion = yield helper.getFromUser(userId, REGION_KEY);
                    if (userRegion) {
                        if (!account) {
                            account = {};
                        }
                        if (!account.settings) {
                            account.settings = {};
                        }
                        updatedAccount = true;
                        account.settings.region = userRegion;
                        yield helper.setToUser(userId, REGION_KEY, null);
                    }
                    const userUrls = yield helper.getFromUser(userId, URLS_KEY);
                    if (userUrls) {
                        if (!account) {
                            account = {};
                        }
                        if (!account.settings) {
                            account.settings = {};
                        }
                        updatedAccount = true;
                        account.settings.environmentUrls = userUrls;
                        yield helper.setToUser(userId, URLS_KEY, null);
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/13-move-provider-keys-to-state-providers.ts
/* unused harmony import specifier */ var _13_move_provider_keys_to_state_providers_Migrator;
var _13_move_provider_keys_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENCRYPTED_PROVIDER_KEYS = {
    key: "providerKeys",
    stateDefinition: {
        name: "crypto",
    },
};
class ProviderKeyMigrator extends (/* unused pure expression or super */ null && (_13_move_provider_keys_to_state_providers_Migrator)) {
    migrate(helper) {
        return _13_move_provider_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _13_move_provider_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.providerKeys) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ENCRYPTED_PROVIDER_KEYS, value);
                        delete account.keys.providerKeys;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _13_move_provider_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _13_move_provider_keys_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ENCRYPTED_PROVIDER_KEYS);
                    if (account && value) {
                        account.keys = Object.assign((_a = account.keys) !== null && _a !== void 0 ? _a : {}, {
                            providerKeys: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ENCRYPTED_PROVIDER_KEYS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/14-move-biometric-client-key-half-state-to-providers.ts
/* unused harmony import specifier */ var _14_move_biometric_client_key_half_state_to_providers_Migrator;
var _14_move_biometric_client_key_half_state_to_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// Biometric text, no auto prompt text, fingerprint validated, and prompt cancelled are refreshed on every app start, so we don't need to migrate them
const CLIENT_KEY_HALF = {
    key: "clientKeyHalf",
    stateDefinition: { name: "biometricSettings" },
};
class MoveBiometricClientKeyHalfToStateProviders extends (/* unused pure expression or super */ null && (_14_move_biometric_client_key_half_state_to_providers_Migrator)) {
    migrate(helper) {
        return _14_move_biometric_client_key_half_state_to_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _14_move_biometric_client_key_half_state_to_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c;
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.keys) === null || _b === void 0 ? void 0 : _b.biometricEncryptionClientKeyHalf) != null) {
                    yield helper.setToUser(userId, CLIENT_KEY_HALF, account.keys.biometricEncryptionClientKeyHalf);
                    // Delete old account data
                    (_c = account === null || account === void 0 ? void 0 : account.keys) === null || _c === void 0 ? true : delete _c.biometricEncryptionClientKeyHalf;
                    yield helper.set(userId, account);
                }
            })));
        });
    }
    rollback(helper) {
        return _14_move_biometric_client_key_half_state_to_providers_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _14_move_biometric_client_key_half_state_to_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    let updatedAccount = false;
                    const userKeyHalf = yield helper.getFromUser(userId, CLIENT_KEY_HALF);
                    if (userKeyHalf) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.keys) !== null && _a !== void 0 ? _a : (account.keys = {});
                        updatedAccount = true;
                        account.keys.biometricEncryptionClientKeyHalf = userKeyHalf;
                        yield helper.setToUser(userId, CLIENT_KEY_HALF, null);
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/15-move-folder-state-to-state-provider.ts
/* unused harmony import specifier */ var _15_move_folder_state_to_state_provider_Migrator;
var _15_move_folder_state_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENCRYPTED_FOLDERS = {
    key: "folders",
    stateDefinition: {
        name: "folder",
    },
};
class FolderMigrator extends (/* unused pure expression or super */ null && (_15_move_folder_state_to_state_provider_Migrator)) {
    migrate(helper) {
        return _15_move_folder_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _15_move_folder_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.folders) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ENCRYPTED_FOLDERS, value);
                        delete account.data.folders;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _15_move_folder_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _15_move_folder_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ENCRYPTED_FOLDERS);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            folders: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ENCRYPTED_FOLDERS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/16-move-last-sync-to-state-provider.ts
/* unused harmony import specifier */ var _16_move_last_sync_to_state_provider_Migrator;
var _16_move_last_sync_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const LAST_SYNC_KEY = {
    key: "lastSync",
    stateDefinition: {
        name: "sync",
    },
};
class LastSyncMigrator extends (/* unused pure expression or super */ null && (_16_move_last_sync_to_state_provider_Migrator)) {
    migrate(helper) {
        return _16_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _16_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.lastSync;
                    yield helper.setToUser(userId, LAST_SYNC_KEY, value !== null && value !== void 0 ? value : null);
                    if (value != null) {
                        delete account.profile.lastSync;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _16_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _16_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, LAST_SYNC_KEY);
                    if (account) {
                        account.profile = Object.assign((_a = account.profile) !== null && _a !== void 0 ? _a : {}, {
                            lastSync: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, LAST_SYNC_KEY, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/17-move-enable-passkeys-to-state-providers.ts
/* unused harmony import specifier */ var _17_move_enable_passkeys_to_state_providers_Migrator;
var _17_move_enable_passkeys_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENABLE_PASSKEYS = {
    key: "enablePasskeys",
    stateDefinition: {
        name: "vaultSettings",
    },
};
class EnablePasskeysMigrator extends (/* unused pure expression or super */ null && (_17_move_enable_passkeys_to_state_providers_Migrator)) {
    migrate(helper) {
        return _17_move_enable_passkeys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const global = yield helper.get("global");
            if ((global === null || global === void 0 ? void 0 : global.enablePasskeys) != null) {
                yield helper.setToGlobal(USER_ENABLE_PASSKEYS, global.enablePasskeys);
                global === null || global === void 0 ? true : delete global.enablePasskeys;
                yield helper.set("global", global);
            }
        });
    }
    rollback(helper) {
        return _17_move_enable_passkeys_to_state_providers_awaiter(this, void 0, void 0, function* () {
            let global = yield helper.get("global");
            const globalEnablePasskeys = yield helper.getFromGlobal(USER_ENABLE_PASSKEYS);
            if (globalEnablePasskeys != null) {
                global = Object.assign(global !== null && global !== void 0 ? global : {}, { enablePasskeys: globalEnablePasskeys });
                yield helper.set("global", global);
                yield helper.setToGlobal(USER_ENABLE_PASSKEYS, undefined);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/18-move-autofill-settings-to-state-providers.ts
/* unused harmony import specifier */ var _18_move_autofill_settings_to_state_providers_Migrator;
var _18_move_autofill_settings_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _18_move_autofill_settings_to_state_providers_AutofillOverlayVisibility = {
    Off: 0,
    OnButtonClick: 1,
    OnFieldFocus: 2,
};
const autofillSettingsStateDefinition = {
    stateDefinition: {
        name: "autofillSettings",
    },
};
class AutofillSettingsKeyMigrator extends (/* unused pure expression or super */ null && (_18_move_autofill_settings_to_state_providers_Migrator)) {
    migrate(helper) {
        return _18_move_autofill_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            // global state (e.g. "autoFillOverlayVisibility -> inlineMenuVisibility")
            const globalState = yield helper.get("global");
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.autoFillOverlayVisibility) != null) {
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "autofillSettingsLocal",
                    },
                    key: "inlineMenuVisibility",
                }, globalState.autoFillOverlayVisibility);
                // delete `autoFillOverlayVisibility` from state global
                delete globalState.autoFillOverlayVisibility;
                yield helper.set("global", globalState);
            }
            // account state (e.g. account settings -> state provider framework keys)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            // migrate account state
            function migrateAccount(userId, account) {
                return _18_move_autofill_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    let updateAccount = false;
                    const accountSettings = account === null || account === void 0 ? void 0 : account.settings;
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.autoFillOnPageLoadDefault) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadDefault" }), accountSettings.autoFillOnPageLoadDefault);
                        delete account.settings.autoFillOnPageLoadDefault;
                        updateAccount = true;
                    }
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.enableAutoFillOnPageLoad) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoad" }), accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.enableAutoFillOnPageLoad);
                        delete account.settings.enableAutoFillOnPageLoad;
                        updateAccount = true;
                    }
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.dismissedAutoFillOnPageLoadCallout) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadCalloutIsDismissed" }), accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.dismissedAutoFillOnPageLoadCallout);
                        delete account.settings.dismissedAutoFillOnPageLoadCallout;
                        updateAccount = true;
                    }
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.disableAutoTotpCopy) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autoCopyTotp" }), 
                        // invert the value to match the new naming convention
                        !(accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.disableAutoTotpCopy));
                        delete account.settings.disableAutoTotpCopy;
                        updateAccount = true;
                    }
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.activateAutoFillOnPageLoadFromPolicy) != null) {
                        yield helper.setToUser(userId, {
                            stateDefinition: {
                                name: "autofillSettingsLocal",
                            },
                            key: "activateAutofillOnPageLoadFromPolicy",
                        }, accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.activateAutoFillOnPageLoadFromPolicy);
                        delete account.settings.activateAutoFillOnPageLoadFromPolicy;
                        updateAccount = true;
                    }
                    if (updateAccount) {
                        // update the state account settings with the migrated values deleted
                        yield helper.set(userId, account);
                    }
                });
            }
        });
    }
    rollback(helper) {
        return _18_move_autofill_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            // global state (e.g. "inlineMenuVisibility -> autoFillOverlayVisibility")
            const globalState = (yield helper.get("global")) || {};
            const inlineMenuVisibility = yield helper.getFromGlobal({
                stateDefinition: {
                    name: "autofillSettingsLocal",
                },
                key: "inlineMenuVisibility",
            });
            if (inlineMenuVisibility) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { autoFillOverlayVisibility: inlineMenuVisibility }));
                // remove the global state provider framework key for `inlineMenuVisibility`
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "autofillSettingsLocal",
                    },
                    key: "inlineMenuVisibility",
                }, null);
            }
            // account state (e.g. state provider framework keys -> account settings)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            // rollback account state
            function rollbackAccount(userId, account) {
                return _18_move_autofill_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    let updateAccount = false;
                    let settings = (account === null || account === void 0 ? void 0 : account.settings) || {};
                    const autoFillOnPageLoadDefault = yield helper.getFromUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadDefault" }));
                    const enableAutoFillOnPageLoad = yield helper.getFromUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoad" }));
                    const dismissedAutoFillOnPageLoadCallout = yield helper.getFromUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadCalloutIsDismissed" }));
                    const autoCopyTotp = yield helper.getFromUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autoCopyTotp" }));
                    const activateAutoFillOnPageLoadFromPolicy = yield helper.getFromUser(userId, {
                        stateDefinition: {
                            name: "autofillSettingsLocal",
                        },
                        key: "activateAutofillOnPageLoadFromPolicy",
                    });
                    // update new settings and remove the account state provider framework keys for the rolled back values
                    if (autoFillOnPageLoadDefault != null) {
                        settings = Object.assign(Object.assign({}, settings), { autoFillOnPageLoadDefault });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadDefault" }), null);
                        updateAccount = true;
                    }
                    if (enableAutoFillOnPageLoad != null) {
                        settings = Object.assign(Object.assign({}, settings), { enableAutoFillOnPageLoad });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoad" }), null);
                        updateAccount = true;
                    }
                    if (dismissedAutoFillOnPageLoadCallout != null) {
                        settings = Object.assign(Object.assign({}, settings), { dismissedAutoFillOnPageLoadCallout });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autofillOnPageLoadCalloutIsDismissed" }), null);
                        updateAccount = true;
                    }
                    if (autoCopyTotp != null) {
                        // invert the value to match the new naming convention
                        settings = Object.assign(Object.assign({}, settings), { disableAutoTotpCopy: !autoCopyTotp });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsStateDefinition), { key: "autoCopyTotp" }), null);
                        updateAccount = true;
                    }
                    if (activateAutoFillOnPageLoadFromPolicy != null) {
                        settings = Object.assign(Object.assign({}, settings), { activateAutoFillOnPageLoadFromPolicy });
                        yield helper.setToUser(userId, {
                            stateDefinition: {
                                name: "autofillSettingsLocal",
                            },
                            key: "activateAutofillOnPageLoadFromPolicy",
                        }, null);
                        updateAccount = true;
                    }
                    if (updateAccount) {
                        // commit updated settings to state
                        yield helper.set(userId, Object.assign(Object.assign({}, account), { settings }));
                    }
                });
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/19-migrate-require-password-on-start.ts
/* unused harmony import specifier */ var _19_migrate_require_password_on_start_Migrator;
var _19_migrate_require_password_on_start_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// Biometric text, no auto prompt text, fingerprint validated, and prompt cancelled are refreshed on every app start, so we don't need to migrate them
const REQUIRE_PASSWORD_ON_START = {
    key: "requirePasswordOnStart",
    stateDefinition: { name: "biometricSettings" },
};
class RequirePasswordOnStartMigrator extends (/* unused pure expression or super */ null && (_19_migrate_require_password_on_start_Migrator)) {
    migrate(helper) {
        return _19_migrate_require_password_on_start_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _19_migrate_require_password_on_start_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b;
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.requirePasswordOnStart) != null) {
                    yield helper.setToUser(userId, REQUIRE_PASSWORD_ON_START, account.settings.requirePasswordOnStart);
                    // Delete old account data
                    delete account.settings.requirePasswordOnStart;
                    yield helper.set(userId, account);
                }
            })));
        });
    }
    rollback(helper) {
        return _19_migrate_require_password_on_start_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _19_migrate_require_password_on_start_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const requirePassword = yield helper.getFromUser(userId, REQUIRE_PASSWORD_ON_START);
                    if (requirePassword) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.settings) !== null && _a !== void 0 ? _a : (account.settings = {});
                        account.settings.requirePasswordOnStart = requirePassword;
                        yield helper.setToUser(userId, REQUIRE_PASSWORD_ON_START, null);
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/20-move-private-key-to-state-providers.ts
/* unused harmony import specifier */ var _20_move_private_key_to_state_providers_Migrator;
var _20_move_private_key_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENCRYPTED_PRIVATE_KEY = {
    key: "privateKey",
    stateDefinition: {
        name: "crypto",
    },
};
class PrivateKeyMigrator extends (/* unused pure expression or super */ null && (_20_move_private_key_to_state_providers_Migrator)) {
    migrate(helper) {
        return _20_move_private_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _20_move_private_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.privateKey) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ENCRYPTED_PRIVATE_KEY, value);
                        delete account.keys.privateKey;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _20_move_private_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _20_move_private_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ENCRYPTED_PRIVATE_KEY);
                    if (account && value) {
                        account.keys = Object.assign((_a = account.keys) !== null && _a !== void 0 ? _a : {}, {
                            privateKey: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ENCRYPTED_PRIVATE_KEY, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/21-move-collections-state-to-state-provider.ts
/* unused harmony import specifier */ var _21_move_collections_state_to_state_provider_Migrator;
var _21_move_collections_state_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_ENCRYPTED_COLLECTIONS = {
    key: "collections",
    stateDefinition: {
        name: "collection",
    },
};
class CollectionMigrator extends (/* unused pure expression or super */ null && (_21_move_collections_state_to_state_provider_Migrator)) {
    migrate(helper) {
        return _21_move_collections_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _21_move_collections_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.collections) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ENCRYPTED_COLLECTIONS, value);
                        delete account.data.collections;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _21_move_collections_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _21_move_collections_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ENCRYPTED_COLLECTIONS);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            collections: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ENCRYPTED_COLLECTIONS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/22-move-collapsed-groupings-to-state-provider.ts
/* unused harmony import specifier */ var _22_move_collapsed_groupings_to_state_provider_Migrator;
var _22_move_collapsed_groupings_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const COLLAPSED_GROUPINGS = {
    key: "collapsedGroupings",
    stateDefinition: {
        name: "vaultFilter",
    },
};
class CollapsedGroupingsMigrator extends (/* unused pure expression or super */ null && (_22_move_collapsed_groupings_to_state_provider_Migrator)) {
    migrate(helper) {
        return _22_move_collapsed_groupings_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _22_move_collapsed_groupings_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.collapsedGroupings;
                    if (value != null) {
                        yield helper.setToUser(userId, COLLAPSED_GROUPINGS, value);
                        delete account.settings.collapsedGroupings;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _22_move_collapsed_groupings_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _22_move_collapsed_groupings_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, COLLAPSED_GROUPINGS);
                    if (account) {
                        account.settings = Object.assign((_a = account.settings) !== null && _a !== void 0 ? _a : {}, {
                            collapsedGroupings: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, COLLAPSED_GROUPINGS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/23-move-biometric-prompts-to-state-providers.ts
/* unused harmony import specifier */ var _23_move_biometric_prompts_to_state_providers_Migrator;
var _23_move_biometric_prompts_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// prompt cancelled is refreshed on every app start/quit/unlock, so we don't need to migrate it
const DISMISSED_BIOMETRIC_REQUIRE_PASSWORD_ON_START_CALLOUT = {
    key: "dismissedBiometricRequirePasswordOnStartCallout",
    stateDefinition: { name: "biometricSettings" },
};
const PROMPT_AUTOMATICALLY = {
    key: "promptAutomatically",
    stateDefinition: { name: "biometricSettings" },
};
class MoveBiometricPromptsToStateProviders extends (/* unused pure expression or super */ null && (_23_move_biometric_prompts_to_state_providers_Migrator)) {
    migrate(helper) {
        return _23_move_biometric_prompts_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _23_move_biometric_prompts_to_state_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c, _d, _e;
                if (account == null) {
                    return;
                }
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.dismissedBiometricRequirePasswordOnStartCallout) != null) {
                    yield helper.setToUser(userId, DISMISSED_BIOMETRIC_REQUIRE_PASSWORD_ON_START_CALLOUT, account.settings.dismissedBiometricRequirePasswordOnStartCallout);
                }
                if (((_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? void 0 : _c.disableAutoBiometricsPrompt) != null) {
                    yield helper.setToUser(userId, PROMPT_AUTOMATICALLY, !account.settings.disableAutoBiometricsPrompt);
                }
                // Delete old account data
                (_d = account === null || account === void 0 ? void 0 : account.settings) === null || _d === void 0 ? true : delete _d.dismissedBiometricRequirePasswordOnStartCallout;
                (_e = account === null || account === void 0 ? void 0 : account.settings) === null || _e === void 0 ? true : delete _e.disableAutoBiometricsPrompt;
                yield helper.set(userId, account);
            })));
        });
    }
    rollback(helper) {
        return _23_move_biometric_prompts_to_state_providers_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _23_move_biometric_prompts_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    let updatedAccount = false;
                    const userDismissed = yield helper.getFromUser(userId, DISMISSED_BIOMETRIC_REQUIRE_PASSWORD_ON_START_CALLOUT);
                    if (userDismissed) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.settings) !== null && _a !== void 0 ? _a : (account.settings = {});
                        updatedAccount = true;
                        account.settings.dismissedBiometricRequirePasswordOnStartCallout = userDismissed;
                        yield helper.setToUser(userId, DISMISSED_BIOMETRIC_REQUIRE_PASSWORD_ON_START_CALLOUT, null);
                    }
                    const userPromptAutomatically = yield helper.getFromUser(userId, PROMPT_AUTOMATICALLY);
                    if (userPromptAutomatically != null) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_b = account.settings) !== null && _b !== void 0 ? _b : (account.settings = {});
                        updatedAccount = true;
                        account.settings.disableAutoBiometricsPrompt = !userPromptAutomatically;
                        yield helper.setToUser(userId, PROMPT_AUTOMATICALLY, null);
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/24-move-sm-onboarding-key-to-state-providers.ts
/* unused harmony import specifier */ var _24_move_sm_onboarding_key_to_state_providers_Migrator;
var _24_move_sm_onboarding_key_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const SM_ONBOARDING_TASKS = {
    key: "tasks",
    stateDefinition: { name: "smOnboarding" },
};
class SmOnboardingTasksMigrator extends (/* unused pure expression or super */ null && (_24_move_sm_onboarding_key_to_state_providers_Migrator)) {
    migrate(helper) {
        return _24_move_sm_onboarding_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _24_move_sm_onboarding_key_to_state_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b;
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.smOnboardingTasks) != null) {
                    yield helper.setToUser(userId, SM_ONBOARDING_TASKS, account.settings.smOnboardingTasks);
                    // Delete old account data
                    delete account.settings.smOnboardingTasks;
                    yield helper.set(userId, account);
                }
            })));
        });
    }
    rollback(helper) {
        return _24_move_sm_onboarding_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _24_move_sm_onboarding_key_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const smOnboardingTasks = yield helper.getFromUser(userId, SM_ONBOARDING_TASKS);
                    if (smOnboardingTasks) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.settings) !== null && _a !== void 0 ? _a : (account.settings = {});
                        account.settings.smOnboardingTasks = smOnboardingTasks;
                        yield helper.setToUser(userId, SM_ONBOARDING_TASKS, null);
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/25-move-clear-clipboard-to-autofill-settings-state-provider.ts
/* unused harmony import specifier */ var _25_move_clear_clipboard_to_autofill_settings_state_provider_Migrator;
var _25_move_clear_clipboard_to_autofill_settings_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _25_move_clear_clipboard_to_autofill_settings_state_provider_ClearClipboardDelay = {
    Never: null,
    TenSeconds: 10,
    TwentySeconds: 20,
    ThirtySeconds: 30,
    OneMinute: 60,
    TwoMinutes: 120,
    FiveMinutes: 300,
};
const autofillSettingsLocalStateDefinition = {
    stateDefinition: {
        name: "autofillSettingsLocal",
    },
};
class ClearClipboardDelayMigrator extends (/* unused pure expression or super */ null && (_25_move_clear_clipboard_to_autofill_settings_state_provider_Migrator)) {
    migrate(helper) {
        return _25_move_clear_clipboard_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            // account state (e.g. account settings -> state provider framework keys)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            // migrate account state
            function migrateAccount(userId, account) {
                return _25_move_clear_clipboard_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
                    const accountSettings = account === null || account === void 0 ? void 0 : account.settings;
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.clearClipboard) !== undefined) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsLocalStateDefinition), { key: "clearClipboardDelay" }), accountSettings.clearClipboard);
                        delete account.settings.clearClipboard;
                        // update the state account settings with the migrated values deleted
                        yield helper.set(userId, account);
                    }
                });
            }
        });
    }
    rollback(helper) {
        return _25_move_clear_clipboard_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            // account state (e.g. state provider framework keys -> account settings)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            // rollback account state
            function rollbackAccount(userId, account) {
                return _25_move_clear_clipboard_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
                    let settings = (account === null || account === void 0 ? void 0 : account.settings) || {};
                    const clearClipboardDelay = yield helper.getFromUser(userId, Object.assign(Object.assign({}, autofillSettingsLocalStateDefinition), { key: "clearClipboardDelay" }));
                    // update new settings and remove the account state provider framework keys for the rolled back values
                    if (clearClipboardDelay !== undefined) {
                        settings = Object.assign(Object.assign({}, settings), { clearClipboard: clearClipboardDelay });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, autofillSettingsLocalStateDefinition), { key: "clearClipboardDelay" }), null);
                        // commit updated settings to state
                        yield helper.set(userId, Object.assign(Object.assign({}, account), { settings }));
                    }
                });
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/26-revert-move-last-sync-to-state-provider.ts
/* unused harmony import specifier */ var _26_revert_move_last_sync_to_state_provider_Migrator;
var _26_revert_move_last_sync_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _26_revert_move_last_sync_to_state_provider_LAST_SYNC_KEY = {
    key: "lastSync",
    stateDefinition: {
        name: "sync",
    },
};
class RevertLastSyncMigrator extends (/* unused pure expression or super */ null && (_26_revert_move_last_sync_to_state_provider_Migrator)) {
    rollback(helper) {
        return _26_revert_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _26_revert_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.lastSync;
                    yield helper.setToUser(userId, _26_revert_move_last_sync_to_state_provider_LAST_SYNC_KEY, value !== null && value !== void 0 ? value : null);
                    if (value != null) {
                        delete account.profile.lastSync;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
    migrate(helper) {
        return _26_revert_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _26_revert_move_last_sync_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, _26_revert_move_last_sync_to_state_provider_LAST_SYNC_KEY);
                    if (account) {
                        account.profile = Object.assign((_a = account.profile) !== null && _a !== void 0 ? _a : {}, {
                            lastSync: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, _26_revert_move_last_sync_to_state_provider_LAST_SYNC_KEY, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/27-move-badge-settings-to-state-providers.ts
/* unused harmony import specifier */ var _27_move_badge_settings_to_state_providers_Migrator;
var _27_move_badge_settings_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const enableBadgeCounterKeyDefinition = {
    stateDefinition: {
        name: "badgeSettings",
    },
    key: "enableBadgeCounter",
};
class BadgeSettingsMigrator extends (/* unused pure expression or super */ null && (_27_move_badge_settings_to_state_providers_Migrator)) {
    migrate(helper) {
        return _27_move_badge_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            // account state (e.g. account settings -> state provider framework keys)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            // migrate account state
            function migrateAccount(userId, account) {
                return _27_move_badge_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    const accountSettings = account === null || account === void 0 ? void 0 : account.settings;
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.disableBadgeCounter) != undefined) {
                        yield helper.setToUser(userId, enableBadgeCounterKeyDefinition, !accountSettings.disableBadgeCounter);
                        delete account.settings.disableBadgeCounter;
                        // update the state account settings with the migrated values deleted
                        yield helper.set(userId, account);
                    }
                });
            }
        });
    }
    rollback(helper) {
        return _27_move_badge_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            // account state (e.g. state provider framework keys -> account settings)
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            // rollback account state
            function rollbackAccount(userId, account) {
                return _27_move_badge_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    let settings = (account === null || account === void 0 ? void 0 : account.settings) || {};
                    const enableBadgeCounter = yield helper.getFromUser(userId, enableBadgeCounterKeyDefinition);
                    // update new settings and remove the account state provider framework keys for the rolled back values
                    if (enableBadgeCounter != undefined) {
                        settings = Object.assign(Object.assign({}, settings), { disableBadgeCounter: !enableBadgeCounter });
                        yield helper.setToUser(userId, enableBadgeCounterKeyDefinition, null);
                        // commit updated settings to state
                        yield helper.set(userId, Object.assign(Object.assign({}, account), { settings }));
                    }
                });
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/28-move-biometric-unlock-to-state-providers.ts
/* unused harmony import specifier */ var _28_move_biometric_unlock_to_state_providers_Migrator;
var _28_move_biometric_unlock_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const BIOMETRIC_UNLOCK_ENABLED = {
    key: "biometricUnlockEnabled",
    stateDefinition: { name: "biometricSettings" },
};
class MoveBiometricUnlockToStateProviders extends (/* unused pure expression or super */ null && (_28_move_biometric_unlock_to_state_providers_Migrator)) {
    migrate(helper) {
        return _28_move_biometric_unlock_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _28_move_biometric_unlock_to_state_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c;
                if (account == null) {
                    return;
                }
                // Move account data
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.biometricUnlock) != null) {
                    yield helper.setToUser(userId, BIOMETRIC_UNLOCK_ENABLED, account.settings.biometricUnlock);
                }
                // Delete old account data
                (_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? true : delete _c.biometricUnlock;
                yield helper.set(userId, account);
            })));
        });
    }
    rollback(helper) {
        return _28_move_biometric_unlock_to_state_providers_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _28_move_biometric_unlock_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const biometricUnlock = yield helper.getFromUser(userId, BIOMETRIC_UNLOCK_ENABLED);
                    if (biometricUnlock != null) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.settings) !== null && _a !== void 0 ? _a : (account.settings = {});
                        account.settings.biometricUnlock = biometricUnlock;
                        yield helper.setToUser(userId, BIOMETRIC_UNLOCK_ENABLED, null);
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/29-move-user-notification-settings-to-state-provider.ts
/* unused harmony import specifier */ var _29_move_user_notification_settings_to_state_provider_Migrator;
var _29_move_user_notification_settings_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class UserNotificationSettingsKeyMigrator extends (/* unused pure expression or super */ null && (_29_move_user_notification_settings_to_state_provider_Migrator)) {
    migrate(helper) {
        return _29_move_user_notification_settings_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const globalState = yield helper.get("global");
            // disableAddLoginNotification -> enableAddedLoginPrompt
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.disableAddLoginNotification) != null) {
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "userNotificationSettings",
                    },
                    key: "enableAddedLoginPrompt",
                }, !globalState.disableAddLoginNotification);
                // delete `disableAddLoginNotification` from state global
                delete globalState.disableAddLoginNotification;
                yield helper.set("global", globalState);
            }
            // disableChangedPasswordNotification -> enableChangedPasswordPrompt
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.disableChangedPasswordNotification) != null) {
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "userNotificationSettings",
                    },
                    key: "enableChangedPasswordPrompt",
                }, !globalState.disableChangedPasswordNotification);
                // delete `disableChangedPasswordNotification` from state global
                delete globalState.disableChangedPasswordNotification;
                yield helper.set("global", globalState);
            }
        });
    }
    rollback(helper) {
        return _29_move_user_notification_settings_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const globalState = (yield helper.get("global")) || {};
            const enableAddedLoginPrompt = yield helper.getFromGlobal({
                stateDefinition: {
                    name: "userNotificationSettings",
                },
                key: "enableAddedLoginPrompt",
            });
            const enableChangedPasswordPrompt = yield helper.getFromGlobal({
                stateDefinition: {
                    name: "userNotificationSettings",
                },
                key: "enableChangedPasswordPrompt",
            });
            // enableAddedLoginPrompt -> disableAddLoginNotification
            if (enableAddedLoginPrompt) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { disableAddLoginNotification: !enableAddedLoginPrompt }));
                // remove the global state provider framework key for `enableAddedLoginPrompt`
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "userNotificationSettings",
                    },
                    key: "enableAddedLoginPrompt",
                }, null);
            }
            // enableChangedPasswordPrompt -> disableChangedPasswordNotification
            if (enableChangedPasswordPrompt) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { disableChangedPasswordNotification: !enableChangedPasswordPrompt }));
                // remove the global state provider framework key for `enableChangedPasswordPrompt`
                yield helper.setToGlobal({
                    stateDefinition: {
                        name: "userNotificationSettings",
                    },
                    key: "enableChangedPasswordPrompt",
                }, null);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/30-move-policy-state-to-state-provider.ts
/* unused harmony import specifier */ var _30_move_policy_state_to_state_provider_Migrator;
var _30_move_policy_state_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var PolicyType;
(function (PolicyType) {
    PolicyType[PolicyType["TwoFactorAuthentication"] = 0] = "TwoFactorAuthentication";
    PolicyType[PolicyType["MasterPassword"] = 1] = "MasterPassword";
    PolicyType[PolicyType["PasswordGenerator"] = 2] = "PasswordGenerator";
    PolicyType[PolicyType["SingleOrg"] = 3] = "SingleOrg";
    PolicyType[PolicyType["RequireSso"] = 4] = "RequireSso";
    PolicyType[PolicyType["PersonalOwnership"] = 5] = "PersonalOwnership";
    PolicyType[PolicyType["DisableSend"] = 6] = "DisableSend";
    PolicyType[PolicyType["SendOptions"] = 7] = "SendOptions";
    PolicyType[PolicyType["ResetPassword"] = 8] = "ResetPassword";
    PolicyType[PolicyType["MaximumVaultTimeout"] = 9] = "MaximumVaultTimeout";
    PolicyType[PolicyType["DisablePersonalVaultExport"] = 10] = "DisablePersonalVaultExport";
    PolicyType[PolicyType["ActivateAutofill"] = 11] = "ActivateAutofill";
})(PolicyType || (PolicyType = {}));
const POLICIES_KEY = {
    key: "policies",
    stateDefinition: {
        name: "policies",
    },
};
class PolicyMigrator extends (/* unused pure expression or super */ null && (_30_move_policy_state_to_state_provider_Migrator)) {
    migrate(helper) {
        return _30_move_policy_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _30_move_policy_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.policies) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, POLICIES_KEY, value);
                        delete account.data.policies;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => migrateAccount(userId, account)));
        });
    }
    rollback(helper) {
        return _30_move_policy_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _30_move_policy_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, POLICIES_KEY);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            policies: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, POLICIES_KEY, null);
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => rollbackAccount(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/31-move-enable-context-menu-to-autofill-settings-state-provider.ts
/* unused harmony import specifier */ var _31_move_enable_context_menu_to_autofill_settings_state_provider_Migrator;
var _31_move_enable_context_menu_to_autofill_settings_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const enableContextMenuKeyDefinition = {
    stateDefinition: {
        name: "autofillSettings",
    },
    key: "enableContextMenu",
};
class EnableContextMenuMigrator extends (/* unused pure expression or super */ null && (_31_move_enable_context_menu_to_autofill_settings_state_provider_Migrator)) {
    migrate(helper) {
        return _31_move_enable_context_menu_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            const globalState = yield helper.get("global");
            // disableContextMenuItem -> enableContextMenu
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.disableContextMenuItem) != null) {
                yield helper.setToGlobal(enableContextMenuKeyDefinition, !globalState.disableContextMenuItem);
                // delete `disableContextMenuItem` from state global
                delete globalState.disableContextMenuItem;
                yield helper.set("global", globalState);
            }
        });
    }
    rollback(helper) {
        return _31_move_enable_context_menu_to_autofill_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            const globalState = (yield helper.get("global")) || {};
            const enableContextMenu = yield helper.getFromGlobal(enableContextMenuKeyDefinition);
            // enableContextMenu -> disableContextMenuItem
            if (enableContextMenu != null) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { disableContextMenuItem: !enableContextMenu }));
                // remove the global state provider framework key for `enableContextMenu`
                yield helper.setToGlobal(enableContextMenuKeyDefinition, null);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/32-move-preferred-language.ts
/* unused harmony import specifier */ var _32_move_preferred_language_Migrator;
var _32_move_preferred_language_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const LOCALE_KEY = {
    key: "locale",
    stateDefinition: {
        name: "translation",
    },
};
class PreferredLanguageMigrator extends (/* unused pure expression or super */ null && (_32_move_preferred_language_Migrator)) {
    migrate(helper) {
        return _32_move_preferred_language_awaiter(this, void 0, void 0, function* () {
            // global state
            const global = yield helper.get("global");
            if (!(global === null || global === void 0 ? void 0 : global.locale)) {
                return;
            }
            yield helper.setToGlobal(LOCALE_KEY, global.locale);
            delete global.locale;
            yield helper.set("global", global);
        });
    }
    rollback(helper) {
        return _32_move_preferred_language_awaiter(this, void 0, void 0, function* () {
            var _a;
            const locale = yield helper.getFromGlobal(LOCALE_KEY);
            if (!locale) {
                return;
            }
            const global = (_a = (yield helper.get("global"))) !== null && _a !== void 0 ? _a : {};
            global.locale = locale;
            yield helper.set("global", global);
            yield helper.setToGlobal(LOCALE_KEY, null);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/33-move-app-id-to-state-providers.ts
/* unused harmony import specifier */ var _33_move_app_id_to_state_providers_Migrator;
var _33_move_app_id_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const APP_ID_STORAGE_KEY = "appId";
const ANONYMOUS_APP_ID_STORAGE_KEY = "anonymousAppId";
const APP_ID_KEY = {
    key: APP_ID_STORAGE_KEY,
    stateDefinition: { name: "applicationId" },
};
const ANONYMOUS_APP_ID_KEY = {
    key: ANONYMOUS_APP_ID_STORAGE_KEY,
    stateDefinition: { name: "applicationId" },
};
class AppIdMigrator extends (/* unused pure expression or super */ null && (_33_move_app_id_to_state_providers_Migrator)) {
    migrate(helper) {
        return _33_move_app_id_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const appId = yield helper.get(APP_ID_STORAGE_KEY);
            const anonymousAppId = yield helper.get(ANONYMOUS_APP_ID_STORAGE_KEY);
            if (appId != null) {
                yield helper.setToGlobal(APP_ID_KEY, appId);
                yield helper.set(APP_ID_STORAGE_KEY, null);
            }
            if (anonymousAppId != null) {
                yield helper.setToGlobal(ANONYMOUS_APP_ID_KEY, anonymousAppId);
                yield helper.set(ANONYMOUS_APP_ID_STORAGE_KEY, null);
            }
        });
    }
    rollback(helper) {
        return _33_move_app_id_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const appId = yield helper.getFromGlobal(APP_ID_KEY);
            const anonymousAppId = yield helper.getFromGlobal(ANONYMOUS_APP_ID_KEY);
            if (appId != null) {
                yield helper.set(APP_ID_STORAGE_KEY, appId);
                yield helper.setToGlobal(APP_ID_KEY, null);
            }
            if (anonymousAppId != null) {
                yield helper.set(ANONYMOUS_APP_ID_STORAGE_KEY, anonymousAppId);
                yield helper.setToGlobal(ANONYMOUS_APP_ID_KEY, null);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/34-move-domain-settings-to-state-providers.ts
/* unused harmony import specifier */ var _34_move_domain_settings_to_state_providers_Migrator;
var _34_move_domain_settings_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const UriMatchStrategy = {
    Domain: 0,
    Host: 1,
    StartsWith: 2,
    Exact: 3,
    RegularExpression: 4,
    Never: 5,
};
const defaultUriMatchStrategyDefinition = {
    stateDefinition: {
        name: "domainSettings",
    },
    key: "defaultUriMatchStrategy",
};
const equivalentDomainsDefinition = {
    stateDefinition: {
        name: "domainSettings",
    },
    key: "equivalentDomains",
};
const neverDomainsDefinition = {
    stateDefinition: {
        name: "domainSettings",
    },
    key: "neverDomains",
};
class DomainSettingsMigrator extends (/* unused pure expression or super */ null && (_34_move_domain_settings_to_state_providers_Migrator)) {
    migrate(helper) {
        return _34_move_domain_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            let updateAccount = false;
            // global state ("neverDomains")
            const globalState = yield helper.get("global");
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.neverDomains) != null) {
                yield helper.setToGlobal(neverDomainsDefinition, globalState.neverDomains);
                // delete `neverDomains` from state global
                delete globalState.neverDomains;
                yield helper.set("global", globalState);
            }
            // account state ("defaultUriMatch" and "settings.equivalentDomains")
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            // migrate account state
            function migrateAccount(userId, account) {
                return _34_move_domain_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const accountSettings = account === null || account === void 0 ? void 0 : account.settings;
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.defaultUriMatch) != undefined) {
                        yield helper.setToUser(userId, defaultUriMatchStrategyDefinition, accountSettings.defaultUriMatch);
                        delete account.settings.defaultUriMatch;
                        updateAccount = true;
                    }
                    if (((_a = accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.settings) === null || _a === void 0 ? void 0 : _a.equivalentDomains) != undefined) {
                        yield helper.setToUser(userId, equivalentDomainsDefinition, accountSettings.settings.equivalentDomains);
                        delete account.settings.settings.equivalentDomains;
                        delete account.settings.settings;
                        updateAccount = true;
                    }
                    if (updateAccount) {
                        // update the state account settings with the migrated values deleted
                        yield helper.set(userId, account);
                    }
                });
            }
        });
    }
    rollback(helper) {
        return _34_move_domain_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
            let updateAccount = false;
            // global state ("neverDomains")
            const globalState = (yield helper.get("global")) || {};
            const neverDomains = yield helper.getFromGlobal(neverDomainsDefinition);
            if (neverDomains != null) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { neverDomains: neverDomains }));
                // remove the global state provider framework key for `neverDomains`
                yield helper.setToGlobal(neverDomainsDefinition, null);
            }
            // account state ("defaultUriMatchStrategy" and "equivalentDomains")
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            // rollback account state
            function rollbackAccount(userId, account) {
                return _34_move_domain_settings_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    let settings = (account === null || account === void 0 ? void 0 : account.settings) || {};
                    const defaultUriMatchStrategy = yield helper.getFromUser(userId, defaultUriMatchStrategyDefinition);
                    const equivalentDomains = yield helper.getFromUser(userId, equivalentDomainsDefinition);
                    // update new settings and remove the account state provider framework keys for the rolled back values
                    if (defaultUriMatchStrategy != null) {
                        settings = Object.assign(Object.assign({}, settings), { defaultUriMatch: defaultUriMatchStrategy });
                        yield helper.setToUser(userId, defaultUriMatchStrategyDefinition, null);
                        updateAccount = true;
                    }
                    if (equivalentDomains != null) {
                        settings = Object.assign(Object.assign({}, settings), { settings: { equivalentDomains } });
                        yield helper.setToUser(userId, equivalentDomainsDefinition, null);
                        updateAccount = true;
                    }
                    // commit updated settings to state
                    if (updateAccount) {
                        yield helper.set(userId, Object.assign(Object.assign({}, account), { settings }));
                    }
                });
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/35-move-theme-to-state-providers.ts
/* unused harmony import specifier */ var _35_move_theme_to_state_providers_Migrator;
var _35_move_theme_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const THEME_SELECTION = {
    key: "selection",
    stateDefinition: { name: "theming" },
};
class MoveThemeToStateProviderMigrator extends (/* unused pure expression or super */ null && (_35_move_theme_to_state_providers_Migrator)) {
    migrate(helper) {
        return _35_move_theme_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyGlobalState = yield helper.get("global");
            const theme = legacyGlobalState === null || legacyGlobalState === void 0 ? void 0 : legacyGlobalState.theme;
            if (theme != null) {
                yield helper.setToGlobal(THEME_SELECTION, theme);
                delete legacyGlobalState.theme;
                yield helper.set("global", legacyGlobalState);
            }
        });
    }
    rollback(helper) {
        return _35_move_theme_to_state_providers_awaiter(this, void 0, void 0, function* () {
            var _a;
            const theme = yield helper.getFromGlobal(THEME_SELECTION);
            if (theme != null) {
                const legacyGlobal = (_a = (yield helper.get("global"))) !== null && _a !== void 0 ? _a : {};
                legacyGlobal.theme = theme;
                yield helper.set("global", legacyGlobal);
                yield helper.removeFromGlobal(THEME_SELECTION);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/36-move-show-card-and-identity-to-state-provider.ts
/* unused harmony import specifier */ var _36_move_show_card_and_identity_to_state_provider_Migrator;
var _36_move_show_card_and_identity_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const vaultSettingsStateDefinition = {
    stateDefinition: {
        name: "vaultSettings",
    },
};
class VaultSettingsKeyMigrator extends (/* unused pure expression or super */ null && (_36_move_show_card_and_identity_to_state_provider_Migrator)) {
    migrate(helper) {
        return _36_move_show_card_and_identity_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            function migrateAccount(userId, account) {
                return _36_move_show_card_and_identity_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    let updateAccount = false;
                    const accountSettings = account === null || account === void 0 ? void 0 : account.settings;
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.dontShowCardsCurrentTab) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showCardsCurrentTab" }), !accountSettings.dontShowCardsCurrentTab);
                        delete account.settings.dontShowCardsCurrentTab;
                        updateAccount = true;
                    }
                    if ((accountSettings === null || accountSettings === void 0 ? void 0 : accountSettings.dontShowIdentitiesCurrentTab) != null) {
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showIdentitiesCurrentTab" }), !accountSettings.dontShowIdentitiesCurrentTab);
                        delete account.settings.dontShowIdentitiesCurrentTab;
                        updateAccount = true;
                    }
                    if (updateAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
        });
    }
    rollback(helper) {
        return _36_move_show_card_and_identity_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            function rollbackAccount(userId, account) {
                return _36_move_show_card_and_identity_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    let updateAccount = false;
                    let settings = (_a = account === null || account === void 0 ? void 0 : account.settings) !== null && _a !== void 0 ? _a : {};
                    const showCardsCurrentTab = yield helper.getFromUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showCardsCurrentTab" }));
                    const showIdentitiesCurrentTab = yield helper.getFromUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showIdentitiesCurrentTab" }));
                    if (showCardsCurrentTab != null) {
                        // invert the value to match the new naming convention
                        settings = Object.assign(Object.assign({}, settings), { dontShowCardsCurrentTab: !showCardsCurrentTab });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showCardsCurrentTab" }), null);
                        updateAccount = true;
                    }
                    if (showIdentitiesCurrentTab != null) {
                        // invert the value to match the new naming convention
                        settings = Object.assign(Object.assign({}, settings), { dontShowIdentitiesCurrentTab: !showIdentitiesCurrentTab });
                        yield helper.setToUser(userId, Object.assign(Object.assign({}, vaultSettingsStateDefinition), { key: "showIdentitiesCurrentTab" }), null);
                        updateAccount = true;
                    }
                    if (updateAccount) {
                        yield helper.set(userId, Object.assign(Object.assign({}, account), { settings }));
                    }
                });
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/37-move-avatar-color-to-state-providers.ts
/* unused harmony import specifier */ var _37_move_avatar_color_to_state_providers_Migrator;
var _37_move_avatar_color_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const AVATAR_COLOR_STATE = { name: "avatar" };
const AVATAR_COLOR_KEY = {
    key: "avatarColor",
    stateDefinition: AVATAR_COLOR_STATE,
};
class AvatarColorMigrator extends (/* unused pure expression or super */ null && (_37_move_avatar_color_to_state_providers_Migrator)) {
    migrate(helper) {
        return _37_move_avatar_color_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _37_move_avatar_color_to_state_providers_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c;
                // Move account avatarColor
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.avatarColor) != null) {
                    yield helper.setToUser(userId, AVATAR_COLOR_KEY, account.settings.avatarColor);
                    // Delete old account avatarColor property
                    (_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? true : delete _c.avatarColor;
                    yield helper.set(userId, account);
                }
            })));
        });
    }
    rollback(helper) {
        return _37_move_avatar_color_to_state_providers_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _37_move_avatar_color_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    let updatedAccount = false;
                    const userAvatarColor = yield helper.getFromUser(userId, AVATAR_COLOR_KEY);
                    if (userAvatarColor) {
                        if (!account) {
                            account = {};
                        }
                        updatedAccount = true;
                        account.settings.avatarColor = userAvatarColor;
                        yield helper.setToUser(userId, AVATAR_COLOR_KEY, null);
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/38-migrate-token-svc-to-state-provider.ts
/* unused harmony import specifier */ var _38_migrate_token_svc_to_state_provider_Migrator;
var _38_migrate_token_svc_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL = {
    key: "emailTwoFactorTokenRecord",
    stateDefinition: {
        name: "tokenDiskLocal",
    },
};
const TOKEN_STATE_DEF_LIKE = {
    name: "token",
};
const ACCESS_TOKEN_DISK = {
    key: "accessToken", // matches KeyDefinition.key
    stateDefinition: TOKEN_STATE_DEF_LIKE,
};
const REFRESH_TOKEN_DISK = {
    key: "refreshToken",
    stateDefinition: TOKEN_STATE_DEF_LIKE,
};
const API_KEY_CLIENT_ID_DISK = {
    key: "apiKeyClientId",
    stateDefinition: TOKEN_STATE_DEF_LIKE,
};
const API_KEY_CLIENT_SECRET_DISK = {
    key: "apiKeyClientSecret",
    stateDefinition: TOKEN_STATE_DEF_LIKE,
};
class TokenServiceStateProviderMigrator extends (/* unused pure expression or super */ null && (_38_migrate_token_svc_to_state_provider_Migrator)) {
    migrate(helper) {
        return _38_migrate_token_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
            // Move global data
            const globalData = yield helper.get("global");
            // Create new global record for 2FA token that we can accumulate data in
            const emailTwoFactorTokenRecord = {};
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account, globalTwoFactorToken, emailTwoFactorTokenRecord) {
                return _38_migrate_token_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c, _d, _e;
                    let updatedAccount = false;
                    // migrate 2FA token from global to user state
                    // Due to the existing implementation, n users on the same device share the same global state value for 2FA token.
                    // So, we will just migrate it to all users to keep it valid for whichever was the user that set it previously.
                    // Note: don't bother migrating 2FA Token if user account or email is undefined
                    const email = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.email;
                    if (globalTwoFactorToken != undefined && account != undefined && email != undefined) {
                        emailTwoFactorTokenRecord[email] = globalTwoFactorToken;
                        // Note: don't set updatedAccount to true here as we aren't updating
                        // the legacy user state, just migrating a global state to a new user state
                    }
                    // Migrate access token
                    const existingAccessToken = (_b = account === null || account === void 0 ? void 0 : account.tokens) === null || _b === void 0 ? void 0 : _b.accessToken;
                    if (existingAccessToken != null) {
                        // Only migrate data that exists
                        if (helper.type !== "web-disk-local") {
                            // only migrate access token to session storage - never local.
                            yield helper.setToUser(userId, ACCESS_TOKEN_DISK, existingAccessToken);
                        }
                        delete account.tokens.accessToken;
                        updatedAccount = true;
                    }
                    // Migrate refresh token
                    const existingRefreshToken = (_c = account === null || account === void 0 ? void 0 : account.tokens) === null || _c === void 0 ? void 0 : _c.refreshToken;
                    if (existingRefreshToken != null) {
                        if (helper.type !== "web-disk-local") {
                            // only migrate refresh token to session storage - never local.
                            yield helper.setToUser(userId, REFRESH_TOKEN_DISK, existingRefreshToken);
                        }
                        delete account.tokens.refreshToken;
                        updatedAccount = true;
                    }
                    // Migrate API key client id
                    const existingApiKeyClientId = (_d = account === null || account === void 0 ? void 0 : account.profile) === null || _d === void 0 ? void 0 : _d.apiKeyClientId;
                    if (existingApiKeyClientId != null) {
                        if (helper.type !== "web-disk-local") {
                            // only migrate client id to session storage - never local.
                            yield helper.setToUser(userId, API_KEY_CLIENT_ID_DISK, existingApiKeyClientId);
                        }
                        delete account.profile.apiKeyClientId;
                        updatedAccount = true;
                    }
                    // Migrate API key client secret
                    const existingApiKeyClientSecret = (_e = account === null || account === void 0 ? void 0 : account.keys) === null || _e === void 0 ? void 0 : _e.apiKeyClientSecret;
                    if (existingApiKeyClientSecret != null) {
                        if (helper.type !== "web-disk-local") {
                            // only migrate client secret to session storage - never local.
                            yield helper.setToUser(userId, API_KEY_CLIENT_SECRET_DISK, existingApiKeyClientSecret);
                        }
                        delete account.keys.apiKeyClientSecret;
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        // Save the migrated account only if it was updated
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([
                ...accounts.map(({ userId, account }) => migrateAccount(userId, account, globalData === null || globalData === void 0 ? void 0 : globalData.twoFactorToken, emailTwoFactorTokenRecord)),
            ]);
            // Save the global 2FA token record
            yield helper.setToGlobal(EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL, emailTwoFactorTokenRecord);
            // Delete global data
            globalData === null || globalData === void 0 ? true : delete globalData.twoFactorToken;
            yield helper.set("global", globalData);
        });
    }
    rollback(helper) {
        return _38_migrate_token_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
            var _a;
            const accounts = yield helper.getAccounts();
            // Since we migrated the global 2FA token to all users, we need to rollback the 2FA token for all users
            // but we only need to set it to the global state once
            // Go through accounts and find the first user that has a non-null email and 2FA token
            let migratedTwoFactorToken = null;
            for (const { account } of accounts) {
                const email = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.email;
                if (email == null) {
                    continue;
                }
                const emailTwoFactorTokenRecord = yield helper.getFromGlobal(EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL);
                migratedTwoFactorToken = emailTwoFactorTokenRecord[email];
                if (migratedTwoFactorToken != null) {
                    break;
                }
            }
            if (migratedTwoFactorToken != null) {
                let legacyGlobal = yield helper.get("global");
                if (!legacyGlobal) {
                    legacyGlobal = {};
                }
                legacyGlobal.twoFactorToken = migratedTwoFactorToken;
                yield helper.set("global", legacyGlobal);
            }
            // delete global 2FA token record
            yield helper.setToGlobal(EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL, null);
            function rollbackAccount(userId, account) {
                return _38_migrate_token_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    let updatedLegacyAccount = false;
                    // Rollback access token
                    const migratedAccessToken = yield helper.getFromUser(userId, ACCESS_TOKEN_DISK);
                    if ((account === null || account === void 0 ? void 0 : account.tokens) && migratedAccessToken != null) {
                        account.tokens.accessToken = migratedAccessToken;
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, ACCESS_TOKEN_DISK, null);
                    // Rollback refresh token
                    const migratedRefreshToken = yield helper.getFromUser(userId, REFRESH_TOKEN_DISK);
                    if ((account === null || account === void 0 ? void 0 : account.tokens) && migratedRefreshToken != null) {
                        account.tokens.refreshToken = migratedRefreshToken;
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, REFRESH_TOKEN_DISK, null);
                    // Rollback API key client id
                    const migratedApiKeyClientId = yield helper.getFromUser(userId, API_KEY_CLIENT_ID_DISK);
                    if ((account === null || account === void 0 ? void 0 : account.profile) && migratedApiKeyClientId != null) {
                        account.profile.apiKeyClientId = migratedApiKeyClientId;
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, API_KEY_CLIENT_ID_DISK, null);
                    // Rollback API key client secret
                    const migratedApiKeyClientSecret = yield helper.getFromUser(userId, API_KEY_CLIENT_SECRET_DISK);
                    if ((account === null || account === void 0 ? void 0 : account.keys) && migratedApiKeyClientSecret != null) {
                        account.keys.apiKeyClientSecret = migratedApiKeyClientSecret;
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, API_KEY_CLIENT_SECRET_DISK, null);
                    if (updatedLegacyAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/39-move-billing-account-profile-to-state-providers.ts
/* unused harmony import specifier */ var _39_move_billing_account_profile_to_state_providers_Migrator;
var _39_move_billing_account_profile_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const BILLING_ACCOUNT_PROFILE_KEY_DEFINITION = {
    key: "accountProfile",
    stateDefinition: {
        name: "billing",
    },
};
class MoveBillingAccountProfileMigrator extends (/* unused pure expression or super */ null && (_39_move_billing_account_profile_to_state_providers_Migrator)) {
    migrate(helper) {
        return _39_move_billing_account_profile_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            const migrateAccount = (userId, account) => _39_move_billing_account_profile_to_state_providers_awaiter(this, void 0, void 0, function* () {
                var _a, _b, _c, _d;
                const hasPremiumPersonally = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.hasPremiumPersonally;
                const hasPremiumFromOrganization = (_b = account === null || account === void 0 ? void 0 : account.profile) === null || _b === void 0 ? void 0 : _b.hasPremiumFromOrganization;
                if (hasPremiumPersonally != null || hasPremiumFromOrganization != null) {
                    yield helper.setToUser(userId, BILLING_ACCOUNT_PROFILE_KEY_DEFINITION, {
                        hasPremiumPersonally: hasPremiumPersonally,
                        hasPremiumFromOrganization: hasPremiumFromOrganization,
                    });
                    (_c = account === null || account === void 0 ? void 0 : account.profile) === null || _c === void 0 ? true : delete _c.hasPremiumPersonally;
                    (_d = account === null || account === void 0 ? void 0 : account.profile) === null || _d === void 0 ? true : delete _d.hasPremiumFromOrganization;
                    yield helper.set(userId, account);
                }
            });
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _39_move_billing_account_profile_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            const rollbackAccount = (userId, account) => _39_move_billing_account_profile_to_state_providers_awaiter(this, void 0, void 0, function* () {
                var _a;
                const value = yield helper.getFromUser(userId, BILLING_ACCOUNT_PROFILE_KEY_DEFINITION);
                if (account && value) {
                    account.profile = Object.assign((_a = account.profile) !== null && _a !== void 0 ? _a : {}, {
                        hasPremiumPersonally: value === null || value === void 0 ? void 0 : value.hasPremiumPersonally,
                        hasPremiumFromOrganization: value === null || value === void 0 ? void 0 : value.hasPremiumFromOrganization,
                    });
                    yield helper.set(userId, account);
                }
                yield helper.setToUser(userId, BILLING_ACCOUNT_PROFILE_KEY_DEFINITION, null);
            });
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/4-remove-ever-been-unlocked.ts
/* unused harmony import specifier */ var _4_remove_ever_been_unlocked_Migrator;
/* unused harmony import specifier */ var _4_remove_ever_been_unlocked_IRREVERSIBLE;
var _4_remove_ever_been_unlocked_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class RemoveEverBeenUnlockedMigrator extends (/* unused pure expression or super */ null && (_4_remove_ever_been_unlocked_Migrator)) {
    migrate(helper) {
        return _4_remove_ever_been_unlocked_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function removeEverBeenUnlocked(userId, account) {
                return _4_remove_ever_been_unlocked_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    if (((_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.everBeenUnlocked) != null) {
                        delete account.profile.everBeenUnlocked;
                        return helper.set(userId, account);
                    }
                });
            }
            // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            Promise.all(accounts.map(({ userId, account }) => removeEverBeenUnlocked(userId, account)));
        });
    }
    rollback(helper) {
        throw _4_remove_ever_been_unlocked_IRREVERSIBLE;
    }
    // Override is necessary because default implementation assumes `stateVersion` at the root, but for this version
    // it is nested inside a global object.
    updateVersion(helper, direction) {
        return _4_remove_ever_been_unlocked_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            const global = (yield helper.get("global")) || {};
            yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: endVersion }));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/40-move-organization-state-to-state-provider.ts
/* unused harmony import specifier */ var _40_move_organization_state_to_state_provider_Migrator;
var _40_move_organization_state_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// Local declarations of `OrganizationData` and the types of it's properties.
// Duplicated to remain frozen in time when migration occurs.
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var OrganizationUserStatusType;
(function (OrganizationUserStatusType) {
    OrganizationUserStatusType[OrganizationUserStatusType["Invited"] = 0] = "Invited";
    OrganizationUserStatusType[OrganizationUserStatusType["Accepted"] = 1] = "Accepted";
    OrganizationUserStatusType[OrganizationUserStatusType["Confirmed"] = 2] = "Confirmed";
    OrganizationUserStatusType[OrganizationUserStatusType["Revoked"] = -1] = "Revoked";
})(OrganizationUserStatusType || (OrganizationUserStatusType = {}));
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var OrganizationUserType;
(function (OrganizationUserType) {
    OrganizationUserType[OrganizationUserType["Owner"] = 0] = "Owner";
    OrganizationUserType[OrganizationUserType["Admin"] = 1] = "Admin";
    OrganizationUserType[OrganizationUserType["User"] = 2] = "User";
    OrganizationUserType[OrganizationUserType["Manager"] = 3] = "Manager";
    OrganizationUserType[OrganizationUserType["Custom"] = 4] = "Custom";
})(OrganizationUserType || (OrganizationUserType = {}));
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var ProviderType;
(function (ProviderType) {
    ProviderType[ProviderType["Msp"] = 0] = "Msp";
    ProviderType[ProviderType["Reseller"] = 1] = "Reseller";
})(ProviderType || (ProviderType = {}));
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var ProductType;
(function (ProductType) {
    ProductType[ProductType["Free"] = 0] = "Free";
    ProductType[ProductType["Families"] = 1] = "Families";
    ProductType[ProductType["Teams"] = 2] = "Teams";
    ProductType[ProductType["Enterprise"] = 3] = "Enterprise";
    ProductType[ProductType["TeamsStarter"] = 4] = "TeamsStarter";
})(ProductType || (ProductType = {}));
const USER_ORGANIZATIONS = {
    key: "organizations",
    stateDefinition: {
        name: "organizations",
    },
};
class OrganizationMigrator extends (/* unused pure expression or super */ null && (_40_move_organization_state_to_state_provider_Migrator)) {
    migrate(helper) {
        return _40_move_organization_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _40_move_organization_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.organizations;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_ORGANIZATIONS, value);
                        delete account.data.organizations;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => migrateAccount(userId, account)));
        });
    }
    rollback(helper) {
        return _40_move_organization_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _40_move_organization_state_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, USER_ORGANIZATIONS);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            organizations: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_ORGANIZATIONS, null);
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => rollbackAccount(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/41-move-event-collection-to-state-provider.ts
/* unused harmony import specifier */ var _41_move_event_collection_to_state_provider_Migrator;
var _41_move_event_collection_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const EVENT_COLLECTION = {
    stateDefinition: {
        name: "eventCollection",
    },
    key: "eventCollection",
};
class EventCollectionMigrator extends (/* unused pure expression or super */ null && (_41_move_event_collection_to_state_provider_Migrator)) {
    migrate(helper) {
        return _41_move_event_collection_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _41_move_event_collection_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.eventCollection;
                    if (value != null) {
                        yield helper.setToUser(userId, EVENT_COLLECTION, value);
                        delete account.data.eventCollection;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _41_move_event_collection_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _41_move_event_collection_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, EVENT_COLLECTION);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            eventCollection: value,
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, EVENT_COLLECTION, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/42-move-enable-favicon-to-domain-settings-state-provider.ts
/* unused harmony import specifier */ var _42_move_enable_favicon_to_domain_settings_state_provider_Migrator;
var _42_move_enable_favicon_to_domain_settings_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const ShowFaviconDefinition = {
    stateDefinition: {
        name: "domainSettings",
    },
    key: "showFavicons",
};
class EnableFaviconMigrator extends (/* unused pure expression or super */ null && (_42_move_enable_favicon_to_domain_settings_state_provider_Migrator)) {
    migrate(helper) {
        return _42_move_enable_favicon_to_domain_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            // global state ("disableFavicon" -> "showFavicons")
            const globalState = yield helper.get("global");
            if ((globalState === null || globalState === void 0 ? void 0 : globalState.disableFavicon) != null) {
                yield helper.setToGlobal(ShowFaviconDefinition, !globalState.disableFavicon);
                // delete `disableFavicon` from state global
                delete globalState.disableFavicon;
                yield helper.set("global", globalState);
            }
        });
    }
    rollback(helper) {
        return _42_move_enable_favicon_to_domain_settings_state_provider_awaiter(this, void 0, void 0, function* () {
            // global state ("showFavicons" -> "disableFavicon")
            const globalState = (yield helper.get("global")) || {};
            const showFavicons = yield helper.getFromGlobal(ShowFaviconDefinition);
            if (showFavicons != null) {
                yield helper.set("global", Object.assign(Object.assign({}, globalState), { disableFavicon: !showFavicons }));
                // remove the global state provider framework key for `showFavicons`
                yield helper.setToGlobal(ShowFaviconDefinition, null);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/43-move-auto-confirm-finger-prints-to-state-provider.ts
/* unused harmony import specifier */ var _43_move_auto_confirm_finger_prints_to_state_provider_Migrator;
var _43_move_auto_confirm_finger_prints_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const ORGANIZATION_MANAGEMENT_PREFERENCES = {
    name: "organizationManagementPreferences",
};
const AUTO_CONFIRM_FINGERPRINTS = {
    key: "autoConfirmFingerPrints",
    stateDefinition: ORGANIZATION_MANAGEMENT_PREFERENCES,
};
class AutoConfirmFingerPrintsMigrator extends (/* unused pure expression or super */ null && (_43_move_auto_confirm_finger_prints_to_state_provider_Migrator)) {
    migrate(helper) {
        return _43_move_auto_confirm_finger_prints_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            yield Promise.all(legacyAccounts.map((_a) => _43_move_auto_confirm_finger_prints_to_state_provider_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c;
                if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.autoConfirmFingerPrints) != null) {
                    yield helper.setToUser(userId, AUTO_CONFIRM_FINGERPRINTS, account.settings.autoConfirmFingerPrints);
                    (_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? true : delete _c.autoConfirmFingerPrints;
                    yield helper.set(userId, account);
                }
            })));
        });
    }
    rollback(helper) {
        return _43_move_auto_confirm_finger_prints_to_state_provider_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId, account) {
                return _43_move_auto_confirm_finger_prints_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    let updatedAccount = false;
                    const autoConfirmFingerPrints = yield helper.getFromUser(userId, AUTO_CONFIRM_FINGERPRINTS);
                    if (autoConfirmFingerPrints) {
                        if (!account) {
                            account = {};
                        }
                        updatedAccount = true;
                        account.settings.autoConfirmFingerPrints = autoConfirmFingerPrints;
                        yield helper.setToUser(userId, AUTO_CONFIRM_FINGERPRINTS, null);
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackUser(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/44-move-user-decryption-options-to-state-provider.ts
/* unused harmony import specifier */ var _44_move_user_decryption_options_to_state_provider_Migrator;
var _44_move_user_decryption_options_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const USER_DECRYPTION_OPTIONS = {
    key: "decryptionOptions",
    stateDefinition: {
        name: "userDecryptionOptions",
    },
};
class UserDecryptionOptionsMigrator extends (/* unused pure expression or super */ null && (_44_move_user_decryption_options_to_state_provider_Migrator)) {
    migrate(helper) {
        return _44_move_user_decryption_options_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _44_move_user_decryption_options_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    const value = account === null || account === void 0 ? void 0 : account.decryptionOptions;
                    if (value != null) {
                        yield helper.setToUser(userId, USER_DECRYPTION_OPTIONS, value);
                        delete account.decryptionOptions;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _44_move_user_decryption_options_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _44_move_user_decryption_options_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    const value = yield helper.getFromUser(userId, USER_DECRYPTION_OPTIONS);
                    if (account) {
                        account.decryptionOptions = Object.assign(account.decryptionOptions, value);
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, USER_DECRYPTION_OPTIONS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/45-merge-environment-state.ts
/* unused harmony import specifier */ var _45_merge_environment_state_Migrator;
var _45_merge_environment_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _45_merge_environment_state_ENVIRONMENT_STATE = { name: "environment" };
const ENVIRONMENT_REGION = {
    key: "region",
    stateDefinition: _45_merge_environment_state_ENVIRONMENT_STATE,
};
const ENVIRONMENT_URLS = {
    key: "urls",
    stateDefinition: _45_merge_environment_state_ENVIRONMENT_STATE,
};
const ENVIRONMENT_ENVIRONMENT = {
    key: "environment",
    stateDefinition: _45_merge_environment_state_ENVIRONMENT_STATE,
};
class MergeEnvironmentState extends (/* unused pure expression or super */ null && (_45_merge_environment_state_Migrator)) {
    migrate(helper) {
        return _45_merge_environment_state_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _45_merge_environment_state_awaiter(this, void 0, void 0, function* () {
                    const region = yield helper.getFromUser(userId, ENVIRONMENT_REGION);
                    const urls = yield helper.getFromUser(userId, ENVIRONMENT_URLS);
                    if (region == null && urls == null) {
                        return;
                    }
                    yield helper.setToUser(userId, ENVIRONMENT_ENVIRONMENT, {
                        region,
                        urls,
                    });
                    yield helper.removeFromUser(userId, ENVIRONMENT_REGION);
                    yield helper.removeFromUser(userId, ENVIRONMENT_URLS);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            const region = yield helper.getFromGlobal(ENVIRONMENT_REGION);
            const urls = yield helper.getFromGlobal(ENVIRONMENT_URLS);
            if (region == null && urls == null) {
                return;
            }
            yield helper.setToGlobal(ENVIRONMENT_ENVIRONMENT, {
                region,
                urls,
            });
            yield helper.removeFromGlobal(ENVIRONMENT_REGION);
            yield helper.removeFromGlobal(ENVIRONMENT_URLS);
        });
    }
    rollback(helper) {
        return _45_merge_environment_state_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _45_merge_environment_state_awaiter(this, void 0, void 0, function* () {
                    const state = (yield helper.getFromUser(userId, ENVIRONMENT_ENVIRONMENT));
                    yield helper.setToUser(userId, ENVIRONMENT_REGION, state === null || state === void 0 ? void 0 : state.region);
                    yield helper.setToUser(userId, ENVIRONMENT_URLS, state === null || state === void 0 ? void 0 : state.urls);
                    yield helper.removeFromUser(userId, ENVIRONMENT_ENVIRONMENT);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
            const state = (yield helper.getFromGlobal(ENVIRONMENT_ENVIRONMENT));
            yield helper.setToGlobal(ENVIRONMENT_REGION, state === null || state === void 0 ? void 0 : state.region);
            yield helper.setToGlobal(ENVIRONMENT_URLS, state === null || state === void 0 ? void 0 : state.urls);
            yield helper.removeFromGlobal(ENVIRONMENT_ENVIRONMENT);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/46-delete-orphaned-biometric-prompt-data.ts
/* unused harmony import specifier */ var _46_delete_orphaned_biometric_prompt_data_Migrator;
/* unused harmony import specifier */ var _46_delete_orphaned_biometric_prompt_data_IRREVERSIBLE;
var _46_delete_orphaned_biometric_prompt_data_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const PROMPT_CANCELLED = {
    key: "promptCancelled",
    stateDefinition: { name: "biometricSettings" },
};
class DeleteBiometricPromptCancelledData extends (/* unused pure expression or super */ null && (_46_delete_orphaned_biometric_prompt_data_Migrator)) {
    migrate(helper) {
        return _46_delete_orphaned_biometric_prompt_data_awaiter(this, void 0, void 0, function* () {
            yield Promise.all((yield helper.getAccounts()).map((_a) => _46_delete_orphaned_biometric_prompt_data_awaiter(this, [_a], void 0, function* ({ userId }) {
                if (helper.getFromUser(userId, PROMPT_CANCELLED) != null) {
                    yield helper.removeFromUser(userId, PROMPT_CANCELLED);
                }
            })));
        });
    }
    rollback(helper) {
        return _46_delete_orphaned_biometric_prompt_data_awaiter(this, void 0, void 0, function* () {
            throw _46_delete_orphaned_biometric_prompt_data_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/47-move-desktop-settings.ts
/* unused harmony import specifier */ var _47_move_desktop_settings_Migrator;
/* unused harmony import specifier */ var _47_move_desktop_settings_IRREVERSIBLE;
var _47_move_desktop_settings_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const DESKTOP_SETTINGS_STATE = { name: "desktopSettings" };
const WINDOW_KEY = { key: "window", stateDefinition: DESKTOP_SETTINGS_STATE };
const CLOSE_TO_TRAY_KEY = {
    key: "closeToTray",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const MINIMIZE_TO_TRAY_KEY = {
    key: "minimizeToTray",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const START_TO_TRAY_KEY = {
    key: "startToTray",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const TRAY_ENABLED_KEY = {
    key: "trayEnabled",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const OPEN_AT_LOGIN_KEY = {
    key: "openAtLogin",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const ALWAYS_SHOW_DOCK_KEY = {
    key: "alwaysShowDock",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
const ALWAYS_ON_TOP_KEY = {
    key: "alwaysOnTop",
    stateDefinition: DESKTOP_SETTINGS_STATE,
};
class MoveDesktopSettingsMigrator extends (/* unused pure expression or super */ null && (_47_move_desktop_settings_Migrator)) {
    migrate(helper) {
        return _47_move_desktop_settings_awaiter(this, void 0, void 0, function* () {
            const legacyGlobal = yield helper.get("global");
            let updatedGlobal = false;
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.window) !== undefined) {
                yield helper.setToGlobal(WINDOW_KEY, legacyGlobal.window);
                updatedGlobal = true;
                delete legacyGlobal.window;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableCloseToTray) != null) {
                yield helper.setToGlobal(CLOSE_TO_TRAY_KEY, legacyGlobal.enableCloseToTray);
                updatedGlobal = true;
                delete legacyGlobal.enableCloseToTray;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableMinimizeToTray) != null) {
                yield helper.setToGlobal(MINIMIZE_TO_TRAY_KEY, legacyGlobal.enableMinimizeToTray);
                updatedGlobal = true;
                delete legacyGlobal.enableMinimizeToTray;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableStartToTray) != null) {
                yield helper.setToGlobal(START_TO_TRAY_KEY, legacyGlobal.enableStartToTray);
                updatedGlobal = true;
                delete legacyGlobal.enableStartToTray;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableTray) != null) {
                yield helper.setToGlobal(TRAY_ENABLED_KEY, legacyGlobal.enableTray);
                updatedGlobal = true;
                delete legacyGlobal.enableTray;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.openAtLogin) != null) {
                yield helper.setToGlobal(OPEN_AT_LOGIN_KEY, legacyGlobal.openAtLogin);
                updatedGlobal = true;
                delete legacyGlobal.openAtLogin;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.alwaysShowDock) != null) {
                yield helper.setToGlobal(ALWAYS_SHOW_DOCK_KEY, legacyGlobal.alwaysShowDock);
                updatedGlobal = true;
                delete legacyGlobal.alwaysShowDock;
            }
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableAlwaysOnTop) != null) {
                yield helper.setToGlobal(ALWAYS_ON_TOP_KEY, legacyGlobal.enableAlwaysOnTop);
                updatedGlobal = true;
                delete legacyGlobal.enableAlwaysOnTop;
            }
            if (updatedGlobal) {
                yield helper.set("global", legacyGlobal);
            }
            function migrateAccount(userId, account) {
                return _47_move_desktop_settings_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    // We only migrate the global setting for this, if we find it on the account object
                    // just delete it.
                    if (((_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.enableAlwaysOnTop) != null) {
                        delete account.settings.enableAlwaysOnTop;
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => migrateAccount(userId, account)));
        });
    }
    rollback(helper) {
        throw _47_move_desktop_settings_IRREVERSIBLE;
    }
}

;// ../../libs/state/src/state-migrations/migrations/48-move-ddg-to-state-provider.ts
/* unused harmony import specifier */ var _48_move_ddg_to_state_provider_Migrator;
var _48_move_ddg_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const DDG_KEY = {
    key: "enableDuckDuckGoBrowserIntegration",
    stateDefinition: {
        name: "autofillSettings",
    },
};
class MoveDdgToStateProviderMigrator extends (/* unused pure expression or super */ null && (_48_move_ddg_to_state_provider_Migrator)) {
    migrate(helper) {
        return _48_move_ddg_to_state_provider_awaiter(this, void 0, void 0, function* () {
            // global state
            const global = yield helper.get("global");
            if ((global === null || global === void 0 ? void 0 : global.enableDuckDuckGoBrowserIntegration) == null) {
                return;
            }
            yield helper.setToGlobal(DDG_KEY, global.enableDuckDuckGoBrowserIntegration);
            delete global.enableDuckDuckGoBrowserIntegration;
            yield helper.set("global", global);
        });
    }
    rollback(helper) {
        return _48_move_ddg_to_state_provider_awaiter(this, void 0, void 0, function* () {
            var _a;
            const enableDdg = yield helper.getFromGlobal(DDG_KEY);
            if (!enableDdg) {
                return;
            }
            const global = (_a = (yield helper.get("global"))) !== null && _a !== void 0 ? _a : {};
            global.enableDuckDuckGoBrowserIntegration = enableDdg;
            yield helper.set("global", global);
            yield helper.removeFromGlobal(DDG_KEY);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/49-move-account-server-configs.ts
/* unused harmony import specifier */ var _49_move_account_server_configs_Migrator;
var _49_move_account_server_configs_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _49_move_account_server_configs_CONFIG_DISK = { name: "config" };
const USER_SERVER_CONFIG = {
    stateDefinition: _49_move_account_server_configs_CONFIG_DISK,
    key: "serverConfig",
};
class AccountServerConfigMigrator extends (/* unused pure expression or super */ null && (_49_move_account_server_configs_Migrator)) {
    migrate(helper) {
        return _49_move_account_server_configs_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _49_move_account_server_configs_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    if (((_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.serverConfig) != null) {
                        yield helper.setToUser(userId, USER_SERVER_CONFIG, account.settings.serverConfig);
                        delete account.settings.serverConfig;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _49_move_account_server_configs_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _49_move_account_server_configs_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const serverConfig = yield helper.getFromUser(userId, USER_SERVER_CONFIG);
                    if (serverConfig) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.settings) !== null && _a !== void 0 ? _a : (account.settings = {});
                        account.settings.serverConfig = serverConfig;
                        yield helper.setToUser(userId, USER_SERVER_CONFIG, null);
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/5-add-key-type-to-org-keys.ts
/* unused harmony import specifier */ var _5_add_key_type_to_org_keys_Migrator;
var _5_add_key_type_to_org_keys_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class AddKeyTypeToOrgKeysMigrator extends (/* unused pure expression or super */ null && (_5_add_key_type_to_org_keys_Migrator)) {
    migrate(helper) {
        return _5_add_key_type_to_org_keys_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function updateOrgKey(userId, account) {
                return _5_add_key_type_to_org_keys_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const encryptedOrgKeys = (_b = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.organizationKeys) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (encryptedOrgKeys == null) {
                        return;
                    }
                    const newOrgKeys = {};
                    Object.entries(encryptedOrgKeys).forEach(([orgId, encKey]) => {
                        newOrgKeys[orgId] = {
                            type: "organization",
                            key: encKey,
                        };
                    });
                    account.keys.organizationKeys.encrypted = newOrgKeys;
                    yield helper.set(userId, account);
                });
            }
            // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            Promise.all(accounts.map(({ userId, account }) => updateOrgKey(userId, account)));
        });
    }
    rollback(helper) {
        return _5_add_key_type_to_org_keys_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function updateOrgKey(userId, account) {
                return _5_add_key_type_to_org_keys_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const encryptedOrgKeys = (_b = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.organizationKeys) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (encryptedOrgKeys == null) {
                        return;
                    }
                    const newOrgKeys = {};
                    Object.entries(encryptedOrgKeys).forEach(([orgId, encKey]) => {
                        newOrgKeys[orgId] = encKey.key;
                    });
                    account.keys.organizationKeys.encrypted = newOrgKeys;
                    yield helper.set(userId, account);
                });
            }
            // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
            // eslint-disable-next-line @typescript-eslint/no-floating-promises
            Promise.all(accounts.map((_a) => _5_add_key_type_to_org_keys_awaiter(this, [_a], void 0, function* ({ userId, account }) { return updateOrgKey(userId, account); })));
        });
    }
    // Override is necessary because default implementation assumes `stateVersion` at the root, but for this version
    // it is nested inside a global object.
    updateVersion(helper, direction) {
        return _5_add_key_type_to_org_keys_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            const global = (yield helper.get("global")) || {};
            yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: endVersion }));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/50-move-key-connector-to-state-provider.ts
/* unused harmony import specifier */ var _50_move_key_connector_to_state_provider_Migrator;
var _50_move_key_connector_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const usesKeyConnectorKeyDefinition = {
    key: "usesKeyConnector",
    stateDefinition: {
        name: "keyConnector",
    },
};
const convertAccountToKeyConnectorKeyDefinition = {
    key: "convertAccountToKeyConnector",
    stateDefinition: {
        name: "keyConnector",
    },
};
class KeyConnectorMigrator extends (/* unused pure expression or super */ null && (_50_move_key_connector_to_state_provider_Migrator)) {
    migrate(helper) {
        return _50_move_key_connector_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _50_move_key_connector_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const usesKeyConnector = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.usesKeyConnector;
                    const convertAccountToKeyConnector = (_b = account === null || account === void 0 ? void 0 : account.profile) === null || _b === void 0 ? void 0 : _b.convertAccountToKeyConnector;
                    if (usesKeyConnector == null && convertAccountToKeyConnector == null) {
                        return;
                    }
                    if (usesKeyConnector != null) {
                        yield helper.setToUser(userId, usesKeyConnectorKeyDefinition, usesKeyConnector);
                        delete account.profile.usesKeyConnector;
                    }
                    if (convertAccountToKeyConnector != null) {
                        yield helper.setToUser(userId, convertAccountToKeyConnectorKeyDefinition, convertAccountToKeyConnector);
                        delete account.profile.convertAccountToKeyConnector;
                    }
                    yield helper.set(userId, account);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _50_move_key_connector_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _50_move_key_connector_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    const usesKeyConnector = yield helper.getFromUser(userId, usesKeyConnectorKeyDefinition);
                    const convertAccountToKeyConnector = yield helper.getFromUser(userId, convertAccountToKeyConnectorKeyDefinition);
                    if (usesKeyConnector == null && convertAccountToKeyConnector == null) {
                        return;
                    }
                    if (usesKeyConnector != null) {
                        account.profile.usesKeyConnector = usesKeyConnector;
                        yield helper.setToUser(userId, usesKeyConnectorKeyDefinition, null);
                    }
                    if (convertAccountToKeyConnector != null) {
                        account.profile.convertAccountToKeyConnector = convertAccountToKeyConnector;
                        yield helper.setToUser(userId, convertAccountToKeyConnectorKeyDefinition, null);
                    }
                    yield helper.set(userId, account);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/51-move-remembered-email-to-state-providers.ts
/* unused harmony import specifier */ var _51_move_remembered_email_to_state_providers_Migrator;
var _51_move_remembered_email_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const LOGIN_EMAIL_STATE = { name: "loginEmail" };
const STORED_EMAIL = {
    key: "storedEmail",
    stateDefinition: LOGIN_EMAIL_STATE,
};
class RememberedEmailMigrator extends (/* unused pure expression or super */ null && (_51_move_remembered_email_to_state_providers_Migrator)) {
    migrate(helper) {
        return _51_move_remembered_email_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const legacyGlobal = yield helper.get("global");
            // Move global data
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.rememberedEmail) != null) {
                yield helper.setToGlobal(STORED_EMAIL, legacyGlobal.rememberedEmail);
            }
            // Delete legacy global data
            legacyGlobal === null || legacyGlobal === void 0 ? true : delete legacyGlobal.rememberedEmail;
            yield helper.set("global", legacyGlobal);
        });
    }
    rollback(helper) {
        return _51_move_remembered_email_to_state_providers_awaiter(this, void 0, void 0, function* () {
            let legacyGlobal = yield helper.get("global");
            let updatedLegacyGlobal = false;
            const globalStoredEmail = yield helper.getFromGlobal(STORED_EMAIL);
            if (globalStoredEmail) {
                if (!legacyGlobal) {
                    legacyGlobal = {};
                }
                updatedLegacyGlobal = true;
                legacyGlobal.rememberedEmail = globalStoredEmail;
                yield helper.setToGlobal(STORED_EMAIL, null);
            }
            if (updatedLegacyGlobal) {
                yield helper.set("global", legacyGlobal);
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/52-delete-installed-version.ts
/* unused harmony import specifier */ var _52_delete_installed_version_Migrator;
/* unused harmony import specifier */ var _52_delete_installed_version_IRREVERSIBLE;
var _52_delete_installed_version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class DeleteInstalledVersion extends (/* unused pure expression or super */ null && (_52_delete_installed_version_Migrator)) {
    migrate(helper) {
        return _52_delete_installed_version_awaiter(this, void 0, void 0, function* () {
            const legacyGlobal = yield helper.get("global");
            if ((legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.installedVersion) != null) {
                delete legacyGlobal.installedVersion;
                yield helper.set("global", legacyGlobal);
            }
        });
    }
    rollback(helper) {
        throw _52_delete_installed_version_IRREVERSIBLE;
    }
}

;// ../../libs/state/src/state-migrations/migrations/53-migrate-device-trust-svc-to-state-providers.ts
/* unused harmony import specifier */ var _53_migrate_device_trust_svc_to_state_providers_Migrator;
var _53_migrate_device_trust_svc_to_state_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const DEVICE_KEY = {
    key: "deviceKey", // matches KeyDefinition.key in DeviceTrustService
    stateDefinition: {
        name: "deviceTrust", // matches StateDefinition.name in StateDefinitions
    },
};
const SHOULD_TRUST_DEVICE = {
    key: "shouldTrustDevice",
    stateDefinition: {
        name: "deviceTrust",
    },
};
class DeviceTrustServiceStateProviderMigrator extends (/* unused pure expression or super */ null && (_53_migrate_device_trust_svc_to_state_providers_Migrator)) {
    migrate(helper) {
        return _53_migrate_device_trust_svc_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _53_migrate_device_trust_svc_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    let updatedAccount = false;
                    // Migrate deviceKey
                    const existingDeviceKey = (_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.deviceKey;
                    if (existingDeviceKey != null) {
                        // Only migrate data that exists
                        yield helper.setToUser(userId, DEVICE_KEY, existingDeviceKey);
                        delete account.keys.deviceKey;
                        updatedAccount = true;
                    }
                    // Migrate shouldTrustDevice
                    const existingShouldTrustDevice = (_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.trustDeviceChoiceForDecryption;
                    if (existingShouldTrustDevice != null) {
                        yield helper.setToUser(userId, SHOULD_TRUST_DEVICE, existingShouldTrustDevice);
                        delete account.settings.trustDeviceChoiceForDecryption;
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        // Save the migrated account
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _53_migrate_device_trust_svc_to_state_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _53_migrate_device_trust_svc_to_state_providers_awaiter(this, void 0, void 0, function* () {
                    // Rollback deviceKey
                    const migratedDeviceKey = yield helper.getFromUser(userId, DEVICE_KEY);
                    if ((account === null || account === void 0 ? void 0 : account.keys) && migratedDeviceKey != null) {
                        account.keys.deviceKey = migratedDeviceKey;
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, DEVICE_KEY, null);
                    // Rollback shouldTrustDevice
                    const migratedShouldTrustDevice = yield helper.getFromUser(userId, SHOULD_TRUST_DEVICE);
                    if ((account === null || account === void 0 ? void 0 : account.settings) && migratedShouldTrustDevice != null) {
                        account.settings.trustDeviceChoiceForDecryption = migratedShouldTrustDevice;
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, SHOULD_TRUST_DEVICE, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/54-move-encrypted-sends.ts
/* unused harmony import specifier */ var _54_move_encrypted_sends_Migrator;
var _54_move_encrypted_sends_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var SendType;
(function (SendType) {
    SendType[SendType["Text"] = 0] = "Text";
    SendType[SendType["File"] = 1] = "File";
})(SendType || (SendType = {}));
const ENCRYPTED_SENDS = {
    stateDefinition: {
        name: "send",
    },
    key: "sends",
};
/**
 * Only encrypted sends are stored on disk. Only the encrypted items need to be
 * migrated from the previous sends state data.
 */
class SendMigrator extends (/* unused pure expression or super */ null && (_54_move_encrypted_sends_Migrator)) {
    migrate(helper) {
        return _54_move_encrypted_sends_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _54_move_encrypted_sends_awaiter(this, void 0, void 0, function* () {
                    var _a, _b;
                    const value = (_b = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.sends) === null || _b === void 0 ? void 0 : _b.encrypted;
                    if (value != null) {
                        yield helper.setToUser(userId, ENCRYPTED_SENDS, value);
                        delete account.data.sends;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _54_move_encrypted_sends_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _54_move_encrypted_sends_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, ENCRYPTED_SENDS);
                    if (account) {
                        account.data = Object.assign((_a = account.data) !== null && _a !== void 0 ? _a : {}, {
                            sends: {
                                encrypted: value,
                            },
                        });
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, ENCRYPTED_SENDS, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/55-move-master-key-state-to-provider.ts
/* unused harmony import specifier */ var _55_move_master_key_state_to_provider_Migrator;
var _55_move_master_key_state_to_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const FORCE_SET_PASSWORD_REASON_DEFINITION = {
    key: "forceSetPasswordReason",
    stateDefinition: {
        name: "masterPassword",
    },
};
const MASTER_KEY_HASH_DEFINITION = {
    key: "masterKeyHash",
    stateDefinition: {
        name: "masterPassword",
    },
};
const MASTER_KEY_ENCRYPTED_USER_KEY_DEFINITION = {
    key: "masterKeyEncryptedUserKey",
    stateDefinition: {
        name: "masterPassword",
    },
};
class MoveMasterKeyStateToProviderMigrator extends (/* unused pure expression or super */ null && (_55_move_master_key_state_to_provider_Migrator)) {
    migrate(helper) {
        return _55_move_master_key_state_to_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _55_move_master_key_state_to_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c;
                    const forceSetPasswordReason = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.forceSetPasswordReason;
                    if (forceSetPasswordReason != null) {
                        yield helper.setToUser(userId, FORCE_SET_PASSWORD_REASON_DEFINITION, forceSetPasswordReason);
                        delete account.profile.forceSetPasswordReason;
                        yield helper.set(userId, account);
                    }
                    const masterKeyHash = (_b = account === null || account === void 0 ? void 0 : account.profile) === null || _b === void 0 ? void 0 : _b.keyHash;
                    if (masterKeyHash != null) {
                        yield helper.setToUser(userId, MASTER_KEY_HASH_DEFINITION, masterKeyHash);
                        delete account.profile.keyHash;
                        yield helper.set(userId, account);
                    }
                    const masterKeyEncryptedUserKey = (_c = account === null || account === void 0 ? void 0 : account.keys) === null || _c === void 0 ? void 0 : _c.masterKeyEncryptedUserKey;
                    if (masterKeyEncryptedUserKey != null) {
                        yield helper.setToUser(userId, MASTER_KEY_ENCRYPTED_USER_KEY_DEFINITION, masterKeyEncryptedUserKey);
                        delete account.keys.masterKeyEncryptedUserKey;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _55_move_master_key_state_to_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _55_move_master_key_state_to_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c;
                    const forceSetPasswordReason = yield helper.getFromUser(userId, FORCE_SET_PASSWORD_REASON_DEFINITION);
                    const masterKeyHash = yield helper.getFromUser(userId, MASTER_KEY_HASH_DEFINITION);
                    const masterKeyEncryptedUserKey = yield helper.getFromUser(userId, MASTER_KEY_ENCRYPTED_USER_KEY_DEFINITION);
                    if (account != null) {
                        if (forceSetPasswordReason != null) {
                            account.profile = Object.assign((_a = account.profile) !== null && _a !== void 0 ? _a : {}, {
                                forceSetPasswordReason,
                            });
                        }
                        if (masterKeyHash != null) {
                            account.profile = Object.assign((_b = account.profile) !== null && _b !== void 0 ? _b : {}, {
                                keyHash: masterKeyHash,
                            });
                        }
                        if (masterKeyEncryptedUserKey != null) {
                            account.keys = Object.assign((_c = account.keys) !== null && _c !== void 0 ? _c : {}, {
                                masterKeyEncryptedUserKey,
                            });
                        }
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, FORCE_SET_PASSWORD_REASON_DEFINITION, null);
                    yield helper.setToUser(userId, MASTER_KEY_HASH_DEFINITION, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/56-move-auth-requests.ts
/* unused harmony import specifier */ var _56_move_auth_requests_Migrator;
var _56_move_auth_requests_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const ADMIN_AUTH_REQUEST_KEY = {
    stateDefinition: {
        name: "authRequestLocal",
    },
    key: "adminAuthRequest",
};
const ACCEPT_AUTH_REQUESTS_KEY = {
    stateDefinition: {
        name: "authRequestLocal",
    },
    key: "acceptAuthRequests",
};
class AuthRequestMigrator extends (/* unused pure expression or super */ null && (_56_move_auth_requests_Migrator)) {
    migrate(helper) {
        return _56_move_auth_requests_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _56_move_auth_requests_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    let updatedAccount = false;
                    // Migrate admin auth request
                    const existingAdminAuthRequest = account === null || account === void 0 ? void 0 : account.adminAuthRequest;
                    if (existingAdminAuthRequest != null) {
                        yield helper.setToUser(userId, ADMIN_AUTH_REQUEST_KEY, existingAdminAuthRequest);
                        delete account.adminAuthRequest;
                        updatedAccount = true;
                    }
                    // Migrate approve login requests
                    const existingApproveLoginRequests = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.approveLoginRequests;
                    if (existingApproveLoginRequests != null) {
                        yield helper.setToUser(userId, ACCEPT_AUTH_REQUESTS_KEY, existingApproveLoginRequests);
                        delete account.settings.approveLoginRequests;
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        // Save the migrated account
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _56_move_auth_requests_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _56_move_auth_requests_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    let updatedAccount = false;
                    // Rollback admin auth request
                    const migratedAdminAuthRequest = yield helper.getFromUser(userId, ADMIN_AUTH_REQUEST_KEY);
                    if (migratedAdminAuthRequest != null) {
                        account.adminAuthRequest = migratedAdminAuthRequest;
                        updatedAccount = true;
                    }
                    yield helper.setToUser(userId, ADMIN_AUTH_REQUEST_KEY, null);
                    // Rollback approve login requests
                    const migratedAcceptAuthRequest = yield helper.getFromUser(userId, ACCEPT_AUTH_REQUESTS_KEY);
                    if (migratedAcceptAuthRequest != null) {
                        account.settings = Object.assign((_a = account.settings) !== null && _a !== void 0 ? _a : {}, {
                            approveLoginRequests: migratedAcceptAuthRequest,
                        });
                        updatedAccount = true;
                    }
                    yield helper.setToUser(userId, ACCEPT_AUTH_REQUESTS_KEY, null);
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/57-move-cipher-service-to-state-provider.ts
/* unused harmony import specifier */ var _57_move_cipher_service_to_state_provider_Migrator;
var _57_move_cipher_service_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _57_move_cipher_service_to_state_provider_CIPHERS_DISK_LOCAL = {
    key: "localData",
    stateDefinition: {
        name: "ciphersLocal",
    },
};
const _57_move_cipher_service_to_state_provider_CIPHERS_DISK = {
    key: "ciphers",
    stateDefinition: {
        name: "ciphers",
    },
};
class CipherServiceMigrator extends (/* unused pure expression or super */ null && (_57_move_cipher_service_to_state_provider_Migrator)) {
    migrate(helper) {
        return _57_move_cipher_service_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _57_move_cipher_service_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c;
                    let updatedAccount = false;
                    //Migrate localData
                    const localData = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.localData;
                    if (localData != null) {
                        yield helper.setToUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK_LOCAL, localData);
                        delete account.data.localData;
                        updatedAccount = true;
                    }
                    //Migrate ciphers
                    const ciphers = (_c = (_b = account === null || account === void 0 ? void 0 : account.data) === null || _b === void 0 ? void 0 : _b.ciphers) === null || _c === void 0 ? void 0 : _c.encrypted;
                    if (ciphers != null) {
                        yield helper.setToUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK, ciphers);
                        delete account.data.ciphers;
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _57_move_cipher_service_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _57_move_cipher_service_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    //rollback localData
                    const localData = yield helper.getFromUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK_LOCAL);
                    if (account.data && localData != null) {
                        account.data.localData = localData;
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK_LOCAL, null);
                    //rollback ciphers
                    const ciphers = yield helper.getFromUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK);
                    if (account.data && ciphers != null) {
                        (_a = account.data).ciphers || (_a.ciphers = { encrypted: null });
                        account.data.ciphers.encrypted = ciphers;
                        yield helper.set(userId, account);
                    }
                    yield helper.setToUser(userId, _57_move_cipher_service_to_state_provider_CIPHERS_DISK, null);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/58-remove-refresh-token-migrated-state-provider-flag.ts
/* unused harmony import specifier */ var _58_remove_refresh_token_migrated_state_provider_flag_Migrator;
/* unused harmony import specifier */ var _58_remove_refresh_token_migrated_state_provider_flag_IRREVERSIBLE;
var _58_remove_refresh_token_migrated_state_provider_flag_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const REFRESH_TOKEN_MIGRATED_TO_SECURE_STORAGE = {
    key: "refreshTokenMigratedToSecureStorage", // matches KeyDefinition.key
    stateDefinition: {
        name: "token", // matches StateDefinition.name in StateDefinitions
    },
};
class RemoveRefreshTokenMigratedFlagMigrator extends (/* unused pure expression or super */ null && (_58_remove_refresh_token_migrated_state_provider_flag_Migrator)) {
    migrate(helper) {
        return _58_remove_refresh_token_migrated_state_provider_flag_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _58_remove_refresh_token_migrated_state_provider_flag_awaiter(this, void 0, void 0, function* () {
                    const refreshTokenMigratedFlag = yield helper.getFromUser(userId, REFRESH_TOKEN_MIGRATED_TO_SECURE_STORAGE);
                    if (refreshTokenMigratedFlag != null) {
                        // Only delete the flag if it exists
                        yield helper.removeFromUser(userId, REFRESH_TOKEN_MIGRATED_TO_SECURE_STORAGE);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _58_remove_refresh_token_migrated_state_provider_flag_awaiter(this, void 0, void 0, function* () {
            throw _58_remove_refresh_token_migrated_state_provider_flag_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/59-move-kdf-config-to-state-provider.ts
/* unused harmony import specifier */ var _59_move_kdf_config_to_state_provider_Migrator;
var _59_move_kdf_config_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var KdfType;
(function (KdfType) {
    KdfType[KdfType["PBKDF2_SHA256"] = 0] = "PBKDF2_SHA256";
    KdfType[KdfType["Argon2id"] = 1] = "Argon2id";
})(KdfType || (KdfType = {}));
class KdfConfig {
}
const kdfConfigKeyDefinition = {
    key: "kdfConfig",
    stateDefinition: {
        name: "kdfConfig",
    },
};
class KdfConfigMigrator extends (/* unused pure expression or super */ null && (_59_move_kdf_config_to_state_provider_Migrator)) {
    migrate(helper) {
        return _59_move_kdf_config_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _59_move_kdf_config_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c, _d, _e, _f, _g, _h;
                    const iterations = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.kdfIterations;
                    const kdfType = (_b = account === null || account === void 0 ? void 0 : account.profile) === null || _b === void 0 ? void 0 : _b.kdfType;
                    const memory = (_c = account === null || account === void 0 ? void 0 : account.profile) === null || _c === void 0 ? void 0 : _c.kdfMemory;
                    const parallelism = (_d = account === null || account === void 0 ? void 0 : account.profile) === null || _d === void 0 ? void 0 : _d.kdfParallelism;
                    const kdfConfig = {
                        iterations: iterations,
                        kdfType: kdfType,
                        memory: memory,
                        parallelism: parallelism,
                    };
                    if (kdfConfig != null) {
                        yield helper.setToUser(userId, kdfConfigKeyDefinition, kdfConfig);
                        (_e = account === null || account === void 0 ? void 0 : account.profile) === null || _e === void 0 ? true : delete _e.kdfIterations;
                        (_f = account === null || account === void 0 ? void 0 : account.profile) === null || _f === void 0 ? true : delete _f.kdfType;
                        (_g = account === null || account === void 0 ? void 0 : account.profile) === null || _g === void 0 ? true : delete _g.kdfMemory;
                        (_h = account === null || account === void 0 ? void 0 : account.profile) === null || _h === void 0 ? true : delete _h.kdfParallelism;
                    }
                    yield helper.set(userId, account);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _59_move_kdf_config_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _59_move_kdf_config_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    const kdfConfig = yield helper.getFromUser(userId, kdfConfigKeyDefinition);
                    if (kdfConfig != null) {
                        account.profile.kdfIterations = kdfConfig.iterations;
                        account.profile.kdfType = kdfConfig.kdfType;
                        account.profile.kdfMemory = kdfConfig.memory;
                        account.profile.kdfParallelism = kdfConfig.parallelism;
                        yield helper.setToUser(userId, kdfConfigKeyDefinition, null);
                    }
                    yield helper.set(userId, account);
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/6-remove-legacy-etm-key.ts
/* unused harmony import specifier */ var _6_remove_legacy_etm_key_Migrator;
/* unused harmony import specifier */ var _6_remove_legacy_etm_key_IRREVERSIBLE;
var _6_remove_legacy_etm_key_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class RemoveLegacyEtmKeyMigrator extends (/* unused pure expression or super */ null && (_6_remove_legacy_etm_key_Migrator)) {
    migrate(helper) {
        return _6_remove_legacy_etm_key_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function updateAccount(userId, account) {
                return _6_remove_legacy_etm_key_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    if ((_a = account === null || account === void 0 ? void 0 : account.keys) === null || _a === void 0 ? void 0 : _a.legacyEtmKey) {
                        delete account.keys.legacyEtmKey;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => updateAccount(userId, account)));
        });
    }
    rollback(helper) {
        return _6_remove_legacy_etm_key_awaiter(this, void 0, void 0, function* () {
            throw _6_remove_legacy_etm_key_IRREVERSIBLE;
        });
    }
    // Override is necessary because default implementation assumes `stateVersion` at the root, but for this version
    // it is nested inside a global object.
    updateVersion(helper, direction) {
        return _6_remove_legacy_etm_key_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            const global = (yield helper.get("global")) || {};
            yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: endVersion }));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/60-known-accounts.ts
/* unused harmony import specifier */ var _60_known_accounts_Migrator;
var _60_known_accounts_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const ACCOUNT_ACCOUNTS = {
    stateDefinition: {
        name: "account",
    },
    key: "accounts",
};
const ACCOUNT_ACTIVE_ACCOUNT_ID = {
    stateDefinition: {
        name: "account",
    },
    key: "activeAccountId",
};
const ACCOUNT_ACTIVITY = {
    stateDefinition: {
        name: "account",
    },
    key: "activity",
};
class KnownAccountsMigrator extends (/* unused pure expression or super */ null && (_60_known_accounts_Migrator)) {
    migrate(helper) {
        return _60_known_accounts_awaiter(this, void 0, void 0, function* () {
            yield this.migrateAuthenticatedAccounts(helper);
            yield this.migrateActiveAccountId(helper);
            yield this.migrateAccountActivity(helper);
        });
    }
    rollback(helper) {
        return _60_known_accounts_awaiter(this, void 0, void 0, function* () {
            var _a;
            // authenticated account are removed, but the accounts record also contains logged out accounts. Best we can do is to add them all back
            const userIds = (_a = (yield helper.getKnownUserIds())) !== null && _a !== void 0 ? _a : [];
            yield helper.set("authenticatedAccounts", userIds);
            yield helper.removeFromGlobal(ACCOUNT_ACCOUNTS);
            // Active Account Id
            const activeAccountId = yield helper.getFromGlobal(ACCOUNT_ACTIVE_ACCOUNT_ID);
            if (activeAccountId) {
                yield helper.set("activeUserId", activeAccountId);
            }
            yield helper.removeFromGlobal(ACCOUNT_ACTIVE_ACCOUNT_ID);
            // Account Activity
            const accountActivity = yield helper.getFromGlobal(ACCOUNT_ACTIVITY);
            if (accountActivity) {
                const toStore = Object.entries(accountActivity).reduce((agg, [userId, dateString]) => {
                    agg[userId] = new Date(dateString).getTime();
                    return agg;
                }, {});
                yield helper.set("accountActivity", toStore);
            }
            yield helper.removeFromGlobal(ACCOUNT_ACTIVITY);
        });
    }
    migrateAuthenticatedAccounts(helper) {
        return _60_known_accounts_awaiter(this, void 0, void 0, function* () {
            var _a;
            const authenticatedAccounts = (_a = (yield helper.get("authenticatedAccounts"))) !== null && _a !== void 0 ? _a : [];
            const accounts = yield Promise.all(authenticatedAccounts.map((userId) => _60_known_accounts_awaiter(this, void 0, void 0, function* () {
                const account = yield helper.get(userId);
                return { userId, account };
            })));
            const accountsToStore = accounts.reduce((agg, { userId, account }) => {
                var _a, _b;
                if (account === null || account === void 0 ? void 0 : account.profile) {
                    agg[userId] = {
                        email: (_a = account.profile.email) !== null && _a !== void 0 ? _a : "",
                        emailVerified: (_b = account.profile.emailVerified) !== null && _b !== void 0 ? _b : false,
                        name: account.profile.name,
                    };
                }
                return agg;
            }, {});
            yield helper.setToGlobal(ACCOUNT_ACCOUNTS, accountsToStore);
            yield helper.remove("authenticatedAccounts");
        });
    }
    migrateAccountActivity(helper) {
        return _60_known_accounts_awaiter(this, void 0, void 0, function* () {
            const stored = yield helper.get("accountActivity");
            const accountActivity = Object.entries(stored !== null && stored !== void 0 ? stored : {}).reduce((agg, [userId, dateMs]) => {
                agg[userId] = JSON.stringify(new Date(dateMs));
                return agg;
            }, {});
            yield helper.setToGlobal(ACCOUNT_ACTIVITY, accountActivity);
            yield helper.remove("accountActivity");
        });
    }
    migrateActiveAccountId(helper) {
        return _60_known_accounts_awaiter(this, void 0, void 0, function* () {
            const activeAccountId = yield helper.get("activeUserId");
            yield helper.setToGlobal(ACCOUNT_ACTIVE_ACCOUNT_ID, activeAccountId);
            yield helper.remove("activeUserId");
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/61-move-pin-state-to-providers.ts
/* unused harmony import specifier */ var _61_move_pin_state_to_providers_Migrator;
var _61_move_pin_state_to_providers_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const PIN_STATE = { name: "pinUnlock" };
const PIN_KEY_ENCRYPTED_USER_KEY_PERSISTENT = {
    stateDefinition: PIN_STATE,
    key: "pinKeyEncryptedUserKeyPersistent",
};
const USER_KEY_ENCRYPTED_PIN = {
    stateDefinition: PIN_STATE,
    key: "userKeyEncryptedPin",
};
const OLD_PIN_KEY_ENCRYPTED_MASTER_KEY = {
    stateDefinition: PIN_STATE,
    key: "oldPinKeyEncryptedMasterKey",
};
class PinStateMigrator extends (/* unused pure expression or super */ null && (_61_move_pin_state_to_providers_Migrator)) {
    migrate(helper) {
        return _61_move_pin_state_to_providers_awaiter(this, void 0, void 0, function* () {
            const legacyAccounts = yield helper.getAccounts();
            let updatedAccount = false;
            function migrateAccount(userId, account) {
                return _61_move_pin_state_to_providers_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c, _d;
                    // Migrate pinKeyEncryptedUserKey (to `pinKeyEncryptedUserKeyPersistent`)
                    if (((_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.pinKeyEncryptedUserKey) != null) {
                        yield helper.setToUser(userId, PIN_KEY_ENCRYPTED_USER_KEY_PERSISTENT, account.settings.pinKeyEncryptedUserKey);
                        delete account.settings.pinKeyEncryptedUserKey;
                        updatedAccount = true;
                    }
                    // Migrate protectedPin (to `userKeyEncryptedPin`)
                    if (((_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? void 0 : _b.protectedPin) != null) {
                        yield helper.setToUser(userId, USER_KEY_ENCRYPTED_PIN, account.settings.protectedPin);
                        delete account.settings.protectedPin;
                        updatedAccount = true;
                    }
                    // Migrate pinProtected (to `oldPinKeyEncryptedMasterKey`)
                    if (((_d = (_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? void 0 : _c.pinProtected) === null || _d === void 0 ? void 0 : _d.encrypted) != null) {
                        yield helper.setToUser(userId, OLD_PIN_KEY_ENCRYPTED_MASTER_KEY, account.settings.pinProtected.encrypted);
                        delete account.settings.pinProtected;
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([
                ...legacyAccounts.map(({ userId, account }) => migrateAccount(userId, account)),
            ]);
        });
    }
    rollback(helper) {
        return _61_move_pin_state_to_providers_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _61_move_pin_state_to_providers_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    let updatedAccount = false;
                    const accountPinKeyEncryptedUserKeyPersistent = yield helper.getFromUser(userId, PIN_KEY_ENCRYPTED_USER_KEY_PERSISTENT);
                    const accountUserKeyEncryptedPin = yield helper.getFromUser(userId, USER_KEY_ENCRYPTED_PIN);
                    const accountOldPinKeyEncryptedMasterKey = yield helper.getFromUser(userId, OLD_PIN_KEY_ENCRYPTED_MASTER_KEY);
                    if (!account) {
                        account = {};
                    }
                    if (accountPinKeyEncryptedUserKeyPersistent != null) {
                        account.settings.pinKeyEncryptedUserKey = accountPinKeyEncryptedUserKeyPersistent;
                        yield helper.setToUser(userId, PIN_KEY_ENCRYPTED_USER_KEY_PERSISTENT, null);
                        updatedAccount = true;
                    }
                    if (accountUserKeyEncryptedPin != null) {
                        account.settings.protectedPin = accountUserKeyEncryptedPin;
                        yield helper.setToUser(userId, USER_KEY_ENCRYPTED_PIN, null);
                        updatedAccount = true;
                    }
                    if (accountOldPinKeyEncryptedMasterKey != null) {
                        account.settings = Object.assign((_a = account.settings) !== null && _a !== void 0 ? _a : {}, {
                            pinProtected: {
                                encrypted: accountOldPinKeyEncryptedMasterKey,
                            },
                        });
                        yield helper.setToUser(userId, OLD_PIN_KEY_ENCRYPTED_MASTER_KEY, null);
                        updatedAccount = true;
                    }
                    if (updatedAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all(accounts.map(({ userId, account }) => rollbackAccount(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/62-migrate-vault-timeout-settings-svc-to-state-provider.ts
/* unused harmony import specifier */ var _62_migrate_vault_timeout_settings_svc_to_state_provider_Migrator;
var _62_migrate_vault_timeout_settings_svc_to_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const VAULT_TIMEOUT_SETTINGS_STATE_DEF_LIKE = {
    name: "vaultTimeoutSettings",
};
const VAULT_TIMEOUT = {
    key: "vaultTimeout", // matches KeyDefinition.key
    stateDefinition: VAULT_TIMEOUT_SETTINGS_STATE_DEF_LIKE,
};
const VAULT_TIMEOUT_ACTION = {
    key: "vaultTimeoutAction", // matches KeyDefinition.key
    stateDefinition: VAULT_TIMEOUT_SETTINGS_STATE_DEF_LIKE,
};
// Define mapping of old values to new values for migration purposes
const vaultTimeoutTypeMigrateRecord = {
    null: "never",
    "-1": "onRestart",
    "-2": "onLocked",
    "-3": "onSleep",
    "-4": "onIdle",
};
// define mapping of new values to old values for rollback purposes
const vaultTimeoutTypeRollbackRecord = {
    never: null,
    onRestart: -1,
    onLocked: -2,
    onSleep: -3,
    onIdle: -4,
};
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var _62_migrate_vault_timeout_settings_svc_to_state_provider_ClientType;
(function (ClientType) {
    ClientType["Web"] = "web";
    ClientType["Browser"] = "browser";
    ClientType["Desktop"] = "desktop";
    ClientType["Cli"] = "cli";
})(_62_migrate_vault_timeout_settings_svc_to_state_provider_ClientType || (_62_migrate_vault_timeout_settings_svc_to_state_provider_ClientType = {}));
class VaultTimeoutSettingsServiceStateProviderMigrator extends (/* unused pure expression or super */ null && (_62_migrate_vault_timeout_settings_svc_to_state_provider_Migrator)) {
    migrate(helper) {
        return _62_migrate_vault_timeout_settings_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const globalData = yield helper.get("global");
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _62_migrate_vault_timeout_settings_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    var _a, _b, _c, _d;
                    let updatedAccount = false;
                    // Migrate vault timeout
                    let existingVaultTimeout = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.vaultTimeout;
                    if (helper.clientType === _62_migrate_vault_timeout_settings_svc_to_state_provider_ClientType.Cli && existingVaultTimeout === undefined) {
                        // The CLI does not set a vault timeout by default so we need to set it to null
                        // so that the migration can migrate null to "never" as the CLI does not have a vault timeout.
                        existingVaultTimeout = null;
                    }
                    if (existingVaultTimeout !== undefined) {
                        // check undefined so that we allow null values (previously meant never timeout)
                        // Only migrate data that exists
                        if (existingVaultTimeout === null || existingVaultTimeout < 0) {
                            // Map null or negative values to new string values
                            const newVaultTimeout = vaultTimeoutTypeMigrateRecord[existingVaultTimeout];
                            yield helper.setToUser(userId, VAULT_TIMEOUT, newVaultTimeout);
                        }
                        else {
                            // Persist positive numbers as is
                            yield helper.setToUser(userId, VAULT_TIMEOUT, existingVaultTimeout);
                        }
                        (_b = account === null || account === void 0 ? void 0 : account.settings) === null || _b === void 0 ? true : delete _b.vaultTimeout;
                        updatedAccount = true;
                    }
                    // Migrate vault timeout action
                    const existingVaultTimeoutAction = (_c = account === null || account === void 0 ? void 0 : account.settings) === null || _c === void 0 ? void 0 : _c.vaultTimeoutAction;
                    if (existingVaultTimeoutAction != null) {
                        // Only migrate data that exists
                        yield helper.setToUser(userId, VAULT_TIMEOUT_ACTION, existingVaultTimeoutAction);
                        (_d = account === null || account === void 0 ? void 0 : account.settings) === null || _d === void 0 ? true : delete _d.vaultTimeoutAction;
                        updatedAccount = true;
                    }
                    // Note: we are explicitly not worrying about mapping over the global fallback vault timeout / action
                    // into the new state provider framework.  It was originally a fallback but hasn't been used for years
                    // so this migration will clean up the global properties fully.
                    if (updatedAccount) {
                        // Save the migrated account only if it was updated
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
            // Delete global data (works for browser extension and web; CLI doesn't have these as global settings).
            globalData === null || globalData === void 0 ? true : delete globalData.vaultTimeout;
            globalData === null || globalData === void 0 ? true : delete globalData.vaultTimeoutAction;
            yield helper.set("global", globalData);
            // Remove desktop only settings. These aren't found by the above global key removal b/c of
            // the different storage key format. This removal does not cause any issues on migrating for other clients.
            yield helper.remove("global\\.vaultTimeout");
            yield helper.remove("global\\.vaultTimeoutAction");
        });
    }
    rollback(helper) {
        return _62_migrate_vault_timeout_settings_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function rollbackAccount(userId, account) {
                return _62_migrate_vault_timeout_settings_svc_to_state_provider_awaiter(this, void 0, void 0, function* () {
                    let updatedLegacyAccount = false;
                    // Rollback vault timeout
                    const migratedVaultTimeout = yield helper.getFromUser(userId, VAULT_TIMEOUT);
                    if ((account === null || account === void 0 ? void 0 : account.settings) && migratedVaultTimeout != null) {
                        if (typeof migratedVaultTimeout === "string") {
                            // Map new string values back to old values
                            account.settings.vaultTimeout = vaultTimeoutTypeRollbackRecord[migratedVaultTimeout];
                        }
                        else {
                            // persist numbers as is
                            account.settings.vaultTimeout = migratedVaultTimeout;
                        }
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, VAULT_TIMEOUT, null);
                    // Rollback vault timeout action
                    const migratedVaultTimeoutAction = yield helper.getFromUser(userId, VAULT_TIMEOUT_ACTION);
                    if ((account === null || account === void 0 ? void 0 : account.settings) && migratedVaultTimeoutAction != null) {
                        account.settings.vaultTimeoutAction = migratedVaultTimeoutAction;
                        updatedLegacyAccount = true;
                    }
                    yield helper.setToUser(userId, VAULT_TIMEOUT_ACTION, null);
                    if (updatedLegacyAccount) {
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => rollbackAccount(userId, account))]);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/63-migrate-password-settings.ts
/* unused harmony import specifier */ var _63_migrate_password_settings_Migrator;
var _63_migrate_password_settings_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const NAVIGATION = {
    stateDefinition: {
        name: "generator",
    },
    key: "generatorSettings",
};
const PASSWORD = {
    stateDefinition: {
        name: "generator",
    },
    key: "passwordGeneratorSettings",
};
const PASSPHRASE = {
    stateDefinition: {
        name: "generator",
    },
    key: "passphraseGeneratorSettings",
};
class PasswordOptionsMigrator extends (/* unused pure expression or super */ null && (_63_migrate_password_settings_Migrator)) {
    migrate(helper) {
        return _63_migrate_password_settings_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _63_migrate_password_settings_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const legacyOptions = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.passwordGenerationOptions;
                    if (legacyOptions) {
                        const converted = convertSettings(legacyOptions);
                        yield storeSettings(helper, userId, converted);
                        yield deleteSettings(helper, userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _63_migrate_password_settings_awaiter(this, void 0, void 0, function* () {
            // not supported
        });
    }
}
function convertSettings(options) {
    const password = {
        length: options.length,
        ambiguous: options.ambiguous,
        uppercase: options.uppercase,
        minUppercase: options.minUppercase,
        lowercase: options.lowercase,
        minLowercase: options.minLowercase,
        number: options.number,
        minNumber: options.minNumber,
        special: options.special,
        minSpecial: options.minSpecial,
    };
    const generator = {
        type: options.type,
    };
    const passphrase = {
        numWords: options.numWords,
        wordSeparator: options.wordSeparator,
        capitalize: options.capitalize,
        includeNumber: options.includeNumber,
    };
    return { generator, password, passphrase };
}
function storeSettings(helper, userId, converted) {
    return _63_migrate_password_settings_awaiter(this, void 0, void 0, function* () {
        var _a;
        const existing = (_a = (yield helper.getFromUser(userId, NAVIGATION))) !== null && _a !== void 0 ? _a : {};
        const updated = Object.assign(existing, converted.generator);
        yield Promise.all([
            helper.setToUser(userId, NAVIGATION, updated),
            helper.setToUser(userId, PASSPHRASE, converted.passphrase),
            helper.setToUser(userId, PASSWORD, converted.password),
        ]);
    });
}
function deleteSettings(helper, userId, account) {
    return _63_migrate_password_settings_awaiter(this, void 0, void 0, function* () {
        var _a;
        (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? true : delete _a.passwordGenerationOptions;
        yield helper.set(userId, account);
    });
}

;// ../../libs/state/src/state-migrations/migrations/64-migrate-generator-history.ts
/* unused harmony import specifier */ var _64_migrate_generator_history_Migrator;
var _64_migrate_generator_history_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const HISTORY = {
    stateDefinition: {
        name: "generator",
    },
    key: "localGeneratorHistoryBuffer",
};
class GeneratorHistoryMigrator extends (/* unused pure expression or super */ null && (_64_migrate_generator_history_Migrator)) {
    migrate(helper) {
        return _64_migrate_generator_history_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _64_migrate_generator_history_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const data = (_a = account === null || account === void 0 ? void 0 : account.data) === null || _a === void 0 ? void 0 : _a.passwordGenerationHistory;
                    if (data && data.encrypted) {
                        yield helper.setToUser(userId, HISTORY, data.encrypted);
                        delete account.data.passwordGenerationHistory;
                        yield helper.set(userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _64_migrate_generator_history_awaiter(this, void 0, void 0, function* () {
            // not supported
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/65-migrate-forwarder-settings.ts
/* unused harmony import specifier */ var _65_migrate_forwarder_settings_Migrator;
var _65_migrate_forwarder_settings_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _65_migrate_forwarder_settings_NAVIGATION = {
    stateDefinition: {
        name: "generator",
    },
    key: "generatorSettings",
};
const CATCHALL = {
    stateDefinition: {
        name: "generator",
    },
    key: "catchallGeneratorSettings",
};
const EFF_USERNAME = {
    stateDefinition: {
        name: "generator",
    },
    key: "effUsernameGeneratorSettings",
};
const SUBADDRESS = {
    stateDefinition: {
        name: "generator",
    },
    key: "subaddressGeneratorSettings",
};
const ADDY_IO = {
    stateDefinition: {
        name: "generator",
    },
    key: "addyIoBuffer",
};
const DUCK_DUCK_GO = {
    stateDefinition: {
        name: "generator",
    },
    key: "duckDuckGoBuffer",
};
const FASTMAIL = {
    stateDefinition: {
        name: "generator",
    },
    key: "fastmailBuffer",
};
const FIREFOX_RELAY = {
    stateDefinition: {
        name: "generator",
    },
    key: "firefoxRelayBuffer",
};
const FORWARD_EMAIL = {
    stateDefinition: {
        name: "generator",
    },
    key: "forwardEmailBuffer",
};
const SIMPLE_LOGIN = {
    stateDefinition: {
        name: "generator",
    },
    key: "simpleLoginBuffer",
};
class ForwarderOptionsMigrator extends (/* unused pure expression or super */ null && (_65_migrate_forwarder_settings_Migrator)) {
    migrate(helper) {
        return _65_migrate_forwarder_settings_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _65_migrate_forwarder_settings_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const legacyOptions = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.usernameGenerationOptions;
                    if (legacyOptions) {
                        const converted = _65_migrate_forwarder_settings_convertSettings(legacyOptions);
                        yield _65_migrate_forwarder_settings_storeSettings(helper, userId, converted);
                        yield _65_migrate_forwarder_settings_deleteSettings(helper, userId, account);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _65_migrate_forwarder_settings_awaiter(this, void 0, void 0, function* () {
            // not supported
        });
    }
}
function _65_migrate_forwarder_settings_convertSettings(options) {
    const forwarders = {
        addyIo: {
            baseUrl: options.forwardedAnonAddyBaseUrl,
            token: options.forwardedAnonAddyApiToken,
            domain: options.forwardedAnonAddyDomain,
        },
        duckDuckGo: {
            token: options.forwardedDuckDuckGoToken,
        },
        fastmail: {
            token: options.forwardedFastmailApiToken,
        },
        firefoxRelay: {
            token: options.forwardedFirefoxApiToken,
        },
        forwardEmail: {
            token: options.forwardedForwardEmailApiToken,
            domain: options.forwardedForwardEmailDomain,
        },
        simpleLogin: {
            token: options.forwardedSimpleLoginApiKey,
            baseUrl: options.forwardedSimpleLoginBaseUrl,
        },
    };
    const generator = {
        username: options.type,
        forwarder: options.forwardedService,
    };
    const algorithms = {
        effUsername: {
            wordCapitalize: options.wordCapitalize,
            wordIncludeNumber: options.wordIncludeNumber,
        },
        subaddress: {
            subaddressType: options.subaddressType,
            subaddressEmail: options.subaddressEmail,
        },
        catchall: {
            catchallType: options.catchallType,
            catchallDomain: options.catchallDomain,
        },
    };
    return { generator, algorithms, forwarders };
}
function _65_migrate_forwarder_settings_storeSettings(helper, userId, converted) {
    return _65_migrate_forwarder_settings_awaiter(this, void 0, void 0, function* () {
        yield Promise.all([
            helper.setToUser(userId, _65_migrate_forwarder_settings_NAVIGATION, converted.generator),
            helper.setToUser(userId, CATCHALL, converted.algorithms.catchall),
            helper.setToUser(userId, EFF_USERNAME, converted.algorithms.effUsername),
            helper.setToUser(userId, SUBADDRESS, converted.algorithms.subaddress),
            helper.setToUser(userId, ADDY_IO, converted.forwarders.addyIo),
            helper.setToUser(userId, DUCK_DUCK_GO, converted.forwarders.duckDuckGo),
            helper.setToUser(userId, FASTMAIL, converted.forwarders.fastmail),
            helper.setToUser(userId, FIREFOX_RELAY, converted.forwarders.firefoxRelay),
            helper.setToUser(userId, FORWARD_EMAIL, converted.forwarders.forwardEmail),
            helper.setToUser(userId, SIMPLE_LOGIN, converted.forwarders.simpleLogin),
        ]);
    });
}
function _65_migrate_forwarder_settings_deleteSettings(helper, userId, account) {
    return _65_migrate_forwarder_settings_awaiter(this, void 0, void 0, function* () {
        var _a;
        (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? true : delete _a.usernameGenerationOptions;
        yield helper.set(userId, account);
    });
}

;// ../../libs/state/src/state-migrations/migrations/66-move-final-desktop-settings.ts
/* unused harmony import specifier */ var _66_move_final_desktop_settings_Migrator;
var _66_move_final_desktop_settings_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _66_move_final_desktop_settings_DESKTOP_SETTINGS_DISK = {
    name: "desktopSettings",
};
const BROWSER_INTEGRATION_ENABLED = {
    key: "browserIntegrationEnabled",
    stateDefinition: _66_move_final_desktop_settings_DESKTOP_SETTINGS_DISK,
};
const BROWSER_INTEGRATION_FINGERPRINT_ENABLED = {
    key: "browserIntegrationFingerprintEnabled",
    stateDefinition: _66_move_final_desktop_settings_DESKTOP_SETTINGS_DISK,
};
const MINIMIZE_ON_COPY = {
    key: "minimizeOnCopy",
    stateDefinition: _66_move_final_desktop_settings_DESKTOP_SETTINGS_DISK,
};
class MoveFinalDesktopSettingsMigrator extends (/* unused pure expression or super */ null && (_66_move_final_desktop_settings_Migrator)) {
    migrate(helper) {
        return _66_move_final_desktop_settings_awaiter(this, void 0, void 0, function* () {
            const legacyGlobal = yield helper.get("global");
            const enableBrowserIntegrationValue = legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableBrowserIntegration;
            const enableBrowserIntegrationFingerprintValue = legacyGlobal === null || legacyGlobal === void 0 ? void 0 : legacyGlobal.enableBrowserIntegrationFingerprint;
            let updatedGlobal = false;
            if (enableBrowserIntegrationValue != null) {
                yield helper.setToGlobal(BROWSER_INTEGRATION_ENABLED, enableBrowserIntegrationValue);
                delete legacyGlobal.enableBrowserIntegration;
                updatedGlobal = true;
            }
            if (enableBrowserIntegrationFingerprintValue != null) {
                yield helper.setToGlobal(BROWSER_INTEGRATION_FINGERPRINT_ENABLED, enableBrowserIntegrationFingerprintValue);
                delete legacyGlobal.enableBrowserIntegrationFingerprint;
                updatedGlobal = true;
            }
            if (updatedGlobal) {
                yield helper.set("global", legacyGlobal);
            }
            function migrateAccount(userId, account) {
                return _66_move_final_desktop_settings_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const minimizeOnCopyToClipboardValue = (_a = account === null || account === void 0 ? void 0 : account.settings) === null || _a === void 0 ? void 0 : _a.minimizeOnCopyToClipboard;
                    if (minimizeOnCopyToClipboardValue != null) {
                        yield helper.setToUser(userId, MINIMIZE_ON_COPY, minimizeOnCopyToClipboardValue);
                        delete account.settings.minimizeOnCopyToClipboard;
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => migrateAccount(userId, account)));
        });
    }
    rollback(helper) {
        return _66_move_final_desktop_settings_awaiter(this, void 0, void 0, function* () {
            const browserIntegrationEnabledValue = yield helper.getFromGlobal(BROWSER_INTEGRATION_ENABLED);
            const browserIntegrationFingerprintEnabled = yield helper.getFromGlobal(BROWSER_INTEGRATION_FINGERPRINT_ENABLED);
            if (browserIntegrationEnabledValue != null) {
                let legacyGlobal = yield helper.get("global");
                legacyGlobal !== null && legacyGlobal !== void 0 ? legacyGlobal : (legacyGlobal = {});
                legacyGlobal.enableBrowserIntegration = browserIntegrationEnabledValue;
                yield helper.set("global", legacyGlobal);
                yield helper.removeFromGlobal(BROWSER_INTEGRATION_ENABLED);
            }
            if (browserIntegrationFingerprintEnabled != null) {
                let legacyGlobal = yield helper.get("global");
                legacyGlobal !== null && legacyGlobal !== void 0 ? legacyGlobal : (legacyGlobal = {});
                legacyGlobal.enableBrowserIntegrationFingerprint = browserIntegrationFingerprintEnabled;
                yield helper.set("global", legacyGlobal);
                yield helper.removeFromGlobal(BROWSER_INTEGRATION_FINGERPRINT_ENABLED);
            }
            function rollbackAccount(userId, account) {
                return _66_move_final_desktop_settings_awaiter(this, void 0, void 0, function* () {
                    const minimizeOnCopyToClipboardValue = yield helper.getFromUser(userId, MINIMIZE_ON_COPY);
                    if (minimizeOnCopyToClipboardValue != null) {
                        account !== null && account !== void 0 ? account : (account = { settings: {} });
                        account.settings.minimizeOnCopyToClipboard = minimizeOnCopyToClipboardValue;
                        yield helper.set(userId, account);
                        yield helper.removeFromUser(userId, MINIMIZE_ON_COPY);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackAccount(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/67-remove-unassigned-items-banner-dismissed.ts
/* unused harmony import specifier */ var _67_remove_unassigned_items_banner_dismissed_Migrator;
/* unused harmony import specifier */ var _67_remove_unassigned_items_banner_dismissed_IRREVERSIBLE;
var _67_remove_unassigned_items_banner_dismissed_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const SHOW_BANNER = {
    key: "showBanner",
    stateDefinition: { name: "unassignedItemsBanner" },
};
class RemoveUnassignedItemsBannerDismissed extends (/* unused pure expression or super */ null && (_67_remove_unassigned_items_banner_dismissed_Migrator)) {
    migrate(helper) {
        return _67_remove_unassigned_items_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            yield Promise.all((yield helper.getAccounts()).map((_a) => _67_remove_unassigned_items_banner_dismissed_awaiter(this, [_a], void 0, function* ({ userId }) {
                if (helper.getFromUser(userId, SHOW_BANNER) != null) {
                    yield helper.removeFromUser(userId, SHOW_BANNER);
                }
            })));
        });
    }
    rollback(helper) {
        return _67_remove_unassigned_items_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            throw _67_remove_unassigned_items_banner_dismissed_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/68-move-last-sync-date.ts
/* unused harmony import specifier */ var _68_move_last_sync_date_Migrator;
var _68_move_last_sync_date_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _68_move_last_sync_date_LAST_SYNC_KEY = {
    key: "lastSync",
    stateDefinition: {
        name: "sync",
    },
};
class MoveLastSyncDate extends (/* unused pure expression or super */ null && (_68_move_last_sync_date_Migrator)) {
    migrate(helper) {
        return _68_move_last_sync_date_awaiter(this, void 0, void 0, function* () {
            function migrateAccount(userId, account) {
                return _68_move_last_sync_date_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = (_a = account === null || account === void 0 ? void 0 : account.profile) === null || _a === void 0 ? void 0 : _a.lastSync;
                    if (value != null) {
                        yield helper.setToUser(userId, _68_move_last_sync_date_LAST_SYNC_KEY, value);
                        delete account.profile.lastSync;
                        yield helper.set(userId, account);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => migrateAccount(userId, account)));
        });
    }
    rollback(helper) {
        return _68_move_last_sync_date_awaiter(this, void 0, void 0, function* () {
            function rollbackAccount(userId, account) {
                return _68_move_last_sync_date_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    const value = yield helper.getFromUser(userId, _68_move_last_sync_date_LAST_SYNC_KEY);
                    if (value != null) {
                        account !== null && account !== void 0 ? account : (account = {});
                        (_a = account.profile) !== null && _a !== void 0 ? _a : (account.profile = {});
                        account.profile.lastSync = value;
                        yield helper.set(userId, account);
                        yield helper.removeFromUser(userId, _68_move_last_sync_date_LAST_SYNC_KEY);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId, account }) => rollbackAccount(userId, account)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/69-migrate-incorrect-folder-key.ts
/* unused harmony import specifier */ var _69_migrate_incorrect_folder_key_Migrator;
var _69_migrate_incorrect_folder_key_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const BAD_FOLDER_KEY = {
    key: "folder", // We inadvertently changed the key from "folders" to "folder"
    stateDefinition: {
        name: "folder",
    },
};
const GOOD_FOLDER_KEY = {
    key: "folders", // We should keep the key as "folders"
    stateDefinition: {
        name: "folder",
    },
};
class MigrateIncorrectFolderKey extends (/* unused pure expression or super */ null && (_69_migrate_incorrect_folder_key_Migrator)) {
    migrate(helper) {
        return _69_migrate_incorrect_folder_key_awaiter(this, void 0, void 0, function* () {
            function migrateUser(userId) {
                return _69_migrate_incorrect_folder_key_awaiter(this, void 0, void 0, function* () {
                    const value = yield helper.getFromUser(userId, BAD_FOLDER_KEY);
                    if (value != null) {
                        yield helper.setToUser(userId, GOOD_FOLDER_KEY, value);
                    }
                    yield helper.removeFromUser(userId, BAD_FOLDER_KEY);
                });
            }
            const users = yield helper.getKnownUserIds();
            yield Promise.all(users.map((userId) => migrateUser(userId)));
        });
    }
    rollback(helper) {
        return _69_migrate_incorrect_folder_key_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId) {
                return _69_migrate_incorrect_folder_key_awaiter(this, void 0, void 0, function* () {
                    const value = yield helper.getFromUser(userId, GOOD_FOLDER_KEY);
                    if (value != null) {
                        yield helper.setToUser(userId, BAD_FOLDER_KEY, value);
                    }
                    yield helper.removeFromUser(userId, GOOD_FOLDER_KEY);
                });
            }
            const users = yield helper.getKnownUserIds();
            yield Promise.all(users.map((userId) => rollbackUser(userId)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/7-move-biometric-auto-prompt-to-account.ts
/* unused harmony import specifier */ var _7_move_biometric_auto_prompt_to_account_Migrator;
/* unused harmony import specifier */ var _7_move_biometric_auto_prompt_to_account_IRREVERSIBLE;
var _7_move_biometric_auto_prompt_to_account_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class MoveBiometricAutoPromptToAccount extends (/* unused pure expression or super */ null && (_7_move_biometric_auto_prompt_to_account_Migrator)) {
    migrate(helper) {
        return _7_move_biometric_auto_prompt_to_account_awaiter(this, void 0, void 0, function* () {
            var _a;
            const global = yield helper.get("global");
            const noAutoPromptBiometrics = (_a = global === null || global === void 0 ? void 0 : global.noAutoPromptBiometrics) !== null && _a !== void 0 ? _a : false;
            const accounts = yield helper.getAccounts();
            function updateAccount(userId, account) {
                return _7_move_biometric_auto_prompt_to_account_awaiter(this, void 0, void 0, function* () {
                    var _a;
                    if (account == null) {
                        return;
                    }
                    if (noAutoPromptBiometrics) {
                        account.settings = Object.assign((_a = account === null || account === void 0 ? void 0 : account.settings) !== null && _a !== void 0 ? _a : {}, {
                            disableAutoBiometricsPrompt: true,
                        });
                        yield helper.set(userId, account);
                    }
                });
            }
            delete global.noAutoPromptBiometrics;
            yield Promise.all([
                ...accounts.map(({ userId, account }) => updateAccount(userId, account)),
                helper.set("global", global),
            ]);
        });
    }
    rollback(helper) {
        return _7_move_biometric_auto_prompt_to_account_awaiter(this, void 0, void 0, function* () {
            throw _7_move_biometric_auto_prompt_to_account_IRREVERSIBLE;
        });
    }
    // Override is necessary because default implementation assumes `stateVersion` at the root, but for this version
    // it is nested inside a global object.
    updateVersion(helper, direction) {
        return _7_move_biometric_auto_prompt_to_account_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            const global = (yield helper.get("global")) || {};
            yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: endVersion }));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/70-remove-ac-banner-dismissed.ts
/* unused harmony import specifier */ var _70_remove_ac_banner_dismissed_Migrator;
/* unused harmony import specifier */ var _70_remove_ac_banner_dismissed_IRREVERSIBLE;
var _70_remove_ac_banner_dismissed_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const SHOW_BANNER_KEY = {
    key: "acBannersDismissed",
    stateDefinition: { name: "showProviderClientVaultPrivacyBanner" },
};
class RemoveAcBannersDismissed extends (/* unused pure expression or super */ null && (_70_remove_ac_banner_dismissed_Migrator)) {
    migrate(helper) {
        return _70_remove_ac_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            yield Promise.all((yield helper.getAccounts()).map((_a) => _70_remove_ac_banner_dismissed_awaiter(this, [_a], void 0, function* ({ userId }) {
                if (helper.getFromUser(userId, SHOW_BANNER_KEY) != null) {
                    yield helper.removeFromUser(userId, SHOW_BANNER_KEY);
                }
            })));
        });
    }
    rollback(helper) {
        return _70_remove_ac_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            throw _70_remove_ac_banner_dismissed_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/71-remove-new-customization-options-callout-dismissed.ts
/* unused harmony import specifier */ var _71_remove_new_customization_options_callout_dismissed_Migrator;
/* unused harmony import specifier */ var _71_remove_new_customization_options_callout_dismissed_IRREVERSIBLE;
var _71_remove_new_customization_options_callout_dismissed_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const SHOW_CALLOUT_KEY = {
    key: "newCustomizationOptionsCalloutDismissed",
    stateDefinition: { name: "bannersDismissed" },
};
class RemoveNewCustomizationOptionsCalloutDismissed extends (/* unused pure expression or super */ null && (_71_remove_new_customization_options_callout_dismissed_Migrator)) {
    migrate(helper) {
        return _71_remove_new_customization_options_callout_dismissed_awaiter(this, void 0, void 0, function* () {
            yield Promise.all((yield helper.getAccounts()).map((_a) => _71_remove_new_customization_options_callout_dismissed_awaiter(this, [_a], void 0, function* ({ userId }) {
                if (helper.getFromUser(userId, SHOW_CALLOUT_KEY) != null) {
                    yield helper.removeFromUser(userId, SHOW_CALLOUT_KEY);
                }
            })));
        });
    }
    rollback(helper) {
        return _71_remove_new_customization_options_callout_dismissed_awaiter(this, void 0, void 0, function* () {
            throw _71_remove_new_customization_options_callout_dismissed_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/72-remove-account-deprovisioning-banner-dismissed.ts
/* unused harmony import specifier */ var _72_remove_account_deprovisioning_banner_dismissed_Migrator;
/* unused harmony import specifier */ var _72_remove_account_deprovisioning_banner_dismissed_IRREVERSIBLE;
var _72_remove_account_deprovisioning_banner_dismissed_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _72_remove_account_deprovisioning_banner_dismissed_SHOW_BANNER_KEY = {
    key: "showAccountDeprovisioningBanner",
    stateDefinition: { name: "accountDeprovisioningBanner" },
};
class RemoveAccountDeprovisioningBannerDismissed extends (/* unused pure expression or super */ null && (_72_remove_account_deprovisioning_banner_dismissed_Migrator)) {
    migrate(helper) {
        return _72_remove_account_deprovisioning_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            yield Promise.all((yield helper.getAccounts()).map((_a) => _72_remove_account_deprovisioning_banner_dismissed_awaiter(this, [_a], void 0, function* ({ userId }) {
                if (helper.getFromUser(userId, _72_remove_account_deprovisioning_banner_dismissed_SHOW_BANNER_KEY) != null) {
                    yield helper.removeFromUser(userId, _72_remove_account_deprovisioning_banner_dismissed_SHOW_BANNER_KEY);
                }
            })));
        });
    }
    rollback(helper) {
        return _72_remove_account_deprovisioning_banner_dismissed_awaiter(this, void 0, void 0, function* () {
            throw _72_remove_account_deprovisioning_banner_dismissed_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/73-add-master-password-unlock-data.ts
/* unused harmony import specifier */ var _73_add_master_password_unlock_data_Migrator;
var _73_add_master_password_unlock_data_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _73_add_master_password_unlock_data_ACCOUNT_ACCOUNTS = {
    stateDefinition: {
        name: "account",
    },
    key: "accounts",
};
const MASTER_PASSWORD_UNLOCK_KEY = {
    key: "masterPasswordUnlockKey",
    stateDefinition: { name: "masterPasswordUnlock" },
};
const MASTER_KEY_ENCRYPTED_USER_KEY = {
    key: "masterKeyEncryptedUserKey",
    stateDefinition: { name: "masterPassword" },
};
const _73_add_master_password_unlock_data_KDF_CONFIG_DISK = {
    key: "kdfConfig",
    stateDefinition: { name: "kdfConfig" },
};
class AddMasterPasswordUnlockData extends (/* unused pure expression or super */ null && (_73_add_master_password_unlock_data_Migrator)) {
    migrate(helper) {
        return _73_add_master_password_unlock_data_awaiter(this, void 0, void 0, function* () {
            function migrateAccount(userId, account) {
                return _73_add_master_password_unlock_data_awaiter(this, void 0, void 0, function* () {
                    const email = account === null || account === void 0 ? void 0 : account.email;
                    const kdfConfig = yield helper.getFromUser(userId, _73_add_master_password_unlock_data_KDF_CONFIG_DISK);
                    const masterKeyEncryptedUserKey = yield helper.getFromUser(userId, MASTER_KEY_ENCRYPTED_USER_KEY);
                    if ((yield helper.getFromUser(userId, MASTER_PASSWORD_UNLOCK_KEY)) == null &&
                        email != null &&
                        kdfConfig != null &&
                        masterKeyEncryptedUserKey != null) {
                        yield helper.setToUser(userId, MASTER_PASSWORD_UNLOCK_KEY, {
                            salt: email.trim().toLowerCase(),
                            kdf: kdfConfig,
                            masterKeyWrappedUserKey: masterKeyEncryptedUserKey,
                        });
                    }
                });
            }
            const accountDictionary = yield helper.getFromGlobal(_73_add_master_password_unlock_data_ACCOUNT_ACCOUNTS);
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => migrateAccount(userId, accountDictionary[userId])));
        });
    }
    rollback(helper) {
        return _73_add_master_password_unlock_data_awaiter(this, void 0, void 0, function* () {
            function rollbackAccount(userId) {
                return _73_add_master_password_unlock_data_awaiter(this, void 0, void 0, function* () {
                    if ((yield helper.getFromUser(userId, MASTER_PASSWORD_UNLOCK_KEY)) != null) {
                        yield helper.removeFromUser(userId, MASTER_PASSWORD_UNLOCK_KEY);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => rollbackAccount(userId)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/74-remove-legacy-pin.ts
/* unused harmony import specifier */ var _74_remove_legacy_pin_Migrator;
/* unused harmony import specifier */ var _74_remove_legacy_pin_IRREVERSIBLE;
var _74_remove_legacy_pin_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const PinProtectedUserKey = {
    key: "pinKeyEncryptedUserKeyPersistent",
    stateDefinition: {
        name: "pinUnlock",
    },
};
class RemoveLegacyPin extends (/* unused pure expression or super */ null && (_74_remove_legacy_pin_Migrator)) {
    migrate(helper) {
        return _74_remove_legacy_pin_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            function migrateAccount(userId, account) {
                return _74_remove_legacy_pin_awaiter(this, void 0, void 0, function* () {
                    const pinProtectedUserKey = yield helper.getFromUser(userId, PinProtectedUserKey);
                    if (pinProtectedUserKey != null) {
                        yield helper.removeFromUser(userId, PinProtectedUserKey);
                    }
                });
            }
            yield Promise.all([...accounts.map(({ userId, account }) => migrateAccount(userId, account))]);
        });
    }
    rollback(helper) {
        return _74_remove_legacy_pin_awaiter(this, void 0, void 0, function* () {
            throw _74_remove_legacy_pin_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/75-remove-user-encrypted-private-key.ts
/* unused harmony import specifier */ var _75_remove_user_encrypted_private_key_Migrator;
/* unused harmony import specifier */ var _75_remove_user_encrypted_private_key_IRREVERSIBLE;
var _75_remove_user_encrypted_private_key_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const userEncryptedPrivateKey = {
    key: "privateKey",
    stateDefinition: {
        name: "crypto",
    },
};
const userKeyEncryptedSigningKey = {
    key: "userSigningKey",
    stateDefinition: {
        name: "crypto",
    },
};
const userSignedPublicKey = {
    key: "userSignedPublicKey",
    stateDefinition: {
        name: "crypto",
    },
};
const accountSecurityState = {
    key: "accountSecurityState",
    stateDefinition: {
        name: "crypto",
    },
};
const accountCryptographicState = {
    key: "accountCryptographicState",
    stateDefinition: {
        name: "crypto",
    },
};
class RemoveUserEncryptedPrivateKey extends (/* unused pure expression or super */ null && (_75_remove_user_encrypted_private_key_Migrator)) {
    migrate(helper) {
        return _75_remove_user_encrypted_private_key_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            for (const { userId } of accounts) {
                // Check if account cryptographic state already exists
                const existingAccountCryptoState = yield helper.getFromUser(userId, accountCryptographicState);
                // Gather all individual cryptographic key state parts
                const privateKey = yield helper.getFromUser(userId, userEncryptedPrivateKey);
                const signingKey = yield helper.getFromUser(userId, userKeyEncryptedSigningKey);
                const signedPubKey = yield helper.getFromUser(userId, userSignedPublicKey);
                const accountSecurity = yield helper.getFromUser(userId, accountSecurityState);
                // Only migrate if account cryptographic state does not exist
                if (!existingAccountCryptoState) {
                    // Build the new account cryptographic state object
                    let newAccountCryptographicState;
                    if (privateKey != null &&
                        signingKey == null &&
                        signedPubKey == null &&
                        accountSecurity == null) {
                        newAccountCryptographicState = { V1: { private_key: privateKey } };
                        yield helper.setToUser(userId, accountCryptographicState, newAccountCryptographicState);
                    }
                    else if (privateKey != null &&
                        signingKey != null &&
                        signedPubKey != null &&
                        accountSecurity != null) {
                        newAccountCryptographicState = {
                            V2: {
                                private_key: privateKey,
                                signing_key: signingKey,
                                signed_public_key: signedPubKey,
                                security_state: accountSecurity,
                            },
                        };
                        yield helper.setToUser(userId, accountCryptographicState, newAccountCryptographicState);
                    }
                    else {
                        helper.logService.warning(`Incomplete cryptographic state for user ${userId}, skipping migration of account cryptographic state.`);
                    }
                }
                // Always remove the old states
                if (privateKey != null) {
                    yield helper.removeFromUser(userId, userEncryptedPrivateKey);
                }
                if (signingKey != null) {
                    yield helper.removeFromUser(userId, userKeyEncryptedSigningKey);
                }
                if (signedPubKey != null) {
                    yield helper.removeFromUser(userId, userSignedPublicKey);
                }
                if (accountSecurity != null) {
                    yield helper.removeFromUser(userId, accountSecurityState);
                }
            }
        });
    }
    rollback(helper) {
        return _75_remove_user_encrypted_private_key_awaiter(this, void 0, void 0, function* () {
            throw _75_remove_user_encrypted_private_key_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/76-migrate-popup-width-options.ts
/* unused harmony import specifier */ var _76_migrate_popup_width_options_Migrator;
/* unused harmony import specifier */ var _76_migrate_popup_width_options_IRREVERSIBLE;
var _76_migrate_popup_width_options_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

/** Maps old popup width option keys to their new equivalents. */
const OLD_TO_NEW_WIDTH_MAP = {
    wide: "default",
    "extra-wide": "wide",
};
const POPUP_WIDTH_KEY = {
    key: "popup-width",
    stateDefinition: { name: "popupStyle" },
};
class MigratePopupWidthOptions extends (/* unused pure expression or super */ null && (_76_migrate_popup_width_options_Migrator)) {
    migrate(helper) {
        return _76_migrate_popup_width_options_awaiter(this, void 0, void 0, function* () {
            const currentWidth = yield helper.getFromGlobal(POPUP_WIDTH_KEY);
            if (currentWidth != null && currentWidth in OLD_TO_NEW_WIDTH_MAP) {
                yield helper.setToGlobal(POPUP_WIDTH_KEY, OLD_TO_NEW_WIDTH_MAP[currentWidth]);
            }
        });
    }
    rollback(helper) {
        return _76_migrate_popup_width_options_awaiter(this, void 0, void 0, function* () {
            throw _76_migrate_popup_width_options_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/77-clear-clipboard-delay-to-string.ts
/* unused harmony import specifier */ var _77_clear_clipboard_delay_to_string_Migrator;
var _77_clear_clipboard_delay_to_string_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

// Old integer values that might exist in user data
const OLD_CLEAR_CLIPBOARD_DELAY_VALUES = {
    NEVER: null,
    TEN_SECONDS: 10,
    TWENTY_SECONDS: 20,
    THIRTY_SECONDS: 30,
    ONE_MINUTE: 60,
    TWO_MINUTES: 120,
    FIVE_MINUTES: 300,
};
// New string values
const NEW_CLEAR_CLIPBOARD_DELAY_VALUES = {
    NEVER: "never",
    TEN_SECONDS: "tenSeconds",
    TWENTY_SECONDS: "twentySeconds",
    THIRTY_SECONDS: "thirtySeconds",
    ONE_MINUTE: "oneMinute",
    TWO_MINUTES: "twoMinutes",
    FIVE_MINUTES: "fiveMinutes",
};
const CLEAR_CLIPBOARD_DELAY_KEY = {
    stateDefinition: {
        name: "autofillSettingsLocal",
    },
    key: "clearClipboardDelay",
};
const HAD_PRE_MIGRATION_CLIPBOARD_VALUE_KEY = {
    stateDefinition: {
        name: "autofillSettingsLocal",
    },
    key: "hadPreMigrationClipboardValue",
};
class ClearClipboardDelayToStringMigrator extends (/* unused pure expression or super */ null && (_77_clear_clipboard_delay_to_string_Migrator)) {
    migrate(helper) {
        return _77_clear_clipboard_delay_to_string_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => this.migrateAccount(helper, userId)));
        });
    }
    migrateAccount(helper, userId) {
        return _77_clear_clipboard_delay_to_string_awaiter(this, void 0, void 0, function* () {
            const oldValue = yield helper.getFromUser(userId, CLEAR_CLIPBOARD_DELAY_KEY);
            // Skip if no value exists (will use default "fiveMinutes")
            if (oldValue === undefined) {
                return;
            }
            // Only set flag for users who had null (old "Never") before migration.
            // These users will be migrated to "fiveMinutes" (the new default),
            // so they should see a notification that the default has changed.
            if (oldValue === null) {
                yield helper.setToUser(userId, HAD_PRE_MIGRATION_CLIPBOARD_VALUE_KEY, true);
            }
            let newValue;
            // Convert old integer/null values to new string values
            switch (oldValue) {
                case null:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.FIVE_MINUTES;
                    break;
                case 10:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.TEN_SECONDS;
                    break;
                case 20:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.TWENTY_SECONDS;
                    break;
                case 30:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.THIRTY_SECONDS;
                    break;
                case 60:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.ONE_MINUTE;
                    break;
                case 120:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.TWO_MINUTES;
                    break;
                case 300:
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.FIVE_MINUTES;
                    break;
                default:
                    // For any unknown values, default to fiveMinutes
                    newValue = NEW_CLEAR_CLIPBOARD_DELAY_VALUES.FIVE_MINUTES;
                    break;
            }
            // Set the new string value
            yield helper.setToUser(userId, CLEAR_CLIPBOARD_DELAY_KEY, newValue);
        });
    }
    rollback(helper) {
        return _77_clear_clipboard_delay_to_string_awaiter(this, void 0, void 0, function* () {
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => this.rollbackAccount(helper, userId)));
        });
    }
    rollbackAccount(helper, userId) {
        return _77_clear_clipboard_delay_to_string_awaiter(this, void 0, void 0, function* () {
            // Remove the flag on rollback
            yield helper.setToUser(userId, HAD_PRE_MIGRATION_CLIPBOARD_VALUE_KEY, undefined);
            const newValue = yield helper.getFromUser(userId, CLEAR_CLIPBOARD_DELAY_KEY);
            // Skip if no value exists
            if (newValue === undefined) {
                return;
            }
            let oldValue;
            // Convert new string values back to old integer/null values
            switch (newValue) {
                case "never":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.NEVER;
                    break;
                case "tenSeconds":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.TEN_SECONDS;
                    break;
                case "twentySeconds":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.TWENTY_SECONDS;
                    break;
                case "thirtySeconds":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.THIRTY_SECONDS;
                    break;
                case "oneMinute":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.ONE_MINUTE;
                    break;
                case "twoMinutes":
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.TWO_MINUTES;
                    break;
                case "fiveMinutes":
                    // Potential data loss: both null (old "Never") and 300 (old "5 minutes") migrate to
                    // "fiveMinutes", so on rollback both become 300. Users who originally had null/"Never"
                    // will end up with 300/"5 minutes" instead — an acceptable trade-off for a rollback edge case.
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.FIVE_MINUTES;
                    break;
                default:
                    // Default fallback
                    oldValue = OLD_CLEAR_CLIPBOARD_DELAY_VALUES.NEVER;
                    break;
            }
            // Set the old integer/null value
            yield helper.setToUser(userId, CLEAR_CLIPBOARD_DELAY_KEY, oldValue);
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/78-migrate-sso-required-cache.ts
/* unused harmony import specifier */ var _78_migrate_sso_required_cache_Migrator;
/* unused harmony import specifier */ var _78_migrate_sso_required_cache_IRREVERSIBLE;
var _78_migrate_sso_required_cache_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const SSO_REQUIRED_CACHE_KEY = {
    key: "ssoRequiredCache",
    stateDefinition: { name: "ssoLoginLocal" },
};
/**
 * Migrates the `ssoRequiredCache` from the old `string[]` format (email-only) to `null`,
 * clearing stale entries that cannot be migrated since the environment (webVaultUrl) cannot
 * be inferred from an email alone. The cache will be repopulated with the new SsoRequiredCacheEntry[]
 * format on the user's next SSO login.
 */
class MigrateSsoRequiredCache extends (/* unused pure expression or super */ null && (_78_migrate_sso_required_cache_Migrator)) {
    migrate(helper) {
        return _78_migrate_sso_required_cache_awaiter(this, void 0, void 0, function* () {
            const cache = yield helper.getFromGlobal(SSO_REQUIRED_CACHE_KEY);
            if (cache == null || cache.length === 0) {
                return;
            }
            if (typeof cache[0] === "string") {
                yield helper.setToGlobal(SSO_REQUIRED_CACHE_KEY, null);
            }
        });
    }
    rollback(helper) {
        return _78_migrate_sso_required_cache_awaiter(this, void 0, void 0, function* () {
            throw _78_migrate_sso_required_cache_IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/79-initialize-feature-flag-overrides.ts
/* unused harmony import specifier */ var _79_initialize_feature_flag_overrides_Migrator;
var _79_initialize_feature_flag_overrides_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const FEATURE_FLAG_OVERRIDES_KEY = {
    key: "featureFlagOverrides",
    stateDefinition: { name: "config" },
};
/**
 * Initializes the global feature flag overrides state to an empty object when it has never
 * been set. The overrides are a record of flag name -> override value; an empty object means
 * "no overrides". Existing override maps are left unchanged.
 */
class InitializeFeatureFlagOverridesMigrator extends (/* unused pure expression or super */ null && (_79_initialize_feature_flag_overrides_Migrator)) {
    migrate(helper) {
        return _79_initialize_feature_flag_overrides_awaiter(this, void 0, void 0, function* () {
            const overrides = yield helper.getFromGlobal(FEATURE_FLAG_OVERRIDES_KEY);
            if (overrides == null || Object.keys(overrides).length === 0) {
                yield helper.setToGlobal(FEATURE_FLAG_OVERRIDES_KEY, {});
            }
        });
    }
    rollback() {
        return _79_initialize_feature_flag_overrides_awaiter(this, void 0, void 0, function* () {
            // No-op: an empty overrides object and an unset value are equivalent to every reader
            // (resolveFlag treats both as "no overrides"), and we cannot distinguish an override map
            // we initialized from one a user populated. Leaving the value as-is is safe.
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/8-move-state-version.ts
/* unused harmony import specifier */ var _8_move_state_version_Migrator;
var _8_move_state_version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class MoveStateVersionMigrator extends (/* unused pure expression or super */ null && (_8_move_state_version_Migrator)) {
    migrate(helper) {
        return _8_move_state_version_awaiter(this, void 0, void 0, function* () {
            const global = yield helper.get("global");
            if (global.stateVersion) {
                yield helper.set("stateVersion", global.stateVersion);
                delete global.stateVersion;
                yield helper.set("global", global);
            }
            else {
                throw new Error("Migration failed, state version not found");
            }
        });
    }
    rollback(helper) {
        return _8_move_state_version_awaiter(this, void 0, void 0, function* () {
            const version = yield helper.get("stateVersion");
            const global = yield helper.get("global");
            yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: version }));
            yield helper.set("stateVersion", undefined);
        });
    }
    // Override is necessary because default implementation assumes `stateVersion` at the root, but this migration moves
    // it from a `global` object to root.This makes for unique rollback versioning.
    updateVersion(helper, direction) {
        return _8_move_state_version_awaiter(this, void 0, void 0, function* () {
            const endVersion = direction === "up" ? this.toVersion : this.fromVersion;
            helper.currentVersion = endVersion;
            if (direction === "up") {
                yield helper.set("stateVersion", endVersion);
            }
            else {
                const global = (yield helper.get("global")) || {};
                yield helper.set("global", Object.assign(Object.assign({}, global), { stateVersion: endVersion }));
            }
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/80-consolidate-tray-to-run-in-background.ts
/* unused harmony import specifier */ var _80_consolidate_tray_to_run_in_background_Migrator;
/* unused harmony import specifier */ var _80_consolidate_tray_to_run_in_background_IRREVERSIBLE;
var _80_consolidate_tray_to_run_in_background_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE = { name: "desktopSettings" };
const _80_consolidate_tray_to_run_in_background_CLOSE_TO_TRAY_KEY = {
    key: "closeToTray",
    stateDefinition: _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE,
};
const RUN_IN_BACKGROUND_KEY = {
    key: "runInBackground",
    stateDefinition: _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE,
};
const _80_consolidate_tray_to_run_in_background_TRAY_ENABLED_KEY = {
    key: "trayEnabled",
    stateDefinition: _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE,
};
const _80_consolidate_tray_to_run_in_background_MINIMIZE_TO_TRAY_KEY = {
    key: "minimizeToTray",
    stateDefinition: _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE,
};
const _80_consolidate_tray_to_run_in_background_ALWAYS_SHOW_DOCK_KEY = {
    key: "alwaysShowDock",
    stateDefinition: _80_consolidate_tray_to_run_in_background_DESKTOP_SETTINGS_STATE,
};
/**
 * Consolidates the legacy `trayEnabled`, `minimizeToTray`, and `closeToTray` desktop settings
 * into a single "run in the background" setting, stored under the new `runInBackground` key.
 * `runInBackground = closeToTray || trayEnabled`. The now-unused `closeToTray`, `trayEnabled`,
 * `minimizeToTray`, and `alwaysShowDock` keys are removed.
 */
class ConsolidateTrayToRunInBackground extends (/* unused pure expression or super */ null && (_80_consolidate_tray_to_run_in_background_Migrator)) {
    migrate(helper) {
        return _80_consolidate_tray_to_run_in_background_awaiter(this, void 0, void 0, function* () {
            const closeToTray = yield helper.getFromGlobal(_80_consolidate_tray_to_run_in_background_CLOSE_TO_TRAY_KEY);
            const trayEnabled = yield helper.getFromGlobal(_80_consolidate_tray_to_run_in_background_TRAY_ENABLED_KEY);
            // Only write a consolidated value when at least one legacy value existed, so users who
            // never customized these keep falling through to the `!isDev()` default in the service.
            if (closeToTray != null || trayEnabled != null) {
                yield helper.setToGlobal(RUN_IN_BACKGROUND_KEY, Boolean(closeToTray) || Boolean(trayEnabled));
            }
            // Remove orphaned keys (guarded so absent keys aren't touched).
            if (closeToTray != null) {
                yield helper.removeFromGlobal(_80_consolidate_tray_to_run_in_background_CLOSE_TO_TRAY_KEY);
            }
            if (trayEnabled != null) {
                yield helper.removeFromGlobal(_80_consolidate_tray_to_run_in_background_TRAY_ENABLED_KEY);
            }
            if ((yield helper.getFromGlobal(_80_consolidate_tray_to_run_in_background_MINIMIZE_TO_TRAY_KEY)) != null) {
                yield helper.removeFromGlobal(_80_consolidate_tray_to_run_in_background_MINIMIZE_TO_TRAY_KEY);
            }
            if ((yield helper.getFromGlobal(_80_consolidate_tray_to_run_in_background_ALWAYS_SHOW_DOCK_KEY)) != null) {
                yield helper.removeFromGlobal(_80_consolidate_tray_to_run_in_background_ALWAYS_SHOW_DOCK_KEY);
            }
        });
    }
    rollback(helper) {
        throw _80_consolidate_tray_to_run_in_background_IRREVERSIBLE;
    }
}

;// ../../libs/state/src/state-migrations/migrations/81-enable-desktop-sharing-if-biometrics-enabled.ts
/* unused harmony import specifier */ var _81_enable_desktop_sharing_if_biometrics_enabled_Migrator;
var _81_enable_desktop_sharing_if_biometrics_enabled_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _81_enable_desktop_sharing_if_biometrics_enabled_BIOMETRIC_UNLOCK_ENABLED = {
    key: "biometricUnlockEnabled",
    stateDefinition: { name: "biometricSettings" },
};
const ALLOW_SHARING_UNLOCK_STATE_WITH_DESKTOP = {
    key: "allowSharingUnlockStateWithDesktop",
    stateDefinition: { name: "sharedUnlockSettings" },
};
/**
 * For each user that already has biometric unlock enabled, enables sharing unlock state
 * with the desktop app. Previously this setting defaulted to off even when biometrics were
 * configured, so existing users had to manually enable it.
 */
class EnableDesktopSharingIfBiometricsEnabled extends (/* unused pure expression or super */ null && (_81_enable_desktop_sharing_if_biometrics_enabled_Migrator)) {
    migrate(helper) {
        return _81_enable_desktop_sharing_if_biometrics_enabled_awaiter(this, void 0, void 0, function* () {
            function migrateUser(userId) {
                return _81_enable_desktop_sharing_if_biometrics_enabled_awaiter(this, void 0, void 0, function* () {
                    const biometricUnlock = yield helper.getFromUser(userId, _81_enable_desktop_sharing_if_biometrics_enabled_BIOMETRIC_UNLOCK_ENABLED);
                    if (biometricUnlock === true &&
                        (yield helper.getFromUser(userId, ALLOW_SHARING_UNLOCK_STATE_WITH_DESKTOP)) == null) {
                        yield helper.setToUser(userId, ALLOW_SHARING_UNLOCK_STATE_WITH_DESKTOP, true);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => migrateUser(userId)));
        });
    }
    rollback(helper) {
        return _81_enable_desktop_sharing_if_biometrics_enabled_awaiter(this, void 0, void 0, function* () {
            function rollbackUser(userId) {
                return _81_enable_desktop_sharing_if_biometrics_enabled_awaiter(this, void 0, void 0, function* () {
                    const biometricUnlock = yield helper.getFromUser(userId, _81_enable_desktop_sharing_if_biometrics_enabled_BIOMETRIC_UNLOCK_ENABLED);
                    if (biometricUnlock === true) {
                        yield helper.removeFromUser(userId, ALLOW_SHARING_UNLOCK_STATE_WITH_DESKTOP);
                    }
                });
            }
            const accounts = yield helper.getAccounts();
            yield Promise.all(accounts.map(({ userId }) => rollbackUser(userId)));
        });
    }
}

;// ../../libs/state/src/state-migrations/migrations/82-remove-browser-integration-enabled.ts
/* unused harmony import specifier */ var _82_remove_browser_integration_enabled_Migrator;
/* unused harmony import specifier */ var _82_remove_browser_integration_enabled_IRREVERSIBLE;
var _82_remove_browser_integration_enabled_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const _82_remove_browser_integration_enabled_DESKTOP_SETTINGS_STATE = { name: "desktopSettings" };
const BROWSER_INTEGRATION_ENABLED_KEY = {
    key: "browserIntegrationEnabled",
    stateDefinition: _82_remove_browser_integration_enabled_DESKTOP_SETTINGS_STATE,
};
/**
 * Removes the now-unused `browserIntegrationEnabled` desktop setting. Browser integration is always
 * enabled, so the persisted value is orphaned and is removed here.
 */
class RemoveBrowserIntegrationEnabled extends (/* unused pure expression or super */ null && (_82_remove_browser_integration_enabled_Migrator)) {
    migrate(helper) {
        return _82_remove_browser_integration_enabled_awaiter(this, void 0, void 0, function* () {
            if ((yield helper.getFromGlobal(BROWSER_INTEGRATION_ENABLED_KEY)) != null) {
                yield helper.removeFromGlobal(BROWSER_INTEGRATION_ENABLED_KEY);
            }
        });
    }
    rollback(helper) {
        throw _82_remove_browser_integration_enabled_IRREVERSIBLE;
    }
}

;// ../../libs/state/src/state-migrations/migrations/9-move-browser-settings-to-global.ts
/* unused harmony import specifier */ var _9_move_browser_settings_to_global_Migrator;
var _9_move_browser_settings_to_global_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class MoveBrowserSettingsToGlobal extends (/* unused pure expression or super */ null && (_9_move_browser_settings_to_global_Migrator)) {
    // Will first check if any of the accounts have a value from the given accountSelector
    // if they do have a value it will set that value into global state but if multiple
    // users have differing values it will prefer the false setting,
    // if all users have true then it will take true.
    tryAddSetting(accounts, accountSelector, globalSetter) {
        const hasValue = accounts.some(({ account }) => {
            return accountSelector(account) !== undefined;
        });
        if (hasValue) {
            const value = !accounts.some(({ account }) => {
                var _a;
                return ((_a = accountSelector(account)) !== null && _a !== void 0 ? _a : false) === false;
            });
            globalSetter(value);
        }
    }
    migrate(helper) {
        return _9_move_browser_settings_to_global_awaiter(this, void 0, void 0, function* () {
            const global = yield helper.get("global");
            const accounts = yield helper.getAccounts();
            const globalNeverDomainsValue = accounts.reduce((accumulator, { account }) => {
                var _a, _b;
                const normalizedNeverDomains = (_b = (_a = account.settings) === null || _a === void 0 ? void 0 : _a.neverDomains) !== null && _b !== void 0 ? _b : {};
                for (const [id, value] of Object.entries(normalizedNeverDomains)) {
                    accumulator !== null && accumulator !== void 0 ? accumulator : (accumulator = {});
                    accumulator[id] = value;
                }
                return accumulator;
            }, undefined);
            const targetGlobalState = {};
            if (globalNeverDomainsValue != null) {
                targetGlobalState.neverDomains = globalNeverDomainsValue;
            }
            this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableAddLoginNotification; }, (v) => (targetGlobalState.disableAddLoginNotification = v));
            this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableChangedPasswordNotification; }, (v) => (targetGlobalState.disableChangedPasswordNotification = v));
            this.tryAddSetting(accounts, (a) => { var _a; return (_a = a.settings) === null || _a === void 0 ? void 0 : _a.disableContextMenuItem; }, (v) => (targetGlobalState.disableContextMenuItem = v));
            yield helper.set("global", Object.assign(Object.assign({}, global), targetGlobalState));
            yield Promise.all(accounts.map((_a) => _9_move_browser_settings_to_global_awaiter(this, [_a], void 0, function* ({ userId, account }) {
                var _b, _c, _d, _e;
                (_b = account.settings) === null || _b === void 0 ? true : delete _b.disableAddLoginNotification;
                (_c = account.settings) === null || _c === void 0 ? true : delete _c.disableChangedPasswordNotification;
                (_d = account.settings) === null || _d === void 0 ? true : delete _d.disableContextMenuItem;
                (_e = account.settings) === null || _e === void 0 ? true : delete _e.neverDomains;
                yield helper.set(userId, account);
            })));
        });
    }
    rollback(helper) {
        throw new Error("Method not implemented.");
    }
}

;// ../../libs/state/src/state-migrations/migrations/min-version.ts
var min_version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


function minVersionError(current) {
    return `Your local data is too old to be migrated. Your current state version is ${current}, but minimum version is ${MIN_VERSION}.`;
}
class MinVersionMigrator extends Migrator {
    constructor() {
        super(0, MIN_VERSION);
    }
    // Overrides the default implementation to catch any version that may be passed in.
    shouldMigrate(helper) {
        return Promise.resolve(helper.currentVersion < MIN_VERSION);
    }
    migrate(helper) {
        return min_version_awaiter(this, void 0, void 0, function* () {
            if (helper.currentVersion < MIN_VERSION) {
                throw new Error(minVersionError(helper.currentVersion));
            }
        });
    }
    rollback(helper) {
        return min_version_awaiter(this, void 0, void 0, function* () {
            throw IRREVERSIBLE;
        });
    }
}

;// ../../libs/state/src/state-migrations/migrate.ts
/* unused harmony import specifier */ var migrate_MigrationBuilder;
/* unused harmony import specifier */ var migrate_EverHadUserKeyMigrator;
/* unused harmony import specifier */ var migrate_OrganizationKeyMigrator;
/* unused harmony import specifier */ var migrate_MoveEnvironmentStateToProviders;
/* unused harmony import specifier */ var migrate_ProviderKeyMigrator;
/* unused harmony import specifier */ var migrate_MoveBiometricClientKeyHalfToStateProviders;
/* unused harmony import specifier */ var migrate_FolderMigrator;
/* unused harmony import specifier */ var migrate_LastSyncMigrator;
/* unused harmony import specifier */ var migrate_EnablePasskeysMigrator;
/* unused harmony import specifier */ var migrate_AutofillSettingsKeyMigrator;
/* unused harmony import specifier */ var migrate_RequirePasswordOnStartMigrator;
/* unused harmony import specifier */ var migrate_PrivateKeyMigrator;
/* unused harmony import specifier */ var migrate_CollectionMigrator;
/* unused harmony import specifier */ var migrate_CollapsedGroupingsMigrator;
/* unused harmony import specifier */ var migrate_MoveBiometricPromptsToStateProviders;
/* unused harmony import specifier */ var migrate_SmOnboardingTasksMigrator;
/* unused harmony import specifier */ var migrate_ClearClipboardDelayMigrator;
/* unused harmony import specifier */ var migrate_RevertLastSyncMigrator;
/* unused harmony import specifier */ var migrate_BadgeSettingsMigrator;
/* unused harmony import specifier */ var migrate_MoveBiometricUnlockToStateProviders;
/* unused harmony import specifier */ var migrate_UserNotificationSettingsKeyMigrator;
/* unused harmony import specifier */ var migrate_PolicyMigrator;
/* unused harmony import specifier */ var migrate_EnableContextMenuMigrator;
/* unused harmony import specifier */ var migrate_PreferredLanguageMigrator;
/* unused harmony import specifier */ var migrate_AppIdMigrator;
/* unused harmony import specifier */ var migrate_DomainSettingsMigrator;
/* unused harmony import specifier */ var migrate_MoveThemeToStateProviderMigrator;
/* unused harmony import specifier */ var migrate_VaultSettingsKeyMigrator;
/* unused harmony import specifier */ var migrate_AvatarColorMigrator;
/* unused harmony import specifier */ var migrate_TokenServiceStateProviderMigrator;
/* unused harmony import specifier */ var migrate_MoveBillingAccountProfileMigrator;
/* unused harmony import specifier */ var migrate_RemoveEverBeenUnlockedMigrator;
/* unused harmony import specifier */ var migrate_OrganizationMigrator;
/* unused harmony import specifier */ var migrate_EventCollectionMigrator;
/* unused harmony import specifier */ var migrate_EnableFaviconMigrator;
/* unused harmony import specifier */ var migrate_AutoConfirmFingerPrintsMigrator;
/* unused harmony import specifier */ var migrate_UserDecryptionOptionsMigrator;
/* unused harmony import specifier */ var migrate_MergeEnvironmentState;
/* unused harmony import specifier */ var migrate_DeleteBiometricPromptCancelledData;
/* unused harmony import specifier */ var migrate_MoveDesktopSettingsMigrator;
/* unused harmony import specifier */ var migrate_MoveDdgToStateProviderMigrator;
/* unused harmony import specifier */ var migrate_AccountServerConfigMigrator;
/* unused harmony import specifier */ var migrate_AddKeyTypeToOrgKeysMigrator;
/* unused harmony import specifier */ var migrate_KeyConnectorMigrator;
/* unused harmony import specifier */ var migrate_RememberedEmailMigrator;
/* unused harmony import specifier */ var migrate_DeleteInstalledVersion;
/* unused harmony import specifier */ var migrate_DeviceTrustServiceStateProviderMigrator;
/* unused harmony import specifier */ var migrate_SendMigrator;
/* unused harmony import specifier */ var migrate_MoveMasterKeyStateToProviderMigrator;
/* unused harmony import specifier */ var migrate_AuthRequestMigrator;
/* unused harmony import specifier */ var migrate_CipherServiceMigrator;
/* unused harmony import specifier */ var migrate_RemoveRefreshTokenMigratedFlagMigrator;
/* unused harmony import specifier */ var migrate_KdfConfigMigrator;
/* unused harmony import specifier */ var migrate_RemoveLegacyEtmKeyMigrator;
/* unused harmony import specifier */ var migrate_KnownAccountsMigrator;
/* unused harmony import specifier */ var migrate_PinStateMigrator;
/* unused harmony import specifier */ var migrate_VaultTimeoutSettingsServiceStateProviderMigrator;
/* unused harmony import specifier */ var migrate_PasswordOptionsMigrator;
/* unused harmony import specifier */ var migrate_GeneratorHistoryMigrator;
/* unused harmony import specifier */ var migrate_ForwarderOptionsMigrator;
/* unused harmony import specifier */ var migrate_MoveFinalDesktopSettingsMigrator;
/* unused harmony import specifier */ var migrate_RemoveUnassignedItemsBannerDismissed;
/* unused harmony import specifier */ var migrate_MoveLastSyncDate;
/* unused harmony import specifier */ var migrate_MigrateIncorrectFolderKey;
/* unused harmony import specifier */ var migrate_MoveBiometricAutoPromptToAccount;
/* unused harmony import specifier */ var migrate_RemoveAcBannersDismissed;
/* unused harmony import specifier */ var migrate_RemoveNewCustomizationOptionsCalloutDismissed;
/* unused harmony import specifier */ var migrate_RemoveAccountDeprovisioningBannerDismissed;
/* unused harmony import specifier */ var migrate_AddMasterPasswordUnlockData;
/* unused harmony import specifier */ var migrate_RemoveLegacyPin;
/* unused harmony import specifier */ var migrate_RemoveUserEncryptedPrivateKey;
/* unused harmony import specifier */ var migrate_MigratePopupWidthOptions;
/* unused harmony import specifier */ var migrate_ClearClipboardDelayToStringMigrator;
/* unused harmony import specifier */ var migrate_MigrateSsoRequiredCache;
/* unused harmony import specifier */ var migrate_InitializeFeatureFlagOverridesMigrator;
/* unused harmony import specifier */ var migrate_MoveStateVersionMigrator;
/* unused harmony import specifier */ var migrate_ConsolidateTrayToRunInBackground;
/* unused harmony import specifier */ var migrate_EnableDesktopSharingIfBiometricsEnabled;
/* unused harmony import specifier */ var migrate_RemoveBrowserIntegrationEnabled;
/* unused harmony import specifier */ var migrate_MoveBrowserSettingsToGlobal;
/* unused harmony import specifier */ var migrate_MinVersionMigrator;
var migrate_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

















































































const MIN_VERSION = 3;
const CURRENT_VERSION = 82;
function createMigrationBuilder() {
    return migrate_MigrationBuilder.create()
        .with(migrate_MinVersionMigrator)
        .with(migrate_RemoveEverBeenUnlockedMigrator, 3, 4)
        .with(migrate_AddKeyTypeToOrgKeysMigrator, 4, 5)
        .with(migrate_RemoveLegacyEtmKeyMigrator, 5, 6)
        .with(migrate_MoveBiometricAutoPromptToAccount, 6, 7)
        .with(migrate_MoveStateVersionMigrator, 7, 8)
        .with(migrate_MoveBrowserSettingsToGlobal, 8, 9)
        .with(migrate_EverHadUserKeyMigrator, 9, 10)
        .with(migrate_OrganizationKeyMigrator, 10, 11)
        .with(migrate_MoveEnvironmentStateToProviders, 11, 12)
        .with(migrate_ProviderKeyMigrator, 12, 13)
        .with(migrate_MoveBiometricClientKeyHalfToStateProviders, 13, 14)
        .with(migrate_FolderMigrator, 14, 15)
        .with(migrate_LastSyncMigrator, 15, 16)
        .with(migrate_EnablePasskeysMigrator, 16, 17)
        .with(migrate_AutofillSettingsKeyMigrator, 17, 18)
        .with(migrate_RequirePasswordOnStartMigrator, 18, 19)
        .with(migrate_PrivateKeyMigrator, 19, 20)
        .with(migrate_CollectionMigrator, 20, 21)
        .with(migrate_CollapsedGroupingsMigrator, 21, 22)
        .with(migrate_MoveBiometricPromptsToStateProviders, 22, 23)
        .with(migrate_SmOnboardingTasksMigrator, 23, 24)
        .with(migrate_ClearClipboardDelayMigrator, 24, 25)
        .with(migrate_RevertLastSyncMigrator, 25, 26)
        .with(migrate_BadgeSettingsMigrator, 26, 27)
        .with(migrate_MoveBiometricUnlockToStateProviders, 27, 28)
        .with(migrate_UserNotificationSettingsKeyMigrator, 28, 29)
        .with(migrate_PolicyMigrator, 29, 30)
        .with(migrate_EnableContextMenuMigrator, 30, 31)
        .with(migrate_PreferredLanguageMigrator, 31, 32)
        .with(migrate_AppIdMigrator, 32, 33)
        .with(migrate_DomainSettingsMigrator, 33, 34)
        .with(migrate_MoveThemeToStateProviderMigrator, 34, 35)
        .with(migrate_VaultSettingsKeyMigrator, 35, 36)
        .with(migrate_AvatarColorMigrator, 36, 37)
        .with(migrate_TokenServiceStateProviderMigrator, 37, 38)
        .with(migrate_MoveBillingAccountProfileMigrator, 38, 39)
        .with(migrate_OrganizationMigrator, 39, 40)
        .with(migrate_EventCollectionMigrator, 40, 41)
        .with(migrate_EnableFaviconMigrator, 41, 42)
        .with(migrate_AutoConfirmFingerPrintsMigrator, 42, 43)
        .with(migrate_UserDecryptionOptionsMigrator, 43, 44)
        .with(migrate_MergeEnvironmentState, 44, 45)
        .with(migrate_DeleteBiometricPromptCancelledData, 45, 46)
        .with(migrate_MoveDesktopSettingsMigrator, 46, 47)
        .with(migrate_MoveDdgToStateProviderMigrator, 47, 48)
        .with(migrate_AccountServerConfigMigrator, 48, 49)
        .with(migrate_KeyConnectorMigrator, 49, 50)
        .with(migrate_RememberedEmailMigrator, 50, 51)
        .with(migrate_DeleteInstalledVersion, 51, 52)
        .with(migrate_DeviceTrustServiceStateProviderMigrator, 52, 53)
        .with(migrate_SendMigrator, 53, 54)
        .with(migrate_MoveMasterKeyStateToProviderMigrator, 54, 55)
        .with(migrate_AuthRequestMigrator, 55, 56)
        .with(migrate_CipherServiceMigrator, 56, 57)
        .with(migrate_RemoveRefreshTokenMigratedFlagMigrator, 57, 58)
        .with(migrate_KdfConfigMigrator, 58, 59)
        .with(migrate_KnownAccountsMigrator, 59, 60)
        .with(migrate_PinStateMigrator, 60, 61)
        .with(migrate_VaultTimeoutSettingsServiceStateProviderMigrator, 61, 62)
        .with(migrate_PasswordOptionsMigrator, 62, 63)
        .with(migrate_GeneratorHistoryMigrator, 63, 64)
        .with(migrate_ForwarderOptionsMigrator, 64, 65)
        .with(migrate_MoveFinalDesktopSettingsMigrator, 65, 66)
        .with(migrate_RemoveUnassignedItemsBannerDismissed, 66, 67)
        .with(migrate_MoveLastSyncDate, 67, 68)
        .with(migrate_MigrateIncorrectFolderKey, 68, 69)
        .with(migrate_RemoveAcBannersDismissed, 69, 70)
        .with(migrate_RemoveNewCustomizationOptionsCalloutDismissed, 70, 71)
        .with(migrate_RemoveAccountDeprovisioningBannerDismissed, 71, 72)
        .with(migrate_AddMasterPasswordUnlockData, 72, 73)
        .with(migrate_RemoveLegacyPin, 73, 74)
        .with(migrate_RemoveUserEncryptedPrivateKey, 74, 75)
        .with(migrate_MigratePopupWidthOptions, 75, 76)
        .with(migrate_ClearClipboardDelayToStringMigrator, 76, 77)
        .with(migrate_MigrateSsoRequiredCache, 77, 78)
        .with(migrate_InitializeFeatureFlagOverridesMigrator, 78, 79)
        .with(migrate_ConsolidateTrayToRunInBackground, 79, 80)
        .with(migrate_EnableDesktopSharingIfBiometricsEnabled, 80, 81)
        .with(migrate_RemoveBrowserIntegrationEnabled, 81, CURRENT_VERSION);
}
function currentVersion(storageService, logService) {
    return migrate_awaiter(this, void 0, void 0, function* () {
        var _a;
        let state = yield storageService.get("stateVersion");
        if (state == null) {
            // Pre v8
            state = (_a = (yield storageService.get("global"))) === null || _a === void 0 ? void 0 : _a.stateVersion;
        }
        if (state == null) {
            logService.info("No state version found, assuming empty state.");
            return -1;
        }
        logService.info(`State version: ${state}`);
        return state;
    });
}
/**
 * Waits for migrations to have a chance to run and will resolve the promise once they are.
 *
 * @param storageService Disk storage where the `stateVersion` will or is already saved in.
 * @param logService Log service
 */
function waitForMigrations(storageService, logService) {
    return migrate_awaiter(this, void 0, void 0, function* () {
        const isReady = () => migrate_awaiter(this, void 0, void 0, function* () {
            const version = yield currentVersion(storageService, logService);
            // The saved version is what we consider the latest
            // migrations should be complete, the state version
            // shouldn't become larger than `CURRENT_VERSION` in
            // any normal usage of the application but it is common
            // enough in dev scenarios where we want to consider that
            // ready as well and return true in that scenario.
            return version >= CURRENT_VERSION;
        });
        const wait = (time) => migrate_awaiter(this, void 0, void 0, function* () {
            // Wait exponentially
            const nextTime = time * 2;
            if (nextTime > 8192) {
                // Don't wait longer than ~8 seconds in a single wait,
                // if the migrations still haven't happened. They aren't
                // likely to.
                return;
            }
            return new Promise((resolve) => {
                setTimeout(() => migrate_awaiter(this, void 0, void 0, function* () {
                    if (!(yield isReady())) {
                        logService.info(`Waiting for migrations to finish, waiting for ${nextTime}ms`);
                        yield wait(nextTime);
                    }
                    resolve();
                }), time);
            });
        });
        if (!(yield isReady())) {
            // Wait for 2ms to start with
            yield wait(2);
        }
    });
}

;// ../../libs/state/src/state-migrations/migration-helper.ts
var migration_helper_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
class MigrationHelper {
    constructor(currentVersion, storageService, logService, type, clientType) {
        this.currentVersion = currentVersion;
        this.storageService = storageService;
        this.logService = logService;
        this.clientType = clientType;
        this.type = type;
    }
    /**
     * Gets a value from the storage service at the given key.
     *
     * This is a brute force method to just get a value from the storage service. If you can use {@link getFromGlobal} or {@link getFromUser}, you should.
     * @param key location
     * @returns the value at the location
     */
    get(key) {
        return this.storageService.get(key);
    }
    /**
     * Sets a value in the storage service at the given key.
     *
     * This is a brute force method to just set a value in the storage service. If you can use {@link setToGlobal} or {@link setToUser}, you should.
     * @param key location
     * @param value the value to set
     * @returns
     */
    set(key, value) {
        this.logService.info(`Setting ${key}`);
        return this.storageService.save(key, value);
    }
    /**
     * Remove a value in the storage service at the given key.
     *
     * This is a brute force method to just remove a value in the storage service. If you can use {@link removeFromGlobal} or {@link removeFromUser}, you should.
     * @param key location
     * @returns void
     */
    remove(key) {
        this.logService.info(`Removing ${key}`);
        return this.storageService.remove(key);
    }
    /**
     * Gets a globally scoped value from a location derived through the key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link get} for those.
     * @param keyDefinition unique key definition
     * @returns value from store
     */
    getFromGlobal(keyDefinition) {
        return this.get(this.getGlobalKey(keyDefinition));
    }
    /**
     * Sets a globally scoped value to a location derived through the key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link set} for those.
     * @param keyDefinition unique key definition
     * @param value value to store
     * @returns void
     */
    setToGlobal(keyDefinition, value) {
        return this.set(this.getGlobalKey(keyDefinition), value);
    }
    /**
     * Remove a globally scoped location derived through the key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link remove} for those.
     * @param keyDefinition unique key definition
     * @returns void
     */
    removeFromGlobal(keyDefinition) {
        return this.remove(this.getGlobalKey(keyDefinition));
    }
    /**
     * Gets a user scoped value from a location derived through the user id and key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link get} for those.
     * @param userId userId to use in the key
     * @param keyDefinition unique key definition
     * @returns value from store
     */
    getFromUser(userId, keyDefinition) {
        return this.get(this.getUserKey(userId, keyDefinition));
    }
    /**
     * Sets a user scoped value to a location derived through the user id and key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link set} for those.
     * @param userId userId to use in the key
     * @param keyDefinition unique key definition
     * @param value value to store
     * @returns void
     */
    setToUser(userId, keyDefinition, value) {
        return this.set(this.getUserKey(userId, keyDefinition), value);
    }
    /**
     * Remove a user scoped location derived through the key definition
     *
     * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService},
     * use {@link remove} for those.
     * @param keyDefinition unique key definition
     * @returns void
     */
    removeFromUser(userId, keyDefinition) {
        return this.remove(this.getUserKey(userId, keyDefinition));
    }
    info(message) {
        this.logService.info(message);
    }
    /**
     * Helper method to read all Account objects stored by the State Service.
     *
     * This is useful from creating migrations off of this paradigm, but should not be used once a value is migrated to a state provider.
     *
     * @returns a list of all accounts that have been authenticated with state service, cast the expected type.
     */
    getAccounts() {
        return migration_helper_awaiter(this, void 0, void 0, function* () {
            const userIds = yield this.getKnownUserIds();
            return Promise.all(userIds.map((userId) => migration_helper_awaiter(this, void 0, void 0, function* () {
                return ({
                    userId,
                    account: yield this.get(userId),
                });
            })));
        });
    }
    /**
     * Helper method to read known users ids.
     */
    getKnownUserIds() {
        return migration_helper_awaiter(this, void 0, void 0, function* () {
            if (this.currentVersion < 60) {
                return knownAccountUserIdsBuilderPre60(this.storageService);
            }
            else {
                return knownAccountUserIdsBuilder(this.storageService);
            }
        });
    }
    /**
     * Builds a user storage key appropriate for the current version.
     *
     * @param userId userId to use in the key
     * @param keyDefinition state and key to use in the key
     * @returns
     */
    getUserKey(userId, keyDefinition) {
        if (this.currentVersion < 9) {
            return userKeyBuilderPre9();
        }
        else {
            return userKeyBuilder(userId, keyDefinition);
        }
    }
    /**
     * Builds a global storage key appropriate for the current version.
     *
     * @param keyDefinition state and key to use in the key
     * @returns
     */
    getGlobalKey(keyDefinition) {
        if (this.currentVersion < 9) {
            return globalKeyBuilderPre9();
        }
        else {
            return globalKeyBuilder(keyDefinition);
        }
    }
}
/**
 * When this is updated, rename this function to `userKeyBuilderXToY` where `X` is the version number it
 * became relevant, and `Y` prior to the version it was updated.
 *
 * Be sure to update the map in `MigrationHelper` to point to the appropriate function for the current version.
 * @param userId The userId of the user you want the key to be for.
 * @param keyDefinition the key definition of which data the key should point to.
 * @returns
 */
function userKeyBuilder(userId, keyDefinition) {
    return `user_${userId}_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
}
function userKeyBuilderPre9() {
    throw Error("No key builder should be used for versions prior to 9.");
}
/**
 * When this is updated, rename this function to `globalKeyBuilderXToY` where `X` is the version number
 * it became relevant, and `Y` prior to the version it was updated.
 *
 * Be sure to update the map in `MigrationHelper` to point to the appropriate function for the current version.
 * @param keyDefinition the key definition of which data the key should point to.
 * @returns
 */
function globalKeyBuilder(keyDefinition) {
    return `global_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
}
function globalKeyBuilderPre9() {
    throw Error("No key builder should be used for versions prior to 9.");
}
function knownAccountUserIdsBuilderPre60(storageService) {
    return migration_helper_awaiter(this, void 0, void 0, function* () {
        var _a;
        return (_a = (yield storageService.get("authenticatedAccounts"))) !== null && _a !== void 0 ? _a : [];
    });
}
function knownAccountUserIdsBuilder(storageService) {
    return migration_helper_awaiter(this, void 0, void 0, function* () {
        const accounts = yield storageService.get(globalKeyBuilder({ stateDefinition: { name: "account" }, key: "accounts" }));
        return Object.keys(accounts !== null && accounts !== void 0 ? accounts : {});
    });
}

;// ../../libs/state/src/state-migrations/index.ts





;// ../../libs/state/src/index.ts
// Root barrel for @bitwarden/state





;// ../../libs/state-internal/src/default-active-user-state.ts
/* unused harmony import specifier */ var default_active_user_state_firstValueFrom;
/* unused harmony import specifier */ var throwError;
/* unused harmony import specifier */ var NEVER;
/* unused harmony import specifier */ var default_active_user_state_map;
/* unused harmony import specifier */ var default_active_user_state_switchMap;
/* unused harmony import specifier */ var timeout;
var default_active_user_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


class DefaultActiveUserState {
    constructor(keyDefinition, activeUserId$, singleUserStateProvider) {
        this.keyDefinition = keyDefinition;
        this.activeUserId$ = activeUserId$;
        this.singleUserStateProvider = singleUserStateProvider;
        this.combinedState$ = this.activeUserId$.pipe(default_active_user_state_switchMap((userId) => userId != null
            ? this.singleUserStateProvider.get(userId, this.keyDefinition).combinedState$
            : NEVER));
        // State should just be combined state without the user id
        this.state$ = this.combinedState$.pipe(default_active_user_state_map(([_userId, state]) => state));
    }
    update(configureState_1) {
        return default_active_user_state_awaiter(this, arguments, void 0, function* (configureState, options = {}) {
            const userId = yield default_active_user_state_firstValueFrom(this.activeUserId$.pipe(timeout({
                first: 1000,
                with: () => throwError(() => new Error(`Timeout while retrieving active user for key ${this.keyDefinition.fullName}.`)),
            })));
            if (userId == null) {
                throw new Error(`Error storing ${this.keyDefinition.fullName} for the active user: No active user at this time.`);
            }
            return [
                userId,
                yield this.singleUserStateProvider
                    .get(userId, this.keyDefinition)
                    .update(configureState, options),
            ];
        });
    }
}

;// ../../libs/state-internal/src/default-active-user-state.provider.ts
/* unused harmony import specifier */ var distinctUntilChanged;
/* unused harmony import specifier */ var default_active_user_state_provider_DefaultActiveUserState;
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


class DefaultActiveUserStateProvider {
    constructor(activeAccountAccessor, singleUserStateProvider) {
        this.activeAccountAccessor = activeAccountAccessor;
        this.singleUserStateProvider = singleUserStateProvider;
        this.activeUserId$ = this.activeAccountAccessor.activeUserId$.pipe(
        // To avoid going to storage when we don't need to, only get updates when there is a true change.
        distinctUntilChanged((a, b) => (a == null || b == null ? a == b : a === b)));
    }
    get(keyDefinition) {
        // All other providers cache the creation of their corresponding `State` objects, this instance
        // doesn't need to do that since it calls `SingleUserStateProvider` it will go through their caching
        // layer, because of that, the creation of this instance is quite simple and not worth caching.
        return new default_active_user_state_provider_DefaultActiveUserState(keyDefinition, this.activeUserId$, this.singleUserStateProvider);
    }
}

;// ../../libs/state-internal/src/default-derived-state.ts
/* unused harmony import specifier */ var default_derived_state_Subject;
/* unused harmony import specifier */ var default_derived_state_ReplaySubject;
/* unused harmony import specifier */ var default_derived_state_merge;
/* unused harmony import specifier */ var default_derived_state_timer;
/* unused harmony import specifier */ var concatMap;
/* unused harmony import specifier */ var default_derived_state_share;
var default_derived_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

/**
 * Default derived state
 */
class DefaultDerivedState {
    constructor(parentState$, deriveDefinition, dependencies) {
        this.parentState$ = parentState$;
        this.deriveDefinition = deriveDefinition;
        this.dependencies = dependencies;
        this.forcedValueSubject = new default_derived_state_Subject();
        this.storageKey = deriveDefinition.storageKey;
        const derivedState$ = this.parentState$.pipe(concatMap((state) => default_derived_state_awaiter(this, void 0, void 0, function* () {
            let derivedStateOrPromise = this.deriveDefinition.derive(state, this.dependencies);
            if (derivedStateOrPromise instanceof Promise) {
                derivedStateOrPromise = yield derivedStateOrPromise;
            }
            const derivedState = derivedStateOrPromise;
            return derivedState;
        })));
        this.state$ = default_derived_state_merge(this.forcedValueSubject, derivedState$).pipe(default_derived_state_share({
            connector: () => {
                return new default_derived_state_ReplaySubject(1);
            },
            resetOnRefCountZero: () => default_derived_state_timer(this.deriveDefinition.cleanupDelayMs),
        }));
    }
    forceValue(value) {
        return default_derived_state_awaiter(this, void 0, void 0, function* () {
            this.forcedValueSubject.next(value);
            return value;
        });
    }
}

;// ../../libs/state-internal/src/default-derived-state.provider.ts
/* unused harmony import specifier */ var default_derived_state_provider_DefaultDerivedState;

class DefaultDerivedStateProvider {
    constructor() {
        /**
         * The cache uses a WeakMap to maintain separate derived states per user.
         * Each user's state Observable acts as a unique key, without needing to
         * pass around `userId`. Also, when a user's state Observable is cleaned up
         * (like during an account swap) their cache is automatically garbage
         * collected.
         */
        this.cache = new WeakMap();
    }
    get(parentState$, deriveDefinition, dependencies) {
        let stateCache = this.cache.get(parentState$);
        if (!stateCache) {
            stateCache = {};
            this.cache.set(parentState$, stateCache);
        }
        const cacheKey = deriveDefinition.buildCacheKey();
        const existingDerivedState = stateCache[cacheKey];
        if (existingDerivedState != null) {
            // I have to cast out of the unknown generic but this should be safe if rules
            // around domain token are made
            return existingDerivedState;
        }
        const newDerivedState = this.buildDerivedState(parentState$, deriveDefinition, dependencies);
        stateCache[cacheKey] = newDerivedState;
        return newDerivedState;
    }
    buildDerivedState(parentState$, deriveDefinition, dependencies) {
        return new default_derived_state_provider_DefaultDerivedState(parentState$, deriveDefinition, dependencies);
    }
}

;// ../../node_modules/rxjs/dist/esm5/internal/observable/defer.js
function defer(observableFactory){return new Observable(function(subscriber){innerFrom(observableFactory()).subscribe(subscriber);});}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/tap.js
function tap(observerOrNext,error,complete){var tapObserver=isFunction(observerOrNext)||error||complete?{next:observerOrNext,error:error,complete:complete}:observerOrNext;return tapObserver?operate(function(source,subscriber){var _a;(_a=tapObserver.subscribe)===null||_a===void 0?void 0:_a.call(tapObserver);var isUnsub=true;source.subscribe(createOperatorSubscriber(subscriber,function(value){var _a;(_a=tapObserver.next)===null||_a===void 0?void 0:_a.call(tapObserver,value);subscriber.next(value);},function(){var _a;isUnsub=false;(_a=tapObserver.complete)===null||_a===void 0?void 0:_a.call(tapObserver);subscriber.complete();},function(err){var _a;isUnsub=false;(_a=tapObserver.error)===null||_a===void 0?void 0:_a.call(tapObserver,err);subscriber.error(err);},function(){var _a,_b;if(isUnsub){(_a=tapObserver.unsubscribe)===null||_a===void 0?void 0:_a.call(tapObserver);}(_b=tapObserver.finalize)===null||_b===void 0?void 0:_b.call(tapObserver);}));}):identity;}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/timeout.js
var TimeoutError=createErrorClass(function(_super){return function TimeoutErrorImpl(info){if(info===void 0){info=null;}_super(this);this.message='Timeout has occurred';this.name='TimeoutError';this.info=info;};});function timeout_timeout(config,schedulerArg){var _a=isValidDate(config)?{first:config}:typeof config==='number'?{each:config}:config,first=_a.first,each=_a.each,_b=_a.with,_with=_b===void 0?timeoutErrorFactory:_b,_c=_a.scheduler,scheduler=_c===void 0?schedulerArg!==null&&schedulerArg!==void 0?schedulerArg:async_asyncScheduler:_c,_d=_a.meta,meta=_d===void 0?null:_d;if(first==null&&each==null){throw new TypeError('No timeout provided.');}return operate(function(source,subscriber){var originalSourceSubscription;var timerSubscription;var lastValue=null;var seen=0;var startTimer=function(delay){timerSubscription=executeSchedule(subscriber,scheduler,function(){try{originalSourceSubscription.unsubscribe();innerFrom(_with({meta:meta,lastValue:lastValue,seen:seen})).subscribe(subscriber);}catch(err){subscriber.error(err);}},delay);};originalSourceSubscription=source.subscribe(createOperatorSubscriber(subscriber,function(value){timerSubscription===null||timerSubscription===void 0?void 0:timerSubscription.unsubscribe();seen++;subscriber.next(lastValue=value);each>0&&startTimer(each);},undefined,undefined,function(){if(!(timerSubscription===null||timerSubscription===void 0?void 0:timerSubscription.closed)){timerSubscription===null||timerSubscription===void 0?void 0:timerSubscription.unsubscribe();}lastValue=null;}));!seen&&startTimer(first!=null?typeof first==='number'?first:+first-scheduler.now():each);});}function timeoutErrorFactory(info){throw new TimeoutError(info);}
;// ../../libs/state-internal/src/util.ts
var util_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
function getStoredValue(key, storage, deserializer) {
    return util_awaiter(this, void 0, void 0, function* () {
        if (storage.valuesRequireDeserialization) {
            const jsonValue = yield storage.get(key);
            return deserializer(jsonValue);
        }
        else {
            const value = yield storage.get(key);
            return value !== null && value !== void 0 ? value : null;
        }
    });
}
/**
 * Creates a {@link StorageKey}
 * @param keyDefinition The key definition of which data the key should point to.
 * @returns A key that is ready to be used in a storage service to get data.
 */
function util_globalKeyBuilder(keyDefinition) {
    return `global_${keyDefinition.stateDefinition.name}_${keyDefinition.key}`;
}
function populateOptionsWithDefault(options) {
    const { combineLatestWith = null, shouldUpdate = () => true, msTimeout = 1000 } = options;
    return {
        combineLatestWith: combineLatestWith,
        shouldUpdate: shouldUpdate,
        msTimeout: msTimeout,
    };
}

;// ../../libs/state-internal/src/state-base.ts
var state_base_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


class StateBase {
    constructor(key, storageService, keyDefinition, logService) {
        this.key = key;
        this.storageService = storageService;
        this.keyDefinition = keyDefinition;
        this.logService = logService;
        const storageUpdate$ = storageService.updates$.pipe(filter((storageUpdate) => storageUpdate.key === key), switchMap((storageUpdate) => state_base_awaiter(this, void 0, void 0, function* () {
            if (storageUpdate.updateType === "remove") {
                return null;
            }
            return yield getStoredValue(key, storageService, keyDefinition.deserializer);
        })));
        let state$ = merge(defer(() => getStoredValue(key, storageService, keyDefinition.deserializer)), storageUpdate$);
        if (keyDefinition.debug.enableRetrievalLogging) {
            state$ = state$.pipe(tap({
                next: (v) => {
                    this.logService.info(`Retrieving '${key}' from storage, value is ${v == null ? "null" : "non-null"}`);
                },
            }));
        }
        // If 0 cleanup is chosen, treat this as absolutely no cache
        if (keyDefinition.cleanupDelayMs !== 0) {
            state$ = state$.pipe(share({
                connector: () => new ReplaySubject(1),
                resetOnRefCountZero: () => timer(keyDefinition.cleanupDelayMs),
            }));
        }
        this.state$ = state$;
    }
    update(configureState_1) {
        return state_base_awaiter(this, arguments, void 0, function* (configureState, options = {}) {
            const normalizedOptions = populateOptionsWithDefault(options);
            if (this.updatePromise != null) {
                yield this.updatePromise;
            }
            try {
                this.updatePromise = this.internalUpdate(configureState, normalizedOptions);
                return yield this.updatePromise;
            }
            finally {
                this.updatePromise = null;
            }
        });
    }
    internalUpdate(configureState, options) {
        return state_base_awaiter(this, void 0, void 0, function* () {
            const currentState = yield this.getStateForUpdate();
            const combinedDependencies = options.combineLatestWith != null
                ? yield firstValueFrom(options.combineLatestWith.pipe(timeout_timeout(options.msTimeout)))
                : null;
            if (!options.shouldUpdate(currentState, combinedDependencies)) {
                return currentState;
            }
            const newState = configureState(currentState, combinedDependencies);
            yield this.doStorageSave(newState, currentState);
            return newState;
        });
    }
    doStorageSave(newState, oldState) {
        return state_base_awaiter(this, void 0, void 0, function* () {
            if (this.keyDefinition.debug.enableUpdateLogging) {
                this.logService.info(`Updating '${this.key}' from ${oldState == null ? "null" : "non-null"} to ${newState == null ? "null" : "non-null"}`);
            }
            yield this.storageService.save(this.key, newState);
        });
    }
    /** For use in update methods, does not wait for update to complete before yielding state.
     * The expectation is that that await is already done
     */
    getStateForUpdate() {
        return state_base_awaiter(this, void 0, void 0, function* () {
            return yield getStoredValue(this.key, this.storageService, this.keyDefinition.deserializer);
        });
    }
}

;// ../../libs/state-internal/src/default-global-state.ts


class DefaultGlobalState extends StateBase {
    constructor(keyDefinition, chosenLocation, logService) {
        super(util_globalKeyBuilder(keyDefinition), chosenLocation, keyDefinition, logService);
    }
}

;// ../../libs/state-internal/src/default-global-state.provider.ts
/* unused harmony import specifier */ var default_global_state_provider_DefaultGlobalState;

class DefaultGlobalStateProvider {
    constructor(storageServiceProvider, logService) {
        this.storageServiceProvider = storageServiceProvider;
        this.logService = logService;
        this.globalStateCache = {};
    }
    get(keyDefinition) {
        const [location, storageService] = this.storageServiceProvider.get(keyDefinition.stateDefinition.defaultStorageLocation, keyDefinition.stateDefinition.storageLocationOverrides);
        const cacheKey = this.buildCacheKey(location, keyDefinition);
        const existingGlobalState = this.globalStateCache[cacheKey];
        if (existingGlobalState != null) {
            // The cast into the actual generic is safe because of rules around key definitions
            // being unique.
            return existingGlobalState;
        }
        const newGlobalState = new default_global_state_provider_DefaultGlobalState(keyDefinition, storageService, this.logService);
        this.globalStateCache[cacheKey] = newGlobalState;
        return newGlobalState;
    }
    buildCacheKey(location, keyDefinition) {
        return `${location}_${keyDefinition.fullName}`;
    }
}

;// ../../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js
var isArray=Array.isArray;var getPrototypeOf=Object.getPrototypeOf,objectProto=Object.prototype,getKeys=Object.keys;function argsArgArrayOrObject(args){if(args.length===1){var first_1=args[0];if(isArray(first_1)){return{args:first_1,keys:null};}if(isPOJO(first_1)){var keys=getKeys(first_1);return{args:keys.map(function(key){return first_1[key];}),keys:keys};}}return{args:args,keys:null};}function isPOJO(obj){return obj&&typeof obj==='object'&&getPrototypeOf(obj)===objectProto;}
;// ../../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js
var mapOneOrManyArgs_isArray=Array.isArray;function callOrApply(fn,args){return mapOneOrManyArgs_isArray(args)?fn.apply(void 0,__spreadArray([],__read(args))):fn(args);}function mapOneOrManyArgs(fn){return map(function(args){return callOrApply(fn,args);});}
;// ../../node_modules/rxjs/dist/esm5/internal/util/createObject.js
function createObject(keys,values){return keys.reduce(function(result,key,i){return result[key]=values[i],result;},{});}
;// ../../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js
function combineLatest(){var args=[];for(var _i=0;_i<arguments.length;_i++){args[_i]=arguments[_i];}var scheduler=popScheduler(args);var resultSelector=popResultSelector(args);var _a=argsArgArrayOrObject(args),observables=_a.args,keys=_a.keys;if(observables.length===0){return from([],scheduler);}var result=new Observable(combineLatestInit(observables,scheduler,keys?function(values){return createObject(keys,values);}:identity));return resultSelector?result.pipe(mapOneOrManyArgs(resultSelector)):result;}function combineLatestInit(observables,scheduler,valueTransform){if(valueTransform===void 0){valueTransform=identity;}return function(subscriber){maybeSchedule(scheduler,function(){var length=observables.length;var values=new Array(length);var active=length;var remainingFirstValues=length;var _loop_1=function(i){maybeSchedule(scheduler,function(){var source=from(observables[i],scheduler);var hasFirstValue=false;source.subscribe(createOperatorSubscriber(subscriber,function(value){values[i]=value;if(!hasFirstValue){hasFirstValue=true;remainingFirstValues--;}if(!remainingFirstValues){subscriber.next(valueTransform(values.slice()));}},function(){if(! --active){subscriber.complete();}}));},subscriber);};for(var i=0;i<length;i++){_loop_1(i);}},subscriber);};}function maybeSchedule(scheduler,execute,subscription){if(scheduler){executeSchedule(subscription,scheduler,execute);}else{execute();}}
;// ../../libs/state-internal/src/default-single-user-state.ts
var default_single_user_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


class DefaultSingleUserState extends StateBase {
    constructor(userId, keyDefinition, chosenLocation, stateEventRegistrarService, logService) {
        super(keyDefinition.buildKey(userId), chosenLocation, keyDefinition, logService);
        this.userId = userId;
        this.stateEventRegistrarService = stateEventRegistrarService;
        this.combinedState$ = combineLatest([of(userId), this.state$]);
    }
    doStorageSave(newState, oldState) {
        const _super = Object.create(null, {
            doStorageSave: { get: () => super.doStorageSave }
        });
        return default_single_user_state_awaiter(this, void 0, void 0, function* () {
            yield _super.doStorageSave.call(this, newState, oldState);
            yield this.stateEventRegistrarService.registerEvents(this.keyDefinition);
        });
    }
}

;// ../../libs/state-internal/src/default-single-user-state.provider.ts
/* unused harmony import specifier */ var default_single_user_state_provider_DefaultSingleUserState;

class DefaultSingleUserStateProvider {
    constructor(storageServiceProvider, stateEventRegistrarService, logService) {
        this.storageServiceProvider = storageServiceProvider;
        this.stateEventRegistrarService = stateEventRegistrarService;
        this.logService = logService;
        this.cache = {};
    }
    get(userId, keyDefinition) {
        const [location, storageService] = this.storageServiceProvider.get(keyDefinition.stateDefinition.defaultStorageLocation, keyDefinition.stateDefinition.storageLocationOverrides);
        const cacheKey = this.buildCacheKey(location, userId, keyDefinition);
        const existingUserState = this.cache[cacheKey];
        if (existingUserState != null) {
            // I have to cast out of the unknown generic but this should be safe if rules
            // around domain token are made
            return existingUserState;
        }
        const newUserState = new default_single_user_state_provider_DefaultSingleUserState(userId, keyDefinition, storageService, this.stateEventRegistrarService, this.logService);
        this.cache[cacheKey] = newUserState;
        return newUserState;
    }
    buildCacheKey(location, userId, keyDefinition) {
        return `${location}_${keyDefinition.fullName}_${userId}`;
    }
}

;// ../../libs/state-internal/src/default-state.provider.ts
/* unused harmony import specifier */ var default_state_provider_of;
/* unused harmony import specifier */ var default_state_provider_filter;
/* unused harmony import specifier */ var default_state_provider_switchMap;
/* unused harmony import specifier */ var take;
var default_state_provider_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore

class DefaultStateProvider {
    constructor(activeUserStateProvider, singleUserStateProvider, globalStateProvider, derivedStateProvider) {
        this.activeUserStateProvider = activeUserStateProvider;
        this.singleUserStateProvider = singleUserStateProvider;
        this.globalStateProvider = globalStateProvider;
        this.derivedStateProvider = derivedStateProvider;
        this.getActive = this.activeUserStateProvider.get.bind(this.activeUserStateProvider);
        this.getUser = this.singleUserStateProvider.get.bind(this.singleUserStateProvider);
        this.getGlobal = this.globalStateProvider.get.bind(this.globalStateProvider);
        this.getDerived = this.derivedStateProvider.get.bind(this.derivedStateProvider);
        this.activeUserId$ = this.activeUserStateProvider.activeUserId$;
    }
    getUserState$(userKeyDefinition, userId) {
        if (userId) {
            return this.getUser(userId, userKeyDefinition).state$;
        }
        else {
            return this.activeUserId$.pipe(default_state_provider_filter((userId) => userId != null), // Filter out null-ish user ids since we can't get state for a null user id
            take(1), default_state_provider_switchMap((userId) => this.getUser(userId, userKeyDefinition).state$));
        }
    }
    getUserStateOrDefault$(userKeyDefinition, config) {
        const { userId, defaultValue = null } = config;
        if (userId) {
            return this.getUser(userId, userKeyDefinition).state$;
        }
        else {
            return this.activeUserId$.pipe(take(1), default_state_provider_switchMap((userId) => userId != null ? this.getUser(userId, userKeyDefinition).state$ : default_state_provider_of(defaultValue)));
        }
    }
    setUserState(userKeyDefinition, value, userId) {
        return default_state_provider_awaiter(this, void 0, void 0, function* () {
            if (userId) {
                return [userId, yield this.getUser(userId, userKeyDefinition).update(() => value)];
            }
            else {
                return yield this.getActive(userKeyDefinition).update(() => value);
            }
        });
    }
}

;// ../../libs/state-internal/src/inline-derived-state.ts
/* unused harmony import specifier */ var inline_derived_state_concatMap;
var inline_derived_state_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

class InlineDerivedStateProvider {
    get(parentState$, deriveDefinition, dependencies) {
        return new InlineDerivedState(parentState$, deriveDefinition, dependencies);
    }
}
class InlineDerivedState {
    constructor(parentState$, deriveDefinition, dependencies) {
        this.state$ = parentState$.pipe(inline_derived_state_concatMap((value) => inline_derived_state_awaiter(this, void 0, void 0, function* () { return yield deriveDefinition.derive(value, dependencies); })));
    }
    forceValue(value) {
        // No need to force anything, we don't keep a cache
        return Promise.resolve(value);
    }
}

;// ../../libs/state-internal/src/legacy/default-state.service.ts
/* unused harmony import specifier */ var default_state_service_firstValueFrom;
/* unused harmony import specifier */ var GlobalState;
var default_state_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


const keys = {
    global: "global",
};
const partialKeys = {
    userAutoKey: "_user_auto",
    userBiometricKey: "_user_biometric",
};
const DDG_SHARED_KEY = "DuckDuckGoSharedKey";
class DefaultStateService {
    constructor(storageService, secureStorageService, activeUserAccessor) {
        this.storageService = storageService;
        this.secureStorageService = secureStorageService;
        this.activeUserAccessor = activeUserAccessor;
    }
    clean(options) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            yield this.setUserKeyAutoUnlock(null, options);
            yield this.clearUserKeyBiometric(options.userId);
        });
    }
    /**
     * user key when using the "never" option of vault timeout
     */
    getUserKeyAutoUnlock(options) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            if (options.userId == null) {
                return null;
            }
            return yield this.secureStorageService.get(`${options.userId}${partialKeys.userAutoKey}`, {
                userId: options.userId,
                keySuffix: "auto",
            });
        });
    }
    /**
     * user key when using the "never" option of vault timeout
     */
    setUserKeyAutoUnlock(value, options) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            if (options.userId == null) {
                return;
            }
            yield this.saveSecureStorageKey(partialKeys.userAutoKey, value, options.userId, "auto");
        });
    }
    clearUserKeyBiometric(userId) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            if (userId == null) {
                return;
            }
            yield this.saveSecureStorageKey(partialKeys.userBiometricKey, null, userId, "biometric");
        });
    }
    getDuckDuckGoSharedKey() {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            const userId = yield this.getActiveUserIdFromStorage();
            if (userId == null) {
                return null;
            }
            return yield this.secureStorageService.get(DDG_SHARED_KEY);
        });
    }
    setDuckDuckGoSharedKey(value) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            const userId = yield this.getActiveUserIdFromStorage();
            if (userId == null) {
                return;
            }
            value == null
                ? yield this.secureStorageService.remove(DDG_SHARED_KEY)
                : yield this.secureStorageService.save(DDG_SHARED_KEY, value);
        });
    }
    setEnableDuckDuckGoBrowserIntegration(value) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            const globals = (_a = (yield this.storageService.get(keys.global))) !== null && _a !== void 0 ? _a : new GlobalState();
            globals.enableDuckDuckGoBrowserIntegration = value;
            yield this.storageService.save(keys.global, globals);
        });
    }
    getActiveUserIdFromStorage() {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            return yield default_state_service_firstValueFrom(this.activeUserAccessor.activeUserId$);
        });
    }
    saveSecureStorageKey(key, value, userId, keySuffix) {
        return default_state_service_awaiter(this, void 0, void 0, function* () {
            return value == null
                ? yield this.secureStorageService.remove(`${userId}${key}`, { keySuffix: keySuffix })
                : yield this.secureStorageService.save(`${userId}${key}`, value, {
                    keySuffix: keySuffix,
                });
        });
    }
}

;// ../../libs/state-internal/src/default-state-event-registrar.service.ts
var default_state_event_registrar_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

const STATE_LOCK_EVENT = KeyDefinition.array(CLEAR_EVENT_DISK, "lock", {
    deserializer: (e) => e,
});
const STATE_LOGOUT_EVENT = KeyDefinition.array(CLEAR_EVENT_DISK, "logout", {
    deserializer: (e) => e,
});
class DefaultStateEventRegistrarService {
    constructor(globalStateProvider, storageServiceProvider) {
        this.storageServiceProvider = storageServiceProvider;
        this.stateEventStateMap = {
            lock: globalStateProvider.get(STATE_LOCK_EVENT),
            logout: globalStateProvider.get(STATE_LOGOUT_EVENT),
        };
    }
    registerEvents(keyDefinition) {
        return default_state_event_registrar_service_awaiter(this, void 0, void 0, function* () {
            for (const clearEvent of keyDefinition.clearOn) {
                const eventState = this.stateEventStateMap[clearEvent];
                // Determine the storage location for this
                const [storageLocation] = this.storageServiceProvider.get(keyDefinition.stateDefinition.defaultStorageLocation, keyDefinition.stateDefinition.storageLocationOverrides);
                const newEvent = {
                    state: keyDefinition.stateDefinition.name,
                    key: keyDefinition.key,
                    location: storageLocation,
                };
                // Only update the event state if the existing list doesn't have a matching entry
                yield eventState.update((existingTickets) => {
                    existingTickets !== null && existingTickets !== void 0 ? existingTickets : (existingTickets = []);
                    existingTickets.push(newEvent);
                    return existingTickets;
                }, {
                    shouldUpdate: (currentTickets) => {
                        return (
                        // If the current tickets are null, then it will for sure be added
                        currentTickets == null ||
                            // If an existing match couldn't be found, we also need to add one
                            currentTickets.findIndex((e) => e.state === newEvent.state &&
                                e.key === newEvent.key &&
                                e.location === newEvent.location) === -1);
                    },
                });
            }
        });
    }
}

;// ../../libs/state-internal/src/default-state-event-runner.service.ts
/* unused harmony import specifier */ var default_state_event_runner_service_firstValueFrom;
/* unused harmony import specifier */ var default_state_event_runner_service_UserKeyDefinition;
/* unused harmony import specifier */ var default_state_event_runner_service_StateDefinition;
/* unused harmony import specifier */ var default_state_event_runner_service_STATE_LOCK_EVENT;
/* unused harmony import specifier */ var default_state_event_runner_service_STATE_LOGOUT_EVENT;
var default_state_event_runner_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



class DefaultStateEventRunnerService {
    constructor(globalStateProvider, storageServiceProvider) {
        this.storageServiceProvider = storageServiceProvider;
        this.stateEventMap = {
            lock: globalStateProvider.get(default_state_event_runner_service_STATE_LOCK_EVENT),
            logout: globalStateProvider.get(default_state_event_runner_service_STATE_LOGOUT_EVENT),
        };
    }
    handleEvent(event, userId) {
        return default_state_event_runner_service_awaiter(this, void 0, void 0, function* () {
            let tickets = yield default_state_event_runner_service_firstValueFrom(this.stateEventMap[event].state$);
            tickets !== null && tickets !== void 0 ? tickets : (tickets = []);
            const failures = [];
            for (const ticket of tickets) {
                try {
                    const [, service] = this.storageServiceProvider.get(ticket.location, {});
                    const ticketStorageKey = this.storageKeyFor(userId, ticket);
                    // Evaluate current value so we can avoid writing to state if we don't need to
                    const currentValue = yield service.get(ticketStorageKey);
                    if (currentValue != null) {
                        yield service.remove(ticketStorageKey);
                    }
                }
                catch (err) {
                    let errorMessage = "Unknown Error";
                    if (err != null &&
                        typeof err === "object" &&
                        "message" in err &&
                        typeof err.message === "string") {
                        errorMessage = err.message;
                    }
                    failures.push(`${errorMessage} in ${ticket.state} > ${ticket.key} located ${ticket.location}`);
                }
            }
            if (failures.length > 0) {
                // Throw aggregated error
                throw new Error(`One or more errors occurred while handling event '${event}' for user ${userId}.\n${failures.join("\n")}`);
            }
        });
    }
    storageKeyFor(userId, ticket) {
        const userKey = new default_state_event_runner_service_UserKeyDefinition(new default_state_event_runner_service_StateDefinition(ticket.state, ticket.location), ticket.key, {
            deserializer: (v) => v,
            clearOn: [],
        });
        return userKey.buildKey(userId);
    }
}

;// ../../libs/state-internal/src/index.ts

















;// ../../libs/common/src/platform/state/index.ts



;// ../../libs/common/src/auth/services/account.service.ts
/* unused harmony import specifier */ var BehaviorSubject;
/* unused harmony import specifier */ var account_service_combineLatest;
/* unused harmony import specifier */ var account_service_of;
/* unused harmony import specifier */ var combineLatestWith;
/* unused harmony import specifier */ var account_service_distinctUntilChanged;
/* unused harmony import specifier */ var account_service_filter;
/* unused harmony import specifier */ var account_service_map;
/* unused harmony import specifier */ var shareReplay;
/* unused harmony import specifier */ var account_service_switchMap;
/* unused harmony import specifier */ var account_service_timeout;
/* unused harmony import specifier */ var account_service_Utils;
var account_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore



const account_service_ACCOUNT_ACCOUNTS = KeyDefinition.record(ACCOUNT_DISK, "accounts", {
    deserializer: (accountInfo) => (Object.assign(Object.assign({}, accountInfo), { creationDate: accountInfo.creationDate ? new Date(accountInfo.creationDate) : undefined })),
});
const account_service_ACCOUNT_ACTIVE_ACCOUNT_ID = new KeyDefinition(ACCOUNT_DISK, "activeAccountId", {
    deserializer: (id) => id,
});
const account_service_ACCOUNT_ACTIVITY = KeyDefinition.record(ACCOUNT_DISK, "activity", {
    deserializer: (activity) => new Date(activity),
});
const ACCOUNT_VERIFY_NEW_DEVICE_LOGIN = new UserKeyDefinition(ACCOUNT_DISK, "verifyNewDeviceLogin", {
    deserializer: (verifyDevices) => verifyDevices,
    clearOn: ["logout"],
});
const LOGGED_OUT_INFO = {
    email: "",
    emailVerified: false,
    name: undefined,
    creationDate: undefined,
};
/**
 * An rxjs map operator that extracts the UserId from an account, or throws if the account or UserId are null.
 */
const getUserId = map((account) => {
    if (account == null) {
        throw new Error("Null or undefined account");
    }
    return account.id;
});
/**
 * An rxjs map operator that extracts the UserId from an account, or returns undefined if the account or UserId are null.
 */
const getOptionalUserId = map((account) => { var _a; return (_a = account === null || account === void 0 ? void 0 : account.id) !== null && _a !== void 0 ? _a : null; });
class AccountServiceImplementation {
    constructor(messagingService, logService, globalStateProvider, singleUserStateProvider) {
        this.messagingService = messagingService;
        this.logService = logService;
        this.globalStateProvider = globalStateProvider;
        this.singleUserStateProvider = singleUserStateProvider;
        this._showHeader$ = new BehaviorSubject(true);
        this.showHeader$ = this._showHeader$.asObservable();
        this.accountsState = this.globalStateProvider.get(account_service_ACCOUNT_ACCOUNTS);
        this.activeAccountIdState = this.globalStateProvider.get(account_service_ACCOUNT_ACTIVE_ACCOUNT_ID);
        this.accounts$ = this.accountsState.state$.pipe(account_service_map((accounts) => (accounts == null ? {} : accounts)));
        this.activeAccount$ = this.activeAccountIdState.state$.pipe(combineLatestWith(this.accounts$), account_service_map(([id, accounts]) => (id ? Object.assign({ id }, accounts[id]) : null)), account_service_distinctUntilChanged((a, b) => (a === null || a === void 0 ? void 0 : a.id) === (b === null || b === void 0 ? void 0 : b.id) && this.accountInfoEqual(a, b)), shareReplay({ bufferSize: 1, refCount: false }));
        this.accountActivity$ = this.globalStateProvider
            .get(account_service_ACCOUNT_ACTIVITY)
            .state$.pipe(account_service_map((activity) => activity !== null && activity !== void 0 ? activity : {}));
        this.sortedUserIds$ = this.accountActivity$.pipe(account_service_map((activity) => {
            return Object.entries(activity)
                .map(([userId, lastActive]) => ({ userId, lastActive }))
                .sort((a, b) => b.lastActive.getTime() - a.lastActive.getTime()) // later dates first
                .map((a) => a.userId);
        }));
        this.nextUpAccount$ = account_service_combineLatest([
            this.accounts$,
            this.activeAccount$,
            this.sortedUserIds$,
        ]).pipe(account_service_map(([accounts, activeAccount, sortedUserIds]) => {
            const nextId = sortedUserIds.find((id) => id !== (activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.id) && accounts[id] != null);
            return nextId ? Object.assign({ id: nextId }, accounts[nextId]) : null;
        }));
        this.accountVerifyNewDeviceLogin$ = this.activeAccountIdState.state$.pipe(account_service_switchMap((userId) => this.singleUserStateProvider.get(userId, ACCOUNT_VERIFY_NEW_DEVICE_LOGIN).state$));
    }
    addAccount(userId, accountData) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            if (!account_service_Utils.isGuid(userId)) {
                throw new Error("userId is required");
            }
            yield this.accountsState.update((accounts) => {
                accounts || (accounts = {});
                accounts[userId] = accountData;
                return accounts;
            });
            yield this.setAccountActivity(userId, new Date());
        });
    }
    setAccountName(userId, name) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.setAccountInfo(userId, { name });
        });
    }
    setAccountEmail(userId, email) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.setAccountInfo(userId, { email });
        });
    }
    setAccountEmailVerified(userId, emailVerified) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.setAccountInfo(userId, { emailVerified });
        });
    }
    setAccountCreationDate(userId, creationDate) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.setAccountInfo(userId, { creationDate });
        });
    }
    clean(userId) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.setAccountInfo(userId, LOGGED_OUT_INFO);
            yield this.removeAccountActivity(userId);
        });
    }
    switchAccount(userId) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            let updateActivity = false;
            yield this.activeAccountIdState.update((_, __) => {
                updateActivity = true;
                return userId;
            }, {
                combineLatestWith: this.accountsState.state$.pipe(account_service_filter((accounts) => {
                    if (userId == null) {
                        // Don't worry about accounts when we are about to set active user to null
                        return true;
                    }
                    return (accounts === null || accounts === void 0 ? void 0 : accounts[userId]) != null;
                }), 
                // If we don't get the desired account with enough time, just return empty as that will result in the same error
                account_service_timeout({ first: 1000, with: () => account_service_of({}) })),
                shouldUpdate: (id, accounts) => {
                    if (userId != null && (accounts === null || accounts === void 0 ? void 0 : accounts[userId]) == null) {
                        throw new Error("Account does not exist");
                    }
                    // update only if userId changes
                    return id !== userId;
                },
            });
            if (updateActivity) {
                yield this.setAccountActivity(userId, new Date());
            }
        });
    }
    setAccountActivity(userId, lastActivity) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            if (!account_service_Utils.isGuid(userId)) {
                // only store for valid userIds
                return;
            }
            yield this.globalStateProvider.get(account_service_ACCOUNT_ACTIVITY).update((activity) => {
                activity || (activity = {});
                activity[userId] = lastActivity;
                return activity;
            }, {
                shouldUpdate: (oldActivity) => { var _a; return ((_a = oldActivity === null || oldActivity === void 0 ? void 0 : oldActivity[userId]) === null || _a === void 0 ? void 0 : _a.getTime()) !== (lastActivity === null || lastActivity === void 0 ? void 0 : lastActivity.getTime()); },
            });
        });
    }
    setAccountVerifyNewDeviceLogin(userId, setVerifyNewDeviceLogin) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            if (!account_service_Utils.isGuid(userId)) {
                // only store for valid userIds
                return;
            }
            yield this.singleUserStateProvider
                .get(userId, ACCOUNT_VERIFY_NEW_DEVICE_LOGIN)
                .update(() => setVerifyNewDeviceLogin, {
                shouldUpdate: (previousValue) => previousValue !== setVerifyNewDeviceLogin,
            });
        });
    }
    removeAccountActivity(userId) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            yield this.globalStateProvider.get(account_service_ACCOUNT_ACTIVITY).update((activity) => {
                if (activity == null) {
                    return activity;
                }
                delete activity[userId];
                return activity;
            }, { shouldUpdate: (oldActivity) => (oldActivity === null || oldActivity === void 0 ? void 0 : oldActivity[userId]) != null });
        });
    }
    // TODO: update to use our own account status settings. Requires inverting direction of state service accounts flow
    delete() {
        return account_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            try {
                (_a = this.messagingService) === null || _a === void 0 ? void 0 : _a.send("logout");
            }
            catch (e) {
                this.logService.error(e);
                throw e;
            }
        });
    }
    setShowHeader(visible) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            this._showHeader$.next(visible);
        });
    }
    accountInfoEqual(a, b) {
        var _a, _b;
        if (a == null && b == null) {
            return true;
        }
        if (a == null || b == null) {
            return false;
        }
        return (a.email === b.email &&
            a.emailVerified === b.emailVerified &&
            a.name === b.name &&
            ((_a = a.creationDate) === null || _a === void 0 ? void 0 : _a.getTime()) === ((_b = b.creationDate) === null || _b === void 0 ? void 0 : _b.getTime()));
    }
    setAccountInfo(userId, update) {
        return account_service_awaiter(this, void 0, void 0, function* () {
            function newAccountInfo(oldAccountInfo) {
                return Object.assign(Object.assign({}, oldAccountInfo), update);
            }
            yield this.accountsState.update((accounts) => {
                accounts[userId] = newAccountInfo(accounts[userId]);
                return accounts;
            }, {
                // Avoid unnecessary updates
                // TODO: Faster comparison, maybe include a hash on the objects?
                shouldUpdate: (accounts) => {
                    if ((accounts === null || accounts === void 0 ? void 0 : accounts[userId]) == null) {
                        throw new Error("Account does not exist");
                    }
                    return !this.accountInfoEqual(accounts[userId], newAccountInfo(accounts[userId]));
                },
            });
        });
    }
}

;// ../../libs/common/src/autofill/utils/index.ts
/* unused harmony import specifier */ var utils_Utils;
/* unused harmony import specifier */ var utils_IrrelevantExpiryCharactersPatternExpression;
/* unused harmony import specifier */ var utils_DelimiterPatternExpression;
/* unused harmony import specifier */ var utils_ExpiryFullYearPatternExpression;
/* unused harmony import specifier */ var utils_MonthPatternExpression;
/* unused harmony import specifier */ var utils_ExpiryFullYearPattern;


/**
 * Takes a string or number value and returns a string value formatted as a valid 4-digit year
 *
 * @param {(string | number)} yearInput
 * @return {*}  {(Year | null)}
 */
function normalizeExpiryYearFormat(yearInput) {
    // The input[type="number"] is returning a number, convert it to a string
    // An empty field returns null, avoid casting `"null"` to a string
    const yearInputIsEmpty = yearInput == null || yearInput === "";
    let expirationYear = yearInputIsEmpty ? null : `${yearInput}`;
    // Exit early if year is already formatted correctly or empty
    if (yearInputIsEmpty || (expirationYear && /^[1-9]{1}\d{3}$/.test(expirationYear))) {
        return expirationYear;
    }
    expirationYear = (expirationYear || "")
        // For safety, because even input[type="number"] will allow decimals
        .replace(/[^\d]/g, "")
        // remove any leading zero padding (leave the last leading zero if it ends the string)
        .replace(/^[0]+(?=.)/, "");
    if (expirationYear === "") {
        expirationYear = null;
    }
    // given the context of payment card expiry, a year character length of 3, or over 4
    // is more likely to be a mistake than an intentional value for the far past or far future.
    if (expirationYear && expirationYear.length !== 4) {
        const paddedYear = ("00" + expirationYear).slice(-2);
        const currentCentury = `${new Date().getFullYear()}`.slice(0, 2);
        expirationYear = currentCentury + paddedYear;
    }
    return expirationYear;
}
/**
 * Takes a cipher card view and returns "true" if the month and year affirmatively indicate
 * the card is expired. Uncertain cases return "false".
 *
 * @param {CardView} cipherCard
 * @return {*}  {boolean}
 */
function isCardExpired(cipherCard) {
    if (cipherCard) {
        const { expMonth = null, expYear = null } = cipherCard;
        if (!expYear) {
            return false;
        }
        const now = new Date();
        const normalizedYear = normalizeExpiryYearFormat(expYear);
        const parsedYear = normalizedYear ? parseInt(normalizedYear, 10) : NaN;
        const expiryYearIsBeforeCurrentYear = parsedYear < now.getFullYear();
        const expiryYearIsAfterCurrentYear = parsedYear > now.getFullYear();
        // If the expiry year is before the current year, skip checking the month, since it must be expired
        if (normalizedYear && expiryYearIsBeforeCurrentYear) {
            return true;
        }
        // If the expiry year is after the current year, skip checking the month, since it cannot be expired
        if (normalizedYear && expiryYearIsAfterCurrentYear) {
            return false;
        }
        if (normalizedYear && expMonth) {
            const parsedMonthInteger = parseInt(expMonth, 10);
            const parsedMonthIsValid = parsedMonthInteger && !isNaN(parsedMonthInteger);
            // If the parsed month value is 0, we don't know when the expiry passes this year, so do not treat it as expired
            if (!parsedMonthIsValid) {
                return false;
            }
            // `Date` months are zero-indexed
            const parsedMonth = parsedMonthInteger - 1;
            // First day of the next month
            const cardExpiry = new Date(parsedYear, parsedMonth + 1, 1);
            return cardExpiry <= now;
        }
    }
    return false;
}
/**
 * Attempt to split a string into date segments on the basis of expected formats and delimiter symbols.
 *
 * @param {string} combinedExpiryValue
 * @return {*}  {string[]}
 */
function splitCombinedDateValues(combinedExpiryValue) {
    var _a;
    let sanitizedValue = combinedExpiryValue
        .replace(utils_IrrelevantExpiryCharactersPatternExpression, "")
        .trim();
    // Do this after initial value replace to avoid identifying leading whitespace as delimiter
    const parsedDelimiter = ((_a = sanitizedValue.match(utils_DelimiterPatternExpression)) === null || _a === void 0 ? void 0 : _a[0]) || null;
    let dateParts = [sanitizedValue];
    if (parsedDelimiter === null || parsedDelimiter === void 0 ? void 0 : parsedDelimiter.length) {
        // If the parsed delimiter is a whitespace character, assign 's' (character class) instead
        const delimiterPattern = /\s/.test(parsedDelimiter) ? "\\s" : "\\" + parsedDelimiter;
        sanitizedValue = sanitizedValue
            // Remove all other delimiter characters not identified as the delimiter
            .replace(new RegExp(`[^\\d${delimiterPattern}]`, "g"), "")
            // Also de-dupe the delimiter character
            .replace(new RegExp(`[${delimiterPattern}]{2,}`, "g"), parsedDelimiter);
        dateParts = sanitizedValue.split(parsedDelimiter);
    }
    return (dateParts
        // remove values that have no length
        .filter((splitValue) => splitValue === null || splitValue === void 0 ? void 0 : splitValue.length));
}
/**
 * Given an array of split card expiry date parts,
 * returns an array of those values ordered by year then month
 *
 * @param {string[]} splitDateInput
 * @return {*}  {([string | null, string | null])}
 */
function parseDelimitedYearMonthExpiry([firstPart, secondPart]) {
    // Conditionals here are structured to avoid unnecessary evaluations and are ordered
    // from more authoritative checks to checks yielding increasingly inferred conclusions
    // If a 4-digit value is found (when there are multiple parts), it can't be month
    if (utils_ExpiryFullYearPatternExpression.test(firstPart)) {
        return [firstPart, secondPart];
    }
    // If a 4-digit value is found (when there are multiple parts), it can't be month
    if (utils_ExpiryFullYearPatternExpression.test(secondPart)) {
        return [secondPart, firstPart];
    }
    // If it's a two digit value that doesn't match against month pattern, assume it's a year
    if (/\d{2}/.test(firstPart) && !utils_MonthPatternExpression.test(firstPart)) {
        return [firstPart, secondPart];
    }
    // If it's a two digit value that doesn't match against month pattern, assume it's a year
    if (/\d{2}/.test(secondPart) && !utils_MonthPatternExpression.test(secondPart)) {
        return [secondPart, firstPart];
    }
    // Values are too ambiguous (e.g. "12/09"). For the most part,
    // a month-looking value likely is, at the time of writing (year 2024).
    let parsedYear = firstPart;
    let parsedMonth = secondPart;
    if (utils_MonthPatternExpression.test(firstPart)) {
        parsedYear = secondPart;
        parsedMonth = firstPart;
    }
    return [parsedYear, parsedMonth];
}
/**
 * Given a single string of integers, attempts to identify card expiry date portions within
 * and return values ordered by year then month
 *
 * @param {string} dateInput
 * @return {*}  {([string | null, string | null])}
 */
function parseNonDelimitedYearMonthExpiry(dateInput) {
    if (dateInput.length > 4) {
        // e.g.
        // "052024"
        // "202405"
        // "20245"
        // "52024"
        // If the value is over 5-characters long, it likely has a full year format in it
        const [parsedYear, parsedMonth] = dateInput
            .split(new RegExp(`(?=${utils_ExpiryFullYearPattern})|(?<=${utils_ExpiryFullYearPattern})`, "g"))
            .sort((current, next) => (current.length > next.length ? -1 : 1));
        return [parsedYear, parsedMonth];
    }
    if (dateInput.length === 4) {
        // e.g.
        // "0524"
        // "2405"
        // If the `sanitizedFirstPart` value is a length of 4, it must be split in half, since
        // neither a year or month will be represented with three characters
        const splitFirstPartFirstHalf = dateInput.slice(0, 2);
        const splitFirstPartSecondHalf = dateInput.slice(-2);
        let parsedYear = splitFirstPartSecondHalf;
        let parsedMonth = splitFirstPartFirstHalf;
        // If the first part doesn't match a month pattern, assume it's a year
        if (!utils_MonthPatternExpression.test(splitFirstPartFirstHalf)) {
            parsedYear = splitFirstPartFirstHalf;
            parsedMonth = splitFirstPartSecondHalf;
        }
        return [parsedYear, parsedMonth];
    }
    // e.g.
    // "245"
    // "202"
    // "212"
    // "022"
    // "111"
    // A valid year representation here must be two characters so try to find it first.
    let parsedYear = null;
    let parsedMonth = null;
    // Split if there is a digit with a leading zero
    const splitFirstPartOnLeadingZero = dateInput.split(/(?<=0[1-9]{1})|(?=0[1-9]{1})/);
    // Assume a leading zero indicates a month in ambiguous cases (e.g. "202"), since we're
    // dealing with expiry dates and the next two-digit year with a leading zero will be 2100
    if (splitFirstPartOnLeadingZero.length > 1) {
        parsedYear = splitFirstPartOnLeadingZero[0];
        parsedMonth = splitFirstPartOnLeadingZero[1];
        if (splitFirstPartOnLeadingZero[0].startsWith("0")) {
            parsedMonth = splitFirstPartOnLeadingZero[0];
            parsedYear = splitFirstPartOnLeadingZero[1];
        }
    }
    else {
        // Here, a year has to be two-digits, and a month can't be more than one, so assume the first two digits that are greater than the current year is the year representation.
        parsedYear = dateInput.slice(0, 2);
        parsedMonth = dateInput.slice(-1);
        const currentYear = new Date().getFullYear();
        const normalizedYearFormat = normalizeExpiryYearFormat(parsedYear);
        const normalizedParsedYear = normalizedYearFormat && parseInt(normalizedYearFormat, 10);
        const normalizedExpiryYearFormat = normalizeExpiryYearFormat(dateInput.slice(-2));
        const normalizedParsedYearAlternative = normalizedExpiryYearFormat && parseInt(normalizedExpiryYearFormat, 10);
        if (normalizedParsedYear &&
            normalizedParsedYear < currentYear &&
            normalizedParsedYearAlternative &&
            normalizedParsedYearAlternative >= currentYear) {
            parsedYear = dateInput.slice(-2);
            parsedMonth = dateInput.slice(0, 1);
        }
    }
    return [parsedYear, parsedMonth];
}
/**
 * Attempt to parse year and month parts of a combined expiry date value.
 *
 * @param {string} combinedExpiryValue
 * @return {*}  {([string | null, string | null])}
 */
function parseYearMonthExpiry(combinedExpiryValue) {
    var _a, _b;
    let parsedYear = null;
    let parsedMonth = null;
    const dateParts = splitCombinedDateValues(combinedExpiryValue);
    if (dateParts.length < 1) {
        return [null, null];
    }
    const sanitizedFirstPart = ((_a = dateParts[0]) === null || _a === void 0 ? void 0 : _a.replace(utils_IrrelevantExpiryCharactersPatternExpression, "")) || "";
    const sanitizedSecondPart = ((_b = dateParts[1]) === null || _b === void 0 ? void 0 : _b.replace(utils_IrrelevantExpiryCharactersPatternExpression, "")) || "";
    // If there is only one date part, no delimiter was found in the passed value
    if (dateParts.length === 1) {
        const [parsedNonDelimitedYear, parsedNonDelimitedMonth] = parseNonDelimitedYearMonthExpiry(sanitizedFirstPart);
        parsedYear = parsedNonDelimitedYear;
        parsedMonth = parsedNonDelimitedMonth;
    }
    // There are multiple date parts
    else {
        const [parsedDelimitedYear, parsedDelimitedMonth] = parseDelimitedYearMonthExpiry([
            sanitizedFirstPart,
            sanitizedSecondPart,
        ]);
        parsedYear = parsedDelimitedYear;
        parsedMonth = parsedDelimitedMonth;
    }
    const normalizedParsedYear = parsedYear ? normalizeExpiryYearFormat(parsedYear) : null;
    const normalizedParsedMonth = parsedMonth === null || parsedMonth === void 0 ? void 0 : parsedMonth.replace(/^0+/, "").slice(0, 2);
    // Set "empty" values to null
    parsedYear = (normalizedParsedYear === null || normalizedParsedYear === void 0 ? void 0 : normalizedParsedYear.length) ? normalizedParsedYear : null;
    parsedMonth = (normalizedParsedMonth === null || normalizedParsedMonth === void 0 ? void 0 : normalizedParsedMonth.length) ? normalizedParsedMonth : null;
    return [parsedYear, parsedMonth];
}
/**
 * Takes a URL string and a NeverDomains object and determines if the passed URL's hostname is in `urlList`
 *
 * @param {string} url - representation of URL to check
 * @param {NeverDomains} urlList - object with hostname key names
 */
function isUrlInList(url = "", urlList = {}) {
    const urlListKeys = urlList && Object.keys(urlList);
    if (urlListKeys.length && (url === null || url === void 0 ? void 0 : url.length)) {
        let tabHostname;
        try {
            tabHostname = utils_Utils.getHostname(url);
        }
        catch (_a) {
            // If the input was invalid, exit early and return false
            return false;
        }
        if (tabHostname) {
            return urlListKeys.some((blockedHostname) => tabHostname.endsWith(blockedHostname));
        }
    }
    return false;
}

;// ../../libs/common/src/dirt/event-logs/enums/event-type.enum.ts
// Increment by 100 for each new set of events
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var EventType;
(function (EventType) {
    EventType[EventType["User_LoggedIn"] = 1000] = "User_LoggedIn";
    EventType[EventType["User_ChangedPassword"] = 1001] = "User_ChangedPassword";
    EventType[EventType["User_Updated2fa"] = 1002] = "User_Updated2fa";
    EventType[EventType["User_Disabled2fa"] = 1003] = "User_Disabled2fa";
    EventType[EventType["User_Recovered2fa"] = 1004] = "User_Recovered2fa";
    EventType[EventType["User_FailedLogIn"] = 1005] = "User_FailedLogIn";
    EventType[EventType["User_FailedLogIn2fa"] = 1006] = "User_FailedLogIn2fa";
    EventType[EventType["User_ClientExportedVault"] = 1007] = "User_ClientExportedVault";
    EventType[EventType["User_UpdatedTempPassword"] = 1008] = "User_UpdatedTempPassword";
    EventType[EventType["User_MigratedKeyToKeyConnector"] = 1009] = "User_MigratedKeyToKeyConnector";
    EventType[EventType["User_RequestedDeviceApproval"] = 1010] = "User_RequestedDeviceApproval";
    EventType[EventType["User_TdeOffboardingPasswordSet"] = 1011] = "User_TdeOffboardingPasswordSet";
    EventType[EventType["Cipher_Created"] = 1100] = "Cipher_Created";
    EventType[EventType["Cipher_Updated"] = 1101] = "Cipher_Updated";
    EventType[EventType["Cipher_Deleted"] = 1102] = "Cipher_Deleted";
    EventType[EventType["Cipher_AttachmentCreated"] = 1103] = "Cipher_AttachmentCreated";
    EventType[EventType["Cipher_AttachmentDeleted"] = 1104] = "Cipher_AttachmentDeleted";
    EventType[EventType["Cipher_Shared"] = 1105] = "Cipher_Shared";
    EventType[EventType["Cipher_UpdatedCollections"] = 1106] = "Cipher_UpdatedCollections";
    EventType[EventType["Cipher_ClientViewed"] = 1107] = "Cipher_ClientViewed";
    EventType[EventType["Cipher_ClientToggledPasswordVisible"] = 1108] = "Cipher_ClientToggledPasswordVisible";
    EventType[EventType["Cipher_ClientToggledHiddenFieldVisible"] = 1109] = "Cipher_ClientToggledHiddenFieldVisible";
    EventType[EventType["Cipher_ClientToggledCardCodeVisible"] = 1110] = "Cipher_ClientToggledCardCodeVisible";
    EventType[EventType["Cipher_ClientCopiedPassword"] = 1111] = "Cipher_ClientCopiedPassword";
    EventType[EventType["Cipher_ClientCopiedHiddenField"] = 1112] = "Cipher_ClientCopiedHiddenField";
    EventType[EventType["Cipher_ClientCopiedCardCode"] = 1113] = "Cipher_ClientCopiedCardCode";
    EventType[EventType["Cipher_ClientAutofilled"] = 1114] = "Cipher_ClientAutofilled";
    EventType[EventType["Cipher_SoftDeleted"] = 1115] = "Cipher_SoftDeleted";
    EventType[EventType["Cipher_Restored"] = 1116] = "Cipher_Restored";
    EventType[EventType["Cipher_ClientToggledCardNumberVisible"] = 1117] = "Cipher_ClientToggledCardNumberVisible";
    EventType[EventType["Cipher_ClientToggledTOTPSeedVisible"] = 1118] = "Cipher_ClientToggledTOTPSeedVisible";
    EventType[EventType["Cipher_ClientCopiedBankAccountNumber"] = 1119] = "Cipher_ClientCopiedBankAccountNumber";
    EventType[EventType["Cipher_ClientCopiedBankAccountPin"] = 1120] = "Cipher_ClientCopiedBankAccountPin";
    EventType[EventType["Cipher_ClientToggledBankAccountNumberVisible"] = 1121] = "Cipher_ClientToggledBankAccountNumberVisible";
    EventType[EventType["Cipher_ClientToggledBankAccountPinVisible"] = 1122] = "Cipher_ClientToggledBankAccountPinVisible";
    EventType[EventType["Cipher_ClientCopiedLicenseNumber"] = 1123] = "Cipher_ClientCopiedLicenseNumber";
    EventType[EventType["Cipher_ClientToggledLicenseNumberVisible"] = 1124] = "Cipher_ClientToggledLicenseNumberVisible";
    EventType[EventType["Cipher_ClientCopiedPassportNumber"] = 1125] = "Cipher_ClientCopiedPassportNumber";
    EventType[EventType["Cipher_ClientToggledPassportNumberVisible"] = 1126] = "Cipher_ClientToggledPassportNumberVisible";
    EventType[EventType["Cipher_ClientCopiedSwiftCode"] = 1127] = "Cipher_ClientCopiedSwiftCode";
    EventType[EventType["Cipher_ClientToggledSwiftCodeVisible"] = 1128] = "Cipher_ClientToggledSwiftCodeVisible";
    EventType[EventType["Cipher_ClientCopiedIban"] = 1129] = "Cipher_ClientCopiedIban";
    EventType[EventType["Cipher_ClientToggledIbanVisible"] = 1130] = "Cipher_ClientToggledIbanVisible";
    EventType[EventType["Cipher_ClientCopiedNationalIdentificationNumber"] = 1131] = "Cipher_ClientCopiedNationalIdentificationNumber";
    EventType[EventType["Cipher_ClientToggledNationalIdentificationNumberVisible"] = 1132] = "Cipher_ClientToggledNationalIdentificationNumberVisible";
    EventType[EventType["Collection_Created"] = 1300] = "Collection_Created";
    EventType[EventType["Collection_Updated"] = 1301] = "Collection_Updated";
    EventType[EventType["Collection_Deleted"] = 1302] = "Collection_Deleted";
    EventType[EventType["Group_Created"] = 1400] = "Group_Created";
    EventType[EventType["Group_Updated"] = 1401] = "Group_Updated";
    EventType[EventType["Group_Deleted"] = 1402] = "Group_Deleted";
    EventType[EventType["OrganizationUser_Invited"] = 1500] = "OrganizationUser_Invited";
    EventType[EventType["OrganizationUser_Confirmed"] = 1501] = "OrganizationUser_Confirmed";
    EventType[EventType["OrganizationUser_Updated"] = 1502] = "OrganizationUser_Updated";
    EventType[EventType["OrganizationUser_Removed"] = 1503] = "OrganizationUser_Removed";
    EventType[EventType["OrganizationUser_UpdatedGroups"] = 1504] = "OrganizationUser_UpdatedGroups";
    EventType[EventType["OrganizationUser_UnlinkedSso"] = 1505] = "OrganizationUser_UnlinkedSso";
    EventType[EventType["OrganizationUser_ResetPassword_Enroll"] = 1506] = "OrganizationUser_ResetPassword_Enroll";
    EventType[EventType["OrganizationUser_ResetPassword_Withdraw"] = 1507] = "OrganizationUser_ResetPassword_Withdraw";
    EventType[EventType["OrganizationUser_AdminResetPassword"] = 1508] = "OrganizationUser_AdminResetPassword";
    EventType[EventType["OrganizationUser_ResetSsoLink"] = 1509] = "OrganizationUser_ResetSsoLink";
    EventType[EventType["OrganizationUser_FirstSsoLogin"] = 1510] = "OrganizationUser_FirstSsoLogin";
    EventType[EventType["OrganizationUser_Revoked"] = 1511] = "OrganizationUser_Revoked";
    EventType[EventType["OrganizationUser_Restored"] = 1512] = "OrganizationUser_Restored";
    EventType[EventType["OrganizationUser_ApprovedAuthRequest"] = 1513] = "OrganizationUser_ApprovedAuthRequest";
    EventType[EventType["OrganizationUser_RejectedAuthRequest"] = 1514] = "OrganizationUser_RejectedAuthRequest";
    EventType[EventType["OrganizationUser_Deleted"] = 1515] = "OrganizationUser_Deleted";
    EventType[EventType["OrganizationUser_Left"] = 1516] = "OrganizationUser_Left";
    EventType[EventType["OrganizationUser_AutomaticallyConfirmed"] = 1517] = "OrganizationUser_AutomaticallyConfirmed";
    EventType[EventType["OrganizationUser_SelfRevoked"] = 1518] = "OrganizationUser_SelfRevoked";
    EventType[EventType["OrganizationUser_AdminResetTwoFactor"] = 1519] = "OrganizationUser_AdminResetTwoFactor";
    EventType[EventType["OrganizationUser_Revoked_TwoFactorNonCompliance"] = 1520] = "OrganizationUser_Revoked_TwoFactorNonCompliance";
    EventType[EventType["OrganizationUser_Revoked_SingleOrganizationNonCompliance"] = 1521] = "OrganizationUser_Revoked_SingleOrganizationNonCompliance";
    EventType[EventType["OrganizationUser_NotificationBannerActionClicked"] = 1522] = "OrganizationUser_NotificationBannerActionClicked";
    EventType[EventType["OrganizationUser_Staged"] = 1523] = "OrganizationUser_Staged";
    EventType[EventType["OrganizationUser_InviteLinkAccepted"] = 1524] = "OrganizationUser_InviteLinkAccepted";
    EventType[EventType["Organization_Updated"] = 1600] = "Organization_Updated";
    EventType[EventType["Organization_PurgedVault"] = 1601] = "Organization_PurgedVault";
    EventType[EventType["Organization_ClientExportedVault"] = 1602] = "Organization_ClientExportedVault";
    EventType[EventType["Organization_VaultAccessed"] = 1603] = "Organization_VaultAccessed";
    EventType[EventType["Organization_EnabledSso"] = 1604] = "Organization_EnabledSso";
    EventType[EventType["Organization_DisabledSso"] = 1605] = "Organization_DisabledSso";
    EventType[EventType["Organization_EnabledKeyConnector"] = 1606] = "Organization_EnabledKeyConnector";
    EventType[EventType["Organization_DisabledKeyConnector"] = 1607] = "Organization_DisabledKeyConnector";
    EventType[EventType["Organization_SponsorshipsSynced"] = 1608] = "Organization_SponsorshipsSynced";
    EventType[EventType["Organization_CollectionManagementUpdated"] = 1609] = "Organization_CollectionManagementUpdated";
    EventType[EventType["Organization_CollectionManagement_LimitCollectionCreationEnabled"] = 1610] = "Organization_CollectionManagement_LimitCollectionCreationEnabled";
    EventType[EventType["Organization_CollectionManagement_LimitCollectionCreationDisabled"] = 1611] = "Organization_CollectionManagement_LimitCollectionCreationDisabled";
    EventType[EventType["Organization_CollectionManagement_LimitCollectionDeletionEnabled"] = 1612] = "Organization_CollectionManagement_LimitCollectionDeletionEnabled";
    EventType[EventType["Organization_CollectionManagement_LimitCollectionDeletionDisabled"] = 1613] = "Organization_CollectionManagement_LimitCollectionDeletionDisabled";
    EventType[EventType["Organization_CollectionManagement_LimitItemDeletionEnabled"] = 1614] = "Organization_CollectionManagement_LimitItemDeletionEnabled";
    EventType[EventType["Organization_CollectionManagement_LimitItemDeletionDisabled"] = 1615] = "Organization_CollectionManagement_LimitItemDeletionDisabled";
    EventType[EventType["Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled"] = 1616] = "Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled";
    EventType[EventType["Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled"] = 1617] = "Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled";
    EventType[EventType["Organization_ItemOrganization_Accepted"] = 1618] = "Organization_ItemOrganization_Accepted";
    EventType[EventType["Organization_ItemOrganization_Declined"] = 1619] = "Organization_ItemOrganization_Declined";
    EventType[EventType["Organization_AutoConfirmEnabled_Admin"] = 1620] = "Organization_AutoConfirmEnabled_Admin";
    EventType[EventType["Organization_AutoConfirmDisabled_Admin"] = 1621] = "Organization_AutoConfirmDisabled_Admin";
    EventType[EventType["Organization_AutoConfirmEnabled_Portal"] = 1622] = "Organization_AutoConfirmEnabled_Portal";
    EventType[EventType["Organization_AutoConfirmDisabled_Portal"] = 1623] = "Organization_AutoConfirmDisabled_Portal";
    EventType[EventType["Organization_InviteLinkCreated"] = 1624] = "Organization_InviteLinkCreated";
    EventType[EventType["Organization_InviteLinkDomainsEdited"] = 1625] = "Organization_InviteLinkDomainsEdited";
    EventType[EventType["Organization_InviteLinkDeleted"] = 1626] = "Organization_InviteLinkDeleted";
    EventType[EventType["Organization_InviteLinkClientCopied"] = 1627] = "Organization_InviteLinkClientCopied";
    EventType[EventType["Organization_InviteLinkRefreshed"] = 1628] = "Organization_InviteLinkRefreshed";
    EventType[EventType["Policy_Updated"] = 1700] = "Policy_Updated";
    EventType[EventType["ProviderUser_Invited"] = 1800] = "ProviderUser_Invited";
    EventType[EventType["ProviderUser_Confirmed"] = 1801] = "ProviderUser_Confirmed";
    EventType[EventType["ProviderUser_Updated"] = 1802] = "ProviderUser_Updated";
    EventType[EventType["ProviderUser_Removed"] = 1803] = "ProviderUser_Removed";
    EventType[EventType["ProviderOrganization_Created"] = 1900] = "ProviderOrganization_Created";
    EventType[EventType["ProviderOrganization_Added"] = 1901] = "ProviderOrganization_Added";
    EventType[EventType["ProviderOrganization_Removed"] = 1902] = "ProviderOrganization_Removed";
    EventType[EventType["ProviderOrganization_VaultAccessed"] = 1903] = "ProviderOrganization_VaultAccessed";
    EventType[EventType["OrganizationDomain_Added"] = 2000] = "OrganizationDomain_Added";
    EventType[EventType["OrganizationDomain_Removed"] = 2001] = "OrganizationDomain_Removed";
    EventType[EventType["OrganizationDomain_Verified"] = 2002] = "OrganizationDomain_Verified";
    EventType[EventType["OrganizationDomain_NotVerified"] = 2003] = "OrganizationDomain_NotVerified";
    EventType[EventType["Secret_Retrieved"] = 2100] = "Secret_Retrieved";
    EventType[EventType["Secret_Created"] = 2101] = "Secret_Created";
    EventType[EventType["Secret_Edited"] = 2102] = "Secret_Edited";
    EventType[EventType["Secret_Deleted"] = 2103] = "Secret_Deleted";
    EventType[EventType["Secret_Permanently_Deleted"] = 2104] = "Secret_Permanently_Deleted";
    EventType[EventType["Secret_Restored"] = 2105] = "Secret_Restored";
    EventType[EventType["Project_Retrieved"] = 2200] = "Project_Retrieved";
    EventType[EventType["Project_Created"] = 2201] = "Project_Created";
    EventType[EventType["Project_Edited"] = 2202] = "Project_Edited";
    EventType[EventType["Project_Deleted"] = 2203] = "Project_Deleted";
    EventType[EventType["ServiceAccount_UserAdded"] = 2300] = "ServiceAccount_UserAdded";
    EventType[EventType["ServiceAccount_UserRemoved"] = 2301] = "ServiceAccount_UserRemoved";
    EventType[EventType["ServiceAccount_GroupAdded"] = 2302] = "ServiceAccount_GroupAdded";
    EventType[EventType["ServiceAccount_GroupRemoved"] = 2303] = "ServiceAccount_GroupRemoved";
    EventType[EventType["ServiceAccount_Created"] = 2304] = "ServiceAccount_Created";
    EventType[EventType["ServiceAccount_Deleted"] = 2305] = "ServiceAccount_Deleted";
    EventType[EventType["PhishingBlocker_SiteAccessed"] = 2400] = "PhishingBlocker_SiteAccessed";
    EventType[EventType["PhishingBlocker_SiteExited"] = 2401] = "PhishingBlocker_SiteExited";
    EventType[EventType["PhishingBlocker_Bypassed"] = 2402] = "PhishingBlocker_Bypassed";
    EventType[EventType["Send_Created_Text"] = 2500] = "Send_Created_Text";
    EventType[EventType["Send_Created_Text_WithEmailVerification"] = 2501] = "Send_Created_Text_WithEmailVerification";
    EventType[EventType["Send_Created_Text_WithPasswordProtection"] = 2502] = "Send_Created_Text_WithPasswordProtection";
    EventType[EventType["Send_Created_File"] = 2503] = "Send_Created_File";
    EventType[EventType["Send_Created_File_WithEmailVerification"] = 2504] = "Send_Created_File_WithEmailVerification";
    EventType[EventType["Send_Created_File_WithPasswordProtection"] = 2505] = "Send_Created_File_WithPasswordProtection";
    EventType[EventType["Send_Updated_Text"] = 2506] = "Send_Updated_Text";
    EventType[EventType["Send_Updated_File"] = 2507] = "Send_Updated_File";
    EventType[EventType["Send_Deleted_Text"] = 2508] = "Send_Deleted_Text";
    EventType[EventType["Send_Deleted_File"] = 2509] = "Send_Deleted_File";
    EventType[EventType["Send_Accessed_Text"] = 2510] = "Send_Accessed_Text";
    EventType[EventType["Send_Accessed_File"] = 2511] = "Send_Accessed_File";
})(EventType || (EventType = {}));

;// ../../libs/common/src/dirt/event-logs/enums/event-system-user.enum.ts
// Note: the enum key is used to describe the EventSystemUser in the UI. Be careful about changing it.
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
var EventSystemUser;
(function (EventSystemUser) {
    EventSystemUser[EventSystemUser["SCIM"] = 1] = "SCIM";
    EventSystemUser[EventSystemUser["DomainVerification"] = 2] = "DomainVerification";
    EventSystemUser[EventSystemUser["PublicApi"] = 3] = "PublicApi";
    EventSystemUser[EventSystemUser["BitwardenPortal"] = 5] = "BitwardenPortal";
})(EventSystemUser || (EventSystemUser = {}));

;// ../../libs/common/src/dirt/event-logs/enums/event-category.enum.ts

const EventCategory = {
    UserEvents: "userEvents",
    ItemEvents: "itemEvents",
    CollectionEvents: "collectionEvents",
    GroupEvents: "groupEvents",
    OrganizationMemberEvents: "organizationMemberEvents",
    OrganizationEvents: "organizationEvents",
    ProviderEvents: "providerEvents",
};
const EventCategoryEventTypes = {
    [EventCategory.UserEvents]: [
        EventType.User_LoggedIn,
        EventType.User_ChangedPassword,
        EventType.User_Updated2fa,
        EventType.User_Disabled2fa,
        EventType.User_Recovered2fa,
        EventType.User_FailedLogIn,
        EventType.User_FailedLogIn2fa,
        EventType.User_ClientExportedVault,
        EventType.User_UpdatedTempPassword,
        EventType.User_MigratedKeyToKeyConnector,
        EventType.User_RequestedDeviceApproval,
        EventType.User_TdeOffboardingPasswordSet,
    ],
    [EventCategory.ItemEvents]: [
        EventType.Cipher_Created,
        EventType.Cipher_Updated,
        EventType.Cipher_Deleted,
        EventType.Cipher_AttachmentCreated,
        EventType.Cipher_AttachmentDeleted,
        EventType.Cipher_Shared,
        EventType.Cipher_UpdatedCollections,
        EventType.Cipher_ClientViewed,
        EventType.Cipher_ClientToggledPasswordVisible,
        EventType.Cipher_ClientToggledHiddenFieldVisible,
        EventType.Cipher_ClientToggledCardCodeVisible,
        EventType.Cipher_ClientCopiedPassword,
        EventType.Cipher_ClientCopiedHiddenField,
        EventType.Cipher_ClientCopiedCardCode,
        EventType.Cipher_ClientAutofilled,
        EventType.Cipher_SoftDeleted,
        EventType.Cipher_Restored,
        EventType.Cipher_ClientToggledCardNumberVisible,
        EventType.Cipher_ClientToggledTOTPSeedVisible,
        EventType.Cipher_ClientCopiedBankAccountNumber,
        EventType.Cipher_ClientCopiedBankAccountPin,
        EventType.Cipher_ClientToggledBankAccountNumberVisible,
        EventType.Cipher_ClientToggledBankAccountPinVisible,
        EventType.Cipher_ClientCopiedLicenseNumber,
        EventType.Cipher_ClientToggledLicenseNumberVisible,
        EventType.Cipher_ClientCopiedPassportNumber,
        EventType.Cipher_ClientToggledPassportNumberVisible,
        EventType.Cipher_ClientCopiedNationalIdentificationNumber,
        EventType.Cipher_ClientToggledNationalIdentificationNumberVisible,
        EventType.Cipher_ClientCopiedIban,
        EventType.Cipher_ClientToggledIbanVisible,
        EventType.Cipher_ClientCopiedSwiftCode,
        EventType.Cipher_ClientToggledSwiftCodeVisible,
    ],
    [EventCategory.CollectionEvents]: [
        EventType.Collection_Created,
        EventType.Collection_Updated,
        EventType.Collection_Deleted,
    ],
    [EventCategory.GroupEvents]: [
        EventType.Group_Created,
        EventType.Group_Updated,
        EventType.Group_Deleted,
    ],
    [EventCategory.OrganizationMemberEvents]: [
        EventType.OrganizationUser_Invited,
        EventType.OrganizationUser_Confirmed,
        EventType.OrganizationUser_Updated,
        EventType.OrganizationUser_Removed,
        EventType.OrganizationUser_UpdatedGroups,
        EventType.OrganizationUser_UnlinkedSso,
        EventType.OrganizationUser_ResetPassword_Enroll,
        EventType.OrganizationUser_ResetPassword_Withdraw,
        EventType.OrganizationUser_AdminResetPassword,
        EventType.OrganizationUser_AdminResetTwoFactor,
        EventType.OrganizationUser_ResetSsoLink,
        EventType.OrganizationUser_FirstSsoLogin,
        EventType.OrganizationUser_Revoked,
        EventType.OrganizationUser_Restored,
        EventType.OrganizationUser_ApprovedAuthRequest,
        EventType.OrganizationUser_RejectedAuthRequest,
        EventType.OrganizationUser_Deleted,
        EventType.OrganizationUser_Left,
        EventType.OrganizationUser_SelfRevoked,
        EventType.OrganizationUser_Revoked_TwoFactorNonCompliance,
        EventType.OrganizationUser_Revoked_SingleOrganizationNonCompliance,
        EventType.OrganizationUser_NotificationBannerActionClicked,
    ],
    [EventCategory.OrganizationEvents]: [
        EventType.Organization_Updated,
        EventType.Organization_PurgedVault,
        EventType.Organization_ClientExportedVault,
        EventType.Organization_VaultAccessed,
        EventType.Organization_EnabledSso,
        EventType.Organization_DisabledSso,
        EventType.Organization_EnabledKeyConnector,
        EventType.Organization_DisabledKeyConnector,
        EventType.Organization_SponsorshipsSynced,
        EventType.Organization_CollectionManagementUpdated,
        EventType.Organization_CollectionManagement_LimitCollectionCreationEnabled,
        EventType.Organization_CollectionManagement_LimitCollectionCreationDisabled,
        EventType.Organization_CollectionManagement_LimitCollectionDeletionEnabled,
        EventType.Organization_CollectionManagement_LimitCollectionDeletionDisabled,
        EventType.Organization_CollectionManagement_LimitItemDeletionEnabled,
        EventType.Organization_CollectionManagement_LimitItemDeletionDisabled,
        EventType.Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled,
        EventType.Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled,
    ],
    [EventCategory.ProviderEvents]: [
        EventType.ProviderUser_Invited,
        EventType.ProviderUser_Confirmed,
        EventType.ProviderUser_Updated,
        EventType.ProviderUser_Removed,
        EventType.ProviderOrganization_Created,
        EventType.ProviderOrganization_Added,
        EventType.ProviderOrganization_Removed,
        EventType.ProviderOrganization_VaultAccessed,
    ],
};

;// ../../libs/common/src/models/response/base.response.ts
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
class BaseResponse {
    constructor(response) {
        this.response = response;
    }
    getResponseProperty(propertyName, response = null, exactName = false) {
        if (propertyName == null || propertyName === "") {
            throw new Error("propertyName must not be null/empty.");
        }
        if (response == null && this.response != null) {
            response = this.response;
        }
        if (response == null) {
            return null;
        }
        if (!exactName && response[propertyName] === undefined) {
            let otherCasePropertyName = null;
            if (propertyName.charAt(0) === propertyName.charAt(0).toUpperCase()) {
                otherCasePropertyName = propertyName.charAt(0).toLowerCase();
            }
            else {
                otherCasePropertyName = propertyName.charAt(0).toUpperCase();
            }
            if (propertyName.length > 1) {
                otherCasePropertyName += propertyName.slice(1);
            }
            propertyName = otherCasePropertyName;
            if (response[propertyName] === undefined) {
                propertyName = propertyName.toLowerCase();
            }
            if (response[propertyName] === undefined) {
                propertyName = propertyName.toUpperCase();
            }
        }
        return response[propertyName];
    }
}

;// ../../libs/common/src/dirt/event-logs/models/response/event.response.ts

class EventResponse extends BaseResponse {
    constructor(response) {
        super(response);
        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");
        this.systemUser = this.getResponseProperty("SystemUser");
        this.domainName = this.getResponseProperty("DomainName");
        this.secretId = this.getResponseProperty("SecretId");
        this.projectId = this.getResponseProperty("ProjectId");
        this.serviceAccountId = this.getResponseProperty("ServiceAccountId");
        this.grantedServiceAccountId = this.getResponseProperty("GrantedServiceAccountId");
        this.sendId = this.getResponseProperty("SendId");
    }
}

;// ../../libs/common/src/dirt/event-logs/models/data/event.data.ts
class EventData {
    static fromJSON(obj) {
        return Object.assign(new EventData(), obj);
    }
}

;// ../../libs/common/src/dirt/event-logs/services/key-definitions.ts


const key_definitions_EVENT_COLLECTION = UserKeyDefinition.array(EVENT_COLLECTION_DISK, "events", {
    deserializer: (s) => EventData.fromJSON(s),
    clearOn: ["logout"],
});

;// ../../libs/common/src/dirt/event-logs/index.ts
// Enums



// Models




// Abstractions (export abstract classes)




;// ../../libs/common/src/models/domain/domain-service.ts
/*
  See full documentation at:
    https://bitwarden.com/help/uri-match-detection/#match-detection-options

  Domain: "the top-level domain and second-level domain of the URI match the detected resource",
  Host: "the hostname and (if specified) port of the URI matches the detected resource",
  StartsWith: "the detected resource starts with the URI, regardless of what follows it",
  Exact: "the URI matches the detected resource exactly",
  RegularExpression: "the detected resource matches a specified regular expression",
  Never: "never offer auto-fill for the item",
*/
const domain_service_UriMatchStrategy = {
    Domain: 0,
    Host: 1,
    StartsWith: 2,
    Exact: 3,
    RegularExpression: 4,
    Never: 5,
};
/**
 * Normalizes UriMatchStrategySetting for SDK mapping.
 * @param value - The URI match strategy from user data
 * @returns Valid UriMatchType or undefined if invalid
 */
function normalizeUriMatchStrategyForSdk(value) {
    if (value == null) {
        return undefined;
    }
    switch (value) {
        case 0: // Domain
        case 1: // Host
        case 2: // StartsWith
        case 3: // Exact
        case 4: // RegularExpression
        case 5: // Never
            return value;
        default:
            return undefined;
    }
}

;// ../../node_modules/rxjs/dist/esm5/internal/observable/interval.js
function interval(period,scheduler){if(period===void 0){period=0;}if(scheduler===void 0){scheduler=async_asyncScheduler;}if(period<0){period=0;}return timer(period,period,scheduler);}
;// ../../node_modules/rxjs/dist/esm5/internal/operators/takeWhile.js
function takeWhile(predicate,inclusive){if(inclusive===void 0){inclusive=false;}return operate(function(source,subscriber){var index=0;source.subscribe(createOperatorSubscriber(subscriber,function(value){var result=predicate(value,index++);(result||inclusive)&&subscriber.next(value);!result&&subscriber.complete();}));});}
;// ./src/platform/browser/browser-popup-utils.ts
var browser_popup_utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore


/**
 *
 * Value represents width in pixels
 */
const PopupWidthOptions = Object.freeze({
    default: 480,
    wide: 600,
    narrow: 380,
});
/** localStorage key used to cache the user's configured popup width. */
const POPUP_WIDTH_STORAGE_KEY = "bw-popup-width";
class BrowserPopupUtils {
    /**
     * Identifies if the popup is within the sidebar.
     *
     * @param win - The passed window object.
     */
    static inSidebar(win) {
        return BrowserPopupUtils.urlContainsSearchParams(win, "uilocation", "sidebar");
    }
    /**
     * Identifies if the popup is within the popout.
     *
     * @param win - The passed window object.
     */
    static inPopout(win) {
        return BrowserPopupUtils.urlContainsSearchParams(win, "uilocation", "popout");
    }
    /**
     * Identifies if the popup is within the Chrome Side Panel.
     *
     * @param win - The passed window object.
     */
    static inSidePanel(win) {
        return BrowserPopupUtils.urlContainsSearchParams(win, "uilocation", "sidepanel");
    }
    /**
     * Check if the current popup view is open inside of the current browser tab
     * (it is possible in Chrome to open the extension in a tab)
     */
    static isInTab() {
        return browser_popup_utils_awaiter(this, void 0, void 0, function* () {
            var _a;
            const tabId = (_a = (yield BrowserApi.getCurrentTab())) === null || _a === void 0 ? void 0 : _a.id;
            if (tabId === undefined || tabId === null) {
                return false;
            }
            const result = BrowserApi.getExtensionViews({ tabId, type: "tab" });
            return result.length > 0;
        });
    }
    /**
     * Identifies if the popup is within the single action popout.
     *
     * @param win - The passed window object.
     * @param popoutKey - The single action popout key used to identify the popout.
     */
    static inSingleActionPopout(win, popoutKey) {
        return BrowserPopupUtils.urlContainsSearchParams(win, "singleActionPopout", popoutKey);
    }
    /**
     * Identifies if the popup is within the popup.
     *
     * @param win - The passed window object.
     */
    static inPopup(win) {
        return (win.location.href.indexOf("uilocation=") === -1 ||
            win.location.href.indexOf("uilocation=popup") > -1);
    }
    /**
     * Gets the scroll position of the popup.
     *
     * @param win - The passed window object.
     * @param scrollingContainer - Element tag name of the scrolling container.
     */
    static getContentScrollY(win, scrollingContainer = "main") {
        const content = win.document.getElementsByTagName(scrollingContainer)[0];
        return content.scrollTop;
    }
    /**
     * Sets the scroll position of the popup.
     *
     * @param win - The passed window object.
     * @param scrollYAmount - The amount to scroll the popup.
     * @param options - Allows for setting the delay in ms to wait before scrolling the popup and the scrolling container tag name.
     */
    static setContentScrollY(win_1, scrollYAmount_1) {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (win, scrollYAmount, options = {
            delay: 0,
            containerSelector: "main",
        }) {
            const { delay, containerSelector } = options;
            return new Promise((resolve) => win.setTimeout(() => {
                const container = win.document.querySelector(containerSelector);
                if (!isNaN(scrollYAmount) && container) {
                    container.scrollTop = scrollYAmount;
                }
                resolve();
            }, delay));
        });
    }
    /**
     * Identifies if the background page needs to be initialized.
     */
    static backgroundInitializationRequired() {
        return !BrowserApi.getBackgroundPage() || BrowserApi.isManifestVersion(3);
    }
    /**
     * Opens a popout window of any extension page. If the popout window is already open, it will be focused.
     *
     * @param extensionUrlPath - A relative path to the extension page. Example: "popup/index.html#/tabs/vault"
     * @param options - Options for the popout window that overrides the default options.
     */
    static openPopout(extensionUrlPath_1) {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (extensionUrlPath, options = {}) {
            const { senderWindowId, singleActionKey, forceCloseExistingWindows, windowOptions } = options;
            const defaultPopoutWindowOptions = {
                type: "popup",
                focused: true,
                width: yield BrowserPopupUtils.getPopupWidth(),
                height: 630,
            };
            const offsetRight = 15;
            const offsetTop = 90;
            const popupWidth = defaultPopoutWindowOptions.width;
            const senderWindow = yield BrowserApi.getWindow(senderWindowId);
            // On Wayland, browser window coordinates are not being precisely reported. This is
            // particularly troublesome for multi-monitor configurations, where the popup can be placed
            // far enough outside the visible area that the browser refuses to create the window and emits
            // an error: Invalid value for bounds. Bounds must be at least 50% within visible screen space.
            // It is acceptable that this heuristic may fire for X11 sessions.
            const operatingSystemIsLinux = (yield BrowserApi.getPlatformInfo()).os === "linux";
            const coordsMaybeNotPrecise = senderWindow.left === 0 && senderWindow.top === 0;
            const canPositionWindow = !(operatingSystemIsLinux && coordsMaybeNotPrecise);
            const positionOptions = canPositionWindow
                ? {
                    left: senderWindow.left + senderWindow.width - popupWidth - offsetRight,
                    top: senderWindow.top + offsetTop,
                }
                : {};
            const popoutWindowOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultPopoutWindowOptions), positionOptions), windowOptions), { url: BrowserPopupUtils.buildPopoutUrl(extensionUrlPath, singleActionKey) });
            if ((yield BrowserPopupUtils.isSingleActionPopoutOpen(singleActionKey, popoutWindowOptions, forceCloseExistingWindows)) &&
                !forceCloseExistingWindows) {
                return;
            }
            return yield BrowserApi.createWindow(popoutWindowOptions);
        });
    }
    /**
     * Closes the single action popout window.
     *
     * @param popoutKey - The single action popout key used to identify the popout.
     * @param delayClose - The amount of time to wait before closing the popout. Defaults to 0.
     */
    static closeSingleActionPopout(popoutKey_1) {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (popoutKey, delayClose = 0) {
            const extensionUrl = chrome.runtime.getURL("popup/index.html");
            const tabs = yield BrowserApi.tabsQuery({ url: `${extensionUrl}*` });
            for (const tab of tabs) {
                if (!tab.url.includes(`singleActionPopout=${popoutKey}`)) {
                    continue;
                }
                setTimeout(() => BrowserApi.removeWindow(tab.windowId), delayClose);
            }
        });
    }
    /**
     * Opens a popout window for the current page.
     * If the current page is set for the current tab, then the
     * popout window will be set for the vault items listing tab.
     *
     * @param win - The passed window object.
     * @param href - The href to open in the popout window.
     */
    static openCurrentPagePopout(win_1) {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (win, href = null) {
            const popoutUrl = href || win.location.href;
            const parsedUrl = new URL(popoutUrl);
            let hashRoute = parsedUrl.hash;
            if (hashRoute.startsWith("#/tabs/current")) {
                hashRoute = "#/tabs/vault";
            }
            yield BrowserPopupUtils.openPopout(`${parsedUrl.pathname}${hashRoute}`);
            if (BrowserPopupUtils.inPopup(win)) {
                BrowserApi.closePopup(win);
            }
        });
    }
    /**
     * Closes the current popup or popout window from inside that window.
     *
     * @param win - The passed window object.
     */
    static closeCurrentPopupOrPopout(win) {
        return browser_popup_utils_awaiter(this, void 0, void 0, function* () {
            if (BrowserPopupUtils.inPopup(win)) {
                BrowserApi.closePopup(win);
                return;
            }
            if (BrowserPopupUtils.inPopout(win)) {
                const currentWindow = yield BrowserApi.getWindow();
                if ((currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.id) != null) {
                    yield BrowserApi.removeWindow(currentWindow.id);
                }
            }
        });
    }
    /**
     * Waits for the toolbar popup and any popout windows to close, polling up to the specified
     * timeout. Used before extension reload to prevent zombie views with invalidated contexts.
     *
     * @param timeoutMs - Maximum time to wait in milliseconds. Defaults to 1 second.
     * @returns Promise that resolves when all popup/popout views are closed or timeout is reached.
     */
    static waitForAllPopupsClose() {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (timeoutMs = 1000) {
            yield firstValueFrom(interval(100).pipe(switchMap(() => BrowserApi.isAnyPopupOrPopoutOpen()), takeWhile((isOpen) => isOpen, true), filter((isOpen) => !isOpen), timeout_timeout({
                first: timeoutMs,
                with: () => of(true),
            })));
        });
    }
    /**
     * Returns the configured popup window width in pixels.
     *
     * Reads the user's stored width preference from localStorage when available (popup context),
     * falls back to chrome.storage.local for background/service-worker contexts, and finally
     * falls back to the default width.
     */
    static getPopupWidth() {
        return browser_popup_utils_awaiter(this, void 0, void 0, function* () {
            // Popup context: localStorage is synchronously available
            if (typeof localStorage !== "undefined") {
                const storedWidth = localStorage.getItem(POPUP_WIDTH_STORAGE_KEY);
                if (storedWidth != null && storedWidth in PopupWidthOptions) {
                    return PopupWidthOptions[storedWidth];
                }
            }
            // Background/service-worker context: read from chrome.storage.local
            // Key format is derived from the state framework: global_<stateDefinitionName>_<keyName>
            // Values are stored with a serialization wrapper: { "__json__": true, value: '"narrow"' }
            const chromeStorageKey = "global_popupStyle_popup-width";
            try {
                const result = yield chrome.storage.local.get(chromeStorageKey);
                let storedWidth = result[chromeStorageKey];
                // Deserialize the state framework's serialization wrapper if present
                if (storedWidth != null &&
                    storedWidth["__json__"] === true &&
                    typeof storedWidth.value === "string") {
                    storedWidth = JSON.parse(storedWidth.value);
                }
                if (storedWidth != null && storedWidth in PopupWidthOptions) {
                    return PopupWidthOptions[storedWidth];
                }
            }
            catch (_a) {
                // Ignore storage errors and fall through to the default
            }
            return PopupWidthOptions.default;
        });
    }
    /**
     * Identifies if a single action window is open based on the passed popoutKey.
     * Will focus the existing window, and close any other windows that might exist
     * with the same popout key.
     *
     * @param popoutKey - The single action popout key used to identify the popout.
     * @param windowInfo - The window info to use to update the existing window.
     * @param forceCloseExistingWindows - Identifies if the existing windows should be closed.
     */
    static isSingleActionPopoutOpen(popoutKey_1, windowInfo_1) {
        return browser_popup_utils_awaiter(this, arguments, void 0, function* (popoutKey, windowInfo, forceCloseExistingWindows = false) {
            if (!popoutKey) {
                return false;
            }
            const extensionUrl = chrome.runtime.getURL("popup/index.html");
            const popoutTabs = (yield BrowserApi.tabsQuery({ url: `${extensionUrl}*` })).filter((tab) => tab.url.includes(`singleActionPopout=${popoutKey}`));
            if (popoutTabs.length === 0) {
                return false;
            }
            if (!forceCloseExistingWindows) {
                // Update first, remove it from list
                const tab = popoutTabs.shift();
                yield BrowserApi.updateWindowProperties(tab.windowId, {
                    focused: true,
                    width: windowInfo.width,
                    height: windowInfo.height,
                    top: windowInfo.top,
                    left: windowInfo.left,
                });
            }
            popoutTabs.forEach((tab) => BrowserApi.removeWindow(tab.windowId));
            return true;
        });
    }
    /**
     * Identifies if the url contains the specified search param and value.
     *
     * @param win - The passed window object.
     * @param searchParam - The search param to identify.
     * @param searchValue - The search value to identify.
     */
    static urlContainsSearchParams(win, searchParam, searchValue) {
        return win.location.href.indexOf(`${searchParam}=${searchValue}`) > -1;
    }
    /**
     * Builds the popout url path. Ensures that the uilocation param is set to
     * `popout` and that the singleActionPopout param is set to the passed singleActionKey.
     *
     * @param extensionUrlPath - A relative path to the extension page. Example: "popup/index.html#/tabs/vault"
     * @param singleActionKey - The single action popout key used to identify the popout.
     */
    static buildPopoutUrl(extensionUrlPath, singleActionKey) {
        const parsedUrl = new URL(chrome.runtime.getURL(extensionUrlPath));
        parsedUrl.searchParams.set("uilocation", "popout");
        if (singleActionKey) {
            parsedUrl.searchParams.set("singleActionPopout", singleActionKey);
        }
        return parsedUrl.toString();
    }
}

;// ./src/vault/popup/utils/vault-popout-window.ts
/* unused harmony import specifier */ var vault_popout_window_BrowserApi;
/* unused harmony import specifier */ var vault_popout_window_BrowserPopupUtils;
var vault_popout_window_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};


const VaultPopoutType = {
    viewVaultItem: "vault_viewVaultItem",
    addEditVaultItem: "vault_AddEditVaultItem",
    fido2Popout: "vault_Fido2Popout",
};
/**
 * Opens a popout window that facilitates viewing a vault item.
 *
 * @param senderTab - The tab that sent the request.
 * @param cipherOptions - The cipher id and action to perform.
 */
function openViewVaultItemPopout(senderTab, cipherOptions) {
    return vault_popout_window_awaiter(this, void 0, void 0, function* () {
        const { cipherId, action, forceCloseExistingWindows } = cipherOptions;
        let promptWindowPath = "popup/index.html#/view-cipher";
        let queryParamToken = "?";
        const formatQueryString = (key, value) => {
            const queryString = `${queryParamToken}${key}=${value}`;
            queryParamToken = "&";
            return queryString;
        };
        if (cipherId) {
            promptWindowPath += formatQueryString("cipherId", cipherId);
        }
        if (senderTab.id) {
            promptWindowPath += formatQueryString("senderTabId", String(senderTab.id));
        }
        if (action) {
            promptWindowPath += formatQueryString("action", action);
        }
        yield BrowserPopupUtils.openPopout(promptWindowPath, {
            singleActionKey: `${VaultPopoutType.viewVaultItem}_${cipherId}`,
            senderWindowId: senderTab.windowId,
            forceCloseExistingWindows,
        });
    });
}
/**
 * Closes the view vault item popout window.
 *
 * @param singleActionKey - The single action popout key used to identify the popout.
 * @param delayClose - The amount of time to wait before closing the popout. Defaults to 0.
 */
function closeViewVaultItemPopout(singleActionKey_1) {
    return vault_popout_window_awaiter(this, arguments, void 0, function* (singleActionKey, delayClose = 0) {
        yield vault_popout_window_BrowserPopupUtils.closeSingleActionPopout(singleActionKey, delayClose);
    });
}
/**
 * Opens a popout window that facilitates re-prompting for
 * the password of a vault item.
 *
 * @param senderTab - The tab that sent the request.
 * @param cipherOptions - The cipher id and action to perform.
 */
function openVaultItemPasswordRepromptPopout(senderTab, cipherOptions) {
    return vault_popout_window_awaiter(this, void 0, void 0, function* () {
        yield openViewVaultItemPopout(senderTab, Object.assign({ forceCloseExistingWindows: true }, cipherOptions));
        yield BrowserApi.tabSendMessageData(senderTab, "bgVaultItemRepromptPopoutOpened");
    });
}
/**
 * Opens a popout window that facilitates adding or editing a vault item.
 *
 * @param senderTab - The window id of the sender.
 * @param cipherOptions - Options passed as query params to the popout.
 */
function openAddEditVaultItemPopout(senderTab_1) {
    return vault_popout_window_awaiter(this, arguments, void 0, function* (senderTab, cipherOptions = {}) {
        const { cipherId, cipherType, fillAfterSave } = cipherOptions;
        const { url, windowId } = senderTab;
        let singleActionKey = VaultPopoutType.addEditVaultItem;
        let addEditCipherUrl = "popup/index.html#/edit-cipher";
        let queryParamToken = "?";
        const formatQueryString = (key, value) => {
            const queryString = `${queryParamToken}${key}=${value}`;
            queryParamToken = "&";
            return queryString;
        };
        if (cipherId && !cipherType) {
            singleActionKey += `_${cipherId}`;
            addEditCipherUrl += formatQueryString("cipherId", cipherId);
        }
        if (cipherType && !cipherId) {
            singleActionKey += `_${cipherType}`;
            addEditCipherUrl += formatQueryString("type", String(cipherType));
        }
        if (senderTab.url) {
            addEditCipherUrl += formatQueryString("uri", url);
        }
        if (senderTab.id) {
            addEditCipherUrl += formatQueryString("senderTabId", String(senderTab.id));
        }
        if (fillAfterSave) {
            addEditCipherUrl += formatQueryString("fillAfterSave", "true");
        }
        const extensionUrl = chrome.runtime.getURL("popup/index.html");
        const existingPopupTabs = yield vault_popout_window_BrowserApi.tabsQuery({ url: `${extensionUrl}*` });
        const existingPopup = existingPopupTabs.find((tab) => { var _a; return (_a = tab.url) === null || _a === void 0 ? void 0 : _a.includes(`singleActionPopout=${singleActionKey}`); });
        // Check if the an existing popup is already open
        try {
            yield chrome.runtime.sendMessage({
                command: "reloadAddEditCipherData",
                data: { cipherId, cipherType },
            });
            yield vault_popout_window_BrowserApi.updateWindowProperties(existingPopup.windowId, {
                focused: true,
            });
        }
        catch (_a) {
            yield vault_popout_window_BrowserPopupUtils.openPopout(addEditCipherUrl, {
                singleActionKey,
                senderWindowId: windowId,
            });
        }
    });
}
/**
 * Closes the add/edit vault item popout window.
 *
 * @param delayClose - The amount of time to wait before closing the popout. Defaults to 0.
 */
function closeAddEditVaultItemPopout() {
    return vault_popout_window_awaiter(this, arguments, void 0, function* (delayClose = 0) {
        yield vault_popout_window_BrowserPopupUtils.closeSingleActionPopout(VaultPopoutType.addEditVaultItem, delayClose);
    });
}
/**
 * Opens a popout window that facilitates FIDO2
 * authentication and passkey management.
 *
 * @param senderTab - The tab that sent the request.
 * @param options - Options passed as query params to the popout.
 */
function openFido2Popout(senderTab, options) {
    return vault_popout_window_awaiter(this, void 0, void 0, function* () {
        const { sessionId, fallbackSupported } = options;
        const promptWindowPath = "popup/index.html#/fido2" +
            `?sessionId=${sessionId}` +
            `&fallbackSupported=${fallbackSupported}` +
            `&senderTabId=${senderTab.id}` +
            `&senderUrl=${encodeURIComponent(senderTab.url)}`;
        const popoutWindow = yield vault_popout_window_BrowserPopupUtils.openPopout(promptWindowPath, {
            singleActionKey: `${VaultPopoutType.fido2Popout}_${sessionId}`,
            senderWindowId: senderTab.windowId,
            forceCloseExistingWindows: true,
            windowOptions: { height: 570 },
        });
        return popoutWindow.id;
    });
}
/**
 * Closes the FIDO2 popout window associated with the passed session ID.
 *
 * @param sessionId - The session ID of the popout to close.
 */
function closeFido2Popout(sessionId) {
    return vault_popout_window_awaiter(this, void 0, void 0, function* () {
        yield vault_popout_window_BrowserPopupUtils.closeSingleActionPopout(`${VaultPopoutType.fido2Popout}_${sessionId}`);
    });
}


;// ./src/autofill/enums/autofill-message.enums.ts
const AutofillMessageCommand = {
    collectPageDetails: "collectPageDetails",
    collectPageDetailsResponse: "collectPageDetailsResponse",
    pageTransitionDetected: "pageTransitionDetected",
};
const AutofillMessageSender = {
    collectPageDetailsFromTabObservable: "collectPageDetailsFromTabObservable",
};
const AutofillLifecycleCommand = Object.freeze({
    start: "startAutofillMonitors",
    stop: "stopAutofillMonitors",
});
const AutofillerCommand = Object.freeze({
    disable: "disableAutofiller",
});

;// ./src/autofill/models/autofill-script.ts
const FillScriptActionTypes = {
    fill_by_opid: "fill_by_opid",
    click_on_opid: "click_on_opid",
    focus_by_opid: "focus_by_opid",
};
class AutofillScript {
    constructor() {
        this.script = [];
        this.properties = {};
    }
}

;// ../../libs/messaging/src/message.listener.ts

/**
 * A class that allows for listening to messages coming through the application,
 * allows for listening of all messages or just the messages you care about.
 *
 * @note Consider NOT using messaging at all if you can. State Providers offer an observable stream of
 * data that is persisted. This can serve messages that might have been used to notify of settings changes
 * or vault data changes and those observables should be preferred over messaging.
 */
class MessageListener {
    constructor(messageStream) {
        this.messageStream = messageStream;
        /**
         * A stream of all messages sent through the application. It does not contain type information for the
         * other properties on the messages. You are encouraged to instead subscribe to an individual message
         * through {@link messages$}.
         */
        this.allMessages$ = this.messageStream;
    }
    /**
     * Creates an observable stream filtered to just the command given via the {@link CommandDefinition} and typed
     * to the generic contained in the CommandDefinition. Be careful using this method unless all your messages are being
     * sent through `MessageSender.send`, if that isn't the case you should have lower confidence in the message
     * payload being the expected type.
     *
     * @param commandDefinition The CommandDefinition containing the information about the message type you care about.
     */
    messages$(commandDefinition) {
        return this.allMessages$.pipe(filter((msg) => (msg === null || msg === void 0 ? void 0 : msg.command) === commandDefinition.command));
    }
}
/**
 * A helper property for returning a MessageListener that will never emit any messages and will immediately complete.
 */
MessageListener.EMPTY = new MessageListener(EMPTY);

;// ../../libs/messaging/src/message.sender.ts
class MultiMessageSender {
    constructor(innerMessageSenders) {
        this.innerMessageSenders = innerMessageSenders;
    }
    send(commandDefinition, payload = {}) {
        for (const messageSender of this.innerMessageSenders) {
            messageSender.send(commandDefinition, payload);
        }
    }
}
class MessageSender {
    /**
     * A helper method for combine multiple {@link MessageSender}'s.
     * @param messageSenders The message senders that should be combined.
     * @returns A message sender that will relay all messages to the given message senders.
     */
    static combine(...messageSenders) {
        return new MultiMessageSender(messageSenders);
    }
}
/**
 * A helper property for creating a {@link MessageSender} that sends to nowhere.
 */
MessageSender.EMPTY = new MultiMessageSender([]);

;// ../../libs/messaging/src/types.ts
/**
 * A class for defining information about a message, this is helpful
 * alonside `MessageSender` and `MessageListener` for providing a type
 * safe(-ish) way of sending and receiving messages.
 */
class CommandDefinition {
    constructor(command) {
        this.command = command;
    }
}

;// ../../libs/messaging/src/is-external-message.ts
const EXTERNAL_SOURCE_TAG = Symbol("externalSource");
const isExternalMessage = (message) => {
    return (message === null || message === void 0 ? void 0 : message[EXTERNAL_SOURCE_TAG]) === true;
};

;// ../../libs/messaging/src/helpers.ts
/* unused harmony import specifier */ var helpers_map;
/* unused harmony import specifier */ var helpers_EXTERNAL_SOURCE_TAG;


const getCommand = (commandDefinition) => {
    if (typeof commandDefinition === "string") {
        return commandDefinition;
    }
    else {
        return commandDefinition.command;
    }
};
const tagAsExternal = () => {
    return helpers_map((message) => {
        return Object.assign(message, { [helpers_EXTERNAL_SOURCE_TAG]: true });
    });
};

;// ../../libs/messaging/src/subject-message.sender.ts
/* unused harmony import specifier */ var subject_message_sender_getCommand;

class SubjectMessageSender {
    constructor(messagesSubject) {
        this.messagesSubject = messagesSubject;
    }
    send(commandDefinition, payload = {}) {
        const command = subject_message_sender_getCommand(commandDefinition);
        this.messagesSubject.next(Object.assign(payload !== null && payload !== void 0 ? payload : {}, { command: command }));
    }
}

;// ../../libs/messaging/src/index.ts




// Internal implementations



;// ../../libs/common/src/platform/messaging/index.ts


;// ./src/autofill/services/abstractions/autofill.service.ts


const COLLECT_PAGE_DETAILS_RESPONSE_COMMAND = new CommandDefinition(AutofillMessageCommand.collectPageDetailsResponse);
class AutofillService {
}

;// ./src/autofill/services/autofill.service.ts
var autofill_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};











// FIXME (PM-22628): Popup imports are forbidden in background
// eslint-disable-next-line no-restricted-imports







/**
 * A Login cipher stores a single `login.username` that represents whatever the
 * primary login identifier is (an actual username, an email, or a phone number).
 * A targeting-rule `account-login` form may expose that identifier under any of
 * these field types (and often has no `username` field at all). When filling a
 * Login cipher, route `login.username` to the highest-priority identifier field
 * present in the form, in this order, and skip the others.
 */
const loginIdentifierQualifierPriority = [
    AutofillTargetingRuleTypes.username,
    AutofillTargetingRuleTypes.email,
    AutofillTargetingRuleTypes.phone,
];
class autofill_service_AutofillService {
    constructor(cipherService, autofillSettingsService, totpService, eventCollectionService, logService, domainSettingsService, userVerificationService, billingAccountProfileStateService, scriptInjectorService, accountService, authService, userNotificationSettingsService, messageListener, animationControlService, autofillLifecycleService) {
        this.cipherService = cipherService;
        this.autofillSettingsService = autofillSettingsService;
        this.totpService = totpService;
        this.eventCollectionService = eventCollectionService;
        this.logService = logService;
        this.domainSettingsService = domainSettingsService;
        this.userVerificationService = userVerificationService;
        this.billingAccountProfileStateService = billingAccountProfileStateService;
        this.scriptInjectorService = scriptInjectorService;
        this.accountService = accountService;
        this.authService = authService;
        this.userNotificationSettingsService = userNotificationSettingsService;
        this.messageListener = messageListener;
        this.animationControlService = animationControlService;
        this.autofillLifecycleService = autofillLifecycleService;
        this.openVaultItemPasswordRepromptPopout = openVaultItemPasswordRepromptPopout;
        this.currentlyOpeningPasswordRepromptPopout = false;
        this.enableInlineMenuAnimation$ = this.animationControlService.enableInlineMenuAnimation$;
        this.enableNotificationAnimation$ = this.animationControlService.enableNotificationAnimation$;
    }
    /**
     * Collects page details from the specific tab. This method returns an observable that can
     * be subscribed to in order to build the results from all collectPageDetailsResponse
     * messages from the given tab.
     *
     * @param tab The tab to collect page details from
     */
    collectPageDetailsFromTab$(tab) {
        /** Replay Subject that can be utilized when `messages$` may not emit the page details. */
        const pageDetailsFallback$ = new ReplaySubject(1);
        const pageDetailsFromTab$ = this.messageListener
            .messages$(COLLECT_PAGE_DETAILS_RESPONSE_COMMAND)
            .pipe(filter((message) => {
            var _a;
            return message.sender === AutofillMessageSender.collectPageDetailsFromTabObservable &&
                ((_a = message.tab) === null || _a === void 0 ? void 0 : _a.id) === tab.id;
        }), scan((acc, message) => {
            var _a;
            return ((_a = message.webExtSender) === null || _a === void 0 ? void 0 : _a.frameId) === undefined
                ? acc
                : [
                    ...acc,
                    {
                        frameId: message.webExtSender.frameId,
                        tab: message.tab,
                        details: message.details,
                    },
                ];
        }, []));
        void BrowserApi.tabSendMessage(tab, {
            tab: tab,
            command: AutofillMessageCommand.collectPageDetails,
            sender: AutofillMessageSender.collectPageDetailsFromTabObservable,
        }, undefined, true).catch(() => {
            // When `tabSendMessage` throws an error the `pageDetailsFromTab$` will not emit,
            // fallback to an empty array
            pageDetailsFallback$.next([]);
        });
        // Fallback to empty array when:
        // - In Safari, `tabSendMessage` doesn't throw an error for this case.
        // - When opening the extension directly via the URL, `tabSendMessage` doesn't always respond nor throw an error in FireFox.
        //   Adding checks for the major 3 browsers here to be safe.
        const urlHasBrowserProtocol = [
            "moz-extension://",
            "chrome-extension://",
            "safari-web-extension://",
        ].some((protocol) => { var _a; return (_a = tab.url) === null || _a === void 0 ? void 0 : _a.startsWith(protocol); });
        if (!tab.url || urlHasBrowserProtocol) {
            pageDetailsFallback$.next([]);
        }
        // Share the pageDetailsFromTab$ observable so that multiple subscribers don't trigger multiple executions.
        const sharedPageDetailsFromTab$ = pageDetailsFromTab$.pipe(share());
        // Create a timeout observable that emits an empty array if pageDetailsFromTab$ hasn't emitted within 1 second.
        const pageDetailsTimeout$ = timer(1000).pipe(map(() => []), takeUntil(sharedPageDetailsFromTab$));
        // Merge the responses so that if pageDetailsFromTab$ emits, that value is used.
        // Otherwise, if it doesn't emit in time, the timeout observable emits an empty array.
        // Also, pageDetailsFallback$ will emit in error cases.
        return merge(sharedPageDetailsFromTab$, pageDetailsFallback$, pageDetailsTimeout$);
    }
    /**
     * Triggers on installation of the extension Handles injecting
     * content scripts into all tabs that are currently open, and
     * sets up a listener to ensure content scripts can identify
     * if the extension context has been disconnected.
     */
    loadAutofillScriptsOnInstall() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            void this.injectAutofillScriptsInAllTabs();
            this.autofillSettingsService.inlineMenuVisibility$
                .pipe(startWith(undefined), pairwise())
                .subscribe(([previousSetting, currentSetting]) => this.handleInlineMenuVisibilitySettingsChange(previousSetting, currentSetting));
            this.autofillSettingsService.showInlineMenuCards$
                .pipe(startWith(undefined), pairwise())
                .subscribe(([previousSetting, currentSetting]) => this.handleInlineMenuVisibilitySettingsChange(previousSetting, currentSetting));
            this.autofillSettingsService.showInlineMenuIdentities$
                .pipe(startWith(undefined), pairwise())
                .subscribe(([previousSetting, currentSetting]) => this.handleInlineMenuVisibilitySettingsChange(previousSetting, currentSetting));
        });
    }
    /**
     * Triggers a complete reload of all autofill scripts on tabs open within
     * the user's browsing session. This is done by first disconnecting all
     * existing autofill content script ports, which cleans up existing object
     * instances, and then re-injecting the autofill scripts into all tabs.
     */
    reloadAutofillScripts() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            this.autofillLifecycleService.retireAllFrames();
            void this.injectAutofillScriptsInAllTabs();
        });
    }
    /**
     * Injects the autofill scripts into the current tab and all frames
     * found within the tab. Temporarily, will conditionally inject
     * the refactor of the core autofill script if the feature flag
     * is enabled.
     * @param {chrome.tabs.Tab} tab
     * @param {number} frameId
     * @param {boolean} triggeringOnPageLoad
     */
    injectAutofillScripts(tab_1) {
        return autofill_service_awaiter(this, arguments, void 0, function* (tab, frameId = 0, triggeringOnPageLoad = true) {
            const tabId = tab.id;
            if (tabId === undefined) {
                return;
            }
            // Autofill user settings loaded from state can await the active account state indefinitely
            // if not guarded by an active account check (e.g. the user is logged in)
            const activeAccount = yield firstValueFrom(this.accountService.activeAccount$);
            const authStatus = yield firstValueFrom(this.authService.activeAccountStatus$);
            const accountIsUnlocked = authStatus === AuthenticationStatus.Unlocked;
            let autoFillOnPageLoadIsEnabled = false;
            const injectedScripts = [yield this.getBootstrapAutofillContentScript(activeAccount)];
            if (activeAccount && accountIsUnlocked) {
                autoFillOnPageLoadIsEnabled = yield this.getAutofillOnPageLoad();
            }
            if (triggeringOnPageLoad && autoFillOnPageLoadIsEnabled) {
                injectedScripts.push("autofiller.js");
            }
            if (!triggeringOnPageLoad) {
                yield this.scriptInjectorService.inject({
                    tabId,
                    injectDetails: { file: "content/content-message-handler.js", runAt: "document_start" },
                });
            }
            injectedScripts.push("contextMenuHandler.js");
            for (const injectedScript of injectedScripts) {
                yield this.scriptInjectorService.inject({
                    tabId,
                    injectDetails: {
                        file: `content/${injectedScript}`,
                        runAt: "document_start",
                        frame: frameId,
                    },
                });
            }
            // Now that this frame's scripts are injected, hand off to the lifecycle
            // service to begin monitoring it (when an account is logged in).
            yield this.autofillLifecycleService.startMonitoringFrame(tab, frameId);
        });
    }
    /**
     * Identifies the correct autofill script to inject based on whether the
     * inline menu is enabled, and whether the user has the notification bar
     * enabled.
     *
     * @param activeAccount - The active account
     */
    getBootstrapAutofillContentScript(activeAccount) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            let inlineMenuVisibility = AutofillOverlayVisibility.Off;
            if (activeAccount) {
                inlineMenuVisibility = yield this.getInlineMenuVisibility();
            }
            const enableChangedPasswordPrompt = yield firstValueFrom(this.userNotificationSettingsService.enableChangedPasswordPrompt$);
            const enableAddedLoginPrompt = yield firstValueFrom(this.userNotificationSettingsService.enableAddedLoginPrompt$);
            const isNotificationBarEnabled = enableChangedPasswordPrompt || enableAddedLoginPrompt;
            if (!inlineMenuVisibility && !isNotificationBarEnabled) {
                return "bootstrap-autofill.js";
            }
            if (!inlineMenuVisibility && isNotificationBarEnabled) {
                return "bootstrap-autofill-overlay-notifications.js";
            }
            if (inlineMenuVisibility && !isNotificationBarEnabled) {
                return "bootstrap-autofill-overlay-menu.js";
            }
            return "bootstrap-autofill-overlay.js";
        });
    }
    /**
     * Gets all forms with password fields and formats the data
     * for both forms and password input elements.
     * @param {AutofillPageDetails} pageDetails
     * @returns {FormData[]}
     */
    getFormsWithPasswordFields(pageDetails) {
        const formData = [];
        const passwordFields = autofill_service_AutofillService.loadPasswordFields(pageDetails, true, true, false, true, undefined);
        // TODO: this logic prevents multi-step account creation forms (that just start with email)
        // from being passed on to the notification bar content script - even if autofill-init.js found the form and email field.
        // ex: https://signup.live.com/
        if (passwordFields.length === 0) {
            return formData;
        }
        // Back up check for cases where there are several password fields detected,
        // but they are not all part of the form b/c of bad HTML
        // gather password fields that don't have an enclosing form
        const passwordFieldsWithoutForm = passwordFields.filter((pf) => pf.form === undefined);
        const formKeys = Object.keys(pageDetails.forms);
        const formCount = formKeys.length;
        // if we have 3 password fields and only 1 form, and there are password fields that are not within a form
        // but there is at least one password field within the form, then most likely this is a poorly built password change form
        if (passwordFields.length === 3 && formCount == 1 && passwordFieldsWithoutForm.length > 0) {
            // Only one form so get the singular form key
            const soloFormKey = formKeys[0];
            const atLeastOnePasswordFieldWithinSoloForm = passwordFields.filter((pf) => pf.form !== null && pf.form === soloFormKey).length > 0;
            if (atLeastOnePasswordFieldWithinSoloForm) {
                // We have a form with at least one password field,
                // so let's make an assumption that the password fields without a form are actually part of this form
                passwordFieldsWithoutForm.forEach((pf) => {
                    pf.form = soloFormKey;
                });
            }
        }
        for (const formKey in pageDetails.forms) {
            // eslint-disable-next-line
            if (!pageDetails.forms.hasOwnProperty(formKey)) {
                continue;
            }
            const formPasswordFields = passwordFields.filter((pf) => formKey === pf.form);
            if (formPasswordFields.length > 0) {
                let uf = this.findUsernameField(pageDetails, formPasswordFields[0], false, false, false);
                if (uf == null) {
                    // not able to find any viewable username fields. maybe there are some "hidden" ones?
                    uf = this.findUsernameField(pageDetails, formPasswordFields[0], true, true, false);
                }
                formData.push({
                    form: pageDetails.forms[formKey],
                    password: formPasswordFields[0],
                    username: uf !== null && uf !== void 0 ? uf : null,
                    passwords: formPasswordFields,
                });
            }
        }
        return formData;
    }
    /**
     * Gets the overlay's visibility setting from the autofill settings service.
     */
    getInlineMenuVisibility() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            return yield firstValueFrom(this.autofillSettingsService.inlineMenuVisibility$);
        });
    }
    /**
     * Gets the setting for automatically copying TOTP upon autofill from the autofill settings service.
     */
    getShouldAutoCopyTotp() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            return yield firstValueFrom(this.autofillSettingsService.autoCopyTotp$);
        });
    }
    /**
     * Gets the autofill on page load setting from the autofill settings service.
     */
    getAutofillOnPageLoad() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            return yield firstValueFrom(this.autofillSettingsService.autofillOnPageLoad$);
        });
    }
    /**
     * Gets the default URI match strategy setting from the domain settings service.
     */
    getDefaultUriMatchStrategy() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            return yield firstValueFrom(this.domainSettingsService.resolvedDefaultUriMatchStrategy$);
        });
    }
    /**
     * Autofill a given tab with a given login item
     * @param {AutoFillOptions} options Instructions about the autofill operation, including tab and login item
     * @returns {Promise<string | null>} The TOTP code of the successfully autofilled login, if any
     */
    doAutoFill(options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            const tab = options.tab;
            const tabUrl = tab === null || tab === void 0 ? void 0 : tab.url;
            if (!tabUrl || !options.cipher || !options.pageDetails || !options.pageDetails.length) {
                throw new Error("Nothing to autofill.");
            }
            let totp = null;
            const activeAccount = yield firstValueFrom(this.accountService.activeAccount$);
            let canAccessPremium = false;
            if (activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.id) {
                canAccessPremium = yield firstValueFrom(this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeAccount.id));
            }
            const defaultUriMatch = yield this.getDefaultUriMatchStrategy();
            if (!canAccessPremium) {
                options.cipher.login.totp = undefined;
            }
            let didAutofill = false;
            yield Promise.all(options.pageDetails.map((pd) => autofill_service_awaiter(this, void 0, void 0, function* () {
                var _a;
                // make sure we're still on correct tab
                if (pd.tab.id !== tab.id || pd.tab.url !== tab.url) {
                    return;
                }
                // If we have a focused form, filter the page details to only include fields from that form
                const details = options.focusedFieldForm
                    ? Object.assign(Object.assign({}, pd.details), { fields: pd.details.fields.filter((f) => f.form === options.focusedFieldForm) }) : pd.details;
                const fillScript = yield this.generateFillScript(details, {
                    skipUsernameOnlyFill: options.skipUsernameOnlyFill || false,
                    onlyEmptyFields: options.onlyEmptyFields || false,
                    fillNewPassword: options.fillNewPassword || false,
                    allowTotpAutofill: options.allowTotpAutofill || false,
                    autoSubmitLogin: options.autoSubmitLogin || false,
                    cipher: options.cipher,
                    tabUrl,
                    defaultUriMatch: defaultUriMatch,
                    focusedFieldOpid: options.focusedFieldOpid,
                    inlineMenuFillType: options.inlineMenuFillType,
                });
                if (!fillScript || !fillScript.script || !fillScript.script.length) {
                    return;
                }
                if (fillScript.untrustedIframe &&
                    options.allowUntrustedIframe != undefined &&
                    !options.allowUntrustedIframe) {
                    this.logService.info("Autofill on page load was blocked due to an untrusted iframe.");
                    return;
                }
                // Add a small delay between operations
                fillScript.properties.delay_between_operations = 20;
                didAutofill = true;
                if (!options.skipLastUsed && (activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.id)) {
                    yield this.cipherService.updateLastUsedDate(options.cipher.id, activeAccount.id);
                }
                const showAnimations = (_a = (yield firstValueFrom(this.animationControlService.enableAutofillAnimation$))) !== null && _a !== void 0 ? _a : true;
                void BrowserApi.tabSendMessage(tab, {
                    command: options.autoSubmitLogin ? "triggerAutoSubmitLogin" : "fillForm",
                    fillScript: fillScript,
                    url: tab.url,
                    pageDetailsUrl: pd.details.url,
                    showAnimations,
                }, { frameId: pd.frameId });
                // Skip getting the TOTP code for clipboard in these cases
                if (options.cipher.type !== CipherType.Login ||
                    totp !== null ||
                    !options.cipher.login.totp ||
                    (!canAccessPremium && !options.cipher.organizationUseTotp)) {
                    return;
                }
                const shouldAutoCopyTotp = yield this.getShouldAutoCopyTotp();
                totp = shouldAutoCopyTotp
                    ? (yield firstValueFrom(this.totpService.getCode$(options.cipher.login.totp))).code
                    : null;
            })));
            if (didAutofill) {
                yield this.eventCollectionService.collect(EventType.Cipher_ClientAutofilled, options.cipher.id);
                if (totp !== null) {
                    return totp;
                }
                else {
                    return null;
                }
            }
            else {
                throw new Error("Did not autofill.");
            }
        });
    }
    /**
     * Autofill the specified tab with the next login item from the cache
     * @param {PageDetail[]} pageDetails The data scraped from the page
     * @param {chrome.tabs.Tab} tab The tab to be autofilled
     * @param {boolean} fromCommand Whether the autofill is triggered by a keyboard shortcut (`true`) or autofill on page load (`false`)
     * @param {boolean} autoSubmitLogin Whether the autofill is for an auto-submit login
     * @returns {Promise<string | null>} The TOTP code of the successfully autofilled login, if any
     */
    doAutoFillOnTab(pageDetails_1, tab_1, fromCommand_1) {
        return autofill_service_awaiter(this, arguments, void 0, function* (pageDetails, tab, fromCommand, autoSubmitLogin = false) {
            var _a;
            let cipher;
            const activeUserId = yield firstValueFrom(this.accountService.activeAccount$.pipe(getOptionalUserId));
            if (activeUserId == null) {
                return null;
            }
            if (!tab.url) {
                return null;
            }
            const tabUrl = tab.url;
            if (fromCommand) {
                cipher = yield this.cipherService.getNextCipherForUrl(tabUrl, activeUserId);
            }
            else {
                const lastLaunchedCipher = yield this.cipherService.getLastLaunchedForUrl(tabUrl, activeUserId, true);
                const lastLaunched = (_a = lastLaunchedCipher === null || lastLaunchedCipher === void 0 ? void 0 : lastLaunchedCipher.localData) === null || _a === void 0 ? void 0 : _a.lastLaunched;
                if (lastLaunchedCipher &&
                    lastLaunched &&
                    Date.now().valueOf() - lastLaunched.valueOf() < 30000) {
                    cipher = lastLaunchedCipher;
                }
                else {
                    cipher = yield this.cipherService.getLastUsedForUrl(tabUrl, activeUserId, true);
                }
            }
            if (cipher == null || (cipher.reprompt === CipherRepromptType.Password && !fromCommand)) {
                return null;
            }
            if (yield this.isPasswordRepromptRequired(cipher, tab)) {
                if (fromCommand) {
                    this.cipherService.updateLastUsedIndexForUrl(tabUrl);
                }
                return null;
            }
            const totpCode = yield this.doAutoFill({
                tab: tab,
                cipher: cipher,
                pageDetails: pageDetails,
                skipLastUsed: !fromCommand,
                skipUsernameOnlyFill: !fromCommand,
                onlyEmptyFields: !fromCommand,
                fillNewPassword: fromCommand,
                allowUntrustedIframe: fromCommand,
                allowTotpAutofill: fromCommand,
                autoSubmitLogin,
            });
            // Update last used index as autofill has succeeded
            if (fromCommand) {
                this.cipherService.updateLastUsedIndexForUrl(tabUrl);
            }
            return totpCode;
        });
    }
    /**
     * Checks if the cipher requires password reprompt and opens the password reprompt popout if necessary.
     *
     * @param cipher - The cipher to autofill
     * @param tab - The tab to autofill
     * @param action - override for default action once reprompt is completed successfully
     */
    isPasswordRepromptRequired(cipher, tab, action) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            const userHasMasterPassword = yield this.userVerificationService.hasMasterPassword();
            if (cipher.reprompt === CipherRepromptType.Password && userHasMasterPassword) {
                if (!this.isDebouncingPasswordRepromptPopout()) {
                    yield this.openVaultItemPasswordRepromptPopout(tab, {
                        cipherId: cipher.id,
                        action: action !== null && action !== void 0 ? action : "autofill",
                    });
                }
                return true;
            }
            return false;
        });
    }
    /**
     * Autofill the active tab with the next cipher from the cache
     * @param {PageDetail[]} pageDetails The data scraped from the page
     * @param {boolean} fromCommand Whether the autofill is triggered by a keyboard shortcut (`true`) or autofill on page load (`false`)
     * @returns {Promise<string | null>} The TOTP code of the successfully autofilled login, if any
     */
    doAutoFillActiveTab(pageDetails, fromCommand, cipherType) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c;
            if (!((_c = (_b = (_a = pageDetails[0]) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.fields) === null || _c === void 0 ? void 0 : _c.length)) {
                return null;
            }
            const tab = yield this.getActiveTab();
            if (!tab || !tab.url) {
                return null;
            }
            if (!cipherType || cipherType === CipherType.Login) {
                return yield this.doAutoFillOnTab(pageDetails, tab, fromCommand);
            }
            let cipher;
            let cacheKey = "";
            const activeUserId = yield firstValueFrom(this.accountService.activeAccount$.pipe(getOptionalUserId));
            if (activeUserId == null) {
                return null;
            }
            if (cipherType === CipherType.Card) {
                cacheKey = "cardCiphers";
                cipher = yield this.cipherService.getNextCardCipher(activeUserId);
            }
            else {
                cacheKey = "identityCiphers";
                cipher = yield this.cipherService.getNextIdentityCipher(activeUserId);
            }
            if (!cipher || !cacheKey || (cipher.reprompt === CipherRepromptType.Password && !fromCommand)) {
                return null;
            }
            if (yield this.isPasswordRepromptRequired(cipher, tab)) {
                if (fromCommand) {
                    this.cipherService.updateLastUsedIndexForUrl(cacheKey);
                }
                return null;
            }
            const totpCode = yield this.doAutoFill({
                tab: tab,
                cipher: cipher,
                pageDetails: pageDetails,
                skipLastUsed: !fromCommand,
                skipUsernameOnlyFill: !fromCommand,
                onlyEmptyFields: !fromCommand,
                fillNewPassword: false,
                allowUntrustedIframe: fromCommand,
                allowTotpAutofill: false,
            });
            if (fromCommand) {
                this.cipherService.updateLastUsedIndexForUrl(cacheKey);
            }
            return totpCode;
        });
    }
    /**
     * Activates the autofill on page load org policy.
     */
    setAutoFillOnPageLoadOrgPolicy() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            const autofillOnPageLoadOrgPolicy = yield firstValueFrom(this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$);
            if (autofillOnPageLoadOrgPolicy) {
                yield this.autofillSettingsService.setAutofillOnPageLoad(true);
            }
        });
    }
    /**
     * Gets the active tab from the current window.
     * Throws an error if no tab is found.
     * @returns {Promise<chrome.tabs.Tab>}
     * @private
     */
    getActiveTab() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            const tab = yield BrowserApi.getTabFromCurrentWindow();
            if (!tab) {
                throw new Error("No tab found.");
            }
            return tab;
        });
    }
    /**
     * Generates the autofill script for the specified page details and cipher.
     * @param {AutofillPageDetails} pageDetails
     * @param {GenerateFillScriptOptions} options
     * @returns {Promise<AutofillScript | null>}
     * @private
     */
    generateFillScript(pageDetails, options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            if (!pageDetails || !options.cipher) {
                return null;
            }
            // Check if page details contain targeted fields from targeting rules
            // This operation is mutually-exclusive from heuristic data-gathering
            const pageHasTargetedFields = pageDetails.fields.some(({ targeted }) => targeted === true);
            if (pageHasTargetedFields) {
                const fillAssistEnabled = yield firstValueFrom(this.domainSettingsService.resolvedEnableFillAssist$);
                // We could alternatively retrigger gathering page details with the
                // heuristic strategy, but this code path is mostly defensive and not
                // expected to be hit often, since the entrypoints for this workflow
                // are also expected to be gated.
                if (!fillAssistEnabled) {
                    return null;
                }
                return this.generateTargetedFillScript(pageDetails, options);
            }
            const fillScript = new AutofillScript();
            const filledFields = {};
            const fields = options.cipher.fields;
            if (fields && fields.length) {
                const fieldNames = [];
                fields.forEach((f) => {
                    if (f.name != null && autofill_service_AutofillService.hasValue(f.name)) {
                        fieldNames.push(f.name.toLowerCase());
                    }
                });
                pageDetails.fields.forEach((field) => {
                    const fieldOpid = field.opid;
                    if (fieldOpid == null) {
                        return;
                    }
                    if (Object.prototype.hasOwnProperty.call(filledFields, fieldOpid)) {
                        return;
                    }
                    if (!field.viewable && field.tagName !== "span") {
                        return;
                    }
                    // Check if the input is an untyped/mistyped search input
                    if (autofill_service_AutofillService.isSearchField(field)) {
                        return;
                    }
                    const matchingIndex = this.findMatchingFieldIndex(field, fieldNames);
                    if (matchingIndex > -1) {
                        const matchingField = fields[matchingIndex];
                        let val;
                        if (matchingField.type === FieldType.Linked) {
                            if (matchingField.linkedId == null) {
                                return;
                            }
                            // Assumption: Linked Field is not being used to autofill a boolean value
                            val = options.cipher.linkedFieldValue(matchingField.linkedId);
                        }
                        else {
                            const rawVal = matchingField.value;
                            if (rawVal == null) {
                                if (matchingField.type === FieldType.Boolean) {
                                    val = "false";
                                }
                                else {
                                    return;
                                }
                            }
                            else {
                                val = rawVal;
                            }
                        }
                        filledFields[fieldOpid] = field;
                        autofill_service_AutofillService.fillByOpid(fillScript, field, val);
                    }
                });
            }
            let result = null;
            switch (options.cipher.type) {
                case CipherType.Login:
                    result = yield this.generateLoginFillScript(fillScript, pageDetails, filledFields, options);
                    break;
                case CipherType.Card:
                    result = yield this.generateCardFillScript(fillScript, pageDetails, filledFields, options);
                    break;
                case CipherType.Identity:
                    result = yield this.generateIdentityFillScript(fillScript, pageDetails, filledFields, options);
                    break;
                default:
                    return null;
            }
            return result;
        });
    }
    /**
     * Generates fill script actions for targeted fields, mapping cipher values
     * directly to field types identified by targeting rules. Reuses the standard
     * fill_by_opid actions since targeted elements are cached with synthetic opids.
     */
    generateTargetedFillScript(pageDetails, options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            var _a, _b, _c, _d, _e, _f, _g;
            const fillScript = new AutofillScript();
            const cipher = options.cipher;
            const isPasswordGeneration = options.inlineMenuFillType === InlineMenuFillTypes.PasswordGeneration;
            fillScript.savedUrls =
                (_c = (_b = (_a = cipher.login) === null || _a === void 0 ? void 0 : _a.uris) === null || _b === void 0 ? void 0 : _b.filter((u) => u.match != domain_service_UriMatchStrategy.Never && u.uri != null).map((u) => u.uri)) !== null && _c !== void 0 ? _c : [];
            // Note, targeted fields intentionally skip the untrusted iframe check. The
            // presence of targeting rules represents explicit expectations of the target
            // For a Login cipher, `login.username` fills only the single highest-priority
            // identifier field present in an `account-login` form (see the priority list).
            const isLoginCipher = cipher.type === CipherType.Login;
            const loginIdentifierQualifier = isLoginCipher
                ? this.resolveLoginIdentifierQualifier(pageDetails)
                : null;
            for (const field of pageDetails.fields) {
                if (!field.targeted || !field.fieldQualifier) {
                    continue;
                }
                let value;
                if (isPasswordGeneration && field.fieldQualifier === AutofillTargetingRuleTypes.newPassword) {
                    // The Login cipher is a transient representation of the generated password
                    // value, so the usual logic skipping new password fills does not apply here
                    value = (_e = (_d = cipher.login) === null || _d === void 0 ? void 0 : _d.password) !== null && _e !== void 0 ? _e : null;
                }
                else if (isLoginCipher &&
                    field.formCategory === FormPurposeCategories.AccountLogin &&
                    loginIdentifierQualifierPriority.includes(field.fieldQualifier)) {
                    // The login identifier fills the winning identifier field only; sibling
                    // identifier fields are skipped. This presumes a _login_ form will not require
                    // more than one of a `loginIdentifierQualifierPriority` (e.g. only one of
                    // username, email, or phone number).
                    value =
                        field.fieldQualifier === loginIdentifierQualifier
                            ? ((_g = (_f = cipher.login) === null || _f === void 0 ? void 0 : _f.username) !== null && _g !== void 0 ? _g : null)
                            : null;
                }
                else {
                    value = this.getValueForTargetedFieldType(field.fieldQualifier, cipher);
                }
                if (!value) {
                    continue;
                }
                autofill_service_AutofillService.fillByOpid(fillScript, field, value);
            }
            if (!fillScript.script.length) {
                return null;
            }
            return fillScript;
        });
    }
    /**
     * Determines which identifier field a Login cipher's `login.username` should
     * fill, given the targeted fields present on `account-login` forms. Returns
     * the highest-priority present qualifier (username > email > phone), or null
     * when none are present.
     */
    resolveLoginIdentifierQualifier(pageDetails) {
        var _a;
        const presentIdentifierQualifiers = new Set(pageDetails.fields
            .filter((field) => field.targeted &&
            field.formCategory === FormPurposeCategories.AccountLogin &&
            field.fieldQualifier != null)
            .map((field) => field.fieldQualifier));
        return ((_a = loginIdentifierQualifierPriority.find((qualifier) => presentIdentifierQualifiers.has(qualifier))) !== null && _a !== void 0 ? _a : null);
    }
    /**
     * Maps a targeting rule field type to the corresponding cipher value.
     */
    getValueForTargetedFieldType(fieldType, cipher) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
        // Login fields
        if (fieldType === AutofillTargetingRuleTypes.username) {
            return (_b = (_a = cipher.login) === null || _a === void 0 ? void 0 : _a.username) !== null && _b !== void 0 ? _b : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.password) {
            return (_d = (_c = cipher.login) === null || _c === void 0 ? void 0 : _c.password) !== null && _d !== void 0 ? _d : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.newPassword) {
            return null;
        }
        // Card fields
        if (fieldType === AutofillTargetingRuleTypes.cardholderName) {
            return (_f = (_e = cipher.card) === null || _e === void 0 ? void 0 : _e.cardholderName) !== null && _f !== void 0 ? _f : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardNumber) {
            return (_h = (_g = cipher.card) === null || _g === void 0 ? void 0 : _g.number) !== null && _h !== void 0 ? _h : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardExpirationMonth) {
            return (_k = (_j = cipher.card) === null || _j === void 0 ? void 0 : _j.expMonth) !== null && _k !== void 0 ? _k : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardExpirationYear) {
            return (_m = (_l = cipher.card) === null || _l === void 0 ? void 0 : _l.expYear) !== null && _m !== void 0 ? _m : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardExpirationDate) {
            // FIXME combined expiry format is presumed and should be informed by
            // the target format expectation
            return ((_o = cipher.card) === null || _o === void 0 ? void 0 : _o.expMonth) && ((_p = cipher.card) === null || _p === void 0 ? void 0 : _p.expYear)
                ? `${cipher.card.expMonth}/${cipher.card.expYear}`
                : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardCvv) {
            return (_r = (_q = cipher.card) === null || _q === void 0 ? void 0 : _q.code) !== null && _r !== void 0 ? _r : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.cardType) {
            return (_t = (_s = cipher.card) === null || _s === void 0 ? void 0 : _s.brand) !== null && _t !== void 0 ? _t : null;
        }
        // Identity fields
        if (fieldType === AutofillTargetingRuleTypes.honorificPrefix) {
            return (_v = (_u = cipher.identity) === null || _u === void 0 ? void 0 : _u.title) !== null && _v !== void 0 ? _v : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.firstName) {
            return (_x = (_w = cipher.identity) === null || _w === void 0 ? void 0 : _w.firstName) !== null && _x !== void 0 ? _x : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.middleName) {
            return (_z = (_y = cipher.identity) === null || _y === void 0 ? void 0 : _y.middleName) !== null && _z !== void 0 ? _z : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.lastName) {
            return (_1 = (_0 = cipher.identity) === null || _0 === void 0 ? void 0 : _0.lastName) !== null && _1 !== void 0 ? _1 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.fullName) {
            return (_3 = (_2 = cipher.identity) === null || _2 === void 0 ? void 0 : _2.fullName) !== null && _3 !== void 0 ? _3 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.streetAddress) {
            return (_5 = (_4 = cipher.identity) === null || _4 === void 0 ? void 0 : _4.fullAddress) !== null && _5 !== void 0 ? _5 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.addressLine1) {
            return (_7 = (_6 = cipher.identity) === null || _6 === void 0 ? void 0 : _6.address1) !== null && _7 !== void 0 ? _7 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.addressLine2) {
            return (_9 = (_8 = cipher.identity) === null || _8 === void 0 ? void 0 : _8.address2) !== null && _9 !== void 0 ? _9 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.addressLine3) {
            return (_11 = (_10 = cipher.identity) === null || _10 === void 0 ? void 0 : _10.address3) !== null && _11 !== void 0 ? _11 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.addressLevel2) {
            return (_13 = (_12 = cipher.identity) === null || _12 === void 0 ? void 0 : _12.city) !== null && _13 !== void 0 ? _13 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.addressLevel1) {
            return (_15 = (_14 = cipher.identity) === null || _14 === void 0 ? void 0 : _14.state) !== null && _15 !== void 0 ? _15 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.postalCode) {
            return (_17 = (_16 = cipher.identity) === null || _16 === void 0 ? void 0 : _16.postalCode) !== null && _17 !== void 0 ? _17 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.country) {
            return (_19 = (_18 = cipher.identity) === null || _18 === void 0 ? void 0 : _18.country) !== null && _19 !== void 0 ? _19 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.organization) {
            return (_21 = (_20 = cipher.identity) === null || _20 === void 0 ? void 0 : _20.company) !== null && _21 !== void 0 ? _21 : null;
        }
        if (fieldType === AutofillTargetingRuleTypes.phone) {
            return (_23 = (_22 = cipher.identity) === null || _22 === void 0 ? void 0 : _22.phone) !== null && _23 !== void 0 ? _23 : null;
        }
        // FIXME phone sub-parts (phoneCountryCode, phoneAreaCode, phoneLocal,
        // phoneExtension) can be derived by parsing cipher.identity?.phone
        if (fieldType === AutofillTargetingRuleTypes.email) {
            return (_25 = (_24 = cipher.identity) === null || _24 === void 0 ? void 0 : _24.email) !== null && _25 !== void 0 ? _25 : null;
        }
        return null;
    }
    /**
     * Generates the autofill script for the specified page details and login cipher item.
     * @param {AutofillScript} fillScript
     * @param {AutofillPageDetails} pageDetails
     * @param {{[p: string]: AutofillField}} filledFields
     * @param {GenerateFillScriptOptions} options
     * @returns {Promise<AutofillScript | null>}
     * @private
     */
    generateLoginFillScript(fillScript, pageDetails, filledFields, options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            if (!options.cipher.login) {
                return null;
            }
            const passwords = [];
            const usernames = new Map();
            const totps = [];
            let pf = null;
            let username = null;
            let totp = null;
            const login = options.cipher.login;
            const loginURIs = (_a = login === null || login === void 0 ? void 0 : login.uris) !== null && _a !== void 0 ? _a : [];
            fillScript.savedUrls = loginURIs.reduce((acc, savedURI) => {
                if (savedURI.match != domain_service_UriMatchStrategy.Never && savedURI.uri != null) {
                    acc.push(savedURI.uri);
                }
                return acc;
            }, []);
            fillScript.untrustedIframe = yield this.inUntrustedIframe(pageDetails.url, options);
            const passwordFields = autofill_service_AutofillService.loadPasswordFields(pageDetails, false, false, options.onlyEmptyFields, options.fillNewPassword, options.inlineMenuFillType);
            const loginPasswordFields = [];
            const registrationPasswordFields = [];
            passwordFields.forEach((passField) => {
                if (this.isRegistrationPasswordField(pageDetails, passField)) {
                    registrationPasswordFields.push(passField);
                }
                else {
                    loginPasswordFields.push(passField);
                }
            });
            // Prefer login fields over registration fields
            const prioritizedPasswordFields = loginPasswordFields.length > 0 ? loginPasswordFields : registrationPasswordFields;
            const focusedField = options.focusedFieldOpid
                ? pageDetails.fields.find((f) => f.opid === options.focusedFieldOpid)
                : undefined;
            const focusedForm = focusedField === null || focusedField === void 0 ? void 0 : focusedField.form;
            const isFocusedTotpField = focusedField &&
                options.allowTotpAutofill &&
                (focusedField.type === "text" ||
                    focusedField.type === "number" ||
                    focusedField.type === "tel") &&
                (fieldContainsKeyword(focusedField, [
                    ...AutoFillConstants.TotpFieldNames,
                    ...AutoFillConstants.AmbiguousTotpFieldNames,
                ]) ||
                    focusedField.autoCompleteType === "one-time-code") &&
                !fieldContainsKeyword(focusedField, [...AutoFillConstants.RecoveryCodeFieldNames]);
            const focusedUsernameField = focusedField &&
                !isFocusedTotpField &&
                login.username &&
                (focusedField.type === "text" ||
                    focusedField.type === "email" ||
                    focusedField.type === "tel") &&
                focusedField;
            const passwordMatchesFocused = (pf) => {
                var _a;
                return !focusedField
                    ? true
                    : focusedForm != null
                        ? pf.form === focusedForm
                        : !!(focusedUsernameField &&
                            pf.form == null &&
                            ((_a = this.findUsernameField(pageDetails, pf, false, false, true)) === null || _a === void 0 ? void 0 : _a.opid) ===
                                focusedUsernameField.opid);
            };
            const getUsernameForPassword = (pf, withoutForm) => {
                // use focused username if it matches this password, otherwise fall back to finding username field before password
                if (focusedUsernameField && passwordMatchesFocused(pf)) {
                    return focusedUsernameField;
                }
                return this.findUsernameField(pageDetails, pf, false, false, withoutForm);
            };
            if (focusedUsernameField &&
                focusedUsernameField.opid != null &&
                !prioritizedPasswordFields.some(passwordMatchesFocused)) {
                if (!Object.prototype.hasOwnProperty.call(filledFields, focusedUsernameField.opid)) {
                    filledFields[focusedUsernameField.opid] = focusedUsernameField;
                    const usernameVal = login.username;
                    if (usernameVal != null) {
                        autofill_service_AutofillService.fillByOpid(fillScript, focusedUsernameField, usernameVal);
                    }
                    if (options.autoSubmitLogin && focusedUsernameField.form) {
                        fillScript.autosubmit = [focusedUsernameField.form];
                    }
                    return autofill_service_AutofillService.setFillScriptForFocus({ [focusedUsernameField.opid]: focusedUsernameField }, fillScript);
                }
            }
            const pageHasNoFormMetadata = pageDetails.forms == null || Object.keys(pageDetails.forms).length === 0;
            prioritizedPasswordFields.forEach((passField) => {
                if (focusedField && !passwordMatchesFocused(passField)) {
                    return;
                }
                pf = passField;
                passwords.push(pf);
                if (login.username) {
                    username = getUsernameForPassword(pf, pageHasNoFormMetadata);
                    if ((username === null || username === void 0 ? void 0 : username.opid) != null) {
                        usernames.set(username.opid, username);
                    }
                }
                if (options.allowTotpAutofill && login.totp) {
                    totp =
                        isFocusedTotpField && passwordMatchesFocused(passField)
                            ? focusedField
                            : this.findTotpField(pageDetails, pf, false, false, pageHasNoFormMetadata);
                    if (totp) {
                        totps.push(totp);
                    }
                }
            });
            if (passwordFields.length && !passwords.length) {
                // in the event that password fields exist but weren't processed within form elements.
                const isPasswordGeneration = options.inlineMenuFillType === InlineMenuFillTypes.PasswordGeneration;
                const isCurrentPasswordUpdate = options.inlineMenuFillType === InlineMenuFillTypes.CurrentPasswordUpdate;
                // For password generation or current password update, include all password fields from the same form
                // This ensures we have access to all fields regardless of their login/registration classification
                if ((isPasswordGeneration || isCurrentPasswordUpdate) && focusedField) {
                    // Add all password fields from the same form as the focused field
                    const focusedFieldForm = focusedField.form;
                    // Check both login and registration fields to ensure we get all password fields
                    const allPasswordFields = [...loginPasswordFields, ...registrationPasswordFields];
                    allPasswordFields.forEach((passField) => {
                        if (passField.form === focusedFieldForm) {
                            passwords.push(passField);
                        }
                    });
                }
                // If we didn't add any passwords above (either not password generation/update or no matching fields),
                // select matching password if focused, otherwise first in prioritized list.
                if (!passwords.length) {
                    const passwordFieldToUse = focusedField
                        ? prioritizedPasswordFields.find(passwordMatchesFocused) || prioritizedPasswordFields[0]
                        : prioritizedPasswordFields[0];
                    if (passwordFieldToUse) {
                        passwords.push(passwordFieldToUse);
                    }
                }
                // Handle username and TOTP for the first password field
                const firstPasswordField = passwords[0];
                if (firstPasswordField) {
                    if (login.username && firstPasswordField.elementNumber > 0) {
                        username = getUsernameForPassword(firstPasswordField, true);
                        if ((username === null || username === void 0 ? void 0 : username.opid) != null) {
                            usernames.set(username.opid, username);
                        }
                    }
                    if (options.allowTotpAutofill && login.totp && firstPasswordField.elementNumber > 0) {
                        totp =
                            isFocusedTotpField && passwordMatchesFocused(firstPasswordField)
                                ? focusedField
                                : this.findTotpField(pageDetails, firstPasswordField, false, false, true);
                        if (totp) {
                            totps.push(totp);
                        }
                    }
                }
            }
            if (!passwordFields.length) {
                // If there are no passwords, username or TOTP fields may be present.
                // username and TOTP fields are mutually exclusive
                pageDetails.fields.forEach((field) => {
                    if (!field.viewable) {
                        return;
                    }
                    const isTotpCandidate = options.allowTotpAutofill &&
                        ["number", "tel", "text"].some((t) => t === field.type) &&
                        !fieldContainsKeyword(field, [...AutoFillConstants.RecoveryCodeFieldNames]);
                    const isTotpField = isTotpCandidate &&
                        (fieldContainsKeyword(field, AutoFillConstants.TotpFieldNames) ||
                            field.autoCompleteType === "one-time-code");
                    const maybeTotpField = isTotpCandidate && fieldContainsKeyword(field, AutoFillConstants.AmbiguousTotpFieldNames);
                    const isUsernameField = !options.skipUsernameOnlyFill &&
                        ["email", "tel", "text"].some((t) => t === field.type) &&
                        fieldContainsKeyword(field, AutoFillConstants.UsernameFieldNames) &&
                        !isNonLoginUsernameField(field, pageDetails);
                    // Reliable TOTP signals win unconditionally; username wins over ambiguous TOTP signals.
                    switch (true) {
                        case isTotpField:
                            totps.push(field);
                            return;
                        case isUsernameField:
                            usernames.set(field.opid, field);
                            return;
                        case maybeTotpField:
                            totps.push(field);
                            return;
                        default:
                            return;
                    }
                });
            }
            const formElementsSet = new Set();
            const usernamesToFill = focusedUsernameField ? [focusedUsernameField] : [...usernames.values()];
            usernamesToFill.forEach((u) => {
                if (u.opid == null) {
                    return;
                }
                const uOpid = u.opid;
                if (Object.prototype.hasOwnProperty.call(filledFields, uOpid)) {
                    return;
                }
                filledFields[uOpid] = u;
                const usernameVal = login.username;
                if (usernameVal != null) {
                    autofill_service_AutofillService.fillByOpid(fillScript, u, usernameVal);
                }
                if (u.form != null) {
                    formElementsSet.add(u.form);
                }
            });
            passwords.forEach((p) => {
                if (p.opid == null) {
                    return;
                }
                const pOpid = p.opid;
                // eslint-disable-next-line
                if (filledFields.hasOwnProperty(pOpid)) {
                    return;
                }
                filledFields[pOpid] = p;
                if (login.password != null) {
                    autofill_service_AutofillService.fillByOpid(fillScript, p, login.password);
                }
                if (p.form != null) {
                    formElementsSet.add(p.form);
                }
            });
            if (options.autoSubmitLogin && formElementsSet.size) {
                fillScript.autosubmit = Array.from(formElementsSet);
            }
            const loginTotp = login === null || login === void 0 ? void 0 : login.totp;
            if (options.allowTotpAutofill && typeof loginTotp === "string") {
                yield Promise.all(totps.map((t, i) => autofill_service_awaiter(this, void 0, void 0, function* () {
                    if (t.opid == null) {
                        return;
                    }
                    if (Object.prototype.hasOwnProperty.call(filledFields, t.opid)) {
                        return;
                    }
                    filledFields[t.opid] = t;
                    const totpResponse = yield firstValueFrom(this.totpService.getCode$(loginTotp));
                    const totpValue = totpResponse.code;
                    if (totpValue == null) {
                        return;
                    }
                    const totpChar = totpValue.length === totps.length ? totpValue.charAt(i) : totpValue;
                    autofill_service_AutofillService.fillByOpid(fillScript, t, totpChar);
                })));
            }
            fillScript = autofill_service_AutofillService.setFillScriptForFocus(filledFields, fillScript);
            return fillScript;
        });
    }
    /**
     * Generates the autofill script for the specified page details and credit card cipher item.
     * @param {AutofillScript} fillScript
     * @param {AutofillPageDetails} pageDetails
     * @param {{[p: string]: AutofillField}} filledFields
     * @param {GenerateFillScriptOptions} options
     * @returns {AutofillScript|null}
     * @private
     */
    generateCardFillScript(fillScript, pageDetails, filledFields, options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            if (!options.cipher.card) {
                return null;
            }
            const fillFields = {};
            pageDetails.fields.forEach((f) => {
                if (autofill_service_AutofillService.isExcludedFieldType(f, AutoFillConstants.ExcludedAutofillTypes)) {
                    return;
                }
                for (let i = 0; i < CreditCardAutoFillConstants.CardAttributes.length; i++) {
                    const attr = CreditCardAutoFillConstants.CardAttributes[i];
                    // eslint-disable-next-line
                    if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
                        continue;
                    }
                    // ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
                    // ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
                    if (!fillFields.cardholderName &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.CardHolderFieldNames, CreditCardAutoFillConstants.CardHolderFieldNameValues)) {
                        fillFields.cardholderName = f;
                        break;
                    }
                    else if (!fillFields.number &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.CardNumberFieldNames, CreditCardAutoFillConstants.CardNumberFieldNameValues)) {
                        fillFields.number = f;
                        break;
                    }
                    else if (!fillFields.exp &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.CardExpiryFieldNames, CreditCardAutoFillConstants.CardExpiryFieldNameValues)) {
                        fillFields.exp = f;
                        break;
                    }
                    else if (!fillFields.expMonth &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.ExpiryMonthFieldNames)) {
                        fillFields.expMonth = f;
                        break;
                    }
                    else if (!fillFields.expYear &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.ExpiryYearFieldNames)) {
                        fillFields.expYear = f;
                        break;
                    }
                    else if (!fillFields.code &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.CVVFieldNames)) {
                        fillFields.code = f;
                        break;
                    }
                    else if (!fillFields.brand &&
                        autofill_service_AutofillService.isFieldMatch(f[attr], CreditCardAutoFillConstants.CardBrandFieldNames)) {
                        fillFields.brand = f;
                        break;
                    }
                }
            });
            const card = options.cipher.card;
            this.makeScriptAction(fillScript, card, fillFields, filledFields, "cardholderName");
            this.makeScriptAction(fillScript, card, fillFields, filledFields, "number");
            this.makeScriptAction(fillScript, card, fillFields, filledFields, "code");
            this.makeScriptAction(fillScript, card, fillFields, filledFields, "brand");
            // There is an expiration month field and the cipher has an expiration month value
            if (fillFields.expMonth && card.expMonth != null && autofill_service_AutofillService.hasValue(card.expMonth)) {
                let expMonth = card.expMonth;
                if (fillFields.expMonth.selectInfo && fillFields.expMonth.selectInfo.options) {
                    let index = null;
                    const siOptions = fillFields.expMonth.selectInfo.options;
                    if (siOptions.length === 12) {
                        index = parseInt(card.expMonth, 10) - 1;
                    }
                    else if (siOptions.length === 13) {
                        if (siOptions[0][0] != null &&
                            siOptions[0][0] !== "" &&
                            (siOptions[12][0] == null || siOptions[12][0] === "")) {
                            index = parseInt(card.expMonth, 10) - 1;
                        }
                        else {
                            index = parseInt(card.expMonth, 10);
                        }
                    }
                    if (index != null) {
                        const option = siOptions[index];
                        if (option.length > 1) {
                            expMonth = option[1];
                        }
                    }
                }
                else if ((this.fieldAttrsContain(fillFields.expMonth, "mm") ||
                    fillFields.expMonth.maxLength === 2) &&
                    expMonth.length === 1) {
                    expMonth = "0" + expMonth;
                }
                if (fillFields.expMonth.opid != null) {
                    filledFields[fillFields.expMonth.opid] = fillFields.expMonth;
                    autofill_service_AutofillService.fillByOpid(fillScript, fillFields.expMonth, expMonth);
                }
            }
            // There is an expiration year field and the cipher has an expiration year value
            if (fillFields.expYear && card.expYear != null && autofill_service_AutofillService.hasValue(card.expYear)) {
                let expYear = card.expYear;
                if (fillFields.expYear.selectInfo && fillFields.expYear.selectInfo.options) {
                    for (let i = 0; i < fillFields.expYear.selectInfo.options.length; i++) {
                        const o = fillFields.expYear.selectInfo.options[i];
                        if (o[0] === card.expYear || o[1] === card.expYear) {
                            expYear = o[1];
                            break;
                        }
                        if (o[1].length === 2 &&
                            card.expYear.length === 4 &&
                            o[1] === card.expYear.substring(2)) {
                            expYear = o[1];
                            break;
                        }
                        const colonIndex = o[1].indexOf(":");
                        if (colonIndex > -1 && o[1].length > colonIndex + 1) {
                            const val = o[1].substring(colonIndex + 2);
                            if (val.trim() !== "" && val === card.expYear) {
                                expYear = o[1];
                                break;
                            }
                        }
                    }
                }
                else if (this.fieldAttrsContain(fillFields.expYear, "yyyy") ||
                    fillFields.expYear.maxLength === 4) {
                    if (expYear.length === 2) {
                        const normalized = normalizeExpiryYearFormat(expYear);
                        if (normalized != null) {
                            expYear = normalized;
                        }
                    }
                }
                else if (this.fieldAttrsContain(fillFields.expYear, "yy") ||
                    fillFields.expYear.maxLength === 2) {
                    if (expYear.length === 4) {
                        expYear = expYear.substring(2);
                    }
                }
                if (fillFields.expYear.opid != null) {
                    filledFields[fillFields.expYear.opid] = fillFields.expYear;
                    autofill_service_AutofillService.fillByOpid(fillScript, fillFields.expYear, expYear);
                }
            }
            // There is a single expiry date field (combined values) and the cipher has both expiration month and year
            if (fillFields.exp &&
                card.expMonth != null &&
                autofill_service_AutofillService.hasValue(card.expMonth) &&
                card.expYear != null &&
                autofill_service_AutofillService.hasValue(card.expYear)) {
                const combinedExpiryFillValue = this.generateCombinedExpiryValue(card, fillFields.exp);
                if (combinedExpiryFillValue != null) {
                    this.makeScriptActionWithValue(fillScript, combinedExpiryFillValue, fillFields.exp, filledFields);
                }
            }
            return fillScript;
        });
    }
    /**
     * Determines whether an iframe is potentially dangerous ("untrusted") to autofill
     * @param {string} pageUrl The url of the page/iframe, usually from AutofillPageDetails
     * @param {GenerateFillScriptOptions} options The GenerateFillScript options
     * @returns {boolean} `true` if the iframe is untrusted and a warning should be shown, `false` otherwise
     * @private
     */
    inUntrustedIframe(pageUrl, options) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            // If the pageUrl (from the content script) matches the tabUrl (from the sender tab), we are not in an iframe
            // This also avoids a false positive if no URI is saved and the user triggers autofill anyway
            if (pageUrl === options.tabUrl) {
                return false;
            }
            // Check the pageUrl against cipher URIs using the configured match detection.
            // Remember: if we are in this function, the tabUrl already matches a saved URI for the login.
            // We need to verify the pageUrl also matches.
            const equivalentDomains = yield firstValueFrom(this.domainSettingsService.getUrlEquivalentDomains(pageUrl));
            const matchesUri = options.cipher.login.matchesUri(pageUrl, equivalentDomains, options.defaultUriMatch);
            return !matchesUri;
        });
    }
    /**
     * Used when handling autofill on credit card fields. Determines whether
     * the field has an attribute that matches the given value.
     * @param {AutofillField} field
     * @param {string} containsValue
     * @returns {boolean}
     * @private
     */
    fieldAttrsContain(field, containsValue) {
        if (!field) {
            return false;
        }
        let doesContainValue = false;
        CreditCardAutoFillConstants.CardAttributesExtended.forEach((attributeName) => {
            if (doesContainValue || !field[attributeName]) {
                return;
            }
            let fieldValue = field[attributeName];
            fieldValue = fieldValue.replace(/ /g, "").toLowerCase();
            doesContainValue = fieldValue.indexOf(containsValue) > -1;
        });
        return doesContainValue;
    }
    /**
     * Returns a string value representation of the combined card expiration month and year values
     * in a format matching discovered guidance within the field attributes (typically provided for users).
     *
     * @param {CardView} cardCipher
     * @param {AutofillField} field
     */
    generateCombinedExpiryValue(cardCipher, field) {
        /*
          Some expectations of the passed stored card cipher view:
    
          - At the time of writing, the stored card expiry year value (`expYear`)
            can be any arbitrary string (no format validation). We may attempt some format
            normalization here, but expect the user to have entered a string of integers
            with a length of 2 or 4
    
          - the `expiration` property cannot be used for autofill as it is an opinionated
            format
    
          - `expMonth` a stringified integer stored with no zero-padding and is not
            zero-indexed (e.g. January is "1", not "01" or 0)
        */
        var _a;
        // Expiry format options
        let useMonthPadding = true;
        let useYearFull = false;
        let delimiter = "/";
        let orderByYear = false;
        // Because users are allowed to store truncated years, we need to make assumptions
        // about the full year format when called for
        const currentCentury = `${new Date().getFullYear()}`.slice(0, 2);
        // Note, we construct the output rather than doing string replacement against the
        // format guidance pattern to avoid edge cases that would output invalid values
        const [
        // The guidance parsed from the field properties regarding expiry format
        expectedExpiryDateFormat, 
        // The (localized) date pattern set that was used to parse the expiry format guidance
        expiryDateFormatPatterns,] = this.getExpectedExpiryDateFormat(field);
        if (expectedExpiryDateFormat && expiryDateFormatPatterns) {
            const { Month, MonthShort, Year } = expiryDateFormatPatterns;
            const expiryDateDelimitersPattern = "\\" + CardExpiryDateDelimiters.join("\\");
            // assign the delimiter from the expected format string
            delimiter =
                ((_a = expectedExpiryDateFormat.match(new RegExp(`[${expiryDateDelimitersPattern}]`, "g"))) === null || _a === void 0 ? void 0 : _a[0]) ||
                    "";
            // check if the expected format starts with a month form
            // order matters here; check long form first, since short form will match against long
            if (expectedExpiryDateFormat.indexOf(Month + delimiter) === 0) {
                useMonthPadding = true;
                orderByYear = false;
            }
            else if (expectedExpiryDateFormat.indexOf(MonthShort + delimiter) === 0) {
                useMonthPadding = false;
                orderByYear = false;
            }
            else {
                orderByYear = true;
                // short form can match against long form, but long won't match against short
                const containsLongMonthPattern = new RegExp(`${Month}`, "i");
                useMonthPadding = containsLongMonthPattern.test(expectedExpiryDateFormat);
            }
            const containsLongYearPattern = new RegExp(`${Year}`, "i");
            useYearFull = containsLongYearPattern.test(expectedExpiryDateFormat);
        }
        if (cardCipher.expMonth == null || cardCipher.expYear == null) {
            return null;
        }
        const month = useMonthPadding
            ? // Ensure zero-padding
                ("0" + cardCipher.expMonth).slice(-2)
            : // Handle zero-padded stored month values, even though they are not _expected_ to be as such
                cardCipher.expMonth.replaceAll("0", "");
        // Note: assumes the user entered an `expYear` value with a length of either 2 or 4
        const year = (currentCentury + cardCipher.expYear).slice(useYearFull ? -4 : -2);
        const combinedExpiryFillValue = (orderByYear ? [year, month] : [month, year]).join(delimiter);
        return combinedExpiryFillValue;
    }
    /**
     * Returns a string value representation of discovered guidance for a combined month and year expiration value from the field attributes
     *
     * @param {AutofillField} field
     */
    getExpectedExpiryDateFormat(field) {
        let expectedDateFormat = null;
        let dateFormatPatterns = null;
        const expiryDateDelimitersPattern = "\\" + CardExpiryDateDelimiters.join("\\");
        CreditCardAutoFillConstants.CardExpiryDateFormats.find((dateFormat) => {
            dateFormatPatterns = dateFormat;
            const { Month, MonthShort, YearShort, Year } = dateFormat;
            // Non-exhaustive coverage of field guidances. Some uncovered edge cases: ". " delimiter, space-delimited delimiters ("mm / yyyy").
            // We should consider if added whitespace is for improved readability of user-guidance or actually desired in the filled value.
            // e.g. "/((mm|m)[\/\-\.\ ]{0,1}(yyyy|yy))|((yyyy|yy)[\/\-\.\ ]{0,1}(mm|m))/gi"
            const dateFormatPattern = new RegExp(`((${Month}|${MonthShort})[${expiryDateDelimitersPattern}]{0,1}(${Year}|${YearShort}))|((${Year}|${YearShort})[${expiryDateDelimitersPattern}]{0,1}(${Month}|${MonthShort}))`, "gi");
            return CreditCardAutoFillConstants.CardAttributesExtended.find((attributeName) => {
                var _a;
                const fieldAttributeValue = (_a = field[attributeName]) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
                const fieldAttributeMatch = fieldAttributeValue === null || fieldAttributeValue === void 0 ? void 0 : fieldAttributeValue.match(dateFormatPattern);
                // break find as soon as a match is found
                if (fieldAttributeMatch === null || fieldAttributeMatch === void 0 ? void 0 : fieldAttributeMatch.length) {
                    expectedDateFormat = fieldAttributeMatch[0];
                    // remove any irrelevant characters
                    const irrelevantExpiryCharactersPattern = new RegExp(
                    // "or digits" to ensure numbers are removed from guidance pattern, which aren't covered by ^\w
                    `[^\\w${expiryDateDelimitersPattern}]|[\\d]`, "gi");
                    expectedDateFormat.replaceAll(irrelevantExpiryCharactersPattern, "");
                    return true;
                }
                return false;
            });
        });
        // @TODO if expectedDateFormat is still null, and there is a `pattern` attribute, cycle
        // through generated formatted values, checking against the provided regex pattern
        return [expectedDateFormat, dateFormatPatterns];
    }
    /**
     * Generates the autofill script for the specified page details and identity cipher item.
     *
     * @param fillScript - Object to store autofill script, passed between method references
     * @param pageDetails - The details of the page to autofill
     * @param filledFields - The fields that have already been filled, passed between method references
     * @param options - Contains data used to fill cipher items
     */
    generateIdentityFillScript(fillScript, pageDetails, filledFields, options) {
        const identity = options.cipher.identity;
        if (!identity) {
            return null;
        }
        for (let fieldsIndex = 0; fieldsIndex < pageDetails.fields.length; fieldsIndex++) {
            const field = pageDetails.fields[fieldsIndex];
            if (this.excludeFieldFromIdentityFill(field)) {
                continue;
            }
            const keywordsList = this.getIdentityAutofillFieldKeywords(field);
            const keywordsCombined = keywordsList.join(",");
            if (this.shouldMakeIdentityTitleFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.title, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityNameFillScript(filledFields, keywordsList)) {
                this.makeIdentityNameFillScript(fillScript, filledFields, field, identity);
                continue;
            }
            if (this.shouldMakeIdentityFirstNameFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.firstName, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityMiddleNameFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.middleName, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityLastNameFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.lastName, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityEmailFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.email, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityAddress1FillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.address1, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityAddress2FillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.address2, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityAddress3FillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.address3, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityAddressFillScript(filledFields, keywordsList)) {
                this.makeIdentityAddressFillScript(fillScript, filledFields, field, identity);
                continue;
            }
            if (this.shouldMakeIdentityPostalCodeFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.postalCode, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityCityFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.city, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityStateFillScript(filledFields, keywordsCombined)) {
                this.makeIdentityStateFillScript(fillScript, filledFields, field, identity);
                continue;
            }
            if (this.shouldMakeIdentityCountryFillScript(filledFields, keywordsCombined)) {
                this.makeIdentityCountryFillScript(fillScript, filledFields, field, identity);
                continue;
            }
            if (this.shouldMakeIdentityPhoneFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.phone, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityUserNameFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.username, field, filledFields);
                continue;
            }
            if (this.shouldMakeIdentityCompanyFillScript(filledFields, keywordsCombined)) {
                this.makeScriptActionWithValue(fillScript, identity.company, field, filledFields);
            }
        }
        return fillScript;
    }
    /**
     * Identifies if the current field should be excluded from triggering autofill of the identity cipher.
     *
     * @param field - The field to check
     */
    excludeFieldFromIdentityFill(field) {
        return (autofill_service_AutofillService.isExcludedFieldType(field, [
            "password",
            ...AutoFillConstants.ExcludedAutofillTypes,
        ]) ||
            (field.autoCompleteType != null &&
                [...AutoFillConstants.ExcludedIdentityAutocompleteTypes].some((excludedToken) => autofill_service_AutofillService.autoCompleteTypeIncludesToken(field.autoCompleteType, excludedToken))) ||
            !field.viewable);
    }
    /**
     * Gathers all unique keyword identifiers from a field that can be used to determine what
     * identity value should be filled.
     *
     * @param field - The field to gather keywords from
     */
    getIdentityAutofillFieldKeywords(field) {
        const keywords = new Set();
        for (let index = 0; index < IdentityAutoFillConstants.IdentityAttributes.length; index++) {
            const attribute = IdentityAutoFillConstants.IdentityAttributes[index];
            const value = field[attribute];
            if (value != null && typeof value === "string") {
                keywords.add(value
                    .trim()
                    .toLowerCase()
                    .replace(/[^a-zA-Z0-9]+/g, ""));
            }
        }
        return Array.from(keywords);
    }
    /**
     * Identifies if a fill script action for the identity title
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityTitleFillScript(filledFields, keywords) {
        return (!filledFields.title &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.TitleFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity name
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityNameFillScript(filledFields, keywords) {
        return (!filledFields.name &&
            keywords.some((keyword) => autofill_service_AutofillService.isFieldMatch(keyword, IdentityAutoFillConstants.FullNameFieldNames, IdentityAutoFillConstants.FullNameFieldNameValues)));
    }
    /**
     * Identifies if a fill script action for the identity first name
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityFirstNameFillScript(filledFields, keywords) {
        return (!filledFields.firstName &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.FirstnameFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity middle name
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityMiddleNameFillScript(filledFields, keywords) {
        return (!filledFields.middleName &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.MiddlenameFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity last name
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityLastNameFillScript(filledFields, keywords) {
        return (!filledFields.lastName &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.LastnameFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity email
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityEmailFillScript(filledFields, keywords) {
        return (!filledFields.email &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.EmailFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity address
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityAddressFillScript(filledFields, keywords) {
        return (!filledFields.address &&
            keywords.some((keyword) => autofill_service_AutofillService.isFieldMatch(keyword, IdentityAutoFillConstants.AddressFieldNames, IdentityAutoFillConstants.AddressFieldNameValues)));
    }
    /**
     * Identifies if a fill script action for the identity address1
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityAddress1FillScript(filledFields, keywords) {
        return (!filledFields.address1 &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.Address1FieldNames));
    }
    /**
     * Identifies if a fill script action for the identity address2
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityAddress2FillScript(filledFields, keywords) {
        return (!filledFields.address2 &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.Address2FieldNames));
    }
    /**
     * Identifies if a fill script action for the identity address3
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityAddress3FillScript(filledFields, keywords) {
        return (!filledFields.address3 &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.Address3FieldNames));
    }
    /**
     * Identifies if a fill script action for the identity postal code
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityPostalCodeFillScript(filledFields, keywords) {
        return (!filledFields.postalCode &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.PostalCodeFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity city
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityCityFillScript(filledFields, keywords) {
        return (!filledFields.city &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.CityFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity state
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityStateFillScript(filledFields, keywords) {
        return (!filledFields.state &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.StateFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity country
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityCountryFillScript(filledFields, keywords) {
        return (!filledFields.country &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.CountryFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity phone
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityPhoneFillScript(filledFields, keywords) {
        return (!filledFields.phone &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.PhoneFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity username
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityUserNameFillScript(filledFields, keywords) {
        return (!filledFields.username &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.UserNameFieldNames));
    }
    /**
     * Identifies if a fill script action for the identity company
     * field should be created for the provided field.
     *
     * @param filledFields - The fields that have already been filled
     * @param keywords - The keywords from the field
     */
    shouldMakeIdentityCompanyFillScript(filledFields, keywords) {
        return (!filledFields.company &&
            autofill_service_AutofillService.isFieldMatch(keywords, IdentityAutoFillConstants.CompanyFieldNames));
    }
    /**
     * Creates an identity name fill script action for the provided field. This is used
     * when filling a `full name` field, using the first, middle, and last name from the
     * identity cipher item.
     *
     * @param fillScript - The autofill script to add the action to
     * @param filledFields - The fields that have already been filled
     * @param field - The field to fill
     * @param identity - The identity cipher item
     */
    makeIdentityNameFillScript(fillScript, filledFields, field, identity) {
        let name = "";
        if (identity.firstName) {
            name += identity.firstName;
        }
        if (identity.middleName) {
            name += !name ? identity.middleName : ` ${identity.middleName}`;
        }
        if (identity.lastName) {
            name += !name ? identity.lastName : ` ${identity.lastName}`;
        }
        this.makeScriptActionWithValue(fillScript, name, field, filledFields);
    }
    /**
     * Creates an identity address fill script action for the provided field. This is used
     * when filling a generic `address` field, using the address1, address2, and address3
     * from the identity cipher item.
     *
     * @param fillScript - The autofill script to add the action to
     * @param filledFields - The fields that have already been filled
     * @param field - The field to fill
     * @param identity - The identity cipher item
     */
    makeIdentityAddressFillScript(fillScript, filledFields, field, identity) {
        if (!identity.address1) {
            return;
        }
        let address = identity.address1;
        if (identity.address2) {
            address += `, ${identity.address2}`;
        }
        if (identity.address3) {
            address += `, ${identity.address3}`;
        }
        this.makeScriptActionWithValue(fillScript, address, field, filledFields);
    }
    /**
     * Creates an identity state fill script action for the provided field. This is used
     * when filling a `state` field, using the state value from the identity cipher item.
     * If the state value is a full name, it will be converted to an ISO code.
     *
     * @param fillScript - The autofill script to add the action to
     * @param filledFields - The fields that have already been filled
     * @param field - The field to fill
     * @param identity - The identity cipher item
     */
    makeIdentityStateFillScript(fillScript, filledFields, field, identity) {
        if (!identity.state) {
            return;
        }
        if (identity.state.length <= 2) {
            this.makeScriptActionWithValue(fillScript, identity.state, field, filledFields);
            return;
        }
        const stateLower = identity.state.toLowerCase();
        const isoState = IdentityAutoFillConstants.IsoStates[stateLower] ||
            IdentityAutoFillConstants.IsoProvinces[stateLower];
        if (isoState) {
            this.makeScriptActionWithValue(fillScript, isoState, field, filledFields);
        }
    }
    /**
     * Creates an identity country fill script action for the provided field. This is used
     * when filling a `country` field, using the country value from the identity cipher item.
     * If the country value is a full name, it will be converted to an ISO code.
     *
     * @param fillScript - The autofill script to add the action to
     * @param filledFields - The fields that have already been filled
     * @param field - The field to fill
     * @param identity - The identity cipher item
     */
    makeIdentityCountryFillScript(fillScript, filledFields, field, identity) {
        if (!identity.country) {
            return;
        }
        if (identity.country.length <= 2) {
            this.makeScriptActionWithValue(fillScript, identity.country, field, filledFields);
            return;
        }
        const countryLower = identity.country.toLowerCase();
        const isoCountry = IdentityAutoFillConstants.IsoCountries[countryLower];
        if (isoCountry) {
            this.makeScriptActionWithValue(fillScript, isoCountry, field, filledFields);
        }
    }
    /**
     * Accepts an HTMLInputElement type value and a list of
     * excluded types and returns true if the type is excluded.
     * @param {string} type
     * @param {string[]} excludedTypes
     * @returns {boolean}
     * @private
     */
    static isExcludedType(type, excludedTypes) {
        return excludedTypes.indexOf(type) > -1;
    }
    /**
     * Identifies if a passed field contains text artifacts that identify it as a search field.
     *
     * @param field - The autofill field that we are validating as a search field
     */
    static isSearchField(field) {
        const matchFieldAttributeValues = [field.type, field.htmlName, field.htmlID, field.placeholder];
        for (let attrIndex = 0; attrIndex < matchFieldAttributeValues.length; attrIndex++) {
            const attributeValue = matchFieldAttributeValues[attrIndex];
            if (!attributeValue) {
                continue;
            }
            // Separate camel case words and case them to lower case values
            const camelCaseSeparatedFieldAttribute = attributeValue
                .replace(/([a-z])([A-Z])/g, "$1 $2")
                .toLowerCase();
            // Split the attribute by non-alphabetical characters to get the keywords
            const attributeKeywords = camelCaseSeparatedFieldAttribute.split(/[^a-z]/gi);
            for (let keywordIndex = 0; keywordIndex < attributeKeywords.length; keywordIndex++) {
                if (autofill_service_AutofillService.searchFieldNamesSet.has(attributeKeywords[keywordIndex])) {
                    return true;
                }
            }
        }
        return false;
    }
    static isExcludedFieldType(field, excludedTypes) {
        if (autofill_service_AutofillService.forCustomFieldsOnly(field)) {
            return true;
        }
        if (field.type != null && this.isExcludedType(field.type, excludedTypes)) {
            return true;
        }
        // Check if the input is an untyped/mistyped search input
        return this.isSearchField(field);
    }
    /**
     * Accepts the value of a field, a list of possible options that define if
     * a field can be matched to a vault cipher, and a secondary optional list
     * of options that define if a field can be matched to a vault cipher. Returns
     * true if the field value matches one of the options.
     * @param {string} value
     * @param {string[]} options
     * @param {string[]} containsOptions
     * @returns {boolean}
     * @private
     */
    static isFieldMatch(value, options, containsOptions) {
        value = value
            .trim()
            .toLowerCase()
            .replace(/[^a-zA-Z0-9]+/g, "");
        for (let i = 0; i < options.length; i++) {
            let option = options[i];
            const checkValueContains = containsOptions == null || containsOptions.indexOf(option) > -1;
            option = option.toLowerCase().replace(/-/g, "");
            if (value === option || (checkValueContains && value.indexOf(option) > -1)) {
                return true;
            }
        }
        return false;
    }
    /**
     * Helper method used to create a script action for a field. Conditionally
     * accepts a fieldProp value that will be used in place of the dataProp value.
     * @param {AutofillScript} fillScript
     * @param cipherData
     * @param {{[p: string]: AutofillField}} fillFields
     * @param {{[p: string]: AutofillField}} filledFields
     * @param {string} dataProp
     * @param {string} fieldProp
     * @private
     */
    makeScriptAction(fillScript, cipherData, fillFields, filledFields, dataProp, fieldProp) {
        fieldProp = fieldProp || dataProp;
        const field = fillFields[fieldProp];
        if (field != null) {
            this.makeScriptActionWithValue(fillScript, cipherData[dataProp], field, filledFields);
        }
    }
    /**
     * Handles updating the list of filled fields and adding a script action
     * to the fill script. If a select field is passed as part of the fill options,
     * we iterate over the options to check if the passed value matches one of the
     * options. If it does, we add a script action to select the option.
     * @param {AutofillScript} fillScript
     * @param dataValue
     * @param {AutofillField} field
     * @param {{[p: string]: AutofillField}} filledFields
     * @private
     */
    makeScriptActionWithValue(fillScript, dataValue, field, filledFields) {
        let doFill = false;
        if (autofill_service_AutofillService.hasValue(dataValue) && field) {
            if (field.type === "select-one" && field.selectInfo && field.selectInfo.options) {
                for (let i = 0; i < field.selectInfo.options.length; i++) {
                    const option = field.selectInfo.options[i];
                    for (let j = 0; j < option.length; j++) {
                        if (autofill_service_AutofillService.hasValue(option[j]) &&
                            option[j].toLowerCase() === dataValue.toLowerCase()) {
                            doFill = true;
                            if (option.length > 1) {
                                dataValue = option[1];
                            }
                            break;
                        }
                    }
                    if (doFill) {
                        break;
                    }
                }
            }
            else {
                doFill = true;
            }
        }
        if (doFill) {
            filledFields[field.opid] = field;
            autofill_service_AutofillService.fillByOpid(fillScript, field, dataValue);
        }
    }
    static valueIsLikePassword(value) {
        if (value == null) {
            return false;
        }
        // Removes all whitespace, _ and - characters
        const cleanedValue = value.toLowerCase().replace(/[\s_-]/g, "");
        if (cleanedValue.indexOf("password") < 0) {
            return false;
        }
        return !AutoFillConstants.PasswordFieldExcludeList.some((i) => cleanedValue.indexOf(i) > -1);
    }
    static fieldHasDisqualifyingAttributeValue(field) {
        const checkedAttributeValues = [field.htmlID, field.htmlName, field.placeholder];
        let valueIsOnExclusionList = false;
        for (let i = 0; i < checkedAttributeValues.length; i++) {
            const checkedAttributeValue = checkedAttributeValues[i];
            const cleanedValue = checkedAttributeValue === null || checkedAttributeValue === void 0 ? void 0 : checkedAttributeValue.toLowerCase().replace(/[\s_-]/g, "");
            valueIsOnExclusionList = Boolean(cleanedValue && AutoFillConstants.FieldIgnoreList.some((i) => cleanedValue.indexOf(i) > -1));
            if (valueIsOnExclusionList) {
                break;
            }
        }
        return valueIsOnExclusionList;
    }
    static collectExcludedPasswordFieldIds(pageDetails) {
        var _a;
        const passwordFieldsByForm = new Map();
        for (const field of pageDetails.fields) {
            if (field.type !== "password" || field.disabled) {
                continue;
            }
            const formKey = (_a = field.form) !== null && _a !== void 0 ? _a : null;
            const fieldsForForm = passwordFieldsByForm.get(formKey);
            if (fieldsForForm) {
                fieldsForForm.push(field);
            }
            else {
                passwordFieldsByForm.set(formKey, [field]);
            }
        }
        const isCurrentPassword = (f) => autofill_service_AutofillService.autoCompleteTypeIncludesToken(f.autoCompleteType, AutoFillConstants.AutocompleteCurrentPassword);
        const excluded = new Set();
        for (const [, passwordFields] of passwordFieldsByForm) {
            if (passwordFields.length >= 2 && passwordFields.some(isCurrentPassword)) {
                for (const field of passwordFields) {
                    if (!isCurrentPassword(field)) {
                        excluded.add(field.opid);
                    }
                }
            }
        }
        return excluded;
    }
    /**
     * Accepts a pageDetails object with a list of fields and returns a list of
     * fields that are likely to be password fields.
     * @param {AutofillPageDetails} pageDetails
     * @param {boolean} canBeHidden
     * @param {boolean} canBeReadOnly
     * @param {boolean} mustBeEmpty
     * @param {boolean} fillNewPassword
     * @param {InlineMenuFillType} inlineMenuFillType
     * @returns {AutofillField[]}
     */
    static loadPasswordFields(pageDetails, canBeHidden, canBeReadOnly, mustBeEmpty, fillNewPassword, inlineMenuFillType) {
        const arr = [];
        const excludedPasswordFieldOpids = fillNewPassword && inlineMenuFillType === InlineMenuFillTypes.PasswordGeneration
            ? new Set()
            : autofill_service_AutofillService.collectExcludedPasswordFieldIds(pageDetails);
        pageDetails.fields.forEach((f) => {
            const isPassword = f.type === "password";
            if (!isPassword &&
                autofill_service_AutofillService.isExcludedFieldType(f, AutoFillConstants.ExcludedAutofillLoginTypes)) {
                return;
            }
            // If any attribute values match disqualifying values, the entire field should not be used
            if (autofill_service_AutofillService.fieldHasDisqualifyingAttributeValue(f)) {
                return;
            }
            // We want to avoid treating TOTP fields as password fields
            if (fieldContainsKeyword(f, AutoFillConstants.TotpFieldNames)) {
                return;
            }
            const isLikePassword = () => {
                if (f.type !== "text") {
                    return false;
                }
                const testedValues = [f.htmlID, f.htmlName, f.placeholder];
                for (let i = 0; i < testedValues.length; i++) {
                    const value = testedValues[i];
                    if (value != null && autofill_service_AutofillService.valueIsLikePassword(value)) {
                        return true;
                    }
                }
                return false;
            };
            if (!f.disabled &&
                (canBeReadOnly || !f.readonly) &&
                (isPassword || isLikePassword()) &&
                (canBeHidden || f.viewable) &&
                (!mustBeEmpty || f.value == null || f.value.trim() === "") &&
                (fillNewPassword ||
                    !autofill_service_AutofillService.autoCompleteTypeIncludesToken(f.autoCompleteType, AutoFillConstants.AutocompleteNewPassword)) &&
                !excludedPasswordFieldOpids.has(f.opid)) {
                arr.push(f);
            }
        });
        return arr;
    }
    /**
     * Determines if a password field is part of a registration/signup form.
     * @param {AutofillPageDetails} pageDetails
     * @param {AutofillField} passwordField
     * @returns {boolean}
     * @private
     */
    isRegistrationPasswordField(pageDetails, passwordField) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        if (!passwordField.form || !pageDetails.forms) {
            return false;
        }
        const form = pageDetails.forms[passwordField.form];
        if (!form) {
            return false;
        }
        const formIdentifierValues = [
            (_b = (_a = form.htmlID) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a),
            (_d = (_c = form.htmlName) === null || _c === void 0 ? void 0 : _c.toLowerCase) === null || _d === void 0 ? void 0 : _d.call(_c),
            (_f = (_e = passwordField === null || passwordField === void 0 ? void 0 : passwordField.htmlID) === null || _e === void 0 ? void 0 : _e.toLowerCase) === null || _f === void 0 ? void 0 : _f.call(_e),
            (_h = (_g = passwordField === null || passwordField === void 0 ? void 0 : passwordField.htmlName) === null || _g === void 0 ? void 0 : _g.toLowerCase) === null || _h === void 0 ? void 0 : _h.call(_g),
        ].filter((value) => typeof value === "string");
        return formIdentifierValues.some((value) => AutoFillConstants.RegistrationKeywords.some((keyword) => value.includes(keyword)));
    }
    /**
     * Accepts a pageDetails object with a list of fields and returns a list of
     * fields that are likely to be username fields.
     * @param {AutofillPageDetails} pageDetails
     * @param {AutofillField} passwordField
     * @param {boolean} canBeHidden
     * @param {boolean} canBeReadOnly
     * @param {boolean} withoutForm
     * @returns {AutofillField}
     * @private
     */
    findUsernameField(pageDetails, passwordField, canBeHidden, canBeReadOnly, withoutForm) {
        let sameFormCandidate = null;
        let bestCandidate = null;
        const fieldsPrecedingPassword = pageDetails.fields.filter((f) => f.elementNumber < passwordField.elementNumber);
        for (const field of fieldsPrecedingPassword) {
            if (autofill_service_AutofillService.forCustomFieldsOnly(field)) {
                continue;
            }
            if (isNonLoginUsernameField(field, pageDetails)) {
                continue;
            }
            const isUsernameFieldType = field.type === "text" || field.type === "email" || field.type === "tel";
            if (!isUsernameFieldType) {
                continue;
            }
            // Only consider fields with non-null form values as being in the same form;
            // null forms are treated as separate
            const isInSameForm = field.form != null && passwordField.form != null && field.form === passwordField.form;
            const includesUsernameKeyword = fieldContainsKeyword(field, AutoFillConstants.UsernameFieldNames);
            // Email/tel fields in the same form are strong candidates even when visibility
            // checks are unreliable
            const isQualifiedByType = isInSameForm && (field.type === "email" || field.type === "tel");
            const isAccessible = !field.disabled && (canBeReadOnly || !field.readonly);
            const isVisible = canBeHidden || field.viewable || isQualifiedByType;
            const isReachable = withoutForm || isInSameForm || includesUsernameKeyword;
            if (!isAccessible || !isVisible || !isReachable) {
                continue;
            }
            if (isInSameForm) {
                sameFormCandidate = field;
                // A same-form field explicitly named for username is the best possible match
                if (includesUsernameKeyword) {
                    return field;
                }
            }
            else {
                bestCandidate = field;
            }
        }
        // Prefer a same-form candidate, fall back to any matching field
        return sameFormCandidate || bestCandidate;
    }
    /**
     * Accepts a pageDetails object with a list of fields and returns a list of
     * fields that are likely to be TOTP fields.
     * @param {AutofillPageDetails} pageDetails
     * @param {AutofillField} passwordField
     * @param {boolean} canBeHidden
     * @param {boolean} canBeReadOnly
     * @param {boolean} withoutForm
     * @returns {AutofillField}
     * @private
     */
    findTotpField(pageDetails, passwordField, canBeHidden, canBeReadOnly, withoutForm) {
        let totpField = null;
        for (let i = 0; i < pageDetails.fields.length; i++) {
            const f = pageDetails.fields[i];
            if (autofill_service_AutofillService.forCustomFieldsOnly(f)) {
                continue;
            }
            const fieldIsDisqualified = autofill_service_AutofillService.fieldHasDisqualifyingAttributeValue(f);
            if (!fieldIsDisqualified &&
                !f.disabled &&
                (canBeReadOnly || !f.readonly) &&
                (withoutForm || f.form === passwordField.form) &&
                (canBeHidden || f.viewable) &&
                (f.type === "text" ||
                    f.type === "number" ||
                    // sites will commonly use tel in order to get the digit pad against semantic recommendations
                    f.type === "tel") &&
                fieldContainsKeyword(f, [
                    ...AutoFillConstants.TotpFieldNames,
                    ...AutoFillConstants.AmbiguousTotpFieldNames,
                ]) &&
                !fieldContainsKeyword(f, [...AutoFillConstants.RecoveryCodeFieldNames])) {
                totpField = f;
                if (this.findMatchingFieldIndex(f, [
                    ...AutoFillConstants.TotpFieldNames,
                    ...AutoFillConstants.AmbiguousTotpFieldNames,
                ]) > -1 ||
                    f.autoCompleteType === "one-time-code") {
                    // We found an exact match. No need to keep looking.
                    break;
                }
            }
        }
        return totpField;
    }
    /**
     * Accepts a field and returns the index of the first matching property
     * present in a list of attribute names.
     * @param {AutofillField} field
     * @param {string[]} names
     * @returns {number}
     * @private
     */
    findMatchingFieldIndex(field, names) {
        for (let i = 0; i < names.length; i++) {
            if (names[i].indexOf("=") > -1) {
                if (this.fieldPropertyIsPrefixMatch(field, "htmlID", names[i], "id")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "htmlName", names[i], "name")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "label-left", names[i], "label")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "label-right", names[i], "label")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "label-tag", names[i], "label")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "label-aria", names[i], "label")) {
                    return i;
                }
                if (this.fieldPropertyIsPrefixMatch(field, "placeholder", names[i], "placeholder")) {
                    return i;
                }
            }
            if (this.fieldPropertyIsMatch(field, "htmlID", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "htmlName", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "label-left", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "label-right", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "label-tag", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "label-aria", names[i])) {
                return i;
            }
            if (this.fieldPropertyIsMatch(field, "placeholder", names[i])) {
                return i;
            }
        }
        return -1;
    }
    /**
     * Accepts a field, property, name, and prefix and returns true if the field
     * contains a value that matches the given prefixed property.
     * @param field
     * @param {string} property
     * @param {string} name
     * @param {string} prefix
     * @param {string} separator
     * @returns {boolean}
     * @private
     */
    fieldPropertyIsPrefixMatch(field, property, name, prefix, separator = "=") {
        if (name.indexOf(prefix + separator) === 0) {
            const sepIndex = name.indexOf(separator);
            const val = name.substring(sepIndex + 1);
            return val != null && this.fieldPropertyIsMatch(field, property, val);
        }
        return false;
    }
    /**
     * Identifies if a given property within a field matches the value
     * of the passed "name" parameter. If the name starts with "regex=",
     * the value is tested against a case-insensitive regular expression.
     * If the name starts with "csv=", the value is treated as a
     * comma-separated list of values to match.
     * @param field
     * @param {string} property
     * @param {string} name
     * @returns {boolean}
     * @private
     */
    fieldPropertyIsMatch(field, property, name) {
        let fieldVal = field[property];
        if (!autofill_service_AutofillService.hasValue(fieldVal)) {
            return false;
        }
        fieldVal = fieldVal.trim().replace(/(?:\r\n|\r|\n)/g, "");
        if (name.startsWith("regex=")) {
            try {
                const regexParts = name.split("=", 2);
                if (regexParts.length === 2) {
                    const regex = new RegExp(regexParts[1], "i");
                    return regex.test(fieldVal);
                }
            }
            catch (e) {
                this.logService.error(e);
            }
        }
        else if (name.startsWith("csv=")) {
            const csvParts = name.split("=", 2);
            if (csvParts.length === 2) {
                const csvVals = csvParts[1].split(",");
                for (let i = 0; i < csvVals.length; i++) {
                    const val = csvVals[i];
                    if (val != null && val.trim().toLowerCase() === fieldVal.toLowerCase()) {
                        return true;
                    }
                }
                return false;
            }
        }
        return fieldVal.toLowerCase() === name;
    }
    /**
     * True if `autoCompleteType` includes `token` as a space-separated autocomplete token.
     * Handles compound tokens such as `section-login current-password`.
     */
    static autoCompleteTypeIncludesToken(autoCompleteType, token) {
        if (autoCompleteType == null || typeof autoCompleteType !== "string") {
            return false;
        }
        const normalizedToken = token.trim().toLowerCase();
        if (!normalizedToken) {
            return false;
        }
        const parts = autoCompleteType.trim().toLowerCase().split(/\s+/);
        return parts.includes(normalizedToken);
    }
    /**
     * Accepts a string and returns true if the
     * string is not falsy and not empty.
     * @param {string} str
     * @returns {boolean}
     */
    static hasValue(str) {
        return Boolean(str && str !== "");
    }
    /**
     * Sets the `focus_by_opid` autofill script
     * action to the last field that was filled.
     * @param {{[p: string]: AutofillField}} filledFields
     * @param {AutofillScript} fillScript
     * @returns {AutofillScript}
     */
    static setFillScriptForFocus(filledFields, fillScript) {
        let lastField = null;
        let lastPasswordField = null;
        for (const opid in filledFields) {
            // eslint-disable-next-line
            if (filledFields.hasOwnProperty(opid) && filledFields[opid].viewable) {
                lastField = filledFields[opid];
                if (filledFields[opid].type === "password") {
                    lastPasswordField = filledFields[opid];
                }
            }
        }
        // Prioritize password field over others.
        if ((lastPasswordField === null || lastPasswordField === void 0 ? void 0 : lastPasswordField.opid) != null) {
            fillScript.script.push(["focus_by_opid", lastPasswordField.opid]);
        }
        else if ((lastField === null || lastField === void 0 ? void 0 : lastField.opid) != null) {
            fillScript.script.push(["focus_by_opid", lastField.opid]);
        }
        return fillScript;
    }
    /**
     * Updates a fill script to place the `click_on_opid`, `focus_on_opid`, and `fill_by_opid`
     * fill script actions associated with the provided field.
     * @param {AutofillScript} fillScript
     * @param {AutofillField} field
     * @param {string} value
     */
    static fillByOpid(fillScript, field, value) {
        if (field.maxLength && value && value.length > field.maxLength) {
            value = value.substr(0, value.length);
        }
        if (field.tagName !== "span") {
            fillScript.script.push(["click_on_opid", field.opid]);
            fillScript.script.push(["focus_by_opid", field.opid]);
        }
        fillScript.script.push(["fill_by_opid", field.opid, value]);
    }
    /**
     * Identifies if the field is a custom field, a custom
     * field is defined as a field that is a `span` element.
     * @param {AutofillField} field
     * @returns {boolean}
     */
    static forCustomFieldsOnly(field) {
        return field.tagName === "span";
    }
    /**
     * Handles debouncing the opening of the master password reprompt popout.
     */
    isDebouncingPasswordRepromptPopout() {
        if (this.currentlyOpeningPasswordRepromptPopout) {
            return true;
        }
        this.currentlyOpeningPasswordRepromptPopout = true;
        clearTimeout(this.openPasswordRepromptPopoutDebounce);
        this.openPasswordRepromptPopoutDebounce = setTimeout(() => {
            this.currentlyOpeningPasswordRepromptPopout = false;
        }, 100);
        return false;
    }
    /**
     * Queries all open tabs in the user's browsing session
     * and injects the autofill scripts into the page.
     */
    injectAutofillScriptsInAllTabs() {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            const tabs = yield BrowserApi.tabsQuery({});
            for (let index = 0; index < tabs.length; index++) {
                const tab = tabs[index];
                if ((tab === null || tab === void 0 ? void 0 : tab.id) && ((_a = tab.url) === null || _a === void 0 ? void 0 : _a.startsWith("http"))) {
                    const frames = yield BrowserApi.getAllFrameDetails(tab.id);
                    if (frames) {
                        frames.forEach((frame) => this.injectAutofillScripts(tab, frame.frameId, false));
                    }
                }
            }
        });
    }
    /**
     * Updates the autofill inline menu visibility settings in all active tabs
     * when the inlineMenuVisibility, showInlineMenuCards, or showInlineMenuIdentities
     * observables are updated.
     *
     * @param oldSettingValue - The previous setting value
     * @param newSettingValue - The current setting value
     */
    handleInlineMenuVisibilitySettingsChange(oldSettingValue, newSettingValue) {
        return autofill_service_awaiter(this, void 0, void 0, function* () {
            if (oldSettingValue == null || newSettingValue == null || oldSettingValue === newSettingValue) {
                return;
            }
            const isInlineMenuVisibilitySubSetting = typeof oldSettingValue === "boolean" || typeof newSettingValue === "boolean";
            const inlineMenuPreviouslyDisabled = oldSettingValue === AutofillOverlayVisibility.Off;
            const inlineMenuCurrentlyDisabled = newSettingValue === AutofillOverlayVisibility.Off;
            if (!isInlineMenuVisibilitySubSetting &&
                !inlineMenuPreviouslyDisabled &&
                !inlineMenuCurrentlyDisabled) {
                return;
            }
            yield this.reloadAutofillScripts();
        });
    }
}
autofill_service_AutofillService.searchFieldNamesSet = new Set(AutoFillConstants.SearchFieldNames);
/* harmony default export */ var autofill_service = (autofill_service_AutofillService);

;// ./src/autofill/services/inline-menu-field-qualification.service.ts




class InlineMenuFieldQualificationService {
    /**
     * Validates the provided field to indicate if the field is a new email field used for account creation/registration.
     *
     * @param field - The field to validate
     */
    isExplicitIdentityEmailField(field) {
        const matchFieldAttributeValues = [field.type, field.htmlName, field.htmlID, field.placeholder];
        for (let attrIndex = 0; attrIndex < matchFieldAttributeValues.length; attrIndex++) {
            const attributeValueToMatch = matchFieldAttributeValues[attrIndex];
            if (!attributeValueToMatch) {
                continue;
            }
            for (let keywordIndex = 0; keywordIndex < matchFieldAttributeValues.length; keywordIndex++) {
                if (this.newEmailFieldKeywords.has(attributeValueToMatch)) {
                    return true;
                }
            }
        }
        return false;
    }
    constructor() {
        this.searchFieldNamesSet = new Set(AutoFillConstants.SearchFieldNames);
        this.excludedAutofillFieldTypesSet = new Set(AutoFillConstants.ExcludedAutofillLoginTypes);
        this.usernameFieldTypes = new Set(["text", "email", "number", "tel"]);
        this.usernameAutocompleteValue = "username";
        this.emailAutocompleteValue = "email";
        this.webAuthnAutocompleteValue = "webauthn";
        this.loginUsernameAutocompleteValues = new Set([
            this.usernameAutocompleteValue,
            this.emailAutocompleteValue,
            this.webAuthnAutocompleteValue,
        ]);
        this.fieldIgnoreListString = AutoFillConstants.FieldIgnoreList.join(",");
        this.currentPasswordAutocompleteValue = "current-password";
        this.newPasswordAutoCompleteValue = "new-password";
        this.submitButtonKeywordsMap = new WeakMap();
        this.newEmailFieldKeywords = new Set(AutoFillConstants.NewEmailFieldKeywords);
        this.creditCardFieldKeywords = [
            ...new Set([
                ...CreditCardAutoFillConstants.CardHolderFieldNames,
                ...CreditCardAutoFillConstants.CardNumberFieldNames,
                ...CreditCardAutoFillConstants.CardExpiryFieldNames,
                ...CreditCardAutoFillConstants.ExpiryMonthFieldNames,
                ...CreditCardAutoFillConstants.ExpiryYearFieldNames,
                ...CreditCardAutoFillConstants.CVVFieldNames,
                ...CreditCardAutoFillConstants.CardBrandFieldNames,
            ]),
        ];
        this.creditCardNameAutocompleteValues = new Set([
            "cc-name",
            "cc-given-name,",
            "cc-additional-name",
            "cc-family-name",
        ]);
        this.creditCardExpirationDateAutocompleteValue = "cc-exp";
        this.creditCardExpirationMonthAutocompleteValue = "cc-exp-month";
        this.creditCardExpirationYearAutocompleteValue = "cc-exp-year";
        this.creditCardCvvAutocompleteValue = "cc-csc";
        this.creditCardNumberAutocompleteValue = "cc-number";
        this.creditCardTypeAutocompleteValue = "cc-type";
        this.creditCardAutocompleteValues = new Set([
            ...this.creditCardNameAutocompleteValues,
            this.creditCardExpirationDateAutocompleteValue,
            this.creditCardExpirationMonthAutocompleteValue,
            this.creditCardExpirationYearAutocompleteValue,
            this.creditCardNumberAutocompleteValue,
            this.creditCardCvvAutocompleteValue,
            this.creditCardTypeAutocompleteValue,
        ]);
        this.identityHonorificPrefixAutocompleteValue = "honorific-prefix";
        this.identityFullNameAutocompleteValue = "name";
        this.identityFirstNameAutocompleteValue = "given-name";
        this.identityMiddleNameAutocompleteValue = "additional-name";
        this.identityLastNameAutocompleteValue = "family-name";
        this.identityNameAutocompleteValues = new Set([
            this.identityFullNameAutocompleteValue,
            this.identityHonorificPrefixAutocompleteValue,
            this.identityFirstNameAutocompleteValue,
            this.identityMiddleNameAutocompleteValue,
            this.identityLastNameAutocompleteValue,
            "honorific-suffix",
            "nickname",
        ]);
        this.identityCompanyAutocompleteValue = "organization";
        this.identityStreetAddressAutocompleteValue = "street-address";
        this.identityAddressLine1AutocompleteValue = "address-line1";
        this.identityAddressLine2AutocompleteValue = "address-line2";
        this.identityAddressLine3AutocompleteValue = "address-line3";
        this.identityAddressCityAutocompleteValue = "address-level2";
        this.identityAddressStateAutocompleteValue = "address-level1";
        this.identityAddressAutoCompleteValues = new Set([
            this.identityStreetAddressAutocompleteValue,
            this.identityAddressLine1AutocompleteValue,
            this.identityAddressLine2AutocompleteValue,
            this.identityAddressLine3AutocompleteValue,
            this.identityAddressCityAutocompleteValue,
            this.identityAddressStateAutocompleteValue,
            "shipping",
            "billing",
            "address-level4",
            "address-level3",
        ]);
        this.identityCountryAutocompleteValues = new Set(["country", "country-name"]);
        this.identityPostalCodeAutocompleteValue = "postal-code";
        this.identityPhoneAutocompleteValue = "tel";
        this.identityPhoneNumberAutocompleteValues = new Set([
            this.identityPhoneAutocompleteValue,
            "tel-country-code",
            "tel-area-code",
            "tel-local",
            "tel-extension",
        ]);
        this.identityAutocompleteValues = new Set([
            ...this.identityNameAutocompleteValues,
            ...this.loginUsernameAutocompleteValues,
            ...this.identityCompanyAutocompleteValue,
            ...this.identityAddressAutoCompleteValues,
            ...this.identityCountryAutocompleteValues,
            ...this.identityPhoneNumberAutocompleteValues,
            this.identityCompanyAutocompleteValue,
            this.identityPostalCodeAutocompleteValue,
        ]);
        this.totpFieldAutocompleteValue = "one-time-code";
        this.premiumEnabled = false;
        /**
         * Validates the provided field as a credit card name field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardholderName = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardNameAutocompleteValues)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.CardHolderFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a credit card number field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardNumber = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardNumberAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.CardNumberFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a credit card expiration date field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardExpirationDate = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardExpirationDateAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.CardExpiryFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a credit card expiration month field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardExpirationMonth = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardExpirationMonthAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.ExpiryMonthFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a credit card expiration year field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardExpirationYear = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardExpirationYearAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.ExpiryYearFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a credit card CVV field.
         *
         * @param field - The field to validate
         */
        this.isFieldForCardCvv = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.creditCardCvvAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, CreditCardAutoFillConstants.CVVFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity title type field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityTitle = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityHonorificPrefixAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.TitleFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity full name field.
         *
         * @param field
         */
        this.isFieldForIdentityFirstName = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityFirstNameAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.FirstnameFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity middle name field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityMiddleName = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityMiddleNameAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.MiddlenameFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         *  Validates the provided field as an identity last name field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityLastName = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityLastNameAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.LastnameFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity full name field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityFullName = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityFullNameAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.FullNameFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity address field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityAddress1 = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityAddressLine1AutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, [
                ...IdentityAutoFillConstants.AddressFieldNames,
                ...IdentityAutoFillConstants.Address1FieldNames,
            ], KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity address field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityAddress2 = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityAddressLine2AutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.Address2FieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity address field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityAddress3 = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityAddressLine3AutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.Address3FieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity city field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityCity = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityAddressCityAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.CityFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity state field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityState = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityAddressStateAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.StateFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity postal code field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityPostalCode = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityPostalCodeAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.PostalCodeFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity country field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityCountry = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityCountryAutocompleteValues)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.CountryFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity company field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityCompany = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityCompanyAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.CompanyFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity phone field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityPhone = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.identityPhoneAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.PhoneFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity email field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityEmail = (field) => {
            if (this.isExplicitIdentityEmailField(field)) {
                return true;
            }
            if (this.fieldContainsAutocompleteValues(field, this.emailAutocompleteValue) ||
                field.type === "email" ||
                field.htmlName === "email") {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.EmailFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as an identity username field.
         *
         * @param field - The field to validate
         */
        this.isFieldForIdentityUsername = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.usernameAutocompleteValue)) {
                return true;
            }
            return fieldContainsKeyword(field, IdentityAutoFillConstants.UserNameFieldNames, KeywordMatchMode.MatchesToken);
        };
        /**
         * Validates the provided field as a username field.
         *
         * @param field - The field to validate
         */
        this.isUsernameField = (field) => {
            const fieldType = field.type;
            if (!fieldType ||
                !this.usernameFieldTypes.has(fieldType) ||
                this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet) ||
                this.fieldHasDisqualifyingAttributeValue(field) ||
                this.isTotpField(field)) {
                return false;
            }
            return fieldContainsKeyword(field, AutoFillConstants.UsernameFieldNames);
        };
        /**
         * Validates the provided field as an email field.
         *
         * @param field - The field to validate
         */
        this.isEmailField = (field) => {
            if (this.isTotpField(field)) {
                return false;
            }
            if (field.type === "email") {
                return true;
            }
            return (!this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet) &&
                fieldContainsKeyword(field, AutoFillConstants.EmailFieldNames));
        };
        /**
         * Validates the provided field as a current password field.
         *
         * @param field - The field to validate
         */
        this.isCurrentPasswordField = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.newPasswordAutoCompleteValue) ||
                fieldContainsKeyword(field, AutoFillConstants.AccountCreationFieldKeywords)) {
                return false;
            }
            return this.isPasswordField(field);
        };
        /**
         * Validates the provided field as a current password field for an update password form.
         *
         * @param field - The field to validate
         */
        this.isUpdateCurrentPasswordField = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.newPasswordAutoCompleteValue)) {
                return false;
            }
            return (this.isPasswordField(field) &&
                fieldContainsKeyword(field, AutoFillConstants.UpdatePasswordFieldKeywords));
        };
        /**
         * Validates the provided field as a new password field.
         *
         * @param field - The field to validate
         */
        this.isNewPasswordField = (field) => {
            if (this.fieldContainsAutocompleteValues(field, this.currentPasswordAutocompleteValue)) {
                return false;
            }
            return (this.isPasswordField(field) &&
                fieldContainsKeyword(field, AutoFillConstants.AccountCreationFieldKeywords));
        };
        /**
         * Validates the provided field as a password field.
         *
         * @param field - The field to validate
         */
        this.isPasswordField = (field) => {
            const isInputPasswordType = field.type === "password";
            if ((!isInputPasswordType &&
                this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet)) ||
                this.fieldHasDisqualifyingAttributeValue(field) ||
                this.isTotpField(field)) {
                return false;
            }
            return isInputPasswordType || this.isLikePasswordField(field);
        };
        /**
         * Validates whether the provided field is a TOTP field.
         *
         * @param field - The field to validate
         */
        this.isTotpField = (field) => {
            if (fieldContainsKeyword(field, [...AutoFillConstants.RecoveryCodeFieldNames])) {
                return false;
            }
            if (this.fieldContainsAutocompleteValues(field, this.totpFieldAutocompleteValue)) {
                return true;
            }
            return (!this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet) &&
                fieldContainsKeyword(field, AutoFillConstants.TotpFieldNames));
        };
        /**
         * Validates the provided field to indicate if the field is a submit button for a login form.
         *
         * @param element - The element to validate
         */
        this.isElementLoginSubmitButton = (element) => {
            const keywordValues = this.getSubmitButtonKeywords(element);
            return SubmitLoginButtonNames.some((keyword) => keywordValues.indexOf(keyword) > -1);
        };
        /**
         * Validates the provided field to indicate if the field is a submit button for a change password form.
         *
         * @param element - The element to validate
         */
        this.isElementChangePasswordSubmitButton = (element) => {
            const keywordValues = this.getSubmitButtonKeywords(element);
            return SubmitChangePasswordButtonNames.some((keyword) => keywordValues.indexOf(keyword) > -1);
        };
        /**
         * Validates the provided field has `current-password` attribute
         *
         * * @param field - The field to validate
         */
        this.hasCurrentPasswordAutocomplete = (field) => {
            return this.fieldContainsAutocompleteValues(field, this.currentPasswordAutocompleteValue);
        };
        void sendExtensionMessage("getUserPremiumStatus").then((premiumStatus) => {
            this.premiumEnabled = !!(premiumStatus === null || premiumStatus === void 0 ? void 0 : premiumStatus.result);
        });
    }
    /**
     * Validates the provided field as a field for a login form.
     *
     * @param field - The field to validate, should be a username or password field.
     * @param pageDetails - The details of the page that the field is on.
     */
    isFieldForLoginForm(field, pageDetails) {
        /**
         * Totp inline menu is available only for premium users.
         */
        if (this.premiumEnabled) {
            const isTotpField = this.isTotpField(field);
            // Autofill does not fill totp inputs with a "password" `type` attribute value
            const passwordType = field.type === "password";
            if (isTotpField && !passwordType) {
                return true;
            }
        }
        const isCurrentPasswordField = this.isCurrentPasswordField(field);
        if (isCurrentPasswordField) {
            return this.isPasswordFieldForLoginForm(field, pageDetails);
        }
        const isUsernameField = this.isUsernameField(field);
        if (!isUsernameField) {
            return false;
        }
        return this.isUsernameFieldForLoginForm(field, pageDetails);
    }
    /**
     * Validates the provided field as a field for a credit card form.
     *
     * @param field - The field to validate
     * @param pageDetails - The details of the page that the field is on.
     */
    isFieldForCreditCardForm(field, pageDetails) {
        // If the field contains any of the standardized autocomplete attribute values
        // for credit card fields, we should assume that the field is part of a credit card form.
        if (this.fieldContainsAutocompleteValues(field, this.creditCardAutocompleteValues)) {
            return true;
        }
        let parentForm;
        const fieldForm = field.form;
        if (fieldForm) {
            parentForm = pageDetails.forms[fieldForm];
        }
        // If the field does not have a parent form
        if (!parentForm) {
            // If a credit card number field is not present on the page or there are multiple credit
            // card number fields, this field is not part of a credit card form.
            const numberFieldsInPageDetails = pageDetails.fields.filter(this.isFieldForCardNumber);
            if (numberFieldsInPageDetails.length !== 1) {
                return false;
            }
            // If a credit card CVV field is not present on the page or there are multiple credit card
            // CVV fields, this field is not part of a credit card form.
            const cvvFieldsInPageDetails = pageDetails.fields.filter(this.isFieldForCardCvv);
            if (cvvFieldsInPageDetails.length !== 1) {
                return false;
            }
            return fieldContainsKeyword(field, this.creditCardFieldKeywords);
        }
        // If the field has a parent form, check the fields from that form exclusively
        const fieldsFromSameForm = pageDetails.fields.filter((f) => f.form === field.form);
        // If a credit card number field is not present on the page or there are multiple credit
        // card number fields, this field is not part of a credit card form.
        const numberFieldsInPageDetails = fieldsFromSameForm.filter(this.isFieldForCardNumber);
        if (numberFieldsInPageDetails.length !== 1) {
            return false;
        }
        // If a credit card CVV field is not present on the page or there are multiple credit card
        // CVV fields, this field is not part of a credit card form.
        const cvvFieldsInPageDetails = fieldsFromSameForm.filter(this.isFieldForCardCvv);
        if (cvvFieldsInPageDetails.length !== 1) {
            return false;
        }
        return fieldContainsKeyword(field, [...this.creditCardFieldKeywords]);
    }
    /** Validates the provided field as a field for an account creation form.
     *
     * @param field - The field to validate
     * @param pageDetails - The details of the page that the field is on.
     */
    isFieldForAccountCreationForm(field, pageDetails) {
        if (this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet) ||
            this.isTotpField(field)) {
            return false;
        }
        if (!this.isUsernameField(field) && !this.isPasswordField(field)) {
            return false;
        }
        let parentForm;
        const fieldForm = field.form;
        if (fieldForm) {
            parentForm = pageDetails.forms[fieldForm];
        }
        if (!parentForm) {
            // If the field does not have a parent form, but we can identify that the page contains at least
            // one new password field, we should assume that the field is part of an account creation form.
            const newPasswordFields = pageDetails.fields.filter(this.isNewPasswordField);
            if (newPasswordFields.length >= 1) {
                return true;
            }
            // If no password fields are found on the page, check for keywords that indicate the field is
            // part of an account creation form.
            return fieldContainsKeyword(field, AutoFillConstants.AccountCreationFieldKeywords);
        }
        // If the field has a parent form, check the fields from that form exclusively
        const fieldsFromSameForm = pageDetails.fields.filter((f) => f.form === field.form);
        const newPasswordFields = fieldsFromSameForm.filter(this.isNewPasswordField);
        if (newPasswordFields.length >= 1) {
            return true;
        }
        return fieldContainsKeyword(field, AutoFillConstants.AccountCreationFieldKeywords);
    }
    /**
     * Validates the provided field as a field for an identity form.
     *
     * @param field - The field to validate
     * @param _pageDetails - Currently unused, will likely be required in the future
     */
    isFieldForIdentityForm(field, _pageDetails) {
        if (this.isExcludedFieldType(field, this.excludedAutofillFieldTypesSet)) {
            return false;
        }
        return (
        // Recognize explicit identity email fields (like id="new-email")
        this.isFieldForIdentityEmail(field) ||
            this.fieldContainsAutocompleteValues(field, this.identityAutocompleteValues));
    }
    /**
     * Validates the provided field as a password field for a login form.
     *
     * @param field - The field to validate
     * @param pageDetails - The details of the page that the field is on.
     */
    isPasswordFieldForLoginForm(field, pageDetails) {
        let parentForm;
        const fieldForm = field.form;
        if (fieldForm) {
            parentForm = pageDetails.forms[fieldForm];
        }
        // If the provided field is set with an autocomplete value of "current-password", we should assume that
        // the page developer intends for this field to be interpreted as a password field for a login form.
        if (this.fieldContainsAutocompleteValues(field, this.currentPasswordAutocompleteValue)) {
            if (!parentForm) {
                return (pageDetails.fields.filter(this.isNewPasswordField).filter((f) => f.viewable).length === 0);
            }
            return (pageDetails.fields
                .filter(this.isNewPasswordField)
                .filter((f) => f.viewable && f.form === field.form).length === 0);
        }
        const usernameFieldsInPageDetails = pageDetails.fields.filter(this.isUsernameField);
        const passwordFieldsInPageDetails = pageDetails.fields.filter(this.isCurrentPasswordField);
        // If a single username and a single password field exists on the page, we
        // should assume that this field is part of a login form.
        if (usernameFieldsInPageDetails.length === 1 && passwordFieldsInPageDetails.length === 1) {
            return true;
        }
        // If the field is not structured within a form, we need to identify if the field is present on
        // a page with multiple password fields. If that isn't the case, we can assume this is a login form field.
        if (!parentForm) {
            // If no parent form is found, and multiple password fields are present, we should assume that
            // the passed field belongs to a user account creation form.
            if (passwordFieldsInPageDetails.length > 1) {
                return false;
            }
            // If multiple username fields exist on the page, we should assume that
            // the provided field is part of an account creation form.
            const visibleUsernameFields = usernameFieldsInPageDetails.filter((f) => f.viewable);
            if (visibleUsernameFields.length > 1) {
                return false;
            }
            // If a single username field or less is present on the page, then we can assume that the
            // provided field is for a login form.
            return true;
        }
        // If the field has a form parent and there are multiple visible password fields
        // in the form, this is not a login form field
        const visiblePasswordFieldsInPageDetails = passwordFieldsInPageDetails.filter((f) => f.form === field.form && f.viewable);
        if (visiblePasswordFieldsInPageDetails.length > 1) {
            return false;
        }
        // If the form has any visible username fields, we should treat the field as part of a login form
        const visibleUsernameFields = usernameFieldsInPageDetails.filter((f) => f.form === field.form && f.viewable);
        if (visibleUsernameFields.length > 0) {
            return true;
        }
        // If the field has a form parent and a username field exists this is a password field
        return true;
    }
    /**
     * Validates the provided field as a username field for a login form.
     *
     * @param field - The field to validate
     * @param pageDetails - The details of the page that the field is on.
     */
    isUsernameFieldForLoginForm(field, pageDetails) {
        // If the provided field is set with an autocomplete of "username", we should assume that
        // the page developer intends for this field to be interpreted as a username field.
        // Exclude non-login email field from being treated as a login username field
        if (this.isExplicitIdentityEmailField(field)) {
            return false;
        }
        if (this.fieldContainsAutocompleteValues(field, this.loginUsernameAutocompleteValues)) {
            const newPasswordFieldsInPageDetails = pageDetails.fields.filter((field) => field.viewable && this.isNewPasswordField(field));
            return newPasswordFieldsInPageDetails.length === 0;
        }
        // If any keywords in the field's data indicates that this is a field for a "new" or "changed"
        // username, we should assume that this field is not for a login form.
        if (fieldContainsKeyword(field, AutoFillConstants.AccountCreationFieldKeywords)) {
            return false;
        }
        // If the field is not explicitly set as a username field, we need to qualify
        // the field based on the other fields that are present on the page.
        let parentForm;
        const fieldForm = field.form;
        if (fieldForm) {
            parentForm = pageDetails.forms[fieldForm];
        }
        const passwordFieldsInPageDetails = pageDetails.fields.filter(this.isCurrentPasswordField);
        if (isNonLoginUsernameField(field, pageDetails)) {
            return false;
        }
        // If the field is not structured within a form, we need to identify if the field is used in conjunction
        // with a password field. If that's the case, then we should assume that it is a form field element.
        if (!parentForm) {
            // If a formless field is present in a webpage with a single password field, we
            // should assume that it is part of a login workflow.
            const visiblePasswordFieldsInPageDetails = passwordFieldsInPageDetails.filter((passwordField) => passwordField.viewable);
            if (visiblePasswordFieldsInPageDetails.length === 1) {
                return true;
            }
            // If more than a single password field exists on the page, we should assume that the field
            // is part of an account creation form.
            if (visiblePasswordFieldsInPageDetails.length > 1) {
                return false;
            }
            // If no visible fields are found on the page, but we have a single password
            // field we should assume that the field is part of a login form.
            if (passwordFieldsInPageDetails.length === 1) {
                return true;
            }
            // If the page does not contain any password fields, it might be part of a multistep login form.
            // Before defaulting to login, consult the tie-breaker.
            if (isAmbiguousFieldNonLogin(field, pageDetails)) {
                return false;
            }
            return true;
        }
        // If the field is structured within a form, but no password fields are present in the form,
        // we need to consider whether the field is part of a multistep login form.
        if (passwordFieldsInPageDetails.length === 0) {
            // If the form contains a single login-eligible field (excluding non-login types like
            // checkboxes and textareas), we should assume it is part of a multistep login form.
            const loginEligibleFieldsWithinForm = pageDetails.fields.filter((pageDetailsField) => pageDetailsField.form === field.form &&
                pageDetailsField.type != null &&
                this.usernameFieldTypes.has(pageDetailsField.type));
            if (loginEligibleFieldsWithinForm.length === 1) {
                // Before defaulting to login, consult the tie-breaker.
                if (isAmbiguousFieldNonLogin(field, pageDetails)) {
                    return false;
                }
                return true;
            }
            // If multiple login-eligible fields exist within the form, we should check if a
            // single visible field exists. If so, we should assume that the field is part of a login form.
            return loginEligibleFieldsWithinForm.filter((field) => field.viewable).length === 1;
        }
        // If a single password field exists within the page details, and that password field is part of
        // the same form as the provided field, we should assume that the field is part of a login form.
        const visiblePasswordFieldsInPageDetails = passwordFieldsInPageDetails.filter((passwordField) => passwordField.form === field.form && passwordField.viewable);
        if (visiblePasswordFieldsInPageDetails.length === 1) {
            return true;
        }
        // If multiple visible password fields exist within the page details, we need to assume that the
        // provided field is part of an account creation form.
        if (visiblePasswordFieldsInPageDetails.length > 1) {
            return false;
        }
        // If we have a single password field we should assume that the field is part of a login form.
        if (passwordFieldsInPageDetails.length === 1) {
            return true;
        }
        // If no visible password fields are found, this field might be part of a multipart form.
        return true;
    }
    /**
     * Validates the provided field as a field to indicate if the
     * field potentially acts as a password field.
     *
     * @param field - The field to validate
     */
    isLikePasswordField(field) {
        if (field.type !== "text") {
            return false;
        }
        const testedValues = [field.htmlID, field.htmlName, field.placeholder];
        for (let i = 0; i < testedValues.length; i++) {
            const attributeValueToMatch = testedValues[i];
            if (!attributeValueToMatch) {
                continue;
            }
            if (this.valueIsLikePassword(attributeValueToMatch)) {
                return true;
            }
        }
        return false;
    }
    /**
     * Validates the provided value to indicate if the value is like a password.
     *
     * @param value - The value to validate
     */
    valueIsLikePassword(value) {
        if (value == null) {
            return false;
        }
        // Removes all whitespace, _ and - characters
        const cleanedValue = value.toLowerCase().replace(/[\s_-]/g, "");
        if (cleanedValue.indexOf("password") < 0) {
            return false;
        }
        return !AutoFillConstants.PasswordFieldExcludeList.some((i) => cleanedValue.indexOf(i) > -1);
    }
    /**
     * Validates the provided field to indicate if the field has a
     * disqualifying attribute that would impede autofill entirely.
     *
     * @param field - The field to validate
     */
    fieldHasDisqualifyingAttributeValue(field) {
        const checkedAttributeValues = [field.htmlID, field.htmlName, field.placeholder];
        for (let i = 0; i < checkedAttributeValues.length; i++) {
            const checkedAttributeValue = checkedAttributeValues[i];
            const cleanedValue = checkedAttributeValue === null || checkedAttributeValue === void 0 ? void 0 : checkedAttributeValue.toLowerCase().replace(/[\s_-]/g, "");
            if (cleanedValue && this.fieldIgnoreListString.indexOf(cleanedValue) > -1) {
                return true;
            }
        }
        return false;
    }
    /**
     * Validates the provided field to indicate if the field is excluded from autofill.
     *
     * @param field - The field to validate
     * @param excludedTypes - The set of excluded types
     */
    isExcludedFieldType(field, excludedTypes) {
        const fieldType = field.type;
        if (fieldType && excludedTypes.has(fieldType)) {
            return true;
        }
        return this.isSearchField(field);
    }
    /**
     * Validates the provided field to indicate if the field is a search field.
     *
     * @param field - The field to validate
     */
    isSearchField(field) {
        const matchFieldAttributeValues = [field.type, field.htmlName, field.htmlID, field.placeholder];
        for (let attrIndex = 0; attrIndex < matchFieldAttributeValues.length; attrIndex++) {
            const attributeValueToMatch = matchFieldAttributeValues[attrIndex];
            if (!attributeValueToMatch) {
                continue;
            }
            // Separate camel case words and case them to lower case values
            const camelCaseSeparatedFieldAttribute = attributeValueToMatch
                .replace(/([a-z])([A-Z])/g, "$1 $2")
                .toLowerCase();
            // Split the attribute by non-alphabetical characters to get the keywords
            const attributeKeywords = camelCaseSeparatedFieldAttribute.split(/[^a-z]/gi);
            for (let keywordIndex = 0; keywordIndex < attributeKeywords.length; keywordIndex++) {
                if (this.searchFieldNamesSet.has(attributeKeywords[keywordIndex])) {
                    return true;
                }
            }
        }
        return false;
    }
    /**
     * Gather the keywords from the provided element to validate the submit button.
     *
     * @param element - The element to validate
     */
    getSubmitButtonKeywords(element) {
        if (!this.submitButtonKeywordsMap.has(element)) {
            const keywordsSet = getSubmitButtonKeywordsSet(element);
            this.submitButtonKeywordsMap.set(element, Array.from(keywordsSet).join(","));
        }
        return this.submitButtonKeywordsMap.get(element) || "";
    }
    /**
     * Separates the provided field data into space-separated values and checks if any
     * of the values are present in the provided set of autocomplete values.
     *
     * @param autofillFieldData - The field autocomplete value to validate
     * @param compareValues - The set of autocomplete values to check against
     */
    fieldContainsAutocompleteValues(autofillFieldData, compareValues) {
        const fieldAutocompleteValue = autofillFieldData.autoCompleteType;
        if (!fieldAutocompleteValue || typeof fieldAutocompleteValue !== "string") {
            return false;
        }
        if (typeof compareValues === "string") {
            return autofill_service.autoCompleteTypeIncludesToken(fieldAutocompleteValue, compareValues);
        }
        for (const token of compareValues) {
            if (autofill_service.autoCompleteTypeIncludesToken(fieldAutocompleteValue, token)) {
                return true;
            }
        }
        return false;
    }
}

;// ./src/autofill/models/autofill-field.ts
/**
 * Represents a single field that is collected from the page source and is potentially autofilled.
 */
class AutofillField {
}

;// ./src/autofill/services/collect-autofill-content.service.ts
var collect_autofill_content_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};




class CollectAutofillContentService {
    constructor(domElementVisibilityService, domQueryService, autofillOverlayContentService) {
        this.domElementVisibilityService = domElementVisibilityService;
        this.domQueryService = domQueryService;
        this.autofillOverlayContentService = autofillOverlayContentService;
        this.sendExtensionMessage = sendExtensionMessage;
        this.getAttributeBoolean = getAttributeBoolean;
        this.getPropertyOrAttribute = getPropertyOrAttribute;
        this.noFieldsFound = false;
        this.domRecentlyMutated = true;
        /**
         * undefined = not yet fetched, null = no rules (use heuristics),
         * [] = blocklisted (suppress autofill), [...] = use targeted fill
         */
        this.pageTargetingRules = undefined;
        this._autofillFormElements = new Map();
        this.autofillFieldElements = new Map();
        this.autofillFieldsByOpid = new Map();
        this.currentLocationHref = "";
        this.elementInitializingIntersectionObserver = new Set();
        this.isMonitoring = false;
        this.pendingAttributeMutations = new Map();
        this.pendingTopLayerTargets = new Set();
        this.pendingChildListUpdate = false;
        this.lastDetachedPurgeAt = -Infinity;
        this.detachedPurgeThrottleMs = 1000;
        this.updateAfterMutationIdleCallback = null;
        this.pendingOverlaySetup = new Map();
        this.overlaySetupDelayMs = 100;
        this.shadowDomCheckTimeout = null;
        this.pendingShadowDomCheck = false;
        this.pendingMutationAddedElements = new Set();
        this.pendingMutationAddedElementsOverflowed = false;
        // Caps the batch handed to suppressDescendantsInBatch; overflow → full-document scan fallback.
        this.pendingMutationAddedElementsCap = 256;
        this.ownedExperienceTagNames = [];
        this.updateAfterMutationTimeout = 1000;
        this.shadowDomCheckTimeoutMs = 500;
        this.shadowDomCheckDebounceMs = 300;
        this.lastMutationTimestamp = 0;
        this.mutationBurstCount = 0;
        this.mutationCooldownMs = 500;
        this.maxMutationWaitMs = 5000;
        this.nonInputFormFieldTags = new Set(["textarea", "select"]);
        this.ignoredInputTypes = new Set([
            "hidden",
            "submit",
            "reset",
            "button",
            "image",
            "file",
            "search",
            "url",
            "date",
            "time",
            "datetime", // Note: datetime is deprecated in HTML5; keeping here for backwards compatibility
            "datetime-local",
            "week",
            "color",
            "range",
        ]);
        /**
         * Builds an AutofillField object from the given form element. Will only return
         * shared field values if the element is a span element. Will not return any label
         * values if the element is a hidden input element.
         *
         * @param element - The form field element to build the AutofillField object from
         * @param index - The index of the form field element
         */
        this.buildAutofillFieldItem = (element, index) => collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            if (element.closest("button[type='submit']")) {
                return null;
            }
            element.opid = `__${index}`;
            const existingAutofillField = this.autofillFieldElements.get(element);
            if (index >= 0 && existingAutofillField) {
                existingAutofillField.opid = element.opid;
                existingAutofillField.elementNumber = index;
                this.autofillFieldElements.set(element, existingAutofillField);
                return existingAutofillField;
            }
            const autofillFieldBase = {
                opid: element.opid,
                elementNumber: index,
                maxLength: this.getAutofillFieldMaxLength(element),
                viewable: yield this.domElementVisibilityService.isElementViewable(element),
                htmlID: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.ID),
                htmlName: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.NAME),
                htmlClass: this.getPropertyOrAttribute(element, "class"),
                tabindex: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.TABINDEX),
                title: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.TITLE),
                tagName: this.getAttributeLowerCase(element, "tagName"),
                dataSetValues: this.getDataSetValues(element),
            };
            // FIXME should a targeted rule be allowed to fill non-viewable fields
            // without waiting for them to enter the viewport?
            if (!autofillFieldBase.viewable) {
                this.elementInitializingIntersectionObserver.add(element);
                this.intersectionObserver.observe(element);
            }
            if (elementIsSpanElement(element)) {
                this.cacheAutofillFieldElement(index, element, autofillFieldBase);
                return autofillFieldBase;
            }
            let autofillFieldLabels = {};
            const elementType = this.getAttributeLowerCase(element, AUTOFILL_ATTRIBUTES.TYPE);
            if (elementType !== "hidden") {
                autofillFieldLabels = {
                    "label-tag": this.createAutofillFieldLabelTag(element),
                    "label-data": this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.DATA_LABEL),
                    "label-aria": this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.ARIA_LABEL),
                    "label-top": this.createAutofillFieldTopLabel(element),
                    "label-right": this.createAutofillFieldRightLabel(element),
                    "label-left": this.createAutofillFieldLeftLabel(element),
                    placeholder: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.PLACEHOLDER),
                };
            }
            const fieldFormElement = element.form;
            const autofillField = Object.assign(Object.assign(Object.assign({}, autofillFieldBase), autofillFieldLabels), { rel: this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.REL), type: elementType, value: this.getElementValue(element), checked: this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.CHECKED), autoCompleteType: this.getAutoCompleteAttribute(element), disabled: this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.DISABLED), readonly: this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.READONLY), selectInfo: elementIsSelectElement(element)
                    ? this.getSelectElementOptions(element)
                    : null, form: fieldFormElement ? this.getPropertyOrAttribute(fieldFormElement, "opid") : null, "aria-describedby": this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.ARIA_DESCRIBEDBY), "aria-hidden": this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_HIDDEN, true), "aria-disabled": this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_DISABLED, true), "aria-haspopup": this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_HASPOPUP, true), "data-stripe": this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.DATA_STRIPE) });
            this.cacheAutofillFieldElement(index, element, autofillField);
            return autofillField;
        });
        /**
         * Map over all the label elements and creates a
         * string of the text content of each label element.
         * @param {Set<HTMLElement>} labelElementsSet
         * @returns {string}
         * @private
         */
        this.createLabelElementsTag = (labelElementsSet) => {
            return Array.from(labelElementsSet)
                .map((labelElement) => {
                const textContent = labelElement
                    ? labelElement.textContent || labelElement.innerText
                    : null;
                return this.trimAndRemoveNonPrintableText(textContent || "");
            })
                .join("");
        };
        this.setupInitialTopLayerListeners = () => {
            var _a;
            const unownedTopLayerItems = (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.getUnownedTopLayerItems(true);
            if (unownedTopLayerItems === null || unownedTopLayerItems === void 0 ? void 0 : unownedTopLayerItems.length) {
                for (const unownedElement of unownedTopLayerItems) {
                    if (this.shouldListenToTopLayerCandidate(unownedElement)) {
                        this.setupTopLayerCandidateListener(unownedElement);
                    }
                }
            }
        };
        /**
         * Handles observed DOM mutations and identifies if a mutation is related to
         * an autofill element. If so, it will update the autofill element data.
         * @param {MutationRecord[]} mutations
         * @private
         */
        this.handleMutationObserverMutation = (mutations) => {
            var _a, _b;
            if (this.currentLocationHref !== globalThis.location.href) {
                this.handleWindowLocationMutation();
                return;
            }
            // Throttled; runs every wake so detached nodes are reclaimed even when no drain is scheduled.
            this.purgeDetachedNodesIfDue();
            const hasMutationsInShadowRoot = this.domQueryService.checkMutationsInShadowRoots(mutations);
            if (hasMutationsInShadowRoot) {
                this.debouncedRequirePageDetailsUpdate();
            }
            // New-shadow-root detection only runs when a batch actually added nodes;
            // attribute/character-data mutations can't introduce shadow roots.
            const hasAddedNodes = mutations.some((m) => { var _a, _b; return ((_b = (_a = m.addedNodes) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; });
            if (hasAddedNodes) {
                this.collectAddedShadowRootCandidates(mutations);
                if (!this.pendingShadowDomCheck) {
                    this.pendingShadowDomCheck = true;
                    if (this.shadowDomCheckTimeout) {
                        clearTimeout(this.shadowDomCheckTimeout);
                    }
                    this.shadowDomCheckTimeout = setTimeout(() => {
                        this.handleNewShadowRoots();
                        this.pendingShadowDomCheck = false;
                        this.pendingMutationAddedElements.clear();
                        this.pendingMutationAddedElementsOverflowed = false;
                    }, this.shadowDomCheckTimeoutMs);
                }
            }
            // Drain only when idle AND this batch added work; no-op drains are pure overhead.
            const queueWasIdle = !this.hasPendingWork;
            for (const mutation of mutations) {
                if (mutation.type === "attributes") {
                    if (!nodeIsElement(mutation.target)) {
                        continue;
                    }
                    const attributeName = (_a = mutation.attributeName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
                    if (!attributeName) {
                        continue;
                    }
                    const target = mutation.target;
                    let attributeNames = this.pendingAttributeMutations.get(target);
                    if (!attributeNames) {
                        attributeNames = new Set();
                        this.pendingAttributeMutations.set(target, attributeNames);
                    }
                    attributeNames.add(attributeName);
                    if (this.isPopoverAttribute(attributeName)) {
                        this.pendingTopLayerTargets.add(target);
                    }
                }
                else if (mutation.type === "childList") {
                    // Gate the noFieldsFound-invalidating flag; skip the walk once it's set.
                    if (!this.pendingChildListUpdate && this.mutationAddsOrRemovesFormField(mutation)) {
                        this.pendingChildListUpdate = true;
                    }
                    for (const node of (_b = mutation.addedNodes) !== null && _b !== void 0 ? _b : []) {
                        if (!nodeIsElement(node)) {
                            continue;
                        }
                        if (this.shouldListenToTopLayerCandidate(node)) {
                            this.pendingTopLayerTargets.add(node);
                        }
                    }
                }
            }
            if (queueWasIdle && this.hasPendingWork) {
                requestIdleCallbackPolyfill(this.processMutations, { timeout: 500 });
            }
        };
        this.processMutations = () => {
            // Swap first so reentrant mutations during processing land in fresh structures
            // and drain on the next cycle, mirroring the queue-swap the previous design relied on.
            const drainingAttributeMutations = this.pendingAttributeMutations;
            const drainingTopLayer = this.pendingTopLayerTargets;
            const childListNeeded = this.pendingChildListUpdate;
            this.pendingAttributeMutations = new Map();
            this.pendingTopLayerTargets = new Set();
            this.pendingChildListUpdate = false;
            // Drain-time purge: throttled, so this only does work when the window elapsed since the wake-purge.
            this.purgeDetachedNodesIfDue();
            if (drainingAttributeMutations.size === 0 && drainingTopLayer.size === 0 && !childListNeeded) {
                return;
            }
            requestIdleCallbackPolyfill(() => {
                for (const element of drainingTopLayer) {
                    this.setupTopLayerCandidateListener(element);
                }
                if (childListNeeded) {
                    // Full rebuild re-reads every attribute, so the per-attribute path is redundant here.
                    this.requirePageDetailsUpdate();
                }
                else {
                    for (const [target, attributeNames] of drainingAttributeMutations) {
                        for (const attributeName of attributeNames) {
                            this.applyAttributeMutation(target, attributeName);
                        }
                    }
                }
                if (this.domRecentlyMutated) {
                    this.updateAutofillElementsAfterMutation();
                }
            }, { timeout: 500 });
        };
        this.debouncedRequirePageDetailsUpdate = debounce(() => {
            this.requirePageDetailsUpdate();
            this.updateAutofillElementsAfterMutation();
        }, this.shadowDomCheckDebounceMs);
        /**
         * Detects new shadow roots and schedules a page details update if any are found.
         * This is called periodically to catch shadow roots added after initial page load.
         * The update is debounced to prevent excessive collection triggers.
         * @private
         */
        this.handleNewShadowRoots = () => {
            // Hosts added by mutation may have been removed during the 500ms debounce.
            const connected = [];
            for (const element of this.pendingMutationAddedElements) {
                if (element.isConnected) {
                    connected.push(element);
                }
            }
            const hasNewShadowRoots = this.domQueryService.checkForNewShadowRoots(connected);
            if (hasNewShadowRoots) {
                this.debouncedRequirePageDetailsUpdate();
            }
        };
        this.setupTopLayerCandidateListener = (element) => {
            const overlayService = this.autofillOverlayContentService;
            if (overlayService !== undefined) {
                const ownedTags = overlayService.getOwnedInlineMenuTagNames() || [];
                this.ownedExperienceTagNames = ownedTags;
                if (!ownedTags.includes(element.tagName)) {
                    const toggleListener = (event) => {
                        if (event.newState === "open") {
                            // Add a slight delay (but faster than a user's reaction), to ensure the layer
                            // positioning happens after any triggered toggle has completed.
                            setTimeout(() => {
                                overlayService.refreshMenuLayerPosition();
                            }, 100);
                        }
                    };
                    element.addEventListener("toggle", toggleListener);
                    overlayService.refreshMenuLayerPosition();
                }
            }
        };
        this.isPopoverAttribute = (attr) => {
            const popoverAttributes = new Set(["popover", "popovertarget", "popovertargetaction"]);
            return attr && popoverAttributes.has(attr.toLowerCase());
        };
        this.shouldListenToTopLayerCandidate = (element) => {
            return (!this.ownedExperienceTagNames.includes(element.tagName) &&
                (element.tagName === "DIALOG" ||
                    Array.from(element.attributes || []).some((attribute) => this.isPopoverAttribute(attribute.name))));
        };
        /**
         * Handles observed form field elements that are not viewable in the viewport.
         * Will re-evaluate the visibility of the element and set up the autofill
         * overlay listeners on the field if it is viewable.
         *
         * @param entries - The entries observed by the IntersectionObserver
         */
        this.handleFormElementIntersection = (entries) => collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            for (let entryIndex = 0; entryIndex < entries.length; entryIndex++) {
                const entry = entries[entryIndex];
                const formFieldElement = entry.target;
                if (this.elementInitializingIntersectionObserver.has(formFieldElement)) {
                    this.elementInitializingIntersectionObserver.delete(formFieldElement);
                    continue;
                }
                const cachedAutofillFieldElement = this.autofillFieldElements.get(formFieldElement);
                if (!cachedAutofillFieldElement) {
                    this.intersectionObserver.unobserve(entry.target);
                    continue;
                }
                const isViewable = yield this.domElementVisibilityService.isElementViewable(formFieldElement);
                if (!isViewable) {
                    continue;
                }
                cachedAutofillFieldElement.viewable = true;
                this.setupOverlayOnField(formFieldElement, cachedAutofillFieldElement);
                this.intersectionObserver.unobserve(entry.target);
            }
        });
        let inputQuery = "input:not([data-bwignore])";
        for (const type of this.ignoredInputTypes) {
            inputQuery += `:not([type="${type}"])`;
        }
        this.formFieldQueryString = `${inputQuery}, textarea:not([data-bwignore]), select:not([data-bwignore]), span[data-bwautofill]`;
        this.mutationObserver = new MutationObserver(this.handleMutationObserverMutation);
        this.intersectionObserver = new IntersectionObserver(this.handleFormElementIntersection, {
            root: null,
            rootMargin: "0px",
            // Safari doesn't seem to function properly with a threshold of 1.
            threshold: 0.9999,
        });
        // Match owned inline-menu hosts by identity, not tag name — a tag-name match would
        // over-exclude same-tag page elements and is spoofable by the page.
        this.domQueryService.setOwnedShadowHostPredicate((host) => { var _a, _b; return (_b = (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.isElementInlineMenu(host)) !== null && _b !== void 0 ? _b : false; });
    }
    /**
     * Attaches the mutation observer to the document. The intersection
     * observer is allocated at construction; it attaches per-field as
     * fields are cached during page-details collection. Idempotent.
     */
    startMonitoring() {
        if (this.isMonitoring) {
            return;
        }
        this.isMonitoring = true;
        this.currentLocationHref = globalThis.location.href;
        // FIXME we might be able to use an alternate (less expensive) mutation observer setup when targeting rules are being used
        this.mutationObserver.observe(document.documentElement, {
            attributes: true,
            attributeFilter: Object.values(AUTOFILL_ATTRIBUTES),
            childList: true,
            subtree: true,
        });
    }
    /**
     * Detaches observers and clears monitoring-scoped state so a future
     * `startMonitoring()` begins fresh against the current page. Idempotent.
     */
    stopMonitoring() {
        this.isMonitoring = false;
        if (this.updateAfterMutationIdleCallback !== null) {
            cancelIdleCallbackPolyfill(this.updateAfterMutationIdleCallback);
            this.updateAfterMutationIdleCallback = null;
        }
        if (this.shadowDomCheckTimeout) {
            clearTimeout(this.shadowDomCheckTimeout);
            this.shadowDomCheckTimeout = null;
        }
        this.pendingOverlaySetup.forEach((timeout) => globalThis.clearTimeout(timeout));
        this.pendingOverlaySetup.clear();
        this.mutationObserver.disconnect();
        this.intersectionObserver.disconnect();
        this._autofillFormElements.clear();
        this.autofillFieldElements.clear();
        this.autofillFieldsByOpid.clear();
        this.elementInitializingIntersectionObserver.clear();
        this.noFieldsFound = false;
        this.domRecentlyMutated = true;
        this.pendingShadowDomCheck = false;
        this.currentLocationHref = "";
    }
    get autofillFormElements() {
        return this._autofillFormElements;
    }
    /**
     * Builds the data for all forms and fields found within the page DOM.
     * Sets up a mutation observer to verify DOM changes and returns early
     * with cached data if no changes are detected.
     * @returns {Promise<AutofillPageDetails>}
     * @public
     */
    getPageDetails() {
        return collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            var _a;
            // Set up listeners on top-layer candidates that predate Mutation Observer setup
            if (this.autofillOverlayContentService) {
                this.setupInitialTopLayerListeners();
            }
            // Check for targeting rules before running heuristic collection
            if (this.pageTargetingRules === undefined) {
                this.pageTargetingRules =
                    (_a = (yield this.sendExtensionMessage("getUrlAutofillTargetingRules")).result) !== null && _a !== void 0 ? _a : null;
            }
            const targetingRules = this.pageTargetingRules;
            if (targetingRules != null) {
                if (targetingRules.length === 0) {
                    // Blocklisted; return empty page details, skip heuristics
                    return this.getFormattedPageDetails({}, []);
                }
                return this.getTargetedPageDetails(targetingRules);
            }
            if (!this.domRecentlyMutated && this.noFieldsFound) {
                return this.getFormattedPageDetails({}, []);
            }
            if (!this.domRecentlyMutated && this.autofillFieldElements.size) {
                this.updateCachedAutofillFieldVisibility();
                return this.getFormattedPageDetails(this.getFormattedAutofillFormsData(), this.getFormattedAutofillFieldsData());
            }
            const { formElements, formFieldElements } = this.queryAutofillFormAndFieldElements();
            const autofillFormsData = this.buildAutofillFormsData(formElements);
            const autofillFieldsData = yield this.buildAutofillFieldsData(formFieldElements);
            this.sortAutofillFieldElementsMap();
            if (!autofillFieldsData.length) {
                this.noFieldsFound = true;
            }
            this.domRecentlyMutated = false;
            const pageDetails = this.getFormattedPageDetails(autofillFormsData, autofillFieldsData);
            this.setupOverlayListeners(pageDetails);
            return pageDetails;
        });
    }
    /**
     * Find an AutofillField element by its opid, will only return the first
     * element if there are multiple elements with the same opid. If no
     * element is found, null will be returned.
     * @param {string} opid
     * @returns {FormFieldElement | null}
     */
    getAutofillFieldElementByOpid(opid) {
        // O(1): Try dual-index lookup first
        const cachedElement = this.autofillFieldsByOpid.get(opid);
        if (cachedElement) {
            // Validate element is still in DOM (not stale)
            if (cachedElement.isConnected) {
                return cachedElement;
            }
            // Stale entry - clean it up
            this.autofillFieldElements.delete(cachedElement);
            this.autofillFieldsByOpid.delete(opid);
        }
        // Fallback: No cached element or it was stale, query DOM
        const cachedFormFieldElements = Array.from(this.autofillFieldElements.keys());
        const formFieldElements = (cachedFormFieldElements === null || cachedFormFieldElements === void 0 ? void 0 : cachedFormFieldElements.length)
            ? cachedFormFieldElements
            : this.getAutofillFieldElements();
        const fieldElementsWithOpid = formFieldElements.filter((fieldElement) => fieldElement.opid === opid);
        if (!fieldElementsWithOpid.length) {
            const elementIndex = parseInt(opid.split("__")[1], 10);
            return formFieldElements[elementIndex] || null;
        }
        if (fieldElementsWithOpid.length > 1) {
            // eslint-disable-next-line no-console
            console.warn(`More than one element found with opid ${opid}`);
        }
        return fieldElementsWithOpid[0];
    }
    /**
     * Sorts the AutofillFieldElements map by the elementNumber property.
     * @private
     */
    sortAutofillFieldElementsMap() {
        if (!this.autofillFieldElements.size) {
            return;
        }
        this.autofillFieldElements = new Map([...this.autofillFieldElements].sort((a, b) => a[1].elementNumber - b[1].elementNumber));
    }
    /**
     * Formats and returns the AutofillPageDetails object
     *
     * @param autofillFormsData - The data for all the forms found in the page
     * @param autofillFieldsData - The data for all the fields found in the page
     */
    getFormattedPageDetails(autofillFormsData, autofillFieldsData) {
        return {
            title: document.title,
            url: (document.defaultView || globalThis).location.href,
            documentUrl: document.location.href,
            forms: autofillFormsData,
            fields: autofillFieldsData,
            collectedTimestamp: Date.now(),
        };
    }
    /**
     * Builds page details using targeting rule selectors instead of heuristic
     * detection. Iterates through form definitions, resolving each field type's
     * selector array by trying each `DeepSelector` in order and stopping at the
     * first DOM match.
     */
    getTargetedPageDetails(forms) {
        const targets = forms.flatMap((form) => Object.entries(form.fields)
            .filter(([, alternatives]) => alternatives === null || alternatives === void 0 ? void 0 : alternatives.length)
            .map(([fieldType, selectorAlternatives]) => ({
            fieldType,
            selectorAlternatives,
            formCategory: form.category,
        })));
        const { localFields, iframeTargets } = this.resolveTargetedFields(targets);
        this.routeIframeTargets(iframeTargets);
        // If this frame resolved no local targeted fields but already has fields cached
        // from a prior applyExternalTargetedFields call, use those cached fields. This
        // handles the case where an iframe's own getPageDetails() runs the targeting path
        // (because targeting rules apply to the whole tab URL) but all selectors in the
        // rules cross an iframe boundary that doesn't exist inside this frame — so the
        // results are empty, and we must not overwrite the background's page-details entry
        // with an empty payload.
        if (!localFields.length && this.autofillFieldElements.size > 0) {
            this.domRecentlyMutated = false;
            const cachedPageDetails = this.getFormattedPageDetails(this.getFormattedAutofillFormsData(), this.getFormattedAutofillFieldsData());
            this.setupOverlayListeners(cachedPageDetails);
            return cachedPageDetails;
        }
        this.domRecentlyMutated = false;
        /**
         * @TODO check if need to utilize targeting rules for forms/submits within closed
         * shadow roots as well, in order to detect cipher additions/updates
         */
        const pageDetails = this.getFormattedPageDetails({}, localFields);
        this.setupOverlayListeners(pageDetails);
        return pageDetails;
    }
    /**
     * Applies externally-provided targeting rules to this frame. Called when the
     * background dispatches `applyTargetedFields` after a parent frame's
     * targeting rule selector crossed into this iframe. Resolves each selector
     * locally if possible; if a routed selector itself crosses another iframe
     * (multi-hop chain), re-routes via the background to the next frame.
     * Re-sends collectPageDetailsResponse so the background updates its frame
     * records.
     *
     * @param targetedFields - Selector/fieldType pairs resolved to this frame
     */
    applyExternalTargetedFields(targetedFields) {
        return collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            const targets = targetedFields.map((t) => ({
                selectorAlternatives: [t.selector],
                fieldType: t.fieldType,
                formCategory: t.formCategory,
            }));
            const { localFields, iframeTargets } = this.resolveTargetedFields(targets);
            this.routeIframeTargets(iframeTargets);
            // Symmetric to getTargetedPageDetails: if we resolved no local fields but
            // already have cached fields from a prior applyExternalTargetedFields call,
            // re-broadcast those instead of clobbering with an empty payload.
            if (!localFields.length && this.autofillFieldElements.size > 0) {
                this.domRecentlyMutated = false;
                const cachedPageDetails = this.getFormattedPageDetails(this.getFormattedAutofillFormsData(), this.getFormattedAutofillFieldsData());
                void this.sendExtensionMessage("collectPageDetailsResponse", {
                    details: cachedPageDetails,
                    sender: "autofillInit",
                });
                return;
            }
            if (!localFields.length) {
                return;
            }
            this.domRecentlyMutated = false;
            const pageDetails = this.getFormattedPageDetails({}, localFields);
            this.setupOverlayListeners(pageDetails);
            void this.sendExtensionMessage("collectPageDetailsResponse", {
                details: pageDetails,
                sender: "autofillInit",
            });
        });
    }
    /**
     * Resolves a flat list of field targets against the current frame's DOM.
     * For each target, tries each selector alternative in order until one resolves
     * locally or crosses into an iframe. Iframe-crossing selectors are
     * accumulated into `iframeTargets` keyed by the iframe's URL so the caller
     * can route them onward via the background.
     *
     * Termination guarantee: when invoked recursively across frames, each hop
     * strips at least one `>>>` segment from the routed selector, so a selector
     * with N segments terminates after at most N-1 hops.
     */
    resolveTargetedFields(targets) {
        var _a, _b;
        const localFields = [];
        // Accumulates targets that live inside iframes, keyed by the iframe's URL.
        // These are routed to the iframe's own content script instead of being
        // collected here, so the existing sub-frame offset infrastructure handles
        // their positioning correctly.
        const iframeTargets = new Map();
        for (let targetIndex = 0; targetIndex < targets.length; targetIndex++) {
            const { selectorAlternatives, fieldType, formCategory } = targets[targetIndex];
            if (!(selectorAlternatives === null || selectorAlternatives === void 0 ? void 0 : selectorAlternatives.length)) {
                continue;
            }
            for (const selector of selectorAlternatives) {
                if (typeof selector !== "string") {
                    continue;
                }
                // Check whether this selector crosses an iframe boundary before
                // trying to resolve it locally.
                const iframeCrossing = this.domQueryService.findIframeCrossing(selector);
                if (iframeCrossing) {
                    const { iframeElement, innerSelector } = iframeCrossing;
                    const iframeSrc = ((_b = (_a = iframeElement.contentDocument) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.href) || iframeElement.src;
                    // Empty src (srcdoc, about:blank) is deferred — see routing/scope notes.
                    if (iframeSrc) {
                        if (!iframeTargets.has(iframeSrc)) {
                            iframeTargets.set(iframeSrc, []);
                        }
                        iframeTargets.get(iframeSrc).push({
                            selector: innerSelector,
                            fieldType,
                            formCategory,
                        });
                    }
                    break;
                }
                // No iframe boundary — resolve locally (direct element or shadow DOM).
                const matchedElement = this.domQueryService.queryDeepSelector(selector);
                if (matchedElement) {
                    const fieldId = `targeted_field_${targetIndex}_${fieldType}`;
                    const formFieldElement = matchedElement;
                    formFieldElement.opid = fieldId;
                    const autofillField = this.buildTargetedAutofillField(formFieldElement, fieldType, localFields.length, formCategory);
                    localFields.push(autofillField);
                    this.cacheAutofillFieldElement(localFields.length - 1, formFieldElement, autofillField);
                    break;
                }
            }
        }
        return { localFields, iframeTargets };
    }
    /**
     * Resets the cached targeting-rules. Invoked when the background signals
     * that the user disabled fill assist mid-session.
     */
    clearCachedTargetingRules() {
        this.pageTargetingRules = undefined;
    }
    /**
     * Fire-and-forget dispatch of accumulated iframe-crossing selectors to the
     * background, which routes each batch to the matching frame's content script.
     * The receiving frame's `applyExternalTargetedFields` will resolve locally
     * or re-route onward, enabling multi-hop chains.
     */
    routeIframeTargets(iframeTargets) {
        for (const [iframeSrc, iframeTargetedFields] of iframeTargets) {
            void this.sendExtensionMessage("routeTargetedFieldsToFrame", {
                iframeSrc,
                iframeTargetedFields,
            }).catch((error) => {
                // eslint-disable-next-line no-console
                console.warn(`[CollectAutofillContent] Failed to route targeted fields for iframe ${iframeSrc}:`, error);
            });
        }
    }
    /**
     * Builds a minimal AutofillField for a targeted element, setting the
     * fieldQualifier and targeted flag so the fill pipeline can identify it.
     */
    buildTargetedAutofillField(element, fieldType, index, formCategory) {
        var _a, _b;
        const field = new AutofillField();
        field.opid = element.opid;
        field.elementNumber = index;
        // Targeted fields are always treated as viewable regardless of actual
        // visibility. Targeting rules may deliberately select hidden fields
        // (e.g. tabbed forms, fields revealed by user interaction).
        field.viewable = true;
        field.htmlID = element.id || null;
        field.htmlName = element.name || null;
        field.htmlClass = element.className || null;
        field.tabindex = element.getAttribute("tabindex");
        field.title = element.getAttribute("title");
        field.tagName = (_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
        field.type = ((_b = element.type) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || undefined;
        field.fieldQualifier = fieldType;
        field.targeted = true;
        field.formCategory = formCategory;
        return field;
    }
    /**
     * Re-checks the visibility for all form fields and updates the
     * cached data to reflect the most recent visibility state.
     *
     * @private
     */
    updateCachedAutofillFieldVisibility() {
        this.autofillFieldElements.forEach((autofillField, element) => collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            const previouslyViewable = autofillField.viewable;
            autofillField.viewable = yield this.domElementVisibilityService.isElementViewable(element);
            if (!previouslyViewable && autofillField.viewable) {
                this.setupOverlayOnField(element, autofillField);
            }
        }));
    }
    /**
     * Queries the DOM for all the forms elements and
     * returns a collection of AutofillForm objects.
     * @returns {Record<string, AutofillForm>}
     * @private
     */
    buildAutofillFormsData(formElements) {
        var _a;
        for (let index = 0; index < formElements.length; index++) {
            const formElement = formElements[index];
            formElement.opid = `__form__${index}`;
            const existingAutofillForm = this._autofillFormElements.get(formElement);
            if (existingAutofillForm) {
                existingAutofillForm.opid = formElement.opid;
                this._autofillFormElements.set(formElement, existingAutofillForm);
                continue;
            }
            this._autofillFormElements.set(formElement, {
                opid: formElement.opid,
                htmlAction: this.getFormActionAttribute(formElement),
                htmlName: this.getPropertyOrAttribute(formElement, AUTOFILL_ATTRIBUTES.NAME),
                htmlClass: (_a = this.getPropertyOrAttribute(formElement, "class")) !== null && _a !== void 0 ? _a : "",
                htmlID: this.getPropertyOrAttribute(formElement, AUTOFILL_ATTRIBUTES.ID),
                htmlMethod: this.getPropertyOrAttribute(formElement, AUTOFILL_ATTRIBUTES.METHOD),
                htmlAncestorHeadings: this.getAncestorHeadings(formElement),
            });
        }
        return this.getFormattedAutofillFormsData();
    }
    /**
     * Headings inside the form's nearest section/article/main/aside/form ancestor,
     * ordered by depth of common ancestor (closest first). Sibling-form headings skipped.
     */
    getAncestorHeadings(formElement) {
        var _a;
        const scope = (_a = formElement.parentElement) === null || _a === void 0 ? void 0 : _a.closest("section, article, main, aside");
        if (!scope) {
            return [];
        }
        const ancestorDepths = new Map();
        let cursor = formElement;
        let depth = 0;
        while (cursor) {
            ancestorDepths.set(cursor, depth++);
            if (cursor === scope) {
                break;
            }
            cursor = cursor.parentElement;
        }
        return Array.from(scope.querySelectorAll("h1, h2, h3, h4, h5, h6"))
            .flatMap((heading) => {
            const f = heading.closest("form");
            if (f !== null && f !== formElement) {
                return [];
            }
            const text = this.getTextContentFromElement(heading);
            if (!text) {
                return [];
            }
            // Every retained heading lives under `scope`, and `scope` is in `ancestorDepths`,
            // so the walk always terminates at a known ancestor.
            let ancestor = heading;
            while (!ancestorDepths.has(ancestor)) {
                ancestor = ancestor.parentElement;
            }
            return [{ text, distance: ancestorDepths.get(ancestor) }];
        })
            .sort((a, b) => a.distance - b.distance)
            .map((entry) => entry.text);
    }
    /**
     * Returns the action attribute of the form element. If the action attribute
     * is a relative path, it will be converted to an absolute path.
     * @param {ElementWithOpId<HTMLFormElement>} element
     * @returns {string | null}
     * @private
     */
    getFormActionAttribute(element) {
        const action = this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.ACTION);
        if (action === null) {
            return null;
        }
        return new URL(action, globalThis.location.href).href;
    }
    /**
     * Iterates over all known form elements and returns an AutofillForm object
     * containing a key value pair of the form element's opid and the form data.
     * @returns {Record<string, AutofillForm>}
     * @private
     */
    getFormattedAutofillFormsData() {
        const autofillForms = {};
        const autofillFormElements = Array.from(this._autofillFormElements);
        for (let index = 0; index < autofillFormElements.length; index++) {
            const [formElement, autofillForm] = autofillFormElements[index];
            autofillForms[formElement.opid] = autofillForm;
        }
        return autofillForms;
    }
    /**
     * Queries the DOM for all the field elements and
     * returns a list of AutofillField objects.
     * @returns {Promise<AutofillField[]>}
     * @private
     */
    buildAutofillFieldsData(formFieldElements) {
        return collect_autofill_content_service_awaiter(this, void 0, void 0, function* () {
            // Maximum number of form fields to process for autofill to prevent performance issues on pages with excessive fields
            const autofillFieldsLimit = 200;
            const autofillFieldElements = this.getAutofillFieldElements(autofillFieldsLimit, formFieldElements);
            const autofillFieldDataPromises = autofillFieldElements.map((element, i) => this.buildAutofillFieldItem(element, i));
            const candidates = yield Promise.all(autofillFieldDataPromises);
            const autofillFields = candidates.filter((field) => field !== null);
            return autofillFields;
        });
    }
    /**
     * Queries the DOM for all the field elements that can be autofilled,
     * and returns a list limited to the given `fieldsLimit` number that
     * is ordered by priority.
     * @param {number} fieldsLimit - The maximum number of fields to return
     * @param {FormFieldElement[]} previouslyFoundFormFieldElements - The list of all the field elements
     * @returns {FormFieldElement[]}
     * @private
     */
    getAutofillFieldElements(fieldsLimit, previouslyFoundFormFieldElements) {
        var _a;
        let formFieldElements = previouslyFoundFormFieldElements;
        if (!formFieldElements) {
            formFieldElements = this.domQueryService.query(globalThis.document.documentElement, this.formFieldQueryString, (node) => this.isNodeFormFieldElement(node), this.mutationObserver);
        }
        if (!fieldsLimit || formFieldElements.length <= fieldsLimit) {
            return formFieldElements;
        }
        const priorityFormFields = [];
        const unimportantFormFields = [];
        const unimportantFieldTypesSet = new Set(["checkbox", "radio"]);
        for (const element of formFieldElements) {
            if (priorityFormFields.length >= fieldsLimit) {
                return priorityFormFields;
            }
            const fieldType = (_a = this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.TYPE)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
            if (fieldType !== undefined && unimportantFieldTypesSet.has(fieldType)) {
                unimportantFormFields.push(element);
                continue;
            }
            priorityFormFields.push(element);
        }
        const numberUnimportantFieldsToInclude = fieldsLimit - priorityFormFields.length;
        for (let index = 0; index < numberUnimportantFieldsToInclude; index++) {
            priorityFormFields.push(unimportantFormFields[index]);
        }
        return priorityFormFields;
    }
    /**
     * Caches the autofill field element and its data.
     *
     * @param index - The index of the autofill field element
     * @param element - The autofill field element to cache
     * @param autofillFieldData - The autofill field data to cache
     */
    cacheAutofillFieldElement(index, element, autofillFieldData) {
        const opid = autofillFieldData.opid;
        // Remove old element with same opid if it exists
        const oldElement = this.autofillFieldsByOpid.get(opid);
        if (oldElement && oldElement !== element) {
            this.autofillFieldElements.delete(oldElement);
        }
        // Always cache the element, even if index is -1 (for dynamically added fields)
        this.autofillFieldElements.set(element, autofillFieldData);
        this.autofillFieldsByOpid.set(opid, element);
    }
    /**
     * Identifies the autocomplete attribute associated with an element and returns
     * the value of the attribute if it is not set to "off".
     * @param {ElementWithOpId<FormFieldElement>} element
     * @returns {string | null}
     * @private
     */
    getAutoCompleteAttribute(element) {
        return (this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.AUTOCOMPLETE) ||
            this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.X_AUTOCOMPLETE_TYPE) ||
            this.getPropertyOrAttribute(element, AUTOFILL_ATTRIBUTES.AUTOCOMPLETE_TYPE));
    }
    /**
     * Returns the attribute of an element as a lowercase value.
     * @param {ElementWithOpId<FormFieldElement>} element
     * @param {string} attributeName
     * @returns {string | undefined}
     * @private
     */
    getAttributeLowerCase(element, attributeName) {
        var _a;
        return (_a = this.getPropertyOrAttribute(element, attributeName)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
    }
    /**
     * Returns the value of an element's property or attribute.
     * @returns {AutofillField[]}
     * @private
     */
    getFormattedAutofillFieldsData() {
        return Array.from(this.autofillFieldElements.values());
    }
    /**
     * Creates a label tag used to autofill the element pulled from a label
     * associated with the element's id, name, parent element or from an
     * associated description term element if no other labels can be found.
     * Returns a string containing all the `textContent` or `innerText`
     * values of the label elements.
     * @param {FillableFormFieldElement} element
     * @returns {string}
     * @private
     */
    createAutofillFieldLabelTag(element) {
        var _a, _b;
        const labelElementsSet = new Set(element.labels);
        if (labelElementsSet.size) {
            return this.createLabelElementsTag(labelElementsSet);
        }
        const labelElements = this.queryElementLabels(element);
        if (labelElements === null || labelElements === void 0 ? void 0 : labelElements.length) {
            for (const label of labelElements) {
                labelElementsSet.add(label);
            }
        }
        let currentElement = element;
        while (currentElement !== null && currentElement !== document.documentElement) {
            if (elementIsLabelElement(currentElement)) {
                labelElementsSet.add(currentElement);
            }
            currentElement = (_b = (_a = currentElement.parentElement) === null || _a === void 0 ? void 0 : _a.closest("label")) !== null && _b !== void 0 ? _b : null;
        }
        const parentElement = element.parentElement;
        if (!labelElementsSet.size &&
            parentElement !== null &&
            elementIsDescriptionDetailsElement(parentElement)) {
            const prevSibling = parentElement.previousElementSibling;
            if (prevSibling instanceof HTMLElement && elementIsDescriptionTermElement(prevSibling)) {
                labelElementsSet.add(prevSibling);
            }
        }
        return this.createLabelElementsTag(labelElementsSet);
    }
    /**
     * Queries the DOM for label elements associated with the given element
     * by id or name. Returns a NodeList of label elements or null if none
     * are found.
     * @param {FillableFormFieldElement} element
     * @returns {NodeListOf<HTMLLabelElement> | null}
     * @private
     */
    queryElementLabels(element) {
        let labelQuerySelectors = element.id ? `label[for="${element.id}"]` : "";
        if (element.name) {
            const forElementNameSelector = `label[for="${element.name}"]`;
            labelQuerySelectors = labelQuerySelectors
                ? `${labelQuerySelectors}, ${forElementNameSelector}`
                : forElementNameSelector;
        }
        if (!labelQuerySelectors) {
            return null;
        }
        return element.getRootNode().querySelectorAll(labelQuerySelectors.replace(/\n/g, ""));
    }
    /**
     * Gets the maxLength property of the passed FormFieldElement and
     * returns the value or null if the element does not have a
     * maxLength property. If the element has a maxLength property
     * greater than 999, it will return 999.
     * @param {FormFieldElement} element
     * @returns {number | null}
     * @private
     */
    getAutofillFieldMaxLength(element) {
        const elementHasMaxLengthProperty = elementIsInputElement(element) || elementIsTextAreaElement(element);
        const elementMaxLength = elementHasMaxLengthProperty && element.maxLength > -1 ? element.maxLength : 999;
        return elementHasMaxLengthProperty ? Math.min(elementMaxLength, 999) : null;
    }
    /**
     * Iterates over the next siblings of the passed element and
     * returns a string of the text content of each element. Will
     * stop iterating if it encounters a new section element.
     * @param {FormFieldElement} element
     * @returns {string}
     * @private
     */
    createAutofillFieldRightLabel(element) {
        const labelTextContent = [];
        let currentElement = element;
        while (currentElement && currentElement.nextSibling) {
            currentElement = currentElement.nextSibling;
            if (this.isNewSectionElement(currentElement)) {
                break;
            }
            if (this.containsChildField(currentElement)) {
                break;
            }
            const textContent = this.getTextContentFromElement(currentElement);
            if (textContent) {
                labelTextContent.push(textContent);
            }
        }
        return labelTextContent.join("");
    }
    /**
     * Recursively gets the text content from an element's previous siblings
     * and returns a string of the text content of each element.
     * @param {FormFieldElement} element
     * @returns {string}
     * @private
     */
    createAutofillFieldLeftLabel(element) {
        const labelTextContent = this.recursivelyGetTextFromPreviousSiblings(element);
        return labelTextContent.reverse().join("");
    }
    /**
     * Assumes that the input elements that are to be autofilled are within a
     * table structure. Queries the previous sibling of the parent row that
     * the input element is in and returns the text content of the cell that
     * is in the same column as the input element.
     * @param {FormFieldElement} element
     * @returns {string | null}
     * @private
     */
    createAutofillFieldTopLabel(element) {
        var _a, _b;
        const tableDataElement = element.closest("td");
        if (!tableDataElement) {
            return null;
        }
        const tableDataElementIndex = tableDataElement.cellIndex;
        if (tableDataElementIndex < 0) {
            return null;
        }
        const parentSiblingTableRowElement = (_a = tableDataElement.closest("tr")) === null || _a === void 0 ? void 0 : _a.previousElementSibling;
        return ((_b = parentSiblingTableRowElement === null || parentSiblingTableRowElement === void 0 ? void 0 : parentSiblingTableRowElement.cells) === null || _b === void 0 ? void 0 : _b.length) > tableDataElementIndex
            ? this.getTextContentFromElement(parentSiblingTableRowElement.cells[tableDataElementIndex])
            : null;
    }
    /**
     * Checks whether any of an element's descendants are form fields.
     */
    containsChildField(element) {
        if (nodeIsElement(element)) {
            const fields = AutoFillConstants.FieldElements.join(", ");
            return !!element.querySelector(fields);
        }
        else {
            return false;
        }
    }
    /**
     * Check if the element's tag indicates that a transition to a new section of the
     * page is occurring. If so, we should not use the element or its children in order
     * to get autofill context for the previous element.
     * @param {HTMLElement} currentElement
     * @returns {boolean}
     * @private
     */
    isNewSectionElement(currentElement) {
        if (!currentElement) {
            return true;
        }
        const transitionalElementTagsSet = new Set([
            "html",
            "body",
            "button",
            "form",
            "head",
            "iframe",
            "input",
            "option",
            "script",
            "select",
            "table",
            "textarea",
        ]);
        return ("tagName" in currentElement &&
            transitionalElementTagsSet.has(currentElement.tagName.toLowerCase()));
    }
    /**
     * Gets the text content from a passed element, regardless of whether it is a
     * text node, an element node or an HTMLElement.
     * @param {Node | HTMLElement} element
     * @returns {string}
     * @private
     */
    getTextContentFromElement(element) {
        if (element.nodeType === Node.TEXT_NODE) {
            const nodeValue = element.nodeValue;
            if (nodeValue === null) {
                return null;
            }
            return this.trimAndRemoveNonPrintableText(nodeValue);
        }
        const textContentOrInnerText = element.textContent || element.innerText;
        if (textContentOrInnerText === null) {
            return null;
        }
        return this.trimAndRemoveNonPrintableText(textContentOrInnerText);
    }
    /**
     * Removes non-printable characters from the passed text
     * content and trims leading and trailing whitespace.
     * @param {string} textContent
     * @returns {string}
     * @private
     */
    trimAndRemoveNonPrintableText(textContent) {
        return (textContent || "")
            .replace(/\p{C}+|\s+/gu, " ") // Strip out non-printable characters and replace multiple spaces with a single space
            .trim(); // Trim leading and trailing whitespace
    }
    /**
     * Get the text content from the previous siblings of the element. If
     * no text content is found, recursively get the text content from the
     * previous siblings of the parent element.
     * @param {FormFieldElement} element
     * @returns {string[]}
     * @private
     */
    recursivelyGetTextFromPreviousSiblings(element) {
        const textContentItems = [];
        let currentElement = element;
        while (currentElement !== null && currentElement.previousSibling !== null) {
            // Ensure we are capturing text content from nodes and elements.
            currentElement = currentElement.previousSibling;
            if (this.isNewSectionElement(currentElement)) {
                return textContentItems;
            }
            if (this.containsChildField(currentElement)) {
                return textContentItems;
            }
            const textContent = this.getTextContentFromElement(currentElement);
            if (textContent) {
                textContentItems.push(textContent);
            }
        }
        if (currentElement === null || textContentItems.length > 0) {
            return textContentItems;
        }
        // Prioritize capturing text content from elements rather than nodes.
        const parent = currentElement.parentElement !== null
            ? currentElement.parentElement
            : currentElement.parentNode;
        if (parent === null) {
            return textContentItems;
        }
        currentElement = parent;
        let siblingElement = nodeIsElement(currentElement)
            ? currentElement.previousElementSibling
            : currentElement.previousSibling;
        while (siblingElement !== null &&
            siblingElement.lastChild !== null &&
            !this.isNewSectionElement(siblingElement) &&
            !this.containsChildField(siblingElement)) {
            siblingElement = siblingElement.lastChild;
        }
        if (siblingElement === null ||
            this.isNewSectionElement(siblingElement) ||
            this.containsChildField(siblingElement)) {
            return textContentItems;
        }
        const siblingTextContent = this.getTextContentFromElement(siblingElement);
        if (siblingTextContent) {
            textContentItems.push(siblingTextContent);
            return textContentItems;
        }
        return this.recursivelyGetTextFromPreviousSiblings(siblingElement);
    }
    /**
     * Gets the value of the element. If the element is a checkbox, returns a checkmark if the
     * checkbox is checked, or an empty string if it is not checked. If the element is a hidden
     * input, returns the value of the input if it is less than 254 characters, or a truncated
     * value if it is longer than 254 characters.
     * @param {FormFieldElement} element
     * @returns {string}
     * @private
     */
    getElementValue(element) {
        if (!elementIsFillableFormField(element)) {
            const spanTextContent = element.textContent || element.innerText;
            return spanTextContent || "";
        }
        const elementValue = element.value || "";
        const elementType = String(element.type).toLowerCase();
        if ("checked" in element && elementType === "checkbox") {
            return element.checked ? "✓" : "";
        }
        if (elementType === "hidden") {
            const inputValueMaxLength = 254;
            return elementValue.length > inputValueMaxLength
                ? `${elementValue.substring(0, inputValueMaxLength)}...SNIPPED`
                : elementValue;
        }
        return elementValue;
    }
    /**
     * Captures the `data-*` attribute metadata to help with validating the autofill data.
     *
     * @param element - The form field element to capture the `data-*` attribute metadata from
     */
    getDataSetValues(element) {
        let datasetValues = "";
        const dataset = element.dataset;
        for (const key in dataset) {
            datasetValues += `${key}: ${dataset[key]}, `;
        }
        return datasetValues;
    }
    /**
     * Get the options from a select element and return them as an array
     * of arrays indicating the select element option text and value.
     * @param {HTMLSelectElement} element
     * @returns {{options: (string | null)[][]}}
     * @private
     */
    getSelectElementOptions(element) {
        const options = Array.from(element.options).map((option) => {
            const optionText = option.text
                ? String(option.text)
                    .toLowerCase()
                    .replace(/[\s~`!@$%^&#*()\-_+=:;'"[\]|\\,<.>?]/gm, "") // Remove whitespace and punctuation
                : null;
            return [optionText, option.value];
        });
        return { options };
    }
    /**
     * Queries all potential form and field elements from the DOM and returns
     * a collection of form and field elements. Leverages the TreeWalker API
     * to deep query Shadow DOM elements.
     */
    queryAutofillFormAndFieldElements() {
        const formElements = [];
        const formFieldElements = [];
        const queriedElements = this.domQueryService.query(globalThis.document.documentElement, `form, ${this.formFieldQueryString}`, (node) => {
            if (nodeIsFormElement(node)) {
                formElements.push(node);
                return true;
            }
            if (this.isNodeFormFieldElement(node)) {
                formFieldElements.push(node);
                return true;
            }
            return false;
        }, this.mutationObserver);
        if (formElements.length || formFieldElements.length) {
            return { formElements, formFieldElements };
        }
        for (let index = 0; index < queriedElements.length; index++) {
            const element = queriedElements[index];
            if (elementIsFormElement(element)) {
                formElements.push(element);
                continue;
            }
            if (this.isNodeFormFieldElement(element)) {
                formFieldElements.push(element);
            }
        }
        return { formElements, formFieldElements };
    }
    /**
     * Checks if the passed node is a form field element.
     * @param {Node} node
     * @returns {boolean}
     * @private
     */
    isNodeFormFieldElement(node) {
        if (!nodeIsElement(node)) {
            return false;
        }
        const nodeTagName = node.tagName.toLowerCase();
        const nodeIsSpanElementWithAutofillAttribute = nodeTagName === "span" && node.hasAttribute("data-bwautofill");
        if (nodeIsSpanElementWithAutofillAttribute) {
            return true;
        }
        const nodeHasBwIgnoreAttribute = node.hasAttribute("data-bwignore");
        const nodeIsValidInputElement = nodeTagName === "input" && !this.ignoredInputTypes.has(node.type);
        if (nodeIsValidInputElement && !nodeHasBwIgnoreAttribute) {
            return true;
        }
        return this.nonInputFormFieldTags.has(nodeTagName) && !nodeHasBwIgnoreAttribute;
    }
    get hasPendingWork() {
        return (this.pendingAttributeMutations.size > 0 ||
            this.pendingTopLayerTargets.size > 0 ||
            this.pendingChildListUpdate);
    }
    /**
     * Handles a mutation to the window location. Clears the autofill elements
     * and updates the autofill elements after a timeout.
     * @private
     */
    handleWindowLocationMutation() {
        this.currentLocationHref = globalThis.location.href;
        this.domRecentlyMutated = true;
        if (this.autofillOverlayContentService) {
            this.autofillOverlayContentService.pageDetailsUpdateRequired = true;
            this.autofillOverlayContentService.clearUserFilledFields();
            void this.sendExtensionMessage("closeAutofillInlineMenu", { forceCloseInlineMenu: true });
        }
        this.noFieldsFound = false;
        // Targeting rules are URL-scoped and gated by user/feature state at fetch
        // time; the new URL must re-fetch to pick up rule and gate changes.
        this.pageTargetingRules = undefined;
        this._autofillFormElements.clear();
        this.autofillFieldElements.clear();
        this.autofillFieldsByOpid.clear();
        // Reset shadow root tracking on navigation
        this.domQueryService.resetObservedShadowRoots();
        this.updateAutofillElementsAfterMutation();
    }
    applyAttributeMutation(target, attributeName) {
        if (!target.isConnected) {
            return;
        }
        const form = this._autofillFormElements.get(target);
        if (form) {
            this.updateAutofillFormElementData(attributeName, target, form);
            return;
        }
        const field = this.autofillFieldElements.get(target);
        if (field) {
            this.updateAutofillFieldElementData(attributeName, target, field);
        }
    }
    // One sweep per throttle window; -Infinity start lets the first call always run.
    purgeDetachedNodesIfDue() {
        const now = performance.now();
        if (now - this.lastDetachedPurgeAt < this.detachedPurgeThrottleMs) {
            return;
        }
        this.lastDetachedPurgeAt = now;
        this.purgeDetachedFieldMetadata();
        this.domQueryService.purgeDetachedShadowRoots();
    }
    purgeDetachedFieldMetadata() {
        for (const formElement of this._autofillFormElements.keys()) {
            if (!formElement.isConnected) {
                this._autofillFormElements.delete(formElement);
            }
        }
        for (const fieldElement of this.autofillFieldElements.keys()) {
            if (!fieldElement.isConnected) {
                this.autofillFieldElements.delete(fieldElement);
            }
        }
        for (const [opid, fieldElement] of this.autofillFieldsByOpid) {
            if (!fieldElement.isConnected) {
                this.autofillFieldsByOpid.delete(opid);
            }
        }
    }
    // Flag-only. Callers schedule explicitly so the rebuild funnel stays narrow.
    requirePageDetailsUpdate() {
        this.domRecentlyMutated = true;
        if (this.autofillOverlayContentService) {
            this.autofillOverlayContentService.pageDetailsUpdateRequired = true;
        }
        this.noFieldsFound = false;
    }
    // Edge case: a plain element added empty and given `attachShadow()` later
    // with no further child mutations is dropped here. Rare for autofill content;
    // the next mutation cycle catches it.
    collectAddedShadowRootCandidates(mutations) {
        var _a;
        if (this.pendingMutationAddedElementsOverflowed) {
            return;
        }
        for (const mutation of mutations) {
            for (const node of (_a = mutation.addedNodes) !== null && _a !== void 0 ? _a : []) {
                if (!this.isShadowRootCandidate(node)) {
                    continue;
                }
                this.pendingMutationAddedElements.add(node);
                if (this.pendingMutationAddedElements.size >= this.pendingMutationAddedElementsCap) {
                    this.pendingMutationAddedElementsOverflowed = true;
                    // Release element refs immediately; we won't process them this window.
                    this.pendingMutationAddedElements.clear();
                    return;
                }
            }
        }
    }
    mutationAddsOrRemovesFormField(mutation) {
        return (this.nodeListContainsFormField(mutation.addedNodes) ||
            this.nodeListContainsFormField(mutation.removedNodes));
    }
    nodeListContainsFormField(nodes) {
        if (!nodes) {
            return false;
        }
        for (const node of nodes) {
            if (!nodeIsElement(node)) {
                continue;
            }
            if (node.matches(this.formFieldQueryString) ||
                node.querySelector(this.formFieldQueryString) !== null) {
                return true;
            }
        }
        return false;
    }
    isShadowRootCandidate(node) {
        // FIXME (PM-39772): same-realm only — iframe-adopted (foreign-realm) hosts fall through here
        // and are detected only later, not on insert.
        if (!(node instanceof Element)) {
            return false;
        }
        if (node.shadowRoot) {
            return true;
        }
        // Custom element — `attachShadow` may run after observation.
        if (node.tagName.includes("-")) {
            return true;
        }
        return node.firstElementChild !== null;
    }
    /**
     * Updates the autofill elements after a DOM mutation has occurred.
     * Uses adaptive debouncing - extends timeout if DOM is "hot" (rapid mutations).
     * This prevents premature collection during loading spinners or SPA transitions.
     * @private
     */
    updateAutofillElementsAfterMutation() {
        if (this.updateAfterMutationIdleCallback !== null) {
            cancelIdleCallbackPolyfill(this.updateAfterMutationIdleCallback);
            this.updateAfterMutationIdleCallback = null;
        }
        const now = Date.now();
        const timeSinceLastMutation = now - this.lastMutationTimestamp;
        this.lastMutationTimestamp = now;
        // Check if mutations are occurring rapidly (DOM is still "hot")
        if (timeSinceLastMutation < this.mutationCooldownMs) {
            this.mutationBurstCount++;
        }
        else {
            this.mutationBurstCount = 0;
        }
        // Calculate adaptive timeout based on mutation frequency
        // If DOM is "hot" (mutations occurring rapidly), extend the wait time
        let adaptiveTimeout = this.updateAfterMutationTimeout;
        if (this.mutationBurstCount > 0) {
            // Extend timeout proportionally to mutation frequency, up to max wait time
            const extensionMs = Math.min(this.mutationBurstCount * this.mutationCooldownMs, this.maxMutationWaitMs - this.updateAfterMutationTimeout);
            adaptiveTimeout = this.updateAfterMutationTimeout + extensionMs;
        }
        this.updateAfterMutationIdleCallback = requestIdleCallbackPolyfill(this.getPageDetails.bind(this), { timeout: adaptiveTimeout });
    }
    /**
     * Updates the autofill form element data based on the passed attribute name.
     * @param {string} attributeName
     * @param {ElementWithOpId<HTMLFormElement>} element
     * @param {AutofillForm} dataTarget
     * @private
     */
    updateAutofillFormElementData(attributeName, element, dataTarget) {
        const updateAttribute = (dataTargetKey) => {
            this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
        };
        const updateActions = {
            action: () => {
                const actionUrl = this.getFormActionAttribute(element);
                if (actionUrl !== null) {
                    dataTarget.htmlAction = actionUrl;
                }
            },
            name: () => updateAttribute("htmlName"),
            id: () => updateAttribute("htmlID"),
            // Note: `class` is intentionally omitted — it is excluded from the
            // MutationObserver attributeFilter to avoid callback storms on dynamic pages.
            // htmlClass is refreshed on the next full page-detail collection.
            method: () => updateAttribute("htmlMethod"),
        };
        if (!updateActions[attributeName]) {
            return;
        }
        updateActions[attributeName]();
        if (this._autofillFormElements.has(element)) {
            this._autofillFormElements.set(element, dataTarget);
        }
    }
    /**
     * Updates the autofill field element data based on the passed attribute name.
     *
     * @param {string} attributeName
     * @param {ElementWithOpId<FormFieldElement>} element
     * @param {AutofillField} dataTarget
     */
    updateAutofillFieldElementData(attributeName, element, dataTarget) {
        const updateAttribute = (dataTargetKey) => {
            this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
        };
        const updateActions = {
            "aria-describedby": () => updateAttribute(AUTOFILL_ATTRIBUTES.ARIA_DESCRIBEDBY),
            "aria-label": () => updateAttribute("label-aria"),
            "aria-labelledby": () => updateAttribute(AUTOFILL_ATTRIBUTES.ARIA_LABELLEDBY),
            "aria-hidden": () => (dataTarget["aria-hidden"] = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_HIDDEN, true)),
            "aria-disabled": () => (dataTarget["aria-disabled"] = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_DISABLED, true)),
            "aria-haspopup": () => (dataTarget["aria-haspopup"] = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.ARIA_HASPOPUP, true)),
            autocomplete: () => (dataTarget.autoCompleteType = this.getAutoCompleteAttribute(element)),
            autocompletetype: () => (dataTarget.autoCompleteType = this.getAutoCompleteAttribute(element)),
            "x-autocompletetype": () => (dataTarget.autoCompleteType = this.getAutoCompleteAttribute(element)),
            class: () => updateAttribute("htmlClass"),
            checked: () => (dataTarget.checked = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.CHECKED)),
            "data-label": () => updateAttribute("label-data"),
            "data-stripe": () => updateAttribute(AUTOFILL_ATTRIBUTES.DATA_STRIPE),
            disabled: () => (dataTarget.disabled = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.DISABLED)),
            id: () => updateAttribute("htmlID"),
            maxlength: () => (dataTarget.maxLength = this.getAutofillFieldMaxLength(element)),
            name: () => updateAttribute("htmlName"),
            placeholder: () => updateAttribute(AUTOFILL_ATTRIBUTES.PLACEHOLDER),
            readonly: () => (dataTarget.readonly = this.getAttributeBoolean(element, AUTOFILL_ATTRIBUTES.READONLY)),
            rel: () => updateAttribute(AUTOFILL_ATTRIBUTES.REL),
            tabindex: () => updateAttribute(AUTOFILL_ATTRIBUTES.TABINDEX),
            title: () => updateAttribute(AUTOFILL_ATTRIBUTES.TITLE),
            type: () => (dataTarget.type = this.getAttributeLowerCase(element, AUTOFILL_ATTRIBUTES.TYPE)),
        };
        if (!updateActions[attributeName]) {
            return;
        }
        updateActions[attributeName]();
        if (this.autofillFieldElements.has(element)) {
            this.autofillFieldElements.set(element, dataTarget);
        }
    }
    /**
     * Gets the attribute value for the passed element, and returns it. If the dataTarget
     * and dataTargetKey are passed, it will set the value of the dataTarget[dataTargetKey].
     * @param UpdateAutofillDataAttributeParams
     * @returns {string}
     * @private
     */
    updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey, }) {
        const attributeValue = this.getPropertyOrAttribute(element, attributeName);
        if (dataTarget && dataTargetKey) {
            dataTarget[dataTargetKey] = attributeValue;
        }
        return attributeValue;
    }
    /**
     * Iterates over all cached field elements and sets up the inline menu listeners on each field.
     *
     * @param pageDetails - The page details to use for the inline menu listeners
     */
    setupOverlayListeners(pageDetails) {
        if (this.autofillOverlayContentService) {
            this.autofillFieldElements.forEach((autofillField, formFieldElement) => {
                this.setupOverlayOnField(formFieldElement, autofillField, pageDetails);
            });
        }
    }
    /**
     * Sets up the inline menu listener on the passed field element.
     * Debounced per-element to prevent excessive setup/teardown during rapid DOM changes.
     *
     * @param formFieldElement - The form field element to set up the inline menu listener on
     * @param autofillField - The metadata for the form field
     * @param pageDetails - The page details to use for the inline menu listeners
     */
    setupOverlayOnField(formFieldElement, autofillField, pageDetails) {
        if (!this.autofillOverlayContentService) {
            return;
        }
        // Check if there's already a pending debounce for this element
        const existingTimeout = this.pendingOverlaySetup.get(formFieldElement);
        const shouldExecuteImmediately = !existingTimeout;
        // Cancel any pending setup for this element
        if (existingTimeout) {
            globalThis.clearTimeout(existingTimeout);
        }
        // Execute immediately on first call (leading edge), then debounce subsequent calls
        if (shouldExecuteImmediately) {
            this.executeOverlaySetup(formFieldElement, autofillField, pageDetails);
        }
        // Set up debounce timeout that clears the tracking after the delay
        // This allows the next call after the delay to execute immediately again
        const timeoutId = globalThis.setTimeout(() => {
            this.pendingOverlaySetup.delete(formFieldElement);
        }, this.overlaySetupDelayMs);
        this.pendingOverlaySetup.set(formFieldElement, timeoutId);
    }
    /**
     * Executes the overlay setup for a form field element.
     *
     * @param formFieldElement - The form field element to set up the inline menu listener on
     * @param autofillField - The metadata for the form field
     * @param pageDetails - The page details to use for the inline menu listeners
     */
    executeOverlaySetup(formFieldElement, autofillField, pageDetails) {
        // Verify the field is still in the DOM and cached before setup
        if (!formFieldElement.isConnected ||
            !this.autofillFieldElements.has(formFieldElement) ||
            !this.autofillOverlayContentService) {
            return;
        }
        const autofillPageDetails = pageDetails ||
            this.getFormattedPageDetails(this.getFormattedAutofillFormsData(), this.getFormattedAutofillFieldsData());
        void this.autofillOverlayContentService.setupOverlayListeners(formFieldElement, autofillField, autofillPageDetails);
    }
    /**
     * Validates whether a password field is within the document.
     */
    isPasswordFieldWithinDocument() {
        var _a;
        return (((_a = this.domQueryService.query(globalThis.document.documentElement, `input[type="password"]`, (node) => nodeIsInputElement(node) && node.type === "password")) === null || _a === void 0 ? void 0 : _a.length) > 0);
    }
}

;// ./src/autofill/services/insert-autofill-content.service.ts
var insert_autofill_content_service_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};



class InsertAutofillContentService {
    /**
     * InsertAutofillContentService constructor. Instantiates the
     * DomElementVisibilityService and CollectAutofillContentService classes.
     */
    constructor(domElementVisibilityService, collectAutofillContentService) {
        this.domElementVisibilityService = domElementVisibilityService;
        this.collectAutofillContentService = collectAutofillContentService;
        this.autofillInsertActions = {
            fill_by_opid: ({ opid, value }) => this.handleFillFieldByOpidAction(opid, value),
            click_on_opid: ({ opid }) => this.handleClickOnFieldByOpidAction(opid),
            focus_by_opid: ({ opid }) => this.handleFocusOnFieldByOpidAction(opid),
        };
        this.showAnimations = true;
        /**
         * Runs the autofill action based on the action type and the opid.
         * Each action is subsequently delayed by 20 milliseconds.
         * @param {FillScript} [action, opid, value]
         * @returns {Promise<void>}
         * @private
         */
        this.runFillScriptAction = ([action, opid, value]) => {
            if (!opid || !this.autofillInsertActions[action]) {
                return Promise.resolve();
            }
            const delayActionsInMilliseconds = 20;
            return new Promise((resolve) => setTimeout(() => {
                if (action === FillScriptActionTypes.fill_by_opid && !!(value === null || value === void 0 ? void 0 : value.length)) {
                    this.autofillInsertActions.fill_by_opid({ opid, value });
                }
                else if (action === FillScriptActionTypes.click_on_opid) {
                    this.autofillInsertActions.click_on_opid({ opid });
                }
                else if (action === FillScriptActionTypes.focus_by_opid) {
                    this.autofillInsertActions.focus_by_opid({ opid });
                }
                resolve();
            }, delayActionsInMilliseconds));
        };
    }
    /**
     * Handles autofill of the forms on the current page based on the
     * data within the passed fill script object.
     * @param {AutofillScript} fillScript
     * @param {boolean} showAnimations
     * @returns {Promise<void>}
     * @public
     */
    fillForm(fillScript_1) {
        return insert_autofill_content_service_awaiter(this, arguments, void 0, function* (fillScript, showAnimations = true) {
            var _a;
            this.showAnimations = showAnimations;
            if (!((_a = fillScript.script) === null || _a === void 0 ? void 0 : _a.length) ||
                currentlyInSandboxedIframe() ||
                this.userCancelledInsecureUrlAutofill(fillScript.savedUrls) ||
                this.userCancelledUntrustedIframeAutofill(fillScript)) {
                return;
            }
            for (let index = 0; index < fillScript.script.length; index++) {
                yield this.runFillScriptAction(fillScript.script[index]);
            }
        });
    }
    /**
     * Checks if the autofill is occurring on a page that can be considered secure. If the page is not secure,
     * the user is prompted to confirm that they want to autofill on the page.
     * @param {string[] | null} savedUrls
     * @returns {boolean}
     * @private
     */
    userCancelledInsecureUrlAutofill(savedUrls) {
        if (!(savedUrls === null || savedUrls === void 0 ? void 0 : savedUrls.some((url) => url.startsWith(`https://${globalThis.location.hostname}`))) ||
            globalThis.location.protocol !== "http:" ||
            !this.isPasswordFieldWithinDocument()) {
            return false;
        }
        const confirmationWarning = [
            chrome.i18n.getMessage("insecurePageWarning"),
            chrome.i18n.getMessage("insecurePageWarningFillPrompt", [globalThis.location.hostname]),
        ].join("\n\n");
        return !globalThis.confirm(confirmationWarning);
    }
    /**
     * Checks if there is a password field within the current document. Includes
     * password fields that are present within the shadow DOM.
     * @returns {boolean}
     * @private
     */
    isPasswordFieldWithinDocument() {
        return this.collectAutofillContentService.isPasswordFieldWithinDocument();
    }
    /**
     * Checking if the autofill is occurring within an untrusted iframe. If the page is within an untrusted iframe,
     * the user is prompted to confirm that they want to autofill on the page. If the user cancels the autofill,
     * the script will not continue.
     *
     * Note: confirm() is blocked by sandboxed iframes, but we don't want to fill sandboxed iframes anyway.
     * If this occurs, confirm() returns false without displaying the dialog box, and autofill will be aborted.
     * The browser may print a message to the console, but this is not a standard error that we can handle.
     * @param {AutofillScript} fillScript
     * @returns {boolean}
     * @private
     */
    userCancelledUntrustedIframeAutofill(fillScript) {
        if (!fillScript.untrustedIframe) {
            return false;
        }
        const confirmationWarning = [
            chrome.i18n.getMessage("autofillIframeWarning"),
            chrome.i18n.getMessage("autofillIframeWarningTip", [globalThis.location.hostname]),
        ].join("\n\n");
        return !globalThis.confirm(confirmationWarning);
    }
    /**
     * Queries the DOM for an element by opid and inserts the passed value into the element.
     * @param {string} opid
     * @param {string} value
     * @private
     */
    handleFillFieldByOpidAction(opid, value) {
        const element = this.collectAutofillContentService.getAutofillFieldElementByOpid(opid);
        this.insertValueIntoField(element, value);
    }
    /**
     * Handles finding an element by opid and triggering a click event on the element.
     * @param {string} opid
     * @private
     */
    handleClickOnFieldByOpidAction(opid) {
        const element = this.collectAutofillContentService.getAutofillFieldElementByOpid(opid);
        if (element) {
            this.triggerClickOnElement(element);
        }
    }
    /**
     * Handles finding an element by opid and triggering click and focus events on the element.
     * To ensure that we trigger a blur event correctly on a filled field, we first check if the
     * element is already focused. If it is, we blur the element before focusing on it again.
     *
     * @param {string} opid - The opid of the element to focus on.
     */
    handleFocusOnFieldByOpidAction(opid) {
        const element = this.collectAutofillContentService.getAutofillFieldElementByOpid(opid);
        if (!element) {
            return;
        }
        if (document.activeElement === element) {
            element.blur();
        }
        this.simulateUserMouseClickAndFocusEventInteractions(element, true);
    }
    /**
     * Identifies the type of element passed and inserts the value into the element.
     * Will trigger simulated events on the element to ensure that the element is
     * properly updated.
     * @param {FormFieldElement | null} element
     * @param {string} value
     * @private
     */
    insertValueIntoField(element, value) {
        if (!element || !value) {
            return;
        }
        const elementValue = (element === null || element === void 0 ? void 0 : element.value) || (element === null || element === void 0 ? void 0 : element.innerText) || "";
        const elementAlreadyHasTheValue = !!((elementValue === null || elementValue === void 0 ? void 0 : elementValue.length) && elementValue === value);
        if (elementAlreadyHasTheValue || isReadonlyOrDisabledFormFieldElement(element)) {
            return;
        }
        if (!elementIsFillableFormField(element)) {
            this.handleInsertValueAndTriggerSimulatedEvents(element, () => (element.innerText = value));
            return;
        }
        const isFillableCheckboxOrRadioElement = elementIsInputElement(element) &&
            new Set(["checkbox", "radio"]).has(element.type) &&
            new Set(["true", "y", "1", "yes", "✓"]).has(String(value).toLowerCase());
        if (isFillableCheckboxOrRadioElement) {
            this.handleInsertValueAndTriggerSimulatedEvents(element, () => (element.checked = true));
            return;
        }
        this.handleInsertValueAndTriggerSimulatedEvents(element, () => (element.value = value));
    }
    /**
     * Simulates pre- and post-insert events on the element meant to mimic user interactions
     * while inserting the autofill value into the element.
     * @param {FormFieldElement} element
     * @param {Function} valueChangeCallback
     * @private
     */
    handleInsertValueAndTriggerSimulatedEvents(element, valueChangeCallback) {
        this.triggerPreInsertEventsOnElement(element);
        valueChangeCallback();
        this.triggerPostInsertEventsOnElement(element);
        this.triggerFillAnimationOnElement(element);
    }
    /**
     * Simulates a mouse click event on the element, including focusing the event, and
     * the triggers a simulated keyboard event on the element. Will attempt to ensure
     * that the initial element value is not arbitrarily changed by the simulated events.
     * @param {FormFieldElement} element
     * @private
     */
    triggerPreInsertEventsOnElement(element) {
        const initialElementValue = "value" in element ? element.value : "";
        this.simulateUserMouseClickAndFocusEventInteractions(element);
        this.simulateUserKeyboardEventInteractions(element);
        if ("value" in element && initialElementValue !== element.value) {
            element.value = initialElementValue;
        }
    }
    /**
     * Simulates a keyboard event on the element before assigning the autofilled value to the element, and then
     * simulates an input change event on the element to trigger expected events after autofill occurs.
     * @param {FormFieldElement} element
     * @private
     */
    triggerPostInsertEventsOnElement(element) {
        const autofilledValue = "value" in element ? element.value : "";
        this.simulateUserKeyboardEventInteractions(element);
        if ("value" in element && autofilledValue !== element.value) {
            element.value = autofilledValue;
        }
        this.simulateInputElementChangedEvent(element);
    }
    /**
     * Identifies if a passed element can be animated and sets a class on the element
     * to trigger a CSS animation. The animation is removed after a short delay.
     * @param {FormFieldElement} element
     * @private
     */
    triggerFillAnimationOnElement(element) {
        if (!this.showAnimations) {
            return;
        }
        const skipAnimatingElement = elementIsFillableFormField(element) &&
            !new Set(["email", "text", "password", "number", "tel", "url"]).has(element === null || element === void 0 ? void 0 : element.type);
        if (this.domElementVisibilityService.isElementHiddenByCss(element) || skipAnimatingElement) {
            return;
        }
        element.classList.add("com-bitwarden-browser-animated-fill");
        setTimeout(() => element.classList.remove("com-bitwarden-browser-animated-fill"), 200);
    }
    /**
     * Simulates a click  event on the element.
     * @param {HTMLElement} element
     * @private
     */
    triggerClickOnElement(element) {
        if (!element || typeof element.click !== TYPE_CHECK.FUNCTION) {
            return;
        }
        element.click();
    }
    /**
     * Simulates a focus event on the element. Will optionally reset the value of the element
     * if the element has a value property.
     * @param {HTMLElement | undefined} element
     * @param {boolean} shouldResetValue
     * @private
     */
    triggerFocusOnElement(element, shouldResetValue = false) {
        if (!element || typeof element.focus !== TYPE_CHECK.FUNCTION) {
            return;
        }
        let initialValue = "";
        if (shouldResetValue && "value" in element) {
            initialValue = String(element.value);
        }
        element.focus();
        if (initialValue && "value" in element) {
            element.value = initialValue;
        }
    }
    /**
     * Simulates a mouse click and focus event on the element.
     * @param {FormFieldElement} element
     * @param {boolean} shouldResetValue
     * @private
     */
    simulateUserMouseClickAndFocusEventInteractions(element, shouldResetValue = false) {
        this.triggerClickOnElement(element);
        this.triggerFocusOnElement(element, shouldResetValue);
    }
    /**
     * Simulates several keyboard events on the element, mocking a user interaction with the element.
     * @param {FormFieldElement} element
     * @private
     */
    simulateUserKeyboardEventInteractions(element) {
        const simulatedKeyboardEvents = [EVENTS.KEYDOWN, EVENTS.KEYUP];
        for (let index = 0; index < simulatedKeyboardEvents.length; index++) {
            element.dispatchEvent(new KeyboardEvent(simulatedKeyboardEvents[index], { bubbles: true }));
        }
    }
    /**
     * Simulates an input change event on the element, mocking behavior that would occur if a user
     * manually changed a value for the element.
     * @param {FormFieldElement} element
     * @private
     */
    simulateInputElementChangedEvent(element) {
        const simulatedInputEvents = [EVENTS.INPUT, EVENTS.CHANGE];
        for (let index = 0; index < simulatedInputEvents.length; index++) {
            element.dispatchEvent(new Event(simulatedInputEvents[index], { bubbles: true }));
        }
    }
}
/* harmony default export */ var insert_autofill_content_service = (InsertAutofillContentService);

;// ./src/autofill/content/autofill-init.ts
var autofill_init_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};





class AutofillInit {
    /**
     * AutofillInit constructor. Initializes the DomElementVisibilityService,
     * CollectAutofillContentService and InsertAutofillContentService classes.
     *
     * @param domQueryService - Service used to handle DOM queries.
     * @param domElementVisibilityService - Used to check if an element is viewable.
     * @param autofillOverlayContentService - The autofill overlay content service, potentially undefined.
     * @param autofillInlineMenuContentService - The inline menu content service, potentially undefined.
     * @param overlayNotificationsContentService - The overlay notifications content service, potentially undefined.
     */
    constructor(domQueryService, domElementVisibilityService, autofillOverlayContentService, autofillInlineMenuContentService, overlayNotificationsContentService) {
        this.autofillOverlayContentService = autofillOverlayContentService;
        this.autofillInlineMenuContentService = autofillInlineMenuContentService;
        this.overlayNotificationsContentService = overlayNotificationsContentService;
        this.sendExtensionMessage = sendExtensionMessage;
        this.lastContextMenuClickedElement = null;
        this.isMonitoring = false;
        this.extensionMessageHandlers = {
            collectPageDetails: ({ message }) => this.isMonitoring ? this.collectPageDetails(message) : undefined,
            collectPageDetailsImmediately: ({ message }) => this.isMonitoring ? this.collectPageDetails(message, true) : undefined,
            collectAutofillTriage: () => this.isMonitoring ? this.collectPageDetailsForContextMenu() : undefined,
            fillForm: ({ message }) => (this.isMonitoring ? this.fillForm(message) : undefined),
            applyTargetedFields: ({ message }) => this.isMonitoring ? this.applyTargetedFields(message) : undefined,
            clearTargetingRulesCache: () => this.handleClearTargetingRulesCache(),
            startAutofillMonitors: () => this.startMonitoring(),
            stopAutofillMonitors: () => this.stopMonitoring(),
        };
        /**
         * Sends a message to collect page details after a short delay.
         */
        this.sendCollectDetailsMessage = () => {
            this.clearCollectPageDetailsOnLoadTimeout();
            this.collectPageDetailsOnLoadTimeout = setTimeout(() => this.sendExtensionMessage("bgCollectPageDetails", { sender: "autofillInit" }), 750);
        };
        /**
         * Saves a local copy of the last element that was clicked to create the context menu.
         * @param event - The mouse click event.
         */
        this.handleContextMenuClick = (event) => {
            if (EventSecurity.isEventTrusted(event)) {
                this.lastContextMenuClickedElement = event.target;
            }
        };
        /**
         * Handles the extension messages sent to the content script.
         *
         * @param message - The extension message.
         * @param sender - The message sender.
         * @param sendResponse - The send response callback.
         */
        this.handleExtensionMessage = (message, sender, sendResponse) => {
            const command = message.command;
            const handler = this.getExtensionMessageHandler(command);
            if (!handler) {
                return null;
            }
            const messageResponse = handler({ message, sender });
            if (typeof messageResponse === "undefined") {
                return null;
            }
            void Promise.resolve(messageResponse).then((response) => sendResponse(response));
            return true;
        };
        this.collectAutofillContentService = new CollectAutofillContentService(domElementVisibilityService, domQueryService, this.autofillOverlayContentService);
        this.insertAutofillContentService = new insert_autofill_content_service(domElementVisibilityService, this.collectAutofillContentService);
    }
    /**
     * Initializes the autofill content script, setting up
     * the extension message listeners. This method should
     * be called once when the content script is loaded.
     */
    init() {
        this.setupExtensionMessageListeners();
    }
    /**
     * Attaches monitoring-scoped listeners (contextmenu, LOAD) and fans
     * out to each sub-monitor. Idempotent.
     */
    startMonitoring() {
        var _a, _b;
        if (this.isMonitoring) {
            return;
        }
        this.isMonitoring = true;
        // Start sub-monitors first so any page-details collection triggered
        // by this controller below sees a fully wired-up service graph.
        this.collectAutofillContentService.startMonitoring();
        (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.startMonitoring();
        (_b = this.autofillInlineMenuContentService) === null || _b === void 0 ? void 0 : _b.startMonitoring();
        this.collectPageDetailsOnLoad();
    }
    /**
     * Detaches monitoring-scoped listeners, cancels the LOAD timeout,
     * and fans out to each sub-monitor. Idempotent.
     */
    stopMonitoring() {
        var _a, _b;
        this.isMonitoring = false;
        this.clearCollectPageDetailsOnLoadTimeout();
        globalThis.removeEventListener(EVENTS.LOAD, this.sendCollectDetailsMessage);
        this.collectAutofillContentService.stopMonitoring();
        (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.stopMonitoring();
        (_b = this.autofillInlineMenuContentService) === null || _b === void 0 ? void 0 : _b.stopMonitoring();
    }
    /**
     * Triggers a collection of the page details from the
     * background script, ensuring that autofill is ready
     * to act on the page.
     */
    collectPageDetailsOnLoad() {
        if (globalThis.document.readyState === "complete") {
            this.sendCollectDetailsMessage();
        }
        globalThis.addEventListener(EVENTS.LOAD, this.sendCollectDetailsMessage);
    }
    /**
     * Collects the page details and sends them to the
     * extension background script. If the `sendDetailsInResponse`
     * parameter is set to true, the page details will be
     * returned to facilitate sending the details in the
     * response to the extension message.
     *
     * @param message - The extension message.
     * @param sendDetailsInResponse - Determines whether to send the details in the response.
     */
    collectPageDetails(message_1) {
        return autofill_init_awaiter(this, arguments, void 0, function* (message, sendDetailsInResponse = false) {
            const pageDetails = yield this.collectAutofillContentService.getPageDetails();
            if (sendDetailsInResponse) {
                return pageDetails;
            }
            void this.sendExtensionMessage("collectPageDetailsResponse", {
                tab: message.tab,
                details: pageDetails,
                sender: message.sender,
            });
        });
    }
    /**
     * Collects page details and returns them directly in the response for autofill triage.
     */
    collectPageDetailsForContextMenu() {
        return autofill_init_awaiter(this, void 0, void 0, function* () {
            var _a, _b;
            const pageDetails = yield this.collectAutofillContentService.getPageDetails();
            let targetFieldRef;
            const el = this.lastContextMenuClickedElement;
            if (el) {
                const htmlId = el.id;
                const htmlName = el instanceof HTMLInputElement ? el.name : undefined;
                const match = pageDetails.fields.find((f) => (htmlId && f.htmlID === htmlId) || (htmlName && f.htmlName === htmlName));
                targetFieldRef = (_b = (_a = match === null || match === void 0 ? void 0 : match.htmlID) !== null && _a !== void 0 ? _a : match === null || match === void 0 ? void 0 : match.htmlName) !== null && _b !== void 0 ? _b : undefined;
            }
            return { pageDetails, targetFieldRef };
        });
    }
    /**
     * Fills the form with the given fill script.
     *
     * @param {AutofillExtensionMessage} message
     */
    fillForm(_a) {
        return autofill_init_awaiter(this, arguments, void 0, function* ({ fillScript, pageDetailsUrl, showAnimations }) {
            if ((document.defaultView || window).location.href !== pageDetailsUrl || !fillScript) {
                return;
            }
            this.blurFocusedFieldAndCloseInlineMenu();
            yield this.sendExtensionMessage("updateIsFieldCurrentlyFilling", {
                isFieldCurrentlyFilling: true,
            });
            yield this.insertAutofillContentService.fillForm(fillScript, showAnimations !== null && showAnimations !== void 0 ? showAnimations : true);
            setTimeout(() => this.sendExtensionMessage("updateIsFieldCurrentlyFilling", {
                isFieldCurrentlyFilling: false,
            }), 250);
        });
    }
    /**
     * Applies targeted fields dispatched from the background for this frame.
     * Called when the top-level frame has detected that a targeting rule crosses
     * into this iframe and has routed the inner selectors here.
     *
     * @param message - The extension message containing iframe targeted fields.
     */
    applyTargetedFields(message) {
        var _a;
        return this.collectAutofillContentService.applyExternalTargetedFields((_a = message.iframeTargetedFields) !== null && _a !== void 0 ? _a : []);
    }
    /**
     * Drops cached targeting rules in this frame and re-collects page details so
     * the background's `pageDetailsForTab` is repopulated with the new strategy.
     */
    handleClearTargetingRulesCache() {
        this.collectAutofillContentService.clearCachedTargetingRules();
        void this.collectPageDetails({ command: "collectPageDetails", sender: "autofillInit" });
    }
    /**
     * Blurs the most recently focused field and removes the inline menu. Used
     * in cases where the background unlock or vault item reprompt popout
     * is opened.
     */
    blurFocusedFieldAndCloseInlineMenu() {
        var _a;
        (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.blurMostRecentlyFocusedField(true);
    }
    /**
     * Clears the send collect details message timeout.
     */
    clearCollectPageDetailsOnLoadTimeout() {
        if (this.collectPageDetailsOnLoadTimeout) {
            clearTimeout(this.collectPageDetailsOnLoadTimeout);
        }
    }
    /**
     * Sets up the extension message listeners for the content script.
     */
    setupExtensionMessageListeners() {
        chrome.runtime.onMessage.addListener(this.handleExtensionMessage);
        globalThis.document.addEventListener("contextmenu", this.handleContextMenuClick);
    }
    /**
     * Gets the extension message handler for the given command.
     *
     * @param command - The extension message command.
     */
    getExtensionMessageHandler(command) {
        var _a, _b, _c, _d, _e, _f;
        if ((_b = (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[command]) {
            return this.autofillOverlayContentService.messageHandlers[command];
        }
        if ((_d = (_c = this.autofillInlineMenuContentService) === null || _c === void 0 ? void 0 : _c.messageHandlers) === null || _d === void 0 ? void 0 : _d[command]) {
            return this.autofillInlineMenuContentService.messageHandlers[command];
        }
        if ((_f = (_e = this.overlayNotificationsContentService) === null || _e === void 0 ? void 0 : _e.messageHandlers) === null || _f === void 0 ? void 0 : _f[command]) {
            return this.overlayNotificationsContentService.messageHandlers[command];
        }
        return this.extensionMessageHandlers[command];
    }
    /**
     * Handles destroying the autofill init content script. Removes all
     * listeners, timeouts, and object instances to prevent memory leaks.
     */
    destroy() {
        var _a, _b, _c;
        this.stopMonitoring();
        globalThis.document.removeEventListener("contextmenu", this.handleContextMenuClick);
        chrome.runtime.onMessage.removeListener(this.handleExtensionMessage);
        this.lastContextMenuClickedElement = null;
        (_a = this.autofillOverlayContentService) === null || _a === void 0 ? void 0 : _a.destroy();
        (_b = this.autofillInlineMenuContentService) === null || _b === void 0 ? void 0 : _b.destroy();
        (_c = this.overlayNotificationsContentService) === null || _c === void 0 ? void 0 : _c.destroy();
    }
}
/* harmony default export */ var autofill_init = (AutofillInit);

;// ./src/autofill/content/bootstrap-autofill-overlay.ts








(function (windowContext) {
    if (!windowContext.bitwardenAutofillInit) {
        let inlineMenuContentService;
        let overlayNotificationsContentService;
        if (globalThis.self === globalThis.top) {
            inlineMenuContentService = new AutofillInlineMenuContentService();
            overlayNotificationsContentService = new OverlayNotificationsContentService();
        }
        const domQueryService = new DomQueryService();
        const domElementVisibilityService = new dom_element_visibility_service(inlineMenuContentService);
        const inlineMenuFieldQualificationService = new InlineMenuFieldQualificationService();
        const autofillOverlayContentService = new AutofillOverlayContentService(domQueryService, domElementVisibilityService, inlineMenuFieldQualificationService, inlineMenuContentService);
        windowContext.bitwardenAutofillInit = new autofill_init(domQueryService, domElementVisibilityService, autofillOverlayContentService, inlineMenuContentService, overlayNotificationsContentService);
        setupAutofillInitDisconnectAction(windowContext);
        windowContext.bitwardenAutofillInit.init();
    }
})(window);

}();
/******/ })()
;