@xexr/blog-platform 1.1.4 → 1.1.7

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/app/blog/[slug]/page.tsx +10 -3
  3. package/dist/app/blog/page.tsx +12 -11
  4. package/dist/app/blog/series/[slug]/page.d.ts +28 -0
  5. package/dist/app/blog/series/[slug]/page.tsx +39 -0
  6. package/dist/app/blog/series/page.d.ts +24 -0
  7. package/dist/app/blog/series/page.tsx +28 -0
  8. package/dist/components/ArchiveStructuredData.tsx +61 -0
  9. package/dist/components/SeriesArchivePages.tsx +222 -0
  10. package/dist/components/SeriesNavigation.tsx +117 -0
  11. package/dist/components/TopicArchivePages.test.ts +52 -4
  12. package/dist/components/TopicArchivePages.tsx +14 -4
  13. package/dist/{index-Dr8HaKGm.d.mts → index-DsXjuPn4.d.mts} +45 -1
  14. package/dist/{index-Dr8HaKGm.d.ts → index-DsXjuPn4.d.ts} +45 -1
  15. package/dist/index.d.mts +86 -5
  16. package/dist/index.d.ts +86 -5
  17. package/dist/index.js +14 -14
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +14 -14
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/lib/related-articles.d.mts +3 -2
  22. package/dist/lib/related-articles.d.ts +3 -2
  23. package/dist/lib/series.ts +55 -0
  24. package/dist/lib/sitemap.ts +78 -46
  25. package/dist/lib/storage/drizzle.ts +9 -0
  26. package/dist/lib/structured-data.ts +10 -11
  27. package/dist/lib/urls.ts +7 -0
  28. package/dist/{sitemap-BmCh8BpN.d.ts → sitemap-B64QGT4l.d.ts} +11 -4
  29. package/dist/{sitemap-Dbl4CUGI.d.mts → sitemap-Dy7Q4ATM.d.mts} +11 -4
  30. package/dist/sitemap.d.mts +2 -2
  31. package/dist/sitemap.d.ts +2 -2
  32. package/dist/sitemap.js +5 -5
  33. package/dist/sitemap.js.map +1 -1
  34. package/dist/sitemap.mjs +5 -5
  35. package/dist/sitemap.mjs.map +1 -1
  36. package/dist/types/contracts.ts +61 -0
  37. package/dist/types/index.d.mts +1 -1
  38. package/dist/types/index.d.ts +1 -1
  39. package/package.json +12 -13
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';var ee=require('next/link.js'),mt=require('next/image.js'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),dateFns=require('date-fns'),Ge=require('react'),rsc=require('next-mdx-remote-client/rsc'),fa6=require('react-icons/fa6'),ft=require('@radix-ui/react-separator'),Dn=require('rehype-raw'),Un=require('rehype-sanitize'),Hn=require('remark-gfm'),jn=require('remark-toc'),Fn=require('rehype-slug'),crypto=require('crypto'),ratelimit=require('@upstash/ratelimit'),redis=require('@upstash/redis'),drizzleOrm=require('drizzle-orm'),sqliteCore=require('drizzle-orm/sqlite-core'),server_js=require('next/server.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ee__default=/*#__PURE__*/_interopDefault(ee);var mt__default=/*#__PURE__*/_interopDefault(mt);var Ge__namespace=/*#__PURE__*/_interopNamespace(Ge);var ft__namespace=/*#__PURE__*/_interopNamespace(ft);var Dn__default=/*#__PURE__*/_interopDefault(Dn);var Un__default=/*#__PURE__*/_interopDefault(Un);var Hn__default=/*#__PURE__*/_interopDefault(Hn);var jn__default=/*#__PURE__*/_interopDefault(jn);var Fn__default=/*#__PURE__*/_interopDefault(Fn);function b(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var $e=classVarianceAuthority.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 Dr({className:e,variant:t,size:r,asChild:n=false,...o}){return jsxRuntime.jsx(n?reactSlot.Slot:"button",{"data-slot":"button",className:b($e({variant:t,size:r,className:e})),...o})}function et({className:e,...t}){return jsxRuntime.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:b("mx-auto flex w-full justify-center",e),...t})}function tt({className:e,...t}){return jsxRuntime.jsx("ul",{"data-slot":"pagination-content",className:b("flex flex-row items-center gap-1",e),...t})}function Z({...e}){return jsxRuntime.jsx("li",{"data-slot":"pagination-item",...e})}function oe({className:e,isActive:t,size:r="icon",...n}){return jsxRuntime.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:b($e({variant:t?"outline":"ghost",size:r}),e),...n})}function rt({className:e,...t}){return jsxRuntime.jsxs(oe,{"aria-label":"Go to previous page",size:"default",className:b("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsxRuntime.jsx(lucideReact.ChevronLeftIcon,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function nt({className:e,...t}){return jsxRuntime.jsxs(oe,{"aria-label":"Go to next page",size:"default",className:b("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"}),jsxRuntime.jsx(lucideReact.ChevronRightIcon,{})]})}function De({className:e,...t}){return jsxRuntime.jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:b("flex size-9 items-center justify-center",e),...t,children:[jsxRuntime.jsx(lucideReact.MoreHorizontalIcon,{className:"size-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"More pages"})]})}function ge({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:o=5,showPrevNext:i=true,showFirstLast:a=true}){if(t<=1)return null;let c=()=>{let g=Math.floor(o/2),p=Math.max(1,e-g),x=Math.min(t,p+o-1);return x-p+1<o&&(p=Math.max(1,x-o+1)),{start:p,end:x}},{start:l,end:u}=c(),m=Array.from({length:u-l+1},(g,p)=>l+p),s=g=>g===1?r:`${r}?page=${g}`,f=e>1,h=e<t;return jsxRuntime.jsxs(et,{className:n,children:[jsxRuntime.jsxs(tt,{children:[a&&e>2&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Z,{children:jsxRuntime.jsx(oe,{href:s(1),"aria-label":"Go to first page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsxRuntime.jsx(Z,{children:jsxRuntime.jsx(De,{})})]}),i&&jsxRuntime.jsx(Z,{children:f?jsxRuntime.jsx(rt,{href:s(e-1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})})}),m.map(g=>jsxRuntime.jsx(Z,{children:jsxRuntime.jsx(oe,{href:s(g),isActive:g===e,children:g})},g)),i&&jsxRuntime.jsx(Z,{children:h?jsxRuntime.jsx(nt,{href:s(e+1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"})})}),a&&e<t-1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u<t-1&&jsxRuntime.jsx(Z,{children:jsxRuntime.jsx(De,{})}),jsxRuntime.jsx(Z,{children:jsxRuntime.jsx(oe,{href:s(t),"aria-label":"Go to last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxRuntime.jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function Vr(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:c=>Math.ceil(c/t)}}function qr(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 E(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function N(e,t){let r=E(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function _(e,t){return N(e,`authors/${t}`)}function Xr(e){let t=new URL(e);return E(t.pathname)}function Ue(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,isAccessibleForFree:i=true,includeOptionalProperties:a=true}=t,c=r??e.site.domain,l=r?`https://${c}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${c}${n}/${e.slug}`,u=e.author?He(e.author,{customDomain:r,pathPrefix:n}):void 0,m=ot(e.site,{customDomain:r,pathPrefix:n}),f=`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:u,publisher:m,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:f,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(g=>({"@type":"Thing",name:g}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function He(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}${_(n,e.slug)}`:_(n,e.slug);o.url=a;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(o.knowsAbout=[...e.toneAdjectives]),o}function ot(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 at(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,includeSearchAction:i=true}=t,c=`https://${r??e.domain}${n}`,l=ot(e,t),u={"@context":"https://schema.org","@type":"WebSite","@id":`${c}#website`,name:e.name,url:c,publisher:l};return e.description?.trim()&&(u.description=e.description),(o??e.locale)&&(u.inLanguage=o??e.locale),i&&(u.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${c}?search={search_term_string}`},"query-input":"required name=search_term_string"}),u}function $t(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 st(e,t={}){let r=[];r.push(Ue(e,t)),r.push(at(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($t(o,t)),r}function lt(e,t=[],r={}){let n=[];if(n.push(at(e,r)),t.length>0){let o=t.slice(0,5).map(i=>Ue(i,r));n.push(...o);}return n}function Dt(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 Ut(e){return JSON.stringify(e,null,0).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ae(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:Ut(e)}}}function Wr(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 Ne=class extends Error{constructor(r,n,o){super(r);this.code=n;this.details=o;this.name="StructuredDataError";}code;details};function Kr(e,t={}){try{let r=Ue(e,t),n=Dt(r);return n.isValid?{schema:r}:{error:new Ne("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new Ne("Failed to generate structured data","GENERATION_FAILED",r)}}}var V="bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text text-transparent",fe={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 j(e={}){return {"--blog-accent":e.accentColor??fe.accentColor,"--blog-accent-hover":e.accentHoverColor??fe.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??fe.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??fe.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??fe.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??fe.accentBorderColor}}function ct(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:dateFns.format(r,"d MMMM yyyy"),publishedRelativeLabel:dateFns.formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:dateFns.format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function ut(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=Yr(o[2]);i&&t.push({id:Qr(i),text:i,level:o[1].length});}return t}function jt(e){return `${e} ${e===1?"section":"sections"}`}function Ft(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function Yr(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function Qr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}var Fe="Thanks, you're on the list. We'll confirm before sending updates.";function Te({siteId:e,settings:t,sourceSurface:r,sourceArticleSlug:n,sourceUrl:o,previewMode:i=false,className:a}){let[c,l]=Ge.useState(null),[u,m]=Ge.useState(null),[s,f]=Ge.useState(false),[h,g]=Ge.useState(false),p=on(e),x=Ge.useSyncExternalStore(ln,()=>an(p),()=>false),S=s||!i&&x;async function $(A){A.preventDefault(),m(null),l(null);let C=new FormData(A.currentTarget),H=dt(C,"company");if(i){l(Fe),f(true),A.currentTarget.reset();return}g(true);try{let pe=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:dt(C,"email"),name:nn(C,"name"),sourceSurface:r,sourceUrl:rn(o),sourceArticleSlug:n??null,honeypot:H})});if(!pe.ok)throw new Error("Newsletter signup failed.");let Ze=await pe.json().catch(()=>null),Br=cn(Ze)??Fe;sn(p),l(Br),f(!0),A.currentTarget.reset();}catch{l(null),m("Newsletter signup failed. Please try again.");}finally{g(false);}}return jsxRuntime.jsx("section",{className:b("border-y border-[var(--blog-accent-border)] py-5 sm:py-6",a),"aria-labelledby":`newsletter-${r}-title`,children:jsxRuntime.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.4fr)] lg:items-end",children:[jsxRuntime.jsxs("div",{className:"max-w-xl space-y-1",children:[jsxRuntime.jsx("h2",{id:`newsletter-${r}-title`,className:"text-base leading-6 font-semibold",children:t.title}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm leading-6",children:t.description})]}),S?jsxRuntime.jsxs("div",{className:"flex items-start gap-3 text-sm leading-6 text-emerald-500",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15",children:jsxRuntime.jsx(lucideReact.Check,{className:"size-3.5","aria-hidden":"true"})}),jsxRuntime.jsx("p",{children:c??Fe})]}):jsxRuntime.jsxs("form",{onSubmit:$,className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,0.8fr)_minmax(0,1fr)_auto]",children:[jsxRuntime.jsx("label",{className:"sr-only",htmlFor:`newsletter-name-${r}`,children:"Name"}),jsxRuntime.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"}),jsxRuntime.jsx("label",{className:"sr-only",htmlFor:`newsletter-email-${r}`,children:"Email"}),jsxRuntime.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"}),jsxRuntime.jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"hidden"}),jsxRuntime.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,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]}),u&&jsxRuntime.jsx("p",{className:"text-sm text-red-600",children:u})]})]})})}function rn(e){return e?.startsWith("http://")||e?.startsWith("https://")?e:typeof window<"u"?window.location.href:null}function dt(e,t){let r=e.get(t);return typeof r=="string"?r:""}function nn(e,t){let r=dt(e,t).trim();return r.length===0?null:r}function on(e){return `bloggy_newsletter_subscribed_${e}`}function an(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 sn(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 ln(e){return typeof window>"u"?()=>{}:(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e))}function cn(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:null}function qt({articles:e,siteName:t,siteTagline:r,className:n,site:o,includeStructuredData:i=false,basePath:a="/blog",pagination:c,theme:l,newsletter:u,newsletterPreviewMode:m=false}){let s=E(a)||"/",f=u??o?.newsletter,h=o?.id??e[0]?.site.id;return jsxRuntime.jsxs("div",{style:j(l),className:b("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&&jsxRuntime.jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsxRuntime.jsx("h1",{className:b("blog-title mb-2 text-3xl font-light tracking-tight text-balance sm:text-4xl lg:text-5xl",V),children:t}),r&&jsxRuntime.jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r}),jsxRuntime.jsxs("nav",{"aria-label":"Browse blog",className:"mt-5 flex flex-wrap items-center justify-center gap-2 text-sm",children:[jsxRuntime.jsx(ee__default.default,{href:s,"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"}),jsxRuntime.jsx(ee__default.default,{href:N(s,"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"}),jsxRuntime.jsx(ee__default.default,{href:N(s,"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"})]})]}),jsxRuntime.jsxs("main",{className:"articles-list",children:[e.length===0?jsxRuntime.jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsxRuntime.jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsxRuntime.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."})]}):jsxRuntime.jsx("div",{className:"space-y-0",children:e.map(g=>jsxRuntime.jsx(mn,{article:g,basePath:s},g.id))}),c&&c.totalPages>1&&jsxRuntime.jsx("div",{className:"pagination-wrapper mt-12",children:jsxRuntime.jsx(ge,{currentPage:c.currentPage,totalPages:c.totalPages,baseUrl:c.baseUrl??s,className:"justify-center"})})]}),f?.enabled&&h&&jsxRuntime.jsx(Te,{siteId:h,settings:f,sourceSurface:"blog_home",previewMode:m,className:"mt-10 sm:mt-12"}),i&&o&&(()=>{let g=ae(lt(o,e.slice(0,5),{pathPrefix:s}));return jsxRuntime.jsx("script",{type:g.type,dangerouslySetInnerHTML:g.dangerouslySetInnerHTML})})()]})}function dn(e){return `${Math.ceil(e/60)} min read`}function mn({article:e,basePath:t}){let r=N(t,e.slug),n=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=dn(e.readingSeconds),i=e.featuredImage;return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"space-y-4 lg:hidden",children:[i&&jsxRuntime.jsx(ee__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-full overflow-hidden rounded-2xl bg-[var(--blog-accent-bg)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(mt__default.default,{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"})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(ee__default.default,{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:jsxRuntime.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})}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(zt,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsxRuntime.jsx(Gt,{topic:a,basePath:t},a.id))})]})]}),jsxRuntime.jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[i&&jsxRuntime.jsx(ee__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl bg-[var(--blog-accent-bg)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none xl:w-72","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(mt__default.default,{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"})}),jsxRuntime.jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(ee__default.default,{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:jsxRuntime.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&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsxRuntime.jsx(Gt,{topic:a,basePath:t},a.id))})]}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(zt,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:o})]})]})]})]})}function Gt({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?jsxRuntime.jsx(ee__default.default,{href:N(t,`topics/${n}`),className:r,children:e.name}):jsxRuntime.jsx("span",{className:r,children:e.name})}function zt({author:e,basePath:t}){return jsxRuntime.jsxs(ee__default.default,{href:_(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(pn,{author:e,size:"sm"}),e.name]})}function pn({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=gn(e.name);return e.avatarUrl?jsxRuntime.jsx(mt__default.default,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:b("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function gn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function fn(e,t,r,n,o="/blog"){let i=e?`${e} - Blog`:"Blog",a=n&&n.currentPage>1?`${i} - Page ${n.currentPage}`:i,c=t??"Read our latest articles and insights.",l=E(o)||"/",u=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,s=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:a,description:c,openGraph:{title:a,description:c,type:"website",...r&&{url:u}},twitter:{card:"summary_large_image",title:a,description:c},alternates:{...u&&{canonical:u}},other:{...m&&{prev:m},...s&&{next:s}}}}var bn=classVarianceAuthority.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 Re({className:e,variant:t,...r}){return jsxRuntime.jsx("div",{className:b(bn({variant:t}),e),...r})}function Ce({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card",className:b("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function yn({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-header",className:b("@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 vn({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-title",className:b("leading-none font-semibold",e),...t})}function Pn({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-description",className:b("text-muted-foreground text-sm",e),...t})}function Le({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-content",className:b("px-6",e),...t})}function An({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-footer",className:b("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Tn(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 Xt(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 Rn(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await Xt(e.url,t?.clipboard),"copied")}function ze({title:e,url:t,className:r,size:n="md"}){let[o,i]=Ge__namespace.default.useState(false),[a,c]=Ge__namespace.default.useState(false),l=Ge__namespace.default.useMemo(()=>Tn(t,typeof window>"u"?void 0:window.location.href),[t]);Ge__namespace.default.useEffect(()=>{if(!o)return;let h=window.setTimeout(()=>i(false),2e3);return ()=>window.clearTimeout(h)},[o]);async function u(){await Xt(l),i(true);}async function m(){c(true);try{await Rn({title:e,url:l})==="copied"&&i(!0);}finally{c(false);}}let s=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",f=n==="sm"?"size-3.5":"size-4";return jsxRuntime.jsxs("div",{className:b("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxRuntime.jsxs("button",{type:"button","aria-label":"Copy article link",onClick:u,className:b("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)]",s),children:[o?jsxRuntime.jsx(lucideReact.Check,{className:f,"aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Copy,{className:f,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o?"Copied":"Copy link"})]}),jsxRuntime.jsxs("button",{type:"button","aria-label":"Share article",onClick:m,disabled:a,className:b("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",s),children:[jsxRuntime.jsx(lucideReact.Share2,{className:f,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:"Share"})]})]})}function Kt({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsxRuntime.jsx("img",{alt:e,className:t,...n});let o=`blog-image-preview-${Ln(r)}`,i=Cn(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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:jsxRuntime.jsx("img",{src:r,alt:e,className:b("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})}),jsxRuntime.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:[jsxRuntime.jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsxRuntime.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:jsxRuntime.jsx("img",{src:i,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsxRuntime.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 Cn(e){if(!e.includes("/cdn-cgi/image/"))return e;try{let t=new URL(e),r=t.pathname.split("/"),n=r.findIndex(o=>o==="image");return n===-1||r[n-1]!=="cdn-cgi"||!r[n+1]?e:(r[n+1]="width=1600,quality=90,format=webp",t.pathname=r.join("/"),t.toString())}catch{return e}}function Ln(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 gt({items:e,contentId:t,variant:r,showProgress:n=true}){let o=e[0]?.id??null,i=Ge.useMemo(()=>e.map(a=>a.id),[e]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bn,{contentId:t,itemIds:i}),n&&jsxRuntime.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}),jsxRuntime.jsx(On,{items:e,activeItemId:o,variant:r})]})}function Bn({contentId:e,itemIds:t}){return Ge.useEffect(()=>{let r=0,n=decodeURIComponent(window.location.hash.replace(/^#/,"")),o=l=>{let u=Array.from(document.querySelectorAll("[data-blog-toc-link]"));for(let m of u){let s=m.getAttribute("data-blog-toc-link")===l;m.setAttribute("data-active",s?"true":"false"),s?m.setAttribute("aria-current","location"):m.removeAttribute("aria-current");}},i=()=>{let l=document.getElementById(e);if(!l)return;let u=Array.from(document.querySelectorAll(`[data-blog-reading-progress="${e}"]`)),m=l.getBoundingClientRect(),s=window.scrollY,f=m.top+s,h=l.offsetHeight-window.innerHeight,g=h<=0?s>=f?100:0:(s-f)/h*100,p=En(g);for(let A of u)A.style.transform=`scaleX(${p/100})`,A.setAttribute("aria-valuenow",String(Math.round(p)));let x=t.map(A=>document.getElementById(A)).filter(A=>!!A);if(n&&t.includes(n)){o(n),n="";return}let S=Math.max(160,Math.round(window.innerHeight*.33)),$=x.filter(A=>A.getBoundingClientRect().top<=S).at(-1)??x[0]??null;o($?$.id:null);},a=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(i);},c=()=>{n=decodeURIComponent(window.location.hash.replace(/^#/,"")),a();};return a(),window.addEventListener("scroll",a,{passive:true}),window.addEventListener("resize",a),window.addEventListener("hashchange",c),()=>{window.cancelAnimationFrame(r),window.removeEventListener("scroll",a),window.removeEventListener("resize",a),window.removeEventListener("hashchange",c);}},[e,t]),null}function En(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function On({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsxRuntime.jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let i=Ft(o.id,t);return jsxRuntime.jsx("li",{className:o.level===3?"pl-4":void 0,children:jsxRuntime.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"?jsxRuntime.jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxRuntime.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:[jsxRuntime.jsx("span",{children:"On this page"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[jt(e.length),jsxRuntime.jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsxRuntime.jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsxRuntime.jsx("aside",{className:"hidden lg:block",children:jsxRuntime.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:[jsxRuntime.jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}var le=Ge__namespace.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},o)=>jsxRuntime.jsx(ft__namespace.Root,{ref:o,decorative:r,orientation:t,className:b("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));le.displayName=ft__namespace.Root.displayName;var Gn=Un.defaultSchema.attributes?.["*"]??[],zn=Un.defaultSchema.attributes?.a??[],Vn=Un.defaultSchema.attributes?.img??[],qn={...Un.defaultSchema,tagNames:[...Un.defaultSchema.tagNames??[],"figure","figcaption"],attributes:{...Un.defaultSchema.attributes,"*":[...Gn,"className"],a:[...zn,"className","href","target","rel","title"],img:[...Vn,"className","src","alt","title","width","height","loading"],figure:["className"],figcaption:["className"],span:["className"]},protocols:{...Un.defaultSchema.protocols,href:["http","https","mailto","tel"],src:["http","https"]}},Yt={mdxOptions:{format:"md",remarkPlugins:[jn__default.default,Hn__default.default],rehypePlugins:[Dn__default.default,[Un__default.default,qn],Xn,Fn__default.default]}};function Xn(){return e=>{Qt(e);}}function Qt(e){e.children&&(e.children=e.children.flatMap(t=>(Qt(t),Wn(t)?t.children?.filter(ht)??[t]:[t])));}function Wn(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(ht);return t.length===1&&Kn(t[0])}function Kn(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(ht);return t.length===1&&t[0]?.tagName==="img"}function ht(e){return e.type!=="text"||!!e.value?.trim()}function bt(e,t,r={}){let n=r.limit??3;if(n<=0)return [];let o=Zt(e),i=Jn(e,t),a=(m,s)=>er(s)-er(m)||tr(m).localeCompare(tr(s)),c=o?i.filter(m=>Zt(m)===o).sort(a):[],l=new Set(c.map(m=>m.id)),u=i.filter(m=>!l.has(m.id)).sort(a);return [...c,...u].slice(0,n)}function Jn(e,t){let r=new Set,n=new Set,o=[];for(let i of t)i.id===e.id||i.slug===e.slug||r.has(i.id)||n.has(i.slug)||(r.add(i.id),n.add(i.slug),o.push(i));return o}function Zt(e){let t=e.topics??[];return t.find(r=>r.isPrimary)?.slug??t[0]?.slug??null}function er(e){let t=Date.parse(e.publishedAt??e.updatedAt??"");return Number.isFinite(t)?t:0}function tr(e){return e.title??e.slug}function ti(e){return `${Math.ceil(e/60)} min read`}function ri(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function ni({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??ri(t??"");return jsxRuntime.jsxs("span",{children:["Credit:"," ",t?jsxRuntime.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 sr({article:e,className:t,navigation:r,basePath:n="/blog",theme:o,postArticleCta:i,newsletter:a,newsletterPreviewMode:c=false,articles:l=[],relatedArticles:u=[],showShareLinks:m=true}){let s=E(n)||"/",f=ct(e.publishedAt,e.updatedAt),h=ti(e.readingSeconds),g=ut(e.content),p=e.meta.canonicalUrl??N(s,e.slug),x=a??e.site.newsletter,S=i??e.cta,$=e.featuredImage,A=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl),C=u.length>0?u.slice(0,3):bt(e,l);return jsxRuntime.jsxs("article",{style:j(o),className:b("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&&jsxRuntime.jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxRuntime.jsxs(ee__default.default,{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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsxRuntime.jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsxRuntime.jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsxRuntime.jsx("style",{children:`
1
+ 'use strict';var ee=require('next/link.js'),wt=require('next/image.js'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),dateFns=require('date-fns'),Ye=require('react'),rsc=require('next-mdx-remote-client/rsc'),fa6=require('react-icons/fa6'),Rt=require('@radix-ui/react-separator'),Qi=require('rehype-raw'),Zi=require('rehype-sanitize'),en=require('remark-gfm'),tn=require('remark-toc'),rn=require('rehype-slug'),crypto=require('crypto'),ratelimit=require('@upstash/ratelimit'),redis=require('@upstash/redis'),drizzleOrm=require('drizzle-orm'),sqliteCore=require('drizzle-orm/sqlite-core'),server_js=require('next/server.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ee__default=/*#__PURE__*/_interopDefault(ee);var wt__default=/*#__PURE__*/_interopDefault(wt);var Ye__namespace=/*#__PURE__*/_interopNamespace(Ye);var Rt__namespace=/*#__PURE__*/_interopNamespace(Rt);var Qi__default=/*#__PURE__*/_interopDefault(Qi);var Zi__default=/*#__PURE__*/_interopDefault(Zi);var en__default=/*#__PURE__*/_interopDefault(en);var tn__default=/*#__PURE__*/_interopDefault(tn);var rn__default=/*#__PURE__*/_interopDefault(rn);function f(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var je=classVarianceAuthority.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 Zr({className:e,variant:t,size:r,asChild:i=false,...o}){return jsxRuntime.jsx(i?reactSlot.Slot:"button",{"data-slot":"button",className:f(je({variant:t,size:r,className:e})),...o})}function mt({className:e,...t}){return jsxRuntime.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:f("mx-auto flex w-full justify-center",e),...t})}function gt({className:e,...t}){return jsxRuntime.jsx("ul",{"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e),...t})}function re({...e}){return jsxRuntime.jsx("li",{"data-slot":"pagination-item",...e})}function ue({className:e,isActive:t,size:r="icon",...i}){return jsxRuntime.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:f(je({variant:t?"outline":"ghost",size:r}),e),...i})}function pt({className:e,...t}){return jsxRuntime.jsxs(ue,{"aria-label":"Go to previous page",size:"default",className:f("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsxRuntime.jsx(lucideReact.ChevronLeftIcon,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function ft({className:e,...t}){return jsxRuntime.jsxs(ue,{"aria-label":"Go to next page",size:"default",className:f("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"}),jsxRuntime.jsx(lucideReact.ChevronRightIcon,{})]})}function ze({className:e,...t}){return jsxRuntime.jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:f("flex size-9 items-center justify-center",e),...t,children:[jsxRuntime.jsx(lucideReact.MoreHorizontalIcon,{className:"size-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"More pages"})]})}function ye({currentPage:e,totalPages:t,baseUrl:r,className:i,maxVisiblePages:o=5,showPrevNext:n=true,showFirstLast:s=true}){if(t<=1)return null;let a=()=>{let p=Math.floor(o/2),g=Math.max(1,e-p),b=Math.min(t,g+o-1);return b-g+1<o&&(g=Math.max(1,b-o+1)),{start:g,end:b}},{start:l,end:u}=a(),c=Array.from({length:u-l+1},(p,g)=>l+g),d=p=>p===1?r:`${r}?page=${p}`,h=e>1,y=e<t;return jsxRuntime.jsxs(mt,{className:i,children:[jsxRuntime.jsxs(gt,{children:[s&&e>2&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(re,{children:jsxRuntime.jsx(ue,{href:d(1),"aria-label":"Go to first page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsxRuntime.jsx(re,{children:jsxRuntime.jsx(ze,{})})]}),n&&jsxRuntime.jsx(re,{children:h?jsxRuntime.jsx(pt,{href:d(e-1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})})}),c.map(p=>jsxRuntime.jsx(re,{children:jsxRuntime.jsx(ue,{href:d(p),isActive:p===e,children:p})},p)),n&&jsxRuntime.jsx(re,{children:y?jsxRuntime.jsx(ft,{href:d(e+1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"})})}),s&&e<t-1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u<t-1&&jsxRuntime.jsx(re,{children:jsxRuntime.jsx(ze,{})}),jsxRuntime.jsx(re,{children:jsxRuntime.jsx(ue,{href:d(t),"aria-label":"Go to last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxRuntime.jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function si(e,t=10){let r=e.page,i=Array.isArray(r)?r[0]:r,o=Math.max(1,parseInt(i??"1",10)),n=(o-1)*t;return {currentPage:o,itemsPerPage:t,offset:n,calculateTotalPages:a=>Math.ceil(a/t)}}function ai(e,t,r,i){let o=i?`${i}${e===1?r:`${r}?page=${e}`}`:void 0,n=e>1&&i?`${i}${e===2?r:`${r}?page=${e-1}`}`:void 0,s=e<t&&i?`${i}${r}?page=${e+1}`:void 0;return {alternates:{...o&&{canonical:o}},other:{...n&&{prev:n},...s&&{next:s}}}}function _(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function v(e,t){let r=_(e),i=t?.replace(/^\/+/,"").replace(/\/+$/,"");return i?`${r}/${i}`.replace(/\/+/g,"/"):r||"/"}function I(e,t){return v(e,`authors/${t}`)}function oe(e,t){return v(e,`series/${t}`)}function li(e){let t=new URL(e);return _(t.pathname)}function Ve(e,t={}){let{customDomain:r,pathPrefix:i="/blog",language:o,isAccessibleForFree:n=true,includeOptionalProperties:s=true}=t,a=r??e.site.domain,l=r?`https://${a}${i}/${e.slug}`:e.meta.canonicalUrl??`https://${a}${i}/${e.slug}`,u=e.author?qe(e.author,{customDomain:r,pathPrefix:i}):void 0,c=bt(e.site,{customDomain:r,pathPrefix:i}),h=`PT${Math.max(1,Math.ceil(e.readingSeconds/60))}M`,y={"@context":"https://schema.org","@type":"BlogPosting","@id":`${l}#article`,headline:e.title,description:e.excerpt,datePublished:e.publishedAt,dateModified:e.updatedAt,author:u,publisher:c,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:h,isAccessibleForFree:n};if(s){e.featuredImage&&(y.image=e.featuredImage),e.meta.keywords.length>0&&(y.keywords=[...e.meta.keywords]),(o??e.site.locale)&&(y.inLanguage=o??e.site.locale);let p=[...(e.topics??[]).map(g=>g.name),...e.series?[e.series.title]:[]];p.length&&(y.about=[...new Set(p)].map(g=>({"@type":"Thing",name:g})));}return y}function qe(e,t={}){let{customDomain:r,pathPrefix:i="/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 n=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(s=>!!s);if(n.length>0&&(o.sameAs=n),e.slug?.trim()){let s=r?`https://${r}${I(i,e.slug)}`:I(i,e.slug);o.url=s;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.expertise?.length&&(o.knowsAbout=[...e.expertise]),o}function bt(e,t={}){let{customDomain:r,pathPrefix:i="/blog"}=t,n=`https://${r??e.domain}${i}`,s={"@context":"https://schema.org","@type":"Organization","@id":`${n}#organization`,name:e.name,url:n};return e.description?.trim()&&(s.description=e.description),e.tagline?.trim()&&(s.description=s.description?`${s.description}. ${e.tagline}`:e.tagline),s}function xt(e,t={}){let{customDomain:r,pathPrefix:i="/blog",language:o,includeSearchAction:n=true}=t,a=`https://${r??e.domain}${i}`,l=bt(e,t),u={"@context":"https://schema.org","@type":"WebSite","@id":`${a}#website`,name:e.name,url:a,publisher:l};return e.description?.trim()&&(u.description=e.description),(o??e.locale)&&(u.inLanguage=o??e.locale),n&&(u.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${a}?search={search_term_string}`},"query-input":"required name=search_term_string"}),u}function Xe(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((i,o)=>({"@type":"ListItem",position:o+1,name:i.name,item:r&&!i.url.startsWith("http")?`https://${r}${i.url}`:i.url}))}}function yt(e,t={}){let r=[];r.push(Ve(e,t)),r.push(xt(e.site,t));let i=t.pathPrefix??"/blog",o=[{name:"Home",url:"/"},{name:e.site.name,url:i},{name:e.title,url:`${i}/${e.slug}`}];return r.push(Xe(o,t)),r}function vt(e,t=[],r={}){let i=[];if(i.push(xt(e,r)),t.length>0){let o=t.slice(0,5).map(n=>Ve(n,r));i.push(...o);}return i}function Qt(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 We(e){return JSON.stringify(e,null,0).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function de(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:We(e)}}}function ci(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 _e=class extends Error{constructor(r,i,o){super(r);this.code=i;this.details=o;this.name="StructuredDataError";}code;details};function ui(e,t={}){try{let r=Ve(e,t),i=Qt(r);return i.isValid?{schema:r}:{error:new _e("Generated schema validation failed","VALIDATION_FAILED",i.errors)}}catch(r){return {error:new _e("Failed to generate structured data","GENERATION_FAILED",r)}}}var U="bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text text-transparent",ve={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 $(e={}){return {"--blog-accent":e.accentColor??ve.accentColor,"--blog-accent-hover":e.accentHoverColor??ve.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??ve.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??ve.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??ve.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??ve.accentBorderColor}}function Pt(e,t){let r=new Date(e),i=new Date(t);return {publishedDateLabel:dateFns.format(r,"d MMMM yyyy"),publishedRelativeLabel:dateFns.formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:dateFns.format(i,"d MMMM yyyy"),isUpdated:i.getTime()!==r.getTime()}}function At(e){let t=[],r=false;for(let i of e.split(`
2
+ `)){if(/^\s*```/.test(i)){r=!r;continue}if(r)continue;let o=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(i);if(!o?.[1]||!o[2])continue;let n=mi(o[2]);n&&t.push({id:gi(n),text:n,level:o[1].length});}return t}function er(e){return `${e} ${e===1?"section":"sections"}`}function tr(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function mi(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function gi(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}var Je="Thanks, you're on the list. We'll confirm before sending updates.";function Be({siteId:e,settings:t,sourceSurface:r,sourceArticleSlug:i,sourceUrl:o,previewMode:n=false,className:s}){let[a,l]=Ye.useState(null),[u,c]=Ye.useState(null),[d,h]=Ye.useState(false),[y,p]=Ye.useState(false),g=yi(e),b=Ye.useSyncExternalStore(Ai,()=>vi(g),()=>false),T=d||!n&&b;async function M(S){S.preventDefault(),c(null),l(null);let B=new FormData(S.currentTarget),D=St(B,"company");if(n){l(Je),h(true),S.currentTarget.reset();return}p(true);try{let xe=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:St(B,"email"),name:xi(B,"name"),sourceSurface:r,sourceUrl:bi(o),sourceArticleSlug:i??null,honeypot:D})});if(!xe.ok)throw new Error("Newsletter signup failed.");let dt=await xe.json().catch(()=>null),Wr=Si(dt)??Je;Pi(g),l(Wr),h(!0),S.currentTarget.reset();}catch{l(null),c("Newsletter signup failed. Please try again.");}finally{p(false);}}return jsxRuntime.jsx("section",{className:f("border-y border-[var(--blog-accent-border)] py-5 sm:py-6",s),"aria-labelledby":`newsletter-${r}-title`,children:jsxRuntime.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.4fr)] lg:items-end",children:[jsxRuntime.jsxs("div",{className:"max-w-xl space-y-1",children:[jsxRuntime.jsx("h2",{id:`newsletter-${r}-title`,className:"text-base leading-6 font-semibold",children:t.title}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm leading-6",children:t.description})]}),T?jsxRuntime.jsxs("div",{className:"flex items-start gap-3 text-sm leading-6 text-emerald-500",role:"status","aria-live":"polite",children:[jsxRuntime.jsx("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15",children:jsxRuntime.jsx(lucideReact.Check,{className:"size-3.5","aria-hidden":"true"})}),jsxRuntime.jsx("p",{children:a??Je})]}):jsxRuntime.jsxs("form",{onSubmit:M,className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,0.8fr)_minmax(0,1fr)_auto]",children:[jsxRuntime.jsx("label",{className:"sr-only",htmlFor:`newsletter-name-${r}`,children:"Name"}),jsxRuntime.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"}),jsxRuntime.jsx("label",{className:"sr-only",htmlFor:`newsletter-email-${r}`,children:"Email"}),jsxRuntime.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"}),jsxRuntime.jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"hidden"}),jsxRuntime.jsxs("button",{type:"submit",disabled:y,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:[y?"Submitting...":t.buttonLabel,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]}),u&&jsxRuntime.jsx("p",{className:"text-sm text-red-600",children:u})]})]})})}function bi(e){return e?.startsWith("http://")||e?.startsWith("https://")?e:typeof window<"u"?window.location.href:null}function St(e,t){let r=e.get(t);return typeof r=="string"?r:""}function xi(e,t){let r=St(e,t).trim();return r.length===0?null:r}function yi(e){return `bloggy_newsletter_subscribed_${e}`}function vi(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 Pi(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 Ai(e){return typeof window>"u"?()=>{}:(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e))}function Si(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:null}function or({articles:e,siteName:t,siteTagline:r,className:i,site:o,includeStructuredData:n=false,basePath:s="/blog",pagination:a,theme:l,newsletter:u,newsletterPreviewMode:c=false}){let d=_(s)||"/",h=u??o?.newsletter,y=o?.id??e[0]?.site.id;return jsxRuntime.jsxs("div",{style:$(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",i),children:[t&&jsxRuntime.jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsxRuntime.jsx("h1",{className:f("blog-title mb-2 text-3xl font-light tracking-tight text-balance sm:text-4xl lg:text-5xl",U),children:t}),r&&jsxRuntime.jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r}),jsxRuntime.jsxs("nav",{"aria-label":"Browse blog",className:"mt-5 flex flex-wrap items-center justify-center gap-2 text-sm",children:[jsxRuntime.jsx(ee__default.default,{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"}),jsxRuntime.jsx(ee__default.default,{href:v(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"}),jsxRuntime.jsx(ee__default.default,{href:v(d,"series"),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:"Series"}),jsxRuntime.jsx(ee__default.default,{href:v(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"})]})]}),jsxRuntime.jsxs("main",{className:"articles-list",children:[e.length===0?jsxRuntime.jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsxRuntime.jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsxRuntime.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."})]}):jsxRuntime.jsx("div",{className:"space-y-0",children:e.map(p=>jsxRuntime.jsx(Ti,{article:p,basePath:d},p.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pagination-wrapper mt-12",children:jsxRuntime.jsx(ye,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??d,className:"justify-center"})})]}),h?.enabled&&y&&jsxRuntime.jsx(Be,{siteId:y,settings:h,sourceSurface:"blog_home",previewMode:c,className:"mt-10 sm:mt-12"}),n&&o&&(()=>{let p=de(vt(o,e.slice(0,5),{pathPrefix:d}));return jsxRuntime.jsx("script",{type:p.type,dangerouslySetInnerHTML:p.dangerouslySetInnerHTML})})()]})}function Ni(e){return `${Math.ceil(e/60)} min read`}function Ti({article:e,basePath:t}){let r=v(t,e.slug),i=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=Ni(e.readingSeconds),n=e.featuredImage;return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"space-y-4 lg:hidden",children:[n&&jsxRuntime.jsx(ee__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-full overflow-hidden rounded-2xl bg-[var(--blog-accent-bg)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(wt__default.default,{src:n,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"})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(ee__default.default,{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:jsxRuntime.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})}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ir,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${i}`,children:i}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsxRuntime.jsx(rr,{topic:s,basePath:t},s.id))})]})]}),jsxRuntime.jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[n&&jsxRuntime.jsx(ee__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl bg-[var(--blog-accent-bg)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none xl:w-72","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(wt__default.default,{src:n,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"})}),jsxRuntime.jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(ee__default.default,{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:jsxRuntime.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&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsxRuntime.jsx(rr,{topic:s,basePath:t},s.id))})]}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ir,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${i}`,children:i}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:o})]})]})]})]})}function rr({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)]",i=e.slug.trim();return i?jsxRuntime.jsx(ee__default.default,{href:v(t,`topics/${i}`),className:r,children:e.name}):jsxRuntime.jsx("span",{className:r,children:e.name})}function ir({author:e,basePath:t}){return jsxRuntime.jsxs(ee__default.default,{href:I(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(Ri,{author:e,size:"sm"}),e.name]})}function Ri({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",i=Ci(e.name);return e.avatarUrl?jsxRuntime.jsx(wt__default.default,{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"}):jsxRuntime.jsx("span",{className:f("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:i})}function Ci(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Li(e,t,r,i,o="/blog"){let n=e?`${e} - Blog`:"Blog",s=i&&i.currentPage>1?`${n} - Page ${i.currentPage}`:n,a=t??"Read our latest articles and insights.",l=_(o)||"/",u=r?`${r}${i&&i.currentPage>1?`${l}?page=${i.currentPage}`:l}`:void 0,c=i&&i.currentPage>1&&r?`${r}${i.currentPage===2?l:`${l}?page=${i.currentPage-1}`}`:void 0,d=i&&i.currentPage<i.totalPages&&r?`${r}${l}?page=${i.currentPage+1}`:void 0;return {title:s,description:a,openGraph:{title:s,description:a,type:"website",...r&&{url:u}},twitter:{card:"summary_large_image",title:s,description:a},alternates:{...u&&{canonical:u}},other:{...c&&{prev:c},...d&&{next:d}}}}var _i=classVarianceAuthority.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 Ie({className:e,variant:t,...r}){return jsxRuntime.jsx("div",{className:f(_i({variant:t}),e),...r})}function Ee({className:e,...t}){return jsxRuntime.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 Ii({className:e,...t}){return jsxRuntime.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 Ei({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-title",className:f("leading-none font-semibold",e),...t})}function Oi({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-description",className:f("text-muted-foreground text-sm",e),...t})}function Oe({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-content",className:f("px-6",e),...t})}function Mi({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-footer",className:f("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Hi(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 sr(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 i=r.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.position="fixed",i.style.left="-9999px",r.body.appendChild(i),i.select();try{if(!r.execCommand("copy"))throw new Error("Copy command failed")}finally{i.remove();}}async function Fi(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await sr(e.url,t?.clipboard),"copied")}function Qe({title:e,url:t,className:r,size:i="md"}){let[o,n]=Ye__namespace.default.useState(false),[s,a]=Ye__namespace.default.useState(false),l=Ye__namespace.default.useMemo(()=>Hi(t,typeof window>"u"?void 0:window.location.href),[t]);Ye__namespace.default.useEffect(()=>{if(!o)return;let y=window.setTimeout(()=>n(false),2e3);return ()=>window.clearTimeout(y)},[o]);async function u(){await sr(l),n(true);}async function c(){a(true);try{await Fi({title:e,url:l})==="copied"&&n(!0);}finally{a(false);}}let d=i==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",h=i==="sm"?"size-3.5":"size-4";return jsxRuntime.jsxs("div",{className:f("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxRuntime.jsxs("button",{type:"button","aria-label":"Copy article link",onClick:u,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?jsxRuntime.jsx(lucideReact.Check,{className:h,"aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Copy,{className:h,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o?"Copied":"Copy link"})]}),jsxRuntime.jsxs("button",{type:"button","aria-label":"Share article",onClick:c,disabled:s,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:[jsxRuntime.jsx(lucideReact.Share2,{className:h,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:"Share"})]})]})}function lr({alt:e="",className:t,src:r,...i}){if(typeof r!="string"||r.length===0)return jsxRuntime.jsx("img",{alt:e,className:t,...i});let o=`blog-image-preview-${ji(r)}`,n=Gi(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.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:jsxRuntime.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),...i})}),jsxRuntime.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:[jsxRuntime.jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsxRuntime.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:jsxRuntime.jsx("img",{src:n,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsxRuntime.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 Gi(e){if(!e.includes("/cdn-cgi/image/"))return e;try{let t=new URL(e),r=t.pathname.split("/"),i=r.findIndex(o=>o==="image");return i===-1||r[i-1]!=="cdn-cgi"||!r[i+1]?e:(r[i+1]="width=1600,quality=90,format=webp",t.pathname=r.join("/"),t.toString())}catch{return e}}function ji(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 Tt({items:e,contentId:t,variant:r,showProgress:i=true}){let o=e[0]?.id??null,n=Ye.useMemo(()=>e.map(s=>s.id),[e]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xi,{contentId:t,itemIds:n}),i&&jsxRuntime.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}),jsxRuntime.jsx(Ki,{items:e,activeItemId:o,variant:r})]})}function Xi({contentId:e,itemIds:t}){return Ye.useEffect(()=>{let r=0,i=decodeURIComponent(window.location.hash.replace(/^#/,"")),o=l=>{let u=Array.from(document.querySelectorAll("[data-blog-toc-link]"));for(let c of u){let d=c.getAttribute("data-blog-toc-link")===l;c.setAttribute("data-active",d?"true":"false"),d?c.setAttribute("aria-current","location"):c.removeAttribute("aria-current");}},n=()=>{let l=document.getElementById(e);if(!l)return;let u=Array.from(document.querySelectorAll(`[data-blog-reading-progress="${e}"]`)),c=l.getBoundingClientRect(),d=window.scrollY,h=c.top+d,y=l.offsetHeight-window.innerHeight,p=y<=0?d>=h?100:0:(d-h)/y*100,g=Wi(p);for(let S of u)S.style.transform=`scaleX(${g/100})`,S.setAttribute("aria-valuenow",String(Math.round(g)));let b=t.map(S=>document.getElementById(S)).filter(S=>!!S);if(i&&t.includes(i)){o(i),i="";return}let T=Math.max(160,Math.round(window.innerHeight*.33)),M=b.filter(S=>S.getBoundingClientRect().top<=T).at(-1)??b[0]??null;o(M?M.id:null);},s=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(n);},a=()=>{i=decodeURIComponent(window.location.hash.replace(/^#/,"")),s();};return s(),window.addEventListener("scroll",s,{passive:true}),window.addEventListener("resize",s),window.addEventListener("hashchange",a),()=>{window.cancelAnimationFrame(r),window.removeEventListener("scroll",s),window.removeEventListener("resize",s),window.removeEventListener("hashchange",a);}},[e,t]),null}function Wi(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function Ki({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let i=jsxRuntime.jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let n=tr(o.id,t);return jsxRuntime.jsx("li",{className:o.level===3?"pl-4":void 0,children:jsxRuntime.jsx("a",{href:`#${o.id}`,"aria-current":n.ariaCurrent,"data-blog-toc-link":o.id,"data-active":n.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"?jsxRuntime.jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxRuntime.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:[jsxRuntime.jsx("span",{children:"On this page"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[er(e.length),jsxRuntime.jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsxRuntime.jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:i})]}):jsxRuntime.jsx("aside",{className:"hidden lg:block",children:jsxRuntime.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:[jsxRuntime.jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),i]})})}var ge=Ye__namespace.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...i},o)=>jsxRuntime.jsx(Rt__namespace.Root,{ref:o,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...i}));ge.displayName=Rt__namespace.Root.displayName;var nn=Zi.defaultSchema.attributes?.["*"]??[],on=Zi.defaultSchema.attributes?.a??[],sn=Zi.defaultSchema.attributes?.img??[],an={...Zi.defaultSchema,tagNames:[...Zi.defaultSchema.tagNames??[],"figure","figcaption"],attributes:{...Zi.defaultSchema.attributes,"*":[...nn,"className"],a:[...on,"className","href","target","rel","title"],img:[...sn,"className","src","alt","title","width","height","loading"],figure:["className"],figcaption:["className"],span:["className"]},protocols:{...Zi.defaultSchema.protocols,href:["http","https","mailto","tel"],src:["http","https"]}},ur={mdxOptions:{format:"md",remarkPlugins:[tn__default.default,en__default.default],rehypePlugins:[Qi__default.default,[Zi__default.default,an],ln,rn__default.default]}};function ln(){return e=>{dr(e);}}function dr(e){e.children&&(e.children=e.children.flatMap(t=>(dr(t),cn(t)?t.children?.filter(Ct)??[t]:[t])));}function cn(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(Ct);return t.length===1&&un(t[0])}function un(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(Ct);return t.length===1&&t[0]?.tagName==="img"}function Ct(e){return e.type!=="text"||!!e.value?.trim()}function Lt({article:e,basePath:t="/blog",className:r}){let i=e.series;return i?jsxRuntime.jsxs("section",{"aria-labelledby":"article-series-title",className:f("rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",r),children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-5 md:flex-row md:items-start md:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm font-medium",children:["Part ",i.position," of ",i.total]}),jsxRuntime.jsx("h2",{id:"article-series-title",className:"text-xl font-semibold",children:jsxRuntime.jsx(ee__default.default,{href:oe(t,i.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:i.title})}),i.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-2xl leading-relaxed",children:i.description})]}),(i.previous??i.next)&&jsxRuntime.jsxs("div",{className:"grid shrink-0 gap-2 sm:grid-cols-2 md:min-w-64 md:grid-cols-1",children:[i.previous&&jsxRuntime.jsxs(ee__default.default,{href:v(t,i.previous.slug),className:"rounded-xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] px-3 py-2 text-sm transition-colors hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground block text-xs",children:"Previous"}),jsxRuntime.jsx("span",{className:"line-clamp-2 font-medium",children:i.previous.title})]}),i.next&&jsxRuntime.jsxs(ee__default.default,{href:v(t,i.next.slug),className:"rounded-xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] px-3 py-2 text-sm transition-colors hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground block text-xs",children:"Next"}),jsxRuntime.jsx("span",{className:"line-clamp-2 font-medium",children:i.next.title})]})]})]}),i.articles.length>0&&jsxRuntime.jsx("ol",{className:"mt-5 grid gap-2",children:i.articles.map(o=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs(ee__default.default,{href:v(t,o.slug),"aria-current":o.isCurrent?"page":void 0,className:f("hover:bg-background/60 flex gap-3 rounded-xl px-3 py-2 text-sm transition-colors hover:no-underline",o.isCurrent&&"bg-background/70"),children:[jsxRuntime.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:o.position}),jsxRuntime.jsx("span",{className:f("line-clamp-2",o.isCurrent?"font-semibold text-[var(--blog-text-accent)]":"font-medium"),children:o.title})]})},o.id))})]}):null}function kt(e,t,r={}){let i=r.limit??3;if(i<=0)return [];let o=mr(e),n=dn(e,t),s=(c,d)=>gr(d)-gr(c)||pr(c).localeCompare(pr(d)),a=o?n.filter(c=>mr(c)===o).sort(s):[],l=new Set(a.map(c=>c.id)),u=n.filter(c=>!l.has(c.id)).sort(s);return [...a,...u].slice(0,i)}function dn(e,t){let r=new Set,i=new Set,o=[];for(let n of t)n.id===e.id||n.slug===e.slug||r.has(n.id)||i.has(n.slug)||(r.add(n.id),i.add(n.slug),o.push(n));return o}function mr(e){let t=e.topics??[];return t.find(r=>r.isPrimary)?.slug??t[0]?.slug??null}function gr(e){let t=Date.parse(e.publishedAt??e.updatedAt??"");return Number.isFinite(t)?t:0}function pr(e){return e.title??e.slug}function hn(e){return `${Math.ceil(e/60)} min read`}function bn(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function xn({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??bn(t??"");return jsxRuntime.jsxs("span",{children:["Credit:"," ",t?jsxRuntime.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 vr({article:e,className:t,navigation:r,basePath:i="/blog",theme:o,postArticleCta:n,newsletter:s,newsletterPreviewMode:a=false,articles:l=[],relatedArticles:u=[],showShareLinks:c=true}){let d=_(i)||"/",h=Pt(e.publishedAt,e.updatedAt),y=hn(e.readingSeconds),p=At(e.content),g=e.meta.canonicalUrl??v(d,e.slug),b=s??e.site.newsletter,T=n??e.cta,M=e.featuredImage,S=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl),B=u.length>0?u.slice(0,3):kt(e,l);return jsxRuntime.jsxs("article",{style:$(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&&jsxRuntime.jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxRuntime.jsxs(ee__default.default,{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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsxRuntime.jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsxRuntime.jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsxRuntime.jsx("style",{children:`
3
3
  .article-content figure > p {
4
4
  margin-top: 0 !important;
5
5
  margin-bottom: 0 !important;
@@ -36,13 +36,13 @@
36
36
  text-decoration-line: underline;
37
37
  text-underline-offset: 0.18em;
38
38
  }
