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.setInitialOrientation = exports.INITIAL_ORIENTATION_KEY = void 0;
7const assert_1 = __importDefault(require("assert"));
8const config_plugins_1 = require("expo/config-plugins");
9const pkg = require('expo-screen-orientation/package.json');
10// This value must match the `EXDefaultScreenOrientationMask` string used in `expo-screen-orientation/ios/EXScreenOrientation/EXScreenOrientationViewController.m` (do not change).
11exports.INITIAL_ORIENTATION_KEY = 'EXDefaultScreenOrientationMask';
12const OrientationLock = {
13    DEFAULT: 'UIInterfaceOrientationMaskAllButUpsideDown',
14    ALL: 'UIInterfaceOrientationMaskAll',
15    PORTRAIT: 'UIInterfaceOrientationMaskPortrait',
16    PORTRAIT_UP: 'UIInterfaceOrientationMaskPortrait',
17    PORTRAIT_DOWN: 'UIInterfaceOrientationMaskPortraitUpsideDown',
18    LANDSCAPE: 'UIInterfaceOrientationMaskLandscape',
19    LANDSCAPE_LEFT: 'UIInterfaceOrientationMaskLandscapeLeft',
20    LANDSCAPE_RIGHT: 'UIInterfaceOrientationMaskLandscapeRight',
21};
22const withScreenOrientationViewController = (config, { initialOrientation } = {}) => {
23    config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
24        const extendedConfig = {
25            ...config,
26            initialOrientation,
27        };
28        config.modResults = setInitialOrientation(extendedConfig, config.modResults);
29        return config;
30    });
31    return config;
32};
33function setInitialOrientation(config, infoPlist) {
34    const initialOrientation = config.initialOrientation;
35    if (!initialOrientation) {
36        delete infoPlist[exports.INITIAL_ORIENTATION_KEY];
37        return infoPlist;
38    }
39    (0, assert_1.default)(initialOrientation in OrientationLock, `Invalid initial orientation "${initialOrientation}" expected one of: ${Object.keys(OrientationLock).join(', ')}`);
40    infoPlist[exports.INITIAL_ORIENTATION_KEY] = OrientationLock[initialOrientation];
41    return infoPlist;
42}
43exports.setInitialOrientation = setInitialOrientation;
44exports.default = (0, config_plugins_1.createRunOncePlugin)(withScreenOrientationViewController, pkg.name, pkg.version);
45