"use strict";
/**
 * react-native mock for component rendering tests (vitest + jsdom)
 *
 * This file is used as a resolve.alias for 'react-native' in vitest.config.render.ts.
 * It provides real React component implementations so @testing-library/react-native
 * can render and query them in jsdom. The real react-native package cannot be loaded
 * in Node 22 due to ESM/typeof issues.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayoutAnimation = exports.I18nManager = exports.AccessibilityInfo = exports.NativeModules = exports.Appearance = exports.BackHandler = exports.Linking = exports.Keyboard = exports.AppState = exports.PixelRatio = exports.Easing = exports.Animated = exports.Alert = exports.Platform = exports.Dimensions = exports.StyleSheet = exports.FlatList = exports.Modal = exports.Pressable = exports.SectionList = exports.RefreshControl = exports.KeyboardAvoidingView = exports.StatusBar = exports.Switch = exports.TouchableWithoutFeedback = exports.TouchableHighlight = exports.TouchableOpacity = exports.ActivityIndicator = exports.SafeAreaView = exports.ScrollView = exports.ImageBackground = exports.Image = exports.TextInput = exports.Text = exports.View = void 0;
exports.useWindowDimensions = useWindowDimensions;
exports.PlatformColor = PlatformColor;
exports.useColorScheme = useColorScheme;
const react_1 = __importDefault(require("react"));
// ---------------------------------------------------------------------------
// Helper: create a simple host component that forwards props to a DOM element
// ---------------------------------------------------------------------------
function createMockComponent(name) {
    const Component = react_1.default.forwardRef((props, ref) => {
        const { children, testID, ...rest } = props;
        return react_1.default.createElement(name, { ...rest, testID, 'data-testid': testID, ref }, children);
    });
    Component.displayName = name;
    return Component;
}
// ---------------------------------------------------------------------------
// Core RN Components
// ---------------------------------------------------------------------------
exports.View = createMockComponent('View');
exports.Text = createMockComponent('Text');
exports.TextInput = createMockComponent('TextInput');
exports.Image = createMockComponent('Image');
exports.ImageBackground = createMockComponent('ImageBackground');
exports.ScrollView = createMockComponent('ScrollView');
exports.SafeAreaView = createMockComponent('SafeAreaView');
exports.ActivityIndicator = createMockComponent('ActivityIndicator');
exports.TouchableOpacity = createMockComponent('TouchableOpacity');
exports.TouchableHighlight = createMockComponent('TouchableHighlight');
exports.TouchableWithoutFeedback = createMockComponent('TouchableWithoutFeedback');
exports.Switch = createMockComponent('Switch');
exports.StatusBar = createMockComponent('StatusBar');
exports.KeyboardAvoidingView = createMockComponent('KeyboardAvoidingView');
exports.RefreshControl = createMockComponent('RefreshControl');
exports.SectionList = createMockComponent('SectionList');
// Pressable needs onPress / disabled support
exports.Pressable = react_1.default.forwardRef((props, ref) => {
    const { children, testID, onPress, disabled, ...rest } = props;
    return react_1.default.createElement('Pressable', {
        ...rest,
        testID,
        'data-testid': testID,
        onClick: disabled ? undefined : onPress,
        disabled,
        onPress,
        ref,
    }, typeof children === 'function' ? children({ pressed: false }) : children);
});
exports.Pressable.displayName = 'Pressable';
// Modal
exports.Modal = react_1.default.forwardRef((props, ref) => {
    const { children, visible, testID, onRequestClose, ...rest } = props;
    if (!visible)
        return null;
    return react_1.default.createElement('Modal', { ...rest, testID, 'data-testid': testID, visible, onRequestClose, ref }, children);
});
exports.Modal.displayName = 'Modal';
// FlatList — simplified: just render items in a ScrollView-like wrapper
exports.FlatList = react_1.default.forwardRef((props, ref) => {
    const { data, renderItem, keyExtractor, testID, ListHeaderComponent, ListFooterComponent, ListEmptyComponent, ...rest } = props;
    const items = data?.map((item, index) => {
        const key = keyExtractor ? keyExtractor(item, index) : String(index);
        return react_1.default.createElement(react_1.default.Fragment, { key }, renderItem({ item, index, separators: {} }));
    }) ?? [];
    const children = [
        ListHeaderComponent ? react_1.default.createElement(react_1.default.Fragment, { key: '__header' }, typeof ListHeaderComponent === 'function' ? react_1.default.createElement(ListHeaderComponent) : ListHeaderComponent) : null,
        ...(items.length === 0 && ListEmptyComponent
            ? [react_1.default.createElement(react_1.default.Fragment, { key: '__empty' }, typeof ListEmptyComponent === 'function' ? react_1.default.createElement(ListEmptyComponent) : ListEmptyComponent)]
            : items),
        ListFooterComponent ? react_1.default.createElement(react_1.default.Fragment, { key: '__footer' }, typeof ListFooterComponent === 'function' ? react_1.default.createElement(ListFooterComponent) : ListFooterComponent) : null,
    ].filter(Boolean);
    return react_1.default.createElement('FlatList', { ...rest, testID, 'data-testid': testID, ref }, ...children);
});
exports.FlatList.displayName = 'FlatList';
// ---------------------------------------------------------------------------
// StyleSheet
// ---------------------------------------------------------------------------
const absoluteFillValue = {
    position: 'absolute',
    left: 0,
    right: 0,
    top: 0,
    bottom: 0,
};
exports.StyleSheet = {
    create: (styles) => styles,
    flatten: (style) => {
        if (Array.isArray(style)) {
            return Object.assign({}, ...style.filter(Boolean).map((s) => exports.StyleSheet.flatten(s)));
        }
        return style ?? {};
    },
    absoluteFill: absoluteFillValue,
    absoluteFillObject: absoluteFillValue,
    hairlineWidth: 1,
    compose: (a, b) => [a, b],
};
// ---------------------------------------------------------------------------
// Dimensions
// ---------------------------------------------------------------------------
const dimensionsValues = { width: 375, height: 812, scale: 2, fontScale: 1 };
exports.Dimensions = {
    get: (_dim) => dimensionsValues,
    addEventListener: () => ({ remove: () => { } }),
    set: () => { },
};
// ---------------------------------------------------------------------------
// useWindowDimensions
// ---------------------------------------------------------------------------
function useWindowDimensions() {
    return dimensionsValues;
}
// ---------------------------------------------------------------------------
// Platform
// ---------------------------------------------------------------------------
exports.Platform = {
    OS: 'ios',
    Version: 18,
    isPad: false,
    isTVOS: false,
    isTV: false,
    select: (obj) => obj.ios ?? obj.default,
    constants: {
        reactNativeVersion: { major: 0, minor: 81, patch: 5 },
    },
};
// ---------------------------------------------------------------------------
// Alert
// ---------------------------------------------------------------------------
exports.Alert = {
    alert: (() => { }),
};
// ---------------------------------------------------------------------------
// Animated
// ---------------------------------------------------------------------------
class AnimatedValue {
    _value;
    _listeners = new Map();
    constructor(value = 0) {
        this._value = value;
    }
    setValue(value) {
        this._value = value;
    }
    setOffset(_offset) { }
    flattenOffset() { }
    extractOffset() { }
    addListener(cb) {
        const id = String(Math.random());
        this._listeners.set(id, cb);
        return id;
    }
    removeListener(id) {
        this._listeners.delete(id);
    }
    removeAllListeners() {
        this._listeners.clear();
    }
    stopAnimation(cb) {
        cb?.(this._value);
    }
    resetAnimation(cb) {
        cb?.(this._value);
    }
    interpolate(config) {
        return {
            ...config,
            __isAnimatedInterpolation: true,
            interpolate: (c) => ({ ...c, __isAnimatedInterpolation: true }),
        };
    }
    // Arithmetic methods for combined animations
    __getValue() { return this._value; }
}
class AnimatedValueXY {
    x;
    y;
    constructor(value) {
        this.x = new AnimatedValue(value?.x ?? 0);
        this.y = new AnimatedValue(value?.y ?? 0);
    }
    setValue(value) {
        this.x.setValue(value.x);
        this.y.setValue(value.y);
    }
    setOffset(offset) {
        this.x.setOffset(offset.x);
        this.y.setOffset(offset.y);
    }
    flattenOffset() {
        this.x.flattenOffset();
        this.y.flattenOffset();
    }
    extractOffset() {
        this.x.extractOffset();
        this.y.extractOffset();
    }
    stopAnimation(cb) {
        this.x.stopAnimation();
        this.y.stopAnimation();
        cb?.({ x: this.x._value, y: this.y._value });
    }
    addListener() { return ''; }
    removeListener() { }
    removeAllListeners() { }
    getLayout() {
        return { left: this.x, top: this.y };
    }
    getTranslateTransform() {
        return [{ translateX: this.x }, { translateY: this.y }];
    }
}
const mockAnimationResult = { start: (cb) => cb?.({ finished: true }), stop: () => { }, reset: () => { } };
exports.Animated = {
    Value: AnimatedValue,
    ValueXY: AnimatedValueXY,
    View: createMockComponent('Animated.View'),
    Text: createMockComponent('Animated.Text'),
    Image: createMockComponent('Animated.Image'),
    ScrollView: createMockComponent('Animated.ScrollView'),
    FlatList: createMockComponent('Animated.FlatList'),
    SectionList: createMockComponent('Animated.SectionList'),
    createAnimatedComponent: (comp) => comp,
    timing: (_value, _config) => mockAnimationResult,
    spring: (_value, _config) => mockAnimationResult,
    decay: (_value, _config) => mockAnimationResult,
    parallel: (_animations) => mockAnimationResult,
    sequence: (_animations) => mockAnimationResult,
    stagger: (_delay, _animations) => mockAnimationResult,
    delay: (_time) => mockAnimationResult,
    loop: (_animation, _config) => mockAnimationResult,
    event: (_argMapping, _config) => () => { },
    add: (a, b) => a,
    subtract: (a, b) => a,
    divide: (a, b) => a,
    multiply: (a, b) => a,
    diffClamp: (a, _min, _max) => a,
};
// ---------------------------------------------------------------------------
// Easing
// ---------------------------------------------------------------------------
exports.Easing = {
    linear: (t) => t,
    ease: (t) => t,
    quad: (t) => t * t,
    cubic: (t) => t * t * t,
    poly: (_n) => (t) => t,
    sin: (t) => t,
    circle: (t) => t,
    exp: (t) => t,
    elastic: (_bounciness) => (t) => t,
    back: (_s) => (t) => t,
    bounce: (t) => t,
    bezier: (_x1, _y1, _x2, _y2) => (t) => t,
    in: (fn) => fn,
    out: (fn) => fn,
    inOut: (fn) => fn,
    step0: (t) => t,
    step1: (t) => t,
};
// ---------------------------------------------------------------------------
// PixelRatio
// ---------------------------------------------------------------------------
exports.PixelRatio = {
    get: () => 2,
    getFontScale: () => 1,
    getPixelSizeForLayoutSize: (size) => size * 2,
    roundToNearestPixel: (size) => Math.round(size * 2) / 2,
};
// ---------------------------------------------------------------------------
// AppState
// ---------------------------------------------------------------------------
exports.AppState = {
    currentState: 'active',
    addEventListener: () => ({ remove: () => { } }),
    removeEventListener: () => { },
};
// ---------------------------------------------------------------------------
// Keyboard
// ---------------------------------------------------------------------------
exports.Keyboard = {
    addListener: () => ({ remove: () => { } }),
    removeListener: () => { },
    dismiss: () => { },
    isVisible: () => false,
    metrics: () => undefined,
};
// ---------------------------------------------------------------------------
// Linking
// ---------------------------------------------------------------------------
exports.Linking = {
    openURL: async () => { },
    canOpenURL: async () => true,
    getInitialURL: async () => null,
    addEventListener: () => ({ remove: () => { } }),
};
// ---------------------------------------------------------------------------
// BackHandler
// ---------------------------------------------------------------------------
exports.BackHandler = {
    addEventListener: () => ({ remove: () => { } }),
    removeEventListener: () => { },
    exitApp: () => { },
};
// ---------------------------------------------------------------------------
// Appearance
// ---------------------------------------------------------------------------
exports.Appearance = {
    getColorScheme: () => 'dark',
    addChangeListener: () => ({ remove: () => { } }),
    setColorScheme: () => { },
};
// ---------------------------------------------------------------------------
// PlatformColor (no-op stub)
// ---------------------------------------------------------------------------
function PlatformColor(..._args) {
    return '';
}
// ---------------------------------------------------------------------------
// NativeModules
// ---------------------------------------------------------------------------
exports.NativeModules = {};
// ---------------------------------------------------------------------------
// AccessibilityInfo
// ---------------------------------------------------------------------------
exports.AccessibilityInfo = {
    isScreenReaderEnabled: async () => false,
    addEventListener: () => ({ remove: () => { } }),
    setAccessibilityFocus: () => { },
    announceForAccessibility: () => { },
    isReduceMotionEnabled: async () => false,
    isBoldTextEnabled: async () => false,
    isGrayscaleEnabled: async () => false,
    isInvertColorsEnabled: async () => false,
    prefersCrossFadeTransitions: async () => false,
};
// ---------------------------------------------------------------------------
// I18nManager
// ---------------------------------------------------------------------------
exports.I18nManager = {
    isRTL: false,
    doLeftAndRightSwapInRTL: true,
    allowRTL: () => { },
    forceRTL: () => { },
    swapLeftAndRightInRTL: () => { },
};
// ---------------------------------------------------------------------------
// LayoutAnimation
// ---------------------------------------------------------------------------
exports.LayoutAnimation = {
    configureNext: () => { },
    create: () => ({}),
    Types: { spring: 'spring', linear: 'linear', easeInEaseOut: 'easeInEaseOut', easeIn: 'easeIn', easeOut: 'easeOut' },
    Properties: { opacity: 'opacity', scaleX: 'scaleX', scaleY: 'scaleY', scaleXY: 'scaleXY' },
    Presets: {
        easeInEaseOut: {},
        linear: {},
        spring: {},
    },
};
// ---------------------------------------------------------------------------
// useColorScheme
// ---------------------------------------------------------------------------
function useColorScheme() {
    return 'dark';
}
// ---------------------------------------------------------------------------
// Default export (some code does `import RN from 'react-native'`)
// ---------------------------------------------------------------------------
const RN = {
    View: exports.View,
    Text: exports.Text,
    TextInput: exports.TextInput,
    Image: exports.Image,
    ImageBackground: exports.ImageBackground,
    ScrollView: exports.ScrollView,
    FlatList: exports.FlatList,
    SectionList: exports.SectionList,
    SafeAreaView: exports.SafeAreaView,
    ActivityIndicator: exports.ActivityIndicator,
    TouchableOpacity: exports.TouchableOpacity,
    TouchableHighlight: exports.TouchableHighlight,
    TouchableWithoutFeedback: exports.TouchableWithoutFeedback,
    Pressable: exports.Pressable,
    Modal: exports.Modal,
    Switch: exports.Switch,
    StatusBar: exports.StatusBar,
    KeyboardAvoidingView: exports.KeyboardAvoidingView,
    RefreshControl: exports.RefreshControl,
    StyleSheet: exports.StyleSheet,
    Dimensions: exports.Dimensions,
    Platform: exports.Platform,
    Alert: exports.Alert,
    Animated: exports.Animated,
    Easing: exports.Easing,
    PixelRatio: exports.PixelRatio,
    AppState: exports.AppState,
    Keyboard: exports.Keyboard,
    Linking: exports.Linking,
    BackHandler: exports.BackHandler,
    Appearance: exports.Appearance,
    PlatformColor,
    NativeModules: exports.NativeModules,
    AccessibilityInfo: exports.AccessibilityInfo,
    I18nManager: exports.I18nManager,
    LayoutAnimation: exports.LayoutAnimation,
    useColorScheme,
    useWindowDimensions,
};
exports.default = RN;
