"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importStar(require("react"));
const react_native_1 = require("react-native");
const react_native_fast_image_1 = tslib_1.__importDefault(require("react-native-fast-image"));
const rn_placeholder_1 = require("rn-placeholder");
const styled_components_1 = require("styled-components");
const styles_1 = require("./styles");
const Image = ({ id, testID, accessibility, containerStyle, displayPlaceholder = true, animationColor, animationContainerColor, style, source, ...rest }) => {
    const [isLoading, setIsLoading] = (0, react_1.useState)(false);
    const theme = (0, react_1.useContext)(styled_components_1.ThemeContext);
    const onImageLoad = () => {
        setIsLoading(false);
    };
    const onImageLoadStart = () => {
        setIsLoading(true);
    };
    const animationStyling = (animationProps) => (<rn_placeholder_1.Shine {...animationProps} style={[
            animationProps.style,
            {
                backgroundColor: animationColor || theme?.background?.z3,
            },
        ]}/>);
    return (<styles_1.Wrapper style={containerStyle}>
      {isLoading && displayPlaceholder && (<rn_placeholder_1.Placeholder Animation={animationStyling}>
          <rn_placeholder_1.PlaceholderMedia style={[
                style,
                {
                    backgroundColor: animationContainerColor || theme?.background?.z2,
                },
            ]}/>
        </rn_placeholder_1.Placeholder>)}
      {(typeof source === 'object' || typeof source === 'string') && (<react_native_fast_image_1.default fallback source={source} testID={testID || id} accessibilityLabel={accessibility} onLoadStart={onImageLoadStart} onLoad={onImageLoad} style={style} {...rest}/>)}
      {typeof source === 'number' && (<react_native_1.Image source={source} testID={testID || id} accessibilityLabel={accessibility} style={style} {...rest}/>)}
    </styles_1.Wrapper>);
};
exports.default = Image;
//# sourceMappingURL=index.js.map