(function (url, position) {var BOTTOM_LEFT="bottom_left",BOTTOM_RIGHT="bottom_right",iframe=document.createElement("iframe");iframe.setAttribute("src",url),iframe.style.width="0",iframe.style.height="0",iframe.style.border="0",iframe.style.margin="0",iframe.style.padding="0",iframe.style.scroll="no",iframe.addEventListener("load",onFrameLoad,!1);var needChatOpen=needChatClose=!1;function onFrameLoad(e){var t=e.target;setInterval(function(){t.style.height=t.contentWindow.document.body.clientHeight+"px",t.style.width=t.contentWindow.document.body.scrollWidth+"px",needChatOpen&&deliverEvent("mia:open",function(){needChatOpen=!1}),needChatClose&&deliverEvent("mia:close",function(){needChatClose=!1})},0),customPosition&&(t.contentWindow.document.body.className+=" mia-chat-custom-position")}function deliverEvent(e,t){var n=new Event(e);iframe.contentWindow.document.dispatchEvent(n),"function"==typeof t&&t()}function acceptEvent(e,t){window.document.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof t&&t()})}acceptEvent("mia:open",function(){needChatOpen=!0}),acceptEvent("mia:close",function(){needChatClose=!0});var customPosition=!1,wrapper=document.querySelector('[data-mia-chat="wrapper"]');if(wrapper)customPosition=!0,wrapper.appendChild(iframe);else{switch((wrapper=document.createElement("div")).className="mia-chat",wrapper.style.position="fixed",position){case BOTTOM_RIGHT:wrapper.style.right="5px",wrapper.style.bottom="-4px";break;case BOTTOM_LEFT:default:wrapper.style.left="5px",wrapper.style.bottom="-4px"}wrapper.style.margin="0",wrapper.style.padding="0",wrapper.style.overflow="hidden",wrapper.style.zIndex=1e6,wrapper.appendChild(iframe),document.body.appendChild(wrapper)}})('/mia-proxy/chat/window/render', 'bottom_left');