;(function(){var Context=function(){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var s=function(){return(s=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function t(i,a,s,c){return new(s=s||Promise)(function(t,e){function n(t){try{r(c.next(t))}catch(t){e(t)}}function o(t){try{r(c.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new s(function(t){t(e.value)}).then(n,o)}r((c=c.apply(i,a||[])).next())})}function c(n,o){var r,i,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(a=2&e[0]?i.return:e[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,e[1])).done)return a;switch(i=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,i=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=o.call(n,s)}catch(t){e=[6,t],i=0}finally{r=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function o(){return"http://nativeapp.toutiao.com"==document.referrer||f.test(d)}function r(){return v.test(d)}function i(){return g.test(d)}function u(){return/windows phone/i.test(d)?"Windows Phone":/android/i.test(d)?"android":/iPad|iPhone|iPod/.test(d)&&!window.MSStream?"ios":"pc"}var e=["joke_essay","Joke"],a=["live_stream"],p=["aweme"],l=["News","NewsSocial","Explore","NewsArticle","NewsInHouse","Video","VideoInHouse","VideoArticle","aweme","open_news"].concat(e,a,["Video","VideoInHouse","VideoArticle"],p,["open_news","TTAD","douyin_lite"]),d=navigator.userAgent,f=new RegExp("("+l.join("|")+")","i"),h=new RegExp("("+e.join("|")+")","i"),v=new RegExp("("+a.join("|")+")","i"),g=new RegExp("("+p.join("|")+")","i"),_=new RegExp("("+["VideoArticle"].join("|")+")","i"),y=(new RegExp("("+["NewsArticle"].join("|")+")","i"),new RegExp("("+["TTAD"].join("|")+")","i")),m=function(){return"android"===u()};function w(t,e){window.sessionStorage.setItem(t,e)}function b(t){return window.sessionStorage.getItem(t)}function I(t){if(t.sourceIndex)return t.sourceIndex-t.parentNode.sourceIndex-1;for(var e=0;t=t.previousElementSibling;)e++;return e}function k(){return{path:location.pathname,referrer:document.referrer,search:location.search,title:document.title||"",page_url:location.href,page_type:window._page_type?window._page_type:0,site_id:function(){var t=window.location.pathname;return(t.match(/\d+/g)||[])[0]||""}()||""}}var S=function(t){if(t)return{xpath:function(t){for(var e="";t.length;){var n=Array.prototype.pop.apply(t);if(n&&n.tagName&&"body"!=n.tagName.toLowerCase()&&"html"!=n.tagName.toLowerCase()){var o="function"==typeof n.getAttribute?n.getAttribute("id"):"";e+=n.tagName.toLowerCase()+I(n)+(o?"#"+o:"")+(0==t.length?"":">")}}return e}(function(t){var e=function(t){var e=[];for(;t;)(t=t.parentNode)&&e.push(t);return e}(t);return e.unshift(t),e}(t))}};function x(t){var e=[];t=t||{};var n=/^(?:string|boolean|number)/i;for(var o in t)t.hasOwnProperty(o)&&n.test(typeof t[o])&&e.push(o+"="+t[o]);return e.join("&")}function C(t,e){var n=RegExp("[?&]"+t+"=([^&]*)").exec(e);return n&&decodeURIComponent(n[1].replace(/\+/g," "))}function L(t){var e=location.search;return C(t,e)||(e=document.referrer),C(t,e)}function E(){return sessionStorage.getItem("_sdk_clickId")?sessionStorage.getItem("_sdk_clickId"):(sessionStorage.setItem("_sdk_clickId",L("clickid")||""),L("clickid"))}var R=0,A=1,M=2,P=(N.prototype.setBridgeState=function(t,e){switch(t){case"adInfo":this.adInfoFlag=e;break;case"appInfo":this.appInfoFlag=e}},N.prototype.callPromise=function(i){return t(this,void 0,void 0,function(){var o,r;return c(this,function(t){switch(t.label){case 0:return[4,(o=this).bridgeLoaded];case 1:return r=t.sent(),this.setBridgeState(i,R),[2,this.retry(function(){return new Promise(function(e,t){var n=setTimeout(function(){o.adInfoFlag!=R&&o.appInfoFlag!=R||t("timeout")},400);r.call(i,{},function(t){o.setBridgeState(i,M),e(t),clearTimeout(n)})})},1)]}})})},N.prototype.retry=function(o,r){void 0===r&&(r=1);var i=this;return new Promise(function(n){o().then(function(t){n(t)},function(){return t(this,void 0,void 0,function(){var e;return c(this,function(t){switch(t.label){case 0:if(1!==r)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),e=n,[4,o()];case 2:return e.apply(void 0,[t.sent()]),[3,4];case 3:return t.sent(),n({}),[3,4];case 4:return[3,6];case 5:n(i.retry(o,r-1)),t.label=6;case 6:return[2]}})})})})},N.prototype.track_event=function(e){return t(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,this.bridgeLoaded];case 1:return t.sent().call("track_event",e),[2]}})})},N.prototype.setSession=function(){return t(this,void 0,void 0,function(){var e,n;return c(this,function(t){switch(t.label){case 0:return n=[{}],[4,this.adInfo];case 1:return n=n.concat([t.sent()]),[4,this.appInfo];case 2:return e=s.apply(void 0,n.concat([t.sent()])),w("bridge",JSON.stringify(e)),[2]}})})},N);function N(t){this.adInfoFlag=A,this.appInfoFlag=A,this.bridgeLoaded=function(t){var n=document.createElement("script");n.src=t;var e=new Promise(function(t,e){n.onload=t,n.onerror=e});return document.head.appendChild(n),e}(t).then(function(){return window.ToutiaoJSBridge}),this.adInfo=this.callPromise("adInfo"),this.appInfo=this.callPromise("appInfo"),this.setSession()}function O(){var e,t=b("umeng")||"{}";try{e=JSON.parse(t)}catch(t){e={}}return e}var U=0,D=2,j=1;"{}"!==JSON.stringify(O())&&(j=D);var J=function(){j=U;var t,e=decodeURIComponent(L("_toutiao_params")||L("_toutiao_recommend")||"");try{t=JSON.parse(e)}catch(t){return{}}return j=D,w("umeng",JSON.stringify(t)),t}(),T=j,H=new P("https://s3.pstatp.com/inapp/toutiao.js"),F=0,B=2,V=!o()&&/(UCBrowser|baiduboxapp|baidubrowser|MQQBrowser|QQ|MicroMessenger|Weibo|Opera|Firefox|MSIE|360SE|MetaSr|TheWorld|Firefox|LBBROWSER|Chrome|Safari)(\s|\/|_)(\S)/i.test(navigator.userAgent)?F:B;var $=function(){return t(this,void 0,void 0,function(){var e,n,o,r,i,a;return c(this,function(t){switch(t.label){case 0:return n=[{}],[4,H.adInfo];case 1:return n=n.concat([t.sent()]),[4,H.appInfo];case 2:return e=s.apply(void 0,n.concat([t.sent()])),o=100+10*H.adInfoFlag+H.appInfoFlag,r=1e3+100*H.adInfoFlag+10*T+V,i=s({},k(),O(),J,function(){var e,t=b("bridge")||"{}";try{e=JSON.parse(t)}catch(t){e={}}return e}(),e),a=JSON.parse(i.log_extra||"{}"),[2,{value:i.cid||"",log_extra:i.log_extra||"",req_id:i.req_id||a.req_id||"",cid:i.cid||"",ad_id:i.ad_id||L("_tt_ad_id")||L("ad_id")||"",device_id:i.device_id||"",user_id:i.user_id||"",uid:i.uid||"",ut:i.ut||"",app_version:i.appVersion||"",version_code:i.version_code||"",app_id:i.aid||"",os:u(),page_url:i.page_url,page_type:i.page_type,site_id:i.site_id,tt_bridge:o,tt_env:r,ad_extra_data:JSON.stringify({clickid:E()})}]}})})};q.prototype.handleLog=function(t,e){return{log:t,context:e}};function q(){}Q.prototype.handleLog=function(t,e){try{var n=s({},e,t,{source:"webunion"});navigator.sendBeacon(this.API_URL,JSON.stringify(n))}catch(t){}};function Q(t){this.API_URL=t}W.prototype.handleLog=function(){};function W(){}var X=(Y.prototype.handleLog=function(t,e){var n="bytedance://"+(h.test(d)||m()||r()||i()?"log_event":"custom_event")+"?";this.isRealtimeReport(e.app_version)&&(n+="&realtime_report=1"),"ios"===u()?n+=this.formatData(s({},e,t)):n+=this.formatData(this.androidData(s({},e,t)));try{window.webkit.messageHandlers.observe.postMessage(n)}catch(t){console.log(n)}if(this.isVideoArticleCompatible(e.app_version))try{window.webkit.messageHandlers.consoleLog.postMessage(n)}catch(t){}},Y.prototype.isVideoArticleCompatible=function(t){var e=!1;try{e=_.test(d)&&"ios"==u()&&parseInt(t.replace(/\./g,""))<=794&&779<=parseInt(t.replace(/\./g,""))}catch(t){}return e},Y.prototype.formatData=function(t){var e="";for(var n in t)"object"==typeof t[n]?e+="&"+n+"="+encodeURIComponent(JSON.stringify(t[n])):e+="&"+n+"="+encodeURIComponent(t[n]);return e},Y.prototype.androidData=function(t){return{category:t.category,tag:t.tag,label:t.label,value:t.cid,extra:t}},Y.prototype.isRealtimeReport=function(t){return"6.6.7"===t},Y);function Y(){}G.prototype.handleLog=function(t,e){var n=function(t,e){return{convert_id:t.convert_id||0,event_type:t.event_type||"",log_extra:e.log_extra,os:e.os,page_url:location.href,page_type:e.page_type}}(t,e),o=s({track_data:encodeURIComponent(JSON.stringify([n]))},e),r=this.API_URL+"?"+x(o);try{(new Image).src=window.location.protocol+r+"&t="+new Date}catch(t){}};function G(t){this.API_URL=t}var z=(K.prototype.isSuperCompatible=function(t,e){var n=!1;try{n="1319"==e&&"android"==u()&&parseInt(t.replace(/\./g,""))<=274&&244<=parseInt(t.replace(/\./g,""))}catch(t){}return n},K.prototype.handleLog=function(t,e){var n="bytedance://log_event?",o=s({},e,t);for(var r in o)"object"==typeof o[r]?n+="&"+r+"="+encodeURIComponent(JSON.stringify(o[r])):n+="&"+r+"="+encodeURIComponent(o[r]);try{window.webkit.messageHandlers.observe.postMessage(n)}catch(t){console.log(n)}if(this.isSuperCompatible(e.app_version,e.app_id)){var i=document.createElement("iframe");i.style.width="1px",i.style.height="1px",i.style.display="none",i.style.position="absolute",i.src=n,document.documentElement.appendChild(i),setTimeout(function(){document.documentElement.removeChild(i)},100)}},K);function K(){}var Z=(tt.prototype.handleLog=function(t,e){var n=function(t,e){return{convert_id:t.convert_id||0,event_type:t.event_type||"",log_extra:e.log_extra,os:e.os,page_url:location.href,page_type:e.page_type,xpath:t.xpath||"",select_content:t.select_content||"",event_value:t.event_value||""}}(t,e),o=s({track_data:encodeURIComponent(JSON.stringify([n]))},e),r=this.API_URL+"?"+x(o);try{!function t(e,n){var o=n||0,r=new XMLHttpRequest;r.open("GET",e.url,!1),r.withCredentials=!0,r.onreadystatechange=function(){4===r.readyState&&200!==r.status&&o<1&&t(e,++o)},r.send(null)}({url:r+"&t="+new Date})}catch(t){}},tt);function tt(t){this.API_URL=t}var et={category:"umeng",tag:"embeded_ad",label:"convert"},nt={sdk_version:"0.0.1"},ot=(rt.prototype.handleLog=function(t,e){if(t=s({},nt,t),o()&&!this.isAwemeCompatible(e.app_version)&&!this.isLiveCompatible(e.app_version)||(t.select_content&&(t.select_content=encodeURIComponent(t.select_content)),this.httpHandler.handleLog(t,e)),o())return t=s({},et,t),y.test(d)?this.iframeHandler.handleLog(t,e):this.consoleHandler.handleLog(t,e)},rt.prototype.isAwemeCompatible=function(t){var e=!1;try{e=i()&&"ios"==u()&&parseInt(t.replace(/\./g,""))<182}catch(t){}return e},rt.prototype.isLiveCompatible=function(t){var e=!1;try{e=r()&&"ios"==u()&&parseInt(t.replace(/\./g,""))<420}catch(t){}return e},rt);function rt(){this.httpHandler=new Z("https://isub.snssdk.com/2/wap/landing_tetris_log/"),this.iframeHandler=new z,this.consoleHandler=new X}var it,at,st=["","webkit","Moz","MS","ms","o"],ct=window,ut=void 0!==function(t,e){var n,o,r=e[0].toUpperCase()+e.slice(1),i=0;for(;i<st.length;){if((o=(n=st[i])?n+r:e)in t)return t[o];i++}return}(ct,"PointerEvent"),pt="ontouchstart"in ct;(at=it=it||{})[at.Default=0]="Default",at[at.Start=1]="Start",at[at.Move=2]="Move",at[at.End=4]="End",at[at.Cancle=8]="Cancle";var lt={pointer:{events:["pointerdown","pointermove","pointerup","pointercancel"],handler:function(t){var e=t.type,n={status:it.Default,timestamp:Date.now(),position:[t.clientX,t.clientY]};return e!==this.events[0]||0!==t.button&&"touch"!==t.pointerType?e===this.events[1]?n.status=it.Move:e===this.events[2]?n.status=it.End:e===this.events[3]&&(n.status=it.Cancle):n.status=it.Start,n}},touch:{events:["touchstart","touchmove","touchend","touchcancel"],handler:function(t){var e=t.type;if(1!==t.changedTouches.length)return null;var n={status:it.Default,timestamp:Date.now(),position:[t.changedTouches[0].clientX,t.changedTouches[0].clientY]};return e===this.events[0]?n.status=it.Start:e===this.events[1]?n.status=it.Move:e===this.events[2]?n.status=it.End:e===this.events[3]&&(n.status=it.Cancle),n.status===it.Default?null:n}},mouse:{events:["mousedown","mousemove","mouseup"],handler:function(t){var e=t.type,n={status:it.Default,timestamp:Date.now(),position:[t.clientX,t.clientY]};return e===this.events[0]&&0===t.button?n.status=it.Start:e===this.events[1]?n.status=it.Move:e===this.events[2]&&(n.status=it.End),n.status&it.Move&&1!==t.which&&(n.status=it.End),n.status===it.Default?null:n}}};"MSPointerEvent"in ct&&!("PointerEvent"in ct)&&(lt.pointer.events=["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"]);var dt=250,ft=9;function ht(t,e,n){for(var o=0;o<t.length;o++)document.addEventListener(t[o],e,n)}var vt={addClickEvent:function(a,t){function e(n){var o,r,i;return function(t){var e=lt[n].handler(t);if(null!==e){if(e.status&it.Start)return o=it.Start,r=e.timestamp,void(i=e.position);if(e.status&it.End)o&it.Start&&e.timestamp-r<dt&&Math.sqrt(Math.pow(e.position[0]-i[0],2)+Math.pow(e.position[1]-i[1],2))<ft&&a(t);else if(e.status&it.Move&&o&it.Start)return}i=[r=o=0,0]}}ut?ht(lt.pointer.events,e("pointer"),t):pt?ht(lt.touch.events,e("touch"),t):ht(lt.mouse.events,e("mouse"),t)}};var gt,_t,yt,mt,wt=(function(t){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}(t.exports=n).prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,o=this._callbacks["$"+t];if(!o)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var r=0;r<o.length;r++)if((n=o[r])===e||n.fn===e){o.splice(r,1);break}return 0===o.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(n){o=0;for(var r=(n=n.slice(0)).length;o<r;++o)n[o].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}}(gt={exports:{}},gt.exports),gt.exports),bt=new ot,It=(n(_t=St,yt=mt=wt),void(_t.prototype=null===yt?Object.create(yt):(kt.prototype=yt.prototype,new kt)),St.prototype._init=function(t){for(;t.length;){var e=t.pop(),n=e[0],o=e.slice(1);this._invoke.apply(this,[n].concat(o))}},St.prototype.sendLog=function(n){return t(this,void 0,void 0,function(){var e;return c(this,function(t){switch(t.label){case 0:return[4,$()];case 1:return e=t.sent(),bt.handleLog(n,e),[2]}})})},St.prototype._get_basedata=function(){return t(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return[4,$()];case 1:return[2,t.sent()]}})})},St.prototype.track=function(t,e){if("string"==typeof t){var n={event_type:t,report_event_from:"jssdk",ad_extra_data:JSON.stringify({clickid:E()})};e&&e.convert_id&&(n.convert_id=e.convert_id),this.sendLog(n),this.emit("track",n)}else console.log("event_type type error")},St);function kt(){this.constructor=_t}function St(t){var r=mt.call(this)||this;return r._invoke=function(t){for(var e,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];r[t]&&(e=r[t]).call.apply(e,[r].concat(n))},r._init(t),r}return function(){if(!window.meteor._invoke){window.meteor._invoke=!0;var t=(window.meteor||[]).slice(),e=new It(t);window.meteor=e,function(){var r,t=document.getElementById("_tt_real_page_url")||null;function i(t){var e={};e.page_url=r||decodeURIComponent(location.href),e.event_type=t.getAttribute("tt-data-eventtype")||"",e.convert_id=t.getAttribute("tt-data-convertid")||"",e.event_value=t.getAttribute("tt-data-eventvalue")||"",e.target=t,e.options=t.getAttribute("tt-data-options")||"",window.meteor.track(s({},e,S(t)))}null!==t&&(r=t.getAttribute("href")||""),vt.addClickEvent(function(t){for(var e=t.target,n=e;e!=document;)"function"==typeof e.hasAttribute&&e.hasAttribute("tt-data-click")&&i(e),e=e.parentNode;if(e==document&&window._xpath_config){var o={};o.target=n,o.event_type="xpath",o.page_url=r||decodeURIComponent(location.href),window.meteor.track(s({},o,S(n)))}},!0),document.addEventListener("beforecopy",function(t){var e=document.getSelection().toString(),n=e.length,o=t.target;if(m()&&(e=encodeURIComponent(e)),window._xpath_config&&0<n&&n<200){var r={};r.target=o,r.select_content=e,r.event_type="xpath",window.meteor.track(s({},r,S(o)))}},!0)}()}}(),window.meteor}();
})();;(function(){if (typeof window._page_type == 'undefined') {
  var isTetris = ['ad.toutiao.com', 'www.toutiaopage.com', 'www.chengzijianzhan.com'].indexOf(location.hostname) > -1
  var isUnion = /(open_news)(\s|\/|_)(\S)/i.test(navigator.userAgent)
  if (!isTetris && isUnion) {
    !function() {
      var script = document.createElement('script')
      script.async = !0
      script.src = 'https://s3.pstatp.com/bytecom/resource/tetris/h5-insight-sdk-1.2.0.iife.js'
      var r = document.getElementsByTagName('script')[0]
      r.parentNode.insertBefore(script, r)
    }();
  }
}
})();