42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
// Generated, do not edit. sha256:5d115259dddad7958f7f0a20af1477db47898da5fb7fe4a5f958f0a3bc9b0df0
|
|
import { isAiRawAllowed } from './gate.js';
|
|
import { getPref } from '../data/preferences.js';
|
|
|
|
function bucketing(key) {
|
|
try { return getPref('ai', key) !== 0; }
|
|
catch { return true; }
|
|
}
|
|
|
|
export function precisionSettings() {
|
|
if (isAiRawAllowed()) {
|
|
return Object.freeze({
|
|
rawValues: true,
|
|
bucketShares: false,
|
|
bucketTotals: false,
|
|
bucketAmounts: false,
|
|
bucketQuantities: false,
|
|
});
|
|
}
|
|
return Object.freeze({
|
|
rawValues: false,
|
|
bucketShares: bucketing('bucket_shares'),
|
|
bucketTotals: bucketing('bucket_totals'),
|
|
bucketAmounts: bucketing('bucket_amounts'),
|
|
bucketQuantities: bucketing('bucket_quantities'),
|
|
});
|
|
}
|
|
|
|
export function shareDisclosure(precision) {
|
|
const p = precision ?? {};
|
|
if (p.rawValues) return 'exact';
|
|
if (!p.bucketAmounts) return 'exact';
|
|
if (p.bucketShares) return 'bucketed';
|
|
if (p.bucketTotals) return 'exact';
|
|
return 'omit';
|
|
}
|
|
|
|
export function precisionKey(precision) {
|
|
const p = precision ?? {};
|
|
return Object.keys(p).sort().map(k => `${k}=${String(p[k])}`).join(',') || 'leeg';
|
|
}
|