six-messenger.legacy.min.js 3.9 KB

1
  1. "use strict";var _window$opener;function _createForOfIteratorHelper(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}window.addEventListener("message",function(e){var r=e.data;switch(null==r?void 0:r.type){case"insert:script":var t=document.createElement("script");r.src&&(t.src=r.src),r.code&&(t.textContent=r.code),document.head.appendChild(t);break;case"insert:css":if(r.src){var n=document.createElement("link");n.rel="stylesheet",n.href=r.src,document.head.appendChild(n)}if(r.code){var o=document.createElement("style");o.textContent=r.code,document.head.appendChild(o)}}});var windowProxy=null!==(_window$opener=window.opener)&&void 0!==_window$opener?_window$opener:window.parent!==window?window.parent:void 0;function getURLSearchParams(e){return null!=e||(e="".concat(location.search,"&").concat(location.hash.split("?")[1]||"")),new URLSearchParams(e)}function _monitor(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=Date.now();return new Promise(function(n,o){var a,i=function(){var u=e();null!=u?(cancelAnimationFrame(a),n(u)):r>0&&Date.now()-t>r?o(new Error("timeout")):a=requestAnimationFrame(i)};i()})}function _getFirstCanvasData(){var e=function(r){return"none"!==getComputedStyle(r).display&&(!r.parentElement||e(r.parentElement))};return _monitor(function(){var r,t=_createForOfIteratorHelper(document.querySelectorAll(".mai-3d [_echarts_instance_] canvas"));try{for(t.s();!(r=t.n()).done;){var n=r.value;if(e(n))return n}}catch(e){t.e(e)}finally{t.f()}return null})}window.addEventListener("loadstart",function(){null==windowProxy||windowProxy.postMessage({type:"event:loadstart"},"*")}),window.addEventListener("load",function(){null==windowProxy||windowProxy.postMessage({type:"event:load"},"*")}),document.addEventListener("DOMContentLoaded",function(){null==windowProxy||windowProxy.postMessage({type:"event:DOMContentLoaded"},"*")}),document.addEventListener("DOMContentLoaded",function(){if(windowProxy){var e=getURLSearchParams();"true"!==e.get("overallLeft")&&"true"!==e.get("overallRight")||1!==_toConsumableArray(e.values()).filter(function(e){return"true"===e}).length||_getFirstCanvasData().then(function(e){var r;_monitor(function(){r=e.toDataURL("image/png"),null==windowProxy||windowProxy.postMessage({type:"event:draw",data:r,done:!1},"*")},1e4).catch(function(){null==windowProxy||windowProxy.postMessage({type:"event:draw",data:r,done:!0},"*")})})}});