PageSourceSearch

https://ieltswritingchecker.org/assets/AdminDashboardPage-Dhud0k8v.js

js ieltswritingchecker.org collected 2026-10-07 02:11:53 UTC 99,659 bytes, 1 lines download raw bytes

1import{r as N,R as ft,j as e,C as V,f as U,i as D,S as Ee,T as kt,U as Y,V as Q,X as K,Y as ee,Z as te,_ as ce,$ as Le,a0 as Ve,a1 as Ye,a2 as wt,k as Ct}from"./main-DrBhI0hH.js";import"./index-_tIqqp10.js";const Qe=["mobile","desktop","tablet","unknown"];function Nt(t){return Qe.includes(t)?t:"unknown"}const Oe=[{id:"submissionRate",label:"Submission rate"},{id:"visits",label:"Visits"},{id:"submittingVisits",label:"Visits with a submission"}],He=[["all","All devices"],["mobile","Mobile"],["desktop","Desktop"],["tablet","Tablet"]],fe=t=>Number.isFinite(t)?`${(t*100).toFixed(1)}%`:"—",G=t=>Number(t||0).toLocaleString("en");function $t({report:t,historyReport:s,isLoading:i,error:l,locale:a,filters:r,onChange:c,LineChart:n}){const v=N.useRef(null),x=N.useRef(!1),[p,C]=N.useState("submissionRate"),[y,k]=N.useState("all"),[S,j]=N.useState(10),[d,b]=N.useState(""),[u,g]=N.useState("");N.useEffect(()=>{t?.filters&&(b(t.filters.startDate),g(t.filters.endDate))},[t]);const o=N.useMemo(()=>(t?.pages||[]).filter(h=>y==="all"||h.type===y).sort((h,_)=>_.visits-h.visits||h.path.localeCompare(_.path)),[t,y]);N.useEffect(()=>{x.current&&(x.current=!1,v.current?.scrollIntoView({block:"start"}),v.current?.focus({preventScroll:!0}))},[y]);const T=Oe.find(h=>h.id===p).label,A=y==="all"?"All landing pages":ft.find(h=>h.id===y)?.label,f=t?.available===!0&&!l&&!i,$=h=>{k(h),j(10)};return e.jsxs("div",{className:"admin-writing-conversion",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{children:"Visits → essay submissions"}),e.jsx("p",{children:"Free users and signed-out visitors only. Active members are excluded from both counts."})]})}),e.jsxs(V,{"aria-label":"Writing conversion filters",children:[e.jsx(U,{label:"Period",children:[7,30,90].map(h=>e.jsxs(D,{isActive:r.conversionDays===h&&!r.conversionStart,disabled:i,onClick:()=>c({conversionDays:h,conversionDevice:r.conversionDevice}),children:["Last ",h," days"]},h))}),e.jsx(U,{label:"Device",children:He.map(([h,_])=>e.jsx(D,{isActive:r.conversionDevice===h,disabled:i,onClick:()=>c({...r,conversionDevice:h}),children:_},h))})]}),e.jsxs("details",{className:"admin-writing-conversion__method",children:[e.jsx("summary",{children:"Custom dates"}),e.jsxs("form",{className:"admin-writing-conversion__dates",onSubmit:h=>{h.preventDefault();const _=new FormData(h.currentTarget);c({conversionDevice:r.conversionDevice,conversionStart:_.get("startDate"),conversionEnd:_.get("endDate")})},children:[e.jsxs("label",{children:["From ",e.jsx("input",{"aria-label":"Conversion start date",name:"startDate",type:"date",required:!0,value:d,onChange:h=>b(h.target.value)})]}),e.jsxs("label",{children:["To ",e.jsx("input",{"aria-label":"Conversion end date",name:"endDate",type:"date",required:!0,value:u,onChange:h=>g(h.target.value)})]}),e.jsx("button",{type:"submit",className:"secondary-button",disabled:i,children:"Apply dates"}),e.jsx("span",{children:"Up to 90 days; through yesterday."})]})]}),i||!t&&!l?e.jsx("div",{className:"history-empty",role:"status",children:"Loading visit and submission data…"}):null,!i&&t?.available===!1&&!l?e.jsxs("div",{className:"history-error",role:"alert",children:["Visit conversion data is unavailable. ",t.reason==="ga_reporting_not_configured"?"Configure the existing GA4 reporting connection.":t.reason==="eligible_visit_history_unavailable"?"This period has no free or signed-out visit tracking yet. Earlier data did not record membership status and cannot be separated. New data appears after GA4 processes it; reports end yesterday.":"Refresh to retry the GA4 report. Incomplete data is not shown as zero."]}):null,f?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"admin-channel-trends__note",children:[t.filters.startDate," – ",t.filters.endDate," · ",He.find(([h])=>h===t.filters.device)?.[1]," · GA4 · ",t.coverage.timezone,".",` Free and signed-out tracking begins ${t.coverage.availableFrom}. Earlier unclassified data is excluded.`," ","Counts cover visits tracked by GA4. Recent days may still update."]}),t.coverage.inconsistentCounts?e.jsx("p",{className:"history-error",children:"Some GA4 counts do not reconcile. Rates for those rows are unavailable; check again after GA4 finishes processing."}):null,e.jsxs("dl",{className:"admin-recovery-rates admin-writing-conversion__totals",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Visits"}),e.jsx("dd",{children:G(t.summary.visits)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Visits with a submission"}),e.jsx("dd",{children:G(t.summary.submittingVisits)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Submission rate"}),e.jsx("dd",{children:fe(t.summary.submissionRate)})]})]}),e.jsx(V,{"aria-label":"Chart metric",children:e.jsx(U,{label:"Show",children:Oe.map(h=>e.jsx(D,{isActive:p===h.id,onClick:()=>C(h.id),children:h.label},h.id))})}),e.jsx(n,{daily:t.daily,title:`Sitewide · ${T}`,locale:a,valueKey:p,valueKind:p==="submissionRate"?"rate":"count",dateBasis:t.coverage.timezone,unitLabel:p==="visits"?"visits":"submitting visits",formatDetail:h=>`${G(h.submittingVisits)} / ${G(h.visits)} visits`,description:"Daily trend for all landing pages. Hover or use arrow keys to inspect a day. Gaps mean the rate is unavailable.",emptyText:"No visits in this period."}),e.jsx(_t,{title:"Compare landing-page types",description:"Select a type to see its individual pages below. Ordered by visits so high-traffic opportunities stay visible.",rows:[...t.pageTypes].sort((h,_)=>_.visits-h.visits),metric:p,metricLabel:T,selectedId:y,onSelect:h=>{x.current=!0,$(h.id),h.id===y&&(v.current?.scrollIntoView({block:"start"}),v.current?.focus({preventScroll:!0}),x.current=!1)}}),e.jsxs("section",{className:"admin-data-panel admin-writing-conversion__pages","aria-labelledby":"
1conversion-pages-title",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsxs("h2",{id:"conversion-pages-title",ref:v,tabIndex:-1,children:[A," · individual pages"]}),e.jsxs("p",{children:[o.length," pages. Showing ",Math.min(S,o.length),", ordered by visits. Localized URLs stay separate."]})]})}),e.jsx(V,{"aria-label":"Landing page type",children:e.jsx(U,{label:"Type",children:[{id:"all",label:"All pages"},...t.pageTypes].map(h=>e.jsx(D,{isActive:y===h.id,onClick:()=>$(h.id),children:h.label},h.id))})}),e.jsx(Je,{rows:o.slice(0,S).map(h=>({...h,id:h.path,label:h.path})),metric:p,metricLabel:T}),o.length?null:e.jsx("p",{className:"history-empty",children:"No tracked visits for this page type in this period."}),o.length>S?e.jsx("button",{type:"button",className:"secondary-button",onClick:()=>j(h=>h+10),children:"Show 10 more pages"}):null]}),e.jsxs("details",{className:"admin-writing-conversion__method",children:[e.jsx("summary",{children:"How to read these charts"}),e.jsx("p",{children:"One visit is one GA4 session. A visit with multiple submissions counts once in the selected period. The first page of that visit gets the credit, even when the visitor goes to the home page to submit."}),e.jsx("p",{children:"Both counts include only activity recorded while signed out or confirmed on Free. Active full-access members and unresolved membership states are excluded. Status is checked at the time of the activity; signed-out visits remain included because their account membership is unknown."}),e.jsx("p",{children:"A submission means a confirmed free user sends a request to check the essay after sign-in and quota checks. It does not mean the review completed successfully. Earlier free activity remains counted when someone later upgrades."}),e.jsx("p",{children:"The rate is visits with a submission ÷ visits. Counts and rates come from the same GA4 date and device selection. The period rate uses the period totals, not an average of daily percentages. GA4 estimates sessions; daily rows can overlap when a session spans midnight."}),e.jsx("p",{children:"GA4 can miss visits and events because of tracking exclusions or blockers, including the site's Ireland exclusion. Tracking starts with the first recorded eligible visit; days with visits and no submissions count as zero conversion. Use consistent date ranges and inspect the counts alongside the percentage. A few visits do not establish a reliable winner."})]})]}):null,e.jsx(At,{report:s,isLoading:i,error:l,locale:a,LineChart:n})]})}function At({report:t,isLoading:s,error:i,locale:l,LineChart:a}){const r=N.useMemo(()=>kt(t),[t]);return e.jsxs("section",{className:"admin-writing-conversion","aria-labelledby":"conversion-history-title",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{id:"conversion-history-title",children:"Historical reference · last 30 days"}),e.jsx("p",{children:"Approximate ratio: completed free essays ÷ all site visits. Historical visits include paid users."})]})}),e.jsxs("p",{className:"admin-channel-trends__note",children:[t?`${t.filters.startDate} – ${t.filters.endDate} · ${t.coverage.timezone}. `:"","Always all devices and all pages, through yesterday. The filters above apply to the free-visitor conversion report."]}),s?e.jsx("div",{className:"history-empty",role:"status",children:"Loading historical reference…"}):i||!r.available?e.jsx("p",{className:"history-error",role:"alert",children:"Historical ratio is unavailable. Both GA4 visits and free-review records are needed. Refresh to retry."}):e.jsxs(e.Fragment,{children:[e.jsx("dl",{className:"admin-recovery-rates admin-writing-conversion__totals",children:e.jsxs("div",{children:[e.jsx("dt",{children:"Period ratio (approx.)"}),e.jsx("dd",{children:Number.isFinite(r.total)?`${(r.total*100).toFixed(2)}%`:"—"})]})}),e.jsx(a,{daily:r.daily,title:"Daily historical ratio",locale:l,valueKey:"referenceRatio",valueKind:"rate",valueLabel:"Historical reference ratio",dateBasis:t.coverage.timezone,description:"Free essays completed per 100 site visits. Hover or use arrow keys to see each day's percentage and counts.",formatDetail:c=>c.freeReviews==null||c.visits==null?"Missing source data":`${G(c.freeReviews)} essays / ${G(c.visits)} visits`,emptyText:"No historical ratio data in this period."}),e.jsx("p",{className:"admin-channel-trends__note",children:"This is a historical reference, not the share of free visitors who submitted. Each essay counts separately; old visits include paid users, and GA4 can miss visits. The period percentage uses total free essays ÷ total visits. Missing records or zero visits leave gaps."})]})]})}function _t({title:t,description:s,...i}){return e.jsxs("section",{className:"admin-data-panel","aria-label":t,children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{children:t}),e.jsx("p",{children:s})]})}),e.jsx(Je,{...i}),i.rows.length?null:e.jsx("p",{className:"history-empty",children:"No tracked visits in this period."})]})}function Je({rows:t,metric:s,metricLabel:i,onSelect:l,selectedId:a}){const r=Math.max(s==="submissionRate"?.01:1,...t.map(n=>n[s]||0)),c=n=>s==="submissionRate"?fe(n):G(n);return e.jsxs("div",{className:"admin-conversion-bars","aria-label":`${i} horizontal bar chart`,children:[e.jsxs("div",{className:"admin-conversion-bars__scale","aria-hidden":"true",children:[e.jsx("span",{children:"0"}),e.jsx("span",{children:i}),e.jsx("span",{children:c(r)}
1)]}),e.jsx("ul",{children:t.map(n=>e.jsxs("li",{children:[e.jsxs("div",{className:"admin-conversion-bars__heading",children:[l?e.jsxs("button",{type:"button","aria-pressed":a===n.id,onClick:()=>l(n),children:[n.label," →"]}):Ee(n.path)?e.jsx("a",{href:Ee(n.path),target:"_blank",rel:"noreferrer",children:n.label}):e.jsx("span",{children:n.label}),e.jsx("strong",{children:c(n[s])})]}),e.jsxs("svg",{viewBox:"0 0 1000 12",preserveAspectRatio:"none","aria-hidden":"true",children:[e.jsx("rect",{className:"admin-conversion-bars__track",width:"1000",height:"12"}),e.jsx("rect",{className:"admin-conversion-bars__value",width:n[s]==null?0:n[s]/r*1e3,height:"12"})]}),e.jsxs("p",{children:[G(n.submittingVisits)," submitting visits / ",G(n.visits)," visits · ",fe(n.submissionRate),n.visits<30?" · Small sample":""]})]},n.id))})]})}const z=(t,s)=>s?`${(t/s*100).toFixed(1)}%`:"—",Tt=t=>{if(t==null)return"—";let s=Math.round(t);const i=Math.floor(s/3600);s%=3600;const l=Math.floor(s/60),a=s%60;return`${i?`${i} 小时 `:""}${l?`${l} 分 `:""}${a} 秒`},St=t=>({noClick:t.mature_users-t.clicked_users,noPay:t.clicked_users-t.exact_chain_paid_users,paid:t.exact_chain_paid_users}),Pt=t=>{let s=0;return t.coverage.map((i,l)=>{const a=i.count-s;return s=i.count,{count:a,mins:i.mins,label:["≤5 分钟","5–10 分钟","10–30 分钟","30 分钟–24 小时","24–48 小时"][l],short:["≤5","5–10","10–30","30分–24时","24–48"][l],unit:l<3?"分钟":l===3?"":"小时"}})};function Ae(){const t=N.useRef(null),[s,i]=N.useState(900);return N.useLayoutEffect(()=>{const l=t.current,a=()=>i(Math.max(220,l.clientWidth));a();const r=new ResizeObserver(a);return r.observe(l),()=>r.disconnect()},[]),[t,s]}const ne=(t,s,i,l,a)=>{const r=(t+i)/2;return`M${t},${s} C${r},${s} ${r},${l} ${i},${l} L${i},${l+a} C${r},${l+a} ${r},${s+a} ${t},${s+a} Z`},ue=(t,s,i,l,a)=>{const r=(s+l)/2;return`M${t},${s} C${t},${r} ${i},${r} ${i},${l} L${i+a},${l} C${i+a},${r} ${t+a},${r} ${t+a},${s} Z`},ke=t=>({onClick:t,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t())}});function B({x:t,y:s,title:i,value:l,sub:a="",anchor:r="start",tone:c=""}){return e.jsxs("text",{className:`flow-label ${c}`,x:t,y:s,textAnchor:r,children:[e.jsx("tspan",{className:"flow-caption",x:t,children:i}),e.jsxs("tspan",{className:"flow-value",x:t,dy:"32",children:[l,e.jsx("tspan",{className:"flow-unit",children:" 人"})]}),a&&e.jsx("tspan",{className:"flow-sub",x:t,dy:"23",children:a})]})}function Rt({cohort:t,mins:s}){const[i,l]=Ae(),[a,r]=N.useState("noClick"),c=l<650,n=St(t),v=t.mature_users,x=t.clicked_users,p=n.paid;if(!v)return e.jsx("p",{className:"admin-conversion-empty",children:"当前窗口暂无观察结束的免费批改用户。"});const y={noClick:{name:"未点击购买",count:n.noClick,base:v,denominator:"批改用户"},noPay:{name:"点击后未关联首购",count:n.noPay,base:x,denominator:"点击用户"},paid:{name:"精确关联首购",count:p,base:v,denominator:"批改用户"}}[a];let k,S,j;if(c){const d=(l-64)/v,b=12,u=72,g=12,o=220,T=l-12-n.noClick*d,A=220,f=12,$=382,h=l-86,_=382;k=[{id:"progress",d:ue(b,u+7,g,o,x*d),tone:"progress"},{id:"noClick",d:ue(b+x*d,u+7,T,A,n.noClick*d),tone:"muted"},{id:"paid",d:ue(g,o+7,f,$,p*d),tone:"paid"},{id:"noPay",d:ue(g+p*d,o+7,h,_,n.noPay*d),tone:"muted"}],S=[{x:b,y:u,width:v*d,height:7,tone:"base"},{x:g,y:o,width:x*d,height:7,tone:"progress"},{x:T,y:A,width:n.noClick*d,height:7,tone:"muted"},{x:f,y:$,width:p*d,height:7,tone:"paid"},{x:h,y:_,width:n.noPay*d,height:7,tone:"muted"}],j=e.jsxs(e.Fragment,{children:[e.jsx(B,{x:b,y:17,title:"免费批改完成",value:v}),e.jsx(B,{x:g,y:166,title:"点击购买",value:x}),e.jsx(B,{x:l-12,y:166,title:"窗口内未点击",value:n.noClick,anchor:"end"}),e.jsx(B,{x:f,y:414,title:"精确关联首购",value:p,tone:"brand"}),e.jsx(B,{x:l-12,y:414,title:"点击后未关联首购",value:n.noPay,anchor:"end"})]})}else{const d=205/v,b=4,u=l*.43,g=l-170,o=84,T=84,A=160,f=84,$=178;k=[{id:"progress",d:ne(b+7,o,u,T,x*d),tone:"progress"},{id:"noClick",d:ne(b+7,o+x*d,u,A,n.noClick*d),tone:"muted"},{id:"paid",d:ne(u+7,T,g,f,p*d),tone:"paid"},{id:"noPay",d:ne(u+7,T+p*d,g,$,n.noPay*d),tone:"muted"}],S=[{x:b,y:o,width:7,height:v*d,tone:"base"},{x:u,y:T,width:7,height:x*d,tone:"progress"},{x:u,y:A,width:7,height:n.noClick*d,tone:"muted"},{x:g,y:f,width:7,height:p*d,tone:"paid"},{x:g,y:$,width:7,height:n.noPay*d,tone:"muted"}],j=e.jsxs(e.Fragment,{children:[e.jsx(B,{x:b,y:20,title:"免费批改完成",value:v}),e.jsx(B,{x:u,y:20,title:"点击购买",value:x,sub:`${z(x,v)} 进入本步`}),e.jsx(B,{x:g,y:20,title:"精确关联首购",value:p,sub:`${z(p,x)} 点击后首购`,tone:"brand"}),e.jsx(B,{x:u+20,y:A+29,title:"窗口内未点击",value:n.noClick,sub:`占批改用户 ${z(n.noClick,v)}`}),e.jsx(B,{x:g+20,y:$+24,title:"点击后未关联首购",value:n.noPay,sub:`占点击用户 ${z(n.noPay,x)}`})]})}return e.jsxs("div",{className:"flow-component",ref:i,children:[e.jsx("svg",{viewBox:`0 0 ${l} ${c?470:350}
1`,className:"flow-svg",role:"img","aria-label":`免费批改${v}人,点击${x}人,首购${p}人;未点击${n.noClick}人,点击后未关联首购${n.noPay}人。带宽与人数成正比。`,children:e.jsxs("g",{"aria-hidden":"true",children:[k.map(d=>e.jsx("path",{d:d.d,className:`flow-ribbon ${d.tone} ${a===d.id?"is-selected":""}`,onClick:()=>d.id!=="progress"&&r(d.id)},d.id)),S.map((d,b)=>e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,className:`flow-node ${d.tone}`},b)),j]})}),e.jsx("div",{className:"flow-selections","aria-label":"选择流向",children:[["noClick","未点击",n.noClick],["noPay","点击后未关联首购",n.noPay],["paid","已首购",p]].map(([d,b,u])=>e.jsxs("button",{"aria-pressed":a===d,onClick:()=>r(d),children:[e.jsx("i",{className:`legend-dot ${d}`}),b,e.jsx("b",{children:u})]},d))}),e.jsxs("div",{className:"flow-inspection","aria-live":"polite",children:[e.jsx("span",{children:y.name}),e.jsxs("b",{children:[y.count," / ",y.base,e.jsxs("small",{children:[" 位",y.denominator]})]}),e.jsx("strong",{children:z(y.count,y.base)})]})]})}function Dt({pathCounts:t,timing:s}){const[i,l]=Ae(),[a,r]=N.useState("review"),c=t.total,n=t.reviewBeforePaid,v=t.noReviewBeforePaid,x=l<420,p=x?8:16,C=x?l-125:l-160,y=128,k=c?y/c:0,S=72,j=35,d=155;return c?e.jsxs("div",{ref:i,children:[e.jsxs("svg",{className:"payer-svg",viewBox:`0 0 ${l} 270`,role:"img","aria-label":`所选日期首购${c}人,付款前有已保存批改${n}人,无已保存批改${v}人。带宽按人数比例。`,children:[e.jsx("path",{d:ne(p+8,S,C,j,n*k),className:`flow-ribbon progress ${a==="review"?"is-selected":""}`,...ke(()=>r("review"))}),e.jsx("path",{d:ne(p+8,S+n*k,C,d,v*k),className:`flow-ribbon direct ${a==="direct"?"is-selected":""}`,...ke(()=>r("direct"))}),e.jsx("rect",{x:p,y:S,width:"8",height:y,className:"flow-node base"}),e.jsx("rect",{x:C,y:j,width:"8",height:n*k,className:"flow-node paid"}),e.jsx("rect",{x:C,y:d,width:"8",height:v*k,className:"flow-node base"}),e.jsx(B,{x:p,y:18,title:"全部首购",value:c}),e.jsx(B,{x:C+16,y:j+17,title:"有已保存批改",value:n,sub:z(n,c),tone:"brand"}),e.jsx(B,{x:C+16,y:d+17,title:"无已保存批改",value:v,sub:z(v,c)})]}),e.jsxs("div",{className:"flow-selections","aria-label":"首购路径",children:[e.jsxs("button",{"aria-pressed":a==="review",onClick:()=>r("review"),children:["有已保存批改 ",e.jsx("b",{children:n})]}),e.jsxs("button",{"aria-pressed":a==="direct",onClick:()=>r("direct"),children:["无已保存批改 ",e.jsx("b",{children:v})]})]}),e.jsx("div",{className:"path-statistics","aria-live":"polite",children:(a==="review"?[["30 分钟内首购",s.review.coverage.find(b=>b.mins===30).count],["30 分钟后首购",n-s.review.coverage.find(b=>b.mins===30).count]]:[["精确关联点击",s.directClick.n],["未精确关联",v-s.directClick.n]]).map(([b,u])=>e.jsxs("div",{children:[e.jsx("span",{children:b}),e.jsxs("strong",{children:[u,e.jsx("small",{children:" 人"})]})]},b))})]}):e.jsx("p",{className:"admin-conversion-empty",children:"所选日期暂无首购记录。"})}function It({timing:t}){const[s,i]=N.useState("review"),[l,a]=N.useState(null),[r,c]=Ae(),n=t?.[s]||{n:0,medianSeconds:null,coverage:[5,10,30,1440,2880].map(u=>({mins:u,count:0}))},v=Pt(n),x=30,p=176,C=28,y=c-8,k=(y-C)/5,S=Math.max(1,...v.map(u=>u.count)),j=S>5?3:1,d=Math.ceil(S/j)*j,b=n.coverage.find(u=>u.mins===30);return e.jsxs("div",{ref:r,children:[e.jsx("div",{className:"chart-switch",role:"group","aria-label":"耗时起点",children:[["review","批改完成后"],["click","购买点击后"]].map(([u,g])=>e.jsx("button",{"aria-pressed":s===u,onClick:()=>{i(u),a(null)},children:g},u))}),n.n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"duration-summary",children:[e.jsxs("div",{children:[e.jsx("span",{children:"中位耗时"}),e.jsx("strong",{children:Tt(n.medianSeconds)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"30 分钟内购买"}),e.jsxs("b",{children:[b.count,"/",n.n,e.jsx("small",{children:" 人"})]})]})]}),e.jsxs("svg",{className:"timing-svg",viewBox:`0 0 ${c} 244`,role:"group","aria-label":`${s==="review"?"批改完成":"精确关联点击"}到首购的耗时分布;${n.n}位首购用户;柱高代表人数,分组时长不同。`,children:[Array.from({length:d/j+1},(u,g)=>g*j).map(u=>e.jsxs("g",{"aria-hidden":"true",children:[e.jsx("line",{x1:C,x2:y,y1:p-u/d*(p-x),y2:p-u/d*(p-x),className:"hist-grid"}),e.jsx("text",{x:C-8,y:p-u/d*(p-x)+4,className:"hist-y",children:u})]},u)),v.map((u,g)=>
1{const o=C+k*g+k*.18,T=k*.64,A=u.count/d*(p-x);return e.jsxs("g",{className:`hist-bin ${l===g?"is-selected":""} ${g>2?"late":""}`,role:"button",tabIndex:"0","aria-label":`${u.label}:${u.count}人,占${z(u.count,n.n)}`,"aria-pressed":l===g,...ke(()=>a(g)),onFocus:()=>a(g),onMouseEnter:()=>a(g),onKeyDown:f=>{if(f.key==="ArrowRight"||f.key==="ArrowLeft"){f.preventDefault();const $=Math.max(0,Math.min(4,g+(f.key==="ArrowRight"?1:-1)));f.currentTarget.parentElement.querySelectorAll(".hist-bin")[$].focus()}else(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a(g))},children:[e.jsx("rect",{x:C+k*g,y:x-20,width:k,height:"220",fill:"transparent"}),e.jsx("rect",{x:o,y:p-A,width:T,height:A,className:"hist-bar"}),e.jsx("text",{x:o+T/2,y:p-A-9,className:"hist-value",children:u.count}),e.jsx("text",{x:o+T/2,y:201,className:"hist-x",children:g===3?e.jsxs(e.Fragment,{children:[e.jsx("tspan",{x:o+T/2,children:"30分"}),e.jsx("tspan",{x:o+T/2,dy:"17",children:"–24时"})]}):e.jsxs(e.Fragment,{children:[e.jsx("tspan",{x:o+T/2,children:u.short}),e.jsx("tspan",{x:o+T/2,dy:"17",children:u.unit})]})})]},u.mins)})]}),e.jsxs("div",{className:"histogram-reading","aria-live":"polite",children:[e.jsx("span",{children:l===null?`已首购样本 ${n.n} 人`:`${v[l].label} · ${v[l].count} / ${n.n} 人`}),e.jsx("b",{children:l===null?"":z(v[l].count,n.n)})]}),e.jsx("span",{className:"chart-unit",children:"柱高:人数 · 时间分组不等宽"})]}):e.jsx("p",{className:"admin-conversion-empty",children:"所选日期暂无可计时的首购记录。"})]})}function Mt({values:t}){if(!t?.length)return null;const s=Math.max(1,...t),i=t.map((l,a)=>`${a/Math.max(1,t.length-1)*160},${40-l/s*32}`).join(" ");return e.jsxs("svg",{className:"sparkline",viewBox:"0 0 160 46",role:"img","aria-label":`每日走势,独立零基线,最高${s}人,首日${t[0]}人,末日${t.at(-1)}人`,children:[e.jsx("line",{x1:"0",x2:"160",y1:"40",y2:"40"}),e.jsx("polyline",{points:i})]})}const ze=[["registrations","注册成功",null],["completed_users","批改完成","completed_events"],["linked_click_users","已关联购买点击","linked_click_events"],["first_paid_users","首次付费",null]],Ft=[[5,"5 分钟"],[10,"10 分钟"],[30,"30 分钟"],[2880,"48 小时"]],Bt=(t,s)=>s?`${(t/s*100).toFixed(1)}%`:"—",ge=t=>t?.replaceAll("-",".")||"—",X=t=>Number(t||0).toLocaleString("zh-CN");function ve({label:t,value:s,onChange:i,options:l}){return e.jsx(U,{label:t,children:l.map(([a,r])=>e.jsx(D,{isActive:s===a,onClick:()=>i(a),children:r},a))})}function Ut({report:t,requestedDays:s,isLoading:i,locale:l,onRangeChange:a,LineChart:r}){const[c,n]=N.useState("overview"),[v,x]=N.useState(30),[p,C]=N.useState(null),[y,k]=N.useState("users"),S=t?.filters?.days===s,j=!i&&(!t?.available||!S),d=t?.daily||[],b=t?.periodTotals||{},u=t?.mainCohort?.find(A=>A.mins===v),g=A=>{C(A),n("trends")},o=ge(t?.coverage?.rangeStart),T=ge(t?.coverage?.rangeEnd);return e.jsxs("section",{className:"admin-conversion-overview","aria-label":"转化分析",children:[e.jsxs("div",{className:"admin-conversion-toolbar",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"转化分析"}),e.jsx("p",{children:!i&&t?.available?`${o} — ${T} · UTC 完整自然日`:"UTC 完整自然日"})]}),e.jsx(V,{children:e.jsx(ve,{label:"报表日期",value:s,onChange:a,options:[[7,"近 7 天"],[30,"近 30 天"],[90,"近 90 天"]]})})]}),e.jsx("div",{className:"admin-conversion-views",role:"group","aria-label":"转化分析视图",children:[["overview","转化总览"],["trends","规模与趋势"]].map(([A,f])=>e.jsx("button",{type:"button","aria-pressed":c===A,onClick:()=>{n(A),C(null)},children:f},A))}),i?e.jsx("div",{className:"admin-data-panel admin-conversion-state",role:"status",children:"正在读取转化数据…"}):null,j?e.jsx("div",{className:"admin-data-panel admin-conversion-state",role:"status",children:t?.reason==="first_party_tables_unavailable"?"转化数据表尚未准备好。":"所选日期暂无完整的可用数据。"}):null,!i&&S&&t?.available?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"admin-conversion-metrics","aria-label":"同期绝对值",children:ze.map(([A,f,$])=>e.jsxs("button",{type:"button",className:"admin-conversion-metric",onClick:()=>g(A),"aria-label":`${f} ${X(b[A])} 人,查看每日趋势`,children:[e.jsx("span",{children:f}),e.jsxs("strong",{children:[X(b[A]),e.jsx("small",{children:" 人"})]}),e.jsx(Mt,{values:d.map(h=>h[A])}),e.jsx("small",{children:$?`${X(b[$])} 次 · 区间去重`:"区间人数"})]},A))}),e.jsxs("div",{className:"admin-conversion-coverage",children:[e.jsx("span",{children:"访客:待补齐"}),e.jsx("span",{children:"提交受理:待补齐"}),e.jsx("span",{children:"当前“批改”按完成保存计"})]}),c==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"admin-data-panel admin-conversion-flow-panel","aria-label":"免费批改后转化",children:[e.jsxs("div",{className:"admin-conversion-panel-heading",children:[e.jsxs("div",{children:[e.jsx("span",{children:"本期首次完成免费批改的用户"}),e.jsx("h3",{children:"免费批改 → 首次付费"})]}),e.jsxs("div",{className:"admin-conversion-main-rate",children:[e.jsx("strong",{children:Bt(u?.exact_chain_paid_users,u?.mature_users)}),e.jsx("small",{children:"精确关联首购 / 观察结束"})]})]}),e.jsxs("div",{className:"admin-conversion-flow-toolbar",children:[e.jsx(V,{children:e.jsx(ve,{label:"批改完成后",value:v,onCh
1ange:x,options:Ft})}),e.jsxs("span",{children:["观察结束 ",X(u?.mature_users)," 人",u?.pending_users?` · 观察中 ${X(u.pending_users)} 人`:""]})]}),u?e.jsx(Rt,{cohort:u,mins:v}):null,u?.paid_users>u?.exact_chain_paid_users?e.jsxs("p",{className:"admin-conversion-data-gap",children:["另有 ",X(u.paid_users-u.exact_chain_paid_users)," 位窗口内首购,缺少精确点击关联。"]}):null,e.jsxs("details",{className:"admin-conversion-definition",children:[e.jsx("summary",{children:"统计口径"}),e.jsx("p",{children:"起点是账号首条明确免费批改的完成保存时间。分母只含选定窗口已观察结束的账号;购买点击和精确关联首购按顺序发生在同一窗口内。超窗付款仍计入同期首购总量。"})]})]}),e.jsxs("div",{className:"admin-conversion-pair",children:[e.jsxs("section",{className:"admin-data-panel",children:[e.jsx("div",{className:"admin-conversion-panel-heading",children:e.jsxs("div",{children:[e.jsxs("span",{children:["所选日期首购 · ",X(t.pathCounts.total)," 人"]}),e.jsx("h3",{children:"首购路径"})]})}),e.jsx(Dt,{pathCounts:t.pathCounts,timing:t.timing}),e.jsxs("details",{className:"admin-conversion-definition",children:[e.jsx("summary",{children:"记录范围"}),e.jsx("p",{children:"“无已保存批改”可能包含已提交但尚未完成的作文。归类按首购前的已保存批改记录计算。"})]})]}),e.jsxs("section",{className:"admin-data-panel",children:[e.jsx("div",{className:"admin-conversion-panel-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"所选日期首购"}),e.jsx("h3",{children:"购买耗时"})]})}),e.jsx(It,{timing:t.timing})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"admin-conversion-trends-toolbar",children:[e.jsx("h3",{children:"每日趋势"}),e.jsx(V,{children:e.jsx(ve,{label:"计数",value:y,onChange:k,options:[["users","人数"],["events","次数"]]})})]}),p?e.jsx("button",{type:"button",className:"admin-conversion-back",onClick:()=>C(null),children:"← 全部指标"}):null,e.jsx("div",{className:`admin-conversion-daily-grid ${p?"is-focused":""}`,children:ze.map(([A,f,$],h)=>{if(p&&A!==p)return null;const _=y==="events",w=_&&$?$:A,P=_?"次":"人";return e.jsx(r,{daily:d.map(R=>({...R,date:R.day})),locale:l,title:`${String(h+1).padStart(2,"0")} · ${f}${_?"次数":"人数"}`,description:_?"每日发生次数":"每日去重人数",emptyText:"暂无已核实的每日记录",unitLabel:P,valueLabel:_?"次数":"人数",valueKey:w,formatDetail:$?R=>_?`当日 ${R[A]} 人`:`当日 ${R[$]} 次`:void 0},`${A}-${y}`)})}),e.jsxs("details",{className:"admin-conversion-daily-detail",children:[e.jsx("summary",{children:"每日明细"}),e.jsx("div",{className:"admin-conversion-table-scroll",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"UTC 日期"}),e.jsx("th",{children:"注册"}),e.jsx("th",{children:"批改人数 / 次数"}),e.jsx("th",{children:"点击人数 / 次数"}),e.jsx("th",{children:"首购"})]})}),e.jsx("tbody",{children:d.map(A=>e.jsxs("tr",{children:[e.jsx("td",{children:A.day}),e.jsx("td",{children:A.registrations}),e.jsxs("td",{children:[A.completed_users," / ",A.completed_events]}),e.jsxs("td",{children:[A.linked_click_users," / ",A.linked_click_events]}),e.jsx("td",{children:A.first_paid_users})]},A.day))})]})})]})]}),e.jsxs("p",{className:"admin-conversion-source",children:["已排除配置中的内部账号 · 点击人数仅含已关联账号 · 截至 ",ge(t.coverage.asOf.slice(0,10))," 00:00 UTC"]})]}):null]})}const J=[{id:ce,label:"Overview"},{id:K,label:"Trends"},{id:ee,label:"Channel trends"},{id:Y,label:"Visits → submissions"},{id:te,label:"Purchase clicks"},{id:Q,label:"Conversion overview"}];function Wt({activeTab:t,onTabChange:s}){const i=N.useRef([]),l=(a,r)=>{let c=null;if(a.key==="ArrowRight"?c=(r+1)%J.length:a.key==="ArrowLeft"?c=(r-1+J.length)%J.length:a.key==="Home"?c=0:a.key==="End"&&(c=J.length-1),c==null)return;a.preventDefault();const n=J[c];i.current[c]?.focus(),s(n.id)};return e.jsx(V,{className:"admin-tabs","aria-label":"Admin sections",children:e.jsx(Ye,{label:"Admin sections",role:"tablist",children:J.map((a,r)=>
1{const c=a.id===t;return e.jsx(D,{"aria-controls":`admin-panel-${a.id}`,"aria-pressed":void 0,"aria-selected":c,id:`admin-tab-${a.id}`,isActive:c,itemRef:n=>{i.current[r]=n},onClick:()=>s(a.id),onKeyDown:n=>l(n,r),role:"tab",tabIndex:c?0:-1,children:a.label},a.id)})})})}function Et({pricingHref:t}){const[s,i]=N.useState("loading"),[l,a]=N.useState(!1),[r,c]=N.useState(""),n=s==="vietnam";N.useEffect(()=>{const S=new AbortController;return fetch("/api/admin/billing-market-preview",{headers:{Accept:"application/json"},signal:S.signal}).then(async j=>{const d=await j.json().catch(()=>({}));if(!j.ok)throw new Error(d.error||"Billing market preview could not be loaded.");i(d.market==="vietnam"?"vietnam":"actual")}).catch(j=>{j?.name!=="AbortError"&&(i("actual"),c(j instanceof Error?j.message:"Billing market preview could not be loaded."))}),()=>S.abort()},[]);const v=async S=>{a(!0),c("");try{const j=await fetch("/api/admin/billing-market-preview",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({market:S})}),d=await j.json().catch(()=>({}));if(!j.ok)throw new Error(d.error||"Billing market preview could not be updated.");const b=d.market==="vietnam"?"vietnam":"actual";if(i(b),b==="vietnam"){window.location.assign(t);return}window.location.reload()}catch(j){c(j instanceof Error?j.message:"Billing market preview could not be updated.")}finally{a(!1)}},x=s==="loading",p=x||l?"VN…":r?"VN error":n?"VN on":"VN",C=r?`Vietnam pricing preview error: ${r}`:x?"Checking Vietnam pricing preview status.":l?"Updating Vietnam pricing preview.":n?"Vietnam pricing preview is active for this browser.":"Vietnam pricing preview is off.",y=n?"Vietnam pricing preview is on. Click to turn it off.":"Vietnam pricing preview is off. Click to turn it on.",k=n?`Vietnam preview is on: $6.99 recurring monthly, with 10% off the first payment for eligible new users using ${Ve}. Click to turn it off.`:`Preview Vietnam pricing: $6.99 recurring monthly, with 10% off the first payment for eligible new users using ${Ve}.`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-label":y,"aria-pressed":n,className:["admin-billing-market-preview-button","secondary-button",n?"is-active":""].filter(Boolean).join(" "),disabled:x||l,onClick:()=>v(n?"actual":"vietnam"),title:r||k,type:"button",children:p}),e.jsx("span",{"aria-atomic":"true","aria-live":r?"assertive":"polite",className:"visually-hidden",role:r?"alert":"status",children:C})]})}function bs({activeTab:t,locale:s,t:i,authUser:l,isAuthLoading:a,overview:r,isLoading:c,error:n,homeHref:v,pricingHref:x,onRefresh:p,onSignIn:C,onBackHome:y,onTabChange:k,RouteStateCardComponent:S,resolveSubmissionCanonicalPath:j,resolveSubmissionFreePreviewPath:d}){const b=S,[u,g]=N.useState(1),[o,T]=N.useState(1),[A,f]=N.useState("user"),[$,h]=N.useState(null),[_,w]=N.useState(30),[P,R]=N.useState({conversionDays:30,conversionDevice:"all"}),[W,E]=N.useState(30),[de,Z]=N.useState(1),[ct,Re]=N.useState(30),[ot,De]=N.useState({ctaConversionGranularity:"week",ctaConversionWeeks:8,ctaConversionDays:30}),[dt,Ie]=N.useState("all"),[ut,Me]=N.useState("all"),[Fe,Be]=N.useState(30),Ue=N.useRef(null),le=N.useRef(void 0);N.useEffect(()=>{if(t===Y){R({conversionDays:30,conversionDevice:"all"});return}if(t===Q){Be(30);return}if(t===K){w(30);return}if(t===ee){E(30);return}if(t===te){Z(1),Re(30),De({ctaConversionGranularity:"week",ctaConversionWeeks:8,ctaConversionDays:30}),Me("all"),Ie("all");return}g(1),T(1),f("user"),h(null),le.current=void 0},[t]),N.useEffect(()=>{const m=le.current;if(m===void 0||c||r?.section!==ce||(r?.submissionsUser?.id??null)!==m)return;const q=Ue.current,jt=q?.querySelector("h2");le.current=void 0,q?.scrollIntoView({block:"start"}),jt?.focus({preventScroll:!0})},[c,r]);const M=(m={})=>{if(t===Q){p({section:Q,conversionRangeDays:m.conversionRangeDays??Fe});return}if(t===Y){p({section:Y,...P,...m});return}if(t===K){p({section:K,trendsRangeDays:m.trendsRangeDays??_});return}if(t===ee){p({section:ee,channelRangeDays:m.channelRangeDays??W});return}if(t===te){p({section:te,...ot,...m,ctaClicksPage:m.ctaClicksPage??de,ctaRangeDays:m.ctaRangeDays??ct,ctaRegistration:m.ctaRegistration??ut,ctaDevice:m.ctaDevice??dt});return}p({section:ce,usersPage:m.usersPage??u,submissionsPage:m.submissionsPage??o,submissionsSource:m.submissionsSource??A,submissionsUserId:Object.prototype.hasOwnProperty.call(m,"submissionsUserId")?m.submissionsUserId:$?.id})};if(a)return e.jsx(b,{title:"Loading admin dashboard",description:"Checking your sign-in session before loading admin data.",t:i,isLoading:!0,onRetry:null,homeHref:v,onBackHome:y});if(!l)return e.jsx("section",{className:"admin-page","aria-labelledby":"admin-title",children:e.jsxs("div",{className:"admin-header",children:[e.jsxs("div",{children:[e.jsx("span",{className:"content-eyebrow",children:"Internal"}),e.jsx(Le,{id:"admin-title",variant:"utility",children:"Admin dashboard"}),e.jsx("p",{children:"Sign in with an admin Google account to view user, writing, and order data."})]}),e.jsxs("div",{className:"admin-actions",children:[e.jsx("a",{className:"secondary-button",href:v,onClick:y,children:"Back home"}),e.jsx("button",{className:"primary-button",type:"button",onClick:C,children:"Sign in"})]})]})});const I=r?.section===t?r:null,H=I?.summary||{},ht=I?.users||[],mt=I?.submissions||[],pt=I?.orders||[],xt=I?.trends||null,bt=I?.channelTrends||null,gt=I?.writingUserConversions||null,vt=I?.purchaseCta||null,yt=I?.conversionOverview||null,We=m=>{const q={id:m.id,email:m.email||"",name:m.name||"",picture:m.picture||""};le.current=q.id,h(q),f("all"),T(1),M({submissionsPage:1,submissionsSource:"all",submissionsUserId:q.id})};return e.jsxs("section",{className:"admin-page","aria-labelledby":"admin-title",children:[e.jsxs("div",{className:"admin-header",children:[e.jsxs("div",{children:[e.jsx("span",{className:"content-eyebrow",children:"Internal"}),e.jsx(Le,{id:"admin-title",variant:"utility",children:"Admin dashboard"})]}),e.jsxs("div",{className:"admin-actions",children:[e.jsx(Et,{pricingHref:x}),e.jsx("a",{className:"secondary-button",href:v,onClick:y,children:"Back home"}),e.jsx("button",{className:"primary-button",type:"button",onClick:()=>
1M(),disabled:c,children:c?"Loading...":"Refresh"})]})]}),n?e.jsx("div",{className:"history-error",children:n}):null,e.jsx(Wt,{activeTab:t,onTabChange:k}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==Q,id:"admin-panel-conversion-overview",role:"tabpanel","aria-labelledby":"admin-tab-conversion-overview",children:t===Q?e.jsx(Ut,{report:yt,requestedDays:Fe,isLoading:c,locale:s,LineChart:ae,onRangeChange:m=>{Be(m),p({section:Q,conversionRangeDays:m})}}):null}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==Y,id:"admin-panel-writing-conversion",role:"tabpanel","aria-labelledby":"admin-tab-writing-conversion",children:t===Y?e.jsx($t,{report:I?.writingConversion,isLoading:c,error:n,locale:s,historyReport:I?.writingConversionHistory,filters:P,LineChart:ae,onChange:m=>{R(m),p({section:Y,...m})}}):null}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==ee,id:"admin-panel-channel-trends",role:"tabpanel","aria-labelledby":"admin-tab-channel-trends",children:t===ee?e.jsx(zt,{channelTrends:bt,isLoading:c,locale:s,onRangeChange:m=>{E(m),M({channelRangeDays:m})},writingUserConversions:gt}):null}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==K,id:"admin-panel-trends",role:"tabpanel","aria-labelledby":"admin-tab-trends",children:t===K?e.jsx(Vt,{trends:xt,isLoading:c,locale:s,onRangeChange:m=>{w(m),M({trendsRangeDays:m})}}):null}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==te,id:"admin-panel-purchase-clicks",role:"tabpanel","aria-labelledby":"admin-tab-purchase-clicks",children:t===te?e.jsx(Jt,{analytics:vt,onConversionChange:m=>{De(q=>({...q,...m})),M(m)},isLoading:c,locale:s,onPageChange:m=>{Z(m),M({ctaClicksPage:m})},onRangeChange:m=>{Re(m),Z(1),M({ctaClicksPage:1,ctaRangeDays:m})},onDeviceChange:m=>{Ie(m),Z(1),M({ctaClicksPage:1,ctaDevice:m})},onRegistrationChange:m=>{Me(m),Z(1),M({ctaClicksPage:1,ctaRegistration:m})}}):null}),e.jsx("div",{className:"admin-tab-panel",hidden:t!==ce,id:"admin-panel-overview",role:"tabpanel","aria-labelledby":"admin-tab-overview",children:t===ce?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"admin-summary-grid","aria-label":"Admin summary",children:[e.jsx(L,{label:"Registered users",value:H.totalUsers}),e.jsx(L,{label:"User submissions",value:H.userSubmissions??H.totalSubmissions}),e.jsx(L,{label:"Access records",value:H.totalOrders}),e.jsx(L,{label:"Active access",value:H.activeOrders}),e.jsx(L,{emptyValue:"—",label:"Local unreviewed writing",value:H.localUnreviewedWriting}),e.jsx(L,{label:"Same-question pages",value:H.sameQuestionPages}),e.jsx(L,{label:"Published tag pages",value:H.publishedTagPages})]}),e.jsx(re,{title:"Registered users",description:"Registered accounts, signup attribution, submission count, and current access status.",emptyText:c?"Loading users...":"No registered users yet.",rows:ht,isBusy:c,pagination:e.jsx(Pe,{label:"Registered users",pagination:I?.usersPagination,isLoading:c,onPageChange:m=>{g(m),M({usersPage:m})}}),columns:[{key:"id",label:"ID",render:m=>m.id},{key:"user",label:"User",render:m=>e.jsx(pe,{email:m.email,name:m.name||"No name",picture:m.picture})},{key:"createdAt",label:"Joined",render:m=>O(m.createdAt,s)},{key:"signupSource",label:"Attribution",render:m=>rt(m.signupSource)},{key:"signupLandingPath",label:"Landing page",render:m=>m.signupLandingPath?e.jsx("code",{title:m.signupLandingPath,children:m.signupLandingPath}):"—"},{key:"lastLoginAt",label:"Last login",render:m=>O(m.lastLoginAt,s)||"-"},{key:"lastActiveAt",label:"Last active",render:m=>O(m.lastActiveAt,s)||"-"},{key:"submissionCount",label:"Reviews",render:m=>e.jsx(Ze,{isLoading:c,onClick:()=>We(m),submissionCount:m.submissionCount,userLabel:m.email||m.name||`user ${m.id}`})},{key:"status",label:"Access",render:m=>e.jsx(Xe,{status:m.accessStatus})}]}),e.jsx(cs,{panelRef:Ue,isLoading:c,locale:s,resolveSubmissionCanonicalPath:j,resolveSubmissionFreePreviewPath:d,submissions:mt,summary:I?.submissionsSummary||H,pagination:I?.submissionsPagination,sourceFilter:A,userFilter:$,onClearUserFilter:()=>{le.current=null,h(null),f("user"),T(1),M({submissionsPage:1,submissionsSource:"user",submissionsUserId:null})},onPageChange:m=>{T(m),M({submissionsPage:m})},onSourceChange:m=>{f(m),T(1),M({submissionsPage:1,submissionsSource:m})}}),e.jsx(re,{title:"Orders / subscriptions",description:"Latest 50 recurring subscriptions and one-time access-pass records from Creem-linked billing data.",emptyText:c?"Loading orders...":"No order or subscription records yet.",rows:pt,isBusy:c,columns:[{key:"updatedAt",label:"Updated",render:m=>O(m.updatedAt,s)},{key:"user",label:"User",render:m=>e.jsx(pe,{email:m.userEmail,name:m.userName||`User #${m.userId}`,picture:m.userPicture})},{key:"submissionCount",label:"Reviews",render:m=>e.jsx(Ze,{isLoading:c,onClick:()=>We({id:m.userId,email:m.userEmail,name:m.userName,picture:m.userPicture}),submissionCount:m.submissionCount,userLabel:m.userEmail||m.userName||`user ${m.userId}`})},{key:"status",label:"Status",render:m=>e.jsx(Xe,{status:m.status})},{key:"accessStartsAt",label:"Access from",render:m=>
1O(m.accessStartsAt,s)||"-"},{key:"accessExpiresAt",label:"Access until",render:m=>O(m.accessExpiresAt,s)||"-"},{key:"creemReferenceId",label:"Creem reference",render:m=>e.jsx(se,{value:m.creemReferenceId})},{key:"cancelAtPeriodEnd",label:"Cancels",render:m=>m.cancelAtPeriodEnd?"Yes":"No"}]})]}):null})]})}const me=[{value:7,label:"7 days"},{value:30,label:"30 days"},{value:90,label:"90 days"}],Lt=[{value:"all",label:"All visitors"},{value:"registered",label:"With registration ID"},{value:"anonymous",label:"No registration ID"}];function Vt({trends:t,isLoading:s,locale:i,onRangeChange:l}){const a=t?.filters||{days:30},r=t?.totals||{},c=Array.isArray(t?.daily)?t.daily:[],n=t?.coverage?.freeReviewsStartDate||"",v=n?c.filter(x=>x.date>=n):[];return e.jsxs(e.Fragment,{children:[e.jsx(V,{"aria-label":"Growth trend filters",children:e.jsx(U,{label:"Date range",children:me.map(x=>e.jsx(D,{isActive:a.days===x.value,onClick:()=>l(x.value),children:x.label},x.value))})}),e.jsxs("div",{className:"admin-summary-grid","aria-label":"Growth trend summary",children:[e.jsx(L,{emptyValue:"—",label:"New users",value:t?r.registrations:null}),e.jsx(L,{emptyValue:"—",label:"Completed reviews",value:t?r.reviews:null}),e.jsx(L,{emptyValue:"—",label:"Users / day",value:t?qe(r.registrations,a.days):null}),e.jsx(L,{emptyValue:"—",label:"Reviews / day",value:t?qe(r.reviews,a.days):null})]}),e.jsxs("div",{className:"admin-trend-chart-grid",children:[e.jsx(ae,{daily:c,description:"New real user accounts created on each UTC day. System import and benchmark accounts are excluded.",emptyText:s?"Loading registration trend...":"No registration data in this range.",isBusy:s,locale:i,title:"Daily registrations",unitLabel:"registrations",valueKey:"registrations"}),e.jsx(ae,{daily:c,description:"Successful user writing reviews saved on each UTC day. Public-sample imports and benchmarks are excluded.",emptyText:s?"Loading review trend...":"No review data in this range.",isBusy:s,locale:i,title:"Daily completed reviews",unitLabel:"completed reviews",valueKey:"reviews"}),e.jsx(ae,{daily:v,description:`Successful reviews saved while the account was on Free. This submission-time snapshot never changes after an upgrade.${n?` Complete daily snapshot data is available from ${xe(n,i)}.`:" Snapshot data begins with the next saved review."}`,emptyText:s?"Loading free-user review trend...":"No submission-time access snapshots in this range.",isBusy:s,locale:i,title:"Daily free-user reviews",unitLabel:"free-user reviews",valueKey:"freeReviews"})]})]})}const Ot=[{id:"home",label:"Home"},{id:"correction",label:"Correction pages"},{id:"pricing",label:"Pricing"},{id:"checker_landing",label:"Checker landing pages"},{id:"public_sample",label:"Public sample pages"},{id:"other",label:"Other"}],Ge=new Set(["home","correction","pricing"]),oe=[{id:"submitter_click",label:"Clicked purchase button",shortLabel:"Button click",valueKey:"clickRate",numeratorKey:"clickedUsers"},{id:"submitter_paid",label:"Completed first payment",shortLabel:"First payment",valueKey:"purchaseRate",numeratorKey:"paidUsers"}],Ht=[{maximum:25,step:5},{maximum:30,step:5},{maximum:40,step:10}
1,{maximum:50,step:10},{maximum:75,step:25},{maximum:100,step:25},{maximum:150,step:25},{maximum:200,step:50},{maximum:250,step:50},{maximum:300,step:50},{maximum:400,step:100},{maximum:500,step:100}];function zt({channelTrends:t,isLoading:s,locale:i,onRangeChange:l,writingUserConversions:a}){const r=t?.filters||{days:30},c=Array.isArray(t?.daily)?t.daily:[],[n,v]=N.useState(()=>new Set(Ge)),x=Ot.filter(j=>Ge.has(j.id)||c.some(d=>{const b=d.channels?.[j.id]||{};return b.impressions||b.clicks||b.purchases})),p=x.filter(j=>n.has(j.id)),C=Yt(t?.coverage),y=t?.available===!1,k=e.jsx(U,{label:"Date range",children:me.map(j=>e.jsx(D,{isActive:r.days===j.value,onClick:()=>l(j.value),children:j.label},j.value))}),S=j=>{v(d=>{const b=new Set(d);if(b.has(j)){if(p.length===1)return d;b.delete(j)}else b.add(j);return b})};return e.jsxs(e.Fragment,{children:[e.jsxs(V,{"aria-label":"Channel trend filters",children:[k,y?null:e.jsx(U,{label:"Channels",children:x.map(j=>e.jsxs(D,{isActive:n.has(j.id),onClick:()=>S(j.id),children:[e.jsx("span",{className:`admin-channel-trend__legend-line admin-channel-trend__legend-line--${j.id}`,"aria-hidden":"true"}),j.label]},j.id))})]}),y?e.jsx(re,{title:"Channel conversion trends",description:"The required channel-trend source for this date range is unavailable.",emptyText:"Channel trend data is temporarily unavailable.",rows:[],isBusy:s,columns:[]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"admin-channel-trends__note",children:[e.jsx("strong",{children:"Source boundary:"})," ",C]}),e.jsxs("div",{className:"admin-channel-trend-grid",children:[e.jsx(he,{channels:p,daily:c,description:"Unique people who saw a purchase button, once per day and channel. GA4 through Aug 21; D1 from Aug 22.",emptyText:s?"Loading channel viewer counts...":"No channel viewer data in this range.",isBusy:s,locale:i,metricKey:"impressions",title:"Daily purchase-button viewers",valueKind:"count"}),e.jsx(he,{channels:p,daily:c,description:"Unique people who clicked a purchase button. GA4 through Aug 21; D1 from Aug 22, grouped by the original UTC viewing day.",emptyText:s?"Loading channel click counts...":"No channel click data in this range.",isBusy:s,locale:i,metricKey:"clicks",title:"Daily purchase-button clickers",valueKind:"count"}),e.jsx(he,{channels:p,daily:c,denominatorKey:"impressions",description:"Unique clickers ÷ unique viewers. GA4 through Aug 21; D1 viewing cohorts from Aug 22. Zero-denominator days are plotted at 0%.",emptyText:s?"Loading channel click rates...":"No channel click-rate data in this range.",isBusy:s,locale:i,metricKey:"clickThroughRate",numeratorKey:"clicks",title:"Daily purchase-button click rate",valueKind:"rate"}),e.jsx(he,{channels:p,daily:c,denominatorKey:"clicks",description:"First-time payers ÷ unique clickers. GA4 through Aug 21; D1 exactly attributed payers from Aug 22. Later D1 payments update the original viewing cohort.",emptyText:s?"Loading channel payment rates...":"No channel payment-rate data in this range.",isBusy:s,locale:i,metricKey:"clickToPurchaseRate",numeratorKey:"purchases",title:"Daily click-to-paid conversion",valueKind:"rate"})]})]}),e.jsx(Gt,{title:"Daily submitter conversion rates",description:a?.available===!1?"The first-party user-conversion source for this date range is unavailable.":"Each UTC day is a cohort of unique users who completed a writing review. Both lines use those submitters as the denominator and ignore page. Later clicks or first payments update the cohort, so recent dates can rise; complete tracking starts Aug 13, 2026.",daily:Array.isArray(a?.daily)?a.daily:[],emptyText:s?"Loading writing-user conversion...":a?.available===!1?"Writing-user conversion data is temporarily unavailable.":"No writing users in this tracked range.",isBusy:s,locale:i})]})}function Gt({daily:t,description:s,emptyText:i,isBusy:l,locale:a,title:r}){const[c,n]=N.useState(900),v=N.useRef(null),x="daily-submitter-conversion-rates-title",p=`${x}-reading`,C=N.useMemo(()=>t.map(u=>({...u,dataSource:"submitter_cohort",channels:Object.fromEntries(oe.map(g=>[g.id,{rate:u[g.valueKey]}]))})),[t]),y=N.useMemo(()=>Ke(C,oe,"rate","rate",c),[C,c]),{chartInspectionProps:k,resetActiveIndex:S,resolvedActiveIndex:j}=_e({itemCount:y.dates.length,plotLeft:y.plotLeft,plotWidth:y.plotWidth,viewBoxWidth:y.viewBoxWidth}),d=j==null?null:y.dates[j],b=j==null?null:t[j];return N.useLayoutEffect(()=>{const u=v.current;if(!u)return;const g=()=>{const T=Math.max(220,Math.min(960,Math.floor(u.clientWidth-4)));n(A=>A===T?A:T)},o=typeof ResizeObserver>"u"?null:new ResizeObserver(g);return g(),o?.observe(u),window.addEventListener("resize",g),()=>{o?.disconnect(),window.removeEventListener("resize",g)}},[t.length]),N.useEffect(()=>{S()},[t,S]),e.jsxs("section",{className:"admin-data-panel admin-submitter-conversion-chart","aria-labelledby":x,"aria-busy":l?"true":"false",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{id:x,children:r}),e.jsx("p",{children:s})]})}),y.dates.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"admin-submitter-conversion-chart__legend","aria-label":"Chart series",children:oe.map(u=>e.jsxs("li",{children:[e.jsx("span",{"aria-hidden":"true",className:`admin-submitter-conversion-chart__legend-line admin-submitter-conversion-chart__legend-line--${u.id}`}),u.label]},u.id))}),e.jsx("div",{className:"admin-trend-chart__canvas",ref:v,children:e.jsxs("svg",{className:"admin-trend-chart__svg",viewBox:`0 0 ${y.viewBoxWidth} ${y.viewBoxHeight}`,role:"img","aria-describedby":p,"aria-label":`${r} line chart. Use left and right arrow keys to inspect each UTC submission day.`,...k,children:[y.yTicks.map(u=>e.jsxs("g",{children:[e.jsx("line",{className:"admin-trend-chart__grid-line",x1:y.plotLeft,x2:y.plotRight,y1:u.y,y2:u.y}),e.jsx("text",{className:"admin-trend-chart__axis-label admin-trend-chart__axis-label--y",x:y.plotLeft-10,y:u.y+4,children:tt(u.value,"rate")})]},u.value)),e.jsx(Te,{locale:a,ticks:y.xTicks,viewBoxHeight:y.viewBoxHeight}),y.series.map(u=>e.jsxs("g",{children:[u.segments.map((g,o)=>e.jsx("polyline",{className:`admin-channel-trend-chart__line admin-submitter-conversion-chart__line--${u.id}`,points:g.map(T=>`${T.x},${T.y}`).join(" ")},`${u.id}-${o}`)),u.points.filter(g=>g.value!=null).map(g=>e.jsx("circle",{className:`admin-channel-trend-chart__point admin-submitter-conversion-chart__point--${u.id}`,cx:g.x,cy:g.y,r:g.index===j?5:2.5},`${u.id}-${g.date}`))]},u.id)),j!=null?e.jsxs(e.Fragment,{children:[e.jsx("line",{className:"admin-trend-chart__active-guide",x1:d.x,x2:d.x,y1:y.plotTop,y2:y.plotBottom}),e.jsx(Se,{date:d.date,height:y.tooltipHeight,locale:a,sourceLabel:"UTC submission cohort",width:y.tooltipWidth,x:d.tooltipX,y:d.tooltipY,children:oe.map((u,g)=>{const o=y.tooltipContentTop+g*y.tooltipRowHeight,T=Math.max(0,Number(b?.[u.numeratorKey])||0),A=Math.max(0,Number(b?.submittingUsers)||0),f=b?.[u.valueKey];return e.jsxs("g",{children:[e.jsx("line",{className:`admin-channel-trend-chart__tooltip-line admin-submitter-conversion-chart__line--${u.id}`,x1:"12",x2:y.compactTooltip?24:28,y1:o-4,y2:o-4}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-label",x:y.
1compactTooltip?30:36,y:o,children:y.compactTooltip?u.shortLabel:u.label}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-value",textAnchor:"end",x:y.tooltipWidth-12,y:o,children:ie(f)}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-detail",x:y.compactTooltip?12:36,y:o+15,children:et({compact:y.compactTooltip,denominator:A,numerator:T})})]},u.id)})})]}):null]})}),e.jsx("p",{className:"visually-hidden",id:p,"aria-live":"polite",children:d?Zt({activeDate:d,activeRow:b,locale:a}):"Focus or hover over the chart to inspect daily values."}),e.jsx("div",{className:"visually-hidden",children:e.jsxs("table",{children:[e.jsxs("caption",{children:[r," source data by UTC submission day"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Submission date"}),e.jsx("th",{scope:"col",children:"Submitting users"}),e.jsx("th",{scope:"col",children:"Clicked users"}),e.jsx("th",{scope:"col",children:"Click rate"}),e.jsx("th",{scope:"col",children:"Paid users"}),e.jsx("th",{scope:"col",children:"Purchase rate"})]})}),e.jsx("tbody",{children:t.map(u=>e.jsxs("tr",{children:[e.jsx("td",{children:u.date}),e.jsx("td",{children:u.submittingUsers}),e.jsx("td",{children:u.clickedUsers}),e.jsx("td",{children:ie(u.clickRate)}),e.jsx("td",{children:u.paidUsers}),e.jsx("td",{children:ie(u.purchaseRate)})]},u.date))})]})})]}):e.jsx("div",{className:"history-empty",children:i})]})}function he({channels:t,daily:s,denominatorKey:i,description:l,emptyText:a,isBusy:r,locale:c,metricKey:n,numeratorKey:v,title:x,valueKind:p="rate"}){const[C,y]=N.useState(900),k=N.useRef(null),S=`${x.replace(/\W+/g,"-").toLowerCase()}-title`,j=`${S}-reading`,d=t.map(f=>f.id).join("|"),b=N.useMemo(()=>Ke(s,t,n,p,C),[d,C,s,n,p]),{chartInspectionProps:u,resetActiveIndex:g,resolvedActiveIndex:o}=_e({itemCount:b.dates.length,plotLeft:b.plotLeft,plotWidth:b.plotWidth,viewBoxWidth:b.viewBoxWidth}),T=o==null?null:b.dates[o],A=o==null?null:s[o];return N.useLayoutEffect(()=>{const f=k.current;if(!f)return;const $=()=>{const _=Math.max(220,Math.min(960,Math.floor(f.clientWidth-4)));y(w=>w===_?w:_)},h=typeof ResizeObserver>"u"?null:new ResizeObserver($);return $(),h?.observe(f),window.addEventListener("resize",$),()=>{h?.disconnect(),window.removeEventListener("resize",$)}},[s.length]),N.useEffect(()=>{g()},[d,s,n,g]),e.jsxs("section",{className:"admin-data-panel admin-channel-trend-chart","aria-labelledby":S,"aria-busy":r?"true":"false",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{id:S,children:x}),e.jsx("p",{children:l})]})}),b.dates.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"admin-trend-chart__canvas",ref:k,children:e.jsxs("svg",{className:"admin-trend-chart__svg",viewBox:`0 0 ${b.viewBoxWidth} ${b.viewBoxHeight}`,role:"img","aria-describedby":j,"aria-label":`${x} multi-channel line chart. Use left and right arrow keys to inspect each reporting day and its data source.`,...u,children:[b.yTicks.map(f=>e.jsxs("g",{children:[e.jsx("line",{className:"admin-trend-chart__grid-line",x1:b.plotLeft,x2:b.plotRight,y1:f.y,y2:f.y}),e.jsx("text",{className:"admin-trend-chart__axis-label admin-trend-chart__axis-label--y",x:b.plotLeft-10,y:f.y+4,children:tt(f.value,p)})]},f.value)),e.jsx(Te,{locale:c,ticks:b.xTicks,viewBoxHeight:b.viewBoxHeight}),b.series.map(f=>e.jsxs("g",{children:[f.segments.map(($,h)=>e.jsx("polyline",{className:`admin-channel-trend-chart__line admin-channel-trend-chart__line--${f.id}`,"data-source":$[0]?.dataSource||"",points:$.map(_=>`${_.x},${_.y}`).join(" ")},`${f.id}-${h}`)),f.points.filter($=>$.value!=null).map($=>e.jsx("circle",{className:`admin-channel-trend-chart__point admin-channel-trend-chart__point--${f.id}`,cx:$.x,cy:$.y,r:$.index===o?5:2.5},`${f.id}-${$.date}`))]},f.id)),o!=null?e.jsxs(e.Fragment,{children:[e.jsx("line",{className:"admin-trend-chart__active-guide",x1:T.x,x2:T.x,y1:b.plotTop,y2:b.plotBottom}),e.jsx(Se,{date:T.date,height:b.tooltipHeight,locale:c,sourceLabel:Ne(A?.dataSource),width:b.tooltipWidth,x:T.tooltipX,y:T.tooltipY,children:t.map((f,$)=>{const h=A?.channels?.[f.id]||we(),_=b.tooltipContentTop+$*b.tooltipRowHeight,w=Ce(h[n],p),P=p==="rate"?nt({compact:b.compactTooltip,counts:h,denominatorKey:i,dataSource:A?.dataSource,metricKey:n,numeratorKey:v}):st({dataSource:A?.dataSource,metricKey:n,value:h[n]}),R=b.compactTooltip?30:36;return e.jsxs("g",{children:[e.jsx("line",{className:`admin-channel-trend-chart__tooltip-line admin-channel-trend-chart__line--${f.id}`,x1:"12",x2:b.compactTooltip?24:28,y1:_-4,y2:_-4}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-label",x:R,y:_,children:f.label}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-value",textAnchor:"end",x:b.tooltipWidth-12,y:_,children:w}),e.jsx("text",{className:"admin-trend-chart__tooltip-series-detail",x:b.compactTooltip?12:36,y:_+15,children:P})]},f.id)})})]}):null]})}),e.jsx("p",{className:"visually-hidden",id:j,"aria-live":"polite",children:T?Xt({activeDate:T,activeRow:A,channels:t,denominatorKey:i,locale:c,metricKey:n,numeratorKey:v,valueKind:p}):"Focus or hover over the chart to inspect daily values."}),e.jsx("div",{className:"visually-hidden",children:e.jsxs("table",{children:[e.jsxs("caption",{children:[x," source data by reporting day"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Date"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Channel"}
1),e.jsx("th",{scope:"col",children:p==="rate"?"Rate":"Count"}),p==="rate"?e.jsx("th",{scope:"col",children:"Numerator"}):null,p==="rate"?e.jsx("th",{scope:"col",children:"Denominator"}):null]})}),e.jsx("tbody",{children:s.flatMap(f=>t.map($=>{const h=f.channels?.[$.id]||we();return e.jsxs("tr",{children:[e.jsx("td",{children:f.date}),e.jsx("td",{children:Ne(f.dataSource)}),e.jsx("td",{children:$.label}),e.jsx("td",{children:Ce(h[n],p)}),p==="rate"?e.jsx("td",{children:h[v]||0}):null,p==="rate"?e.jsx("td",{children:h[i]||0}):null]},`${f.date}-${$.id}`)}))})]})})]}):e.jsx("div",{className:"history-empty",children:a})]})}function _e({itemCount:t,plotLeft:s,plotWidth:i,viewBoxWidth:l}){const[a,r]=N.useState(null),c=N.useRef(!1),n=a==null||!t?null:Math.min(Math.max(a,0),t-1),v=N.useCallback(()=>{r(null)},[]),x=k=>{t&&r(Math.min(Math.max(k,0),t-1))},p=k=>{if(!t)return;const S=n??t-1,j={ArrowLeft:S-1,ArrowRight:S+1,Home:0,End:t-1};Object.hasOwn(j,k.key)&&(k.preventDefault(),x(j[k.key]))},C=k=>{if(c.current=!0,!t)return;const S=k.currentTarget.getBoundingClientRect(),d=((k.clientX-S.left)/S.width*l-s)/i;x(Math.round(d*(t-1)))};return{chartInspectionProps:{onBlur:()=>{c.current||v()},onFocus:()=>{t&&r(k=>k??t-1)},onKeyDown:p,onPointerEnter:C,onPointerLeave:k=>{c.current=!1,document.activeElement!==k.currentTarget&&v()},onPointerMove:C,tabIndex:0},resetActiveIndex:v,resolvedActiveIndex:n}}function Te({locale:t,ticks:s,viewBoxHeight:i,period:l="day"}){return s.map((a,r)=>{const c=r===0?" admin-trend-chart__axis-label--first":r===s.length-1?" admin-trend-chart__axis-label--last":"";return e.jsxs("text",{className:`admin-trend-chart__axis-label admin-trend-chart__axis-label--x${c}`,x:a.x,y:i-27,children:[e.jsx("tspan",{className:"admin-trend-chart__axis-weekday",x:a.x,children:l==="week"?"Week of":lt(a.date,t)}),e.jsx("tspan",{x:a.x,dy:"15",children:$e(a.date,t)})]},a.date)})}function Se({children:t,date:s,height:i,locale:l,sourceLabel:a="",periodEnd:r,width:c,x:n,y:v}){return e.jsxs("g",{className:"admin-trend-chart__tooltip",transform:`translate(${n} ${v})`,children:[e.jsx("rect",{className:"admin-trend-chart__tooltip-background",height:i,rx:"8",width:c}),e.jsx("text",{className:"admin-trend-chart__tooltip-weekday",x:"12",y:"18",children:r?`From ${$e(s,l)}`:lt(s,l,"long")}),e.jsx("text",{className:"admin-trend-chart__tooltip-date",x:"12",y:"36",children:r?`To ${$e(r,l)}`:xe(s,l)}),a?e.jsx("text",{className:"admin-trend-chart__tooltip-source",x:"12",y:"52",children:a}):null,t]})}function Ke(t,s,i,l,a=900){const r=Math.max(220,Math.min(960,Number(a)||900)),c=300,n=r<420?44:54,v=r-24,x=20,p=250,C=v-n,y=p-x,k=Math.min(340,r-16),S=k<300,j=S?34:36,d=74,b=Math.min(c-16,d+Math.max(0,s.length-1)*j+30),u=Array.isArray(t)?t:[],g=u.flatMap(_=>s.map(w=>{const P=_.channels?.[w.id]?.[i];return l==="rate"?Number.isFinite(P)?P*100:null:Math.max(0,Number(P)||0)})).filter(_=>_!=null),o=g.length?Math.max(...g):0,{maximum:T,step:A}=l==="rate"?qt(o):it(g),f=u.map((_,w)=>{const P=u.length===1?n+C/2:n+w/Math.max(1,u.length-1)*C,R=P+k+20<=r?P+12:P-k-12;return{date:_.date,index:w,tooltipX:Math.min(Math.max(R,8),r-k-8),tooltipY:8,x:P}}),$=s.map(_=>{const w=f.map(R=>{const E=(u[R.index]?.channels?.[_.id]||{})[i],de=l==="rate"?Number.isFinite(E)?E*100:null:Math.max(0,Number(E)||0),Z=de??0;return{...R,dataSource:u[R.index]?.dataSource||"",value:de,y:p-Z/T*y}}),P=[];for(const R of w){const W=P.at(-1);!W||W[0]?.dataSource!==R.dataSource?P.push([R]):W.push(R)}return{..._,points:w,segments:P}}),h=[...new Set((r<520?[0,.5,1]:[0,.25,.5,.75,1]).map(_=>Math.round((u.length-1)*_)))];return{compactTooltip:S,dates:f,plotBottom:p,plotLeft:n,plotRight:v,plotTop:x,plotWidth:C,series:$,tooltipContentTop:d,tooltipHeight:b,tooltipRowHeight:j,tooltipWidth:k,viewBoxHeight:c,viewBoxWidth:r,xTicks:h.map(_=>f[_]).filter(Boolean),yTicks:Array.from({length:Math.floor(T/A)+1},(_,w)=>w*A).map(_=>({value:_,y:p-_/T*y}))}}function qt(t){const s=Math.max(0,Number(t)||0),i=Ht.find(a=>s<=a.maximum);if(i)return i;const l=100;return{maximum:Math.ceil(s/l)*l,step:l}}function we(){return{impressions:0,clicks:0,purchases:0,clickThroughRate:null,clickToPurchaseRate:null}}function ie(t){return Number.isFinite(t)?`${(t*100).toFixed(1)}%`:"—"}function et({compact:t=!1,denominator:s,numerator:i}){return s?t?`${i} of ${s} submitters`:`${i} of ${s} submitting users`:"No submitters in that cohort"}function Zt({activeDate:t,activeRow:s,locale:i}){const l=Math.max(0,Number(s?.submittingUsers)||0),a=oe.map(r=>{const c=Math.max(0,Number(s?.[r.numeratorKey])||0);return`${r.label}: ${ie(s?.[r.valueKey])}. ${et({denominator:l,numerator:c})}`});return`${be(t.date,i)}. UTC submission cohort. ${a.join(". ")}`}function Ce(t,s){return s==="rate"?ie(t):String(Math.max(0,Number(t)||0))}function tt(t,s){return s==="rate"?`${t}%`:Math.abs(Number(t)||0)>=1e3?new Intl.NumberFormat("en",{maximumFractionDigits:1,notation:"compact"}).format(t):String(t)}function st({metricKey:t,value:s}){const i=Number(s)===1;return t==="impressions"?i?"viewer":"viewers":i?"clicker":"clickers"}function nt({compact:t=!1,counts:s,dataSource:i,denominatorKey:l,metricKey:a,numeratorKey:r}){const c=Math.max(0,Number(s?.[l])||0),n=Math.max(0,Number(s?.[r])||0),v=a==="clickThroughRate",x=c===1?"viewer":"viewers",p=c===1?"clicker":"clickers",C=n===1?"first-time payer":"first-time payers",y=i==="ga4"?"that day":"in that cohort";if(!c){const k=v?`viewers ${y}`:`clickers ${y}`;return n?v?`${n} ${n===1?"clicker":"clickers"}; no ${k}`:`${n} ${C}; no ${k}`:`No ${k}`}return v?t?`${n} clicked · ${c} ${x}`:`${n} of ${c} ${x} clicked`:t?`${n} paid · ${c} ${p}`:`${n} ${C} ÷ ${c} ${p}`}function Xt({activeDate:t,activeRow:s,channels:i,denominatorKey:l,locale:a,metricKey:r,numeratorKey:c,valueKind:n}){const v=i.map(x=>{const p=s?.channels?.[x.id]||we();if(n==="count"){const y=st({dataSource:s?.dataSource,metricKey:r,value:p[r]});return`${x.label}: ${Ce(p[r],n)} ${y}`}const C=nt({counts:p,dataSource:s?.dataSource,denominatorKey:l,metricKey:r,numeratorKey:c});return`${x.label}: ${ie(p[r])}. ${C}`});return`${be(t.date,a)}. ${Ne(s?.dataSource)}. ${v.join(". ")}`}function Ne(t){return t==="ga4"?"GA4 · property event day":"D1 · UTC viewing cohort"}function Yt(t){const s=t?.sources?.ga4?.available!==!1,i=t?.sources?.d1?.available!==!1;return`${s?"GA4 daily unique users through Aug 21":"GA4 history through Aug 21 is unavailable"}; ${i?"first-party D1 daily unique people from Aug 22":"first-party D1 data from Aug 22 is unavailable"}. D1 counts each account once per day and channel, using a browser visitor ID for anonymous people. Lines pause because source identity and date attribution differ.`}
1function ae({daily:t,description:s,emptyText:i,isBusy:l,locale:a,title:r,unitLabel:c,valueKey:n,valueKind:v="count",valueLabel:x,dateBasis:p="UTC",formatDetail:C,provisionalKey:y,period:k="day"}){const[S,j]=N.useState(760),d=N.useRef(null),b=`${r.replace(/\W+/g,"-").toLowerCase()}-title`,u=`${b}-reading`,g=N.useMemo(()=>Qt(t,n,S,v,y),[S,t,n,v,y]),{chartInspectionProps:o,resetActiveIndex:T,resolvedActiveIndex:A}=_e({itemCount:g.points.length,plotLeft:g.plotLeft,plotWidth:g.plotWidth,viewBoxWidth:g.viewBoxWidth}),f=w=>w==null?"—":v==="rate"?`${w.toFixed(1)}%`:String(w),$=A==null?null:g.points[A],h=$&&C?[C(t[$.index])].flat():[],_=g.tooltipHeight+h.length*20;return N.useLayoutEffect(()=>{const w=d.current;if(!w)return;const P=()=>{const W=Math.max(220,Math.min(960,Math.floor(w.clientWidth-4)));j(E=>E===W?E:W)},R=typeof ResizeObserver>"u"?null:new ResizeObserver(P);return P(),R?.observe(w),window.addEventListener("resize",P),()=>{R?.disconnect(),window.removeEventListener("resize",P)}},[t.length]),N.useEffect(()=>{T()},[t,T]),e.jsxs("section",{className:"admin-data-panel admin-trend-chart","aria-labelledby":b,"aria-busy":l?"true":"false",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{id:b,children:r}),e.jsx("p",{children:s}),g.statusRegions.map(w=>e.jsxs("p",{className:"admin-trend-chart__status","data-status":w.status,children:[w.status==="observing"?"Observing":"Partial history",": ",xe(t[w.startIndex].date,a),t[w.endIndex].periodEnd||t[w.endIndex].date!==t[w.startIndex].date?` – ${xe(t[w.endIndex].periodEnd||t[w.endIndex].date,a)}`:""," · ",p]},w.startIndex))]})}),g.points.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"admin-trend-chart__canvas",ref:d,children:e.jsxs("svg",{className:"admin-trend-chart__svg",viewBox:`0 0 ${g.viewBoxWidth} ${g.viewBoxHeight}`,role:"img","aria-describedby":u,"aria-label":`${r} line chart. Use left and right arrow keys to inspect each ${p} ${k}.`,...o,children:[g.statusRegions.map(w=>e.jsx("rect",{className:"admin-trend-chart__status-region","data-status":w.status,x:w.left,width:w.right-w.left,y:g.plotTop,height:g.plotBottom-g.plotTop},w.startIndex)),g.yTicks.map(w=>e.jsxs("g",{children:[e.jsx("line",{className:"admin-trend-chart__grid-line",x1:g.plotLeft,x2:g.plotRight,y1:w.y,y2:w.y}),e.jsx("text",{className:"admin-trend-chart__axis-label admin-trend-chart__axis-label--y",x:g.plotLeft-10,y:w.y+4,children:f(w.value)})]},w.value)),e.jsx(Te,{locale:a,ticks:g.xTicks,period:k,viewBoxHeight:g.viewBoxHeight}),g.segments.map((w,P)=>e.jsx("polyline",{className:"admin-trend-chart__line",points:w},P)),v==="rate"?g.points.filter(w=>w.value!=null).map(w=>e.jsx("circle",{className:y?`admin-trend-chart__point${w.status?" admin-trend-chart__point--provisional":""}`:"admin-trend-chart__active-point","data-date":w.date,"data-status":w.status||"complete",cx:w.x,cy:w.y,r:y?4:2},w.date)):null,$?e.jsxs("g",{children:[e.jsx("line",{className:"admin-trend-chart__active-guide",x1:$.x,x2:$.x,y1:g.plotTop,y2:g.plotBottom}),$.value!=null?e.jsx("circle",{className:y?`admin-trend-chart__point${$.status?" admin-trend-chart__point--provisional":""}`:"admin-trend-chart__active-point",cx:$.x,cy:$.y,r:"5"}):null,e.jsxs(Se,{date:$.date,periodEnd:t[$.index]?.periodEnd,height:_,locale:a,width:g.tooltipWidth,x:$.tooltipX,y:Math.min($.tooltipY,g.plotBottom-_),children:[e.jsxs("text",{className:"admin-trend-chart__tooltip-value",x:"12",y:"55",children:[f($.value)," ",v==="rate"?"":c]}),h.map((w,P)=>e.jsx("text",{className:"admin-trend-chart__tooltip-series-detail",x:"12",y:75+P*20,children:w},P))]})]}):null]})}),e.jsx("p",{className:"visually-hidden",id:u,"aria-live":"polite",children:$?`${be($.date,a)}${k==="week"?` through ${be(t[$.index].periodEnd,a)}`:""} · ${f($.value)} ${v==="rate"?"":c}${h.length?` · ${h.join(" · ")}`:""}`:`Focus or hover over the chart to inspect ${k==="week"?"weekly":"daily"} values.`}),e.jsx("div",{className:"visually-hidden",children:e.jsxs("table",{children:[e.jsxs("caption",{children:[r," source data in ",p]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Date"}),e.jsx("th",{scope:"col",children:x||(v==="rate"?"Submission rate":c)}),C?e.jsx("th",{scope:"col",children:"Details"}):null]})}),e.jsx("tbody",{children:g.points.map(w=>e.jsxs("tr",{children:[e.jsxs("td",{children:[w.date,k==="week"?` – ${t[w.index].periodEnd}`:""]}),e.jsx("td",{children:f(w.value)}
1),C?e.jsx("td",{children:[C(t[w.index])].flat().join(" · ")}):null]},w.date))})]})})]}):e.jsx("div",{className:"history-empty",children:i})]})}function Qt(t,s,i=760,l="count",a){const r=Math.max(220,Math.min(960,Number(i)||760)),c=280,n=l==="rate"?58:r<420?38:48,v=r-(r<420?12:24),x=22,p=238,C=v-n,y=p-x,k=Array.isArray(t)?t:[],S=k.map(h=>l==="rate"?Number.isFinite(h?.[s])?Math.max(0,h[s])*100:null:Math.max(0,Number(h?.[s])||0)),j=it(S.filter(h=>h!=null)),d=Math.min(184,r-16),b=68,u=k.map((h,_)=>{const w=S[_],P=k.length===1?n+C/2:n+_/(k.length-1)*C,R=p-(w??0)/j.maximum*y,W=Math.min(Math.max(P-d/2,8),r-d-8),E=R<x+b+16?R+14:R-b-10;return{date:h.date,status:a&&h[a]?h.observing===!1?"partial":"observing":null,index:_,tooltipX:W,tooltipY:E,value:w,x:P,y:R}}),g=Math.round(j.maximum/j.step),o=Array.from({length:g+1},(h,_)=>({value:j.step*_,y:p-j.step*_/j.maximum*y})),T=[...new Set((r<520?[0,.5,1]:[0,.25,.5,.75,1]).map(h=>Math.round((k.length-1)*h)))],A=[];let f=[];for(const h of u)h.value==null?(f.length&&A.push(f.join(" ")),f=[]):f.push(`${h.x},${h.y}`);f.length&&A.push(f.join(" "));const $=[];for(const h of u){if(!h.status)continue;const _=$.at(-1),w=u[h.index+1]?(h.x+u[h.index+1].x)/2:v;_?.status===h.status&&_.endIndex===h.index-1?(_.endIndex=h.index,_.right=w):$.push({status:h.status,startIndex:h.index,endIndex:h.index,left:u[h.index-1]?(u[h.index-1].x+h.x)/2:n,right:w})}return{segments:A,statusRegions:$,points:u,plotBottom:p,plotLeft:n,plotRight:v,plotTop:x,plotWidth:C,polylinePoints:u.map(h=>`${h.x},${h.y}`).join(" "),tooltipHeight:b,tooltipWidth:d,viewBoxHeight:c,viewBoxWidth:r,xTicks:T.map(h=>u[h]).filter(Boolean),yTicks:o}}function it(t){const s=Math.max(4,...t),i=s/4,l=10**Math.floor(Math.log10(i)),a=i/l,c=(a<=1?1:a<=2?2:a<=5?5:10)*l;return{maximum:Math.ceil(s/c)*c,step:c}}
1function qe(t,s){return((Number(t)||0)/Math.max(1,Number(s)||1)).toFixed(1)}function Jt({analytics:t,isLoading:s,locale:i,onPageChange:l,onRangeChange:a,onConversionChange:r,onRegistrationChange:c,onDeviceChange:n}){const[v,x]=N.useState(null),p=t?.filters||{days:30,registration:"all"},C=t?.clicks||[],y=t?.checkoutAudit||null,k=t?.checkoutRequestAudit||null,S=t?.recoveryAttribution||null,j=t?.conversionTrend,d=j?.filters||{granularity:"week",weeks:8,days:30},b=d.granularity==="week",u=["Device filtering applies only to this table. ","Each row shows a purchase-button click, or a payment page when the earlier click is unavailable. For a recovery-popup click, Click page shows where the user's interrupted payment originally started.",y?.available===!1?" Apply the latest database migration to include checkout records.":"",k?.available===!1?" Apply the latest database migration to include failed checkout details.":""].join(""),g=e.jsxs(V,{"aria-label":"Purchase click filters",children:[e.jsx(U,{label:"Details date range",children:me.map(o=>e.jsx(D,{isActive:p.days===o.value,onClick:()=>a(o.value),children:o.label},o.value))}),e.jsx(U,{label:"Registration",children:Lt.map(o=>e.jsx(D,{isActive:p.registration===o.value,onClick:()=>c(o.value),children:o.label},o.value))}),e.jsx(U,{label:"Device (details only)",children:["all",...Qe].map(o=>e.jsx(D,{isActive:(p.device||"all")===o,onClick:()=>n(o),children:o==="all"?"All devices":o[0].toUpperCase()+o.slice(1)},o))})]});return t&&t.available===!1?e.jsx(re,{title:"Purchase click details",description:"Apply the latest database migration to start collecting first-party purchase button clicks.",emptyText:"Purchase click tracking is not available yet.",rows:[],isBusy:s,columns:[]}):e.jsxs(e.Fragment,{children:[e.jsxs(V,{"aria-label":"Payment conversion filters",children:[e.jsx(U,{label:"Group by",children:[{value:"day",label:"Daily"},{value:"week",label:"Weekly"}].map(o=>e.jsx(D,{isActive:d.granularity===o.value,onClick:()=>r({ctaConversionGranularity:o.value}),children:o.label},o.value))}),e.jsx(U,{label:"Chart range",children:(b?[4,8,12].map(o=>({value:o,label:`${o} weeks`})):me).map(o=>e.jsx(D,{isActive:(b?d.weeks:d.days)===o.value,onClick:()=>r({[b?"ctaConversionWeeks":"ctaConversionDays"]:o.value}),children:o.label},o.value))})]}),e.jsx(ae,{daily:j?.available?b?j.weekly:j.daily:[],period:b?"week":"day",title:"Payment conversion rate",description:e.jsxs(e.Fragment,{children:[j?.isSynthetic?e.jsx("strong",{children:"Test data — synthetic accounts and payments. "}):null,b?"First-time payers ÷ people who clicked, deduplicated per UTC week (Mon–Sun). ":"First-time payers ÷ people who clicked, deduplicated per UTC day. ","Account IDs only; prior payers and admins excluded. Payments count within 24 hours of a day's first click. ",b?"Hollow points and shaded weeks have partial coverage or are still observing.":"Hollow points and shaded dates are still observing."]}),emptyText:s?"Loading payment conversion...":j?.available?"No purchase clicks recorded in this range.":"Payment conversion data is unavailable. Try refreshing.",isBusy:s,locale:i,valueKey:"rate",valueKind:"rate",valueLabel:"Payment conversion rate",unitLabel:"people",provisionalKey:"provisional",formatDetail:o=>[`${o.paidUsers} paid · ${o.clickedUsers} clicked`,...b?[...o.observedFrom>o.date?[`Data from ${o.observedFrom}`]:o.partial?["Week in progress"]:[],o.observing?"Still observing · 24h":o.clickedUsers?"24h window complete":"No eligible clickers"]:[o.provisional?"Still observing · 24h":o.clickedUsers?"24h window complete":"No eligible clickers"]]}),g,e.jsx(Kt,{attribution:S,isBusy:s,locale:i}),e.jsx(re,{title:"Purchase click details",description:u,emptyText:s?"Loading purchase click details...":"No purchase click details in this range.",rows:C,isBusy:s,pagination:e.jsx(Pe,{label:"Purchase click details",pagination:t?.pagination,isLoading:s,onPageChange:l}),columns:[{key:"clickedAt",label:e.jsx(F,{label:"Clicked",onOpen:()=>x("clickedAt")}),render:o=>o.clickRecorded===!1?"Not recorded":O(o.clickedAt,i)},{key:"userId",label:e.jsx(F,{label:"Registration ID",onOpen:()=>x("userId")}),render:o=>o.userId==null?"Anonymous":`#${o.userId}`},{key:"linkStatus",label:e.jsx(F,{label:"Link status",onOpen:()=>x("linkStatus")}),render:o=>o.clickRecorded===!1?"Click unavailable":o.userId==null?"Not registered":o.wasAuthenticated?"Signed in at click":"Linked after sign-in"},{key:"account",label:e.jsx(F,{label:"Account",onOpen:()=>x("account")}
1),render:o=>o.userId==null?"—":e.jsx(pe,{email:o.userEmail,name:o.userName||`User #${o.userId}`,picture:o.userPicture})},{key:"planId",label:e.jsx(F,{label:"Plan",onOpen:()=>x("planId")}),render:o=>o.planId==="yearly"?"1-year":o.planId==="monthly-onetime"?"1-month":"Monthly"},{key:"placement",label:e.jsx(F,{label:"Started from",onOpen:()=>x("placement")}),render:o=>e.jsx("span",{className:"admin-purchase-origin",children:ls(o).map((T,A)=>e.jsx("span",{className:"admin-purchase-origin__line",children:T},`${T}-${A}`))})},{key:"checkoutAttempts",label:e.jsx(F,{label:"Creem checkout",onOpen:()=>x("checkoutAttempts")}),render:o=>e.jsx(ds,{attempts:o.checkoutAttempts,failure:o.checkoutFailure,locale:i})},{key:"page",label:e.jsx(F,{label:"Click page",onOpen:()=>x("page")}),render:o=>e.jsxs("span",{className:"admin-cta-page",children:[e.jsx("strong",{children:is(o)}),o.clickPath?e.jsx("code",{title:o.clickPath,children:o.clickPath}):e.jsx("span",{children:"Path unavailable"})]})},{key:"visitAttribution",label:e.jsx(F,{label:"Visit source",onOpen:()=>x("visitAttribution")}),render:o=>e.jsxs("span",{className:"admin-cta-page",children:[e.jsx("strong",{children:wt(o.visitAttribution)}),o.visitAttribution?.landingPath?e.jsx("code",{title:o.visitAttribution.landingPath,children:o.visitAttribution.landingPath}):null]})},{key:"signupSource",label:e.jsx(F,{label:"Signup source",onOpen:()=>x("signupSource")}),render:o=>rt(o.signupSource)},{key:"signupLandingPath",label:e.jsx(F,{label:"Signup landing",onOpen:()=>x("signupLandingPath")}),render:o=>o.signupLandingPath?e.jsx("code",{title:o.signupLandingPath,children:o.signupLandingPath}):"—"},{key:"locale",label:e.jsx(F,{label:"Locale",onOpen:()=>x("locale")}),render:o=>o.locale||"—"},{key:"deviceType",label:e.jsx(F,{label:"Device",onOpen:()=>x("deviceType")}),render:o=>{const T=Nt(o.deviceType);return T[0].toUpperCase()+T.slice(1)}}]}),v?e.jsx(ss,{guide:ts[v],onClose:()=>x(null)}):null]})}function Kt({attribution:t,isBusy:s,locale:i}){const l=t?.totals||{},a=l.rates||{},r=[{key:"impressions",label:"Popup shown",value:l.impressions},{key:"clicks",label:"Clicked Continue payment",value:l.clicks},{key:"checkouts",label:"Payment page opened",value:l.checkouts},{key:"purchases",label:"First payment completed",value:l.purchases}],c=es(t?.coverage?.availableFrom,i);return e.jsxs("section",{className:"admin-data-panel admin-recovery-attribution","aria-labelledby":"admin-recovery-attribution-title","aria-busy":s?"true":"false",children:[e.jsx("div",{className:"admin-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{id:"admin-recovery-attribution-title",children:"Recovery popup results"}),e.jsx("p",{children:"See what happened after the recovery popup was shown."})]})}),t?.available===!1?e.jsx("div",{className:"history-empty",children:"Apply the purchase attribution migrations to load checkout recovery results."}):e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"admin-recovery-funnel","aria-label":"Recovery popup results",children:r.map((n,v)=>e.jsxs("li",{className:n.key==="purchases"?"is-result":void 0,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:Number(n.value)||0}),v<r.length-1?e.jsx("i",{"aria-hidden":"true",children:"→"}):null]},n.key))}),e.jsxs("dl",{className:"admin-recovery-rates",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Continued after seeing popup"}),e.jsx("dd",{children:ye(a.clickThrough)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Opened payment page after continuing"}),e.jsx("dd",{children:ye(a.checkoutPerClick)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Paid after opening payment page"}),e.jsx("dd",{children:ye(a.purchasePerCheckout)})]})]}),e.jsxs("p",{className:"admin-recovery-coverage",children:["First payments that can be connected to the recovery popup",c?` · data available from ${c}`:"","."]})]})]})}function ye(t){return Number.isFinite(t)?`${(t*100).toFixed(1)}%`:"—"}function es(t,s){if(!t)return"";try{const i=t.includes("T")?t:`${t.replace(" ","T")}Z`;return new Intl.DateTimeFormat(s,{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(i))}catch{return t}}const ts={deviceType:{title:"Device",description:"Estimated device type when the purchase button was clicked. Browser settings can affect this estimate.",sections:[{title:"Values",items:[["Mobile","A phone browser."],["Desktop","A computer browser."],["Tablet","A tablet browser."],["Unknown","An older or unclassified click, or a checkout without a recorded click."]]}]},clickedAt:{title:"Clicked",description:"When the user clicked a button to buy a plan.",sections:[{title:"Values",items:[["Date and time","When the click happened, shown in your local time."],["Not recorded","We have a checkout, but we do not know when the user clicked."]]}]},userId:{title:"Registration ID",description:"Which registered user this row belongs to.",sections:[{title:"Values",items:[["# followed by a number","The user's account number in this admin."],["Anonymous","We do not know which account made the click."]]}]}
1,linkStatus:{title:"Link status",description:"Whether we know who clicked and when we identified them.",sections:[{title:"Values",items:[["Signed in at click","The user was signed in when they clicked."],["Linked after sign-in","They clicked first and signed in later, so we linked the click to their account."],["Not registered","The click is not linked to an account."],["Click unavailable","We only have the checkout, so there is no click information."]]}]},account:{title:"Account",description:"Who made the click or checkout.",sections:[{title:"Values",items:[["Email and name","The user's email and name."],["—","No account is linked to this row."]]}]},planId:{title:"Plan",description:"What the user chose to buy.",sections:[{title:"Values",items:[["Monthly","A monthly subscription."],["1-month","A one-time purchase for one month of access."],["1-year","A one-time purchase for one year of access."]]}]},checkoutAttempts:{title:"Creem checkout",description:"Whether the user reached the Creem payment page.",sections:[{title:"Values",items:[["Checkout ID","The payment page's reference number."],["From this click","The payment page opened after this click."],["Probably from this click","This payment page most likely opened after this click."],["Click unavailable","We recorded the checkout, but we do not have the earlier click."],["Checkout failed","The request reached the site, but no Creem payment page was returned."],["Checkout interrupted","The site recorded the request, but it did not reach a final result within one minute."],["Blocked before Creem","The request was stopped by a plan or account rule before Creem was called."],["Checkout audit failed","Creem returned a payment page, but its required success record could not be stored safely."],["Support ref","The exact reference shown to the customer for this failed attempt."],["Creem request","The request ID reused only for automatic retries inside this server attempt."],["Creem trace","The provider reference to use when asking Creem support about this failure."],["—","No checkout or server-side failure is shown for this row."]]}]},page:{title:"Click page",description:"Where the user's payment attempt started.",sections:[{title:"Values",items:[["Home page","The home page."],["Pricing page","The dedicated pricing page."],["Correction page","A saved correction report."],["Checker landing page","One of the writing checker pages."],["Public sample page","A public writing sample page."],["Other page","Another page on the site."],["Recovery popup from Home page","The user continued from the recovery popup after first starting payment on the Home page."],["/path","The page address after the domain."],["Path unavailable","We only have the checkout, so the original click page is unknown."]]}]},placement:{title:"Started from",description:"The page, purchase module, and button the user used to continue buying.",sections:[{title:"Format",items:[["Page, module, button","Read the three separate lines from top to bottom."]]},{title:"Pages",items:[["Home page","The home page."],["Pricing page","The dedicated pricing page."],["Correction page","A saved correction report."],["Checker landing page","One of the writing checker pages."],["Public sample page","A public writing sample page."],["Other page","Another page on the site."]]},{title:"Modules",items:[["Pricing section","The plan-selection module shown on the Home, Pricing, or a checker landing page."],["Report unlock","The upgrade area on a locked correction report."],["Sticky purchase bar","The fixed purchase bar on a locked correction report."],["Quota dialog","The upgrade pop-up shown after the free review limit was reached."],["Recovery popup","The user clicked Continue payment in the reminder shown after an interrupted checkout."]]},{title:"Buttons",items:[["Plan button","A plan button in a pricing section."],["Checkout button","The checkout button for the selected plan in a pricing section."],["Main upgrade button","The main upgrade button on a correction report."],["Selected plan button","The checkout button for the selected plan on a correction report or quota dialog."],["Monthly button","The monthly button in the fixed purchase bar."],["1-year button","The 1-year button in the fixed purchase bar."],["Continue payment","The button in the recovery popup."]]}]},visitAttribution:{title:"Visit source",description:"Where this visit came from before this purchase click. It stays attached to this click and the first payment exactly linked to it.",sections:[{title:"Values",items:[["Recall email · type","A tagged recall link brought this visit here. The type is Essay submitted, Checkout started, or Account created. This does not prove that the email caused a purchase."],["UTM · source / Referrer · domain","The campaign or external website recorded for this visit. Bing referrals are shown as Search · Bing."],["Direct / unavailable","This visit was recorded without an identifiable c
1ampaign or external referrer."],["Unknown","No visit source was recorded, including older clicks and checkouts without a linked click. Receiving an email alone never counts as email attribution."]]},{title:"Coverage",items:[["This visit","The source follows navigation and sign-in in this browser tab. A new campaign replaces it; 30 minutes without a captured page or purchase action ends the visit. Click records are retained for 180 days."]]}]},signupSource:{title:"Signup source",description:"How this user first arrived before signing up.",sections:[{title:"Values",items:[["UTM · source","A campaign link brought the user here. The campaign source appears after the dot."],["Referrer · domain","Another website brought the user here. The website appears after the dot."],["Direct / unavailable","We do not know which website or campaign brought the user."],["—","No signup source is available for this row."]]}]},signupLandingPath:{title:"Signup landing",description:"The first page this user visited when they signed up.",sections:[{title:"Values",items:[["/path","The page address after the domain."],["—","We do not have a signup landing page for this user."]],codeTerms:!0}]},locale:{title:"Locale",description:"The language the site was using when the click happened.",sections:[{title:"Values",items:[["en","English."],["zh-CN","Simplified Chinese."],["vi","Vietnamese."],["—","We do not know which language was being used."]],codeTerms:!0}]}};function F({label:t,onOpen:s}){return e.jsxs("span",{className:"admin-table-column-heading",children:[e.jsx("span",{children:t}),e.jsx("button",{className:"admin-table-column-help-button",type:"button","aria-haspopup":"dialog","aria-label":`Explain ${t} column`,title:`Explain ${t} column`,onClick:s,children:e.jsx("span",{"aria-hidden":"true",children:"?"})})]})}function ss({guide:t,onClose:s}){const i=N.useRef(null),l=N.useRef(null),a=N.useRef(s),r=N.useRef(null);return a.current=s,N.useEffect(()=>{r.current=document.activeElement,l.current?.focus();const c=n=>{if(n.key==="Escape"){n.preventDefault(),a.current();return}if(n.key!=="Tab")return;const v=Array.from(i.current?.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]).filter(y=>y.getAttribute("aria-hidden")!=="true");if(!v.length){n.preventDefault();return}const x=v[0],p=v[v.length-1],C=document.activeElement;n.shiftKey&&(C===x||!i.current?.contains(C))?(n.preventDefault(),p.focus()):!n.shiftKey&&C===p&&(n.preventDefault(),x.focus())};return document.body.classList.add("modal-open"),window.addEventListener("keydown",c),()=>{document.body.classList.remove("modal-open"),window.removeEventListener("keydown",c),r.current?.focus?.()}},[]),e.jsx("div",{className:"auth-modal-layer",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("section",{ref:i,className:"admin-table-help-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"purchase-click-guide-title","aria-describedby":"purchase-click-guide-description",children:[e.jsx("button",{ref:l,className:"icon-button auth-modal-close",type:"button","aria-label":`Close ${t.title} guide`,onClick:s,children:e.jsx(ms,{})}),e.jsxs("header",{className:"admin-table-help-dialog__header",children:[e.jsxs("h2",{id:"purchase-click-guide-title",children:[t.title," guide"]}),e.jsx("p",{id:"purchase-click-guide-description",children:t.description})]}),t.sections.map(c=>e.jsx(ns,{title:c.title,items:c.items,codeTerms:c.codeTerms},c.title))]})})}function ns({title:t,items:s,codeTerms:i=!1}){return e.jsxs("section",{className:"admin-table-help-dialog__section",children:[e.jsx("h3",{children:t}),e.jsx("dl",{children:s.map(([l,a])=>e.jsxs("div",{children:[e.jsx("dt",{children:i?e.jsx("code",{children:l}):l}),e.jsx("dd",{children:a})]},l))})]})}function at(t){return{home:"Home page",pricing:"Pricing page",correction:"Correction page",checker_landing:"Checker landing page",public_sample:"Public sample page",other:"Other page"}[t]||"Other page"}function is(t){const s=at(t.ctaPageType);return t.pricingSurface==="checkout_recovery"?`Recovery popup from ${s}`:s}function as(t){return{inline_pricing:"Pricing section",pricing_page:"Pricing section",report_unlock:"Report unlock",report_sticky_purchase_bar:"Sticky purchase bar",quota_dialog:"Quota dialog",checkout_recovery:"Recovery popup"}[t]||t||"Unknown module"}function rs(t){return{pricing_plan_button:"Plan button",pricing_selected_plan_button:"Checkout button",unlock_primary_button:"Main upgrade button",unlock_selected_plan_button:"Selected plan button",sticky_monthly_button:"Monthly button",sticky_yearly_button:"1-year button",recovery_continue_button:"Continue payment"}[t]||t||"Unknown button"}function ls(t){return[at(t.ctaPageType),as(t.pricingSurface),rs(t.ctaId)]}function L({emptyValue:t=0,label:s,value:i}){const l=typeof i=="number"?i:i==null||i===""?t:i;return e.jsxs("article",{className:"admin-summary-card",children:[e.jsx("span",{children:s}),e.jsx("strong",{children:l})]})}function Ze({isLoading:t,onClick:s,submissionCount:i,userLabel:l}){const a=Number(i)||0,r=a===1?"review":"reviews";return e.jsx("button",{className:"admin-inline-button",type:"button","aria-label":`View all ${a} ${r} for ${l}`,disabled:t,onClick:s,children:a})}const je=[{key:"user",label:"User data",emptyLabel:"user submissions",de
1scription:"Reviews submitted by user accounts.",summaryKey:"userSubmissions"},{key:"public_sample_batch",label:"Public samples",emptyLabel:"public sample submissions",description:"Reviews created by the public sample importer.",summaryKey:"publicSampleSubmissions"},{key:"production_benchmark",label:"Benchmark",emptyLabel:"benchmark submissions",description:"Reviews created by production benchmark accounts.",summaryKey:"benchmarkSubmissions"},{key:"all",label:"All",emptyLabel:"writing submissions",description:"Reviews from every submission source.",summaryKey:"totalSubmissions"}];function cs({panelRef:t,isLoading:s,locale:i,resolveSubmissionCanonicalPath:l,resolveSubmissionFreePreviewPath:a,submissions:r,summary:c,pagination:n,sourceFilter:v,userFilter:x,onClearUserFilter:p,onPageChange:C,onSourceChange:y}){const k=je.find(d=>d.key===v)||je[0],S=x?.email||x?.name||`User #${x?.id}`,j=x?` Showing reviews for ${S}.`:"";return e.jsx(re,{panelRef:t,isTitleFocusable:!0,title:"Writing submissions",description:`${k.description}${j} Open one to view the correction page.`,emptyText:s?"Loading submissions...":x?`No ${k.emptyLabel} found for ${S}.`:`No ${k.emptyLabel} yet.`,headingActions:e.jsxs("div",{className:"admin-submission-controls",children:[x?e.jsxs("div",{className:"admin-submission-user-filter","aria-live":"polite",children:[e.jsxs("span",{children:["User: ",e.jsx("strong",{children:S})]}),e.jsx("button",{className:"admin-inline-button",type:"button",disabled:s,onClick:p,children:"Show all users"})]}):null,e.jsx(Ye,{className:"admin-submission-filters",label:"Filter writing submissions by source",children:je.map(d=>{const b=d.key==="all"?r.length:r.filter(g=>g.submissionSource===d.key).length,u=Number(c?.[d.summaryKey]);return e.jsxs(D,{isActive:v===d.key,onClick:()=>y(d.key),children:[d.label,e.jsx(Ct,{children:Number.isFinite(u)?u:b})]},d.key)})})]}),rows:r,isBusy:s,pagination:e.jsx(Pe,{label:"Writing submissions",pagination:n,isLoading:s,onPageChange:C}),columns:[{key:"actions",label:"Details",render:d=>{const b=l(d,i),u=a(d.id,i);return e.jsxs("span",{className:"admin-detail-actions",role:"group","aria-label":`Correction views for submission ${d.id}`,children:[e.jsx("a",{className:"admin-inline-button",href:b,target:"_blank",rel:"noopener noreferrer",children:"Unlocked"}),e.jsx("a",{className:"admin-inline-button admin-inline-button--quiet",href:u,target:"_blank",rel:"noopener noreferrer",title:"View this correction as a free user",children:"Free view"})]})}},{key:"submissionSource",label:"Source",render:d=>e.jsx(os,{source:d.submissionSource})},{key:"createdAt",label:"Created",render:d=>O(d.createdAt,i)},{key:"userEmail",label:"User",render:d=>e.jsx(pe,{email:d.userEmail,name:d.userName||`User #${d.userId}`,picture:d.userPicture})},{key:"taskType",label:"Task",render:d=>`${d.taskType||"-"} / ${d.locale||"-"}`},{key:"overallScore",label:"Score",render:d=>d.overallScore==null?"--":us(Number(d.overallScore))},{key:"promptPreview",label:"Prompt",render:d=>d.promptPreview||"-"}]})}function os({source:t}){const s={user:{label:"User",tone:"user"},public_sample_batch:{label:"Public sample batch",tone:"public-sample"},production_benchmark:{label:"Production benchmark",tone:"benchmark"}}[t]||{label:"User",tone:"user"};return e.jsx("span",{className:`admin-source-badge is-${s.tone}`,children:s.label})}function rt(t){return t==="direct_or_unavailable"?"Direct / unavailable":t?.startsWith("utm:")?`UTM · ${t.slice(4)}`:t?.startsWith("referrer:")?`Referrer · ${t.slice(9)}`:t||"—"}function pe({email:t,name:s,picture:i}){const l=s||t||"User";return e.jsxs("span",{className:"admin-user-cell",children:[e.jsx("span",{className:"admin-user-avatar","aria-hidden":"true",children:i?e.jsx("img",{src:i,alt:"",loading:"lazy",referrerPolicy:"no-referrer"}):hs(l)}),e.jsxs("span",{className:"admin-user-copy",children:[e.jsx("strong",{children:t||"No email"}),e.jsx("em",{children:l})]})]})}function re({panelRef:t=null,isTitleFocusable:s=!1,title:i,description:l,columns:a,rows:r,emptyText:c,headingActions:n=null,pagination:v=null,isBusy:x=!1}){const p=`${i.replace(/\W+/g,"-")}-title`;return e.jsxs("section",{ref:t,className:"admin-data-panel","aria-labelledby":p,"aria-busy":x?"true":"false",children:[e.jsxs("div",{className:"admin-panel-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{id:p,tabIndex:s?-1:void 0,children:i}),e.jsx("p",{children:l})]}),n]}),r.length?e.jsx("div",{className:"admin-table-shell",children:e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:a.map(C=>e.jsx("th",{className:C.className,scope:"col",children:C.label},C.key))})}),e.jsx("tbody",{children:r.map((C,y)=>e.jsx("tr",{children:a.map(k=>e.jsx("td",{className:k.className,children:k.render(C)},`${k.key}-${y}`))},C.id||C.orderKey||C.creemSubscriptionId||C.userId||`${i}-${y}`))})]})}):e.jsx("div",{className:"history-empty",children:c}),v]})}function Pe({label:t,pagination:s,isLoading:i,onPageChange:l}){if(!s||s.totalPages<=1)return null;const a=(s.page-1)*s.pageSize+1,r=Math.min(s.page*s.pageSize,s.totalItems);return e.jsxs("nav",{className:"admin-pagination","aria-label":`${t} pagination`,children:[e.jsxs("p",{children:[a,"-",r," of ",s.totalItems]}),e.jsxs("div",{children:[e.jsx("button",{className:"secondary-button admin-pagination-button",type:"button",disabled:!s.hasPreviousPage||i,onClick:()=>l(s.page-1),children:"Previous"}),e.jsxs("span",{"aria-current":"page",children:["Page ",s.page," of ",s.totalPages]}),e.jsx("button",{className:"secondary-button admin-pagination-button",type:"button",disabled:!s.hasNextPage||i,onClick:()=>l(s.page+1),children:"Next"})]})]})}function Xe({status:t}){const s=String(t||"inactive").toLowerCase(),i=new Set(["active","paid","trialing","checkout_completed","voucher","access_pass","scheduled"]),l=new Set(["expired","refunded","disputed"]),a=i.has(s)?"positive":l.has(s)?"negative":"neutral";return e.jsx("span",{className:`admin-status-badge is-${a}`,children:t||"inactive"})}function se({value:t,compact:s=!0}){if(!t)return"-";const i=s&&t.length>18?`${t.slice(0,8)}...${t.slice(-6)}`:t;return e.jsx("code",{title:t,children:i})}function ds({attempts:t=[],failure:s=null,locale:i}){if(t.length)return e.jsx("span",{className:"admin-checkout-records",children:t.map(c=>e.jsxs("span",{className:"admin-checkout-record",children:[e.jsx(se,{value:c.checkoutId}),e.jsxs("small",{children:[O(c.createdAt,i)," · ",c.matchType==="exact"?"From this click":c.matchType==="historical"?"Probably from this click":"Click unavailable"]})]},c.checkoutId))});if(!s)return"—";const l=s.status==="business_rejected"?"Blocked before Creem":s.status==="checkout_audit_failed"?"Checkout audit failed":s.status==="configuration_failed"?"Billing configuration failed":s.status==="received"?"Checkout interrupted":"Checkout failed",a=s.providerHttpStatus||s.responseStatus,r=s.providerErrorCode||s.errorCode;return e.jsx("span",{className:"admin-checkout-records",children:e.jsxs("span",{className:"admin-checkout-record",children:[e.jsx("strong",{children:l}),s.checkoutId?e.jsx(se,{value:s.checkoutId}):null,e.jsxs("small",{title:s.safeErrorMessage||void 0,children:[O(s.updatedAt||s.createdAt,i),a?` · HTTP ${a}`:"",r?` · ${r}`:"",s.providerAttemptCount>1?` · ${s.providerAttemptCount} provider attempts`:""]}),s.attemptId?e.jsxs("small",{children:["Support ref ",e.jsx(se,{value:s.attemptId,compact:!1})]}
1):null,s.providerRequestId?e.jsxs("small",{children:["Creem request ",e.jsx(se,{value:s.providerRequestId})]}):null,s.providerTraceId?e.jsxs("small",{children:["Creem trace ",e.jsx(se,{value:s.providerTraceId})]}):null]})})}function us(t){return Number.isFinite(t)?t.toFixed(1):"--"}function hs(t){return String(t).trim().charAt(0).toUpperCase()||"?"}function O(t,s){if(!t)return"";try{const i=t.includes("T")?t:`${t.replace(" ","T")}Z`;return new Intl.DateTimeFormat(s,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(i))}catch{return t}}function xe(t,s){if(!t)return"";try{return new Intl.DateTimeFormat(s,{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${t}T00:00:00Z`))}catch{return t}}function $e(t,s){if(!t)return"";try{return new Intl.DateTimeFormat(s,{month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${t}T00:00:00Z`))}catch{return t}}function lt(t,s,i="short"){if(!t)return"";try{return new Intl.DateTimeFormat(s,{weekday:i==="long"?"long":"short",timeZone:"UTC"}).format(new Date(`${t}T00:00:00Z`))}catch{return t}}function be(t,s){if(!t)return"";try{return new Intl.DateTimeFormat(s,{weekday:"long",year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${t}T00:00:00Z`))}catch{return t}}function ms(){return e.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[e.jsx("path",{d:"M6 6l12 12"}),e.jsx("path",{d:"M18 6 6 18"})]})}export{bs 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.