import { useEmberService } from '../hooks/use-ember-service.js';
import { Link } from './link.jsx';
import { jsx } from 'react/jsx-runtime';

function NavLink({
  'aria-current': ariaCurrentProp = 'page',
  children,
  className: classNameProp,
  to,
  style: styleProp,
  ...props
}) {
  let className;
  const router = useEmberService('router');
  const locationPathname = router.currentURL;
  const isActive = locationPathname === to;
  const ariaCurrent = isActive ? ariaCurrentProp : undefined;
  const renderProps = {
    isActive
  };
  if (typeof classNameProp === 'function') {
    className = classNameProp(renderProps);
  } else {
    className = [classNameProp, isActive ? 'active' : null].filter(Boolean).join(' ');
  }
  const style = typeof styleProp === 'function' ? styleProp(renderProps) : styleProp;
  return /*#__PURE__*/jsx(Link, {
    "aria-current": ariaCurrent,
    className: className,
    style: style,
    to: to,
    ...props,
    children: typeof children === 'function' ? children(renderProps) : children
  });
}

export { NavLink };
//# sourceMappingURL=nav-link.jsx.map
