import React, { ForwardedRef, useContext } from 'react';
import { OriginIconProps } from '../type';
import { Context } from '../context';

function IconWrapperComponent(props: OriginIconProps, ref: ForwardedRef<SVGSVGElement>) {
    const { prefix: prefixFromContext } = useContext(Context);
    const { className = '', prefix: prefixFromProps, width = '1em', height = '1em', useCurrentColor = true, spin, ...rest } = props;

    const prefix = prefixFromProps || prefixFromContext || 'hiagent';
    const loadingKls = spin ? ` ${prefix}-icon-loading` : '';
    return <svg className={`${prefix}-icon ${prefix}-icon-wrapper${loadingKls} ${className}`} width={width} height={height} xmlns="http://www.w3.org/2000/svg" fill={useCurrentColor ? 'currentColor' : '#000'} viewBox="0 0 24 24" {...rest} ref={ref}><path fillRule="evenodd" d="M17.077 16.65a1.196 1.196 0 0 0 1.691 0l.846-.846a1.196 1.196 0 0 0 0-1.69L12.85 7.35A1.192 1.192 0 0 0 12 7a1.192 1.192 0 0 0-.85.35l-6.764 6.764a1.196 1.196 0 0 0 0 1.69l.846.846a1.196 1.196 0 0 0 1.69 0L12 11.572l5.077 5.078Z" clipRule="evenodd"/></svg>;
}

const IconWrapper = React.forwardRef(IconWrapperComponent);
export default IconWrapper;
