!function(){"use strict";var t=document.getElementById("themeIcon");function e(){var e=document.documentElement.getAttribute("data-theme");t&&(t.innerHTML="industrial"===e?"☾":"☀")}window.toggleTheme=function(){var t=document.documentElement,n="industrial"===t.getAttribute("data-theme")?"modern":"industrial";t.setAttribute("data-theme",n),localStorage.setItem("nexus-theme",n),e()},e();var n=document.getElementById("heroCanvas");if(n){var a,r=n.getContext("2d"),o=80,i=[];function w(){var t=n.parentElement;n.width=t.offsetWidth,n.height=t.offsetHeight}function x(t){return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}function y(t,e,n,a,o){r.beginPath();for(var i=0;i<4;i++){var l=Math.PI/2*i;r.lineTo(t+Math.cos(l)*n,e+Math.sin(l)*n),r.lineTo(t+Math.cos(l+Math.PI/4)*a,e+Math.sin(l+Math.PI/4)*a)}r.closePath(),r.fillStyle=o,r.fill()}function A(){var t=Math.floor(n.width/o),e=Math.floor(n.height/o);i.push({col:Math.floor(Math.random()*t),row:Math.floor(Math.random()*e),life:0,maxLife:90+60*Math.random()})}function I(){r.clearRect(0,0,n.width,n.height);var t=x("--canvas-grid-color")||"rgba(255,255,255,0.06)",e=x("--canvas-star-color")||"rgba(245,166,35,0.3)",a=x("--canvas-glow-color")||"rgba(245,166,35,0.08)",l=Math.floor(n.width/o)+1,c=Math.floor(n.height/o)+1;r.strokeStyle=t,r.lineWidth=1;for(var s=0;s<=l;s++){var u=s*o;r.beginPath(),r.moveTo(u,0),r.lineTo(u,n.height),r.stroke()}for(var d=0;d<=c;d++){var f=d*o;r.beginPath(),r.moveTo(0,f),r.lineTo(n.width,f),r.stroke()}for(s=0;s<=l;s+=2)for(d=0;d<=c;d+=2)y(s*o,d*o,6,3,e);i.length<6&&Math.random()<.03&&A();for(var h=i.length-1;h>=0;h--){var m=i[h];m.life++;var v=m.life/m.maxLife,g=v<.5?2*v:2*(1-v);r.fillStyle=a,r.globalAlpha=g,r.fillRect(m.col*o+1,m.row*o+1,78,78),r.shadowColor=a,r.shadowBlur=20,r.fillRect(m.col*o+1,m.row*o+1,78,78),r.shadowBlur=0,r.globalAlpha=1,m.life>=m.maxLife&&i.splice(h,1)}requestAnimationFrame(I)}w(),I(),window.addEventListener("resize",(function(){clearTimeout(a),a=setTimeout(w,150)}))}var l=document.querySelectorAll(".nx-reveal, .nx-reveal-scale");if("IntersectionObserver"in window){var c=new IntersectionObserver((function(t){t.forEach((function(t){t.isIntersecting&&(t.target.classList.add("is-visible"),c.unobserve(t.target))}))}),{threshold:.15,rootMargin:"0px 0px -40px 0px"});l.forEach((function(t){c.observe(t)}))}else l.forEach((function(t){t.classList.add("is-visible")}));var s=document.querySelectorAll(".stat-card");if(s.length&&"IntersectionObserver"in window){var u=new IntersectionObserver((function(t){t.forEach((function(t){if(t.isIntersecting){var e=t.target.querySelector(".number");if(e&&!e._animated){e._animated=!0;var n=parseInt(e.getAttribute("data-target"),10)||0,a=e.getAttribute("data-suffix")||"",r=e.getAttribute("data-format")||"num";!function(t,e,n,a,r){var o=null;requestAnimationFrame((function i(l){o||(o=l);var c=Math.min((l-o)/r,1),s=1-Math.pow(1-c,3),u=Math.floor(s*e);-1!==n.indexOf("M")?t.textContent=(u/1e6).toFixed(1)+"M"+a:-1!==n.indexOf("K")?t.textContent=Math.floor(u/1e3)+"K"+a:t.textContent=u+a,c<1&&requestAnimationFrame(i)}))}(e,n,r,a,2e3)}u.unobserve(t.target)}}))}),{threshold:.5});s.forEach((function(t){u.observe(t)}))}var d=document.getElementById("typewriterText");if(d){var f=["POS + Inventario + CFDI 4.0 + Contabilidad","Catalogo TecDoc: 1.5M+ partes, 304K aftermarket","15.8M cross-references OEM ↔ aftermarket","Chatbot IA con voz, foto y diagnostico","WhatsApp Business integrado","Busca por VIN, placas o numero de parte","Marketplace B2B: bodegas ↔ talleres","PWA + Android + modo kiosko + offline"],h=0,m=0,v=!1;function k(){var t=f[h];if(v){if(d.textContent=t.substring(0,m),--m<0)return v=!1,m=0,h=(h+1)%f.length,void setTimeout(k,400);setTimeout(k,30)}else{if(d.textContent=t.substring(0,m+1),++m>=t.length)return v=!0,void setTimeout(k,2e3);setTimeout(k,50)}}setTimeout(k,1200)}var g=document.getElementById("brandsMarquee");function b(t){var e="";t.forEach((function(t){var n,a;e+=''+(n=t.name_brand,(a=document.createElement("div")).textContent=n||"",a.innerHTML+"")})),g.innerHTML=e+e}var M=["Toyota","Nissan","Ford","Volkswagen","Honda","Chevrolet","Hyundai","Kia","Mazda","BMW","Mercedes-Benz","Audi","Renault","Jeep","Dodge","Ram","Subaru","Mitsubishi","Suzuki","Peugeot","Volvo","Fiat","Chrysler","Acura","Infiniti","Lexus","Lincoln","Buick","GMC","Cadillac","Porsche","Mini","Seat","Alfa Romeo","Land Rover","Jaguar"];fetch("/api/catalog/brands").then((function(t){return t.json()})).then((function(t){t&&t.length>0?b(t):b(M.map((function(t,e){return{id_brand:e,name_brand:t}})))})).catch((function(){b(M.map((function(t,e){return{id_brand:e,name_brand:t}})))})),fetch("/api/catalog/stats").then((function(t){return t.json()})).then((function(t){[{format:"1.5M",key:"parts"},{format:"304K",key:"aftermarket_parts"},{format:"15.8M",key:"cross_references"},{format:"num",key:"brands"}].forEach((function(e){var n=document.querySelector('[data-format="'+e.format+'"]'),a=t[e.key];n&&"number"==typeof a&&a>0&&(n.setAttribute("data-target",a),n._animated&&(-1!==e.format.indexOf("M")?n.textContent=(a/1e6).toFixed(1)+"M+":-1!==e.format.indexOf("K")?n.textContent=Math.floor(a/1e3)+"K+":n.textContent=String(a)))}))})).catch((function(){})),document.querySelectorAll('.header-nav a[href^="#"]').forEach((function(t){t.addEventListener("click",(function(e){e.preventDefault();var n=document.querySelector(t.getAttribute("href"));n&&n.scrollIntoView({behavior:"smooth",block:"start"})}))}));var p=document.querySelector(".site-header");p&&window.addEventListener("scroll",(function(){window.scrollY>80?p.style.background="var(--glass-bg-strong)":p.style.background="var(--glass-bg)"}),{passive:!0})}();