I don’t think there is a solution that leaves everyone happy and safe and that’s just the reality of life.
Sometimes a horrible outcome might be the best one. Germany and Japan were completely humiliated in WW2. Both turned out fine. Perhaps Palestine needs to properly lose this war. I mean, Palestine has lost wars several times against Israel before but they didn’t go through similar learning process that Germany and Japan did after WW2.