1"use strict"; 2var __importDefault = (this && this.__importDefault) || function (mod) { 3 return (mod && mod.__esModule) ? mod : { "default": mod }; 4}; 5Object.defineProperty(exports, "__esModule", { value: true }); 6exports.setStrings = exports.resolveProps = exports.withAndroidUserInterfaceStyle = void 0; 7const config_plugins_1 = require("@expo/config-plugins"); 8const assert_1 = __importDefault(require("assert")); 9// strings.xml keys, this should not change. 10const USER_INTERFACE_STYLE_KEY = 'expo_system_ui_user_interface_style'; 11const withAndroidUserInterfaceStyle = (config) => { 12 return (0, config_plugins_1.withStringsXml)(config, (config) => { 13 config.modResults = setStrings(config.modResults, resolveProps(config)); 14 return config; 15 }); 16}; 17exports.withAndroidUserInterfaceStyle = withAndroidUserInterfaceStyle; 18function resolveProps(config) { 19 var _a, _b; 20 const userInterfaceStyle = (_b = (_a = config.android) === null || _a === void 0 ? void 0 : _a.userInterfaceStyle) !== null && _b !== void 0 ? _b : config.userInterfaceStyle; 21 (0, assert_1.default)(!userInterfaceStyle || ['automatic', 'light', 'dark'].includes(userInterfaceStyle), `expo-system-ui: Invalid userInterfaceStyle: "${userInterfaceStyle}"`); 22 return { userInterfaceStyle }; 23} 24exports.resolveProps = resolveProps; 25function setStrings(strings, { userInterfaceStyle }) { 26 const pairs = [[USER_INTERFACE_STYLE_KEY, userInterfaceStyle]]; 27 const stringItems = []; 28 for (const [key, value] of pairs) { 29 if (value == null) { 30 // Since we're using custom strings, we can remove them for convenience between prebuilds. 31 strings = config_plugins_1.AndroidConfig.Strings.removeStringItem(key, strings); 32 } 33 else { 34 stringItems.push(config_plugins_1.AndroidConfig.Resources.buildResourceItem({ 35 name: key, 36 value: String(value), 37 translatable: false, 38 })); 39 } 40 } 41 return config_plugins_1.AndroidConfig.Strings.setStringItem(stringItems, strings); 42} 43exports.setStrings = setStrings; 44