buildString('a', 'b', 'c', 'd') -> 'abcd'\n * buildString(null, undefined) -> ''\n *\n * @param {...*} var_args A list of strings to concatenate. If not a string,\n * it will be casted to one.\n * @return {string} The concatenation of {@code var_args}.\n */\n/* eslint-disable no-unused-vars */\ngoog.string.buildString = function(var_args) {\n return Array.prototype.join.call(arguments, '');\n};\n/* eslint-enable no-unused-vars */\n\n/**\n * Returns a string with at least 64-bits of randomness.\n *\n * Doesn't trust Javascript's random function entirely. Uses a combination of\n * random and current timestamp, and then encodes the string in base-36 to\n * make it shorter.\n *\n * @return {string} A random string, e.g. sn1s7vb4gcic.\n */\ngoog.string.getRandomString = function() {\n const x = 2147483648;\n return Math.floor(Math.random() * x).toString(36) +\n Math.abs(Math.floor(Math.random() * x) ^ goog.now()).toString(36);\n};\n\n\n/**\n * Compares two version numbers.\n *\n * @param {string|number} version1 Version of first item.\n * @param {string|number} version2 Version of second item.\n *\n * @return {number} 1 if {@code version1} is higher.\n * 0 if arguments are equal.\n * -1 if {@code version2} is higher.\n */\ngoog.string.compareVersions = function(version1, version2) {\n let order = 0;\n /*\n * Trim leading and trailing whitespace and split the versions into\n * subversions.\n */\n const v1Subs = goog.string.trim(String(version1)).split('.');\n const v2Subs = goog.string.trim(String(version2)).split('.');\n const subCount = Math.max(v1Subs.length, v2Subs.length);\n\n // Iterate over the subversions, as long as they appear to be equivalent.\n for (let subIdx = 0; order == 0 && subIdx < subCount; subIdx++) {\n const v1Sub = v1Subs[subIdx] || '';\n const v2Sub = v2Subs[subIdx] || '';\n\n /*\n * Split the subversions into pairs of numbers and qualifiers (like 'b').\n * Two different RegExp objects are needed because they are both using\n * the 'g' flag.\n */\n const v1CompParser = new RegExp('(\\\\d*)(\\\\D*)', 'g');\n const v2CompParser = new RegExp('(\\\\d*)(\\\\D*)', 'g');\n do {\n const v1Comp = v1CompParser.exec(v1Sub) || ['', '', ''];\n const v2Comp = v2CompParser.exec(v2Sub) || ['', '', ''];\n // Break if there are no more matches.\n if (v1Comp[0].length == 0 && v2Comp[0].length == 0) {\n break;\n }\n\n /*\n * Parse the numeric part of the subversion. A missing number is\n * equivalent to 0.\n */\n const v1CompNum = v1Comp[1].length == 0 ? 0 : parseInt(v1Comp[1], 10);\n const v2CompNum = v2Comp[1].length == 0 ? 0 : parseInt(v2Comp[1], 10);\n\n /*\n * Compare the subversion components. The number has the highest\n * precedence. Next, if the numbers are equal, a subversion without any\n * qualifier is always higher than a subversion with any qualifier. Next,\n * the qualifiers are compared as strings.\n */\n order = goog.string.compareElements_(v1CompNum, v2CompNum) ||\n goog.string.compareElements_(v1Comp[2].length == 0,\n v2Comp[2].length == 0) ||\n goog.string.compareElements_(v1Comp[2], v2Comp[2]);\n // Stop as soon as an inequality is discovered.\n } while (order == 0);\n }\n\n return order;\n};\n\n\n/**\n * Compares elements of a version number.\n *\n * @param {string|number|boolean} left An element from a version number.\n * @param {string|number|boolean} right An element from a version number.\n *\n * @return {number} 1 if {@code left} is higher.\n * 0 if arguments are equal.\n * -1 if {@code right} is higher.\n * @private\n */\ngoog.string.compareElements_ = function(left, right) {\n if (left < right) {\n return -1;\n } else if (left > right) {\n return 1;\n }\n return 0;\n};\n\n\n/**\n * Maximum value of #goog.string.hashCode, exclusive. 2^32.\n * @type {number}\n * @private\n */\ngoog.string.HASHCODE_MAX_ = 0x100000000;\n\n\n/**\n * String hash function similar to java.lang.String.hashCode().\n * The hash code for a string is computed as\n * s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],\n * where s[i] is the ith character of the string and n is the length of\n * the string. We mod the result to make it between 0 (inclusive) and 2^32\n * (exclusive).\n * @param {string} str A string.\n * @return {number} Hash value for {@code str}, between 0 (inclusive) and 2^32\n * (exclusive). The empty string returns 0.\n */\ngoog.string.hashCode = function(str) {\n let result = 0;\n for (let i = 0; i < str.length; ++i) {\n result = 31 * result + str.charCodeAt(i);\n // Normalize to 4 byte range, 0 ... 2^32.\n result %= goog.string.HASHCODE_MAX_;\n }\n return result;\n};\n\n\n/**\n * The most recent unique ID. |0 is equivalent to Math.floor in this case.\n * @type {number}\n * @private\n */\ngoog.string.uniqueStringCounter_ = Math.random() * 0x80000000 | 0;\n\n\n/**\n * Generates and returns a string which is unique in the current document.\n * This is useful, for example, to create unique IDs for DOM elements.\n * @return {string} A unique id.\n */\ngoog.string.createUniqueString = function() {\n return `goog_${goog.string.uniqueStringCounter_++}`;\n};\n\n\n/**\n * Converts the supplied string to a number, which may be Ininity or NaN.\n * This function strips whitespace: (toNumber(' 123') === 123)\n * This function accepts scientific notation: (toNumber('1e1') === 10)\n *\n * This is better than Javascript's built-in conversions because, sadly:\n * (Number(' ') === 0) and (parseFloat('123a') === 123)\n *\n * @param {string} str The string to convert.\n * @return {number} The number the supplied string represents, or NaN.\n */\ngoog.string.toNumber = function(str) {\n const num = Number(str);\n if (num == 0 && goog.string.isEmpty(str)) {\n return NaN;\n }\n return num;\n};\n\n\n/**\n * Converts a string from selector-case to camelCase (e.g. from\n * \"multi-part-string\" to \"multiPartString\"), useful for converting\n * CSS selectors and HTML dataset keys to their equivalent JS properties.\n * @param {string} str The string in selector-case form.\n * @return {string} The string in camelCase form.\n */\ngoog.string.toCamelCase = function(str) {\n return String(str).replace(/\\-([a-z])/g, (all, match) => match.toUpperCase());\n};\n\n\n/**\n * Converts a string from camelCase to selector-case (e.g. from\n * \"multiPartString\" to \"multi-part-string\"), useful for converting JS\n * style and dataset properties to equivalent CSS selectors and HTML keys.\n * @param {string} str The string in camelCase form.\n * @return {string} The string in selector-case form.\n */\ngoog.string.toSelectorCase = function(str) {\n return String(str).replace(/([A-Z])/g, '-$1').toLowerCase();\n};\n\n\n/**\n * Converts a string into TitleCase. First character of the string is always\n * capitalized in addition to the first letter of every subsequent word.\n * Words are delimited by one or more whitespaces by default. Custom delimiters\n * can optionally be specified to replace the default, which doesn't preserve\n * whitespace delimiters and instead must be explicitly included if needed.\n *\n * Default delimiter => \" \":\n * goog.string.toTitleCase('oneTwoThree') => 'OneTwoThree'\n * goog.string.toTitleCase('one two three') => 'One Two Three'\n * goog.string.toTitleCase(' one two ') => ' One Two '\n * goog.string.toTitleCase('one_two_three') => 'One_two_three'\n * goog.string.toTitleCase('one-two-three') => 'One-two-three'\n *\n * Custom delimiter => \"_-.\":\n * goog.string.toTitleCase('oneTwoThree', '_-.') => 'OneTwoThree'\n * goog.string.toTitleCase('one two three', '_-.') => 'One two three'\n * goog.string.toTitleCase(' one two ', '_-.') => ' one two '\n * goog.string.toTitleCase('one_two_three', '_-.') => 'One_Two_Three'\n * goog.string.toTitleCase('one-two-three', '_-.') => 'One-Two-Three'\n * goog.string.toTitleCase('one...two...three', '_-.') => 'One...Two...Three'\n * goog.string.toTitleCase('one. two. three', '_-.') => 'One. two. three'\n * goog.string.toTitleCase('one-two.three', '_-.') => 'One-Two.Three'\n *\n * @param {string} str String value in camelCase form.\n * @param {string=} opt_delimiters Custom delimiter character set used to\n * distinguish words in the string value. Each character represents a\n * single delimiter. When provided, default whitespace delimiter is\n * overridden and must be explicitly included if needed.\n * @return {string} String value in TitleCase form.\n */\ngoog.string.toTitleCase = function(str, opt_delimiters) {\n let delimiters = goog.isString(opt_delimiters) ?\n goog.string.regExpEscape(opt_delimiters) : '\\\\s';\n\n /*\n * For IE8, we need to prevent using an empty character set. Otherwise,\n * incorrect matching will occur.\n */\n delimiters = delimiters ? `|[${delimiters}]+` : '';\n\n const regexp = new RegExp(`(^${delimiters})([a-z])`, 'g');\n return str.replace(regexp, (all, p1, p2) => p1 + p2.toUpperCase());\n};\n\n\n/**\n * Parse a string in decimal or hexidecimal ('0xFFFF') form.\n *\n * To parse a particular radix, please use parseInt(string, radix) directly. See\n * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt\n *\n * This is a wrapper for the built-in parseInt function that will only parse\n * numbers as base 10 or base 16. Some JS implementations assume strings\n * starting with \"0\" are intended to be octal. ES3 allowed but discouraged\n * this behavior. ES5 forbids it. This function emulates the ES5 behavior.\n *\n * For more information, see Mozilla JS Reference: http://goo.gl/8RiFj\n *\n * @param {string|number|null|undefined} value The value to be parsed.\n * @return {number} The number, parsed. If the string failed to parse, this\n * will be NaN.\n */\ngoog.string.parseInt = function(value) {\n // Force finite numbers to strings.\n if (isFinite(value)) {\n value = String(value);\n }\n\n if (goog.isString(value)) {\n // If the string starts with '0x' or '-0x', parse as hex.\n return /^\\s*-?0x/i.test(value) ?\n parseInt(value, 16) : parseInt(value, 10);\n }\n\n return NaN;\n};\n\nexport default goog;\n","/**\n * Passbolt ~ Open source password manager for teams\n * Copyright (c) 2023 Passbolt SA (https://www.passbolt.com)\n *\n * Licensed under GNU Affero General Public License version 3 of the or any later version.\n * For full copyright and license information, please see the LICENSE.txt\n * Redistributions of files must retain the above copyright notice.\n *\n * @copyright Copyright (c) 2023 Passbolt SA (https://www.passbolt.com)\n * @license https://opensource.org/licenses/AGPL-3.0 AGPL License\n * @link https://www.passbolt.com Passbolt(tm)\n * @since 4.2.0\n */\nclass Lock {\n constructor() {\n this._locked = false;\n this._queue = [];\n }\n\n /**\n * Acquire lock\n * Push a new promise in a queue if the lock is locked\n * @return {Promise