39
- `}),jsxRuntime.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:[jsxRuntime.jsx("h1",{className:b("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",V),children:e.title}),e.excerpt&&jsxRuntime.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}),jsxRuntime.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&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsxs(ee__default.default,{href:_(s,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(nr,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsxRuntime.jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${f.publishedDateLabel}`,children:["Published ",f.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:f.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:h})]}),f.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",f.updatedDateLabel]}),m&&jsxRuntime.jsx(ze,{title:e.title,url:p,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(H=>jsxRuntime.jsx(ee__default.default,{href:N((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${H.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:H.name},H.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),$&&jsxRuntime.jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsxRuntime.jsx(mt__default.default,{src:$,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-auto w-full rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",width:1200,height:800,priority:true}),A&&jsxRuntime.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&&jsxRuntime.jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsxRuntime.jsx("p",{className:"text-xs",children:jsxRuntime.jsx(ni,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(gt,{items:g,contentId:"article-body",variant:"mobile"}),jsxRuntime.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:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:Yt,components:{img:Kt}})})]}),jsxRuntime.jsx(gt,{items:g,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(le,{className:"mb-8"}),jsxRuntime.jsx(Ce,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(Le,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(nr,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsxRuntime.jsx(ee__default.default,{href:_(s,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(ii,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((S??false)||(x?.enabled??false)||m||C.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(le,{}),S&&jsxRuntime.jsx(si,{cta:S}),x?.enabled&&jsxRuntime.jsx(Te,{siteId:e.site.id,settings:x,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:p,previewMode:c}),m&&jsxRuntime.jsx(li,{title:e.title,url:p}),C.length>0&&jsxRuntime.jsx(ci,{articles:C,basePath:s})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(le,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(Ce,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(ee__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(xt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(Le,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(Ce,{className:b("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxRuntime.jsxs(ee__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(xt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(Le,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let H=ae(st(e,{customDomain:e.site.domain,pathPrefix:s}));return jsxRuntime.jsx("script",{type:H.type,dangerouslySetInnerHTML:H.dangerouslySetInnerHTML})})()]})}function nr({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=ai(e.name);return e.avatarUrl?jsxRuntime.jsx(mt__default.default,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:b("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function ii({author:e}){let t=oi(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.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 oi(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function ai(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function si({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row",children:[e.primary&&jsxRuntime.jsxs(ee__default.default,{href:e.primary.href,className:"inline-flex 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.primary.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]}),e.secondary&&jsxRuntime.jsxs(ee__default.default,{href:e.secondary.href,className:"border-border bg-background text-foreground hover:bg-muted inline-flex items-center justify-center gap-2 rounded-full border px-4 py-2 text-sm font-semibold transition-colors",children:[e.secondary.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})]})})}function li({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(ze,{title:e,url:t,size:"sm"}),jsxRuntime.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:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.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:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.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:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function ci({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(ee__default.default,{href:N(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&&jsxRuntime.jsx(xt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function xt({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(mt__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})})}function ui(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${N(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 ur({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:c}){let l=E(o)||"/",u=c?.backToHome?.url??l,m=_(l,e.slug),s=a?.totalItems??t.length,f=ae(He(e,{pathPrefix:l}));return jsxRuntime.jsxs("main",{style:j(i),className:b("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxRuntime.jsxs(ee__default.default,{href:u,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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),c?.backToHome?.label??"Back to all articles"]}),jsxRuntime.jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsxRuntime.jsx(xi,{author:e}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsxRuntime.jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsxRuntime.jsx("h1",{className:b("text-4xl leading-tight font-light text-balance sm:text-5xl",V),children:e.name})]}),e.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsxRuntime.jsx(fi,{author:e})]})]})]}),jsxRuntime.jsx(le,{className:"mb-8"}),jsxRuntime.jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s," ",s===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsxRuntime.jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsxRuntime.jsx(bi,{article:h,basePath:l},h.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pt-4",children:jsxRuntime.jsx(ge,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??m,className:"justify-center"})})]}),jsxRuntime.jsx("script",{type:f.type,dangerouslySetInnerHTML:f.dangerouslySetInnerHTML})]})}function fi({author:e}){let t=hi(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsxRuntime.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 hi(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsxRuntime.jsx(lucideReact.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:jsxRuntime.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:jsxRuntime.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:jsxRuntime.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:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function bi({article:e,basePath:t}){let r=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxRuntime.jsxs(ee__default.default,{href:N(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxRuntime.jsxs("div",{className:"min-w-0 space-y-3",children:[jsxRuntime.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&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsxRuntime.jsx("time",{dateTime:e.publishedAt,children:r}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxRuntime.jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsxRuntime.jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(mt__default.default,{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-300 group-hover:scale-105"})})]})})}function xi({author:e}){return e.avatarUrl?jsxRuntime.jsx(mt__default.default,{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}):jsxRuntime.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:yi(e.name)})}function yi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function vi(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${_(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 Ve=class{articles=new Map;operations=new Map;metadata=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,u)=>{let m=new Date(l[o]).getTime(),s=new Date(u[o]).getTime();return i==="desc"?s-m:m-s}),{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);}async setMetadata(t,r){this.metadata.set(t,r);}async getMetadata(t){return this.metadata.has(t)?this.metadata.get(t):null}};function Pi(){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 Ai(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Pi(),e.__BLOG_PLATFORM_STORAGE__=new Ve);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function M(){return Ai()}function vt(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function xe(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,mr(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function dr(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?mr(o,i.author):o,null);return n?{author:n,articles:r}:null}async function wi(e,t={},r=M()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return dr(e,n)}function mr(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 Si(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function ye(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 Ri({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=E(t)||"/",c=ye(e);return jsxRuntime.jsxs("main",{style:j(i),className:b("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>(m.topics??[]).some(s=>s.slug===l.slug)).length;return jsxRuntime.jsxs(ee__default.default,{href:N(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:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function Ci({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=E(r)||"/",a=Pt(e,t);return jsxRuntime.jsxs("main",{style:j(o),className:b("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:N(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(c=>jsxRuntime.jsx(Li,{article:c,topic:a.topic,basePath:i},c.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function Li({article:e,topic:t,basePath:r}){let n=N(r,e.slug),o=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(ee__default.default,{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&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(mt__default.default,{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"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.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}),jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function _i({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=E(t)||"/",c=xe(e);return jsxRuntime.jsxs("main",{style:j(i),className:b("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>m.author?.slug===l.slug).length;return jsxRuntime.jsx(ee__default.default,{href:_(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:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx(Ii,{author:l}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-2",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function Ii({author:e}){let t=Bi(e.name);return e.avatarUrl?jsxRuntime.jsx(mt__default.default,{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"}):jsxRuntime.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 Bi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function F(e){return `sha256:${crypto.createHash("sha256").update(e).digest("hex")}`}function At(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 Xe=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=>At(t);hashToken(t){return F(t)}},ve=class extends Xe{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"}},We=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 Oi(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new We,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ke(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function wt(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??Oi()}function Mi(e){Ke(new ve(e));}async function W(e){let t=wt(),r=t.extractToken?t.extractToken(e):At(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 $i(e,t=""){let n=wt().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:$i(t.result)}}function Di(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function Hi(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function ji(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.Redis({url:t,token:r}),c=new ratelimit.Ratelimit({redis:a,analytics:i,prefix:o,limiter:ratelimit.Ratelimit.slidingWindow(n,"1m")});ji(c);}function St(){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 fr(e){let t=Hi();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 hr(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 fr(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:hr(r,t)}}function B(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 Ye(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
39
+ `}),jsxRuntime.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:[jsxRuntime.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",U),children:e.title}),e.excerpt&&jsxRuntime.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}),jsxRuntime.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&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsxs(ee__default.default,{href:I(d,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(hr,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsxRuntime.jsx(Ie,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${h.publishedDateLabel}`,children:["Published ",h.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:h.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:y})]}),h.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",h.updatedDateLabel]}),c&&jsxRuntime.jsx(Qe,{title:e.title,url:g,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(D=>jsxRuntime.jsx(ee__default.default,{href:v((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${D.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:D.name},D.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),M&&jsxRuntime.jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsxRuntime.jsx(wt__default.default,{src:M,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-auto w-full rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",width:1200,height:800,priority:true}),S&&jsxRuntime.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&&jsxRuntime.jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsxRuntime.jsx("p",{className:"text-xs",children:jsxRuntime.jsx(xn,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(Tt,{items:p,contentId:"article-body",variant:"mobile"}),jsxRuntime.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)] [&_figcaption]:text-muted-foreground [&_figcaption_.blog-image-credit]:text-muted-foreground/80 [&_figcaption>span:not(.blog-image-credit)]:text-muted-foreground/80 max-w-none [&_figcaption]:!mt-2 [&_figcaption]:text-center [&_figcaption]:!text-sm [&_figcaption]:!leading-snug [&_figcaption_.blog-image-credit]:mt-1 [&_figcaption_.blog-image-credit]:block [&_figcaption_.blog-image-credit]:text-xs [&_figcaption_.blog-image-credit]:tracking-wide [&_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 [&_figure>p]:!my-0",children:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:ur,components:{img:lr}})})]}),jsxRuntime.jsx(Tt,{items:p,contentId:"article-body",variant:"desktop",showProgress:false})]}),jsxRuntime.jsx(Lt,{article:e,basePath:d,className:"mx-auto mt-12 max-w-4xl"}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ge,{className:"mb-8"}),jsxRuntime.jsx(Ee,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(Oe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(hr,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsxRuntime.jsx(ee__default.default,{href:I(d,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(Ie,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(yn,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((T??false)||(b?.enabled??false)||c||B.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(ge,{}),T&&jsxRuntime.jsx(An,{cta:T}),b?.enabled&&jsxRuntime.jsx(Be,{siteId:e.site.id,settings:b,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:g,previewMode:a}),c&&jsxRuntime.jsx(Sn,{title:e.title,url:g}),B.length>0&&jsxRuntime.jsx(wn,{articles:B,basePath:d})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ge,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(Ee,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(ee__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(_t,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(Oe,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(Ee,{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:jsxRuntime.jsxs(ee__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(_t,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(Oe,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let D=de(yt(e,{customDomain:e.site.domain,pathPrefix:d}));return jsxRuntime.jsx("script",{type:D.type,dangerouslySetInnerHTML:D.dangerouslySetInnerHTML})})()]})}function hr({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",i=Pn(e.name);return e.avatarUrl?jsxRuntime.jsx(wt__default.default,{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"}):jsxRuntime.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:i})}function yn({author:e}){let t=vn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.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 vn(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(i=>!!i):[]}function Pn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function An({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row",children:[e.primary&&jsxRuntime.jsxs(ee__default.default,{href:e.primary.href,className:"inline-flex 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.primary.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]}),e.secondary&&jsxRuntime.jsxs(ee__default.default,{href:e.secondary.href,className:"border-border bg-background text-foreground hover:bg-muted inline-flex items-center justify-center gap-2 rounded-full border px-4 py-2 text-sm font-semibold transition-colors",children:[e.secondary.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})]})})}function Sn({title:e,url:t}){let r=encodeURIComponent(e),i=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(Qe,{title:e,url:t,size:"sm"}),jsxRuntime.jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${i}`,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:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${i}`,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:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`mailto:?subject=${r}&body=${i}`,"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:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function wn({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(ee__default.default,{href:v(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&&jsxRuntime.jsx(_t,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function _t({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(wt__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})})}function Nn(e,t="/blog"){let r=e.meta.title??e.title,i=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${v(t,e.slug)}`,n=e.meta.ogImage??e.featuredImage;return {title:r,description:i,keywords:e.meta.keywords.join(", "),authors:e.author?[{name:e.author.name}]:void 0,openGraph:{title:r,description:i,type:"article",url:o,images:n?[{url:n,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:i,images:n?[n]:void 0},alternates:{canonical:o}}}function et({articles:e,title:t,kind:r,slug:i,basePath:o}){let n=e[0]?.site;if(!n)return null;let s=n.domain,a=v(o,`${r}/${i}`),l={"@context":"https://schema.org","@type":"CollectionPage",name:t,url:`https://${s}${a}`,mainEntity:{"@type":"ItemList",itemListElement:e.map((c,d)=>({"@type":"ListItem",position:d+1,name:c.title,url:`https://${s}${v(o,c.slug)}`}))}},u=Xe([{name:"Home",url:"/"},{name:n.name,url:o},{name:r==="topics"?"Topics":"Series",url:v(o,r)},{name:t,url:a}],{customDomain:s});return jsxRuntime.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:We([l,u])}})}function Se(e){let t=new Map;for(let r of e)r.series&&(!t.has(r.series.slug)||r.series.articles.length>(t.get(r.series.slug)?.articles.length??0))&&t.set(r.series.slug,r.series);return Array.from(t.values()).sort((r,i)=>r.title.localeCompare(i.title))}function It(e,t){let r=e.filter(o=>o.series?.slug===t).sort((o,n)=>(o.series?.position??0)-(n.series?.position??0));if(r.length===0)return null;let i=r[0]?.series;return i?{series:i,articles:r}:null}function Rn(e){return e.series??null}function Et({articles:e,basePath:t="/blog",title:r="Series",description:i="Browse related article series.",className:o,theme:n}){let s=_(t)||"/",a=Se(e);return jsxRuntime.jsxs("main",{style:$(n),className:f("blog-series-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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:s,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",U),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:i})]}),a.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No series have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:a.map(l=>jsxRuntime.jsxs(ee__default.default,{href:oe(s,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:[jsxRuntime.jsxs("p",{className:"text-muted-foreground mb-2 text-sm font-medium",children:[l.total," ",l.total===1?"article":"articles"]}),jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.title}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description})]},l.slug))})]})}function Ot({articles:e,seriesSlug:t,basePath:r="/blog",className:i,theme:o}){let n=_(r)||"/",s=It(e,t);return jsxRuntime.jsxs("main",{style:$(o),className:f("blog-series-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",i),children:[s&&jsxRuntime.jsx(et,{articles:s.articles,title:s.series.title,kind:"series",slug:t,basePath:n}),jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:v(n,"series"),className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all series"}),jsxRuntime.jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",U),children:s?.series.title??"Series not found"}),s?.series.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:s.series.description})]}),s?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:s.articles.map(a=>jsxRuntime.jsx(kn,{article:a,basePath:n},a.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this series."})]})}function kn({article:e,basePath:t}){let r=v(t,e.slug),i=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(ee__default.default,{href:r,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&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(wt__default.default,{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"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[e.series&&jsxRuntime.jsxs("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:["Part ",e.series.position]}),jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-balance transition-colors group-hover:text-[var(--blog-accent)]",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:i})]})]})}function Pr(e){return jsxRuntime.jsx(Et,{...e})}function _n(e="/blog"){return {title:"Series",description:"Browse related article series.",alternates:{canonical:`${e.replace(/\/$/,"")}/series`}}}function Ar(e){return jsxRuntime.jsx(Ot,{...e})}function In({title:e,description:t,slug:r,basePath:i="/blog"}){return {title:e,description:t??`Read the ${e} article series.`,alternates:{canonical:`${i.replace(/\/$/,"")}/series/${r}`}}}function Nr({author:e,articles:t,site:r,className:i,basePath:o="/blog",theme:n,pagination:s,navigation:a}){let l=_(o)||"/",u=a?.backToHome?.url??l,c=I(l,e.slug),d=s?.totalItems??t.length,h=de(qe(e,{pathPrefix:l}));return jsxRuntime.jsxs("main",{style:$(n),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",i),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxRuntime.jsxs(ee__default.default,{href:u,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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),a?.backToHome?.label??"Back to all articles"]}),jsxRuntime.jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsxRuntime.jsx(Gn,{author:e}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsxRuntime.jsx(Ie,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsxRuntime.jsx("h1",{className:f("text-4xl leading-tight font-light text-balance sm:text-5xl",U),children:e.name})]}),e.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsxRuntime.jsx(Un,{author:e})]})]})]}),jsxRuntime.jsx(ge,{className:"mb-8"}),jsxRuntime.jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[d," ",d===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsxRuntime.jsx("div",{className:"divide-border divide-y",children:t.map(y=>jsxRuntime.jsx(Fn,{article:y,basePath:l},y.id))}),s&&s.totalPages>1&&jsxRuntime.jsx("div",{className:"pt-4",children:jsxRuntime.jsx(ye,{currentPage:s.currentPage,totalPages:s.totalPages,baseUrl:s.baseUrl??c,className:"justify-center"})})]}),jsxRuntime.jsx("script",{type:h.type,dangerouslySetInnerHTML:h.dangerouslySetInnerHTML})]})}function Un({author:e}){let t=Hn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsxRuntime.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:jsxRuntime.jsx(lucideReact.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:jsxRuntime.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:jsxRuntime.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:jsxRuntime.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:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function Fn({article:e,basePath:t}){let r=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxRuntime.jsxs(ee__default.default,{href:v(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxRuntime.jsxs("div",{className:"min-w-0 space-y-3",children:[jsxRuntime.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&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsxRuntime.jsx("time",{dateTime:e.publishedAt,children:r}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxRuntime.jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsxRuntime.jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(wt__default.default,{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-300 group-hover:scale-105"})})]})})}function Gn({author:e}){return e.avatarUrl?jsxRuntime.jsx(wt__default.default,{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}):jsxRuntime.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 zn(e,t,r="/blog"){let i=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${I(r,e.slug)}`,o=`${e.name} - ${t.name}`,n=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:o,description:n,authors:[{name:e.name}],openGraph:{title:o,description:n,type:"profile",url:i,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:n,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:i}}}var rt=class{articles=new Map;operations=new Map;metadata=new Map;async saveArticle(t,r){let i=await this.checkIdempotency(r);if(i)if(i.success){if(Array.from(this.articles.values()).some(s=>s.id===t.id))return i}else return i;if(this.articles.has(t.slug)){let n={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,n),n}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:i=0,sortBy:o="publishedAt",order:n="desc"}=t,s=Array.from(this.articles.values());return s.sort((l,u)=>{let c=new Date(l[o]).getTime(),d=new Date(u[o]).getTime();return n==="desc"?d-c:c-d}),{articles:s.slice(i,i+r),total:s.length}}async removeArticle(t,r){let i=await this.checkIdempotency(r);if(i)if(i.success){if(!this.articles.has(t))return i}else return i;if(!this.articles.has(t)){let n={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,n),n}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);}async setMetadata(t,r){this.metadata.set(t,r);}async getMetadata(t){return this.metadata.has(t)?this.metadata.get(t):null}};function Vn(){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 qn(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Vn(),e.__BLOG_PLATFORM_STORAGE__=new rt);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function F(){return qn()}function Mt(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function we(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Rr(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,i)=>r.name.localeCompare(i.name))}function Tr(e,t){let r=t.filter(o=>o.author?.slug===e).sort((o,n)=>new Date(n.publishedAt).getTime()-new Date(o.publishedAt).getTime()),i=r.reduce((o,n)=>n.author?Rr(o,n.author):o,null);return i?{author:i,articles:r}:null}async function Xn(e,t={},r=F()){let{articles:i}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return Tr(e,i)}function Rr(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 Wn(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function Ne(e){let t=new Map;for(let r of e)for(let i of r.topics??[])t.has(i.slug)||t.set(i.slug,i);return Array.from(t.values()).sort((r,i)=>r.name.localeCompare(i.name))}function $t(e,t){let r=e.filter(o=>(o.topics??[]).some(n=>n.slug===t));if(r.length===0)return null;let i=r.flatMap(o=>o.topics??[]).find(o=>o.slug===t)??null;return i?{topic:i,articles:r}:null}function Yn({articles:e,basePath:t="/blog",title:r="Topics",description:i="Browse articles by topic.",className:o,theme:n}){let s=_(t)||"/",a=Ne(e);return jsxRuntime.jsxs("main",{style:$(n),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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:s,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",U),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:i})]}),a.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:a.map(l=>{let u=e.filter(c=>(c.topics??[]).some(d=>d.slug===l.slug)).length;return jsxRuntime.jsxs(ee__default.default,{href:v(s,`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:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function Qn({articles:e,topicSlug:t,basePath:r="/blog",className:i,theme:o}){let n=_(r)||"/",s=$t(e,t);return jsxRuntime.jsxs("main",{style:$(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",i),children:[s&&jsxRuntime.jsx(et,{articles:s.articles,title:s.topic.name,kind:"topics",slug:t,basePath:n}),jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:v(n,"topics"),className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",U),children:s?.topic.name??"Topic not found"}),s?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:s.topic.description})]}),s?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:s.articles.map(a=>jsxRuntime.jsx(Zn,{article:a,topic:s.topic,basePath:n},a.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function Zn({article:e,topic:t,basePath:r}){let i=v(r,e.slug),o=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(ee__default.default,{href:i,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&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(wt__default.default,{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"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.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}),jsxRuntime.jsx("h2",{className:"text-xl font-semibold text-balance transition-colors group-hover:text-[var(--blog-accent)]",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function to({articles:e,basePath:t="/blog",title:r="Authors",description:i="Browse articles by author.",className:o,theme:n}){let s=_(t)||"/",a=we(e);return jsxRuntime.jsxs("main",{style:$(n),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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(ee__default.default,{href:s,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:f("text-4xl font-light tracking-tight text-balance sm:text-5xl",U),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:i})]}),a.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:a.map(l=>{let u=e.filter(c=>c.author?.slug===l.slug).length;return jsxRuntime.jsx(ee__default.default,{href:I(s,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:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx(ro,{author:l}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-2",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function ro({author:e}){let t=io(e.name);return e.avatarUrl?jsxRuntime.jsx(wt__default.default,{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"}):jsxRuntime.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 io(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function V(e){return `sha256:${crypto.createHash("sha256").update(e).digest("hex")}`}function Dt(e){let t=e.headers.get("Authorization");if(!t)return null;let i=/^Bearer\s+(.+)$/i.exec(t);if(i?.[1])return i[1];let n=/^Token\s+(.+)$/i.exec(t);return n?.[1]?n[1]:null}var nt=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=>Dt(t);hashToken(t){return V(t)}},Te=class extends nt{constructor(t="BLOG_PLATFORM_API_KEYS"){let r=process.env[t];!r&&t==="BLOG_PLATFORM_API_KEYS"&&(r=process.env.BLOG_AUTH_TOKEN);let i=r?r.split(",").map(o=>o.trim()).filter(Boolean):[];i.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(i);}},Ue=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},ot=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 oo(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new ot,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function st(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function Ut(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??oo()}function so(e){st(new Te(e));}async function J(e){let t=Ut(),r=t.extractToken?t.extractToken(e):Dt(e);if(!r)return {authenticated:false,result:{valid:false,errorCode:"missing"},token:null};let i=await t.validateToken(r);return {authenticated:i.valid,result:i,token:r}}function ao(e,t=""){let i=Ut().errorMessages??{},o,n;switch(e.errorCode){case "missing":o=i.missing??"Authentication token is required",n="PUB005";break;case "expired":o=i.expired??"Authentication token has expired",n="PUB005";break;default:o=i.invalid??"Invalid authentication credentials",n="PUB005";break}return {success:false,error:{code:n,message:o,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function te(e){let t=await J(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:ao(t.result)}}function lo(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function uo(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function mo(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function at(e){let{redisUrl:t,redisToken:r,requestsPerMinute:i=5,keyPrefix:o="blog-platform-ratelimit",analytics:n=true}=e,s=new redis.Redis({url:t,token:r}),a=new ratelimit.Ratelimit({redis:s,analytics:n,prefix:o,limiter:ratelimit.Ratelimit.slidingWindow(i,"1m")});mo(a);}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}at({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function kr(e){let t=uo();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 _r(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 Y(e,t=""){let r=await kr(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:_r(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 lt(e){let{auth:t,storage:r,rateLimit:i,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
40
40
  Example: initBlogPlatform({ auth: new EnvAuth() })
41
- 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"),Je(n)):o?(console.log("Blog platform: Auto-configuring rate limiting from environment"),St()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),vt(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 Fi(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Ye(e);}function Gi(){Ye({auth:new Be,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function zi(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.`);Ye({auth:new ve(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var T=sqliteCore.sqliteTable("bp_articles",{id:sqliteCore.text("id").primaryKey(),slug:sqliteCore.text("slug").notNull(),title:sqliteCore.text("title").notNull(),excerpt:sqliteCore.text("excerpt").notNull(),content:sqliteCore.text("content").notNull(),readingSeconds:sqliteCore.integer("reading_seconds").notNull(),wordCount:sqliteCore.integer("word_count").notNull(),publishedAt:sqliteCore.text("published_at").notNull(),updatedAt:sqliteCore.text("updated_at").notNull(),featuredImage:sqliteCore.text("featured_image"),featuredImageAlt:sqliteCore.text("featured_image_alt"),featuredImageCaption:sqliteCore.text("featured_image_caption"),featuredImageCreditText:sqliteCore.text("featured_image_credit_text"),featuredImageCreditUrl:sqliteCore.text("featured_image_credit_url"),authorJson:sqliteCore.text("author_json"),siteJson:sqliteCore.text("site_json").notNull(),metaJson:sqliteCore.text("meta_json").notNull(),version:sqliteCore.integer("version").notNull()},e=>({slugUniqueIdx:sqliteCore.uniqueIndex("bp_articles_slug_unique").on(e.slug)})),ue=sqliteCore.sqliteTable("bp_operations",{key:sqliteCore.text("key").primaryKey(),resultJson:sqliteCore.text("result_json").notNull(),createdAt:sqliteCore.integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:sqliteCore.integer("expires_at",{mode:"timestamp_ms"})}),ne=sqliteCore.sqliteTable("bp_metadata",{key:sqliteCore.text("key").primaryKey(),valueJson:sqliteCore.text("value_json").notNull(),updatedAt:sqliteCore.integer("updated_at",{mode:"timestamp_ms"}).notNull()}),kt=2,Ee=["bp_articles","bp_operations","bp_metadata"],Wi={bpArticles:T,bpOperations:ue,bpMetadata:ne};function Ki(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??[],__bloggyCta:e.cta??null}),version:e.version}}function br(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),cta:Yi(e.metaJson),topics:Ji(e.metaJson),meta:Qi(e.metaJson),version:e.version}}function _t(e){return JSON.parse(e)}function Ji(e){return _t(e).__bloggyTopics??[]}function Yi(e){return _t(e).__bloggyCta??void 0}function Qi(e){let t=_t(e);return delete t.__bloggyTopics,delete t.__bloggyCta,t}var Oe=class extends Error{code="BLOG_PLATFORM_SCHEMA_MISSING";missingTables;setupSql;constructor(t,r={}){super(`Blog platform database schema is missing required table(s): ${t.join(", ")}. Run the @xexr/blog-platform schema migration/setup for the current package version.`),this.name="BlogPlatformSchemaError",this.missingTables=t,this.setupSql=t.map(Pr),r.cause!==void 0&&(this.cause=r.cause);}},Nt=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:T.id}).from(T).where(drizzleOrm.eq(T.id,t.id)).limit(1)).length!==0)return n}else return n;let o=await this.db.select().from(T).where(drizzleOrm.eq(T.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=Ki(t);o.length===0?await this.db.insert(T).values(a).run():await this.db.update(T).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(drizzleOrm.and(drizzleOrm.eq(T.id,a.id),drizzleOrm.eq(T.slug,a.slug))).run();let c={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,c),c}async getArticle(t){let r=await this.db.select().from(T).where(drizzleOrm.eq(T.slug,t)).limit(1);return r[0]?br(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=o==="publishedAt"?T.publishedAt:T.updatedAt,c=i==="desc"?drizzleOrm.desc(a):a,l=await this.db.select().from(T).orderBy(c).limit(r).offset(n),u=await this.db.select({c:drizzleOrm.sql`count(*)`}).from(T),m=Number(u?.[0]?.c??0);return {articles:l.map(br),total:m}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!((await this.db.select({id:T.id}).from(T).where(drizzleOrm.eq(T.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(T).where(drizzleOrm.eq(T.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(T).where(drizzleOrm.eq(T.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(ue).where(drizzleOrm.eq(ue.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(ue).where(drizzleOrm.eq(ue.key,t)).run(),await this.db.insert(ue).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:o?new Date(o):null}).run();}async setMetadata(t,r){let n=new Date;try{await this.db.delete(ne).where(drizzleOrm.eq(ne.key,t)).run(),await this.db.insert(ne).values({key:t,valueJson:JSON.stringify(r),updatedAt:n}).run();}catch(o){xr(o,"bp_metadata");}}async getMetadata(t){let r;try{r=await this.db.select({valueJson:ne.valueJson}).from(ne).where(drizzleOrm.eq(ne.key,t)).limit(1);}catch(o){xr(o,"bp_metadata");}let n=r[0];if(!n)return null;try{return JSON.parse(n.valueJson)}catch{return null}}};async function vr(e){let t=await e.all(drizzleOrm.sql`
41
+ See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),st(t),i?(console.log("Blog platform: Using custom rate limiting configuration"),at(i)):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"),Mt(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 go(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),lt(e);}function po(){lt({auth:new Ue,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function fo(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.`);lt({auth:new Te(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var N=sqliteCore.sqliteTable("bp_articles",{id:sqliteCore.text("id").primaryKey(),slug:sqliteCore.text("slug").notNull(),title:sqliteCore.text("title").notNull(),excerpt:sqliteCore.text("excerpt").notNull(),content:sqliteCore.text("content").notNull(),readingSeconds:sqliteCore.integer("reading_seconds").notNull(),wordCount:sqliteCore.integer("word_count").notNull(),publishedAt:sqliteCore.text("published_at").notNull(),updatedAt:sqliteCore.text("updated_at").notNull(),featuredImage:sqliteCore.text("featured_image"),featuredImageAlt:sqliteCore.text("featured_image_alt"),featuredImageCaption:sqliteCore.text("featured_image_caption"),featuredImageCreditText:sqliteCore.text("featured_image_credit_text"),featuredImageCreditUrl:sqliteCore.text("featured_image_credit_url"),authorJson:sqliteCore.text("author_json"),siteJson:sqliteCore.text("site_json").notNull(),metaJson:sqliteCore.text("meta_json").notNull(),version:sqliteCore.integer("version").notNull()},e=>({slugUniqueIdx:sqliteCore.uniqueIndex("bp_articles_slug_unique").on(e.slug)})),fe=sqliteCore.sqliteTable("bp_operations",{key:sqliteCore.text("key").primaryKey(),resultJson:sqliteCore.text("result_json").notNull(),createdAt:sqliteCore.integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:sqliteCore.integer("expires_at",{mode:"timestamp_ms"})}),le=sqliteCore.sqliteTable("bp_metadata",{key:sqliteCore.text("key").primaryKey(),valueJson:sqliteCore.text("value_json").notNull(),updatedAt:sqliteCore.integer("updated_at",{mode:"timestamp_ms"}).notNull()}),qt=2,He=["bp_articles","bp_operations","bp_metadata"],yo={bpArticles:N,bpOperations:fe,bpMetadata:le};function vo(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??[],__bloggySeries:e.series??null,__bloggyCta:e.cta??null}),version:e.version}}function Br(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),cta:Ao(e.metaJson),topics:Po(e.metaJson),series:So(e.metaJson),meta:wo(e.metaJson),version:e.version}}function ct(e){return JSON.parse(e)}function Po(e){return ct(e).__bloggyTopics??[]}function Ao(e){return ct(e).__bloggyCta??void 0}function So(e){return ct(e).__bloggySeries??void 0}function wo(e){let t=ct(e);return delete t.__bloggyTopics,delete t.__bloggySeries,delete t.__bloggyCta,t}var Fe=class extends Error{code="BLOG_PLATFORM_SCHEMA_MISSING";missingTables;setupSql;constructor(t,r={}){super(`Blog platform database schema is missing required table(s): ${t.join(", ")}. Run the @xexr/blog-platform schema migration/setup for the current package version.`),this.name="BlogPlatformSchemaError",this.missingTables=t,this.setupSql=t.map(Mr),r.cause!==void 0&&(this.cause=r.cause);}},Ft=class{db;options;constructor(t,r={}){this.db=t,this.options=r;}async saveArticle(t,r){let i=await this.checkIdempotency(r);if(i)if(i.success){if((await this.db.select({id:N.id}).from(N).where(drizzleOrm.eq(N.id,t.id)).limit(1)).length!==0)return i}else return i;let o=await this.db.select().from(N).where(drizzleOrm.eq(N.slug,t.slug)).limit(1),n=o[0];if(n&&n.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 s=vo(t);o.length===0?await this.db.insert(N).values(s).run():await this.db.update(N).set({title:s.title,excerpt:s.excerpt,content:s.content,readingSeconds:s.readingSeconds,wordCount:s.wordCount,updatedAt:s.updatedAt,featuredImage:s.featuredImage,featuredImageAlt:s.featuredImageAlt,featuredImageCaption:s.featuredImageCaption,featuredImageCreditText:s.featuredImageCreditText,featuredImageCreditUrl:s.featuredImageCreditUrl,authorJson:s.authorJson,siteJson:s.siteJson,metaJson:s.metaJson,version:s.version}).where(drizzleOrm.and(drizzleOrm.eq(N.id,s.id),drizzleOrm.eq(N.slug,s.slug))).run();let a={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,a),a}async getArticle(t){let r=await this.db.select().from(N).where(drizzleOrm.eq(N.slug,t)).limit(1);return r[0]?Br(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:i=0,sortBy:o="publishedAt",order:n="desc"}=t,s=o==="publishedAt"?N.publishedAt:N.updatedAt,a=n==="desc"?drizzleOrm.desc(s):s,l=await this.db.select().from(N).orderBy(a).limit(r).offset(i),u=await this.db.select({c:drizzleOrm.sql`count(*)`}).from(N),c=Number(u?.[0]?.c??0);return {articles:l.map(Br),total:c}}async removeArticle(t,r){let i=await this.checkIdempotency(r);if(i)if(i.success){if(!((await this.db.select({id:N.id}).from(N).where(drizzleOrm.eq(N.slug,t)).limit(1)).length>0))return i}else return i;if(!(await this.db.select().from(N).where(drizzleOrm.eq(N.slug,t)).limit(1))[0]){let s={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,s),s}await this.db.delete(N).where(drizzleOrm.eq(N.slug,t)).run();let n={success:true,idempotencyKey:r};return await this.storeOperationResult(r,n),n}async checkIdempotency(t){let r=await this.db.select().from(fe).where(drizzleOrm.eq(fe.key,t)).limit(1);if(!r[0])return null;try{return JSON.parse(r[0].resultJson)}catch{return null}}async storeOperationResult(t,r){let i=Date.now(),o=this.options.operationTtlMs?i+this.options.operationTtlMs:null;await this.db.delete(fe).where(drizzleOrm.eq(fe.key,t)).run(),await this.db.insert(fe).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(i),expiresAt:o?new Date(o):null}).run();}async setMetadata(t,r){let i=new Date;try{await this.db.delete(le).where(drizzleOrm.eq(le.key,t)).run(),await this.db.insert(le).values({key:t,valueJson:JSON.stringify(r),updatedAt:i}).run();}catch(o){Ir(o,"bp_metadata");}}async getMetadata(t){let r;try{r=await this.db.select({valueJson:le.valueJson}).from(le).where(drizzleOrm.eq(le.key,t)).limit(1);}catch(o){Ir(o,"bp_metadata");}let i=r[0];if(!i)return null;try{return JSON.parse(i.valueJson)}catch{return null}}};async function Or(e){let t=await e.all(drizzleOrm.sql`
42
42
  SELECT name
43
43
  FROM sqlite_master
44
44
  WHERE type = 'table'
45
- `),r=new Set(t.map(i=>i.name)),n=Ee.filter(i=>r.has(i)),o=Ee.filter(i=>!r.has(i));return {ok:o.length===0,schemaVersion:kt,requiredTables:Ee,presentTables:n,missingTables:o,setupSql:o.map(Pr)}}async function Zi(e){let t=await vr(e);if(!t.ok)throw new Oe(t.missingTables)}var Tt=`CREATE TABLE IF NOT EXISTS bp_articles (
45
+ `),r=new Set(t.map(n=>n.name)),i=He.filter(n=>r.has(n)),o=He.filter(n=>!r.has(n));return {ok:o.length===0,schemaVersion:qt,requiredTables:He,presentTables:i,missingTables:o,setupSql:o.map(Mr)}}async function No(e){let t=await Or(e);if(!t.ok)throw new Fe(t.missingTables)}var Gt=`CREATE TABLE IF NOT EXISTS bp_articles (
46
46
  id TEXT PRIMARY KEY,
47
47
  slug TEXT NOT NULL UNIQUE,
48
48
  title TEXT NOT NULL,
@@ -61,20 +61,20 @@ See https://github.com/xexr/blog-platform#authentication for more details.`);con
61
61
  site_json TEXT NOT NULL,
62
62
  meta_json TEXT NOT NULL,
63
63
  version INTEGER NOT NULL
64
- );`,Rt=`CREATE TABLE IF NOT EXISTS bp_operations (
64
+ );`,jt=`CREATE TABLE IF NOT EXISTS bp_operations (
65
65
  key TEXT PRIMARY KEY,
66
66
  result_json TEXT NOT NULL,
67
67
  created_at INTEGER NOT NULL,
68
68
  expires_at INTEGER
69
- );`,Ct=`CREATE TABLE IF NOT EXISTS bp_metadata (
69
+ );`,zt=`CREATE TABLE IF NOT EXISTS bp_metadata (
70
70
  key TEXT PRIMARY KEY,
71
71
  value_json TEXT NOT NULL,
72
72
  updated_at INTEGER NOT NULL
73
- );`;function Pr(e){switch(e){case "bp_articles":return Tt;case "bp_operations":return Rt;case "bp_metadata":return Ct}}function xr(e,t){throw eo(e,t)?new Oe([t],{cause:e}):e}function eo(e,t){return Ar(e).some(r=>r.includes(`no such table: ${t}`)||r.includes(`no such table: main.${t}`))}function Ar(e){if(!e||typeof e!="object")return [String(e)];let t=[];e instanceof Error&&t.push(e.message);let r=e.cause;return r!==void 0&&t.push(...Ar(r)),t}function to(){return {schemaVersion:kt,requiredTableNames:Ee,createAll:[Tt,Rt,Ct],createArticles:Tt,createOperations:Rt,createMetadata:Ct}}function Ae(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 wr(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 de(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=Ae(o,r),c=wr(e.slug),l=i.replace(/^(?!\/)/,"/").replace(/\/+$/,""),u=`${a}${l}/${c}`;return n&&(u=u.replace(/\/+$/,"")),u}function ro(e,t,r={}){return de({slug:t,site:e},r)}function no(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 io(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function oo(e,t={}){let r=de(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function ao(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,c=r?.description??e.description,l=t.openGraph?.siteName??e.name,u=[{name:"description",content:c},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&u.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&u.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&u.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&u.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&u.push({name:"application-name",content:t.meta.applicationName});let m=[{property:"og:title",content:a},{property:"og:description",content:c},{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 s=so(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:a,description:c,image:t.openGraph?.defaultImage});return {meta:u,openGraph:m,twitter:s,links:[{rel:"canonical",href:i}],title:a,description:c,canonicalUrl:i}}function so(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 lo(e){let t=[];return t.push(`<title>${U(e.title)}</title>`),e.meta.forEach(r=>{let n=[];r.name&&n.push(`name="${U(r.name)}"`),r.property&&n.push(`property="${U(r.property)}"`),r.httpEquiv&&n.push(`http-equiv="${U(r.httpEquiv)}"`),n.push(`content="${U(r.content)}"`),t.push(`<meta ${n.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${U(r.property)}" content="${U(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${U(r.name)}" content="${U(r.content)}" />`);}),e.links.forEach(r=>{let n=[];n.push(`rel="${U(r.rel)}"`),n.push(`href="${U(r.href)}"`),r.type&&n.push(`type="${U(r.type)}"`),r.title&&n.push(`title="${U(r.title)}"`),t.push(`<link ${n.join(" ")} />`);}),t.join(`
74
- `)}function U(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function co(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 It(e,t,r=[],n={}){let{includeAuthorPages:o=true,includeTopicPages:i=true,includePaginationPages:a=true,articlesPerPage:c=10,maxEntries:l=5e4,changeFrequency:u={},priority:m={}}=n,s=[],f=Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),h=n.canonical?.pathPrefix??"/blog",g=r.length>0?r:xe(t),p=ye([...t]);if(s.push({url:`${f}${h}`,lastModified:z(t),changeFrequency:u.homePage??"daily",priority:m.homePage??1}),t.forEach(x=>{if(s.length>=l)return;let S=de(x,n.canonical);s.push({url:S,lastModified:x.updatedAt,changeFrequency:u.articles??"monthly",priority:m.articles??.8});}),i&&p.length>0&&(s.length<l&&s.push({url:`${f}${N(h,"topics")}`,lastModified:z(t),changeFrequency:u.topicPages??"weekly",priority:m.topicPages??.6}),p.forEach(x=>{if(s.length>=l)return;let S=t.filter($=>($.topics??[]).some(A=>A.slug===x.slug));s.push({url:`${f}${N(h,`topics/${x.slug}`)}`,lastModified:z(S),changeFrequency:u.topicPages??"weekly",priority:m.topicPages??.6});})),o&&g.length>0&&(s.length<l&&s.push({url:`${f}${N(h,"authors")}`,lastModified:z(t),changeFrequency:u.authorPages??"weekly",priority:m.authorPages??.6}),g.forEach(x=>{if(s.length>=l)return;let S=`${f}${_(h,x.slug)}`,$=t.filter(C=>C.author?.id===x.id),A=z($);s.push({url:S,lastModified:A,changeFrequency:u.authorPages??"weekly",priority:m.authorPages??.6});})),a&&t.length>c){let x=Math.ceil(t.length/c);for(let S=2;S<=x&&!(s.length>=l);S++)s.push({url:`${f}${h}?page=${S}`,lastModified:z(t),changeFrequency:u.paginationPages??"daily",priority:m.paginationPages??.5});}return s}function uo(e,t,r=[],n={}){let{includeAuthorPages:o=true,includeTopicPages:i=true,includePaginationPages:a=true,articlesPerPage:c=10,maxEntries:l=5e4,changeFrequency:u={},priority:m={}}=n,s=[],f=Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),h=n.canonical?.pathPrefix??"/blog",g=new Date().toISOString(),p=r.length>0?r:xe(t),x=ye([...t]),S=1;if(S+=t.length,i&&x.length>0&&(S+=x.length+1),o&&(S+=p.length>0?p.length+1:0),a&&t.length>c){let A=Math.ceil(t.length/c);S+=A-1;}let $=S>l;if(s.push({loc:`${f}${h}`,lastmod:z(t),changefreq:u.homePage??"daily",priority:m.homePage??1}),t.forEach(A=>{if(s.length>=l)return;let C=de(A,n.canonical);s.push({loc:C,lastmod:A.updatedAt,changefreq:u.articles??"monthly",priority:m.articles??.8});}),i&&x.length>0&&(s.length<l&&s.push({loc:`${f}${N(h,"topics")}`,lastmod:z(t),changefreq:u.topicPages??"weekly",priority:m.topicPages??.6}),x.forEach(A=>{if(s.length>=l)return;let C=t.filter(H=>(H.topics??[]).some(pe=>pe.slug===A.slug));s.push({loc:`${f}${N(h,`topics/${A.slug}`)}`,lastmod:z(C),changefreq:u.topicPages??"weekly",priority:m.topicPages??.6});})),o&&p.length>0&&(s.length<l&&s.push({loc:`${f}${N(h,"authors")}`,lastmod:z(t),changefreq:u.authorPages??"weekly",priority:m.authorPages??.6}),p.forEach(A=>{if(s.length>=l)return;let C=`${f}${_(h,A.slug)}`,H=t.filter(Ze=>Ze.author?.id===A.id),pe=z(H);s.push({loc:C,lastmod:pe,changefreq:u.authorPages??"weekly",priority:m.authorPages??.6});})),a&&t.length>c){let A=Math.ceil(t.length/c);for(let C=2;C<=A&&!(s.length>=l);C++)s.push({loc:`${f}${h}?page=${C}`,lastmod:z(t),changefreq:u.paginationPages??"daily",priority:m.paginationPages??.5});}return {entries:s,totalEntries:s.length,truncated:$,generatedAt:g,baseUrl:f}}function Sr(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>${Me(i.loc)}</loc>`),i.lastmod&&a.push(` <lastmod>${Me(i.lastmod)}</lastmod>`),i.changefreq&&a.push(` <changefreq>${Me(i.changefreq)}</changefreq>`),i.priority!==void 0&&a.push(` <priority>${i.priority.toFixed(1)}</priority>`),a.push(" </url>"),a.join(`
75
- `)});return [t,r,...o,n].join(`
76
- `)}function mo(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 c=[];return c.push(" <sitemap>"),c.push(` <loc>${Me(a.url)}</loc>`),a.lastmod&&c.push(` <lastmod>${Me(a.lastmod)}</lastmod>`),c.push(" </sitemap>"),c.join(`
77
- `)});return [r,n,...i,o].join(`
78
- `)}function po(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&&!ho(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 z(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 go(e,t,r=[],n={}){return async function(){let a=(await It(e,t,r,n)).map(u=>({loc:u.url,lastmod:typeof u.lastModified=="string"?u.lastModified:u.lastModified?.toISOString(),changefreq:u.changeFrequency,priority:u.priority})),c={entries:a,totalEntries:a.length,generatedAt:new Date().toISOString(),baseUrl:Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=Sr(c);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function fo(e){return async function(){let r=[...e.staticRoutes??[],...e.getStaticRoutes?await e.getStaticRoutes():[]],n=await e.getSite(),o=await e.getArticles(),i=e.getAuthors?await e.getAuthors():[];return [...r,...await It(n,o,i,e.options)]}}function Me(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function ho(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 we={name:"@xexr/blog-platform",version:"1.1.4"};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 J(){let e=Nr(we.version);return {name:we.name,version:we.version,...e}}function ie(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),c={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=c:o==="platform"&&(r.platformVersion=c);}return r}catch{return null}}function Tr(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 Rr={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 xo(){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 {...Rr,enableCSP:!e,frameOptions:t??Rr.frameOptions,enableHSTS:!r}}function yo(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function vo(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Po(e,t={}){let r={...xo(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=yo(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&&Ao(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"]=vo(o);}return n}function Ao(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function Qe(e,t={}){return Po(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var Cr={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 Lr(){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 {...Cr,allowedOrigins:e?e.split(",").map(n=>n.trim()):Cr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function kr(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function _r(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&kr(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 wo(e,t,r,n){return {..._r(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var So=["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={...Lr(),...i},c=_r(e,a),l=Qe(e,a.securityConfig),u={"Content-Type":"application/json",...c,...l,...o};return server_js.NextResponse.json(t,{status:n,headers:u})}function me(e,t,r={}){let{allowedHeaders:n=So,corsConfig:o={}}=r,i={...Lr(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!kr(a,i)){let u=Qe(e,i.securityConfig);return new server_js.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let c=wo(e,i,[...t,"OPTIONS"],n),l=Qe(e,i.securityConfig);return new server_js.NextResponse(null,{status:200,headers:{...c,...l}})}async function No(e){try{let t=await W(e);if(!t.authenticated){let p=await Q(e);return v(e,p.error,{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,x=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},S=B(x);return v(e,n.errorResponse,{status:429,headers:S})}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=To(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 c=e.headers.get("X-Bloggy-Version");if(c){let p=ie(c);if(p?.platformVersion){let x=J();if(p.platformVersion.major!==x.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:x.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(i.dryRun){let p=[];return i.article.wordCount<50&&p.push("Article has fewer than 50 words, which may affect SEO"),(!i.article.excerpt||i.article.excerpt.length<120)&&p.push("Article excerpt is shorter than recommended 120 characters"),i.article.meta.keywords.length||p.push("No SEO keywords provided"),v(e,{success:!0,warnings:p,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(!Et(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 m=await M().saveArticle(l,i.idempotencyKey),s=J(),f=B(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${s.version}`,"X-Idempotency-Key":i.idempotencyKey,...f};m.success&&(h.Location=m.url??`/${l.slug}`);let g=m.success?201:m.error?.code==="PUB003"?409:400;return v(e,m,{status:g,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 To(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 c of a)i[c]||t.push(`Missing required site field: ${c}`);}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 Et(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Co(e){try{let t=await W(e);if(!t.authenticated){let g=await Q(e);return server_js.NextResponse.json(g.error,{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit,p=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},x=B(p);return v(e,n.errorResponse,{status:429,headers:x})}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=Lo(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 c=e.headers.get("X-Bloggy-Version");if(c){let g=ie(c);if(g?.platformVersion){let p=J();if(g.platformVersion.major!==p.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:p.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(!ko(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 p=await M().getArticle(i.slug),x=[];return p||x.push("Article with this slug does not exist"),v(e,{success:!0,warnings:x,idempotencyKey:i.idempotencyKey},{status:200})}let u=await M().removeArticle(i.slug,i.idempotencyKey),m=J(),s=B(n.rateLimitResult),f={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...s},h=u.success?200:u.error?.code==="PUB007"?404:400;return v(e,u,{status:h,headers:f})}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 Lo(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 ko(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function _o(e){try{let t=await W(e);if(!t.authenticated){let s=await Q(e),f={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:s.error?.error?.message??"Authentication required"}};return v(e,f,{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let s=n.errorResponse.error?.details?.rateLimit,f=s&&typeof s=="object"&&"limit"in s&&"remaining"in s&&"reset"in s&&"count"in s&&"success"in s?s:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=B(f),g={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,g,{status:429,headers:h})}let o=J(),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 s=i.split("."),f=parseInt(s[0]??"0",10),h=parseInt(s[1]??"0",10),g=parseInt(s[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:f,minor:h,patch:g};}else {let s=ie(i);s?.bloggyVersion&&(a=s.bloggyVersion);}}catch(s){console.warn("Failed to parse X-Bloggy-Version header:",s);}let c={compatible:!0};a.version!=="unknown"&&(c=Tr(a,o));let l={success:!0,versions:{bloggy:a,platform:o},compatibility:c},u=B(n.rateLimitResult),m={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...u};return v(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 v(e,r,{status:500})}}var Io=/^[A-Za-z0-9-]{8,128}$/;async function Bo(e){let t=await W(e);if(!t.authenticated){let l=await Q(e);return v(e,{success:false,error:{code:l.error?.error?.code??"PUB005",message:l.error?.error?.message??"Authentication required"}},{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let l=B({remaining:0,reset:Date.now()+6e4,limit:5});return v(e,{success:false,error:n.errorResponse.error??{code:"PUB011",message:"Rate limit exceeded"}},{status:429,headers:l})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,Ot("Expected JSON body"),{status:400});let i;try{i=await e.json();}catch{return v(e,Ot("Invalid JSON body"),{status:400})}let a=Oo(i);if(!a.success)return v(e,Ot(a.message),{status:400});let c=[];return a.config.searchSubmission&&(await M().setMetadata("searchSubmission",a.config.searchSubmission),c.push("searchSubmission")),v(e,{success:true,updated:c},{status:200,headers:B(n.rateLimitResult)})}async function Eo(e){return me(e,["POST"],{allowedHeaders:["Content-Type","X-Bloggy-Version","Authorization","X-Requested-With"]})}function Ot(e){return {success:false,error:{code:"PUB001",message:e}}}function Oo(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"Request body must be an object"};let t=e,r=new Set(["version","searchSubmission"]),n=Object.keys(t).filter(i=>!r.has(i));if(n.length>0)return {success:false,message:`Unsupported config section: ${n.join(", ")}`};if(t.version!==1)return {success:false,message:"Config version must be 1"};let o={version:1};if(t.searchSubmission!==void 0){let i=Mo(t.searchSubmission);return i.success?{success:true,config:{...o,searchSubmission:i.config}}:i}return {success:false,message:"At least one supported config section is required"}}function Mo(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"searchSubmission must be an object"};let t=e,r=new Set(["indexNow"]),n=Object.keys(t).filter(a=>!r.has(a));if(n.length>0)return {success:false,message:`Unsupported searchSubmission section: ${n.join(", ")}`};if(t.indexNow===void 0)return {success:false,message:"searchSubmission.indexNow is required"};let o=t.indexNow;if(!o||typeof o!="object"||Array.isArray(o))return {success:false,message:"searchSubmission.indexNow must be an object"};let i=o;if(typeof i.enabled!="boolean")return {success:false,message:"indexNow.enabled must be a boolean"};if(typeof i.key!="string"||!Io.test(i.key))return {success:false,message:"indexNow.key must be 8 to 128 characters using letters, numbers, or dashes"};if(typeof i.keyLocation!="string")return {success:false,message:"indexNow.keyLocation must be a URL"};try{let a=new URL(i.keyLocation);if(a.protocol!=="https:"&&a.protocol!=="http:")return {success:!1,message:"indexNow.keyLocation must use HTTP or HTTPS"}}catch{return {success:false,message:"indexNow.keyLocation must be a URL"}}return {success:true,config:{indexNow:{enabled:i.enabled,key:i.key,keyLocation:i.keyLocation}}}}async function $o(e){let r=(await M().getMetadata("searchSubmission"))?.indexNow;return !r?.enabled||!r.key?new server_js.NextResponse("Not found",{status:404}):new server_js.NextResponse(r.key,{status:200,headers:{"Content-Type":"text/plain; charset=utf-8","Cache-Control":"public, max-age=300, stale-while-revalidate=60"}})}async function Uo(e,{params:t}){try{let{slug:r}=await t,n=await W(e);if(!n.authenticated){let p=await Q(e);return server_js.NextResponse.json(p.error,{status:401})}let o=F(n.token??"anonymous"),i=await K(o);if(!i.allowed){let p=i.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},x=B(p);return v(e,i.errorResponse,{status:429,headers:x})}if(!r||!Et(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 p=ie(a);if(p?.platformVersion){let x=J();if(p.platformVersion.major!==x.major)return v(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:x.version}}},{status:409})}}let u=await M().getArticle(r)!==null,m={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},s=J(),f=B(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${s.version}`,...f},g=e.headers.get("X-Idempotency-Key");return g&&(h["X-Idempotency-Key"]=g,console.log(`Slug check for idempotency: ${g}, exists: ${u}`)),v(e,m,{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 Ho(e){return me(e,["GET"])}var lc=we.version;
79
- exports.ApiKeyAuth=Xe;exports.BLOG_PLATFORM_SCHEMA_VERSION=kt;exports.BLOG_PLATFORM_TABLE_NAMES=Ee;exports.BlogArticlePage=sr;exports.BlogAuthorPage=ur;exports.BlogAuthorsIndexPage=_i;exports.BlogHomePage=qt;exports.BlogPlatformSchemaError=Oe;exports.BlogTopicArchivePage=Ci;exports.BlogTopicsIndexPage=Ri;exports.Button=Dr;exports.Card=Ce;exports.CardContent=Le;exports.CardDescription=Pn;exports.CardFooter=An;exports.CardHeader=yn;exports.CardTitle=vn;exports.DrizzleStorage=Nt;exports.EnvAuth=ve;exports.InMemoryStorage=Ve;exports.NEWSLETTER_SUCCESS_MESSAGE=Fe;exports.NewsletterSignup=Te;exports.NoAuth=Be;exports.PACKAGE_VERSION=lc;exports.Pagination=ge;exports.PaginationContent=tt;exports.PaginationEllipsis=De;exports.PaginationItem=Z;exports.PaginationLink=oe;exports.PaginationNext=nt;exports.PaginationPrevious=rt;exports.ShadcnPagination=et;exports.StructuredDataError=Ne;exports.UninitializedAuth=We;exports.autoConfigureRateLimit=St;exports.blogPlatformDrizzleSchema=Wi;exports.bpArticles=T;exports.bpMetadata=ne;exports.bpOperations=ue;exports.buildAuthorPath=_;exports.buildBlogPath=N;exports.buttonVariants=$e;exports.checkDrizzleAdapterSchema=vr;exports.checkRateLimit=fr;exports.cn=b;exports.configHandler=Bo;exports.configOptionsHandler=Eo;exports.configureRateLimit=Je;exports.createBlogSitemapRoute=go;exports.createDynamicBlogSitemap=fo;exports.createRateLimitErrorResponse=hr;exports.createStructuredDataScript=ae;exports.createTokenFingerprint=F;exports.enforceRateLimit=K;exports.ensureDrizzleAdapterSchema=Zi;exports.extractKeywordsFromArticle=Wr;exports.extractTableOfContents=ut;exports.extractTokenFromHeader=At;exports.formatArticleDateMeta=ct;exports.generateArticleMetadata=ui;exports.generateArticleStructuredData=Ue;exports.generateAuthorPageMetadata=vi;exports.generateAuthorStructuredData=He;exports.generateBlogHomeMetadata=fn;exports.generateBlogHomeStructuredData=lt;exports.generateBlogSitemapEntries=It;exports.generateBreadcrumbStructuredData=$t;exports.generateCanonicalUrl=de;exports.generateCanonicalUrlFromSlug=ro;exports.generateCompleteArticleStructuredData=st;exports.generateOrganizationStructuredData=ot;exports.generatePaginationMetadata=qr;exports.generateSiteMetadata=ao;exports.generateSitemap=uo;exports.generateSitemapIndex=mo;exports.generateWebSiteStructuredData=at;exports.getAllTopics=ye;exports.getArticlePrimaryTopic=Si;exports.getAuthConfig=wt;exports.getAuthorArchive=dr;exports.getAuthorsFromArticles=xe;exports.getBaseUrl=io;exports.getBlogThemeStyle=j;exports.getDrizzleAdapterSql=to;exports.getPathPrefixFromBlogUrl=Xr;exports.getRateLimitHeaders=B;exports.getRelatedFeaturedArticles=bt;exports.getStorage=M;exports.getTopicArchive=Pt;exports.indexNowKeyRoute=$o;exports.initBlogPlatform=Ye;exports.initBlogPlatformDev=Gi;exports.initBlogPlatformOnce=Fi;exports.initBlogPlatformProd=zi;exports.initEnvAuth=Mi;exports.isValidCanonicalUrl=no;exports.loadAuthorArchive=wi;exports.metadataToHtml=lo;exports.normalizeBlogBasePath=E;exports.normalizeDomain=Ae;exports.normalizeSlug=wr;exports.publishHandler=No;exports.safeGenerateArticleStructuredData=Kr;exports.setAuthConfig=Ke;exports.setStorage=vt;exports.shouldSkipAuth=Di;exports.sitemapToXml=Sr;exports.slugExistsHandler=Uo;exports.slugExistsOptionsHandler=Ho;exports.structuredDataToJsonLd=Ut;exports.unpublishHandler=Co;exports.updateArticleCanonicalUrl=oo;exports.usePagination=Vr;exports.validateMetadata=co;exports.validateSitemap=po;exports.validateStructuredData=Dt;exports.versionHandler=_o;//# sourceMappingURL=index.js.map
73
+ );`;function Mr(e){switch(e){case "bp_articles":return Gt;case "bp_operations":return jt;case "bp_metadata":return zt}}function Ir(e,t){throw To(e,t)?new Fe([t],{cause:e}):e}function To(e,t){return $r(e).some(r=>r.includes(`no such table: ${t}`)||r.includes(`no such table: main.${t}`))}function $r(e){if(!e||typeof e!="object")return [String(e)];let t=[];e instanceof Error&&t.push(e.message);let r=e.cause;return r!==void 0&&t.push(...$r(r)),t}function Ro(){return {schemaVersion:qt,requiredTableNames:He,createAll:[Gt,jt,zt],createArticles:Gt,createOperations:jt,createMetadata:zt}}function Ce(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 Dr(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 i=t.replace(/-+/g,"-").replace(/^-+|-+$/g,"");if(!i)throw new Error("Slug cannot consist only of hyphens");return i}function he(e,t={}){let{forceHttps:r=true,removeTrailingSlash:i=true,domain:o=e.site.domain,pathPrefix:n="/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 s=Ce(o,r),a=Dr(e.slug),l=n.replace(/^(?!\/)/,"/").replace(/\/+$/,""),u=`${s}${l}/${a}`;return i&&(u=u.replace(/\/+$/,"")),u}function Co(e,t,r={}){return he({slug:t,site:e},r)}function Lo(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 ko(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function _o(e,t={}){let r=he(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function Bo(e,t={},r){let i=r?.path??"/blog",n=`https://${t.canonical?.domain??e.domain}${i}`,s=r?.title?`${r.title} | ${e.name}`:e.name,a=r?.description??e.description,l=t.openGraph?.siteName??e.name,u=[{name:"description",content:a},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&u.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&u.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&u.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&u.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&u.push({name:"application-name",content:t.meta.applicationName});let c=[{property:"og:title",content:s},{property:"og:description",content:a},{property:"og:url",content:n},{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&&c.push({property:"og:image",content:t.openGraph.defaultImage},{property:"og:image:alt",content:`${l} - ${e.tagline}`});let d=Io(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:s,description:a,image:t.openGraph?.defaultImage});return {meta:u,openGraph:c,twitter:d,links:[{rel:"canonical",href:n}],title:s,description:a,canonicalUrl:n}}function Io(e,t,r){let i=r?.title??e?.meta.title??e?.title??"",o=r?.description??e?.meta.description??e?.excerpt??"",n=r?.image??e?.meta.ogImage??e?.featuredImage,s=[{name:"twitter:card",content:t.cardType},{name:"twitter:title",content:i},{name:"twitter:description",content:o}];return t.site&&s.push({name:"twitter:site",content:t.site}),t.creator&&s.push({name:"twitter:creator",content:t.creator}),n&&(s.push({name:"twitter:image",content:n}),e?.featuredImageAlt),s}function Eo(e){let t=[];return t.push(`<title>${z(e.title)}</title>`),e.meta.forEach(r=>{let i=[];r.name&&i.push(`name="${z(r.name)}"`),r.property&&i.push(`property="${z(r.property)}"`),r.httpEquiv&&i.push(`http-equiv="${z(r.httpEquiv)}"`),i.push(`content="${z(r.content)}"`),t.push(`<meta ${i.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${z(r.property)}" content="${z(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${z(r.name)}" content="${z(r.content)}" />`);}),e.links.forEach(r=>{let i=[];i.push(`rel="${z(r.rel)}"`),i.push(`href="${z(r.href)}"`),r.type&&i.push(`type="${z(r.type)}"`),r.title&&i.push(`title="${z(r.title)}"`),t.push(`<link ${i.join(" ")} />`);}),t.join(`
74
+ `)}function z(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Oo(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(n=>n.property==="og:image")||r.push("OpenGraph image missing - social media sharing will not show image preview"),e.twitter.find(n=>n.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=[],i={}){let{includeAuthorPages:o=true,includeTopicPages:n=true,includeSeriesPages:s=true,maxEntries:a=5e4,changeFrequency:l={},priority:u={}}=i,c=[],d=Ce(i.canonical?.domain??e.domain,i.canonical?.forceHttps??true),h=i.canonical?.pathPrefix??"/blog",y=r.length>0?r:we(t),p=Ne([...t]),g=Se([...t]);return c.push({url:`${d}${h}`,lastModified:G(t),changeFrequency:l.homePage??"daily",priority:u.homePage??1}),t.forEach(b=>{if(c.length>=a)return;let T=he(b,i.canonical);c.push({url:T,lastModified:b.updatedAt,changeFrequency:l.articles??"monthly",priority:u.articles??.8});}),n&&p.length>0&&(c.length<a&&c.push({url:`${d}${v(h,"topics")}`,lastModified:G(t),changeFrequency:l.topicPages??"weekly",priority:u.topicPages??.6}),p.forEach(b=>{if(c.length>=a)return;let T=t.filter(M=>(M.topics??[]).some(S=>S.slug===b.slug));c.push({url:`${d}${v(h,`topics/${b.slug}`)}`,lastModified:G(T),changeFrequency:l.topicPages??"weekly",priority:u.topicPages??.6});})),s&&g.length>0&&(c.length<a&&c.push({url:`${d}${v(h,"series")}`,lastModified:G(t),changeFrequency:l.seriesPages??"weekly",priority:u.seriesPages??.6}),g.forEach(b=>{if(c.length>=a)return;let T=t.filter(M=>M.series?.slug===b.slug);c.push({url:`${d}${oe(h,b.slug)}`,lastModified:G(T),changeFrequency:l.seriesPages??"weekly",priority:u.seriesPages??.6});})),o&&y.length>0&&(c.length<a&&c.push({url:`${d}${v(h,"authors")}`,lastModified:G(t),changeFrequency:l.authorPages??"weekly",priority:u.authorPages??.6}),y.forEach(b=>{if(c.length>=a)return;let T=`${d}${I(h,b.slug)}`,M=t.filter(B=>B.author?.id===b.id),S=G(M);c.push({url:T,lastModified:S,changeFrequency:l.authorPages??"weekly",priority:u.authorPages??.6});})),c}function Mo(e,t,r=[],i={}){let{includeAuthorPages:o=true,includeTopicPages:n=true,includeSeriesPages:s=true,maxEntries:a=5e4,changeFrequency:l={},priority:u={}}=i,c=[],d=Ce(i.canonical?.domain??e.domain,i.canonical?.forceHttps??true),h=i.canonical?.pathPrefix??"/blog",y=new Date().toISOString(),p=r.length>0?r:we(t),g=Ne([...t]),b=Se([...t]),T=1;T+=t.length,n&&g.length>0&&(T+=g.length+1),s&&b.length>0&&(T+=b.length+1),o&&(T+=p.length>0?p.length+1:0);let M=T>a;return c.push({loc:`${d}${h}`,lastmod:G(t),changefreq:l.homePage??"daily",priority:u.homePage??1}),t.forEach(S=>{if(c.length>=a)return;let B=he(S,i.canonical);c.push({loc:B,lastmod:S.updatedAt,changefreq:l.articles??"monthly",priority:u.articles??.8});}),n&&g.length>0&&(c.length<a&&c.push({loc:`${d}${v(h,"topics")}`,lastmod:G(t),changefreq:l.topicPages??"weekly",priority:u.topicPages??.6}),g.forEach(S=>{if(c.length>=a)return;let B=t.filter(D=>(D.topics??[]).some(xe=>xe.slug===S.slug));c.push({loc:`${d}${v(h,`topics/${S.slug}`)}`,lastmod:G(B),changefreq:l.topicPages??"weekly",priority:u.topicPages??.6});})),s&&b.length>0&&(c.length<a&&c.push({loc:`${d}${v(h,"series")}`,lastmod:G(t),changefreq:l.seriesPages??"weekly",priority:u.seriesPages??.6}),b.forEach(S=>{if(c.length>=a)return;let B=t.filter(D=>D.series?.slug===S.slug);c.push({loc:`${d}${oe(h,S.slug)}`,lastmod:G(B),changefreq:l.seriesPages??"weekly",priority:u.seriesPages??.6});})),o&&p.length>0&&(c.length<a&&c.push({loc:`${d}${v(h,"authors")}`,lastmod:G(t),changefreq:l.authorPages??"weekly",priority:u.authorPages??.6}),p.forEach(S=>{if(c.length>=a)return;let B=`${d}${I(h,S.slug)}`,D=t.filter(dt=>dt.author?.id===S.id),xe=G(D);c.push({loc:B,lastmod:xe,changefreq:l.authorPages??"weekly",priority:u.authorPages??.6});})),{entries:c,totalEntries:c.length,truncated:M,generatedAt:y,baseUrl:d}}function Ur(e){let t='<?xml version="1.0" encoding="UTF-8"?>',r='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',i="</urlset>",o=e.entries.map(n=>{let s=[];return s.push(" <url>"),s.push(` <loc>${Ge(n.loc)}</loc>`),n.lastmod&&s.push(` <lastmod>${Ge(n.lastmod)}</lastmod>`),n.changefreq&&s.push(` <changefreq>${Ge(n.changefreq)}</changefreq>`),n.priority!==void 0&&s.push(` <priority>${n.priority.toFixed(1)}</priority>`),s.push(" </url>"),s.join(`
75
+ `)});return [t,r,...o,i].join(`
76
+ `)}function $o(e,t){let r='<?xml version="1.0" encoding="UTF-8"?>',i='<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',o="</sitemapindex>",n=e.map(s=>{let a=[];return a.push(" <sitemap>"),a.push(` <loc>${Ge(s.url)}</loc>`),s.lastmod&&a.push(` <lastmod>${Ge(s.lastmod)}</lastmod>`),a.push(" </sitemap>"),a.join(`
77
+ `)});return [r,i,...n,o].join(`
78
+ `)}function Do(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,n)=>{try{new URL(o.loc);}catch{t.push(`Invalid URL at entry ${n+1}: ${o.loc}`);}o.priority!==void 0&&(o.priority<0||o.priority>1)&&t.push(`Invalid priority at entry ${n+1}: must be between 0.0 and 1.0`),o.lastmod&&!Fo(o.lastmod)&&t.push(`Invalid lastmod date at entry ${n+1}: ${o.lastmod}`),o.loc.length>2048&&r.push(`URL at entry ${n+1} exceeds 2048 character limit`);});let i=new Map;return e.entries.forEach(o=>{let n=i.get(o.loc)??0;i.set(o.loc,n+1);}),i.forEach((o,n)=>{o>1&&t.push(`Duplicate URL found: ${n} (appears ${o} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function G(e){return e.length===0?new Date().toISOString():e.reduce((r,i)=>{let o=new Date(i.updatedAt);return o>r?o:r},new Date(e[0].updatedAt)).toISOString()}function Uo(e,t,r=[],i={}){return async function(){let s=(await Xt(e,t,r,i)).map(u=>({loc:u.url,lastmod:typeof u.lastModified=="string"?u.lastModified:u.lastModified?.toISOString(),changefreq:u.changeFrequency,priority:u.priority})),a={entries:s,totalEntries:s.length,generatedAt:new Date().toISOString(),baseUrl:Ce(i.canonical?.domain??e.domain,i.canonical?.forceHttps??true)},l=Ur(a);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function Ho(e){return async function(){let r=[...e.staticRoutes??[],...e.getStaticRoutes?await e.getStaticRoutes():[]],i=await e.getSite(),o=await e.getArticles(),n=e.getAuthors?await e.getAuthors():[];return [...r,...await Xt(i,o,n,e.options)]}}function Ge(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Fo(e){try{let t=new Date(e),r=t.toISOString(),i=e.endsWith("Z")&&!e.includes(".")?e.replace("Z",".000Z"):e;return r===i&&!isNaN(t.getTime())}catch{return false}}var Le={name:"@xexr/blog-platform",version:"1.1.7"};function Hr(e){let r=e.replace(/^v/,"").split(".");if(r.length<3)throw new Error(`Invalid version format: ${e}`);let i=parseInt(r[0]??"0",10),o=parseInt(r[1]??"0",10),n=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(i)||isNaN(o)||isNaN(n))throw new Error(`Invalid version format: ${e}`);return {major:i,minor:o,patch:n}}function Q(){let e=Hr(Le.version);return {name:Le.name,version:Le.version,...e}}function ce(e){try{let t=e.split(" "),r={};for(let i of t){let[o,n]=i.split("/");if(!o||!n)continue;let s=Hr(n),a={name:o,version:n,...s};o==="bloggy"?r.bloggyVersion=a:o==="platform"&&(r.platformVersion=a);}return r}catch{return null}}function Fr(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 Gr={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 jo(){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 {...Gr,enableCSP:!e,frameOptions:t??Gr.frameOptions,enableHSTS:!r}}function zo(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function Vo(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function qo(e,t={}){let r={...jo(),...t},i={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};i["Content-Security-Policy"]=zo(o);}if(r.enableFrameOptions&&(i["X-Frame-Options"]=r.frameOptions),r.enableContentTypeOptions&&(i["X-Content-Type-Options"]="nosniff"),r.enableXSSProtection&&(i["X-XSS-Protection"]="1; mode=block"),r.enableReferrerPolicy&&(i["Referrer-Policy"]=r.referrerPolicy),r.enableHSTS&&Xo(e)){let o=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");i["Strict-Transport-Security"]=o;}if(r.enablePermissionsPolicy){let o={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};i["Permissions-Policy"]=Vo(o);}return i}function Xo(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function ut(e,t={}){return qo(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var jr={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 zr(){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 {...jr,allowedOrigins:e?e.split(",").map(i=>i.trim()):jr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function Vr(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function qr(e,t){let r=e.headers.get("origin"),i={};return t.allowWildcard?i["Access-Control-Allow-Origin"]="*":r&&Vr(r,t)&&(i["Access-Control-Allow-Origin"]=r),t.allowCredentials&&!t.allowWildcard&&(i["Access-Control-Allow-Credentials"]="true"),t.allowWildcard||(i.Vary="Origin"),i}function Wo(e,t,r,i){return {...qr(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":i.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var Ko=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function P(e,t,r={}){let{status:i=200,headers:o={},corsConfig:n={}}=r,s={...zr(),...n},a=qr(e,s),l=ut(e,s.securityConfig),u={"Content-Type":"application/json",...a,...l,...o};return server_js.NextResponse.json(t,{status:i,headers:u})}function be(e,t,r={}){let{allowedHeaders:i=Ko,corsConfig:o={}}=r,n={...zr(),...o},s=e.headers.get("origin");if(s&&!n.allowWildcard&&!Vr(s,n)){let u=ut(e,n.securityConfig);return new server_js.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let a=Wo(e,n,[...t,"OPTIONS"],i),l=ut(e,n.securityConfig);return new server_js.NextResponse(null,{status:200,headers:{...a,...l}})}async function Jo(e){try{let t=await J(e);if(!t.authenticated){let g=await te(e);return P(e,g.error,{status:401})}let r=V(t.token??"anonymous"),i=await Y(r);if(!i.allowed){let g=i.errorResponse.error?.details?.rateLimit,b=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},T=O(b);return P(e,i.errorResponse,{status:429,headers:T})}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 n;try{n=await e.json();}catch{return P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=Yo(n);if(s.length>0)return P(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:n.idempotencyKey??""},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let g=ce(a);if(g?.platformVersion){let b=Q();if(g.platformVersion.major!==b.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:b.version}},idempotencyKey:n.idempotencyKey},{status:409})}}if(n.dryRun){let g=[];return n.article.wordCount<50&&g.push("Article has fewer than 50 words, which may affect SEO"),(!n.article.excerpt||n.article.excerpt.length<120)&&g.push("Article excerpt is shorter than recommended 120 characters"),n.article.meta.keywords.length||g.push("No SEO keywords provided"),P(e,{success:!0,warnings:g,idempotencyKey:n.idempotencyKey},{status:200})}let l={...n.article,slug:n.slug??n.article.slug,meta:{...n.article.meta,description:n.metaDescription??n.article.meta.description}};if(!Kt(l.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:n.idempotencyKey},{status:400});let c=await F().saveArticle(l,n.idempotencyKey),d=Q(),h=O(i.rateLimitResult),y={"X-Bloggy-Version":`platform/${d.version}`,"X-Idempotency-Key":n.idempotencyKey,...h};c.success&&(y.Location=c.url??`/${l.slug}`);let p=c.success?201:c.error?.code==="PUB003"?409:400;return P(e,c,{status:p,headers:y})}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 Yo(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 i=r.article,o=["id","slug","title","content","publishedAt","site"];for(let n of o)i[n]||t.push(`Missing required article field: ${n}`);if(i.site&&typeof i.site=="object"){let n=i.site,s=["id","name","domain"];for(let a of s)n[a]||t.push(`Missing required site field: ${a}`);}if(i.meta&&typeof i.meta=="object"){let n=i.meta;Array.isArray(n.keywords)||t.push("Article meta.keywords must be an array");}}return t}function Kt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Zo(e){try{let t=await J(e);if(!t.authenticated){let p=await te(e);return server_js.NextResponse.json(p.error,{status:401})}let r=V(t.token??"anonymous"),i=await Y(r);if(!i.allowed){let p=i.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},b=O(g);return P(e,i.errorResponse,{status:429,headers:b})}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 n;try{n=await e.json();}catch{return P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=es(n);if(s.length>0)return P(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:n.idempotencyKey??""},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let p=ce(a);if(p?.platformVersion){let g=Q();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:n.idempotencyKey},{status:409})}}if(!ts(n.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:n.idempotencyKey},{status:400});if(n.dryRun){let g=await F().getArticle(n.slug),b=[];return g||b.push("Article with this slug does not exist"),P(e,{success:!0,warnings:b,idempotencyKey:n.idempotencyKey},{status:200})}let u=await F().removeArticle(n.slug,n.idempotencyKey),c=Q(),d=O(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${c.version}`,"X-Idempotency-Key":n.idempotencyKey,...d},y=u.success?200:u.error?.code==="PUB007"?404:400;return P(e,u,{status:y,headers:h})}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 es(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 ts(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function rs(e){try{let t=await J(e);if(!t.authenticated){let d=await te(e),h={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,h,{status:401})}let r=V(t.token??"anonymous"),i=await Y(r);if(!i.allowed){let d=i.errorResponse.error?.details?.rateLimit,h=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},y=O(h),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:i.errorResponse.error?.message??"Rate limit exceeded"}};return P(e,p,{status:429,headers:y})}let o=Q(),n=e.headers.get("X-Bloggy-Version"),s={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(n)try{if(/^\d+\.\d+\.\d+/.test(n)){let d=n.split("."),h=parseInt(d[0]??"0",10),y=parseInt(d[1]??"0",10),p=parseInt(d[2]?.split("-")[0]??"0",10);s={name:"bloggy",version:n,major:h,minor:y,patch:p};}else {let d=ce(n);d?.bloggyVersion&&(s=d.bloggyVersion);}}catch(d){console.warn("Failed to parse X-Bloggy-Version header:",d);}let a={compatible:!0};s.version!=="unknown"&&(a=Fr(s,o));let l={success:!0,versions:{bloggy:s,platform:o},compatibility:a},u=O(i.rateLimitResult),c={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...u};return P(e,l,{status:200,headers:c})}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})}}var is=/^[A-Za-z0-9-]{8,128}$/;async function ns(e){let t=await J(e);if(!t.authenticated){let l=await te(e);return P(e,{success:false,error:{code:l.error?.error?.code??"PUB005",message:l.error?.error?.message??"Authentication required"}},{status:401})}let r=V(t.token??"anonymous"),i=await Y(r);if(!i.allowed){let l=O({remaining:0,reset:Date.now()+6e4,limit:5});return P(e,{success:false,error:i.errorResponse.error??{code:"PUB011",message:"Rate limit exceeded"}},{status:429,headers:l})}if(!e.headers.get("content-type")?.includes("application/json"))return P(e,Jt("Expected JSON body"),{status:400});let n;try{n=await e.json();}catch{return P(e,Jt("Invalid JSON body"),{status:400})}let s=ss(n);if(!s.success)return P(e,Jt(s.message),{status:400});let a=[];return s.config.searchSubmission&&(await F().setMetadata("searchSubmission",s.config.searchSubmission),a.push("searchSubmission")),P(e,{success:true,updated:a},{status:200,headers:O(i.rateLimitResult)})}async function os(e){return be(e,["POST"],{allowedHeaders:["Content-Type","X-Bloggy-Version","Authorization","X-Requested-With"]})}function Jt(e){return {success:false,error:{code:"PUB001",message:e}}}function ss(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"Request body must be an object"};let t=e,r=new Set(["version","searchSubmission"]),i=Object.keys(t).filter(n=>!r.has(n));if(i.length>0)return {success:false,message:`Unsupported config section: ${i.join(", ")}`};if(t.version!==1)return {success:false,message:"Config version must be 1"};let o={version:1};if(t.searchSubmission!==void 0){let n=as(t.searchSubmission);return n.success?{success:true,config:{...o,searchSubmission:n.config}}:n}return {success:false,message:"At least one supported config section is required"}}function as(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"searchSubmission must be an object"};let t=e,r=new Set(["indexNow"]),i=Object.keys(t).filter(s=>!r.has(s));if(i.length>0)return {success:false,message:`Unsupported searchSubmission section: ${i.join(", ")}`};if(t.indexNow===void 0)return {success:false,message:"searchSubmission.indexNow is required"};let o=t.indexNow;if(!o||typeof o!="object"||Array.isArray(o))return {success:false,message:"searchSubmission.indexNow must be an object"};let n=o;if(typeof n.enabled!="boolean")return {success:false,message:"indexNow.enabled must be a boolean"};if(typeof n.key!="string"||!is.test(n.key))return {success:false,message:"indexNow.key must be 8 to 128 characters using letters, numbers, or dashes"};if(typeof n.keyLocation!="string")return {success:false,message:"indexNow.keyLocation must be a URL"};try{let s=new URL(n.keyLocation);if(s.protocol!=="https:"&&s.protocol!=="http:")return {success:!1,message:"indexNow.keyLocation must use HTTP or HTTPS"}}catch{return {success:false,message:"indexNow.keyLocation must be a URL"}}return {success:true,config:{indexNow:{enabled:n.enabled,key:n.key,keyLocation:n.keyLocation}}}}async function ls(e){let r=(await F().getMetadata("searchSubmission"))?.indexNow;return !r?.enabled||!r.key?new server_js.NextResponse("Not found",{status:404}):new server_js.NextResponse(r.key,{status:200,headers:{"Content-Type":"text/plain; charset=utf-8","Cache-Control":"public, max-age=300, stale-while-revalidate=60"}})}async function us(e,{params:t}){try{let{slug:r}=await t,i=await J(e);if(!i.authenticated){let g=await te(e);return server_js.NextResponse.json(g.error,{status:401})}let o=V(i.token??"anonymous"),n=await Y(o);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},b=O(g);return P(e,n.errorResponse,{status:429,headers:b})}if(!r||!Kt(r))return P(e,{exists:!1,error:{code:"PUB002",message:"Invalid slug format. Must be lowercase letters, numbers, and hyphens only."}},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let g=ce(s);if(g?.platformVersion){let b=Q();if(g.platformVersion.major!==b.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:b.version}}},{status:409})}}let u=await F().getArticle(r)!==null,c={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},d=Q(),h=O(n.rateLimitResult),y={"X-Bloggy-Version":`platform/${d.version}`,...h},p=e.headers.get("X-Idempotency-Key");return p&&(y["X-Idempotency-Key"]=p,console.log(`Slug check for idempotency: ${p}, exists: ${u}`)),P(e,c,{status:200,headers:y})}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 ds(e){return be(e,["GET"])}var lu=Le.version;
79
+ exports.ApiKeyAuth=nt;exports.BLOG_PLATFORM_SCHEMA_VERSION=qt;exports.BLOG_PLATFORM_TABLE_NAMES=He;exports.BlogArticlePage=vr;exports.BlogAuthorPage=Nr;exports.BlogAuthorsIndexPage=to;exports.BlogHomePage=or;exports.BlogPlatformSchemaError=Fe;exports.BlogSeriesArchivePage=Ot;exports.BlogSeriesArchiveRoutePage=Ar;exports.BlogSeriesIndexPage=Et;exports.BlogSeriesPage=Pr;exports.BlogTopicArchivePage=Qn;exports.BlogTopicsIndexPage=Yn;exports.Button=Zr;exports.Card=Ee;exports.CardContent=Oe;exports.CardDescription=Oi;exports.CardFooter=Mi;exports.CardHeader=Ii;exports.CardTitle=Ei;exports.DrizzleStorage=Ft;exports.EnvAuth=Te;exports.InMemoryStorage=rt;exports.NEWSLETTER_SUCCESS_MESSAGE=Je;exports.NewsletterSignup=Be;exports.NoAuth=Ue;exports.PACKAGE_VERSION=lu;exports.Pagination=ye;exports.PaginationContent=gt;exports.PaginationEllipsis=ze;exports.PaginationItem=re;exports.PaginationLink=ue;exports.PaginationNext=ft;exports.PaginationPrevious=pt;exports.SeriesNavigation=Lt;exports.ShadcnPagination=mt;exports.StructuredDataError=_e;exports.UninitializedAuth=ot;exports.autoConfigureRateLimit=Ht;exports.blogPlatformDrizzleSchema=yo;exports.bpArticles=N;exports.bpMetadata=le;exports.bpOperations=fe;exports.buildAuthorPath=I;exports.buildBlogPath=v;exports.buildSeriesPath=oe;exports.buttonVariants=je;exports.checkDrizzleAdapterSchema=Or;exports.checkRateLimit=kr;exports.cn=f;exports.configHandler=ns;exports.configOptionsHandler=os;exports.configureRateLimit=at;exports.createBlogSitemapRoute=Uo;exports.createDynamicBlogSitemap=Ho;exports.createRateLimitErrorResponse=_r;exports.createStructuredDataScript=de;exports.createTokenFingerprint=V;exports.enforceRateLimit=Y;exports.ensureDrizzleAdapterSchema=No;exports.extractKeywordsFromArticle=ci;exports.extractTableOfContents=At;exports.extractTokenFromHeader=Dt;exports.formatArticleDateMeta=Pt;exports.generateArticleMetadata=Nn;exports.generateArticleStructuredData=Ve;exports.generateAuthorPageMetadata=zn;exports.generateAuthorStructuredData=qe;exports.generateBlogHomeMetadata=Li;exports.generateBlogHomeStructuredData=vt;exports.generateBlogSitemapEntries=Xt;exports.generateBreadcrumbStructuredData=Xe;exports.generateCanonicalUrl=he;exports.generateCanonicalUrlFromSlug=Co;exports.generateCompleteArticleStructuredData=yt;exports.generateOrganizationStructuredData=bt;exports.generatePaginationMetadata=ai;exports.generateSeriesArchiveMetadata=In;exports.generateSeriesIndexMetadata=_n;exports.generateSiteMetadata=Bo;exports.generateSitemap=Mo;exports.generateSitemapIndex=$o;exports.generateWebSiteStructuredData=xt;exports.getAllSeries=Se;exports.getAllTopics=Ne;exports.getArticlePrimaryTopic=Wn;exports.getArticleSeriesNavigation=Rn;exports.getAuthConfig=Ut;exports.getAuthorArchive=Tr;exports.getAuthorsFromArticles=we;exports.getBaseUrl=ko;exports.getBlogThemeStyle=$;exports.getDrizzleAdapterSql=Ro;exports.getPathPrefixFromBlogUrl=li;exports.getRateLimitHeaders=O;exports.getRelatedFeaturedArticles=kt;exports.getSeriesArchive=It;exports.getStorage=F;exports.getTopicArchive=$t;exports.indexNowKeyRoute=ls;exports.initBlogPlatform=lt;exports.initBlogPlatformDev=po;exports.initBlogPlatformOnce=go;exports.initBlogPlatformProd=fo;exports.initEnvAuth=so;exports.isValidCanonicalUrl=Lo;exports.loadAuthorArchive=Xn;exports.metadataToHtml=Eo;exports.normalizeBlogBasePath=_;exports.normalizeDomain=Ce;exports.normalizeSlug=Dr;exports.publishHandler=Jo;exports.safeGenerateArticleStructuredData=ui;exports.setAuthConfig=st;exports.setStorage=Mt;exports.shouldSkipAuth=lo;exports.sitemapToXml=Ur;exports.slugExistsHandler=us;exports.slugExistsOptionsHandler=ds;exports.structuredDataToJsonLd=We;exports.unpublishHandler=Zo;exports.updateArticleCanonicalUrl=_o;exports.usePagination=si;exports.validateMetadata=Oo;exports.validateSitemap=Do;exports.validateStructuredData=Qt;exports.versionHandler=rs;//# sourceMappingURL=index.js.map
80
80
  //# sourceMappingURL=index.js.map