1import{k as z,l as G,u as B,a as O,al as R,am as w,an as M,ao as H,r as g,j as e,e as N,B as P,aj as S,ak as T}from"./index-RXgQj7lC.js";import{A as I}from"./AdminLayout-1zFkafbQ.js";import{u as $,F as J,a as l,b as r,d as i,c as o,e as n,t as W,o as X,k as Y,h as F,s as u,j as q}from"./form-BzZp4-QU.js";import{I as x}from"./input-RNAh9j7a.js";import{T as E}from"./textarea-Y21KNY6R.js";import{S as L,a as C,b as K,c as Q,d as h}from"./select-DKXypx6q.js";import{A as Z}from"./arrow-left-BBMybm2C.js";import{S as _}from"./save-VRYtdixW.js";import"./index-CD5vrTmE.js";import"./label-uFJxM1l_.js";import"./index-BYVR4wQV.js";import"./Combination-BLsR3Tyo.js";const ee=X({title:u().min(1,"Title is required"),path:u().min(1,"Path is required").regex(/^\//,"Path must start with a slash (e.g. /about/)"),body:u(),template:q(["institutional","gift-guide"]),status:q(["draft","published"]),sourceUrl:u(),seoTitle:u().optional(),seoDescription:u().optional(),noIndex:F().optional(),noFollow:F().optional(),socialImage:Y().optional()});function xe(){const c=z(),[,f]=G(),m=!c.id||c.id==="new",{toast:p}=B(),d=O(),{data:t,isLoading:U}=R(c.id,{query:{enabled:!m&&!!c.id,queryKey:w(c.id)}}),k=M(),D=H(),[b,y]=g.useState(!1),a=$({resolver:W(ee),defaultValues:{title:"",path:"/",body:"",template:"institutional",status:"draft",sourceUrl:"",seoTitle:"",seoDescription:""}}),v=g.useRef(null);g.useEffect(()=>{t&&v.current!==t.id&&(v.current=t.id,a.reset({title:t.title,path:t.path,body:t.body,template:t.template,status:t.status,sourceUrl:t.sourceUrl,seoTitle:t.seo?.title||"",seoDescription:t.seo?.description||"",noIndex:t.seo?.noIndex||!1,noFollow:t.seo?.noFollow||!1,socialImage:t.seo?.socialImage||void 0}))},[t,a]);const A=async s=>{y(!0);try{const j={title:s.title,path:s.path,body:s.body,template:s.template,status:s.status,sourceUrl:s.sourceUrl,seo:{...t?.seo||{},title:s.seoTitle||"",description:s.seoDescription||"",noIndex:s.noIndex,noFollow:s.noFollow,socialImage:s.socialImage}};if(m){const V=await k.mutateAsync({data:j});p({title:"Page created successfully"}),d.invalidateQueries({queryKey:S()}),d.invalidateQueries({queryKey:T()}),d.invalidateQueries({queryKey:["/api/content/public"]}),f(`/admin/pages/${V.id}`)}else await D.mutateAsync({id:c.id,data:j}),p({title:"Page updated successfully"}),d.invalidateQueries({queryKey:w(c.id)}),d.invalidateQueries({queryKey:S()}),d.invalidateQueries({queryKey:T()}),d.invalidateQueries({queryKey:["/api/content/public"]})}catch{p({title:"Failed to save page",variant:"destructive"})}finally{y(!1)}};return!m&&U?e.jsx(I,{children:e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(N,{className:"w-8 h-8 animate-spin text-muted-foreground"})})}):e.jsx(I,{children:e.jsx(J,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(A),className:"flex flex-col h-[100dvh] bg-background",children:[e.jsxs("header",{className:"flex-shrink-0 flex items-center justify-between p-4 bg-white border-b border-border shadow-sm z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>f("/admin/pages"),className:"text-muted-foreground",children:e.jsx(Z,{className:"w-5 h-5"})}),e.jsx("h1",{className:"text-xl font-bold font-serif text-foreground truncate max-w-md",children:a.watch("title")||(m?"New Page":"Untitled Page")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground hidden md:inline-block",children:a.watch("status")==="published"?"Published":"Draft"}),e.jsxs(P,{type:"submit",disabled:b,className:"bg-ink text-paper hover:bg-signal min-w-[100px]",children:[b?e.jsx(N,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(_,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8 flex flex-col lg:flex-row gap-8",children:[e.jsxs("div",{className:"flex-1 space-y-6",children:[e.jsx(l,{control:a.control,name:"title",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{className:"text-base font-semibold",children:"Title"}),e.jsx(o,{children:e.jsx(x,{placeholder:"Page title",className:"text-lg py-6",...s})}),e.jsx(n,{})]})}),e.jsx(l,{control:a.control,name:"path",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{className:"text-base font-semibold",children:"URL Path"}),e.jsx(o,{children:e.jsx(x,{placeholder:"/about/",...s})}),e.jsx(n,{})]})}),e.jsx(l,{control:a.control,name:"body",render:({field:s})=>e.jsxs(r,{className:"flex-1 flex flex-col",children:[e.jsx(i,{className:"text-base font-semibold",children:"Body (HTML)"}),e.jsx(o,{children:e.jsx(E,{placeholder:"<p>Page content here...</p>",className:"min-h-[400px] font-mono text-sm resize-y",...s})}),e.jsx(n,{})]})})]}),e.jsxs("div",{className:"w-full lg:w-80 space-y-6",children:[e.jsxs("div",{className:"bg-white p-6 rounded-lg border border-border shadow-sm space-y-6",children:[e.jsx("h3",{className:"font-semibold text-lg border-b border-border pb-2",children:"Settings"}),e.jsx(l,{control:a.control,name:"status",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{children:"Status"}),e.jsxs(L,{onValueChange:s.onChange,defaultValue:s.value,value:s.value,children:[e.jsx(o,{children:e.jsx(C,{children:e.jsx(K,{placeholder:"Select status"})})}),e.jsxs(Q,{children:[e.jsx(h,{value:"draft",children:"Draft"}),e.jsx(h,{value:"published",children:"Published"})]})]}),e.jsx(n,{})]})}),e.jsx(l,{control:a.control,name:"template",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{children:"Template"}),e.jsxs(L,{onValueChange:s.onChange,defaultValue:s.value,value:s.value,children:[e.jsx(o,{children:e.jsx(C,{children:e.jsx(K,{placeholder:"Select template"})})}),e.jsxs(Q,{children:[e.jsx(h,{value:"institutional",children:"Institutional"}),e.jsx(h,{value:"gift-guide",children:"Gift Guide"})]})]}),e.jsx(n,{})]})}),e.jsx(l,{control:a.control,name:"sourceUrl",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{children:"Original Source URL (Optional)"}),e.jsx(o,{children:e.jsx(x,{placeholder:"https://...",...s})}),e.jsx(n,{})]})})]}),e.jsxs("div",{className:"bg-white p-6 rounded-lg border border-border shadow-sm space-y-6",children:[e.jsx("h3",{className:"font-semibold text-lg border-b border-border pb-2",children:"SEO"}),e.jsx(l,{control:a.control,name:"seoTitle",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{children:"SEO Title"}),e.jsx(o,{children:e.jsx(x,{placeholder:"Title for search engines",...s})}),e.jsx(n,{})]})}),e.jsx(l,{control:a.control,name:"seoDescription",render:({field:s})=>e.jsxs(r,{children:[e.jsx(i,{children:"Meta Description"}),e.jsx(o,{children:e.jsx(E,{placeholder:"Brief description for search results",className:"h-24 resize-none",...s})}),e.jsx(n,{})]})})]})]})]})})]})})})}export{xe 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.