@xexr/blog-platform 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import F from'next/link';import qe from'next/image';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {ChevronLeftIcon,ChevronRightIcon,MoreHorizontalIcon,ChevronsLeft,ChevronsRight,ArrowLeft,Globe,Mail,ArrowUpRight,Check,Copy,Share2}from'lucide-react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {format,formatDistanceToNow}from'date-fns';import {MDXRemote}from'next-mdx-remote-client/rsc';import {FaXTwitter,FaLinkedinIn,FaGithub}from'react-icons/fa6';import*as Ne from'react';import Ne__default from'react';import*as Ke from'@radix-ui/react-separator';import Gr from'remark-gfm';import Vr from'remark-toc';import Fr from'rehype-slug';import {Ratelimit}from'@upstash/ratelimit';import {Redis}from'@upstash/redis';import {eq,and,desc,sql}from'drizzle-orm';import {sqliteTable,integer,text,uniqueIndex}from'drizzle-orm/sqlite-core';import {NextResponse}from'next/server';function f(...e){return twMerge(clsx(e))}var Pe=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function ir({className:e,variant:t,size:r,asChild:n=false,...o}){return jsx(n?Slot:"button",{"data-slot":"button",className:f(Pe({variant:t,size:r,className:e})),...o})}function Ee({className:e,...t}){return jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:f("mx-auto flex w-full justify-center",e),...t})}function Me({className:e,...t}){return jsx("ul",{"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e),...t})}function z({...e}){return jsx("li",{"data-slot":"pagination-item",...e})}function K({className:e,isActive:t,size:r="icon",...n}){return jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:f(Pe({variant:t?"outline":"ghost",size:r}),e),...n})}function $e({className:e,...t}){return jsxs(K,{"aria-label":"Go to previous page",size:"default",className:f("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsx(ChevronLeftIcon,{}),jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function De({className:e,...t}){return jsxs(K,{"aria-label":"Go to next page",size:"default",className:f("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsx("span",{className:"hidden sm:block",children:"Next"}),jsx(ChevronRightIcon,{})]})}function Ae({className:e,...t}){return jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:f("flex size-9 items-center justify-center",e),...t,children:[jsx(MoreHorizontalIcon,{className:"size-4"}),jsx("span",{className:"sr-only",children:"More pages"})]})}function ee({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:o=5,showPrevNext:i=true,showFirstLast:a=true}){if(t<=1)return null;let s=()=>{let p=Math.floor(o/2),g=Math.max(1,e-p),A=Math.min(t,g+o-1);return A-g+1<o&&(g=Math.max(1,A-o+1)),{start:g,end:A}},{start:l,end:c}=s(),d=Array.from({length:c-l+1},(p,g)=>l+g),m=p=>p===1?r:`${r}?page=${p}`,y=e>1,h=e<t;return jsxs(Ee,{className:n,children:[jsxs(Me,{children:[a&&e>2&&jsxs(Fragment,{children:[jsx(z,{children:jsx(K,{href:m(1),"aria-label":"Go to first page",children:jsx(ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsx(z,{children:jsx(Ae,{})})]}),i&&jsx(z,{children:y?jsx($e,{href:m(e-1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsx("span",{className:"hidden sm:block",children:"Previous"})})}),d.map(p=>jsx(z,{children:jsx(K,{href:m(p),isActive:p===e,children:p})},p)),i&&jsx(z,{children:h?jsx(De,{href:m(e+1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsx("span",{className:"hidden sm:block",children:"Next"})})}),a&&e<t-1&&jsxs(Fragment,{children:[c<t-1&&jsx(z,{children:jsx(Ae,{})}),jsx(z,{children:jsx(K,{href:m(t),"aria-label":"Go to last page",children:jsx(ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function dr(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,o=Math.max(1,parseInt(n??"1",10)),i=(o-1)*t;return {currentPage:o,itemsPerPage:t,offset:i,calculateTotalPages:s=>Math.ceil(s/t)}}function mr(e,t,r,n){let o=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,i=e>1&&n?`${n}${e===2?r:`${r}?page=${e-1}`}`:void 0,a=e<t&&n?`${n}${r}?page=${e+1}`:void 0;return {alternates:{...o&&{canonical:o}},other:{...i&&{prev:i},...a&&{next:a}}}}function C(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function I(e,t){let r=C(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function R(e,t){return I(e,`authors/${t}`)}function pr(e){let t=new URL(e);return C(t.pathname)}function we(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,isAccessibleForFree:i=true,includeOptionalProperties:a=true}=t,s=r??e.site.domain,l=r?`https://${s}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${s}${n}/${e.slug}`,c=e.author?Se(e.author,{customDomain:r,pathPrefix:n}):void 0,d=He(e.site,{customDomain:r,pathPrefix:n}),y=`PT${Math.max(1,Math.ceil(e.readingSeconds/60))}M`,h={"@context":"https://schema.org","@type":"BlogPosting","@id":`${l}#article`,headline:e.title,description:e.excerpt,datePublished:e.publishedAt,dateModified:e.updatedAt,author:c,publisher:d,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:y,isAccessibleForFree:i};return a&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(o??e.site.locale)&&(h.inLanguage=o??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(p=>({"@type":"Thing",name:p}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function Se(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(o.description=e.bio),e.avatarUrl&&(o.image=e.avatarUrl);let i=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(a=>!!a);if(i.length>0&&(o.sameAs=i),e.slug?.trim()){let a=r?`https://${r}${R(n,e.slug)}`:R(n,e.slug);o.url=a;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(o.knowsAbout=[...e.toneAdjectives]),o}function He(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i=`https://${r??e.domain}${n}`,a={"@context":"https://schema.org","@type":"Organization","@id":`${i}#organization`,name:e.name,url:i};return e.description?.trim()&&(a.description=e.description),e.tagline?.trim()&&(a.description=a.description?`${a.description}. ${e.tagline}`:e.tagline),a}function je(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,includeSearchAction:i=true}=t,s=`https://${r??e.domain}${n}`,l=He(e,t),c={"@context":"https://schema.org","@type":"WebSite","@id":`${s}#website`,name:e.name,url:s,publisher:l};return e.description?.trim()&&(c.description=e.description),(o??e.locale)&&(c.inLanguage=o??e.locale),i&&(c.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${s}?search={search_term_string}`},"query-input":"required name=search_term_string"}),c}function dt(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,o)=>({"@type":"ListItem",position:o+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function ze(e,t={}){let r=[];r.push(we(e,t)),r.push(je(e.site,t));let n=t.pathPrefix??"/blog",o=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(dt(o,t)),r}function Ge(e,t=[],r={}){let n=[];if(n.push(je(e,r)),t.length>0){let o=t.slice(0,5).map(i=>we(i,r));n.push(...o);}return n}function mt(e){let t=[];if(e["@context"]?e["@context"]!=="https://schema.org"&&t.push("@context must be 'https://schema.org'"):t.push("Missing required @context property"),e["@type"]||t.push("Missing required @type property"),e["@type"]==="BlogPosting"){let r=e;r.headline||t.push("BlogPosting: Missing required headline"),r.datePublished||t.push("BlogPosting: Missing required datePublished"),r.author||t.push("BlogPosting: Missing required author"),r.publisher||t.push("BlogPosting: Missing required publisher");}return e["@type"]==="Person"&&(e.name||t.push("Person: Missing required name")),e["@type"]==="Organization"&&(e.name||t.push("Organization: Missing required name")),{isValid:t.length===0,errors:t}}function pt(e){return JSON.stringify(e,null,0)}function J(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:pt(e)}}}function gr(e){let t=new Set;return e.meta.keywords.forEach(r=>t.add(r)),e.site.toneAdjectives.forEach(r=>t.add(r)),e.author&&e.author.toneAdjectives.forEach(r=>t.add(r)),Array.from(t)}var ce=class extends Error{constructor(r,n,o){super(r);this.code=n;this.details=o;this.name="StructuredDataError";}code;details};function fr(e,t={}){try{let r=we(e,t),n=mt(r);return n.isValid?{schema:r}:{error:new ce("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new ce("Failed to generate structured data","GENERATION_FAILED",r)}}}var te={accentColor:"hsl(var(--primary))",accentHoverColor:"hsl(var(--primary))",textAccentColor:"hsl(var(--primary))",textAccentHoverColor:"hsl(var(--primary))",accentBackgroundColor:"hsl(var(--primary) / 0.08)",accentBorderColor:"hsl(var(--primary) / 0.25)"};function O(e={}){return {"--blog-accent":e.accentColor??te.accentColor,"--blog-accent-hover":e.accentHoverColor??te.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??te.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??te.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??te.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??te.accentBorderColor}}function Ve(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:format(r,"d MMMM yyyy"),publishedRelativeLabel:formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function Fe(e){let t=[],r=false;for(let n of e.split(`
2
- `)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let o=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!o?.[1]||!o[2])continue;let i=br(o[2]);i&&t.push({id:xr(i),text:i,level:o[1].length});}return t}function ft(e){return `${e} ${e===1?"section":"sections"}`}function ht(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function br(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function xr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}function yt({articles:e,siteName:t,siteTagline:r,className:n,site:o,includeStructuredData:i=false,basePath:a="/blog",pagination:s,theme:l}){let c=C(a)||"/";return jsxs("div",{style:O(l),className:f("blog-home-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[t&&jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsx("h1",{className:"blog-title mb-2 bg-linear-to-r from-[var(--blog-accent-hover)] to-[var(--blog-accent)] bg-clip-text text-3xl font-semibold tracking-tight text-balance text-transparent sm:text-4xl lg:text-5xl",children:t}),r&&jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r})]}),jsxs("main",{className:"articles-list",children:[e.length===0?jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsx("p",{className:"text-muted-foreground/70 mx-auto max-w-md text-base sm:text-lg",children:"This blog doesn't have any published articles yet."})]}):jsx("div",{className:"space-y-0",children:e.map(d=>jsx(Pr,{article:d,basePath:c},d.id))}),s&&s.totalPages>1&&jsx("div",{className:"pagination-wrapper mt-12",children:jsx(ee,{currentPage:s.currentPage,totalPages:s.totalPages,baseUrl:s.baseUrl??c,className:"justify-center"})})]}),i&&o&&(()=>{let d=J(Ge(o,e.slice(0,5),{pathPrefix:c}));return jsx("script",{type:d.type,dangerouslySetInnerHTML:d.dangerouslySetInnerHTML})})()]})}function vr(e){return `${Math.ceil(e/60)} min read`}function Pr({article:e,basePath:t}){let r=I(t,e.slug),n=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=vr(e.readingSeconds),i=e.featuredImage;return jsxs("article",{className:"group border-border mb-6 block border-b pb-6 last:mb-0 last:border-b-0 last:pb-0 sm:mb-8 sm:pb-8",children:[jsxs("div",{className:"space-y-4 lg:hidden",children:[i&&jsx(F,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-full overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:jsx(qe,{src:i,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:400,height:250,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"space-y-3",children:[jsx(F,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsx("h2",{className:"text-lg leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] sm:text-xl md:text-2xl",children:e.title})}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(bt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:a.name},a.id))})]})]}),jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[i&&jsx(F,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none xl:w-72","aria-label":`Read article: ${e.title}`,children:jsx(qe,{src:i,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:288,height:180,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxs("div",{className:"space-y-4",children:[jsx(F,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsx("h2",{className:"text-2xl leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] xl:text-3xl",children:e.title})}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:a.name},a.id))})]}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(bt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]})]})]})]})}function bt({author:e,basePath:t}){return jsxs(F,{href:R(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(Ar,{author:e,size:"sm"}),e.name]})}function Ar({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=wr(e.name);return e.avatarUrl?jsx(qe,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:f("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function wr(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Sr(e,t,r,n,o="/blog"){let i=e?`${e} - Blog`:"Blog",a=n&&n.currentPage>1?`${i} - Page ${n.currentPage}`:i,s=t??"Read our latest articles and insights.",l=C(o)||"/",c=r?`${r}${n&&n.currentPage>1?`${l}?page=${n.currentPage}`:l}`:void 0,d=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?l:`${l}?page=${n.currentPage-1}`}`:void 0,m=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:a,description:s,openGraph:{title:a,description:s,type:"website",...r&&{url:c}},twitter:{card:"summary_large_image",title:a,description:s},alternates:{...c&&{canonical:c}},other:{...d&&{prev:d},...m&&{next:m}}}}var Rr=cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function de({className:e,variant:t,...r}){return jsx("div",{className:f(Rr({variant:t}),e),...r})}function me({className:e,...t}){return jsx("div",{"data-slot":"card",className:f("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function Cr({className:e,...t}){return jsx("div",{"data-slot":"card-header",className:f("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Ir({className:e,...t}){return jsx("div",{"data-slot":"card-title",className:f("leading-none font-semibold",e),...t})}function Lr({className:e,...t}){return jsx("div",{"data-slot":"card-description",className:f("text-muted-foreground text-sm",e),...t})}function pe({className:e,...t}){return jsx("div",{"data-slot":"card-content",className:f("px-6",e),...t})}function kr({className:e,...t}){return jsx("div",{"data-slot":"card-footer",className:f("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Er(e,t){try{return new URL(e).href}catch{if(!t)return e}try{return new URL(e,t).href}catch{return e}}async function vt(e,t=globalThis.navigator?.clipboard,r=typeof document>"u"?void 0:document){if(t)try{await t.writeText(e);return}catch{}if(!r)throw new Error("Clipboard API is unavailable");let n=r.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.left="-9999px",r.body.appendChild(n),n.select();try{if(!r.execCommand("copy"))throw new Error("Copy command failed")}finally{n.remove();}}async function Mr(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await vt(e.url,t?.clipboard),"copied")}function Re({title:e,url:t,className:r,size:n="md"}){let[o,i]=Ne__default.useState(false),[a,s]=Ne__default.useState(false),l=Ne__default.useMemo(()=>Er(t,typeof window>"u"?void 0:window.location.href),[t]);Ne__default.useEffect(()=>{if(!o)return;let h=window.setTimeout(()=>i(false),2e3);return ()=>window.clearTimeout(h)},[o]);async function c(){await vt(l),i(true);}async function d(){s(true);try{await Mr({title:e,url:l})==="copied"&&i(!0);}finally{s(false);}}let m=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",y=n==="sm"?"size-3.5":"size-4";return jsxs("div",{className:f("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxs("button",{type:"button","aria-label":"Copy article link",onClick:c,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",m),children:[o?jsx(Check,{className:y,"aria-hidden":"true"}):jsx(Copy,{className:y,"aria-hidden":"true"}),jsx("span",{children:o?"Copied":"Copy link"})]}),jsxs("button",{type:"button","aria-label":"Share article",onClick:d,disabled:a,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] disabled:cursor-wait disabled:opacity-60",m),children:[jsx(Share2,{className:y,"aria-hidden":"true"}),jsx("span",{children:"Share"})]})]})}function At({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsx("img",{alt:e,className:t,...n});let o=`blog-image-preview-${$r(r)}`;return jsxs(Fragment,{children:[jsx("a",{href:`#${o}`,className:"group mx-auto block cursor-zoom-in rounded-2xl focus-visible:ring-2 focus-visible:ring-[var(--blog-text-accent)] focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":e?`Expand image: ${e}`:"Expand article image",children:jsx("img",{src:r,alt:e,className:f("mx-auto rounded-2xl border border-[var(--blog-accent-border)] shadow-[0_18px_60px_rgb(168_85_247_/_0.12)] transition-opacity group-hover:opacity-95",t),...n})}),jsxs("div",{id:o,className:"invisible fixed inset-0 z-50 flex opacity-0 transition-opacity target:visible target:opacity-100",role:"dialog","aria-modal":"true","aria-label":e?`Image preview: ${e}`:"Image preview",children:[jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsx("div",{className:"pointer-events-none relative z-10 flex min-h-screen w-full items-center justify-center p-4 sm:p-6",children:jsx("img",{src:r,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsx("a",{href:"#article-content",className:"absolute top-4 right-4 z-20 inline-flex size-10 items-center justify-center rounded-full border border-white/20 bg-black/50 text-xl leading-none text-white no-underline transition-colors hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white focus-visible:outline-none","aria-label":"Close image preview",children:"\xD7"})]})]})}function $r(e){let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t).toString(36)}function We({items:e,contentId:t,variant:r,showProgress:n=true}){let o=e[0]?.id??null;return jsxs(Fragment,{children:[n&&jsx("div",{"data-blog-reading-progress":t,className:"fixed inset-x-0 top-0 z-50 h-1 origin-left bg-[var(--blog-accent)] motion-safe:transition-transform",style:{transform:"scaleX(0)"},role:"progressbar","aria-label":"Reading progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0,suppressHydrationWarning:true}),jsx(Ur,{items:e,activeItemId:o,variant:r}),n&&jsx("script",{dangerouslySetInnerHTML:{__html:Hr(t,e)}})]})}function Ur({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let i=ht(o.id,t);return jsx("li",{className:o.level===3?"pl-4":void 0,children:jsx("a",{href:`#${o.id}`,"aria-current":i.ariaCurrent,"data-blog-toc-link":o.id,"data-active":i.isActive?"true":"false",suppressHydrationWarning:true,className:"text-muted-foreground hover:text-[var(--blog-text-accent)] data-[active=true]:border-[var(--blog-accent)] data-[active=true]:text-[var(--blog-text-accent)] block border-l-2 border-transparent pl-3 leading-snug transition-colors",children:o.text})},o.id)})});return r==="mobile"?jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxs("summary",{className:"text-foreground flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold [&::-webkit-details-marker]:hidden",children:[jsx("span",{children:"On this page"}),jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[ft(e.length),jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsx("aside",{className:"hidden lg:block",children:jsxs("nav",{"aria-label":"Table of contents",className:"sticky top-24 max-h-[calc(100vh-8rem)] overflow-y-auto border-l border-border pl-5",children:[jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}function Hr(e,t){return `
1
+ import X from'next/link';import nt from'next/image';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {ChevronLeftIcon,ChevronRightIcon,MoreHorizontalIcon,ChevronsLeft,ChevronsRight,Check,ArrowUpRight,ArrowLeft,Globe,Mail,Copy,Share2}from'lucide-react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {format,formatDistanceToNow}from'date-fns';import*as Ee from'react';import Ee__default,{useState,useSyncExternalStore}from'react';import {MDXRemote}from'next-mdx-remote-client/rsc';import {FaXTwitter,FaLinkedinIn,FaGithub}from'react-icons/fa6';import*as at from'@radix-ui/react-separator';import pn from'remark-gfm';import gn from'remark-toc';import fn from'rehype-slug';import {createHash}from'crypto';import {Ratelimit}from'@upstash/ratelimit';import {Redis}from'@upstash/redis';import {eq,and,desc,sql}from'drizzle-orm';import {sqliteTable,integer,text,uniqueIndex}from'drizzle-orm/sqlite-core';import {NextResponse}from'next/server';function f(...e){return twMerge(clsx(e))}var Le=cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function br({className:e,variant:t,size:r,asChild:n=false,...o}){return jsx(n?Slot:"button",{"data-slot":"button",className:f(Le({variant:t,size:r,className:e})),...o})}function Ve({className:e,...t}){return jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:f("mx-auto flex w-full justify-center",e),...t})}function qe({className:e,...t}){return jsx("ul",{"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e),...t})}function q({...e}){return jsx("li",{"data-slot":"pagination-item",...e})}function ee({className:e,isActive:t,size:r="icon",...n}){return jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:f(Le({variant:t?"outline":"ghost",size:r}),e),...n})}function Xe({className:e,...t}){return jsxs(ee,{"aria-label":"Go to previous page",size:"default",className:f("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsx(ChevronLeftIcon,{}),jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function We({className:e,...t}){return jsxs(ee,{"aria-label":"Go to next page",size:"default",className:f("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsx("span",{className:"hidden sm:block",children:"Next"}),jsx(ChevronRightIcon,{})]})}function Ie({className:e,...t}){return jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:f("flex size-9 items-center justify-center",e),...t,children:[jsx(MoreHorizontalIcon,{className:"size-4"}),jsx("span",{className:"sr-only",children:"More pages"})]})}function ae({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:o=5,showPrevNext:i=true,showFirstLast:a=true}){if(t<=1)return null;let s=()=>{let p=Math.floor(o/2),g=Math.max(1,e-p),v=Math.min(t,g+o-1);return v-g+1<o&&(g=Math.max(1,v-o+1)),{start:g,end:v}},{start:l,end:c}=s(),m=Array.from({length:c-l+1},(p,g)=>l+g),d=p=>p===1?r:`${r}?page=${p}`,x=e>1,h=e<t;return jsxs(Ve,{className:n,children:[jsxs(qe,{children:[a&&e>2&&jsxs(Fragment,{children:[jsx(q,{children:jsx(ee,{href:d(1),"aria-label":"Go to first page",children:jsx(ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsx(q,{children:jsx(Ie,{})})]}),i&&jsx(q,{children:x?jsx(Xe,{href:d(e-1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsx("span",{className:"hidden sm:block",children:"Previous"})})}),m.map(p=>jsx(q,{children:jsx(ee,{href:d(p),isActive:p===e,children:p})},p)),i&&jsx(q,{children:h?jsx(We,{href:d(e+1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsx("span",{className:"hidden sm:block",children:"Next"})})}),a&&e<t-1&&jsxs(Fragment,{children:[c<t-1&&jsx(q,{children:jsx(Ie,{})}),jsx(q,{children:jsx(ee,{href:d(t),"aria-label":"Go to last page",children:jsx(ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function Sr(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,o=Math.max(1,parseInt(n??"1",10)),i=(o-1)*t;return {currentPage:o,itemsPerPage:t,offset:i,calculateTotalPages:s=>Math.ceil(s/t)}}function Nr(e,t,r,n){let o=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,i=e>1&&n?`${n}${e===2?r:`${r}?page=${e-1}`}`:void 0,a=e<t&&n?`${n}${r}?page=${e+1}`:void 0;return {alternates:{...o&&{canonical:o}},other:{...i&&{prev:i},...a&&{next:a}}}}function k(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function T(e,t){let r=k(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function R(e,t){return T(e,`authors/${t}`)}function Tr(e){let t=new URL(e);return k(t.pathname)}function ke(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,isAccessibleForFree:i=true,includeOptionalProperties:a=true}=t,s=r??e.site.domain,l=r?`https://${s}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${s}${n}/${e.slug}`,c=e.author?_e(e.author,{customDomain:r,pathPrefix:n}):void 0,m=Je(e.site,{customDomain:r,pathPrefix:n}),x=`PT${Math.max(1,Math.ceil(e.readingSeconds/60))}M`,h={"@context":"https://schema.org","@type":"BlogPosting","@id":`${l}#article`,headline:e.title,description:e.excerpt,datePublished:e.publishedAt,dateModified:e.updatedAt,author:c,publisher:m,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:x,isAccessibleForFree:i};return a&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(o??e.site.locale)&&(h.inLanguage=o??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(p=>({"@type":"Thing",name:p}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function _e(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(o.description=e.bio),e.avatarUrl&&(o.image=e.avatarUrl);let i=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(a=>!!a);if(i.length>0&&(o.sameAs=i),e.slug?.trim()){let a=r?`https://${r}${R(n,e.slug)}`:R(n,e.slug);o.url=a;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(o.knowsAbout=[...e.toneAdjectives]),o}function Je(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i=`https://${r??e.domain}${n}`,a={"@context":"https://schema.org","@type":"Organization","@id":`${i}#organization`,name:e.name,url:i};return e.description?.trim()&&(a.description=e.description),e.tagline?.trim()&&(a.description=a.description?`${a.description}. ${e.tagline}`:e.tagline),a}function Ye(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,includeSearchAction:i=true}=t,s=`https://${r??e.domain}${n}`,l=Je(e,t),c={"@context":"https://schema.org","@type":"WebSite","@id":`${s}#website`,name:e.name,url:s,publisher:l};return e.description?.trim()&&(c.description=e.description),(o??e.locale)&&(c.inLanguage=o??e.locale),i&&(c.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${s}?search={search_term_string}`},"query-input":"required name=search_term_string"}),c}function wt(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,o)=>({"@type":"ListItem",position:o+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function Qe(e,t={}){let r=[];r.push(ke(e,t)),r.push(Ye(e.site,t));let n=t.pathPrefix??"/blog",o=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(wt(o,t)),r}function Ze(e,t=[],r={}){let n=[];if(n.push(Ye(e,r)),t.length>0){let o=t.slice(0,5).map(i=>ke(i,r));n.push(...o);}return n}function St(e){let t=[];if(e["@context"]?e["@context"]!=="https://schema.org"&&t.push("@context must be 'https://schema.org'"):t.push("Missing required @context property"),e["@type"]||t.push("Missing required @type property"),e["@type"]==="BlogPosting"){let r=e;r.headline||t.push("BlogPosting: Missing required headline"),r.datePublished||t.push("BlogPosting: Missing required datePublished"),r.author||t.push("BlogPosting: Missing required author"),r.publisher||t.push("BlogPosting: Missing required publisher");}return e["@type"]==="Person"&&(e.name||t.push("Person: Missing required name")),e["@type"]==="Organization"&&(e.name||t.push("Organization: Missing required name")),{isValid:t.length===0,errors:t}}function Nt(e){return JSON.stringify(e,null,0)}function te(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:Nt(e)}}}function Rr(e){let t=new Set;return e.meta.keywords.forEach(r=>t.add(r)),e.site.toneAdjectives.forEach(r=>t.add(r)),e.author&&e.author.toneAdjectives.forEach(r=>t.add(r)),Array.from(t)}var be=class extends Error{constructor(r,n,o){super(r);this.code=n;this.details=o;this.name="StructuredDataError";}code;details};function Cr(e,t={}){try{let r=ke(e,t),n=St(r);return n.isValid?{schema:r}:{error:new be("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new be("Failed to generate structured data","GENERATION_FAILED",r)}}}var $="bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text text-transparent",se={accentColor:"hsl(var(--primary))",accentHoverColor:"hsl(var(--primary))",textAccentColor:"hsl(var(--primary))",textAccentHoverColor:"hsl(var(--primary))",accentBackgroundColor:"hsl(var(--primary) / 0.08)",accentBorderColor:"hsl(var(--primary) / 0.25)"};function M(e={}){return {"--blog-accent":e.accentColor??se.accentColor,"--blog-accent-hover":e.accentHoverColor??se.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??se.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??se.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??se.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??se.accentBorderColor}}function et(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:format(r,"d MMMM yyyy"),publishedRelativeLabel:formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function tt(e){let t=[],r=false;for(let n of e.split(`
2
+ `)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let o=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!o?.[1]||!o[2])continue;let i=Ir(o[2]);i&&t.push({id:kr(i),text:i,level:o[1].length});}return t}function Rt(e){return `${e} ${e===1?"section":"sections"}`}function Ct(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function Ir(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function kr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}var Oe="Thanks, you're on the list. We'll confirm before sending updates.";function xe({siteId:e,settings:t,sourceSurface:r,sourceArticleSlug:n,sourceUrl:o,previewMode:i=false,className:a}){let[s,l]=useState(null),[c,m]=useState(null),[d,x]=useState(false),[h,p]=useState(false),g=$r(e),v=useSyncExternalStore(Hr,()=>Dr(g),()=>false),I=d||!i&&v;async function G(oe){oe.preventDefault(),m(null),l(null);let fe=new FormData(oe.currentTarget),ur=rt(fe,"company");if(i){l(Oe),x(true),oe.currentTarget.reset();return}p(true);try{let Pt=await fetch(`${t.captureBaseUrl.replace(/\/$/,"")}/api/newsletter/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteId:Number(e),publicSubscribeToken:t.publicSubscribeToken,email:rt(fe,"email"),name:Mr(fe,"name"),sourceSurface:r,sourceUrl:Er(o),sourceArticleSlug:n??null,honeypot:ur})});if(!Pt.ok)throw new Error("Newsletter signup failed.");let dr=await Pt.json().catch(()=>null),mr=Gr(dr)??Oe;Ur(g),l(mr),x(!0),oe.currentTarget.reset();}catch{l(null),m("Newsletter signup failed. Please try again.");}finally{p(false);}}return jsx("section",{className:f("border-y border-[var(--blog-accent-border)] py-5 sm:py-6",a),"aria-labelledby":`newsletter-${r}-title`,children:jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.4fr)] lg:items-end",children:[jsxs("div",{className:"max-w-xl space-y-1",children:[jsx("h2",{id:`newsletter-${r}-title`,className:"text-base leading-6 font-semibold",children:t.title}),jsx("p",{className:"text-muted-foreground text-sm leading-6",children:t.description})]}),I?jsxs("div",{className:"flex items-start gap-3 text-sm leading-6 text-emerald-500",role:"status","aria-live":"polite",children:[jsx("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15",children:jsx(Check,{className:"size-3.5","aria-hidden":"true"})}),jsx("p",{children:s??Oe})]}):jsxs("form",{onSubmit:G,className:"space-y-3",children:[jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,0.8fr)_minmax(0,1fr)_auto]",children:[jsx("label",{className:"sr-only",htmlFor:`newsletter-name-${r}`,children:"Name"}),jsx("input",{id:`newsletter-name-${r}`,name:"name",type:"text",autoComplete:"name",placeholder:"Name",className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("label",{className:"sr-only",htmlFor:`newsletter-email-${r}`,children:"Email"}),jsx("input",{id:`newsletter-email-${r}`,name:"email",type:"email",autoComplete:"email",placeholder:"Email address",required:true,className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"hidden"}),jsxs("button",{type:"submit",disabled:h,className:"inline-flex min-h-10 w-full shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-5 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",children:[h?"Submitting...":t.buttonLabel,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]}),c&&jsx("p",{className:"text-sm text-red-600",children:c})]})]})})}function Er(e){return e?.startsWith("http://")||e?.startsWith("https://")?e:typeof window<"u"?window.location.href:null}function rt(e,t){let r=e.get(t);return typeof r=="string"?r:""}function Mr(e,t){let r=rt(e,t).trim();return r.length===0?null:r}function $r(e){return `bloggy_newsletter_subscribed_${e}`}function Dr(e){if(typeof window>"u")return false;try{if(window.localStorage.getItem(e)==="true")return !0}catch{}return typeof document>"u"?false:document.cookie.split(";").some(t=>t.trim().startsWith(`${e}=true`))}function Ur(e){if(typeof window<"u")try{window.localStorage.setItem(e,"true");}catch{}typeof document<"u"&&(document.cookie=`${e}=true; Max-Age=31536000; Path=/; SameSite=Lax`);}function Hr(e){return typeof window>"u"?()=>{}:(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e))}function Gr(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:null}function _t({articles:e,siteName:t,siteTagline:r,className:n,site:o,includeStructuredData:i=false,basePath:a="/blog",pagination:s,theme:l,newsletter:c,newsletterPreviewMode:m=false}){let d=k(a)||"/",x=c??o?.newsletter,h=o?.id??e[0]?.site.id;return jsxs("div",{style:M(l),className:f("blog-home-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[t&&jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsx("h1",{className:f("blog-title mb-2 text-3xl font-light tracking-tight text-balance sm:text-4xl lg:text-5xl",$),children:t}),r&&jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r}),jsxs("nav",{"aria-label":"Browse blog",className:"mt-5 flex flex-wrap items-center justify-center gap-2 text-sm",children:[jsx(X,{href:d,"aria-current":"page",className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1.5 font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)] hover:no-underline",children:"All articles"}),jsx(X,{href:T(d,"topics"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Topics"}),jsx(X,{href:T(d,"authors"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Authors"})]})]}),jsxs("main",{className:"articles-list",children:[e.length===0?jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsx("p",{className:"text-muted-foreground/70 mx-auto max-w-md text-base sm:text-lg",children:"This blog doesn't have any published articles yet."})]}):jsx("div",{className:"space-y-0",children:e.map(p=>jsx(zr,{article:p,basePath:d},p.id))}),s&&s.totalPages>1&&jsx("div",{className:"pagination-wrapper mt-12",children:jsx(ae,{currentPage:s.currentPage,totalPages:s.totalPages,baseUrl:s.baseUrl??d,className:"justify-center"})})]}),x?.enabled&&h&&jsx(xe,{siteId:h,settings:x,sourceSurface:"blog_home",previewMode:m,className:"mt-10 sm:mt-12"}),i&&o&&(()=>{let p=te(Ze(o,e.slice(0,5),{pathPrefix:d}));return jsx("script",{type:p.type,dangerouslySetInnerHTML:p.dangerouslySetInnerHTML})})()]})}function Fr(e){return `${Math.ceil(e/60)} min read`}function zr({article:e,basePath:t}){let r=T(t,e.slug),n=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=Fr(e.readingSeconds),i=e.featuredImage;return jsxs("article",{className:"group border-border mb-6 block border-b pb-6 last:mb-0 last:border-b-0 last:pb-0 sm:mb-8 sm:pb-8",children:[jsxs("div",{className:"space-y-4 lg:hidden",children:[i&&jsx(X,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-full overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:jsx(nt,{src:i,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:400,height:250,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"space-y-3",children:[jsx(X,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsx("h2",{className:"text-lg leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] sm:text-xl md:text-2xl",children:e.title})}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(It,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx(Lt,{topic:a,basePath:t},a.id))})]})]}),jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[i&&jsx(X,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none xl:w-72","aria-label":`Read article: ${e.title}`,children:jsx(nt,{src:i,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:288,height:180,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxs("div",{className:"space-y-4",children:[jsx(X,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsx("h2",{className:"text-2xl leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] xl:text-3xl",children:e.title})}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx(Lt,{topic:a,basePath:t},a.id))})]}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(It,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]})]})]})]})}function Lt({topic:e,basePath:t}){let r="rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)]",n=e.slug.trim();return n?jsx(X,{href:T(t,`topics/${n}`),className:r,children:e.name}):jsx("span",{className:r,children:e.name})}function It({author:e,basePath:t}){return jsxs(X,{href:R(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(Vr,{author:e,size:"sm"}),e.name]})}function Vr({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=qr(e.name);return e.avatarUrl?jsx(nt,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:f("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function qr(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Xr(e,t,r,n,o="/blog"){let i=e?`${e} - Blog`:"Blog",a=n&&n.currentPage>1?`${i} - Page ${n.currentPage}`:i,s=t??"Read our latest articles and insights.",l=k(o)||"/",c=r?`${r}${n&&n.currentPage>1?`${l}?page=${n.currentPage}`:l}`:void 0,m=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?l:`${l}?page=${n.currentPage-1}`}`:void 0,d=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:a,description:s,openGraph:{title:a,description:s,type:"website",...r&&{url:c}},twitter:{card:"summary_large_image",title:a,description:s},alternates:{...c&&{canonical:c}},other:{...m&&{prev:m},...d&&{next:d}}}}var Kr=cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ye({className:e,variant:t,...r}){return jsx("div",{className:f(Kr({variant:t}),e),...r})}function ve({className:e,...t}){return jsx("div",{"data-slot":"card",className:f("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function Yr({className:e,...t}){return jsx("div",{"data-slot":"card-header",className:f("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Qr({className:e,...t}){return jsx("div",{"data-slot":"card-title",className:f("leading-none font-semibold",e),...t})}function Zr({className:e,...t}){return jsx("div",{"data-slot":"card-description",className:f("text-muted-foreground text-sm",e),...t})}function Pe({className:e,...t}){return jsx("div",{"data-slot":"card-content",className:f("px-6",e),...t})}function en({className:e,...t}){return jsx("div",{"data-slot":"card-footer",className:f("flex items-center px-6 [.border-t]:pt-6",e),...t})}function on(e,t){try{return new URL(e).href}catch{if(!t)return e}try{return new URL(e,t).href}catch{return e}}async function Bt(e,t=globalThis.navigator?.clipboard,r=typeof document>"u"?void 0:document){if(t)try{await t.writeText(e);return}catch{}if(!r)throw new Error("Clipboard API is unavailable");let n=r.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.left="-9999px",r.body.appendChild(n),n.select();try{if(!r.execCommand("copy"))throw new Error("Copy command failed")}finally{n.remove();}}async function an(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await Bt(e.url,t?.clipboard),"copied")}function Me({title:e,url:t,className:r,size:n="md"}){let[o,i]=Ee__default.useState(false),[a,s]=Ee__default.useState(false),l=Ee__default.useMemo(()=>on(t,typeof window>"u"?void 0:window.location.href),[t]);Ee__default.useEffect(()=>{if(!o)return;let h=window.setTimeout(()=>i(false),2e3);return ()=>window.clearTimeout(h)},[o]);async function c(){await Bt(l),i(true);}async function m(){s(true);try{await an({title:e,url:l})==="copied"&&i(!0);}finally{s(false);}}let d=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",x=n==="sm"?"size-3.5":"size-4";return jsxs("div",{className:f("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxs("button",{type:"button","aria-label":"Copy article link",onClick:c,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",d),children:[o?jsx(Check,{className:x,"aria-hidden":"true"}):jsx(Copy,{className:x,"aria-hidden":"true"}),jsx("span",{children:o?"Copied":"Copy link"})]}),jsxs("button",{type:"button","aria-label":"Share article",onClick:m,disabled:a,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] disabled:cursor-wait disabled:opacity-60",d),children:[jsx(Share2,{className:x,"aria-hidden":"true"}),jsx("span",{children:"Share"})]})]})}function Et({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsx("img",{alt:e,className:t,...n});let o=`blog-image-preview-${sn(r)}`;return jsxs(Fragment,{children:[jsx("a",{href:`#${o}`,className:"group mx-auto block cursor-zoom-in rounded-2xl focus-visible:ring-2 focus-visible:ring-[var(--blog-text-accent)] focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":e?`Expand image: ${e}`:"Expand article image",children:jsx("img",{src:r,alt:e,className:f("mx-auto rounded-2xl border border-[var(--blog-accent-border)] shadow-[0_18px_60px_rgb(168_85_247_/_0.12)] transition-opacity group-hover:opacity-95",t),...n})}),jsxs("div",{id:o,className:"invisible fixed inset-0 z-50 flex opacity-0 transition-opacity target:visible target:opacity-100",role:"dialog","aria-modal":"true","aria-label":e?`Image preview: ${e}`:"Image preview",children:[jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsx("div",{className:"pointer-events-none relative z-10 flex min-h-screen w-full items-center justify-center p-4 sm:p-6",children:jsx("img",{src:r,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsx("a",{href:"#article-content",className:"absolute top-4 right-4 z-20 inline-flex size-10 items-center justify-center rounded-full border border-white/20 bg-black/50 text-xl leading-none text-white no-underline transition-colors hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white focus-visible:outline-none","aria-label":"Close image preview",children:"\xD7"})]})]})}function sn(e){let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t).toString(36)}function ot({items:e,contentId:t,variant:r,showProgress:n=true}){let o=e[0]?.id??null;return jsxs(Fragment,{children:[n&&jsx("div",{"data-blog-reading-progress":t,className:"fixed inset-x-0 top-0 z-50 h-1 origin-left bg-[var(--blog-accent)] motion-safe:transition-transform",style:{transform:"scaleX(0)"},role:"progressbar","aria-label":"Reading progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0,suppressHydrationWarning:true}),jsx(cn,{items:e,activeItemId:o,variant:r}),n&&jsx("script",{dangerouslySetInnerHTML:{__html:un(t,e)}})]})}function cn({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let i=Ct(o.id,t);return jsx("li",{className:o.level===3?"pl-4":void 0,children:jsx("a",{href:`#${o.id}`,"aria-current":i.ariaCurrent,"data-blog-toc-link":o.id,"data-active":i.isActive?"true":"false",suppressHydrationWarning:true,className:"text-muted-foreground hover:text-[var(--blog-text-accent)] data-[active=true]:border-[var(--blog-accent)] data-[active=true]:text-[var(--blog-text-accent)] block border-l-2 border-transparent pl-3 leading-snug transition-colors",children:o.text})},o.id)})});return r==="mobile"?jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxs("summary",{className:"text-foreground flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold [&::-webkit-details-marker]:hidden",children:[jsx("span",{children:"On this page"}),jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[Rt(e.length),jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsx("aside",{className:"hidden lg:block",children:jsxs("nav",{"aria-label":"Table of contents",className:"sticky top-24 max-h-[calc(100vh-8rem)] overflow-y-auto border-l border-border pl-5",children:[jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}function un(e,t){return `
3
3
  (() => {
4
4
  const contentId = ${JSON.stringify(e)};
5
5
  const itemIds = ${JSON.stringify(t.map(r=>r.id))};
@@ -74,7 +74,7 @@ import F from'next/link';import qe from'next/image';import {clsx}from'clsx';impo
74
74
  scheduleUpdate();
75
75
  });
76
76
  })();
77
- `}var Q=Ne.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},o)=>jsx(Ke.Root,{ref:o,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Q.displayName=Ke.Root.displayName;var St={mdxOptions:{remarkPlugins:[Vr,Gr],rehypePlugins:[qr,Fr]}};function qr(){return e=>{Nt(e);}}function Nt(e){e.children&&(e.children=e.children.flatMap(t=>(Nt(t),Xr(t)?t.children?.filter(Je)??[t]:[t])));}function Xr(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(Je);return t.length===1&&Wr(t[0])}function Wr(e){if(e?.type!=="element")return false;if(e.tagName==="img")return true;if(e.tagName!=="a"||!e.children)return false;let t=e.children.filter(Je);return t.length===1&&t[0]?.tagName==="img"}function Je(e){return e.type!=="text"||!!e.value?.trim()}function en(e){return `${Math.ceil(e/60)} min read`}function tn(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function rn({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??tn(t??"");return jsxs("span",{children:["Credit:"," ",t?jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 transition-colors hover:text-[var(--blog-text-accent)]",children:r}):r]})}function Lt({article:e,className:t,navigation:r,basePath:n="/blog",theme:o,postArticleCta:i,relatedArticles:a=[],showShareLinks:s=true}){let l=C(n)||"/",c=Ve(e.publishedAt,e.updatedAt),d=en(e.readingSeconds),m=Fe(e.content),y=e.meta.canonicalUrl??I(l,e.slug),h=e.featuredImage,p=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl);return jsxs("article",{style:O(o),className:f("article-page mx-auto max-w-6xl px-4 py-6 pb-12 sm:px-6 sm:py-8 sm:pb-16 lg:px-8 lg:py-12 lg:pb-24",t),children:[r?.backToHome&&jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxs(F,{href:r.backToHome.url,className:"text-muted-foreground group focus-visible:ring-ring inline-flex touch-manipulation items-center space-x-2 rounded-md px-2 py-1 transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none sm:space-x-3","aria-label":r.backToHome.label??"Return to blog",children:[jsx(ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsx("style",{children:`
77
+ `}var ne=Ee.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},o)=>jsx(at.Root,{ref:o,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));ne.displayName=at.Root.displayName;var $t={mdxOptions:{remarkPlugins:[gn,pn],rehypePlugins:[hn,fn]}};function hn(){return e=>{Dt(e);}}function Dt(e){e.children&&(e.children=e.children.flatMap(t=>(Dt(t),bn(t)?t.children?.filter(st)??[t]:[t])));}function bn(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(st);return t.length===1&&xn(t[0])}function xn(e){if(e?.type!=="element")return false;if(e.tagName==="img")return true;if(e.tagName!=="a"||!e.children)return false;let t=e.children.filter(st);return t.length===1&&t[0]?.tagName==="img"}function st(e){return e.type!=="text"||!!e.value?.trim()}function Sn(e){return `${Math.ceil(e/60)} min read`}function Nn(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Tn({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??Nn(t??"");return jsxs("span",{children:["Credit:"," ",t?jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 transition-colors hover:text-[var(--blog-text-accent)]",children:r}):r]})}function Ft({article:e,className:t,navigation:r,basePath:n="/blog",theme:o,postArticleCta:i,newsletter:a,newsletterPreviewMode:s=false,relatedArticles:l=[],showShareLinks:c=true}){let m=k(n)||"/",d=et(e.publishedAt,e.updatedAt),x=Sn(e.readingSeconds),h=tt(e.content),p=e.meta.canonicalUrl??T(m,e.slug),g=a??e.site.newsletter,v=e.featuredImage,I=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl);return jsxs("article",{style:M(o),className:f("article-page mx-auto max-w-6xl px-4 py-6 pb-12 sm:px-6 sm:py-8 sm:pb-16 lg:px-8 lg:py-12 lg:pb-24",t),children:[r?.backToHome&&jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxs(X,{href:r.backToHome.url,className:"text-muted-foreground group focus-visible:ring-ring inline-flex touch-manipulation items-center space-x-2 rounded-md px-2 py-1 transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none sm:space-x-3","aria-label":r.backToHome.label??"Return to blog",children:[jsx(ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsx("style",{children:`
78
78
  .article-content figure > p {
79
79
  margin-top: 0 !important;
80
80
  margin-bottom: 0 !important;
@@ -111,9 +111,9 @@ import F from'next/link';import qe from'next/image';import {clsx}from'clsx';impo
111
111
  text-decoration-line: underline;
112
112
  text-underline-offset: 0.18em;
113
113
  }
114
- `}),jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsx("h1",{className:"article-title bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text px-4 text-2xl leading-tight font-light tracking-tight text-balance text-transparent sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",children:e.title}),e.excerpt&&jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"sr-only",children:"Author"}),jsxs(F,{href:R(l,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(Rt,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${c.publishedDateLabel}`,children:["Published ",c.publishedDateLabel]}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:c.publishedRelativeLabel}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:d})]}),c.isUpdated&&jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",c.updatedDateLabel]}),s&&jsx(Re,{title:e.title,url:y,size:"sm"}),jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(g=>jsx(F,{href:I((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${g.slug}`),className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1 text-xs font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)]",children:g.name},g.id))}):jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),h&&jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",children:jsx(qe,{src:h,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),p&&jsxs("figcaption",{className:"text-muted-foreground mt-3 space-y-1 px-2 text-center text-sm leading-relaxed sm:px-0",children:[e.featuredImageCaption&&jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsx("p",{className:"text-xs",children:jsx(rn,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxs("div",{className:"min-w-0",children:[jsx(We,{items:m,contentId:"article-body",variant:"mobile"}),jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] [&_figure>p]:!my-0 [&_figcaption]:!mt-2 [&_figcaption]:text-center [&_figcaption]:!text-sm [&_figcaption]:!leading-snug [&_figcaption]:text-muted-foreground [&_figcaption_.blog-image-credit]:mt-1 [&_figcaption_.blog-image-credit]:block [&_figcaption_.blog-image-credit]:text-xs [&_figcaption_.blog-image-credit]:tracking-wide [&_figcaption_.blog-image-credit]:text-muted-foreground/80 [&_figcaption>span:not(.blog-image-credit)]:ml-2 [&_figcaption>span:not(.blog-image-credit)]:border-l [&_figcaption>span:not(.blog-image-credit)]:border-[var(--blog-accent-border)] [&_figcaption>span:not(.blog-image-credit)]:pl-2 [&_figcaption>span:not(.blog-image-credit)]:text-xs [&_figcaption>span:not(.blog-image-credit)]:tracking-wide [&_figcaption>span:not(.blog-image-credit)]:text-muted-foreground/80 max-w-none",children:jsx(MDXRemote,{source:e.content,options:St,components:{img:At}})})]}),jsx(We,{items:m,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsx(Q,{className:"mb-8"}),jsx(me,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxs(pe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsx("div",{className:"shrink-0",children:jsx(Rt,{author:e.author,size:"lg"})}),jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxs("div",{className:"min-w-0",children:[jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsx(F,{href:R(l,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsx(nn,{author:e.author})]}),jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((i??false)||s||a.length>0)&&jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsx(Q,{}),i&&jsx(sn,{cta:i}),s&&jsx(ln,{title:e.title,url:y}),a.length>0&&jsx(cn,{articles:a.slice(0,3),basePath:l})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsx(Q,{className:"mb-8"}),jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsx(me,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxs(F,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsx(Ye,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxs(pe,{className:"p-4",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsx(me,{className:f("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxs(F,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsx(Ye,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxs(pe,{className:"p-4 md:text-right",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let g=J(ze(e,{pathPrefix:l}));return jsx("script",{type:g.type,dangerouslySetInnerHTML:g.dangerouslySetInnerHTML})})()]})}function Rt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=an(e.name);return e.avatarUrl?jsx(qe,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:f("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function nn({author:e}){let t=on(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function on(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsx(FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function an(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function sn({cta:e}){return jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxs("div",{className:"space-y-1",children:[jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxs(F,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function ln({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsx(Re,{title:e,url:t,size:"sm"}),jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(Mail,{className:"size-4","aria-hidden":"true"})})]})}function cn({articles:e,basePath:t}){return jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxs(F,{href:I(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsx(Ye,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxs("div",{className:"p-4",children:[jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function Ye({src:e,alt:t}){return jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsx(qe,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function un(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${I(t,e.slug)}`,i=e.meta.ogImage??e.featuredImage;return {title:r,description:n,keywords:e.meta.keywords.join(", "),authors:e.author?[{name:e.author.name}]:void 0,openGraph:{title:r,description:n,type:"article",url:o,images:i?[{url:i,alt:e.featuredImageAlt??r}]:void 0,publishedTime:e.publishedAt,modifiedTime:e.updatedAt,authors:e.author?[e.author.name]:void 0,siteName:e.site.name},twitter:{card:"summary_large_image",title:r,description:n,images:i?[i]:void 0},alternates:{canonical:o}}}function Bt({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:s}){let l=C(o)||"/",c=s?.backToHome?.url??l,d=R(l,e.slug),m=a?.totalItems??t.length,y=J(Se(e,{pathPrefix:l}));return jsxs("main",{style:O(i),className:f("author-page mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxs(F,{href:c,className:"text-muted-foreground group focus-visible:ring-ring inline-flex items-center gap-2 rounded-md px-2 py-1 text-sm font-medium transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:[jsx(ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),s?.backToHome?.label??"Back to all articles"]}),jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsx(xn,{author:e}),jsxs("div",{className:"min-w-0 space-y-4",children:[jsxs("div",{className:"space-y-2",children:[jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsx("h1",{className:"text-foreground text-4xl leading-tight font-semibold text-balance sm:text-5xl",children:e.name})]}),e.bio&&jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsx(fn,{author:e})]})]})]}),jsx(Q,{className:"mb-8"}),jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxs("div",{children:[jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[m," ",m===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsx(bn,{article:h,basePath:l},h.id))}),a&&a.totalPages>1&&jsx("div",{className:"pt-4",children:jsx(ee,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??d,className:"justify-center"})})]}),jsx("script",{type:y.type,dangerouslySetInnerHTML:y.dangerouslySetInnerHTML})]})}function fn({author:e}){let t=hn(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":r.ariaLabel,className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:r.icon},r.label))})}function hn(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:null,t.x??t.twitter?{href:t.x??t.twitter??"",label:"x",ariaLabel:`${e.name} on X`,external:true,icon:jsx("span",{className:"text-sm font-semibold","aria-hidden":"true",children:"X"})}:null,t.linkedin?{href:t.linkedin,label:"linkedin",ariaLabel:`${e.name} on LinkedIn`,external:true,icon:jsx("span",{className:"text-sm font-bold","aria-hidden":"true",children:"in"})}:null,t.github?{href:t.github,label:"github",ariaLabel:`${e.name} on GitHub`,external:true,icon:jsx("span",{className:"text-xs font-bold","aria-hidden":"true",children:"GH"})}:null,t.email?{href:`mailto:${t.email}`,label:"email",ariaLabel:`Email ${e.name}`,external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function bn({article:e,basePath:t}){let r=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxs(F,{href:I(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxs("div",{className:"min-w-0 space-y-3",children:[jsx("h3",{className:"text-xl leading-tight font-semibold text-balance transition-colors group-hover:text-[var(--blog-text-accent)]",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsx("time",{dateTime:e.publishedAt,children:r}),jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsx(qe,{src:e.featuredImage,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:320,height:200,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})]})})}function xn({author:e}){return e.avatarUrl?jsx(qe,{src:e.avatarUrl,alt:e.name,width:128,height:128,className:"size-28 rounded-full border border-[var(--blog-accent-border)] object-cover sm:size-32",priority:true}):jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-28 items-center justify-center rounded-full text-3xl font-semibold sm:size-32",children:yn(e.name)})}function yn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function vn(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${R(r,e.slug)}`,o=`${e.name} - ${t.name}`,i=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:o,description:i,authors:[{name:e.name}],openGraph:{title:o,description:i,type:"profile",url:n,images:e.avatarUrl?[{url:e.avatarUrl,alt:e.name}]:void 0,siteName:t.name},twitter:{card:e.avatarUrl?"summary_large_image":"summary",title:o,description:i,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:n}}}var Te=class{articles=new Map;operations=new Map;async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(Array.from(this.articles.values()).some(a=>a.id===t.id))return n}else return n;if(this.articles.has(t.slug)){let i={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.set(t.slug,t);let o={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=Array.from(this.articles.values());return a.sort((l,c)=>{let d=new Date(l[o]).getTime(),m=new Date(c[o]).getTime();return i==="desc"?m-d:d-m}),{articles:a.slice(n,n+r),total:a.length}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!this.articles.has(t))return n}else return n;if(!this.articles.has(t)){let i={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.delete(t);let o={success:true,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}};function Pn(){let e=globalThis;if(e.__BLOG_PLATFORM_STORAGE_WARNED__)return;e.__BLOG_PLATFORM_STORAGE_WARNED__=true;let t="Blog platform: No storage provider configured. Falling back to in-memory storage (data is not persisted).";process.env.NODE_ENV==="production"?console.error(`${t} Call initBlogPlatform({ storage: /* your persistent adapter */ }) to avoid data loss.`):console.warn(t);}function An(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Pn(),e.__BLOG_PLATFORM_STORAGE__=new Te);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function H(){return An()}function Ze(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function et(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Et(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function Ot(e,t){let r=t.filter(o=>o.author?.slug===e).sort((o,i)=>new Date(i.publishedAt).getTime()-new Date(o.publishedAt).getTime()),n=r.reduce((o,i)=>i.author?Et(o,i.author):o,null);return n?{author:n,articles:r}:null}async function wn(e,t={},r=H()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return Ot(e,n)}function Et(e,t){return e?{...e,bio:e.bio??t.bio,avatarUrl:e.avatarUrl??t.avatarUrl,pronouns:e.pronouns??t.pronouns,socialLinks:e.socialLinks??t.socialLinks,toneAdjectives:e.toneAdjectives.length>0?e.toneAdjectives:t.toneAdjectives}:t}function Sn(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function tt(e){let t=new Map;for(let r of e)for(let n of r.topics??[])t.has(n.slug)||t.set(n.slug,n);return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function rt(e,t){let r=e.filter(o=>(o.topics??[]).some(i=>i.slug===t));if(r.length===0)return null;let n=r.flatMap(o=>o.topics??[]).find(o=>o.slug===t)??null;return n?{topic:n,articles:r}:null}function Tn({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=C(t)||"/",s=tt(e);return jsxs("main",{style:O(i),className:f("blog-topics-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(F,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(d=>(d.topics??[]).some(m=>m.slug===l.slug)).length;return jsxs(F,{href:I(a,`topics/${l.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[c," ",c===1?"article":"articles"]})]},l.slug)})})]})}function Cn({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=C(r)||"/",a=rt(e,t);return jsxs("main",{style:O(o),className:f("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(F,{href:I(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(s=>jsx(In,{article:s,topic:a.topic,basePath:i},s.id))}):jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function In({article:e,topic:t,basePath:r}){let n=I(r,e.slug),o=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxs(F,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsx(qe,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"space-y-3 p-5",children:[jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function kn({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=C(t)||"/",s=et(e);return jsxs("main",{style:O(i),className:f("blog-authors-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(F,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(d=>d.author?.slug===l.slug).length;return jsx(F,{href:R(a,l.slug),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:jsxs("div",{className:"flex items-start gap-4",children:[jsx(_n,{author:l}),jsxs("div",{className:"min-w-0 space-y-2",children:[jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxs("p",{className:"text-muted-foreground text-sm",children:[c," ",c===1?"article":"articles"]})]})]})},l.slug)})})]})}function _n({author:e}){let t=Bn(e.name);return e.avatarUrl?jsx(qe,{src:e.avatarUrl,alt:e.name,width:56,height:56,className:"size-14 shrink-0 rounded-full border border-[var(--blog-accent-border)] object-cover"}):jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-14 shrink-0 items-center justify-center rounded-full text-base font-semibold",children:t})}function Bn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function nt(e){let t=e.headers.get("Authorization");if(!t)return null;let n=/^Bearer\s+(.+)$/i.exec(t);if(n?.[1])return n[1];let i=/^Token\s+(.+)$/i.exec(t);return i?.[1]?i[1]:null}var Ie=class{validApiKeys;constructor(t){this.validApiKeys=new Set(t);}async validateToken(t){return t?.trim()?this.validApiKeys.has(t)?{valid:true,context:{tokenHash:this.hashToken(t)}}:{valid:false,errorCode:"invalid"}:{valid:false,errorCode:"missing"}}extractToken=t=>nt(t);hashToken(t){return t.substring(0,8)+"..."}},ne=class extends Ie{constructor(t="BLOG_PLATFORM_API_KEYS"){let r=process.env[t];!r&&t==="BLOG_PLATFORM_API_KEYS"&&(r=process.env.BLOG_AUTH_TOKEN);let n=r?r.split(",").map(o=>o.trim()).filter(Boolean):[];n.length===0&&console.warn(`\u26A0\uFE0F No API keys found in environment variable ${t}${t==="BLOG_PLATFORM_API_KEYS"?" (set BLOG_PLATFORM_API_KEYS or BLOG_AUTH_TOKEN)":""}. Authentication will fail for all requests.`),super(n);}},be=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},Le=class{hasWarned=false;async validateToken(t){return this.hasWarned||(console.error("\u274C SECURITY WARNING: Blog platform authentication not initialized! All requests will be rejected. Call initBlogPlatform() to configure authentication."),this.hasWarned=true),{valid:false,errorCode:"invalid"}}};function On(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new Le,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function ke(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function it(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??On()}function En(e){ke(new ne(e));}async function G(e){let t=it(),r=t.extractToken?t.extractToken(e):nt(e);if(!r)return {authenticated:false,result:{valid:false,errorCode:"missing"},token:null};let n=await t.validateToken(r);return {authenticated:n.valid,result:n,token:r}}function Mn(e,t=""){let n=it().errorMessages??{},o,i;switch(e.errorCode){case "missing":o=n.missing??"Authentication token is required",i="PUB005";break;case "expired":o=n.expired??"Authentication token has expired",i="PUB005";break;default:o=n.invalid??"Invalid authentication credentials",i="PUB005";break}return {success:false,error:{code:i,message:o,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function X(e){let t=await G(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:Mn(t.result)}}function $n(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function Un(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function Hn(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function _e(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:o="blog-platform-ratelimit",analytics:i=true}=e,a=new Redis({url:t,token:r}),s=new Ratelimit({redis:a,analytics:i,prefix:o,limiter:Ratelimit.slidingWindow(n,"1m")});Hn(s);}function ot(){let e=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!e||!t){console.warn("Blog platform: No Upstash Redis configuration found. Rate limiting disabled.");return}_e({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function Dt(e){let t=Un();if(!t)return console.warn("Blog platform: Rate limiter not configured. All requests allowed."),{success:true,remaining:999,reset:Date.now()+6e4,limit:5,count:0};try{let r=await t.limit(e);return {success:r.success,remaining:r.remaining,reset:r.reset,limit:r.limit,count:r.limit-r.remaining}}catch(r){return console.error("Blog platform: Rate limit check failed:",r),{success:true,remaining:0,reset:Date.now()+6e4,limit:5,count:0}}}function Ut(e,t=""){let r=Math.ceil((e.reset-Date.now())/6e4);return {success:false,error:{code:"PUB011",message:`Rate limit exceeded. You can make ${e.limit} requests per minute. Try again in ${r} minute(s).`,details:{rateLimit:e}},idempotencyKey:t}}async function V(e,t=""){let r=await Dt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:Ut(r,t)}}function _(e){return {"X-RateLimit-Limit":e.limit.toString(),"X-RateLimit-Remaining":e.remaining.toString(),"X-RateLimit-Reset":e.reset.toString(),"Retry-After":Math.ceil((e.reset-Date.now())/1e3).toString()}}function Be(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
114
+ `}),jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsx("h1",{className:f("article-title px-4 text-2xl leading-tight font-light tracking-tight text-balance sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",$),children:e.title}),e.excerpt&&jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"sr-only",children:"Author"}),jsxs(X,{href:R(m,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(Ut,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsx(ye,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${d.publishedDateLabel}`,children:["Published ",d.publishedDateLabel]}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:d.publishedRelativeLabel}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:x})]}),d.isUpdated&&jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",d.updatedDateLabel]}),c&&jsx(Me,{title:e.title,url:p,size:"sm"}),jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(G=>jsx(X,{href:T((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${G.slug}`),className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1 text-xs font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)]",children:G.name},G.id))}):jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),v&&jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",children:jsx(nt,{src:v,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),I&&jsxs("figcaption",{className:"text-muted-foreground mt-3 space-y-1 px-2 text-center text-sm leading-relaxed sm:px-0",children:[e.featuredImageCaption&&jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsx("p",{className:"text-xs",children:jsx(Tn,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxs("div",{className:"min-w-0",children:[jsx(ot,{items:h,contentId:"article-body",variant:"mobile"}),jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] [&_figure>p]:!my-0 [&_figcaption]:!mt-2 [&_figcaption]:text-center [&_figcaption]:!text-sm [&_figcaption]:!leading-snug [&_figcaption]:text-muted-foreground [&_figcaption_.blog-image-credit]:mt-1 [&_figcaption_.blog-image-credit]:block [&_figcaption_.blog-image-credit]:text-xs [&_figcaption_.blog-image-credit]:tracking-wide [&_figcaption_.blog-image-credit]:text-muted-foreground/80 [&_figcaption>span:not(.blog-image-credit)]:ml-2 [&_figcaption>span:not(.blog-image-credit)]:border-l [&_figcaption>span:not(.blog-image-credit)]:border-[var(--blog-accent-border)] [&_figcaption>span:not(.blog-image-credit)]:pl-2 [&_figcaption>span:not(.blog-image-credit)]:text-xs [&_figcaption>span:not(.blog-image-credit)]:tracking-wide [&_figcaption>span:not(.blog-image-credit)]:text-muted-foreground/80 max-w-none",children:jsx(MDXRemote,{source:e.content,options:$t,components:{img:Et}})})]}),jsx(ot,{items:h,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsx(ne,{className:"mb-8"}),jsx(ve,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxs(Pe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsx("div",{className:"shrink-0",children:jsx(Ut,{author:e.author,size:"lg"})}),jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxs("div",{className:"min-w-0",children:[jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsx(X,{href:R(m,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsx(ye,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsx(Rn,{author:e.author})]}),jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((i??false)||(g?.enabled??false)||c||l.length>0)&&jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsx(ne,{}),i&&jsx(In,{cta:i}),g?.enabled&&jsx(xe,{siteId:e.site.id,settings:g,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:p,previewMode:s}),c&&jsx(kn,{title:e.title,url:p}),l.length>0&&jsx(_n,{articles:l.slice(0,3),basePath:m})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsx(ne,{className:"mb-8"}),jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsx(ve,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxs(X,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsx(lt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxs(Pe,{className:"p-4",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsx(ve,{className:f("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxs(X,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsx(lt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxs(Pe,{className:"p-4 md:text-right",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let G=te(Qe(e,{pathPrefix:m}));return jsx("script",{type:G.type,dangerouslySetInnerHTML:G.dangerouslySetInnerHTML})})()]})}function Ut({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=Ln(e.name);return e.avatarUrl?jsx(nt,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:f("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function Rn({author:e}){let t=Cn(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function Cn(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsx(FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function Ln(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function In({cta:e}){return jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxs("div",{className:"space-y-1",children:[jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxs(X,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function kn({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsx(Me,{title:e,url:t,size:"sm"}),jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsx(Mail,{className:"size-4","aria-hidden":"true"})})]})}function _n({articles:e,basePath:t}){return jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxs(X,{href:T(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsx(lt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxs("div",{className:"p-4",children:[jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function lt({src:e,alt:t}){return jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsx(nt,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function Bn(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${T(t,e.slug)}`,i=e.meta.ogImage??e.featuredImage;return {title:r,description:n,keywords:e.meta.keywords.join(", "),authors:e.author?[{name:e.author.name}]:void 0,openGraph:{title:r,description:n,type:"article",url:o,images:i?[{url:i,alt:e.featuredImageAlt??r}]:void 0,publishedTime:e.publishedAt,modifiedTime:e.updatedAt,authors:e.author?[e.author.name]:void 0,siteName:e.site.name},twitter:{card:"summary_large_image",title:r,description:n,images:i?[i]:void 0},alternates:{canonical:o}}}function qt({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:s}){let l=k(o)||"/",c=s?.backToHome?.url??l,m=R(l,e.slug),d=a?.totalItems??t.length,x=te(_e(e,{pathPrefix:l}));return jsxs("main",{style:M(i),className:f("author-page mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxs(X,{href:c,className:"text-muted-foreground group focus-visible:ring-ring inline-flex items-center gap-2 rounded-md px-2 py-1 text-sm font-medium transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:[jsx(ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),s?.backToHome?.label??"Back to all articles"]}),jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsx(Gn,{author:e}),jsxs("div",{className:"min-w-0 space-y-4",children:[jsxs("div",{className:"space-y-2",children:[jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsx(ye,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsx("h1",{className:f("text-4xl leading-tight font-light text-balance sm:text-5xl",$),children:e.name})]}),e.bio&&jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsx(Dn,{author:e})]})]})]}),jsx(ne,{className:"mb-8"}),jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxs("div",{children:[jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[d," ",d===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsx(Hn,{article:h,basePath:l},h.id))}),a&&a.totalPages>1&&jsx("div",{className:"pt-4",children:jsx(ae,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??m,className:"justify-center"})})]}),jsx("script",{type:x.type,dangerouslySetInnerHTML:x.dangerouslySetInnerHTML})]})}function Dn({author:e}){let t=Un(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":r.ariaLabel,className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:r.icon},r.label))})}function Un(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:null,t.x??t.twitter?{href:t.x??t.twitter??"",label:"x",ariaLabel:`${e.name} on X`,external:true,icon:jsx("span",{className:"text-sm font-semibold","aria-hidden":"true",children:"X"})}:null,t.linkedin?{href:t.linkedin,label:"linkedin",ariaLabel:`${e.name} on LinkedIn`,external:true,icon:jsx("span",{className:"text-sm font-bold","aria-hidden":"true",children:"in"})}:null,t.github?{href:t.github,label:"github",ariaLabel:`${e.name} on GitHub`,external:true,icon:jsx("span",{className:"text-xs font-bold","aria-hidden":"true",children:"GH"})}:null,t.email?{href:`mailto:${t.email}`,label:"email",ariaLabel:`Email ${e.name}`,external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function Hn({article:e,basePath:t}){let r=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxs(X,{href:T(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxs("div",{className:"min-w-0 space-y-3",children:[jsx("h3",{className:"text-xl leading-tight font-semibold text-balance transition-colors group-hover:text-[var(--blog-text-accent)]",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsx("time",{dateTime:e.publishedAt,children:r}),jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsx(nt,{src:e.featuredImage,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:320,height:200,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})]})})}function Gn({author:e}){return e.avatarUrl?jsx(nt,{src:e.avatarUrl,alt:e.name,width:128,height:128,className:"size-28 rounded-full border border-[var(--blog-accent-border)] object-cover sm:size-32",priority:true}):jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-28 items-center justify-center rounded-full text-3xl font-semibold sm:size-32",children:jn(e.name)})}function jn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Fn(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${R(r,e.slug)}`,o=`${e.name} - ${t.name}`,i=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:o,description:i,authors:[{name:e.name}],openGraph:{title:o,description:i,type:"profile",url:n,images:e.avatarUrl?[{url:e.avatarUrl,alt:e.name}]:void 0,siteName:t.name},twitter:{card:e.avatarUrl?"summary_large_image":"summary",title:o,description:i,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:n}}}var $e=class{articles=new Map;operations=new Map;async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(Array.from(this.articles.values()).some(a=>a.id===t.id))return n}else return n;if(this.articles.has(t.slug)){let i={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.set(t.slug,t);let o={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=Array.from(this.articles.values());return a.sort((l,c)=>{let m=new Date(l[o]).getTime(),d=new Date(c[o]).getTime();return i==="desc"?d-m:m-d}),{articles:a.slice(n,n+r),total:a.length}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!this.articles.has(t))return n}else return n;if(!this.articles.has(t)){let i={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.delete(t);let o={success:true,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}};function zn(){let e=globalThis;if(e.__BLOG_PLATFORM_STORAGE_WARNED__)return;e.__BLOG_PLATFORM_STORAGE_WARNED__=true;let t="Blog platform: No storage provider configured. Falling back to in-memory storage (data is not persisted).";process.env.NODE_ENV==="production"?console.error(`${t} Call initBlogPlatform({ storage: /* your persistent adapter */ }) to avoid data loss.`):console.warn(t);}function Vn(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(zn(),e.__BLOG_PLATFORM_STORAGE__=new $e);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function F(){return Vn()}function ut(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function dt(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Wt(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function Xt(e,t){let r=t.filter(o=>o.author?.slug===e).sort((o,i)=>new Date(i.publishedAt).getTime()-new Date(o.publishedAt).getTime()),n=r.reduce((o,i)=>i.author?Wt(o,i.author):o,null);return n?{author:n,articles:r}:null}async function qn(e,t={},r=F()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return Xt(e,n)}function Wt(e,t){return e?{...e,bio:e.bio??t.bio,avatarUrl:e.avatarUrl??t.avatarUrl,pronouns:e.pronouns??t.pronouns,socialLinks:e.socialLinks??t.socialLinks,toneAdjectives:e.toneAdjectives.length>0?e.toneAdjectives:t.toneAdjectives}:t}function Xn(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function mt(e){let t=new Map;for(let r of e)for(let n of r.topics??[])t.has(n.slug)||t.set(n.slug,n);return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function pt(e,t){let r=e.filter(o=>(o.topics??[]).some(i=>i.slug===t));if(r.length===0)return null;let n=r.flatMap(o=>o.topics??[]).find(o=>o.slug===t)??null;return n?{topic:n,articles:r}:null}function Jn({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=k(t)||"/",s=mt(e);return jsxs("main",{style:M(i),className:f("blog-topics-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(X,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",$),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(m=>(m.topics??[]).some(d=>d.slug===l.slug)).length;return jsxs(X,{href:T(a,`topics/${l.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[c," ",c===1?"article":"articles"]})]},l.slug)})})]})}function Yn({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=k(r)||"/",a=pt(e,t);return jsxs("main",{style:M(o),className:f("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(X,{href:T(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",$),children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(s=>jsx(Qn,{article:s,topic:a.topic,basePath:i},s.id))}):jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function Qn({article:e,topic:t,basePath:r}){let n=T(r,e.slug),o=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxs(X,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsx(nt,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxs("div",{className:"space-y-3 p-5",children:[jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function ei({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=k(t)||"/",s=dt(e);return jsxs("main",{style:M(i),className:f("blog-authors-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(X,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",$),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(m=>m.author?.slug===l.slug).length;return jsx(X,{href:R(a,l.slug),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:jsxs("div",{className:"flex items-start gap-4",children:[jsx(ti,{author:l}),jsxs("div",{className:"min-w-0 space-y-2",children:[jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxs("p",{className:"text-muted-foreground text-sm",children:[c," ",c===1?"article":"articles"]})]})]})},l.slug)})})]})}function ti({author:e}){let t=ri(e.name);return e.avatarUrl?jsx(nt,{src:e.avatarUrl,alt:e.name,width:56,height:56,className:"size-14 shrink-0 rounded-full border border-[var(--blog-accent-border)] object-cover"}):jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-14 shrink-0 items-center justify-center rounded-full text-base font-semibold",children:t})}function ri(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function z(e){return `sha256:${createHash("sha256").update(e).digest("hex")}`}function gt(e){let t=e.headers.get("Authorization");if(!t)return null;let n=/^Bearer\s+(.+)$/i.exec(t);if(n?.[1])return n[1];let i=/^Token\s+(.+)$/i.exec(t);return i?.[1]?i[1]:null}var Ue=class{validApiKeys;constructor(t){this.validApiKeys=new Set(t);}async validateToken(t){return t?.trim()?this.validApiKeys.has(t)?{valid:true,context:{tokenHash:this.hashToken(t)}}:{valid:false,errorCode:"invalid"}:{valid:false,errorCode:"missing"}}extractToken=t=>gt(t);hashToken(t){return z(t)}},ue=class extends Ue{constructor(t="BLOG_PLATFORM_API_KEYS"){let r=process.env[t];!r&&t==="BLOG_PLATFORM_API_KEYS"&&(r=process.env.BLOG_AUTH_TOKEN);let n=r?r.split(",").map(o=>o.trim()).filter(Boolean):[];n.length===0&&console.warn(`\u26A0\uFE0F No API keys found in environment variable ${t}${t==="BLOG_PLATFORM_API_KEYS"?" (set BLOG_PLATFORM_API_KEYS or BLOG_AUTH_TOKEN)":""}. Authentication will fail for all requests.`),super(n);}},Ne=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},He=class{hasWarned=false;async validateToken(t){return this.hasWarned||(console.error("\u274C SECURITY WARNING: Blog platform authentication not initialized! All requests will be rejected. Call initBlogPlatform() to configure authentication."),this.hasWarned=true),{valid:false,errorCode:"invalid"}}};function ii(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new He,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ge(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function ft(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??ii()}function oi(e){Ge(new ue(e));}async function W(e){let t=ft(),r=t.extractToken?t.extractToken(e):gt(e);if(!r)return {authenticated:false,result:{valid:false,errorCode:"missing"},token:null};let n=await t.validateToken(r);return {authenticated:n.valid,result:n,token:r}}function ai(e,t=""){let n=ft().errorMessages??{},o,i;switch(e.errorCode){case "missing":o=n.missing??"Authentication token is required",i="PUB005";break;case "expired":o=n.expired??"Authentication token has expired",i="PUB005";break;default:o=n.invalid??"Invalid authentication credentials",i="PUB005";break}return {success:false,error:{code:i,message:o,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function Q(e){let t=await W(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:ai(t.result)}}function si(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function ci(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function ui(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function je(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:o="blog-platform-ratelimit",analytics:i=true}=e,a=new Redis({url:t,token:r}),s=new Ratelimit({redis:a,analytics:i,prefix:o,limiter:Ratelimit.slidingWindow(n,"1m")});ui(s);}function ht(){let e=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!e||!t){console.warn("Blog platform: No Upstash Redis configuration found. Rate limiting disabled.");return}je({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function Yt(e){let t=ci();if(!t)return console.warn("Blog platform: Rate limiter not configured. All requests allowed."),{success:true,remaining:999,reset:Date.now()+6e4,limit:5,count:0};try{let r=await t.limit(e);return {success:r.success,remaining:r.remaining,reset:r.reset,limit:r.limit,count:r.limit-r.remaining}}catch(r){return console.error("Blog platform: Rate limit check failed:",r),{success:true,remaining:0,reset:Date.now()+6e4,limit:5,count:0}}}function Qt(e,t=""){let r=Math.ceil((e.reset-Date.now())/6e4);return {success:false,error:{code:"PUB011",message:`Rate limit exceeded. You can make ${e.limit} requests per minute. Try again in ${r} minute(s).`,details:{rateLimit:e}},idempotencyKey:t}}async function K(e,t=""){let r=await Yt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:Qt(r,t)}}function O(e){return {"X-RateLimit-Limit":e.limit.toString(),"X-RateLimit-Remaining":e.remaining.toString(),"X-RateLimit-Reset":e.reset.toString(),"Retry-After":Math.ceil((e.reset-Date.now())/1e3).toString()}}function Fe(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
115
115
  Example: initBlogPlatform({ auth: new EnvAuth() })
116
- See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),ke(t),n?(console.log("Blog platform: Using custom rate limiting configuration"),_e(n)):o?(console.log("Blog platform: Auto-configuring rate limiting from environment"),ot()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),Ze(r)):console.log("Blog platform: Using default in-memory storage (not suitable for production)"),console.log("Blog platform initialized successfully"),globalThis.__BLOG_PLATFORM_INITIALISED__=true;}function jn(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Be(e);}function zn(){Be({auth:new be,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function Gn(e){let t=e??"BLOG_PLATFORM_API_KEYS";if(!process.env[t])throw new Error(`Missing required environment variable: ${t}. Set this to a comma-separated list of API keys for blog platform authentication.`);Be({auth:new ne(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var w=sqliteTable("bp_articles",{id:text("id").primaryKey(),slug:text("slug").notNull(),title:text("title").notNull(),excerpt:text("excerpt").notNull(),content:text("content").notNull(),readingSeconds:integer("reading_seconds").notNull(),wordCount:integer("word_count").notNull(),publishedAt:text("published_at").notNull(),updatedAt:text("updated_at").notNull(),featuredImage:text("featured_image"),featuredImageAlt:text("featured_image_alt"),featuredImageCaption:text("featured_image_caption"),featuredImageCreditText:text("featured_image_credit_text"),featuredImageCreditUrl:text("featured_image_credit_url"),authorJson:text("author_json"),siteJson:text("site_json").notNull(),metaJson:text("meta_json").notNull(),version:integer("version").notNull()},e=>({slugUniqueIdx:uniqueIndex("bp_articles_slug_unique").on(e.slug)})),ie=sqliteTable("bp_operations",{key:text("key").primaryKey(),resultJson:text("result_json").notNull(),createdAt:integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:integer("expires_at",{mode:"timestamp_ms"})});function Wn(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??null,featuredImageAlt:e.featuredImageAlt??null,featuredImageCaption:e.featuredImageCaption??null,featuredImageCreditText:e.featuredImageCreditText??null,featuredImageCreditUrl:e.featuredImageCreditUrl??null,authorJson:e.author?JSON.stringify(e.author):null,siteJson:JSON.stringify(e.site),metaJson:JSON.stringify({...e.meta,__bloggyTopics:e.topics??[]}),version:e.version}}function Ht(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??void 0,featuredImageAlt:e.featuredImageAlt??void 0,featuredImageCaption:e.featuredImageCaption??void 0,featuredImageCreditText:e.featuredImageCreditText??void 0,featuredImageCreditUrl:e.featuredImageCreditUrl??void 0,author:e.authorJson?JSON.parse(e.authorJson):null,site:JSON.parse(e.siteJson),topics:Kn(e.metaJson),meta:Jn(e.metaJson),version:e.version}}function Kn(e){return JSON.parse(e).__bloggyTopics??[]}function Jn(e){let t=JSON.parse(e);return delete t.__bloggyTopics,t}var at=class{db;options;constructor(t,r={}){this.db=t,this.options=r;}async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if((await this.db.select({id:w.id}).from(w).where(eq(w.id,t.id)).limit(1)).length!==0)return n}else return n;let o=await this.db.select().from(w).where(eq(w.slug,t.slug)).limit(1),i=o[0];if(i&&i.id!==t.id){let l={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,l),l}let a=Wn(t);o.length===0?await this.db.insert(w).values(a).run():await this.db.update(w).set({title:a.title,excerpt:a.excerpt,content:a.content,readingSeconds:a.readingSeconds,wordCount:a.wordCount,updatedAt:a.updatedAt,featuredImage:a.featuredImage,featuredImageAlt:a.featuredImageAlt,featuredImageCaption:a.featuredImageCaption,featuredImageCreditText:a.featuredImageCreditText,featuredImageCreditUrl:a.featuredImageCreditUrl,authorJson:a.authorJson,siteJson:a.siteJson,metaJson:a.metaJson,version:a.version}).where(and(eq(w.id,a.id),eq(w.slug,a.slug))).run();let s={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,s),s}async getArticle(t){let r=await this.db.select().from(w).where(eq(w.slug,t)).limit(1);return r[0]?Ht(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=o==="publishedAt"?w.publishedAt:w.updatedAt,s=i==="desc"?desc(a):a,l=await this.db.select().from(w).orderBy(s).limit(r).offset(n),c=await this.db.select({c:sql`count(*)`}).from(w),d=Number(c?.[0]?.c??0);return {articles:l.map(Ht),total:d}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!((await this.db.select({id:w.id}).from(w).where(eq(w.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(w).where(eq(w.slug,t)).limit(1))[0]){let a={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,a),a}await this.db.delete(w).where(eq(w.slug,t)).run();let i={success:true,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async checkIdempotency(t){let r=await this.db.select().from(ie).where(eq(ie.key,t)).limit(1);if(!r[0])return null;try{return JSON.parse(r[0].resultJson)}catch{return null}}async storeOperationResult(t,r){let n=Date.now(),o=this.options.operationTtlMs?n+this.options.operationTtlMs:null;await this.db.delete(ie).where(eq(ie.key,t)).run(),await this.db.insert(ie).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:o?new Date(o):null}).run();}};function Yn(){return {createArticles:`CREATE TABLE IF NOT EXISTS bp_articles (
116
+ See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),Ge(t),n?(console.log("Blog platform: Using custom rate limiting configuration"),je(n)):o?(console.log("Blog platform: Auto-configuring rate limiting from environment"),ht()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),ut(r)):console.log("Blog platform: Using default in-memory storage (not suitable for production)"),console.log("Blog platform initialized successfully"),globalThis.__BLOG_PLATFORM_INITIALISED__=true;}function di(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Fe(e);}function mi(){Fe({auth:new Ne,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function pi(e){let t=e??"BLOG_PLATFORM_API_KEYS";if(!process.env[t])throw new Error(`Missing required environment variable: ${t}. Set this to a comma-separated list of API keys for blog platform authentication.`);Fe({auth:new ue(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var w=sqliteTable("bp_articles",{id:text("id").primaryKey(),slug:text("slug").notNull(),title:text("title").notNull(),excerpt:text("excerpt").notNull(),content:text("content").notNull(),readingSeconds:integer("reading_seconds").notNull(),wordCount:integer("word_count").notNull(),publishedAt:text("published_at").notNull(),updatedAt:text("updated_at").notNull(),featuredImage:text("featured_image"),featuredImageAlt:text("featured_image_alt"),featuredImageCaption:text("featured_image_caption"),featuredImageCreditText:text("featured_image_credit_text"),featuredImageCreditUrl:text("featured_image_credit_url"),authorJson:text("author_json"),siteJson:text("site_json").notNull(),metaJson:text("meta_json").notNull(),version:integer("version").notNull()},e=>({slugUniqueIdx:uniqueIndex("bp_articles_slug_unique").on(e.slug)})),de=sqliteTable("bp_operations",{key:text("key").primaryKey(),resultJson:text("result_json").notNull(),createdAt:integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:integer("expires_at",{mode:"timestamp_ms"})});function xi(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??null,featuredImageAlt:e.featuredImageAlt??null,featuredImageCaption:e.featuredImageCaption??null,featuredImageCreditText:e.featuredImageCreditText??null,featuredImageCreditUrl:e.featuredImageCreditUrl??null,authorJson:e.author?JSON.stringify(e.author):null,siteJson:JSON.stringify(e.site),metaJson:JSON.stringify({...e.meta,__bloggyTopics:e.topics??[]}),version:e.version}}function Zt(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??void 0,featuredImageAlt:e.featuredImageAlt??void 0,featuredImageCaption:e.featuredImageCaption??void 0,featuredImageCreditText:e.featuredImageCreditText??void 0,featuredImageCreditUrl:e.featuredImageCreditUrl??void 0,author:e.authorJson?JSON.parse(e.authorJson):null,site:JSON.parse(e.siteJson),topics:yi(e.metaJson),meta:vi(e.metaJson),version:e.version}}function yi(e){return JSON.parse(e).__bloggyTopics??[]}function vi(e){let t=JSON.parse(e);return delete t.__bloggyTopics,t}var bt=class{db;options;constructor(t,r={}){this.db=t,this.options=r;}async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if((await this.db.select({id:w.id}).from(w).where(eq(w.id,t.id)).limit(1)).length!==0)return n}else return n;let o=await this.db.select().from(w).where(eq(w.slug,t.slug)).limit(1),i=o[0];if(i&&i.id!==t.id){let l={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,l),l}let a=xi(t);o.length===0?await this.db.insert(w).values(a).run():await this.db.update(w).set({title:a.title,excerpt:a.excerpt,content:a.content,readingSeconds:a.readingSeconds,wordCount:a.wordCount,updatedAt:a.updatedAt,featuredImage:a.featuredImage,featuredImageAlt:a.featuredImageAlt,featuredImageCaption:a.featuredImageCaption,featuredImageCreditText:a.featuredImageCreditText,featuredImageCreditUrl:a.featuredImageCreditUrl,authorJson:a.authorJson,siteJson:a.siteJson,metaJson:a.metaJson,version:a.version}).where(and(eq(w.id,a.id),eq(w.slug,a.slug))).run();let s={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,s),s}async getArticle(t){let r=await this.db.select().from(w).where(eq(w.slug,t)).limit(1);return r[0]?Zt(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=o==="publishedAt"?w.publishedAt:w.updatedAt,s=i==="desc"?desc(a):a,l=await this.db.select().from(w).orderBy(s).limit(r).offset(n),c=await this.db.select({c:sql`count(*)`}).from(w),m=Number(c?.[0]?.c??0);return {articles:l.map(Zt),total:m}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!((await this.db.select({id:w.id}).from(w).where(eq(w.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(w).where(eq(w.slug,t)).limit(1))[0]){let a={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,a),a}await this.db.delete(w).where(eq(w.slug,t)).run();let i={success:true,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async checkIdempotency(t){let r=await this.db.select().from(de).where(eq(de.key,t)).limit(1);if(!r[0])return null;try{return JSON.parse(r[0].resultJson)}catch{return null}}async storeOperationResult(t,r){let n=Date.now(),o=this.options.operationTtlMs?n+this.options.operationTtlMs:null;await this.db.delete(de).where(eq(de.key,t)).run(),await this.db.insert(de).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:o?new Date(o):null}).run();}};function Pi(){return {createArticles:`CREATE TABLE IF NOT EXISTS bp_articles (
117
117
  id TEXT PRIMARY KEY,
118
118
  slug TEXT NOT NULL UNIQUE,
119
119
  title TEXT NOT NULL,
@@ -137,11 +137,11 @@ See https://github.com/xexr/blog-platform#authentication for more details.`);con
137
137
  result_json TEXT NOT NULL,
138
138
  created_at INTEGER NOT NULL,
139
139
  expires_at INTEGER
140
- );`}}function oe(e,t=true){let r=e.trim();return r=r.replace(/\/+$/,""),/^https?:\/\//.exec(r)||(r=`${t?"https":"http"}://${r}`),t&&r.startsWith("http://")&&(r=r.replace("http://","https://")),r}function zt(e){let t=e.trim();if(!t)throw new Error("Slug cannot be empty");if(!/^[a-z0-9-]+$/.test(t))throw new Error("Slug can only contain lowercase letters, numbers, and hyphens");let n=t.replace(/-+/g,"-").replace(/^-+|-+$/g,"");if(!n)throw new Error("Slug cannot consist only of hyphens");return n}function Z(e,t={}){let{forceHttps:r=true,removeTrailingSlash:n=true,domain:o=e.site.domain,pathPrefix:i="/blog"}=t;if(!o)throw new Error("Domain is required for canonical URL generation");if(!e.slug)throw new Error("Article slug is required for canonical URL generation");let a=oe(o,r),s=zt(e.slug),l=i.replace(/^(?!\/)/,"/").replace(/\/+$/,""),c=`${a}${l}/${s}`;return n&&(c=c.replace(/\/+$/,"")),c}function Qn(e,t,r={}){return Z({slug:t,site:e},r)}function Zn(e){try{let t=new URL(e);return !(!["http:","https:"].includes(t.protocol)||!t.hostname||t.hostname.length===0||/^https?:\/\/\//.exec(e)&&!/^https?:\/\/[^\/]/.exec(e)||e.includes(" "))}catch{return false}}function ei(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function ti(e,t={}){let r=Z(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function ri(e,t={},r){let n=r?.path??"/blog",i=`https://${t.canonical?.domain??e.domain}${n}`,a=r?.title?`${r.title} | ${e.name}`:e.name,s=r?.description??e.description,l=t.openGraph?.siteName??e.name,c=[{name:"description",content:s},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&c.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&c.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&c.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&c.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&c.push({name:"application-name",content:t.meta.applicationName});let d=[{property:"og:title",content:a},{property:"og:description",content:s},{property:"og:url",content:i},{property:"og:site_name",content:l},{property:"og:locale",content:t.openGraph?.locale??e.locale},{property:"og:type",content:t.openGraph?.type??"website"}];t.openGraph?.defaultImage&&d.push({property:"og:image",content:t.openGraph.defaultImage},{property:"og:image:alt",content:`${l} - ${e.tagline}`});let m=ni(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:a,description:s,image:t.openGraph?.defaultImage});return {meta:c,openGraph:d,twitter:m,links:[{rel:"canonical",href:i}],title:a,description:s,canonicalUrl:i}}function ni(e,t,r){let n=r?.title??e?.meta.title??e?.title??"",o=r?.description??e?.meta.description??e?.excerpt??"",i=r?.image??e?.meta.ogImage??e?.featuredImage,a=[{name:"twitter:card",content:t.cardType},{name:"twitter:title",content:n},{name:"twitter:description",content:o}];return t.site&&a.push({name:"twitter:site",content:t.site}),t.creator&&a.push({name:"twitter:creator",content:t.creator}),i&&(a.push({name:"twitter:image",content:i}),e?.featuredImageAlt),a}function ii(e){let t=[];return t.push(`<title>${B(e.title)}</title>`),e.meta.forEach(r=>{let n=[];r.name&&n.push(`name="${B(r.name)}"`),r.property&&n.push(`property="${B(r.property)}"`),r.httpEquiv&&n.push(`http-equiv="${B(r.httpEquiv)}"`),n.push(`content="${B(r.content)}"`),t.push(`<meta ${n.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${B(r.property)}" content="${B(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${B(r.name)}" content="${B(r.content)}" />`);}),e.links.forEach(r=>{let n=[];n.push(`rel="${B(r.rel)}"`),n.push(`href="${B(r.href)}"`),r.type&&n.push(`type="${B(r.type)}"`),r.title&&n.push(`title="${B(r.title)}"`),t.push(`<link ${n.join(" ")} />`);}),t.join(`
141
- `)}function B(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function oi(e){let t=[],r=[];return e.title?e.title.length>60?r.push("Title longer than 60 characters may be truncated in search results"):e.title.length<30&&r.push("Title shorter than 30 characters may not be descriptive enough"):t.push("Title is required"),e.description?e.description.length>160?r.push("Meta description longer than 160 characters may be truncated"):e.description.length<120&&r.push("Meta description shorter than 120 characters may not be descriptive enough"):t.push("Meta description is required"),e.canonicalUrl?e.canonicalUrl.startsWith("https://")||r.push("Canonical URL should use HTTPS for better SEO"):t.push("Canonical URL is required"),e.openGraph.find(i=>i.property==="og:image")||r.push("OpenGraph image missing - social media sharing will not show image preview"),e.twitter.find(i=>i.name==="twitter:card")||r.push("Twitter Card type missing - Twitter sharing may not display properly"),{valid:t.length===0,errors:t,warnings:r}}async function st(e,t,r=[],n={}){let{includeAuthorPages:o=true,includePaginationPages:i=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,d=[],m=oe(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),y=n.canonical?.pathPrefix??"/blog";if(d.push({url:`${m}${y}`,lastModified:ae(t),changeFrequency:l.homePage??"daily",priority:c.homePage??1}),t.forEach(h=>{if(d.length>=s)return;let p=Z(h,n.canonical);d.push({url:p,lastModified:h.updatedAt,changeFrequency:l.articles??"monthly",priority:c.articles??.8});}),o&&r.forEach(h=>{if(d.length>=s)return;let p=`${m}${R(y,h.slug)}`,g=t.filter(E=>E.author?.id===h.id),A=ae(g);d.push({url:p,lastModified:A,changeFrequency:l.authorPages??"weekly",priority:c.authorPages??.6});}),i&&t.length>a){let h=Math.ceil(t.length/a);for(let p=2;p<=h&&!(d.length>=s);p++)d.push({url:`${m}${y}?page=${p}`,lastModified:ae(t),changeFrequency:l.paginationPages??"daily",priority:c.paginationPages??.5});}return d}function ai(e,t,r=[],n={}){let{includeAuthorPages:o=true,includePaginationPages:i=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,d=[],m=oe(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),y=n.canonical?.pathPrefix??"/blog",h=new Date().toISOString(),p=1;if(p+=t.length,o&&(p+=r.length),i&&t.length>a){let A=Math.ceil(t.length/a);p+=A-1;}let g=p>s;if(d.push({loc:`${m}${y}`,lastmod:ae(t),changefreq:l.homePage??"daily",priority:c.homePage??1}),t.forEach(A=>{if(d.length>=s)return;let E=Z(A,n.canonical);d.push({loc:E,lastmod:A.updatedAt,changefreq:l.articles??"monthly",priority:c.articles??.8});}),o&&r.forEach(A=>{if(d.length>=s)return;let E=`${m}${R(y,A.slug)}`,Yt=t.filter(Zt=>Zt.author?.id===A.id),Qt=ae(Yt);d.push({loc:E,lastmod:Qt,changefreq:l.authorPages??"weekly",priority:c.authorPages??.6});}),i&&t.length>a){let A=Math.ceil(t.length/a);for(let E=2;E<=A&&!(d.length>=s);E++)d.push({loc:`${m}${y}?page=${E}`,lastmod:ae(t),changefreq:l.paginationPages??"daily",priority:c.paginationPages??.5});}return {entries:d,totalEntries:d.length,truncated:g,generatedAt:h,baseUrl:m}}function Gt(e){let t='<?xml version="1.0" encoding="UTF-8"?>',r='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',n="</urlset>",o=e.entries.map(i=>{let a=[];return a.push(" <url>"),a.push(` <loc>${ye(i.loc)}</loc>`),i.lastmod&&a.push(` <lastmod>${ye(i.lastmod)}</lastmod>`),i.changefreq&&a.push(` <changefreq>${ye(i.changefreq)}</changefreq>`),i.priority!==void 0&&a.push(` <priority>${i.priority.toFixed(1)}</priority>`),a.push(" </url>"),a.join(`
140
+ );`}}function me(e,t=true){let r=e.trim();return r=r.replace(/\/+$/,""),/^https?:\/\//.exec(r)||(r=`${t?"https":"http"}://${r}`),t&&r.startsWith("http://")&&(r=r.replace("http://","https://")),r}function tr(e){let t=e.trim();if(!t)throw new Error("Slug cannot be empty");if(!/^[a-z0-9-]+$/.test(t))throw new Error("Slug can only contain lowercase letters, numbers, and hyphens");let n=t.replace(/-+/g,"-").replace(/^-+|-+$/g,"");if(!n)throw new Error("Slug cannot consist only of hyphens");return n}function ie(e,t={}){let{forceHttps:r=true,removeTrailingSlash:n=true,domain:o=e.site.domain,pathPrefix:i="/blog"}=t;if(!o)throw new Error("Domain is required for canonical URL generation");if(!e.slug)throw new Error("Article slug is required for canonical URL generation");let a=me(o,r),s=tr(e.slug),l=i.replace(/^(?!\/)/,"/").replace(/\/+$/,""),c=`${a}${l}/${s}`;return n&&(c=c.replace(/\/+$/,"")),c}function Ai(e,t,r={}){return ie({slug:t,site:e},r)}function wi(e){try{let t=new URL(e);return !(!["http:","https:"].includes(t.protocol)||!t.hostname||t.hostname.length===0||/^https?:\/\/\//.exec(e)&&!/^https?:\/\/[^\/]/.exec(e)||e.includes(" "))}catch{return false}}function Si(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function Ni(e,t={}){let r=ie(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function Ti(e,t={},r){let n=r?.path??"/blog",i=`https://${t.canonical?.domain??e.domain}${n}`,a=r?.title?`${r.title} | ${e.name}`:e.name,s=r?.description??e.description,l=t.openGraph?.siteName??e.name,c=[{name:"description",content:s},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&c.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&c.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&c.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&c.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&c.push({name:"application-name",content:t.meta.applicationName});let m=[{property:"og:title",content:a},{property:"og:description",content:s},{property:"og:url",content:i},{property:"og:site_name",content:l},{property:"og:locale",content:t.openGraph?.locale??e.locale},{property:"og:type",content:t.openGraph?.type??"website"}];t.openGraph?.defaultImage&&m.push({property:"og:image",content:t.openGraph.defaultImage},{property:"og:image:alt",content:`${l} - ${e.tagline}`});let d=Ri(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:a,description:s,image:t.openGraph?.defaultImage});return {meta:c,openGraph:m,twitter:d,links:[{rel:"canonical",href:i}],title:a,description:s,canonicalUrl:i}}function Ri(e,t,r){let n=r?.title??e?.meta.title??e?.title??"",o=r?.description??e?.meta.description??e?.excerpt??"",i=r?.image??e?.meta.ogImage??e?.featuredImage,a=[{name:"twitter:card",content:t.cardType},{name:"twitter:title",content:n},{name:"twitter:description",content:o}];return t.site&&a.push({name:"twitter:site",content:t.site}),t.creator&&a.push({name:"twitter:creator",content:t.creator}),i&&(a.push({name:"twitter:image",content:i}),e?.featuredImageAlt),a}function Ci(e){let t=[];return t.push(`<title>${E(e.title)}</title>`),e.meta.forEach(r=>{let n=[];r.name&&n.push(`name="${E(r.name)}"`),r.property&&n.push(`property="${E(r.property)}"`),r.httpEquiv&&n.push(`http-equiv="${E(r.httpEquiv)}"`),n.push(`content="${E(r.content)}"`),t.push(`<meta ${n.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${E(r.property)}" content="${E(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${E(r.name)}" content="${E(r.content)}" />`);}),e.links.forEach(r=>{let n=[];n.push(`rel="${E(r.rel)}"`),n.push(`href="${E(r.href)}"`),r.type&&n.push(`type="${E(r.type)}"`),r.title&&n.push(`title="${E(r.title)}"`),t.push(`<link ${n.join(" ")} />`);}),t.join(`
141
+ `)}function E(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Li(e){let t=[],r=[];return e.title?e.title.length>60?r.push("Title longer than 60 characters may be truncated in search results"):e.title.length<30&&r.push("Title shorter than 30 characters may not be descriptive enough"):t.push("Title is required"),e.description?e.description.length>160?r.push("Meta description longer than 160 characters may be truncated"):e.description.length<120&&r.push("Meta description shorter than 120 characters may not be descriptive enough"):t.push("Meta description is required"),e.canonicalUrl?e.canonicalUrl.startsWith("https://")||r.push("Canonical URL should use HTTPS for better SEO"):t.push("Canonical URL is required"),e.openGraph.find(i=>i.property==="og:image")||r.push("OpenGraph image missing - social media sharing will not show image preview"),e.twitter.find(i=>i.name==="twitter:card")||r.push("Twitter Card type missing - Twitter sharing may not display properly"),{valid:t.length===0,errors:t,warnings:r}}async function xt(e,t,r=[],n={}){let{includeAuthorPages:o=true,includePaginationPages:i=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,m=[],d=me(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),x=n.canonical?.pathPrefix??"/blog";if(m.push({url:`${d}${x}`,lastModified:pe(t),changeFrequency:l.homePage??"daily",priority:c.homePage??1}),t.forEach(h=>{if(m.length>=s)return;let p=ie(h,n.canonical);m.push({url:p,lastModified:h.updatedAt,changeFrequency:l.articles??"monthly",priority:c.articles??.8});}),o&&r.forEach(h=>{if(m.length>=s)return;let p=`${d}${R(x,h.slug)}`,g=t.filter(I=>I.author?.id===h.id),v=pe(g);m.push({url:p,lastModified:v,changeFrequency:l.authorPages??"weekly",priority:c.authorPages??.6});}),i&&t.length>a){let h=Math.ceil(t.length/a);for(let p=2;p<=h&&!(m.length>=s);p++)m.push({url:`${d}${x}?page=${p}`,lastModified:pe(t),changeFrequency:l.paginationPages??"daily",priority:c.paginationPages??.5});}return m}function Ii(e,t,r=[],n={}){let{includeAuthorPages:o=true,includePaginationPages:i=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,m=[],d=me(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),x=n.canonical?.pathPrefix??"/blog",h=new Date().toISOString(),p=1;if(p+=t.length,o&&(p+=r.length),i&&t.length>a){let v=Math.ceil(t.length/a);p+=v-1;}let g=p>s;if(m.push({loc:`${d}${x}`,lastmod:pe(t),changefreq:l.homePage??"daily",priority:c.homePage??1}),t.forEach(v=>{if(m.length>=s)return;let I=ie(v,n.canonical);m.push({loc:I,lastmod:v.updatedAt,changefreq:l.articles??"monthly",priority:c.articles??.8});}),o&&r.forEach(v=>{if(m.length>=s)return;let I=`${d}${R(x,v.slug)}`,G=t.filter(fe=>fe.author?.id===v.id),oe=pe(G);m.push({loc:I,lastmod:oe,changefreq:l.authorPages??"weekly",priority:c.authorPages??.6});}),i&&t.length>a){let v=Math.ceil(t.length/a);for(let I=2;I<=v&&!(m.length>=s);I++)m.push({loc:`${d}${x}?page=${I}`,lastmod:pe(t),changefreq:l.paginationPages??"daily",priority:c.paginationPages??.5});}return {entries:m,totalEntries:m.length,truncated:g,generatedAt:h,baseUrl:d}}function rr(e){let t='<?xml version="1.0" encoding="UTF-8"?>',r='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',n="</urlset>",o=e.entries.map(i=>{let a=[];return a.push(" <url>"),a.push(` <loc>${Re(i.loc)}</loc>`),i.lastmod&&a.push(` <lastmod>${Re(i.lastmod)}</lastmod>`),i.changefreq&&a.push(` <changefreq>${Re(i.changefreq)}</changefreq>`),i.priority!==void 0&&a.push(` <priority>${i.priority.toFixed(1)}</priority>`),a.push(" </url>"),a.join(`
142
142
  `)});return [t,r,...o,n].join(`
143
- `)}function si(e,t){let r='<?xml version="1.0" encoding="UTF-8"?>',n='<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',o="</sitemapindex>",i=e.map(a=>{let s=[];return s.push(" <sitemap>"),s.push(` <loc>${ye(a.url)}</loc>`),a.lastmod&&s.push(` <lastmod>${ye(a.lastmod)}</lastmod>`),s.push(" </sitemap>"),s.join(`
143
+ `)}function ki(e,t){let r='<?xml version="1.0" encoding="UTF-8"?>',n='<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',o="</sitemapindex>",i=e.map(a=>{let s=[];return s.push(" <sitemap>"),s.push(` <loc>${Re(a.url)}</loc>`),a.lastmod&&s.push(` <lastmod>${Re(a.lastmod)}</lastmod>`),s.push(" </sitemap>"),s.join(`
144
144
  `)});return [r,n,...i,o].join(`
145
- `)}function li(e){let t=[],r=[];e.entries.length===0?t.push("Sitemap must contain at least one URL"):e.entries.length>5e4&&t.push("Sitemap contains more than 50,000 URLs (Google limit)"),e.truncated&&r.push("Sitemap was truncated due to size limits"),e.entries.forEach((o,i)=>{try{new URL(o.loc);}catch{t.push(`Invalid URL at entry ${i+1}: ${o.loc}`);}o.priority!==void 0&&(o.priority<0||o.priority>1)&&t.push(`Invalid priority at entry ${i+1}: must be between 0.0 and 1.0`),o.lastmod&&!di(o.lastmod)&&t.push(`Invalid lastmod date at entry ${i+1}: ${o.lastmod}`),o.loc.length>2048&&r.push(`URL at entry ${i+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(o=>{let i=n.get(o.loc)??0;n.set(o.loc,i+1);}),n.forEach((o,i)=>{o>1&&t.push(`Duplicate URL found: ${i} (appears ${o} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function ae(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let o=new Date(n.updatedAt);return o>r?o:r},new Date(e[0].updatedAt)).toISOString()}function ci(e,t,r=[],n={}){return async function(){let a=(await st(e,t,r,n)).map(c=>({loc:c.url,lastmod:typeof c.lastModified=="string"?c.lastModified:c.lastModified?.toISOString(),changefreq:c.changeFrequency,priority:c.priority})),s={entries:a,totalEntries:a.length,generatedAt:new Date().toISOString(),baseUrl:oe(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=Gt(s);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function ui(e){return async function(){let r=await e.getSite(),n=await e.getArticles(),o=e.getAuthors?await e.getAuthors():[];return st(r,n,o,e.options)}}function ye(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function di(e){try{let t=new Date(e),r=t.toISOString(),n=e.endsWith("Z")&&!e.includes(".")?e.replace("Z",".000Z"):e;return r===n&&!isNaN(t.getTime())}catch{return false}}var se={name:"@xexr/blog-platform",version:"1.0.10"};function Vt(e){let r=e.replace(/^v/,"").split(".");if(r.length<3)throw new Error(`Invalid version format: ${e}`);let n=parseInt(r[0]??"0",10),o=parseInt(r[1]??"0",10),i=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(o)||isNaN(i))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:o,patch:i}}function D(){let e=Vt(se.version);return {name:se.name,version:se.version,...e}}function W(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let a=Vt(i),s={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=s:o==="platform"&&(r.platformVersion=s);}return r}catch{return null}}function Ft(e,t){try{return e.major!==t.major?{compatible:!1,errorCode:"PUB009",errorMessage:`Major version incompatibility: ${e.name} ${e.version} is not compatible with ${t.name} ${t.version}. Please upgrade.`}:e.minor!==t.minor?{compatible:!0,errorCode:"PUB010",warning:`Minor version difference: ${e.name} ${e.version} with ${t.name} ${t.version}. Some features may not be available.`}:{compatible:!0}}catch(r){return {compatible:false,errorMessage:`Failed to check version compatibility: ${r instanceof Error?r.message:"Unknown error"}`}}}var qt={enableCSP:true,cspDirectives:{"default-src":"'self'","script-src":"'self' 'unsafe-inline'","style-src":"'self' 'unsafe-inline'","img-src":"'self' data: https:","font-src":"'self' https:","connect-src":"'self'","media-src":"'self'","object-src":"'none'","base-uri":"'self'","form-action":"'self'","frame-ancestors":"'none'","upgrade-insecure-requests":""},enableFrameOptions:true,frameOptions:"DENY",enableContentTypeOptions:true,enableXSSProtection:true,enableReferrerPolicy:true,referrerPolicy:"strict-origin-when-cross-origin",enableHSTS:true,hstsMaxAge:31536e3,hstsIncludeSubdomains:true,enablePermissionsPolicy:true,permissionsPolicyDirectives:{camera:"()",microphone:"()",geolocation:"()",payment:"()",usb:"()",accelerometer:"()",gyroscope:"()",magnetometer:"()"}};function pi(){let e=process.env.BLOG_PLATFORM_DISABLE_CSP==="true",t=process.env.BLOG_PLATFORM_FRAME_OPTIONS,r=process.env.BLOG_PLATFORM_DISABLE_HSTS==="true";return {...qt,enableCSP:!e,frameOptions:t??qt.frameOptions,enableHSTS:!r}}function gi(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function fi(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function hi(e,t={}){let r={...pi(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=gi(o);}if(r.enableFrameOptions&&(n["X-Frame-Options"]=r.frameOptions),r.enableContentTypeOptions&&(n["X-Content-Type-Options"]="nosniff"),r.enableXSSProtection&&(n["X-XSS-Protection"]="1; mode=block"),r.enableReferrerPolicy&&(n["Referrer-Policy"]=r.referrerPolicy),r.enableHSTS&&bi(e)){let o=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=o;}if(r.enablePermissionsPolicy){let o={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=fi(o);}return n}function bi(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function Oe(e,t={}){return hi(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var Xt={allowedOrigins:["http://localhost:3000","https://localhost:3000","http://127.0.0.1:3000","https://127.0.0.1:3000"],allowWildcard:false,allowCredentials:false,maxAge:86400,securityConfig:{}};function Wt(){let e=process.env.BLOG_PLATFORM_ALLOWED_ORIGINS,t=process.env.BLOG_PLATFORM_ALLOW_WILDCARD==="true",r=process.env.BLOG_PLATFORM_ALLOW_CREDENTIALS==="true";return {...Xt,allowedOrigins:e?e.split(",").map(n=>n.trim()):Xt.allowedOrigins,allowWildcard:t,allowCredentials:r}}function Kt(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function Jt(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&Kt(r,t)&&(n["Access-Control-Allow-Origin"]=r),t.allowCredentials&&!t.allowWildcard&&(n["Access-Control-Allow-Credentials"]="true"),t.allowWildcard||(n.Vary="Origin"),n}function xi(e,t,r,n){return {...Jt(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var yi=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function v(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,a={...Wt(),...i},s=Jt(e,a),l=Oe(e,a.securityConfig),c={"Content-Type":"application/json",...s,...l,...o};return NextResponse.json(t,{status:n,headers:c})}function ve(e,t,r={}){let{allowedHeaders:n=yi,corsConfig:o={}}=r,i={...Wt(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!Kt(a,i)){let c=Oe(e,i.securityConfig);return new NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...c}})}let s=xi(e,i,[...t,"OPTIONS"],n),l=Oe(e,i.securityConfig);return new NextResponse(null,{status:200,headers:{...s,...l}})}async function vi(e){try{let t=await G(e);if(!t.authenticated){let g=await X(e);return v(e,g.error,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit,A=g&&typeof g=="object"&&"limit"in g&&"remaining"in g&&"reset"in g&&"count"in g&&"success"in g?g:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},E=_(A);return v(e,n.errorResponse,{status:429,headers:E})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Pi(i);if(a.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let g=W(s);if(g?.platformVersion){let A=D();if(g.platformVersion.major!==A.major)return v(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:A.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(i.dryRun){let g=[];return i.article.wordCount<50&&g.push("Article has fewer than 50 words, which may affect SEO"),(!i.article.excerpt||i.article.excerpt.length<120)&&g.push("Article excerpt is shorter than recommended 120 characters"),i.article.meta.keywords.length||g.push("No SEO keywords provided"),v(e,{success:!0,warnings:g,idempotencyKey:i.idempotencyKey},{status:200})}let l={...i.article,slug:i.slug??i.article.slug,meta:{...i.article.meta,description:i.metaDescription??i.article.meta.description}};if(!ct(l.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let d=await H().saveArticle(l,i.idempotencyKey),m=D(),y=_(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...y};d.success&&(h.Location=d.url??`/${l.slug}`);let p=d.success?201:d.error?.code==="PUB003"?409:400;return v(e,d,{status:p,headers:h})}catch(t){return console.error("Publish endpoint error:",t),v(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function Pi(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;if((!r.article||typeof r.article!="object")&&t.push("Missing required field: article"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.article&&typeof r.article=="object"){let n=r.article,o=["id","slug","title","content","publishedAt","site"];for(let i of o)n[i]||t.push(`Missing required article field: ${i}`);if(n.site&&typeof n.site=="object"){let i=n.site,a=["id","name","domain"];for(let s of a)i[s]||t.push(`Missing required site field: ${s}`);}if(n.meta&&typeof n.meta=="object"){let i=n.meta;Array.isArray(i.keywords)||t.push("Article meta.keywords must be an array");}}return t}function ct(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function wi(e){try{let t=await G(e);if(!t.authenticated){let p=await X(e);return NextResponse.json(p.error,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,g=p&&typeof p=="object"&&"limit"in p&&"remaining"in p&&"reset"in p&&"count"in p&&"success"in p?p:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},A=_(g);return v(e,n.errorResponse,{status:429,headers:A})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Si(i);if(a.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let p=W(s);if(p?.platformVersion){let g=D();if(p.platformVersion.major!==g.major)return v(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:g.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(!Ni(i.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});if(i.dryRun){let g=await H().getArticle(i.slug),A=[];return g||A.push("Article with this slug does not exist"),v(e,{success:!0,warnings:A,idempotencyKey:i.idempotencyKey},{status:200})}let c=await H().removeArticle(i.slug,i.idempotencyKey),d=D(),m=_(n.rateLimitResult),y={"X-Bloggy-Version":`platform/${d.version}`,"X-Idempotency-Key":i.idempotencyKey,...m},h=c.success?200:c.error?.code==="PUB007"?404:400;return v(e,c,{status:h,headers:y})}catch(t){return console.error("Unpublish endpoint error:",t),v(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function Si(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;return (!r.slug||typeof r.slug!="string")&&t.push("Missing required field: slug"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.slug&&typeof r.slug=="string"&&!r.slug.trim()&&t.push("Slug cannot be empty"),t}function Ni(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Ri(e){try{let t=await G(e);if(!t.authenticated){let m=await X(e),y={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:m.error?.error?.message??"Authentication required"}};return v(e,y,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let m=n.errorResponse.error?.details?.rateLimit,y=m&&typeof m=="object"&&"limit"in m&&"remaining"in m&&"reset"in m&&"count"in m&&"success"in m?m:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=_(y),p={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:n.errorResponse.error?.message??"Rate limit exceeded"}};return v(e,p,{status:429,headers:h})}let o=D(),i=e.headers.get("X-Bloggy-Version"),a={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(i)try{if(/^\d+\.\d+\.\d+/.test(i)){let m=i.split("."),y=parseInt(m[0]??"0",10),h=parseInt(m[1]??"0",10),p=parseInt(m[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:y,minor:h,patch:p};}else {let m=W(i);m?.bloggyVersion&&(a=m.bloggyVersion);}}catch(m){console.warn("Failed to parse X-Bloggy-Version header:",m);}let s={compatible:!0};a.version!=="unknown"&&(s=Ft(a,o));let l={success:!0,versions:{bloggy:a,platform:o},compatibility:s},c=_(n.rateLimitResult),d={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...c};return v(e,l,{status:200,headers:d})}catch(t){console.error("Version endpoint error:",t);let r={success:false,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:false,errorMessage:"Internal server error while checking version compatibility"},error:t instanceof Error?t.message:"Unknown error"};return v(e,r,{status:500})}}async function Ci(e,{params:t}){try{let{slug:r}=await t,n=await G(e);if(!n.authenticated){let g=await X(e);return NextResponse.json(g.error,{status:401})}let o=n.token??"anonymous",i=await V(o);if(!i.allowed){let g=i.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},A=_(g);return v(e,i.errorResponse,{status:429,headers:A})}if(!r||!ct(r))return v(e,{exists:!1,error:{code:"PUB002",message:"Invalid slug format. Must be lowercase letters, numbers, and hyphens only."}},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let g=W(a);if(g?.platformVersion){let A=D();if(g.platformVersion.major!==A.major)return v(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:A.version}}},{status:409})}}let c=await H().getArticle(r)!==null,d={exists:c,...c&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},m=D(),y=_(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${m.version}`,...y},p=e.headers.get("X-Idempotency-Key");return p&&(h["X-Idempotency-Key"]=p,console.log(`Slug check for idempotency: ${p}, exists: ${c}`)),v(e,d,{status:200,headers:h})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),v(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function Ii(e){return ve(e,["GET"])}var Is=se.version;
146
- export{Ie as ApiKeyAuth,Lt as BlogArticlePage,Bt as BlogAuthorPage,kn as BlogAuthorsIndexPage,yt as BlogHomePage,Cn as BlogTopicArchivePage,Tn as BlogTopicsIndexPage,ir as Button,me as Card,pe as CardContent,Lr as CardDescription,kr as CardFooter,Cr as CardHeader,Ir as CardTitle,at as DrizzleStorage,ne as EnvAuth,Te as InMemoryStorage,be as NoAuth,Is as PACKAGE_VERSION,ee as Pagination,Me as PaginationContent,Ae as PaginationEllipsis,z as PaginationItem,K as PaginationLink,De as PaginationNext,$e as PaginationPrevious,Ee as ShadcnPagination,ce as StructuredDataError,Le as UninitializedAuth,ot as autoConfigureRateLimit,w as bpArticles,ie as bpOperations,R as buildAuthorPath,I as buildBlogPath,Pe as buttonVariants,Dt as checkRateLimit,f as cn,_e as configureRateLimit,ci as createBlogSitemapRoute,ui as createDynamicBlogSitemap,Ut as createRateLimitErrorResponse,J as createStructuredDataScript,V as enforceRateLimit,gr as extractKeywordsFromArticle,Fe as extractTableOfContents,nt as extractTokenFromHeader,Ve as formatArticleDateMeta,un as generateArticleMetadata,we as generateArticleStructuredData,vn as generateAuthorPageMetadata,Se as generateAuthorStructuredData,Sr as generateBlogHomeMetadata,Ge as generateBlogHomeStructuredData,st as generateBlogSitemapEntries,dt as generateBreadcrumbStructuredData,Z as generateCanonicalUrl,Qn as generateCanonicalUrlFromSlug,ze as generateCompleteArticleStructuredData,He as generateOrganizationStructuredData,mr as generatePaginationMetadata,ri as generateSiteMetadata,ai as generateSitemap,si as generateSitemapIndex,je as generateWebSiteStructuredData,tt as getAllTopics,Sn as getArticlePrimaryTopic,it as getAuthConfig,Ot as getAuthorArchive,et as getAuthorsFromArticles,ei as getBaseUrl,O as getBlogThemeStyle,Yn as getDrizzleAdapterSql,pr as getPathPrefixFromBlogUrl,_ as getRateLimitHeaders,H as getStorage,rt as getTopicArchive,Be as initBlogPlatform,zn as initBlogPlatformDev,jn as initBlogPlatformOnce,Gn as initBlogPlatformProd,En as initEnvAuth,Zn as isValidCanonicalUrl,wn as loadAuthorArchive,ii as metadataToHtml,C as normalizeBlogBasePath,oe as normalizeDomain,zt as normalizeSlug,vi as publishHandler,fr as safeGenerateArticleStructuredData,ke as setAuthConfig,Ze as setStorage,$n as shouldSkipAuth,Gt as sitemapToXml,Ci as slugExistsHandler,Ii as slugExistsOptionsHandler,pt as structuredDataToJsonLd,wi as unpublishHandler,ti as updateArticleCanonicalUrl,dr as usePagination,oi as validateMetadata,li as validateSitemap,mt as validateStructuredData,Ri as versionHandler};//# sourceMappingURL=index.mjs.map
145
+ `)}function _i(e){let t=[],r=[];e.entries.length===0?t.push("Sitemap must contain at least one URL"):e.entries.length>5e4&&t.push("Sitemap contains more than 50,000 URLs (Google limit)"),e.truncated&&r.push("Sitemap was truncated due to size limits"),e.entries.forEach((o,i)=>{try{new URL(o.loc);}catch{t.push(`Invalid URL at entry ${i+1}: ${o.loc}`);}o.priority!==void 0&&(o.priority<0||o.priority>1)&&t.push(`Invalid priority at entry ${i+1}: must be between 0.0 and 1.0`),o.lastmod&&!Ei(o.lastmod)&&t.push(`Invalid lastmod date at entry ${i+1}: ${o.lastmod}`),o.loc.length>2048&&r.push(`URL at entry ${i+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(o=>{let i=n.get(o.loc)??0;n.set(o.loc,i+1);}),n.forEach((o,i)=>{o>1&&t.push(`Duplicate URL found: ${i} (appears ${o} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function pe(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let o=new Date(n.updatedAt);return o>r?o:r},new Date(e[0].updatedAt)).toISOString()}function Bi(e,t,r=[],n={}){return async function(){let a=(await xt(e,t,r,n)).map(c=>({loc:c.url,lastmod:typeof c.lastModified=="string"?c.lastModified:c.lastModified?.toISOString(),changefreq:c.changeFrequency,priority:c.priority})),s={entries:a,totalEntries:a.length,generatedAt:new Date().toISOString(),baseUrl:me(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=rr(s);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function Oi(e){return async function(){let r=await e.getSite(),n=await e.getArticles(),o=e.getAuthors?await e.getAuthors():[];return xt(r,n,o,e.options)}}function Re(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Ei(e){try{let t=new Date(e),r=t.toISOString(),n=e.endsWith("Z")&&!e.includes(".")?e.replace("Z",".000Z"):e;return r===n&&!isNaN(t.getTime())}catch{return false}}var ge={name:"@xexr/blog-platform",version:"1.0.12"};function nr(e){let r=e.replace(/^v/,"").split(".");if(r.length<3)throw new Error(`Invalid version format: ${e}`);let n=parseInt(r[0]??"0",10),o=parseInt(r[1]??"0",10),i=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(o)||isNaN(i))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:o,patch:i}}function H(){let e=nr(ge.version);return {name:ge.name,version:ge.version,...e}}function Z(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let a=nr(i),s={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=s:o==="platform"&&(r.platformVersion=s);}return r}catch{return null}}function ir(e,t){try{return e.major!==t.major?{compatible:!1,errorCode:"PUB009",errorMessage:`Major version incompatibility: ${e.name} ${e.version} is not compatible with ${t.name} ${t.version}. Please upgrade.`}:e.minor!==t.minor?{compatible:!0,errorCode:"PUB010",warning:`Minor version difference: ${e.name} ${e.version} with ${t.name} ${t.version}. Some features may not be available.`}:{compatible:!0}}catch(r){return {compatible:false,errorMessage:`Failed to check version compatibility: ${r instanceof Error?r.message:"Unknown error"}`}}}var or={enableCSP:true,cspDirectives:{"default-src":"'self'","script-src":"'self' 'unsafe-inline'","style-src":"'self' 'unsafe-inline'","img-src":"'self' data: https:","font-src":"'self' https:","connect-src":"'self'","media-src":"'self'","object-src":"'none'","base-uri":"'self'","form-action":"'self'","frame-ancestors":"'none'","upgrade-insecure-requests":""},enableFrameOptions:true,frameOptions:"DENY",enableContentTypeOptions:true,enableXSSProtection:true,enableReferrerPolicy:true,referrerPolicy:"strict-origin-when-cross-origin",enableHSTS:true,hstsMaxAge:31536e3,hstsIncludeSubdomains:true,enablePermissionsPolicy:true,permissionsPolicyDirectives:{camera:"()",microphone:"()",geolocation:"()",payment:"()",usb:"()",accelerometer:"()",gyroscope:"()",magnetometer:"()"}};function $i(){let e=process.env.BLOG_PLATFORM_DISABLE_CSP==="true",t=process.env.BLOG_PLATFORM_FRAME_OPTIONS,r=process.env.BLOG_PLATFORM_DISABLE_HSTS==="true";return {...or,enableCSP:!e,frameOptions:t??or.frameOptions,enableHSTS:!r}}function Di(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function Ui(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Hi(e,t={}){let r={...$i(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=Di(o);}if(r.enableFrameOptions&&(n["X-Frame-Options"]=r.frameOptions),r.enableContentTypeOptions&&(n["X-Content-Type-Options"]="nosniff"),r.enableXSSProtection&&(n["X-XSS-Protection"]="1; mode=block"),r.enableReferrerPolicy&&(n["Referrer-Policy"]=r.referrerPolicy),r.enableHSTS&&Gi(e)){let o=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=o;}if(r.enablePermissionsPolicy){let o={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=Ui(o);}return n}function Gi(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function ze(e,t={}){return Hi(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var ar={allowedOrigins:["http://localhost:3000","https://localhost:3000","http://127.0.0.1:3000","https://127.0.0.1:3000"],allowWildcard:false,allowCredentials:false,maxAge:86400,securityConfig:{}};function sr(){let e=process.env.BLOG_PLATFORM_ALLOWED_ORIGINS,t=process.env.BLOG_PLATFORM_ALLOW_WILDCARD==="true",r=process.env.BLOG_PLATFORM_ALLOW_CREDENTIALS==="true";return {...ar,allowedOrigins:e?e.split(",").map(n=>n.trim()):ar.allowedOrigins,allowWildcard:t,allowCredentials:r}}function lr(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function cr(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&lr(r,t)&&(n["Access-Control-Allow-Origin"]=r),t.allowCredentials&&!t.allowWildcard&&(n["Access-Control-Allow-Credentials"]="true"),t.allowWildcard||(n.Vary="Origin"),n}function ji(e,t,r,n){return {...cr(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var Fi=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function P(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,a={...sr(),...i},s=cr(e,a),l=ze(e,a.securityConfig),c={"Content-Type":"application/json",...s,...l,...o};return NextResponse.json(t,{status:n,headers:c})}function Ce(e,t,r={}){let{allowedHeaders:n=Fi,corsConfig:o={}}=r,i={...sr(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!lr(a,i)){let c=ze(e,i.securityConfig);return new NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...c}})}let s=ji(e,i,[...t,"OPTIONS"],n),l=ze(e,i.securityConfig);return new NextResponse(null,{status:200,headers:{...s,...l}})}async function zi(e){try{let t=await W(e);if(!t.authenticated){let g=await Q(e);return P(e,g.error,{status:401})}let r=z(t.token??"anonymous"),n=await K(r);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit,v=g&&typeof g=="object"&&"limit"in g&&"remaining"in g&&"reset"in g&&"count"in g&&"success"in g?g:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},I=O(v);return P(e,n.errorResponse,{status:429,headers:I})}if(!e.headers.get("content-type")?.includes("application/json"))return P(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Vi(i);if(a.length>0)return P(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let g=Z(s);if(g?.platformVersion){let v=H();if(g.platformVersion.major!==v.major)return P(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:v.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(i.dryRun){let g=[];return i.article.wordCount<50&&g.push("Article has fewer than 50 words, which may affect SEO"),(!i.article.excerpt||i.article.excerpt.length<120)&&g.push("Article excerpt is shorter than recommended 120 characters"),i.article.meta.keywords.length||g.push("No SEO keywords provided"),P(e,{success:!0,warnings:g,idempotencyKey:i.idempotencyKey},{status:200})}let l={...i.article,slug:i.slug??i.article.slug,meta:{...i.article.meta,description:i.metaDescription??i.article.meta.description}};if(!vt(l.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let m=await F().saveArticle(l,i.idempotencyKey),d=H(),x=O(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${d.version}`,"X-Idempotency-Key":i.idempotencyKey,...x};m.success&&(h.Location=m.url??`/${l.slug}`);let p=m.success?201:m.error?.code==="PUB003"?409:400;return P(e,m,{status:p,headers:h})}catch(t){return console.error("Publish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function Vi(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;if((!r.article||typeof r.article!="object")&&t.push("Missing required field: article"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.article&&typeof r.article=="object"){let n=r.article,o=["id","slug","title","content","publishedAt","site"];for(let i of o)n[i]||t.push(`Missing required article field: ${i}`);if(n.site&&typeof n.site=="object"){let i=n.site,a=["id","name","domain"];for(let s of a)i[s]||t.push(`Missing required site field: ${s}`);}if(n.meta&&typeof n.meta=="object"){let i=n.meta;Array.isArray(i.keywords)||t.push("Article meta.keywords must be an array");}}return t}function vt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Xi(e){try{let t=await W(e);if(!t.authenticated){let p=await Q(e);return NextResponse.json(p.error,{status:401})}let r=z(t.token??"anonymous"),n=await K(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,g=p&&typeof p=="object"&&"limit"in p&&"remaining"in p&&"reset"in p&&"count"in p&&"success"in p?p:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},v=O(g);return P(e,n.errorResponse,{status:429,headers:v})}if(!e.headers.get("content-type")?.includes("application/json"))return P(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Wi(i);if(a.length>0)return P(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let p=Z(s);if(p?.platformVersion){let g=H();if(p.platformVersion.major!==g.major)return P(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:g.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(!Ki(i.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});if(i.dryRun){let g=await F().getArticle(i.slug),v=[];return g||v.push("Article with this slug does not exist"),P(e,{success:!0,warnings:v,idempotencyKey:i.idempotencyKey},{status:200})}let c=await F().removeArticle(i.slug,i.idempotencyKey),m=H(),d=O(n.rateLimitResult),x={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...d},h=c.success?200:c.error?.code==="PUB007"?404:400;return P(e,c,{status:h,headers:x})}catch(t){return console.error("Unpublish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function Wi(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;return (!r.slug||typeof r.slug!="string")&&t.push("Missing required field: slug"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.slug&&typeof r.slug=="string"&&!r.slug.trim()&&t.push("Slug cannot be empty"),t}function Ki(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Ji(e){try{let t=await W(e);if(!t.authenticated){let d=await Q(e),x={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:d.error?.error?.message??"Authentication required"}};return P(e,x,{status:401})}let r=z(t.token??"anonymous"),n=await K(r);if(!n.allowed){let d=n.errorResponse.error?.details?.rateLimit,x=d&&typeof d=="object"&&"limit"in d&&"remaining"in d&&"reset"in d&&"count"in d&&"success"in d?d:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=O(x),p={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:n.errorResponse.error?.message??"Rate limit exceeded"}};return P(e,p,{status:429,headers:h})}let o=H(),i=e.headers.get("X-Bloggy-Version"),a={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(i)try{if(/^\d+\.\d+\.\d+/.test(i)){let d=i.split("."),x=parseInt(d[0]??"0",10),h=parseInt(d[1]??"0",10),p=parseInt(d[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:x,minor:h,patch:p};}else {let d=Z(i);d?.bloggyVersion&&(a=d.bloggyVersion);}}catch(d){console.warn("Failed to parse X-Bloggy-Version header:",d);}let s={compatible:!0};a.version!=="unknown"&&(s=ir(a,o));let l={success:!0,versions:{bloggy:a,platform:o},compatibility:s},c=O(n.rateLimitResult),m={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...c};return P(e,l,{status:200,headers:m})}catch(t){console.error("Version endpoint error:",t);let r={success:false,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:false,errorMessage:"Internal server error while checking version compatibility"},error:t instanceof Error?t.message:"Unknown error"};return P(e,r,{status:500})}}async function Qi(e,{params:t}){try{let{slug:r}=await t,n=await W(e);if(!n.authenticated){let g=await Q(e);return NextResponse.json(g.error,{status:401})}let o=z(n.token??"anonymous"),i=await K(o);if(!i.allowed){let g=i.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},v=O(g);return P(e,i.errorResponse,{status:429,headers:v})}if(!r||!vt(r))return P(e,{exists:!1,error:{code:"PUB002",message:"Invalid slug format. Must be lowercase letters, numbers, and hyphens only."}},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let g=Z(a);if(g?.platformVersion){let v=H();if(g.platformVersion.major!==v.major)return P(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:v.version}}},{status:409})}}let c=await F().getArticle(r)!==null,m={exists:c,...c&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},d=H(),x=O(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${d.version}`,...x},p=e.headers.get("X-Idempotency-Key");return p&&(h["X-Idempotency-Key"]=p,console.log(`Slug check for idempotency: ${p}, exists: ${c}`)),P(e,m,{status:200,headers:h})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),P(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function Zi(e){return Ce(e,["GET"])}var sl=ge.version;
146
+ export{Ue as ApiKeyAuth,Ft as BlogArticlePage,qt as BlogAuthorPage,ei as BlogAuthorsIndexPage,_t as BlogHomePage,Yn as BlogTopicArchivePage,Jn as BlogTopicsIndexPage,br as Button,ve as Card,Pe as CardContent,Zr as CardDescription,en as CardFooter,Yr as CardHeader,Qr as CardTitle,bt as DrizzleStorage,ue as EnvAuth,$e as InMemoryStorage,Oe as NEWSLETTER_SUCCESS_MESSAGE,xe as NewsletterSignup,Ne as NoAuth,sl as PACKAGE_VERSION,ae as Pagination,qe as PaginationContent,Ie as PaginationEllipsis,q as PaginationItem,ee as PaginationLink,We as PaginationNext,Xe as PaginationPrevious,Ve as ShadcnPagination,be as StructuredDataError,He as UninitializedAuth,ht as autoConfigureRateLimit,w as bpArticles,de as bpOperations,R as buildAuthorPath,T as buildBlogPath,Le as buttonVariants,Yt as checkRateLimit,f as cn,je as configureRateLimit,Bi as createBlogSitemapRoute,Oi as createDynamicBlogSitemap,Qt as createRateLimitErrorResponse,te as createStructuredDataScript,z as createTokenFingerprint,K as enforceRateLimit,Rr as extractKeywordsFromArticle,tt as extractTableOfContents,gt as extractTokenFromHeader,et as formatArticleDateMeta,Bn as generateArticleMetadata,ke as generateArticleStructuredData,Fn as generateAuthorPageMetadata,_e as generateAuthorStructuredData,Xr as generateBlogHomeMetadata,Ze as generateBlogHomeStructuredData,xt as generateBlogSitemapEntries,wt as generateBreadcrumbStructuredData,ie as generateCanonicalUrl,Ai as generateCanonicalUrlFromSlug,Qe as generateCompleteArticleStructuredData,Je as generateOrganizationStructuredData,Nr as generatePaginationMetadata,Ti as generateSiteMetadata,Ii as generateSitemap,ki as generateSitemapIndex,Ye as generateWebSiteStructuredData,mt as getAllTopics,Xn as getArticlePrimaryTopic,ft as getAuthConfig,Xt as getAuthorArchive,dt as getAuthorsFromArticles,Si as getBaseUrl,M as getBlogThemeStyle,Pi as getDrizzleAdapterSql,Tr as getPathPrefixFromBlogUrl,O as getRateLimitHeaders,F as getStorage,pt as getTopicArchive,Fe as initBlogPlatform,mi as initBlogPlatformDev,di as initBlogPlatformOnce,pi as initBlogPlatformProd,oi as initEnvAuth,wi as isValidCanonicalUrl,qn as loadAuthorArchive,Ci as metadataToHtml,k as normalizeBlogBasePath,me as normalizeDomain,tr as normalizeSlug,zi as publishHandler,Cr as safeGenerateArticleStructuredData,Ge as setAuthConfig,ut as setStorage,si as shouldSkipAuth,rr as sitemapToXml,Qi as slugExistsHandler,Zi as slugExistsOptionsHandler,Nt as structuredDataToJsonLd,Xi as unpublishHandler,Ni as updateArticleCanonicalUrl,Sr as usePagination,Li as validateMetadata,_i as validateSitemap,St as validateStructuredData,Ji as versionHandler};//# sourceMappingURL=index.mjs.map
147
147
  //# sourceMappingURL=index.mjs.map