"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.IconDecorator = exports.IconBase = exports.Icon = void 0;
Object.defineProperty(exports, "icons", {
  enumerable: true,
  get: function get() {
    return _IconList["default"];
  }
});
Object.defineProperty(exports, "iconsSilicon", {
  enumerable: true,
  get: function get() {
    return _IconList.iconListSilicon;
  }
});
var _kind = _interopRequireDefault(require("@enact/core/kind"));
var _Icon = require("@enact/ui/Icon");
var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));
var _compose = _interopRequireDefault(require("ramda/src/compose"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _Skinnable = _interopRequireDefault(require("../Skinnable"));
var _IconList = _interopRequireWildcard(require("./IconList.js"));
var _IconModule = _interopRequireDefault(require("./Icon.module.css"));
var _excluded = ["css", "skin"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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; }
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); } /**
 * Provides Agate styled icon components and behaviors.
 *
 * @example
 * <Icon>closex</Icon>
 *
 * @module agate/Icon
 * @exports Icon
 * @exports IconBase
 * @exports IconDecorator
 * @exports icons
 * @exports iconsSilicon
 */
/**
 * Renders an Agate-styled icon without any behavior.
 *
 * @class IconBase
 * @memberof agate/Icon
 * @extends ui/Icon.Icon
 * @ui
 * @public
 */
var IconBase = exports.IconBase = (0, _kind["default"])({
  name: 'Icon',
  propTypes: /** @lends agate/Icon.IconBase.prototype */{
    /**
     * The icon content.
     *
     * May be specified as either:
     *
     * * A string that represents an icon from the {@link ui/Icon.Icon.iconList|iconList},
     * * An HTML entity string, Unicode reference or hex value (in the form '0x...'),
     * * A URL specifying path to an icon image, or
     * * An object representing a resolution independent resource (See {@link ui/resolution}).
     *
     * @type {String|Object}
     * @public
     */
    children: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
    /**
     * Customizes the component by mapping the supplied collection of CSS class names to the
     * corresponding internal elements and states of this component.
     *
     * The following classes are supported:
     *
     * * `icon` - The root class name
     * * `dingbat` - Applied to dingbat icon
     * * `focus` - Applied when icon is focused
     * * `huge` - Applied to a `size='huge'` icon
     * * `small` - Applied to a `size='small'` icon
     * * `smallest` - Applied to a `size='smallest'` icon
     *
     * @type {Object}
     * @public
     */
    css: _propTypes["default"].object,
    /**
     * The size of the icon.
     *
     * @type {('smallest'|'small'|'large'|'huge')}
     * @default 'large'
     * @public
     */
    size: _propTypes["default"].oneOf(['smallest', 'small', 'large', 'huge']),
    /**
     * The current skin.
     *
     * @type {String}
     * @private
     */
    skin: _propTypes["default"].string,
    /**
     * The amount of sprite "cells" in the src image.
     *
     * This property only affects image-based icons, not icon glyphs.
     *
     * @type {Number}
     * @default 1
     * @public
     */
    spriteCount: _propTypes["default"].number
  },
  defaultProps: {
    size: 'large',
    spriteCount: 1
  },
  styles: {
    css: _IconModule["default"]
  },
  computed: {
    className: function className(_ref) {
      var size = _ref.size,
        styler = _ref.styler;
      return styler.append(size);
    },
    style: function style(_ref2) {
      var spriteCount = _ref2.spriteCount,
        _style = _ref2.style;
      return _objectSpread(_objectSpread({}, _style), {}, {
        '--agate-icon-sprite-count': spriteCount
      });
    }
  },
  render: function render(_ref3) {
    var css = _ref3.css,
      skin = _ref3.skin,
      rest = _objectWithoutProperties(_ref3, _excluded);
    delete rest.spriteCount;
    return _Icon.IconBase.inline(_objectSpread(_objectSpread({}, rest), {}, {
      css: css,
      iconList: skin === 'silicon' ? _IconList.iconListSilicon : _IconList["default"]
    }));
  }
});

// Let's find a way to import this list directly, and bonus feature, render our icons in the docs
// next to their names.
/**
 * An object whose keys can be used as the child of an {@link agate/Icon.Icon|Icon} component.
 *
 * List of Icons:
 * ```
 * circlelarge
 * squarelarge
 * triangleup
 * plus
 * minus
 * arrowup
 * arrowdown
 * arrowleftturn
 * arrowrightturn
 * arrowharpoonright
 * ellipsis
 * check
 * arrowstraightup
 * arrowuturn
 * arrowlargedown
 * arrowlargeup
 * arrowlargeleft
 * arrowlargeright
 * closex
 * search
 * bluetooth2
 * bluetoothoff
 * bright1
 * bright2
 * bluetooth
 * usb
 * volume0
 * volume1
 * volume2
 * wifi
 * happyface
 * notification
 * pairing
 * user
 * calendar
 * edit
 * gallery
 * internet
 * map
 * music
 * video
 * circle
 * previous
 * pairingdisplay
 * box
 * play
 * previoustrack
 * pause
 * nexttrack
 * repeat
 * shuffle
 * error
 * setting
 * popupstop
 * accept
 * decline
 * stop
 * cancel
 * carspeaker
 * speaker
 * earphone
 * detail
 * install
 * send
 * netbook
 * pad
 * mobile
 * update
 * backapp
 * uninstall
 * rain
 * raindrops
 * raincloud
 * snow
 * cloud
 * ice
 * fog
 * sun
 * profileA1
 * profileA2
 * profileA3
 * profileA4
 * profileB1
 * profileB2
 * profileB3
 * profileB4
 * profileC1
 * profileC2
 * profileC3
 * profileC4
 * ac
 * auto
 * airmode
 * airdown
 * airright
 * airup
 * heatseatleft
 * heatseatright
 * aircirculation
 * fan
 * defrosterfront
 * defrosterback
 * airflow
 * home
 * temperature
 * compass
 * phone
 * fanoff
 * datetime
 * display
 * seatbelt
 * apps
 * climate
 * dashboard
 * expand
 * radio
 * rearscreen
 * weather
 * fullscreen
 * menu
 * history
 * browser
 * lock
 * search2
 * bookmark
 * star
 * hollowstar
 * halfstar
 * refresh
 * time
 * pausebold
 * playbold
 * controls
 * diagnostics
 * mapbox
 * displaycontrol
 * controlleft
 * controlright
 * mainpage
 * playlist
 * resume
 * trailer
 * plusbold
 * minusbold
 * ```
 *
 * @name iconList
 * @memberof agate/Icon
 * @constant
 * @type {Object}
 * @public
 */

/**
 * Agate-specific behaviors to apply to {@link agate/Icon.IconBase|IconBase}.
 *
 * @hoc
 * @memberof agate/Icon
 * @mixes agate/Skinnable.Skinnable
 * @public
 */
var IconDecorator = exports.IconDecorator = (0, _compose["default"])(_Pure["default"], (0, _Skinnable["default"])({
  prop: 'skin'
}));

/**
 * An Agate-styled icon.
 *
 * @class Icon
 * @memberof agate/Icon
 * @extends agate/Icon.IconBase
 * @mixes agate/Icon.IconDecorator
 * @ui
 * @public
 */
var Icon = exports.Icon = IconDecorator(IconBase);
var _default = exports["default"] = Icon;