{"version":3,"sources":["../src/presence/index.native.tsx"],"names":["useState","useRef","Animated","useReducedMotion","useEffect","motion","Easing","jsx"],"mappings":";;;;;;;;;AAsCA,IAAM,YAAA,GAA6B,EAAE,OAAA,EAAS,CAAA,EAAG,YAAY,CAAA,EAAE;AAExD,SAAS,QAAA,CAAS;AAAA,EACvB,OAAA;AAAA,EACA,IAAA,GAAO,YAAA;AAAA,EACP,QAAA;AAAA,EACA,cAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAAkB;AAChB,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAIA,eAAkB,OAAO,CAAA;AAEvD,EAAA,MAAM,QAAA,GAAWC,aAAO,IAAIC,oBAAA,CAAS,MAAM,OAAA,GAAU,CAAA,GAAI,CAAC,CAAC,CAAA,CAAE,OAAA;AAC7D,EAAA,MAAM,UAAUC,sBAAA,EAAiB;AAEjC,EAAA,MAAM,SAASF,YAAA,CAAO,EAAE,MAAM,QAAA,EAAU,cAAA,EAAgB,SAAS,CAAA;AACjE,EAAA,MAAA,CAAO,OAAA,GAAU,EAAE,IAAA,EAAM,QAAA,EAAU,gBAAgB,OAAA,EAAQ;AAE3D,EAAA,IAAI,OAAA,IAAW,CAAC,OAAA,EAAS,UAAA,CAAW,IAAI,CAAA;AAExC,EAAAG,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,IAAI,MAAA,CAAO,OAAA;AACjB,IAAA,MAAM,OAAO,OAAA,GAAUC,WAAA,CAAO,YAAA,CAAa,QAAA,GAAWA,YAAO,WAAA,CAAY,QAAA;AACzE,IAAA,MAAM,IAAA,GAAOH,oBAAA,CAAS,MAAA,CAAO,QAAA,EAAU;AAAA,MACrC,OAAA,EAAS,UAAU,CAAA,GAAI,CAAA;AAAA,MACvB,QAAA,EAAU,CAAA,CAAE,OAAA,GAAU,EAAA,GAAM,EAAE,QAAA,IAAY,IAAA;AAAA,MAC1C,MAAA,EAAQI,kBAAA,CAAO,GAAA,CAAIA,kBA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3F;AAEJ,EAAA,uBACEC,cAAA;AAAA,IAACL,oBAAA,CAAS,IAAA;AAAA,IAAT;AAAA,MACC,KAAA,EAAO;AAAA,QACL,KAAA;AAAA,QACA;AAAA,UACE,OAAA,EAAS,KAAK,OAAA,KAAY,MAAA,GAAY,MAAM,IAAA,CAAK,OAAA,EAAS,CAAC,CAAA,GAAI,CAAA;AAAA,UAC/D;AAAA;AACF,OACF;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"presence.native.cjs","sourcesContent":["/**\n * Presence (native). Mount/unmount transition primitive — same contract\n * as web: children stay mounted while the exit animation runs, then\n * unmount and `onExitComplete` fires.\n *\n *   <Presence present={open}>{panel}</Presence>\n *   <Presence present={open} from={{ opacity: 0, scale: 0.98 }}>{panel}</Presence>\n *\n * Divergence from web: animates with RN Animated.timing, so the `easing`\n * prop (a CSS string on web) is ignored here — native uses Easing.out(cubic),\n * the closest match to the motion tokens' out curves. `duration` is honored.\n * Reduced motion (AccessibilityInfo) collapses to a fast opacity-only fade.\n */\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { Animated, Easing, type ViewStyle } from \"react-native\";\nimport { motion } from \"@plyxui/core\";\nimport { useReducedMotion } from \"@plyxui/hooks\";\n\nexport interface PresenceFrom {\n  opacity?: number;\n  translateX?: number;\n  translateY?: number;\n  scale?: number;\n}\n\nexport interface PresenceProps {\n  present: boolean;\n  /** Hidden pose the content enters from and exits to. Default `{ opacity: 0, translateY: 8 }`. */\n  from?: PresenceFrom;\n  /** Override duration (ms) for both enter and exit. Defaults to the motion tokens. */\n  duration?: number;\n  /** Accepted for API parity with web; ignored on native (see header). */\n  easing?: string;\n  onExitComplete?: () => void;\n  style?: ViewStyle;\n  children?: ReactNode;\n}\n\nconst DEFAULT_FROM: PresenceFrom = { opacity: 0, translateY: 8 };\n\nexport function Presence({\n  present,\n  from = DEFAULT_FROM,\n  duration,\n  onExitComplete,\n  style,\n  children,\n}: PresenceProps) {\n  const [mounted, setMounted] = useState<boolean>(present);\n  // 0 = hidden pose, 1 = identity. One driver interpolates every property.\n  const progress = useRef(new Animated.Value(present ? 1 : 0)).current;\n  const reduced = useReducedMotion();\n\n  const latest = useRef({ from, duration, onExitComplete, reduced });\n  latest.current = { from, duration, onExitComplete, reduced };\n\n  if (present && !mounted) setMounted(true);\n\n  useEffect(() => {\n    const l = latest.current;\n    const base = present ? motion.overlayEnter.duration : motion.overlayExit.duration;\n    const anim = Animated.timing(progress, {\n      toValue: present ? 1 : 0,\n      duration: l.reduced ? 50 : (l.duration ?? base),\n      easing: Easing.out(Easing.cubic),\n      useNativeDriver: true,\n    });\n    anim.start(({ finished }) => {\n      if (finished && !present) {\n        setMounted(false);\n        latest.current.onExitComplete?.();\n      }\n    });\n    return () => anim.stop();\n  }, [present, progress]);\n\n  if (!mounted) return null;\n\n  const pose = latest.current.reduced ? { opacity: 0 } : from;\n  const range = (hidden: number, shown: number) =>\n    progress.interpolate({ inputRange: [0, 1], outputRange: [hidden, shown] });\n\n  const transform: ViewStyle[\"transform\"] = latest.current.reduced\n    ? []\n    : [\n        ...(pose.translateX !== undefined\n          ? [{ translateX: range(pose.translateX, 0) as unknown as number }]\n          : []),\n        ...(pose.translateY !== undefined\n          ? [{ translateY: range(pose.translateY, 0) as unknown as number }]\n          : []),\n        ...(pose.scale !== undefined ? [{ scale: range(pose.scale, 1) as unknown as number }] : []),\n      ];\n\n  return (\n    <Animated.View\n      style={[\n        style,\n        {\n          opacity: pose.opacity !== undefined ? range(pose.opacity, 1) : 1,\n          transform,\n        },\n      ]}\n    >\n      {children}\n    </Animated.View>\n  );\n}\n"]}