// Metro module 311 (f312).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import _possibleConstructorReturn from "./_possibleConstructorReturn";
import _getPrototypeOf from "./_getPrototypeOf";
import _inherits from "./_inherits";
import { PureComponent, Fragment } from "react";
import { jsx } from "react/jsx-runtime";
import { shouldUseRemoveClippedSubviewsAsDefaultOnIOS } from "./Module27";
import Module312 from "./Module312";
import * as _Module38 from "./Module38";
import View from "./View";
import * as _Module254 from "./Module254";
import memoizeOne from "./memoizeOne";
import * as _deepDiffer from "./deepDiffer";
let _excluded, styles;
let FlatList;
let env320 = {};
env320[11] = function _isNativeReflectConstruct() {
let c12238_0;
try {
c12238_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c12238_0;
};
env320[11] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
_excluded = ["numColumns", "columnWrapperStyle", "removeClippedSubviews", "strictMode"];
FlatList = function FlatList(a0) {
_classCallCheck(this, FlatList);
const r9 = [a0];
const r8 = _getPrototypeOf(FlatList);
const r17 = (0, env320[11])() ? Reflect.construct(r8, r9, _getPrototypeOf(this).constructor) : r8.apply(this, r9);
const _this = _possibleConstructorReturn(this, r17);
_this._virtualizedListPairs = [];
_this._captureRef = (a0) => {
_this._listRef = a0;
};
_this._getItem = (a0, a1) => {
let numColumns = _this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
if (numColumns > 1) {
const r14 = [];
let r0 = 0;
while (r0 < numColumns) {
const r1 = a1 * numColumns + r0;
const length = a0.length;
const r2 = r0;
if (r1 < length) {
r14.push(a0[r1]);
}
r0 = r2 + 1;
}
return r14;
}
return a0[a1];
};
_this._getItemCount = (a0) => {
if (a0 != null && typeof Object(a0).length === "number") {
let numColumns = _this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
return numColumns > 1 ? Math.ceil(a0.length / numColumns) : a0.length;
}
return 0;
};
_this._keyExtractor = (a0, a1) => {
let r19;
let numColumns = _this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
let c28632_1 = numColumns;
let keyExtractor3 = _this.props.keyExtractor;
if (keyExtractor3 == null) {
keyExtractor3 = Module312.keyExtractor;
}
const keyExtractor2 = keyExtractor3;
if (numColumns > 1) {
_Module38(Array.isArray(a0), "FlatList: Encountered internal consistency error, expected each item to consist of an array with 1-%s columns; instead, received a single item.", numColumns);
r19 = a0.map((item, index) => keyExtractor2(item, a1 * c28632_1 + index)).join(":");
} else {
r19 = keyExtractor2(a0, a1);
}
return r19;
};
_this._renderer = (a0, c28633_1, c28633_2, a3, a4) => {
let Component = a0;
let c28633_3 = a3 == null ? 1 : a3;
const render2 = (a0) => {};
const renderProp = (a0) => {
let r15;
let index;
let c31146_0 = a0;
if (c28633_3 > 1) {
const item = a0.item;
index = a0.index;
_Module38(Array.isArray(item), "Expected array of items with numColumns > 1");
return (0, jsx)(View, {
style: _Module254.default.compose(styles.row, c28633_2),
children: item.map((a0, a1) => {
let children;
const r4 = {
item: a0,
index: index * c28633_3 + a1,
separators: c31146_0.separators
};
if (Component) {
children = ;
} else {
children = c28633_1 ? c28633_1(r4) : null;
}
return children != null ? (0, jsx)(Fragment, {
children
}, a1) : null;
})
});
}
if (Component) {
r15 = ;
} else {
r15 = c28633_1 ? c28633_1(a0) : null;
}
return r15;
};
return a0 ? {
ListItemComponent: renderProp
} : {
renderItem: renderProp
};
};
_this._memoizedRenderer = memoizeOne(_this._renderer);
_this._checkProps(_this.props);
const viewabilityConfigCallbackPairs = _this.props.viewabilityConfigCallbackPairs;
const props = _this.props;
if (viewabilityConfigCallbackPairs) {
_this._virtualizedListPairs = props.viewabilityConfigCallbackPairs.map((viewabilityConfigCallbackPair) => ({
viewabilityConfig: viewabilityConfigCallbackPair.viewabilityConfig,
onViewableItemsChanged: _this._createOnViewableItemsChanged(viewabilityConfigCallbackPair.onViewableItemsChanged)
}));
} else if (props.onViewableItemsChanged) {
_this._virtualizedListPairs.push({
viewabilityConfig: _this.props.viewabilityConfig,
onViewableItemsChanged: _this._createOnViewableItemsChanged(function(...args) {
_Module38(_this.props.onViewableItemsChanged, "Changing the nullability of onViewableItemsChanged is not supported. Once a function or null is supplied that cannot be changed.");
const props = _this.props;
return props.onViewableItemsChanged.apply(props, [...args]);
})
});
}
return _this;
};
_inherits(FlatList, PureComponent);
const r67 = _createClass(FlatList, [{
key: "scrollToEnd",
value: function scrollToEnd(a0) {
if (this._listRef) {
this._listRef.scrollToEnd(a0);
}
}
}, {
key: "scrollToIndex",
value: function scrollToIndex(a0) {
if (this._listRef) {
this._listRef.scrollToIndex(a0);
}
}
}, {
key: "scrollToItem",
value: function scrollToItem(a0) {
if (this._listRef) {
this._listRef.scrollToItem(a0);
}
}
}, {
key: "scrollToOffset",
value: function scrollToOffset(a0) {
if (this._listRef) {
this._listRef.scrollToOffset(a0);
}
}
}, {
key: "recordInteraction",
value: function recordInteraction() {
if (this._listRef) {
this._listRef.recordInteraction();
}
}
}, {
key: "flashScrollIndicators",
value: function flashScrollIndicators() {
if (this._listRef) {
this._listRef.flashScrollIndicators();
}
}
}, {
key: "getScrollResponder",
value: function getScrollResponder() {
if (this._listRef) {
return this._listRef.getScrollResponder();
}
}
}, {
key: "getNativeScrollRef",
value: function getNativeScrollRef() {
if (this._listRef) {
return this._listRef.getScrollRef();
}
}
}, {
key: "getScrollableNode",
value: function getScrollableNode() {
if (this._listRef) {
return this._listRef.getScrollableNode();
}
}
}, {
key: "setNativeProps",
value: function setNativeProps(a0) {
if (this._listRef) {
this._listRef.setNativeProps(a0);
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(a0) {
_Module38(a0.numColumns === this.props.numColumns, "Changing numColumns on the fly is not supported. Change the key prop on FlatList when changing the number of columns to force a fresh render of the component.");
_Module38(a0.onViewableItemsChanged == null === (this.props.onViewableItemsChanged == null), "Changing onViewableItemsChanged nullability on the fly is not supported");
_Module38(!_deepDiffer.default(a0.viewabilityConfig, this.props.viewabilityConfig), "Changing viewabilityConfig on the fly is not supported");
_Module38(a0.viewabilityConfigCallbackPairs === this.props.viewabilityConfigCallbackPairs, "Changing viewabilityConfigCallbackPairs on the fly is not supported");
this._checkProps(this.props);
}
}, {
key: "_checkProps",
value: function _checkProps(a0) {
const { getItem, getItemCount, horizontal, columnWrapperStyle } = a0;
let onViewableItemsChanged = a0.onViewableItemsChanged;
const viewabilityConfigCallbackPairs = a0.viewabilityConfigCallbackPairs;
let numColumns = this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
_Module38(getItem ? !getItem : !getItemCount, "FlatList does not support custom data formats.");
if (numColumns > 1) {
_Module38(!horizontal, "numColumns does not support horizontal.");
} else {
_Module38(!columnWrapperStyle, "columnWrapperStyle not supported for single column lists");
}
if (onViewableItemsChanged) {
onViewableItemsChanged = viewabilityConfigCallbackPairs;
}
_Module38(!onViewableItemsChanged, "FlatList does not support setting both onViewableItemsChanged and viewabilityConfigCallbackPairs.");
}
}, {
key: "_pushMultiColumnViewable",
value: function _pushMultiColumnViewable(c23640_0, a1) {
let c23640_1 = a1;
let numColumns = this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
let c23640_2 = numColumns;
let keyExtractor3 = this.props.keyExtractor;
if (keyExtractor3 == null) {
keyExtractor3 = Module312.keyExtractor;
}
const keyExtractor = keyExtractor3;
a1.item.forEach((a0, a1) => {
_Module38(c23640_1.index != null, "Missing index!");
const index2 = c23640_1.index * c23640_2 + a1;
c23640_0.push({
...c23640_1,
item: a0,
key: keyExtractor(a0, index2),
index: index2
});
});
}
}, {
key: "_createOnViewableItemsChanged",
value: function _createOnViewableItemsChanged(c23641_0) {
return (a0) => {
let numColumns = this.props.numColumns;
if (numColumns == null) {
numColumns = 1;
}
if (c23641_0) {
if (numColumns > 1) {
const changed = [];
let c28634_0 = changed;
const viewableItems = [];
let c28634_1 = viewableItems;
a0.viewableItems.forEach((viewableItem) => this._pushMultiColumnViewable(c28634_1, viewableItem));
a0.changed.forEach((item) => this._pushMultiColumnViewable(c28634_0, item));
c23641_0({
viewableItems,
changed
});
} else {
c23641_0(a0);
}
}
};
}
}, {
key: "render",
value: function render() {
const props = this.props;
const { numColumns, columnWrapperStyle } = props;
let removeClippedSubviews = props.removeClippedSubviews;
const { strictMode = false, ...rest } = props;
const r8 = strictMode ? this._memoizedRenderer : this._renderer;
shouldUseRemoveClippedSubviewsAsDefaultOnIOS();
if (removeClippedSubviews == null) {
removeClippedSubviews = true;
}
return ;
}
}]);
styles = _Module254.default.create({
row: {
flexDirection: "row"
}
});
export default r67;