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AAC,iBAAiB,CAAC,UAAU;oBAC9B,CAAC,CAAC,iBAAiB,CAAC,QAAQ;aAC/B;YACH,CAAC,CAAC,IAAI,CAAC;QAEX,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,QAC3B,CAAC,YAA8C,EAAE,EAAE;YAClD,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,IAAI,YAAY,CAAC,eAAe,CAAC,CAAC;YAC3E,OAAO,CACL,oBAAC,mBAAmB,oBACd,KAAK,EACL,qBAAqB,IACzB,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,EAChC,eAAe,EAAE,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,IAClD,CACH,CAAC;QACJ,CAAC,CAC6B,CACjC,CAAC;IACJ,CAAC;;AA5CM,0BAAY,GAAG;IACpB,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,YAAY;CAC1B,CAAC;AA8CJ,iGAAiG;AACjG,MAAM,CAAC,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { requireNativeViewManager } from '@unimodules/core';\nimport nullthrows from 'nullthrows';\nimport React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { AdOptionsViewContext, AdOptionsViewContextValue } from './withNativeAd';\n\nenum NativeOrientation {\n Horizontal = 0,\n Vertical = 1,\n}\n\ntype Props = React.ComponentProps<typeof View> & {\n iconSize: number;\n iconColor?: string;\n orientation: 'horizontal' | 'vertical';\n};\n\nexport default class AdOptionsView extends React.Component<Props> {\n static defaultProps = {\n iconSize: 23,\n orientation: 'horizontal',\n };\n\n shouldAlignHorizontal = () => this.props.orientation === 'horizontal';\n\n render() {\n const style = this.shouldAlignHorizontal()\n ? {\n width: this.props.iconSize * 2,\n height: this.props.iconSize,\n }\n : {\n width: this.props.iconSize,\n height: this.props.iconSize * 2,\n };\n\n const { iconSize, orientation, ...props } = this.props;\n const platformSpecificProps =\n Platform.OS === 'android'\n ? {\n iconSize,\n orientation: this.shouldAlignHorizontal()\n ? NativeOrientation.Horizontal\n : NativeOrientation.Vertical,\n }\n : null;\n\n return (\n <AdOptionsViewContext.Consumer>\n {(contextValue: AdOptionsViewContextValue | null) => {\n const adViewRef = nullthrows(contextValue && contextValue.nativeAdViewRef);\n return (\n <NativeAdOptionsView\n {...props}\n {...platformSpecificProps}\n style={[this.props.style, style]}\n nativeAdViewTag={findNodeHandle(adViewRef.current)}\n />\n );\n }}\n </AdOptionsViewContext.Consumer>\n );\n }\n}\n\n// The native AdOptionsView has the same props as regular View\nexport type NativeAdOptionsView = React.Component<Props>;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- the type and variable share a name\nexport const NativeAdOptionsView = requireNativeViewManager('AdOptionsView');\n"]}
\No newline at end of file