import _extends from 'babel-runtime/helpers/extends';
var __rest = this && this.__rest || function (s, e) {
    var t = {};
    for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
    }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
        if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
    }
    return t;
};
import React, { useMemo } from 'react';
import { createFromIconfontCN } from '@fishx/icons';
import * as FishxIcons from '@fishx/icons';
function IconFont(props) {
    var type = props.type,
        url = props.url,
        rest = __rest(props, ["type", "url"]);

    var Icon = useMemo(function () {
        return createFromIconfontCN({
            scriptUrl: url
        });
    }, [url]);
    var Component = function Component(_ref) {
        var type = _ref.type;

        if (type) {
            var FishIcon = FishxIcons[type];
            return React.createElement(FishIcon, rest);
        } else return null;
    };
    if (url) {
        return React.createElement(Icon, _extends({ type: type }, rest));
    } else {
        return React.createElement(Component, _extends({ type: type }, rest));
    }
}
export default IconFont;