'; } function openPdf(){ if (!root.__veLast) return; var s = root.__veLast.state; var r = root.__veLast.res; var link = root.__veLast.link || buildUrl(root, { install: s.install, width: s.w, height: s.h, depth: s.d }); var logoUrl = detectLogoUrl(); var html = buildPdfHtml(s, r, link, logoUrl); var iframe = document.createElement('iframe'); iframe.style.position = 'fixed'; iframe.style.left = '-9999px'; iframe.style.top = '0'; iframe.style.width = '1px'; iframe.style.height = '1px'; iframe.style.opacity = '0'; iframe.style.border = '0'; iframe.setAttribute('aria-hidden','true'); document.body.appendChild(iframe); var doc = iframe.contentWindow.document; doc.open(); doc.write(html); doc.close(); var cleaned = false; function cleanup(){ if (cleaned) return; cleaned = true; try{ document.body.removeChild(iframe); }catch(e){} } try{ iframe.contentWindow.onafterprint = cleanup; }catch(e){} setTimeout(cleanup, 60000); try{ iframe.contentWindow.focus(); iframe.contentWindow.print(); pushEvent('download_pdf', { tool: 'dishwasher_niche_checklist' }); } catch(e){ cleanup(); toast('Не удалось открыть печать. Проверьте настройки браузера.'); } } qsa(root, 'input').forEach(function(el){ el.addEventListener('input', function(){ userInteracted = true; scheduleCalc(); }); el.addEventListener('change', function(){ userInteracted = true; syncVisibility(); scheduleCalc(); }); }); if (btnCopyResult){ btnCopyResult.addEventListener('click', function(){ if (!root.__veLast) return; copyToClipboard(root.__veLast.share).then(function(){ toast('Результат скопирован'); pushEvent('copy_result', { tool:'dishwasher_niche_checklist' }); }).catch(function(){ toast('Не удалось скопировать'); }); }); } if (btnCopyLink){ btnCopyLink.addEventListener('click', function(){ if (!root.__veLast) return; copyToClipboard(root.__veLast.link).then(function(){ toast('Ссылка скопирована'); pushEvent('copy_link', { tool:'dishwasher_niche_checklist' }); }).catch(function(){ toast('Не удалось скопировать'); }); }); } if (btnPdf){ btnPdf.addEventListener('click', function(){ if (!root.__veLast) return; openPdf(); }); } setBtns(false); applyDefaults(); applyParams(); syncVisibility(); calcAndRender(); return true; } var mountTimer = null; function scheduleMount(){ clearTimeout(mountTimer); mountTimer = setTimeout(mountAll, 50); } function mountAll(){ var roots = document.querySelectorAll('[data-ve-pmm-lite]'); for (var i=0; i= 20) clearInterval(iv); }, 300); if (window.MutationObserver){ try{ var mo = new MutationObserver(function(){ scheduleMount(); }); mo.observe(document.documentElement || document.body, { childList:true, subtree:true }); }catch(e){} } })();