1import{r as t,s as m,j as e,m as h,L as d,I as g,B as y,bw as r}from"./index-KSWbwNeY.js";import{A as v}from"./AdminNav-DsaLvjFx.js";import{C as j,b as N,c as w,d as S,a as b}from"./card-CwL_ed79.js";import{L as C}from"./label-ndOKmXJw.js";import{S as _}from"./user-cog-DvqSS7bY.js";import{S as L}from"./save-xjMYTeam.js";import"./index-DsYLezIw.js";import"./trash-2-CwcwS_bf.js";import"./book-open-DS7Nmuzn.js";import"./receipt-DgWJf9Ou.js";import"./chevron-down-D7IdZFzc.js";const z=()=>{const[a,i]=t.useState(1),[p,x]=t.useState(!0),[n,l]=t.useState(!1);t.useEffect(()=>{u()},[]);const u=async()=>{try{const{data:s,error:c}=await m.from("site_settings").select("value").eq("key","free_articles_per_day").single();if(c)throw c;if((s==null?void 0:s.value)!=null){const o=typeof s.value=="number"?s.value:Number(s.value);isNaN(o)||i(o)}}catch(s){console.error("Error fetching settings:",s)}finally{x(!1)}},f=async()=>{if(a<0){r({title:"Invalid value",description:"Must be 0 or greater.",variant:"destructive"});return}l(!0);try{const{error:s}=await m.from("site_settings").update({value:a,updated_at:new Date().toISOString()}).eq("key","free_articles_per_day");if(s)throw s;r({title:"Saved",description:`Free article limit set to ${a} per day.`})}catch(s){r({title:"Error",description:s.message,variant:"destructive"})}finally{l(!1)}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(v,{}),e.jsx("main",{className:"ml-52 p-6",children:e.jsxs(h.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},className:"max-w-xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(_,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-xl font-semibold text-foreground",children:"Paywall Settings"})]}),e.jsxs(j,{children:[e.jsxs(N,{children:[e.jsx(w,{className:"text-base",children:"Free Article Limit"}),e.jsx(S,{children:"How many articles can anonymous (non-logged-in) readers access per day before the paywall appears."})]}),e.jsx(b,{className:"space-y-4",children:p?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(d,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"free-articles",children:"Articles per day"}),e.jsx(g,{id:"free-articles",type:"number",min:0,max:100,value:a,onChange:s=>i(parseInt(s.target.value)||0),className:"w-32"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Set to 0 to show paywall on every article. Current: ",e.jsx("strong",{children:a})," free ",a===1?"article":"articles","/day."]})]}),e.jsxs(y,{onClick:f,disabled:n,size:"sm",children:[n?e.jsx(d,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(L,{className:"h-4 w-4 mr-2"}),"Save"]})]})})]})]})})]})};export{z 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.