{"version":3,"file":"parent-routes.cjs","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"],"names":["map","joinOperator","filter"],"mappings":";;;AAGA,MAAM,yBAAyB;AAExB,SAAS,sBACd,OACA,iBACA,UAOa;AAIb,QAAM,OAAY,MAAM;AAAA,IACtBA,MAAAA,IAAI,CAAC,CAAC,QAAQ,KAAK,aAAa,MAAoC;AAAA,MAClE;AAAA,MACA,CAAC,QAAQ,KAAK,aAAa;AAAA,IAAA,CAC5B;AAAA,EAAA;AAEH,QAAM,SAAc,gBAAgB;AAAA,IAClCA,MAAAA,IAAI,CAAC,CAAC,gBAAgB,aAAa,MAAM;AAAA,MACvC;AAAA,MACA,CAAC,gBAAgB,aAAa;AAAA,IAAA,CAC/B;AAAA,EAAA;AAGH,SAAO,KAAK;AAAA,IACVC,WAAa,QAAQ,OAAO;AAAA,IAC5BC,MAAAA;AAAAA,MAAO,CAAC,CAAA,EAAG,CAAC,SAAS,SAAS,CAAC,MAC7B,QAAQ,WAAW,QAAQ,aAAa,IAAI;AAAA,IAAA;AAAA,IAE9CF,MAAAA,IAAI,CAAC,CAAA,EAAG,CAAC,SAAS,SAAS,CAAC,MAAW;AACrC,YAAM,CAAC,QAAQ,KAAK,aAAa,IAAI;AACrC,YAAM,CAAC,gBAAgB,aAAa,IAAI;AACxC,aAAO,SAAS,QAAQ,KAAK,gBAAgB,eAAe,aAAa;AAAA,IAC3E,CAAC;AAAA,EAAA;AAEL;;"}