{"version":3,"file":"usePathname.cjs","names":["useState","useMemo","getPathWithoutLocale"],"sources":["../../../src/client/usePathname.ts"],"sourcesContent":["'use client';\n\nimport { getPathWithoutLocale } from '@intlayer/core/localization';\nimport { useEffect, useMemo, useState } from 'react';\n\n/**\n * React hook that returns the current pathname with the locale segment removed.\n *\n * Reacts to browser back/forward navigation via the `popstate` event.\n * Falls back to an empty string during server-side rendering.\n *\n * @returns The current pathname without the locale prefix.\n *\n * @example\n * ```tsx\n * import { usePathname } from 'react-intlayer';\n *\n * const NavItem = ({ href }: { href: string }) => {\n *   const pathname = usePathname();\n *   return <a className={pathname === href ? 'active' : ''}>{href}</a>;\n * };\n * ```\n */\nexport const usePathname = (): string => {\n  const [rawPathname, setRawPathname] = useState<string>(\n    typeof window !== 'undefined' ? window.location.pathname : ''\n  );\n\n  useEffect(() => {\n    const handleLocationChange = (): void => {\n      setRawPathname(window.location.pathname);\n    };\n\n    window.addEventListener('popstate', handleLocationChange);\n    return () => window.removeEventListener('popstate', handleLocationChange);\n  }, []);\n\n  return useMemo(() => getPathWithoutLocale(rawPathname), [rawPathname]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,oBAA4B;CACvC,MAAM,CAAC,aAAa,sBAAkBA,gBACpC,OAAO,WAAW,cAAc,OAAO,SAAS,WAAW,EAC7D;CAEA,2BAAgB;EACd,MAAM,6BAAmC;GACvC,eAAe,OAAO,SAAS,QAAQ;EACzC;EAEA,OAAO,iBAAiB,YAAY,oBAAoB;EACxD,aAAa,OAAO,oBAAoB,YAAY,oBAAoB;CAC1E,GAAG,CAAC,CAAC;CAEL,WAAOC,yBAAcC,kDAAqB,WAAW,GAAG,CAAC,WAAW,CAAC;AACvE"}