UNPKG

shadow-function

Version:

ioing lib - shadow Function, worker Function

1 lines 28.7 kB
console.log("shadow-function v1.0.101"),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.ioing={})}(this,function(t){"use strict";function d(t,e,n){var o,r,i,a,s;if(void 0===e&&(e=!1),void 0===n&&(n={}),t){if(n="Object"===S(n)?n:{},e)for(o=0,r=Object.getOwnPropertyNames(t);o<r.length&&(a=t[i=r[o]],s=n[i],a)&&(c=a,!Object.isFrozen(c))&&!s&&(d(a.prototype,!0,n),d(a.__proto__,!0,n),(Object.getOwnPropertyDescriptor(t,i)||{}).writable);o++)t[i]=a&&"object"==typeof a?d(a,!0):a;var c;return Object.freeze(t)}}var a,i,r,e,n,o,c,s,u,p,l,w,h,f,m,y,g,b,E=["Object","Function","Array","Number","parseFloat","parseInt","Infinity","NaN","undefined","Boolean","String","Symbol","Date","Promise","RegExp","Error","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","JSON","Math","console","Intl","ArrayBuffer","Uint8Array","Int8Array","Uint16Array","Int16Array","Uint32Array","Int32Array","Float32Array","Float64Array","Uint8ClampedArray","BigUint64Array","BigInt64Array","DataView","Map","BigInt","Set","WeakMap","WeakSet","Proxy","Reflect","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape","eval","isFinite","isNaN","TreeWalker","SVGAElement","Range","NodeList","NodeIterator","NodeFilter","Node","Element","HTMLElement","document","innerheight","innerwidth","outerheight","outerwidth","pageXOffset","pageYOffset","addEventListener","removeEventListener","dispatchEvent","Screen","alert","clearInterval","clearTimeout","valueOf","confirm","scrollTo","setInterval","setTimeout","toString","Float32Array","Proxy","EventTarget","hasOwnProperty","isPrototypeOf","toLocaleString","propertyIsEnumerable","__proto__","__defineGetter__","__lookupGetter__","__defineSetter__","__lookupSetter__"],v=function(){function t(t,e,n){void 0===t&&(t=!1),void 0===e&&(e=["*"]),void 0===n&&(n="allow-scripts allow-same-origin"),this.windowOwnPropertyNames=E;var o=this.sandbox=document.createElement("iframe");return o.src="about:blank",o.style.display="none",this.windowOwnPropertyNames=this.windowOwnPropertyNames.concat(e),this.white=t,this.set(n),this.enter(),this.shadow(),t||this.exit(),this}return t.getWindowOwnPropertyNames=function(){return E},t.debugger=function(t,e){void 0===e&&(e={"safe-context":"safe"});var n="I know the danger!";t===n?(this.prototype["open debugger"]=!0,"unsafe"===e["safe-context"]?this.prototype["unsafe-context"]=!0:console.warn("%c Sandbox: Opening the 'debugger' will result in a risk of losing security!","font-size: 32px; color: red")):console.log("Sandbox: Opening 'debugger' input '"+n+"'")},t.prototype.shadow=function(){var t,e,n,o,r,i,a,s=this.sandbox.contentWindow,c=this.sandbox.contentDocument;if(this.window=s,this.content=this.document=c,this.white)return this;for(t=this.getProtoProperty(this.window),e=this.window.Object,n=~this.windowOwnPropertyNames.indexOf("*"),this.shadowWindow=new s.Object,o=function(t){if(r.window[t]+""!="[object Window]"&&(n||~r.windowOwnPropertyNames.indexOf(t)))r.shadowWindow[t]=r.window[t];else try{e.defineProperty(r.shadowWindow,t,{configurable:!0,enumerable:!0,writable:!0,get:function(){return console.error("Sandbox Error: Unauthorized use of window['"+t+"']."),null}}),r.delProtoProperty(r.window,t)}catch(t){}},r=this,i=0,a=t;i<a.length;i++)o(a[i]);return this.shadowWindow.shadowWindow=this.shadowWindow,this.shadowWindow.window=this.shadowWindow,this},t.prototype.getProtoProperty=function(t){var e=Object.getOwnPropertyNames(t);return t.__proto__?e.concat(this.getProtoProperty(t.__proto__)):e},t.prototype.delProtoProperty=function(t,e){return!!t&&(t.__proto__?t.__proto__.hasOwnProperty(e)?delete t.__proto__[e]:this.delProtoProperty(t.__proto__,e):delete t[e])},t.prototype.set=function(t){this.sandbox.setAttribute("sandbox",t)},t.prototype.reset=function(t){return this.exit(),this.set(t),this.enter(),this.shadow(),this},t.prototype.open=function(){return this.content.open(),this},t.prototype.write=function(t){return void 0===t&&(t='<head><meta charset="utf-8"></head>'),this.content.write(t),this},t.prototype.close=function(){return this.content.close(),this},t.prototype.enter=function(){document.documentElement.appendChild(this.sandbox)},t.prototype.exit=function(){if(!this["open debugger"]){var t=this.sandbox.parentNode;t&&t.removeChild(this.sandbox)}},t}(),S=function(t){var e=Object.prototype.toString.call(t),n=/\s*\[(\w+) (\w+)\]\s*/.exec(e)||[];switch(n[1]){case"object":return n[2];case"native":return"native"}return"unknow"},T={Node:["nodeName","nodeType","textContent"],Element:["style","onblur","onfocus","onscroll","offsetWidth","offsetHeight","clientWidth","clientHeight","innerText","setAttribute","removeAttribute","createTextNode","addEventListener","getElementsByTagName"],HTMLElement:[],HTMLBodyElement:[],HTMLDivElement:[],HTMLUListElement:[],HTMLLIElement:[],HTMLVideoElement:[],HTMLAudioElement:[],HTMLSelectElement:[],HTMLOptionElement:[],HTMLInputElement:[],HTMLSpanElement:[],HTMLDListElement:[],HTMLFontElement:[],HTMLHeadingElement:[],HTMLParagraphElement:[],HTMLDocument:["documentElement","body"],Navigator:["appCodeName","appName","appVersion","language","languages","maxTouchPoints","onLine","platform","product","productSub","userAgent","vendor","vendorSub"],UserActivation:["hasBeenActive","isActive"],Promise:["then","catch","resolve"],Touch:["clientX","clientY","force","identifier","pageX","pageY","radiusX","radiusY","rotationAngle","screenX","screenY","target"],TouchEvent:["altKey","bubbles","cancelBubble","cancelable","changedTouches","composed","ctrlKey","currentTarget","defaultPrevented","detail","eventPhase","metaKey","returnValue","shiftKey","sourceCapabilities","targetTouches","timeStamp","touches","type","which"],MouseEvent:["altKey","bubbles","button","buttons","cancelBubble","cancelable","clientX","clientY","composed","ctrlKey","defaultPrevented","detail","eventPhase","fromElement","getModifierState","initMouseEvent","layerX","layerY","metaKey","movementX","movementY","offsetX","offsetY","pageX","pageY","relatedTarget","returnValue","screenX","screenY","shiftKey","sourceCapabilities","timeStamp","type","which","x","y"]},O=function(){function t(){var e=this;this.sandbox=new v(!1,this["allow properties"]||["*"]),this.shadowWindow=this.sandbox.shadowWindow,this.ShadowFunction=this.shadowWindow.Function,this.shadowHasOwnProperty=this.shadowWindow.Object.hasOwnProperty,this.ShadowObject=this.shadowWindow.Object,this.ShadowProxy=this.shadowWindow.Proxy,this.allowProtoProperties=T,this.run=function(){return null},this.tracker=function(t){if("symbol"==typeof t.name||!isNaN(Number(t.name)))return"no";switch(t.name){case"length":case"__proto__":break;default:return e.log(t)}return"no"},this.freezeShadowProto(this.shadowWindow)}return t.prototype.log=function(t){return console.log("Event Log:",t)},t.debugger=function(t,e){void 0===e&&(e={"no-Proxy":!1});var n="I know the danger!";t===n?(this.prototype["open debugger"]=!0,e["no-Proxy"]&&(this.prototype["open debugger: no-Proxy"]=!0),!0!==v.prototype["unsafe-context"]&&console.warn("%c ShadowFunction: Opening the 'debugger' will result in a risk of losing security!","font-size: 32px; color: red")):console.log("ShadowFunction: Opening 'debugger' input '"+n+"'")},t.assignContextProperties=function(t){void 0===t&&(t=["*"]),this.prototype["allow properties"]=t},t.prototype.setAllowProtoProperties=function(t){return Object.assign(this.allowProtoProperties,t),this.preShadowFunction.bind(this)},t.prototype.freezeShadowProto=function(t){var e,n,o,r,i=this.ShadowObject,a=i.getOwnPropertyNames(t);for(e=0,n=a;e<n.length&&(r=t[o=n[e]])&&(i.getOwnPropertyDescriptor(t,o)||{}).writable;e++)"object"==typeof r&&this.freezeShadowProto(r);i.isFrozen(t.prototype)||i.freeze(t.prototype)},t.prototype.getAllowProperties=function(t){return this.getAllowProtoProperties(t).concat(Object.getOwnPropertyNames(t))},t.prototype.getAllowProtoProperties=function(t){var e=this.allowProtoProperties[S(t)]||[];return t.__proto__?e.concat(this.getAllowProtoProperties(t.__proto__)):e},t.prototype.isElementObject=function(t){return!!/HTML(\w+)?Element/.exec(S(t))},t.prototype.isFixedObject=function(t){return!this.isElementObject(t)&&"object"==typeof t},t.prototype.safeGetter=function(t,e,n){return this["open debugger"]&&"..."===n?(console.warn("ShadowFunction: Unsafe return in debug mode!"),t):-1===this.getAllowProperties(t).indexOf(n)?(this.tracker({origin:t,name:n,action:"read"}),e[n]):t[n]&&!this.isFixedObject(t[n])&&t[n].hasOwnProperty===this.shadowHasOwnProperty?t[n]:this.proxy(t[n],t)},t.prototype.safeSetter=function(t,e,n,o){return e[n]=this.proxy(o,e),this.tracker({origin:t,name:n,action:"write",value:o})==="allow set "+n&&(t[n]=e[n]),!0},t.prototype.puppet=function(o){var r=this,t=this.ShadowProxy,e=Object.getOwnPropertyNames(o),n=new this.ShadowObject;return e.map(function(t){(Object.getOwnPropertyDescriptor(n,t)||{writable:!0}).writable&&(n[t]="...")}),new t(n,{get:function(t,e){return r.safeGetter(o,t,e)},set:function(t,e,n){return r.safeSetter(o,t,e,n)}})},t.prototype.proxy=function(t,e){if(void 0===e&&(e=null),this["open debugger: no-Proxy"]||!t)return t;switch(typeof t){case"string":case"number":case"boolean":case"undefined":return t;case"function":return this.safeReturnFunction(t,e);case"object":return this.puppet(t)}},t.prototype.safeReturnFunction=function(t,e){var n,o,r,i=new this.ShadowFunction("fn","origin","proxy","\n return (function () {\n return function () {\n return proxy(fn.apply(origin, proxy(arguments)))\n }\n })()\n ")(t,e,this.proxy.bind(this)),a=Object.getOwnPropertyNames(t);for(n=0,o=a;n<o.length;n++)if(r=o[n],(Object.getOwnPropertyDescriptor(t,r)||{writable:!0}).writable){if("prototype"===r)continue;i[r]=this.proxy({0:t[r]})[0]}return i},t.prototype.preShadowFunction=function(t){return this.shadowFunction=new this.ShadowFunction("\n (function () {\n with (arguments[0].window || {}) {\n with (arguments[0].context || {}) {\n (function () {"+t+"}).bind(Object.assign(arguments[0].window || {}, arguments[0].context || {}))()\n }\n }\n })(this)"),this.runShadowFunction.bind(this)},t.prototype.runShadowFunction=function(t){var e=this.proxy(t),n=this.shadowFunction;return n.apply(this.ShadowObject.assign(new this.ShadowObject,{window:this.shadowWindow,context:e})),{run:this.preShadowFunction.bind(this),proxy:this.proxy.bind(this),sandbox:this.sandbox}},t}(),P=function(t,e,n){var o=new O;if(n&&(o.log=n),e)o.run=o.setAllowProtoProperties(e)(t);else switch(typeof t){case"object":o.run=o.setAllowProtoProperties(t);break;case"string":o.run=o.preShadowFunction(t);break;default:throw new Error("ShadowFunction: Uncaught SyntaxError: Unexpected identifier.")}return o.run};P.debugger=O.debugger.bind(O),a=document,i=0,r=function(){function t(t,e,n,o){void 0===n&&(n=[{},{}]);var r=this;this.run=function(){return null},this.constructorId=0,this.o=0,this.allowTagName={DIV:!0,B:!0,P:!0,H1:!0,H2:!0,H3:!0,H4:!0,H5:!0,DL:!0,DT:!0,DD:!0,EM:!0,HR:!0,UL:!0,LI:!0,OL:!0,TD:!0,TH:!0,TR:!0,TT:!0,NAV:!0,SUP:!0,SUB:!0,SPAN:!0,FONT:!0,BR:!0,STYLE:!0,SMALL:!0,LABEL:!0,TABLE:!0,TBODY:!0,THEAD:!0,TFOOT:!0,BUTTON:!0,FOOTER:!0,HEADER:!0,STRONG:!0},this.tracker=function(t){"function"==typeof r.log?r.log(t):console.log("Event Log:",t)},this.getRealElement=function(t){return r.TREE[t.uuid]||new Error("ShadowFunction: Cannot synchronously read compiled style. Async read after the rendering ends / or use '<HTMLElement>.oncomputed = () => { element.offsetTop }'!")},this.TREE={0:t.attachShadow?t.attachShadow({mode:"open"}):t},this.SHADOWTREE={},Object.assign(this.allowTagName,n[0]||n),this.log=o,this.constructorId=i++,this.shadowFunction=new P(n[1]||{},void 0,o),this.shadowFunction=this.shadowFunction(this.injection())(this.empowerment()),this.sandbox=this.shadowFunction.sandbox,this.shadowWindow=this.sandbox.shadowWindow,this.shadowDocumentBody=this.shadowWindow.document.body,this.ShadowObject=this.shadowWindow.Object,this.ShadowNode=this.shadowWindow.Node,this.ShadowElement=this.shadowWindow.Element,this.shadowGetAttribute=this.ShadowElement.prototype.getAttribute,this.setShadowObserver(),this.write(e),this.run=this.shadowFunction.run.bind(this)}return t.prototype.empowerment=function(){var a=this;return{getShadowElement:function(t){return a.getRealElement(t)},getShadowElementProps:function(t,e){return a.getRealElement(t)[e]},getComputedStyle:function(t,e){return void 0===e&&(e=null),getComputedStyle(a.getRealElement(t),e)},setShadowEventListener:function(t,e,n,o){var r=null,i="on-shadow-"+e+"-"+a.constructorId;switch(t){case"[object Window]":r=window;break;case"[object HTMLDocument]":r=document;break;case"[object HTMLBodyElement]":r=document.body;break;case"[object HTMLHtmlElement]":r=document.documentElement}if(r){if(!n)return r.removeEventListener(e,r[i]);Object.defineProperty(r,i,{enumerable:!1,configurable:!0,writable:!1,value:function(t){n.apply(n,[a.createShadowEventObject(t)])}}),r.addEventListener(e,r[i],o)}}}},t.prototype.isElementObject=function(t){return!!/HTML(\w+)?Element/.exec(S(t))},t.prototype.createShadowEventObject=function(t){var e,n,o={};for(e in t)switch(typeof(n=t[e])){case"string":case"number":case"boolean":case"undefined":o[e]=n;break;case"function":o[e]=n.bind(t);break;case"object":switch(e){case"changedTouches":case"sourceCapabilities":case"targetTouches":case"touches":o[e]=this.createShadowEventObject(n);break;case"srcElement":case"target":case"toElement":this.isElementObject(n)&&(o[e]=this.SHADOWTREE[n.uuid]);break;default:isNaN(Number(e))?o[e]=n:o[e]=this.createShadowEventObject(n)}}return o},t.prototype.injection=function(){return"\n window.addEventListener = EventTarget.prototype.addEventListener = function (type, callback, options) {\n var target = this\n var targetTypeName = Object.prototype.toString.call(target)\n if (!target['onShadowEventNames']) {\n Object.defineProperty(target, 'onShadowEventNames', {\n enumerable: false,\n configurable: true,\n writable: true,\n value: [type]\n })\n } else {\n target['onShadowEventNames'].push(type)\n }\n if (!target['onshadow' + type]) {\n Object.defineProperty(target, 'onshadow' + type, {\n enumerable: false,\n configurable: true,\n writable: true,\n value: {\n type: type,\n options: options,\n callback: [callback]\n }\n })\n setShadowEventListener(targetTypeName, type, function () {\n var args = arguments\n target['onshadow' + type].callback.map(function (fn) {\n fn.apply(target, args)\n })\n }, options)\n } else {\n target['onshadow' + type].callback.push(callback)\n }\n }\n window.removeEventListener = EventTarget.prototype.removeEventListener = function (type, callback, options) {\n var target = this\n var targetTypeName = Object.prototype.toString.call(target)\n var callbackIndex = this['onshadow' + type].callback.indexOf(callback)\n var eventNameIndex = this['onShadowEventNames'].indexOf(type)\n if (eventNameIndex !== -1) {\n this['onShadowEventNames'].splice(eventNameIndex, 1)\n }\n if (callbackIndex !== -1) {\n this['onshadow' + type].callback.splice(callbackIndex, 1)\n }\n if (this['onshadow' + type].callback.length === 0) {\n setShadowEventListener(targetTypeName, type)\n }\n }\n shadowWindow.Object.defineProperties(shadowWindow.HTMLElement.prototype, {\n 'offsetHeight': {\n get () {\n return getShadowElementProps(this, 'offsetHeight')\n }\n },\n 'offsetWidth': {\n get () {\n return getShadowElementProps(this, 'offsetWidth')\n }\n },\n 'offsetTop': {\n get () {\n return getShadowElementProps(this, 'offsetTop')\n }\n },\n 'offsetLeft': {\n get () {\n return getShadowElementProps(this, 'offsetLeft')\n }\n },\n 'offsetParent': {\n get () {\n return getShadowElementProps(this, 'offsetParent')\n }\n },\n 'ref': {\n get () {\n return getShadowElement(this)\n }\n }\n })\n "},t.prototype.setShadowObserver=function(){var r=this;new MutationObserver(function(t){var e,n,o=function(t){var e=t.target;switch(t.type){case"attributes":r.setAttribute(t.attributeName,e);break;case"characterData":r.setCharacterData(e);break;case"childList":Array.prototype.forEach.call(t.removedNodes,function(t){r.walker(r.iterator(t),e,!0)}),Array.prototype.forEach.call(t.addedNodes,function(t){r.walker(r.iterator(t),e)})}};for(e=0,n=t;e<n.length;e++)o(n[e])}).observe(this.shadowDocumentBody,{subtree:!0,attributes:!0,childList:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0})},t.prototype.write=function(t){this.shadowDocumentBody.innerHTML="<div>"+t+"</div>"},t.prototype.uuid=function(t,e){return e=parseInt(t.parentNode&&t.parentNode.uuid||0,10),e++,this.o++,e=e+"."+this.o,t.uuid||(this.ShadowObject.defineProperty(t,"uuid",{configurable:!1,enumerable:!1,value:e}),this.SHADOWTREE[e]=t),e},t.prototype.iterator=function(t){return t.nextNode?t:a.createNodeIterator(t,NodeFilter.SHOW_ALL,null)},t.prototype.walker=function(t,e,n){void 0===n&&(n=!1);for(var o=t.nextNode();o;){switch(this.uuid(o),o.nodeType){case Node.ELEMENT_NODE:n?this.removeElement(o,e):this.createElement(o,e);break;case Node.TEXT_NODE:n?this.removeTextNode(o,e):this.createTextNode(o,e)}if(!(o=t.nextNode()))break}},t.prototype.getParentId=function(t,e){return(t.parentNode?t.parentNode.uuid:e.uuid)||0},t.prototype.createElement=function(t,e){var n,o=t.uuid,r=this.ShadowNode.prototype.cloneNode.call(t).nodeName,i=this.getParentId(t,e);if(!this.TREE[o]){switch(r){case this.allowTagName[r]?r:null:this.TREE[o]=a.createElement(r),this.TREE[o].uuid=o;break;default:throw this.tracker({tagName:r,action:"createElement"}),new Error("ShadowFunction: The tag name provided ('"+r+"') is not a valid name of whitelist.")}for(n=0;n<t.attributes.length;n++)this.setAttribute(t.attributes[n].name,t);t.completedState="complete",this.TREE[i].appendChild(this.TREE[o]),this.createEvent(t),this.shadowFunction.run("\n typeof computed === 'function' && computed(el)\n ")({el:this.TREE[o],computed:t.oncomputed})}},t.prototype.removeElement=function(t,e){var n=t.uuid,o=this.getParentId(t,e);this.TREE[o]&&this.TREE[n]&&this.TREE[o].removeChild(this.TREE[n]),delete this.TREE[n]},t.prototype.createTextNode=function(t,e){var n=t.uuid,o=this.getParentId(t,e),r=t.textContent||"";this.TREE[n]||(this.TREE[n]=a.createTextNode(r),this.TREE[n].uuid=n,this.TREE[o]&&this.TREE[o].appendChild(this.TREE[n]))},t.prototype.removeTextNode=function(t,e){var n=t.uuid,o=this.getParentId(t,e);this.TREE[o]&&this.TREE[n]&&this.TREE[o].removeChild(this.TREE[n]),delete this.TREE[n]},t.prototype.createEvent=function(n){var o=this,t=n.onShadowEventNames;t&&t.map(function(t){var e=n["onshadow"+t];e&&o.TREE[n.uuid].addEventListener(e.type,function(t){t=o.createShadowEventObject(t),o.shadowFunction.run("\n for (let i = 0; i < events.length; i++) {\n typeof(events[i]) === 'function' && events[i].apply(node, args)\n }\n ")({events:e.callback.map(function(t){return t.bind(n)}),node:n,args:[t]})},e.options)})},t.prototype.setAttribute=function(t,e){var n=this.TREE[e.uuid],o=this.ShadowNode.prototype.cloneNode.call(e),r=o.tagName,i=this.allowTagName[r],a=this.shadowGetAttribute.call(o,t),s=!1;if(n){switch(t){case"id":case"name":case"style":case"class":case"width":case"height":s=!0;break;default:if("function"!=typeof i||!i(t,a))throw this.tracker({tagName:r,attributeName:t,action:"setAttribute",value:a}),new Error("ShadowFunction: The attribute name provided ('"+t+" in <"+r.toLocaleLowerCase()+" />') is not a valid name of whitelist.");s=!0}n&&s&&n.setAttribute(t,a)}},t.prototype.setCharacterData=function(t){var e=this.TREE[t.uuid];e&&(e.textContent=t.textContent)},t}(),e=function(t,e,n,o){return void 0===n&&(n=[{},{}]),new r(t,e,n,o).run},n=function(){function t(t,e,n,o){return void 0===e&&(e=document.body),void 0===n&&(n="default-src 'self';"),this.root=e,this.create(t,n,o),this.run.bind(this)}return t.prototype.hashSource=function(){return new Array(8+Math.round(8*Math.random())).join(",").split(",").map(function(){return String.fromCharCode(97+Math.round(25*Math.random()))}).join("")},t.prototype.injectRequestParentAction=function(t){var s=this,c=this.hashSource();return window.addEventListener("message",function(t){var e,n,o=t.data||{},r=o.method,i=o.params,a=function(t){s.sandbox.contentWindow&&s.sandbox.contentWindow.postMessage({data:t,key:r+":"+JSON.stringify(i)},"*")};o.hash===c&&(n=void 0,(n="function"==typeof(e=s.methods[r])?e(i):e)instanceof Promise?n.then(a):a(n))},!1),'\n <meta http-equiv="Content-Security-Policy" content="'+t+"\">\n <script>\n window.requestParentAction = function (method, params) {\n parent.postMessage({ method: method, params: params, hash: '"+c+"' }, '"+location.origin+"')\n return new Promise(function (reslove, reject) {\n function callback (data) {\n if (data && data.data && data.data.data) {\n if (method + ':' + JSON.stringify(params) === data.data.key) {\n window.removeEventListener('message', callback)\n reslove(data.data.data)\n }\n } else {\n reject()\n }\n }\n window.addEventListener('message', callback)\n })\n }\n <\/script>\n "},t.prototype.create=function(t,e,n){void 0===n&&(n="fullscreen");var o=document.createElement("iframe");o.csp=e,o.src=URL.createObjectURL(new Blob([this.injectRequestParentAction(e)+" ;\n "+t],{type:"text/html"})),o.setAttribute("sandbox","allow-scripts"),"fullscreen"===n&&o.setAttribute("style","position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%"),this.sandbox=o},t.prototype.run=function(t){this.methods=t,this.root.appendChild(this.sandbox)},t}(),o=new v,c=function(){var t=o.shadowWindow.String,e=o.shadowWindow.Math,n=o.shadowWindow.Array;return new n(8+e.round(8*e.random())).join(",").split(",").map(function(){return t.fromCharCode(33+e.round(89*e.random()))}).join("")},s=function(){function t(t,e){var a,s,n,o,r,i=this;for(this.password=c(),this.tracker=function(t){"function"==typeof i.log?i.log(t):console.log("Event Log:",t)},s=(a=this).password,this.log=e,n=function(t){var o=t[0],r=t[1],i=o[r];Object.defineProperty(o,r,{get:function(){return a.password=s=c(),function(t,e){if(t!==s){var n={object:o,name:r,action:"read"};return e&&(n.value=e,n.action="write"),void a.tracker(n)}if(!e)return i;i=e}},set:function(){},enumerable:!0,configurable:!1}),d(o,!0)},o=0,r=t;o<r.length;o++)n(r[o]);return this}return t.prototype.lock=function(){E.forEach(function(t){var e=typeof window[t];if("object"===e||"function"===e)try{switch(t){case"window":break;default:d(window[t],!0)}}catch(t){}})},t}(),u=function(t){return t="string"==typeof t?t:"function"==typeof t?Object.toString.call(t):"",new Worker(URL.createObjectURL(new Blob([t],{type:"text/javascript"})))},p=function(){function t(t,e){this.task=t,this.polls=e.polls||2,this.timeout=e.timeout||3e3,this.timeoutId=null}return t.prototype.try=function(){var t=this;if(this.polls<=0)return!1;this.timeoutId=setTimeout(function(){0<t.polls--&&t.task()&&t.try()},this.timeout)},t.prototype.stop=function(){clearTimeout(this.timeoutId)},t.prototype.wait=function(t){this.timeout=t},t.prototype.over=function(){this.stop(),this.polls=0},t}(),l=document.documentElement,w="\n function clearUnsafe (proto) {\n var props = Object.getOwnPropertyNames(proto)\n props.map(function (key) {\n try {\n proto[key] = null\n delete proto[key]\n } catch (e) {}\n })\n }\n clearUnsafe(Document.prototype)\n clearUnsafe(Function.prototype)\n clearUnsafe(Object.prototype)\n clearUnsafe(HTMLElement.prototype)\n clearUnsafe(Element.prototype)\n clearUnsafe(Node.prototype)\n clearUnsafe(String.prototype)\n clearUnsafe(window)\n",h=function(u,h){return void 0===h&&(h={receiver:"",timeout:3e4,dataType:"module"}),new Promise(function(r,i){function a(){clearTimeout(o),window.removeEventListener("online",t,!1),e.parentElement&&l.removeChild(e)}function t(){var o=new Array(8+Math.round(8*Math.random())).join(",").split(",").map(function(){return String.fromCharCode(97+Math.round(25*Math.random()))}).join(""),t=document.createElement("script");t.src=u,u=t.src,(e=document.createElement("iframe")).style.display="none",e.csp="script-src 'unsafe-inline' "+u.split(/\?|\#/)[0]+" 'nonce-"+o+"'; "+(h.reportUrl?"report-uri "+h.reportUrl:""),e.src=URL.createObjectURL(new Blob(['\n <html>\n <head>\n <meta http-equiv="Content-Security-Policy" content="'+e.csp+'">\n <script id='+o+" nonce="+o+' src="'+u+'" async><\/script>\n <script nonce='+o+">\n (function () {\n var parent = window.parent\n var script = document.getElementById('"+o+"')\n window['"+c+"'] = window['moduleExportsReceiver'] = function (data) {\n window['moduleExportsReceiver'] = function () {}\n parent['on"+o+"'] ? parent['on"+o+"']({ data: { response: data, src: '"+u+"', hash: '"+o+"' } }) : parent.postMessage({ response: JSON.parse(JSON.stringify(data)), src: '"+u+"', hash: '"+o+"' }, '"+location.origin+"')\n }\n script.onerror = window['getModuleError'] = function () {\n window['moduleExportsReceiver'](null)\n }\n script.onload = window['getModuleLoaded'] = function () {\n var data = Object.keys(window.exports).length ? window.exports : window.module.exports\n window['moduleExportsReceiver'](data)\n }\n "+("json"===s?w:"")+"\n })()\n window.module = {\n exports: {}\n }\n window.exports = {}\n <\/script>\n <head>\n <body>\n </body>\n </html>\n "],{type:"text/html"})),"module"!==s&&e.setAttribute("sandbox","allow-scripts"),window["on"+o]=function(t){var e=t.data,n=e?e.response:"";e.src===u&&e.hash===o&&(a(),delete window["on"+o],n?r(n):i(e))},window.addEventListener("message",window["on"+o],!1),l.appendChild(e)}var e,n,o,s=h.dataType,c=h.receiver,d=h.timeout;d=d||3e4,n=new p(t,{timeout:3e3,polls:2}),o=setTimeout(function(){var t;t="timeout",a(),n.try(),0===n.polls&&i(t)},d),t(),!1===navigator.onLine&&(a(),n.stop(),window.addEventListener("online",t,!1))})},f=function(r,o){var e,i,a,t,n,s;for(void 0===o&&(o=""),e=[],i={},a="",t=function(n){e.push(new Promise(function(e,t){fetch(o+n).then(function(t){return t.text()}).then(function(t){i[n]=t,e()}).catch(function(){console.log("load "+n+" failed!"),t()})}))},n=0,s=r;n<s.length;n++)t(s[n]);return new Promise(function(o,t){Promise.all(e).then(function(){var t,e,n;for(t=0,e=r;t<e.length;t++)n=e[t],a+="; \n"+i[n]+"; \n";o(a)}).catch(function(){t()})})},m=(new v).shadowWindow.eval,y=function(t){var e="";return Object.entries(t).forEach(function(t){"object"==typeof t[1]&&(t[1]=JSON.stringify(t[1])),e+=t.join("=")+"&"}),e.substring(0,e.length-1)},g=function(d){return new Promise(function(e,t){var n=d.url,o=d.data,r=d.callbackKey,i=d.callbackName,a=d.timeout,s=d.reportUrl,c="";if(a=a||3e4,i=i||"JSONP",(o=o||{})[r=r||"callback"]=i,c=y(o),!n||"string"!=typeof n)return t("params url is not defined");n+=(-1!==n.indexOf("?")?"&":"?")+c,h(n,{receiver:i,timeout:a,reportUrl:s}).then(function(t){e(JSON.parse(JSON.stringify(t)))}).catch(t)})},b=function(t){var e=document.createElement("meta");e.setAttribute("charset","utf-8"),e.setAttribute("http-equiv","Content-Security-Policy"),e.setAttribute("content",t),document.getElementsByTagName("head")[0].appendChild(e)},t.Sandbox=v,t.ShadowFunction=P,t.ShadowDocument=e,t.WorkerFunction=u,t.BlackDocument=n,t.Strongbox=s,t.TryAgain=p,t.getShadowModule=h,t.loadShadowScript=f,t.safeEval=m,t.jsonp=g,t.csp=b,Object.defineProperty(t,"__esModule",{value:!0})});