Why I cant define a nested function?

I’m trying to call a function when the first function is called, but when I try it, I receive a message telling me that the nested function is not defined

var indiceTema = 0


function darkVer(){
    if (indiceTema == 0){
        indiceTema = 1
    }else indiceTema = 0

    function mudaCor(indice){
        
        document.body.style.backgroundColor = lasColores[indiceTema][indice].corBackground
        document.getElementsByTagName("main")[0].style.background = lasColores[indiceTema][indice].corBackgroundMain
        document.getElementById("botao_form").style.background = lasColores[indiceTema][indice].corLink

        var inputCor = document.getElementsByTagName("input")
        for (index = 0; index < inputCor.length; index++){
            inputCor[index].style.background = lasColores[indiceTema][indice].corBackgroundInput
            inputCor[index].style.borderColor = lasColores[indiceTema][indice].corLink
        }

        var linkCor = document.getElementsByClassName("link_cor")
        for (var index = 0; index < linkCor.length; index++){
            linkCor[index].style.color = lasColores[indiceTema][indice].corLink
        }

        document.getElementById("dark").innerHTML = luaSolo[indiceTema]
        document.getElementById("dark").style.backgroundColor = tema[indiceTema]
        document.getElementById("dark").style.color = "#000"
        document.getElementsByTagName("h1")[0].style.color = tema[indiceTema]

        for (var index = 0; index < document.getElementsByTagName("p").length; index++){
            document.getElementsByTagName("p")[index].style.color = tema[indiceTema]
        }

        for (var index = 0; index < document.getElementsByTagName("label").length; index++){
            document.getElementsByTagName("label")[index].style.color = tema[indiceTema]
        }

    }
}

When I finish writing the mudaCor(), his name becomes a little transparent, and I have no idea how to fix it