"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.WindDirectionControlDecorator = exports.WindDirectionControlBase = exports.WindDirectionControl = void 0;
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"));
var _jsxRuntime = require("react/jsx-runtime");
var _excluded = ["airDirectionIcon", "disabled", "onChange", "value"];
/**
 * Agate styled WindDirectionControl component and behavior.
 *
 * @example
 * <WindDirectionControl />
 *
 * @module agate/WindDirectionControl
 * @exports WindDirectionControl
 * @exports WindDirectionControlBase
 * @exports WindDirectionControlDecorator
 */
// Children supplied to ArcPicker/WindDirectionControl. The number of items in this array represents the number of
// Arcs rendered on the screen.
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
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 = exports.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, _excluded);
    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 {@link agate/WindDirectionControl.WindDirectionControlBase|WindDirectionControlBase}.
 *
 * @hoc
 * @memberof agate/WindDirectionControl
 * @mixes ui/Changeable.Changeable
 * @mixes agate/Skinnable.Skinnable
 * @public
 */
var WindDirectionControlDecorator = exports.WindDirectionControlDecorator = (0, _compose["default"])(_Changeable["default"], _Skinnable["default"]);

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