backport: fix prerender issue with intercepting routes + generateStaticParams (#75170)
Backports the testcase added in
https://github.com/vercel/next.js/pull/75167 in
[9bf61bc](https://github.com/vercel/next.js/pull/75170/commits/9bf61bc76c25f3eb345aac7db34929ecde232569).
Confirmed failure via [this
run](https://github.com/vercel/next.js/actions/runs/12898849331/job/35966678688?pr=75170)
Adds the fix in
[0ab1e32](https://github.com/vercel/next.js/pull/75170/commits/0ab1e32f04f09de2b2651b7e889633e43f4834a2).
This change is identical to the code used in canary, which was added as
part of the `rootParams` feature via
https://github.com/vercel/next.js/pull/73816
([ref](https://github.com/vercel/next.js/blob/d12e2e82b778eef8393f47944a258a55c6c508fe/packages/next/src/build/static-paths/app.ts#L316-L317))
This regression was caused by `segments` containing all possible
segments (including parallel routes), not just the page segment. As a
result, `paramKeys` was incorrectly being calculated. We don't need to
traverse the segments to determine the param keys: we have the route
regex & matcher, it's more reliable to extract it from that.