ECMAScript-2021 - variable error on the second time the rule is run?

I am myself just starting to migrate my old files/rules-DSL stuff to JSScripting so I can unfortunately not be of much help here.
Perhaps putting the class into an external file and loading this makes a difference here ?
See how @rlkoshak does this in his bag of rules here : https://community.openhab.org/t/some-js-scripting-ui-rules-examples/131305