PageSourceSearch

https://agentswarms.fyi/assets/blog._slug-wJzHeZEa.js

js agentswarms.fyi collected 2026-10-08 00:26:49 UTC 8,982 bytes, 1 lines download raw bytes

1import{ad as N,r as a,s as x,j as e,t as p,M as v,b9 as k,ba as _,L as C}from"./index-BJahAV3N.js";import{a as S,b as D,B as L,c as B}from"./BlogViewCounter-BBV3fgPy.js";import{T as A,a as q}from"./thumbs-up-CPttut4q.js";import{S as T}from"./send-CrzTkPIH.js";import{A as E}from"./arrow-left-GVFRJ_2z.js";import{C as M}from"./clock-BW5YSkhZ.js";import{E as P}from"./external-link-PlE-C8eX.js";import"./proxy-Cu50gLAc.js";import"./minus-DHOGznzi.js";import"./mic-UR2Mep-c.js";import"./cloud-UVzkXEOJ.js";import"./workflow-p_UvGqJe.js";import"./clipboard-list-CxhRtK3W.js";import"./scale-DT6bcKD8.js";import"./plug-aCcdONNm.js";import"./refresh-cw-cUKghpb6.js";import"./lightbulb-yvxNqskk.js";import"./check-BzR4xCqJ.js";import"./share-2-CZIjOMhp.js";import"./eye-BTow0Sm8.js";function R({slug:t}){const{user:s,isAuthenticated:n}=N(),[o,i]=a.useState(0),[g,h]=a.useState(0),[d,b]=a.useState(null),[j,f]=a.useState(!1),m=a.useCallback(async()=>{try{const{data:l}=await x.from("blog_reactions").select("user_id, reaction").eq("blog_slug",t),r=l??[];i(r.filter(c=>c.reaction==="like").length),h(r.filter(c=>c.reaction==="dislike").length),b(r.find(c=>c.user_id===s?.id)?.reaction??null)}catch{}},[t,s?.id]);a.useEffect(()=>{m()},[m]);async function u(l){if(!n||!s){p.info("Sign in to react to this post.");return}if(!j){f(!0);try{d===l?await x.from("blog_reactions").delete().eq("user_id",s.id).eq("blog_slug",t):await x.from("blog_reactions").upsert({user_id:s.id,blog_slug:t,reaction:l},{onConflict:"user_id,blog_slug"}),await m()}catch{p.error("Couldn't save your reaction.")}finally{f(!1)}}}const y=l=>`inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors ${l?"border-primary/60 bg-primary/15 text-primary":"border-border/60 text-muted-foreground hover:border-border hover:text-foreground"}`;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>u("like"),className:y(d==="like"),"aria-pressed":d==="like",children:[e.jsx(A,{className:"h-4 w-4"})," ",o]}),e.jsxs("button",{type:"button",onClick:()=>u("dislike"),className:y(d==="dislike"),"aria-pressed":d==="dislike",children:[e.jsx(q,{className:"h-4 w-4"})," ",g]}),!n&&e.jsx("a",{href:"/login",className:"text-xs text-muted-foreground hover:text-foreground",children:"Sign in to react"})]})}function $(t){const s=Date.now()-new Date(t).getTime(),n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const o=Math.floor(n/60);if(o<24)return`${o}h ago`;const i=Math.floor(o/24);return i<30?`${i}d ago`:new Date(t).toLocaleDateString()}function z({slug:t}){const{user:s,isAuthenticated:n}=N(),[o,i]=a.useState([]),[g,h]=a.useState(""),[d,b]=a.useState(!0),[j,f]=a.useState(!1),m=s?.user_metadata?.name||(s?.email?s.email.split("@")[0]:"Reader"),u=a.useCallback(async()=>{b(!0);try{const{data:r}=await x.from("blog_comments").select("id, user_id, author_name, content, created_at").eq("blog_slug",t).order("created_at",{ascending:!1});i(r??[])}catch{i([])}finally{b(!1)}},[t]);a.useEffect(()=>{u()},[u]);async function y(){const r=g.trim();if(!(!r||!s)){if(r.length>2e3){p.error("Comment is too long (2000 char max).");return}f(!0);try{await x.from("blog_comments").insert({blog_slug:t,user_id:s.id,author_name:m,content:r}),h(""),await u()}catch{p.error("Couldn't post your comment. The comments table may not be set up yet.")}finally{f(!1)}}}async function l(r){try{await x.from("blog_comments").delete().eq("id",r),i(c=>c.filter(w=>w.id!==r))}catch{p.error("Couldn't delete the comment.")}}return e.jsxs("section",{className:"space-y-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-xl font-bold tracking-tight text-foreground",children:[e.jsx(v,{className:"h-5 w-5 text-primary"}),"Comments"," ",o.length>0&&e.jsxs("span",{className:"text-muted-foreground",children:["(",o.length,")"]})]}),n?e.jsxs("div",{className:"rounded-xl border border-border/60 bg-card/40 p-4",children:[e.jsx("textarea",{value:g,onChange:r=>h(r.target.value),rows:3,placeholder:"Share your take, a war story, or a question…",className:"w-full resize-y rounded-lg border border-border/60 bg-background/60 p-3 text-sm text-foreground outline-none placeholder:text-muted-foreground focus:border-primary/50"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Posting as ",e.jsx("span",{className:"font-medium text-foreground",children:m})]}),e.jsxs("button",{type:"button",onClick:y,disabled:j||!g.trim(),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(T,{className:"h-3.5 w-3.5"})," ",j?"Posting…":"Post comment"]})]})]}):e.jsxs("div",{className:"rounded-xl border border-border/60 bg-card/40 p-4 text-sm text-muted-foreground",children:[e.jsx("a",{href:"/login",className:"font-semibold text-primary hover:underline",children:"Sign in"})," ","to join the discussion."]}),d?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading comments…"}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No comments yet — be the first."}):e.jsx("ul",{className:"space-y-4",children:o.map(r=>e.jsxs("li",{className:"rounded-xl border border-border/60 bg-card/30 p-4",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 place-items-center rounded-full bg-gradient-to-br from-primary to-nexus-glow text-xs font-bold text-primary-foreground",children:r.author_name?.[0]?.toUpperCase()??"R"}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:r.author_name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",$(r.created_at)]}),s?.id===r.user_id&&e.jsx("button",{type:"button",onClick:()=>l(r.id),className:"ml-auto text-muted-foreground transition-colors hover:text-destructive","aria-label":"Delete comment",title:"Delete",children:e.jsx(k,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground
1/85",children:r.content})]},r.id))})]})}function U(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"})}function ie(){const{post:t}=_.useLoaderData();return e.jsxs("article",{className:"mx-auto max-w-3xl px-6 pb-24 pt-28",children:[e.jsxs(C,{to:"/blog",className:"mb-8 inline-flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(E,{className:"h-4 w-4"})," All posts"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.tags.map(s=>e.jsx("span",{className:"rounded-full border border-primary/30 bg-primary/10 px-2.5 py-0.5 text-[11px] font-semibold uppercase tracking-wider text-primary",children:s},s))}),e.jsx("h1",{className:"mt-4 text-3xl font-extrabold leading-tight tracking-tight text-foreground sm:text-4xl lg:text-5xl",children:t.title}),e.jsx("p",{className:"mt-4 text-lg leading-relaxed text-muted-foreground",children:t.subtitle}),e.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[e.jsx("span",{className:"grid h-10 w-10 place-items-center rounded-full bg-gradient-to-br from-primary to-nexus-glow text-sm font-bold text-primary-foreground",children:"AS"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("div",{className:"font-semibold text-foreground",children:t.author}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("span",{children:U(t.date)}),e.jsx("span",{children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(M,{className:"h-3 w-3"})," ",t.readingTime]}),e.jsx("span",{children:"·"}),e.jsx(S,{slug:t.slug,increment:!0})]})]}),e.jsx(D,{slug:t.slug,title:t.title,excerpt:t.excerpt})]}),e.jsx("div",{className:"mt-8",children:e.jsx(L,{post:t,size:"hero"})}),e.jsx("div",{className:"mt-10",children:e.jsx(B,{post:t})}),t.references&&t.references.length>0&&e.jsxs("div",{className:"mt-12 rounded-2xl border border-border/60 bg-card/30 p-6",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground",children:"Further reading & references"}),e.jsx("ul",{className:"mt-3 space-y-2",children:t.references.map(s=>e.jsx("li",{children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-start gap-1.5 text-sm text-primary hover:underline",children:[e.jsx(P,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{children:s.label})]})},s.url))})]}),e.jsx("hr",{className:"my-12 border-border/50"}),e.jsxs("div",{className:"mb-12 flex flex-col items-center gap-3 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Was this useful?"}),e.jsx(R,{slug:t.slug})]}),e.jsx(z,{slug:t.slug})]})}
1export{ie as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.