"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WindDirectionControlDecorator = exports.WindDirectionControlBase = exports.WindDirectionControl = exports["default"] = void 0;

var _jsxRuntime = require("react/jsx-runtime");

var _kind = _interopRequireDefault(require("@enact/core/kind"));

var _util = require("@enact/core/util");

var _Changeable = _interopRequireDefault(require("@enact/ui/Changeable"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _compose = _interopRequireDefault(require("ramda/src/compose"));

var _ArcPicker = _interopRequireDefault(require("../ArcPicker"));

var _Icon = _interopRequireDefault(require("../Icon"));

var _Skinnable = _interopRequireDefault(require("../Skinnable"));

var _WindDirectionControlModule = _interopRequireDefault(require("./WindDirectionControl.module.css"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

// Children supplied to ArcPicker/WindDirectionControl. The number of items in this array represents the number of
// Arcs rendered on the screen.
var children = ['airDown', 'airRight', 'airUp'];
/**
 * An Agate component for displaying Wind Direction Control.
 *
 * @class WindDirectionControlBase
 * @memberof agate/WindDirectionControl
 * @extends agate/ArcPicker.ArcPicker
 * @ui
 * @public
 */

var WindDirectionControlBase = (0, _kind["default"])({
  name: 'WindDirectionControlBase',
  propTypes:
  /** @lends agate/WindDirectionControl.WindDirectionControlBase.prototype */
  {
    /**
     * Whether or not the component is in a disabled state.
     *
     * @type {Boolean}
     * @public
     */
    disabled: _propTypes["default"].bool,

    /**
     * Called when value is changed.
     *
     * @type {Function}
     * @public
     */
    onChange: _propTypes["default"].func,

    /**
     * State of WindDirectionControl.
     *
     * @type {('airDown'|'airRight'|'airUp')}
     * @default 'airDown'
     * @public
     */
    value: _propTypes["default"].oneOf(['airDown', 'airRight', 'airUp'])
  },
  defaultProps: {
    value: 'airDown'
  },
  styles: {
    css: _WindDirectionControlModule["default"],
    className: 'windDirectionControl'
  },
  computed: {
    airDirectionIcon: function airDirectionIcon(_ref) {
      var value = _ref.value;
      return value.toLowerCase();
    }
  },
  render: function render(_ref2) {
    var airDirectionIcon = _ref2.airDirectionIcon,
        disabled = _ref2.disabled,
        onChange = _ref2.onChange,
        value = _ref2.value,
        rest = _objectWithoutProperties(_ref2, ["airDirectionIcon", "disabled", "onChange", "value"]);

    var ariaProps = (0, _util.extractAriaProps)(rest);
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], _objectSpread(_objectSpread({}, ariaProps), {}, {
        disabled: disabled,
        endAngle: 210,
        onChange: onChange,
        slotCenter: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon["default"], {
          className: _WindDirectionControlModule["default"].airDirectionIcon,
          css: _WindDirectionControlModule["default"],
          children: airDirectionIcon
        }),
        value: value,
        children: children
      }))
    }));
  }
});
/**
 * Applies Agate specific behaviors to [WindDirectionControlBase]{@link agate/WindDirectionControl.WindDirectionControlBase}.
 *
 * @hoc
 * @memberof agate/WindDirectionControl
 * @mixes ui/Changeable.Changeable
 * @mixes agate/Skinnable.Skinnable
 * @public
 */

exports.WindDirectionControlBase = WindDirectionControlBase;
var WindDirectionControlDecorator = (0, _compose["default"])(_Changeable["default"], _Skinnable["default"]);
/**
 * WindDirectionControl with Agate styling and
 * [WindDirectionControlDecorator]{@link agate/WindDirectionControl.WindDirectionControlDecorator} applied.
 *
 * Usage:
 * ```
 * <WindDirectionControl />
 * ```
 *
 * @class WindDirectionControl
 * @memberof agate/WindDirectionControl
 * @extends agate/WindDirectionControl.WindDirectionControlBase
 * @mixes agate/WindDirectionControl.WindDirectionControlDecorator
 * @ui
 * @public
 */

exports.WindDirectionControlDecorator = WindDirectionControlDecorator;
var WindDirectionControl = WindDirectionControlDecorator(WindDirectionControlBase);
exports.WindDirectionControl = WindDirectionControl;
var _default = WindDirectionControl;
exports["default"] = _default;