{"ast":null,"code":"import { Children as $iqq3r$Children, cloneElement as $iqq3r$cloneElement, useState as $iqq3r$useState, useRef as $iqq3r$useRef, useEffect as $iqq3r$useEffect, useCallback as $iqq3r$useCallback, useReducer as $iqq3r$useReducer } from \"react\";\nimport { flushSync as $iqq3r$flushSync } from \"react-dom\";\nimport { useComposedRefs as $iqq3r$useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { useLayoutEffect as $iqq3r$useLayoutEffect } from \"@radix-ui/react-use-layout-effect\";\nfunction $fe963b355347cc68$export$3e6543de14f8614f(initialState, machine) {\n  return $iqq3r$useReducer((state, event) => {\n    const nextState = machine[state][event];\n    return nextState !== null && nextState !== void 0 ? nextState : state;\n  }, initialState);\n}\nconst $921a889cee6df7e8$export$99c2b779aa4e8b8b = props => {\n  const {\n    present: present,\n    children: children\n  } = props;\n  const presence = $921a889cee6df7e8$var$usePresence(present);\n  const child = typeof children === 'function' ? children({\n    present: presence.isPresent\n  }) : $iqq3r$Children.only(children);\n  const ref = $iqq3r$useComposedRefs(presence.ref, child.ref);\n  const forceMount = typeof children === 'function';\n  return forceMount || presence.isPresent ? /*#__PURE__*/$iqq3r$cloneElement(child, {\n    ref: ref\n  }) : null;\n};\n$921a889cee6df7e8$export$99c2b779aa4e8b8b.displayName = 'Presence';\n/* -------------------------------------------------------------------------------------------------\n * usePresence\n * -----------------------------------------------------------------------------------------------*/\nfunction $921a889cee6df7e8$var$usePresence(present) {\n  const [node1, setNode] = $iqq3r$useState();\n  const stylesRef = $iqq3r$useRef({});\n  const prevPresentRef = $iqq3r$useRef(present);\n  const prevAnimationNameRef = $iqq3r$useRef('none');\n  const initialState = present ? 'mounted' : 'unmounted';\n  const [state, send] = $fe963b355347cc68$export$3e6543de14f8614f(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  $iqq3r$useEffect(() => {\n    const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n    prevAnimationNameRef.current = state === 'mounted' ? currentAnimationName : 'none';\n  }, [state]);\n  $iqq3r$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 = $921a889cee6df7e8$var$getAnimationName(styles);\n      if (present) send('MOUNT');else if (currentAnimationName === 'none' || (styles === null || styles === void 0 ? void 0 : styles.display) === 'none')\n        // If there is no exit animation or the element is hidden, animations won't run\n        // so we unmount instantly\n        send('UNMOUNT');else {\n        /**\n        * When `present` changes to `false`, we check changes to animation-name to\n        * determine whether an animation has started. We chose this approach (reading\n        * computed styles) because there is no `animationrun` event and `animationstart`\n        * fires after `animation-delay` has expired which would be too late.\n        */\n        const isAnimating = prevAnimationName !== currentAnimationName;\n        if (wasPresent && isAnimating) send('ANIMATION_OUT');else send('UNMOUNT');\n      }\n      prevPresentRef.current = present;\n    }\n  }, [present, send]);\n  $iqq3r$useLayoutEffect(() => {\n    if (node1) {\n      /**\n      * Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n      * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n      * make sure we only trigger ANIMATION_END for the currently active animation.\n      */\n      const handleAnimationEnd = event => {\n        const currentAnimationName = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n        const isCurrentAnimation = currentAnimationName.includes(event.animationName);\n        if (event.target === node1 && isCurrentAnimation)\n          // With React 18 concurrency this update is applied\n          // a frame after the animation ends, creating a flash of visible content.\n          // By manually flushing we ensure they sync within a frame, removing the flash.\n          $iqq3r$flushSync(() => send('ANIMATION_END'));\n      };\n      const handleAnimationStart = event => {\n        if (event.target === node1)\n          // if animation occurred, store its name as the previous animation.\n          prevAnimationNameRef.current = $921a889cee6df7e8$var$getAnimationName(stylesRef.current);\n      };\n      node1.addEventListener('animationstart', handleAnimationStart);\n      node1.addEventListener('animationcancel', handleAnimationEnd);\n      node1.addEventListener('animationend', handleAnimationEnd);\n      return () => {\n        node1.removeEventListener('animationstart', handleAnimationStart);\n        node1.removeEventListener('animationcancel', handleAnimationEnd);\n        node1.removeEventListener('animationend', handleAnimationEnd);\n      };\n    } else\n      // Transition to the unmounted state if the node is removed prematurely.\n      // We avoid doing so during cleanup as the node may change but still exist.\n      send('ANIMATION_END');\n  }, [node1, send]);\n  return {\n    isPresent: ['mounted', 'unmountSuspended'].includes(state),\n    ref: $iqq3r$useCallback(node => {\n      if (node) stylesRef.current = getComputedStyle(node);\n      setNode(node);\n    }, [])\n  };\n}\n/* -----------------------------------------------------------------------------------------------*/\nfunction $921a889cee6df7e8$var$getAnimationName(styles) {\n  return (styles === null || styles === void 0 ? void 0 : styles.animationName) || 'none';\n}\nexport { $921a889cee6df7e8$export$99c2b779aa4e8b8b as Presence };","map":{"version":3,"names":["$fe963b355347cc68$export$3e6543de14f8614f","useStateMachine","initialState","machine","$iqq3r$useReducer","state","event","nextState","$921a889cee6df7e8$export$99c2b779aa4e8b8b","props","present","children","presence","$921a889cee6df7e8$var$usePresence","child","isPresent","$iqq3r$Children","only","ref","$iqq3r$useComposedRefs","forceMount","$iqq3r$cloneElement","displayName","usePresence","node1","setNode","$iqq3r$useState","stylesRef","$iqq3r$useRef","prevPresentRef","prevAnimationNameRef","send","mounted","UNMOUNT","ANIMATION_OUT","unmountSuspended","MOUNT","ANIMATION_END","unmounted","$iqq3r$useEffect","currentAnimationName","$921a889cee6df7e8$var$getAnimationName","current","$iqq3r$useLayoutEffect","styles","wasPresent","hasPresentChanged","prevAnimationName","display","isAnimating","handleAnimationEnd","isCurrentAnimation","includes","animationName","target","$iqq3r$flushSync","handleAnimationStart","addEventListener","removeEventListener","$iqq3r$useCallback","node","getComputedStyle","getAnimationName"],"sources":["C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\index.ts","C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\Presence.tsx","C:\\Users\\user\\Desktop\\03portreact\\node_modules\\@radix-ui\\react-presence\\dist\\packages\\react\\presence\\src\\useStateMachine.tsx"],"sourcesContent":["export { Presence } from './Presence';\nexport type { PresenceProps } from './Presence';\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { useStateMachine } from './useStateMachine';\n\ninterface PresenceProps {\n  children: React.ReactElement | ((props: { present: boolean }) => React.ReactElement);\n  present: boolean;\n}\n\nconst Presence: React.FC<PresenceProps> = (props) => {\n  const { present, children } = props;\n  const presence = usePresence(present);\n\n  const child = (\n    typeof children === 'function'\n      ? children({ present: presence.isPresent })\n      : React.Children.only(children)\n  ) as React.ReactElement;\n\n  const ref = useComposedRefs(presence.ref, (child as any).ref);\n  const forceMount = typeof children === 'function';\n  return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;\n};\n\nPresence.displayName = 'Presence';\n\n/* -------------------------------------------------------------------------------------------------\n * usePresence\n * -----------------------------------------------------------------------------------------------*/\n\nfunction usePresence(present: boolean) {\n  const [node, setNode] = React.useState<HTMLElement>();\n  const stylesRef = React.useRef<CSSStyleDeclaration>({} as any);\n  const prevPresentRef = React.useRef(present);\n  const prevAnimationNameRef = React.useRef<string>('none');\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\n  React.useEffect(() => {\n    const currentAnimationName = getAnimationName(stylesRef.current);\n    prevAnimationNameRef.current = state === 'mounted' ? currentAnimationName : 'none';\n  }, [state]);\n\n  useLayoutEffect(() => {\n    const styles = stylesRef.current;\n    const wasPresent = prevPresentRef.current;\n    const hasPresentChanged = wasPresent !== present;\n\n    if (hasPresentChanged) {\n      const prevAnimationName = prevAnimationNameRef.current;\n      const currentAnimationName = getAnimationName(styles);\n\n      if (present) {\n        send('MOUNT');\n      } else if (currentAnimationName === 'none' || styles?.display === 'none') {\n        // If there is no exit animation or the element is hidden, animations won't run\n        // so we unmount instantly\n        send('UNMOUNT');\n      } else {\n        /**\n         * When `present` changes to `false`, we check changes to animation-name to\n         * determine whether an animation has started. We chose this approach (reading\n         * computed styles) because there is no `animationrun` event and `animationstart`\n         * fires after `animation-delay` has expired which would be too late.\n         */\n        const isAnimating = prevAnimationName !== currentAnimationName;\n\n        if (wasPresent && isAnimating) {\n          send('ANIMATION_OUT');\n        } else {\n          send('UNMOUNT');\n        }\n      }\n\n      prevPresentRef.current = present;\n    }\n  }, [present, send]);\n\n  useLayoutEffect(() => {\n    if (node) {\n      /**\n       * Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n       * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n       * make sure we only trigger ANIMATION_END for the currently active animation.\n       */\n      const handleAnimationEnd = (event: AnimationEvent) => {\n        const currentAnimationName = getAnimationName(stylesRef.current);\n        const isCurrentAnimation = currentAnimationName.includes(event.animationName);\n        if (event.target === node && isCurrentAnimation) {\n          // With React 18 concurrency this update is applied\n          // a frame after the animation ends, creating a flash of visible content.\n          // By manually flushing we ensure they sync within a frame, removing the flash.\n          ReactDOM.flushSync(() => send('ANIMATION_END'));\n        }\n      };\n      const handleAnimationStart = (event: AnimationEvent) => {\n        if (event.target === node) {\n          // if animation occurred, store its name as the previous animation.\n          prevAnimationNameRef.current = getAnimationName(stylesRef.current);\n        }\n      };\n      node.addEventListener('animationstart', handleAnimationStart);\n      node.addEventListener('animationcancel', handleAnimationEnd);\n      node.addEventListener('animationend', handleAnimationEnd);\n      return () => {\n        node.removeEventListener('animationstart', handleAnimationStart);\n        node.removeEventListener('animationcancel', handleAnimationEnd);\n        node.removeEventListener('animationend', handleAnimationEnd);\n      };\n    } else {\n      // Transition to the unmounted state if the node is removed prematurely.\n      // We avoid doing so during cleanup as the node may change but still exist.\n      send('ANIMATION_END');\n    }\n  }, [node, send]);\n\n  return {\n    isPresent: ['mounted', 'unmountSuspended'].includes(state),\n    ref: React.useCallback((node: HTMLElement) => {\n      if (node) stylesRef.current = getComputedStyle(node);\n      setNode(node);\n    }, []),\n  };\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getAnimationName(styles?: CSSStyleDeclaration) {\n  return styles?.animationName || 'none';\n}\n\nexport { Presence };\nexport type { PresenceProps };\n","import * as React from 'react';\n\ntype Machine<S> = { [k: string]: { [k: string]: S } };\ntype MachineState<T> = keyof T;\ntype MachineEvent<T> = keyof UnionToIntersection<T[keyof T]>;\n\n// 🤯 https://fettblog.eu/typescript-union-to-intersection/\ntype UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any\n  ? R\n  : never;\n\nexport function useStateMachine<M>(\n  initialState: MachineState<M>,\n  machine: M & Machine<MachineState<M>>\n) {\n  return React.useReducer((state: MachineState<M>, event: MachineEvent<M>): MachineState<M> => {\n    const nextState = (machine[state] as any)[event];\n    return nextState ?? state;\n  }, initialState);\n}\n"],"mappings":";;;;AEWO,SAASA,yCAATC,CACLC,YADK,EAELC,OAFK,EAGL;EACA,OAAOC,iBAAA,CAAiB,CAACC,KAAD,EAAyBC,KAAzB,KAAqE;IAC3F,MAAMC,SAAS,GAAIJ,OAAO,CAACE,KAAD,CAAR,CAAwBC,KAAxB,CAAlB;IACA,OAAOC,SAAP,aAAOA,SAAP,cAAOA,SAAP,GAAoBF,KAApB;GAFK,EAGJH,YAHI,CAAP;;ADJF,MAAMM,yCAAiC,GAAIC,KAAD,IAAW;EACnD,MAA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