var itraceBlankPlugin=function(){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;tt?"e":-1!==["VIDEO","AUDIO","IMG","BUTTON","TEXTAREA","RADIO","CHECKBOX","SELECT","IFRAME","CANVAS","SVG"].indexOf(e.nodeName)||"none"!==r.backgroundImage?"v":"rgba(0, 0, 0, 0)"!==r.backgroundColor||"0px"!==r.borderWidth||"none"!==r.boxShadow?"ve":"oc"};var u=function(r){function o(e){var t;(t=r.call(this,e)||this).reporter=null,t.pluginVer="2.3.0";return t.opts=c({maxDepth:8,minElements:10,startCheckingTime:5e3},e),t}!function(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,t(e,r)}(o,r);var s=o.prototype;return s.init=function(e){var t,r,n,o=this,c=this;c.reporter=e;try{if(c.opts.ignorePageUrls&&a(c.opts.ignorePageUrls)&&c.opts.ignorePageUrls(location))return void c.reporter.print("current url is in ignore list, skip blank check");this.reporter.detectBlank=function(e){o._checkBlank(e)}}catch(e){this.reporter.print(e)}if(null!=(t=this.reporter._sdkEnv)&&t.iOSNBCheck)return function(e,t,r,n){var o;if("function"==typeof(null==(o=window)||null==(o=o.ucapi)?void 0:o.invoke)){var a=i({},t,{success:r,fail:n});window.ucapi.invoke(e,a)}else n&&n("ucapi is not exist")}("webMonitor.setConfig",{startCheckingTime:this.opts.startCheckingTime,frmId:this.reporter._frmId,sampleRate:this.opts.sampleRate,w_rel:this.reporter.rel,uid:this.reporter.uid}),void this.reporter.print("blank check will be performed by client");var s=null==(r=this.reporter._sdkEnv)?void 0:r.isPrerender;!function(e){var t;return void 0===e&&(e={}),e.isPrerender?"compass"===e.prerenderType?"object"==typeof(null==(t=window)?void 0:t.prerenderCommitEvent)&&"prerendercommit"===window.prerenderCommitEvent.type:e.hasPrerenderCommit:"complete"===document.readyState}(this.reporter._sdkEnv)?function(e,t){l(window,t?"wpkpageforeground":"load",function(r){t&&"complete"!==document.readyState?l(window,"load",function(t){e.call(null,t)},!1,!0):e.call(null,r)},!1,!0)}(function(){c._onloadBlankCheck()},s):c._onloadBlankCheck(),null!=(n=this.opts.spaOption)&&n.enable&&l(window,"wpkpgchange",function(){o.reporter.print("spa page change blank detect"),c._routeChangeBlankCheck()})},s._onloadBlankCheck=function(){var e=this;this.onLoadDetectTimer=setTimeout(function(){try{e._checkBlank()}catch(t){e.reporter.print("bkpg checking oops: ",t)}e.onLoadDetectTimer=null},e.opts.startCheckingTime)},s._routeChangeBlankCheck=function(){var t,r=this;this.onLoadDetectTimer&&(clearTimeout(this.onLoadDetectTimer),r.reporter.print("page changed cancel the blank detect after onload")),this.pageChangeDetectTimer&&clearTimeout(this.pageChangeDetectTimer),this.pageChangeDetectTimer=setTimeout(function(){try{var t,n=e({},r.opts);n.rootDom=(null==(t=n.spaOption)?void 0:t.rootDom)||n.rootDom,r._checkBlank(n)}catch(e){r.reporter.print("bkpg checking oops: ",e)}r.pageChangeDetectTimer=null},(null==(t=r.opts.spaOption)?void 0:t.startCheckingTime)||3e3)},s._checkBlank=function(t){var r=this,o=t||r.opts,i=document.body;o.rootNode?i=o.rootNode:o.rootDom&&(i="function"==typeof o.rootDom?o.rootDom():o.rootDom);var c,l,s,u,d,h,f,E,g={deepestLayer:0,hasAtLeastOneVisibleNode:!1,total:0,invisible:0,visibleEmpty:0,occupy:0,domDSL:[]},m={},R=-1,v=Date.now();if(i){var k=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}(i.innerText);if(k)c=o.minTextLength||0,l=k,c&&c>0&&l&&c>l.split("").length?R=105:function(e,t){return function(e,t){for(var r,n=0,o=e.length;nh.deepestLayer&&(h.deepestLayer=t);r.length&&f;){var o=r.shift();h.total++;var i=p(o,n);if(h.domDSL.push({tag:o.tagName,layer:t,cls:o.className,isEmpty:"e"===i||"oc"===i}),"e"!==i){if("v"===i){h.hasAtLeastOneVisibleNode=!0,f=!1;break}if("ve"===i&&(h.visibleEmpty++,d&&h.visibleEmpty>d)){f=!1;break}"oc"===i&&h.occupy++,t<=u&&o.children.length&&E(o.children,t+1)}else h.invisible++}},(h={deepestLayer:0,hasAtLeastOneVisibleNode:!1,total:0,invisible:0,visibleEmpty:0,occupy:0,domDSL:[]}).deepestLayer=1,E(s,1),!(g=h).hasAtLeastOneVisibleNode&&g.visibleEmpty<(o.minElements||4)&&(R=101,m={wl_ven:g.visibleEmpty,wl_ocn:g.occupy})}}else R=103;var O=Date.now()-v;r.reporter.print("节点总数:"+g.total+", 最大层深:"+g.deepestLayer+", 耗时:"+O);var b={w_fp:-1};if(R>=0){r.reporter.print("检测到白屏,白屏类型:"+R),b=e({w_fp:R,w_dsl:JSON.stringify(g.domDSL),w_depth:g.deepestLayer,w_domcnt:g.total,wl_dcost:O},m),r.sendData(b);var P=document.documentElement.innerHTML||"";P.length<=1e5&&r.reporter.report({category:n.MAINDOC,sampleRate:1,bl1:P,_forcePost:!0}),r.reporter._hasCollectResTiming||(r.reporter.report({category:n.RESTIMING,bl1:JSON.stringify(performance.getEntriesByType("resource")),bl2:performance.timeOrigin||performance.timing.fetchStart,_forcePost:!0}),r.reporter._hasCollectResTiming=!0)}try{o.callback&&a(o.callback)&&o.callback(b)}catch(e){this.reporter.print("blank callback error",e)}},s.sendData=function(e){c(e,{category:n.BKPG,sampleRate:this.sampleRate,pluginVer:this.pluginVer}),this.reporter.report(e)},o}(o);return u.pluginId="iTraceBlankPlugin",u}();