"use strict";(()=>{function y(r){return r==="localhost"||r==="[::1]"||/^127(?:\.\d{1,3}){3}$/.test(r)}function A(r){if(!r.apiBase)return{enabled:!1,reason:"API_BASE_REQUIRED"};try{let e=new URL(r.apiBase);if(r.apiBase.trim()!==r.apiBase||r.apiBase.includes("?")||r.apiBase.includes("#")||e.username||e.password||e.search||e.hash)return{enabled:!1,reason:"INVALID_API_BASE"};let i=y(e.hostname);if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))return{enabled:!1,reason:"INSECURE_API_BASE"};let t=r.pageOrigin?new URL(r.pageOrigin):null;if(t&&(t.username||t.password||t.search||t.hash||!["http:","https:"].includes(t.protocol)||t.pathname!=="/"))return{enabled:!1,reason:"INVALID_PAGE_ORIGIN"};let n=t!==null&&y(t.hostname);if(!i&&(r.runtime!=="production"||n))return{enabled:!1,reason:"NON_LOCAL_DEVELOPMENT_ENDPOINT"};if(i&&t&&!n)return{enabled:!1,reason:"LOCAL_API_REQUIRES_LOCAL_PAGE"};if(r.runtime==="development"&&!n)return{enabled:!1,reason:"LOCAL_PAGE_REQUIRED"};let s=r.runtime==="development"&&t?new URL("/bi",t):new URL(`${e.href.replace(/\/+$/,"")}/bi`);return Object.freeze({enabled:!0,endpoint:s.href})}catch{return{enabled:!1,reason:"INVALID_API_BASE"}}}function R(){return A({apiBase:process.env.NEXT_PUBLIC_SERVER_BASE_URL,runtime:"production",pageOrigin:typeof window>"u"?void 0:window.location.origin})}function h(r){if(!/^[A-Za-z0-9_.:-]{1,32}$/.test(r))throw new Error("Invalid BI ID prefix");return`${r}:${globalThis.crypto.randomUUID()}`}var b=new Set(["zh-cn","zh-tw","en","ja","ko","vi","th"]),g=r=>r!==void 0&&Number.isSafeInteger(r)&&r>0,k="https://www.odaily.news";function T(r){let e=r.replace(/\/+$/,"").split("/");return e[2]==="search"?`/${e[1]}/search`:e.join("/")}function V(r,e,i){let t=T(i),n=`/${e}`;switch(r.pageType){case"HOME":return t===n;case"SEARCH":return t===`${n}/search`;case"FLASH_LIST":return t===`${n}/newsflash`;case"LIST":return t===`${n}/post`||t===`${n}/list`;case"COLUMN":return g(r.resourceId)&&(t===`${n}/deep`||t===`${n}/column/${r.resourceId}`);case"AUTHOR":case"TOPIC":return g(r.resourceId)&&t===`${n}/${r.pageType.toLowerCase()}/${r.resourceId}`;case"ARTICLE_DETAIL":case"FLASH_DETAIL":{let s=r.pageContent;return!!s&&g(s.contentId)&&s.contentType===(r.pageType==="ARTICLE_DETAIL"?"ARTICLE":"FLASH")&&t===`${n}/${s.contentType==="ARTICLE"?"post":"newsflash"}/${s.contentId}`}}}function l(r,e,i){let t=e.toLowerCase();if(!b.has(t)||!V(r,e,i))return null;let n;switch(r.pageType){case"HOME":n="";break;case"SEARCH":n="/search";break;case"FLASH_LIST":n="/newsflash";break;case"LIST":n="/list";break;case"COLUMN":case"TOPIC":case"AUTHOR":n=`/${r.pageType.toLowerCase()}/${r.resourceId}`;break;default:n=`/${r.pageType==="ARTICLE_DETAIL"?"post":"newsflash"}/${r.pageContent.contentId}`}let s=new URL(`/${t}${n}`,k);if(r.categoryId!==void 0){if(!g(r.categoryId)||["ARTICLE_DETAIL","FLASH_DETAIL","SEARCH"].includes(r.pageType))return null;s.searchParams.set("categoryId",String(r.categoryId))}return r.mode&&s.searchParams.set("mode",r.mode),s.href}function S(r,e){try{let i=new URL(r);if(!["http:","https:"].includes(i.protocol)||i.username||i.password||!["odaily.news","www.odaily.news"].includes(i.hostname)&&i.origin!==e)return null;let t=i.pathname.split("/").filter(Boolean),n=b.has(t[0]?.toLowerCase())?t.shift():"zh-cn",s=t[0],o;if(!s)o={pageType:"HOME"};else if(s==="search")o={pageType:"SEARCH"};else if((s==="post"||s==="list")&&t.length===1)o={pageType:"LIST"};else if(s==="newsflash"&&t.length===1)o={pageType:"FLASH_LIST"};else if(t.length===2&&/^[1-9][0-9]*$/.test(t[1])){let d=Number(t[1]);if(s==="post"||s==="newsflash")o={pageType:s==="post"?"ARTICLE_DETAIL":"FLASH_DETAIL",pageContent:{contentType:s==="post"?"ARTICLE":"FLASH",contentId:d}};else if(["column","topic","author"].includes(s))o={pageType:s.toUpperCase(),resourceId:d};else return null}else return null;let a=i.searchParams.get("categoryId")??(s==="post"?i.searchParams.get("tagId"):null);a&&(o={...o,categoryId:Number(a)});let u=i.searchParams.get("mode");return(u==="all"||u==="important"||u==="category")&&(o={...o,mode:u}),l(o,n,`/${n}/${t.join("/")}`.replace(/\/$/,""))}catch{return null}}function v(r,e,i){let t=i==="AD";switch(r){case"HOME":return(e==="BANNER"||e==="FEED")&&!t||e==="SIDEBAR_FLASH"&&i==="FLASH"||["BANNER_AD","FEED_AD_1","FEED_AD_2","SIDEBAR_AD"].includes(e)&&t;case"ARTICLE_DETAIL":return e==="BOTTOM_RECOMMEND"&&!t||e==="SIDEBAR_FLASH"&&i==="FLASH"||["SIDEBAR_AD","DETAIL_BOTTOM_AD"].includes(e)&&t;case"FLASH_DETAIL":return e==="BOTTOM_RECOMMEND"&&!t||e==="DETAIL_BOTTOM_AD"&&t;case"FLASH_LIST":return e==="FEED"&&i==="FLASH"||["FEED_AD_1","FEED_AD_2"].includes(e)&&t;case"SEARCH":return e==="FEED"&&!t;default:return e==="FEED"&&!t||["FEED_AD_1","FEED_AD_2"].includes(e)&&t}}function D(r){return`${r.position}:${r.targetType}:${r.targetId}`}function O(r){return typeof r=="object"&&r!==null&&"code"in r&&r.code===200}var _=(c=>(c[c.TIME_LINE=1]="TIME_LINE",c[c.VIEWPOINT=2]="VIEWPOINT",c[c.POST=3]="POST",c[c.NEWS_FLASH=4]="NEWS_FLASH",c[c.FEED=5]="FEED",c[c.PHOTO=6]="PHOTO",c[c.VIDEO=7]="VIDEO",c[c.AD=8]="AD",c[c.VOTE=9]="VOTE",c[c.ACTIVITY=10]="ACTIVITY",c[c.TOPIC=11]="TOPIC",c[c.AUTHOR=12]="AUTHOR",c[c.URL=13]="URL",c))(_||{}),H={1:"\u65F6\u95F4\u7EBF",2:"\u89C2\u70B9",3:"\u6587\u7AE0",4:"\u5FEB\u8BAF",5:"\u4FE1\u606F\u6D41",6:"\u56FE\u96C6",7:"\u89C6\u9891",8:"\u5E7F\u544A",9:"\u6295\u7968",10:"\u6D3B\u52A8",11:"\u4E13\u9898",12:"\u4F5C\u8005",13:"\u94FE\u63A5"},z=new Map(Object.values(_).filter(r=>typeof r=="number").map(r=>[r,H[r]]));var w=Object.freeze({share:"_odbi_s",action:"_odbi_a"}),P=/^[A-Za-z0-9_.:-]{1,96}$/;function C(r){try{let e=new URL(r),i=e.searchParams.getAll(w.share),t=e.searchParams.getAll(w.action);return i.length!==1||t.length!==1||!P.test(i[0])||!P.test(t[0])?null:{shareId:i[0],shareActionId:t[0]}}catch{return null}}var f={from:"_odbi_from",position:"_odbi_pos"},I=class{constructor(){this.pathname=null;this.currentUrl=null;this.context={kind:"DOCUMENT"}}navigate(e){let i=T(e);return i===this.pathname?!1:(this.pathname!==null&&(this.context={kind:"NAVIGATION",referrerUrl:this.currentUrl}),this.pathname=i,this.currentUrl=null,!0)}page(e){return this.currentUrl&&this.currentUrl!==e&&(this.context={kind:"NAVIGATION",referrerUrl:this.currentUrl}),this.currentUrl=e,this.context}unavailable(){this.currentUrl!==null&&(this.currentUrl=null,this.context={kind:"NAVIGATION",referrerUrl:null})}restored(){this.currentUrl=null,this.context={kind:"RESTORED"}}};function N(r,e,i={kind:"DOCUMENT"}){if(i.kind==="RESTORED")return{kind:"UNKNOWN"};let t=new URL(r);if(C(r))return{kind:"SHARE"};let n=t.searchParams.get(f.from),s=n?S(n):i.kind==="NAVIGATION"?i.referrerUrl:S(e,t.origin);if(s){let o=t.searchParams.get(f.position),a=new URL(s).pathname.split("/")[2],u=a?a==="post"?"ARTICLE_DETAIL":a==="newsflash"?new URL(s).pathname.split("/")[3]?"FLASH_DETAIL":"FLASH_LIST":a==="search"?"SEARCH":a==="column"?"COLUMN":a==="topic"?"TOPIC":a==="author"?"AUTHOR":"LIST":"HOME",d=n&&o&&["ARTICLE","FLASH","AD"].some(p=>v(u,o,p));return{kind:"INTERNAL",referrerUrl:s,...d?{position:o}:{}}}if(i.kind!=="DOCUMENT"||!e)return{kind:"UNKNOWN"};try{let o=new URL(e);return!["http:","https:"].includes(o.protocol)||o.username||o.password?{kind:"UNKNOWN"}:o.origin===t.origin||["odaily.news","www.odaily.news"].includes(o.hostname)?{kind:"INTERNAL"}:{kind:/(^|\.)(google\.[a-z.]+|bing\.com|baidu\.com|duckduckgo\.com)$/.test(o.hostname)?"SEARCH":"EXTERNAL",referrerUrl:`${o.protocol}//${o.hostname}`}}catch{return{kind:"UNKNOWN"}}}function x(){try{let r=new URL(location.href);for(let e of[f.from,f.position,"_odbi_c","_odbi_n","_odbi_s","_odbi_a"])r.searchParams.delete(e);r.href!==location.href&&history.replaceState(history.state,"",`${r.pathname}${r.search}${r.hash}`)}catch{}}var L=class{constructor(e=R()){this.config=e;this.mounts=new Map;this.documentMount=null;this.listeners=new Set;this.diagnostics=[];this.counts={};this.state=null;this.currentVisit=null;this.pendingExposures=[];this.pathname="";this.sourceHistory=new I;this.started=!1;this.providers=0;this.suspended=!1;this.reconciling=!1;this.onVisibilityChange=()=>{this.requestReconcile()};this.onPageHide=()=>{this.retire(),this.sourceHistory.restored(),this.suspended=!0};this.onPageShow=e=>{this.suspended=!1,e.persisted&&(this.retire(),this.sourceHistory.restored()),this.requestReconcile()}}report(e,i={}){let t={at:new Date().toISOString(),code:e,...i};this.counts[e]=(this.counts[e]??0)+1,this.diagnostics.push(t),this.diagnostics.length>100&&this.diagnostics.shift(),window.dispatchEvent(new CustomEvent("odaily:bi-diagnostic",{detail:t}))}identify(){try{let e="odaily_bi_visitor",i=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${e}=`))?.slice(e.length+1);if(i&&/^[A-Za-z0-9_.:-]{1,96}$/.test(i))this.visitorId=i;else{let t=h("visitor");document.cookie=`${e}=${t}; Path=/; Max-Age=31536000; SameSite=Lax${location.protocol==="https:"?"; Secure":""}`,document.cookie.split(";").some(n=>n.trim()===`${e}=${t}`)&&(this.visitorId=t)}}catch{}this.visitorId||this.report("VISITOR_UNAVAILABLE")}start(){if(!(this.started||!this.config.enabled)){this.started=!0,this.suspended=!1,this.identify();try{sessionStorage.removeItem("odaily:bi:queue:v1"),sessionStorage.removeItem("odaily:bi:queue:v2")}catch{}this.setPathname(location.pathname),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide),window.addEventListener("pageshow",this.onPageShow),this.requestReconcile()}}connect(){return this.providers++,this.start(),()=>{this.providers--,queueMicrotask(()=>{this.providers||this.stop()})}}stop(){this.retire(),this.started=!1,document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pagehide",this.onPageHide),window.removeEventListener("pageshow",this.onPageShow)}setPathname(e){this.sourceHistory.navigate(e)&&this.retire(),this.documentMount&&this.documentMount.pathname!==e&&this.documentMount.release(),this.pathname=e,this.requestReconcile()}mountPage(e,i,t){let n=this.registerPage(e,i,t);return this.documentMount?.pathname===t&&l(e,i,t)&&this.documentMount.release(),n}mountDocumentPage(e,i,t,n){let s=l(e,i,t);if(!s||this.documentMount||[...this.mounts.values()].some(u=>u.pathname===t&&l(u.page,u.language,t)===s))return;let o=this.registerPage(e,i,t),a=()=>{this.documentMount?.release===a&&(this.documentMount=null,o(),n())};return this.documentMount={pathname:t,release:a},a}registerPage(e,i,t){let n=Symbol("page");return this.mounts.set(n,{page:e,language:i,pathname:t}),this.requestReconcile(),()=>{this.mounts.delete(n),this.requestReconcile()}}requestReconcile(){this.reconciling||(this.reconciling=!0,queueMicrotask(()=>{this.reconciling=!1,this.reconcile()}))}reconcile(){if(!this.started||this.suspended)return;let e=[...this.mounts.values()].filter(u=>u.pathname===this.pathname),i=e[e.length-1];if(!i){this.sourceHistory.unavailable(),this.retire();return}let t=l(i.page,i.language,i.pathname);if(!t){this.sourceHistory.unavailable(),this.retire();return}if(this.state?.visit.key===t||(this.retire(),document.visibilityState!=="visible"))return;let n=Object.freeze({...i.page,pageViewId:h("page"),language:i.language,url:t,...this.visitorId?{visitorId:this.visitorId}:{}}),s=Object.freeze({key:t,context:n,pathname:i.pathname,openedAt:new Date().toISOString()}),o={visit:s,status:"PENDING",exposures:new Set,duration:0,progress:0,lastReading:""};this.state=o;let a=N(location.href,document.referrer,this.sourceHistory.page(t));x(),this.send("page-open",{pageViewId:n.pageViewId,pageType:n.pageType,url:t,...n.visitorId?{visitorId:n.visitorId}:{},...n.pageContent?{contentId:String(n.pageContent.contentId)}:{},source:a}).then(u=>{o.status=u?"ACCEPTED":"FAILED",this.state===o&&u&&this.started&&!this.suspended&&this.changeVisit(s)})}retire(){this.flushExposures(),this.changeVisit(null),this.state=null}changeVisit(e){this.currentVisit!==e&&(this.currentVisit=e,[...this.listeners].forEach(i=>i(e)))}getVisit(){return this.currentVisit}subscribeVisit(e){return this.listeners.add(e),e(this.currentVisit),()=>{this.listeners.delete(e)}}accepted(e){let i=this.state;return i?.status==="ACCEPTED"&&i.visit===e&&Date.now()-Date.parse(e.openedAt)<864e5?i:null}reportExposure(e,i){let t=this.accepted(e),n=D(i);!t||t.exposures.has(n)||(t.exposures.add(n),this.pendingExposures.push(i),this.pendingExposures.length===1&&queueMicrotask(()=>this.flushExposures()))}flushExposures(){let e=this.pendingExposures.splice(0),i=this.state?.visit;if(!i||!this.accepted(i))return;let{pageViewId:t,pageType:n,url:s}=i.context;for(let o=0;on.abort(),5e3);this.report("REQUEST_SENT",t);try{let o=await fetch(`${this.config.endpoint}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),credentials:"omit",cache:"no-store",keepalive:!0,signal:n.signal}),a=await o.json(),u=o.ok&&O(a);return this.report(u?"REQUEST_ACCEPTED":"REQUEST_DROPPED",{...t,status:o.status}),o.status===404&&typeof a=="object"&&a!==null&&"code"in a&&a.code===1200007&&this.state?.visit.context.pageViewId===i.pageViewId&&(this.state.status="FAILED",this.changeVisit(null)),u}catch{return this.report(n.signal.aborted?"TIMEOUT_DROPPED":"NETWORK_DROPPED",t),!1}finally{clearTimeout(s)}}getDiagnostics(){return{enabled:this.config.enabled,reason:this.config.enabled?null:this.config.reason,collectionStatus:this.started?"READY":"STOPPED",pageOpenStatus:this.state?.status??null,pageViewId:this.state?.visit.context.pageViewId??null,counts:{...this.counts},recent:[...this.diagnostics]}}},E=Symbol.for("odaily.bi.client.v1");function U(r){if(typeof window>"u")return null;let e=window;return e[E]??(e[E]=new L(r)),e[E]}function F(){let r=document.currentScript;if(!(r instanceof HTMLScriptElement))return;let{biPage:e,biId:i,biLocale:t,biApiBase:n,biRuntime:s}=r.dataset;if(!i||!/^[1-9]\d*$/.test(i)||!t)return;let o=Number(i),a;if(e==="ARTICLE_DETAIL")a={pageType:e,pageContent:{contentType:"ARTICLE",contentId:o}};else if(e==="FLASH_DETAIL")a={pageType:e,pageContent:{contentType:"FLASH",contentId:o}};else return;let{pathname:u,origin:d}=window.location;if(!l(a,t,u))return;let p=A({apiBase:n,runtime:s,pageOrigin:d});if(!p.enabled)return;let m=U(p);if(!m?.config.enabled)return;let B=new MutationObserver(()=>{r.isConnected||c?.()}),c=m.mountDocumentPage(a,t,u,()=>B.disconnect());c&&(B.observe(document,{childList:!0,subtree:!0}),m.start())}F();})();
Linera เปิดตัวการลงทะเบียนล่วงหน้าสำหรับการขายชุมชน LNRA และเปิดเผยแบบจำลองเศรษฐกิจโทเค็น
