码桶
发现社区成员的开源项目
Screen-Bj_Rpel0.js25 KB
import{j as t,R as Be,u as qe,d as Qe,r as l,P as ye}from"./index-GWuvg2UH.js";import{e as G}from"./echarts-CEICS1Jr.js";import{u as Ye}from"./useVisibilityRefresh-DRH6QDT3.js";const r={bg:"#0a0e1c",panel:"rgba(19, 26, 50, 0.65)",border:"rgba(70, 100, 190, 0.28)",text:"#e6edff",sub:"#7f8cb8",accent:"#45c8ff",green:"#3ddc97",orange:"#ffb84d",purple:"#b388ff",red:"#ff7d9c"},be=["#3aa0ff","#36d399","#ffd666","#b37feb","#ff7a9e","#5ad8e6","#8fd3ff","#d3f26a"],Je=["#ffb84d","#c3ccdf","#d29a6a"],x=15,Xe=[{k:"today",zh:"今日",en:"Today"},{k:"yesterday",zh:"昨日",en:"Yesterday"},{k:"7d",zh:"近 7 天",en:"7d"},{k:"30d",zh:"近 30 天",en:"30d"},{k:"custom",zh:"自定义",en:"Custom"}],se=s=>({background:s?"rgba(69,200,255,0.18)":"transparent",border:`1px solid ${s?r.accent:r.border}`,color:s?r.text:r.sub,fontSize:12,borderRadius:6,padding:"3px 10px",cursor:"pointer",lineHeight:"16px",whiteSpace:"nowrap"}),ve={background:"rgba(10, 22, 56, 0.8)",border:`1px solid ${r.border}`,borderRadius:5,color:r.text,fontSize:12,padding:"2px 6px",outline:"none",colorScheme:"dark"};function _(s,e){const o=l.useRef(null),a=l.useRef(null);return l.useEffect(()=>{const c=o.current;if(!c)return;const n=G.init(c);a.current=n;const d=new ResizeObserver(()=>n.resize());return d.observe(c),()=>{d.disconnect(),n.dispose(),a.current=null}},[]),l.useEffect(()=>{a.current&&s&&a.current.setOption(s,!0)},e||[s]),o}const Se={};let K=null;function we(s){return String(s||"").replace(/(维吾尔|回族|壮族)?自治区$|特别行政区$|省$|市$/,"")}const Ze={中国:"China",China:"China",中国台湾:"China",Taiwan:"China","Taiwan, China":"China",中国香港:"China","Hong Kong":"China","Hong Kong, China":"China",中国澳门:"China",Macao:"China",Macau:"China","Macao, China":"China","United States":"United States",US:"United States",USA:"United States","United States of America":"United States","United Kingdom":"United Kingdom",UK:"United Kingdom","Great Britain":"United Kingdom",Russia:"Russia","Russian Federation":"Russia","South Korea":"Korea",Korea:"Korea","Republic of Korea":"Korea","North Korea":"Dem. Rep. Korea","Dem. Rep. Korea":"Dem. Rep. Korea",Laos:"Lao PDR","Lao PDR":"Lao PDR",Burma:"Myanmar",Myanmar:"Myanmar","Czech Republic":"Czech Rep.",Czechia:"Czech Rep.","Ivory Coast":"Côte d'Ivoire","Côte d'Ivoire":"Côte d'Ivoire","East Timor":"Timor-Leste","Timor-Leste":"Timor-Leste","Viet Nam":"Vietnam",Vietnam:"Vietnam","Brunei Darussalam":"Brunei",Swaziland:"Swaziland",Macedonia:"Macedonia"};function et(s){return Se[s]?Promise.resolve():fetch(`/geo/${s}.json`).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if(s==="china"){K={};for(const o of e.features||[]){const a=o&&o.properties&&o.properties.name;a&&(K[we(a)]=a)}}G.registerMap(s==="china"?"screen-china":"screen-world",e),Se[s]=!0})}function S({title:s,extra:e,children:o,style:a}){return t.jsxs("div",{style:{background:r.panel,border:`1px solid ${r.border}`,borderRadius:10,padding:"10px 12px",display:"flex",flexDirection:"column",minHeight:0,...a},children:[(s||e)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:4},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[t.jsx("span",{style:{width:4,height:13,background:r.accent,borderRadius:2,display:"inline-block",flexShrink:0}}),t.jsx("span",{style:{color:r.text,fontSize:13,fontWeight:600,letterSpacing:1,whiteSpace:"nowrap"},children:s})]}),e]}),t.jsx("div",{style:{flex:1,minHeight:0},children:o})]})}function I({items:s,value:e,onChange:o}){return t.jsx("div",{style:{display:"flex",gap:4,flexShrink:0},children:s.map(a=>t.jsx("button",{onClick:()=>o(a.k),style:{background:e===a.k?"rgba(69,200,255,0.18)":"transparent",border:`1px solid ${e===a.k?r.accent:r.border}`,color:e===a.k?r.text:r.sub,fontSize:11,borderRadius:5,padding:"1px 8px",cursor:"pointer",lineHeight:"18px"},children:a.label},a.k))})}function P({text:s}){return t.jsx("div",{style:{color:"#5a6f9e",fontSize:12,padding:20,textAlign:"center"},children:s})}class tt extends Be.Component{constructor(e){super(e),this.state={err:null}}static getDerivedStateFromError(e){return{err:e}}render(){var e;return this.state.err?t.jsx("pre",{style:{color:"#ff8ca3",padding:24,whiteSpace:"pre-wrap"},children:String(((e=this.state.err)==null?void 0:e.stack)||this.state.err)}):this.props.children}}function nt(s){return{direct:"直接访问",search:"搜索引擎",social:"社交网络",email:"邮件",ads:"广告",link:"外链",paid:"付费",utm:"UTM",other:"其他"}[s]||s||"未知"}function rt(s,e=26){const o=String(s||"");return o.length>e?`${o.slice(0,e)}…`:o}function st(s){const e=Number(s)||0;return e>=3600?`${Math.floor(e/3600)}h${Math.round(e%3600/60)}m`:e>=60?`${Math.floor(e/60)}m${e%60}s`:`${e}s`}function p(s){const e=Number(s)||0;return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${(e/1e4).toFixed(1)}w`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function z(s,e){const o=Number(s)||0,a=Number(e)||0;return a===0?null:Math.round((o-a)/a*1e3)/10}function ot({pct:s,upIsGood:e=!0}){if(s==null)return null;const o=s>=0,c=(e?o:!o)?r.green:r.red;return t.jsxs("span",{style:{fontSize:11,color:c,whiteSpace:"nowrap"},children:[o?"▲":"▼"," ",Math.abs(s),"%",t.jsx("span",{style:{color:r.sub,marginLeft:3},children:"环比"})]})}function it(s,e){return{grid:{left:8,right:16,top:30,bottom:4,containLabel:!0},tooltip:{trigger:"axis"},legend:{data:["PV","UV"],textStyle:{color:r.sub},top:0,right:4,itemWidth:16},xAxis:{type:"category",data:s.map(o=>o.day.slice(5)),boundaryGap:!1,axisLine:{lineStyle:{color:"rgba(90,120,190,0.4)"}},axisLabel:{color:r.sub,fontSize:10,interval:Math.max(0,Math.floor(e/10)-1)}},yAxis:{type:"value",splitLine:{lineStyle:{color:"rgba(90,120,190,0.12)"}},axisLabel:{color:r.sub,fontSize:10}},series:[{name:"PV",type:"line",smooth:!0,symbol:"none",data:s.map(o=>o.pv),lineStyle:{width:2.5,color:"#4dd7ff"},itemStyle:{color:"#4dd7ff"},areaStyle:{color:new G.graphic.LinearGradient(0,0,0,1,[{offset:0,color:"rgba(77,215,255,0.35)"},{offset:1,color:"rgba(77,215,255,0)"}])}},{name:"UV",type:"line",smooth:!0,symbol:"none",data:s.map(o=>o.uv),lineStyle:{width:2,color:"#b7e05e"},itemStyle:{color:"#b7e05e"}}]}}function at(s,e){const o=Array.isArray(s)?s:[];return{grid:{left:8,right:16,top:30,bottom:4,containLabel:!0},tooltip:{trigger:"axis",formatter:a=>{var c,n;return`${e} ${String(((c=a[0])==null?void 0:c.axisValue)??"").padStart(2,"0")}:00<br/>PV ${p((n=a[0])==null?void 0:n.value)}`}},legend:{data:["PV"],textStyle:{color:r.sub},top:0,right:4,itemWidth:16},xAxis:{type:"category",data:o.map((a,c)=>String(c).padStart(2,"0")),boundaryGap:!1,axisLine:{lineStyle:{color:"rgba(90,120,190,0.4)"}},axisLabel:{color:r.sub,fontSize:10,interval:1,formatter:a=>`${a}:00`}},yAxis:{type:"value",splitLine:{lineStyle:{color:"rgba(90,120,190,0.12)"}},axisLabel:{color:r.sub,fontSize:10}},series:[{name:"PV",type:"line",smooth:!0,symbol:"none",data:o,lineStyle:{width:2.5,color:"#4dd7ff"},itemStyle:{color:"#4dd7ff"},areaStyle:{color:new G.graphic.LinearGradient(0,0,0,1,[{offset:0,color:"rgba(77,215,255,0.35)"},{offset:1,color:"rgba(77,215,255,0)"}])}}]}}function oe(s,e){const o=(s||[]).slice(0,8),a=o.reduce((c,n)=>c+(n.pv||0),0)||1;return{tooltip:{trigger:"item",formatter:c=>`${e(c.name)}<br/>PV ${p(c.value)} · ${(c.value/a*100).toFixed(1)}%`},series:[{type:"pie",radius:["52%","78%"],center:["50%","52%"],label:{color:r.sub,fontSize:10,formatter:c=>`${rt(e(c.name),8)}
${(c.value/a*100).toFixed(0)}%`},labelLine:{lineStyle:{color:"rgba(90,120,190,0.4)"}},data:o.map((c,n)=>({name:c.name,value:c.pv,itemStyle:{color:be[n%be.length]}}))}]}}function lt(s,e){if(!e)return null;let o;if(s==="world"){const n=new Map;for(const d of e.countries||[]){const m=Ze[d.name]||d.name,w=n.get(m)||{pv:0,raw:d.name};w.pv+=Number(d.pv)||0,n.set(m,w)}o=[...n.entries()].map(([d,m])=>({name:d,disp:m.raw,pv:m.pv}))}else o=(e.provinces||[]).map(n=>({name:K&&K[we(n.name)]||n.name,disp:n.name,pv:Number(n.pv)||0}));const a=o.filter(n=>n.name&&n.pv>0).map(n=>({name:n.name,disp:n.disp,value:n.pv})),c=Math.max(1,...a.map(n=>n.value));return{tooltip:{trigger:"item",formatter:n=>n.data?`${n.data.disp||n.name}<br/>PV ${p(n.data.value)}`:n.name},visualMap:{min:0,max:c,show:!0,left:8,bottom:6,calculable:!1,text:["高","低"],textStyle:{color:r.sub,fontSize:10},inRange:{color:["#173a6e","#1e6fd9","#45c8ff"]},itemHeight:60,itemWidth:10},series:[{type:"map",map:s==="world"?"screen-world":"screen-china",roam:!0,selectedMode:!1,scaleLimit:{min:.7,max:8},itemStyle:{areaColor:"#121a36",borderColor:"rgba(110,150,240,0.4)",borderWidth:.6},emphasis:{label:{show:!0,color:"#dfe9ff",fontSize:11},itemStyle:{areaColor:"#2f9fe0"}},data:a}]}}function ct({items:s,zh:e}){const o=s||[];if(!o.length)return t.jsx(P,{text:e?"暂无数据":"No data"});const a=o.reduce((n,d)=>n+(d.pv||0),0)||1,c=o[0].pv||1;return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5,overflow:"auto",height:"100%",paddingRight:2},children:o.map((n,d)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,flexShrink:0},children:[t.jsx("span",{style:{width:17,height:17,borderRadius:4,flexShrink:0,textAlign:"center",lineHeight:"17px",fontSize:10,fontWeight:700,color:"#10203f",background:d<3?Je[d]:"rgba(90,120,190,0.25)"},children:d+1}),t.jsx("span",{style:{flex:1,fontFamily:"Consolas, monospace",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:r.text},title:n.name,children:n.name}),t.jsx("span",{style:{width:70,height:5,background:"rgba(90,120,190,0.18)",borderRadius:3,overflow:"hidden",flexShrink:0},children:t.jsx("span",{style:{display:"block",height:"100%",width:`${n.pv/c*100}%`,background:`linear-gradient(90deg, ${r.accent}, ${r.green})`,borderRadius:3}})}),t.jsx("span",{style:{width:44,textAlign:"right",color:r.accent,fontFamily:"Consolas, monospace",flexShrink:0},children:p(n.pv)}),t.jsxs("span",{style:{width:42,textAlign:"right",color:r.sub,flexShrink:0},children:[(n.pv/a*100).toFixed(1),"%"]})]},d))})}function dt({items:s,zh:e}){return!s||!s.length?t.jsx(P,{text:e?"暂无数据":"No data"}):t.jsxs("div",{style:{height:"100%",overflow:"auto"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 60px 60px",color:r.sub,fontSize:11,paddingBottom:4,borderBottom:`1px solid ${r.border}`,position:"sticky",top:0,background:"rgba(19,26,50,0.9)"},children:[t.jsx("span",{children:"IP"}),t.jsx("span",{style:{textAlign:"right"},children:"PV"}),t.jsx("span",{style:{textAlign:"right"},children:"UV"})]}),s.map((o,a)=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 60px 60px",fontSize:12,padding:"4px 0",borderBottom:"1px solid rgba(70,100,190,0.12)"},children:[t.jsx("span",{style:{fontFamily:"Consolas, monospace",color:r.green,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o.name}),t.jsx("span",{style:{textAlign:"right",color:r.text,fontFamily:"Consolas, monospace"},children:p(o.pv)}),t.jsx("span",{style:{textAlign:"right",color:r.sub,fontFamily:"Consolas, monospace"},children:p(o.uv)})]},a))]})}function ut({items:s,zh:e,label:o}){if(!s||!s.length)return t.jsx(P,{text:e?"暂无数据":"No data"});const a=s.reduce((c,n)=>c+(n.pv||0),0)||1;return t.jsxs("div",{style:{height:"100%",overflow:"auto"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 60px 56px",color:r.sub,fontSize:11,paddingBottom:4,borderBottom:`1px solid ${r.border}`,position:"sticky",top:0,background:"rgba(19,26,50,0.9)"},children:[t.jsx("span",{children:o}),t.jsx("span",{style:{textAlign:"right"},children:"PV"}),t.jsx("span",{style:{textAlign:"right"},children:"占比"})]}),s.map((c,n)=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 60px 56px",fontSize:12,padding:"4px 0",borderBottom:"1px solid rgba(70,100,190,0.12)"},children:[t.jsx("span",{style:{color:r.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name||"-"}),t.jsx("span",{style:{textAlign:"right",color:r.accent,fontFamily:"Consolas, monospace"},children:p(c.pv)}),t.jsxs("span",{style:{textAlign:"right",color:r.sub},children:[(c.pv/a*100).toFixed(1),"%"]})]},n))]})}function pt(){var xe,me;const{lang:s}=qe(),e=s==="zh-CN",[o]=Qe(),a=o.get("site_id")||"",c=o.get("token")||"",[n,d]=l.useState(null),[m,w]=l.useState(""),[je,ke]=l.useState(()=>new Date),T=`wstat_screen_pwd_${a}`,[W,B]=l.useState(()=>{try{return sessionStorage.getItem(T)||""}catch{return""}}),[Ce,q]=l.useState(!1),[ie,Re]=l.useState(""),[ae,Q]=l.useState(""),[E,$e]=l.useState("china"),[le,Ie]=l.useState(!1);l.useEffect(()=>{et(E).then(()=>Ie(!0)).catch(()=>{})},[E]);const[Y,ze]=l.useState("pages"),[N,Pe]=l.useState("channels"),[O,Te]=l.useState("ips"),[J,Ee]=l.useState("browsers"),[X,Le]=l.useState("countries"),[L,Ae]=l.useState("today"),[j,ce]=l.useState(""),[k,de]=l.useState(""),[Me,Z]=l.useState(x),[h,Fe]=l.useState(!1),[A,ee]=l.useState(!1),ue=l.useRef(null),C=l.useRef(x),M=l.useRef(null),pe=l.useMemo(()=>L==="custom"?!j||!k?"range=today":`range=custom&start=${encodeURIComponent(j)}&end=${encodeURIComponent(k)}`:`range=${encodeURIComponent(L)}`,[L,j,k]),R=l.useCallback(async()=>{if(!a||!c){w(e?"缺少 site_id 或 token 参数":"Missing site_id or token");return}try{const i=`/api/screen/data?site_id=${encodeURIComponent(a)}&token=${encodeURIComponent(c)}&${pe}`+(W?`&password=${encodeURIComponent(W)}`:""),b=await fetch(i,{cache:"no-store"}),f=await b.json().catch(()=>null);if(f&&f.code===4031){try{sessionStorage.removeItem(T)}catch{}B(""),Q(""),q(!0),d(null);return}if(f&&f.code===4032){try{sessionStorage.removeItem(T)}catch{}B(""),Q(e?"访问密码错误,请重试":"Wrong password"),q(!0);return}if(!b.ok||!f||f.code!==0)throw new Error((f==null?void 0:f.msg)||`HTTP ${b.status}`);d(f.data),w(""),q(!1)}catch(i){w(i.message)}},[a,c,W,e,T,pe]);l.useEffect(()=>{R()},[R]),l.useEffect(()=>{C.current=x,Z(x);const i=setInterval(()=>{ke(new Date),C.current-=1,C.current<=0&&(C.current=x,R()),Z(Math.max(0,C.current))},1e3);return()=>clearInterval(i)},[R]);const fe=l.useCallback(()=>{C.current=x,Z(x),R()},[R]);Ye(fe),l.useEffect(()=>{const i=()=>Fe(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",i),()=>document.removeEventListener("fullscreenchange",i)},[]);const De=l.useCallback(()=>{const i=ue.current||document.documentElement;if(document.fullscreenElement){document.exitFullscreen&&document.exitFullscreen();return}const b=i.requestFullscreen||i.webkitRequestFullscreen||i.msRequestFullscreen;if(b)try{b.call(i)}catch{}},[]),y=l.useCallback(()=>{ee(!1),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>ee(!0),4e3)},[]);l.useEffect(()=>{if(!h){ee(!1);return}return y(),window.addEventListener("mousemove",y),window.addEventListener("mousedown",y),window.addEventListener("keydown",y),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mousedown",y),window.removeEventListener("keydown",y),M.current&&clearTimeout(M.current)}},[h,y]);const he=()=>{const i=ie.trim();if(i){try{sessionStorage.setItem(T,i)}catch{}B(i),Q("")}},u=(n==null?void 0:n.totals)||{},$=(n==null?void 0:n.prev)||{},te=(n==null?void 0:n.trend)||[],ne=(n==null?void 0:n.paths)||{},ge=(n==null?void 0:n.sources)||{},re=(n==null?void 0:n.env)||{},v=(n==null?void 0:n.geo)||{},F=N==="channels"?ge.channels:ge.referrers,D=J==="browsers"?re.browsers:J==="os"?re.os:re.devices,U=X==="countries"?v.countries:X==="provinces"?v.provinces:v.cities,g=(n==null?void 0:n.range)||{},V=!!g.single_day,Ue=V?String(g.start||(n==null?void 0:n.today)||""):`${String(g.start||"").slice(5)} ~ ${String(g.end||"").slice(5)}`,H=(n==null?void 0:n.today)||new Date().toISOString().slice(0,10),_e=i=>{if(i==="custom"){const b=new Date(`${H}T00:00:00`),f=new Date(b.getTime()-6*864e5);j||ce(f.toISOString().slice(0,10)),k||de(H)}Ae(i)},Ne=_(V?at(n==null?void 0:n.hourly,g.hourly_day||g.end):it(te,g.days||te.length||30),[te,V,n==null?void 0:n.hourly,g.hourly_day,g.end,g.days]),Oe=_(lt(E,le?v:null),[E,le,v]),Ve=_(oe(F,i=>N==="channels"?nt(i):i),[F,N]),He=_(oe(D,i=>i),[D]),Ke=_(oe(U,i=>i),[U]);if(Ce)return t.jsxs("div",{style:{height:"100vh",background:r.bg,color:r.text,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:16,backgroundImage:"radial-gradient(ellipse 80% 50% at 50% -10%, rgba(42,92,255,0.25), transparent)"},children:[t.jsxs("div",{style:{background:r.panel,border:`1px solid ${r.border}`,borderRadius:12,padding:"36px 40px",width:360,display:"flex",flexDirection:"column",gap:14},children:[t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:{fontSize:34,marginBottom:6},children:"🔒"}),t.jsx("div",{style:{fontSize:18,fontWeight:700,letterSpacing:2},children:e?"访问验证":"Access"}),t.jsx("div",{style:{color:r.sub,fontSize:12,marginTop:4},children:e?"该数据大屏已启用访问密码":"This dashboard is password protected"})]}),t.jsx("input",{type:"password",autoFocus:!0,value:ie,onChange:i=>Re(i.target.value),onKeyDown:i=>{i.key==="Enter"&&he()},placeholder:e?"请输入访问密码":"Access password",style:{background:"rgba(10, 22, 56, 0.8)",border:`1px solid ${r.border}`,borderRadius:8,outline:"none",color:r.text,fontSize:15,padding:"10px 14px",textAlign:"center",letterSpacing:2}}),ae&&t.jsx("div",{style:{color:"#ff8ca3",fontSize:12,textAlign:"center"},children:ae}),t.jsx("button",{onClick:he,style:{background:`linear-gradient(90deg, ${r.accent}, #2a7cff)`,border:"none",borderRadius:8,cursor:"pointer",color:"#fff",fontSize:15,fontWeight:600,padding:"10px 0",letterSpacing:4},children:e?"进入大屏":"Enter"})]}),t.jsx(ye,{dark:!0})]});if(m&&!n)return t.jsx("div",{style:{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:r.bg,color:"#ff8ca3",fontSize:16},children:m});const Ge=[{label:e?"浏览量 (PV)":"Pageviews",value:p(u.pv),delta:z(u.pv,$.pv),color:"#4dd7ff",upIsGood:!0},{label:e?"独立访客 (UV)":"Visitors",value:p(u.uv),delta:z(u.uv,$.uv),color:"#5ad8e6",upIsGood:!0},{label:e?"IP 数":"Unique IP",value:p(u.ip),delta:z(u.ip,$.ip),color:r.purple,upIsGood:!0},{label:e?"跳出率":"Bounce",value:u.bounce_rate!=null?`${Number(u.bounce_rate).toFixed(1)}%`:"-",delta:z(u.bounce_rate,$.bounce_rate),color:"#ff7d9c",upIsGood:!1},{label:e?"停留时长":"Avg duration",value:st(u.avg_duration),delta:z(u.avg_duration,$.avg_duration),color:r.green,upIsGood:!0},{label:e?"新访客":"New visitors",value:p(u.new_users),delta:z(u.new_users,$.new_users),color:r.orange,upIsGood:!0},{label:e?"受访页":"Pages",value:p(u.pages),delta:null,color:"#8fa8ff",upIsGood:!0}],We=Y==="pages"?ne.pages:Y==="entries"?ne.entries:ne.exits;return t.jsxs("div",{ref:ue,style:{height:"100vh",background:r.bg,color:r.text,padding:"12px 16px",display:"flex",flexDirection:"column",gap:10,backgroundImage:"radial-gradient(ellipse 80% 50% at 50% -10%, rgba(42,92,255,0.22), transparent)",overflow:"hidden",cursor:h&&A?"none":"default"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",height:44,flexShrink:0,gap:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:14,minWidth:0},children:[t.jsx("span",{style:{fontSize:22,fontWeight:700,letterSpacing:2,whiteSpace:"nowrap"},children:e?"网站数据监测大屏":"Web Analytics"}),t.jsxs("span",{style:{color:r.sub,fontSize:13,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[((xe=n==null?void 0:n.site)==null?void 0:xe.name)||""," · ",((me=n==null?void 0:n.site)==null?void 0:me.domain)||""]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,flexShrink:0,opacity:h&&A?0:1,transition:"opacity 0.5s",pointerEvents:h&&A?"none":"auto"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:Xe.map(i=>t.jsx("button",{onClick:()=>_e(i.k),style:se(L===i.k),children:e?i.zh:i.en},i.k))}),L==="custom"&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[t.jsx("input",{type:"date",value:j,max:k||H,onChange:i=>ce(i.target.value),style:ve}),t.jsx("span",{style:{color:r.sub,fontSize:12},children:"~"}),t.jsx("input",{type:"date",value:k,max:H,min:j||void 0,onChange:i=>de(i.target.value),style:ve})]}),t.jsxs("button",{onClick:fe,title:e?`每 ${x} 秒自动刷新,点击立即刷新`:`Auto refresh every ${x}s, click to refresh now`,style:{...se(!1),display:"inline-flex",alignItems:"center",gap:5,fontFamily:"Consolas, monospace"},children:[t.jsx("span",{style:{display:"inline-block",animation:"wstatSpin 1.8s linear infinite"},children:"⟳"}),Me,"s"]}),t.jsx("button",{onClick:De,title:h?e?"退出全屏":"Exit fullscreen":e?"全屏展示":"Fullscreen",style:{...se(h),fontSize:14,padding:"2px 9px",lineHeight:"16px"},children:h?"⤢":"⛶"}),t.jsx("span",{style:{width:1,height:18,background:r.border}}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:13,color:r.sub,whiteSpace:"nowrap"},children:[t.jsx("span",{style:{width:8,height:8,borderRadius:8,background:r.green,boxShadow:`0 0 8px ${r.green}`}}),e?"实时在线":"Online"," ",t.jsx("b",{style:{color:r.green,fontSize:20},children:p(u.online||0)})]}),t.jsx("span",{style:{fontFamily:"Consolas, monospace",fontSize:17,color:r.text,whiteSpace:"nowrap"},children:je.toLocaleTimeString("sv-SE")})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr) 0.9fr",gap:10,flexShrink:0},children:[Ge.map(i=>t.jsxs("div",{style:{background:r.panel,border:`1px solid ${r.border}`,borderRadius:10,padding:"8px 14px",position:"relative",overflow:"hidden"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,bottom:0,width:3,background:i.color,opacity:.8}}),t.jsxs("div",{style:{color:r.sub,fontSize:11,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{children:i.label}),t.jsx(ot,{pct:i.delta,upIsGood:i.upIsGood})]}),t.jsx("div",{style:{fontSize:26,fontWeight:700,color:i.color,fontFamily:'Consolas, "DIN Alternate", sans-serif',lineHeight:1.35},children:i.value})]},i.label)),t.jsxs("div",{style:{background:r.panel,border:"1px solid rgba(61,220,151,0.4)",borderRadius:10,padding:"8px 14px",position:"relative",overflow:"hidden"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,bottom:0,width:3,background:r.green,opacity:.9}}),t.jsx("div",{style:{color:r.sub,fontSize:11},children:e?"实时在线":"Online now"}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[t.jsx("span",{style:{fontSize:26,fontWeight:700,color:r.green,fontFamily:'Consolas, "DIN Alternate", sans-serif',lineHeight:1.35},children:p(u.online||0)}),t.jsx("span",{style:{width:7,height:7,borderRadius:7,background:r.green,boxShadow:`0 0 8px ${r.green}`,animation:"wstatPulse 2s infinite"}})]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1.15fr 1fr",gap:10,flex:1.02,minHeight:0},children:[t.jsx(S,{title:`${V?e?"分时趋势":"Hourly":e?"访问趋势":"Trend"}(${Ue})`,children:t.jsx("div",{ref:Ne,style:{height:"100%",minHeight:150}})}),t.jsx(S,{title:`${e?"路径":"Paths"}(TOP 10)`,extra:t.jsx(I,{value:Y,onChange:ze,items:[{k:"pages",label:e?"路径":"Pages"},{k:"entries",label:e?"入口":"Entry"},{k:"exits",label:e?"退出":"Exit"}]}),children:t.jsx(ct,{items:We,zh:e})}),t.jsx(S,{title:`${e?"来源":"Sources"}(TOP 10)`,extra:t.jsx(I,{value:N,onChange:Pe,items:[{k:"channels",label:e?"渠道":"Channel"},{k:"referrers",label:e?"来路域名":"Referrer"}]}),children:F!=null&&F.length?t.jsx("div",{ref:Ve,style:{height:"100%",minHeight:140}}):t.jsx(P,{text:e?"暂无数据":"No data"})})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.5fr 1.05fr 1fr 1fr",gap:10,flex:1.3,minHeight:0},children:[t.jsx(S,{title:e?"访客地域分布":"Geography",extra:t.jsx(I,{value:E,onChange:$e,items:[{k:"world",label:e?"世界":"World"},{k:"china",label:e?"中国":"China"}]}),children:t.jsx("div",{ref:Oe,style:{height:"100%",minHeight:150}})}),t.jsx(S,{title:e?"IP 统计":"IP Stats",extra:t.jsx(I,{value:O,onChange:Te,items:[{k:"ips",label:"IP"},{k:"countries",label:e?"国家":"Country"},{k:"provinces",label:e?"省份":"Region"}]}),children:O==="ips"?t.jsx(dt,{items:n==null?void 0:n.ips,zh:e}):t.jsx(ut,{items:O==="countries"?v.countries:v.provinces,zh:e,label:O==="countries"?e?"国家":"Country":e?"省份":"Region"})}),t.jsx(S,{title:`${e?"环境":"Environment"}(TOP 10)`,extra:t.jsx(I,{value:J,onChange:Ee,items:[{k:"browsers",label:e?"浏览器":"Browser"},{k:"os",label:e?"系统":"OS"},{k:"devices",label:e?"设备":"Device"}]}),children:D!=null&&D.length?t.jsx("div",{ref:He,style:{height:"100%",minHeight:140}}):t.jsx(P,{text:e?"暂无数据":"No data"})}),t.jsx(S,{title:`${e?"位置":"Location"}(TOP 10)`,extra:t.jsx(I,{value:X,onChange:Le,items:[{k:"countries",label:e?"国家":"Country"},{k:"provinces",label:e?"区域":"Region"},{k:"cities",label:e?"城市":"City"}]}),children:U!=null&&U.length?t.jsx("div",{ref:Ke,style:{height:"100%",minHeight:140}}):t.jsx(P,{text:e?"暂无数据":"No data"})})]}),t.jsx("div",{style:{flexShrink:0,display:"flex",justifyContent:"flex-end",marginTop:-6,opacity:h&&A?0:1,transition:"opacity 0.5s",pointerEvents:h&&A?"none":"auto"},children:t.jsx(ye,{dark:!0})}),t.jsx("style",{children:`
@keyframes wstatPulse { 0% { opacity: 1; } 50% { opacity: 0.35; } 100% { opacity: 1; } }
@keyframes wstatSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
`})]})}function xt(){return t.jsx(tt,{children:t.jsx(pt,{})})}export{xt as default};