Format a byte count as a short, human-readable size string using binary (1024-based) units. Used by the settings panel to show how much storage the caches and price history occupy.
Converts the first character of a string to uppercase.
MD5 hash function that handles various input types. Converts input to string representation before hashing.
Builds a URL-style query string from a plain object. Keys are emitted in insertion order. Array values are comma-joined.
Base64-encodes a UTF-8 string (raw bytes, not URI-encoded).
ASCII-only input uses btoa directly.
Opaque base-36 timestamp string (milliseconds + random suffix). Used by some suppliers for cache-busting request IDs.
Generates an array of page sizes based on the total number of rows. The array starts with the base size and doubles each time until it reaches the total.
Serializes a string to a base64 encoded string. Useful for safely storing strings that may contain special characters. First URI encodes the string, then base64 encodes it.
Deserializes a base64 encoded string back to its original form. Reverses the serialize() operation by first base64 decoding, then URI decoding the result.
Creates a promise that resolves after the specified delay. Useful for adding delays in async operations or rate limiting.
Delays the execution of an action by the specified number of milliseconds. Combines sleep() with a callback function for cleaner async code.
Takes a function and an array of values, applies the function to each value in sequence, and returns the first non-undefined/null result. Useful for trying multiple possible inputs until finding one that produces a valid result.
Maps an array of items using a function and filters out any null or undefined results.
Decodes HTML entities in a string.
Converts HTML to ASCII. Closing block-level tags (paragraphs, headings, list
items, table rows/cells, …) and <br> become line breaks; every other tag is
stripped and the common HTML entities are decoded. Runs of blank lines left by
empty or nested blocks are collapsed to a single line break.
Finds the href of the first PDF-linking anchor in a block of HTML. Useful for pulling out
linked documents such as Safety Data Sheets or spec sheets that suppliers attach as
<a href="….pdf"> inside descriptions or info sections.
Tries to parse a JSON string. If it fails, it returns the original string.
Extracts and parses the first top-level JSON array or object from a string that may contain trailing non-JSON content (e.g. delimiters like "&&&").
Gets the user's location (two-letter country code) from the browser's i18n API. This just splits the locale by the "-" character and returns the second part. This is a simple way to get the country code from the locale.
Gets the user's preferred UI language locale from the browser's i18n API.
Used to seed the language user setting. Falls back to "en-US" outside an
extension context (e.g. tests).
Resolves a locale code to a human-readable language name using the
countries-list language data. The native name is preferred (e.g. "Deutsch"),
falling back to the English name and finally the raw code.
Strips HTML tags from a string.
Converts HTML to Markdown using TurndownService.
Formats HTML into a readable plain text string, handling paragraphs, lists, and links.
Resolves a value out of a nested object/array using a key path.
Enriches a list of valibot issues (or any { path }-shaped records) with the
actual value found at each issue's path in the source object. Useful when
logging validation failures — stock issues only say "expected X at path Y",
and knowing what was there makes debugging drastically faster.
Preloads a list of images and returns a promise that resolves to an array of results.
Parse a raw string (typically an input's value) into a finite number,
returning undefined for empty or malformed input. Uses Number() rather
than parseFloat, which would silently accept trailing garbage and turn
"12abc" into 12. The empty check is explicit because Number("") and
Number(" ") are both 0, not NaN.
Format a Unix epoch timestamp (in milliseconds) as a short, locale-aware "month day, hour:minute" string for UI surfaces like the history and excluded-products lists in the settings drawer. Shared so both panels render the same shape without drifting over time.