{"version":3,"file":"usePathname.cjs","names":["useNextPathname","useState","useMemo","getPathWithoutLocale"],"sources":["../../../src/client/usePathname.ts"],"sourcesContent":["'use client';\n\nimport { getPathWithoutLocale } from '@intlayer/core/localization';\nimport { usePathname as useNextPathname } from 'next/navigation.js';\nimport { useEffect, useMemo, useState } from 'react';\n\n/**\n * Next.js hook that returns the current pathname with the locale segment removed.\n *\n * Wraps Next.js `usePathname()` so it re-renders on client navigations and\n * appends any search parameters before stripping the locale prefix.\n *\n * @returns The current pathname without the locale prefix.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { usePathname } from 'next-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 nextPathname = useNextPathname();\n  const [searchParams, setSearchParams] = useState<string>('');\n\n  useEffect(() => {\n    const search = typeof window !== 'undefined' ? window.location.search : '';\n    setSearchParams(search);\n  }, [nextPathname]);\n\n  const fullPath = searchParams\n    ? `${nextPathname}${searchParams}`\n    : nextPathname;\n\n  return useMemo(() => getPathWithoutLocale(fullPath), [fullPath]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAA4B;CACvC,MAAM,mBAAeA,gCAAgB;CACrC,MAAM,CAAC,cAAc,uBAAmBC,gBAAiB,EAAE;CAE3D,2BAAgB;EACd,MAAM,SAAS,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS;EACxE,gBAAgB,MAAM;CACxB,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,WAAW,eACb,GAAG,eAAe,iBAClB;CAEJ,WAAOC,yBAAcC,kDAAqB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACjE"}