{"version":3,"file":"link.cjs","names":["Solid","_isRouteDeparting","deepEqual","functionalUpdate","getUrlScheme","hasKeys","isDangerousProtocol","preloadWarning","removeTrailingSlash","isServer","Dynamic","useRouter","nearestMatchContext","useIntersectionObserver","useHydrated","AnyRouter","Constrain","LinkOptions","ParsedLocation","RegisteredRouter","RoutePaths","ValidateLinkOptions","ValidateLinkOptionsArray","useLinkProps","TRouter","TFrom","options","UseLinkPropsOptions","TTo","TMaskFrom","TMaskTo","ComponentProps","createLinkProps","LINK_OPTION_KEYS","ownKeys","ReadonlyArray","router","propsSafeToSpread","splitProps","Array","routeId","useContext","currentLocation","stores","location","get","createMemo","prev","getDest","dest","key","NAVIGATION_KEYS","value","isStore","Object","values","some","hasHydrated","ssr","undefined","getLinkState","LinkState","to","disabled","scheme","href","external","active","protocolAllowlist","has","process","env","NODE_ENV","console","warn","options_","_fromLocation","next","untrack","buildLocation","shown","maskedLocation","publicHref","shownHref","history","createHref","activeOptions","currentPath","pathname","basepath","nextPath","exact","startsWith","length","includeSearch","search","explicitUndefined","includeHash","hash","linkState","ResolvedLinkStateProps","Omit","style","JSX","CSSProperties","resolveLinkStateProps","base","target","assign","STATIC_DISABLED_PROPS","activeProps","inactiveProps","class","STATIC_DEFAULT_ACTIVE_ATTRIBUTES","stateProps","STATIC_ACTIVE_PROPS","EMPTY_OBJECT","baseStyle","stateStyle","baseClass","stateClass","className","STATIC_ACTIVE_ATTRIBUTES","props","onClick","onBlur","onFocus","onMouseEnter","onMouseLeave","onMouseOut","onMouseOver","onTouchStart","ref","STATIC_EVENT_PROPS","mergeProps","hasRenderFetched","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","doPreload","preloadRoute","catch","err","setRef","createSignal","Element","preloadTimeout","ReturnType","setTimeout","cancelPreload","clearTimeout","enqueuePreload","e","MouseEvent","FocusEvent","IntersectionObserverEntry","isIntersecting","createEffect","handleClick","elementTarget","currentTarget","HTMLAnchorElement","SVGAElement","getAttribute","effectiveTarget","metaKey","altKey","ctrlKey","shiftKey","defaultPrevented","button","preventDefault","navigate","handleTouchStart","handleLeave","createComposedHandler","linkRef","el","resolved","resolvedProps","$PROXY","const","LINK_ELEMENT_KEYS","role","callHandler","Event","event","TEvent","T","handler","EventHandlerUnion","getHandler","fallback","ActiveLinkOptions","ActiveLinkOptionProps","TComp","ActiveLinkProps","Partial","LinkComponentSolidProps","LinkProps","LinkPropsChildren","children","state","isActive","ValidComponent","CreateLinkProps","LinkComponentProps","LinkComponent","TDefaultFrom","LinkComponentRoute","defaultFrom","createLink","Comp","_$createComponent","Link","_$mergeProps","_asChild","local","linkProps","ch","_","svgLinkProps","_el$","_tmpl$","_el$2","firstChild","_$spread","_$insert","_el$3","_tmpl$2","memo","component","LinkOptionsFnOptions","TOptions","LinkOptionsFn","linkOptions","useRouter","Solid","nearestMatchContext","isServer","_isRouteDeparting","useHydrated","getUrlScheme","isDangerousProtocol","removeTrailingSlash","deepEqual","functionalUpdate","hasKeys","preloadWarning","_$createComponent","_$mergeProps","Dynamic"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport {\n  _isRouteDeparting,\n  deepEqual,\n  functionalUpdate,\n  getUrlScheme,\n  hasKeys,\n  isDangerousProtocol,\n  preloadWarning,\n  removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouter } from './useRouter'\nimport { nearestMatchContext } from './matchContext'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useHydrated } from './ClientOnly'\nimport type {\n  AnyRouter,\n  Constrain,\n  LinkOptions,\n  ParsedLocation,\n  RegisteredRouter,\n  RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n  ValidateLinkOptions,\n  ValidateLinkOptionsArray,\n} from './typePrimitives'\n\nexport function useLinkProps<\n  TRouter extends AnyRouter = RegisteredRouter,\n  TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n  TTo extends string = '',\n  TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n  TMaskTo extends string = '',\n>(\n  options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): Solid.ComponentProps<'a'> {\n  return createLinkProps(options as any, LINK_OPTION_KEYS)\n}\n\n// `ownKeys` are the options that never reach the element.\nfunction createLinkProps(\n  options: UseLinkPropsOptions,\n  ownKeys: ReadonlyArray<string>,\n): Solid.ComponentProps<'a'> {\n  const router = useRouter()\n  // Options are read directly: one props proxy, no merged-default getters.\n  const [, propsSafeToSpread] = Solid.splitProps(\n    options,\n    ownKeys as Array<keyof typeof options>,\n  )\n\n  // A live match never changes route, so read it once without tracking.\n  const routeId = Solid.useContext(nearestMatchContext)[0 /* routeId */]()\n\n  // While a publishing navigation leaves the Link's route, keep the location\n  // the route still presents so the Link does no work. The route unmounts\n  // when that navigation commits, and any other outcome publishes a newer\n  // location. Compare by identity: a same-href navigation can change state.\n  // The server renders one location: no reactivity there.\n  const currentLocation =\n    (isServer ?? router.isServer)\n      ? () => router.stores.location.get()\n      : Solid.createMemo((prev?: ParsedLocation) => {\n          const location = router.stores.location.get()\n          return prev && _isRouteDeparting(router, routeId, location)\n            ? prev\n            : location\n        })\n\n  // The Link's own destination options, replaced only when a destination prop\n  // changes: the router reuses a location built from the same object without\n  // reading the current location. A Solid store changes in place, so a store\n  // prop value (checked one level deep, not nested) gets a fresh object per\n  // location instead, re-reading the store at each navigation as before. A\n  // mask holds destination options of its own, so its values are checked too.\n  const getDest = () => {\n    const dest: any = {}\n    for (const key of NAVIGATION_KEYS) {\n      const value = (dest[key] = (options as any)[key])\n      if (\n        isStore(value) ||\n        (key === 'mask' && value && Object.values(value).some(isStore))\n      ) {\n        currentLocation()\n      }\n    }\n    return dest\n  }\n  const dest =\n    (isServer ?? router.isServer) ? getDest : Solid.createMemo(getDest)\n\n  // Only a hydrating client renders the server's hash-less active state first.\n  const hasHydrated =\n    !(isServer ?? router.isServer) && router.options.ssr\n      ? useHydrated()\n      : undefined\n\n  // Everything the Link derives from its destination and the location, in\n  // one computation: [element href, external href (null when blocked),\n  // active]. An unchanged result keeps its identity, so a navigation that\n  // leaves the Link as it was notifies nothing downstream.\n  const getLinkState = (prev?: LinkState): LinkState => {\n    const location = currentLocation()\n    const to = options.to\n    const disabled = options.disabled\n    const scheme = typeof to === 'string' && getUrlScheme(to)\n    let href: string | undefined\n    let external: string | null | undefined\n    let active = false\n    if (scheme) {\n      if (router.protocolAllowlist.has(scheme)) {\n        external = to\n      } else {\n        if (process.env.NODE_ENV !== 'production') {\n          console.warn(`Blocked Link with dangerous protocol: ${to}`)\n        }\n        external = null\n      }\n    } else {\n      const options_ = dest()\n      // Clicks and preloads go where the href points.\n      options_._fromLocation = location\n      // untrack because router-core will also access stores, which are signals in solid\n      const next = Solid.untrack(() => router.buildLocation(options_))\n      if (!disabled) {\n        // Use publicHref - it contains the correct href for display\n        // When a rewrite changes the origin, publicHref is the full URL\n        // Otherwise it's the origin-stripped path\n        // This avoids constructing URL objects in the hot path\n        const shown = next.maskedLocation ?? next\n        const publicHref = shown.publicHref\n        const shownHref = shown.external\n          ? publicHref\n          : router.history.createHref(publicHref) || '/'\n        if (\n          (shown.external || shownHref !== publicHref) &&\n          isDangerousProtocol(shownHref, router.protocolAllowlist)\n        ) {\n          if (process.env.NODE_ENV !== 'production') {\n            console.warn(`Blocked Link with dangerous protocol: ${shownHref}`)\n          }\n        } else {\n          href = shownHref\n        }\n      }\n      external =\n        !href && !disabled\n          ? null\n          : href && getUrlScheme(href)\n            ? href\n            : undefined\n      if (external === undefined) {\n        const activeOptions = options.activeOptions\n        const currentPath = removeTrailingSlash(\n          location.pathname,\n          router.basepath,\n        )\n        const nextPath = removeTrailingSlash(next.pathname, router.basepath)\n        // Both modes compare normalized paths; fuzzy matches need a segment boundary.\n        active =\n          (activeOptions?.exact\n            ? currentPath === nextPath\n            : currentPath.startsWith(nextPath) &&\n              (currentPath.length === nextPath.length ||\n                currentPath[nextPath.length] === '/')) &&\n          (!(activeOptions?.includeSearch ?? true) ||\n            deepEqual(\n              location.search,\n              next.search,\n              !activeOptions?.exact,\n              activeOptions?.explicitUndefined,\n            )) &&\n          (!activeOptions?.includeHash ||\n            (hasHydrated && !hasHydrated() ? '' : location.hash) === next.hash)\n      }\n    }\n    href = external === null ? undefined : external || href\n    return prev &&\n      prev[0 /* href */] === href &&\n      prev[1 /* external */] === external &&\n      prev[2 /* active */] === active\n      ? prev\n      : [href, external, active]\n  }\n  const linkState =\n    (isServer ?? router.isServer)\n      ? getLinkState\n      : Solid.createMemo(getLinkState)\n\n  type ResolvedLinkStateProps = Omit<Solid.ComponentProps<'a'>, 'style'> & {\n    style?: Solid.JSX.CSSProperties\n  }\n\n  const resolveLinkStateProps = (\n    [href, external, active]: LinkState,\n    base: Solid.ComponentProps<'a'> & { disabled?: boolean },\n  ) => {\n    const disabled = options.disabled || external === null\n    base.href = href\n    base.disabled = disabled\n    base.target = options.target\n    if (disabled) {\n      Object.assign(base, STATIC_DISABLED_PROPS)\n    }\n\n    if (\n      options.activeProps === undefined &&\n      options.inactiveProps === undefined &&\n      options.class === undefined &&\n      options.style === undefined\n    ) {\n      return active\n        ? Object.assign(base, STATIC_DEFAULT_ACTIVE_ATTRIBUTES)\n        : base\n    }\n\n    const stateProps: ResolvedLinkStateProps =\n      functionalUpdate(\n        (active ? options.activeProps : options.inactiveProps) ??\n          (active ? STATIC_ACTIVE_PROPS : EMPTY_OBJECT),\n        {},\n      ) ?? EMPTY_OBJECT\n    const baseStyle = options.style\n    const stateStyle = stateProps.style\n    // Snapshot reactive style properties so in-place updates remain observable.\n    const style =\n      baseStyle || stateStyle ? { ...baseStyle, ...stateStyle } : undefined\n    const baseClass = options.class\n    const stateClass = stateProps.class\n    const className = baseClass\n      ? stateClass\n        ? `${baseClass} ${stateClass}`\n        : baseClass\n      : stateClass\n\n    return {\n      ...base,\n      ...stateProps,\n      // State props can override element props, but not routing options.\n      href,\n      disabled,\n      target: base.target,\n      ...(style && hasKeys(style) && { style }),\n      ...(className && { class: className }),\n      ...(active && STATIC_ACTIVE_ATTRIBUTES),\n    } as ResolvedLinkStateProps\n  }\n\n  // Keep the guard inline so browser builds can drop the server return.\n  if (isServer ?? router.isServer) {\n    const props = resolveLinkStateProps(linkState(), {\n      onClick: options.onClick,\n      onBlur: options.onBlur,\n      onFocus: options.onFocus,\n      onMouseEnter: options.onMouseEnter,\n      onMouseLeave: options.onMouseLeave,\n      onMouseOut: options.onMouseOut,\n      onMouseOver: options.onMouseOver,\n      onTouchStart: options.onTouchStart,\n      ref: options.ref,\n    })\n    // Avoid creating merged-prop getters for absent server event handlers.\n    for (const key of STATIC_EVENT_PROPS) {\n      if (props[key] === undefined) {\n        delete props[key]\n      }\n    }\n    return Solid.mergeProps(propsSafeToSpread, props) as any\n  }\n\n  let hasRenderFetched = false\n\n  const preload = () =>\n    !options.reloadDocument &&\n    linkState()[1 /* external */] === undefined &&\n    !options.disabled &&\n    (options.preload ?? router.options.defaultPreload)\n  const preloadDelay = () =>\n    options.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n  const doPreload = () =>\n    router.preloadRoute(dest()).catch((err: any) => {\n      console.warn(err)\n      console.warn(preloadWarning)\n    })\n\n  const [ref, setRef] = Solid.createSignal<Element | null>(null)\n\n  let preloadTimeout: ReturnType<typeof setTimeout> | undefined\n  const cancelPreload = () => {\n    clearTimeout(preloadTimeout)\n    preloadTimeout = undefined\n  }\n\n  const enqueuePreload = (\n    e?: MouseEvent | FocusEvent | IntersectionObserverEntry,\n  ) => {\n    if (!e) {\n      cancelPreload()\n      return\n    }\n\n    if (\n      !(\n        (e as IntersectionObserverEntry).isIntersecting ??\n        preload() === 'intent'\n      )\n    ) {\n      if ((e as IntersectionObserverEntry).isIntersecting === false) {\n        cancelPreload()\n      }\n      return\n    }\n\n    if (!preloadDelay()) {\n      doPreload()\n      return\n    }\n\n    preloadTimeout ??= setTimeout(() => {\n      preloadTimeout = undefined\n      doPreload()\n    }, preloadDelay())\n  }\n\n  useIntersectionObserver(ref, enqueuePreload, preload)\n\n  Solid.createEffect(() => {\n    if (hasRenderFetched) {\n      return\n    }\n    if (preload() === 'render') {\n      doPreload()\n      hasRenderFetched = true\n    }\n  })\n\n  // The click handler\n  const handleClick = (e: MouseEvent) => {\n    // Check actual element's target attribute as fallback\n    const elementTarget = (\n      e.currentTarget as HTMLAnchorElement | SVGAElement\n    ).getAttribute('target')\n    const effectiveTarget =\n      options.target !== undefined ? options.target : elementTarget\n\n    if (\n      !options.disabled &&\n      linkState()[1 /* external */] === undefined &&\n      !(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) &&\n      !e.defaultPrevented &&\n      (!effectiveTarget || effectiveTarget === '_self') &&\n      e.button === 0\n    ) {\n      e.preventDefault()\n      cancelPreload()\n\n      // All is well? Navigate!\n      // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n      router.navigate(dest())\n    }\n  }\n\n  const handleTouchStart = () => {\n    if (preload() !== 'intent') return\n    doPreload()\n  }\n\n  const handleLeave = () => {\n    if (preload() === 'intent') {\n      cancelPreload()\n    }\n  }\n\n  const onClick = createComposedHandler(() => options.onClick, handleClick)\n  const onBlur = createComposedHandler(() => options.onBlur, handleLeave)\n  const onFocus = createComposedHandler(() => options.onFocus, enqueuePreload)\n  const onMouseEnter = createComposedHandler(\n    () => options.onMouseEnter,\n    enqueuePreload,\n  )\n  const onMouseOver = createComposedHandler(\n    () => options.onMouseOver,\n    enqueuePreload,\n  )\n  const onMouseLeave = createComposedHandler(\n    () => options.onMouseLeave,\n    handleLeave,\n  )\n  const onMouseOut = createComposedHandler(\n    () => options.onMouseOut,\n    handleLeave,\n  )\n  const onTouchStart = createComposedHandler(\n    () => options.onTouchStart,\n    handleTouchStart,\n  )\n\n  // One ref callback per element. The selected state props' ref, else the\n  // Link's own, receives the element once; a state change does not re-call it.\n  const linkRef = (el: Element) => {\n    setRef(el)\n    const ref = resolved.ref ?? options.ref\n    if (typeof ref === 'function') {\n      ref(el as HTMLAnchorElement)\n    }\n  }\n\n  // `mergeProps` memoizes this itself; the ref reads its latest result.\n  let resolved: Solid.ComponentProps<'a'>\n  const resolvedProps = () =>\n    (resolved = resolveLinkStateProps(linkState(), {\n      onClick,\n      onBlur,\n      onFocus,\n      onMouseEnter,\n      onMouseOver,\n      onMouseLeave,\n      onMouseOut,\n      onTouchStart,\n    }))\n\n  // The ref sits after the memo so reading it does not track the memo: the\n  // element's ref effect then runs once.\n  return Solid.mergeProps(propsSafeToSpread, resolvedProps, {\n    ref: linkRef,\n  }) as any\n}\n\n// [element href, external href (null when blocked), active]\ntype LinkState = [\n  href: string | undefined,\n  external: string | null | undefined,\n  active: boolean,\n]\n\nconst isStore = (value: any): boolean => !!value?.[Solid.$PROXY]\n\n// Props that decide where and how a Link navigates.\nconst NAVIGATION_KEYS = [\n  'to',\n  'reloadDocument',\n  'replace',\n  'resetScroll',\n  'hashScrollIntoView',\n  'startTransition',\n  'viewTransition',\n  'ignoreBlocker',\n  'params',\n  'search',\n  'hash',\n  'state',\n  'mask',\n  'unsafeRelative',\n  'from',\n  'href',\n] as const\n// Options the Link consumes; every other option is an element prop.\nconst LINK_OPTION_KEYS = [\n  ...NAVIGATION_KEYS,\n  'activeProps',\n  'inactiveProps',\n  'activeOptions',\n  'preload',\n  'preloadDelay',\n  'preloadIntentProximity',\n  'target',\n  'disabled',\n  'style',\n  'class',\n  'onClick',\n  'onBlur',\n  'onFocus',\n  'onMouseEnter',\n  'onMouseLeave',\n  'onMouseOver',\n  'onMouseOut',\n  'onTouchStart',\n]\n// A Link also consumes its children and component, and drops `type`.\nconst LINK_ELEMENT_KEYS = [...LINK_OPTION_KEYS, '_asChild', 'children', 'type']\nconst STATIC_EVENT_PROPS = [\n  'onClick',\n  'onBlur',\n  'onFocus',\n  'onMouseEnter',\n  'onMouseLeave',\n  'onMouseOut',\n  'onMouseOver',\n  'onTouchStart',\n] as const\nconst STATIC_ACTIVE_PROPS = { class: 'active' }\nconst EMPTY_OBJECT = {}\nconst STATIC_DEFAULT_ACTIVE_ATTRIBUTES = {\n  class: 'active',\n  'data-status': 'active',\n  'aria-current': 'page',\n}\nconst STATIC_DISABLED_PROPS = {\n  role: 'link' as const,\n  'aria-disabled': true,\n}\nconst STATIC_ACTIVE_ATTRIBUTES = {\n  'data-status': 'active',\n  'aria-current': 'page',\n}\n\n/** Call a JSX.EventHandlerUnion with the event. */\nfunction callHandler<T, TEvent extends Event>(\n  event: TEvent & { currentTarget: T; target: Element },\n  handler: Solid.JSX.EventHandlerUnion<T, TEvent>,\n) {\n  if (typeof handler === 'function') {\n    handler(event)\n  } else {\n    handler[0](handler[1], event)\n  }\n  return event.defaultPrevented\n}\n\nfunction createComposedHandler<T, TEvent extends Event>(\n  getHandler: () => Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n  fallback: (event: TEvent) => void,\n) {\n  return (event: TEvent & { currentTarget: T; target: Element }) => {\n    const handler = getHandler()\n    if (!handler || !callHandler(event, handler)) fallback(event)\n  }\n}\n\nexport type UseLinkPropsOptions<\n  TRouter extends AnyRouter = RegisteredRouter,\n  TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n  TTo extends string | undefined = '.',\n  TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n  TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n  Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\n\nexport type ActiveLinkOptions<\n  TComp = 'a',\n  TRouter extends AnyRouter = RegisteredRouter,\n  TFrom extends string = string,\n  TTo extends string | undefined = '.',\n  TMaskFrom extends string = TFrom,\n  TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n  ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n  LinkComponentSolidProps<TComp> & {\n    [key: `data-${string}`]: unknown\n  }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n  /**\n   * A function that returns additional props for the `active` state of this link.\n   * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n   */\n  activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n  /**\n   * A function that returns additional props for the `inactive` state of this link.\n   * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n   */\n  inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n  TComp = 'a',\n  TRouter extends AnyRouter = RegisteredRouter,\n  TFrom extends string = string,\n  TTo extends string | undefined = '.',\n  TMaskFrom extends string = TFrom,\n  TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n  LinkPropsChildren\n\nexport interface LinkPropsChildren {\n  // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n  children?:\n    | Solid.JSX.Element\n    | ((state: { isActive: boolean }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n  ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n  : never\n\nexport type LinkComponentProps<\n  TComp = 'a',\n  TRouter extends AnyRouter = RegisteredRouter,\n  TFrom extends string = string,\n  TTo extends string | undefined = '.',\n  TMaskFrom extends string = TFrom,\n  TMaskTo extends string = '.',\n> = LinkComponentSolidProps<TComp> &\n  LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n  any,\n  any,\n  string,\n  string,\n  string,\n  string\n>\n\nexport type LinkComponent<\n  in out TComp,\n  in out TDefaultFrom extends string = string,\n> = <\n  TRouter extends AnyRouter = RegisteredRouter,\n  const TFrom extends string = TDefaultFrom,\n  const TTo extends string | undefined = undefined,\n  const TMaskFrom extends string = TFrom,\n  const TMaskTo extends string = '',\n>(\n  props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Solid.JSX.Element\n\nexport interface LinkComponentRoute<\n  in out TDefaultFrom extends string = string,\n> {\n  defaultFrom: TDefaultFrom;\n  <\n    TRouter extends AnyRouter = RegisteredRouter,\n    const TTo extends string | undefined = undefined,\n    const TMaskTo extends string = '',\n  >(\n    props: LinkComponentProps<\n      'a',\n      TRouter,\n      this['defaultFrom'],\n      TTo,\n      this['defaultFrom'],\n      TMaskTo\n    >,\n  ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n  Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n  return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n  const local = props as typeof props & { _asChild: any }\n  // One props proxy between the element and the Link's props.\n  const linkProps = createLinkProps(props as any, LINK_ELEMENT_KEYS)\n\n  // Element insertion tracks this itself; only a custom component, which may\n  // read its children more than once, gets a memo.\n  const children = () => {\n    const ch = local.children\n    if (typeof ch === 'function') {\n      return ch({\n        get isActive() {\n          return (linkProps as any)['data-status'] === 'active'\n        },\n      })\n    }\n\n    return ch satisfies Solid.JSX.Element\n  }\n\n  if (local._asChild === 'svg') {\n    const [_, svgLinkProps] = Solid.splitProps(linkProps, ['class'])\n    return (\n      <svg>\n        <a {...svgLinkProps}>{children()}</a>\n      </svg>\n    )\n  }\n\n  if (!local._asChild) {\n    return <a {...linkProps}>{children()}</a>\n  }\n\n  const memo = Solid.createMemo(children)\n  return (\n    <Dynamic component={local._asChild as Solid.ValidComponent} {...linkProps}>\n      {memo()}\n    </Dynamic>\n  )\n}\n\nexport type LinkOptionsFnOptions<\n  TOptions,\n  TComp,\n  TRouter extends AnyRouter = RegisteredRouter,\n> =\n  TOptions extends ReadonlyArray<any>\n    ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n    : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n  const TOptions,\n  TRouter extends AnyRouter = RegisteredRouter,\n>(\n  options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n  return options as any\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,SAAgBuB,aAOdG,SAC2B;CAC3B,OAAOM,gBAAgBN,SAAgBO,gBAAgB;AACzD;AAGA,SAASD,gBACPN,SACAQ,SAC2B;CAC3B,MAAME,SAASzB,kBAAAA,UAAU;CAEzB,MAAM,GAAG0B,qBAAqBrC,SAAMsC,WAClCZ,SACAQ,OACF;CAGA,MAAMM,UAAUxC,SAAMyC,WAAW7B,qBAAAA,mBAAmB,CAAC,CAAC,EAAgB,CAAC;CAOvE,MAAM8B,kBACHjC,+BAAAA,YAAY2B,OAAO3B,iBACV2B,OAAOO,OAAOC,SAASC,IAAI,IACjC7C,SAAM8C,YAAYC,SAA0B;EAC1C,MAAMH,WAAWR,OAAOO,OAAOC,SAASC,IAAI;EAC5C,OAAOE,SAAAA,GAAQ9C,sBAAAA,kBAAAA,CAAkBmC,QAAQI,SAASI,QAAQ,IACtDG,OACAH;CACN,CAAC;CAQP,MAAMI,gBAAgB;EACpB,MAAMC,OAAY,CAAC;EACnB,KAAK,MAAMC,OAAOC,iBAAiB;GACjC,MAAMC,QAASH,KAAKC,OAAQxB,QAAgBwB;GAC5C,IACEG,QAAQD,KAAK,KACZF,QAAQ,UAAUE,SAASE,OAAOC,OAAOH,KAAK,CAAC,CAACI,KAAKH,OAAO,GAE7DX,gBAAgB;EAEpB;EACA,OAAOO;CACT;CACA,MAAMA,OACHxC,+BAAAA,YAAY2B,OAAO3B,WAAYuC,UAAUhD,SAAM8C,WAAWE,OAAO;CAGpE,MAAMS,cACJ,EAAEhD,+BAAAA,YAAY2B,OAAO3B,aAAa2B,OAAOV,QAAQgC,MAC7C5C,mBAAAA,YAAY,IACZ6C,KAAAA;CAMN,MAAMC,gBAAgBb,SAAgC;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