1import{j as e,ab as B,a0 as Te,G as Ee,az as Ie,a9 as D,aw as lt,T as rt,aU as Oe,$ as Re,a2 as nt,k as ze,S as it,E as ot,ar as ct}from"./ui-B8JvSNI8.js";import{r as o}from"./vendor-Cm67UgTX.js";import{N as dt,r as mt}from"./index-DCEbEYry.js";import{P as xt}from"./Pagination-BrNmAmoc.js";import{A as pt}from"./AdminModalPortal-ClVhyrUA.js";import{u as Le}from"./useDataCache-nbZekfJT.js";import"./supabase-DlzPxpeg.js";import"./analytics-DDD2QK2m.js";async function m(s,i={}){var x;try{return await dt(s,i)}catch(c){throw(c.message==="Unauthorized"||(x=c.message)!=null&&x.includes("Not authenticated"))&&(mt(),window.location.href="/admin/login"),c}}const u={getProperties:()=>m("/admin/seo/properties"),getSettings:()=>m("/admin/seo/settings"),updateSetting:(s,i)=>m("/admin/seo/settings",{method:"PATCH",body:JSON.stringify({key:s,value:i})}),runAudit:(s,i=!1)=>m("/admin/seo/audit/run",{method:"POST",body:JSON.stringify({property:s,includeHtml:i})}),listRuns:s=>m(`/admin/seo/audit/runs${s?`?property=${encodeURIComponent(s)}`:""}`),getRun:s=>m(`/admin/seo/audit/runs/${s}`),listIssues:s=>{const i=new URLSearchParams;return s.property&&i.set("property",s.property),s.status&&i.set("status",s.status),s.severity&&i.set("severity",s.severity),s.limit&&i.set("limit",String(s.limit)),s.offset&&i.set("offset",String(s.offset)),m(`/admin/seo/issues?${i.toString()}`)},updateIssue:(s,i)=>m(`/admin/seo/issues/${s}`,{method:"PATCH",body:JSON.stringify({status:i})}),getTrends:(s,i=90)=>m(`/admin/seo/trends?property=${encodeURIComponent(s)}&days=${i}`),generateFix:s=>m("/admin/seo/fixes/generate",{method:"POST",body:JSON.stringify({issueId:s})}),listFixes:s=>m(`/admin/seo/fixes/issue/${s}`),approveFix:s=>m(`/admin/seo/fixes/${s}/approve`,{method:"POST"}),rejectFix:s=>m(`/admin/seo/fixes/${s}/reject`,{method:"POST"}),applyFix:s=>m(`/admin/seo/fixes/${s}/apply`,{method:"POST"}),submitSitemap:s=>m("/admin/seo/sitemap/submit",{method:"POST",body:JSON.stringify({property:s})}),inspectUrl:s=>m("/admin/seo/gsc/inspect",{method:"POST",body:JSON.stringify({url:s})}),getGscQueries:()=>m("/admin/seo/gsc/queries")},Ge="seo_assistant_prefs",ut="seo_assistant_page_size",O={property:"ayuveda.ai",severityFilter:"all",statusFilter:"open",page:1,pageSize:25,includeHtml:!1},Ue=new Set([10,25,50,100]);function gt(){var s;if(typeof window=="undefined")return O;try{const i=window.localStorage.getItem(Ge);if(i){const c=JSON.parse(i),w=Ue.has(c.pageSize)?c.pageSize:O.pageSize;return{...O,...c,page:Math.max(1,(s=c.page)!=null?s:1),pageSize:w}}const x=window.localStorage.getItem(ut);if(x){const c=parseInt(x,10);return{...O,pageSize:Ue.has(c)?c:O.pageSize}}}catch(i){}return O}function ht(s){typeof window!="undefined"&&window.localStorage.setItem(Ge,JSON.stringify(s))}function re(s){return!!(s==="content.summary.missing"||s.includes("title")||s.includes("description")||s.includes("og_image"))}function Me(s){return s.includes("alt")||s.startsWith("html.images")?"Alt text must be edited manually in the page content.":s==="content.summary.missing"?"Use Improve with AI to draft a medical summary, then Approve & Apply.":s.startsWith("content.")||s.startsWith("html.content")?"Content depth issues need manual editing in Diseases/Symptoms/Wiki admin.":s.startsWith("technical.")||s.startsWith("html.http")?"Technical issues require deployment or infrastru
1cture changes.":s.startsWith("html.")||s.startsWith("schema.")?"HTML/schema issues must be fixed in frontend templates or page code.":s.startsWith("indexability.")?"Change publish status in the relevant content admin.":"This issue type is not supported for automated AI apply yet."}const _t=()=>{var ue,ge,he,be,fe,je,Ne,we,ye,ve,Se,_e,ke,Ae,Ce,$e,Fe,Pe;const[s,i]=o.useState(()=>gt()),{property:x,severityFilter:c,statusFilter:w,page:v,pageSize:S,includeHtml:ne}=s,ie=o.useCallback(t=>{i(a=>{const n=typeof t=="function"?t(a):t;return ht(n),n})},[]),j=o.useCallback(t=>{ie(a=>({...a,...t}))},[ie]),[_,R]=o.useState(!1),[z,L]=o.useState(null),[d,k]=o.useState(null),[oe,h]=o.useState(null),[l,A]=o.useState(null),[M,U]=o.useState([]),[Z,G]=o.useState(!1),[ce,K]=o.useState(null),[V,C]=o.useState(null),[N,b]=o.useState(null),[We,W]=o.useState(null),Je=o.useCallback(async()=>{const[t,a,n,p]=await Promise.all([u.getProperties(),u.listRuns(x),u.getTrends(x),u.getSettings()]);return{properties:t.properties,latestRun:a.runs[0]||null,trends:n.trends,settings:p}},[x]),{data:g,isLoading:He,error:Q,refetch:qe}=Le(`admin_seo_summary_${x}`,Je),Ye=(ue=g==null?void 0:g.properties)!=null?ue:[],r=(ge=g==null?void 0:g.latestRun)!=null?ge:null,Be=(he=g==null?void 0:g.trends)!=null?he:[],f=(be=g==null?void 0:g.settings)!=null?be:null,De=o.useCallback(()=>u.listIssues({property:x,status:w==="all"?void 0:w,severity:c==="all"?void 0:c,limit:S,offset:(v-1)*S}),[x,w,c,v,S]),{data:$,isLoading:X,error:ee,refetch:F}=Le(`admin_seo_issues_${x}_${w}_${c}_${v}_${S}`,De),P=(fe=$==null?void 0:$.issues)!=null?fe:[],T=(je=$==null?void 0:$.total)!=null?je:0,J=Math.max(1,Math.ceil(T/S));o.useEffect(()=>{Q&&h(Q.message||"Failed to load SEO data")},[Q]),o.useEffect(()=>{ee&&h(ee.message||"Failed to load issues")},[ee]);const H=qe;o.useEffect(()=>{T>0&&v>J&&j({page:J})},[T,v,J,j]);const de=o.useCallback(async t=>{try{const{run:a,progress:n}=await u.getRun(t);return n?k(n):a.processing_status==="processing"&&k(p=>p!=null?p:{phase:"evaluating",label:"Audit in progressâ¦",current:0,total:1,percent:12}),a.processing_status==="processing"?!1:(R(!1),L(null),k(null),a.processing_status==="failed"?h(a.error_message||"Audit failed"):C({ok:!0,message:"Audit complete. Results updated below."}),await H(),await F(),!0)}catch(a){return h(a.message||"Failed to check audit status"),R(!1),L(null),k(null),!0}},[H,F]);o.useEffect(()=>{if(!z)return;let t=!1,a;const n=async()=>{if(t)return;!await de(z)&&!t&&(a=setTimeout(n,1500))};return a=setTimeout(n,400),()=>{t=!0,clearTimeout(a)}},[z,de]),o.useEffect(()=>{(r==null?void 0:r.processing_status)==="processing"&&r.id&&!z&&!_&&(R(!0),L(r.id))},[r==null?void 0:r.processing_status,r==null?void 0:r.id,z,_]);const Ze=t=>{j({pageSize:t,page:1})},Ke=async()=>{R(!0),h(null),C(null),k({phase:"loading",label:"Starting auditâ¦",current:0,total:1,percent:2});try{const{runId:t}=await u.runAudit(x,ne);L(t)}catch(t){h(t.message),R(!1),L(null),k(null)}},Ve=async t=>{G(!0),b(null);try{const{suggestion:a}=await u.generateFix(t.id);U(n=>[a,...n]),b({type:"success",text:"Suggestion generated. Review below before applying."})}catch(a){const n=a.message||"Failed to generate suggestion";h(n),b({type:"error",text:n})}finally{G(!1)}},Qe=async t=>{var a;G(!0),W(t),b(null),h(null);try{await u.approveFix(t);const n=await u.applyFix(t),p=(a=n.indexNow)!=null&&a.success?`${n.message} IndexNow notified search engines.`:n.message||(n.resolved?"Fix applied successfully. Issue marked resolved.":"Fix saved, but the issue remains open.");U(y=>y.map(le=>le.id===t?{...le,status:"applied"}:le)),n.resolved?(A(y=>y?{...y,status:"resolved"}:null),b({type:"success",text:p}),C({ok:!0,message:p}),await H(),await F(),window.setTimeout(()=>{A(null),b(null),W(null)},1800)):(A(y=>y?{...y,status:"open"}:null),b({type:"warning",text:p}),C({ok:!1,message:p}),await F())}catch(n){const p=n.message||"Failed to apply fix";h(p),b({type:"error",text:p})}finally{G(!1),W(null)}},me=async t=>{A(t),U([]),K(null),b(null),W(null);try{const{suggestions:a}=await u.listFixes(t.id);U(a)}catch(a){U([])}},Xe=async t=>{try{const a=await u.inspectUrl(t);K(a)}catch(a){K({error:a.message})}},et=async()=>{try{const t=await u.submitSitemap(x);C({ok:!0,message:t.message||"Sitemap submitted successfully."})}catch(t){C({ok:!1,message:t.message||"Sitemap submission failed"})}},q=(Ne=r==null?void 0:r.overall_score)!=null?Ne:null,te=(r==null?void 0:r.issue_counts)||{critical:0,warning:0,info:0},se=t=>t==="critical"?e.jsx(ze,{className:"h-4 w-4 text-rose-600"}):t==="warning"?e.jsx(D,{className:"h-4 w-4 text-amber-600"}):e.jsx(ct,{className:"h-4 w-4 text-indigo-500"}),ae=t=>t==="critical"?"bg-rose-50 text-rose-700 border-rose-200":t==="warning"?"bg-amber-50 text-amber-800 border-amber-200":"bg-indigo-50 text-indigo-700 border-indigo-200",xe=t=>t>=80?"text-emerald-600":t>=60?"text-amber-600":"text-rose-600",tt=t=>t>=80?"bg-emerald-500":t>=60?"bg-amber-500":"bg-rose-500",st=t=>t==="resolved"?"bg-emerald-50 text-emerald-800 border-emerald-200":t==="ignored"?"bg-slate-100 text-slate-600 border-slate-200":"bg-indigo-50 text-indigo-800 border-indigo-200",at=t=>new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"}),Y=Be.slice(-12),pe=t=>t.replace(/^https?:\/\//,"").replace(/\/$/,""),E="px-3 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500 sm:px-4 sm:py-3 lg:px-5",I="max-w-0 px-3 py-2.5 sm:px-4 sm:py-3 lg:px-5";return He&&!g?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(B,{className:"h-9 w-9 animate-spin text-emerald-600"})}):e.jsxs("div",{className:"w-full min-w-0 space-y-6 sm:space-y-8 pb-16",children:[e.jsxs("div",{className:"relative min-w-0 overflow-hidden rounded-2xl bg-gradient-to-br from-slate-800 via-slate-800 to-slate-900 px-4 py-6 shadow-xl ring-1 ring-slate-700/50 sm:px-6 sm:py-8 lg:px-8",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_80%_8
10%_at_50%_-20%,rgba(16,185,129,0.15),transparent)]"}),e.jsxs("div",{className:"relative flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-emerald-400 sm:text-sm",children:"SEO Assistant"}),e.jsx("h1",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl lg:text-3xl",children:"SEO Operations"}),e.jsx("p",{className:"max-w-xl text-xs text-slate-400 sm:text-sm",children:"Audit metadata, prioritize fixes, generate AI suggestions, and track health over time."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:x,onChange:t=>j({property:t.target.value,page:1}),className:"rounded-lg border border-slate-600 bg-slate-900/80 px-3 py-2 text-sm text-white outline-none focus:border-emerald-500/50",children:Ye.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-300",children:[e.jsx("input",{type:"checkbox",checked:ne,onChange:t=>j({includeHtml:t.target.checked}),className:"rounded border-slate-500"}),"HTML crawl"]}),e.jsxs("button",{type:"button",onClick:Ke,disabled:_,className:"flex items-center gap-2 rounded-lg bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:opacity-50",children:[_?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(Te,{className:"h-4 w-4"}),"Run audit"]})]})]}),_&&e.jsxs("div",{className:"relative mt-5 space-y-2 border-t border-slate-700/60 pt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2 text-slate-300",children:[e.jsx(B,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-emerald-400"}),e.jsx("span",{className:"truncate",children:(we=d==null?void 0:d.label)!=null?we:"Audit in progressâ¦"})]}),e.jsxs("span",{className:"shrink-0 font-bold tabular-nums text-emerald-400",children:[(ye=d==null?void 0:d.percent)!=null?ye:0,"%"]})]}),e.jsx("div",{className:"h-2.5 overflow-hidden rounded-full bg-slate-700/80",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":(ve=d==null?void 0:d.percent)!=null?ve:0,"aria-label":"SEO audit progress",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-600 via-emerald-500 to-teal-400 transition-[width] duration-500 ease-out",style:{width:`${Math.max((Se=d==null?void 0:d.percent)!=null?Se:8,8)}%`}})}),(d==null?void 0:d.url)&&e.jsx("p",{className:"truncate text-[10px] text-slate-500",title:d.url,children:d.url})]})]}),oe&&e.jsx("div",{className:"rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-800",children:oe}),V&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${V.ok?"border-emerald-200 bg-emerald-50 text-emerald-800":"border-rose-200 bg-rose-50 text-rose-800"}`,children:V.message}),e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-[0.2em] text-slate-500 sm:mb-4",children:["Audit summary",_&&e.jsx("span",{className:"ml-2 normal-case tracking-normal text-emerald-600",children:"· audit running"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4 lg:grid-cols-5",children:[{label:"Health score",value:q!=null?`${q}%`:"â",accent:"border-l-emerald-500 bg-emerald-50/40",valueClass:q!=null?xe(q):"text-slate-400"},{label:"Critical",value:te.critical,accent:"border-l-rose-500 bg-rose-50/40",valueClass:"text-rose-600"},{label:"Warnings",value:te.warning,accent:"border-l-amber-500 bg-amber-50/40",valueClass:"text-amber-600"},{label:"Info",value:te.info,accent:"border-l-indigo-500 bg-indigo-50/40",valueClass:"text-indigo-600"},{label:"Pages scanned",value:(_e=r==null?void 0:r.pages_scanned)!=null?_e:"â",accent:"border-l-slate-400 bg-slate-50/80",valueClass:"text-slate-900"}].map(({label:t,value:a,accent:n,valueClass:p})=>e.jsxs("div",{className:`min-w-0 rounded-xl border border-slate-200/80 border-l-4 bg-white p-4 shadow-sm sm:p-5 ${n}`,children:[e.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:t}),e.jsx("p",{className:`tabular-nums text-3xl font-bold ${p}`,children:a})]},t))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:et,className:"flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50",children:[e.jsx(Ee,{className:"h-4 w-4 text-slate-500"})," Submit sitemap"]}),e.jsxs("button",{type:"button",onClick:()=>{H(),F()},className:"flex items-center gap-2 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50",children:[e.jsx(Te,{className:"h-4 w-4 text-slate-500"})," Refresh"]}),(ke=f==null?void 0:f.gsc)!=null&&ke.configured?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs font-medium text-emerald-800",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"})," GSC connected"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs font-medium text-amber-800",children:[e.jsx(D,{className:"h-3.5 w-3.5"})," GSC not configured"]}),((Ae=f==null?void 0:f.indexNow)==null?void 0:Ae.configured)&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(lt,{className:"h-3.5 w-3.5 text-amber-500"})," IndexNow ready"]})]}),Y.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"h-4 w-4 text-emerald-600"}),e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Score trend"})]}),e.jsx("p",{className:"text-xs text-slate-500",children:Y.length===1?"One audit recorded â run more audits to compare over time":`Last ${Y.length} completed audits`})]}),e.jsxs("div",{className:"grid grid-cols-[2rem_1fr] gap-3",children:[e.jsxs("div",{className:"flex h-40 flex-col justify-between pb-8 text-[10px] font-medium text-slate-400",children:[e.jsx("span",{children:"100%"}),e.jsx("span",{children:"50%"}),e.jsx("span",{children:"0%"})]}),e.jsxs("div",{className:"relative h-40 border-b border-l border-slate-200 pb-8",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 border-t border-dashed border-slate-100"}),e.jsx("div",{className:"flex h-full items-end gap-1.5 sm:gap-2",children:Y.map(t=>e.jsxs("div",{className:"group flex min-w-0 flex-1 flex-col items-center justify-end h-full",title:`${t.overall_score}
1% â ${new Date(t.created_at).toLocaleString()}`,children:[e.jsxs("span",{className:"mb-1 text-[10px] font-bold tabular-nums text-slate-700 sm:text-xs",children:[t.overall_score,"%"]}),e.jsx("div",{className:`w-full min-h-[6px] rounded-t transition-all group-hover:opacity-90 ${tt(t.overall_score)}`,style:{height:`${Math.max(4,t.overall_score)}%`}}),e.jsx("span",{className:"mt-1.5 max-w-full truncate text-[9px] text-slate-500 sm:text-[10px]",children:at(t.created_at)})]},t.id))})]})]}),(r==null?void 0:r.overall_score)!=null&&e.jsxs("p",{className:"mt-3 text-xs text-slate-500",children:["Latest health score:"," ",e.jsxs("span",{className:`font-semibold ${xe(r.overall_score)}`,children:[r.overall_score,"%"]}),r.completed_at&&e.jsxs("span",{children:[" · ",new Date(r.completed_at).toLocaleString()]})]})]}),e.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-4 shadow-sm",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Severity"}),["all","critical","warning","info"].map(t=>e.jsx("button",{type:"button",onClick:()=>j({severityFilter:t,page:1}),className:`rounded-lg px-3 py-1.5 text-xs font-medium capitalize transition-colors ${c===t?"bg-emerald-600 text-white shadow-sm":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,children:t},t)),e.jsx("span",{className:"mx-2 hidden h-4 w-px bg-slate-200 sm:inline"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Status"}),["open","resolved","ignored","all"].map(t=>e.jsx("button",{type:"button",onClick:()=>j({statusFilter:t,page:1}),className:`rounded-lg px-3 py-1.5 text-xs font-medium capitalize transition-colors ${w===t?"bg-indigo-600 text-white shadow-sm":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,children:t},`status-${t}`)),e.jsxs("span",{className:"ml-auto text-xs font-medium text-slate-500",children:[T.toLocaleString()," issues"]})]})}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm",children:[e.jsx("div",{className:"space-y-3 p-3 md:hidden",children:X&&P.length===0?[...Array(5)].map((t,a)=>e.jsx("div",{className:"h-24 animate-pulse rounded-xl bg-slate-100"},a)):P.length===0?e.jsxs("div",{className:"px-4 py-12 text-center",children:[e.jsx(Oe,{className:"mx-auto mb-3 h-10 w-10 text-slate-300"}),e.jsx("p",{className:"font-semibold text-slate-800",children:"No issues found"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Run an audit to scan your site, or adjust filters above."})]}):P.map(t=>e.jsxs("article",{className:"rounded-xl border border-slate-200 bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-bold uppercase ${ae(t.severity)}`,children:[se(t.severity),t.severity]}),e.jsxs("button",{type:"button",onClick:()=>me(t),className:"inline-flex shrink-0 items-center gap-0.5 whitespace-nowrap text-xs font-semibold text-emerald-700 hover:text-emerald-600",children:["Review ",e.jsx(Re,{className:"h-3 w-3"})]})]}),e.jsx("p",{className:"mt-2 truncate font-medium text-slate-900",title:t.page_title||t.page_url,children:t.page_title||"Untitled page"}),e.jsx("a",{href:t.page_url,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-xs text-emerald-700 underline decoration-emerald-700/30 underline-offset-2 hover:text-emerald-600",title:t.page_url,onClick:a=>a.stopPropagation(),children:pe(t.page_url)}),e.jsx("p",{className:"mt-1.5 line-clamp-2 text-sm text-slate-700",title:t.message,children:t.message}),e.jsx("p",{className:"mt-1 truncate text-[10px] text-slate-400",title:t.category,children:t.category})]},t.id))}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full min-w-0 table-fixed text-left text-sm",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-[5.5rem] sm:w-[6.25rem]"}),e.jsx("col",{className:"w-[14%] sm:w-[13%] lg:w-[12%]"}),e.jsx("col",{className:"w-[26%] sm:w-[24%] lg:w-[22%]"}),e.jsx("col",{className:"w-[28%] sm:w-[26%] lg:w-[28%]"}),e.jsx("col",{className:"hidden w-[11%] sm:table-column lg:w-[10%]"}),e.jsx("col",{className:"w-[4.5rem] sm:w-[5rem]"})]}),e.jsx("thead",{className:"bg-slate-50/80",children:e.jsxs("tr",{children:[e.jsx("th",{className:E,
1children:"Severity"}),e.jsx("th",{className:E,children:"Page"}),e.jsx("th",{className:E,children:"URL"}),e.jsx("th",{className:E,children:"Issue"}),e.jsx("th",{className:`${E} hidden sm:table-cell`,children:"Category"}),e.jsx("th",{className:`${E} text-right`,children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:X&&P.length===0?[...Array(5)].map((t,a)=>e.jsx("tr",{className:"animate-pulse",children:e.jsx("td",{colSpan:6,className:"px-4 py-4",children:e.jsx("div",{className:"h-4 rounded bg-slate-100"})})},a)):P.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:6,className:"px-6 py-16 text-center",children:[e.jsx(Oe,{className:"mx-auto mb-3 h-10 w-10 text-slate-300"}),e.jsx("p",{className:"font-semibold text-slate-800",children:"No issues found"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Run an audit to scan your site, or adjust filters above."})]})}):P.map(t=>e.jsxs("tr",{className:"transition-colors hover:bg-slate-50/80",children:[e.jsx("td",{className:`${I} align-top`,children:e.jsxs("span",{className:`inline-flex max-w-full items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-bold uppercase sm:gap-1.5 sm:px-2 sm:text-[10px] ${ae(t.severity)}`,title:t.severity,children:[se(t.severity),e.jsx("span",{className:"truncate",children:t.severity})]})}),e.jsxs("td",{className:`${I} align-top`,children:[e.jsx("p",{className:"truncate font-medium text-slate-900",title:t.page_title||t.page_url,children:t.page_title||"Untitled page"}),e.jsx("p",{className:"truncate text-xs text-slate-500",title:t.page_type,children:t.page_type})]}),e.jsx("td",{className:`${I} align-top`,children:e.jsx("a",{href:t.page_url,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-xs text-emerald-700 underline decoration-emerald-700/30 underline-offset-2 hover:text-emerald-600 sm:text-sm",title:t.page_url,onClick:a=>a.stopPropagation(),children:pe(t.page_url)})}),e.jsxs("td",{className:`${I} align-top`,children:[e.jsx("p",{className:"line-clamp-2 text-slate-700 sm:truncate sm:whitespace-nowrap",title:t.message,children:t.message}),e.jsx("p",{className:"mt-0.5 truncate text-[10px] text-slate-400 sm:hidden",title:t.category,children:t.category})]}),e.jsx("td",{className:`${I} hidden align-top sm:table-cell`,children:e.jsx("p",{className:"truncate text-xs font-medium text-slate-600",title:t.category,children:t.category})}),e.jsx("td",{className:`${I} align-top text-right`,children:e.jsxs("button",{type:"button",onClick:()=>me(t),className:"inline-flex items-center gap-0.5 whitespace-nowrap text-xs font-semibold text-emerald-700 hover:text-emerald-600 sm:gap-1",children:["Review ",e.jsx(Re,{className:"h-3 w-3"})]})})]},t.id))})]})}),T>0&&e.jsx(xt,{variant:"light",currentPage:v,totalPages:J,pageSize:S,totalResults:T,onPageChange:t=>j({page:t}),onPageSizeChange:Ze,isLoading:X,pageSizeOptions:[10,25,50,100]})]}),l&&e.jsx(pt,{children:e.jsx("div",{className:"fixed inset-0 z-[200] flex justify-end bg-slate-900/40 backdrop-blur-sm",onClick:()=>A(null),role:"presentation",children:e.jsxs("div",{className:"flex h-full w-full max-w-lg flex-col overflow-y-auto border-l border-slate-200 bg-white shadow-2xl",onClick:t=>t.stopPropagation(),role:"dialog","aria-labelledby":"seo-issue-drawer-title",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-start justify-between border-b border-slate-100 bg-white px-6 py-5",children:[e.jsxs("div",{className:"min-w-0 pr-4",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-bold uppercase ${ae(l.severity)}`,children:[se(l.severity),l.severity]}),e.jsx("span",{className:`inline-flex rounded-full border px-2 py-0.5 text-[10px] font-bold uppercase ${st(l.status)}`,children:l.status})]}),e.jsx("h2",{id:"seo-issue-drawer-title",className:"text-lg font-bold text-slate-900",children:l.message}),e.jsx("p",{className:"mt-1 truncate text-xs text-slate-500",children:l.page_url})]}),e.jsx("button",{type:"button",onClick:()=>A(null),className:"rounded-lg p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700","aria-label":"Close",children:e.jsx(nt,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 space-y-5 p-6",children:[N&&e.jsx("div",{className:`rounded-lg border px-4 py-3 text-sm ${N.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-900":N.type==="warning"?"border-amber-200 bg-amber-50 text-amber-900":"border-rose-200 bg-rose-50 text-rose-900"}`,role:"status",children:N.type==="success"?e.jsxs("span",{className:"inline-flex items-start gap-2",children:[e.jsx(Ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),N.text]}):N.type==="warning"?e.jsxs("span",{className:"inline-flex items-start gap-2",children:[e.jsx(D,{className:"mt-0.5 h-4 w-4 shrink-0"}),N.text]}):e.jsxs("span",{className:"inline-flex items-start gap-2",children:[e.jsx(ze,{className:"mt-0.5 h-4 w-4 shrink-0"}),N.text]})}),M.some(t=>t.status==="applied")&&l.status==="open"&&e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:e.jsxs("span",{className:"inline-flex items-start gap-2",children:[e.jsx(D,{className:"mt-0.5 h-4 w-4 shrink-0"}),"A fix was applied, but this issue is still open because the saved content does not yet pass the SEO rule (for example, meta description under 120 characters). Use Improve with AI or edit the content, then run an audit."]})}),e.jsx("p",{className:"text-sm text-slate-600",children:l.recommendation}),!re(l.rule_id)&&e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-700",children:[e.jsx("p",{className:"font-medium text-slate-900",children:"Manual fix required"}),e.jsx("p",{className:"mt-1 text-slate-600",children:Me(l.rule_id)})]}),l.current_value&&e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-3",children:[e.jsx("p",{className:"mb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current value"}),e.jsx("p",{className:"text-sm text-slate-800",children:l.current_value}),l.rule_id.includes("description")&&e.jsxs("p",{className:"mt-1 text-xs text-slate-500",children:[l.current_value.length," characters",l.rule_id.includes("too_short")&&" · minimum 120 required",l.rule_id.includes("too_long")&&" · maximum 160 allowed"]})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4 shadow-sm",children:[e.jsx("p",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"SERP preview"}),e.jsx("p",{className:"truncate text-base text-[#1a0dab]",children:(($e=(Ce=M[0])==null?void 0:Ce.suggested_value)==null?void 0:$e.slice(0,60))||l.page_title||"Page title"}),e.jsx("p",{className:"truncate text-xs text-[#006621]",children:l.page_url}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-slate-600",children:((Fe=M[0])==null?void 0:Fe.suggested_value)||l.current_value||"Meta description previewâ¦"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>Ve(l),disabled:Z||!re(l.rule_id),title:re(l.rule_id)?void 0:Me(l.rule_id),className:"inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-500 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(it,{className:"h-4 w-4"}),Z?"Generatingâ¦":"Improve with AI"]}),e.jsxs("a",{href:l.page_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",children:[e.jsx(ot,{className:"h-4 w-4"})," View page"]}),((Pe=f==null?void 0:f.gsc)==null?void 0:Pe.configured)&&e.jsxs("button",{type:"button",onClick:()=>Xe(l.page_url),className:"inline-flex items-center gap-2 rounded-lg border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",children:[e.jsx(Ee,{className:"h-4 w-4"})," GSC inspect"]})]}),ce&&e.jsx("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-3",children:e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs text-slate-700",children:JSON.stringify(ce,null,2)})}),M.map(t=>e.jsxs("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50/50 p-4",children:[e.jsxs("p",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-emerald-800",children:[t.source==="ai"?"AI suggestion":"Rule suggestion"," â ",t.field_name]}),e.jsx("p",{className:"mb-2 text-sm font-medium text-slate-900",children:t.suggested_value}),t.rationale&&e.jsx("p",{className:"mb-3 text-xs text-slate-600",children:t.rationale}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Qe(t.id),disabled:Z||t.status==="applied",className:"inline-flex items-center gap-1.5 rounded-lg bg-emerald-600 px-3 py-1.5 text-xs font-bold text-white hover:bg-emerald-500 disabled:opacity-50",children:We===t.id?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"h-3.5 w-3.5 animate-spin"}),"Applyingâ¦"]}
1):t.status==="applied"?"Applied":"Approve & Apply"}),e.jsx("button",{type:"button",onClick:()=>u.rejectFix(t.id).then(F),className:"rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-xs font-medium text-slate-600 hover:bg-slate-50",children:"Dismiss"})]})]},t.id)),e.jsx("p",{className:"text-[10px] text-slate-400",children:"YMYL content: review AI suggestions for medical accuracy before applying."})]})]})})})]})};export{_t 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.