1import{r as m,j as e}from"./framer-motion-Csoo3owf.js";import{s as y,x as w,B as f}from"./index-Cd7Xe2r1.js";import{C as V,b as D,c as U,d as H,a as q}from"./card-DKMVvTOB.js";import{B as k}from"./badge-C_kERCnT.js";import{P as I}from"./progress-CE_LRjnA.js";import{i as J}from"./devBypass-txw6gr2R.js";import{ae as X,ao as F,aN as Q,R as N,au as C,O as W,aM as Y,aO as Z,ap as K}from"./icons-Dl6Qu6_W.js";import{a as ee}from"./router-BrUOo1th.js";import"./radix-CfnEDMAP.js";import"./tanstack-FGaHpTQk.js";import"./supabase-D6KXu-dp.js";function te(o){var a;if(!o)return;if(typeof o=="string")return o.slice(0,300);const h=o;return((a=h.error)==null?void 0:a.message)??h.message??JSON.stringify(o).slice(0,300)}function A({index:o,label:h,info:a,description:r,action:v}){const p=a.state==="running"?e.jsx(C,{className:"w-5 h-5 animate-spin text-primary"}):a.state==="ok"?e.jsx(W,{className:"w-5 h-5 text-green-600"}):a.state==="error"?e.jsx(Y,{className:"w-5 h-5 text-destructive"}):e.jsx(Z,{className:"w-5 h-5 text-muted-foreground"}),b=a.state==="ok"?e.jsx(k,{className:"bg-green-600 hover:bg-green-600",children:"Done"}):a.state==="running"?e.jsx(k,{variant:"secondary",children:"Runningâ¦"}):a.state==="error"?e.jsx(k,{variant:"destructive",children:"Error"}):e.jsx(k,{variant:"outline",children:"Pending"}),n=a.state==="error"?"border-destructive/40 bg-destructive/5":a.state==="ok"?"border-green-500/30 bg-green-500/5":"border-border bg-card";return e.jsxs("div",{className:`flex items-start gap-3 p-4 rounded-lg border ${n}`,children:[e.jsx("div",{className:"mt-0.5",children:p}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("p",{className:"font-semibold",children:[o,". ",h]}),b]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:r}),a.detail&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono break-all",children:a.detail}),a.error&&e.jsxs("div",{className:"mt-2 p-2 rounded bg-destructive/10 border border-destructive/30 flex items-start gap-2",children:[e.jsx(K,{className:"w-4 h-4 text-destructive shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-destructive font-mono break-all",children:a.error})]}),v&&e.jsx("div",{className:"mt-3",children:v})]})]})}function fe(){const o=ee(),[h,a]=m.useState(!1),[r,v]=m.useState(null),[p,b]=m.useState(!1),[n,E]=m.useState(null),[P,G]=m.useState(null),[c,x]=m.useState({meta:{state:"pending"},verify:{state:"pending"},sitemap:{state:"pending"}});m.useEffect(()=>{(async()=>{if(J()){a(!0);return}if(sessionStorage.getItem("2fa_verified")!=="true")return o("/login");const{data:{user:i}}=await y.auth.getUser();if(!i)return o("/login");const{data:l}=await y.from("user_roles").select("role").eq("user_id",i.id).in("role",["admin","user"]).maybeSingle();if(!l)return o("/");a(!0)})()},[o]);const R=m.useCallback(s=>{s&&x(i=>{var l;return{meta:s.meta.ok?{state:"ok",detail:`Token "${(l=s.meta.found)==null?void 0:l.slice(0,16)}â¦" detected.`}:{state:"error",error:s.meta.error??(s.meta.found?`A different token is currently live: "${s.meta.found.slice(0,20)}â¦". Publish the latest version to push the new token.`:"The google-site-verification meta tag was not found on https://www.i-rent.net/. Click Publish, wait ~30 seconds, then Refresh.")},verify:s.verified?{state:"ok",detail:"https://www.i-rent.net/ is verified and listed in Search Console."}:i.verify.state==="error"?i.verify:{state:"pending"},sitemap:s.sitemapSubmitted?{state:"ok",detail:"sitemap.xml is registered with Google."}:i.sitemap.state==="error"?i.sitemap:{state:"pending"}}})},[]),d=m.useCallback(async()=>{b(!0);try{const{data:s,error:i}=await y.functions.invoke("seo-publish-status",{body:{action:"status"}});if(i)throw i;v(s??null),R(s??null),G(new Date)}catch(s){const i=s instanceof Error?s.message:"Unknown error";w({title:"Check failed",description:i,variant:"destructive"}),x(l=>({...l,meta:{state:"error",error:i}}))}finally{b(!1)}},[R]);m.useEffect(()=>{h&&d()},[h,d]);const u=async(s,i,l)=>{E(s),x(t=>({...t,[l]:{state:"running"}}));try{const{data:t,error:g}=await y.functions.invoke("seo-publish-status",{body:{action:s}});if(g)throw g;const S=!(t!=null&&t.status)||t.status>=200&&t.status<300,_=t!=null&&t.attempts&&t.attempts>1?` (succeeded after ${t.attempts} attempts, waited ${Math.round((t.waitedMs??0)/100)/10}s for backoff)`:"";if(S)return w({title:`${i} succeeded${_}`}),x($=>
1({...$,[l]:{state:"ok",detail:`Completed${_}.`}})),!0;const O=(t==null?void 0:t.status)===429,M=te(t==null?void 0:t.body)??"Unknown error from Google.",z=O?`HTTP 429 rate-limited after ${(t==null?void 0:t.attempts)??1} attempt(s) with ${Math.round(((t==null?void 0:t.waitedMs)??0)/100)/10}s of backoff. ${M}`:`HTTP ${t==null?void 0:t.status} after ${(t==null?void 0:t.attempts)??1} attempt(s): ${M}`;return x($=>({...$,[l]:{state:"error",error:z}})),w({title:`${i} failed`,description:z,variant:"destructive"}),!1}catch(t){const g=t instanceof Error?t.message:"Unknown error";return x(S=>({...S,[l]:{state:"error",error:g}})),w({title:`${i} failed`,description:g,variant:"destructive"}),!1}finally{E(null)}},B=async()=>{if(r){if(!r.meta.ok){w({title:"Publish first",description:"The META tag is not live on www.i-rent.net yet. Click Publish in the editor, then Refresh.",variant:"destructive"});return}!r.verified&&(!await u("verify","Verify ownership","verify")||!await u("add_site","Add site to Search Console","verify"))||(await u("submit_sitemap","Submit sitemap","sitemap"),await d())}},j=["meta","verify","sitemap"].filter(s=>c[s].state==="ok").length,L=Math.round(j/3*100),T=["meta","verify","sitemap"].some(s=>c[s].state==="error");return h?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container py-8 max-w-3xl",children:[e.jsxs(f,{variant:"ghost",onClick:()=>o("/admin"),className:"gap-2 mb-4",children:[e.jsx(X,{className:"w-4 h-4"})," Back to Admin"]}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(F,{className:"w-8 h-8 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold",children:"SEO Publish Status"})]}),e.jsxs("p",{className:"text-muted-foreground mb-6",children:["Verify Google Search Console setup for ",e.jsx("code",{children:"https://www.i-rent.net/"}),"."]}),e.jsxs(V,{className:"mb-6",children:[e.jsxs(D,{children:[e.jsxs(U,{className:"text-lg flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Overall progress"}),e.jsxs("span",{className:`text-base font-mono ${j===3?"text-green-600":T?"text-destructive":"text-muted-foreground"}`,children:[j," / 3"]})]}),e.jsx(H,{children:j===3?"All checks passed. Google should start crawling within hours.":T?"One or more steps need attention â see the error details below.":"Run all checks, or step through them individually."})]}),e.jsxs(q,{className:"space-y-4",children:[e.jsx(I,{value:L,className:"h-3"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(f,{onClick:B,disabled:p||!!n||!r,className:"gap-2",children:[e.jsx(Q,{className:"w-4 h-4"})," Run all"]}),e.jsxs(f,{variant:"outline",onClick:d,disabled:p||!!n,className:"gap-2",children:[e.jsx(N,{className:`w-4 h-4 ${p?"animate-spin":""}`})," Refresh status"]}),P&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Last: ",P.toLocaleTimeString()]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(A,{index:1,label:"META tag live on www.i-rent.net",info:c.meta,description:"The google-site-verification meta tag in index.html must be live on the production domain before Google can verify ownership.",action:c.meta.state==="error"&&e.jsxs(f,{size:"sm",variant:"outline",disabled:p||!!n,onClick:d,className:"gap-1",children:[e.jsx(N,{className:`w-3 h-3 ${p?"animate-spin":""}`}),"Retry check"]})}),e.jsx(A,{index:2,label:"Google Search Console verification & site added",info:c.verify,description:"Calls Google's verify endpoint, then registers https://www.i-rent.net/ as a property in Search Console.",action:c.verify.state!=="ok"&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.verify.state==="error"&&e.jsxs(f,{size:"sm",variant:"default",disabled:!!n||!(r!=null&&r.meta.ok),onClick:async()=>{await u("verify","Verify ownership","verify")&&await u("add_site","Add site","verify"),await d()},className:"gap-1",children:[e.jsx(N,{className:`w-3 h-3 ${n?"animate-spin":""}`}),"Retry step"]}),e.jsxs(f,{size:"sm",variant:"outline",disabled:!!n||!(r!=null&&r.meta.ok),onClick:async()=>{await u("verify","Verify ownership","verify"),await d()},children:[n==="verify"?e.jsx(C,{className:"w-3 h-3 animate-spin mr-1"}):null,"Verify ownership"]}),e.jsxs(f,{size:"sm",variant:"outline",disabled:!!n,onClick:async()=>{await u("add_site","Add site","verify"),await d()},children:[n==="add_site"?e.jsx(C,{className:"w-3 h-3 animate-spin mr-1"}):null,"Add to Search Console"]})]})}),e.jsx(A,{index:3,label:"Sitemap submitted",info:c.sitemap,description:"Submits https://www.i-rent.net/sitemap.xml to Google Search Console so it gets crawled regularly.",action:c.sitemap.state!=="ok"&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.sitemap.state==="error"&&e.jsxs(f,{size:"sm",variant:"default",disabled:!!n||!(r!=null&&r.verified),onClick:async()=>{await u("submit_sitemap","Submit sitemap","sitemap"),await d()},className:"gap-1",children:[e.jsx(N,{className:`w-3 h-3 ${n==="submit_sitemap"?"animate-spin":""}`}),"Retry step"]}),e.jsxs(f,{size:"sm",variant:"outline",disabled:!!n||!(r!=null&&r.verified),onClick:async()=>{await u("submit_sitemap","Submit sitemap","sitemap"),await d()},children:[n==="submit_sitemap"?e.jsx(C,{className:"w-3 h-3 animate-spin mr-1"}):null,"Submit sitemap"]})]})})]})]})}):null}export{fe as default}; 2//# sourceMappingURL=SeoPublishStatusPage-BoDA5Wwd.js.map
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.