export const encodeOptions = (data, prefix) => {
    return `${prefix}<${btoa(JSON.stringify(data))}>`;
};
export const decodeOptions = (data, prefix) => {
    const meta = new RegExp(`^${prefix}\<(?<meta>.*)\>$`).exec(data)?.groups?.meta;
    if (meta) {
        try {
            return JSON.parse(atob(meta));
        }
        catch (error) {
            throw new Error(`Failed to decode JSON from ${meta}.`);
        }
    }
};
