"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "icons", {
  enumerable: true,
  get: function get() {
    return _IconList["default"];
  }
});
Object.defineProperty(exports, "iconsSilicon", {
  enumerable: true,
  get: function get() {
    return _IconList.iconListSilicon;
  }
});
exports.IconDecorator = exports.IconBase = exports.Icon = exports["default"] = void 0;

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

var _Icon = _interopRequireDefault(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"));

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": 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; }

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; }

/**
 * Renders an Agate-styled icon without any behavior.
 *
 * @class IconBase
 * @memberof agate/Icon
 * @extends ui/Icon.Icon
 * @ui
 * @public
 */
var 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 [iconList]{@link ui/Icon.Icon.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, ["css", "skin"]);

    delete rest.spriteCount;
    return _Icon["default"].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 [Icon]{@link agate/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 [IconBase]{@link agate/Icon.IconBase}.
 *
 * @hoc
 * @memberof agate/Icon
 * @mixes agate/Skinnable.Skinnable
 * @public
 */

exports.IconBase = IconBase;
var 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
 */

exports.IconDecorator = IconDecorator;
var Icon = IconDecorator(IconBase);
exports.Icon = Icon;
var _default = Icon;
exports["default"] = _default;