(()=>{let E=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)}),x="https://api.analytics.sales-marker.jp/event",O="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNjc4ODAxOTE5fQ.olKX9MVukd8vZypL2gTNqRApxzhgNp8uuPG9mFSMtz0",k="https://app.sales-marker.jp",y="https://marketing-marker.jp",A="https://access-site.net/static/access-net.html",P="SALES_MARKER_IFRAME_TOKEN",D="SALES_MARKER_PARENT_TOKEN",L="SALES_MARKER_ACCESS_SITE_COOKIE",b="SALES_MARKER_ACCESS_SITE_COOKIE_IFRAME",I="disablepersonintent",C=/analytics\.sales-marker\.jp/i,K=()=>{let n=document.currentScript;if(n instanceof HTMLScriptElement&&n.hasAttribute(I))return!0;let e=document.getElementsByTagName("script");for(let t=0;t<e.length;t++){let i=e[t];if(C.test(i.src)&&i.hasAttribute(I))return!0}return!1},c,h=()=>{let n=new URL(A).origin,e=!1,t=document.createElement("iframe");t.id=b,t.src=A,t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;width:0;height:0;border:0;visibility:hidden;pointer-events:none";let i=()=>{if(e)return;let a=t.contentWindow;if(a===null)return;e=!0;let s=E();a.postMessage({type:D,data:s},n),c=s},r=a=>{if(a.origin!==n)return;let s=a.data;if((s==null?void 0:s.type)!==P||typeof s.cookies!="object"||s.cookies===null)return;let _=s.cookies[L];_!==void 0&&_!==""?(c=_,console.log("--- cookieToken ---",c),window.removeEventListener("message",r)):i()};window.addEventListener("message",r),document.body.appendChild(t)};K()||(document.body!==null?h():document.addEventListener("DOMContentLoaded",h,{once:!0}));let F={"sales-marker-analytics-tag":k,"marketing-marker-analytics-tag":y},G="SalesMarkerAnalyticsTagTest",V="test=sales-marker-analytics-tag",T=1e3,m=2e4,S=30*1e3,f=E(),u=window.location.href,p=!1,g=0,o=document.hasFocus()?Date.now():null,N=Date.now(),d=()=>g+(o!==null?Date.now()-o:0),U=()=>{let n=Date.now()-N;if(n>=S)return m;let e=n/S,t=T*Math.pow(m/T,e);return Math.min(t,m)},j=()=>{o!==null&&(g+=Date.now()-o,o=null)},J=()=>{o===null&&(o=Date.now())},Y=()=>{g=0,o=document.hasFocus()?Date.now():null,N=Date.now()},R=()=>{Y(),l(d())},W=n=>{var i,r;let e=new URL(u),t=(r=(i=/^(?:https?:\/\/)?(?:[^@/\n]+@)?(?:www\.)?([^:/?\n]+)/gim.exec(e.hostname))==null?void 0:i[1])!=null?r:"";return{pathname:e.pathname,domain:t,search:e.search,title:document.title,userAgent:window.navigator.userAgent,createdAt:new Date().toISOString(),version:2,href:u,action:"pageview",duration:n,sessionId:f,hasFocused:document.hasFocus(),visibilityState:document.visibilityState,cookie:c}},l=n=>{let e=W(n);fetch(x,{method:"POST",body:JSON.stringify(e),keepalive:!0,mode:"cors",headers:{Authorization:`Bearer ${O}`,"Content-Type":"application/json"}}).catch(console.error)};R();let v=()=>{setTimeout(()=>{document.hasFocus()&&l(d()),v()},U())};v();function z(){u!==window.location.href&&(l(d()),u=window.location.href,f=E(),R())}let q=()=>{!document.hasFocus()&&!p?(l(d()),j(),p=!0):document.hasFocus()&&(J(),p=!1)};setInterval(()=>{z(),q()},100);let[X]=V.split("="),M=new URLSearchParams(window.location.search).get(X);if(M===null)return;let w=F[M];w!==void 0&&window.opener.postMessage({action:G,message:"ok"},w)})();
