/* Js for , Version=1785139387 */
 if(typeof(v) != "object") v = {};v.pageID = 85;;
;
        // 数字滚动动画函数（支持千位分隔符和单位）
        const animateCounter = (counterElement) => {
            const target = +counterElement.getAttribute('data-target');
            const unit = counterElement.getAttribute('data-unit') || ''; 
            const duration = 2000; 
            let start = 0;
            let current = 0;

            const step = (timestamp) => {
                if (!start) start = timestamp;
                const elapsed = timestamp - start;

                const progress = Math.min(elapsed / duration, 1);
                current = Math.floor(progress * target); 

                const formattedNumber = current.toLocaleString('en-US'); 
                
                counterElement.textContent = formattedNumber + unit;

                if (progress < 1) {
                    requestAnimationFrame(step);
                } else {
                    counterElement.textContent = target.toLocaleString('en-US') + unit; 
                }
            };

            requestAnimationFrame(step);
        };

        // 页面加载完成后执行
        document.addEventListener("DOMContentLoaded", function() {
            const sections = document.querySelectorAll('.fade-in-section');
            const generalCounters = document.querySelectorAll('.data-dashboard .counter'); 
            const capacityCounters = document.querySelectorAll('.capacity-counter'); 
            
            const allCounters = [...generalCounters, ...capacityCounters];

            const counterObserverMap = new WeakMap();

            const options = {
                root: null, 
                rootMargin: '0px',
                threshold: 0.1 
            };

            const observer = new IntersectionObserver((entries, observer) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        // 1. 实现整体区块淡入效果
                        entry.target.classList.add('is-visible');

                        // 2. 触发数字滚动效果
                        if (entry.target.id === 'data-visualization' || entry.target.id === 'products-capacity') {
                            allCounters.forEach(counter => {
                                if (entry.target.contains(counter) && !counterObserverMap.get(counter)) {
                                    animateCounter(counter);
                                    counterObserverMap.set(counter, true);
                                }
                            });
                        }
                        
                        // 3. 触发时间轴分步动画
                        if (entry.target.id === 'progress') {
                            const timelineItems = entry.target.querySelectorAll('.timeline-item');
                            timelineItems.forEach((item, index) => {
                                // 错开动画：每个项目延迟 200ms 出现
                                setTimeout(() => {
                                    item.classList.add('item-visible');
                                }, index * 200);
                            });
                        }
                        
                        observer.unobserve(entry.target);
                    }
                });
            }, options);

            sections.forEach(section => {
                observer.observe(section);
            });
        });
    