Smooth animation onClick button

Thank you so much!

What i have to replace with “app”?
ERROR : " Cannot find name ‘app’ "

const animation ={    
    state:'hidden',
    play:()=>{
        t1.reverse();
        t2.play();
        app.state ='shown'
    },

This is what i have done:

// Initialize the timelines;
const t1 = wixAnimations.timeline();
const t2 = wixAnimations.timeline();

// Define the animations
t1.add($w("#box40"), { opacity: 0, duration: 350 });
t1.add($w("#box39"), { opacity: 1, duration: 350 });

// Hide the box that should be hidden by default.
t1.play();

// Initialize animations
const animation = {
    state: 'hidden',
    play: () => {
        t1.reverse();
        t2.play();
        app.state = 'shown'
    },
    reverse: () => {
        t1.play();
        t2.reverse();
        app.state = 'hidden';
    }
}

// Define an event handler
$w('#button24').onClick(() => {
    animation.state === 'hidden' ? animation.play() : animation.reverse();
})