var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

import React from 'react';
import { If, Then, Else } from 'react-if';
import * as colors from '../../mixins/colors';
import { Block } from 'jsxstyle';

var AppIcon = function (_React$Component) {
    _inherits(AppIcon, _React$Component);

    function AppIcon() {
        _classCallCheck(this, AppIcon);

        return _possibleConstructorReturn(this, (AppIcon.__proto__ || Object.getPrototypeOf(AppIcon)).apply(this, arguments));
    }

    _createClass(AppIcon, [{
        key: 'render',
        value: function render() {
            var _this2 = this;

            var _props = this.props,
                app = _props.app,
                width = _props.width,
                height = _props.height,
                nativeWidth = _props.nativeWidth,
                nativeHeight = _props.nativeHeight;

            var alphabetSymbol = app.title ? app.title[0].toUpperCase() : 'A';
            return React.createElement(Block, { width: width, height: height, props: {
                    'data-component': 'app-icon',
                    'data-app-id': app.id,
                    title: this.appTitle
                } }, React.createElement(If, { condition: !!this.props.app.icon }, React.createElement(Then, null, function () {
                return React.createElement(Block, { component: 'img', maxWidth: '100%', maxHeight: '100%', height: '100%', props: {
                        src: app.icon + '?w=' + nativeWidth + '&h=' + nativeHeight,
                        alt: _this2.appTitle + ' on Cloudflare Apps'
                    } });
            }), React.createElement(Else, null, function () {
                return React.createElement(Block, { component: 'svg', props: { viewBox: '0 0 144 144' } }, React.createElement("rect", { x: '0', y: '0', width: '100%', height: '100%', rx: '30', ry: '30', fill: colors.accentGray3 }), React.createElement("text", { textAnchor: 'middle', x: '50%', y: '50%', dy: '.36em', fill: colors.accentGray2, fontSize: '80', fontWeight: 'bold' }, alphabetSymbol));
            })));
        }
    }, {
        key: 'appTitle',
        get: function get() {
            return this.props.app.title || 'Untitled App';
        }
    }]);

    return AppIcon;
}(React.Component);

export default AppIcon;
//# sourceMappingURL=app-icon.js.map