/* Minification failed. Returning unminified contents.
(1,10): run-time error CSS1031: Expected selector, found 'renderizarBotaoWhatsApp('
(1,10): run-time error CSS1025: Expected comma or open brace, found 'renderizarBotaoWhatsApp('
 */
function renderizarBotaoWhatsApp(numero, mensagem, formulario, naoExibirFormulario) {
    try {
        if (!numero)
            return

        let urlParaAbrir = `https://api.whatsapp.com/send?phone=${numero}`

        if (mensagem) urlParaAbrir += `&text=${mensagem}`

        let body = ""
        let head = `
            <style>
                #whatsapp-button {
                    position: fixed;
                    bottom: 20px;
                    right: 20px;
                    z-index: 999;
                    cursor: pointer; 
                    animation: shakeButton 7s infinite; 
                }

                @keyframes shakeButton {
                    0%, 100% {
                        transform: translateX(0);
                    }
                    10%, 30%, 50%, 70%, 90% {
                        transform: translateX(-9px);
                    }
                    20%, 40%, 60%, 80% {
                        transform: translateX(9px);
                    }
                }

                #lead-form-frame {
                    position: fixed;
                    bottom: 140px;
                    right: 20px;
                    width: 400px; 
                    height: 400px; 
                    z-index: 999;
                    -webkit-box-shadow: -2px 0px 18px -10px rgba(0,0,0,0.75);
                    -moz-box-shadow: -2px 0px 18px -10px rgba(0,0,0,0.75);
                    box-shadow: -2px 0px 18px -10px rgba(0,0,0,0.75);
                }

                #lead-form-frame iframe {
                    width: 100%;
                    height: 100%;
                }
            </style>
        `

        console.log(formulario)

        if (naoExibirFormulario)
            formulario = null

        if (formulario) {
            body = `
                    <div id="lead-form-frame" style="display: none;">
                        <iframe src="${formulario}?abrirEmNovaAba=${urlParaAbrir}" frameborder="0" scrolling="no"></iframe>
                    </div>
                    <div id="whatsapp-button">
                        <img src="https://i.pinimg.com/originals/f5/28/cc/f528cc010d8a9bfcef07d08106976d0f.png" alt="WhatsApp" width="100" height="100">
                    </div>
                `
        }
        else {
            body = `<div id="whatsapp-button">
                        <a href="${urlParaAbrir}" target="_blank">
                            <img src="https://i.pinimg.com/originals/f5/28/cc/f528cc010d8a9bfcef07d08106976d0f.png" alt="WhatsApp" width="100" height="100">
                        </a>
                    </div>`
        }


        document.getElementsByTagName("head")[0].innerHTML += head;
        document.getElementsByTagName("body")[0].innerHTML += body;

        if (formulario) {
            document.getElementById("whatsapp-button").addEventListener("click", () => {
                var frameLeadFormCRM = document.getElementById("lead-form-frame")

                frameLeadFormCRM.style.display = frameLeadFormCRM.style.display === "none" ? "block" : "none"
            })
        }
    } catch (e) {
        console.log("Ocorreu um erro ao carregar o botão de WhatsApp" + JSON.stringify(e))
    }
}
