Files
discord-decomp/_bundle/contentClassificationToAgeRestrictionConclusion.js
T
2026-11-01 12:12:55 +02:00

130 lines
4.9 KiB
JavaScript

// Metro module 5909 (f5910).
import { AgeRestrictionSource } from "./Module5910";
import { AgeRestrictionStatus } from "./Module5911";
import { deserialize, has, hasAny } from "./HighLow";
import { DiscordContentClassificationFlags, DiscordContentClassificationFlagMasks } from "./Module5912";
import { ContentRatingESRBRatingSets } from "./Module5913";
import { ContentRatingPEGIRatingSets } from "./Module5914";
import { ContentRatingGOPClassificationSets } from "./Module5915";
import { ContentRatingIGDBThemeSets } from "./Module5916";
import { compare } from "./Module5917";
let c3702_3, c3702_4;
const contentClassificationToAgeRestrictionConclusion = function contentClassificationToAgeRestrictionConclusion(a0) {
let r46, r87, r129;
if (a0 == null) {
return c3702_4;
}
const r5 = [];
const { type, data } = a0;
if (type === c3702_3.MINIMAL) {
if (data.discord_classifications != null) {
const DISCORD_CLASSIFICATION = AgeRestrictionSource.DISCORD_CLASSIFICATION;
const r107 = deserialize(data.discord_classifications);
const r115 = has(r107, DiscordContentClassificationFlags.EMERGENCY_ONLY_USE_IF_YOU_HAVE_TO_FORCE_MARK_AGE_RESTRICTED);
const r116 = {
source: DISCORD_CLASSIFICATION,
status: null
};
if (r115) {
r116.status = AgeRestrictionStatus.ADULT;
r129 = r116;
} else {
r116.status = hasAny(r107, DiscordContentClassificationFlagMasks.RESTRICTED_TO_ADULT) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE;
r129 = r116;
}
r5.push(r129);
}
} else if (data.manual_classifications != null) {
const MANUAL_CLASSIFICATION = AgeRestrictionSource.MANUAL_CLASSIFICATION;
const r65 = deserialize(data.manual_classifications);
const r73 = has(r65, DiscordContentClassificationFlags.EMERGENCY_ONLY_USE_IF_YOU_HAVE_TO_FORCE_MARK_AGE_RESTRICTED);
const r74 = {
source: MANUAL_CLASSIFICATION,
status: null
};
if (r73) {
r74.status = AgeRestrictionStatus.ADULT;
r87 = r74;
} else {
r74.status = hasAny(r65, DiscordContentClassificationFlagMasks.RESTRICTED_TO_ADULT) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE;
r87 = r74;
}
r5.push(r87);
} else if (data.automated_classifications != null) {
const AUTOMATED_CLASSIFICATION = AgeRestrictionSource.AUTOMATED_CLASSIFICATION;
const r25 = deserialize(data.automated_classifications);
const r32 = has(r25, DiscordContentClassificationFlags.EMERGENCY_ONLY_USE_IF_YOU_HAVE_TO_FORCE_MARK_AGE_RESTRICTED);
const r33 = {
source: AUTOMATED_CLASSIFICATION,
status: null
};
if (r32) {
r33.status = AgeRestrictionStatus.ADULT;
r46 = r33;
} else {
r33.status = hasAny(r25, DiscordContentClassificationFlagMasks.RESTRICTED_TO_ADULT) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE;
r46 = r33;
}
r5.push(r46);
}
if (data.agency_ratings != null) {
if (data.agency_ratings.esrb != null) {
r5.push({
source: AgeRestrictionSource.AGENCY_CLASSIFICATION_ESRB,
status: ContentRatingESRBRatingSets.IS_ADULT_ONLY.has(data.agency_ratings.esrb.rating) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE
});
}
if (data.agency_ratings.pegi != null) {
r5.push({
source: AgeRestrictionSource.AGENCY_CLASSIFICATION_PEGI,
status: ContentRatingPEGIRatingSets.IS_ADULT_ONLY.has(data.agency_ratings.pegi.rating) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE
});
}
if (data.agency_ratings.gop != null) {
r5.push({
source: AgeRestrictionSource.AGENCY_CLASSIFICATION_GOP,
status: ContentRatingGOPClassificationSets.IS_ADULT.has(data.agency_ratings.gop.classification) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE
});
}
if (data.agency_ratings.igdb != null) {
let themes = data.agency_ratings.igdb.themes;
if (themes == null) {
themes = [];
}
r5.push({
source: AgeRestrictionSource.AGENCY_CLASSIFICATION_IGDB,
status: themes.some((theme) => ContentRatingIGDBThemeSets.ADULT_THEMES.has(theme)) ? AgeRestrictionStatus.ADULT : AgeRestrictionStatus.EVERYONE
});
}
}
return (function _mostRestrictiveConclusion(a0) {
let r0 = null;
for (const item of a0) {
if (r0 != null) {
if (compare(item.status, r0.status) > 0) {
r0 = item;
}
} else {
r0 = item;
}
}
if (r0 == null) {
r0 = c3702_4;
}
return r0;
})(r5);
};
c3702_3 = {
FULL: "full",
MINIMAL: "minimal"
};
c3702_4 = {
source: AgeRestrictionSource.NO_CLASSIFICATION,
status: AgeRestrictionStatus.EVERYONE
};
export { c3702_3 as ContentClassificationVariant };
export function contentClassificationToAgeRestriction(a0) {
return contentClassificationToAgeRestrictionConclusion(a0).status;
}
export { contentClassificationToAgeRestrictionConclusion };