(function(){"use strict";const I="https://widget.drive-dk.com",O="https://widget-test.drive-dk.com",R="https://lk.rosstrah.ru",v="ekosmotr-technical-inspection-widget",L=o=>{const s=document.cookie.split("; ").find(r=>r.startsWith(`${encodeURIComponent(o)}=`));return s?decodeURIComponent(s.substring(s.indexOf("=")+1)):null},D=(o,s,r,l="*")=>{const p={type:s,payload:r};o.postMessage(p,l)},u=(o,s,r)=>{const l=I;o.contentWindow&&D(o.contentWindow,s,r,l)},S=o=>{window.addEventListener("message",o)},N=o=>{window.removeEventListener("message",o)},C=o=>{S(o)},G=o=>{N(o)},M=o=>{navigator.geolocation||console.warn("Геолокация не поддерживается браузером"),navigator.geolocation.getCurrentPosition(o,s=>{s.code===s.PERMISSION_DENIED?console.warn("Доступ к геолокации запрещен"):console.warn("Не удалось получить координаты")})};(()=>{const o="ti-widget",s=`${o}-styles`,r=`${o}-loader`,l=`${o}-loader-circle`,p=`${o}-loader-clip`,_=`${o}-loader-rotate`,W="400px",P=()=>{if(document.getElementById(s))return;const e=document.createElement("style");e.id=s,e.textContent=` #${r} { width: 100%; height: ${W}; display: flex; justify-content: center; align-items: center; } #${r} .${l} { width: 50px; aspect-ratio: 1; border-radius: 50%; border: 4px solid rgb(130, 130, 130); animation: ${p} 0.8s infinite linear alternate, ${_} 1.6s infinite linear; } @keyframes ${p} { 0% {clip-path: polygon(50% 50%,0 0, 50% 0%, 50% 0%, 50% 0%, 50% 0%, 50% 0% )} 12.5% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100% 0%, 100% 0%, 100% 0%, 100% 0% )} 25% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100% 0%, 100% 100%, 100% 100%, 100% 100% )} 50% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100% 0%, 100% 100%, 50% 100%, 0% 100% )} 62.5% {clip-path: polygon(50% 50%,100% 0, 100% 0%, 100% 0%, 100% 100%, 50% 100%, 0% 100% )} 75% {clip-path: polygon(50% 50%,100% 100%, 100% 100%, 100% 100%, 100% 100%, 50% 100%, 0% 100% )} 100% {clip-path: polygon(50% 50%,50% 100%, 50% 100%, 50% 100%, 50% 100%, 50% 100%, 0% 100% )} } @keyframes ${_} { 0% {transform:scaleY(1) rotate(0deg)} 49.99%{transform:scaleY(1) rotate(135deg)} 50% {transform:scaleY(-1) rotate(0deg)} 100% {transform:scaleY(-1) rotate(-135deg)} } `,document.head.appendChild(e)},k=e=>{if(!e.querySelector(`#${r}`)){const c=document.createElement("div");c.id=r;const n=document.createElement("div");n.className=l,c.appendChild(n),e.appendChild(c),P()}},h=(e,t)=>{if(!e.contentWindow)return;const c={accessKey:t.getAttribute("data-access-key"),userKey:t.getAttribute("data-user-key"),isFooter:t.getAttribute("data-is-footer"),isDraft:t.getAttribute("data-is-draft"),themeName:t.getAttribute("data-theme"),themeMode:t.getAttribute("data-mode"),cityId:t.getAttribute("data-city"),subcategory:t.getAttribute("data-subcategory"),stationMask:t.getAttribute("data-station"),clientName:t.getAttribute("data-client-name"),clientPhone:t.getAttribute("data-client-phone"),vehicleRegNumber:t.getAttribute("data-reg-number"),vehicleBrand:t.getAttribute("data-brand"),vehicleModel:t.getAttribute("data-model"),vehicleIdVariant:t.getAttribute("data-vehicle-id-variant"),vehicleId:t.getAttribute("data-vehicle-id")};u(e,"TI_WIDGET_SET_PARTNER_ATTRIBUTES",c)},A=e=>{u(e,"TI_WIDGET_SET_WINDOW_DATA",{partnerUrl:window.location.href})};let T=null,m=0;const y=5,$=120/y,U=e=>{const t=L("roistat_visit");return t?(u(e,"TI_WIDGET_SET_PARTNER_COOKIES",{roistatVisit:t}),!0):!1},g=()=>{T&&(clearInterval(T),T=null),m=0},x=(e,t)=>{g(),T=window.setInterval(()=>{if(!document.body.contains(t)||!(e!=null&&e.contentWindow)){g();return}if(m+=1,m>$){g();return}if(U(e)){g();return}},y*1e3)},H=e=>{M(t=>{u(e,"TI_WIDGET_SET_NAVIGATOR_DATA",{geolocation:[t.coords.latitude,t.coords.longitude]})})};let d,a;const V=()=>{d&&(d.disconnect(),d=null),a&&(G(a),a=null),g()},b=["yoomoney.ru"];{const e=new URL(R).hostname;e&&b.push(e)}const Y=50,f=()=>{const e=document.getElementById(v);if(!e){V();return}let t=e.querySelector("iframe");const c=I;t||(k(e),t=document.createElement("iframe"),t.setAttribute("width","100%"),t.setAttribute("scrolling","no"),t.setAttribute("frameborder","0"),t.setAttribute("src",c),t.setAttribute("allow","clipboard-read; clipboard-write"),t.setAttribute("title","Technical inspection widget"),e.appendChild(t),t.onload=()=>{setTimeout(()=>{t&&(h(t,e),A(t),x(t,e))},100)},a||(a=({data:n,origin:E})=>{var w;if(!(![I,O].includes(E)||typeof n!="object"||n===null)){if(n.type==="TI_WIDGET_READY"){const i=e.querySelector(`#${r}`);i&&i.remove()}if(n.type==="TI_WIDGET_PARENT_UPDATE_SIZE"){const i=(w=n.payload)==null?void 0:w.height;t&&i&&(t.style.height=`${i}px`)}if(n.type==="TI_WIDGET_PARENT_NAVIGATE_TO")try{const i=new URL(n.payload.url,window.location.href);(i.protocol==="https:"||i.protocol==="http:")&&b.includes(i.hostname)&&(window.location.href=i.href)}catch{console.warn("Невалидный URL для перехода из виджета техосмотра")}if(n.type==="TI_WIDGET_PARENT_GET_GEOLOCATION"&&t&&H(t),n.type==="TI_WIDGET_PARENT_SCROLL_TO"){if(!t)return;const{top:i}=n.payload||{};if(i==null)return;const B=t.getBoundingClientRect(),F=window.pageYOffset+B.top+i-Y;window.scrollTo({top:Math.max(0,F),behavior:"smooth"})}}},a&&C(a)),d||(d=new MutationObserver(()=>{t&&(h(t,e),A(t))}),d.observe(e,{attributes:!0})),window.addEventListener("message",n=>{var E;t&&((E=n.data)==null?void 0:E.type)==="SET_THEME"&&u(t,"TI_WIDGET_SET_THEME",{theme:n.data.theme})}))};document.readyState==="complete"||document.readyState==="interactive"?f():window.addEventListener("DOMContentLoaded",()=>{f()}),new MutationObserver(()=>{f()}).observe(document.body,{childList:!0,subtree:!0})})()})();