class TechnicalSheetEnhanced extends HTMLElement {
connectedCallback() {
const equipment = JSON.parse(this.getAttribute('equipment') || '{}');
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const syncStatus = equipment.sync_status || "synchronized";
const statusConfig = {
synchronized: {
label: "✓ Sincronizado",
color: "bg-green-500/20 text-green-700 border-green-300",
},
recovered: {
label: "↑ Recuperado",
color: "bg-blue-500/20 text-blue-700 border-blue-300",
},
orphaned: {
label: "⚠ Orfanato",
color: "bg-orange-500/20 text-orange-700 border-orange-300",
},
};
const status = statusConfig[syncStatus];
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
${status.label}
${equipment.category?.toUpperCase() || 'CATEGORY'}
${equipment.manufacturer || 'Manufacturer'}
${equipment.model || 'Model'}
Saída
${equipment.power_kw || 0} kW
Conexão
${equipment.voltage_v || 0}V
${equipment.mppt_count ? `
Rastreadores
${equipment.mppt_count}
` : ''}
${equipment.efficiency_percent ? `
Rendimento
${equipment.efficiency_percent}%
` : ''}
${equipment.price_brl != null ? `
R$ ${equipment.price_brl.toLocaleString("pt-BR", { minimumFractionDigits: 2 })}
Orçamento disponível
` : ''}
${equipment.recovered_value && equipment.recovered_value > 0 ? `
+R$ ${equipment.recovered_value.toLocaleString("pt-BR", { maximumFractionDigits: 0 })}
Valor sincronizado
` : ''}
`;
// Add event listeners
const viewBtn = this.shadowRoot.querySelector('button:first-of-type');
viewBtn.addEventListener('click', () => {
this.dispatchEvent(new CustomEvent('view-details', {
detail: equipment,
bubbles: true,
composed: true
}));
});
}
}
customElements.define('technical-sheet-enhanced', TechnicalSheetEnhanced);