PageSourceSearch

https://alphasigs.net/assets/TelegramPortal-BSUwf0oP.js

js alphasigs.net collected 2026-10-05 23:14:28 UTC 256,429 bytes, 11 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFLoader-DPV8zZL8.js","assets/three-vendor-C5Tu9S6t.js","assets/RoomEnvironment-BCyMDyAK.js"])))=>i.map(i=>d[i]);
2import{r as i,j as e}from"./framer-vendor-BQFVqQmJ.js";import{u as nr}from"./usePresenceSection-CXjt1671.js";import{y as Pl,s as X,_ as es,z as rr,H as ir,c as Ul,aw as or,i as cr,d as dr,F as xr}from"./index-CjIeyhK0.js";import{e as mr}from"./newsService-BQgcVFO6.js";import{p as Nt,C as pr}from"./quantum3dCamera-XaZFqiva.js";import{D as hr}from"./database-D989o2A5.js";import{O as ur}from"./orbit-CyQNO8FT.js";import{F as br}from"./footprints-zKef0unS.js";import{G as fr}from"./git-branch-DNQr8lCf.js";import{T as gr}from"./tag-D-OU4Gob.js";import{R as jr}from"./rotate-ccw-CjH9-cAc.js";import{L as Nr}from"./loader-2-2t0eZCiY.js";import{C as yr}from"./CardHelp-Dudye4uY.js";import{S as wr}from"./AnimatedFigures-pFn5dpuj.js";import{S as Vs,a as vr}from"./SignalLeaderDetail-C70hiaDA.js";import{m as _r}from"./modelAssets-Cve_j_kn.js";import{R as kr,P as Sr,a as Cr}from"./FootprintLeaderDetail-zNby6yp6.js";import{R as $r}from"./ReferralShareModal-CMcx4fSQ.js";import{Q as Il,A as Ol,H as Bl,D as Wl,a as Hl,b as ql,r as Mr,M as Ar}from"./advancedStats-CX6M1zkz.js";import{k as Dr,r as Gl,q as zl}from"./liveCoreSignal-BVn0TuoH.js";import{g as Lr,e as Tr,u as Rr}from"./portfolioOptimizer-Cs4lTlXA.js";import"./attentionPresence-CEDwXfSq.js";import"./userProfile-p6pv0ku8.js";import"./chart-vendor-D7KebX4S.js";import"./supabase-vendor-DJa18kbt.js";import"./help-circle-CMLbn46g.js";import"./trending-up-CBXZ7X3x.js";import"./shield-alert-CkS9T0F3.js";import"./award-uG-zyCxI.js";import"./flame-BIukEp-6.js";import"./trf-BqOrmo5D.js";import"./crown-DOUSA71V.js";import"./coins-DRRmiirH.js";import"./star-D6yVohWT.js";import"./gift-DFLVEdfq.js";import"./check-BwVKdKV7.js";import"./copy-DbEAbvhP.js";import"./chevron-right-n19QyBXg.js";import"./image-BwkzZyWG.js";import"./assetRanking-kutTatfc.js";import"./arrow-up-down-BajiIHyv.js";import"./arrow-up-DS2RQfLR.js";import"./arrow-down-BorHiYDD.js";const Vl={planeHalf:11,heightBand:7,heightMetric:"auto",edgeK:3,edgeThreshold:.55,maxEdges:420,maxFaces:140},Me={win:"250, 204, 21",loss:"52, 211, 153",pending:"148, 163, 184",breakeven:"96, 165, 250"};function Fr(a){return Me[a]??Me.pending}function Er(a){return a==="win"||a==="loss"||a==="breakeven"?a:"pending"}function jt(a){if(a==null)return null;const n=typeof a=="string"?Number.parseFloat(a):a;return Number.isFinite(n)?n:null}function Ge(a,n,r){return Math.min(r,Math.max(n,a))}function Pr(a){if(Array.isArray(a)){const n=a.map(r=>typeof r=="string"?Number.parseFloat(r):r);return n.every(r=>Number.isFinite(r))?n:null}if(typeof a=="string"){const n=a.trim();if(!n)return null;const r=n.replace(/^[[(]/,"").replace(/[\])]$/,"");if(!r)return null;const x=r.split(",").map(o=>Number.parseFloat(o));return x.length>0&&x.every(o=>Number.isFinite(o))?x:null}return null}function Ur(a){const n=new Array(a);let r=0;for(let o=0;o<a;o+=1){const d=Math.sin(o*1.37+.5)+.5*Math.cos(o*.71+1.1);n[o]=d,r+=d*d}const x=r>0?1/Math.sqrt(r):1;for(let o=0;o<a;o+=1)n[o]*=x;return n}function Ir(a,n,r=160){let x=Ur(n);for(let d=0;d<r;d+=1){const u=new Array(n).fill(0);for(let p=0;p<n;p+=1){const w=a[p];let C=0;for(let c=0;c<n;c+=1)C+=w[c]*x[c];u[p]=C}let f=0;for(let p=0;p<n;p+=1)f+=u[p]*u[p];if(f<1e-18)break;const y=1/Math.sqrt(f);for(let p=0;p<n;p+=1)u[p]*=y;x=u}let o=0;for(let d=0;d<n;d+=1){let u=0;for(let f=0;f<n;f+=1)u+=a[d][f]*x[f];o+=x[d]*u}return{vector:x,value:o}}function Or(a){const n=a.length,r=n>0?a[0].length:0;if(n<2||r===0)return{coords:a.map(()=>[0,0,0]),variance:[0,0,0]};const x=new Array(r).fill(0);for(const c of a)for(let N=0;N<r;N+=1)x[N]+=c[N];for(let c=0;c<r;c+=1)x[c]/=n;const o=a.map(c=>c.map((N,v)=>N-x[v])),d=Array.from({length:r},()=>new Array(r).fill(0));for(const c of o)for(let N=0;N<r;N+=1){const v=c[N];if(v===0)continue;const M=d[N];for(let F=N;F<r;F+=1)M[F]+=v*c[F]}for(let c=0;c<r;c+=1)for(let N=c;N<r;N+=1){const v=d[c][N]/n;d[c][N]=v,d[N][c]=v}let u=0;for(let c=0;c<r;c+=1)u+=d[c][c];u=u||1;const f=[],y=[],p=d.map(c=>c.slice());for(let c=0;c<3;c+=1){const{vector:N,value:v}=Ir(p,r);f.push(N),y.push(Math.max(v,0));for(let M=0;M<r;M+=1){const F=N[M];for(let B=0;B<r;B+=1)p[M][B]-=v*F*N[B]}}const w=o.map(c=>f.map(N=>{let v=0;for(let M=0;M<r;M+=1)v+=c[M]*N[M];return v})),C=[y[0]/u,y[1]/u,y[2]/u];return{coords:w,variance:C}}function Yl(a,n){if(a.length===0)return 0;if(a.length===1)return a[0];const r=(a.length-1)*n,x=Math.floor(r),o=r-x,d=a[x+1];return d===void 0?a[x]:a[x]+o*(d-a[x])}function Xl(a){const n=a.length;if(n<=1)return a.map(()=>.5);const r=a.map((o,d)=>[o,d]).sort((o,d)=>o[0]-d[0]),x=new Array(n);return r.forEach(([,o],d)=>{x[o]=d/(n-1)}),x}function ts(a,n){if(a.length===0)return[];const r=a.slice().sort((f,y)=>f-y),x=Yl(r,.05),o=Yl(r,.95),d=(x+o)/2,u=(o-x)/2||1;return a.map(f=>Ge((f-d)/u,-1.2,1.2)*n)}function Br(a,n){const r=a.market_state;if(r&&typeof r=="object"){const x=jt(r.volatilityTemp);if(x!==null)return Ge(x/100,0,1);const o=jt(r.atrPercent);if(o!==null)return Ge(o/5,0,1);const d=jt(r.volatility);if(d!==null)return Ge(d<=1?d:d/100,0,1);const u=jt(r.atr);if(u!==null)return Ge(u/50,0,1)}return n!==null?Ge(Math.abs(n)/10,.05,1):.35}function Wr(a,n,r,x){const o=Math.min(a.length,n.length);let d=0;for(let p=0;p<o;p+=1)d+=a[p]*n[p];const u=r??Math.sqrt(a.reduce((p,w)=>p+w*w,0)),f=x??Math.sqrt(n.reduce((p,w)=>p+w*w,0)),y=u*f;return y>1e-12?d/y:0}function Hr(a,n,r,x){const o=a.length;if(o<2)return[];const d=a.map(p=>Math.sqrt(p.reduce((w,C)=>w+C*C,0))),u=[];for(let p=0;p<o;p+=1)for(let w=p+1;w<o;w+=1){const C=Wr(a[p],a[w],d[p],d[w]);C>=r&&u.push({a:p,b:w,similarity:C})}u.sort((p,w)=>w.similarity-p.similarity);const f=new Array(o).fill(0),y=[];for(const p of u){if(y.length>=x)break;f[p.a]>=n||f[p.b]>=n||(y.push(p),f[p.a]+=1,f[p.b]+=1)}return y}function qr(a,n){if(n<=0||a.length<3)return[];const r=new Map,x=(u,f,y)=>{let p=r.get(u);p||(p=new Map,r.set(u,p)),p.set(f,y)};for(const u of a)x(u.a,u.b,u.similarity),x(u.b,u.a,u.similarity);const o=new Set,d=[];for(const u of a){const f=r.get(u.a),y=r.get(u.b);if(!(!f||!y))for(const[p,w]of f){if(p===u.b)continue;const C=y.get(p);if(C===void 0)continue;const c=[u.a,u.b,p].sort((v,M)=>v-M),N=`${c[0]}-${c[1]}-${c[2]}`;o.has(N)||(o.add(N),d.push({a:c[0],b:c[1],c:c[2],strength:(u.similarity+w+C)/3}))}}return d.sort((u,f)=>f.strength-u.strength),d.slice(0,n)}function Zl(a,n={},r="live"){const x={...Vl,...n},o=[];let d=0;for(const R of a){const j=Pr(R.embedding);
2j&&(d===0&&(d=j.length),j.length===d&&o.push({row:R,vec:j}))}if(o.length<2)return{points:[],edges:[],faces:[],variance:[0,0,0],source:r,count:o.length};const u=o.map(R=>R.vec),{coords:f,variance:y}=Or(u),p=ts(f.map(R=>R[0]),x.planeHalf),w=ts(f.map(R=>R[1]),x.planeHalf),C=o.map(R=>jt(R.row.pnl_percent)),c=o.map(R=>Er(R.row.outcome)),N=c.filter(R=>R==="win"||R==="loss").length/c.length,v=x.heightMetric==="auto"?N>=.15?"outcome":"pca3":x.heightMetric,M=ts(f.map(R=>R[2]),1);let F;if(v==="pnl"){const R=C.map(j=>j??0);F=ts(R,x.heightBand).map((j,b)=>C[b]===null?0:j)}else if(v==="outcome"){const R=x.heightBand,j=[],b=[];c.forEach(($,L)=>{$==="win"?j.push(L):$==="loss"&&b.push(L)});const D=($,L)=>C[$]!==null?L*C[$]:Math.abs(M[$]),g=Xl(j.map($=>D($,1))),U=Xl(b.map($=>D($,-1))),O=new Map;j.forEach(($,L)=>O.set($,g[L])),b.forEach(($,L)=>O.set($,U[L])),F=c.map(($,L)=>{const W=.18*M[L]*R;return $==="win"?Ge((.22+.7*(O.get(L)??.5))*R+W,-1.25*R,1.25*R):$==="loss"?Ge(-(.22+.7*(O.get(L)??.5))*R+W,-1.25*R,1.25*R):.5*M[L]*R})}else F=M.map(R=>R*x.heightBand);const B=o.map((R,j)=>{const b=c[j],D=C[j],g=D!==null?D:p[j]/x.planeHalf,U=D!==null?`${D>=0?"+":""}${D.toFixed(2)}%`:g.toFixed(4),O=R.row.created_at?Date.parse(R.row.created_at):Number.NaN;return{id:R.row.id,symbol:R.row.symbol,x:p[j],y:F[j],z:w[j],outcome:b,pnlPercent:D,labelValue:g,label:U,volatility:Br(R.row,D),color:Fr(b),createdAt:Number.isFinite(O)?O:0}}),T=Hr(u,x.edgeK,x.edgeThreshold,x.maxEdges),J=qr(T,x.maxFaces??Vl.maxFaces);return{points:B,edges:T,faces:J,variance:y,source:r,count:B.length}}async function Gr(a,{symbol:n=null,limit:r=300}={}){try{const{data:x,error:o}=await a.rpc("get_constellation_embeddings",{p_limit:r,p_symbol:n});if(!o&&Array.isArray(x)&&x.length>0)return x}catch{}try{let x=a.from("trade_embeddings").select("id, symbol, embedding, outcome, pnl_percent, market_state, similarity_score, created_at").order("created_at",{ascending:!1}).limit(r);n&&(x=x.eq("symbol",n));const{data:o,error:d}=await x;if(!d&&Array.isArray(o))return o}catch{}return[]}async function zr(a,n={},r={}){const x=await Gr(a,n);if(x.length>=2){const o=Zl(x,r,"live");if(o.points.length>=2)return o}return Zl(Yr({symbol:n.symbol??"BTCUSDT"}),r,"synthetic")}function Vr(a){let n=a>>>0;return()=>{n|=0,n=n+1831565813|0;let r=Math.imul(n^n>>>15,1|n);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Yr(a={}){const{symbol:n="BTCUSDT",clusters:r=4,perCluster:x=34,dim:o=64,seed:d=1337}=a,u=Vr(d),f=()=>{const w=Math.max(u(),1e-9),C=u();return Math.sqrt(-2*Math.log(w))*Math.cos(2*Math.PI*C)},y=[],p=Date.now();for(let w=0;w<r;w+=1){const C=new Array(o).fill(0);for(let N=0;N<8;N+=1)C[(w*11+N*7)%o]=f()*.9;const c=(w%2===0?.62:.34)+w/r*.08;for(let N=0;N<x;N+=1){const v=C.map(J=>J+f()*.32),M=u()<c,F=u()<.82,B=F?M?"win":"loss":"pending",T=F?M?.4+u()*4.6:-(.4+u()*3.8):null;y.push({id:`syn-${w}-${N}`,symbol:n,embedding:v,outcome:B,pnl_percent:T,market_state:{volatilityTemp:24+w*14+u()*22},created_at:new Date(p-(y.length+1)*6e4).toISOString()})}}return y}const Ys={yaw:.55,pitch:-.42,zoom:1.05,panX:0,dolly:0},Kl={yaw:0,pitch:-.16,zoom:1,panX:0,dolly:0},Xr=-7.8,Zr=12,Qs=28,Kr=5,Jr=.12,Qr=14,Jl=46,Fe=-pr*.55;function et(a,n,r){return Math.min(r,Math.max(n,a))}function Xs(a){const n=a.split(",");return[parseInt(n[0],10)||0,parseInt(n[1],10)||0,parseInt(n[2],10)||0]}function rn(a){let n=a>>>0;return()=>{n|=0,n=n+1831565813|0;let r=Math.imul(n^n>>>15,1|n);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}const ei=(()=>{const a=rn(987654321),n=[],r=Zr,x=(o,d)=>{const u=Xr+(a()*2-1)*.7,f=Math.pow(et(1-Math.abs(o)/r,0,1),1.6);n.push({x:o,y:u,z:d,t:f,tw:a()})};for(let o=0;o<1100;o+=1)x((a()*2-1)*r,(a()*2-1)*r);for(let o=0;o<520;o+=1)x((a()*2-1)*3.2,(a()*2-1)*r);return n})();function ti(a,n,r,x,o,d,u){for(const f of o)for(const y of ei){const p=Nt(y.x,y.y,y.z+f,n,r,x);if(p.depth<=Fe)continue;const w=d(p.depth);if(w<.03)continue;const C=.78+.22*Math.sin(u*.7+y.tw*6.283),c=(.05+.32*y.t)*w*C,N=Math.round(70+140*y.t),v=Math.round(150+15*y.t),M=Math.round(80-25*y.t);a.fillStyle=`rgba(${N}, ${v}, ${M}, ${c})`;const F=Math.max(.7,1.3*p.scale);a.fillRect(p.x-F/2,p.y-F/2,F,F)}}const si=(()=>{const a=rn(424242),n=[[120,70,200],[80,110,230],[205,90,185],[95,195,225],[228,228,250]],r=()=>{const o=a();return o<.42?n[0]:o<.7?n[1]:o<.85?n[2]:o<.95?n[3]:n[4]},x=[];for(let o=0;o<900;o+=1)x.push({x:(a()*2-1)*20,y:8+a()*16,z:(a()*2-1)*20,c:r(),b:.3+a()*.6,tw:a(),big:a()<.06});for(let o=0;o<420;o+=1){const d=a()*2-1;
2x.push({x:d*22+(a()*2-1)*3,y:10+a()*12+d*4,z:d*10+(a()*2-1)*3,c:r(),b:.5+a()*.5,tw:a(),big:a()<.1})}return x})();function ai(a,n,r,x,o,d){a.save(),a.globalCompositeOperation="lighter";for(const u of o)for(const f of si){const y=Nt(f.x,f.y,f.z+u,n,r,x);if(y.depth<=Fe)continue;const p=.6+.4*Math.sin(d*1.3+f.tw*6.283),w=et(.35+y.scale*.9,0,1),C=f.b*.5*p*w;if(C<.02)continue;a.fillStyle=`rgba(${f.c[0]}, ${f.c[1]}, ${f.c[2]}, ${C})`;const c=f.big?Math.max(1.4,2.4*y.scale):Math.max(.7,1.3*y.scale);f.big&&(a.shadowColor=`rgba(${f.c[0]}, ${f.c[1]}, ${f.c[2]}, ${C})`,a.shadowBlur=6),a.fillRect(y.x-c/2,y.y-c/2,c,c),f.big&&(a.shadowBlur=0)}a.restore()}function Zs(a,n,r,x,o,d,u,f,y){if(a.clearRect(0,0,n,r),!o||o.points.length===0)return;const p=o.points,w=p.reduce((j,b)=>j+b.volatility,0)/Math.max(p.length,1),C=-70-r*.04;a.save(),a.translate(0,C);const c=u==="fly"?[0,-Qs,Qs]:[0];ai(a,n,r,x,c,f);const N=p.map(j=>Nt(j.x,j.y,j.z,n,r,x)),v=[];for(const j of c)for(let b=0;b<p.length;b+=1){const D=j===0?N[b]:Nt(p[b].x,p[b].y,p[b].z+j,n,r,x);D.depth>Fe&&v.push({i:b,pr:D})}if(v.length===0){a.restore();return}let M=1/0,F=-1/0;for(const j of v)j.pr.depth<M&&(M=j.pr.depth),j.pr.depth>F&&(F=j.pr.depth);const B=F-M||1,T=j=>et(1-(j-M)/B,0,1);if(ti(a,n,r,x,c,T,f),d.showFaces&&o.faces.length>0){a.save(),a.globalCompositeOperation="lighter";for(const j of o.faces){const b=N[j.a],D=N[j.b],g=N[j.c];if(b.depth<=Fe||D.depth<=Fe||g.depth<=Fe)continue;const U=(T(b.depth)+T(D.depth)+T(g.depth))/3;if(U<.12)continue;const[O,$,L]=Xs(p[j.a].color),[W,ee,ce]=Xs(p[j.b].color),[Z,Y,je]=Xs(p[j.c].color),Be=Math.round((O+W+Z)/3),Ee=Math.round(($+ee+Y)/3),xe=Math.round((L+ce+je)/3),le=(.015+.07*j.strength)*U;a.fillStyle=`rgba(${Be}, ${Ee}, ${xe}, ${le})`,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(D.x,D.y),a.lineTo(g.x,g.y),a.closePath(),a.fill()}a.restore()}if(d.showEdges)for(const j of o.edges){const b=N[j.a],D=N[j.b];if(b.depth<=Fe||D.depth<=Fe)continue;const g=(T(b.depth)+T(D.depth))/2;a.strokeStyle=`rgba(150, 197, 214, ${.05+.3*j.similarity*g})`,a.lineWidth=.6+.5*g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(D.x,D.y),a.stroke()}v.sort((j,b)=>b.pr.depth-j.pr.depth),a.lineJoin="round";for(const j of v){const b=j.pr,D=p[j.i],g=T(b.depth),U=D.pnlPercent!==null?et(Math.abs(D.pnlPercent)/5,0,1):.4,O=et((2.3+U*3.4)*b.scale,1,16),$=(.18+.82*g)*(1-.42*D.volatility);a.save(),a.globalCompositeOperation="lighter";const L=O*(2.1+1.3*D.volatility);a.fillStyle=`rgba(${D.color}, ${.09*$})`,a.beginPath(),a.arc(b.x,b.y,L,0,Math.PI*2),a.fill(),a.fillStyle=`rgba(${D.color}, ${.2*$})`,a.beginPath(),a.arc(b.x,b.y,O*1.5,0,Math.PI*2),a.fill(),a.fillStyle=`rgba(${D.color}, ${$})`,a.beginPath(),a.arc(b.x,b.y,O,0,Math.PI*2),a.fill(),a.fillStyle=`rgba(255, 255, 255, ${.5*$})`,a.beginPath(),a.arc(b.x,b.y,Math.max(O*.3,.6),0,Math.PI*2),a.fill(),a.restore()}if(d.showLabels){const j=new Map;for(const g of v){const U=j.get(g.i);(!U||g.pr.depth<U.depth)&&j.set(g.i,g.pr)}const b=[...j.entries()].map(([g,U])=>({p:p[g],pr:U})).filter(g=>T(g.pr.depth)>.42).sort((g,U)=>Math.abs(U.p.labelValue)-Math.abs(g.p.labelValue)),D=[];a.font="600 11px ui-monospace, SFMono-Regular, Menlo, monospace",a.textBaseline="middle",a.textAlign="left";for(const g of b){if(D.length>=Qr)break;D.some(U=>Math.abs(U.x-g.pr.x)<Jl&&Math.abs(U.y-g.pr.y)<Jl)||(D.push(g.pr),a.fillStyle=`rgba(${g.p.color}, ${.82*T(g.pr.depth)})`,a.fillText(g.p.label,g.pr.x+8,g.pr.y-8))}if(y===""){const g=new Map;for(let $=0;$<p.length;$+=1){const L=N[$];if(L.depth<=Fe||T(L.depth)<.25)continue;const W=g.get(p[$].symbol)??{sx:0,sy:0,n:0};W.sx+=L.x,W.sy+=L.y,W.n+=1,g.set(p[$].symbol,W)}const U=[...g.entries()].map(([$,L])=>({sym:$,x:L.sx/L.n,y:L.sy/L.n,n:L.n})).sort(($,L)=>L.n-$.n).slice(0,12);a.font="700 12px ui-sans-serif, system-ui, sans-serif";const O=[];for(const $ of U){if(O.some(W=>Math.abs(W.x-$.x)<84&&Math.abs(W.y-$.y)<22))continue;O.push($);const L=a.measureText($.sym).width;a.fillStyle="rgba(0, 0, 0, 0.5)",a.fillRect($.x-5,$.y-9,L+10,18),a.fillStyle="rgba(255, 255, 255, 0.92)",a.fillText($.sym,$.x,$.y+.5)}}}a.restore();const J=.06+.22*w,R=a.createLinearGradient(0,r*.52,0,r);R.addColorStop(0,"rgba(120, 150, 120, 0)"),R.addColorStop(1,`rgba(120, 150, 120, ${J})`),a.fillStyle=R,a.fillRect(0,r*.52,n,r*.48)}
2function li({symbol:a,height:n=540}){const r=i.useRef(null),x=i.useRef(null),o=i.useRef({...Ys}),d=i.useRef(null),u=i.useRef({w:800,h:n}),f=i.useRef(0),y=i.useRef(0),p=i.useRef(0),w=i.useRef(null),C=i.useRef(!0),c=i.useRef("orbit"),N=i.useRef({showEdges:!0,showLabels:!0,showFaces:!0}),v=i.useRef(a??""),[M,F]=i.useState(null),[B,T]=i.useState(!0),[J,R]=i.useState(!0),[j,b]=i.useState(!0),[D,g]=i.useState(!0),[U,O]=i.useState(!0),[$,L]=i.useState("orbit"),[W,ee]=i.useState(a??""),[ce,Z]=i.useState([]),[Y,je]=i.useState(null);i.useEffect(()=>{C.current=U},[U]),i.useEffect(()=>{N.current={showEdges:J,showLabels:j,showFaces:D}},[J,j,D]),i.useEffect(()=>{c.current=$,o.current={...$==="fly"?Kl:Ys},p.current=0},[$]),i.useEffect(()=>{v.current=W},[W]),i.useEffect(()=>{let A=!0;return T(!0),zr(X,{symbol:W||null,limit:320}).then(G=>{if(A&&(d.current=G,F(G),W===""&&G.points.length>0)){const te=new Map;for(const K of G.points)te.set(K.symbol,(te.get(K.symbol)??0)+1);Z([...te.entries()].map(([K,re])=>({s:K,n:re})).sort((K,re)=>re.n-K.n))}}).catch(()=>{A&&(d.current=null,F(null))}).finally(()=>{A&&T(!1)}),()=>{A=!1}},[W]),i.useEffect(()=>{const A=x.current,G=r.current;if(!A||!G)return;const te=()=>{const ie=A.getBoundingClientRect();if(ie.width===0||ie.height===0)return!1;const ge=Math.min(window.devicePixelRatio||1,2);u.current={w:ie.width,h:ie.height},G.width=Math.round(ie.width*ge),G.height=Math.round(ie.height*ge),G.style.width=`${ie.width}px`,G.style.height=`${ie.height}px`;const _e=G.getContext("2d");return _e&&(_e.setTransform(ge,0,0,ge,0,0),Zs(_e,ie.width,ie.height,o.current,d.current,N.current,c.current,performance.now()/1e3,v.current)),!0};let K=0;const re=()=>{te()||(K=requestAnimationFrame(re))};re();const ae=new ResizeObserver(()=>te());return ae.observe(A),()=>{ae.disconnect(),K&&cancelAnimationFrame(K)}},[]),i.useEffect(()=>{const A=r.current,G=A==null?void 0:A.getContext("2d");if(!G)return;const te=K=>{const re=y.current?Math.min((K-y.current)/1e3,.05):.016;y.current=K;const{w:ae,h:ie}=u.current,ge=o.current;c.current==="fly"?(p.current+=Kr*re,ge.dolly=p.current%Qs):(ge.dolly=0,C.current&&!w.current&&(ge.yaw+=Jr*re)),Zs(G,ae,ie,ge,d.current,N.current,c.current,K/1e3,v.current),f.current=requestAnimationFrame(te)};return f.current=requestAnimationFrame(te),()=>cancelAnimationFrame(f.current)},[]),i.useEffect(()=>{var G;const A=(G=r.current)==null?void 0:G.getContext("2d");A&&Zs(A,u.current.w,u.current.h,o.current,d.current,N.current,c.current,performance.now()/1e3,v.current)},[M,$,J,j,D,W]),i.useEffect(()=>{const A=r.current;if(!A)return;const G=te=>{te.preventDefault();const K=o.current;K.zoom=et(K.zoom*(1-te.deltaY*.001),.45,3.2)};return A.addEventListener("wheel",G,{passive:!1}),()=>A.removeEventListener("wheel",G)},[]);const Be=A=>{w.current={x:A.clientX,y:A.clientY},A.currentTarget.setPointerCapture(A.pointerId)},Ee=A=>{const G=w.current;if(G){const Ne=A.clientX-G.x,We=A.clientY-G.y,He=o.current;He.yaw+=Ne*.005,He.pitch=et(He.pitch+We*.005,-1.25,-.02),w.current={x:A.clientX,y:A.clientY};return}const te=r.current,K=d.current;if(!te||!K)return;const re=te.getBoundingClientRect(),ae=A.clientX-re.left,ie=A.clientY-re.top,{w:ge,h:_e}=u.current,ls=o.current,ns=-70-_e*.04;let Te=null,ct=18*18;for(const Ne of K.points){const We=Nt(Ne.x,Ne.y,Ne.z,ge,_e,ls);if(We.depth<=Fe)continue;const He=We.x-ae,wt=We.y+ns-ie,ze=He*He+wt*wt;ze<ct&&(ct=ze,Te=Ne)}je(Te?{symbol:Te.symbol,outcome:Te.outcome,label:Te.label,pnl:Te.pnlPercent,x:ae,y:ie}:Ne=>Ne&&null)},xe=A=>{w.current=null,je(null);try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}},le=()=>{o.current={...c.current==="fly"?Kl:Ys},p.current=0},fe=M==null?void 0:M.source,Ae=M?Math.round((M.variance[0]+M.variance[1]+M.variance[2])*100):0,De=M?M.points.reduce((A,G)=>(A[G.outcome]=(A[G.outcome]??0)+1,A),{}):null,ne=A=>`inline-flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-bold transition ${A?"border-cyan-400/60 bg-cyan-500/15 text-cyan-100":"border-white/10 bg-white/5 text-slate-400 hover:text-slate-200"}`,Le=A=>`rounded-lg border px-2.5 py-1 text-xs font-bold transition ${A?"border-cyan-400/60 bg-cyan-500/15 text-cyan-100":"border-white/10 bg-white/5 text-slate-400 hover:text-slate-200"}`;return e.jsxs("div",{className:"relative",children:[ce.length>1?e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"mr-0.5 text-xs font-semibold text-slate-400",children:"สินทรัพย์ที่เทรด:"}),e.jsx("button",{className:Le(W===""),onClick:()=>ee(""),children:"ทั้งหมด"}),ce.map(({s:A,n:G})=>e.jsxs("button",{className:Le(W===A),onClick:()=>ee(A),children:[A,e.jsx("span",{className:"ml-1 text-[10px] opacity-60",children:G})]},A))]}):null,e.jsxs("div",{ref:x,className:"relative overflow-hidden rounded-3xl border border-cyan-500/20 bg-[radial-gradient(ellipse_at_50%_45%,#08080f,#000000)] shadow-2xl shadow-black/40",style:{height:n},children:[e.jsx("canvas",{ref:r,className:"h-full w-full touch-none cursor-grab active:cursor-grabbing",onPointerDown:Be,onPointerMove:Ee,onPointerUp:xe,onPointerLeave:xe}),Y?e.jsxs("div",{className:"pointer-events-none absolute z-30 -translate-y-full rounded-lg border border-white/15 bg-black/85 px-2.5 py-1 text-[11px] font-medium text-slate-100 shadow-lg backdrop-blur",style:{left:Y.x+10,top:Y.y-2},children:[e.jsx("span",{className:"font-bold text-white",children:Y.symbol})," ",e.jsx("span",{style:{color:Y.outcome==="win"?`rgb(${Me.win})`:Y.outcome==="loss"?`rgb(${Me.loss})`:`rgb(${Me.pending})`},children:Y.outcome==="win"?"ชนะ":Y.outcome==="loss"?"แพ้":"รอผล"}),Y.pnl!=null?e.jsxs("span",{className:"text-slate-300",children:[" · ",Y.label]}):null]}):null,e.jsxs("div",{className:"pointer-events-none absolute left-4 top-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-white/10 bg-black/55 px-3 py-1.5 text-xs font-bold text-slate-100 backdrop-blur",children:[fe==="synthetic"?e.jsx(Pl,{className:"h-3.5 w-3.5 text-amber-300"}):e.jsx(hr,{className:"h-3.5 w-3.5 text-emerald-300"}),fe==="synthetic"?"Demo cloud (no live embeddings)":"Live trade_embeddings",M?e.jsxs("span",{className:"text-slate-400",children:["· ",M.count," pts"]}):null]}),De?e.jsxs("div",{className:"inline-flex w-fit items-center gap-2 rounded-full border border-white/10 bg-black/45 px-3 py-1 text-[11px] font-medium text-slate-300 backdrop-blur",children:[e.jsxs("span",{style:{color:`rgb(${Me.win})`},children:[De.win??0," ชนะ"]}),e.jsxs("span",{style:{color:`rgb(${Me.loss})`},children:[De.loss??0," แพ้"]}),e.jsxs("span",{style:{color:`rgb(${Me.pending})`},children:[De.pending??0," รอ"]}),e.jsxs("span",{className:"text-slate-500",children:["· PCA ",Ae,"%"]})]}):null]}),e.jsxs("div",{className:"absolute right-4 top-4 flex flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{className:"flex rounded-lg border border-white/10 bg-white/5 p-0.5",children:[e.jsxs("button",{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-bold transition ${$==="orbit"?"bg-cyan-500 text-slate-950":"text-slate-300 hover:bg-white/10"}`,onClick:()=>L("orbit"),children:[e.jsx(ur,{className:"h-3.5 w-3.5"})," หมุนรอบ"]}),e.jsxs("button",{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-bold transition ${$==="fly"?"bg-cyan-500 text-slate-950":"text-slate-300 hover:bg-white/10"}`,onClick:()=>L("fly"),children:[e.jsx(br,{className:"h-3.5 w-3.5"})," เดินทะลุ"]})]}),e.jsxs("button",{className:ne(J),onClick:()=>R(A=>!A),children:[e.jsx(fr,{className:"h-3.5 w-3.5"})," Links"]}),e.jsxs("button",{className:ne(D),onClick:()=>g(A=>!A),children:[e.jsx(Pl,{className:"h-3.5 w-3.5"})," Mesh"]}),e.jsxs("button",{className:ne(j),onClick:()=>b(A=>!A),children:[e.jsx(gr,{className:"h-3.5 w-3.5"})," Labels"]}),$==="orbit"?e.jsxs("button",{className:ne(U),onClick:()=>O(A=>!A),children:[e.jsx(jr,{className:"h-3.5 w-3.5"})," Auto"]}):null,e.jsx("button",{className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-bold text-slate-300 transition hover:text-white",onClick:le,children:"Reset"})]}),e.jsxs("div",{className:"pointer-events-none absolute bottom-4 left-4 flex flex-wrap items-center gap-3 rounded-xl border border-white/10 bg-black/50 px-3 py-2 text-[11px] font-semibold text-slate-200 backdrop-blur",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{background:`rgb(${Me.win})`}})," ชนะ"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{background:`rgb(${Me.loss})`}})," แพ้"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{background:`rgb(${Me.pending})`}})," รอผล"]}),e.jsx("span",{className:"text-slate-500",children:"สูง=ชนะ · ต่ำ=แพ้ · หมอก=volatility · เส้น=similarity"})]}),e.jsx("div",{className:"pointer-events-none absolute bottom-4 right-4 rounded-lg border border-white/10 bg-black/45 px-3 py-1.5 text-[11px] text-slate-400 backdrop-blur",children:$==="fly"?"กล้องไหลไปข้างหน้า · ลากเพื่อมองรอบ":"ลากเพื่อหมุน · scroll เพื่อซูม"}),B?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-slate-950/40 backdrop-blur-sm",children:e.jsxs("div",{className:"inline-flex items-center gap-2 text-sm font-bold text-cyan-200",children:[e.jsx(Nr,{className:"h-5 w-5 animate-spin"})," กำลังสร้างโลกการเงิน…"]})}):null]})]})}const ni=_r("footprint-lab-molecule.glb"),ri="Material.006";function Ql({size:a=40,className:n="",label:r="Footprint Lab"}){const x=i.useRef(null),[o,d]=i.useState(!1),[u,f]=i.useState(!1);return i.useEffect(()=>{const y=x.current;if(!y)return;let p=!1,w=null;return(async()=>{var Ee;let C;try{C=await Promise.all([es(()=>import("./three-vendor-C5Tu9S6t.js"),[]),es(()=>import("./GLTFLoader-DPV8zZL8.js"),__vite__mapDeps([0,1])),es(()=>import("./meshopt_decoder.module-CkuQsJa_.js"),[]),es(()=>
2import("./RoomEnvironment-BCyMDyAK.js"),__vite__mapDeps([2,1]))])}catch{p||d(!0);return}if(p)return;const[c,{GLTFLoader:N},{MeshoptDecoder:v},{RoomEnvironment:M}]=C;let F;try{F=new c.WebGLRenderer({alpha:!0,antialias:!0,powerPreference:"low-power"})}catch{p||d(!0);return}F.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),F.setSize(a,a),F.toneMapping=c.ACESFilmicToneMapping,F.toneMappingExposure=1.15,F.domElement.style.display="block",y.appendChild(F.domElement);const B=new c.Scene,T=new c.PerspectiveCamera(32,1,.1,100);T.position.set(0,.28,2.55),T.lookAt(0,0,0);const J=new c.PMREMGenerator(F),R=J.fromScene(new M,.04);B.environment=R.texture;const j=new c.DirectionalLight(16777215,1.6);j.position.set(2,3,2.5);const b=new c.DirectionalLight(16096779,1.1);b.position.set(-2.5,.5,-2),B.add(j,b,new c.AmbientLight(16777215,.35));const D=new c.Group;D.rotation.x=.12,B.add(D);const g=((Ee=window.matchMedia)==null?void 0:Ee.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let U=!0,O=document.visibilityState==="visible";const $=()=>!g&&U&&O;let L=0,W=0;const ee=xe=>{const le=W?Math.min((xe-W)/1e3,.1):0;W=xe,D.rotation.y+=le*.55,F.render(B,T),L=$()?requestAnimationFrame(ee):0},ce=()=>{!L&&$()&&(W=0,L=requestAnimationFrame(ee))},Z=()=>{L||F.render(B,T)},Y=new IntersectionObserver(([xe])=>{U=xe.isIntersecting,ce()},{threshold:0});Y.observe(y);const je=()=>{O=document.visibilityState==="visible",ce()};if(document.addEventListener("visibilitychange",je),w=()=>{cancelAnimationFrame(L),Y.disconnect(),document.removeEventListener("visibilitychange",je),F.dispose(),B.traverse(xe=>{const le=xe;le.geometry&&le.geometry.dispose(),le.material&&(Array.isArray(le.material)?le.material:[le.material]).forEach(fe=>fe.dispose())}),R.texture.dispose(),J.dispose();try{F.forceContextLoss()}catch{}F.domElement.remove()},p){w();return}const Be=new N;Be.setMeshoptDecoder(v),Be.load(ni,xe=>{if(p)return;const le=xe.scene;le.traverse(te=>{const K=te;if(K.isMesh)for(const re of Array.isArray(K.material)?K.material:[K.material]){const ae=re;ae.envMapIntensity=1,ae.name===ri&&(ae.metalness=.15,ae.roughness=.1,ae.transparent=!0,ae.opacity=.42,ae.depthWrite=!1)}});const fe=new c.Box3().setFromObject(le),Ae=fe.getSize(new c.Vector3),De=fe.getCenter(new c.Vector3),ne=1/(Math.max(Ae.x,Ae.y,Ae.z)||1);le.position.sub(De).multiplyScalar(ne),le.scale.setScalar(ne);const Le=Ae.y*ne/2,A=Math.hypot(Ae.x*ne,Ae.z*ne)/2,G=T.fov*Math.PI/360;T.position.set(0,Le*.12,Math.max(Le,A)/Math.tan(G)*1.1),T.lookAt(0,0,0),D.add(le),f(!0),Z(),ce()},void 0,()=>{p||d(!0)})})(),()=>{p=!0,w==null||w()}},[a]),o?e.jsx("span",{className:n,style:{fontSize:a*.8,lineHeight:1},children:"🧪"}):e.jsxs("span",{className:`relative inline-block shrink-0 align-middle ${n}`,style:{width:a,height:a},role:"img","aria-label":r,children:[!u&&e.jsx("span",{className:"absolute inset-0 grid place-items-center",style:{fontSize:a*.8,lineHeight:1},"aria-hidden":!0,children:"🧪"}),e.jsx("span",{ref:x,"aria-hidden":!0,className:"transition-opacity duration-500",style:{display:"block",width:a,height:a,opacity:u?1:0}})]})}function ss(a){const n=a||"";return/10015|Unknown Webhook/i.test(n)?"Webhook ถูกลบหรือไม่มีอยู่แล้ว (Unknown Webhook)":/50027|Invalid Webhook Token/i.test(n)?"Webhook URL ไม่ถูกต้อง":n?`Discord ตอบ: ${n.slice(0,80)}`:"ส่งไม่สำเร็จ"}const yt=[{group:"Crypto",symbols:["BTCUSD","ETHUSD","SOLUSD","XRPUSD","BNBUSD","LTCUSD","LINKUSD","AVAXUSD","DOGEUSD","ADAUSD"]},{group:"Metals",symbols:["XAUUSD","XAGUSD"]},{group:"Forex",symbols:["EURUSD","GBPUSD","AUDUSD","USDJPY","USDCAD","EURJPY","EURCAD"]},{group:"Indices",symbols:["US30","US500","USTEC","NASCOMP","US2000","DE40","UK100","FRA40","ESP35","EU50","JP225","HK50","CN50","AUS200","IN50","SET"]},{group:"Stocks",symbols:["WMT","PTG"]}],ii=yt.flatMap(a=>a.symbols),oi=[{group:"Crypto",icon:"₿",symbols:["BTCUSD","ETHUSD","SOLUSD","BNBUSD","LTCUSD","LINKUSD","DOGEUSD","AVAXUSD","ADAUSD","XRPUSD"]},{group:"Metals",icon:"🥇",symbols:["XAUUSD","XAGUSD"],note:"XAUUSD อ่าน order flow จาก PAXG (ทองโทเคน) — แหล่งราคาทองเดียวกับที่ระบบใช้ · XAGUSD ยังไม่มีแหล่งข้อมูล"},{group:"Forex",icon:"💱",symbols:["EURUSD","GBPUSD","USDJPY","AUDUSD"],note:"EURUSD กำลังเก็บสถิติจาก EURUSDT · คู่อื่นไม่มี order book สาธารณะ"}],ci=yt.map(a=>a.group),en=new Set(["BTCUSD","ETHUSD","SOLUSD","XRPUSD","BNBUSD","LTCUSD","LINKUSD","AVAXUSD","DOGEUSD","ADAUSD","XAUUSD"]);function di({assets:a,onSet:n}){const[r,x]=i.useState(null),[o,d]=i.useState("broker");i.useEffect(()=>{let c=!0;return Dr().then(N=>{c&&x(N)}),()=>{c=!1}},[]);const u=i.useMemo(()=>r?[...r.values()].map(c=>({r:c,cost:zl(c,o),net:Gl(c,o)})).sort((c,N)=>c.net==null!=(N.net==null)?c.net==null?1:-1:(N.net??-1/0)-(c.net??-1/0)):[],[r,o]),f=u.filter(c=>c.net!=null),y=new Set(a.map(c=>c.toUpperCase())),p=a.filter(c=>{const N=r==null?void 0:r.get(c.toUpperCase());return!N||Gl(N,o)==null}),w=()=>{const c=y.size===0?f.map(v=>v.r.asset):a.map(v=>v.toUpperCase()),N=new Set(c.map(v=>({a:v,cost:zl(r==null?void 0:r.get(v),o)})).filter(v=>v.cost!=null).sort((v,M)=>
2(M.cost??0)-(v.cost??0)).slice(0,3).map(v=>v.a));n(c.filter(v=>!N.has(v)))},C=(c,N=3)=>c==null||!Number.isFinite(c)?"—":`${c>=0?"+":""}${c.toFixed(N)}`;return e.jsxs("div",{className:"mt-4 rounded-xl border border-slate-700/60 bg-slate-900/40 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-200",children:"จัดพอร์ตด้วยต้นทุนจริง"}),e.jsx("div",{className:"flex items-center gap-0.5 rounded border border-slate-700 bg-slate-950/60 p-0.5",children:["broker","exchange"].map(c=>e.jsx("button",{onClick:()=>d(c),className:`rounded px-2 py-0.5 text-[10px] transition-colors ${o===c?"bg-cyan-500/20 text-cyan-300":"text-slate-500 hover:text-slate-300"}`,children:c==="broker"?"โบรก CFD":"Exchange"},c))}),e.jsx("button",{onClick:w,disabled:f.length<3,className:"rounded-lg border border-emerald-500/40 bg-emerald-500/10 px-2.5 py-1 text-[11px] font-semibold text-emerald-200 transition-colors hover:bg-emerald-500/20 disabled:opacity-40",children:"ตัด 3 คู่ที่ต้นทุนแพงที่สุด"})]}),e.jsxs("p",{className:"mb-2 text-[11px] leading-relaxed text-slate-400",children:["ตอนนี้ช่องนี้รับ"," ",e.jsx("b",{className:"text-slate-200",children:a.length===0?"ทุกคู่":`${a.length} คู่`})," · ","วัดนอกตัวอย่างแล้ว การตัดคู่ที่ต้นทุนแพงออกลด drawdown จาก"," ",e.jsxs("b",{className:"tabular-nums text-slate-300",children:[Lr.toFixed(3),"R"]})," เหลือ"," ",e.jsxs("b",{className:"tabular-nums text-emerald-300",children:[Tr.toFixed(3),"R"]})," ","(",e.jsxs("b",{children:["−",Rr,"%"]}),") — เป็นการลด",e.jsx("b",{className:"text-slate-300",children:"ความเสี่ยงขาลง"})," ไม่ใช่เพิ่มกำไร"]}),r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"max-h-64 overflow-auto rounded border border-slate-800",children:e.jsxs("table",{className:"w-full min-w-[400px] text-[11px]",children:[e.jsx("thead",{className:"sticky top-0 bg-slate-900",children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:[e.jsx("th",{className:"py-1 pl-2 pr-2 text-left font-medium",children:"รับ"}),e.jsx("th",{className:"py-1 pr-2 text-left font-medium",children:"คู่"}),e.jsx("th",{className:"py-1 pr-2 text-right font-medium",children:"ไม้"}),e.jsx("th",{className:"py-1 pr-2 text-right font-medium",children:"ชนะ"}),e.jsx("th",{className:"py-1 pr-2 text-right font-medium",children:"ทุน"}),e.jsx("th",{className:"py-1 pr-2 text-right font-medium",children:"net R"})]})}),e.jsx("tbody",{children:u.map(({r:c,cost:N,net:v})=>{const M=y.size===0||y.has(c.asset);return e.jsxs("tr",{className:`border-t border-slate-800/70 ${v==null?"opacity-60":""}`,children:[e.jsx("td",{className:"py-1 pl-2 pr-2",children:e.jsx("input",{type:"checkbox",checked:y.has(c.asset),"aria-label":`ส่ง ${c.asset} เข้าช่องนี้`,onChange:F=>{const B=new Set(y);F.target.checked?B.add(c.asset):B.delete(c.asset),n([...B])},className:"h-3 w-3 accent-cyan-500"})}),e.jsx("td",{className:`py-1 pr-2 font-medium ${M?"text-slate-200":"text-slate-500"}`,children:c.asset}),e.jsx("td",{className:"py-1 pr-2 text-right tabular-nums text-slate-400",children:c.n.toLocaleString()}),e.jsx("td",{className:"py-1 pr-2 text-right tabular-nums text-slate-400",title:"จุดคุ้มทุน 60% ที่ RR 0.667 — ต่ำกว่านี้คือขาดทุนแม้ชนะบ่อย",children:c.winPct==null?"—":`${c.winPct}%`}),e.jsx("td",{className:"py-1 pr-2 text-right tabular-nums text-slate-500",children:N==null?"—":`−${N.toFixed(3)}`}),e.jsx("td",{className:`py-1 pr-2 text-right font-semibold tabular-nums ${v==null?"text-slate-600":v>0?"text-emerald-300":v>-.05?"text-amber-300":"text-rose-300"}
2`,children:v==null?"ไม่มีสเปรด":C(v)})]},c.asset)})})]})}),e.jsxs("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:["เรียงตาม ",e.jsx("b",{className:"text-slate-400",children:"net R"})," (กำไรต่อไม้หลังหักสเปรดที่วัดจริง) ไม่ใช่ Win % — ที่ RR 0.667 จุดคุ้มทุนคือ 60% และคู่ที่ชนะบ่อยที่สุดมักไม่ใช่คู่ที่เหลือเงินมากที่สุด · สถิติมาจากบุ๊ค",e.jsx("b",{className:"text-slate-400",children:"ทั้งเอนจิน"})," ไม่ใช่จากช่องนี้ เพราะไม้ต่อคู่ของช่องเดียวยังน้อยเกินกว่าจะจัดอันดับได้"]}),p.length>0&&e.jsxs("p",{className:"mt-1.5 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1.5 text-[10px] leading-relaxed text-amber-200/85",children:["⚠️ ",p.length," คู่ที่เลือกไว้ยังไม่มีสเปรดที่วัดจริงบนเวนิวนี้ (",p.slice(0,6).join(", "),p.length>6?"…":"",") — คิด net R ให้ไม่ได้ จึงไม่เดาให้ ส่งได้ตามปกติแต่ยังไม่รู้ต้นทุน"]}),a.length>0&&e.jsxs("p",{className:"mt-1.5 text-[10px] leading-relaxed text-slate-500",children:["หมายเหตุ: ตัวกรองนี้เป็น",e.jsx("b",{className:"text-slate-400",children:"รายการที่อนุญาต"})," — ถ้าเราเพิ่มคู่ใหม่ทีหลัง ช่องนี้จะ",e.jsx("b",{className:"text-slate-400",children:"ไม่ได้รับ"}),"จนกว่าคุณจะกลับมาเพิ่มเอง (เว้นว่างไว้ = รับทุกคู่เสมอ)"]})]}):e.jsx("p",{className:"py-3 text-center text-[11px] text-slate-500",children:"กำลังโหลดข้อมูลต้นทุน…"})]})}var nn;const xi=new Set(((nn=yt.find(a=>a.group==="Crypto"))==null?void 0:nn.symbols)||[]),mi={XAUUSD:"ทองคำ",XAGUSD:"เงิน",US30:"Dow Jones",US500:"S&P 500",USTEC:"Nasdaq 100",NASCOMP:"Nasdaq Composite",US2000:"Russell 2000",DE40:"DAX",UK100:"FTSE 100",FRA40:"CAC 40",ESP35:"IBEX 35",EU50:"Euro Stoxx 50",JP225:"Nikkei 225",HK50:"Hang Seng",CN50:"China (HSCEI)",AUS200:"ASX 200",IN50:"Nifty 50",SET:"SET ไทย",WMT:"Walmart",PTG:"PTG"},ve=a=>mi[a]||"";function tn({tfs:a,onTfs:n,pattern:r,onPattern:x}){return e.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] px-3.5 py-3","data-pa-tf-filter":!0,children:[e.jsx("p",{className:"text-xs text-slate-400",children:"ดู Price Action จากไทม์เฟรม (เลือกได้หลายอัน · ผ่านถ้าเจอใน TF ใดก็ได้)"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:[{v:"15m",l:"M15"},{v:"1h",l:"H1"},{v:"4h",l:"H4"},{v:"1d",l:"D1"}].map(o=>e.jsx("button",{type:"button",onClick:()=>n(d=>d.includes(o.v)?d.filter(u=>u!==o.v):[...d,o.v]),className:`rounded-lg border px-3 py-1.5 text-xs ${a.includes(o.v)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:o.l},o.v))}),a.length===0?e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed text-slate-500",children:"ยังไม่เลือก TF = ใช้ pattern ที่ engine ตรวจบนแท่ง 15m ของสัญญาณเอง (แบบเดิม — แทบไม่มีสำหรับทอง/forex/indices)"}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-3 text-xs text-slate-400",children:"ชนิด pattern"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:[{v:"any",label:"ทุก pattern",hint:"Engulfing, Hammer, Morning Star, Pin bar ฯลฯ ที่ชี้ทิศเดียวกับสัญญาณ"},{v:"engulfing",label:"Engulfing เท่านั้น",hint:"แท่งกลืนกิน — Bullish Engulfing สำหรับ BUY · Bearish Engulfing สำหรับ SELL"}].map(o=>e.jsx("button",{type:"button",onClick:()=>x(o.v),title:o.hint,className:`rounded-lg border px-2.5 py-1.5 text-xs ${r===o.v?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:o.label},o.v))}),e.jsxs("p",{className:"mt-2 text-[11px] leading-relaxed text-slate-500",children:["ส่งเมื่อ",e.jsx("span",{className:"text-slate-300",children:"แท่งที่ปิดล่าสุด"}),"ของ ",a.map(o=>({"15m":"M15","1h":"H1","4h":"H4","1d":"D1"})[o]).join(" / ")," มี ",r==="engulfing"?"Engulfing":"pattern"," ทิศเดียวกับสัญญาณ (BUY ต้องเป็นขาขึ้น · SELL ต้องเป็นขาลง) · ใช้ได้ทุกสินทรัพย์รวมทอง/forex/indices"," · ","ชื่อ pattern กับ TF ที่เà¸
2ˆà¸­à¸ˆà¸°à¹à¸ªà¸”งบนการ์ดสัญญาณ"]}),e.jsxs("p",{className:"mt-1 text-[11px] leading-relaxed text-amber-400/80",children:["สัญญาณจะน้อยลงมาก: ต่อ 1 TF ผ่านราว ",r==="engulfing"?"1 ใน 11":"1 ใน 5"," ของสัญญาณ (วัดจากแท่งจริง 3,876 แท่งต่อ TF)"," · ","เป็นตัวกรองเพื่อเลือกสัญญาณตามสไตล์ ยังไม่มีการวัดว่าทำให้อัตราชนะสูงขึ้น"]})]})]})}const sn=[{v:"7d",l:"7 วัน"},{v:"30d",l:"30 วัน"},{v:"90d",l:"90 วัน"},{v:"all",l:"ทั้งหมด"}],pi=a=>{var n;return((n=yt.find(r=>r.symbols.includes(a)))==null?void 0:n.group)||"อื่นๆ"};function an(a){const n=(a||"").trim(),r=n.match(/(\d{5,}:[A-Za-z0-9_-]{20,})/);return r?r[1]:n}const Ks=({off:a})=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 3l18 18"}),e.jsx("path",{d:"M10.6 10.6a3 3 0 004.2 4.2"}),e.jsx("path",{d:"M9.9 4.2A10 10 0 0112 5c6.5 0 10 7 10 7a18 18 0 01-2.4 3.3M6.1 6.1A18 18 0 002 12s3.5 7 10 7a10 10 0 003.3-.5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),Js=[{label:"1 นาที",value:1},{label:"5 นาที",value:5},{label:"10 นาที",value:10},{label:"15 นาที",value:15},{label:"30 นาที",value:30},{label:"1 ชั่วโมง",value:60},{label:"2 ชั่วโมง",value:120},{label:"4 ชั่วโมง",value:240},{label:"1 วัน",value:1440},{label:"1 สัปดาห์",value:10080},{label:"1 เดือน",value:43200}],hi=[{label:"กรุงเทพ (GMT+7)",value:"Asia/Bangkok"},{label:"สิงคโปร์ / ฮ่องกง (GMT+8)",value:"Asia/Singapore"},{label:"โตเกียว (GMT+9)",value:"Asia/Tokyo"},{label:"ดูไบ (GMT+4)",value:"Asia/Dubai"},{label:"ลอนดอน (GMT+0/1)",value:"Europe/London"},{label:"ยุโรปกลาง (GMT+1/2)",value:"Europe/Paris"},{label:"นิวยอร์ก (GMT-5/4)",value:"America/New_York"},{label:"ลอสแอนเจลิส (GMT-8/7)",value:"America/Los_Angeles"},{label:"UTC",value:"UTC"}],q="rounded-2xl border border-white/[0.06] bg-white/[0.02] backdrop-blur p-5",$e="text-xs font-medium text-slate-400",oe="w-full rounded-xl border border-white/10 bg-slate-950/50 px-3.5 py-2.5 text-sm text-slate-100 outline-none transition focus:border-cyan-500/70 focus:ring-2 focus:ring-cyan-500/20";function ui({values:a,color:n="#22d3ee"}){if(a.length<2)return e.jsx("div",{className:"h-8"});const r=120,x=32,o=Math.min(...a),d=Math.max(...a),u=d-o||1,f=a.map((y,p)=>`${p/(a.length-1)*r},${x-(y-o)/u*(x-4)-2}`);return e.jsx("svg",{viewBox:`0 0 ${r} ${x}`,className:"mt-2 h-8 w-full",preserveAspectRatio:"none",children:e.jsx("polyline",{fill:"none",stroke:n,strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",points:f.join(" "),opacity:"0.9",pathLength:1,strokeDasharray:"1",strokeDashoffset:1,style:{animation:"tgDraw 1.1s ease .15s forwards"}})})}function bi({points:a,netPct:n,wins:r,losses:x}){const o=n>=0,d=o?"#34d399":"#f87171",u=Z=>new Date(Z+"T00:00:00").toLocaleDateString("th-TH",{day:"2-digit",month:"short"}),f=a.length,y=r+x>0?Math.round(r/(r+x)*100):null;if(f<2)return e.jsx("div",{className:"flex h-40 items-center justify-center rounded-xl border border-white/5 bg-black/20 px-6 text-center text-sm text-slate-500",children:f===0?"ยังไม่มีไม้ที่ปิดผล — รอสัญญาณเข้า WIN/LOSS ก่อน เส้นทุนจะเริ่มวาด":"มีข้อมูลวันเดียว — เส้นทุนจะแสดงเมื่อมีอย่างน้อย 2 วัน"});
2const p=760,w=220,C=8,c=8,N=20,v=10,M=p-C-c,F=w-N-v,B=a.map(Z=>Number(Z.cum)),T=Math.min(0,...B),R=Math.max(0,...B)-T||1,j=a.length,b=Z=>C+Z/(j-1)*M,D=Z=>N+(1-(Z-T)/R)*F,g=D(0),U=a.map((Z,Y)=>`${b(Y).toFixed(1)},${D(Number(Z.cum)).toFixed(1)}`).join(" "),O=`M ${b(0).toFixed(1)},${g.toFixed(1)} `+a.map((Z,Y)=>`L ${b(Y).toFixed(1)},${D(Number(Z.cum)).toFixed(1)}`).join(" ")+` L ${b(j-1).toFixed(1)},${g.toFixed(1)} Z`,$=a.reduce((Z,Y)=>Number(Y.cum)>Number(Z.cum)?Y:Z),L=a.reduce((Z,Y)=>Number(Y.cum)<Number(Z.cum)?Y:Z),W=a[j-1],ee=b(j-1),ce=D(Number(W.cum));return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-4xl font-bold tracking-tight",style:{color:d},children:[o?"+":"",n,"%"]}),e.jsx("span",{className:"text-xs text-slate-500",children:"กำไรสะสม (Net)"})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-slate-500",children:[f," วันเทรด · ",u(a[0].d)," → ",u(W.d)," · ",e.jsxs("span",{className:"text-emerald-400/90",children:[r," ชนะ"]})," / ",e.jsxs("span",{className:"text-rose-400/90",children:[x," แพ้"]}),y!=null?` · ${y}% winrate`:""]})]}),e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsxs("span",{className:"rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-2.5 py-1 text-emerald-300",children:["▲ พีค +",$.cum,"%"]}),e.jsxs("span",{className:"rounded-lg border border-rose-500/25 bg-rose-500/[0.06] px-2.5 py-1 text-rose-300",children:["▼ ต่ำสุด ",L.cum,"%"]})]})]}),e.jsxs("svg",{viewBox:`0 0 ${p} ${w}`,className:"block w-full",children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"eqGreen",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#34d399",stopOpacity:"0.38"}),e.jsx("stop",{offset:"100%",stopColor:"#34d399",stopOpacity:"0"})]}),e.jsxs("linearGradient",{id:"eqRed",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#f87171",stopOpacity:"0"}),e.jsx("stop",{offset:"100%",stopColor:"#f87171",stopOpacity:"0.38"})]}),e.jsx("clipPath",{id:"eqAbove",children:e.jsx("rect",{x:"0",y:"0",width:p,height:Math.max(0,g)})}),e.jsx("clipPath",{id:"eqBelow",children:e.jsx("rect",{x:"0",y:g,width:p,height:Math.max(0,w-g)})})]}),e.jsx("path",{d:O,fill:"url(#eqGreen)",clipPath:"url(#eqAbove)"}),e.jsx("path",{d:O,fill:"url(#eqRed)",clipPath:"url(#eqBelow)"}),e.jsx("line",{x1:C,y1:g,x2:p-c,y2:g,stroke:"#64748b",strokeWidth:"1",strokeDasharray:"4 4",opacity:"0.5"}),e.jsx("text",{x:C+2,y:Math.min(w-3,g+12),fill:"#64748b",fontSize:"9",children:"เท่าทุน 0%"}),e.jsx("polyline",{points:U,fill:"none",stroke:d,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),a.map((Z,Y)=>e.jsx("circle",{cx:b(Y),cy:D(Number(Z.cum)),r:"2.4",fill:Number(Z.net)>=0?"#34d399":"#f87171",opacity:"0.9"},Y)),e.jsx("circle",{cx:ee,cy:ce,r:"6",fill:d,opacity:"0.22",children:e.jsx("animate",{attributeName:"r",values:"6;9;6",dur:"2.4s",repeatCount:"indefinite"})}),e.jsx("circle",{cx:ee,cy:ce,r:"3.2",fill:d})]}),e.jsxs("div",{className:"mt-1.5 flex justify-between text-[10px] text-slate-500",children:[e.jsx("span",{children:u(a[0].d)}),f>4&&e.jsx("span",{children:u(a[Math.floor((j-1)/2)].d)}),e.jsx("span",{children:u(W.d)})]})]})}const on=["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."];function cn({text:a}){const n=o=>a.split(/(-?\d+(?:\.\d+)?)/).map(d=>/^-?\d+(?:\.\d+)?$/.test(d)?(parseFloat(d)*o).toFixed((d.split(".")[1]||"").length):d).join(""),[r,x]=i.useState(()=>n(0));return i.useEffect(()=>{let o=0;const d=performance.now(),u=f=>{const y=Math.min(1,(f-d)/900);x(n(1-Math.pow(1-y,3))),y<1&&(o=requestAnimationFrame(u))};return o=requestAnimationFrame(u),()=>cancelAnimationFrame(o)},[a]),e.jsx(e.Fragment,{children:r})}const fi="@keyframes tgReveal{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}@keyframes tgDraw{to{stroke-dashoffset:0}}@keyframes tgPop{from{opacity:0;transform:scale(.85)}to{opacity:1;transform:none}}@keyframes tgFade{from{opacity:0}
2to{opacity:1}}.tg-reveal{animation:tgReveal .5s ease both}",gi="@keyframes calIn{from{opacity:0;transform:scale(.86)}to{opacity:1;transform:scale(1)}}@keyframes calRingUp{0%{box-shadow:0 0 0 0 rgba(52,211,153,.5)}100%{box-shadow:0 0 0 8px rgba(52,211,153,0)}}@keyframes calRingDown{0%{box-shadow:0 0 0 0 rgba(248,113,113,.5)}100%{box-shadow:0 0 0 8px rgba(248,113,113,0)}}.cal-cell{transition:transform .14s ease}.cal-cell:hover{transform:translateY(-2px) scale(1.05);z-index:1}";function ji({equity:a}){const n=i.useMemo(()=>{const g=new Map;for(const U of a)g.set(U.d,{net:Number(U.net),w:Number(U.w)||0,l:Number(U.l)||0});return g},[a]),r=i.useMemo(()=>{const g=new Set;for(const U of a)g.add(U.d.slice(0,7));return Array.from(g).sort()},[a]),[x,o]=i.useState(r.length-1);if(i.useEffect(()=>{o(r.length-1)},[r.length]),!r.length)return null;const d=Math.min(Math.max(x,0),r.length-1),u=r[d],[f,y]=u.split("-").map(Number),p=new Date(f,y,0).getDate(),w=(new Date(f,y-1,1).getDay()+6)%7,C=g=>g?n.get(`${u}-${String(g).padStart(2,"0")}`):void 0;let c=0,N=0,v=0,M=0,F=.5,B=0;for(let g=1;g<=p;g++){const U=C(g);U&&(c+=U.net,N+=U.w,v+=U.l,M++,B=g,F=Math.max(F,Math.abs(U.net)))}const T=N+v>0?Math.round(N/(N+v)*100):null,J=[];for(let g=0;g<w;g++)J.push(null);for(let g=1;g<=p;g++)J.push(g);for(;J.length%7!==0;)J.push(null);const R=[];for(let g=0;g<J.length;g+=7)R.push(J.slice(g,g+7));const j=g=>g>=0?"+":"",b=g=>`rgba(${g>=0?"52,211,153":"248,113,113"},${(.14+.5*Math.min(1,Math.abs(g)/F)).toFixed(3)})`,D=["จ","อ","พ","พฤ","ศ","ส","อา"];return e.jsxs("div",{children:[e.jsx("style",{children:gi}),e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsxs("span",{className:"rounded-lg border px-2.5 py-1 font-semibold",style:{color:c>=0?"#34d399":"#f87171",borderColor:c>=0?"rgba(52,211,153,0.3)":"rgba(248,113,113,0.3)",background:c>=0?"rgba(52,211,153,0.06)":"rgba(248,113,113,0.06)"},children:[j(c),c.toFixed(2),"% เดือนนี้"]}),e.jsxs("span",{className:"text-slate-500",children:[M," วันเทรด · ",e.jsxs("span",{className:"text-emerald-400/90",children:[N," ชนะ"]})," / ",e.jsxs("span",{className:"text-rose-400/90",children:[v," แพ้"]}),T!=null?` · ${T}% winrate`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>o(d-1),disabled:d<=0,className:"rounded-lg border border-white/10 px-2.5 py-1 text-sm text-slate-300 transition hover:bg-white/5 disabled:cursor-not-allowed disabled:opacity-30",children:"‹"}),e.jsxs("span",{className:"min-w-[92px] text-center text-sm font-medium text-slate-200",children:[on[y-1]," ",f+543]}),e.jsx("button",{onClick:()=>o(d+1),disabled:d>=r.length-1,className:"rounded-lg border border-white/10 px-2.5 py-1 text-sm text-slate-300 transition hover:bg-white/5 disabled:cursor-not-allowed disabled:opacity-30",children:"›"})]})]}),e.jsxs("div",{className:"mb-1 grid grid-cols-8 gap-1 text-center text-[10px] font-medium text-slate-500",children:[D.map(g=>e.jsx("div",{children:g},g)),e.jsx("div",{className:"text-cyan-400/70",children:"รวม"})]}),e.jsx("div",{className:"space-y-1",children:R.map((g,U)=>{let O=0,$=0;for(const L of g){const W=C(L);W&&(O+=W.net,$++)}return e.jsxs("div",{className:"grid grid-cols-8 gap-1",children:[g.map((L,W)=>{if(L==null)return e.jsx("div",{},W);const ee=C(L),ce=Math.min((L-1)*10,320),Z=ee&&L===B?`, ${ee.net>=0?"calRingUp":"calRingDown"} 1.9s ease-out ${ce+450}ms infinite`:"";return e.jsxs("div",{style:{background:ee?b(ee.net):void 0,borderColor:ee?ee.net>=0?"rgba(52,211,153,0.4)":"rgba(248,113,113,0.4)":"rgba(255,255,255,0.06)",animation:`calIn .45s ease ${ce}ms both${Z}`},className:"cal-cell flex min-h-[54px] flex-col rounded-lg border p-1.5",children:[e.jsx("span",{className:"text-[10px] leading-none text-slate-300/70",children:L}),ee&&e.jsxs("span",{className:"mt-auto text-center",children:[e.jsxs("span",{className:"block text-[12px] font-bold leading-tight",style:{color:ee.net>=0?"#6ee7b7":"#fca5a5"},children:[j(ee.net),ee.net.toFixed(2),"%"]}),e.jsxs("span",{className:"block text-[9px] leading-tight text-white/50",children:[ee.
2w,"W · ",ee.l,"L"]})]})]},W)}),e.jsx("div",{className:"flex min-h-[54px] flex-col items-center justify-center rounded-lg border border-white/5 bg-white/[0.02] p-1",children:$>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[12px] font-bold leading-tight",style:{color:O>=0?"#34d399":"#f87171"},children:[j(O),O.toFixed(2),"%"]}),e.jsxs("span",{className:"mt-0.5 text-[9px] text-slate-500",children:[$," วัน"]})]}):e.jsx("span",{className:"text-[11px] text-slate-600",children:"—"})})]},U)})},u)]})}function Ni({data:a}){if(!a.length)return e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีข้อมูล"});const n=a.map(T=>({...T,net:Number(T.net)})),r=360,x=152,o=12,d=12,u=22,f=116,y=f-u,p=r-o-d,w=Math.max(0,...n.map(T=>T.net)),C=Math.max(0,...n.map(T=>-T.net)),c=w+C||1,N=u+w/c*y,v=n.length,M=p/v,F=Math.min(46,M*.52),B=T=>`${on[parseInt(T.slice(5,7),10)-1]||T.slice(5)} ${T.slice(2,4)}`;return e.jsxs("div",{children:[e.jsxs("svg",{viewBox:`0 0 ${r} ${x}`,className:"block w-full",children:[e.jsx("line",{x1:o,y1:N,x2:r-d,y2:N,stroke:"#64748b",strokeWidth:"1",strokeDasharray:"4 4",opacity:"0.5"}),e.jsx("text",{x:o,y:N-3,fill:"#64748b",fontSize:"8",children:"0%"}),n.map((T,J)=>{const R=o+M*J+M/2,j=Math.max(1.5,Math.abs(T.net)/c*y),b=T.net>=0,D=b?N-j:N,g=b?"#34d399":"#f87171",U=b?Math.max(9,D-4):Math.min(x-20,D+j+11);return e.jsxs("g",{children:[e.jsx("title",{children:`${B(T.m)} · ${T.net>0?"+":""}${T.net}% · ${T.total} สัญญาณ`}),e.jsx("rect",{x:R-F/2,y:D,width:F,height:j,rx:"3",fill:g,opacity:"0.85"}),e.jsxs("text",{x:R,y:U,textAnchor:"middle",fontSize:"9.5",fontWeight:"600",fill:g,children:[T.net>0?"+":"",T.net,"%"]}),e.jsx("text",{x:R,y:x-5,textAnchor:"middle",fontSize:"9",fill:"#94a3b8",children:B(T.m)})]},T.m)})]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-slate-500",children:"แท่งเขียว = เดือนกำไร · แท่งแดง = เดือนขาดทุน · เทียบเส้น 0% (เท่าทุน)"})]})}function yi({win:a,loss:n,expired:r,pending:x}){const o=a+n+r+x,d=[{v:a,c:"#34d399",label:"Win"},{v:n,c:"#f87171",label:"Loss"},{v:r,c:"#94a3b8",label:"Expired"},{v:x,c:"#22d3ee",label:"รอผล"}].filter(w=>w.v>0),u=56,f=2*Math.PI*u,y=a+n>0?Math.round(a/(a+n)*100):null;let p=0;return e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("svg",{viewBox:"0 0 150 150",className:"h-40 w-40",style:{animation:"tgPop .6s ease-out both"},children:[e.jsx("circle",{cx:"75",cy:"75",r:u,fill:"none",stroke:"#1b2740",strokeWidth:"14"}),o>0&&d.map((w,C)=>{const c=w.v/o,N=`${(c*f).toFixed(2)} ${(f-c*f).toFixed(2)}`,v=-p*f;return p+=c,e.jsx("circle",{cx:"75",cy:"75",r:u,fill:"none",stroke:w.c,strokeWidth:"14",strokeDasharray:N,strokeDashoffset:v.toFixed(2),transform:"rotate(-90 75 75)",style:{animation:"tgFade .5s ease both",animationDelay:`${250+C*140}ms`}},C)}),e.jsx("text",{x:"75",y:"70",textAnchor:"middle",className:"fill-white",fontSize:"26",fontWeight:"700",children:e.jsx(cn,{text:y==null?"—":`${y}%`})}),e.jsx("text",{x:"75",y:"90",textAnchor:"middle",fill:"#64748b",fontSize:"11",children:"Win Rate"})]}),e.jsx("div",{className:"mt-3 grid w-full grid-cols-2 gap-x-4 gap-y-1.5 text-xs",children:[{v:a,c:"#34d399",l:"Win"},{v:n,c:"#f87171",l:"Loss"},{v:r,c:"#94a3b8",l:"Expired"},{v:x,c:"#22d3ee",l:"รอผล"}].map(w=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-slate-400",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-sm",style:{background:w.c}}),w.l]}),e.jsx("span",{className:"font-medium text-slate-200",children:w.v})]},w.l))})]})}function as({label:a,frac:n,color:r,right:x,outOfFilter:o}){return e.jsxs("div",{className:`flex items-center gap-2 text-xs ${o?"opacity-55":""}`,children:[e.jsxs("span",{className:"flex w-24 shrink-0 items-center gap-1 text-slate-400",children:[e.jsx("span",{className:"truncate",children:a}),o&&e.jsx("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 py-0.5 text-[9px] font-medium text-amber-300/90",children:"ถอดแล้ว"})]}),e.jsx("div",{className:"h-2.5 flex-1 overflow-hidden rounded-full bg-white/5",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(2,Math.min(100,n
2*100))}%`,background:r}})}),e.jsx("span",{className:"w-16 shrink-0 text-right text-slate-300",children:x})]})}function wi({label:a,sub:n,net:r,win:x,loss:o,maxAbs:d,outOfFilter:u}){const f=r>=0,y=d>0?Math.min(1,Math.abs(r)/d):0,p=x+o>0?Math.round(x/(x+o)*100):null;return e.jsxs("div",{className:`flex items-center gap-2.5 text-xs ${u?"opacity-55":""}`,children:[e.jsxs("div",{className:"w-24 shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-1 font-medium text-slate-200",children:[e.jsx("span",{className:"truncate",children:a}),u&&e.jsx("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 py-0.5 text-[9px] font-medium text-amber-300/90",children:"ถอดแล้ว"})]}),n&&e.jsx("span",{className:"block truncate text-[10px] text-slate-500",children:n})]}),e.jsxs("div",{className:"relative h-2.5 flex-1",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-white/[0.04]"}),e.jsx("div",{className:"absolute left-1/2 top-0 h-full w-px bg-white/15"}),e.jsx("div",{className:"absolute top-0 h-full rounded-full",style:f?{left:"50%",width:`${y*50}%`,background:"#34d399"}:{right:"50%",width:`${y*50}%`,background:"#f87171"}})]}),e.jsxs("span",{className:"w-14 shrink-0 text-right font-semibold",style:{color:f?"#34d399":"#f87171"},children:[r>0?"+":"",r,"%"]}),e.jsxs("span",{className:"w-20 shrink-0 text-right text-slate-400",children:[x,"-",o,p!=null?` · ${p}%`:""]})]})}function vi({rank:a,label:n,sub:r,net:x,win:o,loss:d,closed:u,coverage:f,maxAbs:y}){const p=x>=0,w=y>0?Math.min(1,Math.abs(x)/y):0,C=u>0?Math.round(o/u*100):null,c=a===1?"border-amber-400/40 bg-amber-400/20 text-amber-300":a===2?"border-slate-300/30 bg-slate-300/15 text-slate-200":a===3?"border-orange-400/30 bg-orange-400/15 text-orange-300":"border-white/10 bg-white/5 text-slate-400";return e.jsxs("div",{className:"flex items-center gap-2.5 text-xs",children:[e.jsx("span",{className:`grid h-6 w-6 shrink-0 place-items-center rounded-lg border text-[11px] font-bold ${c}`,children:a}),e.jsxs("div",{className:"w-20 shrink-0 sm:w-24",children:[e.jsx("span",{className:"block truncate font-medium text-slate-200",children:n}),r&&e.jsx("span",{className:"block truncate text-[10px] text-slate-500",children:r})]}),e.jsxs("div",{className:"relative h-2.5 flex-1",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-white/[0.04]"}),e.jsx("div",{className:"absolute left-1/2 top-0 h-full w-px bg-white/15"}),e.jsx("div",{className:"absolute top-0 h-full rounded-full",style:p?{left:"50%",width:`${w*50}%`,background:"#34d399"}:{right:"50%",width:`${w*50}%`,background:"#f87171"}})]}),e.jsxs("span",{className:"w-14 shrink-0 text-right font-semibold",style:{color:p?"#34d399":"#f87171"},children:[x>0?"+":"",x,"%"]}),e.jsxs("span",{className:"hidden w-20 shrink-0 text-right text-slate-400 sm:block",children:[o,"-",d,C!=null?` · ${C}%`:""]}),e.jsxs("span",{className:"hidden w-24 shrink-0 justify-end gap-1.5 text-right text-[10px] text-slate-500 md:flex",children:[e.jsxs("span",{children:[u," ไม้"]}),e.jsxs("span",{className:f<50?"rounded bg-amber-500/15 px-1 py-0.5 text-amber-300/90":"",title:`ปิดผลแล้ว ${f}% ของสัญญาณคู่นี้ — ที่เหลือยังรอผล`,children:["ปิด ",f,"%"]})]})]})}const ln=a=>a?a>=60?`${(a/60).toFixed(1)} ชม.`:`${Math.round(a)} น.`:"—";function _i(a,n,r,x){if(a==="telegram")return e.jsxs("g",{children:[e.jsx("circle",{cx:n,cy:r,r:"11",fill:"#229ED9"}),e.jsxs("g",{fill:"none",stroke:"#ffffff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",transform:`translate(${n-7},${r-7}) scale(0.58)`,children:[e.jsx("path",{d:"M22 3 L11 14"}),e.jsx("path",{d:"M22 3 L15 21 L11 14 L3 10 Z"})]})]});let o;switch(a){case"ai":o=e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"5",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"5",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"12",x2:"19",y2:"8"}),e.jsx("line",{x1:"12",y1:"12",x2:"19",y2:"16"}),e.jsx("circle",{cx:"5",cy:"8",r:"2.1"}),e.jsx("circle",{cx:"5",cy:"16",r:"2.1"}),e.jsx("circle",{cx:"12",cy:"12",r:"2.4"}),e.jsx("circle",{cx:"19",cy:"8",r:"2.1"}),e.jsx("circle",{cx:"19",cy:"16",r:"2.1"})]});break;case"filter":o=e.jsx("path",{d:"M3 5 H21 L14 13 V20 L10 18 V13 Z"});break;case"gauge":o=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("circle",{cx:"12",cy:"12",r:"3.6"})]});break;case"risk":o=e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3 L19 6 V11 C19 16 16 19 12 21 C8 19 5 16 5 11 V6 Z"}),e.jsx("path",{d:"M9 12 l2 2 l4 -4"})]});break;case"clock":o=e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M12 8 V12 L15 14"})]});break;case"report":o=e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 20 H20"}),e.jsx("path",{d:"M7 20 V14"}),e.jsx("path",{d:"M12 20 V8"}),e.jsx("path",{d:"M17 20 V11"})]});break;default:o=e.jsx(e.Fragment,{})}return e.jsxs("g",{children:[e.jsx("circle",{cx:n,cy:r,r:"11",fill:x,fillOpacity:"0.16"}),e.jsx("g",{fill:"none",stroke:x,strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",transform:`translate(${n-7},${r-7}) scale(0.58)`,children:o})]})}function ki(a){const n=(r,x,o,d,u,f,y,p,w,C)=>e.jsxs("g",{className:"pf-node",onClick:()=>a.onNav(p),children:[e.jsx("rect",{className:"pf-card",x:r,y:x,width:o,height:d,rx:"13",fill:"#15120a",stroke:u,strokeOpacity:"0.45"}),e.jsx("rect",{x:r,y:x,width:"4",height:d,rx:"2",fill:u}),_i(w,r+26,x+d/2,u),e.jsx("text",{x:r+46,y:x+d/2-3,fill:"#f3ecd9",fontSize:"14",fontWeight:"600",children:f}),e.jsx("text",{x:r+46,y:x+d/2+15,fill:"#9a8c66",fontSize:"11",children:y}
2),C&&e.jsx("circle",{className:"pf-pulse",cx:r+o-16,cy:x+16,r:"3.6",fill:C})]});return e.jsxs("svg",{width:"100%",viewBox:"0 0 1000 600",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Signal pipeline",style:{display:"block"},children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"pf-orb",cx:"50%",cy:"45%",r:"60%",children:[e.jsx("stop",{offset:"0",stopColor:"#fff3cf"}),e.jsx("stop",{offset:"0.35",stopColor:"#f5c451"}),e.jsx("stop",{offset:"0.8",stopColor:"#b8860b"}),e.jsx("stop",{offset:"1",stopColor:"#6b4e08"})]}),e.jsxs("radialGradient",{id:"pf-halo",cx:"50%",cy:"50%",r:"50%",children:[e.jsx("stop",{offset:"0",stopColor:"#f5c451",stopOpacity:"0.3"}),e.jsx("stop",{offset:"1",stopColor:"#f5c451",stopOpacity:"0"})]}),e.jsxs("linearGradient",{id:"pf-wire",x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0",stopColor:"#8a6a14"}),e.jsx("stop",{offset:"1",stopColor:"#f5c451"})]}),e.jsxs("filter",{id:"pf-glow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:[e.jsx("feGaussianBlur",{stdDeviation:"2.6",result:"b"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"b"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),e.jsx("style",{children:`
3          .pf-node{cursor:pointer;transition:opacity .15s}
4          .pf-node:hover{opacity:.92}
5          .pf-node:hover .pf-card{stroke-opacity:.95}
6          .pf-pulse{animation:pfpulse 1.6s ease-in-out infinite;transform-box:fill-box;transform-origin:center}
7          @keyframes pfpulse{0%,100%{opacity:1}50%{opacity:.3}}
8          @keyframes pfhalo{0%,100%{opacity:.5}50%{opacity:.9}}
9        `})]}),e.jsx("rect",{x:"0",y:"0",width:"1000",height:"600",rx:"14",fill:"#0a0a0d"}),e.jsx("ellipse",{cx:"520",cy:"300",rx:"320",ry:"240",fill:"url(#pf-halo)"}),e.jsx("text",{x:"120",y:"74",fill:"#c79a2e",fontSize:"11",fontWeight:"700",letterSpacing:"2",children:"① แหล่งสัญญาณและกรอง"}),e.jsx("text",{x:"486",y:"74",fill:"#c79a2e",fontSize:"11",fontWeight:"700",letterSpacing:"2",children:"② สมอง AI"}),e.jsx("text",{x:"772",y:"74",fill:"#c79a2e",fontSize:"11",fontWeight:"700",letterSpacing:"2",children:"③ ส่งเข้ากลุ่ม"}),e.jsxs("g",{filter:"url(#pf-glow)",children:[e.jsx("path",{d:"M280 201 C 366 201, 400 296, 462 297",fill:"none",stroke:"url(#pf-wire)",strokeWidth:"2",opacity:"0.8"}),e.jsx("path",{d:"M280 301 C 372 301, 400 300, 462 300",fill:"none",stroke:"url(#pf-wire)",strokeWidth:"2",opacity:"0.8"}),e.jsx("path",{d:"M280 401 C 366 401, 402 304, 462 303",fill:"none",stroke:"url(#pf-wire)",strokeWidth:"2",opacity:"0.8"}),e.jsx("path",{d:"M578 292 C 648 286, 662 240, 700 240",fill:"none",stroke:"url(#pf-wire)",strokeWidth:"2",opacity:"0.8"}),e.jsx("path",{d:"M800 270 C 800 296, 800 306, 800 330",fill:"none",stroke:"url(#pf-wire)",strokeWidth:"2",opacity:"0.8"}),e.jsx("path",{d:"M524 360 C 518 412, 514 442, 512 470",fill:"none",stroke:a.reportStroke,strokeWidth:"2",opacity:"0.7"})]}),e.jsx("path",{d:"M700 360 C 560 430, 590 360, 512 352",fill:"none",stroke:"#a98a3a",strokeWidth:"1.6",strokeOpacity:"0.6",strokeDasharray:"2 8"}),e.jsx("circle",{r:"2.6",fill:"#ffe9a8",filter:"url(#pf-glow)",children:e.jsx("animateMotion",{dur:"2.5s",repeatCount:"indefinite",path:"M280 301 C 372 301, 400 300, 462 300"})}),e.jsx("circle",{r:"2.6",fill:"#ffe9a8",filter:"url(#pf-glow)",children:e.jsx("animateMotion",{dur:"2.7s",repeatCount:"indefinite",path:"M578 292 C 648 286, 662 240, 700 240"})}),e.jsx("text",{x:"372",y:"250",fill:"#caa94a",fontSize:"10",fontWeight:"600",children:"วิเคราะห์"}),e.jsx("text",{x:"628",y:"232",fill:"#caa94a",fontSize:"10",fontWeight:"600",children:"ตั้งเวลา"}),e.jsx("text",{x:"396",y:"430",fill:"#caa94a",fontSize:"10",fontWeight:"600",children:"ป้อนกลับ · ยิ่งส่งยิ่งแม่น"}),n(70,170,210,62,"#f5c451","Asset Filter",a.assetSub,"signals","filter"),n(70,270,210,62,"#f5c451","Confidence Gate",a.confLabel,"signals","gauge"),n(70,370,210,62,"#f5c451","Risk + Card",a.riskSub,"signals","risk"),e.jsxs("g",{className:"pf-node",onClick:()=>a.onNav("top"),children:[e.jsx("circle",{cx:"520",cy:"300",r:"92",fill:"url(#pf-halo)",style:{animation:"pfhalo 3s ease-in-out infinite"}}),e.jsx("circle",{cx:"520",cy:"300",r:"62",fill:"none",stroke:"#f5c451",strokeOpacity:"0.35",strokeDasharray:"3 6",children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 520 300",to:"360 520 300",dur:"26s",repeatCount:"indef
9inite"})}),e.jsx("circle",{cx:"520",cy:"300",r:"50",fill:"url(#pf-orb)",filter:"url(#pf-glow)"}),e.jsx("text",{x:"520",y:"296",textAnchor:"middle",fill:"#1a1304",fontSize:"17",fontWeight:"800",children:"Alpha AI"}),e.jsx("text",{x:"520",y:"314",textAnchor:"middle",fill:"#5a430a",fontSize:"9.5",fontWeight:"700",children:"Signal Engine · 24/7"})]}),n(700,210,200,60,"#f5c451","Schedule",a.schedSub,"signals","clock"),n(700,330,200,60,a.tgStroke,"Telegram Group",a.tgSub,"setup","telegram",a.tgDot),n(412,470,200,58,a.reportStroke,"Win/Loss Report",a.reportSub,"feed","report"),e.jsxs("g",{transform:"translate(360,556)",children:[e.jsx("rect",{x:"0",y:"0",width:"280",height:"30",rx:"15",fill:"#15120a",stroke:"#d4a017",strokeOpacity:"0.4"}),e.jsx("text",{x:"140",y:"20",textAnchor:"middle",fill:"#caa94a",fontSize:"11",children:"ทุกสัญญาณป้อนกลับเข้าสมอง — ยิ่งส่งยิ่งแม่น"})]})]})}function de({on:a,onChange:n}){return e.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>n(!a),className:`inline-flex h-6 w-11 shrink-0 items-center rounded-full px-0.5 transition-colors ${a?"bg-emerald-500":"bg-slate-600"}`,children:e.jsx("span",{className:`inline-block h-5 w-5 transform rounded-full bg-white shadow-sm transition-transform ${a?"translate-x-5":"translate-x-0"}`})})}function bo(){var _l,kl,Sl,Cl,$l,Ml,Al,Dl,Ll,Tl,Rl,Fl,El;nr("section:signal-control");const a=i.useMemo(()=>new URLSearchParams(window.location.search).get("token")||"",[]),[n,r]=i.useState(""),[x,o]=i.useState("init"),[d,u]=i.useState({balance:0,cost:50,expires_at:null,discordHasAccess:!1,discordExpiresAt:null,discordCost:50}),[f,y]=i.useState(!1),[p,w]=i.useState(null),C=!a,[c,N]=i.useState("overview"),[v,M]=i.useState(null),[F,B]=i.useState(!1),[T,J]=i.useState(!1),[R,j]=i.useState(null),[b,D]=i.useState(null),[g,U]=i.useState(null),[O,$]=i.useState(null),[L,W]=i.useState("30d"),[ee,ce]=i.useState(!1),[Z,Y]=i.useState(!1),[je,Be]=i.useState(""),[Ee,xe]=i.useState(null),[le,fe]=i.useState(!1),[Ae,De]=i.useState(!1),[ne,Le]=i.useState(null),[A,G]=i.useState(null),[te,K]=i.useState(!1),[re,ae]=i.useState(null),[ie,ge]=i.useState([]),[_e,ls]=i.useState("all"),[ns,Te]=i.useState(!1),[ct,Ne]=i.useState(null),[We,He]=i.useState({}),[wt,ze]=i.useState(!0),[tt,Pe]=i.useState(null),[h,dn]=i.useState(null),[z,xn]=i.useState(null),[Ve,mn]=i.useState([]),[pn,rs]=i.useState(1),[hn,vt]=i.useState(null),[_t,ea]=i.useState("chart"),[un,bn]=i.useState(""),[st,is]=i.useState(""),[os,fn]=i.useState(!1),[cs,gn]=i.useState(!1),[ds,jn]=i.useState(!1),[Ye,xs]=i.useState(""),[ke,ta]=i.useState(!1),[ms,sa]=i.useState(!0),[me,dt]=i.useState([]),[at,aa]=i.useState(""),[xt,la]=i.useState(70),[mt,na]=i.useState(1),[Xe,ps]=i.useState(5),[be,ra]=i.useState("Asia/Bangkok"),[kt,ia]=i.useState(!0),[oa,ca]=i.useState(!1),[hs,da]=i.useState(!0),[xa,ma]=i.useState(!1),[St,pa]=i.useState(!1),[lt,ha]=i.useState(9),[nt,ua]=i.useState(0),[Ct,ba]=i.useState(!0),[$t,fa]=i.useState(!1),[ga,Mt]=i.useState(null),[ja,Na]=i.useState(!0),[At,ya]=i.useState(""),[wa,va]=i.useState(!0),[us,_a]=i.useState(!1),[Dt,ka]=i.useState("fade"),[bs,Sa]=i.useState(["1h","4h"]),[fs,Ca]=i.useState(!1),[gs,$a]=i.useState(["1h","4h"]),[js,Ma]=i.useState(!1),[Ns,Aa]=i.useState(!1),[pt,ys]=i.useState(!1),[Lt,ws]=i.useState([]),[vs,_s]=i.useState("any"),[ks,Da]=i.useState(!1),[Ss,La]=i.useState(!1),[ht,Cs]=i.useState(""),[Tt,$s]=i.useState(120),[Ta,Ra]=i.useState([]),[Rt,Fa]=i.useState(""),[Ea,Pa]=i.useState(!0),[Ua,Ia]=i.useState(""),[Oa,Ba]=i.useState(85),[rt,ut]=i.useState([]),[Ft,Nn]=i.useState({}),[Ms,Wa]=i.useState(null),[Et,Ha]=i.useState("telegram"),[As,qa]=i.useState(!1),[Pt,bt]=i.useState(null),[Ds,Ze]=i.useState(!1),[Ga,pe]=i.useState(null),[Ut,It]=i.useState([]),[qe,za]=i.useState(!1),[Ot,Ls]=i.useState(!1),[V,yn]=i.useState(null),[Va,Ya]=i.useState(!1),[Xa,Bt]=i.useState(null),[k,wn]=i.useState(null),[it,Ts]=i.useState([]),[Wt,Za]=i.useState(""),[Rs,Ka]=i.useState(!1),[Fs,Ht]=i.useState(1),[Se,Ke]=i.useState(!1),[Ja,he]=i.useState(null),[Qa,el]=i.useState(""),[Es,tl]=i.useState(!1),[Q,vn]=i.useState(null),[qt,_n]=i.useState("all"),[Gt,kn]=i.useState("lab"),[zt,Ps]=i.useState(!1),[Ue,Sn]=i.useState(null),[Vt,Cn]=i.useState("30d"),[$n,Us]=i.useState(!1),[sl,al]=i.useState(null),Yt=i.useCallback(t=>{const s=t.channel;dn(s),xn(t.stats),mn(t.feed||[]),bn(s.customer_name||""),xs(s.chat_id||""),ta(s.enabled),sa(s.telegram_signals_enabled!==!1),dt(s.filter_assets||[]),la(s.min_confidence),na(Number(s.risk_per_trade_pct)),ps(s.send_interval_minutes),ra(s.timezone||"Asia/Bangkok"),ia(s.send_results),da(s.send_images),ma(s.send_calendar),va(s.send_mtf!==!1),pa(s.brief_enabled===!0),ha(s.brief_hour??9),ua(s.brief_minute??0),ba(s.week_pin!==!1),Na(s.news_guard!==!1),ya(s.custom_footer||""),ca(s.digest_split_by_category===!0),_a(s.swing_enabled===!0),ka(s.swing_mode==="breakout"||s.swing_mode==="both"?s.swing_mode:"fade"),Sa(Array.isArray(s.swing_tfs)&&s.swing_tfs.length?s.swing_tfs:["1h","4h"]),Ca(s.liqsweep_enabled===!0),$a(Array.isArray(s.liqsweep_tfs)&&s.liqsweep_tfs.length?s.liqsweep_tfs:["1h","4h"]),Ma(s.require_mtf),Aa(s.require_smc),ys(s.require_pa),ws(Array.isArray(s.pa_tfs)?s.pa_tfs:[]),_s(s.pa_pattern==="engulfing"?"engulfing":"any"),Da(s.auto_news),$s(s.news_interval_minutes||120),Ra(s.news_categories||[]),Cs(s.news_chat_id||""),La(!!s.news_chat_id),Fa(""),Pa(s.discord_enabled!==!1),Ia(s.discord_ping_role_id||""),Ba(s.discord_ping_min_confidence??85),ut((s.discord_routes||[]).map(m=>({id:m.id,label:m.label||"",kind:m.kind==="news"||m.kind==="footprint"?m.kind:"signals",groups:Array.isArray(m.groups)?m.groups:[],enabled:m.enabled!==!1,webhook:"",webhook_set:!!m.webhook_set,webhook_masked:m.webhook_masked||""})));const l={};for(const m of s.discord_routes||[])l[m.id]={last_ok_at:m.last_ok_at??null,fail_streak:m.fail_streak??0,last_fail_at:m.last_fail_at??null,last_error:m.last_error??null,dead:m.dead===!0||(m.fail_streak??0)>=3};Nn(l)},[]),Ie=i.useCallback(async t=>{ze(!0),Pe(null);const{data:s,error:l}=await X.rpc("tg_portal_get",{p_token:t});if(ze(!1),l){Pe(l.message);return}
9if(!s||s.error){Pe((s==null?void 0:s.error)==="not_found"?"ไม่พบลิงก์นี้ (token ไม่ถูกต้อง)":"token ไม่ถูกต้อง");return}Yt(s)},[Yt]);i.useEffect(()=>{(async()=>{if(a){r(a),o("ready"),Ie(a);const{data:s}=await X.rpc("tg_user_get");s!=null&&s.logged_in&&u({balance:s.balance??0,cost:s.cost??50,expires_at:s.expires_at??null,discordHasAccess:!!s.discord_has_access,discordExpiresAt:s.discord_expires_at??null,discordCost:s.discord_cost??50});return}const{data:t}=await X.rpc("tg_user_get");if(!t||!t.logged_in){o("need_login"),ze(!1);return}u({balance:t.balance??0,cost:t.cost??50,expires_at:t.expires_at??null,discordHasAccess:!!t.discord_has_access,discordExpiresAt:t.discord_expires_at??null,discordCost:t.discord_cost??50}),t.has_access&&t.manage_token?(r(t.manage_token),o("ready"),Ie(t.manage_token)):(o("paywall"),ze(!1))})()},[a,Ie]),i.useEffect(()=>{if(x!=="ready")return;const t=rr();if(!t)return;Be(t);let s=!0;if(ir().then(l=>{s&&(l==null?void 0:l.commission_rate)!=null&&xe(Number(l.commission_rate))}),!Ul.getItem("tg_partner_invite_seen"))return(async()=>{const l=await or(t);s&&(l&&l.directNewCustomers>0||setTimeout(()=>{s&&(Ul.setItem("tg_partner_invite_seen","1"),fe(!0))},1200))})(),()=>{s=!1}},[x]),i.useEffect(()=>{c!=="overview"||!n||X.rpc("tg_portal_analytics",{p_token:n}).then(({data:t})=>{t&&!t.error&&D(t)})},[c,n]);const Je=i.useCallback(t=>{wn({on:!!t.footprint_lab,vipActive:!!t.vip_active,hasRoom:!!t.has_footprint_room,hasTg:!!t.has_telegram,supported:t.supported_assets||[],mainChat:t.main_chat_id||null,tgOn:t.footprint_tg_enabled!==!1,dcOn:!!t.footprint_dc_enabled,paid:!!t.footprint_paid,unlimited:!!t.footprint_unlimited,expiresAt:t.footprint_expires_at||null,cost:Number(t.footprint_cost)||50}),Ts(Array.isArray(t.footprint_assets)?t.footprint_assets:[]),Za(t.footprint_chat_id||"")},[]);i.useEffect(()=>{c!=="footprint"&&c!=="overview"||!n||X.rpc("tg_portal_footprint",{p_token:n,p_action:"get"}).then(({data:t})=>{t!=null&&t.ok&&Je(t)})},[c,n,Je]);
9const ft=(t,s)=>(t==null?void 0:t.error)==="vip_expired"?"⛔ VIP หมดอายุ — ต่ออายุก่อนเปิดใช้ Add-On":(t==null?void 0:t.error)==="payment_required"?`⛔ ต้องเปิดใช้งานด้วย ${(t==null?void 0:t.cost)??50} เครดิตก่อน`:(t==null?void 0:t.error)==="insufficient"?`⛔ เครดิตไม่พอ (มี ${(t==null?void 0:t.balance)??0} · ต้องใช้ ${(t==null?void 0:t.cost)??50})`:(t==null?void 0:t.error)==="no_channel"?"⛔ ยังไม่มีช่อง Signal Control":(t==null?void 0:t.error)==="no_vip"?"⛔ ต้องเข้าสู่ระบบด้วยรหัส VIP ก่อน":`ไม่สำเร็จ: ${(s==null?void 0:s.message)||(t==null?void 0:t.error)||"ลองใหม่อีกครั้ง"}`,Mn=async()=>{if(!n||Se)return;Ke(!0),he(null);const{data:t,error:s}=await X.rpc("tg_user_unlock_footprint");if(s||!(t!=null&&t.ok)){Ke(!1),he(ft(t,s));return}const{data:l}=await X.rpc("tg_portal_footprint",{p_token:n,p_action:"get"});Ke(!1),l!=null&&l.ok&&Je(l),u(m=>({...m,balance:Number(t.balance)??m.balance})),he(`✅ เปิดใช้งานแล้ว — หัก ${t.cost} เครดิต · ใช้ได้ถึง ${new Date(t.footprint_expires_at).toLocaleDateString("th-TH",{day:"2-digit",month:"short",year:"numeric"})} · เครดิตคงเหลือ ${t.balance}`)},ll=async t=>{if(!n||Se)return;Ke(!0),he(null);const s=Qa.trim(),{data:l,error:m}=await X.rpc("tg_portal_footprint",{p_token:n,p_action:t?"on":"off",p_webhook:t&&s?s:null,p_assets:null,p_chat_id:null});if(Ke(!1),m||!(l!=null&&l.ok)){he(ft(l,m));return}Je(l),he(t?"✅ เปิดรับแล้ว — สัญญาณ Footprint + สรุปผลรายวันจะเริ่มเข้าห้องของคุณ":"ปิดการรับสัญญาณ Footprint แล้ว"),t&&s&&(el(""),Ie(n))},An=async()=>{var l;if(!n||Es)return;tl(!0),he(null);const{data:t,error:s}=await X.rpc("tg_portal_footprint",{p_token:n,p_action:"assets",p_webhook:null,p_assets:it,p_chat_id:null});if(tl(!1),s||!(t!=null&&t.ok)){he(ft(t,s));return}Je(t),he((l=t.footprint_assets)!=null&&l.length?`✅ บันทึกแล้ว — รับ ${t.footprint_assets.length} คู่`:"✅ บันทึกแล้ว — รับทุกคู่ที่รองรับ")},Dn=async()=>{if(!n||Rs)return;Ka(!0),he(null);const{data:t,error:s}=await X.rpc("tg_portal_footprint",{p_token:n,p_action:"chat",p_webhook:null,p_assets:null,p_chat_id:Wt.trim(),p_tg_enabled:null,p_dc_enabled:null});if(Ka(!1),s||!(t!=null&&t.ok)){he(ft(t,s));return}Je(t),he(t.footprint_chat_id?"✅ บันทึกแล้ว — Footprint จะเข้ากลุ่มแยกนี้":"✅ ล้างแล้ว — Footprint จะเข้ากลุ่มสัญญาณหลัก")},nl=async(t,s)=>{if(!n||Se)return;Ke(!0),he(null);const{data:l,error:m}=await X.rpc("tg_portal_footprint",{p_token:n,p_action:"targets",p_webhook:null,p_assets:null,p_chat_id:null,p_tg_enabled:t==="tg"?s:null,p_dc_enabled:t==="dc"?s:null});if(Ke(!1),m||!(l!=null&&l.ok)){he(ft(l,m));return}Je(l);const E=t==="tg"?"Telegram":"Discord";he(s?`✅ เปิดส่งเข้า ${E} แล้ว`:`⏸ หยุดส่งเข้า ${E} แล้ว (ตั้งค่าอื่นยังอยู่ครบ)`)},Ln=t=>Ts(s=>s.includes(t)?s.filter(l=>l!==t):[...s,t]),Is=(t,s)=>(t==null?void 0:t.error)==="vip_expired"?"⛔ VIP หมดอายุ — ต่ออายุก่อนเปิดใช้ Add-On":(t==null?void 0:t.error)==="payment_required"?`⛔ ต้องปลดล็อกด้วย ${(t==null?void 0:t.cost)??50} เครดิตก่อน`:(t==null?void 0:t.error)==="insufficient"?`⛔ เครดิตไม่พอ (มี ${(t==null?void 0:t.balance)??0} · ต้องใช้ ${(t==null?void 0:t.cost)??50})`:(t==null?void 0:t.error)==="no_channel"?"⛔ ยังไม่มีช่อง Signal Control":(t==null?void 0:t.error)==="no_vip"?"⛔ ต้องเข้าสู่ระบบด้วยรหัส VIP ก่อน":(t==null?void 0:t.error)==="bad_course"?"⛔ ไม่พบคอร์สที่เลือก":`ไม่สำเร็จ: ${(s==null?void 0:s.message)||(t==null?void 0:t.error)||"ลองใหม่อีกครั้ง"}`,Xt=i.useCallback(async t=>{const{data:s}=await X.rpc("tg_portal_academy",{p_token:t,p_action:"get"});s!=null&&s.ok&&M(s)},[]);i.useEffect(()=>{c!=="academy"||!n||Xt(n)},[c,n,Xt]);const Tn=async()=>
9{if(!n||F)return;B(!0),j(null);const{data:t,error:s}=await X.rpc("tg_user_unlock_academy");if(s||!(t!=null&&t.ok)){B(!1),j(Is(t,s));return}await Xt(n),B(!1),u(l=>({...l,balance:Number(t.balance)??l.balance})),j(`✅ ปลดล็อกแล้ว — หัก ${t.cost} เครดิต · ใช้ได้ถึง ${new Date(t.academy_expires_at).toLocaleDateString("th-TH",{day:"2-digit",month:"short",year:"numeric"})} · คงเหลือ ${t.balance}`)},Rn=async t=>{if(!n||F)return;B(!0),j(null);const{data:s,error:l}=await X.rpc("tg_portal_academy",{p_token:n,p_action:t?"on":"off"});if(B(!1),l||!(s!=null&&s.ok)){j(Is(s,l));return}M(s),j(t?"✅ เปิด drip แล้ว — บทเรียนจะทยอยเข้ากลุ่มของคุณอัตโนมัติ":"ปิด drip แล้ว (ตั้งค่าอื่นยังอยู่ครบ)")},rl=async t=>{if(!n)return;j(null);const{data:s,error:l}=await X.rpc("tg_portal_academy",{p_token:n,p_action:"save",p_course:t.course??null,p_interval_hours:t.interval??null});if(l||!(s!=null&&s.ok)){j(Is(s,l));return}M(s),j("✅ บันทึกแล้ว")},Fn=async()=>{if(!(!n||T)){J(!0),j(null);try{const l=await(await fetch("https://abqqlurckfumqjjkihef.supabase.co/functions/v1/academy-drip",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({token:n})})).json(),m=Array.isArray(l==null?void 0:l.results)?l.results[0]:null;m!=null&&m.sent&&(m.sent.tg||m.sent.dc)?(j("✅ ส่งบทเรียนเข้ากลุ่มแล้ว"),Xt(n)):m!=null&&m.skipped?j(`ยังส่งไม่ได้: ${m.skipped==="unpaid"?"ยังไม่ได้ปลดล็อก":m.skipped==="no_course"?"ยังไม่ได้เลือกคอร์ส":m.skipped==="no_lessons"?"คอร์สยังไม่มีบท":m.skipped}`):j("ส่งไม่สำเร็จ — ตรวจว่าตั้งค่าบอท/กลุ่มแล้ว")}catch{j("ส่งไม่สำเร็จ ลองใหม่อีกครั้ง")}J(!1)}};i.useEffect(()=>{Ht(1)},[qt,Gt]),i.useEffect(()=>{c!=="footprint"||!n||(Ps(!0),X.rpc("tg_portal_footprint_stats",{p_token:n,p_range:qt,p_scope:Gt,p_page:Fs,p_page_size:10}).then(({data:t})=>{t&&!t.error&&vn(t)}).then(()=>Ps(!1),()=>Ps(!1)))},[c,n,qt,Gt,Fs]),i.useEffect(()=>{c!=="footprint"||!n||(Us(!0),X.rpc("footprint_lab_leaderboard",{p_range:Vt,p_token:n}).then(({data:t})=>{t&&!t.error&&Sn(t)}).then(()=>Us(!1),()=>Us(!1)))},[c,n,Vt]),i.useEffect(()=>{c!=="leaderboard"||!n||(ce(!0),X.rpc("signal_control_leaderboard",{p_token:n,p_range:L}).then(({data:t})=>{t&&!t.error&&U(t)}).finally(()=>ce(!1)))},[c,n,L]),i.useEffect(()=>{c!=="leaderboard"||!n||(Y(!0),X.rpc("signal_control_user_leaderboard",{p_range:L,p_token:n}).then(({data:t})=>{t&&!t.error&&$(t)}).finally(()=>Y(!1)))},[c,n,L]);const Zt=i.useCallback(async t=>{const{data:s}=await X.rpc("tg_portal_health",{p_token:t});s&&!s.error&&yn(s)},[]);i.useEffect(()=>{c!=="overview"||!n||Zt(n)},[c,n,Zt]);async function En(){var l;Ya(!0),Bt(null);const{data:t,error:s}=await X.functions.invoke("telegram-broadcast",{body:{action:"flush",manage_token:n}});if(Ya(!1),s){Bt("❌ ล้างไม่สำเร็จ: "+s.message);return}Wa(Array.isArray((l=t==null?void 0:t.discord)==null?void 0:l.rooms)?t.discord.rooms:null),Bt(t!=null&&t.ok?`✅ ล้างท่อแล้ว — บอท @${(t==null?void 0:t.bot_username)??"?"} พร้อมส่ง สัญญาณรอบถัดไปจะถูกส่งทันที`:"⚠️ ล้างแล้วแต่ยังมีปัญหา: "+((t==null?void 0:t.error)||"ตรวจ token/กลุ่มของบอท")),await Promise.all([Zt(n),Ie(n)]),setTimeout(()=>Bt(null),6e3),setTimeout(()=>Wa(null),6e4)}i.useEffect(()=>{if(c!=="news")return;let t=!0;return Te(!0),mr(_e).then(s=>{t&&(ge(s||[]),Te(!1))}).catch(()=>{t&&Te(!1)}),()=>{t=!1}},[c,_e]);async function Pn(t){Ne(t.id);const{data:s,error:l}=await X.functions.invoke("telegram-broadcast",{body:{action:"news",manage_token:n,news:{headline:t.headline,summary:t.summary,source:t.source,url:t.url,image:t.image,sentiment:t.sentiment}}});Ne(null),He(m=>({...m,[t.id]:l||!(s!=null&&s.ok)?"err":"ok"}))}async function Un(){y(!0),Pe(null);const{data:t,error:s}=await X.rpc("tg_user_subscribe");if(y(!1),s){Pe(s.message);return}if(!(t!=null&&t.ok)){Pe((t==null?void 0:t.error)==="insufficient"?"เครดิตไม่พอ (ต้องมีอย่างน้อย 50) — เติมเครดิตก่อน":(t==null?void 0:t.error)==="no_vip"?"ต้องเข้าสู่ระบบ VIP ก่อน":"สมัครไม่สำเร็จ");return}r(t.manage_token),o("ready"),Ie(t.manage_token)}async function In(){y(!0),w(null),Pe(null);const{data:t,error:s}=await X.rpc("tg_user_subscribe");if(y(!1),s){w("ต่ออายุไม่สำเร็จ: "+s.message);return}if(!(t!=null&&t.ok)){w((t==null?void 0:t.error)==="insufficient"?"เครดิตไม่พอ (ต้องมีอย่างน้อย 50)":(t==null?void 0:t.error)==="no_vip"?"ต้องเข้าสู่ระบบ VIP ก่อน":"ต่ออายุไม่สำเร็จ");return}u(l=>({...l,balance:t.balance??l.balance,expires_at:t.expires_at??l.expires_at})),w("✓ ต่ออายุอีก 30 วันแล้ว"),setTimeout(()=>w(null),3500),Ie(t.manage_token||n)}async function il(){qa(!0),bt(null);const{data:t,error:s}=await X.rpc("tg_user_unlock_discord");if(qa(!1),s){bt("ปลดล็อคไม่สำเร็จ: "+s.message);return}if(!(t!=null&&t.ok)){bt((t==null?void 0:t.error)==="insufficient"?"เครดิตไม่พอ (ต้องมีอย่างน้อย 50)":(t==null?void 0:t.error)==="no_channel"?"ต้องสมัคร Signal Control (แพ็กฐาน) ก่อน":(t==null?void 0:t.error)==="no_vip"?"ต้องเข้าสู่ระบบ VIP ก่อน":"ปลดล็อคไม่สำเร็จ");return}u(l=>({...l,balance:t.balance??l.balance,discordHasAccess:!0,discordExpiresAt:t.discord_expires_at??l.discordExpiresAt})),bt("✓ ปลดล็อค Discord แล้ว (30 วัน) — ใส่ Webhook URL ได้เลย"),setTimeout(()=>bt(null),4e3),Ie(n)}async function On(){var E,_;Ze(!0),pe(null),It([]);const{data:t,error:s}=await X.functions.invoke("telegram-broadcast",{body:{action:"bot_probe",manage_token:n}});if(Ze(!1),s||!(t!=null&&t.ok)){pe((t==null?void 0:t.error)==="no_bot_token"?"❌ ยังไม่มี Bot Token ที่บันทึกไว้ — วาง token แล้วกดทดสอบอีกครั้ง":`❌ ${(t==null?void 0:t.error)||(s==null?void 0:s.message)||"ทดสอบไม่สำเร็จ"}`);return}It(t.chats||[]);const l=t.chat_check&&!t.chat_check.ok,m=((E=t.chat_check)==null?void 0:E.ok)&&!["group","supergroup","channel"].includes(String(t.chat_check.type));pe(`✅ บอท @${t.username} ใช้งานได้`+((_=t.chats)!=null&&_.length?` — เจอ ${t.chats.length} กลุ่ม กดเลือกเพื่อใส่ chat_id`:" — ยังไม่เà¸
9ˆà¸­à¸à¸¥à¸¸à¹ˆà¸¡ (เพิ่มบอทเข้ากลุ่มเป็น admin แล้วพิมพ์ในกลุ่ม 1 ครั้ง แล้วกดทดสอบใหม่)")+(m?` · ⚠️ chat_id ที่บันทึกไว้เป็น "${t.chat_check.type}" ไม่ใช่กลุ่ม — สัญญาณจะไม่ถูกส่ง`:"")+(l?` · ⚠️ chat_id ที่บันทึกไว้ใช้ไม่ได้: ${t.chat_check.error}`:""))}async function Bn(){const t=an(st);if(t&&t!==st&&is(t),!t){if(h!=null&&h.has_bot){await On();return}pe("กรุณาวาง Bot Token ก่อนกดทดสอบ");return}if(!/^\d{5,}:[A-Za-z0-9_-]{20,}$/.test(t)){pe("❌ รูปแบบ Bot Token ไม่ถูกต้อง — วางเฉพาะ token เช่น 123456789:AAExampleTokenDoNotUse...");return}Ze(!0),pe(null),It([]);try{const s=await fetch(`https://api.telegram.org/bot${t}/getMe`).then(_=>_.json());if(!s.ok){pe("❌ Bot Token ไม่ถูกต้อง"),Ze(!1);return}const l=await fetch(`https://api.telegram.org/bot${t}/getUpdates`).then(_=>_.json()),m=new Map;for(const _ of l.result||[]){const P=(_.message||_.channel_post||_.my_chat_member||{}).chat;(P==null?void 0:P.id)!=null&&(P.type==="group"||P.type==="supergroup"||P.type==="channel")&&m.set(String(P.id),P.title||P.username||String(P.id))}const E=[...m.entries()].map(([_,I])=>({id:_,title:I}));It(E),pe(`✅ บอท @${s.result.username} ใช้งานได้`+(E.length?` — เจอ ${E.length} กลุ่ม กดเลือกเพื่อใส่ chat_id`:" — ยังไม่เจอกลุ่ม (เพิ่มบอทเข้ากลุ่มเป็น admin แล้วพิมพ์ในกลุ่ม 1 ครั้ง แล้วกดทดสอบใหม่)"))}catch{pe("❌ เชื่อมต่อ Telegram ไม่ได้ — กรอก chat_id เองได้")}Ze(!1)}async function Wn(){var E,_;const t=!!(h!=null&&h.chat_id&&String(h.chat_id).trim()),s=!!(h!=null&&h.has_discord)&&(h==null?void 0:h.discord_enabled)!==!1;if(!t&&!s){pe('❌ ยังไม่มีช่องทางที่บันทึกไว้ — ตั้งค่า Telegram (chat_id) หรือ Discord (webhook) แล้วกด "บันทึก" ก่อน');return}if(Ye.trim()&&Ye.trim()!==((h==null?void 0:h.chat_id)||"")){pe('⚠️ chat_id ยังไม่ถูกบันทึก — กด "บันทึก" ก่อน แล้วค่อยส่งการ์ดทดสอบ');return}Ze(!0),pe(null);const{data:l,error:m}=await X.functions.invoke("telegram-broadcast",{body:{action:"test",manage_token:n}});if(Ze(!1),m){pe("❌ ส่งไม่สำเร็จ: "+m.message);return}if(l!=null&&l.ok){const I=[((E=l==null?void 0:l.telegram)==null?void 0:E.ok)&&"Telegram",((_=l==null?void 0:l.discord)==null?void 0:_.ok)&&"Discord"].filter(Boolean).join(" + ");pe(`✅ ส่งการ์ดทดสอบแล้ว — เช็คใน ${I||"ช่องทางที่ตั้งค่า"}`)}else{const I=[l==null?void 0:l.error,(l==null?void 0:l.telegram)&&!l.telegram.ok&&`TG: ${l.telegram.description||"fail"}`,(l==null?void 0:l.discord)&&!l.discord.ok&&`Discord: ${l.discord.error||"fail"}`].filter(Boolean).join(" · ");pe("❌ ส่งไม่สำเร็จ: "+(I||"unknown"))}}const ol=i.useMemo(()=>{var m,E;let t=0,s=0;try{const _=new Intl.DateTimeFormat("en-US",{timeZone:be||"Asia/Bangkok",hour:"2-digit",minute:"2-digit",hour12:!1}).formatToParts(new Date);t=Number(((m=_.find(I=>I.type==="hour"))==null?void 0:m.value)??0)%24,s=Number(((E=_.find(I=>I.type==="minute"))==null?void 0:E.value)??0)}catch{}const l=`${String(lt).padStart(2,"0")}:${String(nt).padStart(2,"0")} น.`;return t*60+s<lt*60+nt?`วันนี้ ${l}`:`พรุ่งนี้ ${l}`},[be,lt,nt]),Hn=!!h&&(St!==(h.brief_enabled===!0)||lt!==(h.brief_hour??9)||nt!==(h.brief_minute??0)||Ct!==(h.week_pin!==!1));async function cl(t="day"){fa(!0),Mt(null);const{data:s,error:l}=await X.functions.invoke("telegram-broadcast",{body:{action:"brief_test",manage_token:n,kind:t}});if(fa(!1),l){Mt("❌ "+l.message);return}if(s!=null&&s.ok){const m=(s.telegram||[]).some(_=>_==="pinned"),E=(s.telegram||[]).find(_=>String(_).startsWith("pin failed"));Mt(`✅ ส่งแล้ว ${s.sent} ที่ · ข่าว ${s.events} รายการ`+(t==="week"?m?" · ปักหมุดแล้ว":E?` · ปักหมุดไม่ได้ (${E.replace("pin failed: ","")})`:"":""))}else{const m=[s==null?void 0:s.error,...(s==null?void 0:s.telegram)||[],...(s==null?void 0:s.discord)||[]].filter(
9Boolean).join(" · ");Mt("❌ ส่งไม่สำเร็จ: "+(m||"unknown"))}}async function Kt(){za(!0),Ls(!1),Pe(null);const t={customer_name:un,chat_id:Ye.trim(),enabled:ke,telegram_signals_enabled:ms,filter_assets:me,min_confidence:xt,risk_per_trade_pct:mt,send_interval_minutes:Math.max(1,Math.round(Xe)),timezone:be,send_results:kt,send_images:hs,send_calendar:xa,send_mtf:wa,brief_enabled:St,brief_hour:lt,brief_minute:nt,week_pin:Ct,news_guard:ja,custom_footer:At.trim(),digest_split_by_category:oa,swing_enabled:us,swing_mode:Dt,swing_tfs:bs,liqsweep_enabled:fs,liqsweep_tfs:gs,require_mtf:js,require_smc:Ns,require_pa:pt,pa_tfs:Lt,pa_pattern:vs,auto_news:ks,news_interval_minutes:Math.max(5,Math.round(Tt)),news_categories:Ta,news_chat_id:Ss?ht.trim():"",discord_enabled:Ea,discord_ping_role_id:Ua.trim(),discord_ping_min_confidence:Math.min(95,Math.max(50,Math.round(Oa)))};st.trim()&&(t.bot_token=an(st)),Rt.trim()&&(t.discord_webhook_url=Rt.trim()),t.discord_routes=rt.filter(m=>m.label.trim()||m.webhook.trim()||m.webhook_set).map(m=>({id:m.id,label:m.label.trim(),kind:m.kind,groups:m.groups,enabled:m.enabled,webhook:m.webhook.trim()}));const{data:s,error:l}=await X.rpc("tg_portal_save",{p_token:n,p_patch:t});if(za(!1),l||s!=null&&s.error){Pe((l==null?void 0:l.message)||(s==null?void 0:s.error));return}Yt(s),is(""),Ls(!0),setTimeout(()=>Ls(!1),2500)}async function qn(t){K(!0),ae(null);const{data:s,error:l}=await X.rpc("signal_control_copy_preset",{p_token:n,p_source:t.pid});K(!1);const m=(l==null?void 0:l.message)||(s==null?void 0:s.error);if(m){ae("❌ "+({same_channel:"นี่คือสูตรของคุณเองอยู่แล้ว",source_not_found:"ไม่พบสูตรของผู้ใช้คนนี้แล้ว (อาจปิดการส่งไป)",invalid_source:"อ้างอิงสูตรไม่ถูกต้อง",invali
9d_token:"ลิงก์จัดการหมดอายุ — โหลดหน้าใหม่",not_found:"ไม่พบช่องของคุณ"}[m]||m));return}Yt(s),Le(null),ae(`✅ ใช้สูตรของ ${t.name} แล้ว — บันทึกอัตโนมัติ ดูได้ที่แท็บ “ตั้งค่าบอท”`),setTimeout(()=>ae(null),6e3)}const Os=t=>{const s=t.toUpperCase().trim();s&&!me.includes(s)&&dt(l=>[...l,s]),aa("")},dl=t=>dt(s=>s.filter(l=>l!==t)),Gn=()=>ut(t=>[...t,{id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2),label:"",kind:"signals",groups:[],enabled:!0,webhook:"",webhook_set:!1,webhook_masked:""}]),zn=t=>ut(s=>s.filter(l=>l.id!==t)),Jt=(t,s)=>ut(l=>l.map(m=>m.id===t?{...m,...s}:m)),Vn=(t,s)=>ut(l=>l.map(m=>m.id!==t?m:{...m,groups:m.groups.includes(s)?m.groups.filter(E=>E!==s):[...m.groups,s]})),xl=i.useMemo(()=>{const t=at.toUpperCase().trim();return ii.filter(s=>!me.includes(s)&&(t===""||s.includes(t)||ve(s).toUpperCase().includes(t))).slice(0,8)},[at,me]),Qt=i.useMemo(()=>{const t=[...Ve].reverse(),s=[],l=[],m=[],E=[];let _=0,I=0,P=0,S=0;for(const ye of t){_++;const ue=(ye.outcome||"").toUpperCase();ue==="WIN"?I++:ue==="LOSS"&&P++,(ue==="WIN"||ue==="LOSS")&&(S+=Number(ye.profit_percent||0)),s.push(_),m.push(I-P),E.push(S),l.push(I+P?I/(I+P)*100:0)}return{sTotal:s,sWin:l,sWL:m,sNet:E}},[Ve]);if(x==="need_login")return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#070b16] px-6 text-center text-slate-300",children:e.jsxs("div",{className:"max-w-sm space-y-3",children:[e.jsx("div",{className:"mx-auto grid h-12 w-12 place-items-center rounded-2xl bg-cyan-500/15 text-2xl text-cyan-400 font-bold",children:"α"}),e.jsx("h1",{className:"text-xl font-bold text-white",children:"Signal Control"}),e.jsx("p",{className:"text-sm text-slate-400",children:"ต้องเข้าสู่ระบบด้วยรหัส VIP ก่อนจึงจะใช้งานได้"}),e.jsx("a",{href:"/",className:"inline-block rounded-xl bg-cyan-600 px-5 py-2.5 text-sm font-semibold text-white hover:bg-cyan-500",children:"ไปหน้าเข้าสู่ระบบ"})]})});if(x==="paywall"&&cr(dr()))return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#070b16] px-6",style:{backgroundImage:"radial-gradient(60rem 40rem at 80% -10%, rgba(34,211,238,0.06), transparent)"},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-white/[0.08] bg-white/[0.02] p-7 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 grid h-12 w-12 place-items-center rounded-2xl bg-cyan-500/15 text-cyan-400 font-bold text-2xl",children:"α"}),e.jsx("h1",{className:"text-xl font-bold text-white",children:"Signal Control เป็นสิทธิ์ของสมาชิก VIP"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"ส่งสัญญาณ AI แบบเต็ม (ราคาเข้า · SL · TP) เข้ากลุ่ม Telegram ของคุณเอง — บัญชีสมาชิกฟรียังใช้ส่วนนี้ไม่ได้"}),e.jsxs("div",{className:"my-5 rounded-xl bg-slate-950/50 px-4 py-4 text-left text-sm text-slate-300",children:[e.jsx("p",{className:"font-semibold text-white",children:"เส้นทางปลดล็อก"}),e.jsx("p",{className:"mt-1.5",children:"1. อัปเกรดเป็นสมาชิก VIP"}),e.jsx("p",{className:"mt-1",children:"2. ปลดล็อก Signal Control ด้วย 50 เครดิต / 30 วัน"})]}),e.jsx("a",{href:"/products",className:"block w-full rounded-xl bg-cyan-600 px-5 py-3 text-sm font-semibold text-white hover:bg-cyan-500",children:"ดูแพ็กเกจ VIP"}),e.jsx("button",{onClick:()=>{window.location.href="/"},className:"mt-4 text-sm text-slate-400 transition hover:text-cyan-300",children:"← กลับ Dashboard"})]})});if(x==="paywall")return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#070b16] px-6",style:{backgroundImage:"radial-gradient(60rem 40rem at 80% -10%, rgba(34,211,238,0.06), transparent)"},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-white/[0.08] bg-white/[0.02] p-7 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 grid h-12 w-12 place-items-center rounded-2xl bg-cyan-500/15 text-cyan-400 font-bold text-2xl",children:"α"}),e.jsx("h1",{className:"text-xl font-bold text-white",children:"ปลดล็อก Signal Control"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"ส่งสัญญาณ AI เข้ากลุ่ม Telegram ของคุณเอง — เลือกสินทรัพย์/ความถี่/ความเสี่ยงได้เต็มที่"}),e.jsxs("div",{className:"my-5 rounded-xl bg-slate-950/50 py-5",children:[e.jsxs("p",{className:"text-3xl font-bold text-cyan-300",children:["50 ",e.jsx("span",{className:"text-base font-normal text-slate-400",children:"credits / เดือน"})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"≈ 180 บาท ต่อ 30 วัน"})]}),e.jsxs("p",{className:"mb-4 text-sm text-slate-400",children:["เครดิตคงเหลือของคุณ: ",e.jsx("span",{className:`font-semibold ${d.balance>=d.cost?"text-emerald-400":"text-rose-400"}`,children:d.balance})]}),d.expires_at&&e.jsxs("p",{className:"mb-3 text-xs text-amber-400/80",children:["แพ็กเกจหมดอายุเมื่อ ",new Date(d.expires_at).toLocaleStr
9ing("th-TH",{day:"2-digit",month:"short",year:"2-digit"})," — ต่ออายุเพื่อใช้งานต่อ"]}),tt&&e.jsx("p",{className:"mb-3 text-sm text-rose-400",children:tt}),d.balance>=d.cost?e.jsx("button",{onClick:Un,disabled:f,className:"w-full rounded-xl bg-emerald-600 px-5 py-3 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:f?"กำลังดำเนินการ…":"จ่าย 50 credits เพื่อใช้งาน 30 วัน"}):e.jsx("a",{href:"/?buy=credits",className:"block w-full rounded-xl bg-cyan-600 px-5 py-3 text-sm font-semibold text-white hover:bg-cyan-500",children:"เติมเครดิต"}),e.jsx("p",{className:"mt-3 text-xs text-slate-600",children:"หักจากเครดิตในแอป · ใช้งานได้ทันที"}),e.jsx("button",{onClick:()=>{window.location.href="/"},className:"mt-4 text-sm text-slate-400 transition hover:text-cyan-300",children:"← กลับ Dashboard"})]})});if(wt)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#070b16] text-slate-400",children:"กำลังโหลด…"});if(tt&&!h)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#070b16] px-6 text-center text-rose-400",children:tt});const ml=z&&z.win+z.loss>0?Math.round(z.win/(z.win+z.loss)*100):null,pl=new Set(((h==null?void 0:h.filter_assets)||[]).map(t=>t.toUpperCase())),Bs=t=>pl.size>0&&!pl.has(String(t).toUpperCase()),Yn=(h==null?void 0:h.status)==="online"?"text-emerald-400":(h==null?void 0:h.status)==="error"?"text-rose-400":"text-slate-400",hl=Js.some(t=>t.value===Xe),Xn=h!=null&&h.last_sent_at?new Date(h.last_sent_at).toLocaleString("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be}):"—",Oe=h!=null&&h.access_expires_at?new Date(h.access_expires_at).getTime():null,Ws=!(h!=null&&h.owner_vip_code)&&Oe==null,ot=Oe!=null&&Oe<=Date.now(),Re=Oe!=null?Math.max(0,Math.ceil((Oe-Date.now())/864e5)):null,Hs=Oe!=null?new Date(Oe).toLocaleDateString("th-TH",{day:"2-digit",month:"short",year:"2-digit",timeZone:be}):null,qs=ot||Re!=null&&Re<=3?"rose":Re!=null&&Re<=7?"amber":"emerald",ul={rose:"border-rose-500/30 bg-rose-500/[0.07] text-rose-300",amber:"border-amber-500/30 bg-amber-500/[0.07] text-amber-300",emerald:"border-emerald-500/25 bg-emerald-500/[0.06] text-emerald-300"},bl=C&&!Ws,fl=Array.isArray(b==null?void 0:b.equity)?b.equity.map(t=>Number(t.cum)):[],Zn=[{k:"ส่งทั้งหมด",v:String((z==null?void 0:z.total)??0),s:Qt.sTotal,c:"#22d3ee"},{k:"Win Rate",v:ml==null?"—":`${ml}%`,s:Qt.sWin,c:"#34d399"},{k:"W / L",v:`${(z==null?void 0:z.win)??0} / ${(z==null?void 0:z.loss)??0}`,s:Qt.sWL,c:"#a78bfa"},{k:"Net %",v:z?`${z.net_pct>0?"+":""}${z.net_pct}%`:"—",s:fl.length>=2?fl:Qt.sNet,c:((z==null?void 0:z.net_pct)??0)>=0?"#34d399":"#f87171"}],Kn=t=>{N(t==="top"?"overview":t==="feed"?"history":t),window.scrollTo({top:0,behavior:"smooth"})},Gs=!!(h!=null&&h.has_bot&&Ye.trim()&&ke),zs=!!(h!=null&&h.has_bot&&Ye.trim()&&!ke),Jn={assetSub:me.length?`${me.length} สินทรัพย์`:"ทุกสินทรัพย์",confLabel:`≥ ${xt}%`,riskSub:`เสี่ยง ${mt}%${hs?" · การ์ดรูป":""}`,schedSub:((_l=Js.find(t=>t.value===Xe))==null?void 0:_l.label)||`${Xe} นาที`,tgStroke:Gs?"#34d399":zs?"#fbbf24":"#64748b",tgDot:Gs?"#34d399":zs?"#fbbf24":"#475569",tgSub:Gs?"ส่งเข้ากลุ่ม":zs?"พร้อม (ปิดอยู่)":"ยังไม่ตั้งค่า",reportStroke:kt?"#a78bfa":"#475569",reportSub:kt?"เปิดรายงาน":"ปิด",onNav:Kn},gl=[{id:"overview",label:"ภาพรวม"},{id:"setup",label:"ตั้งค่าบอท"},{id:"signals",label:"การส่งสัญญาณ"},{id:"footprint",label:"🧪 Footprint Lab"},{id:"news",label:"Alpha News"},{id:"history",label:"ประวัติ"},{id:"leaderboard",label:"อันดับ"},{id:"constellation",label:"Signal Constellation"}],jl={overview:["ภาพรวม","สรุปสถานะการส่งสัญญาณของคุณ"],setup:["ตั้งค่าบอท","เชื่อมต่อบอทและกลุ่ม Telegram"],signals:["การส่งสัญญาณ","เลือกสินทรัพย์ · ความถี่ 
9· ความเสี่ยง"],footprint:["Footprint Lab","Add-On · สัญญาณ order flow จาก tape จริง · อันดับกลุ่ม"],news:["Alpha News","ข่าวเรียลไทม์ — เลือกส่งเข้ากลุ่ม Telegram"],history:["ประวัติการส่ง","สัญญาณและผลล่าสุด"],leaderboard:["อันดับ","อันดับผู้ใช้ · อันดับคู่ทำกำไร"],constellation:["Signal Constellation","โลก 3D ของสัญญาณจริง — เลือกดูรายสินทรัพย์"],academy:["Academy","เสิร์ฟบทเรียนให้สมาชิก + ส่งเข้ากลุ่มอัตโนมัติ"]},Qn=[{id:"all",label:"ทั้งหมด"},{id:"crypto",label:"Crypto"},{id:"forex",label:"Forex"},{id:"stocks",label:"US Stocks"},{id:"thai",label:"หุ้นไทย"},{id:"commodities",label:"Commodities"}],Nl=[{v:30,l:"30 นาที"},{v:60,l:"1 ชั่วโมง"},{v:120,l:"2 ชั่วโมง"},{v:240,l:"4 ชั่วโมง"},{v:360,l:"6 ชั่วโมง"},{v:720,l:"12 ชั่วโมง"},{v:1440,l:"1 วัน"}],er=[{id:"crypto",label:"Crypto"},{id:"forex",label:"Forex"},{id:"commodities",label:"Commodities"},{id:"general",label:"ทั่วไป"}],yl=Nl.some(t=>t.v===Tt),wl=pt&&Lt.length===0&&me.length>0&&!me.some(t=>xi.has(t)),tr=(h==null?void 0:h.status)==="online"&&ke?"bg-emerald-400":(h==null?void 0:h.status)==="error"?"bg-rose-400":ke?"bg-amber-400":"bg-slate-500",vl=e.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:[e.jsx("button",{onClick:Kt,disabled:qe,className:"rounded-xl bg-emerald-600 px-6 py-2.5 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:qe?"กำลังบันทึก…":"บันทึกการตั้งค่า"}),Ot&&e.jsx("span",{className:"text-sm text-emerald-400",children:"✓ บันทึกแล้ว"}),tt&&e.jsx("span",{className:"text-sm text-rose-400",children:tt}),e.jsxs("span",{className:"ml-auto text-xs text-slate-500",children:["ส่งล่าสุด: ",Xn]})]}),sr=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>Ie(n),className:"shrink-0 rounded-xl border border-white/10 px-3.5 py-2 text-sm text-slate-300 hover:bg-white/5",children:"รีเฟรช"}),((h==null?void 0:h.has_bot)||(h==null?void 0:h.has_discord))&&e.jsx("button",{onClick:Wn,disabled:Ds,className:"shrink-0 rounded-xl border border-cyan-500/40 bg-cyan-500/10 px-3.5 py-2 text-sm text-cyan-300 hover:bg-cyan-500/20 disabled:opacity-50",children:"ส่งการ์ดทดสอบ"}),e.jsxs("label",{className:"flex shrink-0 cursor-pointer items-center gap-2 whitespace-nowrap rounded-xl border border-white/10 px-3.5 py-2 text-sm",children:[e.jsx("span",{className:ke?"text-emerald-400":"text-slate-400",children:ke?"เปิดส่ง":"ปิด"}),e.jsx(de,{on:ke,onChange:ta})]})]}),ar=bl&&e.jsx("button",{onClick:In,disabled:f,className:`shrink-0 rounded-lg px-3.5 py-1.5 text-xs font-semibold text-white disabled:opacity-50 ${ot||Re!=null&&Re<=7?"bg-emerald-600 hover:bg-emerald-500":"border border-white/15 bg-white/5 hover:bg-white/10"}`,children:f?"กำลังต่ออายุ…":`ต่ออายุ +30 วัน (${d.cost} เครดิต)`}),lr=Ws?e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl border border-white/[0.06] bg-white/[0.02] px-4 py-2.5 text-xs text-slate-400",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-400"})," ใช้งานได้ไม่จำกัด (ช่องของแอดมิน)"]}):Oe!=null?e.jsxs("div",{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-2xl border px-4 py-3 ${ul[qs]}`,children:[e.jsx("span",{className:"text-lg leading-none",children:ot?"⛔":qs==="amber"?"⏳":"🟢"}),e.jsxs("div",{className:"min-w-0",children:[ot?e.jsxs("p",{className:"text-sm font-semibold",children:["หมดอายุแล้ว — ระบบ",e.jsx("span",{className:"underline",children:"หยุดส่งสัญญาณ"}),"เข้ากลุ่ม Telegram"]}):e.jsxs("p",{className:"text-sm font-semibold",children:["อายุการใช้งานเหลือ ",Re," วัน"]}),e.jsx("p",{className:"text-xs opacity-80",children:ot?`หมดอายุเมื่อ ${Hs} · ต่ออายุด้วยเครดิตเพื่อส่งสัญญาณต่อ`:`หมดอายุ ${Hs}${Re!=null&&Re<=7?" · แนะนำให้ต่ออายุก่อนหมด":""}`})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[p&&e.jsx("span",{className:"text-xs font-medium text-emerald-300",children:p}),bl&&d.balance<d.cost?e.jsxs("a",{href:"/?buy=credits",className:"shrink-0 rounded-lg bg-cyan-600 px-3.5 py-1.5 text-xs font-semibold text-white hover:bg-cyan-500",children:["เติมเครดิต (",d.balance,")"]}):ar]})]}):null;return e.jsx("div",{className:"min-h-screen bg-[#070b16] text-slate-100",style:{backgroundImage:"radial-gradient(60rem 40rem at 90% -10%, rgba(34,211,238,0.06), transparent), radial-gradient(50rem 40rem at -10% 10%, rgba(16,185,129,0.05), transparent)"},children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1400px]",children:[e.jsxs("aside",{className:"sticky top-0 hidden h-screen w-60 shrink-0 flex-col border-r border-white/[0.06] bg-white/[0.02] p-4 md:flex",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3 px-1",children:[e.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-cyan-500/15 text-cyan-400 font-bold",children:"α"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold leading-tight",children:"Alpha AI"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Signal Control"})]})]}),e.jsx("nav",{className:"flex flex-col gap-1",children:gl.map(t=>e.jsxs("button",{onClick:()=>N(t.id),className:`flex items-center gap-2.5 rounded-xl px-3 py-2.5 text-sm transition ${c===t.id?"bg-cyan-500/15 font-medium text-cyan-300":"text-slate-400 hover:bg-white/5 hover:text-slate-200"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c===t.id?"bg-cyan-400":"bg-slate-600"}`}),t.label]},t.id))}),e.jsxs("div",{className:"mt-auto space-y-2 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-white/10 px-3 py-2",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${tr}`}),e.jsx("span",{className:`text-xs font-medium ${Yn}`,children:ke?h==null?void 0:h.status:"ปิดอยู่"})]}),!Ws&&Oe!=null&&e.jsxs("button",{onClick:()=>N("overview"),className:`w-full rounded-xl border px-3 py-2 text-left text-xs font-medium transition ${ul[qs]}`,children:[ot?"⛔ หมดอายุแล้ว":`⏳ เหลือ ${Re} วัน`,e.jsxs("span",{className:"block text-[10px] font-normal opacity-70",children:["หมดอายุ ",Hs]})]}),e.jsx("button",{onClick:()=>{window.location.href="/"},className:"w-full rounded-xl border border-white/10 px-3 py-2 text-left text-sm text-slate-400 transition hover:text-cyan-300",children:"← กลับ Dashboard"})]})]}),e.jsxs("main",{className:"min-w-0 flex-1 px-4 py-6 lg:px-8",children:[e.jsxs("div",{className:"mb-6 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"flex items-center gap-2.5 text-2xl font-bold tracking-tight",children:[c==="footprint"&&e.jsx(Ql,{size:38}),jl[c][0]]}),e.jsx("p",{className:"text-sm text-slate-400",children:jl[c][1]})]}),sr]}),e.jsx("div",{className:"mb-5 flex gap-1 overflow-x-auto rounded-xl border border-white/10 p-1 md:hidden",children:gl.map(t=>e.jsx("button",{onClick:()=>N(t.id),className:`shrink-0 whitespace-nowrap rounded-lg px-3 py-1.5 text-sm transition ${c===t.id?"bg-cyan-500/15 text-cyan-300":"text-slate-400"}`,children:t.label},t.id))}),c==="overview"&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("style",{children:fi}),e.jsx("div",{className:"tg-reveal",children:lr}),(()=>{var _,I;const t=((_=V==null?void 0:V.clog)==null?void 0:_.level)??(ke?"ok":"off"),s=t==="blocked"?{dot:"bg-rose-400",ring:"border-rose-500/40 bg-rose-500/5",txt:"text-rose-300",label:"🔴 อุดตัน"}
9:t==="warn"?{dot:"bg-amber-400",ring:"border-amber-500/40 bg-amber-500/5",txt:"text-amber-300",label:"🟡 มีการหน่วง"}:t==="off"?{dot:"bg-slate-500",ring:"border-slate-600/40 bg-white/5",txt:"text-slate-300",label:"⚪ ปิดการส่งอยู่"}:{dot:"bg-emerald-400",ring:"border-emerald-500/40 bg-emerald-500/5",txt:"text-emerald-300",label:"🟢 ปกติ"},l=P=>P?new Date(P).toLocaleString("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be}):"—",m=(V==null?void 0:V.deliveries)??{},E=P=>P==="sent"?{cls:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30",txt:"✅ ส่งแล้ว"}:P==="waiting"?{cls:"bg-amber-500/15 text-amber-300 border-amber-500/30",txt:"⏳ รอสัญญาณ"}:{cls:"bg-slate-600/20 text-slate-400 border-slate-500/30",txt:"🆕 ยังไม่มีสัญญาณ"};return e.jsxs("section",{className:`tg-reveal ${q} border ${s.ring}`,style:{animationDelay:"60ms"},children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${s.dot} ${t==="blocked"?"animate-pulse":""}`}),e.jsx("h2",{className:"text-base font-semibold",children:"🩺 Health Check · สุขภาพการส่งสัญญาณ"}),e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-xs font-medium ${s.ring} ${s.txt}`,children:s.label})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>n&&Zt(n),className:"rounded-lg border border-white/10 px-2.5 py-1.5 text-xs text-slate-300 hover:bg-white/5",children:"รีเฟรช"}),e.jsx("button",{onClick:En,disabled:Va,className:"rounded-lg bg-cyan-500/90 px-3 py-1.5 text-xs font-semibold text-slate-950 hover:bg-cyan-400 disabled:opacity-50",children:Va?"กำลังล้าง…":"🧹 ล้างท่ออุดตัน"})]})]}),e.jsx("p",{className:`mb-3 text-sm ${s.txt}`,children:((I=V==null?void 0:V.clog)==null?void 0:I.reason)??(ke?"กำลังโหลดสถานะ…":'การส่งถูกปิดอยู่ — เปิดสวิตช์ "เปิดส่ง" เพื่อเริ่ม')}),Xa&&e.jsx("p",{className:"mb-3 rounded-lg bg-black/30 px-3 py-2 text-xs text-slate-200",children:Xa}),Ms&&Ms.length>0&&e.jsxs("div",{className:"mb-3 rounded-lg bg-black/30 px-3 py-2 text-xs text-slate-200",children:[e.jsx("p",{className:"mb-1 text-[11px] text-slate-400",children:"ผลตรวจ Webhook รายห้อง (ตรวจสด ไม่มีข้อความเข้าห้อง)"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ms.map(P=>{const S=rt.find(ue=>`discord:${ue.id}`===P.platform),ye=(S==null?void 0:S.label)||(P.platform==="discord"?"Webhook เดี่ยว":P.platform.replace(/^discord:/,"").slice(0,8));return e.jsxs("span",{className:`rounded-md border px-2 py-0.5 ${P.ok?"border-emerald-500/30 bg-emerald-500/10 text-emerald-300":"border-rose-500/30 bg-rose-500/10 text-rose-300"}`,children:[P.ok?"✅":"❌"," ",ye,!P.ok&&` · ${ss(P.error)}`]},P.platform)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:"บอท"}),e.jsx("p",{className:`mt-0.5 text-sm font-semibold ${(V==null?void 0:V.status)==="online"?"text-emerald-300":(V==null?void 0:V.status)==="error"?"text-rose-300":"text-slate-300"}`,children:(V==null?void 0:V.status)??"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:"ส่งล่าสุด"}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold text-slate-200",children:l(V==null?void 0:V.last_sent_at)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:"ส่งสำเร็จ 24 ชม."}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold text-emerald-300",children:m.sent_24h??0})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:"ส่งไม่ผ่าน 24 ชม."}),e.jsx("p",{className:`mt-0.5 text-sm font-semibold ${(m.failed_24h??0)>0?"text-rose-300":"text-slate-300"}`,children:m.failed_24h??0})]})]}),(V==null?void 0:V.last_error)&&e.jsxs("p",{className:"mt-3 rounded-lg border border-rose-500/30 bg-rose-500/5 px-3 py-2 text-xs text-rose-300",children:["⚠️ ",V.last_error]}),Array.isArray(V==null?void 0:V.assets)&&V.assets.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1.5 text-[11px] text-slate-400",children:"สถานะรายสินทรัพย์ที่ติ๊กส่ง"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.assets.map((P,S)=>{const ye=E(P.delivery_status);return e.jsxs("span",{className:`rounded-md border px-2 py-1 text-[11px] ${ye.cls}`,style:{animation:"tgFade .4s ease both",animationDelay:`${S*60}ms`},title:P.last_delivered_at?`ส่งล่าสุด ${l(P.last_delivered_at)}`:P.last_signal_at?`เอนจินมีสัญญาณล่าสุด ${l(P.last_signal_at)}`:"เอนจินยังไม่เคยออกสัญญาณตัวนี้",children:[P.asset," · ",ye.txt]},P.asset)})})]}),V&&Array.isArray(V.assets)&&V.assets.length===0&&e.jsx("p",{className:"mt-3 text-[11px] text-slate-500",children:"ส่งทุกสินทรัพย์ (ไม่ได้จำกัดรายตัว)"})]})})(),e.jsx("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:Zn.map((t,s)=>e.jsxs("div",{className:`tg-reveal ${q}`,style:{animationDelay:`${100+s*70}ms`},children:[e.jsx("p",{className:"text-xs text-slate-400",children:t.k}),e.jsx("p",{className:"mt-1 text-3xl font-bold",style:{color:t.c},children:e.jsx(cn,{text:t.v})}),e.jsx(ui,{values:t.s,color:t.c})]},t.k))}),e.jsxs("button",{type:"button",onClick:()=>N("footprint"),className:`tg-reveal ${q} flex w-full items-center gap-3 border !border-amber-500/25 text-left transition hover:!border-amber-500/50`,style:{animationDelay:"180ms"},children:[e.jsx("span",{className:"text-2xl",children:"🧪"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-100",children:"Footprint Lab"}),e.jsx("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-bold text-amber-300",children:"Add-On ใหม่"}),(k==null?void 0:k.on)&&k.paid&&e.jsx("span",{className:"rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:"✅ เปิดรับอยู่"}),(k==null?void 0:k.on)&&!k.paid&&e.jsx("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-300",children:"⏳ หมดอายุ"})]}),e.jsxs("span",{className:"mt-0.5 block text-xs text-slate-400",children:["สัญญาณ order flow จาก tape จริง · ",k!=null&&k.unlimited?"ช่องแอดมิน (ไม่จำกัด)":`${(k==null?void 0:k.cost)??50} เครดิต / 30 วัน`]})]}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-amber-300",children:"ตั้งค่า →"})]}),je&&e.jsxs("button",{type:"button",onClick:()=>De(!0),className:`tg-reveal ${q} flex w-full items-center gap-3 border !border-emerald-500/25 text-left transition hover:!border-emerald-500/50`,style:{animationDelay:"210ms"},children:[e.jsx("span",{className:"text-2xl",children:"🤝"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-100",children:"Partner IB — เปลี่ยนกลุ่มของคุณเป็นรายได้"}),e.jsxs("span",{className:"rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-bold text-emerald-300",children:["คอมมิชชั่น ",Ee??20,"%"]})]}),e.jsx("span",{className:"mt-0.5 block text-xs text-slate-400",children:"สมาชิกในกลุ่มสมัคร VIP ผ่านลิงก์ของคุณ = ค่าคอมจากยอดขายจริง · ไม่มีค่าสมัคร · บันไดสถานะ 4 ขั้นถึง Master IB"})]}),e.jsx("span",{className:"shrink-0 text-xs font-medium text-emerald-300",children:"รับลิงก์ →"})]}),Array.isArray(b==null?void 0:b.equity)&&b.equity.length>0&&e.jsxs("section",{className:`tg-reveal ${q}`,children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("button",{onClick:()=>ea("chart"),className:`rounded-xl px-3.5 py-2 text-sm font-semibold transition ${_t==="chart"?"bg-cyan-500/15 text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:"📈 กราฟกำไรสะสม"}),e.jsx("button",{onClick:()=>ea("calendar"),className:`rounded-xl px-3.5 py-2 text-sm font-semibold transition ${_t==="calendar"?"bg-cyan-500/15 text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:"🗓️ ปฏิทินกำไร–ขาดทุน"})]}),e.jsx("span",{className:"text-[11px] text-slate-500",children:_t==="chart"?`อ้างอิงผลจริงของทุกไม้ที่ปิดแล้ว · ตลอดช่วงที่รัน (${b.equity.length} วัน)`:"ผลจริงรายวัน · สไตล์ FTMO"})]}),_t==="chart"?e.jsx(bi,{points:b.equity,netPct:Number(((kl=b.totals)==null?void 0:kl.net_pct)??0),wins:Number(((Sl=b.totals)==null?void 0:Sl.win)??0),losses:Number(((Cl=b.totals)==null?void 0:Cl.loss)??0)}):e.jsx(ji,{equity:b.equity})]}),e.jsxs("div",{className:"tg-reveal grid grid-cols-1 gap-5 lg:grid-cols-3",children:[e.jsxs("section",{className:`${q} lg:col-span-2`,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Pipeline"}),e.jsx("p",{className:"text-xs text-slate-500",children:"คลิกโหนดเพื่อตั้งค่า step นั้น"})]}),e.jsx(ki,{...Jn})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"ผลแพ้/ชนะ"}),e.jsx(yi,{win:(z==null?void 0:z.win)??0,loss:(z==null?void 0:z.loss)??0,expired:(z==null?void 0:z.expired)??0,pe
9nding:(z==null?void 0:z.pending)??0})]})]}),b&&(($l=b.totals)==null?void 0:$l.total)>0&&e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[{k:"Avg R:R",v:b.totals.avg_rr?`1 : ${b.totals.avg_rr}`:"—",c:"#22d3ee"},{k:"ความมั่นใจเฉลี่ย",v:`${b.totals.avg_conf}%`,c:"#34d399"},{k:"ถือเฉลี่ย · Long",v:ln((Ml=b.holding)==null?void 0:Ml.long_min),c:"#a78bfa"},{k:"ถือเฉลี่ย · Short",v:ln((Al=b.holding)==null?void 0:Al.short_min),c:"#f87171"}].map(t=>e.jsxs("div",{className:q,children:[e.jsx("p",{className:"text-xs text-slate-400",children:t.k}),e.jsx("p",{className:"mt-1 text-xl font-semibold",style:{color:t.c},children:t.v})]},t.k))}),b.adv&&(b.adv.closed??0)>0&&e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-base font-semibold",children:"สถิติเชิงลึกแบบ Myfxbook"}),e.jsx("span",{className:"text-[11px] text-slate-500",children:"ไม้ที่ปิดผลแล้ว · ตลอดช่วงที่รัน"})]}),e.jsxs("div",{className:"mb-3 rounded-xl border border-white/10 bg-black/20 p-3",children:[e.jsx("div",{className:"mb-1 text-xs text-slate-400",children:"คุณภาพระบบ · 5 มิติ"}),e.jsx(Il,{adv:b.adv,days:b.equity,lowSampleAt:100})]}),e.jsx(Ol,{adv:b.adv})]}),(Dl=b.hourly)!=null&&Dl.length||(Ll=b.daily)!=null&&Ll.length?e.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"ชนะ vs แพ้ · รายชั่วโมง"}),e.jsx(Bl,{data:b.hourly??[]})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"ชนะ vs แพ้ · รายวันในสัปดาห์"}),e.jsx(Wl,{data:b.daily??[]})]})]}):null,Array.isArray(b.points)&&b.points.length>0&&e.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-1 text-base font-semibold",children:"Duration · ระยะเวลาถือ vs ผล"}),e.jsx(Hl,{data:b.points})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-1 text-base font-semibold",children:"MAE · การขาดทุนสวนทางสูงสุด"}),e.jsx(ql,{data:b.points})]})]}),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx("h2",{className:"text-base font-semibold",children:"กำไร/ขาดทุน รายคู่ (Net %)"}),e.jsx("span",{className:"text-[11px] text-slate-500",children:"เรียงจากกำไรมากสุด → ขาดทุนมากสุด"})]}),e.jsxs("p",{className:"mb-3 text-[11px] text-slate-500",children:["🟢 ผลรวมเป็นบวก · 🔴 ผลรวมเป็นลบ — ตัวเลขขวา = กำไรสะสม % · สถิติ ชนะ-แพ้ · win rate (นับเฉพาะไม้ที่ปิดผลแล้ว) · ",e.jsx("span",{className:"text-amber-300/90",children:"ถอดแล้ว"})," = ยอดเก่าของคู่ที่ไม่อยู่ในลิสต์ที่ติ๊กแล้ว · ",e.jsx("span",{className:"text-amber-300/90",children:"ยังไม่หักสเปรด/ค่าคอม"})," — คู่เงินหลักมีระยะ TP เฉลี่ยราว 0.05% ของราคา ต้นทุนจึงมีผลมาก"]}),(()=>{const t=[...b.by_asset].filter(l=>l.win+l.loss>0).sort((l,m)=>m.net-l.net);if(!t.length)return e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีคู่ที่ปิดผลแล้ว — รอสัญญาณเข้า WIN/LOSS ก่อน"});const s=Math.max(...t.map(l=>Math.abs(l.net)),1);return e.jsx("div",{className:"space-y-2.5",children:t.map(l=>e.jsx(wi,{label:l.asset,sub:ve(l.asset),net:l.net,win:l.win,loss:l.loss,maxAbs:s,outOfFilter:Bs(l.asset)},l.asset))})})()]}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"สินทรัพย์ที่ส่งบ่อย"}),e.jsx("div",{className:"space-y-2.5",children:(()=>{const t=Math.max(...b.by_asset.map(s=>s.total),1);return b.by_asset.map(s=>e.jsx(as,{label:s.asset,frac:s.total/t,color:"#22d3ee",right:`${s.total} ครั้ง`,outOfFilter:Bs(s.asset)},s.asset))})()})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"Reward : Risk ต่อคู่"}),e.jsx("div",{className:"space-y-2.5",children:(()=>{const t=b.by_asset.filter(l=>l.rr),s=Math.max(...t.map(l=>l.rr),2);return t.length?t.map(l=>e.jsx(as,{label:l.asset,frac:l.rr/s,color:"#34d399",right:`1 : ${l.rr}`,outOfFilter:Bs(l.asset)},l.asset)):e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีข้อมูล R:R"})})()})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"Long vs Short"}),e.jsx("div",{className:"space-y-2.5",children:(()=>{const t=b.direction,s=Math.max(t.long,t.short,1);return e.jsxs(e.Fragment,{children:[e.jsx(as,{label:"Long",frac:t.long/s,color:"#34d399",right:`${t.long} · ${t.long?Math.round(t.long_win/t.long*100):0}%`}),e.jsx(as,{label:"Short",frac:t.short/s,color:"#f87171",right:`${t.short} · ${t.short?Math.round(t.short_win/t.short*100):0}
9%`})]})})()}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-500",children:"ตัวเลข % = win rate ของทิศทางนั้น"})]}),e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"กำไรรายเดือน (Net %)"}),e.jsx(Ni,{data:b.monthly})]})]})]})]}),c==="setup"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:q,children:[e.jsxs("h2",{className:"mb-4 flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-lg bg-cyan-500/15 text-xs text-cyan-400",children:"1"})," ตั้งค่าช่องทางส่งสัญญาณ"]}),e.jsxs("div",{className:"mb-5 flex flex-wrap gap-1.5 border-b border-white/10 pb-3",children:[e.jsxs("button",{onClick:()=>Ha("telegram"),className:`rounded-xl px-4 py-2 text-sm font-medium transition ${Et==="telegram"?"bg-cyan-500/15 text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:["✈️ Telegram ",(h==null?void 0:h.has_bot)&&e.jsx("span",{className:"ml-1 text-emerald-400",children:"●"})]}),e.jsxs("button",{onClick:()=>Ha("discord"),className:`rounded-xl px-4 py-2 text-sm font-medium transition ${Et==="discord"?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/40":"text-slate-400 hover:bg-white/5"}`,children:["🎮 Discord ",(h==null?void 0:h.has_discord)&&(h==null?void 0:h.discord_active)&&e.jsx("span",{className:"ml-1 text-emerald-400",children:"●"}),(h==null?void 0:h.discord_active)===!1&&e.jsx("span",{className:"ml-1 text-amber-400",children:"🔒"})]}),e.jsxs("button",{disabled:!0,title:"เร็วๆ นี้",className:"cursor-not-allowed rounded-xl px-4 py-2 text-sm font-medium text-slate-600",children:["🟩 Line ",e.jsx("span",{className:"ml-1 rounded-md bg-white/5 px-1.5 py-0.5 text-[10px] text-slate-500",children:"เร็วๆ นี้"})]})]}),Et==="telegram"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 rounded-xl border border-cyan-500/20 bg-cyan-500/[0.04] p-3.5 text-xs leading-relaxed",children:[e.jsx("p",{className:"mb-1.5 font-medium text-cyan-300",children:"วิธีตั้งค่า (ทำตามนี้ได้เลย)"}),e.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-slate-400",children:[e.jsxs("li",{children:["วาง ",e.jsx("span",{className:"text-slate-200",children:"เฉพาะ Bot Token"})," เช่น ",e.jsx("span",{className:"font-mono text-slate-200",children:"123456789:AAExampleTokenDoNotUse…"})," ",e.jsx("span",{className:"text-slate-500",children:"(ไม่ต้องใส่ URL หรือ /getUpdates — ถ้าวาง URL เต็มมา ระบบจะตัดให้)"})]}),e.jsxs("li",{children:["กด ",e.jsx("span",{className:"text-cyan-300",children:"“ทดสอบบอท & ดึง chat_id”"})," แล้วเลือกกลุ่มที่บอทเป็นแอดมิน"]}),e.jsxs("li",{children:["กด ",e.jsx("span",{className:"text-emerald-300",children:"“บันทึกการตั้งค่า”"})]}),e.jsxs("li",{children:["เปิดสวิตช์ ",e.jsx("span",{className:"text-emerald-300",children:"“เปิดส่ง”"})," ด้านบน → เริ่มส่งสัญญาณเข้ากลุ่ม"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"Bot Token (จาก @BotFather)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx("input",{className:oe+" pr-11",type:os?"text":"password",autoComplete:"off",placeholder:h!=null&&h.has_bot?`บันทึกไว้แล้ว (${h.bot_token_masked}) — เว้นว่างถ้าไม่เปลี่ยน`:"วาง bot token ที่นี่",value:st,onChange:t=>is(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>fn(t=>!t),"aria-label":os?"ซ่อน token":"แสดง token",className:"absolute right-1.5 top-1/2 -translate-y-1/2 roun
9ded-md p-1.5 text-slate-400 transition hover:text-cyan-300",children:e.jsx(Ks,{off:os})})]}),e.jsxs("p",{className:"mt-1 text-xs text-slate-500",children:["วางเฉพาะ token เช่น ",e.jsx("span",{className:"text-slate-400",children:"123456789:AAExampleTokenDoNotUse…"})," (ถ้าวาง URL เต็ม ระบบจะตัด token ให้อัตโนมัติ)"]}),(h==null?void 0:h.has_bot)&&!st.trim()&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-xs text-emerald-400",children:["✓ บันทึก Bot Token ไว้แล้ว (",h.bot_token_masked,") — เว้นช่องนี้ว่างได้ ระบบจำค่าไว้ให้"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx("button",{onClick:Bn,disabled:Ds,className:"rounded-xl bg-cyan-600 px-4 py-2 text-sm font-medium text-white hover:bg-cyan-500 disabled:opacity-50",children:Ds?"กำลังทดสอบ…":"ทดสอบบอท & ดึง chat_id"})}),Ga&&e.jsx("p",{className:"text-sm text-slate-300",children:Ga}),Ut.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Ut.map(t=>e.jsxs("button",{onClick:()=>xs(t.id),className:`rounded-lg border px-3 py-1.5 text-xs ${Ye===t.id?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-300 hover:bg-white/5"}`,children:[t.title," ",e.jsxs("span",{className:"text-slate-500",children:["(",t.id,")"]})]},t.id))}),e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"Chat ID ของกลุ่ม"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx("input",{className:oe+" pr-11",type:cs?"text":"password",autoComplete:"off",placeholder:"-100...",value:Ye,onChange:t=>xs(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>gn(t=>!t),"aria-label":cs?"ซ่อน Chat ID":"แสดง Chat ID",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-slate-400 transition hover:text-cyan-300",children:e.jsx(Ks,{off:cs})})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"บอทต้องเป็น admin ของกลุ่ม"})]}),e.jsxs("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"flex items-center gap-2 text-sm font-semibold text-slate-200",children:"📈 ส่งสัญญาณเข้ากลุ่มนี้"}),e.jsxs("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:["ปิด = กลุ่มนี้จะ",e.jsx("span",{className:"text-slate-300",children:"ไม่รับสัญญาณ"})," แต่ยัง",e.jsx("span",{className:"text-slate-300",children:"รับข่าว/ปฏิทิน"}),"ได้ตามปกติ (ถ้าเปิดข่าวอัตโนมัติไว้) — เหมาะกับคนที่อยากส่งซิกเข้า Discord อย่างเดียว แล้วใช้ Telegram ไว้แชร์ข่าว"]})]}),e.jsx(de,{on:ms,onChange:sa})]}),!ms&&e.jsx("p",{className:"mt-2 rounded-lg border border-amber-500/20 bg-amber-500/[0.06] px-3 py-2 text-xs text-amber-300",children:"⏸️ ปิดส่งสัญญาณเข้า Telegram อยู่ — ซิกจะเข้าเฉพาะ Discord (ถ้าเปิดไว้) · ข่าวยังส่งเข้ากลุ่มนี้ตามปกติ"})]})]})]}),Et==="discord"&&e.jsxs("div",{className:"space-y-3",children:[(()=>{var l;const t=rt.filter(m=>{var E;return(E=Ft[m.id])==null?void 0:E.dead});if(t.length===0)return null;const s=t.reduce((m,E)=>{var _;return m+(((_=Ft[E.id])==null?void 0:_.fail_streak)??0)},0);return e.jsxs("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/[0.07] p-3.5 text-xs leading-relaxed",children:[e.jsxs("p",{className:"text-sm font-semibold text-rose-300",children:["🔴 ",t.length," ห้องส่งไม่ออก: ",t.map(m=>
9m.label||"ห้องไม่มีชื่อ").join(", ")]}),e.jsxs("p",{className:"mt-1 text-slate-300",children:[ss((l=Ft[t[0].id])==null?void 0:l.last_error)," — ระบบพยายามส่งแล้วล้มติดกัน ",s.toLocaleString()," ครั้ง"]}),e.jsxs("p",{className:"mt-1 text-slate-400",children:["วิธีแก้: ใน Discord สร้าง Webhook ใหม่ (Server Settings → Integrations → Webhooks → New Webhook → Copy Webhook URL) แล้ววาง URL ใหม่แทนที่ในห้องเดิมด้านล่าง จากนั้นกด ",e.jsx("span",{className:"text-emerald-300",children:"บันทึก"})," — การต่ออายุอย่างเดียวไม่ทำให้ห้องกลับมาส่งได้"]})]})})(),e.jsxs("div",{className:"rounded-xl border border-indigo-500/20 bg-indigo-500/[0.04] p-3.5 text-xs leading-relaxed",children:[e.jsx("p",{className:"mb-1.5 font-medium text-indigo-300",children:"วิธีต่อ Discord (ไม่ต้องสร้างบอท)"}),e.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-slate-400",children:[e.jsxs("li",{children:["ในเซิร์ฟเวอร์ Discord: ",e.jsx("span",{className:"text-slate-200",children:"Server Settings → Integrations → Webhooks → New Webhook"})]}),e.jsxs("li",{children:["เลือกห้องที่จะให้สัญญาณเข้า แล้วกด ",e.jsx("span",{className:"text-slate-200",children:"Copy Webhook URL"})]}),e.jsxs("li",{children:["วาง URL ด้านล่าง → ",e.jsx("span",{className:"text-emerald-300",children:"บันทึก"})," → กด ",e.jsx("span",{className:"text-indigo-300",children:"“ส่งการ์ดทดสอบ”"})]})]}),e.jsx("p",{className:"mt-1.5 text-slate-500",children:"จะได้การ์ดสัญญาณ (embed) + ภาพ SMC/PA หลายไทม์เฟรม เหมือนที่ส่งเข้า Telegram"})]}),(h==null?void 0:h.discord_active)===!1&&C?e.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/[0.05] p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-300",children:"🔒 ส่งเข้า Discord เป็นฟีเจอร์เสริม"}),e.jsxs("p",{className:"mt-1 text-xs leading-relaxed text-slate-400",children:["ปลดล็อคการส่งสัญญาณเข้ากลุ่ม Discord — ",e.jsx("span",{className:"text-slate-200",children:"50 เครดิต (180฿) / 30 วัน"})," ต่ออายุเหมือนแพ็กหลัก · ครั้งเดียวใช้ได้ทั้งการ์ดสัญญาณ + ภาพ MTF"]}),e.jsxs("p",{className:"mt-2 text-xs text-slate-400",children:["เครดิตคงเหลือ: ",e.jsx("span",{className:`font-semibold ${d.balance>=d.discordCost?"text-emerald-400":"text-rose-400"}`,children:d.balance})]}),d.balance>=d.discordCost?e.jsx("button",{onClick:il,disabled:As,className:"mt-3 rounded-xl bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-500 disabled:opacity-50",children:As?"กำลังปลดล็อค…":"🔓 ปลดล็อค Discord · 50 เครดิต"}):e.jsxs("a",{href:"/?buy=credits",className:"mt-3 inline-block rounded-xl bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500",children:["เติมเครดิต (",d.balance,")"]}),Pt&&e.jsx("p",{className:"mt-2 text-xs text-slate-300",children:Pt})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-semibold text-indigo-300",children:["🎮 Webhook URL ",e.jsx("span",{className:"text-xs font-normal text-slate-500",children:"(ส่งพร้อม Telegram)"})]}),e.jsxs("label",{className:"flex shrink-0 items-center gap-2 text-xs text-slate-400",children:[e.jsx("input",{type:"checkbox",checked:Ea,onChange:t=>Pa(t.target.checked),className:"accent-indigo-500"}),"เปิดส่ง"]})]}),C&&d.discordExpiresAt&&e.jsxs("p",{className:"text-xs text-emerald-400",children:["✓ ใช้งานได้ · เหลือ ",Math.max(0,Math.ceil((new Date(d.discordExpiresAt).getTime()-Date.now())/864e5))," วัน",d.balance>=d.discordCost&&e.jsx("button",{onClick:il,disabled:As,className:"ml-2 roun
9ded-lg border border-indigo-500/40 px-2 py-0.5 text-[11px] text-indigo-300 hover:bg-indigo-500/10 disabled:opacity-50",children:"+30 วัน"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{className:oe+" pr-11",type:ds?"text":"password",autoComplete:"off",placeholder:h!=null&&h.has_discord?`บันทึกไว้แล้ว (${h.discord_webhook_masked}) — เว้นว่างถ้าไม่เปลี่ยน`:"https://discord.com/api/webhooks/…",value:Rt,onChange:t=>Fa(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>jn(t=>!t),"aria-label":ds?"ซ่อน webhook":"แสดง webhook",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-slate-400 transition hover:text-indigo-300",children:e.jsx(Ks,{off:ds})})]}),(h==null?void 0:h.has_discord)&&!Rt.trim()&&e.jsxs("p",{className:"mt-1 flex items-center gap-1 text-xs text-emerald-400",children:["✓ บันทึก Webhook ไว้แล้ว (",h.discord_webhook_masked,") — เว้นช่องนี้ว่างได้"]}),Pt&&e.jsx("p",{className:"text-xs text-slate-300",children:Pt}),e.jsxs("div",{className:"mt-2 rounded-xl border border-white/10 bg-white/[0.02] p-3.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-semibold text-slate-200",children:["🔔 Ping @role ตอนสัญญาณมั่นใจสูง ",e.jsx("span",{className:"text-xs font-normal text-slate-500",children:"(ไม่บังคับ)"})]}),e.jsxs("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:["ใส่ ",e.jsx("span",{className:"text-slate-300",children:"Role ID"})," เพื่อให้บอทแท็กเตือนสมาชิกที่มี role นั้นเมื่อความมั่นใจ ≥ เกณฑ์ — วิธีเอา ID: เปิด ",e.jsx("span",{className:"text-slate-300",children:"User Settings → Advanced → Developer Mode"})," แล้วคลิกขวาที่ role → ",e.jsx("span",{className:"text-slate-300",children:"Copy Role ID"})," (เว้นว่าง = ไม่ ping)"]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:oe+" flex-1 min-w-[180px]",inputMode:"numeric",placeholder:"Role ID เช่น 123456789012345678",value:Ua,onChange:t=>Ia(t.target.value.replace(/[^0-9]/g,""))}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[e.jsx("span",{children:"ping เมื่อ ≥"}),e.jsx("input",{type:"number",min:50,max:95,className:oe+" w-16 text-center",value:Oa,onChange:t=>Ba(Number(t.target.value)||85)}),e.jsx("span",{children:"%"})]})]})]}),e.jsxs("div",{className:"mt-2 rounded-xl border border-white/10 bg-white/[0.02] p-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-semibold text-slate-200",children:["🗂️ แยกห้องตามหมวด ",e.jsx("span",{className:"text-xs font-normal text-slate-500",children:"(มีหลายกลุ่ม)"})]}),e.jsx("button",{type:"button",onClick:Gn,className:"shrink-0 rounded-lg border border-indigo-500/40 px-2.5 py-1 text-xs font-medium text-indigo-300 hover:bg-indigo-500/10",children:"➕ เพิ่มห้อง"})]}),e.jsxs("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:["ใส่ Webhook แยกแต่ละห้อง แล้วเลือกหมวดที่ห้องนั้นจะรับ (เช่น Crypto เข้าห้องหนึ่ง · Forex อีกห้อง) — เลือก “ข่าว” สำหรับห้องรับข่าว/ปฏิทิน",rt.length>0&&e.jsx("span",{className:"text-amber-300/80",children:" · เมื่อมีห้องด้านล่าง ระบบจะใช้ห้องเหล่านี้แทน Webhook เดี่ยวด้านบน"})]}),rt.length===0?e.jsx("p",{className:"mt-3 rounded-lg border border-dashed border-white/10 px-3 py-4 text-center text-xs text-slate-500",children:"ยังไม่มีห้องแยก — ใช้ Webhook เดี่ยวด้านบน หรือกด “เพิ่มห้อง” เพื่อแยกส่งตามหมวด"}):e.jsx("div",{className:"mt-3 space-y-3",children:rt.map(t=>e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:oe+" flex-1",placeholder:"ชื่อห้อง เช่น Crypto / Forex / ข่าว",value:t.label,onChange:s=>Jt(t.id,{label:s.target.value})}),e.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 text-xs text-slate-400",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:s=>Jt(t.id,{enabled:s.target.checked}),className:"accent-indigo-500"})," เปิด"]}),e.jsx("button",{type:"button",onClick:()=>zn(t.id),"aria-label":"ลบห้อง",className:"shrink-0 rounded-md px-2 py-1 text-xs text-rose-400/70 hover:bg-rose-500/10 hover:text-rose-300",children:"✕"})]}),e.jsx("input",{className:oe+" mt-2",type:"text",autoComplete:"off",placeholder:t.webhook_set?`บันทึกไว้แล้ว (${t.webhook_masked}) — เว้นว่างถ้าไม่เปลี่ยน`:"https://discord.com/api/webhooks/…",value:t.webhook,onChange:s=>Jt(t.id,{webhook:s.target.value})}),(()=>{const s=Ft[t.id];if(!s||!s.last_ok_at&&!s.last_fail_at)return t.kind==="footprint"||!t.webhook_set?null:e.jsx("p",{className:"mt-1.5 text-[11px] text-slate-500",children:"⚪ ยังไม่มีการส่งเข้าห้องนี้"});const l=m=>
9m?new Date(m).toLocaleString("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be}):"—";return s.dead?e.jsxs("p",{className:"mt-1.5 rounded-md border border-rose-500/30 bg-rose-500/10 px-2 py-1 text-[11px] text-rose-300",children:["🔴 ส่งไม่ออก · ล้ม ",s.fail_streak.toLocaleString()," ครั้งติด (ล่าสุด ",l(s.last_fail_at),") · ",ss(s.last_error)," → วาง Webhook ใหม่ด้านบนแล้วบันทึก"]}):s.fail_streak>0?e.jsxs("p",{className:"mt-1.5 text-[11px] text-amber-300",children:["🟡 ล้ม ",s.fail_streak," ครั้งล่าสุด (",ss(s.last_error),") · ส่งสำเร็จล่าสุด ",l(s.last_ok_at)]}):e.jsxs("p",{className:"mt-1.5 text-[11px] text-emerald-400/80",children:["🟢 ส่งล่าสุด ",l(s.last_ok_at)]})})(),e.jsx("div",{className:"mt-2 flex items-center gap-1.5",children:["signals","news","footprint"].map(s=>e.jsx("button",{type:"button",onClick:()=>Jt(t.id,{kind:s}),className:`rounded-lg px-2.5 py-1 text-xs font-medium ${t.kind===s?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/40":"text-slate-400 hover:bg-white/5"}`,children:s==="signals"?"📈 ซิกแนล":s==="news"?"📰 ข่าว/ปฏิทิน":"🧪 Footprint"},s))}),t.kind==="footprint"&&e.jsx("p",{className:"mt-1.5 text-[11px] text-amber-300/70",children:"ห้องนี้รับสัญญาณ Footprint Lab (Add-On) — ต้องเปิดรับในหน้า “ภาพรวม” ด้วย"}),t.kind==="signals"&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("p",{className:"text-[11px] text-slate-500",children:["หมวดที่ห้องนี้รับ ",e.jsx("span",{className:"text-slate-600",children:"(ไม่เลือก = ทุกหมวด)"})]}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-1.5",children:ci.map(s=>e.jsx("button",{type:"button",onClick:()=>Vn(t.id,s),className:`rounded-md border px-2 py-1 text-[11px] ${t.groups.includes(s)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:s},s))})]})]},t.id))})]})]})]})]}),vl]}),c==="signals"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:q,children:[e.jsxs("h2",{className:"mb-4 flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-lg bg-cyan-500/15 text-xs text-cyan-400",children:"2"})," การส่งสัญญาณ"]}),e.jsxs("div",{className:"mb-5",children:[e.jsxs("p",{className:$e,children:["สินทรัพย์ที่จะส่ง ",e.jsx("span",{className:"text-slate-500",children:"(ไม่เลือก = ส่งทุกตัว)"})]}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx("input",{className:oe,placeholder:"ค้นหา/พิมพ์สินทรัพย์ เช่น BTC, XAU, EURUSD แล้วกด Enter",value:at,onChange:t=>aa(t.target.value),onKeyDown:t=>{t.key==="Enter"&&at.trim()&&(t.preventDefault(),Os(at))}}),at&&xl.length>0&&e.jsx("div",{className:"absolute z-10 mt-1 w-full overflow-hidden rounded-xl border border-white/10 bg-slate-900 shadow-xl",children:xl.map(t=>e.jsxs("button",{onClick:()=>Os(t),className:"flex w-full items-center justify-between px-3.5 py-2 text-left text-sm hover:bg-white/5",children:[e.jsxs("span",{children:[t,ve(t)&&e.jsxs("span",{className:"ml-1.5 text-slate-400",children:["· ",ve(t)]}),!en.has(t)&&e.jsx("span",{className:"ml-1 text-amber-500/70",children:"*"})]}),e.jsx("span",{className:"text-xs text-slate-500",children:pi(t)})]},t))})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[me.length===0?e.jsx("span",{className:"rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-3 py-1.5 text-xs text-emerald-300",children:"ส่งทุกสินทรัพย์"}):me.map(t=>e.jsxs("span",{title:ve(t),className:"flex items-center gap-1.5 rounded-lg border border-cyan-500/30 bg-cyan-500/10 px-3 py-1.5 text-xs text-cyan-200",children:[t,!en.has(t)&&e.jsx("span",{className:"text-amber-400/80",children:"*"}),e.jsx("button",{onClick:()=>dl(t),className:"text-cyan-400/60 hover:text-cyan-200",children:"✕"})]},t)),me.length>0&&e.jsx("button",{onClick:()=>dt([]),className:"rounded-lg px-2 py-1.5 text-xs text-slate-400 hover:text-slate-200",children:"ล้างทั้งหมด"})]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:yt.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"w-14 text-[11px] text-slate-500",children:t.group}),t.symbols.map(s=>e.jsxs("button",{title:ve(s),onClick:()=>me.includes(s)?dl(s):Os(s),className:`rounded-md border px-2 py-1 text-[11px] ${me.includes(s)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:[s,ve(s)&&e.jsxs("span",{className:"ml-1 opacity-60",children:["· ",ve(s)]})]},s))]},t.group))}),e.jsx(di,{assets:me,onSet:t=>dt(t)})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"ความถี่การส่ง"}),e.jsxs("select",{className:oe+" mt-1",value:hl?Xe:"custom",onChange:t=>{t.target.value!=="custom"&&ps(Number(t.target.value))},children:[Js.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value)),e.jsx("option",{value:"custom",children:"กำหนดเอง…"})]}),!hl&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{className:oe,type:"number",min:1,value:Xe,onChange:t=>ps(Number(t.target.value))}),e.jsx("span",{className:"text-xs text-slate-400",children:"นาที"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"โซนเวลา (Timezone)"}),e.jsx("select",{className:oe+" mt-1",value:be,onChange:t=>ra(t.target.value),children:hi.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{children:[e.jsxs("p",{className:$e,children:["กรองด้วยคะแนนความมั่นใจ: ",e.jsxs("span",{className:"text-slate-200",children:["≥ ",xt,"%"]}),e.jsxs("span",{className:"ml-1 font-normal text-slate-500",children:["— ตัวปรับ",e.jsx("b",{className:"text-slate-400",children:"ปริมาณ"})," ไม่ใช่คุณภาพ"]})]}),e.jsx("input",{type:"range",min:70,max:95,value:xt,onChange:t=>la(Number(t.target.value)),className:"mt-2 w-full accent-cyan-500","aria-describedby":"
9conf-evidence"}),e.jsxs("div",{id:"conf-evidence",className:"mt-1.5 rounded border border-slate-700/60 bg-slate-900/40 px-2 py-1.5",children:[e.jsxs("p",{className:"text-[10px] leading-relaxed text-slate-400",children:["วัดจริง 6,843 ชุดสัญญาณ — ",e.jsx("b",{className:"text-amber-300",children:"คะแนนยิ่งสูง ผลยิ่งแย่"})," ไม่ใช่ยิ่งดี:"]}),e.jsx("div",{className:"mt-1 grid grid-cols-4 gap-1 text-center text-[10px] tabular-nums",children:[{b:"70–75",w:"59.6%",r:"−0.006"},{b:"76–83",w:"56.1%",r:"−0.065"},{b:"84–92",w:"54.5%",r:"−0.092"},{b:"93–99",w:"57.1%",r:"−0.048"}].map(t=>e.jsxs("div",{className:"rounded bg-slate-950/60 px-1 py-0.5",children:[e.jsx("div",{className:"text-slate-500",children:t.b}),e.jsx("div",{className:"text-slate-300",children:t.w}),e.jsxs("div",{className:"text-rose-300",children:[t.r,"R"]})]},t.b))}),e.jsxs("p",{className:"mt-1 text-[10px] leading-relaxed text-slate-500",children:["เลื่อนขึ้นเพื่อ",e.jsx("b",{className:"text-slate-400",children:"รับน้อยลง"}),"ได้ แต่อย่าเลื่อนขึ้นเพราะคิดว่าจะได้ไม้ที่ดีขึ้น ถ้าจะคัดจริง ให้คัดที่",e.jsx("b",{className:"text-slate-400",children:"คู่เงิน"}),"ตามต้นทุนของโบรกคุณ"]})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:$e,children:["ความเสี่ยงต่อไม้ (แสดงในข้อความ): ",e.jsxs("span",{className:"text-slate-200",children:[mt,"%"]})]}),e.jsx("input",{type:"range",min:.25,max:5,step:.25,value:mt,onChange:t=>na(Number(t.target.value)),className:"mt-2 w-full accent-cyan-500"})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",children:[e.jsx(de,{on:hs,onChange:da}),e.jsx("span",{className:"text-sm text-slate-300",children:"แนบการ์ดรูป"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",children:[e.jsx(de,{on:kt,onChange:ia}),e.jsx("span",{className:"text-sm text-slate-300",children:"แจ้งผล Win/Loss"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",children:[e.jsx(de,{on:xa,onChange:ma}),e.jsx("span",{className:"text-sm text-slate-300",children:"แจ้งข่าว Economic Calendar 📅"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",title:"ส่งข้อความ SMC Trend + Price Action หลายไทม์เฟรม (M15/H1/H4/D1) ตอบใต้สัญญาณแต่ละอัน",children:[e.jsx(de,{on:wa,onChange:va}),e.jsx("span",{className:"text-sm text-slate-300",children:"แนบ SMC/PA หลายไทม์เฟรม 🧭"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",title:"เมื่อมีข่าวแรงภายใน 4 ชั่วโมงข้างหน้าที่เกี่ยวกับคู่นั้น จะเพิ่มบรรทัดเตือนใต้สัญญาณ ว่าให้งดเข้าไม้ 15 นาทีก่อน–หลังข่าว (ไม่ได้บล็อกสัญญาณ)",children:[e.jsx(de,{on:ja,onChange:Na}),e.jsx("span",{className:"text-sm text-slate-300",children:"เตือนช่วงข่าวแรงใต้สัญญาณ ⚠️"})]})]}),e.jsxs("div",{className:"mt-4 rounded-xl border border-white/10 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"ข้อความท้ายโพสต์ของคุณ ✍️"}),e.jsxs("span",{className:`text-xs ${At.length>300?"text-rose-400":"text-slate-500"}`,children:[At.length,"/300"]})]}),e.jsxs("p",{className:"mb-2.5 text-xs leading-relaxed text-slate-500",children:["ข้อความนี้จะต่อท้ายทุกโพสต์ (สัญญาณ · ข่าว · ปฏิทิน · ข่าวเช้า) เหนือบรรทัดแบรนด์ — ใส่ชื่อกลุ่ม ลิงก์ติดต่อ หรือเงื่อนไขของคุณได้"," · ","ลิงก์ที่พิมพ์เป็นข้อความธรรมดาจะกดได้เอง"," · ","ระบบตัดแท็ก HTML ออกเพื่อไม่ให้ Telegram ปฏิเสธข้อความทั้งโพสต์"]}),e.jsx("textarea",{value:At,onChange:t=>ya(t.target.value.slice(0,300)),rows:3,placeholder:`ตัวอย่าง:
10สอบถาม/สมัครสมาชิก → @yourname
11กลุ่มนี้เป็นข้อมูลประกอบการตัดสินใจ ไม่ใช่คำแนะนำการลงทุน`,className:"w-full resize-y rounded-xl border border-white/10 bg-black/30 px-3 py-2 text-sm text-slate-200 placeholder:text-slate-600 focus:border-cyan-500/60 focus:outline-none"}),e.jsxs("p",{className:"mt-2 text-[11px] leading-relaxed text-slate-600",children:["หมายเหตุ: บรรทัด “Alpha AI Signals” ยังอยู่ด้านล่างเสมอ และการ์ดรูปยังมีโลโก้ของระบบ — ข้อความของคุณเป็นส่วน",e.
11jsx("span",{className:"text-slate-400",children:"เพิ่ม"})," ไม่ใช่การเปลี่ยนแบรนด์"]})]}),e.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-xl border border-white/10 bg-white/[0.02] px-3.5 py-3",children:[e.jsx(de,{on:oa,onChange:ca}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"text-slate-200",children:"แยกสรุปผลตามหมวด 🗂️"}),e.jsxs("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-500",children:["สรุปผลรายวัน/รายสัปดาห์จะแยกเป็นการ์ดต่อหมวด (คริปโต · ฟอเร็กซ์ · โลหะ · ดัชนี · หุ้น) แทนการรวมใบเดียว"," · ","ฝั่ง Discord ส่งเข้าห้องสัญญาณตามหมวดของแต่ละห้องให้อัตโนมัติ"," · ","ทำงานเมื่อเปิด “แจ้งผล Win/Loss”"]})]})]}),e.jsx("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.02] px-3.5 py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(de,{on:us,onChange:_a}),e.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[e.jsxs("p",{className:"text-slate-200",children:["สัญญาณ Swing High/Low · ออเดอร์ตั้งรอ 🪤",e.jsx("span",{className:"ml-1.5 rounded-md border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-300 align-middle",children:"Beta"})]}),e.jsxs("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-500",children:["เมื่อเกิด Swing High/Low ใหม่ (fractal 5 แท่ง ยืนยันหลังแท่งปิด) ระบบจะส่งระดับราคา + แผนตั้งออเดอร์รอเข้ากลุ่ม"," · ","ใช้ชุดสินทรัพย์เดียวกับที่เลือกด้านบน"," · ","เริ่มส่งเมื่อเกิด Swing ใหม่ตัวแรกหลังเปิดใช้"]}),us&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs text-slate-400",children:"โหมดการดัก — ระดับเดียวกันแต่เทรดคนละทิศ เลือกตามสไตล์ของคุณ"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:[{v:"fade",label:"🪤 ดักกลับตัว (Fade)",hint:"Sell Limit @ Swing High · Buy Limit @ Swing Low"},{v:"breakout",label:"🚀 ตามทะลุ (Breakout)",hint:"Buy Stop @ Swing High · Sell Stop @ Swing Low"},{v:"both",label:"📦 ส่งทั้งสองแบบ",hint:"สองแผนในข้อความเดียว"}].map(t=>e.jsx("button",{onClick:()=>ka(t.v),title:t.hint,className:`rounded-lg border px-2.5 py-1.5 text-xs ${Dt===t.v?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:t.label},t.v))}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-600",children:Dt==="fade"?"Sell Limit ดักที่ Swing High · Buy Limit ดักที่ Swing Low":Dt==="breakout"?"Buy Stop รอทะลุ Swing High · Sell Stop รอหลุด Swing Low":"ส่งทั้งแผนดักกลับตัว (Limit) และแผนตามทะลุ (Stop) ของระดับเดียวกันในข้อความเดียว"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs text-slate-400",children:"ไทม์เฟรมที่จะส่ง (เลือกได้หลายค่า)"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:[{v:"15m",l:"M15"},{v:"1h",l:"H1"},{v:"4h",l:"H4"},{v:"1d",l:"D1"}].map(t=>e.jsx("button",{onClick:()=>Sa(s=>s.includes(t.v)?s.length>1?s.filter(l=>l!==t.v):s:[...s,t.v]),className:`rounded-lg border px-3 py-1.5 text-xs ${bs.includes(t.v)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:t.l},t.v))}),bs.includes("15m")&&e.jsx("p",{className:"mt-1 text-[11px] text-amber-400/80",children:"M15 เà¸
11à¸´à¸” Swing ใหม่บ่อย — ถ้าเลือกหลายสินทรัพย์ ข้อความจะถี่ขึ้นมาก แนะนำ H1/H4 เป็นหลัก"})]}),e.jsxs("p",{className:"mt-3 text-[11px] leading-relaxed text-slate-600",children:["🧪 Beta — เครื่องมือแจ้งระดับราคาตามโหมดที่คุณตั้งเอง ไม่ใช่คำทำนายของ AI · ออเดอร์ตั้งรออาจไม่ถูก fill"," · ","ระบบติดตามผลแบบรู้ fill: แจ้งเมื่อราคาแตะระดับ / ถึง TP1 / โดน SL (ตามสวิตช์ “แจ้งผล Win/Loss”) พร้อมสรุปรายวันคู่กับ fill rate"," · ","ผลหมวดนี้แยกจากสถิติและอันดับหลักเสมอ"," · ","ไม่ใช่คำแนะนำการลงทุน"]})]})]})]})}),e.jsx("div",{className:"mt-3 rounded-xl border border-white/10 bg-white/[0.02] px-3.5 py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(de,{on:fs,onChange:Ca}),e.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[e.jsxs("p",{className:"text-slate-200",children:["สัญญาณล่าสภาพคล่อง · Liquidity Sweep 🧹",e.jsx("span",{className:"ml-1.5 rounded-md border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] text-amber-300",children:"Beta"})]}),e.jsxs("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-500",children:["เมื่อราคากวาดระดับสภาพคล่อง (swing เดิม หรือ Equal High/Low) แล้ว",e.jsx("span",{className:"text-slate-300",children:"ปิดกลับเข้ามา"})," ระบบจะส่งระดับที่ถูกกวาด ปลายไส้ และราคาปิดเข้ากลุ่ม"," · ","ใช้ชุดสินทรัพย์เดียวกับที่เลือกด้านบน"]}),fs&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs text-slate-400",children:"ไทม์เฟรมที่จะส่ง (เลือกได้หลายอัน)"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:[{v:"15m",l:"M15"},{v:"1h",l:"H1"},{v:"4h",l:"H4"},{v:"1d",l:"D1"}].map(t=>e.jsx("button",{onClick:()=>$a(s=>s.includes(t.v)?s.length>1?s.filter(l=>l!==t.v):s:[...s,t.v]),className:`rounded-lg border px-3 py-1.5 text-xs ${gs.includes(t.v)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:t.l},t.v))}),gs.includes("15m")&&e.jsx("p",{className:"mt-1 text-[11px] text-amber-400/80",children:"M15 เกิดการกวาดบ่อยกว่ามาก — ถ้าเลือกไว้ กลุ่มจะได้ข้อความถี่ขึ้น"})]}),e.jsxs("p",{className:"mt-3 text-[11px] leading-relaxed text-amber-400/80",children:["🧪 Beta — สถิติของสัญญาณกลุ่มนี้วัดได้ ",e.jsx("span",{className:"font-semibold",children:"59%"})," ใน 90 วันล่าสุด ขณะที่ต้องชนะเกิน ",e.jsx("span",{className:"font-semibold",children:"60%"})," จึงจะคุ้มทุน"," · ","ตัวเลขนี้ติดไปในทุกข้อความที่ส่งเข้ากลุ่ม"]}),e.jsxs("p",{className:"mt-1 text-[11px] leading-relaxed text-slate-600",children:["ข้อความรายงาน",e.jsx("span",{className:"text-slate-400",children:"เหตุการณ์ที่เกิดขึ้นแล้ว"})," พร้อมจุดที่ถือว่าผิดทาง (ปลายไส้) และตารางว่าถ้าตั้งเป้าที่ R เท่าไรต้องชนะกี่ % จึงคุ้มทุน"," · ","ระบบไม่ได้ตั้งเป้าให้ และไม่ได้ทำนายว่าราคาจะไปถึงไหน"," · ","ผลหมวดนี้แยกจากสถิติและอันดับหลักเสมอ"]})]})]})]})}),(h==null?void 0:h.pa_alert_only)&&e.jsxs("div",{className:"mt-5 rounded-xl border border-emerald-500/30 bg-emerald-500/5 p-4","data-pa-alert-mode":!0,children:[e.jsx("p",{className:"text-sm font-medium text-emerald-300",children:"โหมดแจ้งเตือน Price Action"}),e.jsxs("p",{className:"mb-3 mt-1 text-xs leading-relaxed text-slate-400",children:["ช่องนี้ส่ง",e.jsx("span",{className:"text-slate-200",children:"เฉพาะการแจ้งเตือนรูปแบบแท่งเทียน"})," — ทุกครั้งที่แท่งของไทม์เฟรมที่เลือกปิด ระบบสแกนคู่เงินในพอร์ตและแจ้งทุกคู่ที่เกิด pattern (ไม่ส่งสัญญาณ AI · ตัวกรองสัญญาณด้านล่างไม่มีผลกับช่องนี้) · ไม่เลือกคู่ = 28 คู่ forex หลัก · รองรับ M15 / H1 / H4 (D1 ไม่แจ้ง)"]}),e.jsx(tn,{tfs:Lt,onTfs:ws,pattern:vs,onPattern:_s}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-600",children:"แจ้งรูปแบบที่เกิดขึ้นแล้ว ไม่ใช่สัญญาณเข้าเทรด และยังไม่มีการวัดผลว่าช่วยให้ชนะมากขึ้น"})]}),e.jsxs("div",{className:"mt-5 rounded-xl border border-white/10 p-4",children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"ตัวกรองชนิดสัญญาณ"}),e.jsxs("p",{className:"mb-3 text-xs text-slate-500",children:["ติ๊กเพื่อส่ง",e.jsx("span",{className:"text-slate-300",children:"เฉพาะ"}),"สัญญาณที่ผ่านการยืนยันนั้น (ทุกสัญญาณมาจาก engine เดียว แต่กรองตามบทวิเคราะห์ที่อยู่ในสัญญาณ) — ไม่ติ๊ก = ส่งทุกสัญญาณ"]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",children:[e.jsx(de,{on:js,onChange:Ma}),e.jsx("span",{className:"text-sm text-slate-300",children:"Multi-Timeframe ตรงกัน"})]}),e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl border border-white/10 px-3.5 py-2.5",children:[e.jsx(de,{on:Ns,onChange:Aa}),e.jsx("span",{className:"text-sm text-slate-300",children:"มีโครงสร้าง SMC (OB/FVG/BOS)"})]}),e.jsxs("div",{className:`flex items-center gap-2.5 rounded-xl border px-3.5 py-2.5 ${wl?"border-amber-500/50":"border-white/10"}`,title:"ส่งเฉพาะสัญญาณที่มี candlestick pattern ทิศเดียวกับสัญญาณ — เลือกไทม์เฟรมด้านล่างได้",children:[e.jsx(de,{on:pt,onChange:ys}),e.jsx("span",{className:"text-sm text-slate-300",children:"มี Price Action pattern"})]})]}),pt&&e.jsx("div",{className:"mt-3",children:e.jsx(tn,{tfs:Lt,onTfs:ws,pattern:vs,onPattern:_s})}),wl&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-xl border border-amber-500/40 bg-amber-500/10 px-3.5 py-2.5",children:[e.jsx("span",{"aria-hidden":!0,
11className:"text-amber-400",children:"⚠️"}),e.jsxs("div",{className:"text-xs leading-relaxed text-amber-200/90",children:[e.jsx("span",{className:"font-medium text-amber-300",children:"ตัวกรอง “มี Price Action pattern” จะบล็อกสัญญาณเกือบทั้งหมดสำหรับพอร์ตนี้"})," — ระบบตรวจ candlestick pattern ให้เฉพาะคริปโตเป็นหลัก (แทบ 0% สำหรับทอง/forex/indices) แนะนำ",e.jsx("button",{type:"button",onClick:()=>ys(!1),className:"mx-1 rounded-md border border-amber-400/50 px-2 py-0.5 font-medium text-amber-200 hover:bg-amber-500/20",children:"ปิดตัวกรองนี้"}),"หรือเพิ่มคริปโตในพอร์ต"]})]})]})]}),vl]}),c==="history"&&(()=>{const s=Math.max(1,Math.ceil(Ve.length/15)),l=Math.min(Math.max(pn,1),s),m=Ve.slice((l-1)*15,l*15),E=[];if(s<=7)for(let _=1;_<=s;_+=1)E.push(_);else{E.push(1);const _=Math.max(2,l-1),I=Math.min(s-1,l+1);_>2&&E.push("…");for(let P=_;P<=I;P+=1)E.push(P);I<s-1&&E.push("…"),E.push(s)}return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:`relative ${q}`,children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[e.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-lg bg-cyan-500/15 text-xs text-cyan-400",children:"3"})," ประวัติการส่งล่าสุด"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Ve.length>0&&e.jsxs("span",{className:"text-xs text-slate-500",children:[Ve.length," รายการ · หน้า ",l,"/",s]}),e.jsxs(yr,{figure:e.jsx(wr,{}),title:'คอลัมน์ "สภาวะคล้าย" คืออะไร',children:[e.jsxs("p",{children:["ตอนที่สัญญาณถูกส่ง ระบบจะย้อนดูสัญญาณเก่าของคู่เดียวกันที่ ",e.jsx("span",{className:"text-gray-100",children:"สภาพตลาดใกล้เคียงกัน"})," แล้วนับว่าตอนนั้นชนะกี่ครั้ง"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-400",children:"ตัวเลข %"})," = อัตราชนะของสภาวะคล้ายในอดีต · ",e.jsx("span",{className:"text-gray-400",children:"n"})," = นับจากกี่ครั้ง (ต่ำกว่า 5 ครั้งจะไม่แสดง)"]}),e.jsxs("p",{children:["กดที่แถบเพื่อดูว่าคล้ายกับสัญญาณของ ",e.jsx("span",{className:"text-gray-100",children:"วันไหนบ้าง"})," และตอนนั้นผลออกมาอย่างไร"]}),e.jsx("p",{className:"text-gray-500",children:'เป็นสถิติย้อนหลัง ไม่ใช่คำทำนาย — และไม่ได้ถูกใช้กรองว่าจะส่งสัญญาณไหน สัญญาณเก่ากว่าระบบนี้จะขึ้นเป็น "—"'})]})]})]}),Ve.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"ยังไม่มีการส่ง"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-slate-500",children:[e.jsx("th",{className:"py-1.5",children:"เวลา"}),e.jsx("th",{children:"สินทรัพย์"}),e.jsx("th",{children:"ทิศทาง"}),e.jsx("th",{children:"Conf"}),e.jsx("th",{children:"สภาวะคล้าย"}),e.jsx("th",{children:"ผล"})]})}),e.jsx("tbody",{children:m.map((_,I)=>{const P=new Date(_.created_at).toLocaleString("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be}),S=(_.outcome||"PENDING").toUpperCase(),ye=S==="WIN"?"text-emerald-400":S==="LOSS"?"text-rose-400":"text-slate-400",ue=S==="WIN"?`WIN${_.profit_percent!=null?` +${Number(_.profit_percent).toFixed(1)}%`:""}`:S==="LOSS"?`LOSS${_.profit_percent!=null?` ${Number(_.profit_percent).toFixed(1)}%`:""}`:S==="UNSUPPORTED"?"ไม่มีผลออโต้":S==="EXPIRED"?"หมดเวลา":"รอผล",se=_.similar_trades,we=se&&se.n>=5?Math.round(se.win_rate*100):null,Ce=we!=null&&Array.isArray(se==null?void 0:se.top)&&se.top.length>0,Qe=hn===I;return e.jsxs(i.Fragment,{children:[e.jsxs("tr",{className:"border-t border-white/5",children:[e.jsx("td",{className:"py-2.5 text-slate-400",children:P}),e.jsx("td",{className:"font-medium",children:_.asset}),e.jsx("td",{className:_.direction==="BUY"?"text-emerald-400":"text-rose-400",children:_.direction==="BUY"?"LONG":"SHORT"}),e.jsxs("td",{className:"text-slate-300",children:[Math.round(Number(_.confidence)),"%"]}),e.jsx("td",{children:we==null?e.jsx("span",{className:"text-slate-600",children:"—"}):e.jsxs("button",{type:"button",onClick:()=>
11Ce&&vt(Qe?null:I),className:`inline-flex items-center gap-1.5 ${Ce?"cursor-pointer":"cursor-default"}`,title:`ณ ตอนส่งสัญญาณ ระบบพบสภาวะตลาดคล้ายกัน ${se.n} ครั้งในอดีต ชนะ ${we}% (P/L เฉลี่ย ${se.avg_pnl>=0?"+":""}${se.avg_pnl}%) — สถิติย้อนหลัง ไม่ใช่คำทำนาย${Ce?" · กดเพื่อดูว่าคล้ายวันไหน":""}`,children:[e.jsx("span",{className:"h-1.5 w-10 overflow-hidden rounded-full bg-white/10",children:e.jsx("span",{className:`block h-full rounded-full ${we>=55?"bg-emerald-400":we>=45?"bg-amber-400":"bg-rose-400"}`,style:{width:`${we}%`}})}),e.jsxs("span",{className:`text-xs ${we>=55?"text-emerald-300":we>=45?"text-amber-300":"text-rose-300"}`,children:[we,"%"]}),e.jsxs("span",{className:"text-[10px] text-slate-500",children:["n=",se.n]}),Ce&&e.jsx("span",{className:"text-[10px] text-cyan-400",children:Qe?"▴":"▾"})]})}),e.jsx("td",{className:ye,children:ue})]}),Qe&&Ce&&e.jsx("tr",{className:"border-t border-white/5 bg-white/[0.02]",children:e.jsxs("td",{colSpan:6,className:"px-3 py-2.5",children:[e.jsxs("p",{className:"mb-1.5 text-[11px] text-slate-400",children:["สัญญาณในอดีตที่สภาพตลาดคล้ายที่สุด (",se.n," ครั้งที่นับรวมในสถิติ · โชว์ 5 อันดับแรก):"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:se.top.map((H,gt)=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-lg border px-2 py-1 text-[11px] ${H.outcome==="win"?"border-emerald-500/25 bg-emerald-500/10 text-emerald-300":"border-rose-500/25 bg-rose-500/10 text-rose-300"}`,children:[e.jsx("span",{className:"text-slate-400",children:H.day}),H.dir&&e.jsx("span",{children:H.dir==="BUY"?"LONG":"SHORT"}),e.jsx("span",{className:"font-medium",children:H.outcome==="win"?"WIN":"LOSS"}),e.jsxs("span",{children:[H.pnl>=0?"+":"",Number(H.pnl).toFixed(2),"%"]}),e.jsxs("span",{className:"text-slate-500",children:["คล้าย ",Math.round(H.sim*100),"%"]})]},gt))}),e.jsx("p",{className:"mt-1.5 text-[10px] text-slate-500",children:'"คล้าย" วัดจากอินดิเคเตอร์+โครงสร้างตลาด ณ ตอนส่ง (vector similarity) — สถิติย้อนหลัง ไม่ใช่คำทำนาย'})]})})]},`${_.created_at}-${_.asset}-${I}`)})})]})}),s>1&&e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-1.5",children:[e.jsx("button",{onClick:()=>{rs(l-1),vt(null)},disabled:l<=1,className:"rounded-lg border border-white/10 px-2.5 py-1.5 text-xs text-slate-300 transition hover:bg-white/5 disabled:opacity-40",children:"ก่อนหน้า"}),E.map((_,I)=>_==="…"?e.jsx("span",{className:"px-1.5 text-xs text-slate-600",children:"…"},`ellipsis-${I}`):e.jsx("button",{onClick:()=>{rs(_),vt(null)},className:`min-w-[2rem] rounded-lg border px-2.5 py-1.5 text-xs transition ${_===l?"border-cyan-500 bg-cyan-500/15 font-semibold text-cyan-300":"border-white/10 text-slate-300 hover:bg-white/5"}`,children:_},_)),e.jsx("button",{onClick:()=>{rs(l+1),vt(null)},disabled:l>=s,className:"rounded-lg border border-white/10 px-2.5 py-1.5 text-xs text-slate-300 transition hover:bg-white/5 disabled:opacity-40",children:"ถัดไป"})]})]})]}),e.jsx("p",{className:"pt-2 text-center text-xs text-slate-600",children:"* Forex / Silver / Indices / Stocks ส่งสัญญาณได้ แต่ไม่มีรายงานผล Win/Loss อัตโนมัติ"}),e.jsx("p",{className:"text-center text-xs text-slate-600",children:'"สภาวะคล้าย" = win-rate ของสัญญาณในอดีตที่สภาพตลาดคล้ายกัน ณ ตอนส่ง (คำนวณด้วย vector similarity) — เป็นสถิติย้อนหลัง ไม่ใช่คำทำนาย · มีเฉพาะสัญญาณช่วงหลัง'})]})})(),c==="constellation"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("details",{open:!0,className:`${q} group`,children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 text-base font-semibold [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:"📖 Signal Constellation คืออะไร — อ่านแผนที่นี้ยังไง"}),e.jsx("span",{className:"ml-auto text-xs font-normal text-cyan-300/70 group-open:hidden",children:"แตะเพื่อดู ▾"}),e.jsx("span",{className:"ml-auto hidden text-xs font-normal text-slate-500 group-open:inline",children:"ซ่อน ▴"})]}),e.jsxs("div",{className:"mt-4 grid gap-5 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-sm font-semibold text-cyan-300",children:"นี่คืออะไร?"}),e.jsxs("p",{className:"text-xs leading-relaxed text-slate-400",children:["แผนที่ 3 มิติของสัญญาณ AI จริง ",e.jsx("b",{className:"text-slate-200",children:"ทุกตัวในอดีต"})," — แต่ละจุดคือ 1 สัญญาณ วางตำแหน่งตาม “สภาพตลาดตอนออกสัญญาณ” สัญญาณที่บริบทคล้ายกันจะอยู่ใกล้กัน ช่วยให้เห็นภาพว่า setup แบบไหน AI ",e.jsx("b",{className:"text-amber-300",children:"ชนะ"})," หรือ ",e.jsx("b",{className:"text-emerald-300",children:"แพ้"})," บ่อย"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-sm font-semibold text-cyan-300",children:"ความหมายของแต่ละอย่าง"}),e.jsxs("ul",{className:"space-y-1.5 text-xs text-slate-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1 inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{background:"#FACC15"}}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"à¸
11ˆà¸¸à¸”ทอง = ชนะ"})," · ลอยอยู่ด้านบน (ยิ่งกำไรมากยิ่งสูง)"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1 inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{background:"#34D399"}}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"จุดเขียว = แพ้"})," · จมอยู่ด้านล่าง (ยิ่งขาดทุนยิ่งลึก)"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1 inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{background:"#94A3B8"}}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"จุดเทา = รอผล"})," · ยังไม่ปิดสัญญาณ"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1 inline-block h-0.5 w-3 shrink-0 rounded bg-cyan-300/70"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"เส้นเชื่อม"})," = สัญญาณที่สภาพตลาดคล้ายกัน"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-0.5 shrink-0",children:"🌫️"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"หมอกฟุ้ง"})," = ตลาดผันผวนสูง (ไม่แน่นอน)"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-0.5 shrink-0",children:"🔢"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-slate-200",children:"ตัวเลขลอย"})," = % กำไร/ขาดทุนของสัญญาณนั้น"]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-sm font-semibold text-cyan-300",children:"วิธีใช้"}),e.jsxs("ul",{className:"space-y-1.5 text-xs text-slate-400",children:[e.jsxs("li",{children:["• เลือก ",e.jsx("b",{className:"text-slate-200",children:"“สินทรัพย์ที่เทรด”"})," ด้านบนเพื่อโฟกัสรายคู่ หรือ “ทั้งหมด”"]}),e.jsxs("li",{children:["• ปุ่ม ",e.jsx("b",{className:"text-slate-200",children:"หมุนรอบ"})," / ",e.jsx("b",{className:"text-slate-200",children:"เดินทะลุ"})," สลับมุมกล้อง"]}),e.jsxs("li",{children:["• ",e.jsx("b",{className:"text-slate-200",children:"ลากเมาส์"})," = หมุน · ",e.jsx("b",{className:"text-slate-200",children:"scroll"})," = ซูม"]}),e.jsxs("li",{children:["• ",e.jsx("b",{className:"text-slate-200",children:"Links / Labels"})," เปิด-ปิดเส้นเชื่อม/ตัวเลข"]})]})]})]}),e.jsxs("p",{className:"mt-4 rounded-lg border border-cyan-500/15 bg-cyan-500/[0.05] px-3 py-2 text-xs leading-relaxed text-slate-300",children:["💡 ",e.jsx("b",{className:"text-cyan-200",children:"เคล็ดลับ:"})," ถ้าเห็น",e.jsx("b",{className:"text-amber-300",children:" กระจุกจุดทอง"}),"หนาแน่น = setup ที่ AI ทำได้ดีในอดีต · โซนที่ ",e.jsx("b",{children:"หมอกหนา"})," = ตลาดผันผวน ระวังสัญญาณหลอก · ตัวเลขในวงเล็บข้างชื่อคู่ = จำนวนสัญญาณของคู่นั้น"]})]}),e.jsx(li,{height:640})]}),c==="academy"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("section",{className:q,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"grid h-10 w-10 flex-none place-items-center rounded-xl bg-cyan-500/15 text-xl text-cyan-300",children:"🎓"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"ห้องเรียน Academy พร้อมเสิร์ฟให้สมาชิกของคุณ"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"สมาชิกทุกคนเข้าเรียนได้ที่หน้า Ac
11ademy — คอร์สพื้นฐานเปิดให้เรียน บทลึกปลดด้วยเครดิต/VIP"}),e.jsx("a",{href:"/academy",target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm font-semibold text-cyan-400 hover:text-cyan-300",children:"เปิดหน้า Academy ↗"})]})]})}),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-base font-semibold",children:"📡 ส่งบทเรียนเข้ากลุ่มอัตโนมัติ (Drip)"}),v&&(v.academy_unlimited?e.jsx("span",{className:"rounded-full bg-emerald-500/14 px-2.5 py-0.5 text-[11px] text-emerald-300",children:"ไม่จำกัด"}):v.academy_paid?e.jsxs("span",{className:"rounded-full bg-emerald-500/14 px-2.5 py-0.5 text-[11px] text-emerald-300",children:["ใช้งานได้",v.academy_expires_at?` · หมดอายุ ${new Date(v.academy_expires_at).toLocaleDateString("th-TH",{day:"2-digit",month:"short"})}`:""]}):e.jsx("span",{className:"rounded-full bg-amber-500/14 px-2.5 py-0.5 text-[11px] text-amber-300",children:"ยังไม่ปลดล็อก"}))]}),e.jsx("p",{className:"text-sm text-slate-400",children:"เลือกคอร์ส แล้วระบบจะทยอยส่งบทเรียน (หัวข้อ + ลิงก์อ่านเต็ม) เข้ากลุ่ม Telegram/Discord ของคุณตามรอบเวลา"}),v?v.academy_paid?e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:!!v.drip_enabled,onChange:t=>Rn(t.target.checked),disabled:F}),"เปิดส่งอัตโนมัติ"]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-slate-400",children:"คอร์สที่จะส่ง"}),e.jsxs("select",{value:v.drip_course||"",onChange:t=>rl({course:t.target.value}),className:"w-full max-w-xs rounded-lg border border-white/10 bg-white/[0.03] px-3 py-2 text-sm text-slate-200",children:[e.jsx("option",{value:"",children:"— เลือกคอร์ส —"}),(v.courses||[]).map(t=>e.jsxs("option",{value:t.slug,className:"bg-slate-900",children:[t.title," (",t.lessons," บท)"]},t.slug))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-slate-400",children:"รอบการส่ง"}),e.jsx("select",{value:v.drip_interval_hours||24,onChange:t=>rl({interval:Number(t.target.value)}),className:"w-full max-w-xs rounded-lg border border-white/10 bg-white/[0.03] px-3 py-2 text-sm text-slate-200",children:[6,12,24,48,72,168].map(t=>e.jsx("option",{value:t,className:"bg-slate-900",children:t===168?"ทุก 7 วัน":t===24?"ทุกวัน":`ทุก ${t} ชม.`},t))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-white/[0.06] pt-3",children:[e.jsx("button",{onClick:Fn,disabled:T||!v.drip_course,className:"inline-flex items-center gap-2 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-cyan-50 transition hover:bg-cyan-500 disabled:opacity-60",children:T?"กำลังส่ง…":"ส่งบทเรียนตอนนี้"}),e.jsxs("span",{className:"text-xs text-slate-500",children:["ปลายทาง: ",v.has_telegram?"Telegram":"—",v.has_discord?" · Discord":""]})]})]}):e.jsx("div",{className:"mt-3",children:e.jsx("button",{onClick:Tn,disabled:F,className:"inline-flex items-center gap-2 rounded-lg bg-amber-500 px-4 py-2 text-sm font-semibold text-amber-950 transition hover:bg-amber-400 disabled:opacity-60",children:"ปลดล็อก Drip — 50 เครดิต / 30 วัน"})}):e.jsx("p",{className:"mt-3 text-sm text-slate-500",children:"กำลังโหลด…"}),R&&e.jsx("p",{className:"mt-3 text-sm font-medium text-cyan-300",children:R})]})]}),c==="leaderboard"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-base font-semibold",children:"🥇 อันดับผู้ใช้ Signal Control (Net %)"}),e.jsx("div",{className:"flex gap-0.5 rounded-lg border border-white/10 p-0.5",children:sn.map(t=>e.jsx("button",{onClick:()=>W(t.v),className:`rounded-md px-2.5 py-1 text-xs transition ${L===t.v?"bg-cyan-500/15 text-cyan-300":"text-slate-400 hover:text-slate-200"}`,children:t.l},t.v))})]}),e.jsxs("p",{className:"mb-4 text-[11px] leading-relaxed text-slate-500",children:["เทียบ",e.jsx("b",{className:"text-slate-300",children:" กำไรสะสมจริง"}),"ของผู้ใช้ทุกคน (จากไม้ที่ AI ส่งเข้ากลุ่มจริง) · ใช้นามแฝงเพื่อความเป็นส่วนตัว ·",e.jsx("span",{className:"text-emerald-300/90",children:" แถวของคุณไฮไลต์สีเขียว + ป้าย “คุณ”"})," ·",e.jsx("b",{className:"text-slate-300",children:" ดู “สูตรâ€
11 ใต้ชื่อแต่ละคน"})," (ช่องทางที่ส่ง · คู่ · ความมั่นใจ · ความเสี่ยง · ความถี่ · ตัวกรอง) ·",e.jsx("span",{className:"text-cyan-300/90",children:" กด “📋 ก็อปสูตรนี้” เพื่อตั้งค่าตามคนนั้นทันที"})," · แสดงเฉพาะผู้ใช้ที่มี ≥ 20 ไม้ปิดผล"]}),Z&&!O?e.jsx("p",{className:"text-xs text-slate-500",children:"กำลังโหลด…"}):(Tl=O==null?void 0:O.channels)!=null&&Tl.length?(()=>{const t=O.channels,s=Math.max(...t.map(l=>Math.abs(Number(l.net_pct))),1);return e.jsx("div",{className:"space-y-2.5",children:t.map(l=>{const m=Number(l.net_pct)>=0,E=Math.min(1,Math.abs(Number(l.net_pct))/s),_=l.rank===1?"border-amber-400/40 bg-amber-400/20 text-amber-300":l.rank===2?"border-slate-300/30 bg-slate-300/15 text-slate-200":l.rank===3?"border-orange-400/30 bg-orange-400/15 text-orange-300":"border-white/10 bg-white/5 text-slate-400";return e.jsxs("div",{className:`rounded-xl px-2 py-1.5 ${l.is_you?"bg-emerald-500/10 ring-1 ring-emerald-500/40":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-xs",children:[e.jsx("span",{className:`grid h-6 w-6 shrink-0 place-items-center rounded-lg border text-[11px] font-bold ${_}`,children:l.rank}),e.jsx("div",{className:"w-24 shrink-0 sm:w-28",children:e.jsxs("span",{className:"block truncate font-medium text-slate-200",children:[l.name,l.is_you&&e.jsx("span",{className:"ml-1 rounded bg-emerald-500/20 px-1 py-0.5 text-[9px] font-semibold text-emerald-300",children:"คุณ"})]})}),e.jsxs("div",{className:"relative h-2.5 flex-1",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-white/[0.04]"}),e.jsx("div",{className:"absolute left-1/2 top-0 h-full w-px bg-white/15"}),e.jsx("div",{className:"absolute top-0 h-full rounded-full",style:m?{left:"50%",width:`${E*50}%`,background:"#34d399"}:{right:"50%",width:`${E*50}%`,background:"#f87171"}})]}),e.jsxs("span",{className:"w-14 shrink-0 text-right font-semibold",style:{color:m?"#34d399":"#f87171"},children:[Number(l.net_pct)>0?"+":"",l.net_pct,"%"]}),e.jsxs("span",{className:"hidden w-20 shrink-0 text-right text-slate-400 sm:block",children:[l.win,"-",l.loss,l.win_rate!=null?` · ${l.win_rate}%`:""]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 pl-8",children:[l.cfg&&e.jsx(Vs,{cfg:l.cfg,platforms:l.platforms}),l.pid&&e.jsx("button",{onClick:()=>G({pid:l.pid,name:l.name,net_pct:Number(l.net_pct),win:Number(l.win),loss:Number(l.loss),win_rate:l.win_rate==null?0:Number(l.win_rate),rank:Number(l.rank),cfg:l.cfg,platforms:l.platforms}),className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-300 transition hover:bg-amber-500/20",children:"📊 สถิติเชิงลึก"}),!l.is_you&&l.pid&&e.jsx("button",{onClick:()=>{ae(null),Le(l)},className:"rounded-md border border-cyan-500/40 bg-cyan-500/10 px-1.5 py-0.5 text-[10px] font-medium text-cyan-300 transition hover:bg-cyan-500/20",children:"📋 ก็อปสูตรนี้"})]})]},l.rank)})})})():e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีข้อมูลพอในช่วงเวลานี้"}),re&&e.jsx("p",{className:`mt-3 text-xs ${re.startsWith("✅")?"text-emerald-400":"text-rose-400"}`,children:re}),e.jsxs("p",{className:"mt-3 text-[10px] text-slate-600",children:[O!=null&&O.generated_at?`อัปเดตล่าสุด ${new Date(O.generated_at).toLocaleString("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be})} · `:"","Net % = ผลรวมกำไร/ขาดทุนจริงของไม้ที่ปิดผล (ชนะ+แพ้) ที่ส่งเข้ากลุ่มของผู้ใช้แต่ละคน · ผลย้อนหลังไม่การันตีผลอนาคต"]})]}),e.jsxs("section",{className:q,children:[e.jsx("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:e.jsx("h2",{className:"text-base font-semibold",children:"🏆 อันดับคู่ทำกำไร (Net %)"})}),e.jsxs("p",{className:"mb-4 text-[11px] leading-relaxed text-slate-500",children:["จัดอันดับจาก",e.jsx("b",{className:"text-slate-300",children:" สัญญาณ AI ทั้งหมด"})," (รวมทุก channel — ไม่ใช่เฉพาะที่คุณติ๊ก) ·",e.jsx("span",{className:"text-emerald-300/90",children:" Net % = กำไรสะสมถ้ารันทุกไม้ที่ปิดผลแล้ว"})," · เรียงมาก→น้อย ·",e.jsx("span",{className:"text-amber-300/90",children:" ปิด X%"})," = คู่ที่ยังปิดผลไม่ครบ ตัวเลขอาจยังไม่นิ่ง · ใช้เป็นไกด์เลือกติ๊กส่ง (บนสุด = AI ทำได้ดี · ล่างสุด = ควรเลี่ยง)"]}),ee&&!g?e.jsx("p",{className:"text-xs text-slate-500",children:"กำลังโหลด…"}):(Rl=g==null?void 0:g.assets)!=null&&Rl.length?(()=>{const t=g.assets,s=Math.max(...t.map(l=>Math.abs(Number(l.net_pct))),1);return e.jsx("div",{className:"space-y-2.5",children:t.map((l,m)=>e.jsx(vi,{rank:m+1,label:l.asset,sub:ve(l.asset),net:Number(l.net_pct),win:l.win,loss:l.loss,closed:l.closed,coverage:Number(l.coverage),maxAbs:s},l.asset))})})():e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีข้อมูลพอในช่วงเวลานี้"}),e.jsxs("p",{className:"mt-3 text-[10px] text-slate-600",children:[g!=null&&g.generated_at?`อัปเดตล่าสุด ${new Date(g.generated_at).toLocaleStr
11ing("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be})} · `:"","คู่ที่มีไม้ปิดผลน้อยกว่า 10 ไม้จะไม่แสดง · ผลย้อนหลังไม่การันตีผลอนาคต"]})]}),ne&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>!te&&Le(null),children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[#0e1420] p-5",onClick:t=>t.stopPropagation(),children:[e.jsxs("h3",{className:"text-base font-semibold",children:["📋 ใช้สูตรของ ",ne.name]}),e.jsxs("p",{className:"mt-1 text-xs text-slate-400",children:["Net ",Number(ne.net_pct)>0?"+":"",ne.net_pct,"% · ",ne.win,"-",ne.loss," ไม้ (",ne.win_rate,"%) ในช่วง ",(Fl=sn.find(t=>t.v===L))==null?void 0:Fl.l]}),e.jsx("p",{className:"mt-4 text-[11px] text-slate-500",children:"สูตรใหม่ที่จะใช้"}),e.jsx("div",{className:"mt-1 rounded-xl border border-cyan-500/25 bg-cyan-500/[0.06] p-2.5",children:e.jsx(Vs,{cfg:{...ne.cfg,tz:null}})}),e.jsx("p",{className:"mt-3 text-[11px] text-slate-500",children:"สูตรเดิมของคุณ (จะถูกทับ)"}),e.jsx("div",{className:"mt-1 rounded-xl border border-white/10 bg-white/[0.02] p-2.5 opacity-70",children:e.jsx(Vs,{cfg:{pairs:me,conf:xt,risk:mt,interval_min:Xe,mtf:js,smc:Ns,pa:pt}})}),e.jsxs("p",{className:"mt-4 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-2 text-[11px] leading-relaxed text-slate-400",children:["ก็อปเฉพาะ",e.jsx("b",{className:"text-slate-300",children:" คู่เงิน · ความมั่นใจ · ความเสี่ยง · ความถี่ · ตัวกรอง"})," เท่านั้น · บอท/กลุ่ม/Discord webhook และเขตเวลาของคุณ",e.jsx("b",{className:"text-slate-300",children:" ไม่ถูกแตะ"})," · บันทึกทันทีเมื่อกดยืนยัน · ",e.jsx("span",{className:"text-amber-300/90",children:"ผลย้อนหลังไม่การันตีผลอนาคต"})]}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>Le(null),disabled:te,className:"rounded-xl border border-white/10 px-3.5 py-2 text-sm text-slate-300 hover:bg-white/5 disabled:opacity-50",children:"ยกเลิก"}),e.jsx("button",{onClick:()=>qn(ne),disabled:te,className:"rounded-xl border border-cyan-500/40 bg-cyan-500/15 px-3.5 py-2 text-sm font-medium text-cyan-300 hover:bg-cyan-500/25 disabled:opacity-50",children:te?"กำลังใช้สูตร…":"ยืนยันใช้สูตรนี้"})]})]})}),A&&e.jsx(vr,{summary:A,range:L,onClose:()=>G(null)})]}),c==="footprint"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{className:`${q} border !border-amber-500/25`,children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ql,{size:26}),e.jsx("h2",{className:"text-base font-semibold",children:"Footprint Lab"}),e.jsx("span",{className:"rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-xs font-bold text-amber-300",children:"Add-On ใหม่"}),(k==null?void 0:k.on)&&e.jsx("span",{className:"rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-300",children:"✅ เปิดรับอยู่"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-bold text-amber-300",children:[(k==null?void 0:k.cost)??50," เครดิต / 30 วัน"]}),(k==null?void 0:k.paid)&&!k.unlimited&&k.expiresAt&&e.jsxs("p",{className:"text-[11px] text-emerald-300",children:["ใช้ได้ถึง ",new Date(k.expiresAt).toLocaleDateString("th-TH",{day:"2-digit",month:"short",year:"numeric"})," · เหลือ ",Math.max(0,Math.ceil((new Date(k.expiresAt).getTime()-Date.now())/864e5))," วัน"]}),(k==null?void 0:k.unlimited)&&e.jsx("p",{className:"text-[11px] text-slate-500",children:"ช่องของแอดมิน · ไม่จำกัด"})]})]}),e.jsx("p",{className:"text-sm leading-relaxed text-slate-400",children:"สัญญาณ order flow จาก tape จริง — bid×ask footprint, CVD divergence, absorption, กำแพง orderbook พร้อมตรวจ spoof — คนละเอนจินกับสัญญาณหลัก ทุกไม้โชว์สถิติสดในข้อความ และมีสรุปผลรายวัน/รายสัปดาห์เข้าห้องอัตโนมัติ"}),e.jsx("p",{className:"mt-1.5 text-[11px] text-amber-300/80",children:"⚠️ Beta กำลังเก็บสถิติ — อย่าเทรดตามด้วยไซซ์จริงจนกว่าสถิติจะผ่านเกณฑ์ (เราà¹
11‚ชว์ผลจริงทุกไม้ ไม่มีตัดตอน)"}),k===null?e.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"กำลังโหลดสถานะ…"}):k.paid?k.on?e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11px]",children:[k.hasTg&&k.tgOn&&e.jsxs("span",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-emerald-300",children:["📨 Telegram · ",Wt.trim()?"กลุ่มแยก":"กลุ่มสัญญาณหลัก"]}),k.hasRoom&&k.dcOn&&e.jsx("span",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-emerald-300",children:"💬 เข้าห้อง Discord (Footprint Lab)"}),k.hasTg&&!k.tgOn&&e.jsx("span",{className:"rounded-md border border-slate-600/40 bg-white/5 px-2 py-1 text-slate-400",children:"⏸ Telegram ปิดอยู่"}),k.hasRoom&&!k.dcOn&&e.jsx("span",{className:"rounded-md border border-slate-600/40 bg-white/5 px-2 py-1 text-slate-400",children:"⏸ Discord ปิดอยู่"}),!k.hasTg&&!k.hasRoom&&e.jsx("span",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-amber-300",children:"⚠️ ยังไม่มีปลายทาง — เชื่อม Telegram ในแท็บ “ตั้งค่าบอท” หรือเพิ่มห้อง Discord แบบ 🧪 Footprint"}),(k.hasTg||k.hasRoom)&&!(k.hasTg&&k.tgOn)&&!(k.hasRoom&&k.dcOn)&&e.jsx("span",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-amber-300",children:"⚠️ ปิดทุกปลายทาง — เปิดรับอยู่แต่ไม่มีอะไรถูกส่งออก"})]}),e.jsx("button",{type:"button",onClick:()=>ll(!1),disabled:Se,className:"rounded-lg border border-white/10 px-3 py-1.5 text-xs text-slate-400 hover:bg-white/5 disabled:opacity-50",children:Se?"กำลังบันทึก…":"ปิดการรับ"})]}):e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("input",{className:oe,type:"text",autoComplete:"off",placeholder:"(ถ้าใช้ Discord) วาง Webhook ห้องที่จะรับ Footprint — เว้นว่างได้ถ้ารับทาง Telegram",value:Qa,onChange:t=>el(t.target.value)}),e.jsx("button",{type:"button",onClick:()=>ll(!0),disabled:Se||!k.vipActive,className:"rounded-xl bg-amber-500/90 px-4 py-2 text-sm font-semibold text-slate-950 hover:bg-amber-400 disabled:opacity-50",children:Se?"กำลังเปิด…":"🧪 เปิดรับสัญญาณ"}),e.jsx("p",{className:"text-[11px] text-emerald-300/80",children:"✅ จ่ายแล้วในรอบนี้ — เปิดกลับไม่เสียเครดิตเพิ่ม"}),!k.vipActive&&e.jsx("p",{className:"text-[11px] text-rose-300",children:"⛔ VIP หมดอายุ — ต่ออายุก่อนเปิดใช้ Add-On"})]}):e.jsxs("div",{className:"mt-3 space-y-2",children:[k.on&&e.jsx("p",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-[11px] text-amber-200",children:"⏳ สิทธิ์ Add-On หมดอายุแล้ว — ระบบหยุดส่งสัญญาณ Footprint แต่ตั้งค่าทั้งหมดของคุณยังอยู่ครบ ต่ออายุแล้วส่งต่อทันที"}),d.balance<(k.cost??50)?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:"/?buy=credits",className:"inline-block rounded-xl bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500",children:["เติมเครดิต (มี ",d.balance," · ต้องใช้ ",k.cost,")"]}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"เครดิตไม่พอสำหรับเปิดใช้งาน Add-On นี้"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:Mn,disabled:Se||!k.vipActive,className:"rounded-xl bg-amber-500/90 px-4 py-2 text-sm font-semibold text-slate-950 hover:bg-amber-400 disabled:opacity-50",children:Se?"กำลังดำเนินการ…":`🧪 ${k.on?"ต่ออายุ":"เปิดใช้งาน"} · หัก ${k.cost} เครดิต (30 วัน)`}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["เครดิตคงเหลือ ",d.balance," · หักครั้งเดียว ใช้ได้ 30 วัน ต่ออายุก่อนหมดจะบวกวันสะสมให้"]})]}),!k.vipActive&&e.jsx("p",{className:"text-[11px] text-rose-300",children:"⛔ VIP หมดอายุ — ต่ออายุ VIP ก่อนเปิดใช้ Add-On"})]}),Ja&&e.jsx("p",{className:"mt-2 rounded-lg bg-black/30 px-3 py-2 text-xs text-slate-200",children:Ja})]}),(k==null?void 0:k.on)&&e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-1 flex items-center gap-2 text-base font-semibold",children:"📨 ปลายทางที่จะส่ง"}),e.jsx("p",{className:"mb-4 text-xs text-slate-500",children:"Footprint ส่งได้ทั้ง Telegram และ Discord — เลือกอย่างใดอย่างหนึ่งหรือทั้งคู่ก็ได้"}),(()=>{const t=({on:s,disabled:l,onChange:m})=>e.jsx("button",{type:"button",role:"switch","aria-checked":s,disabled:l,onClick:()=>m(!s),className:`relative h-5 w-9 shrink-0 rounded-full transition disabled:opacity-40 ${s?"bg-emerald-500/80":"bg-slate-600/60"}`,children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 roun
11ded-full bg-white transition-all ${s?"left-[1.15rem]":"left-0.5"}`})});return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-xl border p-3 transition ${k.hasTg&&k.tgOn?"border-emerald-500/25 bg-emerald-500/[0.03]":"border-white/10 bg-slate-950/40"}`,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"📨 Telegram"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[11px] ${k.tgOn?"text-emerald-300":"text-slate-500"}`,children:k.tgOn?"เปิดส่ง":"ปิดอยู่"}),e.jsx(t,{on:k.tgOn,disabled:!(h!=null&&h.has_bot)||Se,onChange:s=>nl("tg",s)})]})]}),h!=null&&h.has_bot?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mb-2 text-[11px] leading-relaxed text-slate-500",children:["เว้นว่าง = ส่งเข้ากลุ่มสัญญาณหลัก",k.mainChat?` (${k.mainChat})`:""," · ใส่ chat_id เพื่อแยกกลุ่ม Footprint ออกมา (บอทต้องเป็นแอดมินในกลุ่มนั้น)"]}),e.jsx("input",{className:oe,type:"text",autoComplete:"off",placeholder:"chat_id ของกลุ่ม Footprint เช่น -1001234567890",value:Wt,onChange:s=>Za(s.target.value)}),e.jsx("button",{type:"button",onClick:Dn,disabled:Rs,className:"mt-2 rounded-lg border border-white/10 px-3 py-1.5 text-xs text-slate-300 hover:bg-white/5 disabled:opacity-50",children:Rs?"กำลังบันทึก…":Wt.trim()?"บันทึกกลุ่มแยก":"ใช้กลุ่มหลัก"})]}):e.jsx("p",{className:"text-xs text-amber-300/80",children:"ยังไม่ได้เชื่อมบอท — ไปที่แท็บ “ตั้งค่าบอท” ก่อน"})]}),e.jsxs("div",{className:`rounded-xl border p-3 transition ${k.hasRoom&&k.dcOn?"border-emerald-500/25 bg-emerald-500/[0.03]":"border-white/10 bg-slate-950/40"}`,children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"💬 Discord"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[11px] ${k.dcOn?"text-emerald-300":"text-slate-500"}`,children:k.dcOn?"เปิดส่ง":"ปิดอยู่"}),e.jsx(t,{on:k.dcOn,disabled:!k.hasRoom||Se,onChange:s=>nl("dc",s)})]})]}),k.hasRoom?e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-500",children:"ปิดสวิตช์ = หยุดส่งชั่วคราว แต่ webhook ยังถูกเก็บไว้ · แก้ webhook ได้ที่แท็บ “ตั้งค่าบอท” → Discord"}):e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-500",children:"ยังไม่มีห้อง — เพิ่มห้องแบบ 🧪 Footprint ที่แท็บ “ตั้งค่าบอท” → Discord"})]})]})})()]}),(k==null?void 0:k.on)&&e.jsxs("section",{className:q,children:[e.jsx("h2",{className:"mb-1 flex items-center gap-2 text-base font-semibold",children:"📊 สินทรัพย์ที่จะรับ"}),e.jsx("p",{className:"mb-4 text-xs text-slate-500",children:"ไม่เลือกเลย = รับทุกคู่ที่รองรับ · สัญญาณและสรุปผลรายวันจะนับเฉพาะคู่ที่คุณเลือก"}),oi.map(t=>{const s=k.supported||[],l=t.symbols.filter(_=>s.includes(_)),m=l.length>0,E=m&&l.every(_=>it.includes(_));return e.jsxs("div",{className:`mb-3 rounded-xl border p-3 ${m?"border-white/10 bg-slate-950/40":"border-white/[0.06] bg-white/[0.01]"}`,children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-slate-200",children:[t.icon," ",t.group]}),m?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] text-emerald-300",children:["พร้อมใช้งาน · ",l.length," คู่"]}),e.jsx("button",{type:"button",onClick:()=>Ts(_=>E?_.filter(I=>!l.includes(I)):[...new Set([..._,...l])]),className:"ml-auto rounded-lg border border-white/10 px-2.5 py-1 text-[11px] text-slate-300 hover:bg-white/5",children:E?"เอาออกทั้งหมด":"เลือกทั้งหมด"})]}):e.jsx("span",{className:"rounded-full border border-slate-600/40 bg-white/5 px-2 py-0.5 text-[10px] text-slate-400",children:"เร็วๆ นี้"})]}),t.note&&e.jsxs("p",{className:"mb-2 text-[10px] leading-relaxed text-amber-300/70",children:["📍 ",t.note]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.symbols.map(_=>{const I=s.includes(_);return e.jsxs("button",{type:"button",disabled:!I,onClick:()=>Ln(_),title:I?ve(_):"ยังไม่รองรับ",className:`rounded-md border px-2 py-1 text-[11px] transition ${I?it.includes(_)?"border-amber-500 bg-amber-500/10 text-amber-300":"border-white/10 text-slate-400 hover:bg-white/5":"cursor-not-allowed border-white/[0.06] text-slate-600 line-through"}`,children:[_,ve(_)&&e.jsxs("span",{className:"ml-1 opacity-60",children:["· ",ve(_)]})]},_)})})]},t.group)}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",onClick:An,disabled:Es,className:"rounded-xl bg-cyan-600 px-4 py-2 text-sm font-semibold text-white hover:bg-cyan-500 disabled:opacity-50",children:Es?"กำลังบันทึก…":"บันทึกสินทรัพย์"}),e.jsx("span",{className:"text-xs text-slate-500",children:it.length===0?"ตอนนี้: รับทุกคู่ที่รองรับ":`ตอนนี้: รับ ${it.length} คู่`})]})]}),(()=>{const t=Q==null?void 0:Q.overall,s=S=>S==null?null:Number(S),l=S=>S==null?"—":`${Number(S)>=0?"+":""}${Number(S).toFixed(2)}R`,m=S=>S==null?"text-slate-300":Number(S)>=0?"text-emerald-300":"text-rose-300";s(t==null?void 0:t.net_r);const E=s(t==null?void 0:t.win_rate),_=s(t==null?void 0:t.avg_win_r),I=s(t==null?void 0:t.avg_loss_r),P=_&&I?Math.abs(I)/(_+Math.abs(I))*100:null;return e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"flex items-center gap-2 text-base font-semibold",children:"📈 สถิติละเอียด · กำไร-ขาดทุน"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[it.length>0&&["lab","mine"].map(S=>e.jsx("button",{onClick:()=>kn(S),className:`rounded-lg px-2.5 py-1 text-xs ${Gt===S?"bg-cyan-500/15 text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:S==="lab"?"ทั้ง Lab":"เฉพาะคู่ของฉัน"},S)),e.jsx("span",{className:"mx-1 h-4 w-px bg-white/10"}),["7d","30d","all"].map(S=>e.jsx("button",{onClick:()=>_n(S),className:`rounded-lg px-2.5 py-1 text-xs ${qt===S?"bg-cyan-500/15 text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:S==="7d"?"7 วัน":S==="30d"?"30 วัน":"ทั้งหมด"},S))]})]}),zt&&!Q?e.jsx("p",{className:"py-6 text-center text-xs text-slate-500",children:"กำลังโหลดสถิติ…"}):!t||!Number(t.trades)?e.jsx("p",{className:"py-6 text-center text-xs text-slate-500",children:"ยังไม่มีไม้ที่ปิดในช่วงนี้"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[{k:"ผลรวม R",v:l(t.net_r),c:m(t.net_r),s:"ปรับตามระยะ SL"},{k:"Winrate",v:E==null?"—":`${E.toFixed(1)}%`,c:"text-cyan-300",s:`ชนะ ${t.wins} · แพ้ ${t.losses}`},{k:"Profit Factor",v:t.profit_factor==null?"—":Number(t.profit_factor).toFixed(2),c:Number(t.profit_factor)>=1?"text-emerald-300":"text-rose-300",s:">1 = กำไร"}
11,{k:"ผลรวมราคา",v:`${Number(t.net_pct)>=0?"+":""}${Number(t.net_pct).toFixed(2)}%`,c:m(t.net_pct),s:"ผลต่างราคาดิบ"}].map(S=>e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:S.k}),e.jsx("p",{className:`mt-0.5 text-2xl font-bold ${S.c}`,children:S.v}),e.jsx("p",{className:"text-[10px] text-slate-500",children:S.s})]},S.k))}),P!=null&&E!=null&&e.jsxs("div",{className:`mt-3 rounded-xl border px-3 py-2.5 text-xs leading-relaxed ${E>=P?"border-emerald-500/30 bg-emerald-500/5 text-emerald-200":"border-amber-500/30 bg-amber-500/5 text-amber-200"}`,children:["ไม้ชนะเฉลี่ย ",e.jsx("b",{children:l(_)})," · ไม้แพ้เฉลี่ย ",e.jsx("b",{children:l(I)})," → ต้องชนะอย่างน้อย"," ",e.jsxs("b",{children:[P.toFixed(1),"%"]})," ถึงจะเสมอตัว · ตอนนี้ชนะ ",e.jsxs("b",{children:[E.toFixed(1),"%"]})," ",E>=P?"→ อยู่เหนือจุดคุ้มทุน":"→ ยังต่ำกว่าจุดคุ้มทุน (winrate สวยแต่ขาดทุน)"]}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[{k:"Expectancy",v:t.expectancy_r==null?"—":`${Number(t.expectancy_r)>=0?"+":""}${Number(t.expectancy_r).toFixed(3)}R`,c:m(t.expectancy_r),s:"ต่อไม้"},{k:"Max Drawdown",v:`-${Number(Q.max_drawdown_r).toFixed(2)}R`,c:"text-rose-300",s:"จุดสูงสุด→ต่ำสุด"},{k:"ไม้ดีสุด / แย่สุด",v:`${l(t.best_r)} / ${l(t.worst_r)}`,c:"text-slate-200",s:`หมดเวลา ${t.expired} ไม้`},{k:"ปิดทั้งหมด",v:`${t.trades} ไม้`,c:"text-slate-200",s:`conf เฉลี่ย ${t.avg_conf}%`}].map(S=>e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:S.k}),e.jsx("p",{className:`mt-0.5 text-base font-bold ${S.c}`,children:S.v}),e.jsx("p",{className:"text-[10px] text-slate-500",children:S.s})]},S.k))}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"กราฟ R สะสม (ทุกไม้ที่ปิด เรียงตามเวลา)"}),e.jsx(kr,{points:Q.equity||[]}),(()=>{const S=Mr(Q.equity);return S.length>0?e.jsxs("div",{className:"mt-3 border-t border-white/10 pt-3",children:[e.jsx(Sr,{points:S,unit:"R"}),e.jsxs("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:["Net R รายวัน = ผลรวม R ของไม้ที่",e.jsx("b",{className:"text-slate-400",children:"ปิดวันนั้น"})," · วันจัดกลุ่มตามเวลาไทย · W/L นับจากเครื่องหมายของ R"]})]}):null})()]}),Q.adv&&(Q.adv.closed??0)>0&&e.jsxs("div",{className:"mt-5 space-y-4 border-t border-white/10 pt-4",children:[e.jsx("p",{className:"flex items-center gap-1.5 text-xs font-medium text-slate-300",children:"📊 สถิติเชิงลึกแบบ Myfxbook (อิงผลราคา %)"}),e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"คุณภาพระบบ · 4 มิติ"}),e.jsx(Il,{adv:Q.adv,lowSampleAt:100,basisNote:e.jsxs(e.Fragment,{children:["เรดาร์นี้อ่านจาก",e.jsx("b",{children:"ผลราคา %"})," — Footprint ตัดสินจริงที่ ",e.jsx("b",{children:"R"})," (ดูบล็อก R ด้านบน)"]})})]}),e.jsx(Ol,{adv:Q.adv}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"ชนะ vs แพ้ · รายชั่วโมง"}),e.jsx(Bl,{data:Q.hourly??[]})]}),e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"ชนะ vs แพ้ · รายวันในสัปดาห์"}),e.jsx(Wl,{data:Q.daily??[]})]})]}),Array.isArray(Q.monthly)&&Q.monthly.length>0&&e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"กำไรรายเดือน (Net %)"}),e.jsx(Ar,{data:Q.monthly})]}),Array.isArray(Q.points)&&Q.points.length>0&&e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"Duration · ระยะเวลาถือ vs ผล"}),e.jsx(Hl,{data:Q.points})]}),e.jsxs("div",{className:"rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsx("p",{className:"mb-1 text-xs text-slate-400",children:"MAE · การขาดทุนสวนทางสูงสุด"}),e.jsx(ql,{data:Q.points})]})]}),e.jsxs("p",{className:"text-[10px] leading-relaxed text-slate-500",children:["บล็อกนี้อิง",e.jsx("b",{className:"text-slate-400",children:"ผลราคา %"})," (เสริมจากมุมมอง R ด้านบน — Footprint Lab ตัดสินที่ R เป็นหลัก) · Sharpe/StdDev/AHPR/GHPR เป็นค่า",e.jsx("b",{className:"text-slate-400",children:"ต่อไม้"})," วัดคุณภาพระบบ ไม่ใช่ % พอร์ตจริง · MAE คำนวณจากราคา OHLC จริงระหว่างถือไม้"]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-slate-300",children:"รายคู่"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"text-slate-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-1",children:"คู่"}),e.jsx("th",{children:"ไม้"}),e.jsx("th",{children:"Winrate"}),e.jsx("th",{className:"text-right",children:"R"})]})}),e.jsx("tbody",{children:(Q.by_asset||[]).map(S=>e.jsxs("tr",{className:"border-t border-white/[0.04]",children:[e.jsx("td",{className:"py-1.5 font-medium text-slate-200",children:S.asset}),e.jsx("td",{className:"text-slate-400",children:S.trades}),e.jsx("td",{className:"text-slate-400",children:S.win_rate==null?"—":`${S.win_rate}%`}),e.jsx("td",{className:`text-right font-semibold ${m(S.net_r)}`,children:l(S.net_r)})]},S.asset))})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-slate-300",children:"ตามทิศทาง"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(Q.by_direction||[]).map(S=>e.jsxs("div",{className:"rounded-lg border border-white/10 bg-slate-950/40 p-2.5",children:[e.jsx("p",{className:`text-xs font-semibold ${S.direction==="BUY"?"text-emerald-300":"text-rose-300"}`,children:S.direction}),e.jsx("p",{className:`text-lg font-bold ${m(S.net_r)}`,children:l(S.net_r)}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[S.trades," ไม้ · ",S.win_rate??"—","%"]})]},S.direction))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-xs font-medium text-slate-300",children:"ตามรูปแบบ setup"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(Q.by_setup||[]).map(S=>e.jsxs("div",{className:"rounded-lg border border-white/10 bg-slate-950/40 p-2.5",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:S.setup}),e.jsx("p",{className:`text-lg font-bold ${m(S.net_r)}`,children:l(S.net_r)}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[S.trades," ไม้ · ",S.win_rate??"—","%"]})]},S.setup))})]})]})]}),(()=>{const S=Number(Q.page_size)||10,ye=Number(Q.recent_total)||0,ue=Math.max(1,Math.ceil(ye/S)),se=Math.min(Fs,ue),we=2,Ce=[];for(let H=1;H<=ue;H++)H===1||H===ue||H>=se-we&&H<=se+we?Ce.push(H):Ce[Ce.length-1]!=="…"&&Ce.push("…");const Qe="rounded-md px-2.5 py-1 text-xs transition disabled:opacity-40";return e.jsxs("div",{className:"mt-4 rounded-xl border border-white/10 bg-slate-950/40 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-xs font-medium text-slate-300",children:["ไม้ที่ปิดแล้ว (",ye," ไม้)"]}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:["หน้า ",se," / ",ue]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{className:"text-slate-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-1",children:"เวลา"}),e.jsx("th",{children:"คู่"}),e.jsx("th",{children:"ทิศ"}),e.jsx("th",{children:"ผล"}),e.jsx("th",{children:"setup"}),e.jsx("th",{className:"text-right",children:"%"}),e.jsx("th",{className:"text-right",children:"R"})]})}),e.jsx("tbody",{children:(Q.recent||[]).map((H,gt)=>e.jsxs("tr",{className:"border-t border-white/[0.04]",children:[e.jsx("td",{className:"py-1.5 text-slate-500",children:new Date(H.closed_at).toLocaleStr
11ing("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be})}),e.jsx("td",{className:"font-medium text-slate-200",children:H.asset}),e.jsx("td",{className:H.direction==="BUY"?"text-emerald-300":"text-rose-300",children:H.direction}),e.jsx("td",{children:H.outcome==="WIN"?"✅":H.outcome==="LOSS"?"❌":"⏱"}),e.jsx("td",{className:"text-slate-500",children:H.setup}),e.jsxs("td",{className:`text-right ${m(H.pct)}`,children:[Number(H.pct)>=0?"+":"",Number(H.pct).toFixed(2),"%"]}),e.jsx("td",{className:`text-right font-semibold ${m(H.r)}`,children:l(H.r)})]},`${H.closed_at}-${H.asset}-${gt}`))})]})}),ue>1&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-1",children:[e.jsx("button",{className:`${Qe} text-slate-400 hover:bg-white/5`,disabled:se<=1||zt,onClick:()=>Ht(se-1),children:"← ก่อนหน้า"}),Ce.map((H,gt)=>H==="…"?e.jsx("span",{className:"px-1 text-xs text-slate-600",children:"…"},`e${gt}`):e.jsx("button",{disabled:zt,onClick:()=>Ht(H),className:`${Qe} ${H===se?"bg-cyan-500/15 font-semibold text-cyan-300 ring-1 ring-cyan-500/40":"text-slate-400 hover:bg-white/5"}`,children:H},H)),e.jsx("button",{className:`${Qe} text-slate-400 hover:bg-white/5`,disabled:se>=ue||zt,onClick:()=>Ht(se+1),children:"ถัดไป →"})]})]})})(),e.jsx("p",{className:"mt-3 text-[11px] text-slate-500",children:"นับเฉพาะไม้ที่ส่งเข้าห้องจริง (ไม่รวมไม้ shadow ที่ใช้วัดผลภายใน) · R = กำไร/ขาดทุน หารด้วยระยะ SL ของไม้นั้น"})]})]})})(),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-base font-semibold",children:"🥇 อันดับกลุ่ม Footprint Lab (Net R)"}),e.jsx("div",{className:"flex gap-0.5 rounded-lg border border-white/10 p-0.5",children:["7d","30d","all"].map(t=>e.jsx("button",{onClick:()=>Cn(t),className:`rounded-md px-2.5 py-1 text-xs transition ${Vt===t?"bg-cyan-500/15 text-cyan-300":"text-slate-400 hover:text-slate-200"}`,children:t==="7d"?"7 วัน":t==="30d"?"30 วัน":"ทั้งหมด"},t))})]}),e.jsxs("p",{className:"mb-4 text-[11px] leading-relaxed text-slate-500",children:["เทียบ",e.jsx("b",{className:"text-slate-300",children:" ผลรวม R จริง"}),"ของทุกกลุ่มที่เปิด Footprint Lab — นับเฉพาะไม้ที่ส่งเข้าห้องนั้นจริง · ใช้นามแฝงเพื่อความเป็นส่วนตัว · ",e.jsx("span",{className:"text-emerald-300/90",children:"แถวของคุณไฮไลต์สีเขียว + ป้าย “คุณ”"})," · อันดับต่างกันเพราะแต่ละกลุ่ม",e.jsx("b",{className:"text-slate-300",children:"เลือกคู่"}),"และ",e.jsx("b",{className:"text-slate-300",children:"เริ่มรับ"}),"ไม่พร้อมกัน · แสดงเฉพาะกลุ่มที่มีไม้ปิดผล ≥ 10 ไม้"]}),$n&&!Ue?e.jsx("p",{className:"text-xs text-slate-500",children:"กำลังโหลด…"}):(El=Ue==null?void 0:Ue.channels)!=null&&El.length?(()=>{const t=Ue.channels,s=Math.max(...t.map(l=>Math.abs(Number(l.net_r))),.1);return e.jsx("div",{className:"space-y-2.5",children:t.map(l=>{const m=Number(l.net_r)>=0,E=Math.min(1,Math.abs(Number(l.net_r))/s),_=l.rank===1?"border-amber-400/40 bg-amber-400/20 text-amber-300":l.rank===2?"border-slate-300/30 bg-slate-300/15 text-slate-200":l.rank===3?"border-orange-400/30 bg-orange-400/15 text-orange-300":"border-white/10 bg-white/5 text-slate-400";return e.jsxs("div",{className:`rounded-xl px-2 py-1.5 ${l.is_you?"bg-emerald-500/10 ring-1 ring-emerald-500/40":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-xs",children:[e.jsx("span",{className:`grid h-6 w-6 shrink-0 place-items-center rounded-lg border text-[11px] font-bold ${_}`,children:l.rank}),e.jsx("div",{className:"w-24 shrink-0 sm:w-28",children:e.jsxs("span",{className:"block truncate font-medium text-slate-200",children:[l.name,l.is_you&&e.jsx("span",{className:"ml-1 rounded bg-emerald-500/20 px-1 py-0.5 text-[9px] font-semibold text-emerald-300",children:"คุณ"})]})}),e.jsxs("div",{className:"relative h-2.5 flex-1",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-white/[0.04]"}),e.jsx("div",{className:"absolute left-1/2 top-0 h-full w-px bg-white/15"}),e.jsx("div",{className:"absolute top-0 h-full rounded-full",style:m?{left:"50%",width:`${E*50}%`,background:"#34d399"}:{right:"50%",width:`${E*50}%`,background:"#f87171"}})]}),e.jsxs("span",{className:"w-16 shrink-0 text-right font-semibold",style:{color:m?"#34d399":"#f87171"},children:[Number(l.net_r)>0?"+":"",Number(l.net_r).toFixed(2),"R"]}),e.jsxs("span",{className:"hidden w-24 shrink-0 text-right text-slate-400 sm:block",children:[l.win,"-",l.loss,l.win_rate!=null?` · ${l.win_rate}%`:""]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1 pl-8 text-[10px] text-slate-500",children:[e.jsxs("span",{className:Number(l.net_pct)>=0?"text-emerald-400/80":"text-rose-400/80",children:["ราคา ",Number(l.net_pct)>0?"+":"",l.net_pct,"%"]}),e.jsxs("span",{children:["· ",l.trades," ไม้"]}),e.jsx("span",{children:"· รับ:"}),Array.isArray(l.assets)&&l.assets.length?e.jsxs(e.Fragment,{children:[l.assets.slice(0,6).map(I=>e.jsx("span",{className:"rounded border border-white/10 bg-white/5 px-1 py-px text-slate-400",children:I},I)),l.assets.length>6&&e.jsxs("span",{children:["+",l.assets.length-6," คู่"]})]}):e.jsx("span",{className:"text-slate-400",children:"ทุกคู่ที่รองรับ"}),l.pid&&e.jsx("button",{onClick:()=>al({pid:l.pid,name:l.name,rank:Number(l.rank),net_r:Number(l.net_r),net_pct:Number(l.net_pct),win:Number(l.win),loss:Number(l.loss),win_rate:l.win_rate==null?0:Number(l.win_rate),assets:Array.isArray(l.assets)?l.assets:null}),className:"ml-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-300 transition hover:bg-amber-500/20",children:"📊 สถิติเชิงลึก"})]})]},l.rank)})})})():e.jsx("p",{className:"text-xs text-slate-500",children:"ยังไม่มีกลุ่มที่มีไม้ปิดผลครบ 10 ไม้ในช่วงนี้"}),e.jsxs("p",{className:"mt-3 text-[10px] text-slate-600",children:[Ue!=null&&Ue.generated_at?`อัปเดตล่าสุด ${new Date(Ue.generated_at).toLocaleStr
11ing("th-TH",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",timeZone:be})} · `:"","Net R = ผลรวมกำไร/ขาดทุนของไม้ที่ส่งเข้ากลุ่มนั้น หารด้วยระยะ SL ของแต่ละไม้ · ผลย้อนหลังไม่การันตีผลอนาคต"]})]}),sl&&e.jsx(Cr,{summary:sl,range:Vt,onClose:()=>al(null)})]}),c==="news"&&e.jsxs("div",{className:"space-y-4",children:[!(h!=null&&h.has_bot)&&e.jsx("p",{className:"rounded-xl border border-amber-500/20 bg-amber-500/[0.06] px-3.5 py-2.5 text-xs text-amber-300",children:"ตั้งค่าบอท + กลุ่มก่อน จึงจะส่งข่าวเข้ากลุ่มได้"}),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"ข่าวเช้าประจำวัน 📊"}),e.jsx("p",{className:"text-xs text-slate-400",children:"โพสต์สรุปปฏิทินข่าวเศรษฐกิจวันนี้ + แนวโน้มรายสินทรัพย์ + กฎการเทรดหนึ่งข้อ พร้อมการ์ดรูป — วันละครั้ง ตามเวลาที่คุณเลือก"})]}),e.jsx(de,{on:St,onChange:pa})]}),St?e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("div",{className:"flex flex-wrap items-end gap-3",children:e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"เวลาส่ง (เวลาท้องถิ่นของคุณ)"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("select",{value:lt,onChange:t=>ha(Number(t.target.value)),className:oe+" w-20",children:Array.from({length:24},(t,s)=>e.jsx("option",{value:s,children:String(s).padStart(2,"0")},s))}),e.jsx("span",{className:"text-slate-500",children:":"}),e.jsx("select",{value:nt,onChange:t=>ua(Number(t.target.value)),className:oe+" w-20",children:[0,15,30,45].map(t=>e.jsx("option",{value:t,children:String(t).padStart(2,"0")},t))}),e.jsxs("span",{className:"text-xs text-slate-500",children:["น. · ",be]})]})]})}),e.jsx("div",{className:"rounded-xl border border-white/10 bg-white/[0.02] px-3.5 py-2.5 text-xs",children:Hn?e.jsx("p",{className:"text-amber-300",children:"⚠️ ยังไม่ได้บันทึก — กด “บันทึก” ก่อน การตั้งค่านี้จึงจะมีผล"}):h!=null&&h.brief_enabled?e.jsxs("p",{className:"text-slate-300",children:["📮 โพสต์ถัดไป: ",e.jsx("b",{className:"text-emerald-300",children:ol}),e.jsx("span",{className:"text-slate-500",children:" · ระบบส่งเองอัตโนมัติ วันละครั้ง ไม่ต้องกดอะไร"})]}):e.jsxs("p",{className:"text-slate-400",children:["เปิดสวิตช์แล้วกด “บันทึก” — โพสต์แรกจะเป็น ",e.jsx("b",{className:"text-slate-200",children:ol}),e.jsx("span",{className:"text-slate-500",children:" · ถ้าเปิดหลังเวลาที่ตั้งไว้ ระบบจะเริ่มให้พรุ่งนี้ ไม่ส่งย้อนทันที"})]})}),e.jsxs("div",{className:"rounded-xl border border-cyan-500/20 bg-cyan-500/[0.04] p-3.5 text-xs leading-relaxed text-slate-400",children:[e.jsx("p",{className:"mb-1.5 font-medium text-cyan-300",children:"โพสต์นี้มีอะไรบ้าง"}),e.jsxs("ul",{className:"list-inside list-disc space-y-1",children:[e.jsx("li",{children:"ปฏิทินข่าววันนี้ — เวลาไทย พร้อมค่าคาด/ครั้งก่อน (ข่าวที่ออกพร้อมกันรวมเป็นบรรทัดเดียว)"}),e.jsxs("li",{children:["บทวิเคราะห์ + แนวโน้มที่ต้องระวัง เฉพาะสินทรัพย์ที่",e.jsx("span",{className:"text-slate-300",children:"ช่องคุณส่งอยู่"})]}),e.jsx("li",{children:"กฎการเทรดหนึ่งข้อสำหรับวันนั้น"})]}),e.jsxs("p",{className:"mt-2 text-slate-500",children:["ทุกประโยคเป็นเงื่อนไข (“ถ้า… อาจ…”) ไม่ฟันธงทิศทาง และไม่มีจุดเข้า/จุดตัดขาดทุน"," · ","ถ้าเปิด “แยกกลุ่มข่าว” ไว้ โพสต์นี้จะไปกลุ่มข่าว"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:Kt,disabled:qe,className:"rounded-xl bg-emerald-600 px-5 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:qe?"กำลังบันทึก…":"บันทึก"}),e.jsx("button",{onClick:()=>cl("day"),disabled:$t||!(h!=null&&h.has_bot),title:"ส่งข่าวเช้าของวันนี้เข้ากลุ่มทันที เพื่อดูหน้าตาจริง (ไม่กระทบรอบส่งอัตโนมัติของวันนี้)",className:"rounded-xl border border-cyan-500/40 bg-cyan-500/10 px-4 py-2 text-sm font-medium text-cyan-300 hover:bg-cyan-500/20 disabled:opacity-40",children:$t?"กำลังส่ง…":"ส่งตัวอย่างเข้ากลุ่มเลย"}),Ot&&e.jsx("span",{className:"text-sm text-emerald-400",children:"✓ บันทึกแล้ว"})]}),ga&&e.jsx("p",{className:"text-xs text-slate-300",children:ga}),e.jsxs("div",{className:"rounded-xl border border-white/10 p-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-200",children:"ปักหมุดปฏิทินสัปดาห์ ทุกวันจันทร์ 📌"}),e.jsxs("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-500",children:["เช้าวันจันทร์จะโพสต์ปฏิทินข่าวแรงทั้งสัปดาห์เพิ่มอีกหนึ่งโพสต์ แล้ว",e.jsx("span",{className:"text-slate-300",children:"ปักหมุด"}),"ไว้บนสุดของกลุ่ม"," · ","บอทต้องเป็นแอดมินและมีสิทธิ์ปักหมุด ถ้าไม่มีสิทธิ์ โพสต์ยังส่งปกติแต่จะไม่ถูกปักหมุด"," · ","ฝั่ง Discord ปักหมุดผ่าน webhook ไม่ได้ จะส่งเป็นโพสต์ธรรมดา"]})]}),e.jsx(de,{on:Ct,onChange:ba})]}),Ct&&e.jsx("button",{onClick:()=>cl("week"),disabled:$t||!(h!=null&&h.has_bot),className:"mt-3 rounded-xl border border-emerald-500/40 bg-emerald-500/10 px-4 py-2 text-sm font-medium text-emerald-300 hover:bg-emerald-500/20 disabled:opacity-40",children:$t?"กำลังส่ง…":"ดูตัวอย่างโพสต์ปักหมุด"})]})]}):e.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"ปิดอยู่ — เปิดเพื่อให้กลุ่มมีโพสต์ประจำทุกเช้า แม้เป็นวันที่ยังไม่มีสัญญาณ"})]}),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"แยกกลุ่มข่าว 📰"}),e.jsx("p",{className:"text-xs text-slate-400",children:"ส่งข่าว (+ ปฏิทินเศรษฐกิจ) เข้าอีกกลุ่มหนึ่ง แยกจากกลุ่มสัญญาณ — ปิด = ส่งเข้ากลุ่มสัญญาณเหมือนเดิม"})]}),e.jsx(de,{on:Ss,onChange:La})]}),Ss?e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"rounded-xl border border-cyan-500/20 bg-cyan-500/[0.04] p-3.5 text-xs leading-relaxed",children:[e.jsx("p",{className:"mb-1.5 font-medium text-cyan-300",children:"วิธีตั้งกลุ่มข่าว (ทำตามนี้ได้เลย)"}),e.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-slate-400",children:[e.jsxs("li",{children:["สร้างกลุ่ม Telegram ใหม่สำหรับข่าว แล้วเพิ่ม",e.jsx("span",{className:"text-slate-200",children:"บอทตัวเดิม"}),"เข้าไป ตั้งเป็น",e.jsx("span",{className:"text-slate-200",children:"แอดมิน"})]}),e.jsxs("li",{children:["พิมพ์อะไรก็ได้ในกลุ่มข่าว ",e.jsx("span",{className:"text-slate-200",children:"1 ครั้ง"})," (ให้บอทมองเห็นกลุ่ม)"]}),e.jsxs("li",{children:["ไปแท็บ ",e.jsx("span",{className:"text-cyan-300",children:"“ตั้งค่าบอท”"})," กด ",e.jsx("span",{className:"text-cyan-300",children:"“ทดสอบบอท & ดึง chat_id”"})," จะเห็นทุกกลุ่มที่บอทอยู่"]}),e.jsxs("li",{children:["กลับมาที่นี่ ใส่/กดเลือก ",e.jsx("span",{className:"text-slate-200",children:"chat_id ของกลุ่มข่าว"})," แล้วกด ",e.jsx("span",{className:"text-emerald-300",children:"“บันทึก”"})]})]}),e.jsx("p",{className:"mt-2 text-slate-500",children:"ข่าว + ปฏิทินเศรษฐกิจจะไปกลุ่มนี้ · สัญญาณ (ซิก) ยังอยู่กลุ่มเดิม · ปิดสวิตช์เมื่อไหร่ ข่าวกลับไปรวมกับกลุ่มสัญญาณ"})]}),e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"Chat ID ของกลุ่มข่าว"}),e.jsx("input",{className:oe+" mt-1",placeholder:"-100...",value:ht,onChange:t=>Cs(t.target.value)})]}),Ut.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[11px] text-slate-500",children:"กลุ่มที่บอทอยู่ (กดเพื่อใส่):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ut.map(t=>e.jsxs("button",{onClick:()=>Cs(t.id),className:`rounded-lg border px-3 py-1.5 text-xs ${ht===t.id?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-300 hover:bg-white/5"}`,children:[t.title," ",e.jsxs("span",{className:"text-slate-500",children:["(",t.id,")"]})]},t.id))})]}),ht.trim()&&ht.trim()===((h==null?void 0:h.chat_id)||"")&&e.jsx("p",{className:"text-[11px] text-amber-400",children:"⚠️ chat_id นี้เหมือนกลุ่มสัญญาณ — ข่าวจะไปกองรวมกับซิกเหมือนเดิม"})]}):e.jsxs("p",{className:"mt-3 text-xs text-slate-500",children:["ตอนนี้ข่าวส่งเข้า",e.jsx("span",{className:"text-slate-300",children:"กลุ่มสัญญาณ"}),"เดียวกับซิก"]}
11),e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[e.jsx("button",{onClick:Kt,disabled:qe,className:"rounded-xl bg-emerald-600 px-5 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:qe?"กำลังบันทึก…":"บันทึก"}),Ot&&e.jsx("span",{className:"text-sm text-emerald-400",children:"✓ บันทึกแล้ว"})]})]}),e.jsxs("section",{className:q,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",children:"ส่งข่าวอัตโนมัติ 🤖"}),e.jsx("p",{className:"text-xs text-slate-400",children:"ระบบส่งข่าวใหม่ล่าสุดเข้ากลุ่มเองตามรอบเวลา (ไม่ต้องกดเอง)"})]}),e.jsx(de,{on:ks,onChange:Da})]}),ks&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:$e,children:"ความถี่"}),e.jsxs("select",{className:oe+" mt-1",value:yl?Tt:"custom",onChange:t=>{t.target.value!=="custom"&&$s(Number(t.target.value))},children:[Nl.map(t=>e.jsx("option",{value:t.v,children:t.l},t.v)),e.jsx("option",{value:"custom",children:"กำหนดเอง…"})]}),!yl&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{className:oe,type:"number",min:5,value:Tt,onChange:t=>$s(Number(t.target.value))}),e.jsx("span",{className:"whitespace-nowrap text-xs text-slate-400",children:"นาที (ขั้นต่ำ 5)"})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:$e,children:["หมวดข่าว ",e.jsx("span",{className:"text-slate-500",children:"(ไม่เลือก = ทุกหมวด)"})]}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:er.map(t=>e.jsx("button",{onClick:()=>Ra(s=>s.includes(t.id)?s.filter(l=>l!==t.id):[...s,t.id]),className:`rounded-lg border px-3 py-1.5 text-xs ${Ta.includes(t.id)?"border-cyan-500 bg-cyan-500/10 text-cyan-300":"border-white/10 text-slate-400 hover:bg-white/5"}`,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[e.jsx("button",{onClick:Kt,disabled:qe,className:"rounded-xl bg-emerald-600 px-5 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:qe?"กำลังบันทึก…":"บันทึก"}),Ot&&e.jsx("span",{className:"text-sm text-emerald-400",children:"✓ บันทึกแล้ว"})]})]}),e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"หรือเลือกส่งเองทีละข่าว ↓"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Qn.map(t=>e.jsx("button",{onClick:()=>ls(t.id),className:`rounded-lg px-3 py-1.5 text-xs transition ${_e===t.id?"bg-cyan-500/15 text-cyan-300":"border border-white/10 text-slate-400 hover:bg-white/5"}`,children:t.label},t.id))}),ns?e.jsx("p",{className:"text-sm text-slate-500",children:"กำลังโหลดข่าว…"}):ie.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"ยังไม่มีข่าว"}):e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:ie.map(t=>{const s=t.sentiment==="bullish"?"text-emerald-300 bg-emerald-500/10 border-emerald-500/30":t.sentiment==="bearish"?"text-rose-300 bg-rose-500/10 border-rose-500/30":"text-slate-300 bg-white/5 border-white/10";return e.jsxs("div",{className:`${q} flex flex-col`,children:[t.image&&/^https?:/.test(t.image)&&e.jsx("img",{src:t.image,alt:"",className:"mb-3 h-32 w-full rounded-lg object-cover",loading:"lazy"}),e.jsx("p",{className:"line-clamp-2 font-medium text-slate-100",children:t.headline}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-slate-400",children:t.summary}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:`rounded-md border px-2 py-0.5 text-[11px] ${s}`,children:t.sentiment}),e.jsx("span",{className:"truncate text-xs text-slate-500",children:t.source})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between pt-1",children:[e.jsx("span",{className:"text-xs text-slate-500",children:t.datetime?new Date(t.datetime).toLocaleDateString("th-TH",{day:"2-digit",month:"short"}):""}),e.jsx("button",{onClick:()=>Pn(t),disabled:!(h!=null&&h.has_bot)||ct===t.id,className:"rounded-lg bg-cyan-600 px-3.5 py-1.5 text-xs font-medium text-white transition hover:bg-cyan-500 disabled:opacity-50",children:ct===t.id?"กำลังส่ง…":We[t.id]==="ok"?"✓ ส่งแล้ว":We[t.id]==="err"?"ลองใหม่":"ส่งเข้ากลุ่ม"})]})]},t.id)})})]}),le&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>fe(!1),children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-emerald-500/25 bg-[#0e1420] p-5 shadow-2xl shadow-emerald-900/30",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-emerald-500/15 text-xl",children:"🤝"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-white",children:"กลุ่มของคุณ ต่อยอดเป็นรายได้ได้เลย"}),e.jsx("p",{className:"text-xs text-slate-400",children:"โปรแกรมพาร์ทเนอร์ IB สำหรับเจ้าของกลุ่ม Signal Control"})]})]}),e.jsx("button",{onClick:()=>fe(!1),"aria-label":"ปิด",className:"rounded-lg p-1.5 text-slate-400 transition hover:bg-white/10 hover:text-white",children:"✕"})]}),e.jsxs("p",{className:"mt-4 text-[13px] leading-relaxed text-slate-200",children:["คุณส่งสัญญาณเข้ากลุ่ม Telegram/Discord ของตัวเองอยู่แล้ว — สมาชิกที่สมัคร VIP ผ่าน",e.jsx("b",{className:"text-emerald-300",children:"ลิงก์แนะนำของคุณ"})," จะกลายเป็นค่าคอมมิชชั่นของคุณทันที"]}),e.jsxs("ul",{className:"mt-3 space-y-1.5 rounded-xl border border-white/[0.06] bg-white/[0.02] p-3 text-[12.5px] text-slate-300",children:[e.jsxs("li",{children:["✅ ค่าคอม ",e.jsxs("b",{className:"text-white",children:[Ee??20,"%"]})," จากทุกยอดสมัครใหม่"]}),e.jsx("li",{children:"✅ ชวนพาร์ทเนอร์ต่อเป็น Sub-IB ได้ (โครงสร้างสองชั้น จบ)"}),e.jsx("li",{children:"✅ บันไดสถานะ 4 ขั้น Partner → Master IB"}),e.jsx("li",{children:"✅ ไม่มีค่าสมัคร ไม่บังคับยอด"})]}),e.jsx("p",{className:"mt-2 text-[11px] text-slate-500",children:"à¸
11ˆà¹ˆà¸²à¸¢à¸ˆà¸²à¸à¸¢à¸­à¸”ขายที่เกิดขึ้นจริงเท่านั้น ไม่มีค่าตอบแทนจากการชวนคนเข้าระบบ · ไม่ใช่การการันตีรายได้"}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[e.jsx("button",{onClick:()=>{fe(!1),De(!0)},className:"flex-1 rounded-xl bg-emerald-600 px-4 py-2.5 text-sm font-semibold text-white transition hover:bg-emerald-500",children:"รับลิงก์แนะนำของฉัน"}),e.jsx("button",{onClick:()=>{fe(!1),xr("/partner")},className:"flex-1 rounded-xl border border-emerald-500/30 bg-emerald-500/[0.06] px-4 py-2.5 text-sm font-medium text-emerald-300 transition hover:bg-emerald-500/15",children:"ดูแผนพาร์ทเนอร์ 4 ขั้น"})]})]})}),je&&e.jsx($r,{isOpen:Ae,onClose:()=>De(!1),vipCode:je})]})]})})}export{tn as PaTimeframePicker,di as PairCostPanel,bo as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.