// Metro module 10970 (f10971). import { createElement, useRef, useEffect } from "react"; import AppStateStore from "../../../stores/native/AppStateStore"; import { MIN_QUEST_CONTENT_VISIBILITY_PERCENTAGE } from "../lib/analytics/ContentImpressionTrackerConstants"; import { AppStates } from "../../../Constants"; import { useRecyclingState } from "../../../_bundle/noop_6676"; import usePrevious from "../../../hooks/usePrevious"; import { useStateFromStores } from "../../../_bundle/Module589"; import { useAdContentImpressionTrackerProps } from "../lib/analytics/ContentImpressionTrackerHooks"; import { QuestContentImpressionTracker } from "../lib/analytics/ContentImpressionTracker"; import { AdCreativeType } from "../../../_bundle/Module6013"; const AdContentImpressionTrackerBaseNative = function AdContentImpressionTrackerBaseNative(a0) { let r81; let adContentIds, visibilityRef, setVisible; const focused = useStateFromStores([AppStateStore], () => AppStateStore.getState()) === AppStates.ACTIVE; const ref = useRef(null); const previous = usePrevious(focused); const adContentImpressionTrackerProps = useAdContentImpressionTrackerProps(a0); const { key, adContentIds: adContentIds2 } = adContentImpressionTrackerProps; const r13 = { ...a0, adContentIds: adContentIds2 }; adContentIds = void 0; visibilityRef = void 0; adContentIds = r13.adContentIds; visibilityRef = r13.visibilityRef; let overrideVisibility = r13.overrideVisibility; setVisible = void 0; let r49; [r49, setVisible] = useRecyclingState(false, [adContentIds.join("_")]); useEffect(() => { (function initHandlers({ adContentIds: adContentIds2, setVisible: setVisible2, visibilityRef: visibilityRef2 }) { if (visibilityRef2 != null) { const _loop = function _loop(a0) { visibilityRef2.current.children[a0] = { ...visibilityRef2.current.children[a0], calculateVisibility: function calculateVisibility() { let r24, r39, r47, width; const r3 = visibilityRef2 == null; let r13 = void 0; if (!r3) { const current = visibilityRef2.current; const r18 = current == null; r13 = void 0; if (!r18) { const children2 = current.children; r13 = children2 == null ? void 0 : children2[a0]; } } const layout = r13?.layout; L21: { const r23 = layout == null; r24 = 0; if (!r23) { const r29 = (visibilityRef2 == null ? void 0 : visibilityRef2.current.parent?.layout) == null; r24 = 0; if (!r29) { let axis = visibilityRef2.current.axis; if (axis == null) { axis = "vertical"; } if (axis === "horizontal") { const r60 = visibilityRef2.current.parent.scrollX == null; r24 = 0; if (r60) { break L21; } const r62 = [r13.layout.x, r13.layout.x + r13.layout.width]; const r70 = [visibilityRef2.current.parent.scrollX, visibilityRef2.current.parent.scrollX + visibilityRef2.current.parent.layout.width]; width = r13.layout.width; r47 = r70; r39 = r62; } else { const r36 = visibilityRef2.current.parent.scrollY == null; r24 = 0; if (r36) { break L21; } r39 = [r13.layout.y, r13.layout.y + r13.layout.height]; r47 = [visibilityRef2.current.parent.scrollY, visibilityRef2.current.parent.scrollY + visibilityRef2.current.parent.layout.height]; width = r13.layout.height; } if (visibilityRef2.current.parent.firstItemOffset != null) { const firstItemOffset = visibilityRef2.current.parent.firstItemOffset; r39[0] = r39[0] + firstItemOffset; r39[1] = r39[1] + firstItemOffset; } const r94 = Math.max(r39[0], r47[0]); r24 = Math.min(Math.max(0, Math.min(r39[1], r47[1]) - r94) / width, 1); } } } setVisible2(r24 >= MIN_QUEST_CONTENT_VISIBILITY_PERCENTAGE); } }; }; for (const item of adContentIds2) { _loop(item); } } })({ adContentIds, setVisible, visibilityRef }); const children = visibilityRef == null ? void 0 : visibilityRef.current?.children; return () => { if (children != null) { for (const adContentId of adContentIds) { const r16 = children[adContentId]; if (r16 != null) { r16.calculateVisibility = void 0; } } } }; }, [adContentIds, setVisible, visibilityRef]); if (overrideVisibility == null) { overrideVisibility = r49; } const r60 = { ...a0, ...{ visible: overrideVisibility, visibleChanged: overrideVisibility !== usePrevious(overrideVisibility) }, focused, focusedChanged: focused !== previous, reference: ref, isFocused: focused }; const key2 = a0.skipRemountKey ? void 0 : key; const r75 = "questOrQuests" in a0; const r76 = { ...r60, key: key2, adContentIds: adContentIds2 }; if (r75) { r76.adCreativeType = AdCreativeType.QUEST; r81 = r76; } else { r76.adCreativeType = a0.adCreativeType; r81 = r76; } return createElement(QuestContentImpressionTracker, r81); }; export function QuestContentImpressionTrackerNative(props) { return ; } export function BillableAdPlacementImpressionTrackerNative(props) { return ; }