PageSourceSearch

https://procalc.ai/assets/SEOHealthPage-DfK4xO-8.js

js procalc.ai collected 2026-10-05 14:10:02 UTC 36,231 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-apakGoHS.js";import{r,L as Qe}from"./vendor-react-jvbcysPe.js";import{C as q}from"./card-C7I2oSo0.js";import{B as ae}from"./badge-CeaPXS8z.js";import{B as S}from"./button-DFXx_IH3.js";import{T as Oe,a as qe,b as M,c as D}from"./tabs-B91lk357.js";import{T as Se,a as Ce,b as re,c as z,d as Ae,e as P}from"./table-C0twgINi.js";import{P as He}from"./progress-CNbxHZ6d.js";import{m as i,S as Me,L as G,d as ee,h as se,s as oe,X as $e}from"./index-C-zKQm9Z.js";import{l as De,f as Ge,r as Ue,c as Ve,i as Je,a as ie,b as We,d as Xe,u as X,t as Ne,g as Ze,e as Ye,h as Ke,j as es,k as ss,v as ts}from"./seo-auditor-DyMAGMuE.js";import{C as as}from"./clock-1o_oKlU6.js";import{S as we}from"./shield-check-Cb_KQQqY.js";import{R as ve}from"./refresh-cw-DHq32wi4.js";import{C as rs}from"./copy-CFwO1GUF.js";import{D as ls}from"./download-Frl02w_C.js";import{G as Re}from"./globe-DZwZ5xit.js";import{W as O}from"./wand-sparkles-BzmId1Nu.js";import{P as ke}from"./plus-CiUoz_-I.js";import{E as ns}from"./external-link-CepXWAIq.js";import{T as cs}from"./trash-2-B9064oDd.js";import{F as te}from"./file-text-CKB4fzMw.js";import{L as os}from"./layout-list-DmjKaj53.js";import{C as is}from"./code-xml-BI_wDtHd.js";import{S as ds}from"./settings-2-BKeUwdo9.js";import{L as xs}from"./link-2-YXj1yUaV.js";import{P as ms}from"./pencil-KpVDk0GL.js";import"./vendor-data-8a2i1Wjw.js";function us({severity:a}){const j={critical:{label:"🔴 Critical",cls:"bg-destructive/10 text-destructive border-destructive/20"},warning:{label:"🟠 Warning",cls:"bg-orange-500/10 text-orange-600 border-orange-500/20"},info:{label:"🟡 Info",cls:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}},l=j[a]??j.info;return e.jsx(ae,{variant:"outline",className:`text-xs ${l.cls}`,children:l.label})}function hs({cat:a,active:j,onClick:l}){const $={links:e.jsx(xs,{className:"h-4 w-4"}),content:e.jsx(te,{className:"h-4 w-4"}),technical:e.jsx(ds,{className:"h-4 w-4"}),schema:e.jsx(is,{className:"h-4 w-4"}),structure:e.jsx(os,{className:"h-4 w-4"}),crawl:e.jsx(Re,{className:"h-4 w-4"})},d=Math.round(a.passRate*100);return e.jsxs(q,{className:`p-3 cursor-pointer transition-all rounded-xl border ${j?"border-primary ring-1 ring-primary/30":"border-border hover:border-primary/40"}`,onClick:l,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:$[a.key]}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:`text-xl font-bold font-mono ${a.issueCount===0?"text-green-600":"text-destructive"}`,children:a.issueCount}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"issues"})]}),e.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${d>=90?"bg-green-500":d>=70?"bg-yellow-500":"bg-destructive"}`,style:{width:`${d}%`}})})]})}function ye({value:a,onSave:j}){const[l,$]=r.useState(!1),[d,N]=r.useState(a),[h,w]=r.useState(!1);return l?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:d,onChange:v=>N(v.target.value),className:"px-2 py-1 text-sm border border-border rounded bg-background text-foreground w-[200px]",autoFocus:!0}),e.jsx("button",{disabled:h,onClick:async()=>{w(!0);try{await j(d),i.success("Saved")}catch{i.error("Save failed")}w(!1),$(!1)},children:h?e.jsx(G,{className:"h-3 w-3 animate-spin"}):e.jsx(se,{className:"h-3 w-3 text-green-600"})}),e.jsx("button",{onClick:()=>$(!1),children:e.jsx($e,{className:"h-3 w-3 text-muted-foreground"})})]}):e.jsxs("div",{className:"flex items-center gap-1 group",children:[e.jsx("span",{className:"text-sm text-foreground truncate max-w-[200px]",children:a}),e.jsx("button",{onClick:()=>{N(a),$(!0)},className:"opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ms,{className:"h-3 w-3 text-muted-foreground"})})]})}function L({label:a,icon:j,onClick:l,variant:$="outline"}){const[d,N]=r.useState(!1);return e.jsxs(S,{variant:$==="destructive"?"destructive":"outline",size:"sm",className:"text-xs h-7",disabled:d,onClick:async()=>{N(!0);try{await l()}finally{N(!1)}},children:[d?e.jsx(G,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx("span",{className:"mr-1",children:j}),a]})}function Z({issues:a,domainFilter:j,tabKey:l,calcs:$,onRefresh:d}){const[N,h]=r.useState(""),[w,v]=r.useState(new Set),[I,A]=r.useState(!1),[_,T]=r.useState(null),[c,E]=r.useState({}),u=r.useMemo(()=>{let t=a;if(j!=="all"&&(t=t.filter(m=>m.domain===j)),N){const m=N.toLowerCase();t=t.filter(p=>p.slug.toLowerCase().includes(m)||p.name.toLowerCase().includes(m)||p.issue.toLowerCase().includes(m))}return t},[a,j,N]),o=t=>{const m=new Set(w);m.has(t)?m.delete(t):m.add(t),v(m)},k=()=>{w.size===u.length?v(new Set):v(new Set(u.map(t=>
1t.id)))},C=async(t,m)=>{try{const{error:p}=await oe.functions.invoke("generate-calculator-content",{body:{action:"generate-single",calculator_id:t,force:!0}});if(p)throw p;i.success("Regenerating content for calculator")}catch(p){i.error("Regeneration failed: "+(p instanceof Error?p.message:String(p)))}},H=async()=>{A(!0);for(const t of w)await C(t);v(new Set),A(!1),i.success(`Queued ${w.size} regenerations`)};if(a.length===0)return e.jsx("p",{className:"text-sm text-muted-foreground py-8 text-center",children:"✅ No issues found"});const b=l==="content"||l==="schema";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Filter issues…",value:N,onChange:t=>h(t.target.value),className:"w-full pl-9 pr-3 py-2 text-sm border border-border rounded-lg bg-background text-foreground"})]}),b&&w.size>0&&e.jsxs(S,{size:"sm",onClick:H,disabled:I,children:[I?e.jsx(G,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(O,{className:"h-3 w-3 mr-1"}),"Regenerate ",w.size," selected"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[u.length," issue",u.length!==1?"s":""]}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs(re,{children:[b&&e.jsx(z,{className:"w-8",children:e.jsx("input",{type:"checkbox",checked:w.size===u.length&&u.length>0,onChange:k})}),e.jsx(z,{className:"text-xs",children:"Severity"}),e.jsx(z,{className:"text-xs",children:"Domain"}),e.jsx(z,{className:"text-xs",children:"Calculator"}),e.jsx(z,{className:"text-xs",children:"Issue"}),e.jsx(z,{className:"text-xs",children:"Value"}),e.jsx(z,{className:"text-xs",children:"Actions"})]})}),e.jsx(Ae,{children:u.slice(0,200).map((t,m)=>{var n;const p=`${t.id}-${m}`,R=_===p;return e.jsxs(re,{className:"group",children:[b&&e.jsx(P,{children:e.jsx("input",{type:"checkbox",checked:w.has(t.id),onChange:()=>o(t.id)})}),e.jsx(P,{children:e.jsx(us,{severity:t.severity})}),e.jsx(P,{className:"text-xs font-mono text-muted-foreground",children:t.domain}),e.jsx(P,{children:e.jsx("a",{href:`/${(n=t.domain)==null?void 0:n.toLowerCase()}/${t.slug}`,className:"text-sm text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t.name})}),e.jsx(P,{className:"text-sm text-foreground max-w-xs",children:l==="technical"&&(t.issue.includes("Duplicate title")||t.issue.includes("Duplicate description"))?e.jsx(ye,{value:String(t.value??""),onSave:async x=>{const F=t.issue.includes("title")?"meta_title":"meta_description";await X(t.id,F,x),d()}}):e.jsx("span",{className:"truncate block",children:t.issue})}),e.jsx(P,{className:"text-xs font-mono text-muted-foreground",children:t.value??"—"}),e.jsxs(P,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[l==="links"&&t.issue.includes("Orphaned")&&e.jsx(L,{label:"Suggest Links",icon:e.jsx(ke,{className:"h-3 w-3"}),onClick:()=>T(R?null:p)}),l==="content"&&t.issue.includes("Thin")&&e.jsx(L,{label:"Regenerate",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)}),l==="content"&&t.issue.includes("Missing")&&t.detail&&e.jsxs(e.Fragment,{children:[t.detail.includes("FAQ")&&e.jsx(L,{label:"Gen FAQ",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)}),t.detail.includes("How-To")&&e.jsx(L,{label:"Gen How-To",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)}),t.detail.includes("Desc")&&e.jsx(L,{label:"Gen Desc",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)})]}),l==="technical"&&t.issue.includes("Canonical")&&e.jsx(L,{label:"Fix Canonical",icon:e.jsx(se,{className:"h-3 w-3"}),onClick:async()=>{await X(t.id,"canonical_override",null),i.success("Canonical cleared"),d()}}),l==="schema"&&t.issue.includes("title too long")&&e.jsx(L,{label:"Truncate",icon:e.jsx(se,{className:"h-3 w-3"}),onClick:async()=>{const{data:x}=await oe.from("calculators").select("meta_title").eq("id",t.id).single();if(x!=null&&x.meta_title){const F=Ne(x.meta_title,55);await X(t.id,"meta_title",F),i.success(`Title truncated to ${F.length} chars`),d()}}}),l==="schema"&&t.issue.includes("desc too long")&&e.jsx(L,{label:"Truncate",icon:e.jsx(se,{className:"h-3 w-3"}),onClick:async()=>{const{data:x}=await oe.from("calculators").select("meta_description").eq("id",t.id).single();if(x!=null&&x.meta_description){const F=Ne(x.meta_description,125);await X(t.id,"meta_description",F),i.success(`Description truncated to ${F.length} chars`),d()}}}),l==="schema"&&t.issue.includes("no FAQ")&&e.jsx(L,{label:"Gen FAQ",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)}),l==="structure"&&t.issue.includes("No H2")&&e.jsx(L,{label:"Regenerate",icon:e.jsx(O,{className:"h-3 w-3"}),onClick:()=>C(t.id)}),l==="structure"&&(t.issue.includes("Title too short")||t.issue.includes("Title too long"))&&e.jsx(ye,{value:String(t.value??""),onSave:async x=>{await X(t.id,"meta_title",x),d()}})]}),R&&l==="links"&&e.jsxs("div",{className:"mt-2 p-2 border border-border rounded-lg bg-muted/50 space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-semibold",children:"Add to rabbit holes of:"}),Ze($,t.slug,t.domain).map(x=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-foreground",children:x.name}),e.jsx(L,{label:"Add",icon:e.jsx(ke,{className:"h-3 w-3"}),onClick:async()=>{await Ye(x.id,t.slug),i.success(`Added ${t.slug} to ${x.slug} rabbit holes`)}})]},x.id))]})]})]},p)})})]}),u.length>200&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center py-2",children:["Showing 200 of ",u.length," issues"]})]})]})}function ps({calcs:a}){const[j,l]=r.useState(!1),[$,d]=r.useState(0),[N,h]=r.useState([]),[w,v]=r.useState({}),[I,A]=r.useState(null);r.useEffect(()=>{try{const c=localStorage.getItem("procalc_link_validation");if(c){const E=JSON.parse(c);h(E.results??[]),A(E.validatedAt??null)}}catch{}},[]);const _=async()=>
1{l(!0),d(0);const c=ss(a),E=[...c.keys()],u=20,o=[];for(let b=0;b<E.length;b+=u)o.push(E.slice(b,b+u));const k=[];for(let b=0;b<o.length;b++){try{const t=await ts(o[b]);for(const m of t){const p=c.get(m.url)??[];k.push({...m,calcIds:p.map(R=>R.calcId),calcNames:p.map(R=>`${R.domain}/${R.slug}`)})}}catch(t){console.error("Batch validation error:",t)}d(Math.round((b+1)/o.length*100))}h(k);const C=new Date().toISOString();A(C),localStorage.setItem("procalc_link_validation",JSON.stringify({results:k,validatedAt:C})),l(!1);const H=k.filter(b=>!b.ok);i.success(`Validated ${k.length} URLs — ${H.length} broken`)},T=N.filter(c=>!c.ok);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(S,{onClick:_,disabled:j,size:"sm",children:[j?e.jsx(G,{className:"h-4 w-4 animate-spin mr-1.5"}):e.jsx(ns,{className:"h-4 w-4 mr-1.5"}),j?"Validating…":"Validate External Links"]}),I&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last checked: ",new Date(I).toLocaleString()]}),N.length>0&&e.jsxs(ae,{variant:"outline",className:`text-xs ${T.length>0?"bg-destructive/10 text-destructive":"bg-green-500/10 text-green-600"}`,children:[T.length," broken / ",N.length," total"]})]}),j&&e.jsx(He,{value:$,className:"h-2"}),T.length>0&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs(re,{children:[e.jsx(z,{className:"text-xs",children:"Status"}),e.jsx(z,{className:"text-xs",children:"URL"}),e.jsx(z,{className:"text-xs",children:"Used By"}),e.jsx(z,{className:"text-xs",children:"Actions"})]})}),e.jsx(Ae,{children:T.slice(0,100).map((c,E)=>e.jsxs(re,{children:[e.jsx(P,{children:e.jsx(ae,{variant:"outline",className:"text-xs bg-destructive/10 text-destructive font-mono",children:c.status||"ERR"})}),e.jsxs(P,{className:"text-xs font-mono text-foreground max-w-[300px] truncate",children:[e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:underline",children:c.url}),c.error&&e.jsx("span",{className:"block text-destructive text-[10px]",children:c.error})]}),e.jsxs(P,{className:"text-xs text-muted-foreground",children:[c.calcNames.slice(0,3).join(", "),c.calcNames.length>3&&` +${c.calcNames.length-3}`]}),e.jsx(P,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"text",placeholder:"Replacement URL…",value:w[c.url]??"",onChange:u=>v(o=>({...o,[c.url]:u.target.value})),className:"px-2 py-1 text-xs border border-border rounded bg-background text-foreground w-[180px]"}),e.jsx(S,{variant:"outline",size:"sm",className:"h-6 text-xs",disabled:!w[c.url],onClick:async()=>{const u=w[c.url];if(u){for(const o of c.calcIds)await Ke(o,c.url,u);i.success(`Replaced in ${c.calcIds.length} calculator(s)`)}},children:"Replace"})]}),e.jsxs(S,{variant:"destructive",size:"sm",className:"h-6 text-xs w-fit",onClick:async()=>{for(const u of c.calcIds)await es(u,c.url);i.success(`Removed from ${c.calcIds.length} calculator(s)`),h(u=>u.filter(o=>o.url!==c.url))},children:[e.jsx(cs,{className:"h-3 w-3 mr-1"})," Remove"]})]})})]},E))})]})})]})}function gs(){var he,pe,ge,fe,be,je;const[a,j]=r.useState(null),[l,$]=r.useState(null),[d,N]=r.useState(!1),[h,w]=r.useState(!1),[v,I]=r.useState(null),[A,_]=r.useState(null),[T,c]=r.useState(0),[E,u]=r.useState(0),[o,k]=r.useState(10),[C,H]=r.useState({applied:0,errors:0}),[b,t]=r.useState({applied:0,errors:0}),[m,p]=r.useState(!1),[R,n]=r.useState(null),[x,F]=r.useState(null),[Fe,le]=r.useState(0),[Y,Te]=r.useState({applied:0,errors:0}),[ne,Be]=r.useState(""),V=r.useRef(null),J=r.useRef(null),W=r.useRef(null);r.useEffect(()=>{if(!d){c(0);return}c(0);const s=setInterval(()=>c(g=>g+1),1e3);return()=>clearInterval(s)},[!!d]),r.useEffect(()=>{if(!h){u(0);return}u(0);const s=setInterval(()=>u(g=>g+1),1e3);return()=>clearInterval(s)},[!!h]),r.useEffect(()=>{if(!m){le(0);return}le(0);const s=setInterval(()=>le(g=>g+1),1e3);return()=>clearInterval(s)},[!!m]);const U=async(s,g,f)=>{const y=await fetch(`https://nizrdexbryphrkmcergs.supabase.co/functions/v1/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5penJkZXhicnlwaHJrbWNlcmdzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzUzMTcyNTgsImV4cCI6MjA5MDg5MzI1OH0.oraXwVUA796TZ117VppaOvqCs1iBTTA1jFBYAB_77Hc"},body:JSON.stringify(g),signal:f});if(!y.ok)throw new Error(`HTTP ${y.status}: ${await y.text().then(Q=>Q.slice(0,100))}`);return y.json()},de=async()=>
1{V.current=new AbortController,p("Checking missing FAQs…");try{const s=await U("generate-faq",{mode:"status"},V.current.signal);n(s),i.success(`${s.total} calculators missing FAQs`)}catch(s){s.name==="AbortError"?i("Scan cancelled"):i.error(`Scan failed: ${s.message}`)}p(!1)},xe=async s=>{var f;V.current=new AbortController;const g=s?`Previewing FAQ backfill (${o} calcs)…`:`Generating FAQs (${o} calcs, ~${o*5}s)…`;p(g),F(null);try{const y={mode:"batch",batch_size:o,dry_run:s};ne&&(y.domain=ne);const Q=await U("generate-faq",y,V.current.signal);F(Q);const B=((f=Q.results)==null?void 0:f.filter(K=>K.success).length)??0,Pe=(Q.processed??0)-B;s||Te(K=>({applied:K.applied+B,errors:K.errors+Pe})),i.success(`${s?"Previewed":"Generated"} FAQs for ${B}/${Q.processed} calculators`),s||de()}catch(y){y.name==="AbortError"?i("Backfill cancelled (server may still finish)"):i.error(`Backfill failed: ${y.message}`)}p(!1)},_e=()=>{var s;(s=V.current)==null||s.abort()},Ee=async()=>{J.current=new AbortController,N("Scanning 192 calculators…");try{const s=await U("seo-faq-frontload",{mode:"batch",dry_run:!0},J.current.signal);j(s),i.success(`Scanned ${s.total_scanned} — ${s.needs_work} need FAQ front-loading`)}catch(s){s.name==="AbortError"?i("FAQ scan cancelled"):i.error(`FAQ scan failed: ${s.message}`)}N(!1)},me=async s=>{var g;J.current=new AbortController,N(s?`Rewriting FAQs (${o} calcs, ~${o*6}s)…`:`Previewing FAQ rewrites (${o})…`),I(null);try{const f=await U("seo-faq-frontload",{mode:"batch",batch_size:o,apply:s},J.current.signal);I(f);const y=((g=f.results)==null?void 0:g.filter(B=>!B.error).length)??0,Q=(f.processed??0)-y;s&&H(B=>({applied:B.applied+y,errors:B.errors+Q})),i.success(`${s?"Applied":"Previewed"} ${y}/${f.processed} FAQ rewrites`)}catch(f){f.name==="AbortError"?i("FAQ batch cancelled (server may still finish)"):i.error(`FAQ batch failed: ${f.message}`)}N(!1)},Ie=()=>{var s;(s=J.current)==null||s.abort()},Le=async()=>{W.current=new AbortController,w("Scanning seo_content…");try{const s=await U("seo-answer-blocks",{mode:"batch",dry_run:!0},W.current.signal);$(s),i.success(`Scanned ${s.total_scanned} — ${s.needs_work} need answer blocks`)}catch(s){s.name==="AbortError"?i("Block scan cancelled"):i.error(`Block scan failed: ${s.message}`)}w(!1)},ue=async s=>{var g;W.current=new AbortController,w(s?`Generating answer blocks (${o} calcs, ~${o*6}s)…`:`Previewing answer blocks (${o})…`),_(null);try{const f=await U("seo-answer-blocks",{mode:"batch",batch_size:o,apply:s},W.current.signal);_(f);const y=((g=f.results)==null?void 0:g.filter(B=>!B.error).length)??0,Q=(f.processed??0)-y;s&&t(B=>({applied:B.applied+y,errors:B.errors+Q})),i.success(`${s?"Applied":"Previewed"} ${y}/${f.processed} answer blocks`)}catch(f){f.name==="AbortError"?i("Block batch cancelled (server may still finish)"):i.error(`Block batch failed: ${f.message}`)}w(!1)},ze=()=>{var s;(s=W.current)==null||s.abort()},ce=({label:s,seconds:g,onStop:f})=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-blue-50 dark:bg-blue-950/30 rounded-lg px-3 py-2",children:[e.jsx(G,{className:"h-4 w-4 animate-spin text-primary shrink-0"}),e.jsx("span",{className:"text-primary flex-1",children:s}),e.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[g,"s"]}),e.jsxs(S,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-destructive hover:text-destructive",onClick:f,children:[e.jsx($e,{className:"h-3 w-3 mr-1"})," Stop"]})]});return e.jsxs(q,{className:"p-4 rounded-xl border border-border space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"GEO Optimization"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Optimize content for AI extraction — front-load FAQ answers and add structured answer blocks to seo_content."})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[e.jsx("span",{children:"Batch:"}),[5,10,25,50].map(s=>e.jsx("button",{onClick:()=>k(s),className:`px-1.5 py-0.5 rounded transition-colors ${o===s?"bg-primary text-primary-foreground font-semibold":"bg-muted hover:bg-muted/80"}`,children:s},s))]})]}),e.jsxs("div",{className:"space-y-3 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-base font-semibold",children:["0. FAQ Backfill ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:"(228 missing)"})]}),Y.applied>0&&e.jsxs("span",{className:"text-xs font-mono text-green-600",children:["Session: ",Y.applied," generated",Y.errors>0?`, ${Y.errors} errors`:""]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Generates 5–8 FAQ 
1items for calculators that have ",e.jsx("strong",{children:"none"}),". Priority order: Math → Finance → Property → Investing → Health → rest."]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(S,{size:"sm",variant:"outline",onClick:de,disabled:!!m,children:[e.jsx(ee,{className:"h-3.5 w-3.5 mr-1.5"})," Check Status"]}),e.jsxs(S,{size:"sm",variant:"outline",onClick:()=>xe(!0),disabled:!!m,children:[e.jsx(te,{className:"h-3.5 w-3.5 mr-1.5"})," Preview ",o]}),e.jsxs(S,{size:"sm",onClick:()=>xe(!1),disabled:!!m,children:[e.jsx(O,{className:"h-3.5 w-3.5 mr-1.5"})," Generate ",o]}),e.jsxs("select",{value:ne,onChange:s=>Be(s.target.value),className:"text-xs border border-border rounded px-2 py-1 bg-background text-foreground",children:[e.jsx("option",{value:"",children:"All domains"}),["Math","Finance","Property","Investing","Health","Engineering","Automotive","Fitness","Business","Science","Technology","Food","Writing","Literature","Physics","Astronomy","Art","History","Psychology","Geography","Legal","Insurance","Sports","Gaming","Travel","Culture","Construction"].map(s=>e.jsx("option",{value:s,children:s},s))]})]}),m&&e.jsx(ce,{label:m,seconds:Fe,onStop:_e}),R&&!m&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"font-mono text-destructive",children:R.total})," calculators missing FAQs"]}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-0.5 mt-1",children:Object.entries(R.by_domain).map(([s,g])=>e.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:s}),": ",String(g)]},s))})]}),x&&!m&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1.5 max-h-64 overflow-y-auto",children:[e.jsxs("p",{className:"font-medium",children:[x.dry_run?"👁️ Preview":"✅ Generated"," — ",x.succeeded,"/",x.processed," succeeded"]}),(he=x.results)==null?void 0:he.map(s=>{var g;return e.jsx("div",{className:"border-t border-border/50 pt-1",children:e.jsxs("p",{className:"font-mono text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[s.domain,"/"]}),s.slug,":"," ",s.success?e.jsxs("span",{className:"text-green-600",children:[s.faq_count," FAQs generated"]}):e.jsx("span",{className:"text-destructive",children:(g=s.error)==null?void 0:g.slice(0,80)})]})},s.slug)})]})]}),e.jsxs("div",{className:"space-y-3 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold",children:"1. FAQ Front-Loading"}),C.applied>0&&e.jsxs("span",{className:"text-xs font-mono text-green-600",children:["Session: ",C.applied," applied",C.errors>0?`, ${C.errors} errors`:""]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Rewrites FAQ answers so the first sentence is a standalone citable passage (40-60 words)."}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(S,{size:"sm",variant:"outline",onClick:Ee,disabled:!!d,children:[e.jsx(ee,{className:"h-3.5 w-3.5 mr-1.5"})," Scan FAQs"]}),e.jsxs(S,{size:"sm",variant:"outline",onClick:()=>me(!1),disabled:!!d,children:[e.jsx(te,{className:"h-3.5 w-3.5 mr-1.5"})," Preview ",o]}),e.jsxs(S,{size:"sm",onClick:()=>me(!0),disabled:!!d,children:[e.jsx(O,{className:"h-3.5 w-3.5 mr-1.5"})," Apply ",o]})]}),d&&e.jsx(ce,{label:d,seconds:T,onStop:Ie}),a&&!d&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:a.total_scanned})," calculators scanned"]}),e.jsxs("p",{children:[e.jsx("strong",{children:a.needs_work})," have low-scoring FAQs (below threshold)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Top candidates: ",(pe=a.batch)==null?void 0:pe.slice(0,5).map(s=>`${s.slug} (${s.avg_score})`).join(", ")]})]}),v&&!d&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1.5 max-h-64 overflow-y-auto",children:[e.jsxs("p",{className:"font-medium",children:[v.applied?"✅ Applied":"👁️ Preview"," — ",(ge=v.results)==null?void 0:ge.filter(s=>!s.error).length,"/",v.processed," succeeded"]}),(fe=v.results)==null?void 0:fe.map(s=>e.jsx("div",{className:"border-t border-border/50 pt-1.5",children:e.jsxs("p",{className:"font-mono text-xs",children:[s.slug,": ",s.error?e.jsx("span",{className:"text-destructive",children:s.error.slice(0,80)}):e.jsxs("span",{className:"text-green-600",children:[s.avg_score_before," → ",s.avg_score_after," (",s.rewrites,"/",s.total_faqs," rewritten)"]})]})},s.slug))]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold",children:"2. Answer Blocks in seo_content"}),b.applied>0&&e.jsxs("span",{className:"text-xs font-mono text-green-600",children:["Session: ",b.applied," applied",b.errors>0?`, ${b.errors} errors`:""]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Generates ",e.jsx("code",{className:"text-xs bg-muted px-1 rounded",children:"<p><strong>Q?</strong> 40-60 word answer.</p>"}
1)," blocks prepended to seo_content."]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(S,{size:"sm",variant:"outline",onClick:Le,disabled:!!h,children:[e.jsx(ee,{className:"h-3.5 w-3.5 mr-1.5"})," Scan Content"]}),e.jsxs(S,{size:"sm",variant:"outline",onClick:()=>ue(!1),disabled:!!h,children:[e.jsx(te,{className:"h-3.5 w-3.5 mr-1.5"})," Preview ",o]}),e.jsxs(S,{size:"sm",onClick:()=>ue(!0),disabled:!!h,children:[e.jsx(O,{className:"h-3.5 w-3.5 mr-1.5"})," Apply ",o]})]}),h&&e.jsx(ce,{label:h,seconds:E,onStop:ze}),l&&!h&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:l.total_scanned})," calculators scanned"]}),e.jsxs("p",{children:[e.jsx("strong",{children:l.already_have_blocks})," already have answer blocks"]}),e.jsxs("p",{children:[e.jsx("strong",{children:l.needs_work})," need answer blocks added"]})]}),A&&!h&&e.jsxs("div",{className:"text-sm bg-muted/50 rounded-lg p-3 space-y-1.5 max-h-64 overflow-y-auto",children:[e.jsxs("p",{className:"font-medium",children:[A.applied?"✅ Applied":"👁️ Preview"," — ",(be=A.results)==null?void 0:be.filter(s=>!s.error).length,"/",A.processed," succeeded"]}),(je=A.results)==null?void 0:je.map(s=>{var g;return e.jsxs("div",{className:"border-t border-border/50 pt-1.5",children:[e.jsxs("p",{className:"font-mono text-xs",children:[s.slug,": ",s.error?e.jsx("span",{className:"text-destructive",children:s.error.slice(0,80)}):e.jsxs("span",{className:"text-green-600",children:[s.blocks_generated," blocks generated"]})]}),!s.error&&((g=s.blocks)==null?void 0:g.map((f,y)=>e.jsxs("p",{className:"text-xs text-muted-foreground ml-3",children:["• ",f.question]},y)))]},s.slug)})]})]})]})}function Ds(){var b,t,m,p,R;const[a,j]=r.useState(null),[l,$]=r.useState(!1),[d,N]=r.useState("links"),[h,w]=r.useState("all"),[v,I]=r.useState([]);r.useEffect(()=>{const n=De();n&&(j(n),Ge().then(I).catch(()=>{}))},[]);const A=r.useCallback(async()=>{$(!0);try{const{audit:n,calcs:x}=await Ue();I(x),j(n),i.success(`Audit complete: ${n.calculatorCount} calculators checked`)}catch(n){i.error("Audit failed: "+(n instanceof Error?n.message:String(n)))}finally{$(!1)}},[]),_=r.useCallback(()=>{A()},[A]),{score:T,categories:c}=r.useMemo(()=>a?Ve(a):{score:0,categories:[]},[a]),E=r.useCallback(()=>{if(!a)return;const n=Je(ie(a)),x=new Blob([n],{type:"text/csv"}),F=document.createElement("a");F.href=URL.createObjectURL(x),F.download=`seo-health-${new Date().toISOString().slice(0,10)}.csv`,F.click()},[a]),u=r.useCallback(()=>{a&&(navigator.clipboard.writeText(We(a)),i.success("Report copied to clipboard"))},[a]),o=r.useMemo(()=>{if(!a)return[];const n=ie(a);return[...new Set(n.map(x=>x.domain))].sort()},[a]),k=r.useMemo(()=>a?{links:[...a.links.orphaned,...a.links.lowInbound],content:[...a.content.thin,...a.content.missingFields],technical:[...a.technical.canonicalMismatches,...a.technical.duplicateTitles,...a.technical.duplicateDescriptions,...a.technical.duplicateNames],schema:[...a.schema.metaLe
1ngthViolations,...a.schema.missingFaq],structure:[...a.structure.titleLength,...a.structure.h2Issues],crawl:[]}:{},[a]),C=r.useMemo(()=>{if(!(a!=null&&a.auditedAt))return null;const n=Date.now()-new Date(a.auditedAt).getTime();return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)} min ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`},[a]),H=Xe(a);return e.jsxs("section",{className:"space-y-6 p-4 md:p-6 max-w-[1400px]",children:[e.jsx(Me,{title:"SEO Health Command Center | ProCalc.ai Admin",description:"Internal SEO audit dashboard",noindex:!0}),a&&H&&e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-lg border border-yellow-500/30 bg-yellow-500/5",children:[e.jsx(as,{className:"h-4 w-4 text-yellow-600 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-foreground",children:["Last audit was ",C,". Run a fresh audit to catch new issues."]}),e.jsx(S,{size:"sm",variant:"outline",className:"ml-auto h-7 text-xs",onClick:A,disabled:l,children:"Run Now"})]}),e.jsxs("header",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(we,{className:"h-6 w-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold font-sans text-foreground",children:"SEO Health Command Center"}),e.jsx(ae,{variant:"outline",className:"text-xs",children:"Internal"}),C&&!H&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Last audit: ",C]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:`text-4xl font-bold font-mono ${T>=800?"text-green-600":T>=600?"text-yellow-600":"text-destructive"}`,children:a?T:"—"}),e.jsx("span",{className:"text-lg text-muted-foreground font-mono",children:"/ 1000"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 ml-auto",children:[e.jsxs(S,{onClick:A,disabled:l,children:[l?e.jsx(G,{className:"h-4 w-4 animate-spin mr-1.5"}):e.jsx(ve,{className:"h-4 w-4 mr-1.5"}),l?"Running…":"Run Full Audit"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:u,disabled:!a,children:[e.jsx(rs,{className:"h-4 w-4 mr-1.5"})," Copy Report"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:E,disabled:!a,children:[e.jsx(ls,{className:"h-4 w-4 mr-1.5"})," Export CSV"]}),e.jsxs("select",{value:h,onChange:n=>w(n.target.value),className:"px-3 py-1.5 text-sm border border-border rounded-lg bg-background text-foreground",children:[e.jsx("option",{value:"all",children:"All Domains"}),o.map(n=>e.jsx("option",{value:n,children:n.charAt(0).toUpperCase()+n.slice(1)},n))]})]})]}),c.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:c.map(n=>e.jsx(hs,{cat:n,active:d===n.key,onClick:()=>N(n.key)},n.key))}),a?e.jsxs(Oe,{value:d,onValueChange:N,children:[e.jsxs(qe,{className:"flex-wrap",children:[e.jsxs(M,{value:"links",children:["🔗 Links (",((b=k.links)==null?void 0:b.length)??0,")"]}),e.jsxs(M,{value:"content",children:["📝 Content (",((t=k.content)==null?void 0:t.length)??0,")"]}),e.jsxs(M,{value:"technical",children:["⚙️ Technical (",((m=k.technical)==null?void 0:m.length)??0,")"]}),e.jsxs(M,{value:"schema",children:["🏷️ Schema (",((p=k.schema)==null?void 0:p.length)??0,")"]}),e.jsxs(M,{value:"structure",children:["📐 Structure (",((R=k.structure)==null?void 0:R.length)??0,")"]}),e.jsx(M,{value:"crawl",children:"🌐 Live Crawl"}),e.jsx(M,{value:"geo",children:"🤖 GEO"})]}),e.jsx(D,{value:"links",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Link Health"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Orphaned pages, low inbound connections, and broken external links."}),e.jsx(Z,{issues:k.links??[],domainFilter:h,tabKey:"links",calcs:v,onRefresh:_})]}),e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-2",children:"🔍 External Link Validator"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Check source_citations for broken external links across all calculators."}),e.jsx(ps,{calcs:v})]})]})}),e.jsx(D,{value:"content",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Content Quality"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Thin content and missing SEO fields. Use bulk actions to regenerate."}),e.jsx(Z,{issues:k.content??[],domainFilter:h,tabKey:"content",calcs:v,onRefresh:_})]})}),e.jsx(D,{value:"technical",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Technical SEO"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Canonical mismatches and duplicate titles/descriptions. Click to edit inline."}),e.jsx(Z,{issues:k.technical??[],domainFilter:h,tabKey:"technical",calcs:v,onRefresh:_})]})}),e.jsx(D,{value:"schema",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Schema & Meta"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Twitter/OG meta length violations and missing FAQ data."}),e.jsx(Z,{issues:k.schema??[],domainFilter:h,tabKey:"schema",calcs:v,onRefresh:_})]})}),e.jsx(D,{value:"structure",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Page Structure"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Title lengths and H2 heading analysis."}),e.jsx(Z,{issues:k.structure??[],domainFilter:h,tabKey:"structure",calcs:v,onRefresh:_})]})}),e.jsx(D,{value:"crawl",children:e.jsxs(q,{className:"p-4 rounded-xl border border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Live Crawl"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Use the existing crawler to verify prerender status and live HTML. Visit ",e.jsx(Qe,{to:"/admin/prerender",className:"text-primary hover:underline",children:"/admin/prerender"})," for full crawl capabilities."]}),e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground
1/50"}),"Live crawl checks are available via the Prerender tab.",e.jsx("br",{}),"This tab reserved for future inline crawl integration."]})]})}),e.jsx(D,{value:"geo",children:e.jsx(gs,{})})]}):e.jsxs(q,{className:"p-12 rounded-xl border border-border text-center",children:[e.jsx(we,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground/30"}),e.jsx("p",{className:"text-lg font-semibold text-foreground mb-2",children:"No audit data"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:'Click "Run Full Audit" to scan all live calculators for SEO issues.'}),e.jsxs(S,{onClick:A,disabled:l,children:[l?e.jsx(G,{className:"h-4 w-4 animate-spin mr-1.5"}):e.jsx(ve,{className:"h-4 w-4 mr-1.5"}),"Run Full Audit"]})]}),a&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[a.calculatorCount," calculators audited · ",ie(a).length," total issues · Score ",T,"/1000"]})]})}export{Ds 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.