{"version":3,"file":"not-found.cjs","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","getNotFound","error","cause","undefined","CatchNotFound","props","fallback","JSX","Element","onCatch","children","router","pathname","createMemo","stores","location","state","status","_$createComponent","getResetKey","notFoundError","errorComponent","DefaultGlobalNotFound","_tmpl$"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport * as Solid from 'solid-js'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { NotFoundError } from '@tanstack/router-core'\n\n// Solid wraps non-Error throws in an Error and stores the original thrown value\n// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.\nexport function getNotFound(\n  error: unknown,\n): (NotFoundError & { isNotFound: true }) | undefined {\n  if (isNotFound(error)) {\n    return error as NotFoundError & { isNotFound: true }\n  }\n\n  if (isNotFound((error as any)?.cause)) {\n    return (error as any).cause as NotFoundError & { isNotFound: true }\n  }\n\n  return undefined\n}\n\nexport function CatchNotFound(props: {\n  fallback?: (error: NotFoundError) => Solid.JSX.Element\n  onCatch?: (error: NotFoundError) => void\n  children: Solid.JSX.Element\n}) {\n  const router = useRouter()\n  // TODO: Some way for the user to programmatically reset the not-found boundary?\n  const pathname = Solid.createMemo(() => router.stores.location.state.pathname)\n  const status = Solid.createMemo(() => router.stores.status.state)\n\n  return (\n    <CatchBoundary\n      getResetKey={() => `not-found-${pathname()}-${status()}`}\n      onCatch={(error) => {\n        const notFoundError = getNotFound(error)\n\n        if (notFoundError) {\n          props.onCatch?.(notFoundError)\n        } else {\n          throw error\n        }\n      }}\n      errorComponent={({ error }) => {\n        const notFoundError = getNotFound(error)\n\n        if (notFoundError) {\n          return props.fallback?.(notFoundError)\n        } else {\n          throw error\n        }\n      }}\n    >\n      {props.children}\n    </CatchBoundary>\n  )\n}\n\nexport function DefaultGlobalNotFound() {\n  return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgBK,YACdC,OACoD;AACpD,MAAA,GAAA,sBAAA,YAAeA,MAAM,CACnB,QAAOA;AAGT,MAAA,GAAA,sBAAA,YAAgBA,OAAeC,MAAM,CACnC,QAAQD,MAAcC;;AAM1B,SAAgBE,cAAcC,OAI3B;CACD,MAAMM,SAASb,kBAAAA,WAAW;CAE1B,MAAMc,WAAWhB,SAAMiB,iBAAiBF,OAAOG,OAAOC,SAASC,MAAMJ,SAAS;CAC9E,MAAMK,SAASrB,SAAMiB,iBAAiBF,OAAOG,OAAOG,OAAOD,MAAM;AAEjE,SAAA,GAAA,aAAA,iBACGnB,sBAAAA,eAAa;EACZsB,mBAAmB,aAAaP,UAAU,CAAA,GAAIK,QAAQ;EACtDR,UAAUR,UAAU;GAClB,MAAMmB,gBAAgBpB,YAAYC,MAAM;AAExC,OAAImB,cACFf,OAAMI,UAAUW,cAAc;OAE9B,OAAMnB;;EAGVoB,iBAAiB,EAAEpB,YAAY;GAC7B,MAAMmB,gBAAgBpB,YAAYC,MAAM;AAExC,OAAImB,cACF,QAAOf,MAAMC,WAAWc,cAAc;OAEtC,OAAMnB;;EAET,IAAAS,WAAA;AAAA,UAEAL,MAAMK;;EAAQ,CAAA;;AAKrB,SAAgBY,wBAAwB;AACtC,QAAAC,QAAA"}