Trim and Extend Curve Grasshopper

Hallo ! i am really struggling since a while with this issue, i am trying to delete extended part of a curve, and to extend curve when its not connected to get a on continues curve at the end, i sorted already all points counterclockwise, i would really appriecte any help. Thanks

Extend and trim Curve.gh (2.2 KB)