function hashSerializedState(state) {
    const str = 'string' == typeof state ? state : stableJsonStringify(state);
    let hash = 2166136261;
    for(let i = 0; i < str.length; i++){
        hash ^= str.charCodeAt(i);
        hash = Math.imul(hash, 16777619);
    }
    return (hash >>> 0).toString(16);
}
function stableJsonStringify(value) {
    return JSON.stringify(value, (_key, val)=>{
        if (null == val) return val;
        if (Array.isArray(val)) return val;
        if ('object' != typeof val) return val;
        const obj = val;
        const keys = Object.keys(obj).sort();
        const sorted = {};
        for (const key of keys)sorted[key] = obj[key];
        return sorted;
    });
}
export { hashSerializedState };
