import{j as e}from"./radix-ui-CVZWoPyd.js";import{r as t}from"./react-vendor-BmlOtb7g.js";import{S as s}from"./SEO-BGpcOjpb.js";import{A as r}from"./AppSidebar-BQ3UxiE1.js";import a from"./NotFoundPage-BFhrCV_w.js";import{b as o}from"./react-router-DzDVDRUd.js";import"./index-BCSgDlp8.js";import"./supabase-C8kocL5G.js";import"./utils-Ceo22G_t.js";import"./use-mobile-onbIdywO.js";import"./CheckoutButton-BXcL0vXQ.js";import"./analytics-CgKQjs6u.js";import"./arrow-right-CcptuZBy.js";import"./wrench-n19foI4n.js";import"./x-DIEzjPMA.js";import"./log-out-DrMwdybL.js";import"./briefcase-Cj6O7NU7.js";import"./circle-plus-C5zM2HoU.js";import"./sparkles-D1jOictl.js";import"./trending-up-DMpQ-MB3.js";import"./building-2-xmYyS5DZ.js";import"./book-open-D7nUFbtH.js";import"./settings-BQk8nNSr.js";import"./chevron-right-D_Z5YBDv.js";import"./chevron-left-D5q9zZf8.js";import"./credit-card-CUy9-vWB.js";import"./arrow-left-C1RZbPAl.js";const i=()=>{const{slug:i}=o(),[l,n]=t.useState(null),[d,m]=t.useState(!0),[c,p]=t.useState(null);if(t.useEffect(()=>{if(!i)return;var e,t,s;e=void 0,t=null,s=function*(){try{m(!0);const e=yield fetch(`/api/blog-posts/${i}`);if(404===e.status)return n(null),void p("Post not found");if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=yield e.json();n(t.post)}catch(e){p(e instanceof Error?e.message:"Failed to load post"),console.error(`Error fetching blog post ${i}:`,e)}finally{m(!1)}},new Promise((r,a)=>{var o=e=>{try{l(s.next(e))}catch(t){a(t)}},i=e=>{try{l(s.throw(e))}catch(t){a(t)}},l=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,i);l((s=s.apply(e,t)).next())})},[i]),d)return e.jsx("p",{className:"text-center py-10",children:"Loading post..."});if(c&&!l)return e.jsx(a,{});if(!l)return e.jsx(a,{});const u="undefined"!=typeof window?`${window.location.origin}/blog/${l.slug}`:`/blog/${l.slug}`;return e.jsxs("div",{className:"flex h-screen",children:[e.jsx(s,{title:l.title,description:l.meta_description||l.summary,canonical:u,image:l.featured_image_url,publishedDate:l.publication_date,modifiedDate:l.last_modified_date,authorName:l.author,section:l.categories&&l.categories.length>0?l.categories[0]:void 0,keywords:l.keywords}),e.jsx(r,{}),e.jsx("div",{className:"flex-1 overflow-y-auto bg-white",children:e.jsx("main",{className:"container mx-auto px-4 pt-12 pb-8",children:e.jsxs("article",{className:"max-w-5xl mx-auto bg-white p-6 md:p-10 shadow-lg rounded-xl border border-slate-200/60",children:[e.jsx("h1",{className:"text-4xl sm:text-5xl font-bold tracking-tight text-slate-900 leading-tight mb-6",children:l.title}),e.jsxs("div",{className:"text-sm text-slate-500 leading-normal mb-6",children:[l.publication_date&&e.jsxs("span",{children:["Published: ",new Date(l.publication_date).toLocaleDateString()]}),l.last_modified_date&&l.publication_date&&e.jsx("span",{className:"mx-2",children:"|"}),l.last_modified_date&&e.jsxs("span",{children:["Updated: ",new Date(l.last_modified_date).toLocaleDateString()]}),l.author&&(l.publication_date||l.last_modified_date)&&e.jsx("span",{className:"mx-2",children:"|"}),l.author&&e.jsxs("span",{children:["By ",l.author]})]}),l.featured_image_url&&e.jsx("img",{src:l.featured_image_url,alt:l.title,className:"w-full h-auto max-h-96 object-cover rounded-lg shadow-lg mb-8 border border-slate-200/60"}),e.jsx("div",{className:"prose prose-lg max-w-none prose-slate",dangerouslySetInnerHTML:{__html:l.content}}),l.categories&&l.categories.length>0&&e.jsxs("div",{className:"mt-8 pt-4 border-t border-slate-200/60",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800 leading-normal mb-2",children:"Categories:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.categories.map(t=>e.jsx("span",{className:"bg-slate-100 text-slate-700 px-3 py-1 rounded-full text-sm",children:t},t))})]}),l.keywords&&l.keywords.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-200/60",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800 leading-normal mb-2",children:"Keywords:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.keywords.map(t=>e.jsx("span",{className:"bg-slate-100 text-slate-700 px-3 py-1 rounded-full text-sm",children:t},t))})]})]})})})]})};export{i as default};