1import{b3 as T,r as o,s as u,j as e,P as x,aT as r,b as j,G as p,B as _,C as y,o as w,as as $,S as N,Q as v,aa as q,k as P,l as K,a5 as F}from"./index-D8_nJFcn.js";import I from"./purify.es-Csrj9YNg.js";import{K as z}from"./KbArticleFrame-BkscpRT0.js";import{A as k}from"./arrow-left-BWnqGZMQ.js";import{L as R}from"./layers-fGyw5u67.js";import{V as U}from"./video-iBLTeWEI.js";function Q(){const{slug:i}=T(),[t,A]=o.useState(null),[h,S]=o.useState([]),[B,L]=o.useState(null),[C,g]=o.useState(!0);o.useEffect(()=>{i&&(async()=>{g(!0);const{data:s,error:l}=await u.from("knowledge_articles").select("*").eq("slug",i).eq("is_published",!0).single();if(!l&&s&&(A(s),s.category)){const{data:n}=await u.from("knowledge_articles").select("id, title, slug, content_type").eq("category",s.category).eq("is_published",!0).neq("id",s.id).order("order_index",{ascending:!0}).limit(5);n&&S(n);const{data:a}=await u.from("knowledge_articles").select("slug, title, order_index").eq("category",s.category).eq("is_published",!0).gt("order_index",s.order_index??0).order("order_index",{ascending:!0}).limit(1).maybeSingle();L(a?{slug:a.slug,title:a.title}:null)}g(!1)})()},[i]);const E=s=>{if(!s)return null;const l=s.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(l)return`https://www.youtube.com/embed/${l[1]}`;const n=s.match(/vimeo\.com\/(\d+)/);if(n)return`https://player.vimeo.com/video/${n[1]}`;const a=s.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);return a?`https://www.loom.com/embed/${a[1]}`:s},b=s=>{switch(s){case"video":return e.jsx(U,{className:"h-4 w-4"});case"mixed":return e.jsx(R,{className:"h-4 w-4"});default:return e.jsx(F,{className:"h-4 w-4"})}},O=s=>I.sanitize(s).replace(/<p><\/p>/g,"<p> </p>").replace(/<p>\s*<\/p>/g,"<p> </p>");if(C)return e.jsx(x,{children:e.jsxs("div",{className:"container mx-auto py-8 px-4",children:[e.jsx(r,{className:"h-8 w-48 mb-6"}),e.jsx(r,{className:"h-12 w-3/4 mb-4"}),e.jsx(r,{className:"aspect-video w-full mb-6"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(r,{className:"h-4 w-full"}),e.jsx(r,{className:"h-4 w-full"}),e.jsx(r,{className:"h-4 w-3/4"})]})]})});if(!t)return e.jsxs(x,{children:[e.jsx(j,{title:"Article Not Found",description:"This article could not be found.",noIndex:!0}),e.jsxs("div",{className:"container mx-auto py-8 px-4",children:[e.jsx(p,{to:"/knowledge",children:e.jsxs(_,{variant:"ghost",className:"mb-6",children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Back to Knowledge Base"]})}),e.jsx(y,{children:e.jsxs(w,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx($,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"Article not found"}),e.jsx("p",{className:"text-muted-foreground",children:"The article you're looking for doesn't exist or has been removed."})]})})]})]});const c=E(t.video_url),d=`${N}/knowledge/${t.slug}`,f=t.description||`${t.title} â DealOrb Knowledge Base`,m={"@context":"https://schema.org","@type":"Article",headline:t.title,description:f,url:d,mainEntityOfPage:d,publisher:{"@type":"Organization",name:"DealOrb",logo:{"@type":"ImageObject",url:`${N}/DealOrb_Logo.png`}}};return t.created_at&&(m.datePublished=t.created_at),t.updated_at&&(m.dateModified=t.updated_at),e.jsxs(x,{children:[e.jsx(j,{title:t.title,description:f,canonicalUrl:d,ogType:"article",schema:m}),e.jsxs("div",{className:"container mx-auto py-8 px-4",children:[e.jsx(p,{to:"/knowledge",children:e.jsxs(_,{variant:"ghost",className:"mb-6",children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Back to Knowledge Base"]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"lg:col-span-3",children:[!(t.content&&/<style[\s>]/i.test(t.content))&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 flex-wrap",children:[t.category&&e.jsx(v,{variant:"outline",children:t.category}),e.jsxs(v,{variant:"secondary",className:"gap-1",children:[b(t.content_type),t.content_type==="video"?"Video":t.content_type==="mixed"?"Mixed":"Article"]}),t.duration_minutes&&e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(q,{className:"h-4 w-4"}),t.duration_minutes," min"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-4",children:t.title}),t.description&&e.jsx("p",{className:"text-lg text-muted-foreground mb-6",children:t.description}),c&&(t.content_type==="video"||t.content_type==="mixed")&&e.jsx("div",{className:"aspect-video mb-8 rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:c,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:t.title})})]}),t.content&&(/<style[\s>]/i.test(t.content)?e.jsx(z,{html:t.content,title:t.title,videoEmbedUrl:c,nextArticle:B,basePath:"/knowledge"}):e.jsx("div",{className:"prose prose-neutral dark:prose-invert max-w-none [&_p]:mb-4 [&_p:empty]:min-h-[1.5em] [&_a]:text-primary [&_a]:underline [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded-lg [&_img]:my-4 [&_table]:border-collapse [&_table]:border [&_table]:border-border [&_table]:w-full [&_table]:my-4 [&_th]:border [&_th]:border-border [&_th]:bg-muted [&_th]:px-4 [&_th]:py-2 [&_th]:text-left [&_th]:font-semibold [&_td]:border [&_td]:border-border [&_td]:px-4 [&_td]:py-2",dangerouslySetInnerHTML:{__html:O(t.content)}}))]}),h.length>0&&e.jsx("div",{className:"lg:col-span-1",children:e.jsxs(y,{className:"bg-card/50",children:[e.jsx(P,{children:e.jsx(K,{className:"text-lg",children:"Related Articles"})}),e.jsx(w,{className:"space-y-3",children:h.map(s=>e.jsx(p,{to:`/knowledge/${s.slug}`,className:"block",children:e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[b(s.content_type),e.jsx("span",{className:"text-sm hover:text-primary transition-colors",children:s.title})]})},s.id))})]})})]})]})]})}export{Q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.