{"version":3,"file":"index-WTf0UCpn.cjs","sources":["../../../node_modules/.pnpm/@radix-ui+react-presence@1.1.10_@types+react-dom@19.2.3_@types+react@19.2.14__@types+re_9b678092ad36c1d353c465dad28dc07f/node_modules/@radix-ui/react-presence/dist/index.mjs"],"sourcesContent":["\"use client\";\nvar __defProp = Object.defineProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\n\n// src/presence.tsx\nimport * as React2 from \"react\";\nimport { useLayoutEffect } from \"@radix-ui/react-use-layout-effect\";\n\n// src/use-state-machine.tsx\nimport * as React from \"react\";\nfunction useStateMachine(initialState, machine) {\n  return React.useReducer((state, event) => {\n    const nextState = machine[state][event];\n    return nextState ?? state;\n  }, initialState);\n}\n__name(useStateMachine, \"useStateMachine\");\n\n// src/presence.tsx\nvar Presence = /* @__PURE__ */ __name((props) => {\n  const { present, children } = props;\n  const presence = usePresence(present);\n  const child = typeof children === \"function\" ? children({ present: presence.isPresent }) : React2.Children.only(children);\n  const ref = useStableComposedRefs(presence.ref, getElementRef(child));\n  const forceMount = typeof children === \"function\";\n  return forceMount || presence.isPresent ? React2.cloneElement(child, { ref }) : null;\n}, \"Presence\");\nfunction usePresence(present) {\n  const [node, setNode] = React2.useState();\n  const stylesRef = React2.useRef(null);\n  const prevPresentRef = React2.useRef(present);\n  const prevAnimationNameRef = React2.useRef(\"none\");\n  const mountAnimationNameRef = React2.useRef(void 0);\n  const initialState = present ? \"mounted\" : \"unmounted\";\n  const [state, send] = useStateMachine(initialState, {\n    mounted: {\n      UNMOUNT: \"unmounted\",\n      ANIMATION_OUT: \"unmountSuspended\"\n    },\n    unmountSuspended: {\n      MOUNT: \"mounted\",\n      ANIMATION_END: \"unmounted\"\n    },\n    unmounted: {\n      MOUNT: \"mounted\"\n    }\n  });\n  React2.useEffect(() => {\n    if (state === \"mounted\") {\n      prevAnimationNameRef.current = mountAnimationNameRef.current ?? getAnimationName(stylesRef.current);\n      mountAnimationNameRef.current = void 0;\n    } else {\n      prevAnimationNameRef.current = \"none\";\n    }\n  }, [state]);\n  useLayoutEffect(() => {\n    const styles = stylesRef.current;\n    const wasPresent = prevPresentRef.current;\n    const hasPresentChanged = wasPresent !== present;\n    if (hasPresentChanged) {\n      const prevAnimationName = prevAnimationNameRef.current;\n      const currentAnimationName = getAnimationName(styles);\n      if (present) {\n        mountAnimationNameRef.current = currentAnimationName;\n        send(\"MOUNT\");\n      } else if (currentAnimationName === \"none\" || styles?.display === \"none\") {\n        send(\"UNMOUNT\");\n      } else {\n        const isAnimating = prevAnimationName !== currentAnimationName;\n        if (wasPresent && isAnimating) {\n          send(\"ANIMATION_OUT\");\n        } else {\n          send(\"UNMOUNT\");\n        }\n      }\n      prevPresentRef.current = present;\n    }\n  }, [present, send]);\n  useLayoutEffect(() => {\n    if (node) {\n      let timeoutId;\n      const ownerWindow = node.ownerDocument.defaultView ?? window;\n      const handleAnimationEnd = /* @__PURE__ */ __name((event) => {\n        const currentAnimationName = getAnimationName(stylesRef.current);\n        const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));\n        if (event.target === node && isCurrentAnimation) {\n          send(\"ANIMATION_END\");\n          if (!prevPresentRef.current) {\n            const currentFillMode = node.style.animationFillMode;\n            node.style.animationFillMode = \"forwards\";\n            timeoutId = ownerWindow.setTimeout(() => {\n              if (node.style.animationFillMode === \"forwards\") {\n                node.style.animationFillMode = currentFillMode;\n              }\n            });\n          }\n        }\n      }, \"handleAnimationEnd\");\n      const handleAnimationStart = /* @__PURE__ */ __name((event) => {\n        if (event.target === node) {\n          prevAnimationNameRef.current = getAnimationName(stylesRef.current);\n        }\n      }, \"handleAnimationStart\");\n      node.addEventListener(\"animationstart\", handleAnimationStart);\n      node.addEventListener(\"animationcancel\", handleAnimationEnd);\n      node.addEventListener(\"animationend\", handleAnimationEnd);\n      return () => {\n        ownerWindow.clearTimeout(timeoutId);\n        node.removeEventListener(\"animationstart\", handleAnimationStart);\n        node.removeEventListener(\"animationcancel\", handleAnimationEnd);\n        node.removeEventListener(\"animationend\", handleAnimationEnd);\n      };\n    } else {\n      send(\"ANIMATION_END\");\n    }\n  }, [node, send]);\n  return {\n    isPresent: [\"mounted\", \"unmountSuspended\"].includes(state),\n    ref: React2.useCallback((node2) => {\n      if (node2) {\n        const styles = getComputedStyle(node2);\n        stylesRef.current = styles;\n        mountAnimationNameRef.current = getAnimationName(styles);\n      } else {\n        stylesRef.current = null;\n      }\n      setNode(node2);\n    }, [])\n  };\n}\n__name(usePresence, \"usePresence\");\nfunction setRef(ref, value) {\n  if (typeof ref === \"function\") {\n    return ref(value);\n  } else if (ref !== null && ref !== void 0) {\n    ref.current = value;\n  }\n}\n__name(setRef, \"setRef\");\nfunction useStableComposedRefs(...refs) {\n  const refsRef = React2.useRef(refs);\n  refsRef.current = refs;\n  return React2.useCallback((node) => {\n    const currentRefs = refsRef.current;\n    let hasCleanup = false;\n    const cleanups = currentRefs.map((ref) => {\n      const cleanup = setRef(ref, node);\n      if (!hasCleanup && typeof cleanup === \"function\") {\n        hasCleanup = true;\n      }\n      return cleanup;\n    });\n    if (hasCleanup) {\n      return () => {\n        for (let i = 0; i < cleanups.length; i++) {\n          const cleanup = cleanups[i];\n          if (typeof cleanup === \"function\") {\n            cleanup();\n          } else {\n            setRef(currentRefs[i], null);\n          }\n        }\n      };\n    }\n  }, []);\n}\n__name(useStableComposedRefs, \"useStableComposedRefs\");\nfunction getAnimationName(styles) {\n  return styles?.animationName || \"none\";\n}\n__name(getAnimationName, \"getAnimationName\");\nfunction getElementRef(element) {\n  let getter = Object.getOwnPropertyDescriptor(element.props, \"ref\")?.get;\n  let mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n  if (mayWarn) {\n    return element.ref;\n  }\n  getter = Object.getOwnPropertyDescriptor(element, \"ref\")?.get;\n  mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n  if (mayWarn) {\n    return element.props.ref;\n  }\n  return element.props.ref || element.ref;\n}\n__name(getElementRef, \"getElementRef\");\nvar Root = Presence;\nexport {\n  Presence,\n  Root\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":["__defProp","__name","target","value","useStateMachine","initialState","machine","React","state","event","Presence","props","present","children","presence","usePresence","child","React2","ref","useStableComposedRefs","getElementRef","node","setNode","stylesRef","prevPresentRef","prevAnimationNameRef","mountAnimationNameRef","send","getAnimationName","useLayoutEffect","styles","wasPresent","prevAnimationName","currentAnimationName","timeoutId","ownerWindow","handleAnimationEnd","isCurrentAnimation","currentFillMode","handleAnimationStart","node2","setRef","refs","refsRef","currentRefs","hasCleanup","cleanups","cleanup","element","getter","_a","mayWarn","_b"],"mappings":"+WACA,IAAIA,EAAY,OAAO,eACnBC,EAAS,CAACC,EAAQC,IAAUH,EAAUE,EAAQ,OAAQ,CAAE,MAAAC,EAAO,aAAc,GAAM,EAQvF,SAASC,EAAgBC,EAAcC,EAAS,CAC9C,OAAOC,EAAM,WAAW,CAACC,EAAOC,IACZH,EAAQE,CAAK,EAAEC,CAAK,GAClBD,EACnBH,CAAY,CACjB,CACAJ,EAAOG,EAAiB,iBAAiB,EAGtC,IAACM,EAA2BT,EAAQU,GAAU,CAC/C,KAAM,CAAE,QAAAC,EAAS,SAAAC,CAAQ,EAAKF,EACxBG,EAAWC,EAAYH,CAAO,EAC9BI,EAAQ,OAAOH,GAAa,WAAaA,EAAS,CAAE,QAASC,EAAS,SAAS,CAAE,EAAIG,EAAO,SAAS,KAAKJ,CAAQ,EAClHK,EAAMC,EAAsBL,EAAS,IAAKM,EAAcJ,CAAK,CAAC,EAEpE,OADmB,OAAOH,GAAa,YAClBC,EAAS,UAAYG,EAAO,aAAaD,EAAO,CAAE,IAAAE,CAAG,CAAE,EAAI,IAClF,EAAG,UAAU,EACb,SAASH,EAAYH,EAAS,CAC5B,KAAM,CAACS,EAAMC,CAAO,EAAIL,EAAO,SAAQ,EACjCM,EAAYN,EAAO,OAAO,IAAI,EAC9BO,EAAiBP,EAAO,OAAOL,CAAO,EACtCa,EAAuBR,EAAO,OAA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