1import{c as w,r,s as i,g as o,j as e,L as l,B as d,i as b}from"./index-C9cYLvaG.js";import{P as v}from"./plus-Dy4Te-us.js";import{E as k}from"./external-link-Cg02cm9_.js";import{f as C}from"./format-BEMO4FpZ.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const u=w("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);function S(){const[n,h]=r.useState([]),[f,g]=r.useState([]),[j,c]=r.useState(!0),[a,m]=r.useState(!1);r.useEffect(()=>{document.title="Help articles - Pulse CMS",x()},[]);const x=async()=>{c(!0);const[s,t]=await Promise.all([i.from("help_articles").select("id, slug, title, category_id, published, updated_at").order("updated_at",{ascending:!1}),i.from("help_categories").select("id, slug, name").order("sort_order")]);s.error&&o.error("Failed to load articles",{description:s.error.message}),h(s.data??[]),g(t.data??[]),c(!1)},p=async()=>{if(confirm("Import all articles from help.vwd.ai? This may take a minute.")){m(!0);try{const{data:s,error:t}=await i.functions.invoke("import-help-articles");if(t)throw t;o.success("Import complete",{description:`Imported ${(s==null?void 0:s.imported)??0} of ${(s==null?void 0:s.articles_found)??0} articles (${(s==null?void 0:s.failed)??0} failed).`}),await x()}catch(s){o.error("Import failed",{description:s.message})}finally{m(!1)}}},N=s=>{var t;return s?((t=f.find(y=>y.id===s))==null?void 0:t.name)??"â":"â"};return e.jsxs("div",{className:"p-10 max-w-6xl",children:[e.jsxs("div",{className:"flex items-start justify-between mb-10 gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"display-h3 mb-2",children:"Help articles"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Articles published at ",e.jsx(l,{to:"/help",className:"underline hover:text-foreground",children:"vwd.ai/help"}),"."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(d,{variant:"outline",className:"rounded-full",onClick:p,disabled:a,children:[a?e.jsx(b,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(u,{className:"w-4 h-4 mr-2"}),a?"Importingâ¦":"Import from help.vwd.ai"]}),e.jsx(d,{asChild:!0,className:"rounded-full",children:e.jsxs(l,{to:"/admin/help/new",children:[e.jsx(v,{className:"w-4 h-4 mr-2"})," New article"]})})]})]}),j?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loadingâ¦"}):n.length===0?e.jsxs("div",{className:"glass-card rounded-xl p-16 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-6",children:"No articles yet. Import from help.vwd.ai or create one."}),e.jsxs("div",{className:"flex justify-center gap-2",children:[e.jsxs(d,{variant:"outline",className:"rounded-full",onClick:p,disabled:a,children:[e.jsx(u,{className:"w-4 h-4 mr-2"})," Import"]}),e.jsx(d,{asChild:!0,className:"rounded-full",children:e.jsx(l,{to:"/admin/help/new",children:"Create article"})})]})]}):e.jsx("div",{className:"glass-card rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"py-3 px-5 text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Title"}),e.jsx("th",{className:"py-3 px-5 text-xs uppercase tracking-wider text-muted-foreground font-medium w-44",children:"Category"}),e.jsx("th",{className:"py-3 px-5 text-xs uppercase tracking-wider text-muted-foreground font-medium w-28",children:"Status"}),e.jsx("th",{className:"py-3 px-5 text-xs uppercase tracking-wider text-muted-foreground font-medium w-32",children:"Updated"}),e.jsx("th",{className:"py-3 px-5 w-10"})]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-secondary/30 transition-colors",children:[e.jsxs("td",{className:"py-4 px-5",children:[e.jsx(l,{to:`/admin/help/${s.id}`,className:"text-foreground hover:text-primary transition-colors",children:s.title||"(Untitled)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["/",s.slug]})]}),e.jsx("td",{className:"py-4 px-5 text-sm text-muted-foreground",children:N(s.category_id)}),e.jsx("td",{className:"py-4 px-5",children:e.jsx("span",{className:`inline-block px-2.5 py-1 rounded-full text-xs ${s.published?"bg-green-500/20 text-green-400":"bg-muted text-muted-foreground"}`,children:s.published?"published":"draft"})}),e.jsx("td",{className:"py-4 px-5 text-sm text-muted-foreground",children:C(new Date(s.updated_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-4 px-5 text-right",children:e.jsx("a",{href:`/help/${s.slug}`,target:"_blank",rel:"noreferrer",className:"text-muted-foreground hover:text-foreground",children:e.jsx(k,{className:"w-4 h-4 inline"})})})]},s.id))})]})})]})}export{S 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.