'use strict';

var index = require('../../../../feature-flags/es/index.js');
var PropTypes = require('prop-types');
var React = require('react');
var deprecate = require('../../prop-types/deprecate.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

/**
 * Copyright IBM Corp. 2016, 2023
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */


// TODO: Can this variable be deleted now? It isn't used anywhere.
/**
 * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
 * or disable feature flags in a given React tree
 */
const FeatureFlagContext = /*#__PURE__*/React.createContext(index.FeatureFlags);
({
  children: PropTypes__default.default.node,
  /**
   * Provide the feature flags to enabled or disabled in the current Rea,ct tree
   */
  flags: deprecate.deprecate(PropTypes__default.default.objectOf(PropTypes__default.default.bool), 'The `flags` prop for `FeatureFlag` has ' + 'been deprecated. Please run the `featureflag-deprecate-flags-prop` codemod to migrate to individual boolean props.' + `npx @carbon/upgrade migrate featureflag-deprecate-flags-prop --write`),
  enableV12TileDefaultIcons: PropTypes__default.default.bool,
  enableV12TileRadioIcons: PropTypes__default.default.bool,
  enableV12Overflowmenu: PropTypes__default.default.bool,
  enableTreeviewControllable: PropTypes__default.default.bool,
  enableExperimentalFocusWrapWithoutSentinels: PropTypes__default.default.bool,
  enableFocusWrapWithoutSentinels: PropTypes__default.default.bool,
  enableDialogElement: PropTypes__default.default.bool,
  enableV12DynamicFloatingStyles: PropTypes__default.default.bool,
  enableEnhancedFileUploader: PropTypes__default.default.bool,
  enablePresence: PropTypes__default.default.bool
});

/**
 * Access whether a given flag is enabled or disabled in a given
 * FeatureFlagContext
 *
 * @returns {boolean}
 */
function useFeatureFlag(flag) {
  const scope = React.useContext(FeatureFlagContext);
  return scope.enabled(flag);
}

exports.FeatureFlagContext = FeatureFlagContext;
exports.useFeatureFlag = useFeatureFlag;
