1import{r as i,t as a,j as e,a as A}from"./app-Bu4rFHE_.js";import{B as c}from"./button-LVwty3Ea.js";import{T as U}from"./textarea-BLBArkcX.js";import{L as W}from"./label-fZlIwUE-.js";import{C as f,a as v,b as j,c as _,d as y}from"./card-hp6ge7on.js";import{A as F,a as O,D as B}from"./alert-xfZ_aJDn.js";import{u as P}from"./use-toast-SkuMSTTa.js";import{s as C}from"./client-DPMyg0XR.js";import{T as q}from"./triangle-alert-BuaZ0LwM.js";import{S as z}from"./save-9hz6SKkD.js";import{R as H}from"./rotate-ccw-CIxADf4o.js";import{C as I}from"./copy-B_JyFHq-.js";const m=`User-agent: * 2Allow: / 3Disallow: /admin/ 4 5Sitemap: https://oleno.ai/sitemap.xml`;function se(){const[o,d]=i.useState(m),[p,x]=i.useState(null),[h,g]=i.useState(!1),[N,k]=i.useState(!0),[l,u]=i.useState([]),{toast:r}=P();i.useEffect(()=>{S()},[]);const S=async()=>{var s;try{const{data:t,error:n}=await C.from("site_settings").select("robots_txt, updated_at").eq("id","00000000-0000-0000-0000-000000000001").single();if(n)throw n;t!=null&&t.robots_txt&&(d(t.robots_txt),x(new Date(t.updated_at))),a("robots_page_view",{has_content:!!(t!=null&&t.robots_txt),content_length:((s=t==null?void 0:t.robots_txt)==null?void 0:s.length)||0})}catch(t){console.error("Error loading robots.txt:",t),r({title:"Error",description:"Failed to load robots.txt. Using default template.",variant:"destructive"})}finally{k(!1)}},b=i.useCallback(s=>{const t=[];return(s.includes(`Disallow: / 6`)||s.includes("Disallow: / "))&&(t.push({type:"blocks_all",message:"Warning: 'Disallow: /' blocks all search engine crawlers from your entire site."}),a("robots_validation_warning",{warning_type:"blocks_all"})),s.includes("/admin")||(t.push({type:"admin_not_blocked",message:"Warning: Admin area (/admin/) is not disallowed. Consider adding 'Disallow: /admin/'"}),a("robots_validation_warning",{warning_type:"admin_not_blocked"})),s.toLowerCase().includes("sitemap:")||(t.push({type:"missing_sitemap",message:"Warning: No sitemap URL specified. Consider adding 'Sitemap: https://oleno.ai/sitemap.xml'"}),a("robots_validation_warning",{warning_type:"missing_sitemap"})),["/blog","/pricing","/features"].forEach(w=>{s.includes(`Disallow: ${w}`)&&(t.push({type:"blocks_important",message:`Warning: Blocking important page: ${w}`}),a("robots_validation_warning",{warning_type:"blocks_important"}))}),t},[]),R=s=>{d(s);const t=b(s);u(t),a("robots_edit",{content_length:s.length})},D=async()=>{g(!0);try{const{error:s}=await C.from("site_settings").update({robots_txt:o}).eq("id","00000000-0000-0000-0000-000000000001");if(s)throw s;x(new Date),r({title:"Success",description:"Robots.txt saved successfully."}),a("robots_save",{content_length:o.length,has_warnings:l.length>0,warning_count:l.length})}catch(s){console.error("Error saving robots.txt:",s),r({title:"Error",description:"Failed to save robots.txt. Please try again.",variant:"destructive"})}finally{g(!1)}},E=()=>{d(m),u(b(m)),r({title:"Reset",description:"Content reset to default template."}),a("robots_reset",{})},L=()=>{const s=new Blob([o],{type:"text/plain"}),t=URL.createObjectURL(s),n=document.createElement("a");n.href=t,n.download="robots.txt",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t),r({title:"Downloaded",description:"robots.txt file downloaded successfully."}),a("robots_download",{content_length:o.length})},T=async()=>{try{await navigator.clipboard.writeText(o),r({title:"Copied",description:"Content copied to clipboard."}),a("robots_copy",{content_length:o.length})}catch{r({title:"Error",description:"Failed to copy to clipboard.",variant:"destructive"})}};return N?e.jsx("div",{className:"container mx-auto py-8 px-4 max-w-6xl",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-1/4"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2"}),e.jsx("div",{className:"h-96 bg-muted rounded"})]})}):e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"Robots.txt Editor - Oleno Admin",description:"Configure search engine crawler access and behavior",robots:"noindex, nofollow"}),e.jsxs("div",{className:"container mx-auto py-8 px-4 max-w-6xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:"Robots.txt Editor"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure search engine crawler access and behavior"}),p&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Last saved: ",p.toLocaleStr
6ing()]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs(f,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"Edit Robots.txt"}),e.jsx(_,{children:"Configure which pages search engines can crawl"})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"robots-content",children:"Content"}),e.jsx(U,{id:"robots-content",value:o,onChange:s=>R(s.target.value),className:"font-mono min-h-[400px] resize-none",placeholder:"Enter robots.txt content..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," characters"]})]}),l.length>0&&e.jsx("div",{className:"space-y-2",children:l.map((s,t)=>e.jsxs(F,{variant:"default",className:"border-yellow-500/50 bg-yellow-50 dark:bg-yellow-950/30",children:[e.jsx(q,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400"}),e.jsx(O,{className:"text-yellow-800 dark:text-yellow-200",children:s.message})]},t))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(c,{onClick:D,disabled:h,children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),h?"Saving...":"Save"]}),e.jsxs(c,{variant:"outline",onClick:E,children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Reset to Default"]}),e.jsxs(c,{variant:"outline",onClick:L,children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Download"]})]})]})]}),e.jsxs(f,{children:[e.jsxs(v,{children:[e.jsx(j,{children:"Live Preview"}),e.jsx(_,{children:"Preview of your robots.txt file"})]}),e.jsxs(y,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted p-4 rounded-lg overflow-x-auto text-sm font-mono min-h-[400px] whitespace-pre-wrap",children:o||"No content"}),e.jsx(c,{variant:"ghost",size:"sm",onClick:T,className:"absolute top-2 right-2","aria-label":"Copy to clipboard",children:e.jsx(I,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Note:"})," This file will be publicly accessible at"," ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"/robots.txt"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Changes take effect immediately after saving."})]})]})]})]})]})]})}export{se 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.