{"version":3,"file":"parent-routes.cjs","names":["map","joinOperator","filter"],"sources":["../../../../src/query/compiler/parent-routes.ts"],"sourcesContent":["import { filter, join as joinOperator, map } from '@tanstack/db-ivm'\nimport type { KeyedStream } from '../../types.js'\n\nconst PARENT_ROUTE_CROSS_KEY = `__tanstack_parent_route_cross__`\n\nexport function crossJoinParentRoutes(\n  input: KeyedStream,\n  parentKeyStream: KeyedStream,\n  assemble: (\n    rowKey: unknown,\n    row: unknown,\n    correlationKey: unknown,\n    parentContext: unknown,\n    callbackValue?: unknown,\n  ) => [unknown, unknown],\n): KeyedStream {\n  // Recursive sources need their route before a correlation field is always\n  // available. The constant key intentionally creates one copy of each input\n  // row per active route; callers filter those copies once the field is visible.\n  const rows: any = input.pipe(\n    map(([rowKey, row, callbackValue]: [unknown, unknown, unknown?]) => [\n      PARENT_ROUTE_CROSS_KEY,\n      [rowKey, row, callbackValue],\n    ]),\n  )\n  const routes: any = parentKeyStream.pipe(\n    map(([correlationKey, parentContext]) => [\n      PARENT_ROUTE_CROSS_KEY,\n      [correlationKey, parentContext],\n    ]),\n  )\n\n  return rows.pipe(\n    joinOperator(routes, `inner`),\n    filter(([, [rowSide, routeSide]]: any) =>\n      Boolean(rowSide != null && routeSide != null),\n    ),\n    map(([, [rowSide, routeSide]]: any) => {\n      const [rowKey, row, callbackValue] = rowSide\n      const [correlationKey, parentContext] = routeSide\n      return assemble(rowKey, row, correlationKey, parentContext, callbackValue)\n    }),\n  ) as KeyedStream\n}\n"],"mappings":";AAGA,IAAM,yBAAyB;AAE/B,SAAgB,sBACd,OACA,iBACA,UAOa;CAIb,MAAM,OAAY,MAAM,MAAA,GACtBA,iBAAAA,IAAAA,EAAK,CAAC,QAAQ,KAAK,mBAAiD,CAClE,wBACA;EAAC;EAAQ;EAAK;CAAa,CAC7B,CAAC,CACH;CACA,MAAM,SAAc,gBAAgB,MAAA,GAClCA,iBAAAA,IAAAA,EAAK,CAAC,gBAAgB,mBAAmB,CACvC,wBACA,CAAC,gBAAgB,aAAa,CAChC,CAAC,CACH;CAEA,OAAO,KAAK,MAAA,GACVC,iBAAAA,KAAAA,CAAa,QAAQ,OAAO,IAAA,GAC5BC,iBAAAA,OAAAA,EAAQ,GAAG,CAAC,SAAS,gBACnB,QAAQ,WAAW,QAAQ,aAAa,IAAI,CAC9C,IAAA,GACAF,iBAAAA,IAAAA,EAAK,GAAG,CAAC,SAAS,gBAAqB;EACrC,MAAM,CAAC,QAAQ,KAAK,iBAAiB;EACrC,MAAM,CAAC,gBAAgB,iBAAiB;EACxC,OAAO,SAAS,QAAQ,KAAK,gBAAgB,eAAe,aAAa;CAC3E,CAAC,CACH;AACF"}