Precisa de Ajuda? Atendimento
0
Seguranca
Com relação aos seus dados pessoais de endereçamento, pagamento e conteúdo do pedido, você pode estar certo de que não serão utilizados para outros fins que não o de processamento dos pedidos realizados, não sendo portanto divulgados em hipótese alguma.

Com relação à segurança no tráfego de dados, toda transação que envolver pagamento, seja por cartão de crédito ou não, estará encriptada com a tecnologia SSL (Secure Socket Layer). Isso significa que só nossa empresa terá acesso a estes dados.

`; } else { return '👋 Olá! Bem-vindo à Phoenix Hospitalar™! Estou aqui para te ajudar a escolher o equipamento hospitalar perfeito. O que você está procurando?'; } } function playNotificationSound() { try { const audioContext = new (window.AudioContext || window.webkitAudioContext)(); const oscillator = audioContext.createOscillator(); const gainNode = audioContext.createGain(); oscillator.connect(gainNode); gainNode.connect(audioContext.destination); oscillator.frequency.value = 800; oscillator.type = 'sine'; gainNode.gain.setValueAtTime(0.1, audioContext.currentTime); gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.1); oscillator.start(audioContext.currentTime); oscillator.stop(audioContext.currentTime + 0.1); } catch (error) { console.error('[Phoenix Widget] Erro ao tocar som:', error); } } const widgetHTML = `
`; document.body.insertAdjacentHTML('beforeend', widgetHTML); const button = document.getElementById('phoenix-chat-button'); const modal = document.getElementById('phoenix-chat-modal'); const closeBtn = document.getElementById('phoenix-chat-close'); const input = document.getElementById('phoenix-chat-input'); const sendBtn = document.getElementById('phoenix-chat-send'); const messagesContainer = document.getElementById('phoenix-chat-messages'); const flyingBird = document.getElementById('phoenix-flying-bird'); const hoveringBird = document.getElementById('phoenix-hovering'); const typingIndicator = document.getElementById('phoenix-typing-indicator'); state.sessionId = sessionStorage.getItem('phoenix_session_id'); if (!state.sessionId) { state.sessionId = `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`; sessionStorage.setItem('phoenix_session_id', state.sessionId); } function startPolling() { if (state.pollingTimer) clearInterval(state.pollingTimer); state.pollingTimer = setInterval(async () => { try { const url = `${WIDGET_CONFIG.apiUrl}/messages/${state.sessionId}${state.lastMessageId ? `?lastMessageId=${state.lastMessageId}` : ''}`; const response = await fetch(url); const data = await response.json(); if (data.success) { if (data.isTyping && !state.isTypingVisible) { typingIndicator.style.display = 'block'; state.isTypingVisible = true; } else if (!data.isTyping && state.isTypingVisible) { typingIndicator.style.display = 'none'; state.isTypingVisible = false; } if (data.messages && data.messages.length > 0) { data.messages.forEach(msg => { if (msg.sender !== 'user') { addMessage(msg.content, msg.sender === 'vendor' ? 'vendor' : 'ai'); state.lastMessageId = msg.id; playNotificationSound(); } }); if (state.isTypingVisible) { typingIndicator.style.display = 'none'; state.isTypingVisible = false; } } } } catch (error) { console.error('[Phoenix Widget] Error polling messages:', error); } }, WIDGET_CONFIG.pollingInterval); } function stopPolling() { if (state.pollingTimer) { clearInterval(state.pollingTimer); state.pollingTimer = null; } } async function openModal(autoOpened = false) { button.style.display = 'none'; flyingBird.style.display = 'block'; flyingBird.style.animation = 'flyUp 1.5s ease-out forwards'; setTimeout(async () => { modal.style.display = 'flex'; flyingBird.style.display = 'none'; hoveringBird.style.display = 'block'; input.focus(); if (autoOpened && !state.sessionId) { try { const response = await fetch(`${WIDGET_CONFIG.apiUrl}/start`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ productUrl: window.location.href, productName: document.title }), }); if (response.ok) { const data = await response.json(); state.sessionId = data.sessionId; if (data.greeting) addMessage(data.greeting, 'ai'); } } catch (error) { console.error('[Phoenix Widget] Erro ao iniciar conversa:', error); } } startPolling(); }, 1000); markAsVisited(); } function closeModal() { modal.style.display = 'none'; hoveringBird.style.display = 'none'; button.style.display = 'flex'; stopPolling(); } if (!hasVisitedBefore()) { setTimeout(() => { openModal(true); }, WIDGET_CONFIG.autoOpenDelay); } button.addEventListener('click', openModal); closeBtn.addEventListener('click', closeModal); async function sendMessage() { const message = input.value.trim(); if (!message) return; addMessage(message, 'user'); input.value = ''; try { const response = await fetch(`${WIDGET_CONFIG.apiUrl}/send-message`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ sessionId: state.sessionId, message, productUrl: window.location.href, isLocationPage: isLocationPage() }), }); const data = await response.json(); if (!data.success) { addMessage('Erro ao enviar mensagem. Tente novamente.', 'ai'); } } catch (error) { console.error('Erro ao enviar mensagem:', error); addMessage('Erro ao enviar mensagem. Tente novamente.', 'ai'); } } function addMessage(text, sender) { const isUser = sender === 'user'; const isVendor = sender === 'vendor'; const bgColor = isUser ? '#667eea' : (isVendor ? '#25D366' : '#f3f4f6'); const textColor = isUser || isVendor ? 'white' : '#1f2937'; const marginLeft = isUser ? '40px' : '0'; const formattedText = text.replace(/(https:\/\/wa\.me\/\d+)/g, '???? Abrir WhatsApp'); const messageHTML = `
${!isUser ? `
Phoenix
${isVendor ? 'Consultor Phoenix' : 'Phoenix Hospitalar'}
` : ''}
${formattedText}
`; messagesContainer.insertAdjacentHTML('beforeend', messageHTML); messagesContainer.scrollTop = messagesContainer.scrollHeight; } sendBtn.addEventListener('click', sendMessage); input.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); }); fetch(`${WIDGET_CONFIG.apiUrl}/start`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ productUrl: window.location.href, sessionId: state.sessionId, isLocationPage: isLocationPage() }), }).catch(err => console.error('Erro ao iniciar sessão:', err)); })();