(function(){"use strict";(h=>{const{screen:{width:O,height:R},navigator:{language:U},location:S,localStorage:A,document:i,history:m}=h,{hostname:P,pathname:_,search:C}=S,{currentScript:g}=i;if(!g)return;const l="data-",q="false",u=g.getAttribute.bind(g),z=u(l+"website-id"),x=u(l+"host-url"),I=u(l+"auto-track")!==q,J=u(l+"do-not-track"),E=u(l+"domains")||"",M=E.split(",").map(t=>t.trim()),B=`${x?x.replace(/\/$/,""):g.src.split("/").slice(0,-1).join("/")}/csttr.php`,F=`${O}x${R}`,G=/data-tianji-event-([\w-_]+)/,D=l+"tianji-event",H=300,$=(t,r,e)=>{const n=t[r];return(...a)=>(e.apply(null,a),n.apply(t,a))},Q=t=>{try{return new URL(t).pathname}catch{return t}},p=()=>({website:z,hostname:P,screen:F,language:U,title:w,url:v,referrer:y}),V=()=>{const{doNotTrack:t,navigator:r,external:e}=h,n="msTrackingProtectionEnabled",a=()=>e&&n in e&&e[n](),o=t||r.doNotTrack||r.msDoNotTrack||a();return o=="1"||o==="yes"},j=()=>A&&A.getItem("tianji.disabled")||J&&V()||E&&!M.includes(P),L=(t,r,e)=>{e&&(y=v,v=Q(e.toString()),v!==y&&setTimeout(b,H))},W=()=>{const t=e=>{const n=e.getAttribute.bind(e),a=n(D);if(a){const o={};return e.getAttributeNames().forEach(f=>{const s=f.match(G);s&&(o[s[1]]=n(f))}),b(a,o)}return Promise.resolve()},r=e=>{var f;const n=(s,T)=>{let c=s;for(let N=0;N{c||(S.href=s)}))}else t(a)};i.addEventListener("click",r,!0)},X=()=>{const t=([n])=>{w=n&&n.target?n.target.text:void 0},r=new MutationObserver(t),e=i.querySelector("head > title");e&&r.observe(e,{subtree:!0,characterData:!0,childList:!0})},d=(t,r="event")=>{if(j())return;const e={"Content-Type":"application/json"};return typeof k<"u"&&(e["x-tianji-cache"]=k),fetch(B,{method:"POST",body:JSON.stringify({type:r,payload:t}),headers:e}).then(n=>n.text()).then(n=>k=n).catch(()=>{})},b=(t,r)=>d(typeof t=="string"?{...p(),name:t,data:typeof r=="object"?r:void 0}:typeof t=="object"?t:typeof t=="function"?t(p()):p()),Y=t=>d({...p(),data:t},"identify");h.tianji||(h.tianji={track:b,identify:Y});let v=`${_}${C}`,y=i.referrer,w=i.title,k,K;if(I&&!j()){m.pushState=$(m,"pushState",L),m.replaceState=$(m,"replaceState",L),W(),X();const t=()=>{i.readyState==="complete"&&!K&&(b(),K=!0)};i.addEventListener("readystatechange",t,!0),t()}})(window)})();