{"version":3,"file":"Scripts.cjs","names":["Solid","_getAssetMatches","replaceEqualDeep","isServer","Asset","useRouter","RouterManagedTag","Scripts","router","nonce","options","ssr","scripts","createMemo","previous","Array","matches","stores","get","next","assets","manifest","match","script","children","attrs","push","tag","asset","routes","routeId","serverBufferedScript","serverSsr","takeBufferedScripts","undefined","_$createComponent","For","each"],"sources":["../../src/Scripts.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { _getAssetMatches, replaceEqualDeep } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = () => {\n  const router = useRouter()\n  const nonce = router.options.ssr?.nonce\n\n  const scripts = Solid.createMemo(\n    (previous: Array<RouterManagedTag> | undefined) => {\n      const matches = _getAssetMatches(router.stores.matches.get())\n      const next: Array<RouterManagedTag> = []\n      const assets: Array<RouterManagedTag> = []\n      const manifest = router.ssr?.manifest\n      for (const match of matches) {\n        for (const script of match.scripts ?? []) {\n          if (!script) {\n            continue\n          }\n          const { children, ...attrs } = script\n          next.push({\n            tag: 'script',\n            attrs: { ...attrs, nonce },\n            children: children as string | undefined,\n          })\n        }\n        for (const asset of manifest?.routes[match.routeId]?.scripts ?? []) {\n          assets.push({\n            tag: 'script',\n            attrs: { ...asset.attrs, nonce },\n            children: asset.children,\n          })\n        }\n      }\n      next.push(...assets)\n      return previous ? replaceEqualDeep(previous, next) : next\n    },\n  )\n  const serverBufferedScript =\n    (isServer ?? router.isServer) && router.serverSsr\n      ? router.serverSsr.takeBufferedScripts()\n      : undefined\n\n  return (\n    <>\n      {serverBufferedScript && <Asset {...serverBufferedScript} />}\n      <Solid.For each={scripts()}>{(asset) => <Asset {...asset} />}</Solid.For>\n    </>\n  )\n}\n"],"mappings":";;;;;;;;;AAOA,IAAaO,gBAAgB;CAC3B,MAAMC,SAASH,kBAAAA,UAAU;CACzB,MAAMI,QAAQD,O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