PageSourceSearch

https://ecomlaunch.lovable.app/assets/app.customers.ai-knowledge-Fl5k3lc7.js

js ecomlaunch.lovable.app collected 2026-10-03 03:31:06 UTC 7,654 bytes, 1 lines download raw bytes

1import{h as r,i,k as d,l as n,r as t,j as e,t as o}from"./index-Bc8uQra3.js";import{B as l}from"./button-DVvJL4bF.js";import{C as h}from"./card-CdTl6fXz.js";import{I as Z}from"./input-3BpfHHt1.js";import{T}from"./textarea-CmfAB-fi.js";import{L as u}from"./loader-circle-M3cuBuXS.js";import{R as z}from"./refresh-cw-C7735rkP.js";import{B as L}from"./building-2-D8WsxMxh.js";import{T as P}from"./trash-2-BaAzWgEz.js";import{F as ee}from"./file-text-k7YgIWWp.js";import{B as se}from"./book-open-3TkKEvUW.js";import"./index-B3u76lnK.js";import"./index-DZfpZ2bg.js";import"./index-LHNt3CwB.js";import"./utils-BQHNewu7.js";import"./createLucideIcon-0l2H4Kpo.js";const ae=r({method:"GET"}).middleware([i]).handler(d("85d1ec00f7edeacc6a2ef7721b4e780b4852fb2b7116a3d3098497d2a5d72a44")),te=r({method:"POST"}).middleware([i]).handler(d("3ee1cb00c290cda083e42e98c4124dbe871e34b5364d528b8f90068d4c9062bb")),ne=r({method:"POST"}).middleware([i]).handler(d("641d41e8934e6b4aaf0a61a0161e219c7cf46888670141e8a739596b03be8aa8")),re=r({method:"POST"}).middleware([i]).handler(d("1561bfd8058060ac200aafba561681729b4b67949980669b7558d1e0e9ecac62")),ie=r({method:"GET"}).middleware([i]).handler(d("979ae5493516fce96b777e11290890bac9feb0d0687075b4e656c79b9225b06d")),de=r({method:"POST"}).middleware([i]).handler(d("01c37fef662bd723f92c93284b2cb8ceda66b06f0274f3bf94a9ef60ff2bcd8f")),ce=r({method:"POST"}).middleware([i]).handler(d("fbbdfd27d32ff40132251ec83c9644b96d1c042436a52bdfed9fd5598c9c2a80")),oe=r({method:"GET"}).middleware([i]).handler(d("3aafcfa627cf9f34739ea463631340fb70c4e81605bad035df84122ec64aedd5")),le=r({method:"POST"}).middleware([i]).handler(d("8cbad7d1a08e28e64ad4d083bc7bb0bddc992db7181301c752aecdd0255a8293"));function Ce(){const A=n(ae),_=n(te),K=n(ne),E=n(re),F=n(ie),$=n(de),O=n(ce),R=n(oe),B=n(le),[b,D]=t.useState([]),[w,G]=t.useState([]),[V,I]=t.useState(!0),[c,m]=t.useState(null),[g,v]=t.useState(),[j,f]=t.useState(""),[k,p]=t.useState(""),[q,U]=t.useState([]),[N,H]=t.useState(""),[y,S]=t.useState(""),x=async()=>{I(!0);try{const[s,a,Y]=await Promise.all([A({}),F({}),R({})]);D(s),G(a),U(Y)}finally{I(!1)}};t.useEffect(()=>{x()},[]);const C=async s=>{m(s);try{const a=s==="pdf"?await K({}):await E({});o.success(s==="pdf"?`Indexerat ${a.indexed} PDF:er (hoppade över ${a.skipped??0}).`:`Indexerat ${a.indexed} lektioner.`),a.errors?.length&&(o.warning(`${a.errors.length} fel — se konsolen.`),console.warn(a.errors)),await x()}catch(a){o.error(a?.message??"Indexering misslyckades")}finally{m(null)}},J=async()=>{if(!N||y.trim().length<30){o.error("Välj avsnitt och klistra in transkriberingen.");return}m("transcript");try{const s=await B({data:{lesson_id:N,transcript:y}});o.success(`Indexerade ${s.chunks} textbitar från "${s.title}".`),S(""),await x()}catch(s){o.error(s?.message??"Kunde inte indexera transkriberingen")}finally{m(null)}},M=async()=>{if(!(!j.trim()||!k.trim())){m("save");try{await $({data:{id:g,title:j,content:k}}),o.success("Sparat och indexerat."),f(""),p(""),v(void 0),await x()}catch(s){o.error(s?.message??"Kunde inte spara")}finally{m(null)}}},Q=async s=>{confirm(`Radera "${s.source_title}" från kunskapsbasen?`)&&(await _({data:{source_type:s.source_type,source_id:s.source_id}}),await x())},W=async s=>{confirm("Radera detta företagsinfo-stycke?")&&(await O({data:{id:s}}),await x())},X=s=>s==="pdf"?ee:s==="lesson"||s==="transcript"?se:L;return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"AI Kunskapsbas"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Det här är vad EcomLaunch AI vet om er. Indexera PDF:er och lektioner, eller skriv in företagsinfo som boten ska kunna citera."})]}),e.jsxs(h,{className:"p-5 space-y-4",children:[e.jsx("h2",{className:"font-semibold",children:"Indexera utbildningsmaterial"}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs(l,{onClick:()=>C("pdf"),disabled:!!c,children:[c==="pdf"?e.jsx(u,{className:"size-4 mr-2 animate-spin"}):e.jsx(z,{className:"size-4 mr-2"}),"Indexera alla PDF:er"]}
1),e.jsxs(l,{variant:"secondary",onClick:()=>C("lesson"),disabled:!!c,children:[c==="lesson"?e.jsx(u,{className:"size-4 mr-2 animate-spin"}):e.jsx(z,{className:"size-4 mr-2"}),"Indexera lektionsbeskrivningar"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Kör efter att du laddat upp nya PDF:er eller ändrat lektioner. Tar några sekunder per fil."})]}),e.jsxs(h,{className:"p-5 space-y-4",children:[e.jsx("h2",{className:"font-semibold",children:"Videotranskribering"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Klistra in texten från en video (undertextfil med tidsstämplar går bra) så kan AI:n svara på exakt vad mentorn säger i avsnittet."}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("select",{className:"h-10 rounded-md border bg-background px-3 text-sm",value:N,onChange:s=>H(s.target.value),children:[e.jsx("option",{value:"",children:"Välj avsnitt…"}),q.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]}),e.jsx(T,{placeholder:"Klistra in transkriberingen här…",rows:8,value:y,onChange:s=>S(s.target.value)}),e.jsx("div",{children:e.jsxs(l,{onClick:J,disabled:!!c,children:[c==="transcript"&&e.jsx(u,{className:"size-4 mr-2 animate-spin"}),"Indexera transkribering"]})})]})]}),e.jsxs(h,{className:"p-5 space-y-4",children:[e.jsx("h2",{className:"font-semibold",children:"Företagsinfo"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Z,{placeholder:"Rubrik (t.ex. 'Om EcomLaunch', 'Kontaktuppgifter', 'Återbetalningspolicy')",value:j,onChange:s=>f(s.target.value)}),e.jsx(T,{placeholder:"Skriv informationen som AI:n ska kunna svara utifrån...",rows:8,value:k,onChange:s=>p(s.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{onClick:M,disabled:c==="save",children:[c==="save"&&e.jsx(u,{className:"size-4 mr-2 animate-spin"}),g?"Uppdatera":"Lägg till"]}),g&&e.jsx(l,{variant:"ghost",onClick:()=>{v(void 0),f(""),p("")},children:"Avbryt"})]})]}),w.length>0&&e.jsx("div",{className:"divide-y border rounded-lg",children:w.map(s=>e.jsxs("div",{className:"p-3 flex items-start gap-3",children:[e.jsx(L,{className:"size-4 mt-1 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:s.title}),e.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:s.content})]}),e.jsx(l,{size:"sm",variant:"ghost",onClick:()=>{v(s.id),f(s.title),p(s.content)},children:"Redigera"}),e.jsx(l,{size:"sm",variant:"ghost",onClick:()=>W(s.id),children:e.jsx(P,{className:"size-4"})})]},s.id))})]}),e.jsxs(h,{className:"p-5 space-y-3",children:[e.jsxs("h2",{className:"font-semibold",children:["Indexerade källor (",b.length,")"]}),V?e.jsx(u,{className:"size-5 animate-spin text-muted-foreground"}):b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Inget indexerat än. Använd knapparna ovan."}):e.jsx("div",{className:"divide-y border rounded-lg",children:b.map(s=>{const a=X(s.source_type);return e.jsxs("div",{className:"p-3 flex items-center gap-3",children:[e.jsx(a,{className:"size-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:s.source_title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.source_type," · ",s.chunks," bitar"]})]}),e.jsx(l,{size:"sm",variant:"ghost",onClick:()=>Q(s),children:e.jsx(P,{className:"size-4"})})]},`${s.source_type}-${s.source_id}`)})})]})]})}export{Ce 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.