Others and I already posted several examples of how to split PDFs, eg. Splitting a PDF at a recurring string/expression and Split PDFs - Custom Break - #14 by pete31 and Splitting PDFs | JavaScript for Automation (JXA). They are fairly short, clear and instructive. We can talk about them, eg how to modify them to do what you want.
But for me (!), there’s no point in talking about crap code like the one produced by whatever AI. That’s just not worth my time and energy.